ah_jjzhgd_service/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/ProMapper.xml

337 lines
16 KiB
XML
Raw Normal View History

2024-03-11 10:17:19 +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" >
2024-04-18 14:04:25 +08:00
<mapper namespace="com.securitycontrol.background.mapper.IProMapper">
2024-03-11 14:52:40 +08:00
<!--新增/修改 工程-->
<insert id="addOrUpdatePro">
<if test="type == 1">
INSERT INTO tb_project
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="proId != null and proId != ''">pro_id,</if>
<if test="userId != null">user_id,</if>
<if test="signCode != null and signCode!=''">sign_code,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
<if test="proCode != null and proCode!=''">pro_code,</if>
<if test="proName != null and proName!=''">pro_name,</if>
<if test="proCost != null and proCost!=''">pro_cost,</if>
<if test="sgUnit != null and sgUnit!=''">sg_unit,</if>
<if test="jlUnit != null and jlUnit!=''">jl_unit,</if>
<if test="proType != null and proType!=''">pro_type,</if>
<if test="proScale != null and proScale!=''">pro_scale,</if>
<if test="manager != null and manager!=''">manager,</if>
<if test="proBrief != null and proBrief!=''">pro_brief,</if>
<if test="nowGx != null and nowGx!=''">now_gx,</if>
<if test="status != null and status!=''">status,</if>
<if test="planStartTime != null and planStartTime!=''">plan_start_time,</if>
<if test="planEndTime != null and planEndTime!=''">plan_end_time,</if>
<if test="startTime != null and startTime!=''">start_time,</if>
<if test="endTime != null and endTime!=''">end_time,</if>
<if test="org != null and org!=''">org,</if>
2024-03-26 20:55:07 +08:00
del_flag,
2024-04-02 15:27:36 +08:00
<if test="bidType != null and bidType!=''">bid_type,</if>
<if test="sgManage != null and sgManage!=''">sg_manage,</if>
<if test="jlManage != null and jlManage!=''">jl_manage,</if>
<if test="subType != null and subType!=''">sub_type,</if>
<if test="tcDate != null and tcDate!=''">tc_date,</if>
2024-03-11 14:52:40 +08:00
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="proId != null and proId != ''">#{proId},</if>
<if test="userId != null">#{userId},</if>
<if test="signCode != null and signCode!=''">#{signCode},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
<if test="proCode != null and proCode!=''">#{proCode},</if>
<if test="proName != null and proName != ''">#{proName},</if>
<if test="proCost != null and proCost!=''">#{proCost},</if>
<if test="sgUnit != null and sgUnit!=''">#{sgUnit},</if>
<if test="jlUnit != null and jlUnit!=''">#{jlUnit},</if>
<if test="proType != null and proType!=''">#{proType},</if>
<if test="proScale != null and proScale != ''">#{proScale},</if>
<if test="manager != null and manager!=''">#{manager},</if>
<if test="proBrief != null and proBrief!=''">#{proBrief},</if>
<if test="nowGx != null and nowGx!=''">#{nowGx},</if>
<if test="status != null and status!=''">#{status},</if>
<if test="planStartTime != null and planStartTime != ''">#{planStartTime},</if>
<if test="planEndTime != null and planEndTime!=''">#{planEndTime},</if>
<if test="startTime != null and startTime!=''">#{startTime},</if>
<if test="endTime != null and endTime!=''">#{endTime},</if>
<if test="org != null and org!=''">#{org},</if>
2024-03-26 20:55:07 +08:00
0,
2024-04-02 15:27:36 +08:00
<if test="bidType != null and bidType!=''">#{bidType},</if>
<if test="sgManage != null and sgManage!=''">#{sgManage},</if>
<if test="jlManage != null and jlManage!=''">#{jlManage},</if>
<if test="subType != null and subType!=''">#{subType},</if>
<if test="tcDate != null and tcDate!=''">#{tcDate},</if>
2024-03-11 14:52:40 +08:00
</trim>
</if>
<if test="type == 2">
2024-04-24 15:53:06 +08:00
UPDATE tb_project SET sign_code = #{signCode},bid_code = #{bidCode},pro_code = #{proCode},
pro_name = #{proName},pro_cost = #{proCost},sg_unit = #{sgUnit},jl_unit = #{jlUnit},pro_type = #{proType},
pro_scale = #{proScale},manager = #{manager},now_gx = #{nowGx},status = #{status},plan_start_time = #{planStartTime},
plan_end_time = #{planEndTime},start_time = #{startTime},end_time = #{endTime},org = #{org},bid_type = #{bidType},
2024-06-17 10:21:40 +08:00
sg_manage = #{sgManage},jl_manage = #{jlManage},sub_type = #{subType},tc_date = #{tcDate},pro_brief = #{proBrief} WHERE pro_id = #{proId}
2024-03-11 14:52:40 +08:00
</if>
</insert>
2024-03-12 13:20:40 +08:00
<!--保存文件资源-->
<insert id="addFiles">
INSERT INTO tb_resource_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="resourceId != null and resourceId != ''">id,</if>
<if test="fileType != null">file_type,</if>
<if test="fileId != null and fileId!=''">file_id,</if>
<if test="fileSuffix != null and fileSuffix!=''">file_suffix,</if>
<if test="fileName != null and fileName!=''">file_name,</if>
<if test="sourceId != null and sourceId!=''">source_id,</if>
<if test="sourceType != null and sourceType!=''">source_type,</if>
del_flag,
<if test="updateTime != null and updateTime!=''">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="resourceId != null and resourceId != ''">#{resourceId},</if>
<if test="fileType != null">#{fileType},</if>
<if test="fileId != null and fileId!=''">#{fileId},</if>
<if test="fileSuffix != null and fileSuffix!=''">#{fileSuffix},</if>
<if test="fileName != null and fileName!=''">#{fileName},</if>
<if test="sourceId != null and sourceId!=''">#{sourceId},</if>
<if test="sourceType != null and sourceType!=''">#{sourceType},</if>
2024-04-23 11:12:05 +08:00
0,
2024-03-12 13:20:40 +08:00
<if test="updateTime != null and updateTime!=''">#{updateTime},</if>
</trim>
</insert>
2024-03-13 19:05:42 +08:00
<!--新增/修改 工序计划-->
<insert id="addOrUpdateGxPlan">
<if test="type == 1">
INSERT INTO tb_gx_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null and planId != ''">plan_id,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
<if test="gxId != null and gxId!=''">gx_id,</if>
<if test="gxWeight != null and gxWeight!=''">gx_weight,</if>
<if test="planStartTime != null and planStartTime!=''">plan_start_time,</if>
<if test="planEndTime != null and planEndTime!=''">plan_end_time,</if>
<if test="startTime != null and startTime!=''">start_time,</if>
<if test="endTime != null and endTime!=''">end_time,</if>
<if test="delaReason != null and delaReason!=''">dela_reason,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null and planId != ''">#{planId},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
<if test="gxId != null and gxId!=''">#{gxId},</if>
<if test="gxWeight != null and gxWeight!=''">#{gxWeight},</if>
<if test="planStartTime != null and planStartTime != ''">#{planStartTime},</if>
<if test="planEndTime != null and planEndTime!=''">#{planEndTime},</if>
<if test="startTime != null and startTime!=''">#{startTime},</if>
<if test="endTime != null and endTime!=''">#{endTime},</if>
<if test="delaReason != null and delaReason!=''">#{delaReason},</if>
0,
</trim>
</if>
<if test="type == 2">
UPDATE tb_gx_plan
<set>
<if test="gxId != null and gxId != ''">gx_id = #{gxId},</if>
<if test="gxWeight != null and gxWeight != ''">gx_weight = #{gxWeight},</if>
<if test="planStartTime != null and planStartTime != ''">plan_start_time = #{planStartTime},</if>
<if test="planEndTime != null and planEndTime != ''">plan_end_time = #{planEndTime},</if>
<if test="startTime != null and startTime != ''">start_time = #{startTime},</if>
<if test="endTime != null and endTime != ''">end_time = #{endTime},</if>
<if test="delaReason != null and delaReason != ''">dela_reason = #{delaReason},</if>
</set>
WHERE plan_id = #{planId}
</if>
</insert>
<!--工程完工-->
<update id="editProStatus">
UPDATE tb_project
<set>
<if test="startTime != null and startTime!=''">start_time = #{startTime},</if>
<if test="endTime != null and endTime!=''">end_time = #{endTime},</if>
<if test="status != null and status != ''">status = '完工',</if>
</set>
WHERE pro_id = #{proId}
</update>
2024-03-11 14:52:40 +08:00
<!--删除工程-->
<delete id="delPro">
2024-03-26 20:55:07 +08:00
UPDATE tb_project SET del_flag = 1 WHERE pro_id = #{proId}
2024-03-11 14:52:40 +08:00
</delete>
<!--删除工程工序计划-->
<delete id="delProGxPlan">
2024-03-14 14:18:02 +08:00
# DELETE FROM tb_gx_plan WHERE
2024-03-12 13:20:40 +08:00
</delete>
<!--删除文件-->
<delete id="delFile">
DELETE FROM tb_resource_file WHERE file_id = #{fileId}
2024-03-11 14:52:40 +08:00
</delete>
2024-03-13 19:05:42 +08:00
<!--删除工序计划-->
<delete id="delGxPlanById">
DELETE FROM tb_gx_plan WHERE plan_id = #{planId}
</delete>
2024-03-11 14:52:40 +08:00
<!--获取工程列表-->
<select id="getProLists" resultType="com.securitycontrol.entity.system.base.vo.ProVo">
SELECT tp.pro_id AS proId,
2024-03-14 14:18:02 +08:00
sb.city_name AS org,
tp.pro_name AS proName,
tp.pro_type AS proType,
tp.pro_scale AS proScale,
tp.jl_unit AS jlUnit,
tp.sg_unit AS sgUnit,
tp.manager AS manager,
tp.plan_start_time AS planStartTime,
tp.plan_end_time AS planEndTime,
tp.start_time AS startTime,
tp.end_time AS endTime,
tp.pro_cost AS proCost,
tp.pro_brief AS proBrief,
2024-03-27 12:03:18 +08:00
sd.dict_name AS status,
2024-03-14 14:18:02 +08:00
tp.bid_code AS bidCode,
tp.sign_code AS signCode,
2024-04-24 15:53:06 +08:00
tp.pro_code AS proCode,
tp.sg_manage AS sgManage,
tp.jl_manage AS jlManage
2024-03-11 14:52:40 +08:00
FROM tb_project tp
LEFT JOIN sys_build sb ON tp.org = sb.org_id
2024-03-27 12:03:18 +08:00
LEFT JOIN sys_dict sd ON sd.dict_code = tp.status AND sd.del_flag = 0
2024-03-13 15:21:14 +08:00
<where>
2024-03-26 20:55:07 +08:00
tp.del_flag = 0
2024-03-13 15:21:14 +08:00
<if test="keyWord !=null and keyWord!=''">
AND (
2024-03-14 14:18:02 +08:00
INSTR(tp.pro_name,#{keyWord}) > 0 OR
INSTR(tp.jl_unit,#{keyWord}) > 0 OR
INSTR(tp.sg_unit,#{keyWord}) > 0 OR
INSTR(tp.manager,#{keyWord}) > 0
2024-03-13 15:21:14 +08:00
)
</if>
</where>
2024-03-11 14:52:40 +08:00
</select>
<!--工程图片/平面图数量-->
<select id="getProFiles" resultType="java.lang.Integer">
2024-03-16 19:15:20 +08:00
SELECT COUNT(*) FROM tb_resource_file WHERE source_id = #{proId} AND file_type = 1 AND source_type = '工程图片'
2024-03-11 14:52:40 +08:00
UNION ALL
2024-03-16 19:15:20 +08:00
SELECT COUNT(*) FROM tb_resource_file WHERE source_id = #{proId} AND file_type = 1 AND source_type = '工程平面图'
2024-03-11 14:52:40 +08:00
</select>
<!--工程详情-->
<select id="getProById" resultType="com.securitycontrol.entity.system.base.vo.ProVo">
SELECT tp.pro_id AS proId,
2024-03-14 14:18:02 +08:00
tp.sign_code AS signCode,
tp.bid_code AS bidCode,
tp.pro_code AS proCode,
tp.pro_name AS proName,
tp.pro_cost AS proCost,
tp.sg_unit AS sgUnit,
tp.jl_unit AS jlUnit,
tp.pro_type AS proType,
tp.pro_scale AS proScale,
tp.manager AS manager,
tp.pro_brief AS proBrief,
tp.now_gx AS nowGx,
tp.status,
tp.plan_start_time AS planStartTime,
tp.plan_end_time AS planEndTime,
tp.start_time AS startTime,
2024-03-16 19:15:20 +08:00
tp.end_time AS endTime,
2024-04-02 15:27:36 +08:00
tp.org,
tp.bid_type AS bidType,
tp.sg_manage AS sgManage,
tp.jl_manage AS jlManage,
tp.sub_type AS subType,
tp.tc_date AS tcDate
2024-03-11 14:52:40 +08:00
FROM tb_project tp
2024-03-12 13:20:40 +08:00
WHERE pro_id = #{proId}
</select>
<!--获取工程图片/平面图-->
<select id="getFiles" resultType="com.securitycontrol.entity.system.vo.ResourceFileVo">
SELECT id AS resourceId,
2024-03-14 14:18:02 +08:00
file_id AS fileId,
CASE source_type WHEN '工程图片' THEN '1' WHEN '工程平面图' THEN '2' END AS sourceType
2024-04-23 11:13:45 +08:00
FROM tb_resource_file WHERE source_id = #{proId} AND del_flag = 0
2024-03-11 14:52:40 +08:00
</select>
2024-03-13 19:05:42 +08:00
<!--获取工序列表-->
<select id="getGxPlanLists" resultType="com.securitycontrol.entity.system.base.vo.GxPlanVo">
SELECT tgp.plan_id AS planId,
2024-03-16 16:06:27 +08:00
tgp.gx_weight AS gxWeight,
2024-03-14 14:18:02 +08:00
tgp.plan_start_time AS planStartTime,
tgp.plan_end_time AS planEndTime,
tgp.start_time AS startTime,
tgp.end_time AS endTime,
tgp.dela_reason AS delaReason,
tgp.bid_code AS bidCode,
2024-03-18 10:02:51 +08:00
<if test="proType == '变电'">
sd.dict_name AS gxName,
</if>
<if test="proType == '线路'">
tpg.gt_name AS gxName,
</if>
2024-03-30 13:37:44 +08:00
tgp.gx_id AS gxId,
tgp.plan_progress AS planProgress
2024-03-13 19:05:42 +08:00
FROM tb_gx_plan tgp
2024-03-18 10:02:51 +08:00
<if test="proType == '变电'">
LEFT JOIN sys_dict sd ON sd.dict_code = tgp.gx_id
</if>
<if test="proType == '线路'">
LEFT JOIN t_pro_gt tpg ON tgp.gx_id = tpg.gt_id
</if>
2024-03-13 19:05:42 +08:00
WHERE tgp.bid_code = #{bidCode}
2024-03-18 10:26:52 +08:00
<if test="proType == '变电' and keyWord!='' and keyWord!=null">
2024-03-18 10:02:51 +08:00
AND INSTR(sd.dict_name,#{keyWord}) > 0
</if>
2024-03-18 10:26:52 +08:00
<if test="proType == '线路' and keyWord!='' and keyWord!=null">
2024-03-18 10:02:51 +08:00
AND INSTR(tpg.gt_name,#{keyWord}) > 0
2024-03-13 19:05:42 +08:00
</if>
</select>
<!--工序计划详情-->
<select id="getGxPlanById" resultType="com.securitycontrol.entity.system.base.vo.GxPlanVo">
SELECT tgp.plan_id AS planId,
2024-03-14 14:18:02 +08:00
gx_weight AS gxWeight,
tgp.plan_start_time AS planStartTime,
tgp.plan_end_time AS planEndTime,
tgp.start_time AS startTime,
tgp.end_time AS endTime,
tgp.dela_reason AS delaReason,
2024-03-16 21:18:14 +08:00
tgp.bid_code AS bidCode,
tgp.gx_id AS gxId
2024-03-13 19:05:42 +08:00
FROM tb_gx_plan tgp
WHERE tgp.bid_code = #{bidCode} AND tgp.plan_id =#{planId}
</select>
<!--工程是否包含工序计划-->
<select id="isHasGxPlan" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_gx_plan WHERE bid_code = #{bidCode}
</select>
2024-03-16 16:06:27 +08:00
<!--当前工序计划是否存在进度填报数据-->
<select id="hasGxProgress" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_project_progress WHERE plan_id = #{planId}
</select>
2024-03-16 19:15:20 +08:00
<select id="proIsExist" resultType="java.lang.Integer">
<if test="proId == null or proId == ''">
2024-03-26 20:55:07 +08:00
SELECT COUNT(*) FROM tb_project tp WHERE bid_code = #{bidCode} AND del_flag = 0
2024-03-16 19:15:20 +08:00
</if>
<if test="proId != null and proId != ''">
2024-03-26 20:55:07 +08:00
SELECT COUNT(*) FROM tb_project tp WHERE bid_code = #{bidCode} AND pro_id != #{proId} AND del_flag = 0
2024-03-16 19:15:20 +08:00
</if>
</select>
2024-03-20 10:22:42 +08:00
<!--获取工序计划作业权重占比-->
<select id="getGxWeight" resultType="java.util.Map">
SELECT plan_id AS planId,
gx_weight AS gxWeight
FROM tb_gx_plan
WHERE bid_code = #{bidCode}
</select>
2024-03-27 12:03:18 +08:00
<!--获取工程状态-->
<select id="getProStatus" resultType="java.util.Map">
SELECT sd2.dict_code AS id,
sd2.dict_name AS name
FROM sys_dict sd
LEFT JOIN sys_dict sd2 ON sd.dict_code = sd2.p_code AND sd2.del_flag = 0
WHERE sd.dict_code = 1200 AND sd.del_flag = 0
ORDER BY sd2.dict_sort
</select>
2024-03-30 13:37:44 +08:00
<!--添加工序计划时杆塔是否被重复添加-->
<select id="getTowerIsExist" resultType="java.lang.Integer">
2024-04-17 17:51:45 +08:00
<if test="planId == null or planId == ''">
SELECT COUNT(*) FROM tb_gx_plan WHERE gx_id = #{gxId} AND bid_code = #{bidCode} AND del_flag = 0
</if>
<if test="planId != null and planId != ''">
SELECT COUNT(*) FROM tb_gx_plan WHERE gx_id = #{gxId} AND bid_code = #{bidCode} AND plan_id != #{planId} AND del_flag = 0
</if>
2024-03-30 13:37:44 +08:00
</select>
2024-03-11 10:17:19 +08:00
</mapper>