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

166 lines
4.5 KiB
XML
Raw Normal View History

2024-07-24 17:57:31 +08:00
<!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.TestReportManageDao">
<insert id="addSamples" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
INSERT INTO tb_sample(custom_id,
custom_name,
department,
sample_user,
sample_time,
create_time,
create_user,
sample_date)
VALUES (#{customId},
#{customName},
#{sampleDepartment},
#{sampleUser},
#{sampleTime},
NOW(),
#{createBy},
#{sampleTime})
</insert>
<insert id="addSamplesDevice">
INSERT INTO tb_sample_device(sample_id,
dev_type_name,
dev_type_code,
dev_module,
dev_code,
customer_code,
sample_time,
create_time,
create_user)
VALUES (#{id},
#{sampleTools},
#{devTypeCode},
#{devModule},
#{devCode},
#{customerCode},
#{sampleTime},
NOW(),
#{createBy})
</insert>
<update id="updateTeamId">
UPDATE tb_sample
SET team_id = #{teamId}
WHERE id = #{id}
</update>
<select id="list" resultType="com.bonus.aqgqj.basis.entity.dto.TestReportManageDto">
select
ts.id,
tc.custom_name AS customName,
ts.sample_user AS sampleUser,
ts.sample_time AS sampleTime,
su.user_name AS collectSamplesUser,
tsd.create_time AS collectSamplesTime,
tt.team_name AS teamName,
IFNULL(te.devNum,0) as devNum
FROM tb_sample ts
LEFT JOIN tb_custom tc
on tc.id = ts.custom_id
LEFT JOIN tb_sample_device tsd on tsd.sample_id = ts.id
LEFT JOIN (
SELECT
te.sample_id,
SUM( te.dev_num ) AS devNum
FROM
tb_exper te
WHERE
te.del_flag = 0
GROUP BY
te.sample_id
) te ON te.sample_id = ts.id
LEFT JOIN sys_user su on su.id = tsd.create_user
LEFT JOIN tb_team tt on tt.id = ts.team_id
WHERE ts.del_flag = '0'
<if test="collectSamplesUser != null and collectSamplesUser != ''">
AND su.user_name like concat('%', #{collectSamplesUser}, '%')
</if>
<if test="sampleTools != null and sampleTools != ''">
and tsd.dev_type_name like concat('%',#{sampleTools}, '%')
</if>
<if test="keyWord != null and keyWord != ''">
AND (
ts.sample_user like concat('%', #{keyWord}, '%') OR
tc.custom_name like concat('%', #{keyWord}, '%') OR
tt.team_name like concat('%', #{keyWord}, '%')
)
</if>
GROUP BY ts.id
</select>
<select id="getSampleTools" resultType="java.lang.String">
SELECT GROUP_CONCAT(aa.dev_type_name SEPARATOR '、') AS sampleTools
FROM (SELECT DISTINCT tsd.dev_type_name
FROM tb_sample_device tsd
LEFT JOIN tb_sample ts ON ts.id = tsd.sample_id
WHERE tsd.sample_id = #{id}
AND tsd.del_falg = '0') aa
</select>
<select id="getDetailsList" resultType="com.bonus.aqgqj.basis.entity.dto.TestReportManageDto">
SELECT
te.id,
te.dev_type_name as sampleTools,
ts.department as sampleDepartment,
te.dev_module as devModule,
te.dev_num as devNum
FROM
tb_exper te
LEFT JOIN tb_sample ts on ts.id=te.sample_id and ts.del_flag=0
WHERE
te.del_flag=0
and ts.id=#{id}
<if test="sampleTools != null and sampleTools != ''">
and te.dev_type_name like concat('%',#{sampleTools}, '%')
</if>
<if test="keyWord != null and keyWord != ''">
AND (
ts.department like concat('%', #{keyWord}, '%') OR
te.dev_module like concat('%', #{keyWord}, '%')
)
</if>
</select>
<select id="listTools" resultType="com.bonus.aqgqj.basis.entity.dto.TestReportManageDto">
select
id,
dict_name as name
from
sys_distinct
where
p_id = 92
and del_flag = 0
</select>
<select id="getAllCustomName" resultType="com.bonus.aqgqj.basis.entity.dto.TestReportManageDto">
SELECT
id,
custom_name AS name
FROM
tb_custom
WHERE
del_flag = 0
and custom_status=0
</select>
<select id="getDevTypeCodeById" resultType="java.lang.String">
select sd.dict_code
from sys_distinct sd
where sd.p_id = 92
and sd.id = #{sampleToolsId}
and del_flag = 0
</select>
<select id="selectCustomerCode" resultType="java.lang.String">
SELECT
SUBSTRING( customer_code, - 4 ) AS CODE
FROM
tb_sample_device
WHERE
SUBSTRING( customer_code, 1, 8 )= #{nowDate}
ORDER BY
customer_code DESC
LIMIT 1
</select>
<select id="getTeamSelected" resultType="com.bonus.aqgqj.basis.entity.dto.TestReportManageDto">
SELECT id,
team_name AS name
FROM tb_team
WHERE del_flag = 0
</select>
</mapper>