DetailsOfTheRefuelingPlanMapper.xml 14 KB

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