875 lines
30 KiB
XML
875 lines
30 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'
|
|
<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>
|
|
|
|
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'
|
|
<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>
|
|
|
|
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'
|
|
<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>
|
|
) 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="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
|
|
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">
|
|
/*根据往来单位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
|
|
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 bu.dept_id = #{deptId}
|
|
</if>
|
|
UNION
|
|
SELECT DISTINCT
|
|
concat( 'gs', sd.dept_id ) AS id,
|
|
sd.dept_name AS proName,
|
|
'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 bu.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>
|
|
<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>
|
|
</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 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
|
|
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
|
|
pro_id AS proId,
|
|
pro_name AS proName,
|
|
external_id AS projectId
|
|
FROM
|
|
bm_project
|
|
WHERE
|
|
del_flag = '0'
|
|
</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,
|
|
bu.unit_name AS name
|
|
FROM
|
|
bm_unit bu
|
|
WHERE
|
|
bu.del_flag = '0'
|
|
and bu.type_id = 1731
|
|
</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
|
|
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 project_status = '在建'
|
|
<if test="departId != null and departId != ''">
|
|
AND project_dept_id = #{departId}
|
|
</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="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>
|
|
</mapper>
|