Commit 49adb43258faf452d09bc1a5325ff6e4e313cb97

Authored by yeqianyong
1 parent fd7fe8a8

楚江erp: 填写实发数逻辑调整

@@ -9,7 +9,9 @@ import com.lframework.starter.web.inner.service.system.SysUserService; @@ -9,7 +9,9 @@ import com.lframework.starter.web.inner.service.system.SysUserService;
9 import com.lframework.xingyun.sc.bo.shipments.order.GetShipmentsOrderInfoBo; 9 import com.lframework.xingyun.sc.bo.shipments.order.GetShipmentsOrderInfoBo;
10 import com.lframework.xingyun.sc.bo.shipments.order.QueryShipmentsOrderInfoBo; 10 import com.lframework.xingyun.sc.bo.shipments.order.QueryShipmentsOrderInfoBo;
11 import com.lframework.xingyun.sc.bo.shipments.plan.ShipmentsPlanDetailBo; 11 import com.lframework.xingyun.sc.bo.shipments.plan.ShipmentsPlanDetailBo;
  12 +import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
12 import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail; 13 import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail;
  14 +import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
13 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; 15 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService;
14 import com.lframework.xingyun.sc.utils.ExcelUtil; 16 import com.lframework.xingyun.sc.utils.ExcelUtil;
15 import com.lframework.xingyun.sc.utils.LatexFormulaExcelExporterUtil; 17 import com.lframework.xingyun.sc.utils.LatexFormulaExcelExporterUtil;
@@ -27,6 +29,7 @@ import javax.validation.constraints.NotBlank; @@ -27,6 +29,7 @@ import javax.validation.constraints.NotBlank;
27 import io.swagger.annotations.ApiImplicitParam; 29 import io.swagger.annotations.ApiImplicitParam;
28 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; 30 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
29 import com.lframework.starter.common.exceptions.impl.DefaultClientException; 31 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  32 +import io.swagger.annotations.ApiModelProperty;
30 import io.swagger.annotations.ApiOperation; 33 import io.swagger.annotations.ApiOperation;
31 import com.lframework.starter.common.utils.CollectionUtil; 34 import com.lframework.starter.common.utils.CollectionUtil;
32 import io.swagger.annotations.Api; 35 import io.swagger.annotations.Api;
@@ -37,6 +40,7 @@ import org.apache.poi.ss.usermodel.Sheet; @@ -37,6 +40,7 @@ import org.apache.poi.ss.usermodel.Sheet;
37 import org.apache.poi.ss.usermodel.Workbook; 40 import org.apache.poi.ss.usermodel.Workbook;
38 import org.apache.poi.xssf.usermodel.XSSFWorkbook; 41 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
39 import org.springframework.data.redis.core.RedisTemplate; 42 import org.springframework.data.redis.core.RedisTemplate;
  43 +import org.springframework.scheduling.annotation.Scheduled;
40 import org.springframework.web.bind.annotation.DeleteMapping; 44 import org.springframework.web.bind.annotation.DeleteMapping;
41 import com.lframework.starter.web.core.controller.DefaultBaseController; 45 import com.lframework.starter.web.core.controller.DefaultBaseController;
42 import com.lframework.starter.web.core.annotations.security.HasPermission; 46 import com.lframework.starter.web.core.annotations.security.HasPermission;
@@ -50,6 +54,7 @@ import java.math.RoundingMode; @@ -50,6 +54,7 @@ import java.math.RoundingMode;
50 import java.nio.file.Files; 54 import java.nio.file.Files;
51 import java.nio.file.Path; 55 import java.nio.file.Path;
52 import java.nio.file.Paths; 56 import java.nio.file.Paths;
  57 +import java.time.LocalDate;
53 import java.time.format.DateTimeFormatter; 58 import java.time.format.DateTimeFormatter;
54 import java.util.*; 59 import java.util.*;
55 import java.util.stream.Collectors; 60 import java.util.stream.Collectors;
@@ -78,6 +83,8 @@ public class ShipmentsOrderInfoController extends DefaultBaseController { @@ -78,6 +83,8 @@ public class ShipmentsOrderInfoController extends DefaultBaseController {
78 private RedisTemplate redisTemplate; 83 private RedisTemplate redisTemplate;
79 @Resource 84 @Resource
80 private SysDeptService sysDeptService; 85 private SysDeptService sysDeptService;
  86 + @Resource
  87 + private PurchaseOrderInfoService purchaseOrderInfoService;
81 88
82 89
83 /** 90 /**
@@ -228,6 +235,39 @@ public class ShipmentsOrderInfoController extends DefaultBaseController { @@ -228,6 +235,39 @@ public class ShipmentsOrderInfoController extends DefaultBaseController {
228 return InvokeResultBuilder.success(); 235 return InvokeResultBuilder.success();
229 } 236 }
230 237
  238 + @ApiModelProperty("数据处理")
  239 + @GetMapping("/dataHandler")
  240 + @Scheduled(cron = "0 8 0 * * ?")
  241 + public InvokeResult<Void> dataHandler() {
  242 + List<ShipmentsOrderInfo> shipmentsOrderInfoList = shipmentsOrderInfoService.queryByShipmentDate(LocalDate.now());
  243 + if (CollectionUtils.isNotEmpty(shipmentsOrderInfoList)) {
  244 + for (ShipmentsOrderInfo orderInfo : shipmentsOrderInfoList) {
  245 + ShipmentsOrderInfo shipmentsOrderInfo = shipmentsOrderInfoService.findById(orderInfo.getId());
  246 + List<ShipmentsPlanDetail> detailList = shipmentsPlanDetailService.listByShipmentOrderId(shipmentsOrderInfo.getId());
  247 + if (CollectionUtils.isNotEmpty(detailList)) {
  248 + continue;
  249 + }
  250 + List<String> orderIds = new ArrayList<>();
  251 + List<String> orderSpecIds = new ArrayList<>();
  252 + List<String> detailIds = new ArrayList<>();
  253 + for (ShipmentsPlanDetail shipmentsPlanDetail : detailList) {
  254 + if (!orderIds.contains(shipmentsPlanDetail.getOrderId())) {
  255 + orderIds.add(shipmentsPlanDetail.getOrderId());
  256 + }
  257 + if (!orderSpecIds.contains(shipmentsPlanDetail.getOrderSpecId())) {
  258 + orderSpecIds.add(shipmentsPlanDetail.getOrderSpecId());
  259 + }
  260 + if (!detailIds.contains(shipmentsPlanDetail.getId())) {
  261 + detailIds.add(shipmentsPlanDetail.getId());
  262 + }
  263 + }
  264 + List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds);
  265 + shipmentsOrderInfoService.handleData(shipmentsOrderInfo, orderInfoList, orderSpecIds, detailIds);
  266 + }
  267 + }
  268 + return InvokeResultBuilder.success();
  269 + }
  270 +
231 271
232 /** 272 /**
233 * 发货单批量打印 273 * 发货单批量打印
@@ -136,6 +136,13 @@ public class ShipmentsOrderInfo extends BaseEntity implements BaseDto { @@ -136,6 +136,13 @@ public class ShipmentsOrderInfo extends BaseEntity implements BaseDto {
136 private LocalDate newShipmentDate; 136 private LocalDate newShipmentDate;
137 137
138 /** 138 /**
  139 + * 发货类型
  140 + * ALL:全部发货
  141 + * PART:部分发货
  142 + */
  143 + private String shipmentType;
  144 +
  145 + /**
139 * 发货明细数据 146 * 发货明细数据
140 */ 147 */
141 @TableField(exist = false) 148 @TableField(exist = false)
@@ -388,6 +388,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr @@ -388,6 +388,7 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
388 } 388 }
389 LambdaUpdateWrapper<ShipmentsOrderInfo> updateWrapper = Wrappers.lambdaUpdate(ShipmentsOrderInfo.class); 389 LambdaUpdateWrapper<ShipmentsOrderInfo> updateWrapper = Wrappers.lambdaUpdate(ShipmentsOrderInfo.class);
390 updateWrapper.set(ShipmentsOrderInfo::getOnTimeShipment, vo.getOnTimeShipment()) 390 updateWrapper.set(ShipmentsOrderInfo::getOnTimeShipment, vo.getOnTimeShipment())
  391 + .set(ShipmentsOrderInfo::getShipmentType, vo.getType())
391 .eq(ShipmentsOrderInfo::getId, shipmentsOrderId); 392 .eq(ShipmentsOrderInfo::getId, shipmentsOrderId);
392 getBaseMapper().update(updateWrapper); 393 getBaseMapper().update(updateWrapper);
393 394
@@ -433,48 +434,10 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr @@ -433,48 +434,10 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
433 orderInfo.setDetailList(shipmentsOrderDetailList); 434 orderInfo.setDetailList(shipmentsOrderDetailList);
434 // 更新发货明细 435 // 更新发货明细
435 shipmentsPlanDetailService.updateBatchById(dataList); 436 shipmentsPlanDetailService.updateBatchById(dataList);
436 - // 更新发货单状态  
437 - updateStatus(shipmentsOrderId, "SHIPMENTS");  
438 - // 更新订货单物料行发货状态  
439 - purchaseOrderLineService.dispatched(orderSpecIds);  
440 - // 更新订货单状态  
441 - purchaseOrderInfoService.updateStatus(orderIds);  
442 - // 消息通知  
443 - String type = vo.getType(); 437 + // 获取订货单数据
444 List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds); 438 List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds);
445 - if (CollectionUtils.isNotEmpty(orderInfoList)) {  
446 - // 试样订单生成反馈单数据  
447 - sampleResultFeedbackService.generateFeedbackData(orderInfoList, detailIds);  
448 -  
449 - List<String> userIds = new ArrayList<>();  
450 - StringBuilder orderNoBuilder = new StringBuilder();  
451 - for (PurchaseOrderInfo info : orderInfoList) {  
452 - userIds.add(info.getContractCreateById());  
453 - orderNoBuilder.append(info.getOrderNo()).append("、");  
454 - }  
455 - if (orderNoBuilder.length() > 0) {  
456 - orderNoBuilder.setLength(orderNoBuilder.length() - 1);  
457 - }  
458 - String title = "订货单:" + orderNoBuilder + ",";  
459 - if ("ALL".equals(type)) {  
460 - title += "已全部发货!";  
461 - } else if ("PART".equals(type)) {  
462 - title += "已部分发货!";  
463 - }  
464 - messageHandler.sendMsg(userIds, title, title, shipmentsOrderId, null);  
465 - }  
466 - // 判断当前日期是否大于等于发货日期  
467 - LocalDate now = LocalDate.now();  
468 - LocalDate shipmentsDate = orderInfo.getShipmentsDate();  
469 - if (BooleanUtils.isTrue(vo.getOnTimeShipment()) && !now.isBefore(shipmentsDate)) {  
470 - // 生成应收款台账明细数据  
471 - receiptLedgerInfoService.generateLedgerInfo(Collections.singletonList(orderInfo));  
472 - // 生成发货明细报表数据  
473 - shipmentDetailStatisticsService.generateStatisticsData(detailIds);  
474 - // 生成要车计划、要车单数据  
475 - ShipmentsOrderInfo shipmentsOrderInfo = findById(shipmentsOrderId);  
476 - carRequestPlanService.generate(orderInfoList, shipmentsOrderInfo);  
477 - } 439 + // 试样订单生成反馈单数据
  440 + sampleResultFeedbackService.generateFeedbackData(orderInfoList, detailIds);
478 //生成产品试样结果跟踪单 441 //生成产品试样结果跟踪单
479 if (CollectionUtils.isNotEmpty(orderIds)) { 442 if (CollectionUtils.isNotEmpty(orderIds)) {
480 Map<Object, List<ShipmentsPlanDetail>> map = shipmentsOrderDetailList.stream() 443 Map<Object, List<ShipmentsPlanDetail>> map = shipmentsOrderDetailList.stream()
@@ -533,6 +496,13 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr @@ -533,6 +496,13 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
533 sampleResultTrackingService.create(vo1); 496 sampleResultTrackingService.create(vo1);
534 } 497 }
535 } 498 }
  499 + // 判断当前日期是否大于等于发货日期
  500 + LocalDate now = LocalDate.now();
  501 + LocalDate shipmentsDate = orderInfo.getShipmentsDate();
  502 + if (BooleanUtils.isTrue(vo.getOnTimeShipment()) && !now.isBefore(shipmentsDate)) {
  503 + orderInfo = findById(shipmentsOrderId);
  504 + handleData(orderInfo, orderInfoList, orderSpecIds, detailIds);
  505 + }
536 } 506 }
537 507
538 @Override 508 @Override
@@ -660,9 +630,9 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr @@ -660,9 +630,9 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
660 // 今天或之前的数据 630 // 今天或之前的数据
661 shipmentDate = LocalDate.now(); 631 shipmentDate = LocalDate.now();
662 queryWrapper.and(wrapper -> wrapper 632 queryWrapper.and(wrapper -> wrapper
663 - .le(ShipmentsOrderInfo::getShipmentsDate, LocalDate.now()) 633 + .lt(ShipmentsOrderInfo::getShipmentsDate, LocalDate.now())
664 .or() 634 .or()
665 - .le(ShipmentsOrderInfo::getNewShipmentDate, LocalDate.now())); 635 + .lt(ShipmentsOrderInfo::getNewShipmentDate, LocalDate.now()));
666 } 636 }
667 List<ShipmentsOrderInfo> shipmentsOrderInfos = getBaseMapper().selectList(queryWrapper); 637 List<ShipmentsOrderInfo> shipmentsOrderInfos = getBaseMapper().selectList(queryWrapper);
668 if (CollectionUtils.isEmpty(shipmentsOrderInfos)) { 638 if (CollectionUtils.isEmpty(shipmentsOrderInfos)) {
@@ -710,6 +680,43 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr @@ -710,6 +680,43 @@ public class ShipmentsOrderInfoServiceImpl extends BaseMpServiceImpl<ShipmentsOr
710 return result; 680 return result;
711 } 681 }
712 682
  683 + @Override
  684 + @Transactional(rollbackFor = Exception.class)
  685 + public void handleData(ShipmentsOrderInfo shipmentsOrderInfo, List<PurchaseOrderInfo> orderInfoList
  686 + , List<String> orderSpecIds, List<String> detailIds) {
  687 + // 更新发货单状态
  688 + updateStatus(shipmentsOrderInfo.getId(), "SHIPMENTS");
  689 + // 更新订货单物料行发货状态
  690 + purchaseOrderLineService.dispatched(orderSpecIds);
  691 + // 更新订货单状态
  692 + List<String> orderIds = orderInfoList.stream().map(PurchaseOrderInfo::getId).collect(Collectors.toList());
  693 + purchaseOrderInfoService.updateStatus(orderIds);
  694 + // 生成应收款台账明细数据
  695 + receiptLedgerInfoService.generateLedgerInfo(Collections.singletonList(shipmentsOrderInfo));
  696 + // 生成发货明细报表数据
  697 + shipmentDetailStatisticsService.generateStatisticsData(detailIds);
  698 + // 生成要车计划、要车单数据
  699 + carRequestPlanService.generate(orderInfoList, shipmentsOrderInfo);
  700 + // 消息通知
  701 + String type = shipmentsOrderInfo.getShipmentType();
  702 + List<String> userIds = new ArrayList<>();
  703 + StringBuilder orderNoBuilder = new StringBuilder();
  704 + for (PurchaseOrderInfo info : orderInfoList) {
  705 + userIds.add(info.getContractCreateById());
  706 + orderNoBuilder.append(info.getOrderNo()).append("、");
  707 + }
  708 + if (orderNoBuilder.length() > 0) {
  709 + orderNoBuilder.setLength(orderNoBuilder.length() - 1);
  710 + }
  711 + String title = "订货单:" + orderNoBuilder + ",";
  712 + if ("ALL".equals(type)) {
  713 + title += "已全部发货!";
  714 + } else if ("PART".equals(type)) {
  715 + title += "已部分发货!";
  716 + }
  717 + messageHandler.sendMsg(userIds, title, title, shipmentsOrderInfo.getId(), null);
  718 + }
  719 +
713 720
714 /** 721 /**
715 * 处理批次数据 722 * 处理批次数据
1 package com.lframework.xingyun.sc.service.shipments; 1 package com.lframework.xingyun.sc.service.shipments;
2 2
  3 +import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
3 import com.lframework.xingyun.sc.vo.shipments.order.*; 4 import com.lframework.xingyun.sc.vo.shipments.order.*;
4 import com.lframework.xingyun.sc.entity.ShipmentsOrderInfo; 5 import com.lframework.xingyun.sc.entity.ShipmentsOrderInfo;
5 import com.lframework.starter.web.core.service.BaseMpService; 6 import com.lframework.starter.web.core.service.BaseMpService;
@@ -139,4 +140,18 @@ public interface ShipmentsOrderInfoService extends BaseMpService<ShipmentsOrderI @@ -139,4 +140,18 @@ public interface ShipmentsOrderInfoService extends BaseMpService<ShipmentsOrderI
139 * @return String 140 * @return String
140 */ 141 */
141 String generateSerialNumber(String pre, String key, String format, LocalDateTime startTime, LocalDateTime endTime); 142 String generateSerialNumber(String pre, String key, String format, LocalDateTime startTime, LocalDateTime endTime);
  143 +
  144 + /**
  145 + * 数据处理
  146 + * 状态流转
  147 + * 台账数据
  148 + * 报表数据
  149 + * 要车相关数据
  150 + *
  151 + * @param shipmentsOrderInfo 发货单信息
  152 + * @param orderInfoList 订货单数据集
  153 + * @param orderSpecIds 订货单规格ID集合
  154 + * @param detailIds 订货单明细
  155 + */
  156 + void handleData(ShipmentsOrderInfo shipmentsOrderInfo, List<PurchaseOrderInfo> orderInfoList, List<String> orderSpecIds, List<String> detailIds);
142 } 157 }
@@ -221,7 +221,11 @@ @@ -221,7 +221,11 @@
221 supplier, 221 supplier,
222 customer_short_name, 222 customer_short_name,
223 customer_type, 223 customer_type,
224 - delivery_method 224 + delivery_method,
  225 + create_by_id,
  226 + update_by_id,
  227 + create_time,
  228 + update_time
225 ) VALUES 229 ) VALUES
226 <foreach collection="list" item="item" separator=","> 230 <foreach collection="list" item="item" separator=",">
227 ( 231 (
@@ -264,7 +268,11 @@ @@ -264,7 +268,11 @@
264 #{item.supplier}, 268 #{item.supplier},
265 #{item.customerShortName}, 269 #{item.customerShortName},
266 #{item.customerType}, 270 #{item.customerType},
267 - #{item.deliveryMethod} 271 + #{item.deliveryMethod},
  272 + #{item.createById},
  273 + #{item.updateById},
  274 + #{item.createTime},
  275 + #{item.updateTime}
268 ) 276 )
269 </foreach> 277 </foreach>
270 </insert> 278 </insert>