维修管理优化

This commit is contained in:
syruan 2024-12-12 13:54:27 +08:00
parent 0fde9252fe
commit dbabe955ef
5 changed files with 42 additions and 51 deletions

View File

@ -25,13 +25,6 @@ public class RemoteStoreLogFallbackFactory implements FallbackFactory<RemoteStor
public RemoteStoreLogService create(Throwable throwable)
{
log.error("日志服务调用失败:{}", throwable.getMessage());
return new RemoteStoreLogService()
{
@Override
public R<Boolean> batchInsert(List<BmStorageLog> bmStorageLogList, String source) throws Exception {
return R.fail("保存物资库存日志失败:" + throwable.getMessage());
}
};
return (bmStorageLogList, source) -> R.fail("保存物资库存日志失败:" + throwable.getMessage());
}
}

View File

@ -69,7 +69,7 @@ public class RepairAuditDetailsController extends BaseController {
@PostMapping("/export")
@SysLog(title = "导出修试审核任务列表", businessType = OperaType.EXPORT, module = "机具系统->导出修试审核任务列表")
public void exportAudit(HttpServletResponse response, RepairAuditDetails bean) {
if (bean == null) {
if (Objects.isNull(bean)) {
bean = new RepairAuditDetails();
}
if (Objects.isNull(bean.getTaskType())) {
@ -153,7 +153,7 @@ public class RepairAuditDetailsController extends BaseController {
@PostMapping("/exportEasyExcel")
public void export(HttpServletResponse response, RepairAuditDetails repairAuditDetails) {
List<RepairAuditDetails> list = repairAuditDetailsService.selectRepairAuditDetailsList(repairAuditDetails);
ExcelUtil<RepairAuditDetails> util = new ExcelUtil<RepairAuditDetails>(RepairAuditDetails.class);
ExcelUtil<RepairAuditDetails> util = new ExcelUtil<>(RepairAuditDetails.class);
util.exportExcel(response, list, "修试审核详细数据");
}

View File

@ -1,12 +1,10 @@
package com.bonus.material.repair.domain.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.basic.domain.BmFileInfo;
import com.bonus.material.repair.domain.RepairPartDetails;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream;
import java.math.BigDecimal;
import java.util.ArrayList;

View File

@ -55,6 +55,9 @@ public interface RepairService {
*/
AjaxResult fastRepairApply(List<RepairTaskDetails> list);
/**
* 批量维修
*/
AjaxResult batchRepairApply(@NotNull List<RepairDeviceVO> repairDeviceVOList);
/**

View File

@ -98,17 +98,11 @@ public class RepairServiceImpl implements RepairService {
.reduce(BigDecimal.ZERO, BigDecimal::add);
// BigDecimal typeCostSum = tempList.stream().map(RepairDeviceVO::getTotalCost).reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setRepairDeviceList(tempList)
.setIds(ids)
.setTypeRepairNum(repairNumSum)
.setTypeRepairedNum(repairedNumSum)
.setTypeScrapNum(scrapNumSum)
.setTaskId(tempList.get(0).getTaskId())
.setCode(tempList.get(0).getCode())
.setTypeName(tempList.get(0).getTypeName())
.setTypeId(tempList.get(0).getTypeId())
.setType(tempList.get(0).getType())
.setUnitName(tempList.get(0).getUnitName())
.setManageType(tempList.get(0).getManageType());
.setIds(ids).setTypeRepairNum(repairNumSum).setTypeRepairedNum(repairedNumSum)
.setTypeScrapNum(scrapNumSum).setTaskId(tempList.get(0).getTaskId())
.setCode(tempList.get(0).getCode()).setTypeName(tempList.get(0).getTypeName())
.setTypeId(tempList.get(0).getTypeId()).setType(tempList.get(0).getType())
.setUnitName(tempList.get(0).getUnitName()).setManageType(tempList.get(0).getManageType());
// .setTypeCost(typeCostSum);
repairDeviceSummaryVoList.add(vo);
}
@ -203,10 +197,9 @@ public class RepairServiceImpl implements RepairService {
List<RepairPart> repairPartList = repairAuditDetailsMapper.getPartDetailsByTaskId(new RepairAuditDetails().setTaskId(taskId));
repairPartList = mergePartsNum(repairPartList);
RepairTicketVo result = new RepairTicketVo()
.setRepairTaskInfo(repairTaskInfo)
RepairTicketVo result = new RepairTicketVo().setRepairTaskInfo(repairTaskInfo)
.setRepairDeviceSummaryList(repairDeviceSummaryList)
.setRepairPartArray(Optional.of(repairPartList).orElse(new ArrayList<>()));
.setRepairPartArray(Optional.of(repairPartList).orElse(Collections.emptyList()));
return AjaxResult.success(result);
} catch (NumberFormatException e) {
@ -229,7 +222,7 @@ public class RepairServiceImpl implements RepairService {
);
List<RepairPart> list = new ArrayList<>(map.values());
list.forEach(item -> item.setPartCost(Optional.ofNullable(item.getPartPrice()).orElse(BigDecimal.ZERO)
.multiply(new BigDecimal(Optional.ofNullable(item.getPartNum()).orElse(0))))
.multiply(BigDecimal.valueOf(Optional.ofNullable(item.getPartNum()).orElse(0))))
);
return list;
} catch (Exception e) {
@ -261,8 +254,7 @@ public class RepairServiceImpl implements RepairService {
String sfPart = "1";
if (CollectionUtil.isNotEmpty(partList)) {
bean.setRepairNum(partList.get(0).getRepairNum());
bean.setRepairer(partList.get(0).getRepairer());
bean.setRepairNum(partList.get(0).getRepairNum()).setRepairer(partList.get(0).getRepairer());
}
// 根据维修类型更新维修数量报废数量
@ -281,8 +273,8 @@ public class RepairServiceImpl implements RepairService {
}
case TO_SCRAP: {
BigDecimal scrapNum = details.getScrapNum().add(bean.getScrapNum());
BigDecimal num = scrapNum.add(details.getRepairedNum()) ;
if (num.compareTo( details.getRepairNum()) >0) {
BigDecimal totalNum = scrapNum.add(details.getRepairedNum());
if (totalNum.compareTo(details.getRepairNum()) > 0) {
throw new ServiceException("维修数量大于维修总量");
}
// 更新报废数量
@ -304,11 +296,11 @@ public class RepairServiceImpl implements RepairService {
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(BigDecimal.ZERO);
}
partDetails.setTaskId(bean.getTaskId());
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
partDetails.setCompanyId(bean.getCompanyId());
partDetails.setTaskId(bean.getTaskId())
.setMaId(bean.getMaId())
.setTypeId(bean.getTypeId())
.setCompanyId(bean.getCompanyId())
.setCreateBy(String.valueOf(Optional.ofNullable(loginUser.getUserid()).orElse(0L)));
// 根据 partId 找配件单价
BigDecimal partPrice = repairMapper.selectPartPrice(partDetails.getPartId());
@ -341,21 +333,16 @@ public class RepairServiceImpl implements RepairService {
} else {
bean.setSupplierId(partList.get(0).getSupplierId());
}
if (partList.get(0).getPartPrice() == null) {
bean.setPartPrice(BigDecimal.ZERO);
} else {
bean.setPartPrice(partList.get(0).getPartPrice());
}
bean.setPartPrice(partList.get(0).getPartPrice() == null ? BigDecimal.ZERO : partList.get(0).getPartPrice());
bean.setPartNum(partList.get(0).getPartNum());
// 新增维修记录表
repairMapper.addRecord(bean);
}
// 配件费用计算
sfCosts = countPartCosts(partList, sfCosts);
// 判断是否是收费配件
if (sfPart.equals(sfCosts.toString())) {
if (Objects.equals(sfPart, sfCosts.toString())) {
// SQL: 新增维修费用记录表
repairMapper.addRepairCost(bean, sfCosts, sfPart);
}
@ -373,6 +360,15 @@ public class RepairServiceImpl implements RepairService {
if (bean == null || bean.getRepairNum() == null) {
throw new ServiceException("维修数量不能为空");
}
if (details.getRepairedNum() == null) {
details.setRepairedNum(BigDecimal.ZERO);
}
if (details.getScrapNum() == null) {
details.setScrapNum(BigDecimal.ZERO);
}
if (details.getRepairNum() == null) {
details.setRepairNum(BigDecimal.ZERO);
}
BigDecimal repairNum = details.getRepairedNum().add(bean.getRepairNum()) ;
if (repairNum.add(details.getScrapNum()).compareTo(details.getRepairNum())>0) {
@ -407,8 +403,8 @@ public class RepairServiceImpl implements RepairService {
repairRecord.setCreateBy(String.valueOf(loginUser.getUserid()));
repairRecord.setCompanyId(bean.getCompanyId());
repairMapper.addRecord(repairRecord);
BigDecimal i = repairedNum.add(bean.getRepairedNum());
repairMapper.updateRepairedNumTwo(bean.getId(), i, loginUser.getUserid());
BigDecimal repairNum = repairedNum.add(bean.getRepairedNum());
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
}
// 执行完毕无异常返回至前端
@ -439,20 +435,20 @@ public class RepairServiceImpl implements RepairService {
case INNER_REPAIR: {
partList = bean.getCodeInRepairPartList();
// 更新维修数量并修改维修人员
repairMapper.updateRepairedNumAndStatus(bean.getId(), BigDecimal.ZERO, 1, loginUser.getUserid(), loginUser.getUserid());
repairMapper.updateRepairedNumAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid(), loginUser.getUserid());
break;
}
case RETURN_FACTORY: {
partList = bean.getCodeOutRepairPartList();
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), BigDecimal.ZERO, 1, loginUser.getUserid());
repairMapper.updateRepairedNumTwoAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
break;
}
case TO_SCRAP: {
// 报废无需上传配件直接初始化空集合
partList = bean.getCodeScrapRepairPartList();
// 更新报废数量
repairMapper.updateScrapNumAndStatus(bean.getId(), BigDecimal.ZERO, 1, loginUser.getUserid());
repairMapper.updateScrapNumAndStatus(bean.getId(), BigDecimal.ONE, 1, loginUser.getUserid());
break;
}
default:
@ -613,6 +609,7 @@ public class RepairServiceImpl implements RepairService {
throw new ServiceException("本次维修提交总数过大");
}
//本次修完了
// TODO 这里需要完善要全部先走This后再提交时PUT到真实修改数量
if ((bean.getRepairNum().subtract(innerRepairNum).subtract(outerRepairNum).subtract(scrapNum).compareTo(BigDecimal.valueOf(0)) ) == 0) {
repairMapper.updateRepairedNum(bean.getId(), innerRepairNum.add(outerRepairNum) , loginUser.getUserid(), loginUser.getUserid());
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());