Commit 0b7a36ef8c84a3a8b0dee90dab8e6907d13d1960

Authored by yeqianyong
2 parents cb460df9 2b0f534b

Merge remote-tracking branch 'origin/master_0929' into master_0929

... ... @@ -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;
... ... @@ -484,17 +486,25 @@ 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 + redisHandler.del("GET_SHIPMENTS_ORDER_ID_" + draftRequestCarTicket.getId());
  498 + }
495 499 return ticketVo;
496 500 }
497 501
  502 + /**
  503 + * 延期发货
  504 + *
  505 + * @param flowStatus
  506 + * @param businessId
  507 + */
498 508 private void handleDelayedShipmentData(String flowStatus, String businessId) {
499 509 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
500 510 || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
... ... @@ -502,6 +512,33 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
502 512 QueryDelayedShipmentDetailVo vo = new QueryDelayedShipmentDetailVo();
503 513 vo.setDelayedShipmentId(businessId);
504 514 List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo);
  515 + Object shipmentsOrderId = redisHandler.get("GET_SHIPMENTS_ORDER_ID_" + businessId);
  516 + if (shipmentsOrderId != null) {
  517 + QueryRequestCarTicketVo vo2 = new QueryRequestCarTicketVo();
  518 + vo2.setShipmentsOrderId(String.valueOf(shipmentsOrderId));
  519 + List<RequestCarTicket> query1 = requestCarTicketService.query(vo2);
  520 + if (CollectionUtil.isEmpty(query1)) {
  521 + String requestCarTicketId = query1.get(0).getId();
  522 + //计划吨位
  523 + BigDecimal quantity = query1.get(0).getQuantity();
  524 + if (CollectionUtil.isNotEmpty(query)) {
  525 + //扣减要车单计划吨位(目前只有单条)
  526 + DelayedShipmentDetail delayedShipmentDetail1 = query.get(0);
  527 + //发货数量
  528 + BigDecimal quantity1 = delayedShipmentDetail1.getQuantity();
  529 + BigDecimal difference = quantity.subtract(quantity1);
  530 + if (difference.compareTo(BigDecimal.ZERO) == 0) {
  531 + //删除要车单
  532 + requestCarTicketService.deleteById(requestCarTicketId);
  533 + redisHandler.del("GET_SHIPMENTS_ORDER_ID_" + businessId);
  534 + } else {
  535 + //更新计划吨位
  536 + requestCarTicketService.updateQuantity(requestCarTicketId, difference);
  537 + redisHandler.del("GET_SHIPMENTS_ORDER_ID_" + businessId);
  538 + }
  539 + }
  540 + }
  541 + }
505 542 if (CollectionUtils.isNotEmpty(query)) {
506 543 for (DelayedShipmentDetail delayedShipmentDetail : query) {
507 544 //更新订货单物料行发货时间
... ...
... ... @@ -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
... ...
... ... @@ -10,6 +10,7 @@ import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
10 10 import com.lframework.starter.common.utils.CollectionUtil;
11 11 import com.lframework.starter.common.utils.StringUtil;
12 12 import com.lframework.starter.mq.core.service.MqProducerService;
  13 +import com.lframework.starter.web.core.components.redis.RedisHandler;
13 14 import com.lframework.starter.web.core.components.security.SecurityUtil;
14 15 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
15 16 import com.lframework.starter.web.core.utils.PageResultUtil;;
... ... @@ -31,18 +32,23 @@ import com.lframework.starter.web.inner.service.system.SysUserService;
31 32 import com.lframework.xingyun.sc.entity.DelayedShipment;
32 33 import com.lframework.xingyun.sc.entity.DelayedShipmentDetail;
33 34 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  35 +import com.lframework.xingyun.sc.entity.RequestCarTicket;
34 36 import com.lframework.xingyun.sc.handlers.TransactorHandler;
35 37 import com.lframework.xingyun.sc.mappers.DelayedShipmentMapper;
36 38 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
37 39 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
38 40 import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService;
  41 +import com.lframework.xingyun.sc.service.shipments.car.RequestCarTicketService;
39 42 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentDetailService;
40 43 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentService;
  44 +import com.lframework.xingyun.sc.vo.shipments.car.QueryRequestCarTicketVo;
41 45 import com.lframework.xingyun.sc.vo.shipments.delay.*;
42 46 import org.apache.commons.collections.CollectionUtils;
  47 +import org.springframework.beans.factory.annotation.Autowired;
43 48 import org.springframework.transaction.annotation.Transactional;
44 49 import org.springframework.stereotype.Service;
45 50 import javax.annotation.Resource;
  51 +import java.math.BigDecimal;
46 52 import java.time.LocalDate;
47 53 import java.time.temporal.ChronoUnit;
48 54 import java.util.ArrayList;
... ... @@ -72,6 +78,11 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
72 78 private FlowTaskWrapperMapper flowTaskWrapperMapper;
73 79 @Resource
74 80 private PurchaseOrderInfoService purchaseOrderInfoService;
  81 + @Resource
  82 + private RequestCarTicketService requestCarTicketService;
  83 + @Autowired
  84 + private RedisHandler redisHandler;
  85 +
75 86
76 87 @Override
77 88 public PageResult<DelayedShipment> query(Integer pageIndex, Integer pageSize, QueryDelayedShipmentVo vo) {
... ... @@ -203,6 +214,8 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
203 214 if (delayedExceedOneDay && !hasAny) {
204 215 //开启审核
205 216 vo.setWorkshopCode(delayedShipmentDetail.getWorkshopCode());
  217 + String key = "GET_SHIPMENTS_ORDER_ID_" + data.getId();
  218 + redisHandler.set(key, vo.getShipmentsOrderId());
206 219
207 220 flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, vo);
208 221 } else {
... ... @@ -212,6 +225,30 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
212 225 QueryDelayedShipmentDetailVo vo1 = new QueryDelayedShipmentDetailVo();
213 226 vo1.setDelayedShipmentId(data.getId());
214 227 List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo1);
  228 + if (StringUtil.isNotEmpty(vo.getShipmentsOrderId())) {
  229 + QueryRequestCarTicketVo vo2 = new QueryRequestCarTicketVo();
  230 + vo2.setShipmentsOrderId(vo.getShipmentsOrderId());
  231 + List<RequestCarTicket> query1 = requestCarTicketService.query(vo2);
  232 + if (CollectionUtil.isNotEmpty(query1)) {
  233 + String requestCarTicketId = query1.get(0).getId();
  234 + //计划吨位
  235 + BigDecimal quantity = query1.get(0).getQuantity();
  236 + if (CollectionUtil.isNotEmpty(query)) {
  237 + //扣减要车单计划吨位(目前只有单条)
  238 + DelayedShipmentDetail delayedShipmentDetail1 = query.get(0);
  239 + //发货数量
  240 + BigDecimal quantity1 = delayedShipmentDetail1.getQuantity();
  241 + BigDecimal difference = quantity.subtract(quantity1);
  242 + if (difference.compareTo(BigDecimal.ZERO) == 0) {
  243 + //删除要车单
  244 + requestCarTicketService.deleteById(requestCarTicketId);
  245 + } else {
  246 + //更新计划吨位
  247 + requestCarTicketService.updateQuantity(requestCarTicketId, difference);
  248 + }
  249 + }
  250 + }
  251 + }
215 252 if (CollectionUtil.isNotEmpty(query)) {
216 253 for (DelayedShipmentDetail detail : query) {
217 254 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>
... ...