WmspCheckWarehouseMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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.dil.mapper.WmspCheckWarehouseMapper">
  4. <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.WmspCheckWarehouse">
  5. <id column="CHECK_ID" jdbcType="DECIMAL" property="checkId" />
  6. <result column="WAREHOUSE_ID" jdbcType="DECIMAL" property="warehouseId" />
  7. <result column="MATERIAL_ID" jdbcType="DECIMAL" property="materialId" />
  8. <result column="REAL_MATERIAL_AMOUNT" jdbcType="DECIMAL" property="realMaterialAmount" />
  9. <result column="ELECTRONICS_MATERIAL_AMOUNT" jdbcType="DECIMAL" property="electronicsMaterialAmount" />
  10. <result column="CHECK_PROFITLOSS" jdbcType="DECIMAL" property="checkProfitloss" />
  11. <result column="INSERT_USERNAME" jdbcType="VARCHAR" property="insertUsername" />
  12. <result column="INSERT_TIME" jdbcType="TIMESTAMP" property="insertTime" />
  13. <result column="UPDATE_USERNAME" jdbcType="VARCHAR" property="updateUsername" />
  14. <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
  15. <result column="INSERT_UPDATE_REMARK" jdbcType="VARCHAR" property="insertUpdateRemark" />
  16. </resultMap>
  17. <sql id="columns">
  18. CHECK_ID, WAREHOUSE_ID, MATERIAL_ID, REAL_MATERIAL_AMOUNT, ELECTRONICS_MATERIAL_AMOUNT,
  19. CHECK_PROFITLOSS, INSERT_USERNAME, INSERT_TIME, UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK
  20. </sql>
  21. <sql id="columns_alias">
  22. t.CHECK_ID, t.WAREHOUSE_ID, t.MATERIAL_ID, t.REAL_MATERIAL_AMOUNT, t.ELECTRONICS_MATERIAL_AMOUNT,
  23. t.CHECK_PROFITLOSS, t.INSERT_USERNAME, t.INSERT_TIME, t.UPDATE_USERNAME, t.UPDATE_TIME,
  24. t.INSERT_UPDATE_REMARK
  25. </sql>
  26. <sql id="select">
  27. SELECT <include refid="columns" /> FROM WMSP_CHECK_WAREHOUSE
  28. </sql>
  29. <sql id="select_alias">
  30. SELECT <include refid="columns_alias" /> FROM WMSP_CHECK_WAREHOUSE t
  31. </sql>
  32. <sql id="where">
  33. <where>
  34. <if test="checkId != null">
  35. and CHECK_ID = #{checkId}
  36. </if>
  37. <if test="warehouseId != null">
  38. and WAREHOUSE_ID = #{warehouseId}
  39. </if>
  40. <if test="materialId != null">
  41. and MATERIAL_ID = #{materialId}
  42. </if>
  43. <if test="realMaterialAmount != null">
  44. and REAL_MATERIAL_AMOUNT = #{realMaterialAmount}
  45. </if>
  46. <if test="electronicsMaterialAmount != null">
  47. and ELECTRONICS_MATERIAL_AMOUNT = #{electronicsMaterialAmount}
  48. </if>
  49. <if test="checkProfitloss != null">
  50. and CHECK_PROFITLOSS = #{checkProfitloss}
  51. </if>
  52. <if test="insertUsername != null and insertUsername != ''">
  53. and INSERT_USERNAME = #{insertUsername}
  54. </if>
  55. <if test="insertTime != null">
  56. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  57. </if>
  58. <if test="updateUsername != null and updateUsername != ''">
  59. and UPDATE_USERNAME = #{updateUsername}
  60. </if>
  61. <if test="updateTime != null">
  62. and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
  63. </if>
  64. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  65. and INSERT_UPDATE_REMARK = #{insertUpdateRemark}
  66. </if>
  67. </where>
  68. </sql>
  69. <sql id="whereLike">
  70. <where>
  71. <if test="checkId != null">
  72. and CHECK_ID = #{checkId}
  73. </if>
  74. <if test="warehouseId != null">
  75. and WAREHOUSE_ID = #{warehouseId}
  76. </if>
  77. <if test="materialId != null">
  78. and MATERIAL_ID = #{materialId}
  79. </if>
  80. <if test="realMaterialAmount != null">
  81. and REAL_MATERIAL_AMOUNT = #{realMaterialAmount}
  82. </if>
  83. <if test="electronicsMaterialAmount != null">
  84. and ELECTRONICS_MATERIAL_AMOUNT = #{electronicsMaterialAmount}
  85. </if>
  86. <if test="checkProfitloss != null">
  87. and CHECK_PROFITLOSS = #{checkProfitloss}
  88. </if>
  89. <if test="insertUsername != null and insertUsername != ''">
  90. and INSERT_USERNAME LIKE '%${insertUsername}%'
  91. </if>
  92. <if test="insertTime != null">
  93. and TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = #{insertTime}
  94. </if>
  95. <if test="updateUsername != null and updateUsername != ''">
  96. and UPDATE_USERNAME LIKE '%${updateUsername}%'
  97. </if>
  98. <if test="updateTime != null">
  99. and TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = #{updateTime}
  100. </if>
  101. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  102. and INSERT_UPDATE_REMARK LIKE '%${insertUpdateRemark}%'
  103. </if>
  104. </where>
  105. </sql>
  106. <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
  107. delete from WMSP_CHECK_WAREHOUSE
  108. where CHECK_ID = #{checkId,jdbcType=DECIMAL}
  109. </delete>
  110. <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
  111. delete from WMSP_CHECK_WAREHOUSE
  112. where 1!=1
  113. <if test="warehouseId != null">
  114. or WAREHOUSE_ID = #{warehouseId}
  115. </if>
  116. <if test="materialId != null">
  117. or MATERIAL_ID = #{materialId}
  118. </if>
  119. <if test="realMaterialAmount != null">
  120. or REAL_MATERIAL_AMOUNT = #{realMaterialAmount}
  121. </if>
  122. <if test="electronicsMaterialAmount != null">
  123. or ELECTRONICS_MATERIAL_AMOUNT = #{electronicsMaterialAmount}
  124. </if>
  125. <if test="checkProfitloss != null">
  126. or CHECK_PROFITLOSS = #{checkProfitloss}
  127. </if>
  128. <if test="insertUsername != null and insertUsername != ''">
  129. or INSERT_USERNAME = #{insertUsername}
  130. </if>
  131. <if test="insertTime != null">
  132. or TO_CHAR(INSERT_TIME,'yyyy-MM-dd') = '#{insertTime}'
  133. </if>
  134. <if test="updateUsername != null and updateUsername != ''">
  135. or UPDATE_USERNAME = #{updateUsername}
  136. </if>
  137. <if test="updateTime != null">
  138. or TO_CHAR(UPDATE_TIME,'yyyy-MM-dd') = '#{updateTime}'
  139. </if>
  140. <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
  141. or INSERT_UPDATE_REMARK = #{insertUpdateRemark}
  142. </if>
  143. </delete>
  144. <insert id="insert" parameterType="com.steerinfo.dil.model.WmspCheckWarehouse">
  145. insert into WMSP_CHECK_WAREHOUSE (CHECK_ID, WAREHOUSE_ID, MATERIAL_ID,
  146. REAL_MATERIAL_AMOUNT, ELECTRONICS_MATERIAL_AMOUNT,
  147. CHECK_PROFITLOSS, INSERT_USERNAME, INSERT_TIME,
  148. UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK
  149. )
  150. values (#{checkId,jdbcType=DECIMAL}, #{warehouseId,jdbcType=DECIMAL}, #{materialId,jdbcType=DECIMAL},
  151. #{realMaterialAmount,jdbcType=DECIMAL}, #{electronicsMaterialAmount,jdbcType=DECIMAL},
  152. #{checkProfitloss,jdbcType=DECIMAL}, #{insertUsername,jdbcType=VARCHAR}, #{insertTime,jdbcType=TIMESTAMP},
  153. #{updateUsername,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{insertUpdateRemark,jdbcType=VARCHAR}
  154. )
  155. </insert>
  156. <insert id="insertSelective" parameterType="com.steerinfo.dil.model.WmspCheckWarehouse">
  157. insert into WMSP_CHECK_WAREHOUSE
  158. <trim prefix="(" suffix=")" suffixOverrides=",">
  159. <if test="checkId != null">
  160. CHECK_ID,
  161. </if>
  162. <if test="warehouseId != null">
  163. WAREHOUSE_ID,
  164. </if>
  165. <if test="materialId != null">
  166. MATERIAL_ID,
  167. </if>
  168. <if test="realMaterialAmount != null">
  169. REAL_MATERIAL_AMOUNT,
  170. </if>
  171. <if test="electronicsMaterialAmount != null">
  172. ELECTRONICS_MATERIAL_AMOUNT,
  173. </if>
  174. <if test="checkProfitloss != null">
  175. CHECK_PROFITLOSS,
  176. </if>
  177. <if test="insertUsername != null">
  178. INSERT_USERNAME,
  179. </if>
  180. <if test="insertTime != null">
  181. INSERT_TIME,
  182. </if>
  183. <if test="updateUsername != null">
  184. UPDATE_USERNAME,
  185. </if>
  186. <if test="updateTime != null">
  187. UPDATE_TIME,
  188. </if>
  189. <if test="insertUpdateRemark != null">
  190. INSERT_UPDATE_REMARK,
  191. </if>
  192. </trim>
  193. <trim prefix="values (" suffix=")" suffixOverrides=",">
  194. <if test="checkId != null">
  195. #{checkId,jdbcType=DECIMAL},
  196. </if>
  197. <if test="warehouseId != null">
  198. #{warehouseId,jdbcType=DECIMAL},
  199. </if>
  200. <if test="materialId != null">
  201. #{materialId,jdbcType=DECIMAL},
  202. </if>
  203. <if test="realMaterialAmount != null">
  204. #{realMaterialAmount,jdbcType=DECIMAL},
  205. </if>
  206. <if test="electronicsMaterialAmount != null">
  207. #{electronicsMaterialAmount,jdbcType=DECIMAL},
  208. </if>
  209. <if test="checkProfitloss != null">
  210. #{checkProfitloss,jdbcType=DECIMAL},
  211. </if>
  212. <if test="insertUsername != null">
  213. #{insertUsername,jdbcType=VARCHAR},
  214. </if>
  215. <if test="insertTime != null">
  216. #{insertTime,jdbcType=TIMESTAMP},
  217. </if>
  218. <if test="updateUsername != null">
  219. #{updateUsername,jdbcType=VARCHAR},
  220. </if>
  221. <if test="updateTime != null">
  222. #{updateTime,jdbcType=TIMESTAMP},
  223. </if>
  224. <if test="insertUpdateRemark != null">
  225. #{insertUpdateRemark,jdbcType=VARCHAR},
  226. </if>
  227. </trim>
  228. </insert>
  229. <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.WmspCheckWarehouse">
  230. update WMSP_CHECK_WAREHOUSE
  231. set WAREHOUSE_ID = #{warehouseId,jdbcType=DECIMAL},
  232. MATERIAL_ID = #{materialId,jdbcType=DECIMAL},
  233. REAL_MATERIAL_AMOUNT = #{realMaterialAmount,jdbcType=DECIMAL},
  234. ELECTRONICS_MATERIAL_AMOUNT = #{electronicsMaterialAmount,jdbcType=DECIMAL},
  235. CHECK_PROFITLOSS = #{checkProfitloss,jdbcType=DECIMAL},
  236. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  237. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  238. UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
  239. UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
  240. INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR}
  241. where CHECK_ID = #{checkId,jdbcType=DECIMAL}
  242. </update>
  243. <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.WmspCheckWarehouse">
  244. update WMSP_CHECK_WAREHOUSE
  245. <set>
  246. <if test="warehouseId != null">
  247. WAREHOUSE_ID = #{warehouseId,jdbcType=DECIMAL},
  248. </if>
  249. <if test="materialId != null">
  250. MATERIAL_ID = #{materialId,jdbcType=DECIMAL},
  251. </if>
  252. <if test="realMaterialAmount != null">
  253. REAL_MATERIAL_AMOUNT = #{realMaterialAmount,jdbcType=DECIMAL},
  254. </if>
  255. <if test="electronicsMaterialAmount != null">
  256. ELECTRONICS_MATERIAL_AMOUNT = #{electronicsMaterialAmount,jdbcType=DECIMAL},
  257. </if>
  258. <if test="checkProfitloss != null">
  259. CHECK_PROFITLOSS = #{checkProfitloss,jdbcType=DECIMAL},
  260. </if>
  261. <if test="insertUsername != null">
  262. INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
  263. </if>
  264. <if test="insertTime != null">
  265. INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
  266. </if>
  267. <if test="updateUsername != null">
  268. UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
  269. </if>
  270. <if test="updateTime != null">
  271. UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
  272. </if>
  273. <if test="insertUpdateRemark != null">
  274. INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
  275. </if>
  276. </set>
  277. where CHECK_ID = #{checkId,jdbcType=DECIMAL}
  278. </update>
  279. <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
  280. <include refid="select" />
  281. where CHECK_ID = #{checkId,jdbcType=DECIMAL}
  282. </select>
  283. <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  284. <include refid="select" />
  285. <include refid="where" />
  286. </select>
  287. <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  288. <include refid="select" />
  289. <include refid="whereLike" />
  290. </select>
  291. <insert id="batchInsert" parameterType="java.util.List">
  292. insert into WMSP_CHECK_WAREHOUSE
  293. (CHECK_ID,
  294. WAREHOUSE_ID, MATERIAL_ID, REAL_MATERIAL_AMOUNT,
  295. ELECTRONICS_MATERIAL_AMOUNT, CHECK_PROFITLOSS,
  296. INSERT_USERNAME, INSERT_TIME,
  297. UPDATE_USERNAME, UPDATE_TIME,
  298. INSERT_UPDATE_REMARK)
  299. ( <foreach collection="list" item="item" separator="union all">
  300. select
  301. #{item.checkId,jdbcType=DECIMAL},
  302. #{item.warehouseId,jdbcType=DECIMAL}, #{item.materialId,jdbcType=DECIMAL}, #{item.realMaterialAmount,jdbcType=DECIMAL},
  303. #{item.electronicsMaterialAmount,jdbcType=DECIMAL}, #{item.checkProfitloss,jdbcType=DECIMAL},
  304. #{item.insertUsername,jdbcType=VARCHAR}, #{item.insertTime,jdbcType=TIMESTAMP},
  305. #{item.updateUsername,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
  306. #{item.insertUpdateRemark,jdbcType=VARCHAR} from dual
  307. </foreach> )
  308. </insert>
  309. <update id="batchUpdate" parameterType="java.util.List">
  310. update WMSP_CHECK_WAREHOUSE
  311. set
  312. CHECK_ID=
  313. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  314. when #{item.checkId,jdbcType=DECIMAL} then #{item.checkId,jdbcType=DECIMAL}
  315. </foreach>
  316. ,WAREHOUSE_ID=
  317. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  318. when #{item.checkId,jdbcType=DECIMAL} then #{item.warehouseId,jdbcType=DECIMAL}
  319. </foreach>
  320. ,MATERIAL_ID=
  321. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  322. when #{item.checkId,jdbcType=DECIMAL} then #{item.materialId,jdbcType=DECIMAL}
  323. </foreach>
  324. ,REAL_MATERIAL_AMOUNT=
  325. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  326. when #{item.checkId,jdbcType=DECIMAL} then #{item.realMaterialAmount,jdbcType=DECIMAL}
  327. </foreach>
  328. ,ELECTRONICS_MATERIAL_AMOUNT=
  329. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  330. when #{item.checkId,jdbcType=DECIMAL} then #{item.electronicsMaterialAmount,jdbcType=DECIMAL}
  331. </foreach>
  332. ,CHECK_PROFITLOSS=
  333. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  334. when #{item.checkId,jdbcType=DECIMAL} then #{item.checkProfitloss,jdbcType=DECIMAL}
  335. </foreach>
  336. ,INSERT_USERNAME=
  337. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  338. when #{item.checkId,jdbcType=DECIMAL} then #{item.insertUsername,jdbcType=VARCHAR}
  339. </foreach>
  340. ,INSERT_TIME=
  341. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  342. when #{item.checkId,jdbcType=DECIMAL} then #{item.insertTime,jdbcType=TIMESTAMP}
  343. </foreach>
  344. ,UPDATE_USERNAME=
  345. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  346. when #{item.checkId,jdbcType=DECIMAL} then #{item.updateUsername,jdbcType=VARCHAR}
  347. </foreach>
  348. ,UPDATE_TIME=
  349. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  350. when #{item.checkId,jdbcType=DECIMAL} then #{item.updateTime,jdbcType=TIMESTAMP}
  351. </foreach>
  352. ,INSERT_UPDATE_REMARK=
  353. <foreach close="end" collection="list" index="index" item="item" open="case CHECK_ID" separator=" ">
  354. when #{item.checkId,jdbcType=DECIMAL} then #{item.insertUpdateRemark,jdbcType=VARCHAR}
  355. </foreach>
  356. where CHECK_ID in
  357. <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
  358. #{item.checkId,jdbcType=DECIMAL}
  359. </foreach>
  360. </update>
  361. <delete id="batchDelete" parameterType="java.util.List">
  362. delete from WMSP_CHECK_WAREHOUSE
  363. where CHECK_ID in
  364. <foreach close=")" collection="list" item="id" open="(" separator=",">
  365. #{id}
  366. </foreach>
  367. </delete>
  368. <!-- 友情提示!!!-->
  369. <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
  370. <!-- 查询盘库实绩,根据新增时间倒排-->
  371. <select id="getStockTakingList" resultType="java.util.Map">
  372. SELECT WCW.WAREHOUSE_ID "warehouseId",
  373. RM.MATERIAL_NAME || RM.MATERIAL_SPECIFICATION || '(' ||
  374. RM.MATERIAL_MODEL || ')' "materialName",
  375. RW.WAREHOUSE_NAME "warehouseName",
  376. WCW.MATERIAL_ID "materialId",
  377. WCW.REAL_MATERIAL_AMOUNT "realMaterialAmount",
  378. WCW.ELECTRONICS_MATERIAL_AMOUNT "electronicsMaterialAmount",
  379. WCW.CHECK_PROFITLOSS "checkProfitloss",
  380. WCW.INSERT_TIME "insertTime"
  381. FROM WMSP_CHECK_WAREHOUSE WCW
  382. LEFT JOIN RMS_MATERIAL RM
  383. ON RM.MATERIAL_ID = WCW.MATERIAL_ID
  384. LEFT JOIN RMS_WAREHOUSE RW
  385. ON RW.WAREHOUSE_ID = WCW.WAREHOUSE_ID
  386. ORDER BY WCW.INSERT_TIME DESC
  387. </select>
  388. <select id="getMaxId" resultType="java.math.BigDecimal">
  389. SELECT MAX(WCM.CHECK_ID)
  390. FROM WMSP_CHECK_WAREHOUSE WCM
  391. </select>
  392. </mapper>