2024-11-11 14:00:09 +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.common.mapper.SelectMapper">
|
|
|
|
|
<!--往来单位-->
|
2024-11-12 12:20:43 +08:00
|
|
|
<select id="getUnitList" resultType="com.bonus.material.basic.domain.BmUnit">
|
2024-11-11 14:00:09 +08:00
|
|
|
/*根据标段工程id关联协议查询往来单位*/
|
2024-11-12 12:55:48 +08:00
|
|
|
<if test="projectId != null">
|
2024-11-12 12:20:43 +08:00
|
|
|
SELECT DISTINCT bu.unit_id AS unitId,
|
|
|
|
|
bu.unit_name AS unitName
|
2024-11-11 17:10:57 +08:00
|
|
|
FROM bm_project bpl
|
|
|
|
|
LEFT JOIN bm_agreement_info bai ON bpl.pro_id = bai.project_id AND bai.`status` = '1'
|
|
|
|
|
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id AND bu.del_flag = '0'
|
2024-11-12 12:41:27 +08:00
|
|
|
WHERE bpl.pro_id = #{projectId} AND bpl.del_flag = '0'
|
2024-11-11 14:00:09 +08:00
|
|
|
</if>
|
2024-11-12 12:55:48 +08:00
|
|
|
<if test="projectId == null">
|
2024-11-12 12:20:43 +08:00
|
|
|
SELECT unit_id AS unitId,
|
|
|
|
|
unit_name AS unitName
|
2024-11-11 17:10:57 +08:00
|
|
|
FROM bm_unit
|
2024-11-11 14:00:09 +08:00
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!--标段工程-->
|
2024-11-12 12:20:43 +08:00
|
|
|
<select id="getProjectList" resultType="com.bonus.material.basic.domain.BmProject">
|
2024-11-11 14:00:09 +08:00
|
|
|
/*根据往来单位id关联协议查询工程*/
|
2024-11-12 12:55:48 +08:00
|
|
|
<if test="unitId != null">
|
|
|
|
|
SELECT DISTINCT bp.pro_id AS proId,
|
|
|
|
|
bp.pro_name AS proName
|
2024-11-11 17:10:57 +08:00
|
|
|
FROM bm_unit bu
|
2024-11-12 12:55:48 +08:00
|
|
|
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id AND bai.`status` = '1'
|
2024-11-12 12:20:43 +08:00
|
|
|
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id AND bp.del_flag = '0'
|
2024-11-12 12:41:27 +08:00
|
|
|
WHERE bu.unit_id = #{unitId} AND bu.del_flag = '0'
|
2024-11-11 14:00:09 +08:00
|
|
|
</if>
|
2024-11-12 12:55:48 +08:00
|
|
|
<if test="unitId == null">
|
|
|
|
|
SELECT pro_id AS proId,
|
|
|
|
|
pro_name AS proName
|
2024-11-11 17:10:57 +08:00
|
|
|
FROM bm_project
|
2024-11-11 14:00:09 +08:00
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!--机具类型-->
|
|
|
|
|
<select id="getMaTypeData" resultType="com.bonus.material.common.domain.vo.SelectVo">
|
|
|
|
|
SELECT type_id AS id,
|
|
|
|
|
type_name AS `name`
|
|
|
|
|
FROM ma_type
|
|
|
|
|
WHERE `level` = #{type} AND del_flag = '0'
|
|
|
|
|
</select>
|
2024-11-12 12:20:43 +08:00
|
|
|
|
2024-11-11 14:00:09 +08:00
|
|
|
<!--设备类型树-->
|
|
|
|
|
<select id="getDeviceTypeTree" resultType="com.bonus.common.biz.domain.TreeNode">
|
|
|
|
|
SELECT mt.type_id AS id,
|
|
|
|
|
mt.type_name AS label,
|
|
|
|
|
mt.parent_id AS parentId,
|
|
|
|
|
mt.unit_name AS unitName,
|
|
|
|
|
CASE mt.manage_type
|
|
|
|
|
WHEN 0 THEN
|
|
|
|
|
IFNULL(subquery0.num, 0)
|
|
|
|
|
ELSE
|
2024-11-11 14:51:58 +08:00
|
|
|
IFNULL(mt.storage_num, 0)
|
2024-11-11 14:00:09 +08:00
|
|
|
END as num,
|
|
|
|
|
mt.model_code AS modelCode,
|
|
|
|
|
mt.manage_type AS manageType
|
|
|
|
|
FROM ma_type mt
|
|
|
|
|
left join (SELECT mt.type_id,
|
|
|
|
|
mt2.type_name AS typeName,
|
|
|
|
|
mt.type_name AS typeModelName,
|
|
|
|
|
count(mm.ma_id) num
|
|
|
|
|
FROM ma_machine mm
|
|
|
|
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
2024-11-13 16:02:59 +08:00
|
|
|
WHERE mm.ma_code is not null and mm.ma_status in (1)
|
2024-11-11 14:00:09 +08:00
|
|
|
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
2024-11-11 14:51:58 +08:00
|
|
|
WHERE mt.del_flag = '0'
|
2024-11-11 14:00:09 +08:00
|
|
|
<if test="level!=null and level!=''">
|
|
|
|
|
<if test="level == 2">
|
|
|
|
|
AND mt.level IN ('1','2')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="level == 3">
|
|
|
|
|
AND mt.level IN ('1','2','3')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="level == 4">
|
|
|
|
|
AND mt.level IN ('1','2','3','4')
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
2024-11-12 12:20:43 +08:00
|
|
|
|
2024-11-11 14:00:09 +08:00
|
|
|
<!--资产属性-->
|
|
|
|
|
<select id="getAssetAttributesCbx" resultType="com.bonus.material.common.domain.vo.SelectVo">
|
|
|
|
|
SELECT prop_id AS id,
|
|
|
|
|
prop_name AS `name`
|
|
|
|
|
FROM ma_prop_info
|
|
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
ORDER BY create_time
|
|
|
|
|
</select>
|
2024-11-12 12:20:43 +08:00
|
|
|
|
2024-11-11 14:00:09 +08:00
|
|
|
<!--机具厂家-->
|
|
|
|
|
<select id="getDeviceFactoryCbx" resultType="com.bonus.material.common.domain.vo.SelectVo">
|
|
|
|
|
SELECT supplier_id AS id,
|
|
|
|
|
supplier AS `name`
|
|
|
|
|
FROM ma_supplier_info
|
|
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
ORDER BY create_time
|
|
|
|
|
</select>
|
2024-11-12 12:20:43 +08:00
|
|
|
|
2024-11-11 14:00:09 +08:00
|
|
|
<!--配件所属上级树-->
|
|
|
|
|
<select id="getAccessoryTree" resultType="com.bonus.common.biz.domain.TreeNode">
|
|
|
|
|
SELECT pa_id AS id,
|
|
|
|
|
pa_name AS label,
|
|
|
|
|
parent_id AS parentId,
|
|
|
|
|
unit_id as unitName,
|
|
|
|
|
level
|
|
|
|
|
FROM ma_part_type
|
|
|
|
|
WHERE del_flag = '0'
|
|
|
|
|
ORDER BY create_time
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getPartTree" resultType="com.bonus.common.biz.domain.TreeNode">
|
|
|
|
|
SELECT pa_id AS id,
|
|
|
|
|
pa_name AS label,
|
|
|
|
|
parent_id AS parentId,
|
|
|
|
|
level
|
|
|
|
|
FROM ma_part_type
|
|
|
|
|
WHERE del_flag = '0' and level != '3'
|
|
|
|
|
ORDER BY create_time
|
|
|
|
|
</select>
|
2024-11-12 12:20:43 +08:00
|
|
|
|
2024-11-11 14:00:09 +08:00
|
|
|
<!--货架-->
|
|
|
|
|
<select id="getGoodsShelvesCbx" resultType="com.bonus.common.biz.domain.TreeNode">
|
|
|
|
|
SELECT house_id AS id,
|
|
|
|
|
house_name AS label,
|
|
|
|
|
parent_id AS parentId
|
|
|
|
|
FROM ma_house_info
|
|
|
|
|
WHERE del_flag = '0' AND status = '0'
|
|
|
|
|
</select>
|
2024-11-12 12:20:43 +08:00
|
|
|
|
2024-11-11 14:00:09 +08:00
|
|
|
<!--往来单位id和标段工程id获取协议信息-->
|
|
|
|
|
<select id="getAgreementInfoById" resultType="com.bonus.material.common.domain.vo.AgreementVo">
|
|
|
|
|
SELECT agreement_id AS agreementId,
|
|
|
|
|
agreement_code AS agreementCode,
|
|
|
|
|
is_slt AS isSlt
|
|
|
|
|
FROM bm_agreement_info
|
|
|
|
|
WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'
|
|
|
|
|
</select>
|
2024-11-13 18:01:55 +08:00
|
|
|
|
|
|
|
|
<select id="getUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
|
|
|
|
SELECT
|
|
|
|
|
mt.type_id as typeId,
|
|
|
|
|
mt.type_name as typeName,
|
|
|
|
|
mt.parent_id as parentId,
|
|
|
|
|
mt.unit_name as unitName,
|
|
|
|
|
mt.manage_type as manageType,
|
|
|
|
|
SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS num,
|
|
|
|
|
mt.LEVEL as level
|
|
|
|
|
FROM
|
|
|
|
|
ma_type mt
|
|
|
|
|
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
|
|
|
|
WHERE
|
|
|
|
|
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId}
|
|
|
|
|
AND sai2.STATUS = '0' and sai.lease_type = 0 and sai2.num > 0)
|
|
|
|
|
GROUP BY
|
|
|
|
|
mt.type_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getUseTypeTreeL3" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
|
|
|
|
SELECT
|
|
|
|
|
mt3.type_id as typeId,
|
|
|
|
|
mt3.type_name as typeName,
|
|
|
|
|
mt3.parent_id as parentId,
|
|
|
|
|
mt3.unit_name as unitName,
|
|
|
|
|
NULL as manageType,
|
|
|
|
|
0 AS num,
|
|
|
|
|
mt3.LEVEL as level
|
|
|
|
|
FROM
|
|
|
|
|
ma_type mt3 where type_id in
|
|
|
|
|
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getUseTypeTreeL21" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
|
|
|
|
SELECT
|
|
|
|
|
mt2.type_id as typeId,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt2.parent_id as parentId,
|
|
|
|
|
mt2.unit_name as unitName,
|
|
|
|
|
NULL as manageType,
|
|
|
|
|
0 AS num,
|
|
|
|
|
mt2.LEVEL as level
|
|
|
|
|
FROM
|
|
|
|
|
ma_type mt2 where type_id in
|
|
|
|
|
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
|
|
|
|
|
union
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
mt1.type_id as typeId,
|
|
|
|
|
mt1.type_name as typeName,
|
|
|
|
|
mt1.parent_id as parentId,
|
|
|
|
|
mt1.unit_name as unitName,
|
|
|
|
|
NULL as manageType,
|
|
|
|
|
0 AS num,
|
|
|
|
|
mt1.LEVEL as level
|
|
|
|
|
FROM
|
|
|
|
|
ma_type mt1 left join (
|
|
|
|
|
SELECT
|
|
|
|
|
mt2.type_id as typeId,
|
|
|
|
|
mt2.type_name as typeName,
|
|
|
|
|
mt2.parent_id as parentId,
|
|
|
|
|
mt2.unit_name as unitName,
|
|
|
|
|
NULL as manageType,
|
|
|
|
|
0 AS num,
|
|
|
|
|
mt2.LEVEL as level
|
|
|
|
|
FROM
|
|
|
|
|
ma_type mt2) mt2 on mt2.parentId = mt1.type_id where mt2.typeId in
|
|
|
|
|
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
|
|
|
|
#{item}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
2024-11-11 14:00:09 +08:00
|
|
|
</mapper>
|