|
1
|
1
|
package com.lframework.xingyun.sc.controller.purchase;
|
|
2
|
2
|
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
4
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
3
|
5
|
import com.lframework.starter.common.exceptions.impl.DefaultClientException;
|
|
4
|
6
|
import com.lframework.starter.common.utils.CollectionUtil;
|
|
5
|
7
|
import com.lframework.starter.web.core.annotations.security.HasPermission;
|
|
...
|
...
|
@@ -8,9 +10,22 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
|
8
|
10
|
import com.lframework.starter.web.core.components.resp.PageResult;
|
|
9
|
11
|
import com.lframework.starter.web.core.controller.DefaultBaseController;
|
|
10
|
12
|
import com.lframework.starter.web.core.utils.PageResultUtil;
|
|
|
13
|
+import com.lframework.starter.web.inner.entity.SysDataDicItem;
|
|
|
14
|
+import com.lframework.starter.web.inner.entity.SysDept;
|
|
|
15
|
+import com.lframework.starter.web.inner.service.system.SysDataDicItemService;
|
|
|
16
|
+import com.lframework.starter.web.inner.service.system.SysDeptService;
|
|
|
17
|
+import com.lframework.xingyun.basedata.entity.Customer;
|
|
|
18
|
+import com.lframework.xingyun.basedata.entity.Workshop;
|
|
|
19
|
+import com.lframework.xingyun.basedata.service.customer.CustomerService;
|
|
|
20
|
+import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
|
|
11
|
21
|
import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderBo;
|
|
|
22
|
+import com.lframework.xingyun.sc.bo.purchase.GetReplenishmentOrderLineBo;
|
|
12
|
23
|
import com.lframework.xingyun.sc.bo.purchase.QueryReplenishmentOrderBo;
|
|
|
24
|
+import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
|
|
13
|
25
|
import com.lframework.xingyun.sc.entity.ReplenishmentOrder;
|
|
|
26
|
+import com.lframework.xingyun.sc.entity.ReplenishmentOrderLine;
|
|
|
27
|
+import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
|
|
|
28
|
+import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderLineService;
|
|
14
|
29
|
import com.lframework.xingyun.sc.service.purchase.ReplenishmentOrderService;
|
|
15
|
30
|
import com.lframework.xingyun.sc.vo.purchase.CreateReplenishmentOrderVo;
|
|
16
|
31
|
import com.lframework.xingyun.sc.vo.purchase.QueryReplenishmentOrderVo;
|
|
...
|
...
|
@@ -18,13 +33,18 @@ import com.lframework.xingyun.sc.vo.purchase.UpdateReplenishmentOrderVo; |
|
18
|
33
|
import io.swagger.annotations.Api;
|
|
19
|
34
|
import io.swagger.annotations.ApiImplicitParam;
|
|
20
|
35
|
import io.swagger.annotations.ApiOperation;
|
|
21
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
36
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
37
|
+import org.apache.commons.lang3.StringUtils;
|
|
22
|
38
|
import org.springframework.validation.annotation.Validated;
|
|
23
|
39
|
import org.springframework.web.bind.annotation.*;
|
|
24
|
40
|
|
|
|
41
|
+import javax.annotation.Resource;
|
|
25
|
42
|
import javax.validation.Valid;
|
|
26
|
43
|
import javax.validation.constraints.NotBlank;
|
|
|
44
|
+import java.util.ArrayList;
|
|
27
|
45
|
import java.util.List;
|
|
|
46
|
+import java.util.Map;
|
|
|
47
|
+import java.util.function.Function;
|
|
28
|
48
|
import java.util.stream.Collectors;
|
|
29
|
49
|
|
|
30
|
50
|
/**
|
|
...
|
...
|
@@ -33,11 +53,26 @@ import java.util.stream.Collectors; |
|
33
|
53
|
@Api(tags = "补货单")
|
|
34
|
54
|
@Validated
|
|
35
|
55
|
@RestController
|
|
36
|
|
-@RequestMapping("/purchase/replenishmentorder")
|
|
|
56
|
+@RequestMapping("/purchase/replenishmentOrder")
|
|
37
|
57
|
public class ReplenishmentOrderController extends DefaultBaseController {
|
|
38
|
58
|
|
|
39
|
|
- @Autowired
|
|
|
59
|
+ @Resource
|
|
40
|
60
|
private ReplenishmentOrderService replenishmentOrderService;
|
|
|
61
|
+ @Resource
|
|
|
62
|
+ private SysDeptService sysDeptService;
|
|
|
63
|
+ @Resource
|
|
|
64
|
+ private CustomerService customerService;
|
|
|
65
|
+ @Resource
|
|
|
66
|
+ private SysDataDicItemService sysDataDicItemService;
|
|
|
67
|
+ @Resource
|
|
|
68
|
+ private WorkshopService workshopService;
|
|
|
69
|
+ @Resource
|
|
|
70
|
+ private PurchaseOrderInfoService purchaseOrderInfoService;
|
|
|
71
|
+ @Resource
|
|
|
72
|
+ private ReplenishmentOrderLineService replenishmentOrderLineService;
|
|
|
73
|
+
|
|
|
74
|
+
|
|
|
75
|
+ public static final String AUDIT_STATUS_DIC_CODE = "AUDIT_STATUS"; // 审核状态
|
|
41
|
76
|
|
|
42
|
77
|
/**
|
|
43
|
78
|
* 查询列表
|
|
...
|
...
|
@@ -56,7 +91,55 @@ public class ReplenishmentOrderController extends DefaultBaseController { |
|
56
|
91
|
results = datas.stream().map(QueryReplenishmentOrderBo::new).collect(Collectors.toList());
|
|
57
|
92
|
}
|
|
58
|
93
|
|
|
59
|
|
- return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
|
|
|
94
|
+ PageResult<QueryReplenishmentOrderBo> boPageResult = PageResultUtil.rebuild(pageResult, results);
|
|
|
95
|
+ if (CollectionUtils.isEmpty(boPageResult.getDatas())) {
|
|
|
96
|
+ return InvokeResultBuilder.success(boPageResult);
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ List<QueryReplenishmentOrderBo> boList = boPageResult.getDatas();
|
|
|
100
|
+ List<String> deptIdList = boList.stream().map(QueryReplenishmentOrderBo::getDeptId).collect(Collectors.toList());
|
|
|
101
|
+ Map<String, SysDept> sysDeptMap = CollectionUtils.emptyIfNull(sysDeptService.listByIds(deptIdList))
|
|
|
102
|
+ .stream()
|
|
|
103
|
+ .collect(Collectors.toMap(SysDept::getId, Function.identity()));
|
|
|
104
|
+ List<String> workshopIdList = boList.stream().map(QueryReplenishmentOrderBo::getWorkshopId).collect(Collectors.toList());
|
|
|
105
|
+ Map<String, Workshop> workshopMap = CollectionUtils.emptyIfNull(workshopService.listByIds(workshopIdList))
|
|
|
106
|
+ .stream()
|
|
|
107
|
+ .collect(Collectors.toMap(Workshop::getId, Function.identity()));
|
|
|
108
|
+ List<String> customerIdList = boList.stream().map(QueryReplenishmentOrderBo::getCustomerId).collect(Collectors.toList());
|
|
|
109
|
+ Map<String, Customer> customerMap = CollectionUtils.emptyIfNull(customerService.listByIds(customerIdList))
|
|
|
110
|
+ .stream()
|
|
|
111
|
+ .collect(Collectors.toMap(Customer::getId, Function.identity()));
|
|
|
112
|
+ List<SysDataDicItem> sysDataDicItemList = sysDataDicItemService.findByDicCode(AUDIT_STATUS_DIC_CODE);
|
|
|
113
|
+ Map<String, String> auditCodeAndNameMap = CollectionUtils.emptyIfNull(sysDataDicItemList)
|
|
|
114
|
+ .stream()
|
|
|
115
|
+ .collect(Collectors.toMap(SysDataDicItem::getCode, SysDataDicItem::getName));
|
|
|
116
|
+ boList.forEach(queryReplenishmentOrderBo -> {
|
|
|
117
|
+ if (queryReplenishmentOrderBo == null) {
|
|
|
118
|
+ return;
|
|
|
119
|
+ }
|
|
|
120
|
+
|
|
|
121
|
+ if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getDeptId())) {
|
|
|
122
|
+ SysDept sysDept = sysDeptMap.get(queryReplenishmentOrderBo.getDeptId());
|
|
|
123
|
+ queryReplenishmentOrderBo.setDeptName(sysDept == null ? "" : sysDept.getName());
|
|
|
124
|
+ }
|
|
|
125
|
+
|
|
|
126
|
+ if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getCustomerId())) {
|
|
|
127
|
+ Customer customer = customerMap.get(queryReplenishmentOrderBo.getCustomerId());
|
|
|
128
|
+ queryReplenishmentOrderBo.setCustomerName(customer == null ? "" : customer.getName());
|
|
|
129
|
+ }
|
|
|
130
|
+
|
|
|
131
|
+ if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getWorkshopId())) {
|
|
|
132
|
+ Workshop workshop = workshopMap.get(queryReplenishmentOrderBo.getWorkshopId());
|
|
|
133
|
+ queryReplenishmentOrderBo.setWorkshopName(workshop == null ? "" : workshop.getName());
|
|
|
134
|
+ }
|
|
|
135
|
+
|
|
|
136
|
+ if (StringUtils.isNotBlank(queryReplenishmentOrderBo.getStatus())) {
|
|
|
137
|
+ queryReplenishmentOrderBo.setStatusName(auditCodeAndNameMap.get(queryReplenishmentOrderBo.getStatus()));
|
|
|
138
|
+ }
|
|
|
139
|
+ });
|
|
|
140
|
+
|
|
|
141
|
+ boPageResult.setDatas(boList);
|
|
|
142
|
+ return InvokeResultBuilder.success(boPageResult);
|
|
60
|
143
|
}
|
|
61
|
144
|
|
|
62
|
145
|
/**
|
|
...
|
...
|
@@ -74,7 +157,32 @@ public class ReplenishmentOrderController extends DefaultBaseController { |
|
74
|
157
|
}
|
|
75
|
158
|
|
|
76
|
159
|
GetReplenishmentOrderBo result = new GetReplenishmentOrderBo(data);
|
|
|
160
|
+ SysDept sysDept = sysDeptService.findById(data.getDeptId());
|
|
|
161
|
+ result.setDeptName(sysDept == null ? "" : sysDept.getName());
|
|
|
162
|
+ Workshop workshop = workshopService.findById(data.getWorkshopId());
|
|
|
163
|
+ result.setWorkshopName(workshop == null ? "" : workshop.getName());
|
|
|
164
|
+ Customer customer = customerService.findById(data.getCustomerId());
|
|
|
165
|
+ result.setCustomerName(customer == null ? "" : customer.getName());
|
|
|
166
|
+ SysDataDicItem sysDataDicItem = sysDataDicItemService.findByCode(AUDIT_STATUS_DIC_CODE, data.getStatus());
|
|
|
167
|
+ result.setStatusName(sysDataDicItem == null ? "" : sysDataDicItem.getName());
|
|
|
168
|
+ PurchaseOrderInfo purchaseOrderInfo = purchaseOrderInfoService.findById(data.getPurchaseOrderId());
|
|
|
169
|
+ result.setPurchaseOrderName(purchaseOrderInfo == null ? "" : purchaseOrderInfo.getOrderNo());
|
|
|
170
|
+
|
|
|
171
|
+ Wrapper<ReplenishmentOrderLine> lineWrapper = Wrappers.lambdaQuery(ReplenishmentOrderLine.class)
|
|
|
172
|
+ .eq(ReplenishmentOrderLine::getReplenishmentOrderId, id)
|
|
|
173
|
+ .orderByAsc(ReplenishmentOrderLine::getShowOrder);
|
|
|
174
|
+ List<ReplenishmentOrderLine> replenishmentOrderLineList = replenishmentOrderLineService.list(lineWrapper);
|
|
|
175
|
+ if (CollectionUtils.isEmpty(replenishmentOrderLineList)) {
|
|
|
176
|
+ throw new DefaultClientException("补货单物料行为空!");
|
|
|
177
|
+ }
|
|
|
178
|
+
|
|
|
179
|
+ List<GetReplenishmentOrderLineBo> lineBoList = new ArrayList<>(replenishmentOrderLineList.size());
|
|
|
180
|
+ replenishmentOrderLineList.forEach(replenishmentOrderLine -> {
|
|
|
181
|
+ GetReplenishmentOrderLineBo replenishmentOrderLineBo = new GetReplenishmentOrderLineBo(replenishmentOrderLine);
|
|
|
182
|
+ lineBoList.add(replenishmentOrderLineBo);
|
|
|
183
|
+ });
|
|
77
|
184
|
|
|
|
185
|
+ result.setReplenishmentOrderLineList(lineBoList);
|
|
78
|
186
|
return InvokeResultBuilder.success(result);
|
|
79
|
187
|
}
|
|
80
|
188
|
|
...
|
...
|
|