维修管理-报废逻辑优化

This commit is contained in:
syruan 2024-11-19 10:01:43 +08:00
parent 7b9b0eac65
commit a759a4bdba
2 changed files with 111 additions and 65 deletions

View File

@ -66,9 +66,23 @@ public class RepairPartDetails extends BaseEntity {
private String repairContent;
/** 维修数量 */
@ApiModelProperty(value = "维修数量")
private Integer repairNum;
/** 报废数量 */
@ApiModelProperty(value = "报废数量")
private Integer scrapNum;
/** 报废原因 */
@ApiModelProperty(value = "报废原因")
private String scrapReason;
/** 报废原因类型0自然损坏1人为损坏 */
@Excel(name = "损坏原因类型", readConverterExp = "0=自然损坏1人为损坏")
private String scrapType;
/** 维修人员 */
@ApiModelProperty(value = "维修人")
private String repairer;
@ApiModelProperty(value = "配件名称")

View File

@ -320,7 +320,7 @@ public class RepairServiceImpl implements RepairService {
// 处理配件--数量管理--内部维修
if (CollectionUtil.isNotEmpty(bean.getNumberInRepairPartList())) {
partList = bean.getNumberInRepairPartList();
if (bean.getNumberInRepairPartList().get(0).getRepairNum() != null && bean.getNumberInRepairPartList().get(0).getRepairNum() != 0) {
// ---------------校验维修数量-----------------
// 统计已维修数量 + 本次维修数量
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberInRepairPartList().get(0).getRepairNum();
@ -335,16 +335,19 @@ public class RepairServiceImpl implements RepairService {
// 处理配件集合数据
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
}
}
// 处理配件集合数据 -- 数量管理--外部返厂维修
if (CollectionUtil.isNotEmpty(bean.getNumberOutRepairPartList())) {
BigDecimal sfCosts = new BigDecimal("0");
partList = bean.getNumberOutRepairPartList();
// 判断外部维修配件数量是否为空
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum() != 0) {
// ---------------校验维修数量-----------------
// 统计已维修数量 + 本次维修数量
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberOutRepairPartList().get(0).getRepairNum();
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + partList.get(0).getRepairNum();
// 统计报废数量 + 维修合计数量
int num = repairNum + details.getScrapNum();
if (num > details.getRepairNum()) {
@ -383,12 +386,15 @@ public class RepairServiceImpl implements RepairService {
// SQL: 新增维修费用记录表
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
}
}
// 处理配件集合数据 -- 数量管理--报废维修
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList())) {
// 判断报废数量是否为空
if (bean.getNumberScrapRepairPartList().get(0).getScrapNum() != null && bean.getNumberScrapRepairPartList().get(0).getScrapNum() > 0) {
// -------------校验维修数量开始----------------
// 统计历史已报废数量 + 本次报废数量 = 报废总数
// TODO : get数组的维修数量不对后续修改对象
int scrapNum = OptionalInt.of(details.getScrapNum()).orElse(0) + bean.getNumberScrapRepairPartList().get(0).getRepairNum();
int scrapNum = OptionalInt.of(details.getScrapNum()).orElse(0) + bean.getNumberScrapRepairPartList().get(0).getScrapNum();
// 统计 报废总数 + 历史已维修数量,
int num = scrapNum + details.getRepairedNum();
// 不能大与总的待维修数量
@ -399,6 +405,21 @@ public class RepairServiceImpl implements RepairService {
// 更新报废数量
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
// 报废类型无需配件所以配件为空添加维修记录表
// 维修记录表信息
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.setCreateBy(loginUser.getUsername());
repairApplyRecord.setStatus(0L);
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
}
} else {
throw new ServiceException("请选择正确的维修类型");
@ -434,6 +455,17 @@ public class RepairServiceImpl implements RepairService {
*/
private void copeNumberManageInList(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType) {
if (CollectionUtil.isNotEmpty(partList)) {
// 如果是数量管理那么默认为内部维修
if (bean.getRepairType() == null && bean.getManageType() != null && manageType == manageTypeByNumber) {
bean.setRepairType(inRepairType);
}
// 再检查还是null的话直接结束任务
if (bean.getRepairType() == null) {
return;
}
// 内部维修
if (bean.getRepairType() == inRepairType) {
// 遍历配件列表判断配件类型收费还是不收费
@ -455,7 +487,7 @@ public class RepairServiceImpl implements RepairService {
repairApplyRecord.setCreateBy(loginUser.getUsername());
repairApplyRecord.setStatus(0L);
if (partDetails.getPartId() != null) {
if (partDetails.getPartId() != null && partDetails.getPartNum() != null) {
// 有维修配件时,如果价格为空设置为0
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));