|
...
|
...
|
@@ -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"})
|
...
|
...
|
|