Commit f040396500c8fce0e6a788f82a9c669cafc90fbc

Authored by 房远帅
1 parent 5f99ceac

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

... ... @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.handlers;
3 3 import com.lframework.starter.bpm.dto.FlowInstanceExtDto;
4 4 import com.lframework.starter.bpm.enums.FlowInstanceStatus;
5 5 import com.lframework.starter.bpm.service.BusinessDataHandlerService;
  6 +import com.lframework.starter.common.utils.CollectionUtil;
6 7 import com.lframework.starter.mq.core.service.MqProducerService;
7 8 import com.lframework.starter.web.core.components.redis.RedisHandler;
8 9 import com.lframework.starter.web.core.components.security.SecurityUtil;
... ... @@ -30,6 +31,7 @@ import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo;
30 31 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderRevokeLineVo;
31 32 import com.lframework.xingyun.sc.vo.shipments.car.CreateCarRequestPlanVo;
32 33 import com.lframework.xingyun.sc.vo.shipments.car.CreateRequestCarTicketVo;
  34 +import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
33 35 import com.lframework.xingyun.sc.vo.shipments.delay.QueryDelayedShipmentDetailVo;
34 36 import lombok.extern.slf4j.Slf4j;
35 37 import org.apache.commons.collections.CollectionUtils;
... ... @@ -155,7 +157,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
155 157 handleReplenishmentOrderStatus(flowStatus, businessId);
156 158 break;
157 159 case "DELAYED_SHIPMENT":
158   - handleDelayedShipmentData(flowStatus, businessId);
  160 + handleDelayedShipmentData(flowStatus, businessId, variable.get("shipmentsOrderId"));
159 161 break;
160 162 default:
161 163 break;
... ... @@ -484,24 +486,55 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
484 486 ticketVo.setWorkshopId(draftRequestCarTicket.getWorkshopId());
485 487 ticketVo.setOrderNo(draftRequestCarTicket.getOrderNo());
486 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 491 ticketVo.setExternalAuditor(SecurityUtil.getCurrentUser().getId());
493 492 //经营办审核人(发货计划提交人)
494 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 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 508 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
500 509 || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
501 510 delayedShipmentService.updateStatus(businessId, "PASS");
502 511 QueryDelayedShipmentDetailVo vo = new QueryDelayedShipmentDetailVo();
503 512 vo.setDelayedShipmentId(businessId);
504 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 538 if (CollectionUtils.isNotEmpty(query)) {
506 539 for (DelayedShipmentDetail delayedShipmentDetail : query) {
507 540 //更新订货单物料行发货时间
... ...
... ... @@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
29 29 import org.springframework.stereotype.Service;
30 30
31 31 import javax.annotation.Resource;
  32 +import java.math.BigDecimal;
32 33 import java.util.List;
33 34
34 35 @Service
... ... @@ -226,6 +227,27 @@ public class RequestCarTicketServiceImpl extends BaseMpServiceImpl<RequestCarTic
226 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 251 @OpLog(type = OtherOpLogType.class, name = "删除要车单表,ID:{}", params = {"#id"})
230 252 @Transactional(rollbackFor = Exception.class)
231 253 @Override
... ...
... ... @@ -31,18 +31,22 @@ import com.lframework.starter.web.inner.service.system.SysUserService;
31 31 import com.lframework.xingyun.sc.entity.DelayedShipment;
32 32 import com.lframework.xingyun.sc.entity.DelayedShipmentDetail;
33 33 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  34 +import com.lframework.xingyun.sc.entity.RequestCarTicket;
34 35 import com.lframework.xingyun.sc.handlers.TransactorHandler;
35 36 import com.lframework.xingyun.sc.mappers.DelayedShipmentMapper;
36 37 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
37 38 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
38 39 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService;
  40 +import com.lframework.xingyun.sc.service.shipments.car.RequestCarTicketService;
39 41 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentDetailService;
40 42 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentService;
  43 +import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
41 44 import com.lframework.xingyun.sc.vo.shipments.delay.*;
42 45 import org.apache.commons.collections.CollectionUtils;
43 46 import org.springframework.transaction.annotation.Transactional;
44 47 import org.springframework.stereotype.Service;
45 48 import javax.annotation.Resource;
  49 +import java.math.BigDecimal;
46 50 import java.time.LocalDate;
47 51 import java.time.temporal.ChronoUnit;
48 52 import java.util.ArrayList;
... ... @@ -72,6 +76,9 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
72 76 private FlowTaskWrapperMapper flowTaskWrapperMapper;
73 77 @Resource
74 78 private PurchaseOrderInfoService purchaseOrderInfoService;
  79 + @Resource
  80 + private RequestCarTicketService requestCarTicketService;
  81 +
75 82
76 83 @Override
77 84 public PageResult<DelayedShipment> query(Integer pageIndex, Integer pageSize, QueryDelayedShipmentVo vo) {
... ... @@ -212,6 +219,30 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
212 219 QueryDelayedShipmentDetailVo vo1 = new QueryDelayedShipmentDetailVo();
213 220 vo1.setDelayedShipmentId(data.getId());
214 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 246 if (CollectionUtil.isNotEmpty(query)) {
216 247 for (DelayedShipmentDetail detail : query) {
217 248 purchaseOrderLineService.updateDeliveryDate(detail.getOrderSpecId(), detail.getApplyShipmentDate());
... ...
... ... @@ -6,6 +6,8 @@ import com.lframework.xingyun.sc.entity.RequestCarTicket;
6 6 import com.lframework.xingyun.sc.vo.shipments.car.CreateRequestCarTicketVo;
7 7 import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
8 8 import com.lframework.xingyun.sc.vo.shipments.car.UpdateRequestCarTicketVo;
  9 +
  10 +import java.math.BigDecimal;
9 11 import java.util.List;
10 12
11 13 /**
... ... @@ -65,6 +67,14 @@ public interface RequestCarTicketService extends BaseMpService<RequestCarTicket>
65 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 78 * 根据ID删除
69 79 * @param id
70 80 * @return
... ...
... ... @@ -4,6 +4,8 @@ import lombok.Data;
4 4 import com.lframework.starter.web.core.vo.PageVo;
5 5 import com.lframework.starter.web.core.vo.BaseVo;
6 6 import io.swagger.annotations.ApiModelProperty;
  7 +import org.hibernate.validator.constraints.Length;
  8 +
7 9 import java.io.Serializable;
8 10
9 11 @Data
... ... @@ -60,4 +62,10 @@ public class QueryRequestCarTicketVo extends PageVo implements BaseVo, Serializa
60 62 @ApiModelProperty("要车计划ID")
61 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 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 34 @ApiModelProperty("申请日期")
... ...
... ... @@ -30,6 +30,7 @@
30 30 <result column="operations_department_auditor" property="operationsDepartmentAuditor"/>
31 31 <result column="operations_department_auditor_name" property="operationsDepartmentAuditorName"/>
32 32 <result column="status" property="status"/>
  33 + <result column="shipments_order_id" property="shipmentsOrderId"/>
33 34 <result column="create_by_id" property="createById"/>
34 35 <result column="create_by" property="createBy"/>
35 36 <result column="update_by_id" property="updateById"/>
... ... @@ -112,6 +113,9 @@
112 113 <if test="vo.planId != null and vo.planId != ''">
113 114 AND tb.plan_id = #{vo.planId}
114 115 </if>
  116 + <if test="vo.shipmentsOrderId != null and vo.shipmentsOrderId != ''">
  117 + AND tb.shipments_order_id = #{vo.shipmentsOrderId}
  118 + </if>
115 119 </where>
116 120 ORDER BY tb.create_time DESC
117 121 </select>
... ...