refactor(coal): 优化代码结构和精度处理

- 重构了 SmartCamCarLicenseSnapshotDataService 中的条件判断逻辑,减少了代码重复
- 在 WarehouseReceiptService 中将价格精度从 2 位小数调整为 4 位小数,提高精度
This commit is contained in:
2025-04-15 20:17:24 +08:00
parent a57de0dbf3
commit 78cfab5738
2 changed files with 5 additions and 10 deletions

View File

@@ -319,25 +319,20 @@ public class SmartCamCarLicenseSnapshotDataService
boolean entry = StringUtils.equals(entity.getSmartCam().getDirection(), "0");
if (byNumber == null) {
SmartCamCarDataEntity smartCamCarDataEntity = new SmartCamCarDataEntity();
smartCamCarDataEntity.setNumber(entity.getNumber());
if (entry) {
SmartCamCarDataEntity smartCamCarDataEntity = new SmartCamCarDataEntity();
smartCamCarDataEntity.setNumber(entity.getNumber());
smartCamCarDataEntity.setEntry(entity);
smartCamCarDataEntity.setEntryTime(entity.getInfoTimeObj());
smartCamCarDataEntity.setOrganizationId(entity.getOrganizationId());
smartCamCarDataRepository.save(smartCamCarDataEntity);
} else {
SmartCamCarDataEntity smartCamCarDataEntity = new SmartCamCarDataEntity();
smartCamCarDataEntity.setNumber(entity.getNumber());
smartCamCarDataEntity.setExit(entity);
smartCamCarDataEntity.setExitTime(entity.getInfoTimeObj());
smartCamCarDataEntity.setOrganizationId(entity.getOrganizationId());
smartCamCarDataRepository.save(smartCamCarDataEntity);
}
smartCamCarDataEntity.setOrganizationId(entity.getOrganizationId());
smartCamCarDataRepository.save(smartCamCarDataEntity);
} else {

View File

@@ -253,7 +253,7 @@ public class WarehouseReceiptService
BigDecimal.valueOf(
ObjectUtils.defaultIfNull(
warehouseReceiptDetailEntity.getPrice(), 0.0))
.setScale(2, RoundingMode.HALF_UP)
.setScale(4, RoundingMode.HALF_UP)
.doubleValue());
warehouseReceiptDetailEntity.setNumber(