Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/scrap/ScrapApplyDetailsMapper.xml

219 lines
11 KiB
XML
Raw Normal View History

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.scrap.mapper.ScrapApplyDetailsMapper">
<resultMap type="com.bonus.material.scrap.domain.ScrapApplyDetails" id="ScrapApplyDetailsResult">
<result property="id" column="id" />
<result property="taskId" column="task_id" />
<result property="parentId" column="parent_id" />
<result property="maId" column="ma_id" />
<result property="typeId" column="type_id" />
<result property="scrapNum" column="scrap_num" />
<result property="scrapSource" column="scrap_source" />
<result property="scrapType" column="scrap_type" />
<result property="status" column="status" />
<result property="auditBy" column="audit_by" />
<result property="auditTime" column="audit_time" />
<result property="auditRemark" column="audit_remark" />
<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" />
<result property="fileName" column="file_name" />
<result property="fileUrl" column="file_url" />
</resultMap>
<sql id="selectScrapApplyDetailsVo">
select id, task_id, parent_id, ma_id, type_id, scrap_num, scrap_source, scrap_type, status, audit_by, audit_time,
audit_remark, create_by, create_time, update_by, update_time, remark, company_id, file_name, file_url
from scrap_apply_details
2024-09-27 15:44:11 +08:00
</sql>
2024-12-13 14:33:19 +08:00
<select id="selectScrapApplyDetailsList" parameterType="com.bonus.material.scrap.domain.ScrapApplyDetails" resultType="com.bonus.material.scrap.domain.vo.ScrapTaskListVo">
SELECT
sad.task_id, sad.create_by, sad.create_time,sad.update_time,sad.company_id,
tt.`code` AS scrapCode, tt2.`code` as repairCode ,tt.task_status AS taskStatus,tt.task_type as taskType,tt.company_id AS companyId,tt.remark,
2024-12-13 14:33:19 +08:00
bui.unit_name AS backUnit,
bpi.pro_name AS backPro,
su.nick_name AS createName,
GROUP_CONCAT(DISTINCT mt2.type_name) as type
FROM
scrap_apply_details sad
LEFT JOIN ma_type mt on sad.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN tm_task tt on sad.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON sad.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
LEFT JOIN bm_unit bui ON bai2.unit_id = bui.unit_id
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
left join sys_user su on sad.create_by = su.user_id
left join repair_audit_details rad ON sad.parent_id = rad.id
left join tm_task tt2 ON tt2.task_id = rad.task_id
2024-12-13 14:33:19 +08:00
<!-- <where> -->
<!-- <if test="taskId != null "> and task_id = #{taskId}</if>-->
<!-- <if test="parentId != null "> and parent_id = #{parentId}</if>-->
<!-- <if test="maId != null "> and ma_id = #{maId}</if>-->
<!-- <if test="typeId != null "> and type_id = #{typeId}</if>-->
<!-- <if test="scrapNum != null "> and scrap_num = #{scrapNum}</if>-->
<!-- <if test="scrapSource != null and scrapSource != ''"> and scrap_source = #{scrapSource}</if>-->
<!-- <if test="scrapType != null and scrapType != ''"> and scrap_type = #{scrapType}</if>-->
<!-- <if test="status != null and status != ''"> and status = #{status}</if>-->
<!-- <if test="auditBy != null "> and audit_by = #{auditBy}</if>-->
<!-- <if test="auditTime != null "> and audit_time = #{auditTime}</if>-->
<!-- <if test="auditRemark != null and auditRemark != ''"> and audit_remark = #{auditRemark}</if>-->
<!-- <if test="companyId != null "> and company_id = #{companyId}</if>-->
<!-- <if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>-->
<!-- <if test="fileUrl != null and fileUrl != ''"> and file_url = #{fileUrl}</if>-->
<!-- </where>-->
GROUP BY sad.task_id,bui.unit_name,bpi.pro_name,su.nick_name
order by tt.create_time desc
2024-09-27 15:44:11 +08:00
</select>
<select id="selectRepairQuestListByTaskId" resultType="com.bonus.material.scrap.domain.ScrapApplyDetails">
select
sad.id as id,sad.task_id as taskId,sad.parent_id,sad.ma_id as maId,
sad.scrap_source,sad.scrap_type,
sad.status as status,ifnull(sad.scrap_num,0) as scrapNum,
sad.audit_by,sad.audit_remark,sad.audit_time,
sad.update_time as updateTime,sad.type_id as typeId,
sad.create_by,sad.create_time,sad.file_name,sad.file_url,
mt2.type_name as typeName,mt2.type_id as typeNameId,
mt.type_name as type,mt.unit_name as unitName,mt.manage_type as manageType,
mm.ma_code as code,
su.nick_name as scraper
from
scrap_apply_details sad
left join ma_type mt on sad.type_id = mt.type_id
left join ma_machine mm on mm.ma_id = sad.ma_id
left join sys_user su on sad.create_by = su.user_id
left join ma_type mt2 on mt.parent_id = mt2.type_id
where
sad.task_id = #{taskId}
GROUP BY sad.id
order by sad.create_time desc
</select>
2024-09-27 15:44:11 +08:00
<select id="selectScrapApplyDetailsById" parameterType="Long" resultMap="ScrapApplyDetailsResult">
<include refid="selectScrapApplyDetailsVo"/>
where id = #{id}
</select>
<insert id="insertScrapApplyDetails" parameterType="com.bonus.material.scrap.domain.ScrapApplyDetails" useGeneratedKeys="true" keyProperty="id">
insert into scrap_apply_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="maId != null">ma_id,</if>
<if test="typeId != null">type_id,</if>
<if test="scrapNum != null">scrap_num,</if>
<if test="scrapSource != null">scrap_source,</if>
<if test="scrapType != null">scrap_type,</if>
<if test="status != null">status,</if>
<if test="auditBy != null">audit_by,</if>
<if test="auditTime != null">audit_time,</if>
<if test="auditRemark != null">audit_remark,</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>
<if test="fileName != null">file_name,</if>
<if test="fileUrl != null">file_url,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="maId != null">#{maId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="scrapNum != null">#{scrapNum},</if>
<if test="scrapSource != null">#{scrapSource},</if>
<if test="scrapType != null">#{scrapType},</if>
<if test="status != null">#{status},</if>
<if test="auditBy != null">#{auditBy},</if>
<if test="auditTime != null">#{auditTime},</if>
<if test="auditRemark != null">#{auditRemark},</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>
<if test="fileName != null">#{fileName},</if>
<if test="fileUrl != null">#{fileUrl},</if>
</trim>
</insert>
<update id="updateScrapApplyDetails" parameterType="com.bonus.material.scrap.domain.ScrapApplyDetails">
update scrap_apply_details
<trim prefix="SET" suffixOverrides=",">
<if test="taskId != null">task_id = #{taskId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="maId != null">ma_id = #{maId},</if>
<if test="typeId != null">type_id = #{typeId},</if>
<if test="scrapNum != null">scrap_num = #{scrapNum},</if>
<if test="scrapSource != null">scrap_source = #{scrapSource},</if>
<if test="scrapType != null">scrap_type = #{scrapType},</if>
<if test="status != null">status = #{status},</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="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>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="fileUrl != null">file_url = #{fileUrl},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteScrapApplyDetailsById" parameterType="Long">
delete from scrap_apply_details where id = #{id}
</delete>
<delete id="deleteScrapApplyDetailsByIds" parameterType="String">
delete from scrap_apply_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getByRepairId" resultType="com.bonus.material.repair.domain.RepairAuditDetails">
select task_id as taskId,
ma_id as maId,
type_id as typeId
from repair_apply_details
where id = #{repairId}
</select>
<select id="getGyoupRepairRecord" resultType="com.bonus.material.repair.domain.RepairRecord">
select sum(scrap_num) as scrapNum,
scrap_reason as scrapReason,
scrap_type as scrapType,
file_ids as fileIds
from repair_apply_record rar
where repair_type = '3'
<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>
group by scrap_type
</select>
2024-09-27 15:44:11 +08:00
</mapper>