ProdInOutMapper.xml 15 KB

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