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

382 lines
15 KiB
XML
Raw Normal View History

2025-09-15 21:56:18 +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.MaDevInfoMapper">
2025-09-16 18:27:18 +08:00
<resultMap id="BaseResultMap" type="com.bonus.material.devchange.domain.MaDevInfo">
<id column="ma_id" property="maId"/>
<result column="device_name" property="deviceName"/>
<result column="device_weight" property="deviceWeight"/>
<result column="device_count" property="deviceCount"/>
<result column="code" property="code"/>
<result column="identify_code" property="identifyCode"/>
<result column="type_id" property="typeId"/>
<result column="ma_status" property="maStatus"/>
<result column="lease_scope" property="leaseScope"/>
<result column="location" property="location"/>
<result column="brand" property="brand"/>
<result column="model_name" property="modelName"/>
<result column="production_date" property="productionDate"/>
<result column="working_hours" property="workingHours"/>
<result column="serial_number" property="serialNumber"/>
<result column="month_lease_price" property="monthLeasePrice"/>
<result column="day_lease_price" property="dayLeasePrice"/>
<result column="pic_url" property="picUrl"/>
<result column="js_month_price" property="jsMonthPrice"/>
<result column="js_day_price" property="jsDayPrice"/>
<result column="description" property="description"/>
<result column="gps_code" property="gpsCode"/>
<result column="own_co" property="ownCo"/>
<result column="person" property="person"/>
<result column="person_phone" property="personPhone"/>
<result column="create_time" property="createTime"/>
<result column="creator" property="creator"/>
<result column="deposit" property="deposit"/>
<result column="is_active" property="isActive"/>
<result column="update_time" property="updateTime"/>
<result column="update_by" property="updateBy"/>
<result column="is_operator" property="isOperator"/>
<result column="specification" property="specification"/>
<result column="province_id" property="provinceId"/>
<result column="city_id" property="cityId"/>
<result column="area_id" property="areaId"/>
<result column="video_url" property="videoUrl"/>
<result column="own_id" property="ownId"/>
<result column="check_date" property="checkDate"/>
<result column="check_cycle" property="checkCycle"/>
<result column="is_qc" property="isQc"/>
<result column="is_safe_book" property="isSafeBook"/>
<result column="is_zone" property="isZone"/>
<result column="zone_id" property="zoneId"/>
<result column="total_up_day" property="totalUpDay"/>
<result column="total_lease_day" property="totalLeaseDay"/>
<result column="origina_value" property="originaValue"/>
<result column="change_status" jdbcType="CHAR" property="changeStatus"/>
<result column="expiration_time" jdbcType="DATE" property="expirationTime"/>
<result column="entry_status" jdbcType="CHAR" property="entryStatus"/>
<result column="up_down_status" jdbcType="CHAR" property="upDownStatus"/>
<result column="json_data" property="jsonData"/>
<result column="buy_price" property="buyPrice"/>
<result column="item_type_model" property="itemTypeModel"/>
<result column="on_project" property="onProject"/>
<result column="childGx" property="childGx"/>
<result column="company_name" property="companyName"/>
<result column="devCategory" property="devCategory"/>
<result column="devModel" property="devModel"/>
<result column="devName" property="devName"/>
<result column="devSubcategory" property="devSubcategory"/>
<result column="mainGx" property="mainGx"/>
<result column="next_check_time" property="nextCheckTime"/>
<result column="proType" property="proType"/>
<result column="unit_name" property="unitName"/>
2025-09-22 10:00:27 +08:00
<result column="pro_name" property="proName"/>
2025-09-16 18:27:18 +08:00
</resultMap>
<sql id="Base_Column_List">
ma_id, device_name, device_weight, device_count, code, identify_code, type_id, ma_status,
2025-09-15 21:56:18 +08:00
lease_scope, `location`, brand, model_name, production_date, working_hours, serial_number,
month_lease_price, day_lease_price, pic_url, js_month_price, js_day_price, description,
gps_code, own_co, person, person_phone, create_time, creator, deposit, is_active,
update_time, update_by, is_operator, specification, province_id, city_id, area_id,
video_url, own_id, check_date, check_cycle, is_qc, is_safe_book, is_zone, zone_id,
total_up_day, total_lease_day, origina_value, change_status, expiration_time, entry_status,
up_down_status, json_data, buy_price, item_type_model, on_project
2025-09-16 18:27:18 +08:00
</sql>
2025-09-22 10:00:27 +08:00
<delete id="delProperties">
delete
from ma_dev_info_properties
where ma_id = #{maId}
</delete>
<insert id="insertDevInfoProperties">
insert into
ma_dev_info_properties(ma_id, property_name, property_value, create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{maId},
#{item.propertyName},
#{item.propertyValue},
now()
)
</foreach>
</insert>
2025-09-16 18:27:18 +08:00
<select id="list" resultMap="BaseResultMap">
2025-09-22 10:00:27 +08:00
SELECT DISTINCT
2025-09-16 18:27:18 +08:00
mtv.proType,
mtv.mainGx,
mtv.childGx,
mtv.devCategory,
mtv.devSubcategory,
mtv.devName,
mtv.devModel,
mtv.unit_name,
mdi.ma_id,
mdi.device_name,
mdi.model_name,
mdi.ma_status,
mdi.`code`,
mdi.expiration_time,
c.company_name,
mdi.buy_price,
mdi.production_date,
mdi.working_hours,
mdi.on_project,
2025-09-22 10:00:27 +08:00
jsp.pro_name,
2025-09-16 18:27:18 +08:00
mdi.person,
mdi.person_phone,
mdi.change_status,
mdi.up_down_status,
mdq.next_check_time,
mdi.brand,
mdi.pic_url
FROM
ma_dev_info mdi
2025-09-15 21:56:18 +08:00
LEFT JOIN ma_dev_qc mdq ON mdq.ma_id = mdi.ma_id
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.own_co
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
2025-09-22 10:00:27 +08:00
LEFT JOIN jj_sing_project jsp ON jsp.pro_code = mdi.on_project
2025-09-22 18:53:28 +08:00
WHERE mdi.is_active = 1 and mdi.entry_status = 1
2025-09-16 18:27:18 +08:00
<if test="typeId != null">
and (
mtv.mainGxId = #{typeId}
or mtv.childGxId = #{typeId}
or mtv.devCategoryId = #{typeId}
or mtv.devSubcategoryId = #{typeId}
or mtv.devNameId = #{typeId}
or mtv.devModelId = #{typeId}
or mtv.maxTypeId = #{typeId}
)
</if>
<if test="companyName != null and companyName !=''">
and c.company_name like concat('%',#{companyName},'%')
</if>
<if test="onProject != null and onProject !=''">
and mdi.on_project like concat('%',#{onProject},'%')
</if>
<if test="deviceName != null and deviceName !=''">
2025-09-25 19:20:28 +08:00
and mdi.device_name, like concat('%',#{deviceName},'%')
2025-09-16 18:27:18 +08:00
</if>
<if test="code != null and code !=''">
and mdi.`code` like concat('%',#{code},'%')
</if>
<if test="changeStatus != null and changeStatus !=''">
2025-09-22 10:00:27 +08:00
and mdi.change_status like concat('%',#{changeStatus},'%')
2025-09-16 18:27:18 +08:00
</if>
<if test="brand != null and brand !=''">
and mdi.brand like concat('%',#{brand},'%')
</if>
<if test="productionDate != null and productionDate !=''">
and mdi.production_date like concat('%',#{brand},'%')
</if>
<if test="workingHours != null and workingHours !=''">
and mdi.working_hours like concat('%',#{workingHours},'%')
</if>
<if test="buyPrice != null and buyPrice !=''">
and mdi.buy_price like concat('%',#{buyPrice},'%')
</if>
<if test="nextCheckTime != null and nextCheckTime !=''">
and mdq.next_check_time like concat('%',#{nextCheckTime},'%')
</if>
2025-09-22 10:00:27 +08:00
</select>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<update id="updateDeviceStatus">
<foreach collection="list" item="data" index="index" separator=";">
UPDATE ma_dev_info SET up_down_status = #{data.value} where ma_id =#{data.key}
</foreach>
</update>
<!-- 完善的updateDeviceApi方法 -->
<update id="updateDeviceApi" parameterType="com.bonus.material.devchange.domain.MaDevInfo">
UPDATE ma_dev_info
<set>
<!-- 基础信息字段 -->
<if test="deviceName != null and deviceName != ''">
device_name = #{deviceName},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<if test="deviceWeight != null">
device_weight = #{deviceWeight},
</if>
<if test="deviceCount != null">
device_count = #{deviceCount},
</if>
<if test="code != null and code != ''">
code = #{code},
</if>
<if test="identifyCode != null and identifyCode != ''">
identify_code = #{identifyCode},
</if>
<if test="typeId != null">
type_id = #{typeId},
</if>
<if test="maStatus != null and maStatus != ''">
ma_status = #{maStatus},
</if>
<if test="leaseScope != null and leaseScope != ''">
lease_scope = #{leaseScope},
</if>
<if test="location != null and location != ''">
`location` = #{location},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<!-- 设备属性字段 -->
<if test="brand != null and brand != ''">
brand = #{brand},
</if>
<if test="modelName != null and modelName != ''">
model_name = #{modelName},
</if>
<if test="productionDate != null">
production_date = #{productionDate},
</if>
<if test="workingHours != null">
working_hours = #{workingHours},
</if>
<if test="serialNumber != null and serialNumber != ''">
serial_number = #{serialNumber},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<!-- 价格相关字段 -->
<if test="monthLeasePrice != null">
month_lease_price = #{monthLeasePrice},
</if>
<if test="dayLeasePrice != null">
day_lease_price = #{dayLeasePrice},
</if>
<if test="jsMonthPrice != null">
js_month_price = #{jsMonthPrice},
</if>
<if test="jsDayPrice != null">
js_day_price = #{jsDayPrice},
</if>
<if test="deposit != null">
deposit = #{deposit},
</if>
<if test="buyPrice != null">
buy_price = #{buyPrice},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<!-- 状态相关字段 -->
<if test="isActive != null">
is_active = #{isActive},
</if>
<if test="changeStatus != null and changeStatus != ''">
change_status = #{changeStatus},
</if>
<if test="expirationTime != null">
expiration_time = #{expirationTime},
</if>
<if test="entryStatus != null and entryStatus != ''">
entry_status = #{entryStatus},
</if>
<if test="upDownStatus != null and upDownStatus != ''">
up_down_status = #{upDownStatus},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<!-- 其他信息字段 -->
<if test="picUrl != null and picUrl != ''">
pic_url = #{picUrl},
</if>
<if test="videoUrl != null and videoUrl != ''">
video_url = #{videoUrl},
</if>
<if test="description != null and description != ''">
description = #{description},
</if>
<if test="gpsCode != null and gpsCode != ''">
gps_code = #{gpsCode},
</if>
<if test="onProject != null and onProject != ''">
on_project = #{onProject},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<!-- 负责人信息 -->
<if test="person != null and person != ''">
person = #{person},
</if>
<if test="personPhone != null and personPhone != ''">
person_phone = #{personPhone},
</if>
2025-09-16 18:27:18 +08:00
2025-09-22 10:00:27 +08:00
<!-- 更新时间和操作人(建议每次更新都设置) -->
update_time = now(),
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
</set>
<!-- 必须指定更新条件以ma_id为主键 -->
WHERE ma_id = #{maId}
2025-09-16 18:27:18 +08:00
</update>
2025-09-22 10:00:27 +08:00
<update id="delDevice">
2025-09-16 18:27:18 +08:00
UPDATE ma_dev_info SET is_active = 0 where ma_id in
2025-09-22 10:00:27 +08:00
<foreach collection="array" item="maId" open="(" separator="," close=")">
#{maId}
2025-09-16 18:27:18 +08:00
</foreach>
2025-09-22 10:00:27 +08:00
</update>
2025-09-16 18:27:18 +08:00
<select id="deviceTree" resultType="com.bonus.material.devchange.domain.DeviceTreeBean">
SELECT mt.type_id as id,
mt.type_name as name,
mt.level,
mt.parent_id as pId
FROM ma_type mt
2025-09-22 10:00:27 +08:00
WHERE mt.level != '7'
2025-09-16 18:27:18 +08:00
</select>
<select id="deviceCount" resultType="com.bonus.material.devchange.domain.DeviceCountBean">
SELECT
2025-09-15 21:56:18 +08:00
count(distinct if(mdi.change_status = '1', mdi.ma_id, null)) as inStock,
count(distinct if(mdi.change_status = '2', mdi.ma_id, null)) as ownUse,
count(distinct if(mdi.change_status = '3', mdi.ma_id, null)) as share,
count(distinct if(mdi.change_status = '5', mdi.ma_id, null)) as underRepair
2025-09-16 18:27:18 +08:00
FROM
ma_dev_info mdi
LEFT JOIN ma_dev_qc mdq ON mdq.ma_id = mdi.ma_id
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.own_co
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
WHERE mdi.is_active = 1
<if test="typeId != null">
and (
mtv.mainGxId = #{typeId}
or mtv.childGxId = #{typeId}
or mtv.devCategoryId = #{typeId}
or mtv.devSubcategoryId = #{typeId}
or mtv.devNameId = #{typeId}
or mtv.devModelId = #{typeId}
or mtv.maxTypeId = #{typeId}
)
</if>
</select>
<select id="getProperties" resultType="com.bonus.material.device.domain.vo.DevInfoPropertyVo">
select property_name propertyName, property_value propertyValue
from ma_dev_info_properties
where ma_id = #{maId}
</select>
<select id="deviceLocationSel" resultType="com.bonus.material.devchange.domain.MapBean">
SELECT '0' as `key`,
location as `value`
FROM ma_dev_info
WHERE is_active = 1
</select>
<select id="companySel" resultType="com.bonus.material.devchange.domain.MapBean">
SELECT
2025-09-15 21:56:18 +08:00
bci.id as `key`,
bci.company_name as `value`
2025-09-16 18:27:18 +08:00
FROM
2025-09-15 21:56:18 +08:00
bm_company_info bci
2025-09-16 18:27:18 +08:00
<where>
<if test="id != null">
and bci.id = #{id}
</if>
</where>
</select>
2025-09-15 21:56:18 +08:00
</mapper>