2025-09-14 15:56:37 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
<!DOCTYPE mapper
|
2025-10-14 17:22:35 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-09-14 15:56:37 +08:00
|
|
|
<mapper namespace="com.bonus.material.devchange.mapper.DevChangeMapper">
|
2025-09-14 22:16:28 +08:00
|
|
|
<insert id="addChangeInfo" keyProperty="id" useGeneratedKeys="true">
|
2025-10-14 17:22:35 +08:00
|
|
|
insert into cs_device_change(change_status, type, status, pro_code, pro_name,
|
|
|
|
|
pro_type, dev_num, voltage_level, use_unit, pro_province, pro_city,
|
|
|
|
|
pro_county, pro_location, create_time, create_user, del_flag, user_name,
|
|
|
|
|
user_phone, change_unit)
|
|
|
|
|
values ( #{changeStatus}, #{type}, #{status}, #{proCode}, #{proName}, #{proType}, #{devNum}, #{voltageLevel}
|
|
|
|
|
, #{useUint}
|
|
|
|
|
, #{proProvince}, #{proCity}, #{proCounty}, #{proLocation}, now(), #{createUser}, 0, #{userName}
|
|
|
|
|
, #{userName}, #{changeUnit})
|
2025-09-14 22:16:28 +08:00
|
|
|
</insert>
|
|
|
|
|
<insert id="addDetailsInfo">
|
2025-10-14 17:22:35 +08:00
|
|
|
insert into cs_device_change_details(change_id, dev_id, use_time, reason_id,
|
|
|
|
|
reason_val, remark,
|
|
|
|
|
repairman, repair_time, repair_content, del_flag)
|
|
|
|
|
values (#{changeId}, #{devId}, #{useTime}, #{reasonId}, #{reasonVal}, #{remark}, #{repairman}, #{repairTime},
|
|
|
|
|
#{repairContent}, 0)
|
2025-09-15 20:42:21 +08:00
|
|
|
</insert>
|
2025-09-14 15:56:37 +08:00
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
<insert id="addDevChangeDetails">
|
2025-10-14 17:22:35 +08:00
|
|
|
insert into cs_device_detials(pro_id, dev_id, num, type, create_time, update_time)
|
|
|
|
|
values (#{proId}, #{devId}, #{num}, #{type}, now(), now())
|
2025-09-14 22:16:28 +08:00
|
|
|
</insert>
|
|
|
|
|
<update id="updateJson">
|
2025-10-14 17:22:35 +08:00
|
|
|
update ma_dev_info
|
|
|
|
|
set json_data=#{jsonData}
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</update>
|
|
|
|
|
<update id="updateDevInfo">
|
2025-10-14 17:22:35 +08:00
|
|
|
update ma_dev_info
|
|
|
|
|
set xq_unit=#{useUint},
|
|
|
|
|
user_info=#{userName},
|
|
|
|
|
user_phone=#{userPhone},
|
|
|
|
|
on_project=#{proCode},
|
|
|
|
|
change_status=#{changeStatus}
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</update>
|
2025-09-15 20:42:21 +08:00
|
|
|
<delete id="deleteDevChangeDetails">
|
2025-10-14 17:22:35 +08:00
|
|
|
delete
|
|
|
|
|
from cs_device_detials
|
|
|
|
|
where id = #{id}
|
2025-09-15 20:42:21 +08:00
|
|
|
</delete>
|
|
|
|
|
<!--xiugao1-->
|
|
|
|
|
<update id="updateChangeDetailsNum">
|
2025-10-14 17:22:35 +08:00
|
|
|
update cs_device_detials
|
|
|
|
|
set num=#{num}
|
|
|
|
|
where id = #{id}
|
2025-09-15 20:42:21 +08:00
|
|
|
</update>
|
2025-09-14 15:56:37 +08:00
|
|
|
<select id="getMaxFeature" resultType="java.lang.Integer">
|
|
|
|
|
select count(1) num
|
|
|
|
|
from ma_dev_info_properties
|
|
|
|
|
GROUP BY ma_id
|
2025-10-14 17:22:35 +08:00
|
|
|
ORDER BY num desc
|
|
|
|
|
limit 1
|
2025-09-14 15:56:37 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="selectDevInfoList" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select dev.ma_id devId,dev.device_name devName,dev.code devCode,dev.json_data,DATE(dev.production_date )
|
|
|
|
|
productDate ,dev.buy_price buyPrice ,dev.brand ,
|
|
|
|
|
mdq.next_check_time nextDate,mt.typeId, mt.unit_name unit,mt.maintenance_alarm_day ,
|
|
|
|
|
mt.proType,mt.level,mt.mainGx,mt.childGx,mt.devCategory ,mt.devSubcategory ,mt.devName,
|
|
|
|
|
mt.devModel ,bci.company_name compName,bci.operate_address orgName,IFNULL(pro.pro_name,'-') proName,
|
|
|
|
|
dev.on_project proId,dev.change_status AS status
|
|
|
|
|
FROM ma_dev_info dev
|
2025-10-13 14:25:44 +08:00
|
|
|
left join bm_company_info bci on bci.company_id=dev.on_company
|
2025-10-14 17:22:35 +08:00
|
|
|
left join ma_type_view mt on mt.typeId=dev.type_id
|
|
|
|
|
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
|
|
|
|
|
dev.ma_id=mdq.ma_id
|
2025-09-15 20:42:21 +08:00
|
|
|
left join jj_sing_project pro on pro.pro_code=dev.on_project
|
2025-09-14 15:56:37 +08:00
|
|
|
where is_active=1
|
2025-10-14 17:22:35 +08:00
|
|
|
<if test="proId!=null and proId!=''">
|
|
|
|
|
and dev.on_project=#{proId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName!=null and devName!=''">
|
|
|
|
|
and dev.device_name like concat('%',#{devName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeId!=null and typeId!=''">
|
|
|
|
|
and mt.typeId=#{typeId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status!=null and status!=''">
|
|
|
|
|
<if test='status=="2"'>
|
|
|
|
|
and dev.change_status in(2,3)
|
2025-09-14 15:56:37 +08:00
|
|
|
</if>
|
2025-10-14 17:22:35 +08:00
|
|
|
<if test='status!="2"'>
|
|
|
|
|
AND dev.change_status=#{status}
|
2025-09-14 15:56:37 +08:00
|
|
|
</if>
|
2025-10-14 17:22:35 +08:00
|
|
|
</if>
|
2025-09-14 15:56:37 +08:00
|
|
|
</select>
|
2025-09-14 22:16:28 +08:00
|
|
|
<select id="getDevPropertyList" resultType="com.bonus.material.device.domain.vo.DevInfoPropertyVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select property_name propertyName, property_value propertyValue
|
|
|
|
|
from ma_dev_info_properties
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getProList" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select pro_code proCode,
|
|
|
|
|
pro_name proName,
|
|
|
|
|
voltage,
|
|
|
|
|
org_name orgName,
|
|
|
|
|
mechanize_rate,
|
|
|
|
|
project_type proType,
|
|
|
|
|
project_type_name proTypeName,
|
|
|
|
|
province,
|
|
|
|
|
city,
|
|
|
|
|
county
|
2025-09-14 22:16:28 +08:00
|
|
|
from jj_sing_project
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getChangeStatus" resultType="java.lang.String">
|
2025-10-14 17:22:35 +08:00
|
|
|
select change_status
|
|
|
|
|
from ma_dev_info
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeList" resultType="com.bonus.material.devchange.domain.CsDeviceChangeVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select cds.id,cds.change_status changeStatus,cds.type,cds.status,cds.pro_code proCode,cds.pro_name proName,
|
2025-09-15 20:42:21 +08:00
|
|
|
cds.pro_type proType,cds.dev_num devNum,cds.voltage_level voltageLevel,
|
|
|
|
|
cds.use_unit useUint,cds.pro_province proProvince,cds.pro_city proCity,cds.pro_county proCounty,
|
|
|
|
|
cds.pro_location proLocation,cds.create_time createTime,
|
|
|
|
|
cds.create_user createUser,cds.del_flag,cds.user_name userName,cds.user_phone userPhone,
|
|
|
|
|
cds.change_unit changeUnit,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN cds.change_status = 1 THEN '在库'
|
|
|
|
|
WHEN cds.change_status = 2 THEN '再用'
|
|
|
|
|
WHEN cds.change_status = 3 THEN '退役'
|
|
|
|
|
WHEN cds.change_status = 4 THEN '维修'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END
|
|
|
|
|
AS changeStatusName
|
2025-10-14 17:22:35 +08:00
|
|
|
, CASE
|
2025-09-15 20:42:21 +08:00
|
|
|
WHEN cds.type = 1 THEN '入库'
|
|
|
|
|
WHEN cds.type = 2 THEN '出库'
|
|
|
|
|
WHEN cds.type = 3 THEN '退役'
|
|
|
|
|
WHEN cds.type = 4 THEN '维修'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END
|
|
|
|
|
AS typeName
|
2025-09-14 22:16:28 +08:00
|
|
|
from cs_device_change cds
|
|
|
|
|
WHERE cds.del_flag=0
|
|
|
|
|
<if test="keyWord!=null and keyWord!=''">
|
2025-10-14 17:22:35 +08:00
|
|
|
and (
|
2025-09-14 22:16:28 +08:00
|
|
|
cds.pro_name like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.voltage_level like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.use_unit like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_province like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_city like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_county like concat('%',#{keyWord},'%') or
|
2025-10-14 17:22:35 +08:00
|
|
|
cds.create_user like concat('%',#{keyWord},'%') or
|
2025-09-14 22:16:28 +08:00
|
|
|
cds.pro_location like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_code like concat('%',#{keyWord},'%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test="type!=null and type!=''">
|
2025-10-14 17:22:35 +08:00
|
|
|
and cds.type=#{type}
|
2025-09-14 22:16:28 +08:00
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
2025-09-14 22:16:28 +08:00
|
|
|
and cds.create_time between #{startTime} and #{endTime}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getChangeUnit" resultType="java.lang.String">
|
|
|
|
|
select bci.company_name compName
|
2025-10-14 17:22:35 +08:00
|
|
|
FROM ma_dev_info dev
|
|
|
|
|
left join bm_company_info bci on bci.company_id = dev.on_company
|
|
|
|
|
where is_active = 1
|
|
|
|
|
and bci.company_name is not null
|
|
|
|
|
and dev.ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getChangeUnitById" resultType="java.lang.String">
|
2025-10-14 17:22:35 +08:00
|
|
|
select xq_unit
|
2025-09-14 22:16:28 +08:00
|
|
|
from ma_dev_info
|
2025-10-14 17:22:35 +08:00
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
2025-09-15 20:42:21 +08:00
|
|
|
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select dev.ma_id devId,
|
|
|
|
|
dev.device_name devName,
|
|
|
|
|
dev.code devCode,
|
|
|
|
|
dev.json_data,
|
|
|
|
|
DATE(dev.production_date) productDate,
|
|
|
|
|
dev.buy_price buyPrice,
|
|
|
|
|
dev.brand,
|
|
|
|
|
mdq.next_check_time nextDate,
|
|
|
|
|
mt.typeId,
|
|
|
|
|
mt.unit_name unit,
|
|
|
|
|
mt.maintenance_alarm_day,
|
|
|
|
|
mt.proType,
|
|
|
|
|
mt.level,
|
|
|
|
|
mt.mainGx,
|
|
|
|
|
mt.childGx,
|
|
|
|
|
mt.devCategory,
|
|
|
|
|
mt.devSubcategory,
|
|
|
|
|
mt.devName,
|
|
|
|
|
mt.devModel,
|
|
|
|
|
bci.company_name compName,
|
|
|
|
|
bci.operate_address orgName,
|
|
|
|
|
IFNULL(pro.pro_name, '-') proName,
|
|
|
|
|
dev.on_project proId
|
2025-09-14 22:16:28 +08:00
|
|
|
FROM cs_device_change_details dcd
|
2025-10-14 17:22:35 +08:00
|
|
|
left join ma_dev_info dev on dcd.dev_id = dev.ma_id
|
|
|
|
|
left join bm_company_info bci on bci.company_id = dev.on_company
|
|
|
|
|
left join ma_type_view mt on mt.typeId = dev.type_id
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT max(next_check_time) next_check_time, ma_id
|
|
|
|
|
from ma_dev_qc
|
|
|
|
|
GROUP BY ma_id) mdq on dev.ma_id = mdq.ma_id
|
|
|
|
|
left join jj_sing_project pro on pro.pro_code = dev.on_project
|
|
|
|
|
where is_active = 1
|
|
|
|
|
and dcd.change_id = #{id}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select distinct voltage
|
2025-09-14 22:16:28 +08:00
|
|
|
from jj_sing_project
|
|
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeDetailsList" resultType="com.bonus.material.devchange.domain.DevChangeDetailsVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select id,
|
|
|
|
|
pro_id proId,
|
2025-09-15 20:42:21 +08:00
|
|
|
dev_id devId,
|
|
|
|
|
num ,
|
|
|
|
|
type,
|
|
|
|
|
create_time,
|
|
|
|
|
update_time
|
|
|
|
|
from cs_device_detials
|
2025-10-14 17:22:35 +08:00
|
|
|
where dev_id=#{devId} and type=#{type}
|
|
|
|
|
<if test="proId!=null and proId!=''">
|
|
|
|
|
pro_id=#{proId}
|
|
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
2025-09-14 15:56:37 +08:00
|
|
|
</mapper>
|