| | |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | <result column="distribute_user_name" property="distributeUserName"/> |
| | | <result column="distribute_dept_name" property="distributeDeptName"/> |
| | | <result column="patrol_task_name" property="patrolTaskName"/> |
| | | <result column="attachment_type" property="attachmentType"/> |
| | | <result column="event_name" property="eventName"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="gdTaskResultExcelResultMap" type="org.sxkj.gd.workorder.excel.GdTaskResultExcel"> |
| | |
| | | |
| | | |
| | | <select id="selectGdTaskResultPage" resultMap="gdTaskResultResultMap"> |
| | | select * from ja_gd_task_result where is_deleted = 0 |
| | | SELECT tr.*, pt.patrol_task_name FROM ja_gd_task_result tr |
| | | INNER JOIN ja_gd_patrol_task pt ON pt.id = tr.patrol_task_id AND pt.is_deleted = 0 |
| | | <if test="gdTaskResult.workOrderId != null"> |
| | | INNER JOIN ja_gd_work_order wo ON wo.id = pt.work_order_id AND wo.is_deleted = 0 |
| | | </if> |
| | | WHERE tr.is_deleted = 0 |
| | | <if test="gdTaskResult.workOrderId != null"> |
| | | AND wo.id = #{gdTaskResult.workOrderId} |
| | | </if> |
| | | <if test="gdTaskResult.patrolTaskIds != null and gdTaskResult.patrolTaskIds.size() > 0"> |
| | | AND tr.patrol_task_id IN |
| | | <foreach collection="gdTaskResult.patrolTaskIds" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | <if test="gdTaskResult.patrolTaskName != null and gdTaskResult.patrolTaskName != ''"> |
| | | AND pt.patrol_task_name LIKE concat('%', #{gdTaskResult.patrolTaskName}, '%') |
| | | </if> |
| | | <if test="gdTaskResult.resultCode != null and gdTaskResult.resultCode != ''"> |
| | | AND tr.result_code LIKE concat('%', #{gdTaskResult.resultCode}, '%') |
| | | </if> |
| | | <if test="gdTaskResult.distributeStatus != null"> |
| | | AND tr.distribute_status = #{gdTaskResult.distributeStatus} |
| | | </if> |
| | | <if test="gdTaskResult.areaCode != null and gdTaskResult.areaCode != ''"> |
| | | AND tr.area_code = #{gdTaskResult.areaCode} |
| | | </if> |
| | | <if test="gdTaskResult.createDept != null"> |
| | | AND tr.create_dept = #{gdTaskResult.createDept} |
| | | </if> |
| | | <if test="gdTaskResult.createUser != null"> |
| | | AND tr.create_user = #{gdTaskResult.createUser} |
| | | </if> |
| | | <if test="gdTaskResult.attachmentType != null"> |
| | | AND tr.attachment_type = #{gdTaskResult.attachmentType} |
| | | </if> |
| | | ORDER BY tr.create_time DESC |
| | | </select> |
| | | |
| | | <select id="selectGdTaskResultListByPatrolTaskId" resultMap="gdTaskResultResultMap"> |
| | | SELECT tr.*, |
| | | COALESCE(bu.real_name, bu.name) as distribute_user_name, |
| | | bd.dept_name as distribute_dept_name |
| | | FROM ja_gd_task_result tr |
| | | LEFT JOIN (SELECT * |
| | | FROM ja_gd_clue_event ce1 |
| | | WHERE ce1.is_deleted = 0 |
| | | AND ce1.create_time = (SELECT MAX(create_time) |
| | | FROM ja_gd_clue_event ce2 |
| | | WHERE ce2.result_id = ce1.result_id |
| | | AND ce2.is_deleted = 0)) ce ON ce.result_id = tr.id |
| | | LEFT JOIN blade_user bu ON bu.id = ce.create_user AND bu.is_deleted = 0 |
| | | LEFT JOIN blade_dept bd ON bd.id = ce.create_dept AND bd.is_deleted = 0 |
| | | WHERE tr.is_deleted = 0 |
| | | SELECT |
| | | tr.*, |
| | | COALESCE ( bu.real_name, bu.NAME ) AS distribute_user_name, |
| | | bd.dept_name AS distribute_dept_name, |
| | | ce.event_name |
| | | FROM |
| | | ja_gd_task_result tr |
| | | LEFT JOIN ( |
| | | SELECT |
| | | * |
| | | FROM |
| | | ja_gd_clue_event ce1 |
| | | WHERE |
| | | ce1.is_deleted = 0 |
| | | AND ce1.create_time = ( SELECT MAX( create_time ) FROM ja_gd_clue_event ce2 WHERE CAST(ce2.result_id AS VARCHAR) = CAST(ce1.result_id AS VARCHAR) AND ce2.is_deleted = 0 ) |
| | | ) ce ON CAST(ce.result_id AS VARCHAR) = CAST(tr.id AS VARCHAR) |
| | | LEFT JOIN blade_user bu ON CAST(bu.id AS VARCHAR) = CAST(ce.create_user AS VARCHAR) |
| | | AND bu.is_deleted = 0 |
| | | LEFT JOIN blade_dept bd ON CAST(bd.id AS VARCHAR) = CAST(ce.create_dept AS VARCHAR) |
| | | AND bd.is_deleted = 0 |
| | | WHERE |
| | | tr.is_deleted = 0 |
| | | AND tr.patrol_task_id = #{patrolTaskId} |
| | | <if test="attachmentTypes != null and attachmentTypes.size() > 0"> |
| | | AND tr.attachment_type IN |
| | | <foreach collection="attachmentTypes" item="type" open="(" separator="," close=")"> |
| | | #{type} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | |
| | | SELECT * FROM ja_gd_task_result ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | <!-- 根据ID更新成果信息(更新所有字段) --> |
| | | <update id="updateTaskResultById"> |
| | | UPDATE ja_gd_task_result |
| | | SET patrol_task_id = #{patrolTaskId}, |
| | | result_code = #{resultCode}, |
| | | result_url = #{resultUrl}, |
| | | shoot_time = #{shootTime}, |
| | | photo_data = CAST(#{photoData} AS JSONB), |
| | | longitude = #{longitude}, |
| | | latitude = #{latitude}, |
| | | distribute_status = #{distributeStatus}, |
| | | area_code = #{areaCode}, |
| | | update_user = #{updateUser}, |
| | | update_time = #{updateTime}, |
| | | status = #{status}, |
| | | is_deleted = #{isDeleted} |
| | | WHERE id = #{id} |
| | | </update> |
| | | |
| | | <!-- 批量插入成果信息 --> |
| | | <insert id="insertBatch" parameterType="java.util.List"> |
| | | INSERT INTO ja_gd_task_result ( |
| | | patrol_task_id, result_code, result_url, shoot_time, |
| | | photo_data, longitude, latitude, distribute_status, area_code, |
| | | create_user, create_dept, create_time, update_user, update_time, |
| | | status, is_deleted, attachment_type, geojson |
| | | ) VALUES |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.patrolTaskId}, #{item.resultCode}, #{item.resultUrl}, #{item.shootTime}, |
| | | CASE WHEN #{item.photoData} IS NULL THEN NULL ELSE CAST(#{item.photoData} AS JSONB) END, #{item.longitude}, #{item.latitude}, #{item.distributeStatus}, #{item.areaCode}, |
| | | #{item.createUser}, #{item.createDept}, #{item.createTime}, #{item.updateUser}, #{item.updateTime}, |
| | | #{item.status}, #{item.isDeleted}, #{item.attachmentType}, #{item.geojson} |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |