1810 lines
60 KiB
XML
1810 lines
60 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.common.mapper.SelectMapper">
|
||
<!--往来单位-->
|
||
<select id="getUnitList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据标段工程id关联协议查询往来单位*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
CONCAT( 'dw', sd.dept_id ) AS id,
|
||
sd.dept_name AS NAME,
|
||
0 AS parentId,
|
||
1 AS LEVEL,
|
||
null AS typeKey
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_unit bu ON sd.dept_id = bu.dept_id
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="typeId != null and typeId != 0">
|
||
AND bu.type_id = #{typeId}
|
||
</if>
|
||
<if test="companyId != null">
|
||
AND bu.company_id = #{companyId}
|
||
</if>
|
||
|
||
|
||
|
||
UNION
|
||
|
||
SELECT DISTINCT
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS id,
|
||
sda.dict_label AS NAME,
|
||
CONCAT( 'dw', bu.dept_id ) AS parentId,
|
||
2 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="typeId != null and typeId != 0">
|
||
AND bu.type_id = #{typeId}
|
||
</if>
|
||
<if test="companyId != null">
|
||
AND bu.company_id = #{companyId}
|
||
</if>
|
||
|
||
UNION
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS NAME,
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS parentId,
|
||
3 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="typeId != null and typeId != 0">
|
||
AND bu.type_id = #{typeId}
|
||
</if>
|
||
<if test="companyId != null">
|
||
AND bu.company_id = #{companyId}
|
||
</if>
|
||
) ff
|
||
ORDER BY
|
||
LEVEL
|
||
</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>
|
||
|
||
<!--设备类型树-->
|
||
<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
|
||
IFNULL(mt.storage_num, 0)
|
||
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
|
||
WHERE mm.ma_code is not null and mm.ma_status in (1)
|
||
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||
WHERE mt.del_flag = '0'
|
||
<if test="companyId != null">
|
||
AND mt.company_id = #{companyId}
|
||
</if>
|
||
<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>
|
||
|
||
<!--资产属性-->
|
||
<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>
|
||
|
||
<!--机具厂家-->
|
||
<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>
|
||
|
||
<!--配件所属上级树-->
|
||
<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>
|
||
|
||
<!--货架-->
|
||
<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>
|
||
|
||
<!--往来单位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,
|
||
is_safe_type AS isSafeType
|
||
FROM bm_agreement_info
|
||
WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'
|
||
</select>
|
||
|
||
<select id="getUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt.type_id as typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.unit_name as unitName,
|
||
mt.unit_value as unitValue,
|
||
mt.manage_type as manageType,
|
||
SUM(sai.num) AS num,
|
||
mt.LEVEL as level
|
||
FROM
|
||
ma_type mt
|
||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||
WHERE
|
||
sai.STATUS = '0' and sai.agreement_id = #{agreementId}
|
||
GROUP BY
|
||
mt.type_id
|
||
HAVING
|
||
num > 0
|
||
|
||
<if test="clzAgreementId != null and clzAgreementId != 0">
|
||
union all
|
||
|
||
SELECT
|
||
mt.type_id as typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.unit_name as unitName,
|
||
mt.unit_value as unitValue,
|
||
mt.manage_type as manageType,
|
||
SUM( IF(sai.agreement_id = #{clzAgreementId} AND sai.STATUS = '0', sai.num, 0) ) AS num,
|
||
mt.LEVEL as level
|
||
FROM
|
||
ma_type mt
|
||
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
|
||
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||
WHERE
|
||
sai.STATUS = '0' and clai.lease_style != 2
|
||
GROUP BY
|
||
mt.type_id
|
||
HAVING
|
||
num> 0
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getUseTypeTreeL3" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt3.type_id as typeId,
|
||
NULL as materialName,
|
||
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,
|
||
NULL as materialName,
|
||
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,
|
||
NULL as materialName,
|
||
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,
|
||
NULL as materialName,
|
||
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>
|
||
|
||
<select id="getProjectList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
bmp.pro_id AS id,
|
||
bmp.pro_name AS name,
|
||
concat( 'gs', bmp.imp_unit ) AS parentId,
|
||
2 AS level
|
||
FROM
|
||
bm_project bmp
|
||
LEFT JOIN sys_dept sd ON sd.dept_id = bmp.imp_unit
|
||
LEFT JOIN bm_agreement_info bai ON bai.project_id = bmp.pro_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
||
AND bu.del_flag = '0'
|
||
WHERE
|
||
sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bmp.del_flag = '0'
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND sd.dept_id = #{deptId}
|
||
</if>
|
||
UNION
|
||
SELECT DISTINCT
|
||
concat( 'gs', sd.dept_id ) AS id,
|
||
sd.dept_name AS name,
|
||
'0' AS parentId,
|
||
1 AS level
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_project bmp ON sd.dept_id = bmp.imp_unit
|
||
LEFT JOIN bm_agreement_info bai ON bai.project_id = bmp.pro_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
||
WHERE
|
||
bmp.pro_id IS NOT NULL
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bmp.del_flag = '0'
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND sd.dept_id = #{deptId}
|
||
</if>
|
||
) a
|
||
ORDER BY
|
||
level
|
||
</select>
|
||
|
||
<select id="getUnitListApp" resultType="com.bonus.material.basic.domain.BmUnit">
|
||
/*根据标段工程id关联协议查询往来单位*/
|
||
<if test="projectId != null">
|
||
SELECT DISTINCT bu.unit_id AS unitId,
|
||
bu.unit_name AS unitName
|
||
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'
|
||
WHERE bpl.pro_id = #{projectId} AND bpl.del_flag = '0'
|
||
<if test="deptId != null and deptId != 0">
|
||
AND bpl.imp_unit = #{deptId}
|
||
</if>
|
||
<if test="typeId != null and typeId != 0">
|
||
AND bu.type_id = #{typeId}
|
||
</if>
|
||
<if test="companyId != null">
|
||
AND bu.dept_id = #{companyId}
|
||
</if>
|
||
</if>
|
||
<if test="projectId == null">
|
||
SELECT unit_id AS unitId,
|
||
unit_name AS unitName
|
||
FROM bm_unit
|
||
WHERE del_flag = '0'
|
||
<if test="deptId != null and deptId != 0">
|
||
AND dept_id = #{deptId}
|
||
</if>
|
||
<if test="typeId != null and typeId != 0">
|
||
AND bu.type_id = #{typeId}
|
||
</if>
|
||
<if test="companyId != null">
|
||
AND bu.dept_id = #{companyId}
|
||
</if>
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getProjectListApp" resultType="com.bonus.material.basic.domain.BmProject">
|
||
/*根据往来单位id关联协议查询工程*/
|
||
<if test="unitId != null">
|
||
SELECT DISTINCT bp.pro_id AS proId,
|
||
bp.pro_name AS proName
|
||
FROM bm_unit bu
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id AND bp.del_flag = '0'
|
||
WHERE bu.unit_id = #{unitId} AND bu.del_flag = '0'
|
||
</if>
|
||
<if test="unitId == null">
|
||
SELECT pro_id AS proId,
|
||
pro_name AS proName
|
||
FROM bm_project
|
||
WHERE del_flag = '0'
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getUseTypeTreeApp" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt.type_id as typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.unit_name as unitName,
|
||
mt.unit_value as unitValue,
|
||
mt.manage_type as manageType,
|
||
SUM( sai.num ) AS num,
|
||
mt.LEVEL as level
|
||
FROM
|
||
ma_type mt
|
||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||
LEFT JOIN ma_type_repair mtr ON mt.type_id = mtr.type_id
|
||
WHERE
|
||
sai.agreement_id = #{agreementId} AND sai.STATUS = '0' and sai.is_slt = 0
|
||
and mt.manage_type = '1'
|
||
<if test="userId != null">
|
||
and mtr.user_id = #{userId}
|
||
</if>
|
||
GROUP BY
|
||
mt.type_id
|
||
HAVING num> 0
|
||
</select>
|
||
|
||
<select id="getMaType" resultType="com.bonus.material.common.domain.vo.SelectVo">
|
||
SELECT type_id AS typeId,
|
||
type_name AS name,
|
||
parent_id AS parentId,
|
||
level AS level,
|
||
unit_name AS unitName,
|
||
unit_value AS unitValue
|
||
FROM ma_type
|
||
WHERE del_flag = '0'
|
||
<if test="level != null and level != ''">
|
||
and level = #{level}
|
||
</if>
|
||
<if test="typeId != null">
|
||
and parent_id = #{typeId}
|
||
</if>
|
||
</select>
|
||
<select id="getConfigList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT id,
|
||
`name`,
|
||
parent_id AS parentId,
|
||
`level`
|
||
FROM bm_standard_config
|
||
WHERE del_flag = 0
|
||
</select>
|
||
<select id="getBranchProject" resultType="com.bonus.material.common.domain.vo.SelectVo">
|
||
SELECT dict_code as id,
|
||
dict_label as `name`
|
||
FROM sys_dict_data
|
||
WHERE dict_type = 'branch_project'
|
||
and `status` = 0
|
||
</select>
|
||
|
||
<select id="getProjectInfo" resultType="com.bonus.material.basic.domain.BmProject">
|
||
SELECT
|
||
bp.pro_id AS proId,
|
||
bp.pro_name AS proName,
|
||
bp.external_id AS projectId,
|
||
bp.imp_unit AS impUnit
|
||
FROM
|
||
bm_project bp
|
||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
|
||
WHERE
|
||
bp.del_flag = '0'
|
||
-- 剔除已结算工程
|
||
AND bp.pro_id IN (SELECT project_id FROM bm_agreement_info WHERE is_slt = 0)
|
||
AND bp.external_id IS NOT NULL
|
||
<if test="impUnit != null and impUnit != ''">
|
||
and bp.imp_unit = #{impUnit}
|
||
</if>
|
||
<if test="impUnitName != null and impUnitName != ''">
|
||
AND sd.dept_name like concat('%',#{impUnitName},'%')
|
||
</if>
|
||
<if test="departName != null and departName != ''">
|
||
AND bp.pro_center like concat('%',#{departName},'%')
|
||
</if>
|
||
ORDER BY sd.order_num,
|
||
CASE
|
||
WHEN df.voltage_level = '其他' THEN 999 -- 其他放在最后
|
||
WHEN df.voltage_level LIKE '%kV' THEN
|
||
CASE
|
||
WHEN df.voltage_level LIKE '±%' THEN
|
||
CAST(REPLACE(REPLACE(df.voltage_level, '±', ''), 'kV', '') AS DECIMAL) + 1000 -- 直流电压特殊处理
|
||
ELSE
|
||
CAST(REPLACE(df.voltage_level, 'kV', '') AS DECIMAL)
|
||
END
|
||
ELSE 998 -- 其他未知格式
|
||
END ASC
|
||
</select>
|
||
<!-- <select id="getTeamList" resultType="com.bonus.material.common.domain.vo.SelectVo">-->
|
||
<!-- /*根据工程id查询班组*/-->
|
||
<!-- select bzgl_bz.id,-->
|
||
<!-- bzgl_bz.bzmc as name,-->
|
||
<!-- bzgl_bz.bzz_name as teamLeaderName,-->
|
||
<!-- bzgl_bz.bzz_idcard as teamLeaderIdCard,-->
|
||
<!-- bzgl_bz.bz as remark,-->
|
||
<!-- bzgl_bz.bz_status as teamStatus,-->
|
||
<!-- bzgl_bz.project_id as projectId,-->
|
||
<!-- bzgl_bz.project_name as projectName,-->
|
||
<!-- org_user.mobile as teamLeaderPhone-->
|
||
<!-- from `micro-tool`.bzgl_bz bzgl_bz-->
|
||
<!-- left join `uni_org`.org_user org_user on bzgl_bz.bzz_idcard = org_user.id_card-->
|
||
<!-- WHERE bzgl_bz.project_id = #{externalId}-->
|
||
<!-- </select>-->
|
||
|
||
|
||
<select id="getAgreementInfoBy" resultType="com.bonus.material.common.domain.vo.AgreementVo">
|
||
SELECT
|
||
bai.agreement_id as agreementId,
|
||
bai.agreement_code as agreementCode
|
||
FROM
|
||
bm_agreement_info bai
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
|
||
WHERE
|
||
bai.status = '1'
|
||
AND bu.type_id = 36
|
||
AND bai.project_id = #{proId}
|
||
</select>
|
||
|
||
<select id="getTeam" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT
|
||
DISTINCT bu.unit_id AS id,
|
||
CONCAT(bu.unit_name, '(身份证后四位:', RIGHT(bzz_idcard, 4), ')') AS name
|
||
FROM
|
||
bm_unit bu
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND bu.type_id = 1731
|
||
<if test="list != null and list.size() >0">
|
||
AND bu.unit_id IN
|
||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
GROUP BY
|
||
CONCAT(bu.unit_name, '(身份证后四位:', RIGHT(bzz_idcard, 4), ')')
|
||
</select>
|
||
|
||
<select id="getTeamLeaseList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS name
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
LEFT JOIN pro_authorize_info pa ON bu.unit_id = pa.team_id
|
||
WHERE
|
||
bai.`status` = '1'
|
||
AND bai.project_id = #{projectId}
|
||
AND pa.lease_id = #{leaseId}
|
||
AND bu.del_flag = '0'
|
||
AND pa.del_flag = '0'
|
||
AND bu.type_id = 1731
|
||
</select>
|
||
|
||
<select id="getUnitListLeasePerson" resultType="com.bonus.material.basic.domain.BmUnit">
|
||
SELECT
|
||
pau.`name` as leasePerson,
|
||
pau.id_number as idCard,
|
||
pau.phone as telphone
|
||
FROM
|
||
pro_authorize_info pai
|
||
LEFT JOIN pro_authorize_user pau ON pai.id = pau.parent_id
|
||
AND pau.del_flag = '0'
|
||
WHERE
|
||
pai.del_flag = '0'
|
||
AND pai.lease_id = #{leaseId}
|
||
and pai.team_id = #{teamId}
|
||
</select>
|
||
|
||
<select id="selectI8ProjectInfo" resultType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo">
|
||
SELECT
|
||
id as externalId,
|
||
project_dept_id as departId
|
||
FROM
|
||
`data_center`.dx_fb_son
|
||
WHERE id = #{externalId}
|
||
</select>
|
||
|
||
<select id="getUserNameList" resultType="java.lang.String">
|
||
SELECT
|
||
cno
|
||
FROM `sbd_audit`.sg_project_post_personnel
|
||
WHERE post_id = '3de0eb390f3611efa1940242ac130004'
|
||
AND depart_id = #{departId}
|
||
</select>
|
||
<select id="getProjectListByClz" resultType="com.bonus.material.basic.domain.BmProject">
|
||
/*根据往来单位id关联协议查询工程*/
|
||
<if test="teamId != null">
|
||
SELECT DISTINCT bp.pro_id AS proId,
|
||
bp.pro_name AS proName,
|
||
bp.external_id AS projectId
|
||
FROM bm_unit bu
|
||
LEFT JOIN clz_bm_agreement_info bai ON bu.unit_id = bai.unit_id AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id AND bp.del_flag = '0'
|
||
WHERE bu.unit_id = #{teamId} AND bu.del_flag = '0'
|
||
</if>
|
||
<if test="teamId == null">
|
||
SELECT pro_id AS proId,
|
||
pro_name AS proName,
|
||
external_id AS projectId
|
||
FROM bm_project
|
||
WHERE del_flag = '0'
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getDepartId" resultType="java.lang.String">
|
||
SELECT
|
||
depart_id
|
||
FROM `sbd_audit`.sg_project_post_personnel
|
||
WHERE post_id = '3de0eb390f3611efa1940242ac130004'
|
||
AND cno = #{username}
|
||
</select>
|
||
|
||
<select id="getProjectId" resultType="java.lang.String">
|
||
SELECT
|
||
id
|
||
FROM
|
||
`data_center`.dx_fb_son
|
||
WHERE
|
||
1 = 1
|
||
<if test="list != null and list.size > 0">
|
||
AND project_dept_id IN
|
||
<foreach item="item" collection="list" separator="," open="(" close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getAgreementInfoByIdBack" resultType="com.bonus.material.common.domain.vo.AgreementVo">
|
||
SELECT agreement_id AS agreementId,
|
||
agreement_code AS agreementCode,
|
||
is_slt AS isSlt
|
||
FROM clz_bm_agreement_info
|
||
WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'
|
||
</select>
|
||
|
||
<select id="getMaterialAgreementInfoByIdBack" 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 = #{proId} AND status = '1'
|
||
</select>
|
||
|
||
<select id="getUnitListXm" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据标段工程id查询无需授权的项目部和后勤*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
CONCAT( 'dw', sd.dept_id ) AS id,
|
||
sd.dept_name AS NAME,
|
||
0 AS parentId,
|
||
1 AS LEVEL,
|
||
null AS typeKey
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_unit bu ON sd.dept_id = bu.dept_id
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND (bu.type_id = 36 or bu.type_id = 1685)
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
UNION
|
||
|
||
SELECT DISTINCT
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS id,
|
||
sda.dict_label AS NAME,
|
||
CONCAT( 'dw', bu.dept_id ) AS parentId,
|
||
2 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND (bu.type_id = 36 or bu.type_id = 1685)
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
|
||
UNION
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS NAME,
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS parentId,
|
||
3 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND (bu.type_id = 36 or bu.type_id = 1685)
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
) ff
|
||
ORDER BY
|
||
LEVEL
|
||
</select>
|
||
|
||
<select id="getUnitListPro" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据标段工程id查询无需授权的项目部和后勤*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
CONCAT( 'dw', sd.dept_id ) AS id,
|
||
sd.dept_name AS NAME,
|
||
0 AS parentId,
|
||
1 AS LEVEL,
|
||
null AS typeKey
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_unit bu ON sd.dept_id = bu.dept_id
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bu.type_id not in (36, 1685)
|
||
|
||
UNION
|
||
|
||
SELECT DISTINCT
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS id,
|
||
sda.dict_label AS NAME,
|
||
CONCAT( 'dw', bu.dept_id ) AS parentId,
|
||
2 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id not in (36, 1685)
|
||
|
||
UNION
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS NAME,
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS parentId,
|
||
3 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id not in (36, 1685)
|
||
) ff
|
||
ORDER BY
|
||
LEVEL
|
||
</select>
|
||
|
||
<select id="selectUnitByLeaseId" resultType="com.bonus.material.basic.domain.BmUnit">
|
||
SELECT id as id,
|
||
lease_id as leaseId,
|
||
team_id as unitId
|
||
FROM pro_authorize_info
|
||
WHERE lease_id = #{leaseId}
|
||
limit 1
|
||
</select>
|
||
<select id="getBackDeviceTypeTree" resultType="com.bonus.common.biz.domain.TreeNode">
|
||
SELECT mt.type_id AS id,
|
||
mt.type_name AS label,
|
||
CASE WHEN mt.level = '3' THEN '0' ELSE mt.parent_id END AS parentId,
|
||
mt.unit_name AS unitName,
|
||
mt.model_code AS modelCode,
|
||
mt.manage_type AS manageType
|
||
FROM ma_type mt
|
||
INNER join (SELECT
|
||
mm.type_id AS type_id,
|
||
mt2.type_name AS typeName,
|
||
mt.type_name AS typeModelName
|
||
FROM
|
||
slt_agreement_info sai
|
||
LEFT JOIN ma_machine mm ON sai.ma_id = mm.ma_id
|
||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||
AND mt.del_flag = '0'
|
||
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||
AND mt2.del_flag = '0'
|
||
LEFT JOIN bm_agreement_info ba ON sai.agreement_id = ba.agreement_id
|
||
WHERE
|
||
mm.ma_status = '2'
|
||
AND ba.unit_id = #{unitId}
|
||
AND ba.project_id = #{proId}
|
||
GROUP BY mm.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||
WHERE mt.del_flag = '0'
|
||
|
||
AND mt.level IN ('3','4')
|
||
|
||
|
||
</select>
|
||
<select id="getUseTypeTreeL4Back" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt.type_id AS typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.LEVEL as level
|
||
|
||
FROM
|
||
slt_agreement_info sai
|
||
LEFT JOIN ma_machine mm ON sai.ma_id = mm.ma_id
|
||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||
AND mt.del_flag = '0'
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||
AND mt1.del_flag = '0'
|
||
LEFT JOIN bm_agreement_info ba ON sai.agreement_id = ba.agreement_id
|
||
LEFT JOIN ma_type_repair mtr ON mm.type_id = mtr.type_id
|
||
WHERE
|
||
mm.ma_status = '2'
|
||
and mtr.user_id = #{userId}
|
||
AND ba.unit_id = #{unitId}
|
||
AND ba.project_id = #{proId}
|
||
GROUP BY mm.type_id
|
||
</select>
|
||
|
||
<select id="getTeamList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT DISTINCT bu.unit_id AS id,
|
||
bzgl_bz.bzmc AS name
|
||
FROM bm_unit bu
|
||
LEFT JOIN `micro-tool`.bzgl_bz bzgl_bz ON bzgl_bz.bzmc = bu.unit_name
|
||
LEFT JOIN `uni_org`.org_user org_user ON bzgl_bz.bzz_idcard = org_user.id_card
|
||
WHERE bu.del_flag = '0'
|
||
<!-- and bzgl_bz.project_id = #{externalId}-->
|
||
</select>
|
||
|
||
<select id="getUseTypeClzTree" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt.type_id as typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.unit_name as unitName,
|
||
mt.unit_value as unitValue,
|
||
mt.manage_type as manageType,
|
||
SUM(sai.num) AS num,
|
||
mt.LEVEL as level,
|
||
mt.jiju_type as jijuType,
|
||
mt.is_check as isCheck
|
||
FROM
|
||
ma_type mt
|
||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||
WHERE
|
||
sai.STATUS = '0' and sai.agreement_id = #{agreementId}
|
||
GROUP BY
|
||
mt.type_id
|
||
HAVING
|
||
num > 0
|
||
</select>
|
||
<select id="getTeamClzTree" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt.type_id as typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.unit_name as unitName,
|
||
mt.unit_value as unitValue,
|
||
mt.manage_type as manageType,
|
||
SUM(sai.num) AS num,
|
||
mt.LEVEL as level,
|
||
mt.jiju_type as jijuType,
|
||
mt.is_check as isCheck
|
||
FROM
|
||
ma_type mt
|
||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||
WHERE
|
||
sai.STATUS = '0' and mt1.type_name is not NULL and mt.type_name is not NULL
|
||
and sai.agreement_id in
|
||
<foreach item="id" collection="agreementId" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
|
||
|
||
GROUP BY
|
||
mt.type_id
|
||
HAVING
|
||
num > 0
|
||
</select>
|
||
<select id="getBzUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
mt.type_id as typeId,
|
||
mt1.type_name as materialName,
|
||
mt.type_name as typeName,
|
||
mt.parent_id as parentId,
|
||
mt.unit_name as unitName,
|
||
mt.unit_value as unitValue,
|
||
mt.manage_type as manageType,
|
||
SUM(sai.num) AS num,
|
||
mt.LEVEL as level,
|
||
clai.lease_style as leaseStyle
|
||
FROM
|
||
ma_type mt
|
||
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
|
||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
|
||
WHERE
|
||
sai.STATUS = '0' and sai.agreement_id = #{agreementId}
|
||
GROUP BY
|
||
mt.type_id
|
||
</select>
|
||
<select id="getDeviceTypeTreeTwo" 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,
|
||
mt.storage_num as num,
|
||
mt.model_code AS modelCode,
|
||
mt.manage_type AS manageType,
|
||
mt.unit_value as unitValue
|
||
FROM ma_type mt
|
||
WHERE mt.del_flag = '0'
|
||
<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 test="companyId != null">
|
||
AND mt.company_id = #{companyId}
|
||
</if>
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getLeaseProjectList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据往来单位id关联协议查询工程*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
bmp.pro_id AS id,
|
||
bmp.pro_name AS name,
|
||
concat( 'gs', bmp.imp_unit ) AS parentId,
|
||
2 AS level
|
||
FROM
|
||
bm_project bmp
|
||
LEFT JOIN sys_dept sd ON sd.dept_id = bmp.imp_unit
|
||
WHERE
|
||
sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bmp.del_flag = '0'
|
||
AND (
|
||
-- 条件1:如果 bp.pro_id 不在 bm_agreement_info 中,该条件恒为真(不过滤)
|
||
NOT EXISTS (SELECT 1 FROM bm_agreement_info WHERE project_id = bmp.pro_id)
|
||
-- 条件2:如果 bp.pro_id 在 bm_agreement_info 中,则应用 IN 子查询过滤
|
||
OR bmp.pro_id IN (
|
||
SELECT project_id
|
||
FROM bm_agreement_info
|
||
WHERE is_slt = 0
|
||
))
|
||
<if test="projectIdList != null and projectIdList.size() > 0">
|
||
AND bmp.external_id in
|
||
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
UNION
|
||
SELECT DISTINCT
|
||
concat( 'gs', sd.dept_id ) AS id,
|
||
sd.dept_name AS name,
|
||
'0' AS parentId,
|
||
1 AS level
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_project bmp ON sd.dept_id = bmp.imp_unit
|
||
WHERE
|
||
bmp.pro_id IS NOT NULL
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bmp.del_flag = '0'
|
||
AND (
|
||
-- 条件1:如果 bp.pro_id 不在 bm_agreement_info 中,该条件恒为真(不过滤)
|
||
NOT EXISTS (SELECT 1 FROM bm_agreement_info WHERE project_id = bmp.pro_id)
|
||
-- 条件2:如果 bp.pro_id 在 bm_agreement_info 中,则应用 IN 子查询过滤
|
||
OR bmp.pro_id IN (
|
||
SELECT project_id
|
||
FROM bm_agreement_info
|
||
WHERE is_slt = 0
|
||
))
|
||
<if test="projectIdList != null and projectIdList.size() > 0">
|
||
AND bmp.external_id in
|
||
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
) a
|
||
ORDER BY
|
||
level
|
||
</select>
|
||
<select id="getDeviceTypeTreeThree" resultType="com.bonus.common.biz.domain.TreeNode">
|
||
SELECT
|
||
l1.type_id as id,
|
||
l1.type_name as label,
|
||
l1.parent_id as parentId,
|
||
l1.level
|
||
FROM ma_type l4
|
||
JOIN ma_type l3 ON l3.type_id = l4.parent_id
|
||
JOIN ma_type l2 ON l2.type_id = l3.parent_id
|
||
LEFT JOIN ma_type l1 ON l1.type_id = l2.parent_id
|
||
WHERE l4.level = 4
|
||
AND l4.manage_type = 0
|
||
AND l1.level BETWEEN 1 AND 3
|
||
UNION
|
||
SELECT
|
||
l2.type_id as id,
|
||
l2.type_name as label,
|
||
l2.parent_id as parentId,
|
||
l2.level
|
||
FROM ma_type l4
|
||
JOIN ma_type l3 ON l3.type_id = l4.parent_id
|
||
JOIN ma_type l2 ON l2.type_id = l3.parent_id
|
||
WHERE l4.level = 4
|
||
AND l4.manage_type = 0
|
||
AND l2.level BETWEEN 1 AND 3
|
||
UNION
|
||
SELECT
|
||
l3.type_id as id,
|
||
l3.type_name as label,
|
||
l3.parent_id as parentId,
|
||
l3.level
|
||
FROM ma_type l4
|
||
JOIN ma_type l3 ON l3.type_id = l4.parent_id
|
||
WHERE l4.level = 4
|
||
AND l4.manage_type = 0
|
||
AND l3.level BETWEEN 1 AND 3
|
||
ORDER BY level, id
|
||
</select>
|
||
|
||
<select id="getAllProjectList" resultType="java.lang.String">
|
||
SELECT
|
||
id
|
||
FROM
|
||
`data_center`.dx_fb_son
|
||
WHERE
|
||
1 = 1
|
||
<if test="list != null and list.size > 0">
|
||
AND project_dept_id IN
|
||
<foreach item="item" collection="list" separator="," open="(" close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
</select>
|
||
<select id="getInProject" resultType="java.lang.String">
|
||
SELECT
|
||
id
|
||
FROM
|
||
`data_center`.dx_fb_son
|
||
WHERE
|
||
1 = 1
|
||
<if test="list != null and list.size > 0">
|
||
AND project_dept_id IN
|
||
<foreach item="item" collection="list" separator="," open="(" close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getTeamData" resultType="com.bonus.material.clz.domain.BmTeam">
|
||
SELECT
|
||
unit_id as id,
|
||
unit_name as teamName
|
||
FROM
|
||
bm_unit
|
||
WHERE bzz_idcard = #{username}
|
||
</select>
|
||
|
||
<select id="getProjectIdByUseName" resultType="java.lang.String">
|
||
SELECT
|
||
project_id
|
||
FROM
|
||
`micro-tool`.bzgl_bz
|
||
WHERE
|
||
bzz_idcard = #{username}
|
||
</select>
|
||
<select id="getProDepartmentByPro" resultType="com.bonus.material.clz.domain.back.MaterialBackPreApply">
|
||
SELECT bu.unit_id as unitId,
|
||
bu.unit_name as unitName,
|
||
bai.agreement_id as agreementId
|
||
FROM bm_agreement_info bai
|
||
LEFT JOIN bm_unit bu on bu.unit_id = bai.unit_id
|
||
WHERE bai.project_id = #{proId}
|
||
and bu.type_id = '36'
|
||
</select>
|
||
|
||
<select id="getAncestors" resultType="java.lang.String">
|
||
select ancestors from sys_dept where dept_id = #{deptId}
|
||
</select>
|
||
|
||
<select id="selectDetails" resultType="com.bonus.material.clz.domain.direct.ClzDirectApplyDetails">
|
||
SELECT
|
||
dad.type_id AS typeId,
|
||
mt2.type_name AS typeName,
|
||
mt.type_name AS typeModelName,
|
||
mt.unit_name AS unitName,
|
||
mt.manage_type AS manageType,
|
||
SUM( dad.direct_num ) AS directNum
|
||
FROM
|
||
clz_direct_apply_info dai
|
||
LEFT JOIN clz_direct_apply_details dad ON dai.id = dad.direct_id
|
||
LEFT JOIN ma_type mt ON mt.type_id = dad.type_id
|
||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||
WHERE
|
||
dai.id = #{id}
|
||
GROUP BY
|
||
dad.type_id
|
||
</select>
|
||
|
||
<select id="getTeamNewList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT
|
||
DISTINCT
|
||
bz.id as id,
|
||
bz.bzmc as name, bz.bzz_name as relName,
|
||
bz.bzz_idcard as teamLeaderIdCard,
|
||
bz.project_id as projectId,
|
||
ou.mobile as relPhone
|
||
from
|
||
`micro-tool`.bzgl_bz bz
|
||
left join `uni_org`.org_user ou on bz.bzz_idcard = ou.id_card
|
||
WHERE
|
||
bz.bz_status = 3
|
||
AND bz.sfjs = 0
|
||
AND bz.project_id = #{externalId}
|
||
<if test="teamName != null and teamName != ''">
|
||
AND bz.bzmc = #{teamName}
|
||
</if>
|
||
GROUP BY bz.bzmc
|
||
</select>
|
||
<select id="getUnsettledProId" resultType="java.lang.String">
|
||
<!-- 数据量小的时候用上面的SQL,数据量大的时候用下面的sql -->
|
||
SELECT bp.pro_id as proId
|
||
FROM bm_project bp
|
||
WHERE bp.pro_id IS NOT NULL
|
||
AND bp.pro_id IN (
|
||
SELECT project_id
|
||
FROM bm_agreement_info
|
||
WHERE is_slt = 0
|
||
and is_show != 0
|
||
)
|
||
<!-- SELECT DISTINCT bp.pro_id as proId-->
|
||
<!-- FROM bm_project bp-->
|
||
<!-- WHERE EXISTS(-->
|
||
<!-- SELECT 1-->
|
||
<!-- FROM bm_agreement_info bai-->
|
||
<!-- INNER JOIN slt_agreement_info sai ON bai.agreement_id = sai.agreement_id-->
|
||
<!-- WHERE bai.project_id = bp.pro_id-->
|
||
<!-- AND sai.is_slt = 0-->
|
||
<!-- )-->
|
||
<!-- AND bp.pro_id IS NOT NULL-->
|
||
</select>
|
||
<select id="selectCheckPerson" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
||
SELECT
|
||
mtr.user_id as userId,
|
||
su.dept_id as deptId
|
||
FROM
|
||
ma_type_repair mtr
|
||
LEFT JOIN sys_user su on su.user_id=mtr.user_id
|
||
WHERE
|
||
mtr.type_id=#{typeId}
|
||
and (su.dept_id='107' or su.dept_id='336' or su.dept_id='106' or su.dept_id='335')
|
||
GROUP BY su.dept_id
|
||
LIMIT 1
|
||
</select>
|
||
<select id="selectSignUrlByUserId" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
||
SELECT
|
||
sign_url as signUrl,
|
||
sign_type as signType
|
||
FROM
|
||
sys_user
|
||
WHERE
|
||
user_id=#{userId}
|
||
</select>
|
||
|
||
<select id="getAgreementId" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||
SELECT
|
||
sai.agreement_id as agreementId,
|
||
sai.type_id as typeId
|
||
FROM
|
||
slt_agreement_info sai
|
||
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
||
WHERE
|
||
sai.is_slt = '0'
|
||
AND sai.`status` = '0'
|
||
AND bai.project_id = #{proId}
|
||
</select>
|
||
|
||
<select id="getStorageAgreementId" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||
SELECT
|
||
sai.agreement_id as agreementId,
|
||
sai.type_id as typeId
|
||
FROM
|
||
clz_slt_agreement_info sai
|
||
LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
||
WHERE
|
||
sai.is_slt = '0'
|
||
AND bai.project_id = #{proId}
|
||
</select>
|
||
|
||
<select id="getJiJuBzAgreementId" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||
SELECT
|
||
sai.agreement_id,
|
||
sai.type_id
|
||
FROM
|
||
slt_agreement_info sai
|
||
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
||
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
|
||
WHERE
|
||
sai.is_slt = '0'
|
||
AND bu.unit_name = #{teamName}
|
||
</select>
|
||
|
||
<select id="getClzAgreementId" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||
SELECT
|
||
sai.agreement_id,
|
||
sai.type_id
|
||
FROM
|
||
clz_slt_agreement_info sai
|
||
LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
||
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
|
||
WHERE
|
||
sai.is_slt = '0'
|
||
AND bu.unit_name = #{teamName}
|
||
</select>
|
||
<select id="selectProAuthorizeInfo" resultType="com.bonus.material.materialStation.domain.ProAuthorizeInfo">
|
||
SELECT
|
||
bp.pro_id AS proId,
|
||
bp.external_id AS externalId
|
||
FROM
|
||
bm_project bp
|
||
LEFT JOIN lease_apply_info lai ON bp.pro_id = lai.project_id
|
||
WHERE
|
||
lai.id = #{leaseId}
|
||
</select>
|
||
|
||
<select id="selectProjectUnitAgreementIdByTeamAndProject" resultType="java.lang.Long">
|
||
SELECT
|
||
baii.agreement_id AS projectUnitAgreementId
|
||
FROM
|
||
bm_agreement_info bai
|
||
LEFT JOIN bm_agreement_info baii ON baii.unit_id = bai.project_unit_id AND baii.project_id = #{projectId}
|
||
AND baii.status = '1'
|
||
WHERE
|
||
bai.unit_id = #{teamId} AND bai.project_id = #{projectId}
|
||
LIMIT 1
|
||
</select>
|
||
<select id="getLintTypeList" resultType="com.bonus.material.ma.domain.Type">
|
||
SELECT
|
||
type_id as typeId,
|
||
type_name as typeName
|
||
FROM
|
||
ma_type
|
||
WHERE 1=1
|
||
<if test="companyId != null">
|
||
and company_id = #{companyId}
|
||
</if>
|
||
and del_flag='0'
|
||
and parent_id='0'
|
||
</select>
|
||
<select id="getMaterialTypeList" resultType="com.bonus.material.ma.domain.Type">
|
||
SELECT
|
||
type_id as typeId,
|
||
type_name as typeName
|
||
FROM
|
||
ma_type
|
||
WHERE
|
||
del_flag='0'
|
||
and `level`='2'
|
||
<if test="companyId != null">
|
||
and company_id = #{companyId}
|
||
</if>
|
||
<if test="constructionType != null and constructionType.length > 0">
|
||
and parent_id in
|
||
<foreach item="item" index="index" collection="constructionType" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
</select>
|
||
|
||
<select id="getDepartList" resultType="java.lang.String">
|
||
SELECT
|
||
depart_id
|
||
FROM
|
||
`sbd_audit`.sg_project_post_personnel
|
||
WHERE
|
||
post_id IN ( '1095e9100f3611efa1940242ac130004', '2ca0d32b0f3611efa1940242ac130004' )
|
||
AND cno = #{username}
|
||
</select>
|
||
|
||
<select id="getProjectByDepartName" resultType="java.lang.String">
|
||
SELECT
|
||
id
|
||
FROM
|
||
`data_center`.dx_fb_son
|
||
WHERE
|
||
project_dept = #{departName}
|
||
</select>
|
||
|
||
<select id="getImpUnitNameList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||
SELECT
|
||
DISTINCT sd.dept_name AS impUnitName
|
||
FROM
|
||
bm_project bp
|
||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||
WHERE
|
||
sd.dept_name IS NOT NULL
|
||
and sd.dept_id not in (342,345,347,348,101,344)
|
||
<if test="impUnitName != null and impUnitName != ''">
|
||
AND sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
|
||
</if>
|
||
<if test="proName != null and proName != ''">
|
||
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
|
||
</if>
|
||
<if test="companyId != null and companyId != ''">
|
||
AND bp.company_id=#{companyId}
|
||
</if>
|
||
<if test="projectIdList != null and projectIdList.size() > 0">
|
||
AND bp.external_id in
|
||
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</if>
|
||
<if test="impUnit != null and impUnit != ''">
|
||
AND bp.imp_unit = #{impUnit}
|
||
</if>
|
||
GROUP BY sd.dept_name
|
||
ORDER BY
|
||
sd.order_num
|
||
</select>
|
||
|
||
<select id="selectMaterialProjectList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
bmp.pro_id AS id,
|
||
bmp.pro_name AS name,
|
||
concat( 'gs', bmp.imp_unit ) AS parentId,
|
||
2 AS level
|
||
FROM
|
||
bm_project bmp
|
||
LEFT JOIN sys_dept sd ON sd.dept_id = bmp.imp_unit
|
||
LEFT JOIN bm_agreement_info bai ON bai.project_id = bmp.pro_id
|
||
AND bai.`status` = '1' and bai.is_slt = '0'
|
||
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
||
AND bu.del_flag = '0'
|
||
WHERE
|
||
sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bmp.del_flag = '0'
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND sd.dept_id = #{deptId}
|
||
</if>
|
||
UNION
|
||
SELECT DISTINCT
|
||
concat( 'gs', sd.dept_id ) AS id,
|
||
sd.dept_name AS name,
|
||
'0' AS parentId,
|
||
1 AS level
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_project bmp ON sd.dept_id = bmp.imp_unit
|
||
LEFT JOIN bm_agreement_info bai ON bai.project_id = bmp.pro_id
|
||
AND bai.`status` = '1' and bai.is_slt = '0'
|
||
LEFT JOIN bm_unit bu ON bu.unit_id = bai.unit_id
|
||
WHERE
|
||
bmp.pro_id IS NOT NULL
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bmp.del_flag = '0'
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
<if test="deptId != null">
|
||
AND sd.dept_id = #{deptId}
|
||
</if>
|
||
) a
|
||
ORDER BY
|
||
level
|
||
</select>
|
||
|
||
<select id="getMaterialUnitList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据标段工程id关联协议查询往来单位*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
CONCAT( 'dw', sd.dept_id ) AS id,
|
||
sd.dept_name AS NAME,
|
||
0 AS parentId,
|
||
1 AS LEVEL,
|
||
null AS typeKey
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_unit bu ON sd.dept_id = bu.dept_id
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1' AND bai.is_slt = '0'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
|
||
UNION
|
||
|
||
SELECT DISTINCT
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS id,
|
||
sda.dict_label AS NAME,
|
||
CONCAT( 'dw', bu.dept_id ) AS parentId,
|
||
2 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1' AND bai.is_slt = '0'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
|
||
UNION
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS NAME,
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS parentId,
|
||
3 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
LEFT JOIN bm_agreement_info bai ON bu.unit_id = bai.unit_id
|
||
AND bai.`status` = '1' AND bai.is_slt = '0'
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
AND bp.del_flag = '0'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="projectId != null">
|
||
AND bp.pro_id = #{projectId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
) ff
|
||
ORDER BY
|
||
LEVEL
|
||
</select>
|
||
|
||
<select id="getTeamIds" resultType="java.lang.Long">
|
||
SELECT
|
||
pai.team_id
|
||
FROM
|
||
pro_authorize_info pai
|
||
LEFT JOIN lease_apply_info lai ON pai.lease_id = lai.id
|
||
WHERE
|
||
lai.project_id = #{projectId}
|
||
GROUP BY
|
||
pai.team_id
|
||
</select>
|
||
|
||
<select id="getDepartInfo" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据标段工程名称关联协议查询往来单位*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
CONCAT( 'dw', sd.dept_id ) AS id,
|
||
sd.dept_name AS NAME,
|
||
0 AS parentId,
|
||
1 AS LEVEL,
|
||
null AS typeKey
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_unit bu ON sd.dept_id = bu.dept_id
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="unitName != null and unitName != ''">
|
||
AND bu.unit_name = #{unitName}
|
||
</if>
|
||
|
||
UNION
|
||
|
||
SELECT DISTINCT
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS id,
|
||
sda.dict_label AS NAME,
|
||
CONCAT( 'dw', bu.dept_id ) AS parentId,
|
||
2 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="unitName != null and unitName != ''">
|
||
AND bu.unit_name = #{unitName}
|
||
</if>
|
||
|
||
UNION
|
||
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS NAME,
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS parentId,
|
||
3 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="unitName != null and unitName != ''">
|
||
AND bu.unit_name = #{unitName}
|
||
</if>
|
||
) ff
|
||
ORDER BY
|
||
LEVEL
|
||
</select>
|
||
|
||
<select id="getDepartName" resultType="java.lang.String">
|
||
SELECT
|
||
project_dept
|
||
FROM
|
||
data_center.dx_fb_son
|
||
WHERE name = #{projectName}
|
||
</select>
|
||
|
||
<select id="getAgreeUnitList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||
/*根据标段工程id关联协议查询往来单位*/
|
||
SELECT
|
||
*
|
||
FROM
|
||
(
|
||
SELECT
|
||
CONCAT( 'dw', sd.dept_id ) AS id,
|
||
sd.dept_name AS NAME,
|
||
0 AS parentId,
|
||
1 AS LEVEL,
|
||
null AS typeKey
|
||
FROM
|
||
sys_dept sd
|
||
LEFT JOIN bm_unit bu ON sd.dept_id = bu.dept_id
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sd.del_flag = '0'
|
||
AND sd.`status` = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
|
||
UNION
|
||
|
||
SELECT DISTINCT
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS id,
|
||
sda.dict_label AS NAME,
|
||
CONCAT( 'dw', bu.dept_id ) AS parentId,
|
||
2 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
|
||
UNION
|
||
SELECT
|
||
bu.unit_id AS id,
|
||
bu.unit_name AS NAME,
|
||
CONCAT( 'lx', bu.dept_id, '-', sda.dict_code ) AS parentId,
|
||
3 AS LEVEL,
|
||
sda.dict_value AS typeKey
|
||
FROM
|
||
bm_unit bu
|
||
LEFT JOIN sys_dict_data sda ON bu.type_id = sda.dict_code
|
||
AND sda.dict_type = 'bm_unit_type'
|
||
WHERE
|
||
bu.del_flag = '0'
|
||
AND sda.STATUS = '0'
|
||
AND bu.type_id != 1731
|
||
<if test="deptId != null">
|
||
AND bu.dept_id = #{deptId}
|
||
</if>
|
||
<if test="unitId != null">
|
||
AND bu.unit_id = #{unitId}
|
||
</if>
|
||
) ff
|
||
ORDER BY
|
||
LEVEL
|
||
</select>
|
||
|
||
<select id="getTypeId" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
select type_id as typeId
|
||
from bm_unit
|
||
where unit_id = #{unitId}
|
||
</select>
|
||
|
||
<select id="getAgreementIdByProId" resultType="com.bonus.material.basic.domain.BmAgreementInfo">
|
||
SELECT
|
||
bai.agreement_id as agreementId,
|
||
bai.agreement_code as agreementCode
|
||
FROM
|
||
clz_bm_agreement_info bai
|
||
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
|
||
WHERE
|
||
bai.project_id = #{proId}
|
||
</select>
|
||
|
||
<select id="getClzUseByTypeId" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||
SELECT
|
||
type_id AS typeId,
|
||
SUM(IFNULL(num, 0 )) AS num
|
||
FROM
|
||
clz_slt_agreement_info
|
||
WHERE
|
||
STATUS = '0'
|
||
AND (source = 1 OR source is NULL)
|
||
AND type_id = #{type.typeId}
|
||
AND agreement_id in
|
||
<foreach item="agreement" collection="agreementIds" open="(" separator="," close=")">
|
||
#{agreement.agreementId}
|
||
</foreach>
|
||
GROUP BY
|
||
type_id
|
||
HAVING
|
||
num > 0
|
||
LIMIT 1
|
||
</select>
|
||
|
||
<select id="getInfoList" resultType="com.bonus.material.basic.domain.BmAgreementInfo">
|
||
SELECT
|
||
bai.unit_id as unitId,
|
||
bai.project_id as projectId,
|
||
bu.type_id as typeId
|
||
FROM
|
||
bm_agreement_info bai
|
||
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
|
||
WHERE
|
||
bai.agreement_id = #{agreementId}
|
||
LIMIT 1
|
||
</select>
|
||
|
||
<select id="getBackDeptId" resultType="java.lang.Long">
|
||
select type_id as typeId
|
||
from bm_unit
|
||
where unit_id = #{unitId}
|
||
LIMIT 1
|
||
</select>
|
||
</mapper>
|