|
...
|
...
|
@@ -5,6 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
5
|
5
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
6
|
6
|
import com.github.pagehelper.PageInfo;
|
|
7
|
7
|
import com.lframework.starter.web.core.components.security.SecurityUtil;
|
|
|
8
|
+import com.lframework.xingyun.basedata.entity.Workshop;
|
|
|
9
|
+import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
|
|
|
10
|
+import com.lframework.xingyun.basedata.vo.workshop.QueryWorkshopVo;
|
|
|
11
|
+import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
|
|
8
|
12
|
import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
|
|
9
|
13
|
import com.lframework.xingyun.sc.entity.ShipmentsPlan;
|
|
10
|
14
|
import com.lframework.xingyun.sc.entity.ShipmentsPlanDetail;
|
|
...
|
...
|
@@ -20,6 +24,7 @@ import com.lframework.starter.web.core.utils.PageHelperUtil; |
|
20
|
24
|
import com.lframework.starter.common.utils.Assert;
|
|
21
|
25
|
import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
|
|
22
|
26
|
import com.lframework.xingyun.sc.mappers.ShipmentsPlanDetailMapper;
|
|
|
27
|
+import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
|
|
23
|
28
|
import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
|
|
24
|
29
|
import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanDetailService;
|
|
25
|
30
|
import com.lframework.xingyun.sc.service.shipments.ShipmentsPlanService;
|
|
...
|
...
|
@@ -36,8 +41,10 @@ import javax.annotation.Resource; |
|
36
|
41
|
import java.math.BigDecimal;
|
|
37
|
42
|
import java.time.LocalDate;
|
|
38
|
43
|
import java.util.ArrayList;
|
|
|
44
|
+import java.util.HashMap;
|
|
39
|
45
|
import java.util.List;
|
|
40
|
46
|
import java.util.Map;
|
|
|
47
|
+import java.util.function.Function;
|
|
41
|
48
|
import java.util.stream.Collectors;
|
|
42
|
49
|
|
|
43
|
50
|
@Service
|
|
...
|
...
|
@@ -48,6 +55,10 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP |
|
48
|
55
|
private PurchaseOrderLineService purchaseOrderLineService;
|
|
49
|
56
|
@Resource
|
|
50
|
57
|
private ShipmentsPlanService shipmentsPlanService;
|
|
|
58
|
+ @Resource
|
|
|
59
|
+ private WorkshopService workshopService;
|
|
|
60
|
+ @Resource
|
|
|
61
|
+ private PurchaseOrderInfoService purchaseOrderInfoService;
|
|
51
|
62
|
|
|
52
|
63
|
|
|
53
|
64
|
@Override
|
|
...
|
...
|
@@ -207,6 +218,69 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP |
|
207
|
218
|
purchaseOrderLineService.batchAdd(orderLineList);
|
|
208
|
219
|
}
|
|
209
|
220
|
|
|
|
221
|
+ @Override
|
|
|
222
|
+ public void autoCreateShipmentPlan() {
|
|
|
223
|
+ // 获取所有厂房
|
|
|
224
|
+ List<Workshop> workshopList = workshopService.query(new QueryWorkshopVo());
|
|
|
225
|
+ LocalDate tomorrow = LocalDate.now().plusDays(1);
|
|
|
226
|
+ LocalDate afTomorrow = LocalDate.now().plusDays(2);
|
|
|
227
|
+ // 获取所有明日、后日需要发货的订货单规格数据
|
|
|
228
|
+ List<LocalDate> dateList = new ArrayList<>();
|
|
|
229
|
+ dateList.add(tomorrow);
|
|
|
230
|
+ dateList.add(afTomorrow);
|
|
|
231
|
+ List<PurchaseOrderLine> orderLineList = purchaseOrderLineService.listByShipmentDate(dateList);
|
|
|
232
|
+ // 获取订货单数据
|
|
|
233
|
+ Map<String, PurchaseOrderInfo> orderInfoMap = new HashMap<>();
|
|
|
234
|
+ if (CollectionUtils.isNotEmpty(orderLineList)) {
|
|
|
235
|
+ List<String> orderIds = orderLineList.stream().map(PurchaseOrderLine::getPurchaseOrderId).collect(Collectors.toList());
|
|
|
236
|
+ List<PurchaseOrderInfo> orderInfoList = purchaseOrderInfoService.listByIds(orderIds);
|
|
|
237
|
+ if (CollectionUtils.isNotEmpty(orderInfoList)) {
|
|
|
238
|
+ orderInfoMap = orderInfoList.stream().collect(Collectors.toMap(PurchaseOrderInfo::getId, Function.identity()));
|
|
|
239
|
+ }
|
|
|
240
|
+ }
|
|
|
241
|
+ for (Workshop workshop : workshopList) {
|
|
|
242
|
+ // 生成发货计划
|
|
|
243
|
+ ShipmentsPlan plan = new ShipmentsPlan();
|
|
|
244
|
+ plan.setId(IdUtil.getId());
|
|
|
245
|
+ plan.setStatus("DRAFT");
|
|
|
246
|
+ plan.setWorkshopId(workshop.getId());
|
|
|
247
|
+ plan.setTomoPreShipDate(tomorrow);
|
|
|
248
|
+ plan.setAfTomoPreShipDate(afTomorrow);
|
|
|
249
|
+
|
|
|
250
|
+ shipmentsPlanService.getBaseMapper().insert(plan);
|
|
|
251
|
+ // 生成发货计划明细
|
|
|
252
|
+ if (CollectionUtils.isNotEmpty(orderLineList)) {
|
|
|
253
|
+ List<ShipmentsPlanDetail> planDetails = new ArrayList<>();
|
|
|
254
|
+ for (PurchaseOrderLine line : orderLineList) {
|
|
|
255
|
+ ShipmentsPlanDetail detail = new ShipmentsPlanDetail();
|
|
|
256
|
+ detail.setId(IdUtil.getId());
|
|
|
257
|
+ detail.setPlanId(plan.getId());
|
|
|
258
|
+ String orderId = line.getPurchaseOrderId();
|
|
|
259
|
+ detail.setOrderId(orderId);
|
|
|
260
|
+ PurchaseOrderInfo orderInfo = orderInfoMap.get(orderId);
|
|
|
261
|
+ if (orderInfo == null) {
|
|
|
262
|
+ continue;
|
|
|
263
|
+ }
|
|
|
264
|
+ String workshopId = orderInfo.getWorkshopId();
|
|
|
265
|
+ if (!workshop.getId().equals(workshopId)) {
|
|
|
266
|
+ continue;
|
|
|
267
|
+ }
|
|
|
268
|
+ detail.setOrderSpecId(line.getId());
|
|
|
269
|
+ detail.setShipmentsDate(line.getDeliveryDate());
|
|
|
270
|
+ detail.setPreShipments(afTomorrow.equals(line.getDeliveryDate()));
|
|
|
271
|
+ detail.setDelFlag(Boolean.FALSE);
|
|
|
272
|
+ detail.setCreateById("1");
|
|
|
273
|
+ detail.setUpdateById("1");
|
|
|
274
|
+
|
|
|
275
|
+ planDetails.add(detail);
|
|
|
276
|
+ }
|
|
|
277
|
+ if (CollectionUtils.isNotEmpty(planDetails)) {
|
|
|
278
|
+ getBaseMapper().batchAdd(planDetails);
|
|
|
279
|
+ }
|
|
|
280
|
+ }
|
|
|
281
|
+ }
|
|
|
282
|
+ }
|
|
|
283
|
+
|
|
210
|
284
|
|
|
211
|
285
|
/**
|
|
212
|
286
|
* 封装发货计划明细数据
|
|
...
|
...
|
@@ -224,6 +298,8 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP |
|
224
|
298
|
data.setOrderSpecId(IdUtil.getId());
|
|
225
|
299
|
data.setParentId(detail.getId());
|
|
226
|
300
|
data.setShipmentsDate(detail.getShipmentsDate());
|
|
|
301
|
+ data.setShipmentsTime(detail.getShipmentsTime());
|
|
|
302
|
+ data.setCanShipments(detail.getCanShipments());
|
|
227
|
303
|
data.setQuantity(quantity);
|
|
228
|
304
|
data.setPreShipments(Boolean.FALSE);
|
|
229
|
305
|
data.setCreateById(userId);
|
...
|
...
|
|