Przeglądaj źródła

仓房已选逻辑优化

lfy 3 tygodni temu
rodzic
commit
2ddc9ea7a8

+ 0 - 8
delivery-module-core/delivery-module-core-biz/src/main/java/com/unis/module/coding/dal/dataobject/dwxx/DwxxDO.java

@@ -99,10 +99,6 @@ public class DwxxDO extends BaseDO {
99 99
      * 审核状态 0、未审核  1、已审核
100 100
      */
101 101
     private Integer shzt;
102
-    /**
103
-     * 标志	区分省级库区还是中储粮
104
-     */
105
-    private String bz;
106 102
 
107 103
     /**
108 104
      * 通讯地址-具体地址
@@ -117,10 +113,6 @@ public class DwxxDO extends BaseDO {
117 113
      */
118 114
     private String dwDeptId;
119 115
     /**
120
-     * 上报id
121
-     */
122
-    private Integer sbid;
123
-    /**
124 116
      * 数据来源
125 117
      */
126 118
     private Integer sjly;

+ 0 - 10
delivery-module-core/delivery-module-core-biz/src/main/java/com/unis/module/coding/dal/dataobject/kqxx/KqxxDO.java

@@ -88,10 +88,6 @@ public class KqxxDO extends BaseDO {
88 88
      */
89 89
     private Integer wtbgckj;
90 90
     /**
91
-     * 标识  区分省级库区还是中储粮
92
-     */
93
-    private String bs;
94
-    /**
95 91
      * 库区地址-市
96 92
      */
97 93
     private String shi;
@@ -112,13 +108,7 @@ public class KqxxDO extends BaseDO {
112 108
      */
113 109
     private String shxydm;
114 110
     /**
115
-     * 库区产权
116
-     */
117
-    private String kqcq;
118
-    /**
119 111
      * 数据来源
120 112
      */
121 113
     private Integer sjly;
122
-    /** 库区性质 */
123
-    private Integer kqxz;
124 114
 }

+ 0 - 1
delivery-module-core/delivery-module-core-biz/src/main/java/com/unis/module/coding/dal/mysql/kqxx/KqxxMapper.java

@@ -32,7 +32,6 @@ public interface KqxxMapper extends BaseMapperX<KqxxDO> {
32 32
                 .eqIfPresent(KqxxDO::getLxdh, reqVO.getLxdh())
33 33
                 .eqIfPresent(KqxxDO::getZdmj, reqVO.getZdmj())
34 34
                 .eqIfPresent(KqxxDO::getResid, reqVO.getResid())
35
-                .eqIfPresent(KqxxDO::getBs, reqVO.getBs())
36 35
                 .betweenIfPresent(KqxxDO::getCreateTime, reqVO.getCreateTime())
37 36
                 .eqIfPresent(KqxxDO::getShi, reqVO.getShi())
38 37
                 .eqIfPresent(KqxxDO::getXian, reqVO.getXian())

+ 65 - 51
delivery-module-core/delivery-module-core-biz/src/main/java/com/unis/module/coding/service/dwxx/DwxxServiceImpl.java

@@ -384,70 +384,84 @@ public class DwxxServiceImpl implements DwxxService {
384 384
     @Transactional
385 385
     public void createCaAndKuAndDWForSheng(CaxxUpdateReqVO updateReqVO) {
386 386
         if (updateReqVO.getKqId() != null) {
387
-            CodingKqxxDO codingKqxxDO = codingKqxxMapper.selectById(updateReqVO.getKqId());
388
-            if (ObjectUtils.isEmpty(codingKqxxDO)) {
389
-                throw exception(ERROR, "当前库区信息不存在!");
390
-            }
391
-            KqxxDO kqxxDO = BeanUtils.toBean(codingKqxxDO, KqxxDO.class);
392
-
393
-            String shengAll = kqxxDO.getSheng();
394
-            String[] parts = shengAll.split(",");
395
-            for (int i = 0; i < parts.length; i++) {
396
-                parts[i] = parts[i].trim(); // 去除空格
397
-            }
398
-            String province = null;
399
-            String city = null;
400
-            String county = null;
401
-            if (parts.length != 0) {
402
-                province = parts[0];
403
-                if (parts.length == 3) {
404
-                    city = parts[1];
405
-                    county = parts[2];
387
+            KqxxDO kqxxDOExist = kqxxMapper.selectById(updateReqVO.getKqId());
388
+            if (ObjectUtils.isEmpty(kqxxDOExist)) {
389
+                CodingKqxxDO codingKqxxDO = codingKqxxMapper.selectById(updateReqVO.getKqId());
390
+                if (ObjectUtils.isEmpty(codingKqxxDO)) {
391
+                    throw exception(ERROR, "当前库区信息不存在!");
406 392
                 }
407
-                if (parts.length == 2) {
408
-                    city = parts[1];
393
+                KqxxDO kqxxDO = BeanUtils.toBean(codingKqxxDO, KqxxDO.class);
394
+                String shengAll = kqxxDO.getSheng();
395
+                String[] parts = shengAll.split(",");
396
+                for (int i = 0; i < parts.length; i++) {
397
+                    parts[i] = parts[i].trim(); // 去除空格
409 398
                 }
399
+                String province = null;
400
+                String city = null;
401
+                String county = null;
402
+                if (parts.length != 0) {
403
+                    province = parts[0];
404
+                    if (parts.length == 3) {
405
+                        city = parts[1];
406
+                        county = parts[2];
407
+                    }
408
+                    if (parts.length == 2) {
409
+                        city = parts[1];
410
+                    }
411
+                }
412
+                List<AreaLevelDO> areaLevelDOS = areaLevelMapper.selectListByName(Arrays.asList(province, city, county));
413
+                if (ObjectUtils.isEmpty(areaLevelDOS)) {
414
+                    throw exception(ERROR, "当前库区所在的行政区划不存在!");
415
+                }
416
+                Map<String, String> map = areaLevelDOS.stream().collect(Collectors.toMap(AreaLevelDO::getAreaName, AreaLevelDO::getAreaCode, (x, y) -> x));
417
+                if (province != null) {
418
+                    String shengCode = map.get(province);
419
+                    kqxxDO.setSheng(shengCode);
420
+                }
421
+                if (city != null) {
422
+                    String shiCode = map.get(city);
423
+                    kqxxDO.setShi(shiCode);
424
+                }
425
+                if (county != null) {
426
+                    String xianCode = map.get(county);
427
+                    kqxxDO.setXian(xianCode);
428
+                }
429
+                kqxxDO.setSjly(1);
430
+                kqxxMapper.insert(kqxxDO);
410 431
             }
411
-            List<AreaLevelDO> areaLevelDOS = areaLevelMapper.selectListByName(Arrays.asList(province, city, county));
412
-            if (ObjectUtils.isEmpty(areaLevelDOS)) {
413
-                throw exception(ERROR, "当前库区所在的行政区划不存在!");
414
-            }
415
-            Map<String, String> map = areaLevelDOS.stream().collect(Collectors.toMap(AreaLevelDO::getAreaName, AreaLevelDO::getAreaCode, (x, y) -> x));
416
-            if (province != null) {
417
-                String shengCode = map.get(province);
418
-                kqxxDO.setSheng(shengCode);
419
-            }
420
-            if (city != null) {
421
-                String shiCode = map.get(city);
422
-                kqxxDO.setShi(shiCode);
423
-            }
424
-            if (county != null) {
425
-                String xianCode = map.get(county);
426
-                kqxxDO.setXian(xianCode);
427
-            }
428
-            kqxxDO.setSjly(1);
429
-            kqxxMapper.insert(kqxxDO);
430 432
         }
431 433
         if (updateReqVO.getDeptId() != null) {
432
-            CodingDwxxDO codingDwxxDO = codingDwxxMapper.selectById(updateReqVO.getDeptId());
433
-            if (ObjectUtils.isEmpty(codingDwxxDO)) {
434
-                throw exception(ERROR, "当前单位信息不存在!");
434
+            DwxxDO dwxxDOExist = dwxxMapper.selectById(updateReqVO.getDeptId());
435
+            if (ObjectUtils.isEmpty(dwxxDOExist)) {
436
+                CodingDwxxDO codingDwxxDO = codingDwxxMapper.selectById(updateReqVO.getDeptId());
437
+                if (ObjectUtils.isEmpty(codingDwxxDO)) {
438
+                    throw exception(ERROR, "当前单位信息不存在!");
439
+                }
440
+                DwxxDO dwxxDO = BeanUtils.toBean(codingDwxxDO, DwxxDO.class);
441
+                dwxxDO.setSjly(1);
442
+                dwxxMapper.insert(dwxxDO);
435 443
             }
436
-            DwxxDO dwxxDO = BeanUtils.toBean(codingDwxxDO, DwxxDO.class);
437
-            dwxxDO.setSjly(1);
438
-            dwxxMapper.insert(dwxxDO);
439 444
         }
440 445
         if (!ObjectUtils.isEmpty(updateReqVO.getIds())) {
441 446
             List<CodingCaxxDO> codingCaxxDOS = codingCaxxMapper.selectList(CodingCaxxDO::getId, updateReqVO.getIds());
442 447
             if (ObjectUtils.isEmpty(codingCaxxDOS)) {
443 448
                 throw exception(ERROR, "所选仓房信息不存在!");
444 449
             }
450
+            List<CaxxDO> caxxDOSExist = caxxMapper.selectListByKqId(updateReqVO.getKqId());
445 451
             List<CaxxDO> caxxDOS = BeanUtils.toBean(codingCaxxDOS, CaxxDO.class);
446
-            caxxDOS.stream().forEach(s -> {
447
-                s.setSjly(1);
448
-                s.setYxcf(1);
449
-            });
450
-            caxxMapper.insertBatch(caxxDOS);
452
+            if (!ObjectUtils.isEmpty(caxxDOS)) {
453
+                if (!ObjectUtils.isEmpty(caxxDOSExist)) {
454
+                    List<Long> idsExist = caxxDOSExist.stream().map(CaxxDO::getId).collect(Collectors.toList());
455
+                     caxxDOS.removeIf(caxxDO -> idsExist.contains(caxxDO.getId()));
456
+                }
457
+                if (!ObjectUtils.isEmpty(caxxDOS)){
458
+                    caxxDOS.stream().forEach(s -> {
459
+                        s.setSjly(1);
460
+                        s.setYxcf(1);
461
+                    });
462
+                    caxxMapper.insertBatch(caxxDOS);
463
+                }
464
+            }
451 465
         }
452 466
     }
453 467