Преглед изворни кода

完善对于车牌号错误的不维护车次序号

lingpeng.li пре 1 месец
родитељ
комит
ae6f48b32c

+ 9 - 4
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/service/impl/StorageBillServiceImpl.java

@@ -5631,15 +5631,19 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
             }
 
             Date shiftStart = shiftRecord.getCreateTime();
-            Date shiftEnd = Optional.ofNullable(shiftRecord.getChangeShiftTime()).orElse(DateUtils.addDays(DateUtils.getStartOfDay(bill.getCreateTime()), 1));
+            Date shiftEnd = Optional.ofNullable(shiftRecord.getChangeShiftTime())
+                    .orElse(DateUtils.addDays(DateUtils.getStartOfDay(bill.getCreateTime()), 1));
 
-            boolean needCalcCarNum = bill.getCarNum() == null || bill.getCarNum() == 0;
+            boolean licensePlateInvalid = bill.getLicensePlateStatus() != null && bill.getLicensePlateStatus() == 1;
+
+            boolean needCalcCarNum = !licensePlateInvalid && (bill.getCarNum() == null || bill.getCarNum() == 0);
             boolean needCalcCarAllNum = bill.getCarAllNum() == null || bill.getCarAllNum() == 0;
             boolean updated = false;
 
             // 查找对应车次列表
             String carNumKey = String.join("_", bill.getCcmNo(), bill.getShiftGroup(), bill.getShift(),
-                    Optional.ofNullable(bill.getLicensePlate()).orElse(""), DateFormatUtils.format(DateUtils.getStartOfDay(bill.getCreateTime()), "yyyy-MM-dd"));
+                    Optional.ofNullable(bill.getLicensePlate()).orElse(""),
+                    DateFormatUtils.format(DateUtils.getStartOfDay(bill.getCreateTime()), "yyyy-MM-dd"));
             List<StorageBill> relatedBills = billGroupMap.getOrDefault(carNumKey, new ArrayList<>()).stream()
                     .filter(b -> b.getCreateTime().compareTo(shiftStart) >= 0 && b.getCreateTime().compareTo(shiftEnd) < 0)
                     .sorted(Comparator.comparing(StorageBill::getCreateTime))
@@ -5673,12 +5677,13 @@ public class StorageBillServiceImpl extends ServiceImpl<StorageBillMapper, Stora
 
             if (updated) this.updateById(bill);
 
-            // 更新交班 outCarNum
+            // 更新交班 outCarNum(依赖 carAllNum,不管车牌状态)
             if (shiftRecord.getOutCarNum() == null || shiftRecord.getOutCarNum() == 0) {
                 shiftRecord.setOutCarNum(bill.getCarAllNum());
                 billetHotsendChangeShiftService.updateById(shiftRecord);
             }
         }
+
     }