Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/codeCollection/WsMaInfoMapper.xml

209 lines
7.2 KiB
XML
Raw Normal View History

2025-06-25 16:48:48 +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.codeCollection.mapper.WsMaInfoMapper">
<resultMap id="BaseResultMap" type="com.bonus.material.codeCollection.domain.WsMaInfo">
<id column="id" property="id"/>
<result column="ma_name" property="maName"/>
<result column="ma_model" property="maModel"/>
<result column="ma_code" property="maCode"/>
<result column="supplier" property="supplier"/>
<result column="this_check_time" property="thisCheckTime"/>
<result column="next_check_time" property="nextCheckTime"/>
<result column="repair_man" property="repairMan"/>
<result column="check_man" property="checkMan"/>
<result column="phone" property="phone"/>
<result column="result" property="result"/>
<result column="type" property="type"/>
<result column="model_id" property="modelId"/>
<result column="is_active" property="isActive"/>
<result column="opt_user" property="optUser"/>
<result column="opt_time" property="optTime"/>
</resultMap>
<select id="selectById" resultMap="BaseResultMap">
2025-07-02 13:49:08 +08:00
SELECT id,
ma_name,
ma_model,
ma_code,
supplier,
DATE(now()) as this_check_time,
DATE(DATE_SUB(DATE_ADD(NOW(), INTERVAL 1 YEAR), INTERVAL 1 DAY)) as next_check_time,
repair_man,
check_man,
phone,
result,
type,
model_id,
is_active,
opt_user,
opt_time
2025-06-25 18:14:50 +08:00
FROM ws_ma_info
WHERE id = #{id}
2025-06-25 16:48:48 +08:00
</select>
2025-06-27 17:55:32 +08:00
2025-06-25 16:48:48 +08:00
<select id="getMaTypeData" resultType="java.util.Map">
SELECT type_id AS id,
type_name AS `name`
FROM ma_type
WHERE `level` = '3'
AND del_flag = '0'
and is_enter = '1'
</select>
<select id="getMaModeData" resultType="java.util.Map">
SELECT type_id AS id,
type_name AS `name`
FROM ma_type
2025-06-25 18:14:50 +08:00
WHERE parent_id = #{parentId}
2025-06-25 16:48:48 +08:00
AND del_flag = '0'
</select>
2025-06-25 18:14:50 +08:00
<select id="getSupplier" resultType="java.util.Map">
SELECT supplier_id AS id,
supplier AS `name`
FROM ma_supplier_info
WHERE del_flag = '0'
</select>
<select id="existsByModelAndCode" resultType="java.lang.Integer">
2025-07-02 13:49:08 +08:00
SELECT COUNT(*)
2025-06-25 18:14:50 +08:00
FROM ws_ma_info
2025-07-04 18:07:30 +08:00
WHERE
ma_code = #{maCode}
2025-06-25 18:14:50 +08:00
</select>
2025-07-28 18:41:33 +08:00
2025-07-29 15:53:01 +08:00
<select id="selectAll" resultType="com.bonus.material.codeCollection.domain.WsMaInfo">
SELECT * FROM (
SELECT
id AS id,
ma_code AS maCode,
ma_name AS maName,
2025-08-22 17:00:02 +08:00
LEFT(next_check_time, 10) AS nextCheckTime,
LEFT(this_check_time, 10) AS thisCheckTime,
2025-07-29 15:53:01 +08:00
ma_model AS maModel,
repair_man AS repairMan
FROM
ws_ma_info
2025-06-27 17:55:32 +08:00
<where>
2025-07-05 22:39:43 +08:00
<if test="maCode != null and maCode != ''">
2025-07-30 15:42:28 +08:00
and (ma_code like concat('%', #{maCode}, '%')
or qr_code = #{maCode})
2025-06-27 17:55:32 +08:00
</if>
</where>
2025-07-29 15:53:01 +08:00
LIMIT 10
) AS t1
UNION ALL
SELECT * FROM (
SELECT
mm.ma_id AS id,
mm.ma_code AS maCode,
mt1.type_name AS maName,
2025-08-22 17:00:02 +08:00
LEFT(mm.next_check_time, 10) AS nextCheckTime,
LEFT(mm.this_check_time, 10) AS thisCheckTime,
2025-07-29 15:53:01 +08:00
mt.type_name AS maModel,
mm.check_man AS repairMan
FROM
ma_machine mm
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt1.type_id = mt.parent_id
<where>
<if test="maCode != null and maCode != ''">
2025-07-30 15:42:28 +08:00
and (mm.ma_code like concat('%', #{maCode}, '%')
or mm.qr_code = #{maCode})
2025-07-29 15:53:01 +08:00
</if>
</where>
LIMIT 10
) AS t2
2025-06-27 17:55:32 +08:00
</select>
2025-08-28 15:25:52 +08:00
<select id="getGadgetList" resultType="com.bonus.material.codeCollection.domain.WsMaInfo">
SELECT id,
ma_name AS maName,
ma_model AS maModel,
ma_code AS maCode,
this_check_time AS thisCheckTime,
next_check_time AS nextCheckTime,
repair_man AS repairMan,
check_man AS checkMan,
phone,
result
FROM ws_ma_info wmi
WHERE is_active = '1'
<if test="keyWord != null and keyWord != ''">
and ( ma_name like concat('%', #{keyWord}, '%') or
ma_model like concat('%', #{keyWord}, '%') or
ma_code like concat('%', #{keyWord}, '%') or
repair_man like concat('%', #{keyWord}, '%') or
check_man like concat('%', #{keyWord}, '%')
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[
and (
DATE_FORMAT( this_check_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} or
DATE_FORMAT( next_check_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
)
]]>
</if>
</select>
2025-06-25 16:48:48 +08:00
2025-06-25 18:14:50 +08:00
<insert id="insert" parameterType="com.bonus.material.codeCollection.domain.WsMaInfo" useGeneratedKeys="true"
keyProperty="id">
INSERT INTO ws_ma_info (ma_name, ma_model, ma_code, supplier, this_check_time, next_check_time,
2025-07-04 18:07:30 +08:00
repair_man, check_man, phone, result, type, model_id, is_active, opt_user, opt_time, qr_code)
2025-06-25 18:14:50 +08:00
VALUES (#{maName}, #{maModel}, #{maCode}, #{supplier}, DATE(now()),
DATE(DATE_SUB(DATE_ADD(NOW(), INTERVAL 1 YEAR), INTERVAL 1 DAY)),
2025-07-04 18:07:30 +08:00
#{repairMan}, #{checkMan}, #{phone}, #{result}, #{type}, #{modelId}, #{isActive}, #{optUser}, now(), #{qrCode})
2025-06-25 16:48:48 +08:00
</insert>
<update id="update" parameterType="com.bonus.material.codeCollection.domain.WsMaInfo">
2025-06-25 18:14:50 +08:00
UPDATE ws_ma_info
SET ma_name = #{maName},
ma_model = #{maModel},
ma_code = #{maCode},
supplier = #{supplier},
this_check_time = #{thisCheckTime},
next_check_time = #{nextCheckTime},
repair_man = #{repairMan},
check_man = #{checkMan},
phone = #{phone},
result = #{result},
type = #{type},
model_id = #{modelId},
is_active = #{isActive},
opt_user = #{optUser},
opt_time = #{optTime}
WHERE id = #{id}
</update>
2025-07-28 18:41:33 +08:00
2025-08-22 17:00:02 +08:00
<update id="updateCheckTime">
2025-07-28 18:41:33 +08:00
<!-- 更新 ws_ma_info 表 -->
2025-06-25 18:14:50 +08:00
UPDATE ws_ma_info
2025-08-22 17:00:02 +08:00
SET this_check_time = #{thisCheckTime},
next_check_time = #{nextCheckTime},
2025-07-28 18:41:33 +08:00
opt_time = NOW()
WHERE ma_code = #{maCode};
<!-- 更新 ma_machine 表 -->
UPDATE ma_machine
2025-08-22 17:00:02 +08:00
SET this_check_time = #{thisCheckTime},
next_check_time = #{nextCheckTime},
2025-07-28 18:41:33 +08:00
update_time = NOW()
WHERE ma_code = #{maCode}
2025-06-25 16:48:48 +08:00
</update>
<delete id="deleteById" parameterType="int">
2025-06-25 18:14:50 +08:00
DELETE
FROM ws_ma_info
WHERE id = #{id}
2025-06-25 16:48:48 +08:00
</delete>
</mapper>