PurchaseApplyServiceDaoImplMapper.xml 15 KB

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