ProdInOutMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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.usoftchina.saas.purchase.mapper.ProdInOutMapper">
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.purchase.po.ProdInOut">
  5. <id column="pi_id" jdbcType="INTEGER" property="id" />
  6. <result column="pi_inoutno" jdbcType="VARCHAR" property="pi_inoutno" />
  7. <result column="pi_class" jdbcType="VARCHAR" property="pi_class" />
  8. <result column="pi_date" jdbcType="TIMESTAMP" property="pi_date" />
  9. <result column="pi_vendid" jdbcType="INTEGER" property="pi_vendid" />
  10. <result column="pi_vendcode" jdbcType="VARCHAR" property="pi_vendcode" />
  11. <result column="pi_vendname" jdbcType="VARCHAR" property="pi_vendname" />
  12. <result column="pi_custid" jdbcType="INTEGER" property="pi_custid" />
  13. <result column="pi_custcode" jdbcType="VARCHAR" property="pi_custcode" />
  14. <result column="pi_custname" jdbcType="VARCHAR" property="pi_custname" />
  15. <result column="pi_puid" jdbcType="INTEGER" property="pi_puid" />
  16. <result column="pi_pucode" jdbcType="VARCHAR" property="pi_pucode" />
  17. <result column="pi_said" jdbcType="INTEGER" property="pi_said" />
  18. <result column="pi_sacode" jdbcType="VARCHAR" property="pi_sacode" />
  19. <result column="pi_total" jdbcType="DOUBLE" property="pi_total" />
  20. <result column="pi_status" jdbcType="VARCHAR" property="pi_status" />
  21. <result column="pi_statuscode" jdbcType="VARCHAR" property="pi_statuscode" />
  22. <result column="pi_printstatus" jdbcType="VARCHAR" property="pi_printstatus" />
  23. <result column="pi_printstatuscode" jdbcType="VARCHAR" property="pi_printstatuscode" />
  24. <result column="companyid" property="companyId" jdbcType="BIGINT" />
  25. <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
  26. <result column="updaterName" jdbcType="VARCHAR" property="updaterName" />
  27. <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
  28. <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
  29. <result column="creatorName" jdbcType="VARCHAR" property="creatorName" />
  30. <result column="createtime" property="createTime" jdbcType="TIMESTAMP" />
  31. <result column="pi_text1" jdbcType="VARCHAR" property="pi_text1" />
  32. <result column="pi_text2" jdbcType="VARCHAR" property="pi_text2" />
  33. <result column="pi_text3" jdbcType="VARCHAR" property="pi_text3" />
  34. <result column="pi_text4" jdbcType="VARCHAR" property="pi_text4" />
  35. <result column="pi_text5" jdbcType="VARCHAR" property="pi_text5" />
  36. <result column="pi_auditdate" jdbcType="TIMESTAMP" property="pi_auditdate" />
  37. <result column="pi_auditman" jdbcType="VARCHAR" property="pi_auditman" />
  38. <result column="pi_remark" jdbcType="VARCHAR" property="pi_remark" />
  39. <result column="pi_ioid" jdbcType="INTEGER" property="pi_ioid" />
  40. <result column="pi_iocode" jdbcType="VARCHAR" property="pi_iocode" />
  41. <result column="pi_prstatus" jdbcType="VARCHAR" property="pi_prstatus" />
  42. <result column="pi_prstatuscode" jdbcType="VARCHAR" property="pi_prstatuscode" />
  43. <result column="pi_currency" jdbcType="VARCHAR" property="pi_currency" />
  44. <result column="pi_buyerid" jdbcType="INTEGER" property="pi_buyerid" />
  45. <result column="pi_buyercode" jdbcType="VARCHAR" property="pi_buyercode" />
  46. <result column="pi_buyername" jdbcType="VARCHAR" property="pi_buyername" />
  47. <result column="pi_sellerid" jdbcType="INTEGER" property="pi_sellerid" />
  48. <result column="pi_sellercode" jdbcType="VARCHAR" property="pi_sellercode" />
  49. <result column="pi_seller" jdbcType="VARCHAR" property="pi_seller" />
  50. </resultMap>
  51. <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.usoftchina.saas.purchase.po.ProdInOut">
  52. <result column="pi_address" jdbcType="LONGVARCHAR" property="pi_address" />
  53. </resultMap>
  54. <sql id="Base_Column_List">
  55. pi_id, pi_inoutno, pi_class, pi_date, pi_vendid, pi_vendcode, pi_vendname, pi_custid,
  56. pi_custcode, pi_custname, pi_puid, pi_pucode, pi_said, pi_sacode, pi_total, pi_status, pi_statuscode, pi_printstatus, pi_printstatuscode,
  57. companyid, updaterid,updaterName,updatetime,creatorid,creatorName,createtime, pi_text1, pi_text2, pi_text3, pi_text4, pi_text5,pi_auditdate,
  58. pi_auditman,pi_remark,pi_ioid,pi_iocode,pi_prstatus,pi_prstatuscode,pi_currency,pi_buyerid,pi_buyercode,pi_buyername,pi_sellerid,pi_sellercode,pi_seller
  59. </sql>
  60. <sql id="Blob_Column_List">
  61. pi_address
  62. </sql>
  63. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
  64. select
  65. <include refid="Base_Column_List" />
  66. ,
  67. <include refid="Blob_Column_List" />
  68. from prodinout
  69. where pi_id = #{pi_id,jdbcType=INTEGER}
  70. </select>
  71. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  72. delete from prodinout
  73. where pi_id = #{pi_id,jdbcType=INTEGER}
  74. </delete>
  75. <insert id="insertSelective" parameterType="com.usoftchina.saas.purchase.po.ProdInOut">
  76. <selectKey resultType="java.lang.Long" keyProperty="id">
  77. SELECT LAST_INSERT_ID() AS ID
  78. </selectKey>
  79. insert into prodinout
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="pi_inoutno != null">
  82. pi_inoutno,
  83. </if>
  84. <if test="pi_class != null">
  85. pi_class,
  86. </if>
  87. <if test="pi_date != null">
  88. pi_date,
  89. </if>
  90. <if test="pi_vendid != null">
  91. pi_vendid,
  92. </if>
  93. <if test="pi_vendcode != null">
  94. pi_vendcode,
  95. </if>
  96. <if test="pi_vendname != null">
  97. pi_vendname,
  98. </if>
  99. <if test="pi_custid != null">
  100. pi_custid,
  101. </if>
  102. <if test="pi_custcode != null">
  103. pi_custcode,
  104. </if>
  105. <if test="pi_custname != null">
  106. pi_custname,
  107. </if>
  108. <if test="pi_puid != null">
  109. pi_puid,
  110. </if>
  111. <if test="pi_pucode != null">
  112. pi_pucode,
  113. </if>
  114. <if test="pi_said != null">
  115. pi_said,
  116. </if>
  117. <if test="pi_sacode != null">
  118. pi_sacode,
  119. </if>
  120. <if test="pi_total != null">
  121. pi_total,
  122. </if>
  123. <if test="pi_status != null">
  124. pi_status,
  125. </if>
  126. <if test="pi_statuscode != null">
  127. pi_statuscode,
  128. </if>
  129. <if test="pi_printstatus != null">
  130. pi_printstatus,
  131. </if>
  132. <if test="pi_printstatuscode != null">
  133. pi_printstatuscode,
  134. </if>
  135. <if test="companyId != null" >
  136. companyid,
  137. </if>
  138. <if test="updaterId != null" >
  139. updaterId,
  140. </if>
  141. <if test="updaterName != null" >
  142. updaterName,
  143. </if>
  144. <if test="updateTime != null" >
  145. updateTime,
  146. </if>
  147. <if test="creatorId != null" >
  148. creatorId,
  149. </if>
  150. <if test="creatorName != null" >
  151. creatorName,
  152. </if>
  153. <if test="createTime != null" >
  154. createTime,
  155. </if>
  156. <if test="pi_text1 != null">
  157. pi_text1,
  158. </if>
  159. <if test="pi_text2 != null">
  160. pi_text2,
  161. </if>
  162. <if test="pi_text3 != null">
  163. pi_text3,
  164. </if>
  165. <if test="pi_text4 != null">
  166. pi_text4,
  167. </if>
  168. <if test="pi_text5 != null">
  169. pi_text5,
  170. </if>
  171. <if test="pi_address != null">
  172. pi_address,
  173. </if>
  174. <if test="pi_auditdate != null">
  175. pi_auditdate,
  176. </if>
  177. <if test="pi_auditman != null">
  178. pi_auditman,
  179. </if>
  180. <if test="pi_remark != null">
  181. pi_remark,
  182. </if>
  183. <if test="pi_ioid != null">
  184. pi_ioid,
  185. </if>
  186. <if test="pi_iocode != null">
  187. pi_iocode,
  188. </if>
  189. <if test="pi_prstatus != null">
  190. pi_prstatus,
  191. </if>
  192. <if test="pi_prstatuscode != null">
  193. pi_prstatuscode,
  194. </if>
  195. <if test="pi_currency != null">
  196. pi_currency,
  197. </if>
  198. <if test="pi_buyerid != null">
  199. pi_buyerid,
  200. </if>
  201. <if test="pi_buyercode != null">
  202. pi_buyercode,
  203. </if>
  204. <if test="pi_buyername != null">
  205. pi_buyername,
  206. </if>
  207. </trim>
  208. <trim prefix="values (" suffix=")" suffixOverrides=",">
  209. <if test="pi_inoutno != null">
  210. #{pi_inoutno,jdbcType=VARCHAR},
  211. </if>
  212. <if test="pi_class != null">
  213. #{pi_class,jdbcType=VARCHAR},
  214. </if>
  215. <if test="pi_date != null">
  216. #{pi_date,jdbcType=TIMESTAMP},
  217. </if>
  218. <if test="pi_vendid != null">
  219. #{pi_vendid,jdbcType=INTEGER},
  220. </if>
  221. <if test="pi_vendcode != null">
  222. #{pi_vendcode,jdbcType=VARCHAR},
  223. </if>
  224. <if test="pi_vendname != null">
  225. #{pi_vendname,jdbcType=VARCHAR},
  226. </if>
  227. <if test="pi_custid != null">
  228. #{pi_custid,jdbcType=INTEGER},
  229. </if>
  230. <if test="pi_custcode != null">
  231. #{pi_custcode,jdbcType=VARCHAR},
  232. </if>
  233. <if test="pi_custname != null">
  234. #{pi_custname,jdbcType=VARCHAR},
  235. </if>
  236. <if test="pi_puid != null">
  237. #{pi_puid,jdbcType=INTEGER},
  238. </if>
  239. <if test="pi_pucode != null">
  240. #{pi_pucode,jdbcType=VARCHAR},
  241. </if>
  242. <if test="pi_said != null">
  243. #{pi_said,jdbcType=INTEGER},
  244. </if>
  245. <if test="pi_sacode != null">
  246. #{pi_sacode,jdbcType=VARCHAR},
  247. </if>
  248. <if test="pi_total != null">
  249. #{pi_total,jdbcType=DOUBLE},
  250. </if>
  251. <if test="pi_status != null">
  252. #{pi_status,jdbcType=VARCHAR},
  253. </if>
  254. <if test="pi_statuscode != null">
  255. #{pi_statuscode,jdbcType=VARCHAR},
  256. </if>
  257. <if test="pi_printstatus != null">
  258. #{pi_printstatus,jdbcType=VARCHAR},
  259. </if>
  260. <if test="pi_printstatuscode != null">
  261. #{pi_printstatuscode,jdbcType=VARCHAR},
  262. </if>
  263. <if test="companyId != null" >
  264. #{companyId,jdbcType=INTEGER},
  265. </if>
  266. <if test="updaterId != null" >
  267. #{updaterId,jdbcType=INTEGER},
  268. </if>
  269. <if test="updaterName != null">
  270. #{updaterName,jdbcType=VARCHAR},
  271. </if>
  272. <if test="updateTime != null" >
  273. #{updateTime,jdbcType=TIMESTAMP},
  274. </if>
  275. <if test="creatorId != null" >
  276. #{creatorId,jdbcType=INTEGER},
  277. </if>
  278. <if test="creatorName != null">
  279. #{creatorName,jdbcType=VARCHAR},
  280. </if>
  281. <if test="createTime != null" >
  282. #{createTime,jdbcType=TIMESTAMP},
  283. </if>
  284. <if test="pi_text1 != null">
  285. #{pi_text1,jdbcType=VARCHAR},
  286. </if>
  287. <if test="pi_text2 != null">
  288. #{pi_text2,jdbcType=VARCHAR},
  289. </if>
  290. <if test="pi_text3 != null">
  291. #{pi_text3,jdbcType=VARCHAR},
  292. </if>
  293. <if test="pi_text4 != null">
  294. #{pi_text4,jdbcType=VARCHAR},
  295. </if>
  296. <if test="pi_text5 != null">
  297. #{pi_text5,jdbcType=VARCHAR},
  298. </if>
  299. <if test="pi_address != null">
  300. #{pi_address,jdbcType=LONGVARCHAR},
  301. </if>
  302. <if test="pi_auditdate != null">
  303. #{pi_auditdate,jdbcType=TIMESTAMP},
  304. </if>
  305. <if test="pi_auditman != null">
  306. #{pi_auditman,jdbcType=VARCHAR},
  307. </if>
  308. <if test="pi_remark != null">
  309. #{pi_remark,jdbcType=VARCHAR},
  310. </if>
  311. <if test="pi_ioid != null">
  312. #{pi_ioid,jdbcType=INTEGER},
  313. </if>
  314. <if test="pi_iocode != null">
  315. #{pi_iocode,jdbcType=VARCHAR},
  316. </if>
  317. <if test="pi_prstatus != null">
  318. #{pi_prstatus,jdbcType=VARCHAR},
  319. </if>
  320. <if test="pi_prstatuscode != null">
  321. #{pi_prstatuscode,jdbcType=VARCHAR},
  322. </if>
  323. <if test="pi_currency != null">
  324. #{pi_currency,jdbcType=VARCHAR},
  325. </if>
  326. <if test="pi_buyerid != null">
  327. #{pi_buyerid,jdbcType=VARCHAR},
  328. </if>
  329. <if test="pi_buyercode != null">
  330. #{pi_buyercode,jdbcType=VARCHAR},
  331. </if>
  332. <if test="pi_buyername != null">
  333. #{pi_buyername,jdbcType=VARCHAR},
  334. </if>
  335. </trim>
  336. </insert>
  337. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.purchase.po.ProdInOut">
  338. update prodinout
  339. <set>
  340. <if test="pi_inoutno != null">
  341. pi_inoutno = #{pi_inoutno,jdbcType=VARCHAR},
  342. </if>
  343. <if test="pi_class != null">
  344. pi_class = #{pi_class,jdbcType=VARCHAR},
  345. </if>
  346. <if test="pi_date != null">
  347. pi_date = #{pi_date,jdbcType=TIMESTAMP},
  348. </if>
  349. <if test="pi_vendid != null">
  350. pi_vendid = #{pi_vendid,jdbcType=INTEGER},
  351. </if>
  352. <if test="pi_vendcode != null">
  353. pi_vendcode = #{pi_vendcode,jdbcType=VARCHAR},
  354. </if>
  355. <if test="pi_vendname != null">
  356. pi_vendname = #{pi_vendname,jdbcType=VARCHAR},
  357. </if>
  358. <if test="pi_custid != null">
  359. pi_custid = #{pi_custid,jdbcType=INTEGER},
  360. </if>
  361. <if test="pi_custcode != null">
  362. pi_custcode = #{pi_custcode,jdbcType=VARCHAR},
  363. </if>
  364. <if test="pi_custname != null">
  365. pi_custname = #{pi_custname,jdbcType=VARCHAR},
  366. </if>
  367. <if test="pi_puid != null">
  368. pi_puid = #{pi_puid,jdbcType=INTEGER},
  369. </if>
  370. <if test="pi_pucode != null">
  371. pi_pucode = #{pi_pucode,jdbcType=VARCHAR},
  372. </if>
  373. <if test="pi_said != null">
  374. pi_said = #{pi_said,jdbcType=INTEGER},
  375. </if>
  376. <if test="pi_sacode != null">
  377. pi_sacode = #{pi_sacode,jdbcType=VARCHAR},
  378. </if>
  379. <if test="pi_total != null">
  380. pi_total = #{pi_total,jdbcType=DOUBLE},
  381. </if>
  382. <if test="pi_status != null">
  383. pi_status = #{pi_status,jdbcType=VARCHAR},
  384. </if>
  385. <if test="pi_statuscode != null">
  386. pi_statuscode = #{pi_statuscode,jdbcType=VARCHAR},
  387. </if>
  388. <if test="pi_printstatus != null">
  389. pi_printstatus = #{pi_printstatus,jdbcType=VARCHAR},
  390. </if>
  391. <if test="pi_printstatuscode != null">
  392. pi_printstatuscode = #{pi_printstatuscode,jdbcType=VARCHAR},
  393. </if>
  394. <if test="companyId != null" >
  395. companyid = #{companyId,jdbcType=INTEGER},
  396. </if>
  397. <if test="updaterId != null" >
  398. updaterId = #{updaterId,jdbcType=INTEGER},
  399. </if>
  400. <if test="updateTime != null" >
  401. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  402. </if>
  403. <if test="pi_text1 != null">
  404. pi_text1 = #{pi_text1,jdbcType=VARCHAR},
  405. </if>
  406. <if test="pi_text2 != null">
  407. pi_text2 = #{pi_text2,jdbcType=VARCHAR},
  408. </if>
  409. <if test="pi_text3 != null">
  410. pi_text3 = #{pi_text3,jdbcType=VARCHAR},
  411. </if>
  412. <if test="pi_text4 != null">
  413. pi_text4 = #{pi_text4,jdbcType=VARCHAR},
  414. </if>
  415. <if test="pi_text5 != null">
  416. pi_text5 = #{pi_text5,jdbcType=VARCHAR},
  417. </if>
  418. <if test="pi_address != null">
  419. pi_address = #{pi_address,jdbcType=LONGVARCHAR},
  420. </if>
  421. <if test="pi_auditdate != null">
  422. pi_auditdate = #{pi_auditdate,jdbcType=TIMESTAMP},
  423. </if>
  424. <if test="pi_auditman != null">
  425. pi_auditman = #{pi_auditman,jdbcType=VARCHAR},
  426. </if>
  427. <if test="pi_remark != null">
  428. pi_remark = #{pi_remark,jdbcType=VARCHAR},
  429. </if>
  430. <if test="pi_currency != null">
  431. pi_currency = #{pi_currency,jdbcType=VARCHAR},
  432. </if>
  433. <if test="pi_buyerid != null">
  434. pi_buyerid = #{pi_buyerid,jdbcType=INTEGER},
  435. </if>
  436. <if test="pi_buyercode != null">
  437. pi_buyercode = #{pi_buyercode,jdbcType=VARCHAR},
  438. </if>
  439. <if test="pi_buyername != null">
  440. pi_buyername = #{pi_buyername,jdbcType=VARCHAR},
  441. </if>
  442. </set>
  443. where pi_id = #{id,jdbcType=INTEGER}
  444. </update>
  445. <select id="validateCodeWhenInsert" resultType="int">
  446. select count(1) from prodinout where pi_inoutno = #{pi_inoutno} and companyid = #{companyId}
  447. </select>
  448. <select id="validateCodeWhenUpdate" resultType="int" >
  449. select count(1) from prodinout where pi_inoutno = #{pi_inoutno} and pi_id != #{id} and companyid = #{companyId}
  450. </select>
  451. <select id="selectCodeById" resultType="string" parameterType="long">
  452. select pi_inoutno from prodinout where pi_id=#{id}
  453. </select>
  454. <select id="checkQtyFromPurchase" resultType="int" parameterType="string">
  455. select count(1) from(
  456. select sum(pd_inqty) nowqty,(select pd_qty from purchasedetail where pd_id = pd_orderid) totalqty from prodiodetail where pd_ordercode=#{pu_code}
  457. GROUP BY pd_orderid) t where t.nowqty>t.totalqty
  458. </select>
  459. <select id="checkQtyFromProdIn" resultType="int" parameterType="long">
  460. select count(1) from(
  461. select sum(b.pd_outqty) nowqty,(select a.pd_inqty from prodiodetail a where a.pd_id = b.pd_ioid and a.pd_piclass='采购验收单') totalqty from prodiodetail b where b.pd_piid = #{id} and b.pd_piclass='采购验退单'
  462. GROUP BY b.pd_ioid) t where t.nowqty>t.totalqty
  463. </select>
  464. <update id="updateCreator">
  465. update prodinout set creatorId = #{userId} , creatorName=#{userName} where pi_id=#{id}
  466. </update>
  467. </mapper>