cqdevicemgt/sgzb-modules/sgzb-material/src/main/resources/mapper/material/RepairAuditDetailsMapper.xml

781 lines
30 KiB
XML
Raw Normal View History

2024-08-08 14:57:05 +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.sgzb.material.mapper.RepairAuditDetailsMapper">
2024-08-08 14:57:05 +08:00
<resultMap type="com.bonus.sgzb.material.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" />
<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">
SELECT
rd.id,
rd.task_id,
rd.repair_id,
rd.ma_id,
rd.type_id,
rd.repair_num,
rd.repaired_num,
rd.scrap_num,
rd.audit_by,
rd.audit_time,
rd.audit_remark,
rd.STATUS,
rd.create_by,
rd.create_time,
rd.update_by,
rd.update_time,
rd.remark,
mt.company_id
FROM
repair_audit_details rd
LEFT JOIN ma_type mt on rd.type_id = mt.type_id
</sql>
<select id="selectRepairAuditDetailsList" parameterType="com.bonus.sgzb.material.domain.RepairAuditDetails" resultMap="RepairAuditDetailsResult">
select rad.* ,mt.type_name specificationType, mt1.type_name machineTypeName, mma.ma_code maCode
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
where rad.task_id = #{taskId}
<if test="keyword != null and keyword != ''">
AND (locate(#{keyword}, mma.ma_code) > 0
or locate(#{keyword}, mt.type_name) > 0
or locate(#{keyword}, mt1.type_name) > 0)
</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
</select>
2024-08-08 14:57:05 +08:00
<select id="selectRepairAuditDetailsById" parameterType="Long" resultMap="RepairAuditDetailsResult">
<include refid="selectRepairAuditDetailsVo"/>
where id = #{id}
</select>
2024-08-08 14:57:05 +08:00
<insert id="insertRepairAuditDetails" parameterType="com.bonus.sgzb.material.domain.RepairAuditDetails">
insert into repair_audit_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<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="id != null">#{id},</if>
<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>
<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>
create_time
)
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>
NOW()
)
</insert>
2025-06-12 09:46:38 +08:00
<insert id="insertScrapData">
insert into scrap_apply_details
(
<if test="taskId != null">
task_id,
</if>
<if test="detail.maId != null">
ma_id,
</if>
<if test="detail.typeId != null">
type_id,
</if>
<if test="detail.parentId != null">
parent_id,
</if>
<if test="detail.repairNum != null">
scrap_num,
</if>
status,
scrap_source,
<if test="detail.createBy != null and detail.createBy != ''">
create_by,
</if>
create_time
)
values (
<if test="taskId != null">
#{taskId},
</if>
<if test="detail.maId != null">
#{detail.maId},
</if>
<if test="detail.typeId != null">
#{detail.typeId},
</if>
<if test="detail.parentId != null">
#{detail.parentId},
</if>
<if test="detail.repairNum != null">
#{detail.repairNum},
</if>
0,
2,
<if test="detail.createBy != null and detail.createBy != ''">
#{detail.createBy},
</if>
NOW()
)
</insert>
2024-08-08 14:57:05 +08:00
<update id="updateRepairAuditDetails" parameterType="com.bonus.sgzb.material.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>
<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="updateAuditStatus">
update repair_audit_details
set audit_by = #{userId},
audit_time = #{dateTime},
status = #{status},
update_by = #{userId},
update_time = #{dateTime},
audit_remark = #{remark}
where parent_id = #{parentId}
</update>
<update id="updateAuditNum">
update repair_apply_details
set
repaired_num = IFNULL(repaired_num, 0) - #{repairedNum},
scrap_num = IFNULL(scrap_num, 0) - #{scrapNum},
status = 0,
update_by = #{createBy},
update_time = now()
where id = #{repairId}
</update>
2024-08-08 14:57:05 +08:00
<update id="updateRepairCost">
update repair_cost
set part_type = #{status}
where repair_id = #{inputDetails.repairId}
</update>
2024-08-15 14:30:15 +08:00
<update id="updateRecodeStatus">
2024-09-06 10:34:28 +08:00
update repair_apply_record set status = 1,update_time = now() where id = #{id}
2024-08-15 14:30:15 +08:00
</update>
2024-08-08 14:57:05 +08:00
<delete id="deleteRepairAuditDetailsById" parameterType="Long">
delete from repair_audit_details where id = #{id}
</delete>
<delete id="deleteRepairAuditDetailsByIds" parameterType="String">
delete from repair_audit_details where id in
2024-08-08 14:57:05 +08:00
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectRepairQuestList" resultType="com.bonus.sgzb.material.vo.ScrapApplyDetailsVO">
SELECT DISTINCT
tk.task_id taskId,
tk.CODE scrapNum,
tk.task_status taskStatus,
dic.NAME taskStatusName,
bui.unit_name unitName,
bpl.lot_name projectName,
su.nick_name createBy,
tk.create_time createTime,
tk.remark,
2025-03-11 09:31:57 +08:00
a.code repairNum
2024-08-08 14:57:05 +08:00
FROM
tm_task tk
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_lot bpl ON bai.project_id = bpl.lot_id
LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id
LEFT JOIN (
SELECT
id,
p_id,
NAME
FROM
sys_dic
WHERE
p_id IN ( SELECT id FROM sys_dic WHERE VALUE = 'ws_shenhe' )) dic ON tk.task_status = dic.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
2025-03-11 09:31:57 +08:00
LEFT JOIN (SELECT rad1.id as id, tt.code as code from repair_apply_details rad1
LEFT JOIN tm_task tt on rad1.task_id = tt.task_id) a ON a.id = rad.repair_id
2024-08-08 14:57:05 +08:00
WHERE
tk.task_type = 45
<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.lot_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.lot_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>
order by tk.create_time desc
</select>
<select id="selectRepairQuestListNew" resultType="com.bonus.sgzb.material.vo.RepairAuditDetailsNew">
select
rad.parent_id as parentId,
rad.create_time,
rad.type_id,
2025-06-12 09:46:38 +08:00
mm.ma_id as maId,
mm.ma_code as maCode,
IFNULL(sum(rad.repair_num), 0) as repairNum,
IFNULL(sum(rad.repaired_num), 0) as repairedNum,
IFNULL(sum(rad.scrap_num), 0) as scrapNum,
rad.status as taskStatus,
DATE_FORMAT(rar.create_time, '%Y-%m-%d') as createTime,
rad.audit_remark as remark,
mt2.type_name as typeName,
mt.type_name as type,
su.nick_name as repairer,
2025-06-18 14:09:36 +08:00
rar.repair_type as repairType,
su1.nick_name as auditBy
from
repair_audit_details rad
left join repair_apply_record rar on rad.parent_id = rar.id
left join ma_machine mm on mm.ma_id = rad.ma_id
left join ma_type mt on rar.type_id = mt.type_id
left join sys_user su on rar.create_by = su.user_id
2025-06-18 14:09:36 +08:00
left join sys_user su1 on rad.audit_by = su1.user_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
where
1=1
<if test="typeName !=null and typeName != ''">
AND mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="type !=null and type != ''">
AND mt.type_name like concat('%',#{type},'%')
</if>
<if test="taskStatus !=null and taskStatus != ''">
AND rad.status = #{taskStatus}
</if>
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
and rar.create_time between #{params.beginTime} and #{params.endTime}
</if>
2025-06-18 14:09:36 +08:00
group by rad.parent_id,rad.create_time,rad.type_id,su1.nick_name,rad.status,rad.audit_remark,mm.ma_code
order by rar.create_time desc
<!-- <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>-->
</select>
2024-08-08 14:57:05 +08:00
<select id="exportRepairQuestList" resultType="com.bonus.sgzb.material.vo.RepairAuditDetailsVO">
SELECT DISTINCT
tk.task_id taskId,
tk.CODE scrapNum,
tk.task_status taskStatus,
dic.NAME taskStatusName,
bui.unit_name unitName,
bpl.lot_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
FROM
tm_task tk
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_lot bpl ON bai.project_id = bpl.lot_id
LEFT JOIN bm_unit_info bui ON bai.unit_id = bui.unit_id
LEFT JOIN (
SELECT
id,
p_id,
NAME
FROM
sys_dic
WHERE
p_id IN ( SELECT id FROM sys_dic WHERE VALUE = 'ws_shenhe' )) dic ON tk.task_status = dic.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 ma_machine mma on rad.ma_id= mma.ma_id
LEFT JOIN sys_user su ON su.user_id = tk.create_by
WHERE
tk.task_type = 45
<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.lot_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.lot_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>
ORDER BY
tk.create_time DESC
</select>
<select id="selectRepairAuditDetailsByTaskId" resultMap="RepairAuditDetailsResult">
<include refid="selectRepairAuditDetailsVo"/>
where task_id = #{taskId}
</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="selectRepairInputByTaskId" resultType="com.bonus.sgzb.material.domain.RepairAuditDetails">
<include refid="selectRepairAuditDetailsVo"/>
where task_id = #{taskId} and repaired_num > 0
</select>
<select id="selectScrapNumByTaskId" resultType="com.bonus.sgzb.material.domain.RepairAuditDetails">
<include refid="selectRepairAuditDetailsVo"/>
where task_id = #{taskId} and scrap_num > 0
</select>
<select id="getBackId" resultType="java.lang.Long">
select back_id
from repair_apply_details
where id = #{repairId}
</select>
<select id="selectnotAuditByTaskId" resultType="com.bonus.sgzb.material.domain.RepairAuditDetails">
<include refid="selectRepairAuditDetailsVo"/>
where task_id = #{taskId} and rd.STATUS = '0'
</select>
<select id="getPartRecord" resultType="com.bonus.sgzb.material.domain.RepairPart">
select concat(mpt2.pa_name,'-',mpt1.pa_name,'-',mpt.pa_name) as partName,
2024-08-08 14:57:05 +08:00
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
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-08-08 14:57:05 +08:00
where 1=1
<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>
</select>
<select id="getRepairRecord" resultType="com.bonus.sgzb.material.domain.RepairRecord">
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,
2025-03-28 15:57:12 +08:00
rar.remark as remark,
rar.id as id,
rar.part_id as partId
2024-08-08 14:57:05 +08:00
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 1=1
<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>
</select>
<select id="getRepairId" resultType="com.bonus.sgzb.material.domain.RepairAuditDetails">
select task_id as taskId,
ma_id as maId,
type_id as typeId
from repair_apply_details
where id = #{repairId}
</select>
2024-08-15 14:30:15 +08:00
<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>
2025-06-18 14:09:36 +08:00
<select id="getMaintenanceRecords" resultType="com.bonus.sgzb.material.vo.RepairAuditDetailsNew">
select
rad.parent_id as parentId,
rad.create_time,
2025-03-11 17:50:09 +08:00
rad.type_id,
2025-06-18 14:09:36 +08:00
mm.ma_id as maId,
mm.ma_code as maCode,
IFNULL(sum(rad.repair_num), 0) as repairNum,
IFNULL(sum(rad.repaired_num), 0) as repairedNum,
IFNULL(sum(rad.scrap_num), 0) as scrapNum,
rad.status as taskStatus,
DATE_FORMAT(rar.create_time, '%Y-%m-%d') as createTime,
-- rad.audit_remark as remark,
2025-06-18 14:09:36 +08:00
mt2.type_name as typeName,
mt.type_name as type,
su.nick_name as repairer,
rar.repair_type as repairType,
su1.nick_name as auditBy,
(
SELECT GROUP_CONCAT(DISTINCT rap.repair_remark SEPARATOR ';')
FROM repair_apply_part rap
WHERE rap.parent_id = rar.id
) as repairRemark,
-- 使用子查询获取 repairRemarkBefore
(
SELECT GROUP_CONCAT(CONCAT(mt.type_name, '', rpad.repair_remark) SEPARATOR ';')
FROM repair_apply_details rpad
LEFT JOIN ma_type mt ON rpad.type_id = mt.type_id
WHERE rpad.id = rad.repair_id
) as repairRemarkBefore,
(
SELECT GROUP_CONCAT(
CASE
-- 当 part_id 存在时,关联表获取 pa_name
WHEN rap.scrap_num > 0 THEN CONCAT('报废数量:',rap.scrap_reason)
WHEN rap.part_id IS NOT NULL THEN CONCAT(mpt.pa_name, ':','数量为',rap.part_num,' ', rap.repair_content)
-- 当 part_id 不存在但 part_name 存在时,直接使用 part_name
WHEN rap.part_name IS NOT NULL THEN CONCAT(rap.part_name, ':','数量为',rap.part_num,' ', rap.repair_content)
-- 两者都不存在时,不显示该记录
ELSE NULL
END
SEPARATOR '; '
)
FROM repair_apply_part rap
LEFT JOIN ma_part_type mpt ON rap.part_id = mpt.pa_id
WHERE rap.parent_id = rar.id
) as remark
2025-06-18 14:09:36 +08:00
from
repair_audit_details rad
left join repair_apply_record rar on rad.parent_id = rar.id
left join ma_machine mm on mm.ma_id = rad.ma_id
left join ma_type mt on rar.type_id = mt.type_id
left join sys_user su on rar.create_by = su.user_id
left join sys_user su1 on rad.audit_by = su1.user_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
where
rad.parent_id = #{parentId}
group by rad.parent_id,rad.create_time,rad.type_id,su1.nick_name,rad.status,rad.audit_remark,mm.ma_code
2025-03-11 17:50:09 +08:00
</select>
<select id="getRepairContent" resultType="com.bonus.sgzb.base.domain.RepairContent">
SELECT
CONCAT(COALESCE ( mm.ma_code, '' ),COALESCE ( rar.repair_remark, '' )) as repairRemark,
CONCAT(
COALESCE ( mm.ma_code, '' ),
COALESCE ( mpt.pa_name, '' ),
COALESCE ( rar.repair_content, '' )) AS repairContent
FROM
repair_apply_record rar
left join repair_part_details rpd on rar.part_id = rpd.part_id and rar.task_id = rpd.task_id
2025-03-11 17:50:09 +08:00
left join ma_part_type mpt ON mpt.pa_id = rpd.part_id
LEFT JOIN ma_machine mm ON mm.ma_id = rar.ma_id
WHERE
rar.task_id = #{repairTaskId} and rar.type_id = #{typeId}
<if test="maId != null">
and rar.ma_id = #{maId}
</if>
</select>
<select id="getfileList" resultType="com.bonus.sgzb.base.api.domain.FileInfo">
SELECT
fi.*
FROM
sys_file_info fi
WHERE
fi.model_id = #{taskId}
and fi.type_id = #{typeId}
<if test="maId != null">
and fi.ma_id = #{maId}
</if>
</select>
2025-03-28 15:57:12 +08:00
<select id="getRepairPartIdList" resultType="com.bonus.sgzb.material.domain.RepairPart">
SELECT
2025-04-17 14:04:37 +08:00
CASE
WHEN mpt.parent_id = 0 THEN mpt.pa_name
WHEN mpt1.parent_id = 0 THEN CONCAT(mpt1.pa_name, '-', mpt.pa_name)
ELSE CONCAT(mpt2.pa_name, '-', mpt1.pa_name, '-', mpt.pa_name)
END AS partName,
IFNULL(rar.part_num, 0) AS partNum,
IFNULL(rar.part_num, 0) * IFNULL(rar.part_price, 0) AS partCost,
2025-03-28 15:57:12 +08:00
rar.repair_remark AS remark
FROM
repair_apply_record rar
LEFT JOIN ma_part_type mpt ON mpt.pa_id = rar.part_id
2025-04-17 14:04:37 +08:00
LEFT JOIN ma_part_type mpt1 ON mpt1.pa_id = mpt.parent_id AND mpt.parent_id != 0
LEFT JOIN ma_part_type mpt2 ON mpt2.pa_id = mpt1.parent_id AND mpt1.parent_id != 0
2025-03-28 15:57:12 +08:00
WHERE
rar.id = #{id}
</select>
<select id="getRepairCost" resultType="com.bonus.sgzb.material.domain.RepairPart">
SELECT
part_name AS partName,
IFNULL( part_num, 0 ) AS partNum,
IFNULL( part_num, 0 ) * IFNULL( part_price, 0 ) AS partCost,
repair_remark AS remark
FROM
repair_apply_record
WHERE
id = #{id}
</select>
2024-08-15 14:30:15 +08:00
2025-03-28 18:24:38 +08:00
<update id="updateRepairInBound">
update ma_machine
set ma_status = 15
where ma_id = #{maId}
</update>
<update id="addStorageNum">
update
ma_type
set
num = (ifnull(num,0)) + #{repairedNum}
where type_id = #{typeId}
</update>
<select id="selectAuditRepairListNew" resultType="com.bonus.sgzb.material.vo.RepairAuditDetailsNew">
select
id as id,
repair_id as repairId,
parent_id as parentId,
2025-06-12 09:46:38 +08:00
ma_id as maId,
IFNULL( repair_num, 0 ) AS repairNum,
IFNULL( repaired_num, 0 ) AS repairedNum,
IFNULL( scrap_num, 0 ) AS scrapNum
from
repair_audit_details rad
where parent_id = #{parentId}
</select>
2025-06-12 09:46:38 +08:00
<select id="getRepairTypeByParentId" resultType="com.bonus.sgzb.material.vo.RepairAuditDetailsNew">
select
id as parentId,
type_id as typeId,
ma_id as maId,
repair_num as repairNum,
repair_type as repairType
from
repair_apply_record rar
where id = #{parentId}
</select>
<update id="updateMaChineStatus">
update ma_machine
set ma_status = #{type}
where ma_id = #{maId}
</update>
<select id="getRepairNumByParentId" resultType="com.bonus.sgzb.material.vo.RepairAuditDetailsNew">
select
id as id,
IFNULL( repair_num, 0 ) AS repairNum,
type_id as typeId
from
repair_apply_record rar
where id = #{parentId}
</select>
<update id="updateStorageNum">
update ma_type
set num = IFNULL(num,0) + IFNULL(#{repairNum},0)
where type_id = #{typeId}
</update>
</mapper>