IfMesEmsSwapfileMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.steerinfo.ems.ifmesemsswapfile.mapper.IfMesEmsSwapfileMapper">
  4. <resultMap id="BaseResultMap" type="com.steerinfo.ems.ifmesemsswapfile.model.IfMesEmsSwapfile">
  5. <result column="FID" jdbcType="VARCHAR" property="fid" />
  6. <result column="TYPE" jdbcType="VARCHAR" property="type" />
  7. <result column="WORKS" jdbcType="VARCHAR" property="works" />
  8. <result column="PRODLINE" jdbcType="VARCHAR" property="prodline" />
  9. <result column="PRODATE" jdbcType="DATE" property="prodate" />
  10. <result column="ORDERNO" jdbcType="VARCHAR" property="orderno" />
  11. <result column="MATERIALCODE" jdbcType="VARCHAR" property="materialcode" />
  12. <result column="MATERIALNAME" jdbcType="VARCHAR" property="materialname" />
  13. <result column="UNIT" jdbcType="VARCHAR" property="unit" />
  14. <result column="QTY" jdbcType="DECIMAL" property="qty" />
  15. <result column="CREATETIME" jdbcType="DATE" property="createtime" />
  16. <result column="STATUS" jdbcType="VARCHAR" property="status" />
  17. <result column="SENDTIME" jdbcType="DATE" property="sendtime" />
  18. <result column="MEMO" jdbcType="DATE" property="memo" />
  19. </resultMap>
  20. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  21. select FID, TYPE, WORKS, PRODLINE, PRODATE, ORDERNO, MATERIALCODE, MATERIALNAME, UNIT, QTY, CREATETIME, STATUS, SENDTIME,MEMO
  22. from IF_MES_EMS_SWAPFILE
  23. where FID = #{id,jdbcType=VARCHAR}
  24. </select>
  25. <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
  26. delete from IF_MES_EMS_SWAPFILE
  27. <where>
  28. <if test="fid != null and fid != ''">
  29. and FID = #{fid}
  30. </if>
  31. <if test="type != null and type != ''">
  32. and TYPE = #{type}
  33. </if>
  34. <if test="works != null and works != ''">
  35. and WORKS = #{works}
  36. </if>
  37. <if test="prodline != null and prodline != ''">
  38. and PRODLINE = #{prodline}
  39. </if>
  40. <if test="prodate != null">
  41. and PRODATE = #{prodate}
  42. </if>
  43. <if test="orderno != null and orderno != ''">
  44. and ORDERNO = #{orderno}
  45. </if>
  46. <if test="materialcode != null and materialcode != ''">
  47. and MATERIALCODE = #{materialcode}
  48. </if>
  49. <if test="materialname != null and materialname != ''">
  50. and MATERIALNAME = #{materialname}
  51. </if>
  52. <if test="unit != null and unit != ''">
  53. and UNIT = #{unit}
  54. </if>
  55. <if test="qty != null and qty != ''">
  56. and QTY = #{qty}
  57. </if>
  58. <if test="createtime != null and createtime != ''">
  59. and CREATETIME = #{createtime}
  60. </if>
  61. <if test="status != null and status != ''">
  62. and STATUS = #{status}
  63. </if>
  64. <if test="sendtime != null and sendtime != ''">
  65. and SENDTIME = #{sendtime}
  66. </if>
  67. </where>
  68. </delete>
  69. <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  70. select FID, TYPE, WORKS, PRODLINE, PRODATE, ORDERNO, MATERIALCODE, MATERIALNAME, UNIT, QTY, CREATETIME, STATUS, SENDTIME,MEMO
  71. from IF_MES_EMS_SWAPFILE
  72. <where>
  73. <if test="fid != null and fid != ''">
  74. and FID = #{fid}
  75. </if>
  76. <if test="type != null and type != ''">
  77. and TYPE = #{type}
  78. </if>
  79. <if test="works != null and works != ''">
  80. and WORKS = #{works}
  81. </if>
  82. <if test="prodline != null and prodline != ''">
  83. and PRODLINE = #{prodline}
  84. </if>
  85. <if test="prodate != null and prodate != ''">
  86. and to_char(PRODATE,'yyyy-MM-dd') LIKE '${prodate}%'
  87. </if>
  88. <if test="orderno != null and orderno != ''">
  89. and ORDERNO = #{orderno}
  90. </if>
  91. <if test="materialcode != null and materialcode != ''">
  92. and MATERIALCODE = #{materialcode}
  93. </if>
  94. <if test="materialname != null and materialname != ''">
  95. and MATERIALNAME = #{materialname}
  96. </if>
  97. <if test="unit != null and unit != ''">
  98. and UNIT = #{unit}
  99. </if>
  100. <if test="qty != null and qty != ''">
  101. and QTY = #{qty}
  102. </if>
  103. <if test="createtime != null and createtime != ''">
  104. and CREATETIME = #{createtime}
  105. </if>
  106. <if test="status != null and status != ''">
  107. and STATUS = #{status}
  108. </if>
  109. <if test="sendtime != null and sendtime != ''">
  110. and SENDTIME = #{sendtime}
  111. </if>
  112. </where>
  113. </select>
  114. <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  115. select FID, TYPE, WORKS, PRODLINE, PRODATE, ORDERNO, MATERIALCODE, MATERIALNAME, UNIT, QTY, CREATETIME, STATUS, SENDTIME,MEMO
  116. from IF_MES_EMS_SWAPFILE
  117. <where>
  118. <if test="fid != null and fid != ''">
  119. and FID LIKE '%${fid}%'
  120. </if>
  121. <if test="type != null and type != ''">
  122. and TYPE = #{type}
  123. </if>
  124. <if test="works != null and works != ''">
  125. and WORKS LIKE '%${works}%'
  126. </if>
  127. <if test="prodline != null and prodline != ''">
  128. and PRODLINE LIKE '%${prodline}%'
  129. </if>
  130. <if test="prodate != null and prodate != ''">
  131. and PRODATE LIKE '%${prodate}%'
  132. </if>
  133. <if test="orderno != null and orderno != ''">
  134. and ORDERNO LIKE '%${orderno}%'
  135. </if>
  136. <if test="materialcode != null and materialcode != ''">
  137. and MATERIALCODE LIKE '%${materialcode}%'
  138. </if>
  139. <if test="materialname != null and materialname != ''">
  140. and MATERIALNAME LIKE '%${materialname}%'
  141. </if>
  142. <if test="unit != null and unit != ''">
  143. and UNIT LIKE '%${unit}%'
  144. </if>
  145. <if test="qty != null and qty != ''">
  146. and QTY LIKE '%${qty}%'
  147. </if>
  148. <if test="createtime != null and createtime != ''">
  149. and CREATETIME LIKE '%${createtime}%'
  150. </if>
  151. <if test="status != null and status != ''">
  152. and STATUS = #{status}
  153. </if>
  154. <if test="sendtime != null and sendtime != ''">
  155. and SENDTIME LIKE '%${sendtime}%'
  156. </if>
  157. </where>
  158. </select>
  159. <select id="selectNewMaterial" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  160. select FID, TYPE, WORKS, PRODLINE, PRODATE, ORDERNO, MATERIALCODE, MATERIALNAME, UNIT, QTY, CREATETIME, STATUS, SENDTIME,MEMO
  161. from IF_MES_EMS_SWAPFILE
  162. where TYPE = #{type,jdbcType=VARCHAR}
  163. and STATUS in ('0','9')
  164. order by PRODATE, PRODLINE, MATERIALCODE
  165. </select>
  166. <select id="getSUM" parameterType="java.util.HashMap" resultType="java.math.BigDecimal">
  167. SELECT
  168. SUM (qty) SUMQTY
  169. FROM IF_MES_EMS_SWAPFILE T
  170. WHERE T.TYPE = '1'
  171. AND T.PRODLINE IN (${prodlines})
  172. AND T.MATERIALCODE
  173. <if test="isnot == 'not'">
  174. NOT
  175. </if>
  176. IN (${materialcodes})
  177. AND TO_CHAR(T.PRODATE, 'yyyy-MM-dd') = #{dataDay,jdbcType=VARCHAR}
  178. </select>
  179. <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.ifmesemsswapfile.model.IfMesEmsSwapfile">
  180. update IF_MES_EMS_SWAPFILE
  181. set TYPE = #{type,jdbcType=VARCHAR},
  182. WORKS = #{works,jdbcType=VARCHAR},
  183. PRODLINE = #{prodline,jdbcType=VARCHAR},
  184. PRODATE = to_date(#{prodate}, 'YYYY-MM-DD HH24:MI:SS'),
  185. ORDERNO = #{orderno,jdbcType=VARCHAR},
  186. MATERIALCODE = #{materialcode,jdbcType=VARCHAR},
  187. MATERIALNAME = #{materialname,jdbcType=VARCHAR},
  188. UNIT = #{unit,jdbcType=VARCHAR},
  189. QTY = #{qty,jdbcType=VARCHAR},
  190. CREATETIME = to_date(#{createtime}, 'YYYY-MM-DD HH24:MI:SS'),
  191. STATUS = #{status,jdbcType=VARCHAR}
  192. where FID = #{fid,jdbcType=VARCHAR}
  193. </update>
  194. <update id="updateStatus" parameterType="java.util.HashMap">
  195. update IF_MES_EMS_SWAPFILE
  196. <set>
  197. <if test="status != null">
  198. STATUS = #{status,jdbcType=VARCHAR},
  199. SENDTIME = SYSDATE,
  200. </if>
  201. </set>
  202. where FID = #{fid,jdbcType=VARCHAR}
  203. </update>
  204. <insert id="insert" parameterType="com.steerinfo.ems.ifmesemsswapfile.model.IfMesEmsSwapfile">
  205. insert into IF_MES_EMS_SWAPFILE
  206. <trim prefix="(" suffix=")" suffixOverrides=",">
  207. <if test="fid != null">
  208. FID,
  209. </if>
  210. <if test="type != null">
  211. TYPE,
  212. </if>
  213. <if test="works != null">
  214. WORKS,
  215. </if>
  216. <if test="prodline != null">
  217. PRODLINE,
  218. </if>
  219. <if test="prodate != null">
  220. PRODATE,
  221. </if>
  222. <if test="orderno != null">
  223. ORDERNO,
  224. </if>
  225. <if test="materialcode != null">
  226. MATERIALCODE,
  227. </if>
  228. <if test="materialname != null">
  229. MATERIALNAME,
  230. </if>
  231. <if test="unit != null">
  232. UNIT,
  233. </if>
  234. <if test="qty != null">
  235. QTY,
  236. </if>
  237. <if test="createtime != null">
  238. CREATETIME,
  239. </if>
  240. <if test="status != null">
  241. STATUS,
  242. </if>
  243. <if test="sendtime != null">
  244. SENDTIME,
  245. </if>
  246. </trim>
  247. <trim prefix="values (" suffix=")" suffixOverrides=",">
  248. <if test="fid != null">
  249. #{fid,jdbcType=VARCHAR},
  250. </if>
  251. <if test="type != null">
  252. #{type,jdbcType=VARCHAR},
  253. </if>
  254. <if test="works != null">
  255. #{works,jdbcType=VARCHAR},
  256. </if>
  257. <if test="prodline != null">
  258. #{prodline,jdbcType=VARCHAR},
  259. </if>
  260. <if test="prodate != null">
  261. to_date ( #{prodate} , 'YYYY-MM-DD HH24:MI:SS' ),
  262. </if>
  263. <if test="orderno != null">
  264. #{orderno,jdbcType=VARCHAR},
  265. </if>
  266. <if test="materialcode != null">
  267. #{materialcode,jdbcType=VARCHAR},
  268. </if>
  269. <if test="materialname != null">
  270. #{materialname,jdbcType=VARCHAR},
  271. </if>
  272. <if test="unit != null">
  273. #{unit,jdbcType=VARCHAR},
  274. </if>
  275. <if test="qty != null">
  276. #{qty,jdbcType=DECIMAL},
  277. </if>
  278. <if test="createtime != null">
  279. to_date ( #{createtime} , 'YYYY-MM-DD HH24:MI:SS' ),
  280. </if>
  281. <if test="status != null">
  282. #{status,jdbcType=VARCHAR},
  283. </if>
  284. <if test="sendtime != null">
  285. to_date ( #{sendtime} , 'YYYY-MM-DD HH24:MI:SS' ),
  286. </if>
  287. </trim>
  288. </insert>
  289. <select id="getQueryList" parameterType="java.util.HashMap" resultType = "Map">
  290. SELECT s.FID, s.TYPE, s.WORKS, s.PRODLINE, CASE WHEN s.TYPE = 1 THEN m.WORKPROCID WHEN s.TYPE = 2 THEN p.WORKPROCID END AS WORKPROCID, s.PRODATE, s.ORDERNO, s.MATERIALCODE, s.MATERIALNAME, s.UNIT, s.QTY, s.CREATETIME, s.STATUS, s.SENDTIME, s.MEMO
  291. FROM IF_MES_EMS_SWAPFILE s
  292. LEFT JOIN T_RM_WORKPROC_PRODUCT p ON s.MATERIALCODE = p.MES_MATERIALCODE
  293. LEFT JOIN T_RM_WORKPROC_MATERIAL m ON s.MATERIALCODE = m.MES_MATERIALCODE
  294. WHERE (m.WORKPROCID IN (${workProcids}) OR p.WORKPROCID IN (${workProcids}))
  295. <if test="prodate != null and prodate != ''">
  296. AND s.PRODATE >= to_date(#{prodate}, 'yyyy-mm-dd')
  297. </if>
  298. <if test="prodate2 != null and prodate2 != ''">
  299. AND s.PRODATE &lt;= to_date(#{prodate2}, 'yyyy-mm-dd')
  300. </if>
  301. <if test="workproc != null and workproc != ''">
  302. AND (p.WORKPROCID LIKE '%${workproc}%' OR m.WORKPROCID LIKE '%${workproc}%')
  303. </if>
  304. <if test="materialname != null and materialname != ''">
  305. AND s.MATERIALNAME LIKE '%${materialname}%'
  306. </if>
  307. <if test="materialcode != null and materialcode != ''">
  308. AND s.MATERIALCODE LIKE '%${materialcode}%'
  309. </if>
  310. <if test="prodline != null and prodline != ''">
  311. AND s.PRODLINE LIKE '%${prodline}%'
  312. </if>
  313. <if test="type != null and type != ''">
  314. AND s.TYPE LIKE '%${type}%'
  315. </if>
  316. ORDER BY s.PRODATE
  317. </select>
  318. <select id="queryProductAndMaterial" parameterType="java.util.HashMap" resultType = "Map">
  319. SELECT A.ITEMID, A.CLOCK, A.TIMEGRANID, A.ACTUALVALUE, A.CORRECTVALUE
  320. , A.APPORTVALUE, A.BZ, A.USERID, A.UPDATETIME, A.UPMAN
  321. , A.UPTIME, B.WORKPROCID, B.MES_MATERIALCODE, B.UNITID, B.${listing} AS MATERIALNAME
  322. FROM ${table_name2} A
  323. LEFT JOIN ${table_name} B ON A.ITEMID = B.ITEMID
  324. WHERE B.WORKPROCID IN (${workProcids})
  325. <if test="clock != null and clock != ''">
  326. AND A.CLOCK >= #{clock}
  327. </if>
  328. <if test="clock2 != null and clock2 != ''">
  329. AND A.CLOCK &lt;= #{clock2}
  330. </if>
  331. AND B.ITEMTYPE = 'R'
  332. AND B.USEFLAG = '1'
  333. AND B.ISFINANCEDATA = '1'
  334. <if test="workproc != null and workproc != ''">
  335. AND B.WORKPROCID IN (${workProcs})
  336. </if>
  337. <if test="materialcode != null and materialcode != ''">
  338. AND B.MES_MATERIALCODE LIKE '%${materialcode}%'
  339. </if>
  340. <if test="itemid != null and itemid != ''">
  341. AND A.ITEMID LIKE '%${itemid}%'
  342. </if>
  343. <if test="itemtype !=null and itemtype!='' ">
  344. AND B.ITEMTYPE = #{itemtype}
  345. </if>
  346. <if test="materialname !=null and materialname!='' ">
  347. AND B.${listing} = #{materialname}
  348. </if>
  349. ORDER BY A.CLOCK,B.SEQNO
  350. </select>
  351. <update id="updateProductAndMaterial" parameterType="java.util.HashMap">
  352. UPDATE ${table_name}
  353. SET APPORTVALUE = #{apportvalue},
  354. CORRECTVALUE = #{correctvalue},
  355. BZ = #{bz},
  356. UPMAN = #{upman},
  357. UPTIME = #{uptime}
  358. WHERE ITEMID = #{itemid}
  359. AND CLOCK = #{clock}
  360. AND TIMEGRANID = #{timegranid}
  361. AND ACTUALVALUE = #{actualvalue}
  362. </update>
  363. </mapper>