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

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