From b3b17b231e2f2840332ce6eb96f791865fdec6d5 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 14 四月 2025 16:38:16 +0800 Subject: [PATCH] 代码优化 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeWorkOrderMapper.xml | 369 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 369 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeWorkOrderMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeWorkOrderMapper.xml new file mode 100644 index 0000000..2c29293 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeWorkOrderMapper.xml @@ -0,0 +1,369 @@ +<?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.dy.pipIrrGlobal.daoOp.OpeWorkOrderMapper"> + <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder"> + <!--@mbg.generated--> + <!--@Table ope_work_order--> + <id column="id" jdbcType="BIGINT" property="id" /> + <result column="dispatcher_id" jdbcType="BIGINT" property="dispatcherId" /> + <result column="inspector_id" jdbcType="BIGINT" property="inspectorId" /> + <result column="task_type_id" jdbcType="BIGINT" property="taskTypeId" /> + <result column="task_content" jdbcType="VARCHAR" property="taskContent" /> + <result column="complete_criteria" jdbcType="VARCHAR" property="completeCriteria" /> + <result column="dead_line" jdbcType="TIMESTAMP" property="deadLine" /> + <result column="complete_time" jdbcType="TIMESTAMP" property="completeTime" /> + <result column="dispatch_time" jdbcType="TIMESTAMP" property="dispatchTime" /> + <result column="client_report_id" jdbcType="BIGINT" property="clientReportId" /> + <result column="inspector_report_id" jdbcType="BIGINT" property="inspectorReportId" /> + <result column="state" jdbcType="TINYINT" property="state" /> + <result column="reject_times" jdbcType="INTEGER" property="rejectTimes" /> + <result column="deleted" jdbcType="BIGINT" property="deleted" /> + </resultMap> + <sql id="Base_Column_List"> + <!--@mbg.generated--> + id, dispatcher_id, inspector_id, task_type_id, task_content, complete_criteria, dead_line, + complete_time, dispatch_time, client_report_id, inspector_report_id, `state`, reject_times, + deleted + </sql> + <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> + <!--@mbg.generated--> + select + <include refid="Base_Column_List" /> + from ope_work_order + where id = #{id,jdbcType=BIGINT} + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> + <!--@mbg.generated--> + delete from ope_work_order + where id = #{id,jdbcType=BIGINT} + </delete> + <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder"> + <!--@mbg.generated--> + insert into ope_work_order (id, dispatcher_id, inspector_id, + task_type_id, task_content, complete_criteria, + dead_line, complete_time, dispatch_time, + client_report_id, inspector_report_id, `state`, + reject_times, deleted) + values (#{id,jdbcType=BIGINT}, #{dispatcherId,jdbcType=BIGINT}, #{inspectorId,jdbcType=BIGINT}, + #{taskTypeId,jdbcType=BIGINT}, #{taskContent,jdbcType=VARCHAR}, #{completeCriteria,jdbcType=VARCHAR}, + #{deadLine,jdbcType=TIMESTAMP}, #{completeTime,jdbcType=TIMESTAMP}, #{dispatchTime,jdbcType=TIMESTAMP}, + #{clientReportId,jdbcType=BIGINT}, #{inspectorReportId,jdbcType=BIGINT}, #{state,jdbcType=TINYINT}, + #{rejectTimes,jdbcType=INTEGER}, #{deleted,jdbcType=BIGINT}) + </insert> + <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder"> + <!--@mbg.generated--> + insert into ope_work_order + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + id, + </if> + <if test="dispatcherId != null"> + dispatcher_id, + </if> + <if test="inspectorId != null"> + inspector_id, + </if> + <if test="taskTypeId != null"> + task_type_id, + </if> + <if test="taskContent != null"> + task_content, + </if> + <if test="completeCriteria != null"> + complete_criteria, + </if> + <if test="deadLine != null"> + dead_line, + </if> + <if test="completeTime != null"> + complete_time, + </if> + <if test="dispatchTime != null"> + dispatch_time, + </if> + <if test="clientReportId != null"> + client_report_id, + </if> + <if test="inspectorReportId != null"> + inspector_report_id, + </if> + <if test="state != null"> + `state`, + </if> + <if test="rejectTimes != null"> + reject_times, + </if> + <if test="deleted != null"> + deleted, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=BIGINT}, + </if> + <if test="dispatcherId != null"> + #{dispatcherId,jdbcType=BIGINT}, + </if> + <if test="inspectorId != null"> + #{inspectorId,jdbcType=BIGINT}, + </if> + <if test="taskTypeId != null"> + #{taskTypeId,jdbcType=BIGINT}, + </if> + <if test="taskContent != null"> + #{taskContent,jdbcType=VARCHAR}, + </if> + <if test="completeCriteria != null"> + #{completeCriteria,jdbcType=VARCHAR}, + </if> + <if test="deadLine != null"> + #{deadLine,jdbcType=TIMESTAMP}, + </if> + <if test="completeTime != null"> + #{completeTime,jdbcType=TIMESTAMP}, + </if> + <if test="dispatchTime != null"> + #{dispatchTime,jdbcType=TIMESTAMP}, + </if> + <if test="clientReportId != null"> + #{clientReportId,jdbcType=BIGINT}, + </if> + <if test="inspectorReportId != null"> + #{inspectorReportId,jdbcType=BIGINT}, + </if> + <if test="state != null"> + #{state,jdbcType=TINYINT}, + </if> + <if test="rejectTimes != null"> + #{rejectTimes,jdbcType=INTEGER}, + </if> + <if test="deleted != null"> + #{deleted,jdbcType=BIGINT}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder"> + <!--@mbg.generated--> + update ope_work_order + <set> + <if test="dispatcherId != null"> + dispatcher_id = #{dispatcherId,jdbcType=BIGINT}, + </if> + <if test="inspectorId != null"> + inspector_id = #{inspectorId,jdbcType=BIGINT}, + </if> + <if test="taskTypeId != null"> + task_type_id = #{taskTypeId,jdbcType=BIGINT}, + </if> + <if test="taskContent != null"> + task_content = #{taskContent,jdbcType=VARCHAR}, + </if> + <if test="completeCriteria != null"> + complete_criteria = #{completeCriteria,jdbcType=VARCHAR}, + </if> + <if test="deadLine != null"> + dead_line = #{deadLine,jdbcType=TIMESTAMP}, + </if> + <if test="completeTime != null"> + complete_time = #{completeTime,jdbcType=TIMESTAMP}, + </if> + <if test="dispatchTime != null"> + dispatch_time = #{dispatchTime,jdbcType=TIMESTAMP}, + </if> + <if test="clientReportId != null"> + client_report_id = #{clientReportId,jdbcType=BIGINT}, + </if> + <if test="inspectorReportId != null"> + inspector_report_id = #{inspectorReportId,jdbcType=BIGINT}, + </if> + <if test="state != null"> + `state` = #{state,jdbcType=TINYINT}, + </if> + <if test="rejectTimes != null"> + reject_times = #{rejectTimes,jdbcType=INTEGER}, + </if> + <if test="deleted != null"> + deleted = #{deleted,jdbcType=BIGINT}, + </if> + </set> + where id = #{id,jdbcType=BIGINT} + </update> + <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder"> + <!--@mbg.generated--> + update ope_work_order + set dispatcher_id = #{dispatcherId,jdbcType=BIGINT}, + inspector_id = #{inspectorId,jdbcType=BIGINT}, + task_type_id = #{taskTypeId,jdbcType=BIGINT}, + task_content = #{taskContent,jdbcType=VARCHAR}, + complete_criteria = #{completeCriteria,jdbcType=VARCHAR}, + dead_line = #{deadLine,jdbcType=TIMESTAMP}, + complete_time = #{completeTime,jdbcType=TIMESTAMP}, + dispatch_time = #{dispatchTime,jdbcType=TIMESTAMP}, + client_report_id = #{clientReportId,jdbcType=BIGINT}, + inspector_report_id = #{inspectorReportId,jdbcType=BIGINT}, + `state` = #{state,jdbcType=TINYINT}, + reject_times = #{rejectTimes,jdbcType=INTEGER}, + deleted = #{deleted,jdbcType=BIGINT} + where id = #{id,jdbcType=BIGINT} + </update> + + <!--鏍规嵁涓婚敭鑾峰彇宸ュ崟瑙嗗浘瀵硅薄--> + <select id="getWorkOrderById" resultType="com.dy.pipIrrGlobal.voOp.VoWorkOrder"> + SELECT + ord.id AS workOrderId, + ord.dispatcher_id AS dispatcherId, + us1.name AS dispatcher, + ord.inspector_id AS inspectorId, + us2.name AS inspector, + typ.task_type AS taskType, + ord.task_content AS taskContent, + ord.complete_criteria AS completeCriteria, + ord.dead_line AS deadLine, + ord.client_report_id AS clientReportId, + ord.inspector_report_id AS inspectorReportId, + ord.complete_time AS completeTime, + ord.dispatch_time AS dispatchTime, + ord.reject_times AS rejectTimes, + res.id AS proResultId, + IFNULL(res.state,0) AS proResultStateId, + CASE + WHEN ord.state = 1 THEN '鏈畬鎴�' + WHEN ord.state = 2 THEN '宸插畬鎴�' + END AS state, + CASE + WHEN IFNULL(res.state,0) = 0 THEN '鏈笂鎶�' + WHEN res.state = 1 THEN '寰呭鏍�' + WHEN res.state = 2 THEN '宸查�氳繃' + WHEN res.state = 3 THEN '琚┏鍥�' + ELSE '鏈笂鎶�' + END AS processingState + FROM ope_work_order ord + INNER JOIN ba_user us1 ON us1.id = ord.dispatcher_id + INNER JOIN ba_user us2 ON us2.id = ord.inspector_id + INNER JOIN ope_task_type typ ON typ.id = ord.task_type_id + LEFT JOIN (SELECT * FROM `ope_processing_result` WHERE deleted = 0) res ON res.work_order_id = ord.id + WHERE ord.deleted = 0 AND ord.id = #{workOrderId} + </select> + + <!--鑾峰彇鎸囧畾娲惧崟浜虹殑銆佹湭涓婃姤鐨勬寚瀹氭湭鍒犻櫎宸ュ崟锛屽垹闄ゅ伐鍗曞墠鍒ゆ柇浣跨敤浣跨敤--> + <select id="getWorkOrder" resultType="com.dy.pipIrrGlobal.pojoOp.OpeWorkOrder"> + SELECT + * + FROM ope_work_order ord + WHERE deleted = 0 + AND NOT EXISTS(SELECT * FROM ope_processing_result res WHERE res.work_order_id = ord.id) + AND id = #{workOrderId} AND dispatcher_id = #{dispatcherId} LIMIT 1 + </select> + + <!--閫昏緫鍒犻櫎涓�涓湭鍒犻櫎鐨勫伐鍗�--> + <update id="deleteWorkOrder"> + UPDATE ope_work_order SET deleted = UNIX_TIMESTAMP() WHERE deleted = 0 AND id = #{workOrderId} + </update> + +<!-- 鏍规嵁鎸囧畾鏉′欢鑾峰彇宸ュ崟鏁伴噺--> + <select id="getWorkOrdersCount" resultType="java.lang.Long"> + select + COUNT(*) AS recordCount + FROM ope_work_order ord + INNER JOIN ba_user us1 ON us1.id = ord.dispatcher_id + INNER JOIN ba_user us2 ON us2.id = ord.inspector_id + INNER JOIN ope_task_type typ ON typ.id = ord.task_type_id + LEFT JOIN (SELECT * FROM `ope_processing_result` WHERE deleted = 0) res ON res.work_order_id = ord.id + <where> + AND ord.deleted = 0 + + <if test = "dispatcherId != null"> + AND ord.dispatcher_id = #{dispatcherId} + </if> + + <if test = "inspectorId != null"> + AND ord.inspector_id = #{inspectorId} + </if> + + <if test = "dispatcher != null and dispatcher !=''"> + AND us1.name like CONCAT('%',#{dispatcher},'%') + </if> + + <if test = "inspector != null and inspector !=''"> + AND us2.name like CONCAT('%',#{inspector},'%') + </if> + + <if test = "state != null"> + AND ord.state = #{state} + </if> + + <if test = "timeStart != null and timeStop != null"> + AND ord.dispatch_time BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + </select> + + <select id="getWorkOrders" resultType="com.dy.pipIrrGlobal.voOp.VoWorkOrder"> + SELECT + ord.id AS workOrderId, + ord.dispatcher_id AS dispatcherId, + us1.name AS dispatcher, + ord.inspector_id AS inspectorId, + us2.name AS inspector, + typ.task_type AS taskType, + ord.task_content AS taskContent, + ord.complete_criteria AS completeCriteria, + ord.dead_line AS deadLine, + ord.client_report_id AS clientReportId, + ord.inspector_report_id AS inspectorReportId, + ord.complete_time AS completeTime, + ord.dispatch_time AS dispatchTime, + ord.reject_times AS rejectTimes, + IFNULL(res.state,0) AS proResultStateId, + CASE + WHEN ord.state = 1 THEN '鏈畬鎴�' + WHEN ord.state = 2 THEN '宸插畬鎴�' + END AS state, + CASE + WHEN IFNULL(res.state,0) = 0 THEN '鏈笂鎶�' + WHEN res.state = 1 THEN '寰呭鏍�' + WHEN res.state = 2 THEN '宸查�氳繃' + WHEN res.state = 3 THEN '琚┏鍥�' + ELSE '鏈笂鎶�' + END AS processingState, + res.id AS proResultId + FROM ope_work_order ord + INNER JOIN ba_user us1 ON us1.id = ord.dispatcher_id + INNER JOIN ba_user us2 ON us2.id = ord.inspector_id + INNER JOIN ope_task_type typ ON typ.id = ord.task_type_id + LEFT JOIN (SELECT * FROM `ope_processing_result` WHERE deleted = 0) res ON res.work_order_id = ord.id + <where> + AND ord.deleted = 0 + + <if test = "dispatcherId != null"> + AND ord.dispatcher_id = #{dispatcherId} + </if> + + <if test = "inspectorId != null"> + AND ord.inspector_id = #{inspectorId} + </if> + + <if test = "dispatcher != null and dispatcher !=''"> + AND us1.name like CONCAT('%',#{dispatcher},'%') + </if> + + <if test = "inspector != null and inspector !=''"> + AND us2.name like CONCAT('%',#{inspector},'%') + </if> + + <if test = "state != null"> + AND ord.state = #{state} + </if> + + <if test = "timeStart != null and timeStop != null"> + AND ord.dispatch_time BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + ORDER BY ord.dispatch_time DESC + <trim prefix="limit " > + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + </select> +</mapper> \ No newline at end of file -- Gitblit v1.8.0