DetailsOfTheRefuelingPlanMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.zkqy.business.mapper.DetailsOfTheRefuelingPlanMapper">
  6. <resultMap type="com.zkqy.business.domain.DetailsOfTheRefuelingPlan" id="DetailsOfTheRefuelingPlanResult">
  7. <result property="id" column="id" />
  8. <result property="timestampRandomCode" column="timestamp_random_code" />
  9. <result property="macId" column="mac_id" />
  10. <result property="machineId" column="machine_id" />
  11. <result property="currentColorCode" column="current_color_code" />
  12. <result property="currentSpecification" column="current_specification" />
  13. <result property="currentLotNumber" column="current_lot_number" />
  14. <result property="currentSpindleCount" column="current_spindle_count" />
  15. <result property="startTime" column="start_time" />
  16. <result property="plannedEndTime" column="planned_end_time" />
  17. <result property="planStatus" column="plan_status" />
  18. <result property="number" column="number" />
  19. <result property="productType" column="productType" />
  20. <result property="productTypeName" column="productTypeName"/>
  21. </resultMap>
  22. <sql id="selectDetailsOfTheRefuelingPlanVo">
  23. select id, timestamp_random_code, mac_id,machine_id, current_color_code, current_specification, current_lot_number, current_spindle_count, start_time, planned_end_time,plan_status,number,productType,product_id,salesman_id,productTypeName from {DBNAME}.details_of_the_refueling_plan
  24. </sql>
  25. <select id="selectDetailsOfTheRefuelingPlanList" parameterType="com.zkqy.business.domain.DetailsOfTheRefuelingPlan" resultMap="DetailsOfTheRefuelingPlanResult">
  26. <include refid="selectDetailsOfTheRefuelingPlanVo"/>
  27. <where>
  28. <if test="timestampRandomCode != null and timestampRandomCode != ''"> and timestamp_random_code = #{timestampRandomCode}</if>
  29. <if test="macId != null "> and mac_id = #{macId}</if>
  30. <if test="machineId != null "> and machine_id = #{machineId}</if>
  31. <if test="currentColorCode != null and currentColorCode != ''"> and current_color_code = #{currentColorCode}</if>
  32. <if test="currentSpecification != null and currentSpecification != ''"> and current_specification = #{currentSpecification}</if>
  33. <if test="currentLotNumber != null "> and current_lot_number = #{currentLotNumber}</if>
  34. <if test="currentSpindleCount != null and currentSpindleCount != ''"> and current_spindle_count = #{currentSpindleCount}</if>
  35. <if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if>
  36. <if test="plannedEndTime != null and plannedEndTime != ''"> and planned_end_time = #{plannedEndTime}</if>
  37. <if test="planStatus != null and planStatus != ''"> and plan_status = #{planStatus}</if>
  38. <if test="number != null and number != ''"> and `number` = #{number}</if>
  39. <if test="productType != null and productType != ''"> and `productType` = #{productType}</if>
  40. <if test="productId != null and productId != ''"> and `product_id` = #{productId}</if>
  41. <if test="salesmanId != null and salesmanId != ''"> and `salesman_id` = #{salesmanId}</if>
  42. </where>
  43. ORDER BY productType
  44. </select>
  45. <select id="selectDetailsOfTheRefuelingPlanListDetiles" parameterType="com.zkqy.business.domain.DetailsOfTheRefuelingPlan" resultMap="DetailsOfTheRefuelingPlanResult">
  46. <include refid="selectDetailsOfTheRefuelingPlanVo"/>
  47. <where>
  48. <if test="timestampRandomCode != null and timestampRandomCode != ''"> and timestamp_random_code = #{timestampRandomCode}</if>
  49. <if test="macId != null "> and mac_id = #{macId}</if>
  50. <if test="machineId != null "> and machine_id = #{machineId}</if>
  51. <if test="currentColorCode != null and currentColorCode != ''"> and current_color_code = #{currentColorCode}</if>
  52. <if test="currentSpecification != null and currentSpecification != ''"> and current_specification = #{currentSpecification}</if>
  53. <if test="currentLotNumber != null "> and current_lot_number = #{currentLotNumber}</if>
  54. <if test="currentSpindleCount != null and currentSpindleCount != ''"> and current_spindle_count = #{currentSpindleCount}</if>
  55. <if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if>
  56. <if test="plannedEndTime != null and plannedEndTime != ''"> and planned_end_time = #{plannedEndTime}</if>
  57. <if test="planStatus != null and planStatus != ''"> and plan_status = #{planStatus}</if>
  58. <if test="number != null and number != ''"> and `number` = #{number}</if>
  59. <if test="productType != null and productType != ''"> and `productType` = #{productType}</if>
  60. and plan_status!=3
  61. </where>
  62. ORDER BY CASE WHEN plan_status = 1 THEN 0 ELSE 1 END, plan_status;
  63. </select>
  64. <select id="selectDetailsOfTheRefuelingPlanById" parameterType="Long" resultMap="DetailsOfTheRefuelingPlanResult">
  65. <include refid="selectDetailsOfTheRefuelingPlanVo"/>
  66. where id = #{id}
  67. </select>
  68. <select id="selectDetailsOfTheRefuelingPlanListCount" resultType="java.lang.Integer">
  69. select count(`id`) from {DBNAME}.details_of_the_refueling_plan
  70. </select>
  71. <insert id="insertDetailsOfTheRefuelingPlan" parameterType="com.zkqy.business.domain.DetailsOfTheRefuelingPlan">
  72. insert into {DBNAME}.details_of_the_refueling_plan
  73. <trim prefix="(" suffix=")" suffixOverrides=",">
  74. <if test="id != null">id,</if>
  75. <if test="timestampRandomCode != null">timestamp_random_code,</if>
  76. <if test="machineId != null">machine_id,</if>
  77. <if test="currentColorCode != null and currentColorCode != ''">current_color_code,</if>
  78. <if test="currentSpecification != null">current_specification,</if>
  79. <if test="currentLotNumber != null">current_lot_number,</if>
  80. <if test="currentSpindleCount != null">current_spindle_count,</if>
  81. <if test="startTime != null">start_time,</if>
  82. <if test="plannedEndTime != null">planned_end_time,</if>
  83. <if test="planStatus != null">plan_status,</if>
  84. <if test="number != null">`number`,</if>
  85. <if test="productType != null and productType != ''">`productType`</if>
  86. </trim>
  87. <trim prefix="values (" suffix=")" suffixOverrides=",">
  88. <if test="id != null">#{id},</if>
  89. <if test="timestampRandomCode != null">#{timestampRandomCode},</if>
  90. <if test="machineId != null">#{machineId},</if>
  91. <if test="currentColorCode != null and currentColorCode != ''">#{currentColorCode},</if>
  92. <if test="currentSpecification != null">#{currentSpecification},</if>
  93. <if test="currentLotNumber != null">#{currentLotNumber},</if>
  94. <if test="currentSpindleCount != null">#{currentSpindleCount},</if>
  95. <if test="startTime != null">#{startTime},</if>
  96. <if test="plannedEndTime != null">#{plannedEndTime},</if>
  97. <if test="planStatus != null">#{planStatus},</if>
  98. <if test="number != null">#{number},</if>
  99. <if test="productType != null and productType != ''"> #{productType}</if>
  100. </trim>
  101. </insert>
  102. <insert id="insertBatchDetailsOfTheRefuelingPlan" parameterType="java.util.List">
  103. INSERT INTO {DBNAME}.details_of_the_refueling_plan
  104. <trim prefix="(" suffix=")" suffixOverrides=",">
  105. timestamp_random_code,
  106. mac_id,
  107. machine_id,
  108. current_color_code,
  109. current_specification,
  110. current_lot_number,
  111. current_spindle_count,
  112. start_time,
  113. planned_end_time,
  114. plan_status,
  115. `number`,
  116. `productType`,
  117. `product_id`,
  118. `salesman_id`,
  119. `productTypeName`
  120. </trim>
  121. VALUES
  122. <foreach collection="list" item="item" separator=",">
  123. <trim prefix="(" suffix=")" suffixOverrides=",">
  124. #{item.timestampRandomCode},
  125. #{item.macId},
  126. #{item.machineId},
  127. #{item.currentColorCode},
  128. #{item.currentSpecification},
  129. #{item.currentLotNumber},
  130. #{item.currentSpindleCount},
  131. #{item.startTime},
  132. #{item.plannedEndTime},
  133. #{item.planStatus},
  134. #{item.number},
  135. #{item.productType},
  136. #{item.productId},
  137. #{item.salesmanId},
  138. #{item.productTypeName}
  139. </trim>
  140. </foreach>
  141. </insert>
  142. <update id="updateDetailsOfTheRefuelingPlan" parameterType="com.zkqy.business.domain.DetailsOfTheRefuelingPlan">
  143. update {DBNAME}.details_of_the_refueling_plan
  144. <trim prefix="SET" suffixOverrides=",">
  145. <if test="timestampRandomCode != null">timestamp_random_code = #{timestampRandomCode},</if>
  146. <if test="machineId != null">machine_id = #{machineId},</if>
  147. <if test="currentColorCode != null and currentColorCode != ''">current_color_code = #{currentColorCode},</if>
  148. <if test="currentSpecification != null">current_specification = #{currentSpecification},</if>
  149. <if test="currentLotNumber != null">current_lot_number = #{currentLotNumber},</if>
  150. <if test="currentSpindleCount != null">current_spindle_count = #{currentSpindleCount},</if>
  151. <if test="startTime != null">start_time = #{startTime},</if>
  152. <if test="plannedEndTime != null">planned_end_time = #{plannedEndTime},</if>
  153. <if test="planStatus != null">plan_status = #{planStatus},</if>
  154. <if test="number != null">`number` = #{number},</if>
  155. <if test="productType != null and productType != ''">`productType`= #{productType},</if>
  156. <if test="productId != null and productId != ''">`product_id`= #{productId},</if>
  157. <if test="salesmanId != null and salesmanId != ''">`salesman_id`= #{salesmanId},</if>
  158. </trim>
  159. where id = #{id}
  160. </update>
  161. <update id="updateDetailsOfTheRefuelingPlanByMachineIdAndProductType" parameterType="com.zkqy.business.domain.DetailsOfTheRefuelingPlan">
  162. update {DBNAME}.details_of_the_refueling_plan
  163. <trim prefix="SET" suffixOverrides=",">
  164. <if test="timestampRandomCode != null">timestamp_random_code = #{timestampRandomCode},</if>
  165. <if test="machineId != null">machine_id = #{machineId},</if>
  166. <if test="currentColorCode != null and currentColorCode != ''">current_color_code = #{currentColorCode},</if>
  167. <if test="currentSpecification != null">current_specification = #{currentSpecification},</if>
  168. <if test="currentLotNumber != null">current_lot_number = #{currentLotNumber},</if>
  169. <if test="currentSpindleCount != null">current_spindle_count = #{currentSpindleCount},</if>
  170. <if test="startTime != null">start_time = #{startTime},</if>
  171. <if test="plannedEndTime != null">planned_end_time = #{plannedEndTime},</if>
  172. <if test="planStatus != null">plan_status = #{planStatus},</if>
  173. <if test="number != null">`number` = #{number},</if>
  174. <if test="productType != null and productType != ''">`productType`= #{productType},</if>
  175. <if test="productId != null and productId != ''">`product_id`= #{productId},</if>
  176. <if test="salesmanId != null and salesmanId != ''">`salesman_id`= #{salesmanId},</if>
  177. </trim>
  178. where machine_id = #{machineId} and productType=#{productType}
  179. <if test="planStatusOld != null and planStatusOld != ''">
  180. and plan_status=#{planStatusOld}
  181. </if>
  182. </update>
  183. <delete id="deleteDetailsOfTheRefuelingPlanById" parameterType="Long">
  184. delete from {DBNAME}.details_of_the_refueling_plan where id = #{id}
  185. </delete>
  186. <delete id="deleteDetailsOfTheRefuelingPlanByIds" parameterType="String">
  187. delete from {DBNAME}.details_of_the_refueling_plan where id in
  188. <foreach item="id" collection="array" open="(" separator="," close=")">
  189. #{id}
  190. </foreach>
  191. </delete>
  192. <delete id="deleteDetailsOfTheRefuelingPlanByMachineId">
  193. delete from {DBNAME}.details_of_the_refueling_plan where machine_id = #{machineId} and timestamp_random_code='停机';
  194. </delete>
  195. </mapper>