|
|
@@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory;
|
|
16
|
16
|
import org.springframework.beans.factory.annotation.Value;
|
|
17
|
17
|
import org.springframework.stereotype.Service;
|
|
18
|
18
|
|
|
|
19
|
+import com.alibaba.fastjson.JSON;
|
|
|
20
|
+import com.alibaba.fastjson.JSONArray;
|
|
19
|
21
|
import com.alibaba.fastjson.JSONObject;
|
|
20
|
22
|
import com.chinaitop.depot.business.mapper.BusinessNoticeReceiveMapper;
|
|
21
|
23
|
import com.chinaitop.depot.business.model.BusinessApproval;
|
|
|
@@ -70,21 +72,21 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
70
|
72
|
BusinessNoticeReceiveExample example = new BusinessNoticeReceiveExample();
|
|
71
|
73
|
Criteria createCriteria = example.createCriteria();
|
|
72
|
74
|
|
|
73
|
|
- if(lyflag!=null){
|
|
74
|
|
- if(lyflag.equals("0")){//油
|
|
|
75
|
+ if (lyflag != null) {
|
|
|
76
|
+ if (lyflag.equals("0") ){//油
|
|
75
|
77
|
createCriteria.andHouseIdIsNotNull();
|
|
76
|
78
|
createCriteria.andWareHouseIdIsNull();
|
|
77
|
|
- }else if(lyflag.equals("1")){//粮
|
|
|
79
|
+ } else if (lyflag.equals("1")) {//粮
|
|
78
|
80
|
createCriteria.andHouseIdIsNotNull();
|
|
79
|
81
|
createCriteria.andWareHouseIdIsNotNull();
|
|
80
|
82
|
}
|
|
81
|
|
- }else{
|
|
|
83
|
+ } else {
|
|
82
|
84
|
//仓房
|
|
83
|
|
- if(businessNoticeReceive.getHouseId()!=null){
|
|
|
85
|
+ if (businessNoticeReceive.getHouseId() != null) {
|
|
84
|
86
|
createCriteria.andHouseIdEqualTo(businessNoticeReceive.getHouseId());
|
|
85
|
87
|
}
|
|
86
|
88
|
//货位
|
|
87
|
|
- if(businessNoticeReceive.getWareHouseId()!=null){
|
|
|
89
|
+ if (businessNoticeReceive.getWareHouseId() != null) {
|
|
88
|
90
|
createCriteria.andWareHouseIdEqualTo(businessNoticeReceive.getWareHouseId());
|
|
89
|
91
|
}
|
|
90
|
92
|
}
|
|
|
@@ -94,12 +96,12 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
94
|
96
|
createCriteria.andCrktypeEqualTo(businessNoticeReceive.getCrktype());
|
|
95
|
97
|
}
|
|
96
|
98
|
//业务类型 竞买 销售 轮换
|
|
97
|
|
- if(cktzd!=null && cktzd.equals("0")){
|
|
98
|
|
- if(businessNoticeReceive.getYwtype()!=null && businessNoticeReceive.getYwtype()!=""){
|
|
99
|
|
- createCriteria.andYwtypeNotEqualTo(businessNoticeReceive.getYwtype());
|
|
|
99
|
+ if (cktzd!=null && cktzd.equals("0")) {
|
|
|
100
|
+ if (StringUtils.isNotBlank(businessNoticeReceive.getYwtype())) {
|
|
|
101
|
+ createCriteria.andYwtypeNotEqualTo(businessNoticeReceive.getYwtype());//查ywtype!=1的数据
|
|
100
|
102
|
}
|
|
101
|
|
- }else{
|
|
102
|
|
- if(businessNoticeReceive.getYwtype()!=null && businessNoticeReceive.getYwtype()!=""){
|
|
|
103
|
+ } else {
|
|
|
104
|
+ if (businessNoticeReceive.getYwtype() != null && businessNoticeReceive.getYwtype()!=""){
|
|
103
|
105
|
createCriteria.andYwtypeEqualTo(businessNoticeReceive.getYwtype());
|
|
104
|
106
|
}
|
|
105
|
107
|
}
|
|
|
@@ -170,7 +172,7 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
170
|
172
|
|
|
171
|
173
|
Map<String, Object> modelMap = new HashMap<String, Object>();
|
|
172
|
174
|
|
|
173
|
|
- if(notice!=null){
|
|
|
175
|
+ if (notice != null) {
|
|
174
|
176
|
// JSON字符串转对象
|
|
175
|
177
|
JSONObject jsonObject = JSONObject.parseObject(notice);
|
|
176
|
178
|
BusinessNoticeReceive businessNoticeReceive = new BusinessNoticeReceive();
|
|
|
@@ -186,19 +188,19 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
186
|
188
|
createCriteria.andNoticeNumberEqualTo(jsonObject.getString("tzdid"));
|
|
187
|
189
|
List<BusinessNoticeReceive> selectByExample = businessNoticeReceiveMapper.selectByExample(example);
|
|
188
|
190
|
|
|
189
|
|
- if(selectByExample.size()>0){//存在修改
|
|
|
191
|
+ if(selectByExample.size()>0){//存在修改(只修改出库期限)
|
|
190
|
192
|
BusinessNoticeReceive record = new BusinessNoticeReceive();
|
|
191
|
193
|
record.setId(selectByExample.get(0).getId());
|
|
192
|
194
|
record.setOutgoingPeriod(jsonObject.getString("ckqx"));
|
|
193
|
195
|
int k = businessNoticeReceiveMapper.updateByPrimaryKeySelective(record);
|
|
194
|
196
|
if(k<0){
|
|
|
197
|
+ modelMap.put("msg", "没有通知单编号为"+jsonObject.getString("tzdid")+"的数据");
|
|
195
|
198
|
modelMap.put("status", "error");
|
|
196
|
199
|
}
|
|
197
|
200
|
}else{
|
|
198
|
201
|
/**
|
|
199
|
202
|
* 新增
|
|
200
|
203
|
*/
|
|
201
|
|
-
|
|
202
|
204
|
if(jsonObject.getString("tzdlx")!=null && jsonObject.getString("ywlx")!=null){
|
|
203
|
205
|
if(ObjectUtils.toString(jsonObject.getString("tzdlx")).equals("01")){ //出入库类型(01:出库 02:入库 03:出入库)
|
|
204
|
206
|
businessNoticeReceive.setCrktype("3"); //1入 3出
|
|
|
@@ -209,14 +211,25 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
209
|
211
|
}else if(ObjectUtils.toString(jsonObject.getString("tzdlx")).equals("03")){
|
|
210
|
212
|
businessNoticeReceive.setCrktype("13"); //1入 3出
|
|
211
|
213
|
businessNoticeReceive.setForwardingUnit(jsonObject.getString("khssyqmc")); //发货单位
|
|
|
214
|
+ } else {
|
|
|
215
|
+ modelMap.put("msg", "未识别的通知单类型");
|
|
|
216
|
+ modelMap.put("status", "error");
|
|
|
217
|
+ return modelMap;
|
|
212
|
218
|
}
|
|
213
|
219
|
|
|
214
|
|
- if(ObjectUtils.toString(jsonObject.getString("ywlx")).equals("6")){ //业务类型 (6:竞买=入库竞价;7:销售=出库竞价 4:轮换=出库包干)
|
|
|
220
|
+ //业务类型 (3:兜底,4:轮换=出库包干,6:竞买=入库竞价,7:销售=出库竞价 )
|
|
|
221
|
+ if (ObjectUtils.toString(jsonObject.getString("ywlx")).equals("6")) { //业务类型 (6:竞买=入库竞价;7:销售=出库竞价 4:轮换=出库包干)
|
|
215
|
222
|
businessNoticeReceive.setYwtype("1"); //1收储=竞买=竞价 2 销售=竞价 3轮换=包干
|
|
216
|
|
- }else if (ObjectUtils.toString(jsonObject.getString("ywlx")).equals("4")){
|
|
|
223
|
+ } else if (ObjectUtils.toString(jsonObject.getString("ywlx")).equals("4")){//4:轮换=出库包干
|
|
217
|
224
|
businessNoticeReceive.setYwtype("3");
|
|
218
|
|
- }else if (ObjectUtils.toString(jsonObject.getString("ywlx")).equals("7")){
|
|
|
225
|
+ }else if (ObjectUtils.toString(jsonObject.getString("ywlx")).equals("7")){//7:销售=出库竞价
|
|
219
|
226
|
businessNoticeReceive.setYwtype("2");
|
|
|
227
|
+ } else if (ObjectUtils.toString(jsonObject.getString("ywlx")).equals("3")){//兜底
|
|
|
228
|
+ businessNoticeReceive.setYwtype("4");
|
|
|
229
|
+ } else {
|
|
|
230
|
+ modelMap.put("msg", "未识别的业务类型");
|
|
|
231
|
+ modelMap.put("status", "error");
|
|
|
232
|
+ return modelMap;
|
|
220
|
233
|
}
|
|
221
|
234
|
|
|
222
|
235
|
businessNoticeReceive.setContractNumber(jsonObject.getString("sshtbm")); //协议编号/合同编号
|
|
|
@@ -236,7 +249,7 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
236
|
249
|
|
|
237
|
250
|
modelMap.put("msg", "根据值"+hwbm+"未获取到对应仓房货位信息,请核对数据");
|
|
238
|
251
|
modelMap.put("status", "error");
|
|
239
|
|
-
|
|
|
252
|
+ return modelMap;
|
|
240
|
253
|
} else {
|
|
241
|
254
|
Integer houseId = (Integer) wareDataMap.get("houseId");
|
|
242
|
255
|
Integer wareHouseId = (Integer) wareDataMap.get("wareHouseId");
|
|
|
@@ -246,20 +259,75 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
246
|
259
|
businessNoticeReceive.setWareHouseId(wareHouseId); //货位
|
|
247
|
260
|
}
|
|
248
|
261
|
businessNoticeReceive.setOrgId(orgId); //组织id
|
|
249
|
|
- if(ObjectUtils.toString(jsonObject.getString("ywlx")).equals("6")){//入库竞价的业务类型
|
|
250
|
|
- if(jsonObject.getString("pz")!=null){
|
|
251
|
|
- String code = jsonObject.getString("pzbm");//品种编码
|
|
252
|
|
- if (StringUtils.isNotBlank(code)) {
|
|
253
|
|
- code = code.substring(0,3);//获取前三位
|
|
254
|
|
- Map<String, Object> basicMap = feignBasicService.getIdByNameAndParentId(1061, null, code);//1061是粮食品种的父ID
|
|
255
|
|
- logger.info("获取到的品种数据如下:");
|
|
256
|
|
- logger.info(basicMap.toString());
|
|
257
|
|
- businessNoticeReceive.setGrainKind((Integer) basicMap.get("enumId")); //接收的品种大类
|
|
258
|
|
- }
|
|
|
262
|
+ if (ObjectUtils.toString(jsonObject.getString("tzdlx")).equals("02")) {//入库类型
|
|
|
263
|
+ String pzbm = jsonObject.getString("pzbm");//品种编码
|
|
|
264
|
+ if (StringUtils.isNotBlank(pzbm)) {
|
|
|
265
|
+ String lypz = null;
|
|
|
266
|
+ if ("2130000".equals(pzbm) || "1410000".equals(pzbm)) {//原油
|
|
|
267
|
+ logger.info("根据品种编码"+pzbm+"获取到的品种数据如下:");
|
|
|
268
|
+ logger.info("原油对应的字典ID是:7144");
|
|
|
269
|
+ lypz = "7144";
|
|
|
270
|
+ } else {
|
|
|
271
|
+ Map<String, Object> basicMap = feignBasicService.getIdByNameAndParentId(1061, null, pzbm);
|
|
|
272
|
+ lypz = basicMap.get("enumId")+"";
|
|
|
273
|
+ logger.info("根据"+pzbm+"获取到的品种数据如下:");
|
|
|
274
|
+ logger.info(basicMap.toString());
|
|
|
275
|
+ }
|
|
|
276
|
+ if (StringUtils.isNotBlank(lypz)) {
|
|
|
277
|
+ businessNoticeReceive.setGrainKind(Integer.parseInt(lypz));
|
|
|
278
|
+ } else {
|
|
|
279
|
+ modelMap.put("msg", "pzbm--"+pzbm+"--有误或不合理");
|
|
|
280
|
+ modelMap.put("status", "error");
|
|
|
281
|
+ return modelMap;
|
|
|
282
|
+ }
|
|
|
283
|
+ } else {
|
|
|
284
|
+ modelMap.put("msg", "pzbm不能为空");
|
|
|
285
|
+ modelMap.put("status", "error");
|
|
|
286
|
+ return modelMap;
|
|
|
287
|
+ }
|
|
|
288
|
+
|
|
|
289
|
+ String mxbm = jsonObject.getString("mxbm");//明细品种编码
|
|
|
290
|
+ if (StringUtils.isNotBlank(mxbm)) {
|
|
|
291
|
+ String mxpz = null;
|
|
|
292
|
+ if ("2130000".equals(mxbm) || "1410000".equals(mxbm)) {//原油下的明细下只用大豆原油
|
|
|
293
|
+ logger.info("根据明细品种编码"+mxbm+"获取到的明细品种数据如下:");
|
|
|
294
|
+ logger.info("原油明细品种对应的字典ID是:7145");
|
|
|
295
|
+ mxpz = "7145";
|
|
|
296
|
+ } else {
|
|
|
297
|
+ Integer enumid = getEnumId(businessNoticeReceive.getGrainKind(), mxbm);
|
|
|
298
|
+ mxpz = enumid+"";
|
|
|
299
|
+ logger.info("根据"+mxbm+"获取到的明细品种数据是:"+enumid);
|
|
|
300
|
+ }
|
|
|
301
|
+ if (StringUtils.isNotBlank(mxpz)) {
|
|
|
302
|
+ businessNoticeReceive.setGrainDetailKind(Integer.parseInt(mxpz));
|
|
|
303
|
+ } else {
|
|
|
304
|
+ modelMap.put("msg", "mxbm--"+mxbm+"--有误或不合理");
|
|
|
305
|
+ modelMap.put("status", "error");
|
|
|
306
|
+ return modelMap;
|
|
|
307
|
+ }
|
|
|
308
|
+ } else {
|
|
|
309
|
+ modelMap.put("msg", "mxbm不能为空");
|
|
|
310
|
+ modelMap.put("status", "error");
|
|
|
311
|
+ return modelMap;
|
|
259
|
312
|
}
|
|
260
|
|
- }else{
|
|
|
313
|
+
|
|
|
314
|
+ String scndbm = jsonObject.getString("scnf");//生产年度
|
|
|
315
|
+ if (StringUtils.isNotBlank(mxbm)) {
|
|
|
316
|
+ String scnf = null;
|
|
|
317
|
+ Map<String, Object> basicMap = feignBasicService.getIdByNameAndParentId(1004, scndbm, null);
|
|
|
318
|
+ scnf = basicMap.get("enumId")+"";
|
|
|
319
|
+ logger.info("根据"+scndbm+"获取到的生产年份数据如下:");
|
|
|
320
|
+ logger.info(basicMap.toString());
|
|
|
321
|
+ if (StringUtils.isNotBlank(scnf)) {
|
|
|
322
|
+ businessNoticeReceive.setProductiveYear(Integer.parseInt(scnf));//生产年份
|
|
|
323
|
+ businessNoticeReceive.setGrainAnnual(Integer.parseInt(scnf));//收获年度
|
|
|
324
|
+ }
|
|
|
325
|
+ }
|
|
|
326
|
+ } else {
|
|
261
|
327
|
//根据仓房、货位、orgId获取粮食品种等信息
|
|
262
|
328
|
Map<String, Object> map = feignAgileService.getDateByChHwh(orgId, houseId, wareHouseId);
|
|
|
329
|
+ logger.info("根据orgId="+orgId+",houseId="+houseId+",warehouseId="+wareHouseId+" 获取到的库存数据如下:");
|
|
|
330
|
+ logger.info(map+"");
|
|
263
|
331
|
grainAttribute = (Integer) map.get("hwxz"); //粮油性质
|
|
264
|
332
|
grainKind = (Integer) map.get("pz"); //品种
|
|
265
|
333
|
Integer grainDetailKind = (Integer) map.get("mxpz"); //明细品种
|
|
|
@@ -299,11 +367,6 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
299
|
367
|
|
|
300
|
368
|
}
|
|
301
|
369
|
String lsyqsl = jsonObject.getString("lsyqsl");
|
|
302
|
|
-// BigDecimal s = new BigDecimal(1000);
|
|
303
|
|
-// BigDecimal sumjhsl = new BigDecimal(lsyqsl);
|
|
304
|
|
-// BigDecimal sumCkslss = sumjhsl.multiply(s);
|
|
305
|
|
- //String count = sumCkslss.toString(); //吨转化为公斤
|
|
306
|
|
-
|
|
307
|
370
|
businessNoticeReceive.setCount(lsyqsl); //计划数量(吨)
|
|
308
|
371
|
businessNoticeReceive.setOutgoingPeriod(jsonObject.getString("ckqx")); //出库期限(日期格式)
|
|
309
|
372
|
|
|
|
@@ -328,7 +391,7 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
328
|
391
|
}
|
|
329
|
392
|
|
|
330
|
393
|
|
|
331
|
|
- }else{
|
|
|
394
|
+ } else {
|
|
332
|
395
|
modelMap.put("msg", "所传数据不能为空");
|
|
333
|
396
|
modelMap.put("status", "error");
|
|
334
|
397
|
}
|
|
|
@@ -336,7 +399,30 @@ public class ReceiveNoticeServiceImpl implements ReceiveNoticeService {
|
|
336
|
399
|
return modelMap;
|
|
337
|
400
|
}
|
|
338
|
401
|
|
|
339
|
|
-
|
|
|
402
|
+ /**
|
|
|
403
|
+ * 根据字典父级ID和国标编码获取下面的一个字典ID
|
|
|
404
|
+ * @param parentId
|
|
|
405
|
+ * @param gbCode
|
|
|
406
|
+ * @return
|
|
|
407
|
+ */
|
|
|
408
|
+ private Integer getEnumId(int parentId, String gbCode) {
|
|
|
409
|
+ Integer enumId = null;
|
|
|
410
|
+ Map<String, Object> map = feignBasicService.findConditionEnum(parentId, null, null);
|
|
|
411
|
+ if (null != map) {
|
|
|
412
|
+ String json_str = JSON.toJSONString(map);
|
|
|
413
|
+ JSONObject json_obj = JSONObject.parseObject(json_str);
|
|
|
414
|
+ JSONArray array = JSONArray.parseArray(json_obj.getString("enumList"));
|
|
|
415
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
416
|
+ JSONObject object = JSONObject.parseObject(array.get(i).toString());
|
|
|
417
|
+ String code = object.getString("gbcode");
|
|
|
418
|
+ if (code.equals(gbCode)) {
|
|
|
419
|
+ enumId = Integer.parseInt(object.getString("id"));
|
|
|
420
|
+ break;
|
|
|
421
|
+ }
|
|
|
422
|
+ }
|
|
|
423
|
+ }
|
|
|
424
|
+ return enumId;
|
|
|
425
|
+ }
|
|
340
|
426
|
|
|
341
|
427
|
@Override
|
|
342
|
428
|
public List<BusinessNoticeReceive> queryByExample(BusinessNoticeReceive businessNoticeReceive) {
|