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_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"/>
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<result column="item_type_model" property="modelName"/>
|
2025-09-16 18:27:18 +08:00
|
|
|
|
<result column="production_date" property="productionDate"/>
|
|
|
|
|
|
<result column="working_hours" property="workingHours"/>
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<result column="pic_url" property="picUrl"/>
|
2025-09-16 18:27:18 +08:00
|
|
|
|
<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"/>
|
2025-10-13 19:22:03 +08:00
|
|
|
|
<result column="on_company" property="ownCo"/>
|
2025-09-16 18:27:18 +08:00
|
|
|
|
<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="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="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="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">
|
2025-10-13 19:22:03 +08:00
|
|
|
|
ma_id, device_name, device_weight, device_count, `code`, identify_code, type_id, ma_status,
|
2025-10-13 19:16:40 +08:00
|
|
|
|
lease_scope, `location`, brand, model_name, production_date, working_hours, serial_number,
|
2025-10-13 19:22:03 +08:00
|
|
|
|
pic_url, js_month_price, js_day_price, `description`,
|
|
|
|
|
|
gps_code, on_company, person, person_phone, create_time, creator, deposit, is_active,
|
2025-09-15 21:56:18 +08:00
|
|
|
|
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>
|
2025-10-13 19:16:40 +08:00
|
|
|
|
|
2025-09-22 10:00:27 +08:00
|
|
|
|
<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
|
|
|
|
|
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-10-13 19:16:40 +08:00
|
|
|
|
|
|
|
|
|
|
<if test="deviceWeight != null">
|
|
|
|
|
|
device_weight = #{deviceWeight},
|
|
|
|
|
|
</if>
|
2025-09-22 10:00:27 +08:00
|
|
|
|
<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>
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<if test="modelName != null and modelName != ''">
|
|
|
|
|
|
model_name = #{modelName},
|
|
|
|
|
|
</if>
|
2025-09-22 10:00:27 +08:00
|
|
|
|
<if test="productionDate != null">
|
|
|
|
|
|
production_date = #{productionDate},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="workingHours != null">
|
|
|
|
|
|
working_hours = #{workingHours},
|
|
|
|
|
|
</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
|
|
|
|
<!-- 其他信息字段 -->
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<if test="picUrl != null and picUrl != ''">
|
|
|
|
|
|
pic_url = #{picUrl},
|
|
|
|
|
|
</if>
|
2025-09-22 10:00:27 +08:00
|
|
|
|
<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
|
2025-10-13 14:25:44 +08:00
|
|
|
|
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
|
2025-09-16 18:27:18 +08:00
|
|
|
|
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-10-13 19:16:40 +08:00
|
|
|
|
<select id="list" resultType="com.bonus.material.devchange.domain.MaDevInfo">
|
|
|
|
|
|
select mdi.ma_id AS maId,
|
|
|
|
|
|
mdi.type_id AS typeId,
|
|
|
|
|
|
mdi.manage_type AS manageType,
|
|
|
|
|
|
mdi.device_count AS count,
|
|
|
|
|
|
mtv.maxTypeId AS majorId,
|
|
|
|
|
|
mtv.proType AS major,
|
|
|
|
|
|
mtv.mainGxId AS mainProcessId,
|
|
|
|
|
|
mtv.mainGx AS mainProcess,
|
|
|
|
|
|
mtv.childGxId AS subProcessId,
|
|
|
|
|
|
mtv.childGx AS subProcess,
|
|
|
|
|
|
mtv.devCategoryId AS mainCategoryId,
|
|
|
|
|
|
mtv.devCategory AS mainCategory,
|
|
|
|
|
|
mtv.devSubcategory AS subCategory,
|
|
|
|
|
|
mtv.devSubcategoryId AS subCategoryId,
|
|
|
|
|
|
mtv.devNameId AS branchId,
|
|
|
|
|
|
mtv.devName AS branch,
|
|
|
|
|
|
mdi.device_name AS name,
|
|
|
|
|
|
mdi.item_type_model As specificationModel,
|
|
|
|
|
|
mdi.code AS code,
|
|
|
|
|
|
mdi.change_status AS status,
|
|
|
|
|
|
TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) AS serviceLife,
|
|
|
|
|
|
jsp.pro_code AS usingProjectId,
|
|
|
|
|
|
jsp.pro_name AS usingProject,
|
|
|
|
|
|
mdi.identify_code AS originalCode,
|
2025-10-14 17:22:35 +08:00
|
|
|
|
mdi.supplier_id AS manufacturerId,
|
2025-10-13 19:16:40 +08:00
|
|
|
|
ms.supplier_name AS manufacturer,
|
|
|
|
|
|
mdi.purchase_date AS purchaseDate,
|
|
|
|
|
|
mdi.production_date AS productionDate,
|
|
|
|
|
|
sd.dept_id AS propertyUnitId,
|
|
|
|
|
|
sd.dept_name AS propertyUnit,
|
|
|
|
|
|
mdi.buy_price AS originalValue,
|
2025-10-14 17:22:35 +08:00
|
|
|
|
mdi.unit AS unit,
|
2025-10-13 19:16:40 +08:00
|
|
|
|
mdq.next_check_time AS nextMaintenanceDate,
|
2025-10-14 20:20:27 +08:00
|
|
|
|
mdi.max_working_hours AS maxServiceLifeYears,
|
|
|
|
|
|
sc.name AS province
|
2025-10-13 19:16:40 +08:00
|
|
|
|
from ma_dev_info mdi
|
|
|
|
|
|
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
|
|
|
|
|
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
|
|
|
|
|
|
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
|
|
|
|
|
|
LEFT JOIN ma_dev_qc mdq ON mdq.ma_id = mdi.ma_id
|
2025-10-14 17:22:35 +08:00
|
|
|
|
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
|
2025-10-14 20:20:27 +08:00
|
|
|
|
LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<where>
|
|
|
|
|
|
mdi.is_active = '1'
|
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
|
and mdi.device_name like concat('%', #{name}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<if test="specificationModel != null and specificationModel != ''">
|
|
|
|
|
|
and mdi.item_type_model like concat('%', #{specificationModel}, '%')
|
|
|
|
|
|
</if>
|
2025-10-14 20:20:27 +08:00
|
|
|
|
|
|
|
|
|
|
<if test="province != null and province != ''">
|
|
|
|
|
|
and sc.area_code = #{province}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<if test="majorId != null and majorId != ''">
|
|
|
|
|
|
and mtv.maxTypeId = #{majorId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="subProcessId != null and subProcessId != ''">
|
|
|
|
|
|
and mtv.childGxId = #{subProcessId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="code != null and code != ''">
|
|
|
|
|
|
and mdi.code like concat('%', #{code}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="originalCode != null and originalCode != ''">
|
|
|
|
|
|
and mdi.identify_code like concat('%', #{originalCode}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="propertyUnitId != null and propertyUnitId != ''">
|
|
|
|
|
|
and sd.dept_id = #{propertyUnitId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<if test="manufacturerId != null and manufacturerId != ''">
|
|
|
|
|
|
and mdi.brand = #{manufacturerId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="minOriginalValue != null and minOriginalValue != '' and maxOriginalValue != null and maxOriginalValue != ''">
|
|
|
|
|
|
and mdi.buy_price >= #{minOriginalValue} and mdi.buy_price <= #{maxOriginalValue}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="startProductionDate != null and startProductionDate != '' and endProductionDate != null and endProductionDate != ''">
|
|
|
|
|
|
and DATE_FORMAT(mdi.production_date,'%Y-%m-%d') between #{startProductionDate} and #{endProductionDate}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="startPurchaseDate != null and startPurchaseDate != '' and endPurchaseDate != null and endPurchaseDate != ''">
|
|
|
|
|
|
and DATE_FORMAT(mdi.purchase_date,'%Y-%m-%d') between #{startPurchaseDate} and #{endPurchaseDate}
|
|
|
|
|
|
</if>
|
2025-10-14 17:22:35 +08:00
|
|
|
|
<if test="status != null and status != ''">
|
2025-10-14 23:00:05 +08:00
|
|
|
|
<if test='status=="2"'>
|
|
|
|
|
|
and mdi.change_status in(2,3)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test='status!="2"'>
|
|
|
|
|
|
AND mdi.change_status=#{status}
|
|
|
|
|
|
</if>
|
2025-10-14 17:22:35 +08:00
|
|
|
|
</if>
|
2025-10-13 19:16:40 +08:00
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getFileList" resultType="com.bonus.material.devchange.domain.MaDevFile">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
id,
|
|
|
|
|
|
ma_id AS maId,
|
|
|
|
|
|
file_type AS fileType,
|
|
|
|
|
|
file_name AS fileName,
|
|
|
|
|
|
file_url AS fileUrl,
|
|
|
|
|
|
creator,
|
|
|
|
|
|
create_time AS createTime,
|
|
|
|
|
|
is_active AS isActive
|
|
|
|
|
|
FROM ma_dev_file
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
-- 基础条件:逻辑未删除
|
|
|
|
|
|
is_active = 1
|
|
|
|
|
|
-- 可选条件:按设备ID筛选(如果需要根据maId查询,取消注释并传入参数)
|
|
|
|
|
|
<if test="maId != null">AND ma_id = #{maId}</if>
|
|
|
|
|
|
-- 可选条件:按文件类型筛选(如果需要,取消注释并传入参数)
|
|
|
|
|
|
<if test="fileType != null">AND file_type = #{fileType}</if>
|
|
|
|
|
|
ORDER BY
|
|
|
|
|
|
create_time DESC -- 按上传时间倒序,最新的文件在前
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getDevice" resultType="com.bonus.material.devchange.domain.MaDevInfo">
|
|
|
|
|
|
select mdi.ma_id AS maId,
|
2025-10-14 17:22:35 +08:00
|
|
|
|
mdi.type_id AS typeId,
|
2025-10-13 19:16:40 +08:00
|
|
|
|
mdi.manage_type AS manageType,
|
|
|
|
|
|
mdi.device_count AS count,
|
|
|
|
|
|
mtv.maxTypeId AS majorId,
|
|
|
|
|
|
mtv.proType AS major,
|
|
|
|
|
|
mtv.mainGxId AS mainProcessId,
|
|
|
|
|
|
mtv.mainGx AS mainProcess,
|
|
|
|
|
|
mtv.childGxId AS subProcessId,
|
|
|
|
|
|
mtv.childGx AS subProcess,
|
|
|
|
|
|
mtv.devCategoryId AS mainCategoryId,
|
|
|
|
|
|
mtv.devCategory AS mainCategory,
|
|
|
|
|
|
mtv.devSubcategory AS subCategory,
|
|
|
|
|
|
mtv.devSubcategoryId AS subCategoryId,
|
|
|
|
|
|
mtv.devNameId AS branchId,
|
|
|
|
|
|
mtv.devName AS branch,
|
|
|
|
|
|
mdi.device_name AS name,
|
|
|
|
|
|
mdi.item_type_model As specificationModel,
|
|
|
|
|
|
mdi.code AS code,
|
|
|
|
|
|
mdi.change_status AS status,
|
|
|
|
|
|
TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) AS serviceLife,
|
|
|
|
|
|
jsp.pro_code AS usingProjectId,
|
|
|
|
|
|
jsp.pro_name AS usingProject,
|
|
|
|
|
|
mdi.identify_code AS originalCode,
|
2025-10-14 17:22:35 +08:00
|
|
|
|
mdi.supplier_id AS manufacturerId,
|
|
|
|
|
|
ms.supplier_name AS manufacturer,
|
2025-10-13 19:16:40 +08:00
|
|
|
|
mdi.purchase_date AS purchaseDate,
|
|
|
|
|
|
mdi.production_date AS productionDate,
|
|
|
|
|
|
sd.dept_id AS propertyUnitId,
|
|
|
|
|
|
sd.dept_name AS propertyUnit,
|
|
|
|
|
|
mdi.buy_price AS originalValue,
|
2025-10-14 17:22:35 +08:00
|
|
|
|
mdi.unit AS unit,
|
2025-10-13 19:16:40 +08:00
|
|
|
|
mdq.next_check_time AS nextMaintenanceDate,
|
|
|
|
|
|
mdi.max_working_hours AS maxServiceLifeYears
|
|
|
|
|
|
from ma_dev_info mdi
|
|
|
|
|
|
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
|
|
|
|
|
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
|
|
|
|
|
|
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
|
|
|
|
|
|
LEFT JOIN ma_dev_qc mdq ON mdq.ma_id = mdi.ma_id
|
2025-10-14 17:22:35 +08:00
|
|
|
|
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
|
2025-10-13 19:16:40 +08:00
|
|
|
|
<where>
|
2025-10-13 21:54:40 +08:00
|
|
|
|
mdi.is_active = '1' AND mdi.ma_id =#{maId}
|
2025-10-13 19:16:40 +08:00
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
2025-10-14 23:00:05 +08:00
|
|
|
|
<select id="getDeviceByMaIds" resultType="com.bonus.material.devchange.domain.MaDevInfo">
|
|
|
|
|
|
SELECT ma_id AS devId,
|
|
|
|
|
|
device_name AS name,
|
|
|
|
|
|
item_type_model As specificationModel,
|
|
|
|
|
|
code AS code
|
|
|
|
|
|
from ma_dev_info
|
|
|
|
|
|
WHERE ma_id IN
|
|
|
|
|
|
<foreach collection="array"
|
|
|
|
|
|
item="maId"
|
|
|
|
|
|
open="("
|
|
|
|
|
|
separator=","
|
|
|
|
|
|
close=")">
|
|
|
|
|
|
#{maId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2025-09-15 21:56:18 +08:00
|
|
|
|
</mapper>
|