接口优化
This commit is contained in:
parent
41b7547bae
commit
80f79f9221
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.common.biz.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author : mashuai
|
||||
* @version : 1.0
|
||||
* 退料任务状态枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum BackTaskStatusEnum {
|
||||
|
||||
BACK_TASK_NO_FINISHED(0, "退料未完成"),
|
||||
BACK_TASK_TO_REJECT(1, "维修驳回"),
|
||||
BACK_TASK_IN_FINISHED(3, "退料已完成");
|
||||
|
||||
private final Integer status;
|
||||
private final String statusName;
|
||||
|
||||
BackTaskStatusEnum(Integer status, String statusName) {
|
||||
this.status = status;
|
||||
this.statusName = statusName;
|
||||
}
|
||||
}
|
||||
|
|
@ -64,20 +64,6 @@ public interface BackApplyInfoMapper {
|
|||
*/
|
||||
String selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType);
|
||||
|
||||
/**
|
||||
* 新增任务
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
int insertTmTask(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* 新增任务关联协议
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
int insertTaskAgreement(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* 新增任务详情
|
||||
* @param details
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ import java.util.stream.Collectors;
|
|||
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.enums.BackTaskStatusEnum;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
|
|
@ -19,6 +21,8 @@ import com.bonus.material.back.domain.vo.MaCodeVo;
|
|||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.domain.TmTaskAgreement;
|
||||
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -233,26 +237,30 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
if (StringUtils.isBlank(code)) {
|
||||
return AjaxResult.error("后台退料编号生成异常,请重试!");
|
||||
}
|
||||
BackApplyInfo backApplyInfo = dto.getBackApplyInfo();
|
||||
backApplyInfo.setCode(code);
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||
backApplyInfo.setTaskType(3);
|
||||
backApplyInfo.setTaskStatus(0);
|
||||
backApplyInfo.setStatus("0");
|
||||
|
||||
int result = 0;
|
||||
try {
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result += backApplyInfoMapper.insertTmTask(backApplyInfo);
|
||||
if (result > 0) {
|
||||
Long taskId = backApplyInfo.getTaskId();
|
||||
result += backApplyInfoMapper.insertTaskAgreement(backApplyInfo);
|
||||
backApplyInfo.setTaskId(taskId);
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||
BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null,thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getUsername());
|
||||
BackApplyInfo backApplyInfo = dto.getBackApplyInfo();
|
||||
backApplyInfo.setTaskId(tmTask.getTaskId());
|
||||
backApplyInfo.setCode(code);
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result += taskMapper.insertTmTask(tmTask);
|
||||
if (result > 0) {
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId());
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
|
||||
}
|
||||
// 保存退料详情
|
||||
result = saveBackApplyDetails(dto, backApplyInfo, result);
|
||||
}
|
||||
// 保存退料详情
|
||||
result = saveBackApplyDetails(dto, backApplyInfo, result);
|
||||
} catch (Exception e) {
|
||||
log.error("保存退料信息时发生异常: ", e);
|
||||
}
|
||||
|
|
@ -271,7 +279,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
details.setCode(backApplyInfo.getCode());
|
||||
details.setParentId(backApplyInfo.getId());
|
||||
details.setAuditNum(details.getPreNum());
|
||||
details.setStatus("0");
|
||||
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
|
||||
details.setCreateBy(SecurityUtils.getUsername());
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料详情
|
||||
|
|
@ -419,23 +427,30 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
result += deleteFileInfoForDetails(backApplyDetailsList, id);
|
||||
// 删除编码设备附件
|
||||
result += deleteFileInfoForMaCodes(maCodeList, id);
|
||||
|
||||
if (result > 0) {
|
||||
//执行新增操作
|
||||
backApplyInfo.setTaskType(3);
|
||||
backApplyInfo.setTaskStatus(0);
|
||||
backApplyInfo.setStatus("0");
|
||||
backApplyInfo.setTaskType(TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
backApplyInfo.setTaskStatus(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus());
|
||||
backApplyInfo.setId(id);
|
||||
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
backApplyInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
backApplyInfo.setBackPerson(dto.getBackApplyInfo().getBackPerson());
|
||||
backApplyInfo.setPhone(dto.getBackApplyInfo().getPhone());
|
||||
backApplyInfo.setRemark(dto.getBackApplyInfo().getRemark() == null ? backApplyInfo.getRemark() : dto.getBackApplyInfo().getRemark());
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null,thisMonthMaxOrder + 1, backApplyInfo.getCode());
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getUsername());
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result += backApplyInfoMapper.insertTmTask(backApplyInfo);
|
||||
result += taskMapper.insertTmTask(tmTask);
|
||||
backApplyInfo.setTaskId(tmTask.getTaskId());
|
||||
if (result > 0) {
|
||||
Long taskId = backApplyInfo.getTaskId();
|
||||
result += backApplyInfoMapper.insertTaskAgreement(backApplyInfo);
|
||||
backApplyInfo.setTaskId(taskId);
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId());
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
result += backApplyInfoMapper.updateBackApplyInfo(backApplyInfo);
|
||||
}
|
||||
// 保存退料详情
|
||||
|
|
@ -714,11 +729,10 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
private int insertTta(Long taskId, List<BackApplyInfo> list) {
|
||||
int res;
|
||||
String agreementId = String.valueOf(list.get(0).getAgreementId());
|
||||
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||
backApplyInfo.setAgreementId(Long.parseLong(agreementId));
|
||||
backApplyInfo.setTaskId(taskId);
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
res = backApplyInfoMapper.insertTaskAgreement(backApplyInfo);
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(taskId, Long.parseLong(agreementId));
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||
res = taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -731,16 +745,16 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
Long newTask = null;
|
||||
// 生成维修单号
|
||||
String code = genCodeRule();
|
||||
BackApplyInfo applyInfo = new BackApplyInfo();
|
||||
applyInfo.setTaskType(4); // 设置任务类型
|
||||
applyInfo.setCode(code); // 设置单号
|
||||
applyInfo.setCreateBy(createBy); // 设置创建者
|
||||
applyInfo.setTaskStatus(0);
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null,thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(createBy);
|
||||
// 插入任务
|
||||
int taskId = backApplyInfoMapper.insertTmTask(applyInfo);
|
||||
int taskId = taskMapper.insertTmTask(tmTask);
|
||||
// 如果插入成功且返回的 taskId 大于 0
|
||||
if (taskId > 0 && applyInfo.getTaskId() > 0) {
|
||||
newTask = applyInfo.getTaskId();
|
||||
if (taskId > 0 && tmTask.getTaskId() > 0) {
|
||||
newTask = tmTask.getTaskId();
|
||||
}
|
||||
return newTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,65 +315,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertTmTask" parameterType = "com.bonus.material.back.domain.BackApplyInfo" keyColumn="task_id" keyProperty="taskId" useGeneratedKeys="true">
|
||||
insert into tm_task (
|
||||
<if test="taskType != null">task_type, </if>
|
||||
<if test="taskStatus != null">task_status, </if>
|
||||
<if test="code != null and code != ''">code, </if>
|
||||
<if test="createBy != null and createBy != ''">create_by, </if>
|
||||
<if test="remark != null and remark != ''">remark, </if>
|
||||
<if test="companyId != null">company_id, </if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="taskType != null">#{taskType}, </if>
|
||||
<if test="taskStatus != null">#{taskStatus}, </if>
|
||||
<if test="code != null and code != ''">#{code}, </if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy}, </if>
|
||||
<if test="remark != null and remark != ''">#{remark}, </if>
|
||||
<if test="companyId != null">#{companyId}, </if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertTaskAgreement">
|
||||
insert into tm_task_agreement
|
||||
(
|
||||
<if test="taskId != null">
|
||||
task_id,
|
||||
</if>
|
||||
<if test="agreementId != null">
|
||||
agreement_id,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="taskId != null">
|
||||
#{taskId},
|
||||
</if>
|
||||
<if test="agreementId != null">
|
||||
#{agreementId},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBackApplyDetails" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into back_apply_details
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
|
|||
|
|
@ -32,8 +32,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<insert id="insertTmTaskAgreement" parameterType="com.bonus.material.task.domain.TmTaskAgreement" useGeneratedKeys="true" keyProperty="taskId">
|
||||
INSERT INTO tm_task_agreement (task_id, agreement_id, create_by, create_time, company_id)
|
||||
VALUES(#{taskId},#{agreementId},#{createBy},NOW(),#{companyId})
|
||||
insert into tm_task_agreement
|
||||
(
|
||||
<if test="taskId != null">
|
||||
task_id,
|
||||
</if>
|
||||
<if test="agreementId != null">
|
||||
agreement_id,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="taskId != null">
|
||||
#{taskId},
|
||||
</if>
|
||||
<if test="agreementId != null">
|
||||
#{agreementId},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateTmTaskAgreement" parameterType="com.bonus.material.task.domain.TmTaskAgreement">
|
||||
|
|
|
|||
Loading…
Reference in New Issue