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-26 18:09:29 +08:00
|
|
|
<update id="updateFileId">
|
|
|
|
|
update ma_dev_qc set file_id = #{fileId} where id = #{id}
|
|
|
|
|
</update>
|
2024-12-06 14:12:02 +08:00
|
|
|
|
2024-12-26 18:09:29 +08:00
|
|
|
<delete id="deleteDevQcByFileId">
|
|
|
|
|
delete from ma_dev_qc where file_id = #{fileId}
|
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-26 18:09:29 +08:00
|
|
|
m2.ma_id AS maId,
|
2024-12-09 17:45:05 +08:00
|
|
|
m2.CODE AS deviceCode,
|
|
|
|
|
m2.device_name AS deviceName,
|
|
|
|
|
m1.qc_code AS qcCode,
|
|
|
|
|
m1.qc_user AS qcUser,
|
|
|
|
|
m1.qc_time AS qcTime,
|
2024-12-23 10:15:42 +08:00
|
|
|
m3.maintenance_alarm_day,
|
2024-12-09 17:45:05 +08:00
|
|
|
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
|
2024-12-26 18:09:29 +08:00
|
|
|
ma_dev_info m2
|
|
|
|
|
LEFT JOIN ma_dev_qc m1 ON m1.ma_id = m2.ma_id
|
|
|
|
|
LEFT JOIN ma_type m3 ON m2.type_id = m3.type_id
|
2024-12-09 17:45:05 +08:00
|
|
|
LEFT JOIN sys_user su ON su.user_id = m1.create_by
|
2024-12-26 18:09:29 +08:00
|
|
|
LEFT 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
|
|
|
|
|
LEFT 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>
|
2024-12-26 18:09:29 +08:00
|
|
|
m2.is_active = '1'
|
2024-12-06 14:12:02 +08:00
|
|
|
<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 != ''">
|
2024-12-26 18:09:29 +08:00
|
|
|
and m2.own_co = #{qcCom}
|
2024-12-13 17:09:37 +08:00
|
|
|
</if>
|
2024-12-06 14:12:02 +08:00
|
|
|
</where>
|
2024-12-26 18:09:29 +08:00
|
|
|
GROUP BY m2.ma_id
|
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
|
2024-12-23 11:03:22 +08:00
|
|
|
LEFT JOIN bm_file_info bfi ON bfi.model_id = mdq.ma_id and bfi.task_id = mdq.id
|
2024-12-09 17:45:05 +08:00
|
|
|
LEFT JOIN sys_user su ON mdq.create_by = su.user_id
|
|
|
|
|
WHERE
|
|
|
|
|
bfi.task_type = 17
|
|
|
|
|
AND bfi.file_type = 4
|
2024-12-23 11:03:22 +08:00
|
|
|
AND bfi.model_id = #{maId}
|
2024-12-09 17:45:05 +08:00
|
|
|
<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,
|
2024-12-23 10:07:37 +08:00
|
|
|
mdc.id,
|
|
|
|
|
mdc.ma_id,
|
2024-12-20 16:06:27 +08:00
|
|
|
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,
|
2024-12-27 10:13:50 +08:00
|
|
|
mdc.ma_id,
|
2024-12-20 17:56:14 +08:00
|
|
|
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-20 20:19:28 +08:00
|
|
|
<select id="checkQcTime" resultType="com.bonus.material.device.domain.MaDevQc">
|
|
|
|
|
SELECT
|
|
|
|
|
mdc.create_time,
|
|
|
|
|
mdc.qc_com,
|
|
|
|
|
mdc.ma_id,
|
|
|
|
|
mdi.device_name,
|
2024-12-26 10:36:27 +08:00
|
|
|
mdi.own_id,
|
|
|
|
|
sd.dept_name as comName,
|
2024-12-20 20:19:28 +08:00
|
|
|
mdc.next_check_time
|
|
|
|
|
FROM
|
|
|
|
|
ma_dev_qc mdc
|
|
|
|
|
left join ma_dev_info mdi on mdi.ma_id = mdc.ma_id
|
2024-12-26 10:36:27 +08:00
|
|
|
left join sys_dept sd on mdc.qc_com = sd.dept_id
|
2024-12-20 20:19:28 +08:00
|
|
|
where mdc.next_check_time < now()
|
|
|
|
|
</select>
|
2024-12-06 14:12:02 +08:00
|
|
|
|
|
|
|
|
</mapper>
|