108 lines
4.5 KiB
XML
108 lines
4.5 KiB
XML
<?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">
|
|
|
|
<delete id="deleteDevQcById">
|
|
delete from ma_dev_qc where id = #{id}
|
|
</delete>
|
|
|
|
<insert id="insertDevQc" useGeneratedKeys="true" keyProperty="id">
|
|
insert into ma_dev_qc
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="maId != null">ma_id,</if>
|
|
<if test="qcName != null and qcName != ''">qc_name,</if>
|
|
<if test="qcCode != null and qcCode != ''">qc_code,</if>
|
|
<if test="qcUser != null and qcUser != ''">qc_user,</if>
|
|
<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>
|
|
<if test="qcName != null and qcName != ''">#{qcName},</if>
|
|
<if test="qcCode != null and qcCode != ''">#{qcCode},</if>
|
|
<if test="qcUser != null and qcUser != ''">#{qcUser},</if>
|
|
<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">
|
|
SELECT SUBSTRING(qc_code, - 4) as code
|
|
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">
|
|
SELECT
|
|
m1.id,
|
|
m1.ma_id AS maId,
|
|
m2.CODE AS deviceCode,
|
|
m2.device_name AS deviceName,
|
|
m1.qc_name AS qcName,
|
|
m1.qc_code AS qcCode,
|
|
m1.qc_user AS qcUser,
|
|
m1.qc_time AS qcTime,
|
|
su.nick_name AS createBy,
|
|
m1.create_time AS createTime
|
|
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
|
|
<where>
|
|
<if test="deviceCode != null and deviceCode != ''">
|
|
and m2.code like concat('%',#{deviceCode},'%')
|
|
</if>
|
|
<if test="qcUser != null and qcUser != ''">
|
|
and m1.qc_user like concat('%',#{qcUser},'%')
|
|
</if>
|
|
<if test="minNum != null and maxNum != ''">
|
|
and latest_qc.num BETWEEN #{minNum} AND #{maxNum}
|
|
</if>
|
|
<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 != ''">
|
|
and DATE_FORMAT(m1.update_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime}
|
|
</if>
|
|
</where>
|
|
ORDER BY
|
|
m1.qc_time DESC
|
|
</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>
|
|
</select>
|
|
|
|
</mapper>
|