2025-09-14 15:56:37 +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.devchange.mapper.DevChangeMapper">
|
2025-09-14 22:16:28 +08:00
|
|
|
<insert id="addChangeInfo" keyProperty="id" useGeneratedKeys="true">
|
|
|
|
|
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})
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="addDetailsInfo">
|
|
|
|
|
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">
|
|
|
|
|
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">
|
|
|
|
|
update ma_dev_info set json_data=#{jsonData} where ma_id=#{devId}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updateDevInfo">
|
|
|
|
|
update ma_dev_info set xq_unit=#{useUint},user_info=#{userName},user_phone=#{userPhone},on_project=#{proCode},
|
|
|
|
|
change_status=#{changeStatus}
|
|
|
|
|
where ma_id=#{devId}
|
|
|
|
|
</update>
|
2025-09-15 20:42:21 +08:00
|
|
|
<delete id="deleteDevChangeDetails">
|
|
|
|
|
delete from cs_device_detials where id=#{id}
|
|
|
|
|
</delete>
|
|
|
|
|
<!--xiugao1-->
|
|
|
|
|
<update id="updateChangeDetailsNum">
|
|
|
|
|
update cs_device_detials set num=#{num} where id=#{id}
|
|
|
|
|
</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
|
|
|
|
|
ORDER BY num desc
|
|
|
|
|
limit 1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectDevInfoList" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
|
|
|
|
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.lease_price,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,
|
2025-09-22 10:00:27 +08:00
|
|
|
dev.on_project proId,dev.change_status AS status
|
2025-09-14 15:56:37 +08:00
|
|
|
FROM ma_dev_info dev
|
2025-09-15 20:42:21 +08:00
|
|
|
left join bm_company_info bci on bci.company_id=dev.own_co
|
|
|
|
|
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
|
2025-09-14 15:56:37 +08:00
|
|
|
where is_active=1
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test="proId!=null and proId!=''">
|
|
|
|
|
and dev.on_project=#{proId}
|
|
|
|
|
</if>
|
2025-09-14 15:56:37 +08:00
|
|
|
<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!=''">
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test='status=="2"'>
|
2025-09-14 22:16:28 +08:00
|
|
|
and dev.change_status in(2,3)
|
|
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test='status!="2"'>
|
2025-09-14 22:16:28 +08:00
|
|
|
AND dev.change_status=#{status}
|
|
|
|
|
</if>
|
2025-09-14 15:56:37 +08:00
|
|
|
</if>
|
|
|
|
|
</select>
|
2025-09-14 22:16:28 +08:00
|
|
|
<select id="getDevPropertyList" resultType="com.bonus.material.device.domain.vo.DevInfoPropertyVo">
|
|
|
|
|
select property_name propertyName,property_value propertyValue
|
|
|
|
|
from ma_dev_info_properties
|
|
|
|
|
where ma_id=#{devId}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getProList" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
|
|
|
|
select pro_code proCode,pro_name proName,voltage,org_name orgName,mechanize_rate,
|
|
|
|
|
project_type proType,project_type_name proTypeName ,province,
|
|
|
|
|
city,county
|
|
|
|
|
from jj_sing_project
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getChangeStatus" resultType="java.lang.String">
|
|
|
|
|
select change_status
|
|
|
|
|
from ma_dev_info
|
|
|
|
|
where ma_id=#{devId}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeList" resultType="com.bonus.material.devchange.domain.CsDeviceChangeVo">
|
|
|
|
|
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
|
|
|
|
|
, CASE
|
|
|
|
|
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!=''">
|
|
|
|
|
and (
|
|
|
|
|
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
|
|
|
|
|
cds.create_user like concat('%',#{keyWord},'%') or
|
|
|
|
|
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!=''">
|
|
|
|
|
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
|
|
|
|
|
FROM ma_dev_info dev
|
|
|
|
|
left join bm_company_info bci on bci.company_id=dev.own_co
|
|
|
|
|
where is_active=1 and bci.company_name is not null
|
|
|
|
|
and dev. ma_id=#{devId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getChangeUnitById" resultType="java.lang.String">
|
|
|
|
|
select xq_unit
|
|
|
|
|
from ma_dev_info
|
|
|
|
|
where ma_id=#{devId}
|
|
|
|
|
</select>
|
2025-09-15 20:42:21 +08:00
|
|
|
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
|
|
|
|
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 ,
|
2025-09-14 22:16:28 +08:00
|
|
|
mdq.next_check_time nextDate,mt.typeId, mt.unit_name unit,mt.maintenance_alarm_day ,
|
|
|
|
|
mt.lease_price,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
|
|
|
|
|
FROM cs_device_change_details dcd
|
|
|
|
|
left join ma_dev_info dev on dcd.dev_id=dev.ma_id
|
|
|
|
|
left join bm_company_info bci on bci.company_id=dev.own_co
|
|
|
|
|
left join ma_type_view mt on mt.typeId=dev.type_id
|
2025-09-15 20:42:21 +08:00
|
|
|
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-14 22:16:28 +08:00
|
|
|
left join jj_sing_project pro on pro.pro_code=dev.on_project
|
|
|
|
|
where is_active=1 and dcd.change_id=#{id}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
|
|
|
|
select distinct voltage
|
|
|
|
|
from jj_sing_project
|
|
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeDetailsList" resultType="com.bonus.material.devchange.domain.DevChangeDetailsVo">
|
|
|
|
|
select id,
|
|
|
|
|
pro_id proId,
|
|
|
|
|
dev_id devId,
|
|
|
|
|
num ,
|
|
|
|
|
type,
|
|
|
|
|
create_time,
|
|
|
|
|
update_time
|
|
|
|
|
from cs_device_detials
|
|
|
|
|
where dev_id=#{devId} and type=#{type}
|
|
|
|
|
<if test="proId!=null and proId!=''">
|
|
|
|
|
pro_id=#{proId}
|
|
|
|
|
</if>
|
|
|
|
|
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
2025-09-14 15:56:37 +08:00
|
|
|
</mapper>
|