维修驳回优化
This commit is contained in:
parent
522ef25d63
commit
0467712248
|
|
@ -160,4 +160,11 @@ public interface RepairAuditDetailsMapper {
|
|||
* @return
|
||||
*/
|
||||
List<RepairHomeInfo> selectDetails(RepairHomeInfo repairHomeInfo);
|
||||
|
||||
/**
|
||||
* 删除repair_apply_record
|
||||
* @param repairAuditDetails
|
||||
* @return
|
||||
*/
|
||||
int deleteRepairRecordByTaskId(RepairAuditDetails repairAuditDetails);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,11 @@ public interface RepairCostMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRepairCostByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据任务id删除维修详细
|
||||
* @param repairCost
|
||||
* @return
|
||||
*/
|
||||
int deleteRepairCostByTaskId(RepairCost repairCost);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,11 @@ public interface RepairPartDetailsMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRepairPartDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量删除维修配件详细
|
||||
* @param repairPartDetails
|
||||
* @return
|
||||
*/
|
||||
int deleteRepairCostByTaskId(RepairPartDetails repairPartDetails);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@ 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.*;
|
||||
import com.bonus.material.repair.mapper.RepairApplyDetailsMapper;
|
||||
import com.bonus.material.repair.mapper.RepairAuditDetailsMapper;
|
||||
import com.bonus.material.repair.mapper.RepairMapper;
|
||||
import com.bonus.material.repair.mapper.*;
|
||||
import com.bonus.material.repair.service.RepairService;
|
||||
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
|
|
@ -89,6 +87,12 @@ public class RepairServiceImpl implements RepairService {
|
|||
@Resource
|
||||
private MachineMapper machineMapper;
|
||||
|
||||
@Resource
|
||||
private RepairCostMapper repairCostMapper;
|
||||
|
||||
@Resource
|
||||
private RepairPartDetailsMapper repairPartDetailsMapper;
|
||||
|
||||
// 1:内部维修 2:外部返厂维修 3:报废
|
||||
private final int INNER_REPAIR = 1; // 需要严格匹配枚举值 RepairTypeEnum.INNER_REPAIR.getTypeId();
|
||||
private final int RETURN_FACTORY = 2; // 需要严格匹配枚举值 RepairTypeEnum.RETURN_FACTORY.getTypeId();
|
||||
|
|
@ -1153,6 +1157,11 @@ public class RepairServiceImpl implements RepairService {
|
|||
return MaterialConstants.REPAIR_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回维修申请
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult rejectRepair(RepairTask bean) {
|
||||
|
|
@ -1205,6 +1214,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
extractedTaskId(taskId);
|
||||
} else {
|
||||
throw new ServiceException("维修任务没有前置任务,不能驳回");
|
||||
}
|
||||
|
|
@ -1219,10 +1229,10 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (repairedScrapNumber > 0) {
|
||||
throw new ServiceException("维修明细已有维修数据,不能驳回");
|
||||
}
|
||||
// 查询明细详情
|
||||
repairApplyDetails = repairApplyDetailsMapper.selectRepairApplyDetailsById(id);
|
||||
}
|
||||
for (Long id : bean.getIds()) {
|
||||
// 查询明细详情
|
||||
repairApplyDetails = repairApplyDetailsMapper.selectRepairApplyDetailsById(id);
|
||||
if (repairApplyDetails != null) {
|
||||
if (repairApplyDetails.getMaId() != null) {
|
||||
machineMapper.updateStatus(repairApplyDetails.getMaId(), MaMachineStatusEnum.IN_USE.getStatus());
|
||||
|
|
@ -1238,6 +1248,9 @@ public class RepairServiceImpl implements RepairService {
|
|||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
if (repairApplyDetails != null) {
|
||||
extractedByDetails(repairApplyDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final DataAccessException e) {
|
||||
|
|
@ -1247,6 +1260,88 @@ public class RepairServiceImpl implements RepairService {
|
|||
return AjaxResult.success("执行完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回至退料详情方法抽取
|
||||
* @param repairApplyDetails
|
||||
*/
|
||||
private void extractedByDetails(RepairApplyDetails repairApplyDetails) {
|
||||
int result;
|
||||
// 5.先根据taskId查询repair_apply_record表是否存在数据,存在则删除
|
||||
RepairAuditDetails repairAuditDetails = new RepairAuditDetails();
|
||||
repairAuditDetails.setTaskId(repairApplyDetails.getTaskId());
|
||||
repairAuditDetails.setTypeId(repairApplyDetails.getTypeId());
|
||||
repairAuditDetails.setMaId(repairApplyDetails.getMaId() == null ? null : repairApplyDetails.getMaId());
|
||||
List<RepairRecord> repairRecord = repairAuditDetailsMapper.getRepairRecord(repairAuditDetails);
|
||||
if (!CollectionUtils.isEmpty(repairRecord)) {
|
||||
result = repairAuditDetailsMapper.deleteRepairRecordByTaskId(repairAuditDetails);
|
||||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
// 6. 先根据taskId查询repair_cost表是否存在数据,存在则删除
|
||||
RepairCost repairCost = new RepairCost();
|
||||
repairCost.setTaskId(repairApplyDetails.getTaskId());
|
||||
repairCost.setTypeId(repairApplyDetails.getTypeId());
|
||||
repairCost.setMaId(repairApplyDetails.getMaId() == null ? null : repairApplyDetails.getMaId());
|
||||
List<RepairCost> repairCosts = repairCostMapper.selectRepairCostList(repairCost);
|
||||
if (!CollectionUtils.isEmpty(repairCosts)) {
|
||||
result = repairCostMapper.deleteRepairCostByTaskId(repairCost);
|
||||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
// 7. 先根据taskId查询repair_part_details表是否存在数据,存在则删除
|
||||
RepairPartDetails repairPartDetails = new RepairPartDetails();
|
||||
repairPartDetails.setTaskId(repairApplyDetails.getTaskId());
|
||||
repairPartDetails.setTypeId(repairApplyDetails.getTypeId());
|
||||
repairPartDetails.setMaId(repairApplyDetails.getMaId() == null ? null : repairApplyDetails.getMaId());
|
||||
List<RepairPartDetails> repairPartDetailList = repairPartDetailsMapper.selectRepairPartDetailsList(repairPartDetails);
|
||||
if (!CollectionUtils.isEmpty(repairPartDetailList)) {
|
||||
result = repairPartDetailsMapper.deleteRepairCostByTaskId(repairPartDetails);
|
||||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回至退料任务单抽取
|
||||
* @param taskId
|
||||
*/
|
||||
private void extractedTaskId(Long taskId) {
|
||||
int result;
|
||||
// 5.先根据taskId查询repair_apply_record表是否存在数据,存在则删除
|
||||
RepairAuditDetails repairAuditDetails = new RepairAuditDetails();
|
||||
repairAuditDetails.setTaskId(taskId);
|
||||
List<RepairRecord> repairRecord = repairAuditDetailsMapper.getRepairRecord(repairAuditDetails);
|
||||
if (!CollectionUtils.isEmpty(repairRecord)) {
|
||||
result = repairAuditDetailsMapper.deleteRepairRecordByTaskId(repairAuditDetails);
|
||||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
// 6. 先根据taskId查询repair_cost表是否存在数据,存在则删除
|
||||
RepairCost repairCost = new RepairCost();
|
||||
repairCost.setTaskId(taskId);
|
||||
List<RepairCost> repairCosts = repairCostMapper.selectRepairCostList(repairCost);
|
||||
if (!CollectionUtils.isEmpty(repairCosts)) {
|
||||
result = repairCostMapper.deleteRepairCostByTaskId(repairCost);
|
||||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
// 7. 先根据taskId查询repair_part_details表是否存在数据,存在则删除
|
||||
RepairPartDetails repairPartDetails = new RepairPartDetails();
|
||||
repairPartDetails.setTaskId(taskId);
|
||||
List<RepairPartDetails> repairPartDetailList = repairPartDetailsMapper.selectRepairPartDetailsList(repairPartDetails);
|
||||
if (!CollectionUtils.isEmpty(repairPartDetailList)) {
|
||||
result = repairPartDetailsMapper.deleteRepairCostByTaskId(repairPartDetails);
|
||||
if (result < 1) {
|
||||
throw new ServiceException("维修驳回失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 维修明细--批量合格--更新明细status,以及repairedNum
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -299,6 +299,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRepairRecordByTaskId">
|
||||
delete from repair_apply_record where task_id = #{taskId}
|
||||
<if test="typeId != null">
|
||||
and type_id = #{typeId}
|
||||
</if>
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<select id="selectRepairQuestList" resultType="com.bonus.material.repair.domain.vo.ScrapApplyDetailsVO">
|
||||
SELECT DISTINCT
|
||||
tk.task_id taskId,
|
||||
|
|
|
|||
|
|
@ -102,4 +102,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteRepairCostByTaskId">
|
||||
delete from repair_cost where task_id = #{taskId}
|
||||
<if test="typeId != null">
|
||||
and type_id = #{typeId}
|
||||
</if>
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -112,4 +112,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRepairCostByTaskId">
|
||||
delete from repair_part_details where task_id = #{taskId}
|
||||
<if test="typeId != null">
|
||||
and type_id = #{typeId}
|
||||
</if>
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue