定损驳回
This commit is contained in:
parent
af7f799433
commit
57f7bf5d16
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ public interface LossAssessmentService {
|
|||
|
||||
/**
|
||||
* 驳回至退料
|
||||
* @param taskList
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult rejectRepair(@NotNull List<Long> taskList);
|
||||
AjaxResult rejectRepair(RepairTask bean);
|
||||
|
||||
/**
|
||||
* 获取详情的详情
|
||||
|
|
|
|||
|
|
@ -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<Long> 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<BackCheckDetails> 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("执行完成");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,26 @@
|
|||
<result property="splitType" column="split_type" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.bonus.material.repair.domain.RepairApplyDetails" id="RepairApplyDetailsResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="maId" column="ma_id" />
|
||||
<result property="typeId" column="type_id" />
|
||||
<result property="repairNum" column="repair_num" />
|
||||
<result property="repairedNum" column="repaired_num" />
|
||||
<result property="scrapNum" column="scrap_num" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="companyId" column="company_id" />
|
||||
<result property="backId" column="back_id" />
|
||||
<result property="repairer" column="repairer" />
|
||||
<result property="preTaskId" column="pre_task_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTmTaskVo">
|
||||
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>
|
||||
|
||||
<update id="updateIsDs">
|
||||
update repair_apply_details
|
||||
set is_ds = 0
|
||||
where task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
<update id="updateStatus">
|
||||
update repair_apply_details
|
||||
set status = 1
|
||||
|
|
@ -204,6 +226,43 @@
|
|||
and is_ds = 1
|
||||
</update>
|
||||
|
||||
<delete id="deleteTask">
|
||||
delete from tm_task where task_id = #{taskId}
|
||||
</delete>
|
||||
<delete id="deleteApplyDetailsByTaskId">
|
||||
delete from repair_apply_details where task_id = #{taskId}
|
||||
</delete>
|
||||
<delete id="deleteRecordByTaskId">
|
||||
delete from repair_apply_record where task_id = #{taskId}
|
||||
</delete>
|
||||
<delete id="deletePartByTaskId">
|
||||
delete from repair_part_details where task_id = #{taskId}
|
||||
</delete>
|
||||
<delete id="deleteCostByTaskId">
|
||||
delete from repair_cost where task_id = #{taskId}
|
||||
</delete>
|
||||
<delete id="delDetailsById">
|
||||
delete from repair_apply_details where id = #{id}
|
||||
</delete>
|
||||
<delete id="delRecord">
|
||||
delete from repair_apply_record where task_id = #{taskId} and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
<delete id="delPart">
|
||||
delete from repair_part_details where task_id = #{taskId} and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
<delete id="delCost">
|
||||
delete from repair_cost where task_id = #{taskId} and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<select id="getLossAssessmentList" resultType="com.bonus.material.repair.domain.RepairTask">
|
||||
SELECT
|
||||
rd.task_id as taskId,
|
||||
|
|
@ -440,6 +499,36 @@
|
|||
mm.ma_code,
|
||||
mpt2.pa_id
|
||||
</select>
|
||||
<select id="selectTaskStatus" resultType="java.lang.Integer">
|
||||
SELECT task_status as taskStatus
|
||||
FROM tm_task
|
||||
WHERE task_id = #{taskId}
|
||||
</select>
|
||||
<select id="selectRepairApplyDetailsById" parameterType="Long" resultMap="RepairApplyDetailsResult">
|
||||
SELECT
|
||||
rad.id,
|
||||
rad.task_id,
|
||||
rad.ma_id,
|
||||
rad.type_id,
|
||||
rad.repair_num,
|
||||
rad.repaired_num,
|
||||
rad.scrap_num,
|
||||
rad.STATUS,
|
||||
rad.create_by,
|
||||
rad.create_time,
|
||||
rad.update_by,
|
||||
rad.update_time,
|
||||
rad.remark,
|
||||
rad.company_id,
|
||||
rad.back_id,
|
||||
rad.repairer,
|
||||
tt.pre_task_id
|
||||
FROM
|
||||
repair_apply_details rad
|
||||
LEFT JOIN tm_task tt on tt.task_id=rad.task_id
|
||||
WHERE
|
||||
id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue