Bonus-Cloud-Material-Mall/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml

143 lines
7.2 KiB
XML
Raw Normal View History

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-14 15:56:37 +08:00
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-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,
dev.on_project proId
FROM ma_dev_info dev
2025-09-14 22:16:28 +08:00
left join bm_company_info bci on bci.company_id=dev.own_co
2025-09-14 15:56:37 +08:00
left join ma_type_view mt on mt.typeId=dev.type_id
LEFT JOIN ma_dev_qc 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
<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-14 22:16:28 +08:00
<if test='status=="0"'>
and dev.change_status in(2,3)
</if>
<if test='status!="0"'>
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,
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
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>
<if test="status!=null and status!=''">
and cds.type=#{status}
</if>
<if test="status!=null and status!=''">
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>
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.CsDeviceChangeDetailsVo">
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,
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
LEFT JOIN ma_dev_qc 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}
</select>
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
select distinct voltage
from jj_sing_project
</select>
2025-09-14 15:56:37 +08:00
</mapper>