优化:编码设备报废存储费用

This commit is contained in:
hayu 2026-01-06 10:18:09 +08:00
parent 650afdb89f
commit 7da8fe1173
1 changed files with 28 additions and 7 deletions

View File

@ -1591,6 +1591,12 @@ public class RepairServiceImpl implements RepairService {
// 构建报废费用记录
RepairApplyRecord scrapCostsRecord = buildScrapCostsRecord(repairDevice);
// SQL: 新增报废费用记录表
int count = repairMapper.getCostCount(scrapCostsRecord);
if (count==0){
repairMapper.addRepairCost(scrapCostsRecord, repairDetails.getBuyPrice(), repairDevice.getCodeScrapRepairPartList().get(0).getScrapType());
}
// 更新报废数量
repairMapper.updateScrapNumAndStatus(repairDevice.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
@ -1923,6 +1929,9 @@ public class RepairServiceImpl implements RepairService {
*/
private void saveScrapFileAndRecord(RepairDeviceVO repairDevice, RepairPartDetails firstPart,
BigDecimal scrapNum, BigDecimal scrapCosts, LoginUser loginUser) {
RepairApplyRecord bean = new RepairApplyRecord();
bean.setTaskId(repairDevice.getTaskId());
int count = repairMapper.getCostCount(bean);
if (CollectionUtil.isNotEmpty(firstPart.getFileList())) {
for (BmFileInfo fileInfo : firstPart.getFileList()) {
// 插入报废文件
@ -1932,7 +1941,9 @@ public class RepairServiceImpl implements RepairService {
loginUser, String.valueOf(fileInfo.getId()));
repairMapper.addRecord(repairApplyRecord);
// 新增报废费用记录
repairMapper.addRepairCost(repairApplyRecord, scrapCosts, repairApplyRecord.getScrapType());
if (count==0){
repairMapper.addRepairCost(repairApplyRecord, scrapCosts, repairApplyRecord.getScrapType());
}
}
} else {
// 构建并插入报废维修记录无文件ID
@ -1940,7 +1951,9 @@ public class RepairServiceImpl implements RepairService {
loginUser, "");
repairMapper.addRecord(repairApplyRecord);
// 新增报废费用记录
repairMapper.addRepairCost(repairApplyRecord, scrapCosts, repairApplyRecord.getScrapType());
if (count==0){
repairMapper.addRepairCost(repairApplyRecord, scrapCosts, repairApplyRecord.getScrapType());
}
}
}
@ -2048,9 +2061,17 @@ public class RepairServiceImpl implements RepairService {
*/
private void copeNumberManageInListNew(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType) {
// 过滤无效数据保留partId不为null的数据生成新集合
List<RepairPartDetails> validPartList = partList.stream()
.filter(partDetails -> partDetails.getPartId() != null)
.collect(Collectors.toList());
List<RepairPartDetails> validPartList;
if (bean.getRepairType() != null && bean.getRepairType() != 2) {
validPartList = partList.stream()
.filter(partDetails -> partDetails.getPartId() != null)
.collect(Collectors.toList());
} else {
validPartList = partList.stream()
.filter(partDetails -> partDetails.getPartName() != null && partDetails.getPartPrice() != null && partDetails.getPartNum() != null)
.collect(Collectors.toList());
}
// 替换原集合
partList.clear();
@ -2318,7 +2339,7 @@ public class RepairServiceImpl implements RepairService {
repairMapper.addRecord(repairApplyRecord);
// 统计并保存费用记录
BigDecimal partCost = Optional.ofNullable(partDetails.getBackCost()).orElse(BigDecimal.ZERO);
BigDecimal partCost = Optional.ofNullable(partDetails.getPartPrice()).orElse(BigDecimal.ZERO);
saveRepairCostRecord(repairApplyRecord, partCost, partDetails.getPartType().toString());
}
}
@ -2347,7 +2368,7 @@ public class RepairServiceImpl implements RepairService {
.setRepairContent(partDetails.getRepairContent())
.setSupplierId(partDetails.getSupplierId())
.setPartNum(partDetails.getPartNum())
.setPartPrice(Optional.ofNullable(partDetails.getBackCost()).orElse(BigDecimal.ZERO))
.setPartPrice(Optional.ofNullable(partDetails.getPartPrice()).orElse(BigDecimal.ZERO))
.setCreateBy(loginUser.getSysUser().getNickName());
// 设置维修/报废数量