维修管理优化 完善记录信息

This commit is contained in:
syruan 2024-11-19 11:10:52 +08:00
parent cfd1e9162d
commit 4c86d69f4b
2 changed files with 46 additions and 83 deletions

View File

@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.experimental.Accessors;
/**
* 维修配件详细对象 repair_part_details
@ -15,6 +16,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
*/
@Data
@ToString
@Accessors(chain = true)
public class RepairPartDetails extends BaseEntity {
private static final long serialVersionUID = 1L;

View File

@ -218,9 +218,8 @@ public class RepairServiceImpl implements RepairService {
* 校验维修数量
*/
private static int verifyRepairNum(RepairApplyRecord bean, RepairTaskDetails details) {
int repairNum = details.getRepairedNum() + bean.getRepairNum();
int num = repairNum + details.getScrapNum();
if (num > details.getRepairNum()) {
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getRepairNum();
if (repairNum + OptionalInt.of(details.getScrapNum()).orElse(0) > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
return repairNum;
@ -301,7 +300,6 @@ public class RepairServiceImpl implements RepairService {
System.err.println("请输入正确的维修类型:" + bean.getRepairType());
break;
}
// 统一处理配件集合数据
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
@ -313,7 +311,7 @@ public class RepairServiceImpl implements RepairService {
// 获取维修详情表中的维修详情记录待维修已维修已报废的数量
RepairTaskDetails details = repairMapper.getById(bean.getId());
if (details == null) {
if (Objects.isNull(details)) {
throw new ServiceException("此维修记录不存在,请检查后提交!");
}
@ -358,30 +356,20 @@ public class RepairServiceImpl implements RepairService {
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
// 数量管理--外部返厂维修
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId());
repairApplyRecord.setMaId(bean.getMaId());
repairApplyRecord.setTypeId(bean.getTypeId());
repairApplyRecord.setRepairType(outRepairType);
repairApplyRecord.setRepairNum(partList.get(0).getRepairNum());
repairApplyRecord.setScrapNum(0);
repairApplyRecord.setCreateBy(loginUser.getUsername());
repairApplyRecord.setPartName(partList.get(0).getPartName());
repairApplyRecord.setPartType(partList.get(0).getPartType());
repairApplyRecord.setRepairContent(partList.get(0).getRepairContent());
if (partList.get(0).getSupplierId() == null) {
throw new ServiceException("请选择返厂厂家");
} else {
repairApplyRecord.setSupplierId(partList.get(0).getSupplierId());
}
if (partList.get(0).getPartPrice() == null) {
repairApplyRecord.setPartPrice(new BigDecimal(0));
} else {
repairApplyRecord.setPartPrice(partList.get(0).getPartPrice());
}
repairApplyRecord.setPartNum(partList.get(0).getPartNum());
repairApplyRecord.setRepairer(loginUser.getUsername());
// 数量管理--外部返厂维修
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(outRepairType).setRepairNum(partList.get(0).getRepairNum()).setScrapNum(0)
.setPartName(partList.get(0).getPartName()).setPartType(partList.get(0).getPartType())
.setRepairContent(partList.get(0).getRepairContent()).setSupplierId(partList.get(0).getSupplierId())
.setPartNum(partList.get(0).getPartNum()).setRepairer(loginUser.getUsername())
.setPartPrice(Optional.ofNullable(partList.get(0).getPartPrice()).orElse(new BigDecimal(0)))
.setCreateBy(loginUser.getUsername());
// 新增维修记录表
repairMapper.addRecord(repairApplyRecord);
@ -413,17 +401,12 @@ public class RepairServiceImpl implements RepairService {
// 报废类型无需配件所以配件为空添加维修记录表
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId());
repairApplyRecord.setMaId(bean.getMaId());
repairApplyRecord.setTypeId(bean.getTypeId());
repairApplyRecord.setRepairType(bean.getRepairType());
repairApplyRecord.setRepairNum(null);
repairApplyRecord.setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum());
repairApplyRecord.setScrapReason(bean.getNumberScrapRepairPartList().get(0).getScrapReason());
repairApplyRecord.setScrapType(bean.getNumberScrapRepairPartList().get(0).getScrapType());
repairApplyRecord.setCreateBy(loginUser.getUsername());
repairApplyRecord.setStatus(0L);
repairApplyRecord.setIsSlt(0L);
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L).setIsSlt(0L)
.setRepairNum(null).setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum())
.setScrapReason(bean.getNumberScrapRepairPartList().get(0).getScrapReason())
.setScrapType(bean.getNumberScrapRepairPartList().get(0).getScrapType())
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
@ -446,7 +429,7 @@ public class RepairServiceImpl implements RepairService {
private static BigDecimal countPartCosts(List<RepairPartDetails> partList, BigDecimal sfCosts) {
for (RepairPartDetails partDetails : partList) {
if (partDetails.getPartCost() != null) {
BigDecimal partCost = partDetails.getPartCost();
BigDecimal partCost = partDetails.getPartPrice();
BigDecimal partNumber = new BigDecimal(partDetails.getPartNum());
sfCosts = sfCosts.add(partCost.multiply(partNumber));
}
@ -480,10 +463,7 @@ public class RepairServiceImpl implements RepairService {
for (RepairPartDetails partDetails : partList) {
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId());
repairApplyRecord.setMaId(bean.getMaId());
repairApplyRecord.setTypeId(bean.getTypeId());
repairApplyRecord.setRepairType(bean.getRepairType());
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setRepairType(bean.getRepairType());
if (manageType == manageTypeByCode) {
repairApplyRecord.setRepairNum(scrapRepairType != bean.getRepairType() ? 1 : 0);
repairApplyRecord.setScrapNum(scrapRepairType == bean.getRepairType() ? 1 : 0);
@ -500,11 +480,8 @@ public class RepairServiceImpl implements RepairService {
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
partDetails.setTaskId(bean.getTaskId());
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setCompanyId(null);
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
partDetails.setCompanyId(null);
// 根据 partId 找配件单价
BigDecimal partPrice = repairMapper.selectPartPrice(partDetails.getPartId());
@ -514,11 +491,11 @@ public class RepairServiceImpl implements RepairService {
repairMapper.addPart(partDetails);
// 设置维修记录的配件费用
repairApplyRecord.setPartPrice(partDetails.getPartCost());
repairApplyRecord.setPartId(partDetails.getPartId() == null ? 0L : partDetails.getPartId());
repairApplyRecord.setPartNum(partDetails.getPartNum());
repairApplyRecord.setRepairContent(partDetails.getRepairContent());
repairApplyRecord.setPartType(partDetails.getPartType());
repairApplyRecord.setPartPrice(partDetails.getPartCost())
.setPartNum(partDetails.getPartNum())
.setRepairContent(partDetails.getRepairContent())
.setPartType(partDetails.getPartType())
.setPartId(partDetails.getPartId() == null ? 0L : partDetails.getPartId());
// 添加维修记录表
repairMapper.addRecord(repairApplyRecord);
} else {
@ -530,47 +507,35 @@ public class RepairServiceImpl implements RepairService {
// 外部维修
if (bean.getRepairType() == outRepairType) {
BigDecimal sfCosts = new BigDecimal("0");
partList = bean.getNumberOutRepairPartList();
// ---------------校验维修数量-----------------
// 统计已维修数量 + 本次维修数量
int repairNum = bean.getRepairedNum() + bean.getRepairNum();
// 统计报废数量 + 维修合计数量
int num = repairNum + bean.getScrapNum();
if (num > bean.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
// ---------------校验维修数量-----------------
int repairNum = OptionalInt.of(bean.getRepairedNum()).orElse(0) + bean.getRepairNum();
// 统计报废数量 + 维修合计数量 不能 大与> 总的待维修量
if (repairNum + OptionalInt.of(bean.getScrapNum()).orElse(0) > bean.getRepairNum()) {throw new ServiceException("维修数量大于维修总量");}
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
// 编码管理--外部返厂维修
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId());
repairApplyRecord.setMaId(bean.getMaId());
repairApplyRecord.setTypeId(bean.getTypeId());
repairApplyRecord.setRepairType(outRepairType);
repairApplyRecord.setPartName(partList.get(0).getPartName());
repairApplyRecord.setPartType(partList.get(0).getPartType());
repairApplyRecord.setRepairContent(partList.get(0).getRepairContent());
RepairApplyRecord repairApplyRecord = new RepairApplyRecord().setTaskId(bean.getTaskId()).setMaId(bean.getMaId())
.setTypeId(bean.getTypeId()).setRepairType(outRepairType)
.setPartName(partList.get(0).getPartName())
.setPartType(partList.get(0).getPartType())
.setRepairContent(partList.get(0).getRepairContent()).setPartNum(partList.get(0).getPartNum());
if (partList.get(0).getSupplierId() == null) {
throw new ServiceException("请选择返厂厂家");
} else {
repairApplyRecord.setSupplierId(partList.get(0).getSupplierId());
}
if (partList.get(0).getPartPrice() == null) {
repairApplyRecord.setPartPrice(new BigDecimal(0));
} else {
repairApplyRecord.setPartPrice(partList.get(0).getPartPrice());
}
repairApplyRecord.setPartNum(partList.get(0).getPartNum());
repairApplyRecord.setPartPrice(Optional.ofNullable(partList.get(0).getPartPrice()).orElse(new BigDecimal(0)));
// 新增维修记录表
repairMapper.addRecord(repairApplyRecord);
// 配件费用计算
sfCosts = countPartCosts(partList, sfCosts);
BigDecimal sfCosts = countPartCosts(partList, new BigDecimal(0));
// TODO: 判断是否是收费配件因数据存在多条可能有些是免费配件 有些收费所以这里用价格统一做处理后续讨论
// SQL: 新增维修费用记录表
@ -579,16 +544,12 @@ public class RepairServiceImpl implements RepairService {
} else {
// 配件为空添加维修记录表
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId());
repairApplyRecord.setMaId(bean.getMaId());
repairApplyRecord.setTypeId(bean.getTypeId());
repairApplyRecord.setRepairType(bean.getRepairType());
repairApplyRecord.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0);
repairApplyRecord.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0);
repairApplyRecord.setCreateBy(loginUser.getUsername());
repairApplyRecord.setStatus(0L);
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L)
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0).setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}