123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- <?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.zhyc.xps.aqpt.mapper.CheckDefMapper">
- <resultMap id="CheckDefDtoMap" type="com.zhyc.xps.aqpt.dto.CheckDefDto">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
- <result column="oc_name" property="ocName" jdbcType="VARCHAR" />
- <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" /><!--risk point ID-->
- <result column="risk_point_title" property="riskPointTitle" jdbcType="VARCHAR" />
- <result column="check_def_id" property="checkDefId" jdbcType="BIGINT" /><!--ID-->
- <result column="check_cat_id" property="checkCatId" jdbcType="BIGINT" />
- <result column="check_cat_title" property="checkCatTitle" jdbcType="VARCHAR" />
- <result column="check_title" property="checkTitle" jdbcType="VARCHAR" />
- <result column="check_desc" property="checkDesc" jdbcType="VARCHAR" />
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
- <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="position_id" property="positionId" jdbcType="BIGINT" />
- <result column="position_name" property="positionName" jdbcType="VARCHAR" />
- <result column="account_id" property="accountId" jdbcType="BIGINT" />
- <result column="account_name" property="accountName" jdbcType="VARCHAR" />
- <result column="check_count" property="checkCount" jdbcType="BIGINT" />
- <result column="def_start_date" property="defStartDate" jdbcType="DATE" />
- <result column="def_end_date" property="defEndDate" jdbcType="DATE" />
- <result column="is_shared" property="isShared" jdbcType="BIGINT" />
- <result column="status" property="status" jdbcType="BIGINT" />
- <result column="job_id" property="jobId" jdbcType="BIGINT" />
- <result column="cycle_title" property="cycleTitle" jdbcType="VARCHAR" />
- <result column="last_cycle_start_time" property="lastCycleStartTime" jdbcType="TIMESTAMP"/>
- <result column="last_cycle_end_time" property="lastCycleEndTime" jdbcType="TIMESTAMP"/>
- </resultMap>
- <sql id="CheckDefDto_Cols">
- A.oc_id,
- O.oc_name,
- A.risk_point_id,
- D.risk_point_title,
- A.check_def_id,
- A.check_cat_id,
- B.check_cat_title,
- A.check_desc,
- A.check_title,
- A.checklist_id,
- C.checklist_title,
- A.group_id,
- A.group_name,
- A.position_id,
- A.position_name,
- A.account_id,
- A.account_name,
- A.check_count,
- A.def_start_date,
- A.def_end_date,
- A.is_shared,
- A.status,
- A.job_id,
- J.cycle_title,
- A.last_cycle_start_time,
- A.last_cycle_end_time
- </sql>
- <!--基于ID查询-->
- <select id="getById" resultMap="CheckDefDtoMap">
- SELECT
- <include refid="CheckDefDto_Cols"/>
- FROM check_def AS A
- LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id)
- LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
- LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
- LEFT JOIN job AS J ON (A.job_id = J.job_id)
- LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
- WHERE A.oc_id = #{ocId ,jdbcType=BIGINT}
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- AND A.check_def_id = #{checkDefId ,jdbcType=BIGINT}
- </select>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="CheckDefDtoMap">
- SELECT
- <include refid="CheckDefDto_Cols"/>
- FROM check_def AS A
- LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id)
- LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
- LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
- LEFT JOIN job AS J ON (A.job_id = J.job_id)
- LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="riskPointId !=null">
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="checkCatId != null">
- AND A.check_cat_id = #{checkCatId, jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checkListId, jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.check_title like "%"#{keywords}"%"
- </if>
- <if test="checkTypeId != null">
- AND A.check_type_id = #{checkTypeId ,jdbcType=BIGINT}
- </if>
- <if test="jobId != null">
- AND A.job_id = #{jobId,jdbcType=BIGINT}
- </if>
- <if test="isShared != null">
- AND A.is_shared = #{isShared ,jdbcType=BIGINT}
- </if>
- <if test="status != null">
- AND A.status = #{status ,jdbcType=BIGINT}
- </if>
- ORDER BY A.created_at DESC
- </select>
- <!--分页查询-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="CheckDefDtoMap">
- SELECT
- <include refid="CheckDefDto_Cols"/>
- FROM check_def AS A
- LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id)
- LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
- LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
- LEFT JOIN job AS J ON (A.job_id = J.job_id)
- LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="riskPointId !=null">
- AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="checkCatId != null">
- AND A.check_cat_id = #{checkCatId, jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.check_title like "%"#{keywords}"%"
- </if>
- <if test="checkTypeId != null">
- AND A.check_type_id = #{checkTypeId ,jdbcType=BIGINT}
- </if>
- <if test="checkLevelId != null">
- AND A.check_level_id = #{checkLevelId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checkListId, jdbcType=BIGINT}
- </if>
- <if test="isShared != null">
- AND A.is_shared = #{isShared ,jdbcType=BIGINT}
- </if>
- <if test="jobId != null">
- AND A.job_id = #{jobId,jdbcType=BIGINT}
- </if>
- <if test="status != null">
- AND A.status = #{status ,jdbcType=BIGINT}
- </if>
- ORDER BY A.created_at DESC
- </select>
- <!--Create-->
- <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.CheckDef">
- INSERT INTO check_def
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="riskPointId != null">
- risk_point_id,
- </if>
- <if test="checkDefId != null">
- check_def_id,
- </if>
- <if test="checkCatId != null">
- check_cat_id,
- </if>
- <if test="checkTitle != null and checkTitle!=''">
- check_title,
- </if>
- <if test="checkDesc != null and checkDesc != ''">
- check_desc,
- </if>
- <if test="checklistId != null">
- checklist_id,
- </if>
- <if test="groupId != null">
- group_id,
- </if>
- <if test="groupName != null and groupName!=''">
- group_name,
- </if>
- <if test="positionId != null">
- position_id,
- </if>
- <if test="positionName != null and positionName!=''">
- position_name,
- </if>
- <if test="accountId != null">
- account_id,
- </if>
- <if test="accountName != null and accountName!=''">
- account_name,
- </if>
- <if test="checkCount != null">
- check_count,
- </if>
- <if test="defStartDate != null">
- def_start_date,
- </if>
- <if test="defEndDate != null">
- def_end_date,
- </if>
- <if test="isShared != null">
- is_shared,
- </if>
- <if test="status != null">
- status,
- </if>
- <if test="jobId != null">
- job_id,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId ,jdbcType=BIGINT},
- </if>
- <if test="riskPointId != null">
- #{riskPointId ,jdbcType=BIGINT},
- </if>
- <if test="checkDefId != null">
- #{checkDefId ,jdbcType=BIGINT},
- </if>
- <if test="checkCatId != null">
- #{checkCatId ,jdbcType=BIGINT},
- </if>
- <if test="checkTitle != null and checkTitle!=''">
- #{checkTitle, jdbcType=VARCHAR},
- </if>
- <if test="checkDesc != null and checkDesc != ''">
- #{checkDesc, jdbcType=VARCHAR},
- </if>
- <if test="checklistId != null">
- #{checklistId, jdbcType=BIGINT},
- </if>
- <if test="groupId != null">
- #{groupId, jdbcType=BIGINT},
- </if>
- <if test="groupName != null and groupName!=''">
- #{groupName, jdbcType=VARCHAR},
- </if>
- <if test="positionId != null">
- #{positionId, jdbcType=BIGINT},
- </if>
- <if test="positionName != null and positionName!=''">
- #{positionName ,jdbcType=VARCHAR},
- </if>
- <if test="accountId != null">
- #{accountId, jdbcType=BIGINT},
- </if>
- <if test="accountName != null and accountName!=''">
- #{accountName, jdbcType=VARCHAR},
- </if>
- <if test="checkCount != null">
- #{checkCount ,jdbcType=INTEGER},
- </if>
- <if test="defStartDate != null">
- #{defStartDate ,jdbcType=DATE},
- </if>
- <if test="defEndDate != null">
- #{defEndDate ,jdbcType=DATE},
- </if>
- <if test="isShared != null">
- #{isShared ,jdbcType=BIGINT},
- </if>
- <if test="status != null">
- #{status ,jdbcType=BIGINT},
- </if>
- <if test="jobId != null">
- #{jobId ,jdbcType=BIGINT},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--更新-->
- <update id="update" parameterType="com.zhyc.xps.aqpt.entity.CheckDef">
- UPDATE check_def
- <trim suffixOverrides=",">
- <set>
- <if test="checkCatId != null">
- check_cat_id = #{checkCatId ,jdbcType=BIGINT},
- </if>
- <if test="checkTitle != null">
- check_title =#{checkTitle ,jdbcType=VARCHAR},
- </if>
- <if test="checkDesc != null and checkDesc != ''">
- check_desc = #{checkDesc ,jdbcType=VARCHAR},
- </if>
- <if test="checklistId != null">
- checklist_id = #{checklistId ,jdbcType=BIGINT},
- </if>
- <if test="groupId != null">
- group_id = #{groupId ,jdbcType=BIGINT},
- </if>
- <if test="groupName != null and groupName!=''">
- group_name = #{groupName, jdbcType=VARCHAR},
- </if>
- <if test="positionId != null">
- position_id = #{positionId ,jdbcType=BIGINT},
- </if>
- <if test="positionName != null and positionName!=''">
- position_name = #{positionName ,jdbcType=VARCHAR},
- </if>
- <if test="accountId != null">
- account_id = #{accountId ,jdbcType=BIGINT},
- </if>
- <if test="accountName != null and accountName!=''">
- account_name = #{accountName, jdbcType=VARCHAR},
- </if>
- <if test="checkCount != null">
- check_count = #{checkCount ,jdbcType=INTEGER},
- </if>
- <if test="defStartDate != null">
- def_start_date = #{defStartDate ,jdbcType=DATE},
- </if>
- <if test="defEndDate != null">
- def_end_date = #{defEndDate ,jdbcType=DATE},
- </if>
- <if test="isShared != null">
- is_shared = #{isShared ,jdbcType=BIGINT},
- </if>
- <if test="status != null">
- status = #{status ,jdbcType=BIGINT},
- </if>
- <if test="jobId != null">
- job_id = #{jobId ,jdbcType=BIGINT},
- </if>
- <if test="lastCycleStartTime != null">
- last_cycle_start_time = #{lastCycleStartTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="lastCycleEndTime != null">
- last_cycle_end_time = #{lastCycleEndTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="updatedBy != null">
- updated_by = #{updatedBy ,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE oc_id = #{ocId ,jdbcType=BIGINT}
- AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- AND check_def_id = #{checkDefId ,jdbcType=BIGINT}
- </update>
- <!--更新Last Cycle Time-->
- <update id="updateLastCycleTime">
- UPDATE check_def
- <trim suffixOverrides=",">
- <set>
- <if test="lastCycleStartTime != null">
- last_cycle_start_time = #{lastCycleStartTime ,jdbcType=TIMESTAMP},
- </if>
- <if test="lastCycleEndTime != null">
- last_cycle_end_time = #{lastCycleEndTime ,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE deleted_flag = 0
- <if test="ocId != null">
- AND oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="checkDefId != null ">
- AND check_def_id = #{checkDefId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--删除 -->
- <update id="delete" parameterType="java.util.Map">
- UPDATE check_def
- <trim suffixOverrides=",">
- <set>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy ,jdbcType=BIGINT},
- </if>
- <if test="deletedAt != null">
- deleted_at = #{deletedAt ,jdbcType=DATE},
- </if>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE deleted_flag = 0
- <if test="ocId != null">
- AND oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="riskPointId != null">
- AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
- </if>
- <if test="checkDefId != null ">
- AND check_def_id = #{checkDefId ,jdbcType=BIGINT}
- </if>
- </update>
- <!--列表查询-->
- <select id="getPendingByList" parameterType="java.util.Map" resultMap="CheckDefDtoMap">
- SELECT
- <include refid="CheckDefDto_Cols"/>
- FROM check_def AS A
- LEFT JOIN check_cat AS B ON (A.oc_id = B.oc_id AND A.check_cat_id = B.check_cat_id )
- LEFT JOIN checklist AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id )
- LEFT JOIN ent_risk_point AS D ON (A.oc_id = D.oc_id AND A.risk_point_id = D.risk_point_id)
- LEFT JOIN job AS J ON (A.job_id = J.job_id)
- LEFT JOIN oc AS O ON (A.oc_id = O.oc_id)
- WHERE A.deleted_flag = 0 AND A.status = 1
- <![CDATA[
- AND (A.last_cycle_end_time <= now() OR A.last_cycle_end_time is null)
- AND (A.def_end_date >= DATE_FORMAT(NOW(),'%Y-%m-%d'))
- ]]>
- <if test="jobId != null">
- AND A.job_id = #{jobId,jdbcType=BIGINT}
- </if>
- ORDER BY A.check_def_id
- </select>
- </mapper>
|