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

90 lines
3.5 KiB
XML

<?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.equipment.mapper.DeptEquipmentConfigMapper">
<delete id="deleteByDeptIdAndTypeId">
DELETE FROM ma_dept_config WHERE dept_id = #{deptId} AND type_id = #{typeId}
</delete>
<select id="selectConfig" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
</select>
<select id="selectConfigByDept" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
SELECT * FROM dept_equipment_config WHERE dept_id = #{deptId}
</select>
<select id="selectDevInfoLists" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
SELECT
d.ma_id AS maId,
d.CODE AS code,
d.on_company,
CONCAT_WS( '>', mt1.type_name, mt2.type_name, mt3.type_name ) AS deviceTypeName ,
d.identify_code AS identifyCode,
d.device_name AS deviceName,
d.device_count AS deviceCount,
d.type_id AS typeId,
mt4.type_name AS typeName,
mt4.unit_name AS unitName,
d.ma_status AS maStatus,
d.brand AS brand,
d.production_date AS productionDate,
d.working_hours AS workingHours,
d.person AS person,
d.person_phone AS personPhone,
d.create_time AS createTime,
d.update_time AS updateTime,
d.on_company AS companyId,
sd.dept_name AS companyName,
c.operate_address AS operateAddress,
mt3.type_id AS thirdId,
mt3.type_name AS thirdName,
mt2.type_id AS secondId,
mt2.type_name AS secondName,
mt1.type_id AS firstId,
mt1.type_name AS firstName
FROM
ma_dev_info d
LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id
AND mt4.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id
AND mt3.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt3.parent_id
AND mt2.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = mt2.parent_id
AND mt1.del_flag = '0'
WHERE
d.is_active = '1' and mt3.type_id=#{deviceId} AND d.on_company=#{companyName}
</select>
<insert id="insertOrUpdateBatch" parameterType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
INSERT INTO ma_dept_config (
dept_id,
type_id,
config_type,
config_value,
config_rate,
config_description,
remark
)
VALUES
<foreach collection="configs" item="item" separator=",">
(
#{deptId},
#{typeId},
#{item.configurationType},
#{item.basicConfig},
#{item.configurationRate},
#{item.configurationDescription},
#{remark}
)
</foreach>
ON DUPLICATE KEY UPDATE
config_value = VALUES(config_value),
config_rate = VALUES(config_rate),
config_description = VALUES(config_description),
remark = VALUES(remark),
update_time = CURRENT_TIMESTAMP
</insert>
</mapper>