PurchaseApplyServiceDaoImplMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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="purchaseApplyServiceDaoImpl">
  6. <resultMap type="com.java110.dto.purchaseApply.PurchaseApplyDto" id="applyMap">
  7. <id column="applyOrderId" property="applyOrderId"/>
  8. <result column="description" property="description"/>
  9. <result column="resOrderType" property="resOrderType"/>
  10. <result column="statusCd" property="statusCd"/>
  11. <result column="state" property="state"/>
  12. <result column="storeId" property="storeId"/>
  13. <result column="userName" property="userName"/>
  14. <result column="bId" property="bId"/>
  15. <result column="userId" property="userId"/>
  16. <result column="createTime" property="createTime"/>
  17. <result column="stateName" property="stateName"/>
  18. <!-- 一对多关系 -->
  19. <collection property="purchaseApplyDetailVo" ofType="com.java110.vo.api.purchaseApply.PurchaseApplyDetailVo" javaType="java.util.ArrayList">
  20. <id property="id" column="id"/>
  21. <result property="applyOrderId" column="applyOrderId"/>
  22. <result property="resId" column="resId"/>
  23. <result property="quantity" column="quantity"/>
  24. <result property="resName" column="resName"/>
  25. <result property="remark" column="remark"/>
  26. <result property="resCode" column="resCode"/>
  27. <result property="price" column="price"/>
  28. <result property="stock" column="stock"/>
  29. </collection>
  30. </resultMap>
  31. <!-- 保存采购申请信息 add by wuxw 2018-07-03 -->
  32. <insert id="saveBusinessPurchaseApplyInfo" parameterType="Map">
  33. insert into business_purchase_apply
  34. (operate,res_order_type,description,apply_order_id,state,store_id,user_id,user_name,b_id)
  35. values
  36. (#{operate},#{resOrderType},#{description},#{applyOrderId},#{state},#{storeId},#{userId},#{userName},#{bId})
  37. </insert>
  38. <!-- 保存采购明细表备份表 -->
  39. <insert id="saveBusinessPurchaseApplyDetailInfo" parameterType="List">
  40. insert into business_purchase_apply_detail (apply_order_id,res_id,quantity,remark,b_id,operate)
  41. values
  42. <foreach collection="list" item="item" index="index" separator=",">
  43. (
  44. #{item.applyOrderId},
  45. #{item.resId},
  46. #{item.quantity},
  47. #{item.remark},
  48. #{item.bId},
  49. #{item.operate}
  50. )
  51. </foreach>
  52. </insert>
  53. <!-- 保存采购明细表-->
  54. <insert id="savePurchaseApplyDetailInfo" parameterType="List">
  55. insert into purchase_apply_detail (apply_order_id,res_id,quantity,remark,b_id,operate)
  56. values
  57. <foreach collection="list" item="item" index="index" separator=",">
  58. (
  59. #{item.applyOrderId},
  60. #{item.resId},
  61. #{item.quantity},
  62. #{item.remark},
  63. #{item.bId},
  64. #{item.operate}
  65. )
  66. </foreach>
  67. </insert>
  68. <!-- 查询采购申请信息(Business) add by wuxw 2018-07-03 -->
  69. <select id="getBusinessPurchaseApplyInfo" parameterType="Map" resultType="Map">
  70. select
  71. t.operate,t.res_order_type resOrderType,
  72. t.description,
  73. t.apply_order_id applyOrderId,t.state,
  74. t.store_id storeId,
  75. t.user_name userName,t.b_id bId,t.user_id userId
  76. from business_purchase_apply t
  77. where 1 =1
  78. <if test="operate !=null and operate != ''">
  79. and t.operate= #{operate}
  80. </if>
  81. <if test="resOrderType !=null and resOrderType != ''">
  82. and t.res_order_type= #{resOrderType}
  83. </if>
  84. <if test="description !=null and description != ''">
  85. and t.description= #{description}
  86. </if>
  87. <if test="applyOrderId !=null and applyOrderId != ''">
  88. and t.apply_order_id= #{applyOrderId}
  89. </if>
  90. <if test="state !=null and state != ''">
  91. and t.state= #{state}
  92. </if>
  93. <if test="storeId !=null and storeId != ''">
  94. and t.store_id= #{storeId}
  95. </if>
  96. <if test="bId !=null and bId != ''">
  97. and t.b_id= #{bId}
  98. </if>
  99. <if test="userId !=null and userId != ''">
  100. and t.user_id= #{userId}
  101. </if>
  102. </select>
  103. <select id="getBusinessPurchaseApplyDetailInfo" parameterType="Map" resultType="Map">
  104. select
  105. t.apply_order_id applyOrderId,t.b_id bId,t.res_id resId,t.quantity,t.remark,t.operate
  106. from business_purchase_apply_detail t
  107. where 1 =1
  108. <if test="operate !=null and operate != ''">
  109. and t.operate= #{operate}
  110. </if>
  111. <if test="description !=null and description != ''">
  112. and t.description= #{description}
  113. </if>
  114. <if test="applyOrderId !=null and applyOrderId != ''">
  115. and t.apply_order_id= #{applyOrderId}
  116. </if>
  117. <if test="bId !=null and bId != ''">
  118. and t.b_id= #{bId}
  119. </if>
  120. </select>
  121. <!-- 保存采购申请信息至 instance表中 add by wuxw 2018-07-03 -->
  122. <insert id="savePurchaseApplyInfoInstance" parameterType="Map">
  123. insert into purchase_apply
  124. (res_order_type,description,apply_order_id,status_cd,state,store_id,user_name,b_id,user_id)
  125. select
  126. t.res_order_type,t.description,t.apply_order_id,'0',t.state,t.store_id,t.user_name,t.b_id,t.user_id
  127. from business_purchase_apply t where 1=1
  128. and t.operate= 'ADD'
  129. <if test="resOrderType !=null and resOrderType != ''">
  130. and t.res_order_type= #{resOrderType}
  131. </if>
  132. <if test="description !=null and description != ''">
  133. and t.description= #{description}
  134. </if>
  135. <if test="applyOrderId !=null and applyOrderId != ''">
  136. and t.apply_order_id= #{applyOrderId}
  137. </if>
  138. <if test="state !=null and state != ''">
  139. and t.state= #{state}
  140. </if>
  141. <if test="storeId !=null and storeId != ''">
  142. and t.store_id= #{storeId}
  143. </if>
  144. <if test="bId !=null and bId != ''">
  145. and t.b_id= #{bId}
  146. </if>
  147. <if test="userId !=null and userId != ''">
  148. and t.user_id= #{userId}
  149. </if>
  150. </insert>
  151. <!-- 查询采购申请信息 add by wuxw 2018-07-03 -->
  152. <select id="getPurchaseApplyInfo" parameterType="Map" resultType="Map">
  153. select
  154. t.res_order_type resOrderType,t.description,
  155. t.apply_order_id applyOrderId,t.status_cd statusCd,t.state,
  156. t.store_id storeId,t.user_name userName,
  157. t.b_id bId,t.user_id userId,t.create_time createTime,d.name stateName
  158. from purchase_apply t
  159. inner join t_dict d on t.state = d.status_cd and d.table_name = 'purchase_apply' and d.table_columns = 'state'
  160. where 1 =1
  161. <if test="resOrderType !=null and resOrderType != ''">
  162. and t.res_order_type= #{resOrderType}
  163. </if>
  164. <if test="description !=null and description != ''">
  165. and t.description= #{description}
  166. </if>
  167. <if test="applyOrderId !=null and applyOrderId != ''">
  168. and t.apply_order_id= #{applyOrderId}
  169. </if>
  170. <if test="userName !=null and userName != ''">
  171. and t.user_name like concat('%',#{userName},'%')
  172. </if>
  173. <if test="statusCd !=null and statusCd != ''">
  174. and t.status_cd= #{statusCd}
  175. </if>
  176. <if test="state !=null and state != ''">
  177. and t.state= #{state}
  178. </if>
  179. <if test="storeId !=null and storeId != ''">
  180. and t.store_id= #{storeId}
  181. </if>
  182. <if test="bId !=null and bId != ''">
  183. and t.b_id= #{bId}
  184. </if>
  185. order by t.create_time desc
  186. <if test="page != -1 and page != null ">
  187. limit #{page}, #{row}
  188. </if>
  189. </select>
  190. <select id="getPurchaseApplyInfo2" parameterType="Map" resultMap="applyMap">
  191. select
  192. t.res_order_type resOrderType,t.description,
  193. t.apply_order_id applyOrderId,t.status_cd statusCd,t.state,
  194. t.store_id storeId,t.user_name userName,
  195. t.b_id bId,t.user_id userId,t.create_time createTime,d.name stateName,
  196. de.apply_order_id applyOrderId,de.res_id resId,de.quantity,de.remark,rs.res_name resName,rs.price,rs.stock,rs.res_code resCode
  197. from purchase_apply t
  198. inner join t_dict d on t.state = d.status_cd and d.table_name = 'purchase_apply' and d.table_columns = 'state'
  199. inner join purchase_apply_detail de on de.apply_order_id = t.apply_order_id
  200. inner join resource_store rs on de.res_id = rs.res_id
  201. where 1 =1
  202. <if test="resOrderType !=null and resOrderType != ''">
  203. and t.res_order_type= #{resOrderType}
  204. </if>
  205. <if test="applyOrderId !=null and applyOrderId != ''">
  206. and t.apply_order_id= #{applyOrderId}
  207. </if>
  208. <if test="statusCd !=null and statusCd != ''">
  209. and t.status_cd= #{statusCd}
  210. </if>
  211. <if test="state !=null and state != ''">
  212. and t.state= #{state}
  213. </if>
  214. <if test="storeId !=null and storeId != ''">
  215. and t.store_id= #{storeId}
  216. </if>
  217. <if test="bId !=null and bId != ''">
  218. and t.b_id= #{bId}
  219. </if>
  220. order by t.create_time desc
  221. <if test="page != -1 and page != null ">
  222. limit #{page}, #{row}
  223. </if>
  224. </select>
  225. <!-- 查询采购明细 -->
  226. <select id="getPurchaseApplyDetailInfo" parameterType="Map" resultType="Map">
  227. select
  228. p.apply_order_id applyOrderId,
  229. p.res_id resId,p.quantity,p.remark,
  230. r.res_name resName,r.res_code resCode,
  231. r.price,r.stock
  232. from
  233. purchase_apply_detail p inner join resource_store r on p.res_id = r.res_id
  234. where 1=1
  235. <if test="applyOrderIds !=null">
  236. and p.apply_order_id in
  237. <foreach collection="applyOrderIds" item="item" open="(" close=")" separator=",">
  238. #{item}
  239. </foreach>
  240. </if>
  241. <if test="bId !=null and bId != ''">
  242. and p.b_id= #{bId}
  243. </if>
  244. <if test="operate !=null and operate != ''">
  245. and p.operate= #{operate}
  246. </if>
  247. </select>
  248. <!-- 修改采购申请信息 add by wuxw 2018-07-03 -->
  249. <update id="updatePurchaseApplyInfoInstance" parameterType="Map">
  250. update purchase_apply t set t.status_cd = #{statusCd}
  251. <if test="newBId != null and newBId != ''">
  252. ,t.b_id = #{newBId}
  253. </if>
  254. <if test="applyDetailId !=null and applyDetailId != ''">
  255. , t.apply_detail_id= #{applyDetailId}
  256. </if>
  257. <if test="resOrderType !=null and resOrderType != ''">
  258. , t.res_order_type= #{resOrderType}
  259. </if>
  260. <if test="description !=null and description != ''">
  261. , t.description= #{description}
  262. </if>
  263. <if test="state !=null and state != ''">
  264. , t.state= #{state}
  265. </if>
  266. <if test="storeId !=null and storeId != ''">
  267. , t.store_id= #{storeId}
  268. </if>
  269. <if test="userId !=null and userId != ''">
  270. , t.user_id= #{userId}
  271. </if>
  272. where 1=1
  273. <if test="applyOrderId !=null and applyOrderId != ''">
  274. and t.apply_order_id= #{applyOrderId}
  275. </if>
  276. <if test="bId !=null and bId != ''">
  277. and t.b_id= #{bId}
  278. </if>
  279. </update>
  280. <!-- 查询采购申请数量 add by wuxw 2018-07-03 -->
  281. <select id="queryPurchaseApplysCount" parameterType="Map" resultType="Map">
  282. select count(1) count
  283. from purchase_apply t
  284. where 1 =1
  285. <if test="resOrderType !=null and resOrderType != ''">
  286. and t.res_order_type= #{resOrderType}
  287. </if>
  288. <if test="description !=null and description != ''">
  289. and t.description= #{description}
  290. </if>
  291. <if test="applyOrderId !=null and applyOrderId != ''">
  292. and t.apply_order_id= #{applyOrderId}
  293. </if>
  294. <if test="statusCd !=null and statusCd != ''">
  295. and t.status_cd= #{statusCd}
  296. </if>
  297. <if test="state !=null and state != ''">
  298. and t.state= #{state}
  299. </if>
  300. <if test="storeId !=null and storeId != ''">
  301. and t.store_id= #{storeId}
  302. </if>
  303. <if test="bId !=null and bId != ''">
  304. and t.b_id= #{bId}
  305. </if>
  306. </select>
  307. </mapper>