CustomerAPIService.java
4.3 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
package com.huaheng.api.U8.Service;
import com.huaheng.api.U8.domain.ICSCustomerModel;
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.CompanyWu;
import com.huaheng.pc.general.company.domain.WarehouseCompany;
import com.huaheng.pc.general.company.mapper.WarehouseCompanyMapperAuto;
import com.huaheng.pc.general.company.service.ICompanyService;
import com.huaheng.pc.general.customer.domain.Customer;
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 CustomerAPIService {
// @Autowired
// ICustomerService iCustomerService;
@Resource
private WarehouseCompanyMapperAuto warehouseCompanyMapperAuto;
@Autowired
BasicDataApiService basicDataApiService;
@Autowired
private ICompanyService companyService;
@Transactional
public AjaxResult ICSCustomer(ICSCustomerModel ICSCustomer) {
if(StringUtils.isEmpty(ICSCustomer.getCompanyCode())){
return AjaxResult.error("没有货主信息");
}
CompanyWu companyWu=new CompanyWu();
companyWu.setuCompanyCode(ICSCustomer.getCompanyCode());
companyWu=companyService.selectCompanyWu(companyWu);
if(companyWu==null){
return AjaxResult.error("货主不存在");
}
WarehouseCompany warehouseCompany = new WarehouseCompany();
warehouseCompany.setCompanyCode(companyWu.getCompanyCode());
List<WarehouseCompany> list = warehouseCompanyMapperAuto.selectListEntityByEqual(warehouseCompany);
if (list == null || list.size() == 0) {
return AjaxResult.error("系统中没有该货主:" + warehouseCompany.toString() + " 信息,请先录入货主信息!");
}
AjaxResult ajaxResult=new AjaxResult();
//查询货主有几个仓库,就新增几次
for (WarehouseCompany item : list) {
Customer customer = new Customer();
customer.setWarehouseId(item.getWarehouseId());
customer.setWarehouseCode(item.getWarehouseCode());
customer.setCode(ICSCustomer.getcCusCode());
customer.setName(ICSCustomer.getcCusName());
customer.setAttentionTo(ICSCustomer.getcCusPerson());
customer.setMobile(ICSCustomer.getcCusPhone());
customer.setCreated(new Date());
customer.setCreatedBy(ShiroUtils.getLoginName());
customer.setLastUpdated(new Date());
customer.setLastUpdatedBy(ShiroUtils.getLoginName());
ajaxResult = basicDataApiService.customer(customer);
}
return ajaxResult;
// //判断系统中是否有该客户,若无则新增,有则更新
// if (iCustomerService.selectcode(ICSCustomer.getcCusCode()) == null) {
// result = iCustomerService.insert(customer);
// if (result < 1) {
// return AjaxResult.success("新增客户档案失败");
// } else {
// return AjaxResult.success("新增客户档案成功");
// }
// } else {
// Customer customer = new Customer();
// customer.setWarehouseId(item.getWarehouseId());
// customer.setCode(ICSCustomer.getcCusCode());
// customer.setName(ICSCustomer.getcCusName());
// customer.setAttentionTo(ICSCustomer.getcCusPerson());
// customer.setMobile(ICSCustomer.getcCusPhone());
// customer.setLastUpdated(new Date());
// customer.setLastUpdatedBy(ShiroUtils.getLoginName());
// result = iCustomerService.updateByModel(customer);
// if (result < 1) {
// return AjaxResult.success("更新客户档案失败!");
// } else {
// return AjaxResult.success("更新客户档案成功!");
// }
}
}