integrated_traffic/src/main/resources/mybatis/datasource/eightwork/BlindBoardMapper.xml

498 lines
17 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.zcloud.mapper.datasource.eightwork.BlindBoardMapper">
<!--表名 -->
<sql id="tableName">
BUS_BLINDBOARD
</sql>
<!-- 字段 -->
<sql id="Field">
f.BLINDBOARD_ID,
f.CORPINFO_ID,
f.TASK_ID,
f.STEP_ID,
f.ISDELETE,
f.CREATTIME,
f.CREATOR,
f.OPERATTIME,
f.OPERATOR,
f.CHECK_NO,
f.WORK_TYPE,
f.NAME,
f.APPLY_DEPARTMENT_ID,
f.APPLY_USER_ID,
f.WORK_START_DATE,
f.MEDIUM,
f.TEMPERATURE,
f.PRESSURE,
f.SPECIAL_WORK,
f.RISK_IDENTIFICATION,
f.CONFESS_DEPARTMENT_ID,
f.CONFESS_USER_ID,
f.ACCEPT_CONFESS_DEPARTMENT_ID,
f.ACCEPT_CONFESS_USER_ID,
f.GUARDIAN_DEPARTMENT_ID,
f.GUARDIAN_USER_ID,
f.WORK_USER_DEPARTMENT_ID,
f.WORK_USER_ID,
f.CONFIRM_DEPARTMENT_ID,
f.CONFIRM_USER_ID,
f.LEADER_DEPARTMENT_ID,
f.LEADER_USER_ID,
f.ACCEPT_DEPARTMENT_ID,
f.ACCEPT_USER_ID,
f.WORK_START_DEPARTMENT_ID,
f.WORK_START_USER_ID,
f.ACCEPT_TIME,
f.PLS_ID,
f.PLS_NAME,
f.WORK_POSITION,
f.VIDEO_PATH,
f.BOARD_PATH,
f.WORKSHOP_DEPARTMENT_ID,
f.WORKSHOP_USER_ID
</sql>
<!-- 字段用于新增 -->
<sql id="Field2">
BLINDBOARD_ID,
CORPINFO_ID,
TASK_ID,
STEP_ID,
ISDELETE,
CREATTIME,
CREATOR,
OPERATTIME,
OPERATOR,
CHECK_NO,
WORK_TYPE,
NAME,
APPLY_DEPARTMENT_ID,
APPLY_USER_ID,
WORK_START_DATE,
MEDIUM,
TEMPERATURE,
PRESSURE,
SPECIAL_WORK,
RISK_IDENTIFICATION,
CONFESS_DEPARTMENT_ID,
CONFESS_USER_ID,
ACCEPT_CONFESS_DEPARTMENT_ID,
ACCEPT_CONFESS_USER_ID,
GUARDIAN_DEPARTMENT_ID,
GUARDIAN_USER_ID,
WORK_USER_DEPARTMENT_ID,
WORK_USER_ID,
CONFIRM_DEPARTMENT_ID,
CONFIRM_USER_ID,
LEADER_DEPARTMENT_ID,
LEADER_USER_ID,
ACCEPT_DEPARTMENT_ID,
ACCEPT_USER_ID,
WORK_START_DEPARTMENT_ID,
WORK_START_USER_ID,
ACCEPT_TIME,
PLS_ID,
PLS_NAME,
WORK_POSITION,
VIDEO_PATH,
BOARD_PATH,
WORKSHOP_DEPARTMENT_ID,
WORKSHOP_USER_ID
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{BLINDBOARD_ID},
#{CORPINFO_ID},
#{TASK_ID},
#{STEP_ID},
#{ISDELETE},
#{CREATTIME},
#{CREATOR},
#{OPERATTIME},
#{OPERATOR},
#{CHECK_NO},
#{WORK_TYPE},
#{NAME},
#{APPLY_DEPARTMENT_ID},
#{APPLY_USER_ID},
#{WORK_START_DATE},
#{MEDIUM},
#{TEMPERATURE},
#{PRESSURE},
#{SPECIAL_WORK},
#{RISK_IDENTIFICATION},
#{CONFESS_DEPARTMENT_ID},
#{CONFESS_USER_ID},
#{ACCEPT_CONFESS_DEPARTMENT_ID},
#{ACCEPT_CONFESS_USER_ID},
#{GUARDIAN_DEPARTMENT_ID},
#{GUARDIAN_USER_ID},
#{WORK_USER_DEPARTMENT_ID},
#{WORK_USER_ID},
#{CONFIRM_DEPARTMENT_ID},
#{CONFIRM_USER_ID},
#{LEADER_DEPARTMENT_ID},
#{LEADER_USER_ID},
#{ACCEPT_DEPARTMENT_ID},
#{ACCEPT_USER_ID},
#{WORK_START_DEPARTMENT_ID},
#{WORK_START_USER_ID},
#{ACCEPT_TIME},
#{PLS_ID},
#{PLS_NAME},
#{WORK_POSITION},
#{VIDEO_PATH},
#{BOARD_PATH},
#{WORKSHOP_DEPARTMENT_ID},
#{WORKSHOP_USER_ID}
</sql>
<!-- 获取编码 -->
<select id="getCode" parameterType="pd" resultType="pd">
SELECT
COUNT(1) as code
FROM <include refid="tableName"></include> f
WHERE f.CORPINFO_ID = #{CORPINFO_ID}
and f.CREATTIME LIKE CONCAT(#{CREATDATE},'%')
</select>
<!-- 新增-->
<insert id="save" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field2"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 删除-->
<delete id="delete" parameterType="pd">
update
<include refid="tableName"></include>
set
ISDELETE = '1'
where
BLINDBOARD_ID = #{BLINDBOARD_ID}
</delete>
<!-- 修改 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
BLINDBOARD_ID = #{BLINDBOARD_ID},
CORPINFO_ID = #{CORPINFO_ID},
TASK_ID = #{TASK_ID},
STEP_ID = #{STEP_ID},
ISDELETE = #{ISDELETE},
CREATTIME = #{CREATTIME},
CREATOR = #{CREATOR},
OPERATTIME = #{OPERATTIME},
OPERATOR = #{OPERATOR},
CHECK_NO = #{CHECK_NO},
WORK_TYPE = #{WORK_TYPE},
NAME = #{NAME},
APPLY_DEPARTMENT_ID = #{APPLY_DEPARTMENT_ID},
APPLY_USER_ID = #{APPLY_USER_ID},
WORK_START_DATE = #{WORK_START_DATE},
MEDIUM = #{MEDIUM},
TEMPERATURE = #{TEMPERATURE},
PRESSURE = #{PRESSURE},
SPECIAL_WORK = #{SPECIAL_WORK},
RISK_IDENTIFICATION = #{RISK_IDENTIFICATION},
CONFESS_DEPARTMENT_ID = #{CONFESS_DEPARTMENT_ID},
CONFESS_USER_ID = #{CONFESS_USER_ID},
ACCEPT_CONFESS_DEPARTMENT_ID = #{ACCEPT_CONFESS_DEPARTMENT_ID},
ACCEPT_CONFESS_USER_ID = #{ACCEPT_CONFESS_USER_ID},
GUARDIAN_DEPARTMENT_ID = #{GUARDIAN_DEPARTMENT_ID},
GUARDIAN_USER_ID = #{GUARDIAN_USER_ID},
WORK_USER_DEPARTMENT_ID = #{WORK_USER_DEPARTMENT_ID},
WORK_USER_ID = #{WORK_USER_ID},
CONFIRM_DEPARTMENT_ID = #{CONFIRM_DEPARTMENT_ID},
CONFIRM_USER_ID = #{CONFIRM_USER_ID},
LEADER_DEPARTMENT_ID = #{LEADER_DEPARTMENT_ID},
LEADER_USER_ID = #{LEADER_USER_ID},
ACCEPT_DEPARTMENT_ID = #{ACCEPT_DEPARTMENT_ID},
ACCEPT_USER_ID = #{ACCEPT_USER_ID},
WORK_START_DEPARTMENT_ID = #{WORK_START_DEPARTMENT_ID},
WORK_START_USER_ID = #{WORK_START_USER_ID},
ACCEPT_TIME = #{ACCEPT_TIME},
PLS_ID = #{PLS_ID},
PLS_NAME = #{PLS_NAME},
WORK_POSITION = #{WORK_POSITION},
VIDEO_PATH = #{VIDEO_PATH},
WORKSHOP_DEPARTMENT_ID = #{WORKSHOP_DEPARTMENT_ID},
WORKSHOP_USER_ID = #{WORKSHOP_USER_ID}
where
BLINDBOARD_ID = #{BLINDBOARD_ID}
</update>
<select id="findById" parameterType="pd" resultType="pd">
SELECT
<include refid="Field"></include>,
appo.`NAME` as APPLY_DEPARTMENT_NAME,
appu.`NAME` as APPLY_USER_NAME,
f.WORK_START_DATE,
f.SPECIAL_WORK,
f.RISK_IDENTIFICATION,
worko.`NAME` as WORKSHOP_DEPARTMENT_NAME,
worku.`NAME` as WORKSHOP_USER_NAME,
woro.`NAME` as WORK_USER_DEPARTMENT_NAME,
woru.`NAME` as WORK_USER_NAME,
cono.`NAME` as CONFESS_DEPARTMENT_NAME,
conu.`NAME` as CONFESS_USER_NAME,
acco.`NAME` as ACCEPT_CONFESS_DEPARTMENT_NAME,
accu.`NAME` as ACCEPT_CONFESS_USER_NAME,
guao.`NAME` as GUARDIAN_DEPARTMENT_NAME,
guau.`NAME` as GUARDIAN_USER_NAME,
confo.`NAME` as CONFIRM_DEPARTMENT_NAME,
confu.`NAME` as CONFIRM_USER_NAME,
leao.`NAME` as LEADER_DEPARTMENT_NAME,
leau.`NAME` as LEADER_USER_NAME,
acceo.`NAME` as ACCEPT_DEPARTMENT_NAME,
acceu.`NAME` as ACCEPT_USER_NAME,
stao.`NAME` as WORK_START_DEPARTMENT_NAME,
stau.`NAME` as WORK_START_USER_NAME
FROM
bus_blindboard AS f
left join oa_department as appo on f.APPLY_DEPARTMENT_ID = appo.DEPARTMENT_ID
left join sys_user as appu on f.APPLY_USER_ID = appu.USER_ID
left join oa_department as worko on f.WORKSHOP_DEPARTMENT_ID = worko.DEPARTMENT_ID
left join sys_user as worku on f.WORKSHOP_USER_ID = worku.USER_ID
left join oa_department as woro on f.WORK_USER_DEPARTMENT_ID = woro.DEPARTMENT_ID
left join sys_user as woru on f.WORK_USER_ID = woru.USER_ID
left join oa_department as cono on f.CONFESS_DEPARTMENT_ID = cono.DEPARTMENT_ID
left join sys_user as conu on f.CONFESS_USER_ID = conu.USER_ID
left join oa_department as acco on f.ACCEPT_CONFESS_DEPARTMENT_ID = acco.DEPARTMENT_ID
left join sys_user as accu on f.ACCEPT_CONFESS_USER_ID = accu.USER_ID
left join oa_department as guao on f.GUARDIAN_DEPARTMENT_ID = guao.DEPARTMENT_ID
left join sys_user as guau on f.GUARDIAN_USER_ID = guau.USER_ID
left join oa_department as confo on f.CONFIRM_DEPARTMENT_ID = confo.DEPARTMENT_ID
left join sys_user as confu on f.CONFIRM_USER_ID = confu.USER_ID
left join oa_department as leao on f.LEADER_DEPARTMENT_ID = leao.DEPARTMENT_ID
left join sys_user as leau on f.LEADER_USER_ID = leau.USER_ID
left join oa_department as acceo on f.ACCEPT_DEPARTMENT_ID = acceo.DEPARTMENT_ID
left join sys_user as acceu on f.ACCEPT_USER_ID = acceu.USER_ID
left join oa_department as stao on f.WORK_START_DEPARTMENT_ID = stao.DEPARTMENT_ID
left join sys_user as stau on f.WORK_START_USER_ID = stau.USER_ID
WHERE f.BLINDBOARD_ID = #{BLINDBOARD_ID}
</select>
<!-- 修改 -->
<update id="editStep" parameterType="pd">
update
<include refid="tableName"></include>
set
<if test="WORK_START_DATE != null and WORK_START_DATE != ''"><!-- 关键词检索 -->
WORK_START_DATE = #{WORK_START_DATE},
</if>
<if test="ACCEPT_TIME != null and ACCEPT_TIME != ''"><!-- 关键词检索 -->
ACCEPT_TIME = #{ACCEPT_TIME},
</if>
STEP_ID = #{STEP_ID}
where
BLINDBOARD_ID = #{BLINDBOARD_ID}
</update>
<!-- 修改 -->
<update id="editContent" parameterType="pd">
update
<include refid="tableName"></include>
set
BOARD_PATH = #{BOARD_PATH}
where
BLINDBOARD_ID = #{BLINDBOARD_ID}
</update>
<update id="editVideo" parameterType="pd">
update
<include refid="tableName"></include>
set
VIDEO_PATH = #{VIDEO_PATH}
where
BLINDBOARD_ID = #{BLINDBOARD_ID}
</update>
<!-- 列表 -->
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>,
appo.`NAME` as APPLY_DEPARTMENT_NAME,
appu.`NAME` as APPLY_USER_NAME,
cono.`NAME` as CONFESS_DEPARTMENT_NAME,
conu.`NAME` as CONFESS_USER_NAME,
acco.`NAME` as ACCEPT_CONFESS_DEPARTMENT_NAME,
accu.`NAME` as ACCEPT_CONFESS_USER_NAME,
guao.`NAME` as GUARDIAN_DEPARTMENT_NAME,
guau.`NAME` as GUARDIAN_USER_NAME,
confo.`NAME` as CONFIRM_DEPARTMENT_NAME,
confu.`NAME` as CONFIRM_USER_NAME,
leao.`NAME` as LEADER_DEPARTMENT_NAME,
leau.`NAME` as LEADER_USER_NAME,
acceo.`NAME` as ACCEPT_DEPARTMENT_NAME,
acceu.`NAME` as ACCEPT_USER_NAME,
stao.`NAME` as WORK_START_DEPARTMENT_NAME,
stau.`NAME` as WORK_START_USER_NAME,
woro.`NAME` as WORK_USER_DEPARTMENT_NAME,
woru.`NAME` as WORK_USER_NAME,
worko.`NAME` as WORKSHOP_DEPARTMENT_NAME,
worku.`NAME` as WORKSHOP_USER_NAME,
log.STEP_NAME,
log.NEXT_STEP_ID,
log.NEXT_STEP_NAME,
log.STATUS
from
<include refid="tableName"></include> f
left join oa_department as appo on f.APPLY_DEPARTMENT_ID = appo.DEPARTMENT_ID
left join sys_user as appu on f.APPLY_USER_ID = appu.USER_ID
left join oa_department as worko on f.WORKSHOP_DEPARTMENT_ID = worko.DEPARTMENT_ID
left join sys_user as worku on f.WORKSHOP_USER_ID = worku.USER_ID
left join oa_department as woro on f.WORK_USER_DEPARTMENT_ID = woro.DEPARTMENT_ID
left join sys_user as woru on f.WORK_USER_ID = woru.USER_ID
left join oa_department as cono on f.CONFESS_DEPARTMENT_ID = cono.DEPARTMENT_ID
left join sys_user as conu on f.CONFESS_USER_ID = conu.USER_ID
left join oa_department as acco on f.ACCEPT_CONFESS_DEPARTMENT_ID = acco.DEPARTMENT_ID
left join sys_user as accu on f.ACCEPT_CONFESS_USER_ID = accu.USER_ID
left join oa_department as guao on f.GUARDIAN_DEPARTMENT_ID = guao.DEPARTMENT_ID
left join sys_user as guau on f.GUARDIAN_USER_ID = guau.USER_ID
left join oa_department as confo on f.CONFIRM_DEPARTMENT_ID = confo.DEPARTMENT_ID
left join sys_user as confu on f.CONFIRM_USER_ID = confu.USER_ID
left join oa_department as leao on f.LEADER_DEPARTMENT_ID = leao.DEPARTMENT_ID
left join sys_user as leau on f.LEADER_USER_ID = leau.USER_ID
left join oa_department as acceo on f.ACCEPT_DEPARTMENT_ID = acceo.DEPARTMENT_ID
left join sys_user as acceu on f.ACCEPT_USER_ID = acceu.USER_ID
left join oa_department as stao on f.WORK_START_DEPARTMENT_ID = stao.DEPARTMENT_ID
left join sys_user as stau on f.WORK_START_USER_ID = stau.USER_ID
left join (select * from(select * from vi_eightwork_flow_log log having 1 order by log.ACT_TIME desc
) tmp group by tmp.WORK_ID) log on log.WORK_ID = f.BLINDBOARD_ID
where f.ISDELETE = '0'
<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
and f.CHECK_NO LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
</if>
<if test="pd.STEP_NAME != null and pd.STEP_NAME != ''"><!-- 关键词检索 -->
and exists (
select 1 from bus_blindboard_sign sign
left join bus_eightwork_step step on step.STEP_ID = sign.STEP_ID
where sign.BLINDBOARD_ID = f.BLINDBOARD_ID
and sign.SIGN_TIME is null
and sign.SIGN_USER_ID = #{pd.USER_ID}
and step.STEP_NAME = #{pd.STEP_NAME}
and f.STEP_ID != -1
)
</if>
<if test="pd.STEP_ID != null and pd.STEP_ID != ''"><!-- 关键词检索 -->
and log.NEXT_STEP_ID = #{pd.STEP_ID} and f.STEP_ID != -1
</if>
<if test="pd.CREATOR != null and pd.CREATOR != ''"><!-- 关键词检索 -->
and f.CREATOR = #{pd.CREATOR}
</if>
order by f.STEP_ID,f.CREATTIME desc
</select>
<select id="checkWorkCount" parameterType="pd" resultType="pd" >
select
step.CODE,count(1) COUNT
from
bus_blindboard_sign sign
left join bus_eightwork_step step on step.STEP_ID = sign.STEP_ID
left join bus_blindboard work on work.BLINDBOARD_ID = sign.BLINDBOARD_ID
where
sign.SIGN_TIME is null
and work.STEP_ID != '-1'
and
sign.SIGN_USER_ID = #{USER_ID}
group by step.CODE
</select>
<select id="listAllMeasures" resultType="pd">
select
*
from
BUS_BLINDBOARD_MEASURES
</select>
<select id="getFlowList" resultType="pd">
select
flow.CAN_SKIP,
flow.ACTOR_FIELD,
step.STEP_NAME,
user.NAME as ACT_USER_NAME,
log.ACT_TIME,
log.STATUS,
cu.SIGN_USER,
cu.FINISHED_SIGN_USER,
cu.STEP_ID as CURRENT_STEP
from
bus_eightwork_task_flow flow
left join bus_eightwork_step step on step.STEP_ID = flow.STEP_ID
left join bus_eightwork_flow_log log on log.STEP_ID = flow.STEP_ID and
log.WORK_ID = #{BLINDBOARD_ID}
left join sys_user user on user.USER_ID = log.ACT_USER
left join (select sign.STEP_ID,
GROUP_CONCAT( if(sign.SIGN_TIME IS NULL,signer.NAME,null) ) sign_user,
GROUP_CONCAT( if(sign.SIGN_TIME IS not NULL,signer.NAME,null) ) finished_sign_user
from bus_blindboard_sign sign
left join sys_user signer on signer.USER_ID = sign.SIGN_USER_ID where sign.BLINDBOARD_ID = #{BLINDBOARD_ID}
GROUP BY sign.STEP_ID) cu on cu.STEP_ID = step.STEP_ID
where
flow.TASK_ID = #{TASK_ID}
and
flow.STEP_ID != 0
order by
flow.ORDER_BY
</select>
<!-- 修改位置 -->
<update id="setPosition" parameterType="pd">
update
<include refid="tableName"></include>
set
WORK_POSITION = #{WORK_POSITION}
where
BLINDBOARD_ID = #{BLINDBOARD_ID}
</update>
<select id="getMapList" resultType="pd">
select
f.BLINDBOARD_ID,
f.CHECK_NO,
f.WORK_POSITION
from
<include refid="tableName"></include> f
left join (select * from(select * from vi_eightwork_flow_log log having 1 order by log.ACT_TIME desc
) tmp group by tmp.WORK_ID) log on log.WORK_ID = f.BLINDBOARD_ID
where f.ISDELETE = '0' and f.WORK_POSITION is not null
and f.CORPINFO_ID = #{CORPINFO_ID}
and f.STEP_ID &gt; 0 and log.NEXT_STEP_ID != 99
</select>
</mapper>