108 lines
4.6 KiB
XML
108 lines
4.6 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.MaDevRmMapper">
|
|
|
|
<delete id="deleteDevQcById">
|
|
delete from ma_dev_rm where ma_id = #{maId}
|
|
</delete>
|
|
|
|
<insert id="insertDevQc" useGeneratedKeys="true" keyProperty="id">
|
|
insert into ma_dev_rm
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="maId != null">ma_id,</if>
|
|
<if test="rmName != null and rmName != ''">rm_name,</if>
|
|
<if test="rmCode != null and rmCode != ''">rm_code,</if>
|
|
<if test="rmTime != null">rm_time,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="rmCom != null and rmCom != ''">rm_com,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="maId != null">#{maId},</if>
|
|
<if test="rmName != null and rmName != ''">#{rmName},</if>
|
|
<if test="rmCode != null and rmCode != ''">#{rmCode},</if>
|
|
<if test="rmTime != null">#{rmTime},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="rmCom != null and rmCom != ''">#{rmCom},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<select id="selectTaskNumByMonth" resultType="java.lang.String">
|
|
SELECT SUBSTRING(rm_code, - 4) as code
|
|
FROM ma_dev_rm
|
|
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.MaDevRm">
|
|
SELECT
|
|
m1.id,
|
|
m1.ma_id AS maId,
|
|
m2.CODE AS deviceCode,
|
|
m2.device_name AS deviceName,
|
|
m1.rm_name AS rmName,
|
|
m1.rm_code AS rmCode,
|
|
m1.rm_time AS rmTime,
|
|
su.nick_name AS createBy,
|
|
latest_rm.num AS num,
|
|
m1.create_time AS updateTime,
|
|
aa.create_time AS createTime
|
|
FROM
|
|
ma_dev_rm 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( rm_time ) AS max_rm_time FROM ma_dev_rm GROUP BY ma_id ) latest_rm ON m1.ma_id = latest_rm.ma_id
|
|
AND m1.rm_time = latest_rm.max_rm_time
|
|
INNER JOIN ( SELECT ma_id, min( create_time ) AS create_time FROM ma_dev_rm GROUP BY ma_id ) aa ON m1.ma_id = aa.ma_id
|
|
<where>
|
|
<if test="deviceCode != null and deviceCode != ''">
|
|
and m2.code like concat('%',#{deviceCode},'%')
|
|
</if>
|
|
<if test="minNum != null and maxNum != null">
|
|
and latest_rm.num BETWEEN #{minNum} AND #{maxNum}
|
|
</if>
|
|
<if test="rmCode != null and rmCode != ''">
|
|
and m1.rm_code like concat('%',#{rmCode},'%')
|
|
</if>
|
|
<if test="rmStartTime != null and rmStartTime != '' and rmEndTime != null and rmEndTime != ''">
|
|
and DATE_FORMAT(m1.rm_time,'%Y-%m-%d') between #{rmStartTime} and #{rmEndTime}
|
|
</if>
|
|
<if test="createStartTime != null and createStartTime != '' and createEndTime != null and createEndTime != ''">
|
|
and DATE_FORMAT(m1.create_time,'%Y-%m-%d') between #{createStartTime} and #{createEndTime}
|
|
</if>
|
|
<if test="rmCom != null and rmCom != ''">
|
|
and m1.rm_com = #{rmCom}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="selectQcList" resultType="com.bonus.material.device.domain.MaDevRm">
|
|
SELECT
|
|
mdq.*,
|
|
su.nick_name AS nickName,
|
|
bfi.url AS url
|
|
FROM
|
|
ma_dev_rm 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 = 6
|
|
AND bfi.task_id = #{id}
|
|
<if test="rmCode != null and rmCode != ''">
|
|
and mdq.rm_code like concat('%',#{rmCode},'%')
|
|
</if>
|
|
<if test="rmStartTime != null and rmStartTime != '' and rmEndTime != null and rmEndTime != ''">
|
|
and DATE_FORMAT(mdq.rm_time,'%Y-%m-%d') between #{rmStartTime} and #{rmEndTime}
|
|
</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>
|