|
@@ -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
|
|