| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <?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.repair.RepairApplicationFormMapper">
- <sql id="Base_Column_List">
- application.*,
- user.real_name as userName,
- user2.real_name as repairUserName,
- user3.real_name as checkUserName,
- sb.name as sbName,part.name as partName,
- sb.no as sbNo, sb.cph as sbCph, sb.model_id as modelId,
- error.name as repairErrorTypeName,
- dept.name as deptName
- </sql>
- <select id="selectPageList" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
- resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
- select
- <include refid="Base_Column_List"/>,
- user4.real_name as repairUser,sbPos.name as positionName,
- part.name as partName,userSecond.real_name as secondRepairUserName,
- userThree.real_name as threeRepairUserName,userFour.real_name as fourRepairUserName
- from t_repair_application_form application
- left join t_sys_user user on application.user_id = user.user_id
- left join t_sys_user user2 on application.repair_user_id = user2.user_id
- left join t_sys_user user3 on application.check_user_id = user3.user_id
- left join t_sys_user userSecond on application.second_repair_user = userSecond.user_id
- left join t_sys_user userThree on application.three_repair_user = userThree.user_id
- left join t_sys_user userFour on application.four_repair_user = userFour.user_id
- left join t_sb_info sb on application.sb_id = sb.id
- left join t_sb_position sbPos on sbPos.id = sb.position_id
- left join t_sys_user user4 on sb.repair_user = user4.user_id
- left join t_error_type error on application.repair_error_type_id = error.id
- left join t_part_info part on application.part_id = part.id
- left join t_sys_dept dept on application.dept_id = dept.dept_id
- <where>
- <if test="keyword != null and keyword != ''">
- and (
- application.no like concat('%',#{keyword},'%') or
- application.content like concat('%',#{keyword},'%') or
- application.remark like concat('%',#{keyword},'%') or
- application.repair_content like concat('%',#{keyword},'%') or
- application.check_content like concat('%',#{keyword},'%') or
- application.examine_content like concat('%',#{keyword},'%') or
- application.refuse_remark like concat('%',#{keyword},'%') or
- application.repair_dispatch_remark like concat('%',#{keyword},'%') or
- application.actual_user like concat('%',#{keyword},'%') or
- application.out_no like concat('%',#{keyword},'%') or
- sb.name like concat('%',#{keyword},'%') or
- sb.no like concat('%',#{keyword},'%') or
- sb.cph like concat('%',#{keyword},'%') or
- sbPos.name like concat('%',#{keyword},'%') or
- error.name like concat('%',#{keyword},'%') or
- part.name like concat('%',#{keyword},'%') or
- user.real_name like concat('%',#{keyword},'%') or
- user2.real_name like concat('%',#{keyword},'%') or
- user3.real_name like concat('%',#{keyword},'%') or
- user4.real_name like concat('%',#{keyword},'%') or
- userSecond.real_name like concat('%',#{keyword},'%') or
- userThree.real_name like concat('%',#{keyword},'%') or
- userFour.real_name like concat('%',#{keyword},'%')
- )
- </if>
- <if test="content != null and content != ''">
- and application.content like concat('%',#{content},'%')
- </if>
- <if test="sbId != null and sbId != ''">
- and application.sb_id = #{sbId}
- </if>
- <if test="category != null and category != ''">
- and application.category = #{category}
- </if>
- <if test="categoryList != null and categoryList.size > 0">
- AND application.category in
- <foreach item="item" index="index" collection="categoryList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="zbh != null and zbh != ''">
- and sb.zbh = #{zbh}
- </if>
- <if test="no != null and no != ''">
- and application.no = #{no}
- </if>
- <if test="planFlag != null and planFlag != ''">
- and application.plan_flag = #{planFlag}
- </if>
- <if test="status != null and status != ''">
- and application.status = #{status}
- </if>
- <if test="statusList != null and statusList.size > 0">
- and application.status in
- <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="actualUser != null and actualUser != ''">
- and application.actual_user = #{actualUser}
- </if>
- <if test="mainRepairId != null and mainRepairId != ''">
- and application.main_repair_id = #{mainRepairId}
- </if>
- <if test="outType != null and outType != ''">
- and application.out_type = #{outType}
- </if>
- <if test="type != null and type != ''">
- and application.type = #{type}
- </if>
- <if test="userId != null and userId != ''">
- and application.user_id = #{userId}
- </if>
- <if test="repairUserId != null and repairUserId != ''">
- <if test="repairUserIdOrNoAssignFlag != null and repairUserIdOrNoAssignFlag == true">
- and (application.repair_user_id = #{repairUserId} or application.repair_user_id is null)
- </if>
- <if test="repairUserIdOrNoAssignFlag == null || repairUserIdOrNoAssignFlag == false">
- and (application.repair_user_id = #{repairUserId} or application.second_repair_user = #{repairUserId} or application.three_repair_user = #{repairUserId} or application.four_repair_user = #{repairUserId})
- </if>
- </if>
- <if test="checkUserId != null and checkUserId != ''">
- and application.check_user_id = #{checkUserId}
- </if>
- <if test="repairUserName != null and repairUserName != ''">
- and user2.real_name like concat('%',#{repairUserName},'%')
- </if>
- <if test="searchStartTime != null">
- and application.apply_time <![CDATA[ >= ]]> #{searchStartTime}
- </if>
- <if test="searchEndTime != null">
- and application.apply_time <![CDATA[ <= ]]> #{searchEndTime}
- </if>
- <if test="deptId != null and deptId != ''">
- and application.dept_id = #{deptId}
- </if>
- <if test="deptIdList != null and deptIdList.size > 0">
- AND application.dept_id in
- <foreach item="item" index="index" collection="deptIdList" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectById" parameterType="java.lang.Object"
- resultType="com.platform.dao.entity.repair.RepairApplicationForm">
- select
- <include refid="Base_Column_List"/>
- from t_repair_application_form application
- left join t_sys_user user on application.user_id = user.user_id
- left join t_sys_user user2 on application.repair_user_id = user2.user_id
- left join t_sys_user user3 on application.check_user_id = user3.user_id
- left join t_sb_info sb on application.sb_id = sb.id
- left join t_part_info part on application.part_id = part.id
- left join t_error_type error on application.repair_error_type_id = error.id
- left join t_sys_dept dept on application.dept_id = dept.dept_id
- where application.id = #{id,jdbcType=VARCHAR}
- </select>
- <select id="selectNoById" parameterType="java.lang.Object" resultType="java.lang.String">
- select no
- from t_repair_application_form
- where id = #{id,jdbcType=VARCHAR}
- </select>
- <!-- 查询存在指定状态报修单的设备ID(用于排除审核中工单的设备) -->
- <select id="selectSbIdsWithStatus" resultType="java.lang.String">
- SELECT DISTINCT application.sb_id
- FROM t_repair_application_form application
- <where>
- <if test="sbIds != null and sbIds.size > 0">
- AND application.sb_id IN
- <foreach item="item" index="index" collection="sbIds" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="status != null and status.size > 0">
- AND application.status IN
- <foreach item="item" index="index" collection="status" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <!-- 维修工时统计:按维修人分组,统计维修结束时间不为空的报修单 -->
- <select id="statisticsWorkHourByUser" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
- resultType="com.platform.dao.vo.report.RepairWorkHourReportVO">
- select application.repair_user_id as repairUserId,
- user2.real_name as repairUserName,
- count(1) as num,
- IFNULL(sum(application.repair_minutes), 0) as totalRepairHours,
- IFNULL(avg(application.repair_minutes), 0) as avgRepairHours,
- IFNULL(sum(application.deal_minutes), 0) as totalDealHours
- from t_repair_application_form application
- left join t_sys_user user2 on application.repair_user_id = user2.user_id
- <where>
- application.repair_end_time is not null
- and application.repair_user_id is not null and application.repair_user_id != ''
- <if test="repairUserId != null and repairUserId != ''">
- and application.repair_user_id = #{repairUserId}
- </if>
- <if test="repairUserName != null and repairUserName != ''">
- and user2.real_name like concat('%',#{repairUserName},'%')
- </if>
- <if test="searchRepairStartTime != null">
- and application.repair_start_time <![CDATA[ >= ]]> #{searchRepairStartTime}
- </if>
- <if test="searchRepairEndTime != null">
- and application.repair_start_time <![CDATA[ <= ]]> #{searchRepairEndTime}
- </if>
- </where>
- group by application.repair_user_id
- order by totalRepairHours desc
- </select>
- <!-- 维修工时统计:按设备分组,统计维修结束时间不为空的报修单 -->
- <select id="statisticsWorkHourBySb" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
- resultType="com.platform.dao.vo.report.RepairWorkHourReportVO">
- select application.sb_id as sbId,
- sb.no as sbNo,
- sb.name as sbName,
- sbType.name as sbTypeName,
- count(1) as num,
- IFNULL(sum(application.repair_minutes), 0) as totalRepairHours,
- IFNULL(avg(application.repair_minutes), 0) as avgRepairHours,
- IFNULL(sum(application.deal_minutes), 0) as totalDealHours
- from t_repair_application_form application
- left join t_sb_info sb on application.sb_id = sb.id
- left join t_sb_type sbType on sb.type_id = sbType.id
- <where>
- application.repair_end_time is not null
- and application.sb_id is not null and application.sb_id != ''
- <if test="sbId != null and sbId != ''">
- and application.sb_id = #{sbId}
- </if>
- <if test="keyword != null and keyword != ''">
- and (sb.name like concat('%',#{keyword},'%') or sb.no like concat('%',#{keyword},'%'))
- </if>
- <if test="searchRepairStartTime != null">
- and application.repair_start_time <![CDATA[ >= ]]> #{searchRepairStartTime}
- </if>
- <if test="searchRepairEndTime != null">
- and application.repair_start_time <![CDATA[ <= ]]> #{searchRepairEndTime}
- </if>
- </where>
- group by application.sb_id
- order by totalRepairHours desc
- </select>
- <!-- 维修工时统计明细:某维修人或某设备已完成维修的报修单列表 -->
- <select id="selectWorkHourDetail" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
- resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
- select
- <include refid="Base_Column_List"/>
- from t_repair_application_form application
- left join t_sys_user user on application.user_id = user.user_id
- left join t_sys_user user2 on application.repair_user_id = user2.user_id
- left join t_sys_user user3 on application.check_user_id = user3.user_id
- left join t_sb_info sb on application.sb_id = sb.id
- left join t_part_info part on application.part_id = part.id
- left join t_error_type error on application.repair_error_type_id = error.id
- left join t_sys_dept dept on application.dept_id = dept.dept_id
- <where>
- application.repair_end_time is not null
- <if test="repairUserId != null and repairUserId != ''">
- and application.repair_user_id = #{repairUserId}
- </if>
- <if test="sbId != null and sbId != ''">
- and application.sb_id = #{sbId}
- </if>
- <if test="searchRepairStartTime != null">
- and application.repair_start_time <![CDATA[ >= ]]> #{searchRepairStartTime}
- </if>
- <if test="searchRepairEndTime != null">
- and application.repair_start_time <![CDATA[ <= ]]> #{searchRepairEndTime}
- </if>
- </where>
- order by application.repair_start_time desc
- </select>
- <select id="selectMaxNo" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO" resultType="String">
- SELECT max(SUBSTRING(no from 18 for 20 )) from t_repair_application_form
- <where>
- <if test="applyTimeStart != null">
- and apply_time <![CDATA[ > ]]> #{applyTimeStart}
- </if>
- <if test="applyTimeEnd != null">
- and apply_time <![CDATA[ < ]]> #{applyTimeEnd}
- </if>
- </where>
- </select>
- <!-- 维修工时统计:按月度统计所有设备的单次平均维修工时 -->
- <select id="statisticsWorkHourByMonth" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
- resultType="com.platform.dao.vo.report.RepairWorkHourReportVO">
- select application.sb_id as sbId,
- sb.no as sbNo,
- sb.name as sbName,
- sbType.name as sbTypeName,
- count(1) as num,
- IFNULL(sum(application.repair_minutes), 0) as totalRepairHours,
- IFNULL(avg(application.repair_minutes), 0) as avgRepairHours,
- IFNULL(sum(application.deal_minutes), 0) as totalDealHours
- from t_repair_application_form application
- left join t_sb_info sb on application.sb_id = sb.id
- left join t_sb_type sbType on sb.type_id = sbType.id
- <where>
- application.repair_end_time is not null
- and application.sb_id is not null and application.sb_id != ''
- <if test="sbId != null and sbId != ''">
- and application.sb_id = #{sbId}
- </if>
- <if test="keyword != null and keyword != ''">
- and (sb.name like concat('%',#{keyword},'%') or sb.no like concat('%',#{keyword},'%'))
- </if>
- <if test="searchRepairStartTime != null">
- and application.repair_start_time <![CDATA[ >= ]]> #{searchRepairStartTime}
- </if>
- <if test="searchRepairEndTime != null">
- and application.repair_start_time <![CDATA[ <= ]]> #{searchRepairEndTime}
- </if>
- </where>
- group by application.sb_id
- having totalRepairHours > 0
- order by totalRepairHours desc
- </select>
- </mapper>
|