Blame view

src/main/java/com/huaheng/api/general/controller/BasicDataApiController.java 12.9 KB
1
2
package com.huaheng.api.general.controller;
lihailong authored
3
4
5
6
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.domain.BarCodeDomain;
lector authored
7
8
import com.huaheng.api.general.domain.ContainerTypeDomain;
import com.huaheng.api.general.domain.InventoryQueryDomain;
lihailong authored
9
import com.huaheng.api.general.service.BarCodeApiService;
10
import com.huaheng.api.general.service.BasicDataApiService;
lihailong authored
11
import com.huaheng.common.utils.security.ShiroUtils;
周峰 authored
12
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
13
14
15
16
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;
pengcheng authored
17
import com.huaheng.pc.config.containerCapacity.domain.ContainerCapacity;
lector authored
18
import com.huaheng.pc.config.containerType.domain.ContainerType;
19
20
import com.huaheng.pc.config.customer.domain.Customer;
import com.huaheng.pc.config.material.domain.Material;
lihailong authored
21
22
23
24
25
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;
26
27
import com.huaheng.pc.config.supplier.domain.Supplier;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
lihailong authored
28
29
30
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
31
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
lector authored
32
import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
33
34
35
36
37
38
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;
39
import org.springframework.transaction.annotation.Transactional;
40
41
import org.springframework.web.bind.annotation.*;
lihailong authored
42
43
import javax.annotation.Resource;
import java.util.Collections;
lector authored
44
45
import java.util.List;
46
47
@RestController
@RequestMapping("/api/basicData")
xqs authored
48
@Api(tags = {"基础数据接口"}, value = "基础数据接口basicData")
游杰 authored
49
public class BasicDataApiController extends BaseController {
50
51
52

    @Autowired
    private BasicDataApiService basicDataApiService;
lihailong authored
53
54
55
56
57
58
59
60
    @Resource
    private MaterialMultipleServiceImpl materialMultipleService;
    @Resource
    private MaterialService materialService;
    @Resource
    private InventoryMaterialSummaryService inventoryMaterialSummaryService;
    @Resource
    private BarCodeApiService barCodeApiService;
61
62
63
64
65

    /**
     * 同步物料
     */
    @Log(title = "物料添加", action = BusinessType.INSERT)
66
    @PostMapping("/addMaterial")
67
68
    @ApiOperation("物料添加公共接口")
    @ResponseBody
周峰 authored
69
    @ApiLogger(apiName = "添加物料", from="ERP")
70
    public AjaxResult AddMaterialApi(@RequestBody Material material)
71
72
73
74
75
    {
        AjaxResult ajaxResult = basicDataApiService.material(material);
        return ajaxResult;
    }
76
77

    @Log(title = "物料查询", action = BusinessType.INSERT)
78
    @PostMapping("/queryMaterial")
79
80
    @ApiOperation("物料查询公共接口")
    @ResponseBody
周峰 authored
81
    @ApiLogger(apiName = "查询物料", from="ERP")
82
83
84
85
86
87
    public AjaxResult QueryMaterialApi(@RequestBody Material material)
    {
        AjaxResult ajaxResult = basicDataApiService.queryMaterial(material);
        return ajaxResult;
    }
lector authored
88
89
90
91
92
93
94
95
96
97
98
    @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;
    }
99
100
101
102
103
104
105
    /**
     * 同步字典
     */
    @Log(title = "字典添加", action = BusinessType.INSERT)
    @PostMapping("/dictData")
    @ApiOperation("字典添加公共接口")
    @ResponseBody
周峰 authored
106
    @ApiLogger(apiName = "添加字典", from="ERP")
107
108
109
110
111
112
113
114
115
116
117
    public AjaxResult UnitlApi(@RequestBody DictData dictData)
    {
        AjaxResult ajaxResult = basicDataApiService.dict(dictData);
        return ajaxResult;
    }


    /**
     * 同步仓库和货主
     */
    @Log(title = "仓库添加", action = BusinessType.INSERT)
118
    @PostMapping("/addWarehouse")
119
120
    @ApiOperation("仓库添加公共接口")
    @ResponseBody
周峰 authored
121
    @ApiLogger(apiName = "添加仓库", from="ERP")
122
123
124
125
126
127
128
129
130
131
    public AjaxResult WarehouseApi(@RequestBody Warehouse warehouse)
    {
        AjaxResult ajaxResult = basicDataApiService.warehouse(warehouse);
        return ajaxResult;
    }

    /**
     * 同步客户档案
     */
    @Log(title = "客户档案添加", action = BusinessType.INSERT)
lihailong authored
132
    @PostMapping("/addCustomer")
133
134
    @ApiOperation("客户档案添加公共接口")
    @ResponseBody
周峰 authored
135
    @ApiLogger(apiName = "添加客户", from="ERP")
136
137
138
139
140
141
142
143
144
145
    public AjaxResult CustomerApi(@RequestBody Customer customer)
    {
        AjaxResult ajaxResult = basicDataApiService.customer(customer);
        return ajaxResult;
    }

    /**
     * 同步部门档案
     */
    @Log(title = "部门档案添加", action = BusinessType.INSERT)
lihailong authored
146
    @PostMapping("/addDepart")
147
148
    @ApiOperation("部门档案添加公共接口")
    @ResponseBody
周峰 authored
149
    @ApiLogger(apiName = "添加部门", from="ERP")
150
151
152
153
154
155
156
157
158
159
    public AjaxResult DeptApi(@RequestBody Dept dept)
    {
        AjaxResult ajaxResult = basicDataApiService.dept(dept);
        return ajaxResult;
    }

    /**
     * 同步人员档案
     */
    @Log(title = "人员档案添加", action = BusinessType.INSERT)
lihailong authored
160
    @PostMapping("/addUser")
161
162
    @ApiOperation("人员档案添加公共接口")
    @ResponseBody
周峰 authored
163
    @ApiLogger(apiName = "添加人员", from="ERP")
164
165
166
167
168
169
    public AjaxResult UserApi(@RequestBody User user)
    {
        AjaxResult ajaxResult = basicDataApiService.user(user);
        return ajaxResult;
    }
170
171
172
173
174

    @Log(title = "用户同步", action = BusinessType.INSERT)
    @PostMapping("/queryUserApi")
    @ApiOperation("用户查询公共接口")
    @ResponseBody
周峰 authored
175
    @ApiLogger(apiName = "查询用户", from="ERP")
176
177
178
179
180
181
    public AjaxResult queryUserApi(@RequestBody User user)
    {
        AjaxResult ajaxResult = basicDataApiService.queryUser(user);
        return ajaxResult;
    }
182
    /**
pengcheng authored
183
184
185
186
187
188
     * 同步容器容量
     */
    @Log(title = "容器容量添加", action = BusinessType.INSERT)
    @PostMapping("/containerCapacity")
    @ApiOperation("容器容量添加公共接口")
    @ResponseBody
周峰 authored
189
    @ApiLogger(apiName = "添加容器容量", from="ERP")
pengcheng authored
190
191
192
193
194
195
    public AjaxResult containerCapacityApi(@RequestBody ContainerCapacity containerCapacity){
        AjaxResult ajaxResult = basicDataApiService.containerCapacity(containerCapacity);
        return ajaxResult;
    }

    /**
lector authored
196
197
198
199
200
201
202
203
204
205
206
207
208
     * 同步容器类型
     */
    @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;
    }

    /**
209
210
211
     * 同步供应商档案
     */
    @Log(title = "供应商档案添加", action = BusinessType.INSERT)
lihailong authored
212
    @PostMapping("/addSupplier")
213
214
    @ApiOperation("供应商档案添加公共接口")
    @ResponseBody
周峰 authored
215
    @ApiLogger(apiName = "添加供应商", from="ERP")
216
217
218
219
220
221
222
    public AjaxResult SupplierApi(@RequestBody Supplier supplier){
        AjaxResult ajaxResult = basicDataApiService.supplier(supplier);
        return ajaxResult;
    }
223
224
225
226
    @Log(title = "库存同步", action = BusinessType.INSERT)
    @PostMapping("/queryInventoryApi")
    @ApiOperation("库存查询公共接口")
    @ResponseBody
周峰 authored
227
    @ApiLogger(apiName = "查询库存", from="ERP")
228
229
230
231
232
233
234
    public AjaxResult queryInventoryApi(@RequestBody InventoryDetail inventoryDetail)
    {
        AjaxResult ajaxResult = basicDataApiService.queryInventoryApi(inventoryDetail);
        return ajaxResult;
    }
lihailong authored
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
    @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("包装成品入库接口")
    @ResponseBody
    @ApiLogger(apiName = "包装成品入库接口", from="MES")
    public AjaxResult addBarCode(@RequestBody BarCodeDomain barCodeDomain)
    {
        AjaxResult ajaxResult = barCodeApiService.addBarCodeApi(barCodeDomain);
        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);
    }
322
323
324

}