|
|
@@ -11,6 +11,7 @@ import javax.annotation.Resource;
|
|
11
|
11
|
|
|
12
|
12
|
import org.apache.commons.lang.StringUtils;
|
|
13
|
13
|
import org.springframework.stereotype.Service;
|
|
|
14
|
+import org.springframework.transaction.annotation.Transactional;
|
|
14
|
15
|
|
|
15
|
16
|
import com.alibaba.fastjson.JSONObject;
|
|
16
|
17
|
import com.chinaitop.depot.business.mapper.BusinessContractReceiveMapper;
|
|
|
@@ -19,6 +20,7 @@ import com.chinaitop.depot.business.model.BusinessContractReceiveExample;
|
|
19
|
20
|
import com.chinaitop.depot.business.model.BusinessContractReceiveExample.Criteria;
|
|
20
|
21
|
import com.chinaitop.depot.business.service.BusinessContractReceiveService;
|
|
21
|
22
|
import com.chinaitop.depot.business.service.FeignBasicService;
|
|
|
23
|
+import com.chinaitop.depot.feignService.DepotKeeperAccountFeignService;
|
|
22
|
24
|
|
|
23
|
25
|
@Service
|
|
24
|
26
|
@SuppressWarnings("all")
|
|
|
@@ -30,7 +32,11 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
30
|
32
|
@Resource
|
|
31
|
33
|
private FeignBasicService feignBasicService;
|
|
32
|
34
|
|
|
|
35
|
+ @Resource
|
|
|
36
|
+ private DepotKeeperAccountFeignService feigenKeeperAccountService;
|
|
|
37
|
+
|
|
33
|
38
|
@Override
|
|
|
39
|
+ @Transactional(rollbackFor = Exception.class)
|
|
34
|
40
|
public Map<String, String> receiveContractData(String data) throws Exception {
|
|
35
|
41
|
Map<String, String> resultMap = new HashMap<>();
|
|
36
|
42
|
if (StringUtils.isBlank(data)) {
|
|
|
@@ -46,11 +52,13 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
46
|
52
|
resultMap.put("msg", msg);
|
|
47
|
53
|
return resultMap;
|
|
48
|
54
|
} else {
|
|
49
|
|
- //保存数据
|
|
50
|
|
- List<BusinessContractReceive> list = (List<BusinessContractReceive>) check_map.get("ware_list");
|
|
51
|
|
- for (BusinessContractReceive b : list) {
|
|
52
|
|
- businessContractReceiveMapper.insert(b);
|
|
53
|
|
- }
|
|
|
55
|
+ //保存合同数据
|
|
|
56
|
+ BusinessContractReceive obj_map = (BusinessContractReceive) check_map.get("ware_list");
|
|
|
57
|
+ businessContractReceiveMapper.insert(obj_map);
|
|
|
58
|
+
|
|
|
59
|
+ //处理客户信息数据
|
|
|
60
|
+ editCustomer(obj_map.getOrgId(), obj_map.getKhmc());
|
|
|
61
|
+
|
|
54
|
62
|
resultMap.put("status", "200");
|
|
55
|
63
|
resultMap.put("msg", "推送成功");
|
|
56
|
64
|
}
|
|
|
@@ -100,7 +108,7 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
100
|
108
|
if (StringUtils.isNotBlank(lspz)) {
|
|
101
|
109
|
dataobj.setLypz(Integer.parseInt(lspz));
|
|
102
|
110
|
} else {
|
|
103
|
|
- sbf.append("粮食品种的值"+pz+"有误,");
|
|
|
111
|
+ sbf.append("粮食品种的值"+pz+"有误或不合理,");
|
|
104
|
112
|
}
|
|
105
|
113
|
} else {
|
|
106
|
114
|
sbf.append("粮食品种不能为空,");
|
|
|
@@ -108,12 +116,13 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
108
|
116
|
String mxpz = obj.getString("mxpz");
|
|
109
|
117
|
if (StringUtils.isNotBlank(mxpz)) {
|
|
110
|
118
|
if (null != dataobj.getLypz()) {
|
|
111
|
|
- Map<String, Object> basicMap = feignBasicService.getIdByNameAndParentId(dataobj.getLypz(), null, pz);
|
|
|
119
|
+ mxpz = mxpz.replace(" ", "");
|
|
|
120
|
+ Map<String, Object> basicMap = feignBasicService.getIdByNameAndParentId(dataobj.getLypz(), null, mxpz);
|
|
112
|
121
|
String lsmxpz = basicMap.get("enumId")+"";
|
|
113
|
122
|
if (StringUtils.isNotBlank(lsmxpz)) {
|
|
114
|
123
|
dataobj.setMxpz(Integer.parseInt(lsmxpz));
|
|
115
|
124
|
} else {
|
|
116
|
|
- sbf.append("粮食明细品种的值"+mxpz+"有误,");
|
|
|
125
|
+ sbf.append("粮食明细品种的值"+mxpz+"有误或不合理,");
|
|
117
|
126
|
}
|
|
118
|
127
|
}
|
|
119
|
128
|
} else {
|
|
|
@@ -121,12 +130,13 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
121
|
130
|
}
|
|
122
|
131
|
String lydj = obj.getString("dj");
|
|
123
|
132
|
if (StringUtils.isNotBlank(lydj)) {
|
|
|
133
|
+ lydj = lydj.replace(" ", "");
|
|
124
|
134
|
Map<String, Object> basicMap = feignBasicService.getIdByNameAndParentId(1002, null, lydj);
|
|
125
|
135
|
String dj = basicMap.get("enumId")+"";
|
|
126
|
136
|
if (StringUtils.isNotBlank(dj)) {
|
|
127
|
137
|
dataobj.setLydj(Integer.parseInt(dj));
|
|
128
|
138
|
} else {
|
|
129
|
|
- sbf.append("粮食等级的值"+lydj+"有误,");
|
|
|
139
|
+ sbf.append("粮食等级的值"+lydj+"有误或不合理,");
|
|
130
|
140
|
}
|
|
131
|
141
|
} else {
|
|
132
|
142
|
sbf.append("粮食等级不能为空,");
|
|
|
@@ -158,33 +168,21 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
158
|
168
|
}
|
|
159
|
169
|
String khmc = obj.getString("khmc");
|
|
160
|
170
|
if (StringUtils.isNotBlank(khmc)) {
|
|
161
|
|
- dataobj.setKhmc(khmc.trim());
|
|
|
171
|
+ dataobj.setKhmc(khmc.replace(" ", "").trim());
|
|
162
|
172
|
} else {
|
|
163
|
173
|
sbf.append("客户名称不能为空,");
|
|
164
|
174
|
}
|
|
165
|
|
- String tyxydm = obj.getString("khzjh");
|
|
166
|
|
- if (StringUtils.isNotBlank(tyxydm)) {
|
|
167
|
|
- dataobj.setTyxydm(tyxydm.trim());
|
|
168
|
|
- } else {
|
|
169
|
|
- sbf.append("客户证件号不能为空,");
|
|
170
|
|
- }
|
|
171
|
|
- String hw_sptid = obj.getString("hwbm");//getWareOrTankObj
|
|
|
175
|
+ String hw_sptid = obj.getString("hwbm");//市平台货物数据主键ID
|
|
172
|
176
|
if (StringUtils.isNotBlank(hw_sptid)) {
|
|
173
|
|
- String []id_nums = hw_sptid.split(",");
|
|
174
|
|
- BusinessContractReceive num_data = null;
|
|
175
|
|
- for (String id : id_nums) {
|
|
176
|
|
- Map<String, Object> basicMap = feignBasicService.getWareOrTankObj(id);
|
|
177
|
|
- if (!"0".equals(basicMap.get("houseId")) && !"0".equals(basicMap.get("warehouseId")) && !"0".equals(basicMap.get("orgId"))) {
|
|
178
|
|
- num_data = dataobj;
|
|
179
|
|
- num_data.setHouseId(Integer.parseInt(basicMap.get("houseId").toString()));
|
|
180
|
|
- num_data.setWarehouseId(Integer.parseInt(basicMap.get("warehouseId").toString()));
|
|
181
|
|
- num_data.setOrgId(Integer.parseInt(basicMap.get("orgId").toString()));
|
|
182
|
|
- num_data.setInputTime(new Date());
|
|
183
|
|
- num_data.setUpdateTime(num_data.getInputTime());
|
|
184
|
|
- list.add(num_data);
|
|
185
|
|
- } else {
|
|
186
|
|
- sbf.append("hwbm的值"+id+"异常,");
|
|
187
|
|
- }
|
|
|
177
|
+ Map<String, Object> basicMap = feignBasicService.getWareOrTankObj(hw_sptid);
|
|
|
178
|
+ if (!"0".equals(basicMap.get("houseId")) && !"0".equals(basicMap.get("warehouseId")) && !"0".equals(basicMap.get("orgId"))) {
|
|
|
179
|
+ dataobj.setHouseId(Integer.parseInt(basicMap.get("houseId").toString()));
|
|
|
180
|
+ dataobj.setWarehouseId(Integer.parseInt(basicMap.get("warehouseId").toString()));
|
|
|
181
|
+ dataobj.setOrgId(Integer.parseInt(basicMap.get("orgId").toString()));
|
|
|
182
|
+ dataobj.setInputTime(new Date());
|
|
|
183
|
+ dataobj.setUpdateTime(dataobj.getInputTime());
|
|
|
184
|
+ } else {
|
|
|
185
|
+ sbf.append("未查询到hwbm的值对应的货位数据,");
|
|
188
|
186
|
}
|
|
189
|
187
|
} else {
|
|
190
|
188
|
sbf.append("hwbm的值不能为空,");
|
|
|
@@ -192,7 +190,7 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
192
|
190
|
|
|
193
|
191
|
Map<String, Object> resultMap = new HashMap<>();
|
|
194
|
192
|
resultMap.put("msg", sbf.toString());
|
|
195
|
|
- resultMap.put("data", list);
|
|
|
193
|
+ resultMap.put("data", dataobj);
|
|
196
|
194
|
|
|
197
|
195
|
return resultMap;
|
|
198
|
196
|
}
|
|
|
@@ -226,4 +224,17 @@ public class BusinessContractReceiveServiceImpl implements BusinessContractRecei
|
|
226
|
224
|
return businessContractReceive;
|
|
227
|
225
|
}
|
|
228
|
226
|
|
|
|
227
|
+ private void editCustomer(Integer orgId, String customerName) throws Exception {
|
|
|
228
|
+ String flag = feigenKeeperAccountService.checkRepeat(orgId, 3153, customerName);
|
|
|
229
|
+
|
|
|
230
|
+ if ("true".equals(flag)) {//说明这个客户没再库级维护
|
|
|
231
|
+ JSONObject json = new JSONObject();
|
|
|
232
|
+ json.put("name", customerName);
|
|
|
233
|
+ json.put("sfwz", "1");
|
|
|
234
|
+ Map<String, Object> modelMap = feigenKeeperAccountService.save(json.toString(), orgId);
|
|
|
235
|
+ if ("error".equals(modelMap.get("status"))) {
|
|
|
236
|
+ throw new Exception("不完整客户保存异常");
|
|
|
237
|
+ }
|
|
|
238
|
+ }
|
|
|
239
|
+ }
|
|
229
|
240
|
}
|