WarehouseAPIService.java
3.7 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
package com.huaheng.api.U8.Service;
import com.huaheng.api.U8.domain.ICSWarehouseModel;
import com.huaheng.api.general.Controller.BasicDataApi;
import com.huaheng.api.general.service.BasicDataApiService;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.company.domain.Company;
import com.huaheng.pc.general.company.domain.WarehouseCompany;
import com.huaheng.pc.general.company.mapper.CompanyMapperAuto;
import com.huaheng.pc.general.company.mapper.WarehouseCompanyMapperAuto;
import com.huaheng.pc.general.company.service.ICompanyService;
import com.huaheng.pc.general.warehouse.domain.Warehouse;
import com.huaheng.pc.general.warehouse.service.IWarehouseService;
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;
import java.util.List;
@Service
public class WarehouseAPIService {
@Autowired
IWarehouseService iWarehouseService;
@Autowired
BasicDataApiService basicDataApiService;
@Resource
private ICompanyService companyService;
@Transactional
public AjaxResult ICSWarehouse(ICSWarehouseModel icsWarehouse) {
Company company=new Company();
company.setCode(icsWarehouse.getCompanyCode());
company=companyService.selectFirstEntity(company);
if(company==null || StringUtils.isEmpty(icsWarehouse.getCompanyCode())){
return AjaxResult.error("没有该货主");
}
Warehouse warehouse = new Warehouse();
warehouse.setCode(icsWarehouse.getcWhCode());
warehouse.setName(icsWarehouse.getcWhName());
warehouse.setCompanyId(company.getId());
warehouse.setUserDef1(icsWarehouse.getFlag());
warehouse.setCreatedBy(ShiroUtils.getLoginName());
warehouse.setCreated(new Date());
warehouse.setLastUpdatedBy(ShiroUtils.getLoginName());
warehouse.setLastUpdated(new Date());
return basicDataApiService.warehouse(warehouse);
}
// 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("更新仓库档案成功!");
// }
// }
// }
}