diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/controller/LossAssessmentController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/controller/LossAssessmentController.java index 00375c6d..df3c1899 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/controller/LossAssessmentController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/controller/LossAssessmentController.java @@ -100,9 +100,9 @@ public class LossAssessmentController extends BaseController { * 驳回退料--批量 */ @ApiOperation(value = "驳回退料--批量") - @DeleteMapping("/{ids}") - public AjaxResult rejectRepair(@PathVariable Long[] ids) { - return service.rejectRepair(Arrays.asList(ids)); + @PostMapping("/reject") + public AjaxResult rejectRepair(@RequestBody RepairTask bean) { + return service.rejectRepair(bean); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/mapper/LossAssessmentMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/mapper/LossAssessmentMapper.java index 4212cf88..99980af4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/mapper/LossAssessmentMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/mapper/LossAssessmentMapper.java @@ -1,10 +1,7 @@ package com.bonus.material.lossAssessment.mapper; import com.bonus.material.ma.domain.PartType; -import com.bonus.material.repair.domain.RepairApplyRecord; -import com.bonus.material.repair.domain.RepairPartDetails; -import com.bonus.material.repair.domain.RepairTask; -import com.bonus.material.repair.domain.RepairTaskDetails; +import com.bonus.material.repair.domain.*; import com.bonus.material.repair.domain.vo.RepairDeviceVO; import com.bonus.material.task.domain.TmTask; import org.apache.ibatis.annotations.Mapper; @@ -175,4 +172,81 @@ public interface LossAssessmentMapper { * @return */ int updateStatus(Long taskId); + + /** + * 查询任务状态 + * @param taskId + * @return + */ + int selectTaskStatus(Long taskId); + + /** + * 删除任务 + * @param taskId + * @return + */ + int deleteTask(Long taskId); + + /** + * 删除repair_apply_details + * @param taskId + * @return + */ + int deleteApplyDetailsByTaskId(Long taskId); + + /** + * 删除repair_apply_record + * @param taskId + * @return + */ + int deleteRecordByTaskId(Long taskId); + + /** + * 删除repair_part_details + * @param taskId + * @return + */ + int deletePartByTaskId(Long taskId); + + /** + * 删除repair_cost + * @param taskId + * @return + */ + int deleteCostByTaskId(Long taskId); + + /** + * 查询repair_apply_details + * @param id + * @return + */ + RepairApplyDetails selectRepairApplyDetailsById(Long id); + + /** + * 删除repair_apply_details + * @param id + * @return + */ + int delDetailsById(Long id); + + /** + * 删除repair_apply_record + * @param repairApplyDetails + * @return + */ + int delRecord(RepairApplyDetails repairApplyDetails); + + /** + * 删除repair_part_details + * @param repairApplyDetails + * @return + */ + int delPart(RepairApplyDetails repairApplyDetails); + + /** + * 删除repair_cost + * @param repairApplyDetails + * @return + */ + int delCost(RepairApplyDetails repairApplyDetails); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/LossAssessmentService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/LossAssessmentService.java index f237f312..668a0307 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/LossAssessmentService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/LossAssessmentService.java @@ -48,10 +48,10 @@ public interface LossAssessmentService { /** * 驳回至退料 - * @param taskList + * @param bean * @return */ - AjaxResult rejectRepair(@NotNull List taskList); + AjaxResult rejectRepair(RepairTask bean); /** * 获取详情的详情 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/impl/LossAssessmentServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/impl/LossAssessmentServiceImpl.java index 84af468c..475c0cd0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/impl/LossAssessmentServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lossAssessment/service/impl/LossAssessmentServiceImpl.java @@ -8,15 +8,15 @@ import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.back.domain.BackApplyInfo; +import com.bonus.material.back.domain.BackCheckDetails; import com.bonus.material.back.mapper.BackApplyInfoMapper; +import com.bonus.material.back.mapper.BackCheckDetailsMapper; import com.bonus.material.basic.mapper.BmFileInfoMapper; import com.bonus.material.lossAssessment.mapper.LossAssessmentMapper; import com.bonus.material.lossAssessment.service.LossAssessmentService; import com.bonus.material.ma.domain.PartType; -import com.bonus.material.repair.domain.RepairApplyRecord; -import com.bonus.material.repair.domain.RepairPartDetails; -import com.bonus.material.repair.domain.RepairTask; -import com.bonus.material.repair.domain.RepairTaskDetails; +import com.bonus.material.ma.mapper.MachineMapper; +import com.bonus.material.repair.domain.*; import com.bonus.material.repair.domain.vo.RepairDeviceSummaryVo; import com.bonus.material.repair.domain.vo.RepairDeviceVO; import com.bonus.material.settlement.mapper.SltAgreementInfoMapper; @@ -55,6 +55,10 @@ public class LossAssessmentServiceImpl implements LossAssessmentService { private BackApplyInfoMapper backApplyInfoMapper; @Resource private SltAgreementInfoMapper sltAgreementInfoMapper; + @Resource + private BackCheckDetailsMapper backCheckDetailsMapper; + @Resource + private MachineMapper machineMapper; @Override @@ -252,72 +256,91 @@ public class LossAssessmentServiceImpl implements LossAssessmentService { @Override @Transactional(rollbackFor = Exception.class) - public AjaxResult rejectRepair(@NotNull List taskList) { + public AjaxResult rejectRepair(RepairTask bean) { String res=""; try { - for (Long taskId : taskList) { - // 判断维修明细是否有已经维修的数据 - final int repairedScrapNumber = mapper.getRepairedScrapNumByTaskId(taskId); - if (0 >= repairedScrapNumber) { - // 1.修改维修task状态为已驳回 - mapper.updateTaskStatus(String.valueOf(taskId), RepairTaskStatusEnum.TASK_STATUS_REJECT.getStatus()); - final TmTask tmTask = mapper.selectTmTaskByTaskId(taskId); - if (null != tmTask && null != tmTask.getPreTaskId()) { - // 2.修改退料任务状态为被维修驳回 - backApplyInfoMapper.updateTaskStatus(new BackApplyInfo() - .setTaskId(tmTask.getPreTaskId()) - .setTaskStatus(BackTaskStatusEnum.BACK_TASK_TO_REJECT.getStatus()) - ); - // 3.退料的在用数量恢复 -- 2025.1.9 ruan修改 已弃用!!! -// backApplyInfoMapper.updateBackApplyDetailsTwo(tmTask.getPreTaskId()); - // 3. 更新结算信息表 - sltAgreementInfoMapper.backRejectSltCope(tmTask.getPreTaskId()); - - //驳回操作不可跨月操作 - if (!StringHelper.isNullOrEmptyString(String.valueOf(tmTask.getCreateTime()))) { - // 将 createTime 转换为 LocalDate - LocalDate taskCreationDate = tmTask.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - // 获取当前日期 - LocalDate today = LocalDate.now(); - // 检查是否在同一月 - if (taskCreationDate.getYear() != today.getYear() || taskCreationDate.getMonth() != today.getMonth()) { - res="只可驳回本月任务"; - throw new ServiceException("只可驳回本月任务"); + if (!CollectionUtils.isEmpty(bean.getTaskIds())) { + for (Long taskId : bean.getTaskIds()) { + //判断是否定损完成 + int status = mapper.selectTaskStatus(taskId); + final TmTask tmTask = mapper.selectTmTaskByTaskId(taskId); + if (status<=0){ + //驳回操作不可跨月操作 + if (!StringHelper.isNullOrEmptyString(String.valueOf(tmTask.getCreateTime()))) { + // 将 createTime 转换为 LocalDate + LocalDate taskCreationDate = tmTask.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + // 获取当前日期 + LocalDate today = LocalDate.now(); + // 检查是否在同一月 + if (taskCreationDate.getYear() != today.getYear() || taskCreationDate.getMonth() != today.getMonth()) { + throw new ServiceException("只可驳回本月任务"); + } + } + //1、清除任务 + int deleteTask = mapper.deleteTask(taskId); + if (deleteTask<0){ + throw new ServiceException("任务驳回失败,请重试"); + } + if (tmTask.getPreTaskId()!=null){ + // 2. 根据任务id查询前置任务数据详情 + BackApplyInfo info = backApplyInfoMapper.selectByTaskId(tmTask.getPreTaskId()); + // 3. 查询back_check_details表数据 + BackCheckDetails backCheckDetails = new BackCheckDetails(); + backCheckDetails.setParentId(info.getId()); + List checkDetails = backCheckDetailsMapper.selectBackCheckDetailsList(backCheckDetails); + // 4. 更新结算信息表 + int result = sltAgreementInfoMapper.backRejectSltCope(tmTask.getPreTaskId()); + if (result < 1) { + throw new ServiceException("维修驳回失败,请联系管理员"); + } + // 5. 对于编码设备,更改设备状态为在用 + if (!CollectionUtils.isEmpty(checkDetails)) { + for (BackCheckDetails backCheckDetail : checkDetails) { + if (backCheckDetail.getMaId() != null) { + // 更新设备状态为在用 + machineMapper.updateStatus(backCheckDetail.getMaId(), MaMachineStatusEnum.IN_USE.getStatus()); + } } } - - //查询是否有签名 根据退料编码查询back_apply_info表 - BackApplyInfo backApplyInfo = backApplyInfoMapper.selectSignByTaskId(taskId); - if (null != backApplyInfo){ - if (!StringHelper.isNullOrEmptyString(backApplyInfo.getBackSignUrl()) || backApplyInfo.getDirectAuditBy()>0){ - res="该任务已有签名,不能驳回"; - throw new ServiceException("该任务已有签名,不能驳回"); - } - } - - if (null == tmTask.getCode() || tmTask.getCode().isEmpty()) { - res="定损任务:" + taskId + "没有退料单号,系统异常!"; - throw new ServiceException("定损任务:" + taskId + "没有退料单号,系统异常!"); - } - // 4.更新退料明细状态 -- 2025.1.9 ruan修改 驳回时--退料明细直接删除 - backApplyInfoMapper.removeBackApplyDetails(tmTask.getCode()); + //6、删除定损数据 + int detailsRes = mapper.deleteApplyDetailsByTaskId(taskId); + int recordRes = mapper.deleteRecordByTaskId(taskId); + int partRes = mapper.deletePartByTaskId(taskId); + int costRes = mapper.deleteCostByTaskId(taskId); } else { - res="定损任务:" + taskId + "没有前置任务,不能驳回"; - throw new ServiceException("定损任务:" + taskId + "没有前置任务,不能驳回"); + throw new ServiceException("定损任务没有前置任务,不能驳回"); } } else { - res="定损任务:" + taskId + "有已定损数据,不能驳回"; - throw new ServiceException("定损任务:" + taskId + "有已定损数据,不能驳回"); + res="此任务已定损完成,不可驳回"; + return AjaxResult.error(res); + } + } + } else if (!CollectionUtils.isEmpty(bean.getIds())) { + RepairApplyDetails repairApplyDetails = null; + for (Long id : bean.getIds()) { + // 查询明细详情 + repairApplyDetails = mapper.selectRepairApplyDetailsById(id); + if (repairApplyDetails != null) { + if (repairApplyDetails.getMaId()!=null){ + machineMapper.updateStatus(repairApplyDetails.getMaId(), MaMachineStatusEnum.IN_USE.getStatus()); + } + } + //驳回后直接清除该条定损记录 + mapper.delDetailsById(id); + mapper.delRecord(repairApplyDetails); + mapper.delPart(repairApplyDetails); + mapper.delCost(repairApplyDetails); + // 更新结算信息表 + int result = sltAgreementInfoMapper.backInUseNum(repairApplyDetails); + if (result < 1) { + throw new ServiceException("定损驳回失败,请联系管理员"); + } } } } catch (final DataAccessException e) { log.error("定损任务驳回",e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - if (!"".equals(res)){ - return AjaxResult.error(res); - } else { - return AjaxResult.error("驳回失败"); - } + return AjaxResult.error("定损任务驳回失败"); } return AjaxResult.success("执行完成"); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lossAssessment/LossAssessmentMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lossAssessment/LossAssessmentMapper.xml index 2b6713c8..a3211f38 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lossAssessment/LossAssessmentMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lossAssessment/LossAssessmentMapper.xml @@ -37,6 +37,26 @@ + + + + + + + + + + + + + + + + + + + + select task_id, pre_task_id, task_type, task_status, code, create_by, create_time, update_by, update_time, remark, company_id, month_order @@ -192,11 +212,13 @@ update_time = NOW() where task_id = #{taskId} + update repair_apply_details set is_ds = 0 where task_id = #{taskId} + update repair_apply_details set status = 1 @@ -204,6 +226,43 @@ and is_ds = 1 + + delete from tm_task where task_id = #{taskId} + + + delete from repair_apply_details where task_id = #{taskId} + + + delete from repair_apply_record where task_id = #{taskId} + + + delete from repair_part_details where task_id = #{taskId} + + + delete from repair_cost where task_id = #{taskId} + + + delete from repair_apply_details where id = #{id} + + + delete from repair_apply_record where task_id = #{taskId} and type_id = #{typeId} + + and ma_id = #{maId} + + + + delete from repair_part_details where task_id = #{taskId} and type_id = #{typeId} + + and ma_id = #{maId} + + + + delete from repair_cost where task_id = #{taskId} and type_id = #{typeId} + + and ma_id = #{maId} + + + + +