ah_sz_gqj/src/main/resources/mappers/basis/ExperimentalMapper.xml

150 lines
7.2 KiB
XML
Raw Normal View History

2024-07-20 15:18:16 +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.aqgqj.basis.dao.ExperimentalMapper">
2024-07-20 17:31:33 +08:00
<!--添加试验信息-->
<insert id="addExper" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_exper
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sampleId != null">sample_id,</if>
<if test="devTypeCode != null and devTypeCode != ''">dev_type_code,</if>
<if test="devTypeName != null and devTypeName != ''">dev_type_name,</if>
<if test="sampleQuantity != null">dev_num,</if>
<if test="devModule != null and devModule!=''">dev_module,</if>
<if test="sampleDate != null and sampleDate!=''">sample_date,</if>
<if test="experTime != null and experTime!=''">exper_time,</if>
<if test="nextExperTime != null and nextExperTime!=''">next_exper_time,</if>
<if test="customId != null">submit_unit,</if>
<if test="experLocal != null and experLocal!=''">submit_location,</if>
<if test="experDev != null and experDev!=''">exper_dev,</if>
<if test="experModule != null and experModule!=''">exper_module,</if>
<if test="experCode != null and experCode!=''">exper_code,</if>
<if test="checkTime != null and checkTime!=''">check_time,</if>
<if test="experStand != null and experStand!=''">exper_stand,</if>
<if test="experConclu != null and experConclu!=''">exper_conclu,</if>
<if test="remarsk != null and remarsk!=''">remarsk,</if>
audit_status,
create_time,
create_user,
update_time,
update_user,
del_flag,
status,
id
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sampleId != null">#{sampleId},</if>
<if test="devTypeCode != null and devTypeCode != ''">#{devTypeCode},</if>
<if test="devTypeName != null and devTypeName != ''">#{devTypeName},</if>
<if test="sampleQuantity != null">#{sampleQuantity},</if>
<if test="devModule != null and devModule!=''">#{devModule},</if>
<if test="sampleDate != null and sampleDate!=''">#{sampleDate},</if>
<if test="experTime != null and experTime!=''">#{experTime},</if>
<if test="nextExperTime != null and nextExperTime!=''">#{nextExperTime},</if>
<if test="customId != null">#{customId},</if>
<if test="experLocal != null and experLocal!=''">#{experLocal},</if>
<if test="experDev != null and experDev!=''">#{experDev},</if>
<if test="experModule != null and experModule!=''">#{experModule},</if>
<if test="experCode != null and experCode!=''">#{experCode},</if>
<if test="checkTime != null and checkTime!=''">#{checkTime},</if>
<if test="experStand != null and experStand!=''">#{experStand},</if>
<if test="experConclu != null and experConclu!=''">#{experConclu},</if>
<if test="remarsk != null and remarsk!=''">#{remarsk},</if>
#{auditStatus}
#{createTime},
#{createUser},
#{updateTime},
#{updateUser},
#{status},
0,
null
</trim>
</insert>
<!--添加试验依据信息数据-->
<insert id="addConfigBasis">
INSERT INTO tb_config_basis(id,exper_id,exper_basis_name) VALUES
<foreach collection="list" separator="," item="item">
(
null,#{id},#{item.basisName}
)
</foreach>
</insert>
2024-07-20 15:18:16 +08:00
<!--试验列表-->
<select id="getList" resultType="com.bonus.aqgqj.basis.entity.vo.ExperimentalVo">
SELECT ts.id,
tc.custom_name AS customName,
DATE_FORMAT(ts.sample_time, '%Y-%m-%d') AS sampleTime,
IFNULL(tsd.num,0) AS customNum,
tsd.sampleDev,
su.user_name AS sampleUserName,
su2.user_name AS dispatchUserName,
DATE_FORMAT(ts.sample_date, '%Y-%m-%d') AS sampleDate,
tt.team_name AS teamName,
ts.audti_status AS audtiStatus,
ts.process_status AS processStatus,
ts.remarks
FROM tb_sample ts
LEFT JOIN tb_custom tc ON ts.custom_id = tc.id
LEFT JOIN sys_user su ON ts.create_user = su.id AND su.del_flag = 0
LEFT JOIN sys_user su2 ON ts.update_user = su2.id AND su2.del_flag = 0
LEFT JOIN tb_team tt ON ts.team_id = tt.id AND tt.del_flag = 0
LEFT JOIN (
SELECT sample_id,COUNT(sample_id) AS num,GROUP_CONCAT(DISTINCT dev_type_name) AS sampleDev,GROUP_CONCAT(DISTINCT dev_type_code) AS sampleDevCode
FROM tb_sample_device
WHERE del_falg = 0
GROUP BY sample_id
) tsd ON tsd.sample_id = ts.id
WHERE ts.del_flag = 0 AND process_status IN (0,5)
<if test="keyWord != null and keyWord!=''">
AND (
INSTR(tt.team_name,#{keyWord}) > 0 OR
INSTR(su2.user_name,#{keyWord}) > 0
)
</if>
<if test="sampleUserName != null and sampleUserName!=''">
AND INSTR(su.user_name,#{sampleUserName}) > 0
</if>
<if test="sampleDate != null and sampleDate!=''">
AND DATE_FORMAT(ts.sample_date, '%Y-%m-%d') = #{sampleDate}
</if>
<if test="devTypeCode != null and devTypeCode!=''">
AND INSTR(tsd.sampleDevCode,#{devTypeCode})
</if>
ORDER BY dispatch_time ASC
</select>
<!--试验详情列表-->
<select id="getDetailList" resultType="com.bonus.aqgqj.basis.entity.vo.ExperimentalDetailVo">
SELECT sample_id AS sampleId,
dev_type_name AS devTypeName,
dev_type_code AS devTypeCode
FROM tb_sample_device
WHERE sample_id = #{id} AND del_falg = 0
<if test="devTypeCode != null and devTypeCode!=''">
AND INSTR(dev_type_code,#{devTypeCode})
</if>
GROUP BY dev_type_code
</select>
<!--查询试验模板数据、基础数据-->
<select id="getTestBasicInfo" resultType="com.bonus.aqgqj.basis.entity.vo.TestVo">
SELECT DATE_FORMAT(ts.sample_date, '%Y-%m-%d') AS sampleDate,
custom_id AS customId,
custom_name AS customName,
2024-07-20 17:31:33 +08:00
a.id AS configId,
a.dev_type_code AS devTypeCode,
a.dev_type_name AS devTypeName,
a.dev_module AS devModule,
a.exper_local_code AS experLocalCode,
a.exper_local AS experLocal
2024-07-20 15:18:16 +08:00
FROM tb_sample ts
LEFT JOIN (
2024-07-20 17:31:33 +08:00
SELECT tsd.dev_type_code,tsc.dev_type_name,tsc.dev_module,tsc.exper_local_code,tsc.exper_local,tsc.id,tsd.sample_id
2024-07-20 15:18:16 +08:00
FROM tb_sample_device tsd
LEFT JOIN tb_exper_config tsc ON tsc.dev_type_code = tsd.dev_type_code AND tsc.del_flag = 0
WHERE tsd.sample_id = #{id} AND tsd.del_falg = 0 AND tsd.dev_type_code = #{devTypeCode}
GROUP BY tsd.dev_type_code
) a ON a.sample_id = ts.id
WHERE ts.id = #{id} AND del_flag = 0
</select>
</mapper>