BasicDataApiController.java
8.97 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
package com.huaheng.api.general.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.api.general.domain.ContainerTypeDomain;
import com.huaheng.api.general.domain.InventoryQueryDomain;
import com.huaheng.api.general.domain.JindieUser;
import com.huaheng.api.general.service.BasicDataApiService;
import com.huaheng.common.utils.StringUtils;
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.framework.web.domain.RetCode;
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.supplier.domain.Supplier;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
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 lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/basicData")
@Api(tags = {"基础数据接口"}, value = "基础数据接口basicData")
public class BasicDataApiController extends BaseController {
@Autowired
private BasicDataApiService basicDataApiService;
@Autowired
MaterialService materialService;
/**
* 同步物料
*/
@Log(title = "物料添加", action = BusinessType.INSERT)
@PostMapping("/addMaterial")
@ApiOperation("物料添加公共接口")
@ResponseBody
@ApiLogger(apiName = "添加物料", from="ERP")
@Transactional
public AjaxResult AddMaterialApi(@RequestBody List<Material> materials)
{
// materials.forEach((material -> {
// AjaxResult ajaxResult = basicDataApiService.material(material);
// if(ajaxResult.getCode()==RetCode.FAIL.getValue()){
// throw new RuntimeException(ajaxResult.getMsg());
// }
// }));
materials.forEach(material -> {
Material material1 = materialService.getOne(new LambdaQueryWrapper<Material>().eq(Material::getCode, material.getCode()));
if(StringUtils.isNotNull(material1)){
material1.setName(material.getName());
material1.setSpec(material.getSpec());
material1.setType(material.getType());
material1.setUnit(material.getUnit());
materialService.updateById(material1);
}else {
materialService.save(material);
}
});
return AjaxResult.success("物料同步成功");
}
@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("/customer")
@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("/dept")
@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("/user")
@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("/supplier")
@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("/jindieUserAdd")
@ApiOperation("金蝶用户添加")
@ResponseBody
@ApiLogger(apiName = "金蝶用户添加", from="ERP")
public AjaxResult jindieUserAdd(@RequestBody JindieUser jindieUser)
{
AjaxResult ajaxResult = basicDataApiService.jindieUserAdd(jindieUser);
if (ajaxResult.getCode()==RetCode.FAIL.getValue()) {
throw new RuntimeException(ajaxResult.getMsg());
}
return AjaxResult.success("人员同步成功");
}
}