| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272 |
- <?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.platform.dao.mapper.check.CheckJobMapper">
- <!-- 首先定义 resultMap -->
- <resultMap id="CheckJobVOMap" type="com.platform.dao.vo.query.check.CheckJobVO">
- <id column="id" property="id"/>
- <!-- 基础字段映射 -->
- <result column="name" property="name"/>
- <result column="type" property="type"/>
- <result column="hours" property="hours"/>
- <result column="miles" property="miles"/>
- <result column="plan_id" property="planId"/>
- <result column="sb_id" property="sbId"/>
- <result column="part_id" property="partId"/>
- <result column="standard_id" property="standardId"/>
- <result column="start_time" property="startTime"/>
- <result column="end_time" property="endTime"/>
- <result column="actual_start_time" property="actualStartTime"/>
- <result column="actual_end_time" property="actualEndTime"/>
- <result column="requirement" property="requirement"/>
- <result column="remark" property="remark"/>
- <result column="feedback" property="feedback"/>
- <result column="status" property="status"/>
- <result column="sb_status" property="sbStatus"/>
- <result column="check_user_id" property="checkUserId"/>
- <result column="check_dept_id" property="checkDeptId"/>
- <result column="created_user_id" property="createdUserId"/>
- <result column="update_user_id" property="updateUserId"/>
- <result column="created_user_name" property="createdUserName"/>
- <result column="update_user_name" property="updateUserName"/>
- <result column="created_time" property="createdTime"/>
- <result column="update_time" property="updateTime"/>
- <result column="standard_hours" property="standardHours"/>
- <result column="real_hours" property="realHours"/>
- <result column="actual_user" property="actualUser"/>
- <result column="receive_overtime" property="receiveOvertime"/>
- <result column="con_task" property="conTask"/>
- <!-- 关联字段映射 -->
- <result column="checkUserName" property="checkUserName"/>
- <result column="sbName" property="sbName"/>
- <result column="sbNo" property="sbNo"/>
- <result column="sbLevel" property="sbLevel"/>
- <result column="partName" property="partName"/>
- <result column="standardNo" property="standardNo"/>
- <result column="standardName" property="standardName"/>
- <result column="standardLevel" property="standardLevel"/>
- <result column="period" property="period"/>
- <result column="periodType" property="periodType"/>
- <result column="positionId" property="positionId"/>
- <result column="positionName" property="positionName"/>
- <result column="checkDeptName" property="checkDeptName"/>
- <collection property="requirementList" ofType="com.platform.dao.entity.check.CheckRequirement">
- <id column="requirement_id" property="id" />
- <result column="std_name" property="stdName" />
- <result column="scope" property="scope" />
- <result column="requirement_type" property="type" />
- <result column="requirement_remark" property="remark" />
- <result column="requirement_created_user_name" property="createdUserName" />
- <result column="requirement_created_time" property="createdTime" />
- <result column="requirement_update_user_name" property="updateUserName" />
- <result column="requirement_update_time" property="updateTime" />
- <result column="requirement_status" property="status" />
- <result column="requirement_method" property="method" />
- <result column="requirement_sb_type" property="sbType" />
- <result column="requirement_check_level" property="checkLevel" />
- <result column="requirement_manage_item" property="manageItem" />
- <result column="requirement_check_item" property="checkItem" />
- <result column="requirement_content" property="content" />
- <result column="requirement_period" property="period" />
- <result column="requirement_sb_type_name" property="sbTypeName" />
- </collection>
- </resultMap>
- <sql id="Base_Column_List">
- checkjob.id,
- checkjob.plan_id,
- checkstandard.standard_hours,
- checkstandard.real_hours,
- checkjob.start_time,
- checkjob.end_time,
- checkjob.actual_user,
- checkjob.type,
- checkjob.actual_start_time,
- checkjob.actual_end_time,
- checkjob.status,
- checkjob.sb_status,
- checkjob.receive_overtime,
- checkjob.check_user_id,
- checkjob.check_dept_id,
- checkjob.created_user_id,
- checkjob.update_user_id,
- checkjob.created_user_name,
- checkjob.update_user_name,checkjob.remark,
- checkjob.created_time,
- checkjob.update_time
- </sql>
- <sql id="Ref_Column_List">
- checkjob.plan_id,
- checkjob.actual_user,
- checkstandard.standard_hours,
- checkstandard.real_hours,
- checkjob.start_time,
- checkjob.type,
- checkjob.check_user_id,
- checkjob.check_dept_id,
- checkjob.end_time,
- checkjob.actual_start_time,
- checkjob.actual_end_time,
- checkjob.checked_num,
- checkjob.abnormal_num,
- checkjob.check_num,checkjob.remark,
- checkjob.status,
- checkjob.receive_overtime,
- checkjob.sb_status
- </sql>
- <sql id="List_Condition">
- <if test="id != null and id != ''">
- and checkjob.id = #{id}
- </if>
- <if test="receiveOvertime != null">
- and checkjob.receive_overtime = #{receiveOvertime}
- </if>
- <if test="planId != null and planId != ''">
- and checkjob.plan_id = #{planId}
- </if>
- <if test="sbId != null and sbId != ''">
- and checkjob.sb_id = #{sbId}
- </if>
- <if test="partId != null and partId != ''">
- and checkjob.part_id = #{partId}
- </if>
- <if test="standardId != null and standardId != ''">
- and checkjob.standard_id = #{standardId}
- </if>
- <if test="requirement != null and requirement != ''">
- and checkjob.requirement = #{requirement}
- </if>
- <if test="remark != null and remark != ''">
- and checkjob.remark = #{remark}
- </if>
- <if test="feedback != null and feedback != ''">
- and checkjob.feedback = #{feedback}
- </if>
- <if test="status ==null and startTimeStart != null ">
- and checkjob.start_time <![CDATA[>=]]>#{startTimeStart}
- </if>
- <if test="status ==null and startTimeEnd != null">
- and checkjob.start_time <![CDATA[<=]]> #{startTimeEnd}
- </if>
- <if test="startTime != null">
- and checkjob.start_time = #{startTime}
- </if>
- <if test="endTimeStart != null">
- and checkjob.end_time <![CDATA[>=]]>; #{endTimeStart}
- </if>
- <if test="endTimeEnd != null">
- and checkjob.end_time <![CDATA[<=]]> #{endTimeEnd}
- </if>
- <if test="endTime != null">
- and checkjob.end_time = #{endTime}
- </if>
- <if test="actualStartTimeStart != null">
- and checkjob.actual_start_time <![CDATA[>=]]>; #{actualStartTimeStart}
- </if>
- <if test="actualStartTimeEnd != null">
- and checkjob.actual_start_time <![CDATA[<=]]> #{actualStartTimeEnd}
- </if>
- <if test="actualStartTime != null">
- and checkjob.actual_start_time = #{actualStartTime}
- </if>
- <if test="actualEndTimeStart != null">
- and checkjob.actual_end_time <![CDATA[>=]]> #{actualEndTimeStart}
- </if>
- <if test="actualEndTimeEnd != null">
- and checkjob.actual_end_time <![CDATA[<=]]> #{actualEndTimeEnd}
- </if>
- <if test="actualEndTime != null">
- and checkjob.actual_end_time = #{actualEndTime}
- </if>
- <if test="status != null">
- and checkjob.status = #{status}
- </if>
- <if test="sbStatus != null">
- and checkjob.sb_status = #{sbStatus}
- </if>
- <if test="createdUserId != null and createdUserId != ''">
- and checkjob.created_user_id = #{createdUserId}
- </if>
- <if test="updateUserId != null and updateUserId != ''">
- and checkjob.update_user_id = #{updateUserId}
- </if>
- <if test="createdUserName != null and createdUserName != ''">
- and checkjob.created_user_name = #{createdUserName}
- </if>
- <if test="updateUserName != null and updateUserName != ''">
- and checkjob.update_user_name = #{updateUserName}
- </if>
- <if test="createdTimeStart != null">
- and checkjob.created_time <![CDATA[>=]]> #{createdTimeStart}
- </if>
- <if test="createdTimeEnd != null">
- and checkjob.created_time <![CDATA[<=]]> #{createdTimeEnd}
- </if>
- <if test="createdTime != null">
- and checkjob.created_time = #{createdTime}
- </if>
- <if test="updateTimeStart != null">
- and checkjob.update_time <![CDATA[>=]]> #{updateTimeStart}
- </if>
- <if test="updateTimeEnd != null">
- and checkjob.update_time <![CDATA[<=]]> #{updateTimeEnd}
- </if>
- <if test="updateTime != null">
- and checkjob.update_time = #{updateTime}
- </if>
- <if test="keyword != null and keyword != ''">
- and (
- standard.no like concat('%',#{keyword},'%') or
- sbinfo.name like concat('%',#{keyword},'%') or
- sbinfo.no like concat('%',#{keyword},'%') or
- sbinfo.zbh like concat('%',#{keyword},'%') )
- </if>
- <if test="zbh != null and zbh != ''">
- and sbinfo.zbh = #{zbh}
- </if>
- <if test="sbLevel != null and sbLevel != ''">
- and sbinfo.level = #{sbLevel}
- </if>
- <if test="typeId != null and typeId != ''">
- and sbinfo.type_id = #{typeId}
- </if>
- <if test="typeIdList != null and typeIdList.size > 0">
- AND sbinfo.type_id in
- <foreach item="item" index="index" collection="typeIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="periodType != null and periodType != ''">
- and standard.period_type = #{periodType}
- </if>
- <if test="standardLevel != null and standardLevel != ''">
- and standard.level = #{standardLevel}
- </if>
- <if test="standardLevelList != null and standardLevelList.size > 0">
- AND standard.level in
- <foreach item="item" index="index" collection="standardLevelList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="checkUserId != null and checkUserId != ''">
- and (
- checkjob.check_user_id = #{checkUserId}
- <if test="checkDeptIds != null and checkDeptIds.size() > 0">
- OR (checkjob.check_dept_id IS NOT NULL AND checkjob.check_dept_id IN
- <foreach item="deptId" collection="checkDeptIds" open="(" close=")" separator=",">
- #{deptId}
- </foreach>)
- </if>
- )
- </if>
- <if test="checkDeptId != null and checkDeptId != ''">
- and checkjob.check_dept_id = #{checkDeptId}
- </if>
- <if test="batchDeptId != null and batchDeptId != ''">
- and (
- EXISTS (
- SELECT 1 FROM t_sys_dept_relation dr_bd
- WHERE dr_bd.ancestor = #{batchDeptId} AND dr_bd.descendant = checkjob.check_dept_id
- )
- OR EXISTS (
- SELECT 1 FROM t_sys_user_dept sud_bd
- INNER JOIN t_sys_dept_relation dr_bd2 ON dr_bd2.descendant = sud_bd.dept_id
- WHERE dr_bd2.ancestor = #{batchDeptId} AND sud_bd.user_id = checkjob.check_user_id
- )
- )
- </if>
- <if test="type != null and type != ''">
- and checkjob.type = #{type}
- </if>
- <if test="searchStartTime != null and ( status==null or status==1 or status==2)">
- and checkjob.start_time <![CDATA[ >= ]]> date_format(#{searchStartTime},'%Y-%m-%d')
- </if>
- <if test="searchEndTime != null and (status==null or status==1 or status==2)">
- and checkjob.start_time <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="searchStartTime != null and status!=null and status==3">
- and checkjob.actual_start_time <![CDATA[ >= ]]> #{searchStartTime}
- </if>
- <if test="searchEndTime != null and status!=null and status==3">
- and checkjob.actual_start_time <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="statusList != null and statusList.size > 0">
- AND checkjob.status in
- <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="checkUserName != null and checkUserName != ''">
- and (
- u.real_name like concat('%',#{checkUserName},'%')
- OR (
- checkjob.check_dept_id IS NOT NULL
- AND EXISTS (
- SELECT 1
- FROM t_sys_user su
- INNER JOIN t_sys_user_dept sud ON sud.user_id = su.user_id
- INNER JOIN t_sys_dept_relation dr ON dr.descendant = sud.dept_id
- WHERE su.real_name like concat('%',#{checkUserName},'%')
- AND dr.ancestor = checkjob.check_dept_id
- )
- )
- )
- </if>
- <if test="actualUser != null and actualUser != ''">
- and checkjob.actual_user like concat('%',#{actualUser},'%')
- </if>
- <if test="positionId!=null and positionId!=''">
- and sbinfo.position_id = #{positionId}
- </if>
- <if test="periodTypeList != null and periodTypeList.size > 0">
- AND standard.period_type in
- <foreach item="item" index="index" collection="periodTypeList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sbLevelList != null and sbLevelList.size > 0">
- AND sbinfo.level in
- <foreach item="item" index="index" collection="sbLevelList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sbNotStatus!=null">
- and sbinfo.status !=#{sbNotStatus}
- </if>
- </sql>
-
- <!-- 子查询专用的条件片段,使用 checkjob_inner 等别名 -->
- <sql id="List_Condition_Inner">
- <if test="id != null and id != ''">
- and checkjob_inner.id = #{id}
- </if>
- <if test="receiveOvertime != null">
- and checkjob_inner.receive_overtime = #{receiveOvertime}
- </if>
- <if test="planId != null and planId != ''">
- and checkjob_inner.plan_id = #{planId}
- </if>
- <if test="sbId != null and sbId != ''">
- and checkjob_inner.sb_id = #{sbId}
- </if>
- <if test="partId != null and partId != ''">
- and checkjob_inner.part_id = #{partId}
- </if>
- <if test="standardId != null and standardId != ''">
- and checkjob_inner.standard_id = #{standardId}
- </if>
- <if test="requirement != null and requirement != ''">
- and checkjob_inner.requirement = #{requirement}
- </if>
- <if test="remark != null and remark != ''">
- and checkjob_inner.remark = #{remark}
- </if>
- <if test="feedback != null and feedback != ''">
- and checkjob_inner.feedback = #{feedback}
- </if>
- <if test="status ==null and startTimeStart != null ">
- and checkjob_inner.start_time <![CDATA[>=]]>#{startTimeStart}
- </if>
- <if test="status ==null and startTimeEnd != null">
- and checkjob_inner.start_time <![CDATA[<=]]> #{startTimeEnd}
- </if>
- <if test="startTime != null">
- and checkjob_inner.start_time = #{startTime}
- </if>
- <if test="endTimeStart != null">
- and checkjob_inner.end_time <![CDATA[>=]]>; #{endTimeStart}
- </if>
- <if test="endTimeEnd != null">
- and checkjob_inner.end_time <![CDATA[<=]]> #{endTimeEnd}
- </if>
- <if test="endTime != null">
- and checkjob_inner.end_time = #{endTime}
- </if>
- <if test="actualStartTimeStart != null">
- and checkjob_inner.actual_start_time <![CDATA[>=]]>; #{actualStartTimeStart}
- </if>
- <if test="actualStartTimeEnd != null">
- and checkjob_inner.actual_start_time <![CDATA[<=]]> #{actualStartTimeEnd}
- </if>
- <if test="actualStartTime != null">
- and checkjob_inner.actual_start_time = #{actualStartTime}
- </if>
- <if test="actualEndTimeStart != null">
- and checkjob_inner.actual_end_time <![CDATA[>=]]> #{actualEndTimeStart}
- </if>
- <if test="actualEndTimeEnd != null">
- and checkjob_inner.actual_end_time <![CDATA[<=]]> #{actualEndTimeEnd}
- </if>
- <if test="actualEndTime != null">
- and checkjob_inner.actual_end_time = #{actualEndTime}
- </if>
- <if test="status != null">
- and checkjob_inner.status = #{status}
- </if>
- <if test="sbStatus != null">
- and checkjob_inner.sb_status = #{sbStatus}
- </if>
- <if test="createdUserId != null and createdUserId != ''">
- and checkjob_inner.created_user_id = #{createdUserId}
- </if>
- <if test="updateUserId != null and updateUserId != ''">
- and checkjob_inner.update_user_id = #{updateUserId}
- </if>
- <if test="createdUserName != null and createdUserName != ''">
- and checkjob_inner.created_user_name = #{createdUserName}
- </if>
- <if test="updateUserName != null and updateUserName != ''">
- and checkjob_inner.update_user_name = #{updateUserName}
- </if>
- <if test="createdTimeStart != null">
- and checkjob_inner.created_time <![CDATA[>=]]> #{createdTimeStart}
- </if>
- <if test="createdTimeEnd != null">
- and checkjob_inner.created_time <![CDATA[<=]]> #{createdTimeEnd}
- </if>
- <if test="createdTime != null">
- and checkjob_inner.created_time = #{createdTime}
- </if>
- <if test="updateTimeStart != null">
- and checkjob_inner.update_time <![CDATA[>=]]> #{updateTimeStart}
- </if>
- <if test="updateTimeEnd != null">
- and checkjob_inner.update_time <![CDATA[<=]]> #{updateTimeEnd}
- </if>
- <if test="updateTime != null">
- and checkjob_inner.update_time = #{updateTime}
- </if>
- <if test="keyword != null and keyword != ''">
- and (
- standard_inner.no like concat('%',#{keyword},'%') or
- sbinfo_inner.name like concat('%',#{keyword},'%') or
- sbinfo_inner.no like concat('%',#{keyword},'%') or
- sbinfo_inner.zbh like concat('%',#{keyword},'%') )
- </if>
- <if test="zbh != null and zbh != ''">
- and sbinfo_inner.zbh = #{zbh}
- </if>
- <if test="sbLevel != null and sbLevel != ''">
- and sbinfo_inner.level = #{sbLevel}
- </if>
- <if test="typeId != null and typeId != ''">
- and sbinfo_inner.type_id = #{typeId}
- </if>
- <if test="typeIdList != null and typeIdList.size > 0">
- AND sbinfo_inner.type_id in
- <foreach item="item" index="index" collection="typeIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="periodType != null and periodType != ''">
- and standard_inner.period_type = #{periodType}
- </if>
- <if test="standardLevel != null and standardLevel != ''">
- and standard_inner.level = #{standardLevel}
- </if>
- <if test="standardLevelList != null and standardLevelList.size > 0">
- AND standard_inner.level in
- <foreach item="item" index="index" collection="standardLevelList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="checkUserId != null and checkUserId != ''">
- and (
- checkjob_inner.check_user_id = #{checkUserId}
- <if test="checkDeptIds != null and checkDeptIds.size() > 0">
- OR (checkjob_inner.check_dept_id IS NOT NULL AND checkjob_inner.check_dept_id IN
- <foreach item="deptId" collection="checkDeptIds" open="(" close=")" separator=",">
- #{deptId}
- </foreach>)
- </if>
- )
- </if>
- <if test="checkDeptId != null and checkDeptId != ''">
- and checkjob_inner.check_dept_id = #{checkDeptId}
- </if>
- <if test="batchDeptId != null and batchDeptId != ''">
- and (
- EXISTS (
- SELECT 1 FROM t_sys_dept_relation dr_bd
- WHERE dr_bd.ancestor = #{batchDeptId} AND dr_bd.descendant = checkjob_inner.check_dept_id
- )
- OR EXISTS (
- SELECT 1 FROM t_sys_user_dept sud_bd
- INNER JOIN t_sys_dept_relation dr_bd2 ON dr_bd2.descendant = sud_bd.dept_id
- WHERE dr_bd2.ancestor = #{batchDeptId} AND sud_bd.user_id = checkjob_inner.check_user_id
- )
- )
- </if>
- <if test="type != null and type != ''">
- and checkjob_inner.type = #{type}
- </if>
- <if test="searchStartTime != null and ( status==null or status==1 or status==2)">
- and checkjob_inner.start_time <![CDATA[ >= ]]> date_format(#{searchStartTime},'%Y-%m-%d')
- </if>
- <if test="searchEndTime != null and (status==null or status==1 or status==2)">
- and checkjob_inner.start_time <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="searchStartTime != null and status!=null and status==3">
- and checkjob_inner.actual_start_time <![CDATA[ >= ]]> #{searchStartTime}
- </if>
- <if test="searchEndTime != null and status!=null and status==3">
- and checkjob_inner.actual_start_time <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="statusList != null and statusList.size > 0">
- AND checkjob_inner.status in
- <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="checkUserName != null and checkUserName != ''">
- and (
- u.real_name like concat('%',#{checkUserName},'%')
- OR (
- checkjob_inner.check_dept_id IS NOT NULL
- AND EXISTS (
- SELECT 1
- FROM t_sys_user su
- INNER JOIN t_sys_user_dept sud ON sud.user_id = su.user_id
- INNER JOIN t_sys_dept_relation dr ON dr.descendant = sud.dept_id
- WHERE su.real_name like concat('%',#{checkUserName},'%')
- AND dr.ancestor = checkjob_inner.check_dept_id
- )
- )
- )
- </if>
- <if test="actualUser != null and actualUser != ''">
- and checkjob_inner.actual_user like concat('%',#{actualUser},'%')
- </if>
- <if test="positionId!=null and positionId!=''">
- and sbinfo_inner.position_id = #{positionId}
- </if>
- <if test="periodTypeList != null and periodTypeList.size > 0">
- AND standard_inner.period_type in
- <foreach item="item" index="index" collection="periodTypeList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sbLevelList != null and sbLevelList.size > 0">
- AND sbinfo_inner.level in
- <foreach item="item" index="index" collection="sbLevelList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="sbNotStatus!=null">
- and sbinfo_inner.status !=#{sbNotStatus}
- </if>
- </sql>
- <select id="selectList" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultMap="CheckJobVOMap">
- select
- checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task,
- u.real_name as checkUserName,
- dept.name as checkDeptName,
- sbinfo.name as sbName,
- sbinfo.no as sbNo,
- sbinfo.level as sbLevel,
- sbinfo.id as sbInfoId,
- partinfo.name as partName,
- standard.no as standardNo,
- standard.name as standardName,
- standard.level as standardLevel,
- standard.period as period,
- standard.period_type as periodType,
- position.id as positionId,
- position.name as positionName,
- cr.id as requirement_id,
- cr.std_name as std_name,
- cr.scope as scope,
- cr.type as requirement_type,
- cr.method as requirement_method,
- cr.sb_type as requirement_sb_type,
- cr.check_level as requirement_check_level,
- cr.manage_item as requirement_manage_item,
- cr.check_item as requirement_check_item,
- cr.content as requirement_content,
- cr.period as requirement_period,
- sbtype.name as requirement_sb_type_name,
- cr.remark as requirement_remark,
- cr.created_user_name as requirement_created_user_name,
- cr.created_time as requirement_created_time,
- cr.update_user_name as requirement_update_user_name,
- cr.update_time as requirement_update_time,
- cr.status as requirement_status
- from t_check_job as checkjob
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_part_info partinfo on partinfo.id = checkjob.part_id
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on checkjob.check_user_id = u.user_id
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
- left join t_sb_position position on position.id = sbinfo.position_id
- left join t_check_standard_requirement csr on csr.standard_id = standard.id
- left join t_check_requirement cr on cr.id = csr.requirement_id
- left join t_sb_type sbtype on sbtype.id = cr.sb_type
- WHERE checkjob.id IN (
- SELECT job_id FROM (
- SELECT checkjob_inner.id as job_id
- FROM t_check_job checkjob_inner
- LEFT JOIN t_sb_info sbinfo_inner ON sbinfo_inner.id = checkjob_inner.sb_id
- LEFT JOIN t_check_standard standard_inner ON standard_inner.id = checkjob_inner.standard_id
- LEFT JOIN t_sys_user u ON checkjob_inner.check_user_id = u.user_id
- <where>
- <include refid="List_Condition_Inner"/>
- </where>
- ORDER BY
- checkjob_inner.status asc,
- <if test="status==null or status==1 or status==2">
- checkjob_inner.start_time asc,
- </if>
- sbinfo_inner.level asc,
- sbinfo_inner.no asc,
- standard_inner.period_type asc,
- standard_inner.period asc
- ) as tmp
- )
- Order By
- checkjob.status asc,
- <if test="status==null or status==1 or status==2">
- checkjob.start_time asc,
- </if>
- sbinfo.level asc,
- sbinfo.no asc,
- standard.period_type asc,
- standard.period asc
- </select>
- <select id="selectList2" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultMap="CheckJobVOMap">
- select
- checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task,
- u.real_name as checkUserName,
- dept.name as checkDeptName,
- sbinfo.name as sbName,
- sbinfo.no as sbNo,
- sbinfo.level as sbLevel,
- sbinfo.id as sbInfoId,
- partinfo.name as partName,
- standard.no as standardNo,
- standard.name as standardName,
- standard.level as standardLevel,
- standard.period as period,
- standard.period_type as periodType,
- position.id as positionId,
- position.name as positionName,
- <!-- 保养要求相关字段 -->
- cr.id as requirement_id,
- cr.std_name as std_name,
- cr.scope as scope,
- cr.type as requirement_type,
- cr.method as requirement_method,
- cr.sb_type as requirement_sb_type,
- cr.check_level as requirement_check_level,
- cr.manage_item as requirement_manage_item,
- cr.check_item as requirement_check_item,
- cr.content as requirement_content,
- cr.period as requirement_period,
- sbtype.name as requirement_sb_type_name,
- cr.remark as requirement_remark,
- cr.created_user_name as requirement_created_user_name,
- cr.created_time as requirement_created_time,
- cr.update_user_name as requirement_update_user_name,
- cr.update_time as requirement_update_time,
- cr.status as requirement_status
- from t_check_job as checkjob
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_part_info partinfo on partinfo.id = checkjob.part_id
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on checkjob.check_user_id = u.user_id
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
- left join t_sb_position position on position.id = sbinfo.position_id
- <!-- 关联保养要求表 -->
- left join t_check_standard_requirement csr on csr.standard_id = standard.id
- left join t_check_requirement cr on cr.id = csr.requirement_id and cr.status = 1
- left join t_sb_type sbtype on sbtype.id = cr.sb_type
- <where>
- <include refid="List_Condition"/>
- </where>
- </select>
- <select id="getScreenCountByTime" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultType="com.platform.dao.vo.query.check.CheckJobVO">
- select count(checkjob.id) as countNum
- from t_check_job as checkjob
- <where>
- <if test="searchStartTime != null">
- and checkjob.start_time <![CDATA[ >= ]]> #{searchStartTime}
- </if>
- <if test="searchEndTime != null">
- and checkjob.start_time <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="status != null">
- and checkjob.status = #{status}
- </if>
- </where>
- </select>
- <select id="countByCondition" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultType="long">
- select count(DISTINCT checkjob.id)
- from t_check_job checkjob
- LEFT JOIN t_sb_info sbinfo ON sbinfo.id = checkjob.sb_id
- LEFT JOIN t_check_standard standard ON standard.id = checkjob.standard_id
- LEFT JOIN t_sys_user u ON checkjob.check_user_id = u.user_id
- <where>
- <include refid="List_Condition"/>
- </where>
- </select>
- <select id="selectDetail" resultType="com.platform.dao.vo.query.check.CheckJobVO">
- select checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task,
- u.real_name as checkUserName,
- dept.name as checkDeptName,
- sbinfo.name sbName,
- sbinfo.no sbNo,
- sbinfo.level sbLevel,
- partinfo.name partName,
- standard.no standardNo,
- standard.name standardName,
- standard.level standardLevel,
- standard.period period,
- standard.next_date as nextDate,
- standard.period_type periodType,
- standard.consumables consumables,
- standard.spare_parts spareParts
- from t_check_job as checkjob
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_part_info partinfo on partinfo.id = checkjob.part_id
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on checkjob.check_user_id = u.user_id
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
- where checkjob.id = #{id}
- </select>
- <select id="getNotFinishNumByDTO" resultType="java.lang.Integer">
- select count(checkjob.id)
- from t_check_job as checkjob
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_part_info partinfo on partinfo.id = checkjob.part_id
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on checkjob.check_user_id = u.user_id
- <where>
- <include refid="List_Condition"/>
- </where>
- </select>
- <select id="selectLastJob" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultType="com.platform.dao.vo.query.check.CheckJobVO">
- select checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task
- from t_check_job as checkjob
- where checkjob.sb_id = #{sbId}
- and checkjob.standard_id = #{standardId}
- order by checkjob.created_time desc limit 1
- </select>
- <update id="updateBatch" parameterType="java.util.List">
- <foreach collection="list" item="item" index="index" open="" close="" separator=";">
- update t_check_job
- <set>
- <if test="item.receiveOvertime != null">
- receive_overtime = #{item.receiveOvertime}
- </if>
- <if test="item.startTime != null">
- start_time = #{item.startTime}
- </if>
- </set>
- where id = #{item.id}
- </foreach>
- </update>
- <update id="updateBatchByDelStandard" parameterType="com.platform.dao.entity.check.CheckJob">
- update t_check_job
- <set>
- status = 3,
- remark = #{remark}
- </set>
- where standard_id = #{standardId}
- and status != 3
- </update>
- <select id="selectListByDate" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultType="com.platform.dao.vo.query.check.CheckJobVO">
- select checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task
- from t_check_job as checkjob
- <where>
- <if test="status != null">
- and checkjob.status = #{status}
- </if>
- <if test="startTimeEnd != null">
- and checkjob.start_time <![CDATA[ <= ]]> #{startTimeEnd}
- </if>
- </where>
- </select>
- <!-- 分页查询任务ID列表 -->
- <select id="selectJobIdPage" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultType="java.lang.String">
- SELECT checkjob_inner.id
- FROM t_check_job checkjob_inner
- LEFT JOIN t_sb_info sbinfo_inner ON sbinfo_inner.id = checkjob_inner.sb_id
- LEFT JOIN t_check_standard standard_inner ON standard_inner.id = checkjob_inner.standard_id
- LEFT JOIN t_sys_user u ON checkjob_inner.check_user_id = u.user_id
- <where>
- <include refid="List_Condition_Inner"/>
- </where>
- </select>
- <!-- 根据ID列表查询完整数据 -->
- <select id="selectListByIds" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultMap="CheckJobVOMap">
- select
- checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task,
- u.real_name as checkUserName,
- dept.name as checkDeptName,
- sbinfo.name as sbName,
- sbinfo.no as sbNo,
- sbinfo.level as sbLevel,
- sbinfo.id as sbInfoId,
- partinfo.name as partName,
- standard.no as standardNo,
- standard.name as standardName,
- standard.level as standardLevel,
- standard.period as period,
- standard.period_type as periodType,
- position.id as positionId,
- position.name as positionName,
- cr.id as requirement_id,
- cr.std_name as std_name,
- cr.scope as scope,
- cr.type as requirement_type,
- cr.method as requirement_method,
- cr.sb_type as requirement_sb_type,
- cr.check_level as requirement_check_level,
- cr.manage_item as requirement_manage_item,
- cr.check_item as requirement_check_item,
- cr.content as requirement_content,
- cr.period as requirement_period,
- sbtype.name as requirement_sb_type_name,
- cr.remark as requirement_remark,
- cr.created_user_name as requirement_created_user_name,
- cr.created_time as requirement_created_time,
- cr.update_user_name as requirement_update_user_name,
- cr.update_time as requirement_update_time,
- cr.status as requirement_status
- from t_check_job as checkjob
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_part_info partinfo on partinfo.id = checkjob.part_id
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on checkjob.check_user_id = u.user_id
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
- left join t_sb_position position on position.id = sbinfo.position_id
- left join t_check_standard_requirement csr on csr.standard_id = standard.id
- left join t_check_requirement cr on cr.id = csr.requirement_id
- left join t_sb_type sbtype on sbtype.id = cr.sb_type
- WHERE checkjob.id IN
- <foreach item="item" index="index" collection="jobIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- Order By
- checkjob.status asc,
- <if test="status==null or status==1 or status==2">
- checkjob.start_time asc,
- </if>
- sbinfo.level asc,
- sbinfo.no asc,
- standard.period_type asc,
- standard.period asc
- </select>
- <!-- 根据ID列表查询完整数据2(record=1) -->
- <select id="selectList2ByIds" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultMap="CheckJobVOMap">
- select
- checkjob.id as id,
- checkjob.plan_id as plan_id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.hours as hours,
- checkjob.miles as miles,
- checkjob.sb_id as sb_id,
- checkjob.part_id as part_id,
- checkjob.standard_id as standard_id,
- checkjob.start_time as start_time,
- checkjob.end_time as end_time,
- checkjob.actual_start_time as actual_start_time,
- checkjob.actual_end_time as actual_end_time,
- checkjob.requirement as requirement,
- checkjob.remark as remark,
- checkjob.feedback as feedback,
- checkjob.status as status,
- checkjob.sb_status as sb_status,
- checkjob.check_user_id as check_user_id,
- checkjob.check_dept_id as check_dept_id,
- checkjob.created_user_id as created_user_id,
- checkjob.update_user_id as update_user_id,
- checkjob.created_user_name as created_user_name,
- checkjob.update_user_name as update_user_name,
- checkjob.created_time as created_time,
- checkjob.update_time as update_time,
- checkjob.standard_hours as standard_hours,
- checkjob.real_hours as real_hours,
- checkjob.actual_user as actual_user,
- checkjob.receive_overtime as receive_overtime,
- checkjob.con_task as con_task,
- u.real_name as checkUserName,
- dept.name as checkDeptName,
- sbinfo.name as sbName,
- sbinfo.no as sbNo,
- sbinfo.level as sbLevel,
- sbinfo.id as sbInfoId,
- partinfo.name as partName,
- standard.no as standardNo,
- standard.name as standardName,
- standard.level as standardLevel,
- standard.period as period,
- standard.period_type as periodType,
- position.id as positionId,
- position.name as positionName,
- cr.id as requirement_id,
- cr.std_name as std_name,
- cr.scope as scope,
- cr.type as requirement_type,
- cr.method as requirement_method,
- cr.sb_type as requirement_sb_type,
- cr.check_level as requirement_check_level,
- cr.manage_item as requirement_manage_item,
- cr.check_item as requirement_check_item,
- cr.content as requirement_content,
- cr.period as requirement_period,
- sbtype.name as requirement_sb_type_name,
- cr.remark as requirement_remark,
- cr.created_user_name as requirement_created_user_name,
- cr.created_time as requirement_created_time,
- cr.update_user_name as requirement_update_user_name,
- cr.update_time as requirement_update_time,
- cr.status as requirement_status
- from t_check_job as checkjob
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_part_info partinfo on partinfo.id = checkjob.part_id
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on checkjob.check_user_id = u.user_id
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
- left join t_sb_position position on position.id = sbinfo.position_id
- left join t_check_standard_requirement csr on csr.standard_id = standard.id
- left join t_check_requirement cr on cr.id = csr.requirement_id and cr.status = 1
- left join t_sb_type sbtype on sbtype.id = cr.sb_type
- WHERE checkjob.id IN
- <foreach item="item" index="index" collection="jobIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </select>
- <!-- 查询执行方式为班组、未完成(status != 3)且开始日期不晚于今天(start_time <= CURDATE())的保养任务,用于每日早上9点定时提醒班长:
- 既包含已逾期任务,也包含今天到期但发邮件时仍未完成的任务;未来任务(start_time > 今天)不提醒。
- 注意:start_time 为日期级(LocalDate),用 <= CURDATE() 可覆盖“今天”一整天,勿改成 < CURDATE() 否则会漏掉今天到期的任务 -->
- <select id="selectUnfinishedTeamJobs" resultType="com.platform.dao.vo.query.check.CheckJobVO">
- select
- checkjob.id as id,
- checkjob.name as name,
- checkjob.sb_id as sbId,
- checkjob.standard_id as standardId,
- checkjob.status as status,
- checkjob.check_dept_id as checkDeptId,
- checkjob.start_time as startTime,
- checkjob.end_time as endTime,
- sbinfo.name as sbName,
- sbinfo.no as sbNo,
- dept.name as checkDeptName
- from t_check_job as checkjob
- inner join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
- left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
- where checkjob.type = 2
- and standard.check_user_type = 4
- and checkjob.check_dept_id is not null
- and checkjob.status != 3
- and checkjob.start_time <= CURDATE()
- order by checkjob.check_dept_id asc, sbinfo.no asc
- </select>
- <!-- 显式更新指定标准下某状态任务的执行人字段,允许将 check_user_id / check_dept_id 置空,
- 用于执行人方式在“班组”与“具体人”之间切换时彻底移交任务归属 -->
- <update id="updateJobExecutor">
- update t_check_job
- set check_user_id = #{checkUserId},
- check_dept_id = #{checkDeptId}
- where standard_id = #{standardId}
- and status = #{status}
- </update>
- <!-- 设备近期点检(保养)日历:只查单台设备当月已完成(status=3)的任务,
- 完成日取 actual_end_time,历史数据为空时依次退化为 actual_start_time、end_time(与年度计划表口径一致),
- 不走 selectList 的多表联查(避免脏数据与免登录场景下的额外开销) -->
- <select id="selectSbFinishedJobs" resultType="com.platform.dao.vo.query.check.CheckJobVO">
- select
- checkjob.id as id,
- checkjob.name as name,
- checkjob.type as type,
- checkjob.status as status,
- checkjob.sb_id as sbId,
- checkjob.start_time as startTime,
- checkjob.end_time as endTime,
- checkjob.actual_user as actualUser,
- coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time) as actualEndTime,
- u.real_name as checkUserName,
- dept.name as checkDeptName,
- standard.name as standardName
- from t_check_job checkjob
- left join t_check_standard standard on standard.id = checkjob.standard_id
- left join t_sys_user u on u.user_id = checkjob.check_user_id
- left join t_sys_dept dept on dept.dept_id = checkjob.check_dept_id
- where checkjob.sb_id = #{sbId}
- and checkjob.status = 3
- and coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time) <![CDATA[>=]]> #{startTime}
- and coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time) <![CDATA[<=]]> #{endTime}
- <if test="type != null">
- and checkjob.type = #{type}
- </if>
- order by actualEndTime asc, checkjob.id asc
- </select>
- <!-- 年度保养计划表:以“保养标准(t_check_standard)”为行来源,排除按天(period_type=1)的保养,
- 即使该标准尚未执行任何任务也会显示一行(月份不打勾);
- 当年某设备每月只要有已完成(status=3)的保养任务则该月打勾√ -->
- <select id="selectAnnualPlan" parameterType="com.platform.dao.dto.check.CheckJobDTO"
- resultType="com.platform.dao.vo.query.check.CheckJobAnnualPlanVO">
- select
- sbtype.name as category,
- sbinfo.name as sbName,
- <!-- 保养负责人与任务生成逻辑保持一致:
- 1-使用人取设备保管人(save_user),2-维修人取设备第一维修人(repair_user),
- 3-指定取标准上已绑定的人(保存时=维修人),4-班组取部门 -->
- case standard.check_user_type
- when 1 then su_save.real_name
- when 2 then su_repair.real_name
- when 3 then coalesce(su.real_name, su_repair.real_name)
- when 4 then sdept.name
- else coalesce(su.real_name, sdept.name)
- end as owner,
- count(distinct sbinfo.id) as sbNum,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 1 then '√' else '' end) as month1,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 2 then '√' else '' end) as month2,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 3 then '√' else '' end) as month3,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 4 then '√' else '' end) as month4,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 5 then '√' else '' end) as month5,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 6 then '√' else '' end) as month6,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 7 then '√' else '' end) as month7,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 8 then '√' else '' end) as month8,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 9 then '√' else '' end) as month9,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 10 then '√' else '' end) as month10,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 11 then '√' else '' end) as month11,
- max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 12 then '√' else '' end) as month12
- from t_check_standard standard
- inner join t_sb_info sbinfo on sbinfo.id = standard.sb_id
- left join t_sb_type sbtype on sbtype.id = sbinfo.type_id
- left join t_sys_user su on standard.check_user_id = su.user_id
- left join t_sys_dept sdept on standard.check_dept_id = sdept.dept_id
- left join t_sys_user su_save on sbinfo.save_user = su_save.user_id
- left join t_sys_user su_repair on sbinfo.repair_user = su_repair.user_id
- left join t_check_job job on job.standard_id = standard.id
- and job.status = 3
- <if test="searchYear != null">
- and year(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = #{searchYear}
- </if>
- <where>
- standard.period_type != 1
- <if test="type != null">
- and standard.type = #{type}
- </if>
- </where>
- group by sbtype.name, sbinfo.name,
- case standard.check_user_type
- when 1 then su_save.real_name
- when 2 then su_repair.real_name
- when 3 then coalesce(su.real_name, su_repair.real_name)
- when 4 then sdept.name
- else coalesce(su.real_name, sdept.name)
- end
- order by sbtype.name asc, sbinfo.name asc
- </select>
- </mapper>
|