|
|
@@ -12,7 +12,7 @@ import com.shinsoft.sto.model.main.Customer;
|
|
12
|
12
|
import com.shinsoft.sto.service.main.CustomerService;
|
|
13
|
13
|
import com.shinsoft.tools.JSONTools;
|
|
14
|
14
|
import com.shinsoft.tools.model.common.ResponseCodeMsg;
|
|
15
|
|
-import com.shinsoft.tools.model.common.ResultJSON;
|
|
|
15
|
+import com.shinsoft.sto.model.system.ResultJSON;
|
|
16
|
16
|
import org.apache.commons.lang3.StringUtils;
|
|
17
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
18
|
18
|
import org.springframework.stereotype.Service;
|
|
|
@@ -61,35 +61,41 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
|
|
61
|
61
|
}
|
|
62
|
62
|
|
|
63
|
63
|
Page<Customer> list = customerMapper.selectPage(customerPage, queryWrapper);
|
|
64
|
|
- resultJSON = JSONTools.toResultJSON(list);
|
|
|
64
|
+ resultJSON = ResultJSON.success(list);
|
|
65
|
65
|
return resultJSON;
|
|
66
|
66
|
}
|
|
67
|
67
|
|
|
68
|
68
|
@Override
|
|
69
|
69
|
public ResultJSON queryByPK(String id) {
|
|
70
|
70
|
Customer customer = customerMapper.selectById(id);
|
|
71
|
|
- resultJSON = JSONTools.toResultJSON(customer);
|
|
|
71
|
+ resultJSON = ResultJSON.success(customer);
|
|
72
|
72
|
return resultJSON;
|
|
73
|
73
|
}
|
|
74
|
74
|
|
|
75
|
75
|
@Override
|
|
76
|
|
- public ResultJSON save(String userId, String json) {
|
|
|
76
|
+ public ResultJSON save(String userId,String belongId, String json) {
|
|
77
|
77
|
Date date = new Date();
|
|
|
78
|
+ boolean success;
|
|
78
|
79
|
Customer customer = JSON.parseObject(json, new TypeReference<Customer>() {
|
|
79
|
80
|
});
|
|
80
|
81
|
if (StringUtils.isEmpty(customer.getId())) {
|
|
|
82
|
+ //增加插入校验,相同客户名称的信息只能保存一条
|
|
|
83
|
+ //增加限制的原因为:入库批量导入的时候使用到的客户名称进行查询赋值,如果出现两条一样的会出现错误
|
|
81
|
84
|
customer.setCancelFlag("0");
|
|
82
|
85
|
customer.setAddId(userId);
|
|
83
|
86
|
customer.setAddTime(date);
|
|
84
|
|
- customerMapper.insert(customer);
|
|
|
87
|
+
|
|
|
88
|
+ List<Customer> customers = customerMapper.selectByName(customer.getCustomerNm(), customer.getCustomerShortNm(), belongId);
|
|
|
89
|
+ if (customers != null && !customers.isEmpty()) {
|
|
|
90
|
+ return ResultJSON.error("客户名称或简称已存在,请勿重复添加");
|
|
|
91
|
+ }
|
|
|
92
|
+ success = customerMapper.insert(customer)> 0;
|
|
85
|
93
|
} else {
|
|
86
|
94
|
customer.setModifyId(userId);
|
|
87
|
95
|
customer.setModifyTime(date);
|
|
88
|
|
- customerMapper.updateById(customer);
|
|
|
96
|
+ success = customerMapper.updateById(customer)> 0;
|
|
89
|
97
|
}
|
|
90
|
|
-
|
|
91
|
|
- resultJSON = JSONTools.toResultJSON(customer);
|
|
92
|
|
- return resultJSON;
|
|
|
98
|
+ return success ? ResultJSON.success("新增成功") : ResultJSON.error("新增失败");
|
|
93
|
99
|
}
|
|
94
|
100
|
|
|
95
|
101
|
@Override
|
|
|
@@ -100,7 +106,7 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
|
|
100
|
106
|
customer.setModifyId(userId);
|
|
101
|
107
|
customer.setModifyTime(date);
|
|
102
|
108
|
customerMapper.updateById(customer);
|
|
103
|
|
- resultJSON = JSONTools.toResultJSON("");
|
|
|
109
|
+ resultJSON = ResultJSON.success("");
|
|
104
|
110
|
return resultJSON;
|
|
105
|
111
|
}
|
|
106
|
112
|
|
|
|
@@ -117,7 +123,7 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
|
|
117
|
123
|
customer.setModifyTime(date);
|
|
118
|
124
|
customerMapper.updateById(customer);
|
|
119
|
125
|
}
|
|
120
|
|
- resultJSON = JSONTools.toResultJSON("");
|
|
|
126
|
+ resultJSON = ResultJSON.success("");
|
|
121
|
127
|
return resultJSON;
|
|
122
|
128
|
}
|
|
123
|
129
|
|
|
|
@@ -125,11 +131,11 @@ public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> im
|
|
125
|
131
|
public ResultJSON querySelect(String belongId) {
|
|
126
|
132
|
try {
|
|
127
|
133
|
List<selectModel> list = customerMapper.selectCustomerOptions(belongId);
|
|
128
|
|
- resultJSON = JSONTools.toResultJSON(list);
|
|
|
134
|
+ resultJSON = ResultJSON.success(list);
|
|
129
|
135
|
return resultJSON;
|
|
130
|
136
|
} catch (Exception ex) {
|
|
131
|
137
|
ex.printStackTrace();
|
|
132
|
|
- resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
|
|
|
138
|
+ resultJSON = ResultJSON.error("查询失败");
|
|
133
|
139
|
return resultJSON;
|
|
134
|
140
|
}
|
|
135
|
141
|
}
|