GxtMonthRepairProjectMapper.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ygtx.gxt.mapper.GxtMonthRepairProjectMapper">
  6. <resultMap type="GxtMonthRepairProject" id="GxtMonthRepairProjectResult">
  7. <result property="id" column="id"/>
  8. <result property="monthScoreId" column="month_score_id"/>
  9. <result property="deptId" column="dept_id"/>
  10. <result property="deptName" column="dept_name"/>
  11. <result property="maintenanceType" column="maintenance_type"/>
  12. <result property="orderCount" column="order_count"/>
  13. <result property="projectScore" column="project_score"/>
  14. <result property="calculatedScore" column="calculated_score"/>
  15. <result property="monthPeriod" column="month_period"/>
  16. </resultMap>
  17. <sql id="selectGxtMonthRepairProjectVo">
  18. select id, month_score_id, dept_id, dept_name, maintenance_type, order_count, project_score, calculated_score, month_period from gxt_month_repair_project
  19. </sql>
  20. <select id="selectGxtMonthRepairProjectList" parameterType="GxtMonthRepairProject" resultMap="GxtMonthRepairProjectResult">
  21. <include refid="selectGxtMonthRepairProjectVo"/>
  22. <where>
  23. <if test="monthScoreId != null "> and month_score_id = #{monthScoreId}</if>
  24. <if test="deptId != null "> and dept_id = #{deptId}</if>
  25. <if test="deptName != null and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
  26. <if test="maintenanceType != null "> and maintenance_type = #{maintenanceType}</if>
  27. <if test="orderCount != null "> and order_count = #{orderCount}</if>
  28. <if test="projectScore != null "> and project_score = #{projectScore}</if>
  29. <if test="calculatedScore != null "> and calculated_score = #{calculatedScore}</if>
  30. <if test="monthPeriod != null and monthPeriod != ''"> and month_period = #{monthPeriod}</if>
  31. </where>
  32. </select>
  33. <select id="selectGxtMonthRepairProjectListByTwice" parameterType="GxtMonthRepairProject" resultMap="GxtMonthRepairProjectResult">
  34. SELECT
  35. maintenance_type,
  36. count(*) AS order_count
  37. FROM
  38. gxt_repair_order
  39. <where>
  40. <if test="deptId != null "> and pcs_station_pid = #{deptId}</if>
  41. <if test="monthPeriod != null and monthPeriod != ''"> and DATE_FORMAT( occur_time, '%Y-%m' ) = #{monthPeriod}</if>
  42. AND maintenance_type IS NOT NULL AND work_order_status = 'archived'
  43. </where>
  44. GROUP BY
  45. maintenance_type
  46. ORDER BY
  47. maintenance_type
  48. </select>
  49. <select id="selectGxtMonthRepairProjectListByAdd" parameterType="GxtMonthRepairProject" resultMap="GxtMonthRepairProjectResult">
  50. SELECT
  51. sp.maintenance_type,
  52. COUNT(ro.id) AS order_count,
  53. sp.score_per_completion AS project_score,
  54. sp.score_per_completion*COUNT(ro.id) AS calculated_score
  55. FROM
  56. gxt_repair_order ro
  57. LEFT JOIN gxt_score_project sp ON ro.maintenance_type = sp.maintenance_type AND sp.status = 0
  58. LEFT JOIN sys_user u ON ro.accept_user_id = u.user_id
  59. WHERE
  60. u.dept_id = #{deptId}
  61. AND (ro.work_order_status='archived' or ro.scoring_status='to_archive')
  62. AND ro.occur_time >= STR_TO_DATE(CONCAT(#{monthPeriod}, '-01 00:00:00'), '%Y-%m-%d %H:%i:%s')
  63. AND ro.occur_time <![CDATA[<]]> DATE_ADD(STR_TO_DATE(CONCAT(#{monthPeriod}, '-01 00:00:00'), '%Y-%m-%d %H:%i:%s'), INTERVAL 1 MONTH)
  64. AND (ro.repair_method IS NULL OR ro.repair_method != '2')
  65. GROUP BY
  66. sp.id
  67. </select>
  68. <select id="selectGxtMonthRepairProjectById" parameterType="Long" resultMap="GxtMonthRepairProjectResult">
  69. <include refid="selectGxtMonthRepairProjectVo"/>
  70. where id = #{id}
  71. </select>
  72. <insert id="insertGxtMonthRepairProject" parameterType="GxtMonthRepairProject" useGeneratedKeys="true" keyProperty="id">
  73. insert into gxt_month_repair_project
  74. <trim prefix="(" suffix=")" suffixOverrides=",">
  75. <if test="monthScoreId != null">month_score_id,</if>
  76. <if test="deptId != null">dept_id,</if>
  77. <if test="deptName != null and deptName != ''">dept_name,</if>
  78. <if test="maintenanceType != null">maintenance_type,</if>
  79. <if test="orderCount != null">order_count,</if>
  80. <if test="projectScore != null">project_score,</if>
  81. <if test="calculatedScore != null">calculated_score,</if>
  82. <if test="monthPeriod != null and monthPeriod != ''">month_period,</if>
  83. </trim>
  84. <trim prefix="values (" suffix=")" suffixOverrides=",">
  85. <if test="monthScoreId != null">#{monthScoreId},</if>
  86. <if test="deptId != null">#{deptId},</if>
  87. <if test="deptName != null and deptName != ''">#{deptName},</if>
  88. <if test="maintenanceType != null">#{maintenanceType},</if>
  89. <if test="orderCount != null">#{orderCount},</if>
  90. <if test="projectScore != null">#{projectScore},</if>
  91. <if test="calculatedScore != null">#{calculatedScore},</if>
  92. <if test="monthPeriod != null and monthPeriod != ''">#{monthPeriod},</if>
  93. </trim>
  94. </insert>
  95. <update id="updateGxtMonthRepairProject" parameterType="GxtMonthRepairProject">
  96. update gxt_month_repair_project
  97. <trim prefix="SET" suffixOverrides=",">
  98. <if test="monthScoreId != null">month_score_id = #{monthScoreId},</if>
  99. <if test="deptId != null">dept_id = #{deptId},</if>
  100. <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
  101. <if test="maintenanceType != null">maintenance_type = #{maintenanceType},</if>
  102. <if test="orderCount != null">order_count = #{orderCount},</if>
  103. <if test="projectScore != null">project_score = #{projectScore},</if>
  104. <if test="calculatedScore != null">calculated_score = #{calculatedScore},</if>
  105. <if test="monthPeriod != null and monthPeriod != ''">month_period = #{monthPeriod},</if>
  106. </trim>
  107. where id = #{id}
  108. </update>
  109. <delete id="deleteGxtMonthRepairProjectById" parameterType="Long">
  110. delete from gxt_month_repair_project where id = #{id}
  111. </delete>
  112. <delete id="deleteGxtMonthRepairProjectByIds" parameterType="Long">
  113. delete from gxt_month_repair_project where id in
  114. <foreach item="id" collection="array" open="(" separator="," close=")">
  115. #{id}
  116. </foreach>
  117. </delete>
  118. </mapper>