维修驳回优化

This commit is contained in:
mashuai 2025-06-23 16:03:58 +08:00
parent b3d4d0c46f
commit 523ad7ecb9
11 changed files with 191 additions and 46 deletions

View File

@ -365,4 +365,11 @@ public interface BackApplyInfoMapper {
* @return
*/
List<MaCodeVo> getMachineByIdAndCode(BackApplyInfo dto);
/**
* 根据任务id查询退料单
* @param taskId
* @return
*/
BackApplyInfo selectByTaskId(Long taskId);
}

View File

@ -198,9 +198,9 @@ public class RepairController extends BaseController {
*/
@ApiOperation(value = "驳回退料--批量")
//@RequiresPermissions(value = "repair:manage:reject")
@DeleteMapping("/{ids}")
public AjaxResult rejectRepair(@PathVariable Long[] ids) {
return service.rejectRepair(Arrays.asList(ids));
@PostMapping("/rejectRepair")
public AjaxResult rejectRepair(@RequestBody RepairTask bean) {
return service.rejectRepair(bean);
}
/**

View File

@ -14,6 +14,8 @@ import java.util.List;
@Data
@ApiModel(value="维修任务")
public class RepairTask {
private Long id;
/**
* 任务id
*/
@ -177,4 +179,8 @@ public class RepairTask {
* 退料人
*/
private String backPerson;
private List<Long> ids;
private List<Long> taskIds;
}

View File

@ -313,4 +313,25 @@ public interface RepairMapper {
* @return
*/
List<PartType> getPartData(RepairTaskDetails bean);
/**
* 删除任务
* @param taskId
* @return
*/
int deleteByTaskId(Long taskId);
/**
* 查询已修和已报废数量
* @param id
* @return
*/
int getRepairedScrapNumById(Long id);
/**
* 删除单条维修任务
* @param id
* @return
*/
int deleteRepairById(Long id);
}

View File

@ -74,7 +74,12 @@ public interface RepairService {
*/
AjaxResult endRepairTask(@NotNull List<RepairTask> taskList);
AjaxResult rejectRepair(@NotNull List<Long> taskList);
/**
* 维修驳回
* @param bean
* @return
*/
AjaxResult rejectRepair(RepairTask bean);
/**

View File

@ -698,12 +698,6 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
}
}
// public static void main(String[] args) {
// Integer a = null;
// Long b = ObjectUtils.defaultIfNull(a, 0).longValue();
// System.out.println(b);
// }
private void batchInsertRepairInputDetails(List<ScrapApplyDetails> scrapApplyDetailList, List<RepairAuditDetails> repairAuditDetailsByQuery, Long agreementId) {
boolean inputFlag = false;
boolean scrapFlag = false;

View File

@ -9,10 +9,13 @@ 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.common.biz.domain.BmFileInfo;
import com.bonus.material.back.mapper.BackCheckDetailsMapper;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.ma.domain.PartType;
import com.bonus.material.ma.mapper.MachineMapper;
import com.bonus.material.ma.mapper.PartTypeMapper;
import com.bonus.material.repair.domain.*;
import com.bonus.material.repair.domain.vo.*;
@ -29,6 +32,7 @@ import com.bonus.system.api.domain.SysUser;
import com.bonus.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -79,6 +83,12 @@ public class RepairServiceImpl implements RepairService {
@Resource
private PartTypeMapper partTypeMapper;
@Resource
private BackCheckDetailsMapper backCheckDetailsMapper;
@Resource
private MachineMapper machineMapper;
// 1:内部维修 2:外部返厂维修 3:报废
private final int INNER_REPAIR = 1; // 需要严格匹配枚举值 RepairTypeEnum.INNER_REPAIR.getTypeId();
private final int RETURN_FACTORY = 2; // 需要严格匹配枚举值 RepairTypeEnum.RETURN_FACTORY.getTypeId();
@ -1145,26 +1155,14 @@ public class RepairServiceImpl implements RepairService {
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult rejectRepair(@NotNull List<Long> taskList) {
public AjaxResult rejectRepair(RepairTask bean) {
try {
for (Long taskId : taskList) {
// 判断维修明细是否有已经维修的数据
final int repairedScrapNumber = repairMapper.getRepairedScrapNumByTaskId(taskId);
if (0 >= repairedScrapNumber) {
// 1.修改维修task状态为已驳回
taskMapper.updateTaskStatus(String.valueOf(taskId), RepairTaskStatusEnum.TASK_STATUS_REJECT.getStatus());
if (CollectionUtils.isEmpty(bean.getTaskIds())) {
for (Long taskId : bean.getTaskIds()) {
// 判断维修明细是否有已经维修的数据
final int repairedScrapNumber = repairMapper.getRepairedScrapNumByTaskId(taskId);
final TmTask tmTask = taskMapper.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 (0 >= repairedScrapNumber) {
//驳回操作不可跨月操作
if (!StringHelper.isNullOrEmptyString(String.valueOf(tmTask.getCreateTime()))) {
// createTime 转换为 LocalDate
@ -1176,25 +1174,70 @@ public class RepairServiceImpl implements RepairService {
throw new ServiceException("只可驳回本月任务");
}
}
//查询是否有签名 根据退料编码查询back_apply_info表
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectSignByTaskId(taskId);
if (null != backApplyInfo){
if (!StringHelper.isNullOrEmptyString(backApplyInfo.getBackSignUrl()) || backApplyInfo.getDirectAuditBy()>0){
throw new ServiceException("该任务已有签名,不能驳回");
// 1.驳回后直接清楚该条维修单记录
int result = taskMapper.deleteTmTaskByTaskId(taskId);
if (result < 1) {
throw new ServiceException("维修驳回失败,请联系管理员");
}
if (null != tmTask.getPreTaskId()) {
// 2. 根据任务id查询前置任务数据详情
BackApplyInfo info = backApplyInfoMapper.selectByTaskId(tmTask.getPreTaskId());
// 3. 查询back_check_details表数据
BackCheckDetails backCheckDetails = new BackCheckDetails();
backCheckDetails.setParentId(info.getId());
List<BackCheckDetails> checkDetails = backCheckDetailsMapper.selectBackCheckDetailsList(backCheckDetails);
// 4. 更新结算信息表
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());
}
}
}
// 4. 删除维修明细数据
result = repairMapper.deleteByTaskId(taskId);
if (result < 1) {
throw new ServiceException("维修驳回失败,请联系管理员");
}
} else {
throw new ServiceException("维修任务没有前置任务,不能驳回");
}
if (null == tmTask.getCode() || tmTask.getCode().isEmpty()) {
throw new ServiceException("维修任务:" + taskId + "没有退料单号,系统异常!");
}
// 4.更新退料明细状态 -- 2025.1.9 ruan修改 驳回时--退料明细直接删除
backApplyInfoMapper.removeBackApplyDetails(tmTask.getCode());
} else {
throw new ServiceException("维修任务:" + taskId + "没有前置任务,不能驳回");
throw new ServiceException("维修任务已有维修数据,不能驳回");
}
}
} else if (!CollectionUtils.isEmpty(bean.getIds())) {
RepairApplyDetails repairApplyDetails = null;
for (Long id : bean.getIds()) {
int repairedScrapNumber = repairMapper.getRepairedScrapNumById(id);
if (repairedScrapNumber > 0) {
throw new ServiceException("维修明细已有维修数据,不能驳回");
}
// 查询明细详情
repairApplyDetails = repairApplyDetailsMapper.selectRepairApplyDetailsById(id);
}
for (Long id : bean.getIds()) {
if (repairApplyDetails != null) {
if (repairApplyDetails.getMaId() != null) {
machineMapper.updateStatus(repairApplyDetails.getMaId(), MaMachineStatusEnum.IN_USE.getStatus());
}
}
// 驳回后直接清除该条维修单记录
int result = repairMapper.deleteRepairById(id);
if (result < 1) {
throw new ServiceException("维修驳回失败,请联系管理员");
}
// 更新结算信息表
result = sltAgreementInfoMapper.backInUseNum(repairApplyDetails);
if (result < 1) {
throw new ServiceException("维修驳回失败,请联系管理员");
}
} else {
throw new ServiceException("维修任务:" + taskId + "有已维修数据,不能驳回");
}
}
} catch (final DataAccessException e) {

View File

@ -1,14 +1,12 @@
package com.bonus.material.settlement.mapper;
import java.util.List;
import java.util.Map;
import com.bonus.common.biz.domain.ProjectTreeNode;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.material.basic.domain.BmProject;
import com.bonus.material.common.domain.dto.SelectDto;
import com.bonus.material.common.domain.vo.AgreementVo;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.repair.domain.RepairApplyDetails;
import com.bonus.material.settlement.domain.SltAgreementApply;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.SltAgreementRelation;
@ -214,4 +212,7 @@ public interface SltAgreementInfoMapper {
List<ProjectTreeNode> getProjectList(int projectId);
List<AgreementVo> getAgreementInfoById(@Param("unitIds") List<Integer> unitIds, @Param("projectId") int projectId);
int backInUseNum(RepairApplyDetails repairApplyDetails);
}

View File

@ -970,4 +970,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and mm.qr_code = #{qrCode}
</if>
</select>
<select id="selectByTaskId" resultType="com.bonus.material.back.domain.BackApplyInfo">
SELECT
bai.id AS id,
bai.CODE AS CODE,
bai.task_id AS taskId,
bai.back_person AS backPerson,
bai.phone AS phone,
bai.create_by AS createBy,
bai.create_time AS createTime,
bai.update_by AS updateBy,
bai.update_time AS updateTime,
bai.remark AS remark,
bai.print_status AS printStatus,
ba.agreement_id AS agreementId,
bu.unit_id AS unitId,
bu.unit_name AS unitName,
bp.pro_id AS proId,
bp.pro_name AS proName,
bai.direct_audit_by AS directAuditBy,
bai.back_sign_url AS backSignUrl,
bai.back_sign_type AS backSignType
FROM
back_apply_info bai
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN bm_agreement_info ba ON ba.agreement_id = tta.agreement_id
AND ba.`status` = 1
LEFT JOIN bm_unit bu ON ba.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN bm_project bp ON ba.project_id = bp.pro_id
AND bp.del_flag = '0'
WHERE
bai.task_id = #{taskId}
</select>
</mapper>

View File

@ -214,6 +214,14 @@
where task_id = #{task.taskId}
</update>
<delete id="deleteByTaskId">
delete from repair_apply_details where task_id = #{taskId}
</delete>
<delete id="deleteRepairById">
delete from repair_apply_details where id = #{id}
</delete>
<select id="getRepairTaskInfoByTaskId" resultType="com.bonus.material.repair.domain.RepairTask">
SELECT
rd.task_id as taskId,
@ -969,6 +977,15 @@
]]>
</select>
<select id="getRepairedScrapNumById" resultType="java.lang.Integer">
SELECT
SUM(repaired_num + scrap_num) as num
FROM
repair_apply_details
WHERE
id = #{id}
</select>
<update id="updateRepairedAndScrapNum">
update
repair_apply_details

View File

@ -584,6 +584,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bai.agreement_id = #{agreementId}
</update>
<update id="backInUseNum">
update
slt_agreement_info sai
join
back_apply_info bai on sai.back_id = bai.id
set
sai.end_time = null, sai.back_id = null, sai.status = '0', sai.update_time = CURRENT_TIMESTAMP
where
bai.task_id = #{taskId} and sai.status = '1'
<if test="typeId != null">
and sai.type_id = #{typeId}
</if>
<if test="maId != null">
and sai.ma_id = #{maId}
</if>
</update>
<select id="getProjectListByUnitIds" resultType="int">
/*根据往来单位id关联协议查询工程*/
SELECT