WarehouseApiService.java
4.31 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
package com.huaheng.pc.u8.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.api.general.service.BasicDataApiService;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.company.domain.Company;
import com.huaheng.pc.config.company.domain.CompanyU8;
import com.huaheng.pc.config.company.service.CompanyU8Service;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.config.warehouse.domain.WarehouseU8;
import com.huaheng.pc.config.warehouse.service.WarehouseService;
import com.huaheng.pc.config.warehouse.service.WarehouseU8Service;
import com.huaheng.pc.u8.domain.ICSWarehouseModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
@Service
public class WarehouseApiService {
@Autowired
WarehouseU8Service warehouseU8Service;
@Autowired
BasicDataApiService basicDataApiService;
@Resource
private CompanyU8Service companyU8Service;
@Resource
private WarehouseService warehouseService;
@Transactional
public AjaxResult ICSWarehouse(ICSWarehouseModel icsWarehouse) {
String warehouseCode = icsWarehouse.getWarehouseCode();
if(StringUtils.isEmpty(warehouseCode)){
return AjaxResult.error("warehouseCode不能为空");
}
Warehouse warehouse = warehouseService.getOne(new LambdaQueryWrapper<Warehouse>()
.eq(Warehouse::getCode, warehouseCode));
if(warehouse==null){
return AjaxResult.error("warehouseCode:"+warehouseCode+" 仓库编码错误。");
}
// 查询货主
CompanyU8 companyU8 = companyU8Service.getOne(new LambdaQueryWrapper<CompanyU8>()
.eq(CompanyU8::getWarehouseCode, icsWarehouse.getWarehouseCode())
.eq(CompanyU8::getUCompanyCode, icsWarehouse.getCompanyCode()));
if(companyU8==null || StringUtils.isEmpty(icsWarehouse.getCompanyCode())){
return AjaxResult.error("没有该货主");
}
WarehouseU8 warehouseU8 = new WarehouseU8();
warehouseU8.setUCompanyCode(companyU8.getUCompanyCode());
warehouseU8.setWarehouseCode(companyU8.getWarehouseCode());
warehouseU8.setCompanyCode(companyU8.getCompanyCode());
warehouseU8.setUWarehouseCode(icsWarehouse.getCWhCode());
warehouseU8.setUWarehouseName(icsWarehouse.getCWhName());
boolean save = warehouseU8Service.save(warehouseU8);
return AjaxResult.toAjax(save);
}
// Warehouse warehouse = new Warehouse();
// //查询货主有几个仓库,就新增几次
// for (WarehouseCompany item : list) {
// int result = 0;
// //判断系统中是否有该仓库,若有则更新,若无则新增
// if (iWarehouseService.selectFirstEntity(warehouse) == null) {
// warehouse.setCode(icsWarehouse.getcWhCode());
// warehouse.setName(icsWarehouse.getcWhName());
// warehouse.setCompanyId(item.getCompanyId());
// warehouse.setUserDef1(icsWarehouse.getFlag());
// result = iWarehouseService.insert(warehouse);
// if (result < 1) {
// return AjaxResult.success("新增仓库档案失败!");
// } else {
// return AjaxResult.success("新增仓库档案成功!");
// }
// } else {
// warehouse.setCode(icsWarehouse.getcWhCode());
// warehouse.setName(icsWarehouse.getcWhName());
// warehouse.setUserDef1(icsWarehouse.getFlag());
// warehouse.setCompanyId(item.getCompanyId());
// warehouse.setLastUpdated(new Date());
// result = iWarehouseService.updateByModel(warehouse);
// if (result < 1) {
// return AjaxResult.success("更新仓库档案失败!");
// } else {
// return AjaxResult.success("更新仓库档案成功!");
// }
// }
// }
}