Commit f040396500c8fce0e6a788f82a9c669cafc90fbc

Authored by 房远帅
1 parent 5f99ceac

楚江ERP:延期发货相关修改

@@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.handlers; @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.handlers;
3 import com.lframework.starter.bpm.dto.FlowInstanceExtDto; 3 import com.lframework.starter.bpm.dto.FlowInstanceExtDto;
4 import com.lframework.starter.bpm.enums.FlowInstanceStatus; 4 import com.lframework.starter.bpm.enums.FlowInstanceStatus;
5 import com.lframework.starter.bpm.service.BusinessDataHandlerService; 5 import com.lframework.starter.bpm.service.BusinessDataHandlerService;
  6 +import com.lframework.starter.common.utils.CollectionUtil;
6 import com.lframework.starter.mq.core.service.MqProducerService; 7 import com.lframework.starter.mq.core.service.MqProducerService;
7 import com.lframework.starter.web.core.components.redis.RedisHandler; 8 import com.lframework.starter.web.core.components.redis.RedisHandler;
8 import com.lframework.starter.web.core.components.security.SecurityUtil; 9 import com.lframework.starter.web.core.components.security.SecurityUtil;
@@ -30,6 +31,7 @@ import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo; @@ -30,6 +31,7 @@ import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo;
30 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderRevokeLineVo; 31 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderRevokeLineVo;
31 import com.lframework.xingyun.sc.vo.shipments.car.CreateCarRequestPlanVo; 32 import com.lframework.xingyun.sc.vo.shipments.car.CreateCarRequestPlanVo;
32 import com.lframework.xingyun.sc.vo.shipments.car.CreateRequestCarTicketVo; 33 import com.lframework.xingyun.sc.vo.shipments.car.CreateRequestCarTicketVo;
  34 +import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
33 import com.lframework.xingyun.sc.vo.shipments.delay.QueryDelayedShipmentDetailVo; 35 import com.lframework.xingyun.sc.vo.shipments.delay.QueryDelayedShipmentDetailVo;
34 import lombok.extern.slf4j.Slf4j; 36 import lombok.extern.slf4j.Slf4j;
35 import org.apache.commons.collections.CollectionUtils; 37 import org.apache.commons.collections.CollectionUtils;
@@ -155,7 +157,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -155,7 +157,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
155 handleReplenishmentOrderStatus(flowStatus, businessId); 157 handleReplenishmentOrderStatus(flowStatus, businessId);
156 break; 158 break;
157 case "DELAYED_SHIPMENT": 159 case "DELAYED_SHIPMENT":
158 - handleDelayedShipmentData(flowStatus, businessId); 160 + handleDelayedShipmentData(flowStatus, businessId, variable.get("shipmentsOrderId"));
159 break; 161 break;
160 default: 162 default:
161 break; 163 break;
@@ -484,24 +486,55 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -484,24 +486,55 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
484 ticketVo.setWorkshopId(draftRequestCarTicket.getWorkshopId()); 486 ticketVo.setWorkshopId(draftRequestCarTicket.getWorkshopId());
485 ticketVo.setOrderNo(draftRequestCarTicket.getOrderNo()); 487 ticketVo.setOrderNo(draftRequestCarTicket.getOrderNo());
486 ticketVo.setOrderingUnit(draftRequestCarTicket.getOrderingUnit()); 488 ticketVo.setOrderingUnit(draftRequestCarTicket.getOrderingUnit());
487 - if (orderInfo.getTotalQuantity() != null) {  
488 - BigDecimal result = orderInfo.getTotalQuantity().divide(new BigDecimal(1000), 4, BigDecimal.ROUND_HALF_UP);  
489 - ticketVo.setQuantity(result);  
490 - } 489 + ticketVo.setQuantity(draftRequestCarTicket.getQuantity());
491 //外办审核人(草稿要车单审核人) 490 //外办审核人(草稿要车单审核人)
492 ticketVo.setExternalAuditor(SecurityUtil.getCurrentUser().getId()); 491 ticketVo.setExternalAuditor(SecurityUtil.getCurrentUser().getId());
493 //经营办审核人(发货计划提交人) 492 //经营办审核人(发货计划提交人)
494 ticketVo.setBusinessOfficeAuditor(draftRequestCarTicket.getBusinessOfficeAuditor()); 493 ticketVo.setBusinessOfficeAuditor(draftRequestCarTicket.getBusinessOfficeAuditor());
  494 + Object o = redisHandler.get("GET_SHIPMENTS_ORDER_ID_" + draftRequestCarTicket.getId());
  495 + if (o != null) {
  496 + ticketVo.setPurchaseOrderId(String.valueOf(o));
  497 + }
495 return ticketVo; 498 return ticketVo;
496 } 499 }
497 500
498 - private void handleDelayedShipmentData(String flowStatus, String businessId) { 501 + /**
  502 + * 延期发货
  503 + *
  504 + * @param flowStatus
  505 + * @param businessId
  506 + */
  507 + private void handleDelayedShipmentData(String flowStatus, String businessId, Object shipmentsOrderId) {
499 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus) 508 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
500 || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) { 509 || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
501 delayedShipmentService.updateStatus(businessId, "PASS"); 510 delayedShipmentService.updateStatus(businessId, "PASS");
502 QueryDelayedShipmentDetailVo vo = new QueryDelayedShipmentDetailVo(); 511 QueryDelayedShipmentDetailVo vo = new QueryDelayedShipmentDetailVo();
503 vo.setDelayedShipmentId(businessId); 512 vo.setDelayedShipmentId(businessId);
504 List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo); 513 List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo);
  514 + if (shipmentsOrderId != null) {
  515 + QueryRequestCarTicketVo vo2 = new QueryRequestCarTicketVo();
  516 + vo2.setShipmentsOrderId(String.valueOf(shipmentsOrderId));
  517 + List<RequestCarTicket> query1 = requestCarTicketService.query(vo2);
  518 + if (CollectionUtil.isEmpty(query1)) {
  519 + String requestCarTicketId = query1.get(0).getId();
  520 + //计划吨位
  521 + BigDecimal quantity = query1.get(0).getQuantity();
  522 + if (CollectionUtil.isNotEmpty(query)) {
  523 + //扣减要车单计划吨位(目前只有单条)
  524 + DelayedShipmentDetail delayedShipmentDetail1 = query.get(0);
  525 + //发货数量
  526 + BigDecimal quantity1 = delayedShipmentDetail1.getQuantity();
  527 + BigDecimal difference = quantity.subtract(quantity1);
  528 + if (difference.compareTo(BigDecimal.ZERO) == 0) {
  529 + //删除要车单
  530 + requestCarTicketService.deleteById(requestCarTicketId);
  531 + } else {
  532 + //更新计划吨位
  533 + requestCarTicketService.updateQuantity(requestCarTicketId, difference);
  534 + }
  535 + }
  536 + }
  537 + }
505 if (CollectionUtils.isNotEmpty(query)) { 538 if (CollectionUtils.isNotEmpty(query)) {
506 for (DelayedShipmentDetail delayedShipmentDetail : query) { 539 for (DelayedShipmentDetail delayedShipmentDetail : query) {
507 //更新订货单物料行发货时间 540 //更新订货单物料行发货时间
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; @@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
29 import org.springframework.stereotype.Service; 29 import org.springframework.stereotype.Service;
30 30
31 import javax.annotation.Resource; 31 import javax.annotation.Resource;
  32 +import java.math.BigDecimal;
32 import java.util.List; 33 import java.util.List;
33 34
34 @Service 35 @Service
@@ -226,6 +227,27 @@ public class RequestCarTicketServiceImpl extends BaseMpServiceImpl<RequestCarTic @@ -226,6 +227,27 @@ public class RequestCarTicketServiceImpl extends BaseMpServiceImpl<RequestCarTic
226 OpLogUtil.setExtra(ids); 227 OpLogUtil.setExtra(ids);
227 } 228 }
228 229
  230 + @OpLog(type = OtherOpLogType.class, name = "修改要车单计划吨位,ID:{}", params = {"#id"})
  231 + @Transactional(rollbackFor = Exception.class)
  232 + @Override
  233 + public void updateQuantity(String id, BigDecimal quantity) {
  234 + if (StringUtils.isBlank(id)) {
  235 + return;
  236 + }
  237 + RequestCarTicket data = getBaseMapper().findById(id);
  238 + if (ObjectUtil.isNull(data)) {
  239 + throw new DefaultClientException("要车单不存在!");
  240 + }
  241 + LambdaUpdateWrapper<RequestCarTicket> updateWrapper = Wrappers.lambdaUpdate(RequestCarTicket.class)
  242 + .set(RequestCarTicket::getQuantity, quantity)
  243 + .eq(RequestCarTicket::getId, id);
  244 +
  245 + getBaseMapper().update(updateWrapper);
  246 +
  247 + OpLogUtil.setVariable("id", data.getId());
  248 + OpLogUtil.setExtra(id);
  249 + }
  250 +
229 @OpLog(type = OtherOpLogType.class, name = "删除要车单表,ID:{}", params = {"#id"}) 251 @OpLog(type = OtherOpLogType.class, name = "删除要车单表,ID:{}", params = {"#id"})
230 @Transactional(rollbackFor = Exception.class) 252 @Transactional(rollbackFor = Exception.class)
231 @Override 253 @Override
@@ -31,18 +31,22 @@ import com.lframework.starter.web.inner.service.system.SysUserService; @@ -31,18 +31,22 @@ import com.lframework.starter.web.inner.service.system.SysUserService;
31 import com.lframework.xingyun.sc.entity.DelayedShipment; 31 import com.lframework.xingyun.sc.entity.DelayedShipment;
32 import com.lframework.xingyun.sc.entity.DelayedShipmentDetail; 32 import com.lframework.xingyun.sc.entity.DelayedShipmentDetail;
33 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo; 33 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  34 +import com.lframework.xingyun.sc.entity.RequestCarTicket;
34 import com.lframework.xingyun.sc.handlers.TransactorHandler; 35 import com.lframework.xingyun.sc.handlers.TransactorHandler;
35 import com.lframework.xingyun.sc.mappers.DelayedShipmentMapper; 36 import com.lframework.xingyun.sc.mappers.DelayedShipmentMapper;
36 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; 37 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
37 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; 38 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
38 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService; 39 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService;
  40 +import com.lframework.xingyun.sc.service.shipments.car.RequestCarTicketService;
39 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentDetailService; 41 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentDetailService;
40 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentService; 42 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentService;
  43 +import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
41 import com.lframework.xingyun.sc.vo.shipments.delay.*; 44 import com.lframework.xingyun.sc.vo.shipments.delay.*;
42 import org.apache.commons.collections.CollectionUtils; 45 import org.apache.commons.collections.CollectionUtils;
43 import org.springframework.transaction.annotation.Transactional; 46 import org.springframework.transaction.annotation.Transactional;
44 import org.springframework.stereotype.Service; 47 import org.springframework.stereotype.Service;
45 import javax.annotation.Resource; 48 import javax.annotation.Resource;
  49 +import java.math.BigDecimal;
46 import java.time.LocalDate; 50 import java.time.LocalDate;
47 import java.time.temporal.ChronoUnit; 51 import java.time.temporal.ChronoUnit;
48 import java.util.ArrayList; 52 import java.util.ArrayList;
@@ -72,6 +76,9 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen @@ -72,6 +76,9 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
72 private FlowTaskWrapperMapper flowTaskWrapperMapper; 76 private FlowTaskWrapperMapper flowTaskWrapperMapper;
73 @Resource 77 @Resource
74 private PurchaseOrderInfoService purchaseOrderInfoService; 78 private PurchaseOrderInfoService purchaseOrderInfoService;
  79 + @Resource
  80 + private RequestCarTicketService requestCarTicketService;
  81 +
75 82
76 @Override 83 @Override
77 public PageResult<DelayedShipment> query(Integer pageIndex, Integer pageSize, QueryDelayedShipmentVo vo) { 84 public PageResult<DelayedShipment> query(Integer pageIndex, Integer pageSize, QueryDelayedShipmentVo vo) {
@@ -212,6 +219,30 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen @@ -212,6 +219,30 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
212 QueryDelayedShipmentDetailVo vo1 = new QueryDelayedShipmentDetailVo(); 219 QueryDelayedShipmentDetailVo vo1 = new QueryDelayedShipmentDetailVo();
213 vo1.setDelayedShipmentId(data.getId()); 220 vo1.setDelayedShipmentId(data.getId());
214 List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo1); 221 List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo1);
  222 + if (StringUtil.isNotEmpty(vo.getShipmentsOrderId())) {
  223 + QueryRequestCarTicketVo vo2 = new QueryRequestCarTicketVo();
  224 + vo2.setShipmentsOrderId(vo.getShipmentsOrderId());
  225 + List<RequestCarTicket> query1 = requestCarTicketService.query(vo2);
  226 + if (CollectionUtil.isEmpty(query1)) {
  227 + String requestCarTicketId = query1.get(0).getId();
  228 + //计划吨位
  229 + BigDecimal quantity = query1.get(0).getQuantity();
  230 + if (CollectionUtil.isNotEmpty(query)) {
  231 + //扣减要车单计划吨位(目前只有单条)
  232 + DelayedShipmentDetail delayedShipmentDetail1 = query.get(0);
  233 + //发货数量
  234 + BigDecimal quantity1 = delayedShipmentDetail1.getQuantity();
  235 + BigDecimal difference = quantity.subtract(quantity1);
  236 + if (difference.compareTo(BigDecimal.ZERO) == 0) {
  237 + //删除要车单
  238 + requestCarTicketService.deleteById(requestCarTicketId);
  239 + } else {
  240 + //更新计划吨位
  241 + requestCarTicketService.updateQuantity(requestCarTicketId, difference);
  242 + }
  243 + }
  244 + }
  245 + }
215 if (CollectionUtil.isNotEmpty(query)) { 246 if (CollectionUtil.isNotEmpty(query)) {
216 for (DelayedShipmentDetail detail : query) { 247 for (DelayedShipmentDetail detail : query) {
217 purchaseOrderLineService.updateDeliveryDate(detail.getOrderSpecId(), detail.getApplyShipmentDate()); 248 purchaseOrderLineService.updateDeliveryDate(detail.getOrderSpecId(), detail.getApplyShipmentDate());
@@ -6,6 +6,8 @@ import com.lframework.xingyun.sc.entity.RequestCarTicket; @@ -6,6 +6,8 @@ import com.lframework.xingyun.sc.entity.RequestCarTicket;
6 import com.lframework.xingyun.sc.vo.shipments.car.CreateRequestCarTicketVo; 6 import com.lframework.xingyun.sc.vo.shipments.car.CreateRequestCarTicketVo;
7 import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo; 7 import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
8 import com.lframework.xingyun.sc.vo.shipments.car.UpdateRequestCarTicketVo; 8 import com.lframework.xingyun.sc.vo.shipments.car.UpdateRequestCarTicketVo;
  9 +
  10 +import java.math.BigDecimal;
9 import java.util.List; 11 import java.util.List;
10 12
11 /** 13 /**
@@ -65,6 +67,14 @@ public interface RequestCarTicketService extends BaseMpService<RequestCarTicket> @@ -65,6 +67,14 @@ public interface RequestCarTicketService extends BaseMpService<RequestCarTicket>
65 void updateExamineUserBatch(List<String> ids, String externalAuditor, String businessOfficeAuditor, String operationsDepartmentAuditor); 67 void updateExamineUserBatch(List<String> ids, String externalAuditor, String businessOfficeAuditor, String operationsDepartmentAuditor);
66 68
67 /** 69 /**
  70 + * 修改计划吨位
  71 + *
  72 + * @param id 主键
  73 + * @param quantity 计划吨位
  74 + */
  75 + void updateQuantity(String id, BigDecimal quantity);
  76 +
  77 + /**
68 * 根据ID删除 78 * 根据ID删除
69 * @param id 79 * @param id
70 * @return 80 * @return
@@ -4,6 +4,8 @@ import lombok.Data; @@ -4,6 +4,8 @@ import lombok.Data;
4 import com.lframework.starter.web.core.vo.PageVo; 4 import com.lframework.starter.web.core.vo.PageVo;
5 import com.lframework.starter.web.core.vo.BaseVo; 5 import com.lframework.starter.web.core.vo.BaseVo;
6 import io.swagger.annotations.ApiModelProperty; 6 import io.swagger.annotations.ApiModelProperty;
  7 +import org.hibernate.validator.constraints.Length;
  8 +
7 import java.io.Serializable; 9 import java.io.Serializable;
8 10
9 @Data 11 @Data
@@ -60,4 +62,10 @@ public class QueryRequestCarTicketVo extends PageVo implements BaseVo, Serializa @@ -60,4 +62,10 @@ public class QueryRequestCarTicketVo extends PageVo implements BaseVo, Serializa
60 @ApiModelProperty("要车计划ID") 62 @ApiModelProperty("要车计划ID")
61 private String planId; 63 private String planId;
62 64
  65 + /**
  66 + * 发货单ID
  67 + */
  68 + @ApiModelProperty("发货单ID")
  69 + private String shipmentsOrderId;
  70 +
63 } 71 }
@@ -23,6 +23,12 @@ public class CreateDelayedShipmentVo implements BaseVo, Serializable { @@ -23,6 +23,12 @@ public class CreateDelayedShipmentVo implements BaseVo, Serializable {
23 private String deptId; 23 private String deptId;
24 24
25 /** 25 /**
  26 + * 发货单ID
  27 + */
  28 + @ApiModelProperty("发货单ID")
  29 + private String shipmentsOrderId;
  30 +
  31 + /**
26 * 申请日期 32 * 申请日期
27 */ 33 */
28 @ApiModelProperty("申请日期") 34 @ApiModelProperty("申请日期")
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
30 <result column="operations_department_auditor" property="operationsDepartmentAuditor"/> 30 <result column="operations_department_auditor" property="operationsDepartmentAuditor"/>
31 <result column="operations_department_auditor_name" property="operationsDepartmentAuditorName"/> 31 <result column="operations_department_auditor_name" property="operationsDepartmentAuditorName"/>
32 <result column="status" property="status"/> 32 <result column="status" property="status"/>
  33 + <result column="shipments_order_id" property="shipmentsOrderId"/>
33 <result column="create_by_id" property="createById"/> 34 <result column="create_by_id" property="createById"/>
34 <result column="create_by" property="createBy"/> 35 <result column="create_by" property="createBy"/>
35 <result column="update_by_id" property="updateById"/> 36 <result column="update_by_id" property="updateById"/>
@@ -112,6 +113,9 @@ @@ -112,6 +113,9 @@
112 <if test="vo.planId != null and vo.planId != ''"> 113 <if test="vo.planId != null and vo.planId != ''">
113 AND tb.plan_id = #{vo.planId} 114 AND tb.plan_id = #{vo.planId}
114 </if> 115 </if>
  116 + <if test="vo.shipmentsOrderId != null and vo.shipmentsOrderId != ''">
  117 + AND tb.shipments_order_id = #{vo.shipmentsOrderId}
  118 + </if>
115 </where> 119 </where>
116 ORDER BY tb.create_time DESC 120 ORDER BY tb.create_time DESC
117 </select> 121 </select>