2024-09-27 15:44:11 +08:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
|
<!DOCTYPE mapper
|
|
|
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
|
<mapper namespace="com.bonus.material.repair.mapper.RepairAuditDetailsMapper">
|
|
|
|
|
|
<resultMap type="com.bonus.material.repair.domain.RepairAuditDetails" id="RepairAuditDetailsResult">
|
|
|
|
|
|
<result property="id" column="id" />
|
|
|
|
|
|
<result property="taskId" column="task_id" />
|
|
|
|
|
|
<result property="repairId" column="repair_id" />
|
|
|
|
|
|
<result property="maId" column="ma_id" />
|
|
|
|
|
|
<result property="typeId" column="type_id" />
|
2024-11-15 10:15:37 +08:00
|
|
|
|
<result property="specificationType" column="specification_type" />
|
|
|
|
|
|
<result property="machineTypeName" column="machine_type_name" />
|
2024-09-27 15:44:11 +08:00
|
|
|
|
<result property="repairNum" column="repair_num" />
|
|
|
|
|
|
<result property="repairedNum" column="repaired_num" />
|
|
|
|
|
|
<result property="scrapNum" column="scrap_num" />
|
|
|
|
|
|
<result property="auditBy" column="audit_by" />
|
|
|
|
|
|
<result property="auditTime" column="audit_time" />
|
|
|
|
|
|
<result property="auditRemark" column="audit_remark" />
|
|
|
|
|
|
<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" />
|
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
|
|
<sql id="selectRepairAuditDetailsVo">
|
2024-11-14 17:37:57 +08:00
|
|
|
|
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
|
2024-09-27 15:44:11 +08:00
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectRepairAuditDetailsList" parameterType="com.bonus.material.repair.domain.RepairAuditDetails" resultMap="RepairAuditDetailsResult">
|
2024-11-15 10:15:37 +08:00
|
|
|
|
select
|
2025-09-02 23:57:30 +08:00
|
|
|
|
rad.* ,mt.type_name as specification_type, mt1.type_name as machine_type_name, mma.ma_code as maCode,sdd.dict_label as maStatus,
|
2025-01-16 19:17:10 +08:00
|
|
|
|
rad.ma_id as maId
|
2025-01-17 13:01:14 +08:00
|
|
|
|
,mt.manage_type as manageType,
|
2025-07-17 18:35:51 +08:00
|
|
|
|
su.nick_name as auditName,
|
2025-07-22 08:57:01 +08:00
|
|
|
|
mt4.type_id as firstId,
|
|
|
|
|
|
mt.unit_name as unitName
|
2024-11-15 10:15:37 +08:00
|
|
|
|
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
|
|
|
|
|
|
left join ma_machine mma on rad.ma_id= mma.ma_id
|
2025-09-02 23:57:30 +08:00
|
|
|
|
LEFT JOIN sys_dict_data sdd on mma.ma_status=sdd.dict_value and sdd.dict_type='ma_machine_status'
|
2025-01-17 13:01:14 +08:00
|
|
|
|
LEFT JOIN sys_user su on rad.audit_by = su.user_id
|
2025-07-17 18:35:51 +08:00
|
|
|
|
left join ma_type mt3 ON mt1.parent_id = mt3.type_id and mt3.del_flag = '0'
|
|
|
|
|
|
left join ma_type mt4 ON mt3.parent_id = mt4.type_id and mt4.del_flag = '0'
|
|
|
|
|
|
<if test="userId != null">
|
|
|
|
|
|
JOIN ma_type_repair mtr ON mtr.type_id = rad.type_id AND mtr.user_id = #{userId}
|
|
|
|
|
|
</if>
|
2024-11-15 10:15:37 +08:00
|
|
|
|
where
|
|
|
|
|
|
rad.task_id = #{taskId}
|
|
|
|
|
|
<if test="keyword != null and keyword != ''">
|
2025-09-02 23:57:30 +08:00
|
|
|
|
and (
|
|
|
|
|
|
mt.type_name like concat('%',#{keyword},'%')
|
|
|
|
|
|
or mt1.type_name like concat('%',#{keyword},'%')
|
|
|
|
|
|
or mma.ma_code like concat('%',#{keyword},'%')
|
|
|
|
|
|
or su.nick_name like concat('%',#{keyword},'%')
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="keys != null and keys != ''">
|
|
|
|
|
|
and (
|
|
|
|
|
|
mt.type_name like concat('%',#{keys},'%')
|
|
|
|
|
|
or mt1.type_name like concat('%',#{keys},'%')
|
|
|
|
|
|
or mma.ma_code like concat('%',#{keys},'%')
|
|
|
|
|
|
or su.nick_name like concat('%',#{keys},'%')
|
|
|
|
|
|
)
|
2024-11-15 10:15:37 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="type != null and type != ''">
|
|
|
|
|
|
AND mt.type_id = #{type}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeName != null and typeName != ''">
|
|
|
|
|
|
AND mt1.type_id = #{typeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
order by rad.create_time desc
|
2024-09-27 15:44:11 +08:00
|
|
|
|
</select>
|
2024-11-25 14:31:54 +08:00
|
|
|
|
|
|
|
|
|
|
<select id="selectRepairAuditDetailsByTaskIds" resultMap="RepairAuditDetailsResult">
|
|
|
|
|
|
select
|
2025-01-10 09:47:54 +08:00
|
|
|
|
rad.* ,mt.type_name as specification_type, mt1.type_name as machine_type_name, mma.ma_code as ma_id
|
2024-11-25 14:31:54 +08:00
|
|
|
|
from
|
2025-01-10 09:47:54 +08:00
|
|
|
|
repair_audit_details rad
|
2024-11-25 14:31:54 +08:00
|
|
|
|
left join ma_type mt on rad.type_id = mt.type_id
|
|
|
|
|
|
left join ma_type mt1 on mt.parent_id = mt1.type_id
|
|
|
|
|
|
left join ma_machine mma on rad.ma_id= mma.ma_id
|
|
|
|
|
|
where
|
2025-01-16 19:17:10 +08:00
|
|
|
|
rad.status = '0'
|
|
|
|
|
|
and rad.task_id in
|
2024-11-25 14:31:54 +08:00
|
|
|
|
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
|
|
|
|
|
|
#{taskId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
order by rad.create_time desc
|
|
|
|
|
|
</select>
|
2025-07-23 18:44:54 +08:00
|
|
|
|
|
2024-09-27 15:44:11 +08:00
|
|
|
|
<select id="selectRepairAuditDetailsById" parameterType="Long" resultMap="RepairAuditDetailsResult">
|
|
|
|
|
|
<include refid="selectRepairAuditDetailsVo"/>
|
|
|
|
|
|
where id = #{id}
|
|
|
|
|
|
</select>
|
2024-11-14 13:48:21 +08:00
|
|
|
|
|
|
|
|
|
|
<select id="getRepairId" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
|
2024-11-14 17:37:57 +08:00
|
|
|
|
select
|
|
|
|
|
|
task_id as taskId,
|
|
|
|
|
|
ma_id as maId,
|
|
|
|
|
|
type_id as typeId
|
|
|
|
|
|
from
|
|
|
|
|
|
repair_apply_details
|
|
|
|
|
|
where
|
|
|
|
|
|
id = #{repairId}
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getPartRecord" resultType="com.bonus.material.repair.domain.RepairPart">
|
2024-11-14 17:37:57 +08:00
|
|
|
|
select
|
|
|
|
|
|
concat(mpt2.pa_name,'-',mpt1.pa_name,'-',mpt.pa_name) as partName,
|
|
|
|
|
|
rpd.part_num as partNum,
|
|
|
|
|
|
rpd.part_cost as partCost,
|
|
|
|
|
|
rpd.part_type as partType,
|
|
|
|
|
|
rpd.remark as remark,
|
|
|
|
|
|
rpd.repair_content as repairContent
|
|
|
|
|
|
from
|
|
|
|
|
|
repair_part_details rpd
|
2024-11-14 13:48:21 +08:00
|
|
|
|
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 mpt2 on mpt2.pa_id = mpt1.parent_id
|
2024-11-14 17:37:57 +08:00
|
|
|
|
<where>
|
|
|
|
|
|
<if test="taskId != null and taskId != ''">
|
|
|
|
|
|
and rpd.task_id = #{taskId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="maId != null and maId != ''">
|
|
|
|
|
|
and rpd.ma_id = #{maId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeId != null and typeId != ''">
|
|
|
|
|
|
and rpd.type_id = #{typeId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="exportRepairQuestList" resultType="com.bonus.material.repair.domain.vo.RepairAuditDetailsVO">
|
|
|
|
|
|
SELECT DISTINCT
|
2024-11-14 15:09:28 +08:00
|
|
|
|
tk.task_id taskId,
|
|
|
|
|
|
tk.CODE scrapNum,
|
|
|
|
|
|
tk.task_status taskStatus,
|
|
|
|
|
|
bui.unit_name unitName,
|
|
|
|
|
|
bpl.pro_name projectName,
|
|
|
|
|
|
su.nick_name createBy,
|
|
|
|
|
|
tk.create_time createTime,
|
|
|
|
|
|
tk.remark,
|
|
|
|
|
|
tk.CODE repairNum,
|
|
|
|
|
|
mt1.type_name as type,
|
|
|
|
|
|
mt.type_name as typeName,
|
|
|
|
|
|
mma.ma_code as maCode,
|
|
|
|
|
|
rad.repair_num as repairNum2,
|
|
|
|
|
|
rad.repaired_num as repairedNum2,
|
|
|
|
|
|
rad.scrap_num as scrapNum2
|
2024-11-14 13:48:21 +08:00
|
|
|
|
FROM
|
2024-11-14 15:09:28 +08:00
|
|
|
|
tm_task tk
|
2024-11-14 13:48:21 +08:00
|
|
|
|
LEFT JOIN tm_task_agreement tta ON tk.task_id = tta.task_id
|
|
|
|
|
|
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
|
2024-11-14 14:53:08 +08:00
|
|
|
|
LEFT JOIN bm_project bpl ON bai.project_id = bpl.pro_id
|
|
|
|
|
|
LEFT JOIN bm_unit bui ON bai.unit_id = bui.unit_id
|
2024-11-14 13:48:21 +08:00
|
|
|
|
LEFT JOIN repair_audit_details rad ON tk.task_id = rad.task_id
|
|
|
|
|
|
LEFT JOIN ma_type mt ON rad.type_id = mt.type_id
|
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
|
left join ma_machine mma on rad.ma_id= mma.ma_id
|
|
|
|
|
|
LEFT JOIN sys_user su ON su.user_id = tk.create_by
|
|
|
|
|
|
WHERE
|
2024-11-25 11:22:35 +08:00
|
|
|
|
tk.task_type = #{taskType}
|
2024-11-14 15:09:28 +08:00
|
|
|
|
<if test="keyword != null and keyword != ''">
|
|
|
|
|
|
AND (locate(#{keyword}, su.nick_name) > 0
|
|
|
|
|
|
or locate(#{keyword}, tk.CODE) > 0
|
|
|
|
|
|
or locate(#{keyword}, bui.unit_name) > 0
|
|
|
|
|
|
or locate(#{keyword}, bpl.pro_name) > 0)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backUnit != null and backUnit != ''">
|
|
|
|
|
|
and bui.unit_id = #{backUnit}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
|
and tk.task_status = #{taskStatus}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backPro != null and backPro != ''">
|
|
|
|
|
|
and bpl.pro_id = #{backPro}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="type != null and type != ''">
|
|
|
|
|
|
and mt1.type_id = #{type}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backCode != null and backCode != ''">
|
|
|
|
|
|
and locate(#{backCode}, tk.code) > 0
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
|
|
|
|
|
and tk.create_time between #{params.beginTime} and #{params.endTime}
|
|
|
|
|
|
</if>
|
2024-11-14 13:48:21 +08:00
|
|
|
|
ORDER BY
|
2024-11-14 15:09:28 +08:00
|
|
|
|
tk.create_time DESC
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getRepairRecord" resultType="com.bonus.material.repair.domain.RepairRecord">
|
2024-11-14 17:37:57 +08:00
|
|
|
|
select
|
|
|
|
|
|
repair_num as repairNum,
|
|
|
|
|
|
scrap_num as scrapNum,
|
|
|
|
|
|
repair_type as repairType,
|
|
|
|
|
|
scrap_reason as scrapReason,
|
|
|
|
|
|
scrap_type as scrapType,
|
|
|
|
|
|
msi.supplier as supplier,
|
|
|
|
|
|
part_num as partNum,
|
|
|
|
|
|
part_price as partPrice,
|
|
|
|
|
|
repair_content as repairContent,
|
|
|
|
|
|
part_type as partType,
|
|
|
|
|
|
part_name as partName,
|
|
|
|
|
|
file_ids as fileIds,
|
|
|
|
|
|
su.nick_name as repairer,
|
|
|
|
|
|
rar.remark
|
|
|
|
|
|
from
|
|
|
|
|
|
repair_apply_record rar
|
|
|
|
|
|
left join
|
|
|
|
|
|
ma_supplier_info msi on msi.supplier_id = rar.supplier_id
|
|
|
|
|
|
left join
|
|
|
|
|
|
sys_user su on su.user_id = rar.repairer
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="taskId != null and taskId != ''">
|
|
|
|
|
|
and rar.task_id = #{taskId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="maId != null and maId != ''">
|
|
|
|
|
|
and rar.ma_id = #{maId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeId != null and typeId != ''">
|
|
|
|
|
|
and rar.type_id = #{typeId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
2025-07-23 18:44:54 +08:00
|
|
|
|
|
2024-09-27 15:44:11 +08:00
|
|
|
|
<insert id="insertRepairAuditDetails" parameterType="com.bonus.material.repair.domain.RepairAuditDetails" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
|
insert into repair_audit_details
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="taskId != null">task_id,</if>
|
|
|
|
|
|
<if test="repairId != null">repair_id,</if>
|
|
|
|
|
|
<if test="maId != null">ma_id,</if>
|
|
|
|
|
|
<if test="typeId != null">type_id,</if>
|
|
|
|
|
|
<if test="repairNum != null">repair_num,</if>
|
|
|
|
|
|
<if test="repairedNum != null">repaired_num,</if>
|
|
|
|
|
|
<if test="scrapNum != null">scrap_num,</if>
|
|
|
|
|
|
<if test="auditBy != null">audit_by,</if>
|
|
|
|
|
|
<if test="auditTime != null">audit_time,</if>
|
|
|
|
|
|
<if test="auditRemark != null">audit_remark,</if>
|
|
|
|
|
|
<if test="status != null">status,</if>
|
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
|
<if test="companyId != null">company_id,</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="taskId != null">#{taskId},</if>
|
|
|
|
|
|
<if test="repairId != null">#{repairId},</if>
|
|
|
|
|
|
<if test="maId != null">#{maId},</if>
|
|
|
|
|
|
<if test="typeId != null">#{typeId},</if>
|
|
|
|
|
|
<if test="repairNum != null">#{repairNum},</if>
|
|
|
|
|
|
<if test="repairedNum != null">#{repairedNum},</if>
|
|
|
|
|
|
<if test="scrapNum != null">#{scrapNum},</if>
|
|
|
|
|
|
<if test="auditBy != null">#{auditBy},</if>
|
|
|
|
|
|
<if test="auditTime != null">#{auditTime},</if>
|
|
|
|
|
|
<if test="auditRemark != null">#{auditRemark},</if>
|
|
|
|
|
|
<if test="status != null">#{status},</if>
|
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateRepairAuditDetails" parameterType="com.bonus.material.repair.domain.RepairAuditDetails">
|
|
|
|
|
|
update repair_audit_details
|
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
|
<if test="taskId != null">task_id = #{taskId},</if>
|
|
|
|
|
|
<if test="repairId != null">repair_id = #{repairId},</if>
|
|
|
|
|
|
<if test="maId != null">ma_id = #{maId},</if>
|
|
|
|
|
|
<if test="typeId != null">type_id = #{typeId},</if>
|
|
|
|
|
|
<if test="repairNum != null">repair_num = #{repairNum},</if>
|
|
|
|
|
|
<if test="repairedNum != null">repaired_num = #{repairedNum},</if>
|
|
|
|
|
|
<if test="scrapNum != null">scrap_num = #{scrapNum},</if>
|
|
|
|
|
|
<if test="auditBy != null">audit_by = #{auditBy},</if>
|
|
|
|
|
|
<if test="auditTime != null">audit_time = #{auditTime},</if>
|
|
|
|
|
|
<if test="auditRemark != null">audit_remark = #{auditRemark},</if>
|
|
|
|
|
|
<if test="status != null">status = #{status},</if>
|
|
|
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
where id = #{id}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteRepairAuditDetailsById" parameterType="Long">
|
|
|
|
|
|
delete from repair_audit_details where id = #{id}
|
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
2024-11-25 11:02:08 +08:00
|
|
|
|
<delete id="deleteRepairAuditDetailsByTaskId" parameterType="Long">
|
|
|
|
|
|
delete from repair_audit_details where task_id = #{taskId}
|
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
2024-11-28 18:16:02 +08:00
|
|
|
|
<delete id="deleteRepairAuditDetailsByRepairId" parameterType="Long">
|
|
|
|
|
|
delete from repair_audit_details where repair_id = #{repairId}
|
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
2024-09-27 15:44:11 +08:00
|
|
|
|
<delete id="deleteRepairAuditDetailsByIds" parameterType="String">
|
2025-07-23 18:44:54 +08:00
|
|
|
|
delete from repair_audit_details where id in
|
2024-09-27 15:44:11 +08:00
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
|
#{id}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</delete>
|
2024-11-14 13:48:21 +08:00
|
|
|
|
|
2025-06-24 09:10:13 +08:00
|
|
|
|
<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>
|
|
|
|
|
|
|
2024-11-14 13:48:21 +08:00
|
|
|
|
<select id="selectRepairQuestList" resultType="com.bonus.material.repair.domain.vo.ScrapApplyDetailsVO">
|
2025-07-22 08:57:01 +08:00
|
|
|
|
SELECT * FROM (
|
2025-08-19 21:59:30 +08:00
|
|
|
|
-- 第一个查询(时间条件:小于 2025-08-20)
|
2024-11-14 13:48:21 +08:00
|
|
|
|
SELECT DISTINCT
|
2025-07-22 08:57:01 +08:00
|
|
|
|
tk.task_id AS taskId,
|
|
|
|
|
|
tk.CODE AS scrapNum,
|
2025-07-14 13:44:56 +08:00
|
|
|
|
tt2.CODE AS repairTaskCode,
|
2025-07-22 08:57:01 +08:00
|
|
|
|
tk.task_status AS taskStatus,
|
|
|
|
|
|
bui.unit_name AS unitName,
|
|
|
|
|
|
bpl.pro_name AS projectName,
|
|
|
|
|
|
su.nick_name AS createBy,
|
|
|
|
|
|
tk.create_time AS createTime,
|
2025-07-14 13:44:56 +08:00
|
|
|
|
tk.remark,
|
2025-07-22 08:57:01 +08:00
|
|
|
|
tk.CODE AS repairNum,
|
|
|
|
|
|
GROUP_CONCAT(DISTINCT mt4.type_id) AS firstId
|
2024-11-14 13:48:21 +08:00
|
|
|
|
FROM
|
2025-07-14 13:44:56 +08:00
|
|
|
|
tm_task tk
|
|
|
|
|
|
LEFT JOIN tm_task tt ON tk.pre_task_id = tt.task_id
|
|
|
|
|
|
LEFT JOIN repair_audit_details rad ON tk.task_id = rad.task_id
|
2025-07-22 08:57:01 +08:00
|
|
|
|
LEFT JOIN tm_task tt2 ON tt2.task_id = rad.repair_id
|
2025-07-14 13:44:56 +08:00
|
|
|
|
LEFT JOIN tm_task_agreement tta ON rad.repair_id = tta.task_id
|
2024-11-14 13:48:21 +08:00
|
|
|
|
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
|
2024-11-14 13:54:07 +08:00
|
|
|
|
LEFT JOIN bm_project bpl ON bai.project_id = bpl.pro_id
|
|
|
|
|
|
LEFT JOIN bm_unit bui ON bai.unit_id = bui.unit_id
|
2024-11-14 13:48:21 +08:00
|
|
|
|
LEFT JOIN ma_type mt ON rad.type_id = mt.type_id
|
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
|
LEFT JOIN sys_user su ON su.user_id = tk.create_by
|
2025-07-22 08:57:01 +08:00
|
|
|
|
LEFT JOIN ma_type mt3 ON mt1.parent_id = mt3.type_id AND mt3.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.del_flag = '0'
|
2025-07-17 18:35:51 +08:00
|
|
|
|
<if test="userId != null">
|
|
|
|
|
|
JOIN ma_type_repair mtr ON mtr.type_id = rad.type_id AND mtr.user_id = #{userId}
|
|
|
|
|
|
</if>
|
2024-11-14 13:48:21 +08:00
|
|
|
|
WHERE
|
2025-08-31 20:55:53 +08:00
|
|
|
|
tk.task_type = #{taskType} and tt2.CODE is not null
|
2025-08-19 21:59:30 +08:00
|
|
|
|
AND tk.create_time < '2025-08-20 00:00:00'
|
2025-07-22 08:57:01 +08:00
|
|
|
|
<if test="backUnit != null and backUnit != ''">
|
|
|
|
|
|
AND bui.unit_id = #{backUnit}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
|
AND tk.task_status = #{taskStatus}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backPro != null and backPro != ''">
|
|
|
|
|
|
AND bpl.pro_id = #{backPro}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="type != null and type != ''">
|
|
|
|
|
|
AND mt1.type_id = #{type}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backCode != null and backCode != ''">
|
|
|
|
|
|
AND LOCATE(#{backCode}, tk.code) > 0
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
|
AND tk.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="appTaskStatus != null and appTaskStatus == 10">
|
|
|
|
|
|
AND tk.task_status = #{appTaskStatus}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="appTaskStatus != null and appTaskStatus == 11">
|
|
|
|
|
|
AND (tk.task_status = 11 OR tk.task_status = 12)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY
|
|
|
|
|
|
tk.CODE
|
|
|
|
|
|
|
|
|
|
|
|
UNION
|
|
|
|
|
|
|
2025-08-19 21:59:30 +08:00
|
|
|
|
-- 第二个查询(时间条件:>= 2025-08-20)
|
2025-07-22 08:57:01 +08:00
|
|
|
|
SELECT DISTINCT
|
|
|
|
|
|
tk.task_id AS taskId,
|
|
|
|
|
|
tk.CODE AS scrapNum,
|
|
|
|
|
|
tt.CODE AS repairTaskCode,
|
|
|
|
|
|
tk.task_status AS taskStatus,
|
|
|
|
|
|
bui.unit_name AS unitName,
|
|
|
|
|
|
bpl.pro_name AS projectName,
|
|
|
|
|
|
su.nick_name AS createBy,
|
|
|
|
|
|
tk.create_time AS createTime,
|
|
|
|
|
|
tk.remark,
|
|
|
|
|
|
tk.CODE AS repairNum,
|
|
|
|
|
|
GROUP_CONCAT(DISTINCT mt4.type_id) AS firstId
|
|
|
|
|
|
FROM
|
|
|
|
|
|
tm_task tk
|
|
|
|
|
|
LEFT JOIN tm_task tt ON tk.pre_task_id = tt.task_id
|
|
|
|
|
|
LEFT JOIN tm_task_agreement tta ON tk.task_id = tta.task_id
|
|
|
|
|
|
LEFT JOIN bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
|
|
|
|
|
|
LEFT JOIN bm_project bpl ON bai.project_id = bpl.pro_id
|
|
|
|
|
|
LEFT JOIN bm_unit bui ON bai.unit_id = bui.unit_id
|
|
|
|
|
|
LEFT JOIN repair_audit_details rad ON tk.task_id = rad.task_id
|
|
|
|
|
|
LEFT JOIN ma_type mt ON rad.type_id = mt.type_id
|
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
|
LEFT JOIN sys_user su ON su.user_id = tk.create_by
|
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt1.parent_id = mt3.type_id AND mt3.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id AND mt4.del_flag = '0'
|
|
|
|
|
|
<if test="userId != null">
|
|
|
|
|
|
JOIN ma_type_repair mtr ON mtr.type_id = rad.type_id AND mtr.user_id = #{userId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
WHERE
|
2025-08-31 20:55:53 +08:00
|
|
|
|
tk.task_type = #{taskType} and tt.CODE is not null
|
2025-08-19 21:59:30 +08:00
|
|
|
|
AND tk.create_time >= '2025-08-20 00:00:00'
|
2025-07-22 08:57:01 +08:00
|
|
|
|
<if test="backUnit != null and backUnit != ''">
|
|
|
|
|
|
AND bui.unit_id = #{backUnit}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
|
AND tk.task_status = #{taskStatus}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backPro != null and backPro != ''">
|
|
|
|
|
|
AND bpl.pro_id = #{backPro}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="type != null and type != ''">
|
|
|
|
|
|
AND mt1.type_id = #{type}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backCode != null and backCode != ''">
|
|
|
|
|
|
AND LOCATE(#{backCode}, tk.code) > 0
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
|
AND tk.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="appTaskStatus != null and appTaskStatus == 10">
|
|
|
|
|
|
AND tk.task_status = #{appTaskStatus}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="appTaskStatus != null and appTaskStatus == 11">
|
|
|
|
|
|
AND (tk.task_status = 11 OR tk.task_status = 12)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY
|
|
|
|
|
|
tk.CODE
|
|
|
|
|
|
) AS combined_results
|
|
|
|
|
|
ORDER BY
|
|
|
|
|
|
taskStatus,
|
|
|
|
|
|
createTime DESC; -- 统一在外部排序
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectTypeNameByTaskId" resultType="java.lang.String">
|
|
|
|
|
|
select GROUP_CONCAT(type_name) 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 = #{taskId}
|
|
|
|
|
|
) t
|
|
|
|
|
|
GROUP BY task_id
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectRepairAuditDetailsByTaskId" resultMap="RepairAuditDetailsResult">
|
|
|
|
|
|
<include refid="selectRepairAuditDetailsVo"/>
|
2025-06-24 14:11:07 +08:00
|
|
|
|
where task_id = #{taskId} and `status` = '0'
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
2024-11-14 17:37:57 +08:00
|
|
|
|
<select id="selectNotAuditByTaskId" resultMap="RepairAuditDetailsResult">
|
2024-11-14 13:48:21 +08:00
|
|
|
|
<include refid="selectRepairAuditDetailsVo"/>
|
2024-11-14 17:37:57 +08:00
|
|
|
|
where task_id = #{taskId} and `status` = '0'
|
2024-11-14 13:48:21 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectRepairInputByTaskId" resultMap="RepairAuditDetailsResult">
|
|
|
|
|
|
<include refid="selectRepairAuditDetailsVo"/>
|
|
|
|
|
|
where task_id = #{taskId} and repaired_num > 0
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectScrapNumByTaskId" resultMap="RepairAuditDetailsResult">
|
|
|
|
|
|
<include refid="selectRepairAuditDetailsVo"/>
|
|
|
|
|
|
where task_id = #{taskId} and scrap_num > 0
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateStatus">
|
|
|
|
|
|
update repair_audit_details
|
|
|
|
|
|
set audit_by = #{auditBy},
|
|
|
|
|
|
audit_time = now(),
|
|
|
|
|
|
status = #{status},
|
|
|
|
|
|
update_by = #{updateBy},
|
|
|
|
|
|
update_time = now(),
|
|
|
|
|
|
audit_remark = #{auditRemark}
|
|
|
|
|
|
where id = #{id}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateRepairCost">
|
|
|
|
|
|
update repair_cost
|
|
|
|
|
|
set part_type = #{status}
|
|
|
|
|
|
where repair_id = #{inputDetails.repairId}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<insert id="insertRepairDetails">
|
|
|
|
|
|
insert into repair_apply_details
|
|
|
|
|
|
(
|
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
|
task_id,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="maId != null">
|
|
|
|
|
|
ma_id,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeId != null">
|
|
|
|
|
|
type_id,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="repairNum != null">
|
|
|
|
|
|
repair_num,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="status != null">
|
|
|
|
|
|
status,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="createBy != null and createBy != ''">
|
|
|
|
|
|
create_by,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="createBy != null and createBy != ''">
|
|
|
|
|
|
update_by,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
update_time,
|
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
|
company_id,
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backId != null">
|
|
|
|
|
|
back_id,
|
|
|
|
|
|
</if>
|
2025-08-19 17:38:39 +08:00
|
|
|
|
create_time,
|
|
|
|
|
|
is_ds
|
2024-11-14 13:48:21 +08:00
|
|
|
|
)
|
|
|
|
|
|
values (
|
|
|
|
|
|
<if test="taskId != null">
|
|
|
|
|
|
#{taskId},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="maId != null">
|
|
|
|
|
|
#{maId},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeId != null">
|
|
|
|
|
|
#{typeId},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="repairNum != null">
|
|
|
|
|
|
#{repairNum},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="status != null">
|
|
|
|
|
|
#{status},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="createBy != null and createBy != ''">
|
|
|
|
|
|
#{createBy},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="createBy != null and createBy != ''">
|
|
|
|
|
|
#{createBy},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
NOW(),
|
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
|
#{companyId},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="backId != null">
|
|
|
|
|
|
#{backId},
|
|
|
|
|
|
</if>
|
2025-08-19 17:38:39 +08:00
|
|
|
|
NOW(),
|
|
|
|
|
|
'1'
|
2024-11-14 13:48:21 +08:00
|
|
|
|
)
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getBackId" resultType="java.lang.Long">
|
|
|
|
|
|
select back_id
|
|
|
|
|
|
from repair_apply_details
|
|
|
|
|
|
where id = #{repairId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getRepairApplyRecordId" resultType="java.lang.String">
|
|
|
|
|
|
SELECT DISTINCT
|
|
|
|
|
|
rar.id
|
|
|
|
|
|
FROM
|
|
|
|
|
|
repair_apply_record rar
|
|
|
|
|
|
LEFT JOIN repair_cost rc ON rar.task_id = rc.task_id
|
|
|
|
|
|
AND rar.type_id = rc.type_id
|
|
|
|
|
|
AND ( rar.ma_id = rc.ma_id OR rar.ma_id IS NULL )
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
rc.repair_id = #{repairId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateRecodeStatus">
|
|
|
|
|
|
update repair_apply_record set status = 1,update_time = now() where id = #{id}
|
|
|
|
|
|
</update>
|
2024-11-14 17:37:57 +08:00
|
|
|
|
|
2024-11-19 15:18:00 +08:00
|
|
|
|
<select id="selectTypeNamesByTaskIds" resultType="com.bonus.common.biz.domain.vo.KeyValueVO">
|
2024-11-14 17:37:57 +08:00
|
|
|
|
select
|
2024-11-19 15:18:00 +08:00
|
|
|
|
task_id as mapKey, GROUP_CONCAT(type_name) as mapValue
|
2024-11-14 17:37:57 +08:00
|
|
|
|
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
|
2024-11-19 15:18:00 +08:00
|
|
|
|
<if test="taskIds != null and taskIds.size() > 0">
|
|
|
|
|
|
where rad.task_id in
|
|
|
|
|
|
<foreach item="taskId" index="index" collection="taskIds" open="(" separator="," close=")">
|
|
|
|
|
|
#{taskId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
2024-11-14 17:37:57 +08:00
|
|
|
|
) t
|
|
|
|
|
|
GROUP BY task_id
|
|
|
|
|
|
</select>
|
2024-11-15 13:16:00 +08:00
|
|
|
|
|
|
|
|
|
|
<update id="updateRepairAuditDetailsBatch">
|
2024-11-15 13:54:57 +08:00
|
|
|
|
update repair_audit_details
|
|
|
|
|
|
set status = #{status}, update_time = now()
|
2025-01-15 17:34:00 +08:00
|
|
|
|
,audit_time = now(), audit_by = #{auditBy}
|
2024-11-15 13:54:57 +08:00
|
|
|
|
where id in
|
2024-11-15 13:16:00 +08:00
|
|
|
|
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
|
|
|
|
|
|
#{id}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</update>
|
2024-11-21 11:11:12 +08:00
|
|
|
|
|
2024-12-23 14:06:52 +08:00
|
|
|
|
<update id="updateMachine">
|
2025-02-18 09:20:55 +08:00
|
|
|
|
UPDATE ma_machine SET ma_status = #{status} WHERE ma_id = #{maId}
|
2024-12-23 14:06:52 +08:00
|
|
|
|
</update>
|
|
|
|
|
|
|
2024-11-21 11:11:12 +08:00
|
|
|
|
<select id="getPartDetailsByTaskId" resultType="com.bonus.material.repair.domain.RepairPart">
|
|
|
|
|
|
select
|
|
|
|
|
|
mpt.pa_name as partName,
|
|
|
|
|
|
rpd.part_num as partNum,
|
2025-03-21 09:19:53 +08:00
|
|
|
|
mpt.buy_price as partPrice,
|
2024-11-21 11:11:12 +08:00
|
|
|
|
rpd.part_type as partType,
|
|
|
|
|
|
rpd.type_id as typeId,
|
|
|
|
|
|
mt.type_name as typeName,
|
|
|
|
|
|
mt1.type_name as maTypeName,
|
|
|
|
|
|
rpd.remark as remark,
|
2025-03-21 09:19:53 +08:00
|
|
|
|
rpd.repair_content as repairContent,
|
|
|
|
|
|
ROUND(IFNULL(rpd.part_num, 0) * IFNULL(mpt.buy_price, 0), 2) as partCost
|
2024-11-21 11:11:12 +08:00
|
|
|
|
from
|
|
|
|
|
|
repair_part_details rpd
|
|
|
|
|
|
left join ma_part_type mpt on mpt.pa_id = rpd.part_id
|
|
|
|
|
|
left join ma_type mt on rpd.type_id = mt.type_id and mt.del_flag = 0
|
|
|
|
|
|
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = 0
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="taskId != null and taskId != ''">
|
|
|
|
|
|
and rpd.task_id = #{taskId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="maId != null and maId != ''">
|
|
|
|
|
|
and rpd.ma_id = #{maId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeId != null and typeId != ''">
|
|
|
|
|
|
and rpd.type_id = #{typeId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
2025-01-15 17:34:00 +08:00
|
|
|
|
|
2025-03-21 09:19:53 +08:00
|
|
|
|
<select id="getPartRecordNum" resultType="com.bonus.material.repair.domain.RepairPart">
|
|
|
|
|
|
select
|
|
|
|
|
|
rar.part_name as partName,
|
|
|
|
|
|
rar.part_num as partNum,
|
|
|
|
|
|
0 as partPrice,
|
|
|
|
|
|
rar.part_price as partCost,
|
|
|
|
|
|
rar.type_id as typeId,
|
|
|
|
|
|
mt.type_name as typeName,
|
|
|
|
|
|
mt1.type_name as maTypeName
|
|
|
|
|
|
from repair_apply_record rar
|
|
|
|
|
|
left join ma_type mt on rar.type_id = mt.type_id and mt.del_flag = 0
|
|
|
|
|
|
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = 0
|
|
|
|
|
|
|
|
|
|
|
|
where rar.part_type = 1 and rar.part_id is null
|
|
|
|
|
|
<if test="taskId != null and taskId != ''">
|
|
|
|
|
|
and rar.task_id = #{taskId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2025-01-15 17:34:00 +08:00
|
|
|
|
<select id="getDetailsList" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
mt1.type_name as typeName,
|
|
|
|
|
|
mt.type_name as specificationType,
|
|
|
|
|
|
rad.type_id as typeId,
|
|
|
|
|
|
rad.task_id as taskId,
|
|
|
|
|
|
mm.ma_code as maCode,
|
|
|
|
|
|
su.nick_name as auditName,
|
|
|
|
|
|
rad.audit_time as auditTime,
|
|
|
|
|
|
rad.repair_num as repairNum,
|
|
|
|
|
|
rad.repaired_num as repairedNum,
|
|
|
|
|
|
rad.scrap_num as scrapNum
|
|
|
|
|
|
FROM
|
|
|
|
|
|
repair_audit_details rad
|
|
|
|
|
|
LEFT JOIN ma_type mt ON rad.type_id = mt.type_id
|
|
|
|
|
|
AND mt.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
|
AND mt1.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN sys_user su on rad.audit_by = su.user_id
|
|
|
|
|
|
LEFT JOIN ma_machine mm on mm.ma_id = rad.ma_id
|
|
|
|
|
|
WHERE rad.task_id = #{taskId}
|
|
|
|
|
|
and rad.type_id = #{typeId}
|
|
|
|
|
|
</select>
|
2025-03-26 16:21:51 +08:00
|
|
|
|
|
|
|
|
|
|
<select id="getRepairHomeList" resultType="com.bonus.material.repair.domain.vo.RepairHomeInfo">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
mt1.type_name AS typeName,
|
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
|
ROUND( SUM( rad.repair_num ), 3 ) AS backNum,
|
|
|
|
|
|
mt.type_id AS typeId,
|
|
|
|
|
|
tt.`code` AS repairCode,
|
|
|
|
|
|
rad.task_id AS taskId,
|
|
|
|
|
|
rad.id AS id
|
|
|
|
|
|
FROM
|
|
|
|
|
|
repair_apply_details rad
|
|
|
|
|
|
LEFT JOIN ma_type mt ON rad.type_id = mt.type_id
|
|
|
|
|
|
AND mt.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
|
AND mt1.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN tm_task tt ON rad.task_id = tt.task_id
|
|
|
|
|
|
WHERE 1 = 1
|
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
|
<![CDATA[and DATE_FORMAT( rad.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY
|
|
|
|
|
|
rad.type_id,
|
|
|
|
|
|
rad.task_id
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectDetails" resultType="com.bonus.material.repair.domain.vo.RepairHomeInfo">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
IFNULL(SUM(rar.part_num),0) AS changePartNum,
|
|
|
|
|
|
SUM(
|
|
|
|
|
|
CASE
|
|
|
|
|
|
WHEN rar.part_type = 1 AND rar.part_id IS NOT NULL THEN rar.part_num * rar.part_price
|
|
|
|
|
|
WHEN rar.part_type = 1 AND rar.part_id IS NULL THEN rar.part_price
|
|
|
|
|
|
ELSE 0
|
|
|
|
|
|
END
|
|
|
|
|
|
) AS amountPartPrice,
|
|
|
|
|
|
SUM(
|
|
|
|
|
|
CASE
|
|
|
|
|
|
WHEN rar.part_type = 0 AND rar.part_id IS NOT NULL THEN rar.part_num * rar.part_price
|
|
|
|
|
|
WHEN rar.part_type = 0 AND rar.part_id IS NULL THEN rar.part_price
|
|
|
|
|
|
ELSE 0
|
|
|
|
|
|
END
|
|
|
|
|
|
) AS noAmountPartPrice,
|
|
|
|
|
|
ROUND(IFNULL(rar.repair_num, 0) + IFNULL(rar.scrap_num , 0)) AS repairedNum,
|
|
|
|
|
|
ROUND(IFNULL(sum(rar.scrap_num ), 0), 0) AS scrapNum,
|
|
|
|
|
|
ROUND((IFNULL(rar.repair_num, 0) + IFNULL(rar.scrap_num , 0)) * IFNULL(mt.sampling_ratio * 0.01, 1), 3)
|
|
|
|
|
|
AS testNum
|
|
|
|
|
|
FROM
|
|
|
|
|
|
repair_apply_record rar
|
|
|
|
|
|
LEFT JOIN ma_type mt ON rar.type_id = mt.type_id
|
|
|
|
|
|
AND mt.del_flag = '0'
|
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
|
AND mt1.del_flag = '0'
|
|
|
|
|
|
WHERE rar.`status` = '1' and
|
|
|
|
|
|
rar.task_id = #{taskId} and rar.type_id = #{typeId}
|
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
|
<![CDATA[and DATE_FORMAT( rar.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY
|
|
|
|
|
|
rar.repair_type
|
|
|
|
|
|
</select>
|
2025-07-29 18:42:23 +08:00
|
|
|
|
<select id="getAuditStatus" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
|
|
|
|
|
|
<include refid="selectRepairAuditDetailsVo"/>
|
|
|
|
|
|
where task_id = #{taskId}
|
|
|
|
|
|
</select>
|
2025-07-23 18:44:54 +08:00
|
|
|
|
</mapper>
|