接口优化

This commit is contained in:
mashuai 2024-11-19 18:20:07 +08:00
parent 41b7547bae
commit 80f79f9221
5 changed files with 112 additions and 113 deletions

View File

@ -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;
}
}

View File

@ -64,20 +64,6 @@ public interface BackApplyInfoMapper {
*/ */
String selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType); 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 * @param details

View File

@ -6,7 +6,9 @@ import java.util.stream.Collectors;
import cn.hutool.core.util.PhoneUtil; import cn.hutool.core.util.PhoneUtil;
import com.alibaba.nacos.common.utils.CollectionUtils; 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.HttpCodeEnum;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils; 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.domain.BmFileInfo;
import com.bonus.material.basic.mapper.BmFileInfoMapper; import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.settlement.domain.SltAgreementInfo; 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.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper; import com.bonus.material.task.mapper.TmTaskMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -233,26 +237,30 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
return AjaxResult.error("后台退料编号生成异常,请重试!"); 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; int result = 0;
try { try {
// 保存退料信息到 tm_task 表中 int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
result += backApplyInfoMapper.insertTmTask(backApplyInfo); TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
if (result > 0) { BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
Long taskId = backApplyInfo.getTaskId(); null,thisMonthMaxOrder + 1, code);
result += backApplyInfoMapper.insertTaskAgreement(backApplyInfo); tmTask.setCreateTime(DateUtils.getNowDate());
backApplyInfo.setTaskId(taskId); 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 += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
} }
// 保存退料详情 // 保存退料详情
result = saveBackApplyDetails(dto, backApplyInfo, result); result = saveBackApplyDetails(dto, backApplyInfo, result);
} catch (Exception e) { } catch (Exception e) {
log.error("保存退料信息时发生异常: ", e); log.error("保存退料信息时发生异常: ", e);
} }
@ -271,7 +279,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
details.setCode(backApplyInfo.getCode()); details.setCode(backApplyInfo.getCode());
details.setParentId(backApplyInfo.getId()); details.setParentId(backApplyInfo.getId());
details.setAuditNum(details.getPreNum()); details.setAuditNum(details.getPreNum());
details.setStatus("0"); details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
details.setCreateBy(SecurityUtils.getUsername()); details.setCreateBy(SecurityUtils.getUsername());
details.setCreateTime(DateUtils.getNowDate()); details.setCreateTime(DateUtils.getNowDate());
// 保存退料详情 // 保存退料详情
@ -419,23 +427,30 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
result += deleteFileInfoForDetails(backApplyDetailsList, id); result += deleteFileInfoForDetails(backApplyDetailsList, id);
// 删除编码设备附件 // 删除编码设备附件
result += deleteFileInfoForMaCodes(maCodeList, id); result += deleteFileInfoForMaCodes(maCodeList, id);
if (result > 0) { if (result > 0) {
//执行新增操作 //执行新增操作
backApplyInfo.setTaskType(3); backApplyInfo.setTaskType(TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
backApplyInfo.setTaskStatus(0); backApplyInfo.setTaskStatus(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus());
backApplyInfo.setStatus("0");
backApplyInfo.setId(id); backApplyInfo.setId(id);
backApplyInfo.setUpdateTime(DateUtils.getNowDate()); backApplyInfo.setUpdateTime(DateUtils.getNowDate());
backApplyInfo.setUpdateBy(SecurityUtils.getUsername()); backApplyInfo.setUpdateBy(SecurityUtils.getUsername());
backApplyInfo.setBackPerson(dto.getBackApplyInfo().getBackPerson()); backApplyInfo.setBackPerson(dto.getBackApplyInfo().getBackPerson());
backApplyInfo.setPhone(dto.getBackApplyInfo().getPhone()); backApplyInfo.setPhone(dto.getBackApplyInfo().getPhone());
backApplyInfo.setRemark(dto.getBackApplyInfo().getRemark() == null ? backApplyInfo.getRemark() : dto.getBackApplyInfo().getRemark()); 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 表中 // 保存退料信息到 tm_task 表中
result += backApplyInfoMapper.insertTmTask(backApplyInfo); result += taskMapper.insertTmTask(tmTask);
backApplyInfo.setTaskId(tmTask.getTaskId());
if (result > 0) { if (result > 0) {
Long taskId = backApplyInfo.getTaskId(); TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId());
result += backApplyInfoMapper.insertTaskAgreement(backApplyInfo); tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
backApplyInfo.setTaskId(taskId); tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
result += backApplyInfoMapper.updateBackApplyInfo(backApplyInfo); result += backApplyInfoMapper.updateBackApplyInfo(backApplyInfo);
} }
// 保存退料详情 // 保存退料详情
@ -714,11 +729,10 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
private int insertTta(Long taskId, List<BackApplyInfo> list) { private int insertTta(Long taskId, List<BackApplyInfo> list) {
int res; int res;
String agreementId = String.valueOf(list.get(0).getAgreementId()); String agreementId = String.valueOf(list.get(0).getAgreementId());
BackApplyInfo backApplyInfo = new BackApplyInfo(); TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(taskId, Long.parseLong(agreementId));
backApplyInfo.setAgreementId(Long.parseLong(agreementId)); tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
backApplyInfo.setTaskId(taskId); tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
backApplyInfo.setCreateBy(SecurityUtils.getUsername()); res = taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
res = backApplyInfoMapper.insertTaskAgreement(backApplyInfo);
return res; return res;
} }
@ -731,16 +745,16 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
Long newTask = null; Long newTask = null;
// 生成维修单号 // 生成维修单号
String code = genCodeRule(); String code = genCodeRule();
BackApplyInfo applyInfo = new BackApplyInfo(); int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
applyInfo.setTaskType(4); // 设置任务类型 TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
applyInfo.setCode(code); // 设置单号 null,thisMonthMaxOrder + 1, code);
applyInfo.setCreateBy(createBy); // 设置创建者 tmTask.setCreateTime(DateUtils.getNowDate());
applyInfo.setTaskStatus(0); tmTask.setCreateBy(createBy);
// 插入任务 // 插入任务
int taskId = backApplyInfoMapper.insertTmTask(applyInfo); int taskId = taskMapper.insertTmTask(tmTask);
// 如果插入成功且返回的 taskId 大于 0 // 如果插入成功且返回的 taskId 大于 0
if (taskId > 0 && applyInfo.getTaskId() > 0) { if (taskId > 0 && tmTask.getTaskId() > 0) {
newTask = applyInfo.getTaskId(); newTask = tmTask.getTaskId();
} }
return newTask; return newTask;
} }

View File

@ -315,65 +315,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </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 id="insertBackApplyDetails" useGeneratedKeys="true" keyProperty="id">
insert into back_apply_details insert into back_apply_details
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -32,8 +32,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="insertTmTaskAgreement" parameterType="com.bonus.material.task.domain.TmTaskAgreement" useGeneratedKeys="true" keyProperty="taskId"> <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) insert into tm_task_agreement
VALUES(#{taskId},#{agreementId},#{createBy},NOW(),#{companyId}) (
<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>
<update id="updateTmTaskAgreement" parameterType="com.bonus.material.task.domain.TmTaskAgreement"> <update id="updateTmTaskAgreement" parameterType="com.bonus.material.task.domain.TmTaskAgreement">