Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml

779 lines
32 KiB
XML
Raw Normal View History

2024-09-27 15:31:39 +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.ma.mapper.MachineMapper">
<resultMap type="com.bonus.material.ma.domain.Machine" id="MachineResult">
<result property="maId" column="ma_id" />
<result property="typeId" column="type_id" />
<result property="maCode" column="ma_code" />
<result property="preCode" column="pre_code" />
<result property="maStatus" column="ma_status" />
<result property="qrCode" column="qr_code" />
<result property="buyPrice" column="buy_price" />
<result property="maVender" column="ma_vender" />
<result property="outFacTime" column="out_fac_time" />
<result property="outFacCode" column="out_fac_code" />
<result property="assetsCode" column="assets_code" />
<result property="checkMan" column="check_man" />
<result property="thisCheckTime" column="this_check_time" />
<result property="nextCheckTime" column="next_check_time" />
<result property="gpsCode" column="gps_code" />
<result property="rfidCode" column="rfid_code" />
<result property="erpCode" column="erp_code" />
<result property="transferCode" column="transfer_code" />
<result property="inOutNum" column="in_out_num" />
<result property="buyTask" column="buy_task" />
<result property="ownHouse" column="own_house" />
<result property="companyId" column="company_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="inspectMan" column="inspect_man" />
<result property="inspectStatus" column="inspect_status" />
<result property="phone" column="phone" />
</resultMap>
<sql id="selectMachineVo">
2024-12-20 10:52:01 +08:00
select ma_id, type_id, ma_code, pre_code, ma_status, qr_code, buy_price, ma_vender, out_fac_time,
out_fac_code, assets_code, check_man, this_check_time, next_check_time, gps_code, rfid_code,
erp_code, transfer_code, in_out_num, buy_task, own_house, company_id, create_time, update_time,
inspect_man, inspect_status, phone from ma_machine
2024-09-27 15:31:39 +08:00
</sql>
2024-11-05 14:53:32 +08:00
<select id="selectMachineList" resultType="com.bonus.material.ma.domain.vo.MachineVo">
2025-02-11 09:21:44 +08:00
select a.*
from (
2024-10-17 16:05:21 +08:00
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
ma.ma_status as maStatus,
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
2024-10-29 16:11:23 +08:00
msi.supplier as maVender,
2024-10-17 16:05:21 +08:00
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
2025-02-20 22:00:39 +08:00
tt.code as buyTask,
2024-10-17 16:05:21 +08:00
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
2025-02-11 09:21:44 +08:00
ma.phone as phone,
2025-07-23 18:56:14 +08:00
mt.jiju_type as jijuType,
2025-02-11 09:21:44 +08:00
CASE
WHEN RIGHT(ma.ma_code, 4) REGEXP '^[0-9]{4}$' THEN CAST(RIGHT(ma.ma_code, 4) AS UNSIGNED)
WHEN RIGHT(ma.ma_code, 3) REGEXP '^[0-9]{3}$' THEN CAST(RIGHT(ma.ma_code, 3) AS UNSIGNED)
WHEN RIGHT(ma.ma_code, 2) REGEXP '^[0-9]{2}$' THEN CAST(RIGHT(ma.ma_code, 2) AS UNSIGNED)
WHEN RIGHT(ma.ma_code, 1) REGEXP '^[0-9]$' THEN CAST(RIGHT(ma.ma_code, 1) AS UNSIGNED)
ELSE '0'
END AS result
2024-10-17 16:05:21 +08:00
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
2025-02-11 09:21:44 +08:00
and mt.`level` = '4' and mt.del_flag = '0'
2024-10-17 16:05:21 +08:00
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
2024-10-29 16:11:23 +08:00
LEFT JOIN ma_supplier_info msi ON msi.supplier_id = ma.ma_vender
2025-02-20 22:00:39 +08:00
LEFT JOIN tm_task tt on tt.task_id=ma.buy_task
2024-10-17 16:05:21 +08:00
where
1 = 1
<if test="keyWord != null and keyWord != ''">
2025-02-11 09:21:44 +08:00
and (
2024-10-17 16:05:21 +08:00
ma.ma_code like concat('%', #{keyWord}, '%')
or ma.assets_code like concat('%', #{keyWord}, '%')
or ma.pre_code like concat('%', #{keyWord}, '%')
or ma.buy_task like concat('%', #{keyWord}, '%')
or ma.own_house like concat('%', #{keyWord}, '%')
2025-06-19 10:28:50 +08:00
or mt4.type_name like concat('%', #{keyWord}, '%')
or mt3.type_name like concat('%', #{keyWord}, '%')
or mt2.type_name like concat('%', #{keyWord}, '%')
or mt.type_name like concat('%', #{keyWord}, '%')
2025-02-11 09:21:44 +08:00
)
2024-10-17 16:05:21 +08:00
</if>
2024-11-14 16:30:20 +08:00
<if test="typeId != null">
and ma.type_id = #{typeId}
</if>
2024-11-16 16:11:59 +08:00
<if test="maStatus != null and maStatus != ''">
and ma.ma_status = #{maStatus}
</if>
2024-11-21 17:43:05 +08:00
<if test="maCode != null and maCode != ''">
2025-02-11 09:21:44 +08:00
and ma.ma_code like concat('%', #{maCode}, '%')
2024-11-21 17:43:05 +08:00
</if>
2025-02-07 17:10:25 +08:00
<if test="qrCode != null and qrCode != ''">
and ma.qr_code like concat('%', #{qrCode}, '%')
</if>
2024-10-17 16:05:21 +08:00
<if test="materialType != null and materialType != ''">
2025-02-11 09:21:44 +08:00
and mt3.type_name like concat('%', #{materialType}, '%')
2024-10-17 16:05:21 +08:00
</if>
<if test="materialName != null and materialName != ''">
2025-02-11 09:21:44 +08:00
and mt2.type_name like concat('%', #{materialName}, '%')
2024-10-17 16:05:21 +08:00
</if>
<if test="materialModel != null and materialModel != ''">
2025-02-11 09:21:44 +08:00
and mt.type_name like concat('%', #{materialModel}, '%')
2024-10-17 16:05:21 +08:00
</if>
<if test="isAssets != null">
<if test="isAssets == 0">
AND ma.assets_code IS NOT NULL
AND ma.assets_code != ''
</if>
<if test="isAssets == 1">
AND (ma.assets_code IS NULL OR ma.assets_code = '')
</if>
</if>
2025-02-11 09:21:44 +08:00
) a
where
1=1
<if test="prefix != null and suffix !=null">
and a.result BETWEEN #{prefix} and #{suffix}
</if>
order by a.createTime desc
2024-09-27 15:31:39 +08:00
</select>
2024-10-17 16:05:21 +08:00
2024-11-05 14:53:32 +08:00
<select id="selectMachineByMaId" resultType="com.bonus.material.ma.domain.vo.MachineVo">
2024-10-17 16:05:21 +08:00
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
ma.ma_status as maStatus,
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
ma.ma_vender as maVender,
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
2025-05-08 16:23:10 +08:00
tt.code as buyTask,
2024-10-17 16:05:21 +08:00
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
2024-10-18 13:26:45 +08:00
ma.phone as phone,
2024-12-24 14:10:56 +08:00
GROUP_CONCAT( DISTINCT su1.user_id ORDER BY su1.user_id SEPARATOR ',' ) AS keeperId,
GROUP_CONCAT( DISTINCT su1.nick_name ORDER BY su1.user_id SEPARATOR ',' ) AS keeperName,
GROUP_CONCAT( DISTINCT su2.user_id ORDER BY su2.user_id SEPARATOR ',' ) AS repairId,
GROUP_CONCAT( DISTINCT su2.nick_name ORDER BY su2.user_id SEPARATOR ',' ) AS repairName,
2024-10-18 13:26:45 +08:00
baa.asset_name as assetName,
2024-10-31 15:21:52 +08:00
ma.assets_id as assetsId,
2024-10-18 13:26:45 +08:00
ma.remark as remark
2024-10-17 16:05:21 +08:00
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
2024-10-18 13:26:45 +08:00
LEFT JOIN ma_type_keeper mtk on ma.type_id = mtk.type_id
2024-12-24 10:05:57 +08:00
LEFT JOIN sys_user su1 on mtk.user_id = su1.user_id
2024-10-18 13:26:45 +08:00
LEFT JOIN ma_type_repair mtr on ma.type_id = mtr.type_id
2024-12-24 10:05:57 +08:00
LEFT JOIN sys_user su2 on mtr.user_id = su2.user_id
2024-10-18 13:26:45 +08:00
LEFT JOIN bm_asset_attributes baa on ma.assets_id = baa.id
2025-05-08 16:23:10 +08:00
LEFT JOIN tm_task tt on tt.task_id=ma.buy_task
2024-10-17 16:05:21 +08:00
where ma.ma_id = #{maId}
2024-09-27 15:31:39 +08:00
</select>
2024-10-17 16:05:21 +08:00
2024-10-17 17:51:42 +08:00
<select id="selectByTypeList" resultType="com.bonus.material.ma.domain.Type">
SELECT
type_id as typeId,
type_name as typeName,
parent_id as parentId,
storage_num as storageNum,
type_code as typeCode,
level as level
FROM
ma_type
WHERE del_flag = '0'
<if test="level != null and level != ''">
and level = #{level}
</if>
2025-06-19 10:28:50 +08:00
<if test="typeId != null">
and parent_id = #{typeId}
</if>
2024-10-17 17:51:42 +08:00
</select>
2024-09-27 15:31:39 +08:00
<insert id="insertMachine" parameterType="com.bonus.material.ma.domain.Machine" useGeneratedKeys="true" keyProperty="maId">
insert into ma_machine
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeId != null">type_id,</if>
<if test="maCode != null">ma_code,</if>
<if test="preCode != null">pre_code,</if>
<if test="maStatus != null">ma_status,</if>
<if test="qrCode != null">qr_code,</if>
<if test="buyPrice != null">buy_price,</if>
<if test="maVender != null">ma_vender,</if>
<if test="outFacTime != null">out_fac_time,</if>
<if test="outFacCode != null">out_fac_code,</if>
<if test="assetsCode != null">assets_code,</if>
<if test="checkMan != null">check_man,</if>
<if test="thisCheckTime != null">this_check_time,</if>
<if test="nextCheckTime != null">next_check_time,</if>
<if test="gpsCode != null">gps_code,</if>
<if test="rfidCode != null">rfid_code,</if>
<if test="erpCode != null">erp_code,</if>
<if test="transferCode != null">transfer_code,</if>
<if test="inOutNum != null">in_out_num,</if>
<if test="buyTask != null">buy_task,</if>
<if test="ownHouse != null">own_house,</if>
<if test="companyId != null">company_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="inspectMan != null">inspect_man,</if>
<if test="inspectStatus != null">inspect_status,</if>
<if test="phone != null">phone,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeId != null">#{typeId},</if>
<if test="maCode != null">#{maCode},</if>
<if test="preCode != null">#{preCode},</if>
<if test="maStatus != null">#{maStatus},</if>
<if test="qrCode != null">#{qrCode},</if>
<if test="buyPrice != null">#{buyPrice},</if>
<if test="maVender != null">#{maVender},</if>
<if test="outFacTime != null">#{outFacTime},</if>
<if test="outFacCode != null">#{outFacCode},</if>
<if test="assetsCode != null">#{assetsCode},</if>
<if test="checkMan != null">#{checkMan},</if>
<if test="thisCheckTime != null">#{thisCheckTime},</if>
<if test="nextCheckTime != null">#{nextCheckTime},</if>
<if test="gpsCode != null">#{gpsCode},</if>
<if test="rfidCode != null">#{rfidCode},</if>
<if test="erpCode != null">#{erpCode},</if>
<if test="transferCode != null">#{transferCode},</if>
<if test="inOutNum != null">#{inOutNum},</if>
<if test="buyTask != null">#{buyTask},</if>
<if test="ownHouse != null">#{ownHouse},</if>
<if test="companyId != null">#{companyId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="inspectMan != null">#{inspectMan},</if>
<if test="inspectStatus != null">#{inspectStatus},</if>
<if test="phone != null">#{phone},</if>
</trim>
</insert>
<update id="updateMachine" parameterType="com.bonus.material.ma.domain.Machine">
update ma_machine
<trim prefix="SET" suffixOverrides=",">
<if test="typeId != null">type_id = #{typeId},</if>
<if test="maCode != null">ma_code = #{maCode},</if>
<if test="preCode != null">pre_code = #{preCode},</if>
<if test="maStatus != null">ma_status = #{maStatus},</if>
<if test="qrCode != null">qr_code = #{qrCode},</if>
<if test="buyPrice != null">buy_price = #{buyPrice},</if>
<if test="maVender != null">ma_vender = #{maVender},</if>
<if test="outFacTime != null">out_fac_time = #{outFacTime},</if>
<if test="outFacCode != null">out_fac_code = #{outFacCode},</if>
<if test="assetsCode != null">assets_code = #{assetsCode},</if>
<if test="checkMan != null">check_man = #{checkMan},</if>
<if test="thisCheckTime != null">this_check_time = #{thisCheckTime},</if>
<if test="nextCheckTime != null">next_check_time = #{nextCheckTime},</if>
<if test="gpsCode != null">gps_code = #{gpsCode},</if>
<if test="rfidCode != null">rfid_code = #{rfidCode},</if>
<if test="erpCode != null">erp_code = #{erpCode},</if>
<if test="transferCode != null">transfer_code = #{transferCode},</if>
<if test="inOutNum != null">in_out_num = #{inOutNum},</if>
<if test="buyTask != null">buy_task = #{buyTask},</if>
<if test="ownHouse != null">own_house = #{ownHouse},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="inspectMan != null">inspect_man = #{inspectMan},</if>
<if test="inspectStatus != null">inspect_status = #{inspectStatus},</if>
<if test="phone != null">phone = #{phone},</if>
2024-10-29 16:42:40 +08:00
<if test="assetsId != null">assets_id = #{assetsId},</if>
<if test="remark != null">remark = #{remark},</if>
2025-06-30 14:19:47 +08:00
<if test="materialModel != null">machine_name = #{materialModel},</if>
2024-09-27 15:31:39 +08:00
</trim>
where ma_id = #{maId}
</update>
<delete id="deleteMachineByMaId" parameterType="Long">
delete from ma_machine where ma_id = #{maId}
</delete>
2024-12-24 19:30:58 +08:00
2024-09-27 15:31:39 +08:00
<delete id="deleteMachineByMaIds" parameterType="String">
delete from ma_machine where ma_id in
2024-09-27 15:31:39 +08:00
<foreach item="maId" collection="array" open="(" separator="," close=")">
#{maId}
</foreach>
</delete>
2024-11-14 16:02:40 +08:00
<select id="getMachineStatus" resultType="java.lang.String">
2024-12-20 10:52:01 +08:00
select ma_status from ma_machine where ma_id = #{maId}
2024-11-14 16:02:40 +08:00
</select>
<update id="updateMaMachineStatus">
UPDATE
2024-12-20 10:52:01 +08:00
ma_machine
2024-11-14 16:02:40 +08:00
SET
2024-12-20 10:52:01 +08:00
ma_status = #{status},create_time = NOW()
2024-11-14 16:02:40 +08:00
<where>
type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''">
and ma_id = #{record.maId}
</if>
</where>
</update>
2024-12-20 10:52:01 +08:00
2024-11-21 17:43:05 +08:00
<update id="updateStatus">
UPDATE
ma_machine
SET
2025-06-29 14:43:51 +08:00
ma_status = #{status},
in_out_num = ifnull(in_out_num,0) + 1
2024-11-21 17:43:05 +08:00
where
ma_id = #{maId}
</update>
2024-12-20 10:52:01 +08:00
<select id="selectMachineByMaCode" resultType="com.bonus.material.ma.domain.vo.MachineVo">
SELECT
ma.ma_id as maId,ma.type_id as typeId,ma.ma_code as maCode,ma.pre_code as preCode,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_status as maStatus,ma.qr_code as qrCode,ma.buy_price as buyPrice,
ma.ma_vender as maVender,ma.out_fac_time as outFacTime,ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,ma.check_man as checkMan,ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,ma.gps_code as gpsCode,ma.rfid_code as rfidCode,
ma.erp_code as erpCode,ma.transfer_code as transferCode,ma.in_out_num as inOutNum,
ma.buy_task as buyTask,ma.own_house as ownHouse,ma.company_id as companyId,ma.remark as remark,
ma.create_time as createTime,ma.update_time as updateTime,ma.inspect_man as inspectMan,ma.assets_id as assetsId,
ma.inspect_status as inspectStatus,ma.phone as phone,
mtk.user_id as keeperId,
mtr.user_id as repairId,
baa.asset_name as assetName
FROM
ma_machine ma
LEFT JOIN
ma_type mt ON ma.type_id = mt.type_id and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN
ma_type mt2 ON mt2.type_id = mt.parent_id and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN
ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN
ma_type mt4 ON mt3.parent_id = mt4.type_id and mt4.`level` = '1' and mt4.del_flag = '0'
LEFT JOIN
ma_type_keeper mtk on ma.type_id = mtk.type_id
LEFT JOIN
ma_type_repair mtr on ma.type_id = mtr.type_id
LEFT JOIN
bm_asset_attributes baa on ma.assets_id = baa.id
2025-07-02 16:39:27 +08:00
where 1 = 1
<if test="maCode != null and maCode != ''">
and ma.ma_code = #{maCode}
</if>
<if test="qrCode != null and qrCode != ''">
and ma.qr_code = #{qrCode}
</if>
2024-12-20 10:52:01 +08:00
group by
ma.ma_id
limit 1
</select>
2024-12-24 19:30:58 +08:00
2025-02-18 09:20:55 +08:00
<select id="getMachineList" resultType="com.bonus.material.ma.domain.Machine">
SELECT
mt1.type_name as materialName,
mt.type_name as materialModel,
mt.type_id as typeId,
mm.ma_id as maId,
mm.ma_code as maCode
FROM
ma_machine mm
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
AND mt.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
WHERE
2025-02-20 19:20:55 +08:00
mm.ma_status = '1' and mt.type_id = #{typeId}
2025-02-18 09:20:55 +08:00
</select>
2025-02-20 22:00:39 +08:00
<select id="getElectronicLabel" resultType="com.bonus.material.ma.domain.Machine">
SELECT
mm.ma_id as maId,
mt2.type_name as materialName,
mt.type_name as materialModel,
mm.ma_code as maCode,
mm.this_check_time as thisCheckTime,
mm.next_check_time as nextCheckTime,
mm.check_man as checkMan,
mm.inspect_man as inspectMan,
mm.phone,
2025-03-05 13:27:10 +08:00
'合格' as inspectStatus,
2025-02-20 22:00:39 +08:00
mm.ma_vender as maVender,
mm.ex_code as exCode,
mm.ex_url as exUrl,
2025-03-05 14:32:17 +08:00
mm.is_jj as isJj,
mm.type_id as typeId
2025-02-20 22:00:39 +08:00
FROM
ma_machine mm
LEFT JOIN ma_type mt on mt.type_id=mm.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
WHERE
2025-03-05 13:27:10 +08:00
mm.ma_status = '2' and
2025-02-20 22:00:39 +08:00
mm.ma_code like concat('%', #{maCode}, '%')
</select>
2025-03-05 13:27:10 +08:00
<select id="selectMaId" resultType="java.lang.Long">
select ma_id
from ma_machine
WHERE ma_code = #{maCode}
</select>
2025-03-05 14:32:17 +08:00
<select id="selectHouse" resultType="com.bonus.material.ma.domain.Machine">
SELECT
whi.house_name as ownHouse
FROM
ma_type mt
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
AND mt1.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
AND mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
AND mt3.del_flag = '0'
LEFT JOIN wh_house_set whs ON mt3.type_id = whs.type_id
LEFT JOIN wh_house_info whi ON whs.house_id = whi.house_id
WHERE
mt.type_id = #{typeId}
</select>
2025-03-05 17:10:17 +08:00
<select id="getByMaCode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
2025-06-25 15:53:52 +08:00
mi.id as maId,
mi.ma_name as materialName,
mi.ma_model as materialModel,
mi.ma_code as maCode,
mi.this_check_time as thisCheckTime,
mi.next_check_time as nextCheckTime,
mi.repair_man as repairMan,
mi.check_man as checkMan,
mi.phone,
mi.result,null AS reportCode,null AS reportUrl,
mi.type
2025-03-05 17:10:17 +08:00
FROM
2025-06-25 15:53:52 +08:00
ws_ma_info mi
WHERE mi.ma_code LIKE CONCAT('%',#{maCode},'%') and mi.is_active = 1 and DATEDIFF(mi.next_check_time,NOW()) > 0
UNION
SELECT
mm.ma_id AS id,
mt2.type_name as maName,
mt.type_name as maModel,
mm.ma_code as maCode,
mm.this_check_time as thisCheckTime,
mm.next_check_time as nextCheckTime,
mm.check_man as repairMan,
ifnull(mm.inspect_man,"高民") as checkMan,
"0551-63703966" as phone,
"合格" as result,mm.ex_code AS reportCode,mm.ex_url AS reportUrl,
is_jj as type
FROM ma_machine mm
LEFT JOIN ma_type mt on mm.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
WHERE mm.ma_code LIKE CONCAT('%',#{maCode},'%') and mt.MANAGE_TYPE =0 and DATEDIFF(mm.next_check_time,NOW()) > 0
2025-03-05 17:10:17 +08:00
</select>
2024-12-24 19:30:58 +08:00
<delete id="deleteMachineByMaCodeAndTypeId">
delete from ma_machine where ma_code = #{maCode} and type_id = #{typeId}
and ma_status = '0'
</delete>
2025-04-16 18:14:53 +08:00
<update id="updateSynchReport" >
update ma_machine
<trim prefix="SET" suffixOverrides=",">
<if test="tester != null">check_man = #{tester},inspect_man = #{tester},</if>
<if test="checkTimeSynch != null">this_check_time = #{checkTimeSynch},</if>
<if test="nextCheckTimeSynch != null">next_check_time = #{nextCheckTimeSynch},</if>
<if test="result != null">inspect_status = #{result},</if>
<if test="reportNum != null">ex_code = #{reportNum},</if>
<if test="pdf != null">ex_url = #{pdf},</if>
<if test="reportName != null">ex_name = #{reportName},</if>
ex_up_time = NOW(),
</trim>
where ma_code = #{selfCode}
</update>
2025-05-08 16:23:10 +08:00
<update id="editAssetsCode" parameterType="com.bonus.material.ma.domain.Machine">
update ma_machine
SET
assets_code = #{assetsCode}
where ma_id = #{maId}
</update>
2025-06-15 09:51:07 +08:00
<select id="selectMachineByQrCode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
mm.ma_id as maId,
mm.ma_code as maCode,
mm.type_id as typeId,
mm.ma_status as maStatus,
mm.qr_code as qrCode,
mm.buy_price as buyPrice,
mm.ma_vender as maVender,
mm.out_fac_time as outFacTime,
mm.out_fac_code as outFacCode,
mm.assets_code as assetsCode,
mm.check_man as checkMan,
mm.this_check_time as thisCheckTime
FROM
ma_machine mm
WHERE
mm.qr_code = #{qrCode}
2025-06-25 16:35:29 +08:00
</select>
2025-06-25 15:40:06 +08:00
2025-06-29 14:43:51 +08:00
<select id="getInfoByQrcode" resultType="com.bonus.material.ma.domain.Machine">
2025-06-25 15:40:06 +08:00
SELECT
mm.ma_id as maId,
mt2.type_name as maName,
mt.type_name as maModel,
mm.ma_code as maCode,
mm.qr_code as qrCode,
mm.type_id as typeId,
sd.dict_label as maStatus,
mm.qr_code as qrCode,
mm.ma_vender as maVender,
mm.out_fac_time as outFacTime,
mm.out_fac_code as outFacCode,
mm.assets_code as assetsCode,
mm.check_man as checkMan,
mm.this_check_time as thisCheckTime,
mm.next_check_time as nextCheckTime,
mm.in_out_num as inOutNum
FROM
ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN sys_dict_data sd on mm.ma_status = sd.dict_value and sd.dict_type = "ma_machine_status"
where mm.qr_code = #{qrCode}
</select>
2025-06-29 14:43:51 +08:00
<select id="getInTimeByQrcode" resultType="com.bonus.material.ma.domain.Machine">
2025-06-25 15:40:06 +08:00
SELECT
bqi.qr_code as qrCode,
bqi.task_id as taskId,
LEFT(bqi.create_time,10) as inTime
FROM
bm_qrcode_info bqi
WHERE bqi.qr_code = #{qrCode}
</select>
2025-06-29 14:43:51 +08:00
<select id="getServiceNumByQrcode" resultType="com.bonus.material.ma.domain.Machine">
2025-06-25 15:40:06 +08:00
SELECT
COUNT(DISTINCT sai.agreement_id) as serviceNum
FROM slt_agreement_info sai
WHERE sai.ma_id = #{maId}
</select>
2025-06-29 14:43:51 +08:00
<select id="getCheckNumByQrcode" resultType="com.bonus.material.ma.domain.Machine">
2025-06-25 15:40:06 +08:00
SELECT
COUNT(rp.ma_id ) as checkNum
FROM
repair_part_details rp
WHERE rp.ma_id = #{maId} and rp.is_ds = 0
</select>
2025-06-29 14:43:51 +08:00
<select id="getScrapTimeByQrcode" resultType="com.bonus.material.ma.domain.Machine">
2025-06-25 15:40:06 +08:00
SELECT
sd.ma_id,
sd.task_id,
sd.ledger_time
FROM
scrap_apply_details sd
WHERE sd.ma_id = #{maId}
</select>
2025-06-29 14:43:51 +08:00
<select id="getLeaseInfoByQrcode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
sai.id,
bu.unit_name AS leaseUnit,
bp.pro_name AS leaseProject,
sai.start_time AS leaseTime,
IF( sai.status = 1, bu.unit_name,"") AS backUnit,
IF( sai.status = 1, bp.pro_name ,"") AS backProject,
IF( sai.status = 1, sai.end_time ,"") AS backTime,
sai.status
FROM
slt_agreement_info sai
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
LEFT JOIN bm_unit bu on bai.unit_id = bu.unit_id
LEFT JOIN bm_project bp on bai.project_id = bp.pro_id
WHERE sai.ma_id = #{maId}
ORDER BY sai.ID desc
limit 1
</select>
<select id="getListByCode" resultType="com.bonus.material.ma.domain.Machine">
SELECT
mm.ma_id as maId,
mt2.type_name as maName,
mt.type_name as maModel,
mm.ma_code as maCode,
mm.qr_code as qrCode,
mm.type_id as typeId,
sd.dict_label as maStatus,
mm.qr_code as qrCode,
mm.ma_vender as maVender,
mm.out_fac_time as outFacTime,
mm.out_fac_code as outFacCode,
mm.assets_code as assetsCode,
mm.check_man as checkMan,
mm.this_check_time as thisCheckTime,
mm.next_check_time as nextCheckTime,
mm.in_out_num as inOutNum
FROM
ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN sys_dict_data sd on mm.ma_status = sd.dict_value and sd.dict_type = "ma_machine_status"
where 1=1
<if test="maCode != null">and mm.ma_code LIKE CONCAT('%',#{maCode},'%')</if>
<if test="maId != null">and mm.ma_id = #{maId}</if>
limit 100
2025-06-25 15:40:06 +08:00
</select>
2025-06-30 14:19:47 +08:00
2025-06-30 18:08:26 +08:00
<select id="getInfoByMaCode" resultType="com.bonus.material.ma.domain.Machine">
2025-06-30 14:19:47 +08:00
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt2.type_name as materialName,
CASE WHEN ma.machine_name IS NOT NULL THEN ma.machine_name ELSE mt.type_name END as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
2025-06-30 18:08:26 +08:00
sda.dict_label as maStatus,
2025-06-30 14:19:47 +08:00
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
ma.ma_vender as maVender,
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
ma.phone as phone,
ma.assets_id as assetsId,
ma.remark as remark
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
2025-06-30 18:08:26 +08:00
LEFT JOIN sys_dict_data sda on sda.dict_value = ma.ma_status
and sda.dict_type = "ma_machine_status"
where
1=1
<if test="maCode != null and maCode != ''">
and ma.ma_code LIKE CONCAT('%',#{maCode},'%')
</if>
<if test="qrCode != null and qrCode != ''">
and ma.qr_code = #{qrCode}
</if>
2025-06-30 14:19:47 +08:00
</select>
2025-07-02 16:39:27 +08:00
<select id="selectMaInfoByMaCode" resultType="com.bonus.material.ma.domain.vo.MachineVo">
SELECT
ma_name as materialName,
ma_model as materialModel,
ma_code as maCode,
supplier as maVender,
this_check_time as thisCheckTime,
next_check_time as nextCheckTime,
repair_man as inspectMan,
check_man as checkMan,
model_id as typeId,
result as inspectStatus,
2025-07-04 18:07:30 +08:00
phone as phone,
id as maId
2025-07-02 16:39:27 +08:00
FROM
ws_ma_info
where ma_code = #{maCode}
</select>
2025-07-04 18:07:30 +08:00
<select id="getInfoByTypeId" resultType="com.bonus.material.ma.domain.Machine">
SELECT
wsi.id as maId,
wsi.model_id as typeId,
wsi.ma_name as materialName,
wsi.ma_model as materialModel,
wsi.ma_code as maCode,
wsi.qr_code as qrCode
FROM
ws_ma_info wsi
LEFT JOIN ma_type mt ON wsi.model_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
WHERE
2025-07-05 21:27:36 +08:00
1 = 1
2025-07-04 18:07:30 +08:00
<if test="typeId != null ">
and wsi.model_id = #{typeId}
</if>
2025-07-26 12:51:23 +08:00
<if test="maCode != null and maCode != ''">
and wsi.ma_code LIKE CONCAT('%',#{maCode},'%')
</if>
2025-07-04 18:07:30 +08:00
</select>
</mapper>