Bonus-Cloud-Material-Mall/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/MaDevQcMapper.xml

153 lines
6.3 KiB
XML
Raw Normal View History

2024-12-06 14:12:02 +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.device.mapper.MaDevQcMapper">
2024-12-20 18:50:16 +08:00
<update id="updateById">
update ma_dev_qc
<set>
2024-12-20 19:29:47 +08:00
<if test="qcUser != null and qcUser != ''">qc_user = #{qcUser},</if>
<if test="qcTime != null ">qc_time = #{qcTime},</if>
2024-12-20 18:50:16 +08:00
<if test="nextCheckTime != null ">next_check_time = #{nextCheckTime},</if>
</set>
where id = #{id}
</update>
2024-12-06 14:12:02 +08:00
<delete id="deleteDevQcById">
2024-12-10 13:39:23 +08:00
delete from ma_dev_qc where ma_id = #{maId}
2024-12-06 14:12:02 +08:00
</delete>
<insert id="insertDevQc" useGeneratedKeys="true" keyProperty="id">
insert into ma_dev_qc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="maId != null">ma_id,</if>
2024-12-20 17:15:04 +08:00
<if test="nextCheckTime != null">next_check_time,</if>
2024-12-06 14:12:02 +08:00
<if test="qcCode != null and qcCode != ''">qc_code,</if>
<if test="qcUser != null and qcUser != ''">qc_user,</if>
2024-12-13 17:09:37 +08:00
<if test="qcCom != null and qcCom != ''">qc_com,</if>
2024-12-06 14:12:02 +08:00
<if test="qcTime != null">qc_time,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="maId != null">#{maId},</if>
2024-12-20 15:26:51 +08:00
<if test="nextCheckTime != null">#{nextCheckTime},</if>
2024-12-06 14:12:02 +08:00
<if test="qcCode != null and qcCode != ''">#{qcCode},</if>
<if test="qcUser != null and qcUser != ''">#{qcUser},</if>
2024-12-13 17:09:37 +08:00
<if test="qcCom != null and qcCom != ''">#{qcCom},</if>
2024-12-06 14:12:02 +08:00
<if test="qcTime != null">#{qcTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<select id="selectTaskNumByMonth" resultType="java.lang.String">
2024-12-09 17:45:05 +08:00
SELECT SUBSTRING(qc_code, - 4) as code
2024-12-06 14:12:02 +08:00
FROM ma_dev_qc
WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
ORDER BY create_time DESC LIMIT 1
</select>
<select id="selectDevQcList" resultType="com.bonus.material.device.domain.MaDevQc">
2024-12-09 17:45:05 +08:00
SELECT
2024-12-06 14:12:02 +08:00
m1.id,
2024-12-09 17:45:05 +08:00
m1.ma_id AS maId,
m2.CODE AS deviceCode,
m2.device_name AS deviceName,
m1.qc_code AS qcCode,
m1.qc_user AS qcUser,
m1.qc_time AS qcTime,
su.nick_name AS createBy,
2024-12-10 15:58:10 +08:00
m1.create_time AS updateTime,
aa.create_time AS createTime
2024-12-09 17:45:05 +08:00
FROM
ma_dev_qc m1
LEFT JOIN ma_dev_info m2 ON m1.ma_id = m2.ma_id
AND m2.is_active = '1'
LEFT JOIN sys_user su ON su.user_id = m1.create_by
INNER JOIN ( SELECT count(*) as num, ma_id, MAX( qc_time ) AS max_qc_time FROM ma_dev_qc GROUP BY ma_id ) latest_qc ON m1.ma_id = latest_qc.ma_id
AND m1.qc_time = latest_qc.max_qc_time
2024-12-10 15:58:10 +08:00
INNER JOIN ( SELECT ma_id, min( create_time ) AS create_time FROM ma_dev_qc GROUP BY ma_id ) aa ON m1.ma_id = aa.ma_id
2024-12-06 14:12:02 +08:00
<where>
<if test="deviceCode != null and deviceCode != ''">
2024-12-09 17:45:05 +08:00
and m2.code like concat('%',#{deviceCode},'%')
2024-12-06 14:12:02 +08:00
</if>
<if test="qcUser != null and qcUser != ''">
and m1.qc_user like concat('%',#{qcUser},'%')
</if>
2024-12-10 13:39:23 +08:00
<if test="minNum != null and maxNum != null">
2024-12-09 17:45:05 +08:00
and latest_qc.num BETWEEN #{minNum} AND #{maxNum}
</if>
2024-12-06 14:12:02 +08:00
<if test="qcCode != null and qcCode != ''">
and m1.qc_code like concat('%',#{qcCode},'%')
</if>
<if test="qcStartTime != null and qcStartTime != '' and qcEndTime != null and qcEndTime != ''">
and DATE_FORMAT(m1.qc_time,'%Y-%m-%d') between #{qcStartTime} and #{qcEndTime}
</if>
<if test="createStartTime != null and createStartTime != '' and createEndTime != null and createEndTime != ''">
2024-12-10 15:58:10 +08:00
and DATE_FORMAT(m1.create_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime}
2024-12-06 14:12:02 +08:00
</if>
2024-12-13 17:09:37 +08:00
<if test="qcCom != null and qcCom != ''">
and m1.qc_com = #{qcCom}
</if>
2024-12-06 14:12:02 +08:00
</where>
2024-12-09 17:45:05 +08:00
</select>
<select id="selectQcList" resultType="com.bonus.material.device.domain.MaDevQc">
SELECT
mdq.*,
su.nick_name AS nickName,
bfi.url AS url
FROM
ma_dev_qc mdq
LEFT JOIN bm_file_info bfi ON bfi.model_id = mdq.ma_id
LEFT JOIN sys_user su ON mdq.create_by = su.user_id
WHERE
bfi.task_type = 17
AND bfi.file_type = 4
AND bfi.task_id = #{id}
<if test="qcCode != null and qcCode != ''">
and mdq.qc_code like concat('%',#{qcCode},'%')
</if>
<if test="qcStartTime != null and qcStartTime != '' and qcEndTime != null and qcEndTime != ''">
and DATE_FORMAT(mdq.qc_time,'%Y-%m-%d') between #{qcStartTime} and #{qcEndTime}
</if>
<if test="createStartTime != null and createStartTime != '' and createEndTime != null and createEndTime != ''">
and DATE_FORMAT(mdq.create_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime}
</if>
2024-12-06 14:12:02 +08:00
</select>
2024-12-20 10:47:36 +08:00
<select id="getQcList" resultType="com.bonus.material.device.domain.MaDevQc">
2024-12-20 16:06:27 +08:00
SELECT
mdc.qc_time,
mt.maintenance_alarm_day,
sd.dept_name comName
FROM
ma_dev_qc mdc
LEFT JOIN ma_dev_info mdi ON mdc.ma_id = mdi.ma_id
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
LEFT JOIN sys_dept sd ON mdc.qc_com = sd.dept_id
WHERE
mdc.ma_id = #{maId}
LIMIT 10
2024-12-20 10:47:36 +08:00
</select>
2024-12-20 17:56:14 +08:00
<select id="getQcListByOne" resultType="com.bonus.material.device.domain.MaDevQc">
SELECT
2024-12-20 18:50:16 +08:00
mdc.id,
2024-12-20 17:56:14 +08:00
mdc.qc_time,
mt.maintenance_alarm_day,
mdc.qc_user,
mdc.next_check_time,
sd.dept_name comName
FROM
ma_dev_qc mdc
LEFT JOIN ma_dev_info mdi ON mdc.ma_id = mdi.ma_id
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
LEFT JOIN sys_dept sd ON mdc.qc_com = sd.dept_id
WHERE
mdc.ma_id = #{maId}
order by mdc.qc_time desc
LIMIT 1
</select>
2024-12-06 14:12:02 +08:00
</mapper>