维修--修饰审核--字典引入、逻辑优化、SQL优化
This commit is contained in:
parent
fc797a22f3
commit
6aad1d0d8f
|
|
@ -57,6 +57,9 @@ public class MaterialConstants {
|
||||||
/** 领料单号的开头字母 */
|
/** 领料单号的开头字母 */
|
||||||
public static final String LEASE_TASK_TYPE_LABEL = "L";
|
public static final String LEASE_TASK_TYPE_LABEL = "L";
|
||||||
|
|
||||||
|
/** 维修单号的开头字母 */
|
||||||
|
public static final String REPAIR_TASK_TYPE_LABEL = "WX";
|
||||||
|
|
||||||
public static final String INNER_PROTOCAL = "1"; //内部单位协议
|
public static final String INNER_PROTOCAL = "1"; //内部单位协议
|
||||||
|
|
||||||
public static final String OUTER_PROTOCAL = "2"; //外部单位协议
|
public static final String OUTER_PROTOCAL = "2"; //外部单位协议
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.bonus.material.repair.mapper;
|
package com.bonus.material.repair.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.bonus.material.repair.domain.RepairAuditDetails;
|
import com.bonus.material.repair.domain.RepairAuditDetails;
|
||||||
import com.bonus.material.repair.domain.RepairPart;
|
import com.bonus.material.repair.domain.RepairPart;
|
||||||
import com.bonus.material.repair.domain.RepairRecord;
|
import com.bonus.material.repair.domain.RepairRecord;
|
||||||
|
|
@ -76,11 +78,25 @@ public interface RepairAuditDetailsMapper {
|
||||||
|
|
||||||
List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails);
|
List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据taskId查询单个规格名称---单个
|
||||||
|
* @param taskId 任务id
|
||||||
|
*/
|
||||||
String selectTypeNameByTaskId(Long taskId);
|
String selectTypeNameByTaskId(Long taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据taskIds批量查询规格名称---批量
|
||||||
|
* @param taskIds 任务id集合
|
||||||
|
*/
|
||||||
|
Map<Long, String> selectTypeNamesByTaskIds(List<Long> taskIds);
|
||||||
|
|
||||||
List<RepairAuditDetails> selectRepairAuditDetailsByTaskId(Long taskId);
|
List<RepairAuditDetails> selectRepairAuditDetailsByTaskId(Long taskId);
|
||||||
|
|
||||||
List<RepairAuditDetails> selectnotAuditByTaskId(Long taskId);
|
/**
|
||||||
|
* 根据taskId查询未审核的数据
|
||||||
|
* @param taskId 任务id
|
||||||
|
*/
|
||||||
|
List<RepairAuditDetails> selectNotAuditByTaskId(Long taskId);
|
||||||
|
|
||||||
List<RepairAuditDetails> selectRepairInputByTaskId(Long taskId);
|
List<RepairAuditDetails> selectRepairInputByTaskId(Long taskId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package com.bonus.material.repair.service.impl;
|
package com.bonus.material.repair.service.impl;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
import java.util.stream.Collectors;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
import com.bonus.common.biz.enums.RepairTaskStatusEnum;
|
import com.bonus.common.biz.enums.RepairTaskStatusEnum;
|
||||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
|
|
@ -100,13 +99,37 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails) {
|
public List<ScrapApplyDetailsVO> selectRepairQuestList(RepairAuditDetails repairAuditDetails) {
|
||||||
List<ScrapApplyDetailsVO> repairQuestList = repairAuditDetailsMapper.selectRepairQuestList(repairAuditDetails);
|
try {
|
||||||
for (ScrapApplyDetailsVO scrapApplyDetailsVO : repairQuestList) {
|
// 获取所有需要查询的 taskId、过滤空的
|
||||||
Long taskId = scrapApplyDetailsVO.getTaskId();
|
List<ScrapApplyDetailsVO> repairQuestList = repairAuditDetailsMapper.selectRepairQuestList(repairAuditDetails);
|
||||||
String typeName = repairAuditDetailsMapper.selectTypeNameByTaskId(taskId);
|
// 通过流过滤掉空对象 并转换为 List集合
|
||||||
scrapApplyDetailsVO.setItemType(typeName);
|
List<Long> taskIds = repairQuestList.stream()
|
||||||
|
.filter(Objects::nonNull) // 过滤掉空的 ScrapApplyDetailsVO 对象
|
||||||
|
.map(ScrapApplyDetailsVO::getTaskId)
|
||||||
|
.filter(Objects::nonNull) // 过滤掉空的 taskId
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 批量查询 typeName
|
||||||
|
Map<Long, String> typeNameMap = repairAuditDetailsMapper.selectTypeNamesByTaskIds(taskIds);
|
||||||
|
|
||||||
|
// 设置 itemType
|
||||||
|
for (ScrapApplyDetailsVO scrapApplyDetailsVO : repairQuestList) {
|
||||||
|
Long taskId = scrapApplyDetailsVO.getTaskId();
|
||||||
|
if (taskId != null) {
|
||||||
|
String typeName = typeNameMap.get(taskId);
|
||||||
|
if (typeName != null) {
|
||||||
|
scrapApplyDetailsVO.setItemType(typeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return repairQuestList;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 异常处理
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServiceException("Failed to get repair quest list" + e.getMessage());
|
||||||
}
|
}
|
||||||
return repairQuestList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,13 +147,13 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
Integer b = 0;
|
Integer b = 0;
|
||||||
for (Long taskId : taskIdList) {
|
for (Long taskId : taskIdList) {
|
||||||
char status;
|
char status;
|
||||||
TmTask task1 = taskMapper.selectTmTaskByTaskId(taskId);
|
TmTask tmTask = taskMapper.selectTmTaskByTaskId(taskId);
|
||||||
if (task1.getTaskStatus() == 47) {
|
if (tmTask.getTaskStatus() == 47) {
|
||||||
throw new Exception("任务已审核已通过");
|
throw new Exception("任务已审核已通过");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RepairAuditDetails> auditAllList = repairAuditDetailsMapper.selectRepairAuditDetailsByTaskId(taskId);
|
List<RepairAuditDetails> auditAllList = repairAuditDetailsMapper.selectRepairAuditDetailsByTaskId(taskId);
|
||||||
List<RepairAuditDetails> notAuditList = repairAuditDetailsMapper.selectnotAuditByTaskId(taskId);
|
List<RepairAuditDetails> notAuditList = repairAuditDetailsMapper.selectNotAuditByTaskId(taskId);
|
||||||
// 查询协议表
|
// 查询协议表
|
||||||
TmTaskAgreement tmTaskAgreement = agreementMapper.selectTmTaskAgreementByTaskId(taskId);
|
TmTaskAgreement tmTaskAgreement = agreementMapper.selectTmTaskAgreementByTaskId(taskId);
|
||||||
String taskCode;
|
String taskCode;
|
||||||
|
|
@ -231,16 +254,16 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
// 修饰审核通过时改修任务为已通过审核
|
// 修饰审核通过时改修任务为已通过审核
|
||||||
if (auditDetailList != null) {
|
if (auditDetailList != null) {
|
||||||
if (auditDetailList.size() == notAuditList.size()) {
|
if (auditDetailList.size() == notAuditList.size()) {
|
||||||
task1.setTaskStatus(47);
|
tmTask.setTaskStatus(47);
|
||||||
}
|
}
|
||||||
} else if (auditAllList != null) {
|
} else if (auditAllList != null) {
|
||||||
if (auditAllList.size() == notAuditList.size()) {
|
if (auditAllList.size() == notAuditList.size()) {
|
||||||
task1.setTaskStatus(47);
|
tmTask.setTaskStatus(47);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
task1.setUpdateTime(new Date());
|
tmTask.setUpdateTime(new Date());
|
||||||
task1.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
tmTask.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||||
taskMapper.updateTmTask(task1);
|
taskMapper.updateTmTask(tmTask);
|
||||||
} else {
|
} else {
|
||||||
status = 2;
|
status = 2;
|
||||||
List<RepairAuditDetails> repairDetailList = new ArrayList<>();
|
List<RepairAuditDetails> repairDetailList = new ArrayList<>();
|
||||||
|
|
@ -253,7 +276,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
if (repairDetailList.get(0).getCompanyId() != null) {
|
if (repairDetailList.get(0).getCompanyId() != null) {
|
||||||
companyId = repairDetailList.get(0).getCompanyId();
|
companyId = repairDetailList.get(0).getCompanyId();
|
||||||
}
|
}
|
||||||
taskCode = purchaseCodeRule("WX", 41);
|
taskCode = purchaseCodeRule(MaterialConstants.REPAIR_TASK_TYPE_LABEL, 41);
|
||||||
taskStatus = 43;
|
taskStatus = 43;
|
||||||
taskType = 41;
|
taskType = 41;
|
||||||
long inputTaskId = genTask(taskCode, taskType, taskStatus, tmTaskAgreement, companyId);
|
long inputTaskId = genTask(taskCode, taskType, taskStatus, tmTaskAgreement, companyId);
|
||||||
|
|
@ -275,15 +298,15 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 修饰审核任务不通过时
|
// 修饰审核任务不通过时
|
||||||
TmTask tmTask = new TmTask();
|
TmTask tmTaskNotExam = new TmTask();
|
||||||
tmTask.setTaskId(taskId);
|
tmTaskNotExam.setTaskId(taskId);
|
||||||
tmTask.setRemark(scrapAudit.getRemark());
|
tmTaskNotExam.setRemark(scrapAudit.getRemark());
|
||||||
if (repairDetailList.size() == notAuditList.size()) {
|
if (repairDetailList.size() == notAuditList.size()) {
|
||||||
tmTask.setTaskStatus(48);
|
tmTaskNotExam.setTaskStatus(48);
|
||||||
}
|
}
|
||||||
tmTask.setUpdateTime(new Date());
|
tmTaskNotExam.setUpdateTime(new Date());
|
||||||
tmTask.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
tmTaskNotExam.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||||
taskMapper.updateTmTask(tmTask);
|
taskMapper.updateTmTask(tmTaskNotExam);
|
||||||
}
|
}
|
||||||
if (scrapAudit.getAuditDetailList() != null && scrapAudit.getAuditDetailList().size() > 0) {
|
if (scrapAudit.getAuditDetailList() != null && scrapAudit.getAuditDetailList().size() > 0) {
|
||||||
if (auditDetailList != null) {
|
if (auditDetailList != null) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectRepairAuditDetailsVo">
|
<sql id="selectRepairAuditDetailsVo">
|
||||||
select id, task_id, repair_id, ma_id, type_id, repair_num, repaired_num, scrap_num, audit_by, audit_time, audit_remark, status, create_by, create_time, update_by, update_time, remark, company_id from repair_audit_details
|
select id, task_id, repair_id, ma_id, type_id, repair_num, repaired_num, scrap_num, audit_by, audit_time,
|
||||||
|
audit_remark, status, create_by, create_time, update_by, update_time, remark, company_id
|
||||||
|
from repair_audit_details
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectRepairAuditDetailsList" parameterType="com.bonus.material.repair.domain.RepairAuditDetails" resultMap="RepairAuditDetailsResult">
|
<select id="selectRepairAuditDetailsList" parameterType="com.bonus.material.repair.domain.RepairAuditDetails" resultMap="RepairAuditDetailsResult">
|
||||||
|
|
@ -41,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="auditBy != null "> and audit_by = #{auditBy}</if>
|
<if test="auditBy != null "> and audit_by = #{auditBy}</if>
|
||||||
<if test="auditTime != null "> and audit_time = #{auditTime}</if>
|
<if test="auditTime != null "> and audit_time = #{auditTime}</if>
|
||||||
<if test="auditRemark != null and auditRemark != ''"> and audit_remark = #{auditRemark}</if>
|
<if test="auditRemark != null and auditRemark != ''"> and audit_remark = #{auditRemark}</if>
|
||||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
<if test="status != null and status != ''"> and `status` = #{status}</if>
|
||||||
<if test="companyId != null "> and company_id = #{companyId}</if>
|
<if test="companyId != null "> and company_id = #{companyId}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -52,34 +54,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getRepairId" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
|
<select id="getRepairId" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
|
||||||
select task_id as taskId,
|
select
|
||||||
ma_id as maId,
|
task_id as taskId,
|
||||||
type_id as typeId
|
ma_id as maId,
|
||||||
from repair_apply_details
|
type_id as typeId
|
||||||
where id = #{repairId}
|
from
|
||||||
|
repair_apply_details
|
||||||
|
where
|
||||||
|
id = #{repairId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getPartRecord" resultType="com.bonus.material.repair.domain.RepairPart">
|
<select id="getPartRecord" resultType="com.bonus.material.repair.domain.RepairPart">
|
||||||
select concat(mpt2.pa_name,'-',mpt1.pa_name,'-',mpt.pa_name) as partName,
|
select
|
||||||
rpd.part_num as partNum,
|
concat(mpt2.pa_name,'-',mpt1.pa_name,'-',mpt.pa_name) as partName,
|
||||||
rpd.part_cost as partCost,
|
rpd.part_num as partNum,
|
||||||
rpd.part_type as partType,
|
rpd.part_cost as partCost,
|
||||||
rpd.remark as remark,
|
rpd.part_type as partType,
|
||||||
rpd.repair_content as repairContent
|
rpd.remark as remark,
|
||||||
from repair_part_details rpd
|
rpd.repair_content as repairContent
|
||||||
|
from
|
||||||
|
repair_part_details rpd
|
||||||
left join ma_part_type mpt on mpt.pa_id = rpd.part_id
|
left join ma_part_type mpt on mpt.pa_id = rpd.part_id
|
||||||
left join ma_part_type mpt1 on mpt1.pa_id = mpt.parent_id
|
left join ma_part_type mpt1 on mpt1.pa_id = mpt.parent_id
|
||||||
left join ma_part_type mpt2 on mpt2.pa_id = mpt1.parent_id
|
left join ma_part_type mpt2 on mpt2.pa_id = mpt1.parent_id
|
||||||
where 1=1
|
<where>
|
||||||
<if test="taskId != null and taskId != ''">
|
<if test="taskId != null and taskId != ''">
|
||||||
and rpd.task_id = #{taskId}
|
and rpd.task_id = #{taskId}
|
||||||
</if>
|
</if>
|
||||||
<if test="maId != null and maId != ''">
|
<if test="maId != null and maId != ''">
|
||||||
and rpd.ma_id = #{maId}
|
and rpd.ma_id = #{maId}
|
||||||
</if>
|
</if>
|
||||||
<if test="typeId != null and typeId != ''">
|
<if test="typeId != null and typeId != ''">
|
||||||
and rpd.type_id = #{typeId}
|
and rpd.type_id = #{typeId}
|
||||||
</if>
|
</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="exportRepairQuestList" resultType="com.bonus.material.repair.domain.vo.RepairAuditDetailsVO">
|
<select id="exportRepairQuestList" resultType="com.bonus.material.repair.domain.vo.RepairAuditDetailsVO">
|
||||||
|
|
@ -141,33 +149,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getRepairRecord" resultType="com.bonus.material.repair.domain.RepairRecord">
|
<select id="getRepairRecord" resultType="com.bonus.material.repair.domain.RepairRecord">
|
||||||
select repair_num as repairNum,
|
select
|
||||||
scrap_num as scrapNum,
|
repair_num as repairNum,
|
||||||
repair_type as repairType,
|
scrap_num as scrapNum,
|
||||||
scrap_reason as scrapReason,
|
repair_type as repairType,
|
||||||
scrap_type as scrapType,
|
scrap_reason as scrapReason,
|
||||||
msi.supplier as supplier,
|
scrap_type as scrapType,
|
||||||
part_num as partNum,
|
msi.supplier as supplier,
|
||||||
part_price as partPrice,
|
part_num as partNum,
|
||||||
repair_content as repairContent,
|
part_price as partPrice,
|
||||||
part_type as partType,
|
repair_content as repairContent,
|
||||||
part_name as partName,
|
part_type as partType,
|
||||||
file_ids as fileIds,
|
part_name as partName,
|
||||||
su.nick_name as repairer,
|
file_ids as fileIds,
|
||||||
rar.remark
|
su.nick_name as repairer,
|
||||||
from repair_apply_record rar
|
rar.remark
|
||||||
left join ma_supplier_info msi on msi.supplier_id = rar.supplier_id
|
from
|
||||||
left join sys_user su on su.user_id = rar.repairer
|
repair_apply_record rar
|
||||||
where 1=1
|
left join
|
||||||
<if test="taskId != null and taskId != ''">
|
ma_supplier_info msi on msi.supplier_id = rar.supplier_id
|
||||||
and rar.task_id = #{taskId}
|
left join
|
||||||
</if>
|
sys_user su on su.user_id = rar.repairer
|
||||||
<if test="maId != null and maId != ''">
|
<where>
|
||||||
and rar.ma_id = #{maId}
|
<if test="taskId != null and taskId != ''">
|
||||||
</if>
|
and rar.task_id = #{taskId}
|
||||||
<if test="typeId != null and typeId != ''">
|
</if>
|
||||||
and rar.type_id = #{typeId}
|
<if test="maId != null and maId != ''">
|
||||||
</if>
|
and rar.ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
<if test="typeId != null and typeId != ''">
|
||||||
|
and rar.type_id = #{typeId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertRepairAuditDetails" parameterType="com.bonus.material.repair.domain.RepairAuditDetails" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertRepairAuditDetails" parameterType="com.bonus.material.repair.domain.RepairAuditDetails" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|
@ -316,9 +329,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where task_id = #{taskId}
|
where task_id = #{taskId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectnotAuditByTaskId" resultMap="RepairAuditDetailsResult">
|
<select id="selectNotAuditByTaskId" resultMap="RepairAuditDetailsResult">
|
||||||
<include refid="selectRepairAuditDetailsVo"/>
|
<include refid="selectRepairAuditDetailsVo"/>
|
||||||
where task_id = #{taskId} and rd.STATUS = '0'
|
where task_id = #{taskId} and `status` = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectRepairInputByTaskId" resultMap="RepairAuditDetailsResult">
|
<select id="selectRepairInputByTaskId" resultMap="RepairAuditDetailsResult">
|
||||||
|
|
@ -435,4 +448,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<update id="updateRecodeStatus">
|
<update id="updateRecodeStatus">
|
||||||
update repair_apply_record set status = 1,update_time = now() where id = #{id}
|
update repair_apply_record set status = 1,update_time = now() where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectTypeNamesByTaskIds" resultType="java.util.Map">
|
||||||
|
<if test="taskIds != null and taskIds.size() > 0">
|
||||||
|
select
|
||||||
|
task_id, GROUP_CONCAT(type_name) as typeName
|
||||||
|
from
|
||||||
|
(select distinct rad.task_id, mt1.type_name
|
||||||
|
from repair_audit_details rad
|
||||||
|
left join ma_type mt on rad.type_id = mt.type_id
|
||||||
|
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
||||||
|
where rad.task_id in
|
||||||
|
<foreach item="taskId" index="index" collection="taskIds" open="(" separator="," close=")">
|
||||||
|
#{taskId}
|
||||||
|
</foreach>
|
||||||
|
) t
|
||||||
|
GROUP BY task_id
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue