BasicDataApiController.java
13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
package com.huaheng.api.general.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.api.general.domain.BarCodeDomain;
import com.huaheng.api.general.domain.ContainerTypeDomain;
import com.huaheng.api.general.domain.InventoryQueryDomain;
import com.huaheng.api.general.service.BarCodeApiService;
import com.huaheng.api.general.service.BasicDataApiService;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.barcode.barcodeDetail.domain.BarCodeDetail;
import com.huaheng.pc.barcode.barcodeHeader.domain.BarCodeHeader;
import com.huaheng.pc.config.containerCapacity.domain.ContainerCapacity;
import com.huaheng.pc.config.containerType.domain.ContainerType;
import com.huaheng.pc.config.customer.domain.Customer;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.materialMultiple.domain.MaterialMultiple;
import com.huaheng.pc.config.materialMultiple.service.MaterialMultipleServiceImpl;
import com.huaheng.pc.config.materialUnit.domain.MaterialUnit;
import com.huaheng.pc.config.materialUnit.service.MaterialUnitService;
import com.huaheng.pc.config.supplier.domain.Supplier;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
import com.huaheng.pc.system.dept.domain.Dept;
import com.huaheng.pc.system.dict.domain.DictData;
import com.huaheng.pc.system.user.domain.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@RestController
@RequestMapping("/api/basicData")
@Api(tags = {"基础数据接口"}, value = "基础数据接口basicData")
public class BasicDataApiController extends BaseController {
@Autowired
private BasicDataApiService basicDataApiService;
@Resource
private MaterialMultipleServiceImpl materialMultipleService;
@Resource
private MaterialService materialService;
@Resource
private InventoryMaterialSummaryService inventoryMaterialSummaryService;
@Resource
private BarCodeApiService barCodeApiService;
/**
* 同步物料
*/
@Log(title = "物料添加", action = BusinessType.INSERT)
@PostMapping("/addMaterial")
@ApiOperation("物料添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加物料", from="ERP")
public AjaxResult AddMaterialApi(@RequestBody Material material)
{
AjaxResult ajaxResult = basicDataApiService.material(material);
return ajaxResult;
}
@Log(title = "物料查询", action = BusinessType.INSERT)
@PostMapping("/queryMaterial")
@ApiOperation("物料查询公共接口")
@ResponseBody
@ApiLogger(apiName = "查询物料", from="ERP")
public AjaxResult QueryMaterialApi(@RequestBody Material material)
{
AjaxResult ajaxResult = basicDataApiService.queryMaterial(material);
return ajaxResult;
}
@Log(title = "库存查询", action = BusinessType.INSERT)
@PostMapping("/queryInventory")
@ApiOperation("库存查询公共接口")
@ResponseBody
@ApiLogger(apiName = "查询物料", from="ERP")
public AjaxResult QueryInventoryApi(@RequestBody InventoryQueryDomain inventoryQueryDomain)
{
// AjaxResult ajaxResult = basicDataApiService.queryMaterial(material);
return null;
}
/**
* 同步字典
*/
@Log(title = "字典添加", action = BusinessType.INSERT)
@PostMapping("/dictData")
@ApiOperation("字典添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加字典", from="ERP")
public AjaxResult UnitlApi(@RequestBody DictData dictData)
{
AjaxResult ajaxResult = basicDataApiService.dict(dictData);
return ajaxResult;
}
/**
* 同步仓库和货主
*/
@Log(title = "仓库添加", action = BusinessType.INSERT)
@PostMapping("/addWarehouse")
@ApiOperation("仓库添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加仓库", from="ERP")
public AjaxResult WarehouseApi(@RequestBody Warehouse warehouse)
{
AjaxResult ajaxResult = basicDataApiService.warehouse(warehouse);
return ajaxResult;
}
/**
* 同步客户档案
*/
@Log(title = "客户档案添加", action = BusinessType.INSERT)
@PostMapping("/addCustomer")
@ApiOperation("客户档案添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加客户", from="ERP")
public AjaxResult CustomerApi(@RequestBody Customer customer)
{
AjaxResult ajaxResult = basicDataApiService.customer(customer);
return ajaxResult;
}
/**
* 同步部门档案
*/
@Log(title = "部门档案添加", action = BusinessType.INSERT)
@PostMapping("/addDepart")
@ApiOperation("部门档案添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加部门", from="ERP")
public AjaxResult DeptApi(@RequestBody Dept dept)
{
AjaxResult ajaxResult = basicDataApiService.dept(dept);
return ajaxResult;
}
/**
* 同步人员档案
*/
@Log(title = "人员档案添加", action = BusinessType.INSERT)
@PostMapping("/addUser")
@ApiOperation("人员档案添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加人员", from="ERP")
public AjaxResult UserApi(@RequestBody User user)
{
AjaxResult ajaxResult = basicDataApiService.user(user);
return ajaxResult;
}
@Log(title = "用户同步", action = BusinessType.INSERT)
@PostMapping("/queryUserApi")
@ApiOperation("用户查询公共接口")
@ResponseBody
@ApiLogger(apiName = "查询用户", from="ERP")
public AjaxResult queryUserApi(@RequestBody User user)
{
AjaxResult ajaxResult = basicDataApiService.queryUser(user);
return ajaxResult;
}
/**
* 同步容器容量
*/
@Log(title = "容器容量添加", action = BusinessType.INSERT)
@PostMapping("/containerCapacity")
@ApiOperation("容器容量添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加容器容量", from="ERP")
public AjaxResult containerCapacityApi(@RequestBody ContainerCapacity containerCapacity){
AjaxResult ajaxResult = basicDataApiService.containerCapacity(containerCapacity);
return ajaxResult;
}
/**
* 同步容器类型
*/
@Log(title = "同步容器类型", action = BusinessType.INSERT)
@PostMapping("/containerType")
@ApiOperation("同步容器类型")
@ResponseBody
@ApiLogger(apiName = "同步容器类型", from="ERP")
public AjaxResult containerTypeApi(@RequestBody ContainerTypeDomain containerTypeDomain){
AjaxResult ajaxResult = basicDataApiService.containerType(containerTypeDomain);
return ajaxResult;
}
/**
* 同步供应商档案
*/
@Log(title = "供应商档案添加", action = BusinessType.INSERT)
@PostMapping("/addSupplier")
@ApiOperation("供应商档案添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加供应商", from="ERP")
public AjaxResult SupplierApi(@RequestBody Supplier supplier){
AjaxResult ajaxResult = basicDataApiService.supplier(supplier);
return ajaxResult;
}
@Log(title = "库存同步", action = BusinessType.INSERT)
@PostMapping("/queryInventoryApi")
@ApiOperation("库存查询公共接口")
@ResponseBody
@ApiLogger(apiName = "查询库存", from="ERP")
public AjaxResult queryInventoryApi(@RequestBody InventoryDetail inventoryDetail)
{
AjaxResult ajaxResult = basicDataApiService.queryInventoryApi(inventoryDetail);
return ajaxResult;
}
@Log(title = "计算单位换算", action = BusinessType.INSERT)
@PostMapping("/addMaterialMultiple")
@ApiOperation("计算单位换算接口")
@ResponseBody
@ApiLogger(apiName = "计算单位换算接口", from="ERP")
public AjaxResult addMaterialMultiple(@RequestBody MaterialMultiple materialMultiple)
{
LambdaQueryWrapper<Material> lam = Wrappers.lambdaQuery();
lam.eq(Material::getCode,materialMultiple.getMaterialCode())
.eq(Material::getWarehouseCode,materialMultiple.getWarehouseCode());
Material material = materialService.getOne(lam);
if(material ==null){
return AjaxResult.error("物料编码错误,系统没有此物料");
}
//todo:胡海-- 物料单位是否存在需要判断 只有系统有维护的单位才可以进行换算
LambdaQueryWrapper<MaterialMultiple> lambda = Wrappers.lambdaQuery();
lambda.eq(MaterialMultiple::getCompanyCode,materialMultiple.getCompanyCode())
.eq(MaterialMultiple::getMaterialCode, materialMultiple)
.eq(MaterialMultiple::getWarehouseCode, materialMultiple.getWarehouseCode())
.eq(MaterialMultiple::getUnitId1, materialMultiple.getUnitId1())
.eq(MaterialMultiple::getUnitId2, materialMultiple.getUnitId2());
if (!materialMultipleService.list(lambda).isEmpty()){
return AjaxResult.error("该信息已存在");
}
materialMultiple.setMaterialName(material.getName());
materialMultiple.setMaterialSpec(material.getSpec());
materialMultiple.setWarehouseCode(materialMultiple.getWarehouseCode());
materialMultiple.setCreatedBy("ERP");
materialMultiple.setLastUpdatedBy("ERP");
materialMultiple.setCompanyCode(materialMultiple.getCompanyCode());
materialMultiple.setUnitId1(materialMultiple.getUnitId1());
materialMultiple.setUnitId2(materialMultiple.getUnitId2());
materialMultiple.setMaterialSpec(materialMultiple.getMaterialSpec());
return toAjax(materialMultipleService.save(materialMultiple));
}
@Log(title = "包装成品信息入库", action = BusinessType.INSERT)
@PostMapping("/addBarCode")
@ApiOperation("MES下发成品入库接口")
@ResponseBody
@ApiLogger(apiName = "MES下发成品入库接口", from="MES")
public AjaxResult addBarCode(@RequestBody BarCodeDomain barCodeDomain)
{
BarCodeHeader barCodeHeader = barCodeDomain.getBarCodeHeader();
List<BarCodeDetail> barCodeDetails = barCodeDomain.getBarCodeDetails();
if(barCodeHeader == null) {
return AjaxResult.error("包装信息入库,包装信息头为空");
}
if(barCodeDetails == null || barCodeDetails.size() <= 0) {
return AjaxResult.error("包装信息入库,包装信息明细为空");
}
AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
@Override
public AjaxResult doProcess() {
AjaxResult ajaxResult = barCodeApiService.addBarCodeApi(barCodeDomain);
return ajaxResult;
}
});
return ajaxResult;
}
/**
* 查询库存
*/
@PostMapping("/searchInventory")
@ApiOperation("查询库存")
@ResponseBody
@ApiLogger(apiName = "查询库存", from = "MES")
public AjaxResult searchInventory(@RequestBody InventoryMaterialSummary inventoryMaterialSummary) {
LambdaQueryWrapper<InventoryMaterialSummary> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper
.eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getWarehouseCode()),
InventoryMaterialSummary::getWarehouseCode, inventoryMaterialSummary.getWarehouseCode())
//物料编码
.eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getMaterialCode()),
InventoryMaterialSummary::getMaterialCode, inventoryMaterialSummary.getMaterialCode())
//物料名称
.eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getMaterialName()),
InventoryMaterialSummary::getMaterialName, inventoryMaterialSummary.getMaterialName())
.eq(StringUtils.isNotEmpty(inventoryMaterialSummary.getZoneCode()),
InventoryMaterialSummary::getZoneCode, inventoryMaterialSummary.getZoneCode())
.eq(InventoryMaterialSummary::getTaskQty, 0)
//货主
.eq(!StringUtils.isEmpty(inventoryMaterialSummary.getCompanyCode()),
InventoryMaterialSummary::getCompanyCode, inventoryMaterialSummary.getCompanyCode());
List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(lambdaQueryWrapper);
if (list == null) {
list = Collections.emptyList();
}
//筛选库存汇总数据的专用方法
List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);
return AjaxResult.success(details);
}
}