Commit a5e7d539f83f1029d066d9393f56ff5329998c5c

Authored by yeqianyong
2 parents 10c67bb6 0091de7d

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

... ... @@ -21,10 +21,13 @@ import com.lframework.xingyun.sc.service.order.*;
21 21 import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService;
22 22 import com.lframework.xingyun.sc.service.shipments.car.RequestCarTicketService;
23 23 import com.lframework.xingyun.sc.service.shipments.car.DraftRequestCarTicketService;
  24 +import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentDetailService;
  25 +import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentService;
24 26 import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelHistoryVo;
25 27 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo;
26 28 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo;
27 29 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderRevokeLineVo;
  30 +import com.lframework.xingyun.sc.vo.shipments.delay.QueryDelayedShipmentDetailVo;
28 31 import lombok.extern.slf4j.Slf4j;
29 32 import org.apache.commons.collections.CollectionUtils;
30 33 import org.apache.commons.collections4.MapUtils;
... ... @@ -79,6 +82,11 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
79 82 private RequestCarTicketService requestCarTicketService;
80 83 @Resource
81 84 private ReplenishmentOrderService replenishmentOrderService;
  85 + @Resource
  86 + private DelayedShipmentService delayedShipmentService;
  87 + @Resource
  88 + private DelayedShipmentDetailService delayedShipmentDetailService;
  89 +
82 90
83 91
84 92 /**
... ... @@ -140,6 +148,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
140 148 case "RESTOCK_APPROVAL":
141 149 handleReplenishmentOrderStatus(flowStatus, businessId);
142 150 break;
  151 + case "DELAYED_SHIPMENT":
  152 + handleDelayedShipmentData(flowStatus, businessId);
  153 + break;
143 154 default:
144 155 break;
145 156 }
... ... @@ -436,4 +447,26 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
436 447 draftRequestCarTicketService.updateExamineUser(businessId, SecurityUtil.getCurrentUser().getId(), null, null);
437 448 }
438 449 }
  450 +
  451 + private void handleDelayedShipmentData(String flowStatus, String businessId) {
  452 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  453 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  454 + delayedShipmentService.updateStatus(businessId, "PASS");
  455 + QueryDelayedShipmentDetailVo vo = new QueryDelayedShipmentDetailVo();
  456 + vo.setDelayedShipmentId(businessId);
  457 + List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo);
  458 + if (CollectionUtils.isNotEmpty(query)) {
  459 + for (DelayedShipmentDetail delayedShipmentDetail : query) {
  460 + //更新订货单物料行发货时间
  461 + purchaseOrderLineService.updateDeliveryDate(delayedShipmentDetail.getOrderSpecId(),
  462 + delayedShipmentDetail.getApplyShipmentDate());
  463 + }
  464 + }
  465 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  466 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  467 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)
  468 + || FlowInstanceStatus.UNDO.getCode().equals(flowStatus)) {
  469 + delayedShipmentService.updateStatus(businessId, "REFUSE");
  470 + }
  471 + }
439 472 }
... ...
... ... @@ -189,6 +189,26 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde
189 189 OpLogUtil.setExtra(id);
190 190 }
191 191
  192 + @OpLog(type = OtherOpLogType.class, name = "修改订货单表物料行发货时间,ID:{}", params = {"#id"})
  193 + @Transactional(rollbackFor = Exception.class)
  194 + @Override
  195 + public void updateDeliveryDate(String id, LocalDate deliveryDate) {
  196 +
  197 + PurchaseOrderLine data = getBaseMapper().selectById(id);
  198 + if (ObjectUtil.isNull(data)) {
  199 + throw new DefaultClientException("订货单表物料行不存在!");
  200 + }
  201 +
  202 + LambdaUpdateWrapper<PurchaseOrderLine> updateWrapper = Wrappers.lambdaUpdate(PurchaseOrderLine.class)
  203 + .set(PurchaseOrderLine::getDeliveryDate, deliveryDate)
  204 + .eq(PurchaseOrderLine::getId, id);
  205 +
  206 + getBaseMapper().update(updateWrapper);
  207 +
  208 + OpLogUtil.setVariable("id", data.getId());
  209 + OpLogUtil.setExtra(id);
  210 + }
  211 +
192 212 @OpLog(type = OtherOpLogType.class, name = "删除订货单表物料行,ID:{}", params = {"#id"})
193 213 @Transactional(rollbackFor = Exception.class)
194 214 @Override
... ...
... ... @@ -3,8 +3,10 @@ package com.lframework.xingyun.sc.impl.shipments.delay;
3 3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
6 7 import com.lframework.starter.common.utils.CollectionUtil;
7 8 import com.lframework.starter.common.utils.StringUtil;
  9 +import com.lframework.starter.web.core.components.security.SecurityUtil;
8 10 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
9 11 import com.lframework.starter.web.core.utils.PageResultUtil;;
10 12 import com.lframework.starter.web.core.components.resp.PageResult;
... ... @@ -16,9 +18,15 @@ import com.lframework.starter.common.utils.ObjectUtil;
16 18 import com.lframework.starter.web.core.annotations.oplog.OpLog;
17 19 import com.lframework.starter.web.core.utils.PageHelperUtil;
18 20 import com.lframework.starter.common.utils.Assert;
  21 +import com.lframework.starter.web.inner.bo.usercenter.UserInfoBo;
19 22 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  23 +import com.lframework.starter.web.inner.dto.system.UserInfoDto;
  24 +import com.lframework.starter.web.inner.service.system.SysUserService;
20 25 import com.lframework.xingyun.sc.entity.DelayedShipment;
  26 +import com.lframework.xingyun.sc.entity.DelayedShipmentDetail;
21 27 import com.lframework.xingyun.sc.mappers.DelayedShipmentMapper;
  28 +import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
  29 +import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService;
22 30 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentDetailService;
23 31 import com.lframework.xingyun.sc.service.shipments.delay.DelayedShipmentService;
24 32 import com.lframework.xingyun.sc.vo.shipments.delay.*;
... ... @@ -26,12 +34,23 @@ import org.springframework.transaction.annotation.Transactional;
26 34 import org.springframework.stereotype.Service;
27 35 import javax.annotation.Resource;
28 36 import java.time.LocalDate;
  37 +import java.time.temporal.ChronoUnit;
  38 +import java.util.ArrayList;
29 39 import java.util.List;
30 40
31 41 @Service
32 42 public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmentMapper, DelayedShipment> implements DelayedShipmentService {
  43 + private static final String BPM_FLAG = "DELAYED_SHIPMENT";
  44 + @Resource
  45 + private FlowInstanceWrapperService flowInstanceWrapperService;
33 46 @Resource
34 47 private DelayedShipmentDetailService delayedShipmentDetailService;
  48 + @Resource
  49 + private ShipmentsPlanDetailService shipmentsPlanDetailService;
  50 + @Resource
  51 + private SysUserService sysUserService;
  52 + @Resource
  53 + private PurchaseOrderLineService purchaseOrderLineService;
35 54
36 55 @Override
37 56 public PageResult<DelayedShipment> query(Integer pageIndex, Integer pageSize, QueryDelayedShipmentVo vo) {
... ... @@ -84,17 +103,85 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
84 103 getBaseMapper().insert(data);
85 104
86 105 //新增延期发货详情列
  106 + List<String> ids = new ArrayList<>();
  107 + String id = null;
  108 + //延期时间是否超过一天
  109 + boolean delayedExceedOneDay = false;
  110 + LocalDate applyShipmentDate = null;
87 111 if (CollectionUtil.isNotEmpty(vo.getDelayedShipmentDetailList())) {
88 112 List<CreateDelayedShipmentDetailVo> delayedShipmentDetailList = vo.getDelayedShipmentDetailList();
89 113 for (CreateDelayedShipmentDetailVo createDelayedShipmentDetailVo : delayedShipmentDetailList) {
90 114 createDelayedShipmentDetailVo.setDelayedShipmentId(data.getId());
91   - delayedShipmentDetailService.create(createDelayedShipmentDetailVo);
  115 + id = delayedShipmentDetailService.create(createDelayedShipmentDetailVo);
  116 + ids.add(createDelayedShipmentDetailVo.getShipmentsPlanDetailId());
  117 + LocalDate deliveryDate = createDelayedShipmentDetailVo.getDeliveryDate();
  118 + applyShipmentDate = createDelayedShipmentDetailVo.getApplyShipmentDate();
  119 + if (deliveryDate != null && applyShipmentDate != null) {
  120 + long daysBetween = Math.abs(ChronoUnit.DAYS.between(deliveryDate, applyShipmentDate));
  121 + if (daysBetween > 1) {
  122 + delayedExceedOneDay = true;
  123 + }
  124 + }
92 125 }
93 126 }
94 127
95 128 OpLogUtil.setVariable("id", data.getId());
96 129 OpLogUtil.setExtra(vo);
97 130
  131 + //新增完成后将数据从发货计划明细/发货单明细数据中移除
  132 + if (CollectionUtil.isNotEmpty(ids)) {
  133 + shipmentsPlanDetailService.batchDelete(ids);
  134 + }
  135 +
  136 + //判断发起人是不是:经营办发货员,经营办计划员,经营办主管,生产科计划员
  137 + String userId = SecurityUtil.getCurrentUser().getId();
  138 + UserInfoDto info = sysUserService.getInfo(userId);
  139 + UserInfoBo userInfoBo = new UserInfoBo(info);
  140 + List<String> roleCodes = userInfoBo.getRoleCodes();
  141 + List<String> newRoleCodes = new ArrayList<>();
  142 + //经营办发货员
  143 + newRoleCodes.add("yfcjybfhy");
  144 + newRoleCodes.add("efcjybfhy");
  145 + newRoleCodes.add("sfcjybfhy");
  146 + newRoleCodes.add("ztfcjybfhy");
  147 + //经营办计划员
  148 + newRoleCodes.add("yfcjybjhy");
  149 + newRoleCodes.add("efcjybjhy");
  150 + newRoleCodes.add("sfcjybjhy");
  151 + newRoleCodes.add("ztfcjybjhy");
  152 + //经营办主管
  153 + newRoleCodes.add("yfcjybzg");
  154 + newRoleCodes.add("efcjybzg");
  155 + newRoleCodes.add("sfcjybzg");
  156 + newRoleCodes.add("ztcjybzg");
  157 + //生产科计划员
  158 + newRoleCodes.add("yfcsckjhy");
  159 + newRoleCodes.add("efcsckjhy");
  160 + newRoleCodes.add("sfcsckjhy");
  161 + newRoleCodes.add("ztfcsckjhy");
  162 + boolean hasAny = newRoleCodes.stream().anyMatch(roleCodes::contains);
  163 + if (delayedExceedOneDay && !hasAny) {
  164 + //开启审核
  165 + DelayedShipmentDetail delayedShipmentDetail = delayedShipmentDetailService.findById(id);
  166 + vo.setWorkshopName(delayedShipmentDetail.getWorkshopName());
  167 +
  168 + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, vo);
  169 + } else {
  170 + //不需要审批直接通过
  171 + updateStatus(data.getId(), "PASS");
  172 + //更新订货单物料行发货时间
  173 + QueryDelayedShipmentDetailVo vo1 = new QueryDelayedShipmentDetailVo();
  174 + vo1.setDelayedShipmentId(data.getId());
  175 + List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo1);
  176 + if (CollectionUtil.isNotEmpty(query)) {
  177 + for (DelayedShipmentDetail delayedShipmentDetail : query) {
  178 + purchaseOrderLineService.updateDeliveryDate(delayedShipmentDetail.getOrderSpecId(),
  179 + delayedShipmentDetail.getApplyShipmentDate());
  180 + }
  181 + }
  182 + }
  183 + //todo 消息通知
  184 +
98 185 return data.getId();
99 186 }
100 187
... ... @@ -118,15 +205,97 @@ public class DelayedShipmentServiceImpl extends BaseMpServiceImpl<DelayedShipmen
118 205 getBaseMapper().update(updateWrapper);
119 206
120 207 //更新延期发货详情列
  208 + //延期时间是否超过一天
  209 + String id = null;
  210 + boolean delayedExceedOneDay = false;
  211 + LocalDate applyShipmentDate = null;
121 212 if (CollectionUtil.isNotEmpty(vo.getDelayedShipmentDetailList())) {
122 213 List<UpdateDelayedShipmentDetailVo> delayedShipmentDetailList = vo.getDelayedShipmentDetailList();
123 214 for (UpdateDelayedShipmentDetailVo updateDelayedShipmentDetailVo : delayedShipmentDetailList) {
124 215 delayedShipmentDetailService.update(updateDelayedShipmentDetailVo);
  216 + id = updateDelayedShipmentDetailVo.getId();
  217 + DelayedShipmentDetail delayedShipmentDetail = delayedShipmentDetailService.findById(id);
  218 + LocalDate deliveryDate = delayedShipmentDetail.getDeliveryDate();
  219 + applyShipmentDate = delayedShipmentDetail.getApplyShipmentDate();
  220 + if (deliveryDate != null && applyShipmentDate != null) {
  221 + long daysBetween = Math.abs(ChronoUnit.DAYS.between(deliveryDate, applyShipmentDate));
  222 + if (daysBetween > 1) {
  223 + delayedExceedOneDay = true;
  224 + }
  225 + }
125 226 }
126 227 }
127 228
128 229 OpLogUtil.setVariable("id", data.getId());
129 230 OpLogUtil.setExtra(vo);
  231 +
  232 + //判断发起人是不是:经营办发货员,经营办计划员,经营办主管,生产科计划员
  233 + String userId = SecurityUtil.getCurrentUser().getId();
  234 + UserInfoDto info = sysUserService.getInfo(userId);
  235 + UserInfoBo userInfoBo = new UserInfoBo(info);
  236 + List<String> roleCodes = userInfoBo.getRoleCodes();
  237 + List<String> newRoleCodes = new ArrayList<>();
  238 + //经营办发货员
  239 + newRoleCodes.add("yfcjybfhy");
  240 + newRoleCodes.add("efcjybfhy");
  241 + newRoleCodes.add("sfcjybfhy");
  242 + newRoleCodes.add("ztfcjybfhy");
  243 + //经营办计划员
  244 + newRoleCodes.add("yfcjybjhy");
  245 + newRoleCodes.add("efcjybjhy");
  246 + newRoleCodes.add("sfcjybjhy");
  247 + newRoleCodes.add("ztfcjybjhy");
  248 + //经营办主管
  249 + newRoleCodes.add("yfcjybzg");
  250 + newRoleCodes.add("efcjybzg");
  251 + newRoleCodes.add("sfcjybzg");
  252 + newRoleCodes.add("ztcjybzg");
  253 + //生产科计划员
  254 + newRoleCodes.add("yfcsckjhy");
  255 + newRoleCodes.add("efcsckjhy");
  256 + newRoleCodes.add("sfcsckjhy");
  257 + newRoleCodes.add("ztfcsckjhy");
  258 + boolean hasAny = newRoleCodes.stream().anyMatch(roleCodes::contains);
  259 + if (delayedExceedOneDay && !hasAny) {
  260 + //开启审核
  261 + DelayedShipmentDetail delayedShipmentDetail = delayedShipmentDetailService.findById(id);
  262 + vo.setWorkshopName(delayedShipmentDetail.getWorkshopName());
  263 +
  264 + flowInstanceWrapperService.startInstance(BPM_FLAG, vo.getId(), BPM_FLAG, vo);
  265 + } else {
  266 + //不需要审批直接通过
  267 + updateStatus(data.getId(), "PASS");
  268 + //更新订货单物料行发货时间
  269 + QueryDelayedShipmentDetailVo vo1 = new QueryDelayedShipmentDetailVo();
  270 + vo1.setDelayedShipmentId(data.getId());
  271 + List<DelayedShipmentDetail> query = delayedShipmentDetailService.query(vo1);
  272 + if (CollectionUtil.isNotEmpty(query)) {
  273 + for (DelayedShipmentDetail delayedShipmentDetail : query) {
  274 + purchaseOrderLineService.updateDeliveryDate(delayedShipmentDetail.getOrderSpecId(),
  275 + delayedShipmentDetail.getApplyShipmentDate());
  276 + }
  277 + }
  278 + }
  279 + //todo 消息通知
  280 + }
  281 +
  282 + @OpLog(type = OtherOpLogType.class, name = "修改状态,ID:{}", params = {"#id"})
  283 + @Transactional(rollbackFor = Exception.class)
  284 + @Override
  285 + public void updateStatus(String id, String status) {
  286 +
  287 + DelayedShipment data = getBaseMapper().selectById(id);
  288 + if (ObjectUtil.isNull(data)) {
  289 + throw new DefaultClientException("延期发货表不存在!");
  290 + }
  291 +
  292 + LambdaUpdateWrapper<DelayedShipment> updateWrapper = Wrappers.lambdaUpdate(DelayedShipment.class)
  293 + .set(DelayedShipment::getStatus, status)
  294 + .eq(DelayedShipment::getId, id);
  295 +
  296 + getBaseMapper().update(updateWrapper);
  297 +
  298 + OpLogUtil.setVariable("id", data.getId());
130 299 }
131 300
132 301 @OpLog(type = OtherOpLogType.class, name = "删除延期发货表,ID:{}", params = {"#id"})
... ...
... ... @@ -58,6 +58,14 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin
58 58 void updateQuantity(String id, BigDecimal quantity);
59 59
60 60 /**
  61 + * 更新交货时间
  62 + *
  63 + * @param id 主建
  64 + * @param deliveryDate 交货时间
  65 + */
  66 + void updateDeliveryDate(String id, LocalDate deliveryDate);
  67 +
  68 + /**
61 69 * 根据ID删除
62 70 * @param id
63 71 * @return
... ...
... ... @@ -47,6 +47,14 @@ public interface DelayedShipmentService extends BaseMpService<DelayedShipment> {
47 47 void update(UpdateDelayedShipmentVo vo);
48 48
49 49 /**
  50 + * 修改状态
  51 + *
  52 + * @param id 主键
  53 + * @param status 状态
  54 + */
  55 + void updateStatus(String id, String status);
  56 +
  57 + /**
50 58 * 根据ID删除
51 59 * @param id
52 60 * @return
... ...
... ... @@ -48,4 +48,10 @@ public class CreateDelayedShipmentVo implements BaseVo, Serializable {
48 48 @ApiModelProperty("延期发货详情")
49 49 private List<CreateDelayedShipmentDetailVo> delayedShipmentDetailList;
50 50
  51 + /**
  52 + * 厂办名称
  53 + */
  54 + @ApiModelProperty("厂办名称")
  55 + private String workshopName;
  56 +
51 57 }
... ...
... ... @@ -56,5 +56,11 @@ public class UpdateDelayedShipmentVo implements BaseVo, Serializable {
56 56 @ApiModelProperty("延期发货详情")
57 57 private List<UpdateDelayedShipmentDetailVo> delayedShipmentDetailList;
58 58
  59 + /**
  60 + * 厂办名称
  61 + */
  62 + @ApiModelProperty("厂办名称")
  63 + private String workshopName;
  64 +
59 65
60 66 }
... ...
... ... @@ -1744,7 +1744,7 @@
1744 1744 <w:szCs w:val="32"/>
1745 1745 <w:lang w:val="en-US" w:eastAsia="zh-CN" w:bidi="zh-CN"/>
1746 1746 </w:rPr>
1747   - <w:t xml:space="preserve"> ${(corePersonnel.mobile)!}</w:t>
  1747 + <w:t xml:space="preserve">${(corePersonnel.mobile)!}</w:t>
1748 1748 </w:r>
1749 1749 </w:p>
1750 1750 </w:tc>
... ...