VendApamountMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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.document.mapper.VendApamountMapper">
  4. <resultMap id="VendApamountResultMapper" type="com.usoftchina.saas.document.entities.VendApamount">
  5. <id column="va_id" jdbcType="INTEGER" property="id" />
  6. <result column="va_vendid" jdbcType="INTEGER" property="va_vendid" />
  7. <result column="va_vendcode" jdbcType="VARCHAR" property="va_vendcode" />
  8. <result column="va_vendname" jdbcType="VARCHAR" property="va_vendname" />
  9. <result column="va_currency" jdbcType="VARCHAR" property="va_currency" />
  10. <result column="va_begindate" jdbcType="TIMESTAMP" property="va_begindate" />
  11. <result column="va_beginapamount" jdbcType="DOUBLE" property="va_beginapamount" />
  12. <result column="va_beginprepayamount" jdbcType="DOUBLE" property="va_beginprepayamount" />
  13. <result column="va_payamount" jdbcType="DOUBLE" property="va_payamount" />
  14. <result column="va_preamount" jdbcType="DOUBLE" property="va_preamount" />
  15. <result column="va_leftamount" jdbcType="DOUBLE" property="va_leftamount" />
  16. <result column="companyId" jdbcType="INTEGER" property="companyId" />
  17. <result column="updaterId" jdbcType="INTEGER" property="updaterId" />
  18. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
  19. <result column="creatorName" jdbcType="VARCHAR" property="creatorName" />
  20. <result column="creatorId" jdbcType="INTEGER" property="creatorId" />
  21. <result column="createTime" jdbcType="TIMESTAMP" property="createTime" />
  22. <result column="updaterName" jdbcType="VARCHAR" property="updaterName" />
  23. </resultMap>
  24. <resultMap id="VendApamountListResultMapper" type="com.usoftchina.saas.document.entities.VendApamountList">
  25. <id column="va_id" jdbcType="INTEGER" property="id" />
  26. <result column="va_vendid" jdbcType="INTEGER" property="va_vendid" />
  27. <result column="va_vendcode" jdbcType="VARCHAR" property="va_vendcode" />
  28. <result column="va_vendname" jdbcType="VARCHAR" property="va_vendname" />
  29. <result column="va_currency" jdbcType="VARCHAR" property="va_currency" />
  30. <result column="va_begindate" jdbcType="TIMESTAMP" property="va_begindate" />
  31. <result column="va_beginapamount" jdbcType="DOUBLE" property="va_beginapamount" />
  32. <result column="va_beginprepayamount" jdbcType="DOUBLE" property="va_beginprepayamount" />
  33. <result column="va_payamount" jdbcType="DOUBLE" property="va_payamount" />
  34. <result column="va_preamount" jdbcType="DOUBLE" property="va_preamount" />
  35. <result column="va_leftamount" jdbcType="DOUBLE" property="va_leftamount" />
  36. </resultMap>
  37. <select id="getListDataByCondition" resultMap="VendApamountListResultMapper">
  38. SELECT * FROM VendApamount
  39. <where>
  40. <if test="condition!=null">
  41. ${condition}
  42. </if>
  43. AND VENDAPAMOUNT.COMPANYID = #{companyId}
  44. AND VENDAPAMOUNT.VA_BEGINDATE IS NOT NULL
  45. </where>
  46. order by VA_ID DESC
  47. </select>
  48. <sql id="Base_Column_List">
  49. va_id, va_vendid, va_vendcode, va_vendname, va_currency, va_begindate, va_beginapamount,
  50. va_beginprepayamount, va_payamount, va_preamount, va_leftamount, companyId, updaterId,
  51. updateTime, creatorName, creatorId, createTime, updaterName
  52. </sql>
  53. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="VendApamountResultMapper">
  54. select
  55. <include refid="Base_Column_List" />
  56. from vendapamount
  57. where va_id = #{id}
  58. </select>
  59. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  60. delete from vendapamount
  61. where va_id = #{id}
  62. </delete>
  63. <select id="selectPeriod" resultType="string">
  64. select PD_DETNO from periodsdetail where companyid=#{companyId} and pd_detno is not null and pd_status=0 order by PD_DETNO LIMIT 1;
  65. </select>
  66. <select id="check" parameterMap="checkParamMap" statementType="CALLABLE">
  67. CALL SP_BEGINLIMIT(?, ?, ?, ?, ?,?)
  68. </select>
  69. <parameterMap id="checkParamMap" type="java.util.Map">
  70. <parameter property="v_type" jdbcType="VARCHAR" mode="IN" />
  71. <parameter property="v_id" jdbcType="INTEGER" mode="IN" />
  72. <parameter property="v_code" jdbcType="VARCHAR" mode="IN" />
  73. <parameter property="v_currency" jdbcType="VARCHAR" mode="IN" />
  74. <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
  75. <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
  76. </parameterMap>
  77. <select id="checkForImport" parameterMap="checkForImportParamMap" statementType="CALLABLE">
  78. CALL SP_CUSTARORVENDAPAFTER(?, ?)
  79. </select>
  80. <parameterMap id="checkForImportParamMap" type="java.util.Map">
  81. <parameter property="v_type" jdbcType="VARCHAR" mode="IN" />
  82. <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
  83. </parameterMap>
  84. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.VendApamount">
  85. <selectKey resultType="java.lang.Long" keyProperty="id">
  86. SELECT LAST_INSERT_ID() AS ID
  87. </selectKey>
  88. insert into vendapamount
  89. <trim prefix="(" suffix=")" suffixOverrides=",">
  90. <if test="va_vendid != null">
  91. va_vendid,
  92. </if>
  93. <if test="va_vendcode != null">
  94. va_vendcode,
  95. </if>
  96. <if test="va_vendname != null">
  97. va_vendname,
  98. </if>
  99. <if test="va_currency != null">
  100. va_currency,
  101. </if>
  102. <if test="va_begindate != null">
  103. va_begindate,
  104. </if>
  105. <if test="va_beginapamount != null">
  106. va_beginapamount,
  107. </if>
  108. <if test="va_beginprepayamount != null">
  109. va_beginprepayamount,
  110. </if>
  111. <if test="va_payamount != null">
  112. va_payamount,
  113. </if>
  114. <if test="va_preamount != null">
  115. va_preamount,
  116. </if>
  117. <if test="va_leftamount != null">
  118. va_leftamount,
  119. </if>
  120. <if test="companyId != null">
  121. companyId,
  122. </if>
  123. <if test="updaterId != null">
  124. updaterId,
  125. </if>
  126. <if test="updateTime != null">
  127. updateTime,
  128. </if>
  129. <if test="creatorName != null">
  130. creatorName,
  131. </if>
  132. <if test="creatorId != null">
  133. creatorId,
  134. </if>
  135. <if test="createTime != null">
  136. createTime,
  137. </if>
  138. <if test="updaterName != null">
  139. updaterName,
  140. </if>
  141. </trim>
  142. <trim prefix="values (" suffix=")" suffixOverrides=",">
  143. <if test="va_vendid != null">
  144. #{va_vendid,jdbcType=INTEGER},
  145. </if>
  146. <if test="va_vendcode != null">
  147. #{va_vendcode,jdbcType=VARCHAR},
  148. </if>
  149. <if test="va_vendname != null">
  150. #{va_vendname,jdbcType=VARCHAR},
  151. </if>
  152. <if test="va_currency != null">
  153. #{va_currency,jdbcType=VARCHAR},
  154. </if>
  155. <if test="va_begindate != null">
  156. #{va_begindate,jdbcType=TIMESTAMP},
  157. </if>
  158. <if test="va_beginapamount != null">
  159. #{va_beginapamount,jdbcType=DOUBLE},
  160. </if>
  161. <if test="va_beginprepayamount != null">
  162. #{va_beginprepayamount,jdbcType=DOUBLE},
  163. </if>
  164. <if test="va_payamount != null">
  165. #{va_payamount,jdbcType=DOUBLE},
  166. </if>
  167. <if test="va_preamount != null">
  168. #{va_preamount,jdbcType=DOUBLE},
  169. </if>
  170. <if test="va_leftamount != null">
  171. #{va_leftamount,jdbcType=DOUBLE},
  172. </if>
  173. <if test="companyId != null">
  174. #{companyId,jdbcType=INTEGER},
  175. </if>
  176. <if test="updaterId != null">
  177. #{updaterId,jdbcType=INTEGER},
  178. </if>
  179. <if test="updateTime != null">
  180. #{updateTime,jdbcType=TIMESTAMP},
  181. </if>
  182. <if test="creatorName != null">
  183. #{creatorName,jdbcType=VARCHAR},
  184. </if>
  185. <if test="creatorId != null">
  186. #{creatorId,jdbcType=INTEGER},
  187. </if>
  188. <if test="createTime != null">
  189. #{createTime,jdbcType=TIMESTAMP},
  190. </if>
  191. <if test="updaterName != null">
  192. #{updaterName,jdbcType=VARCHAR},
  193. </if>
  194. </trim>
  195. </insert>
  196. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.VendApamount">
  197. update vendapamount
  198. <set>
  199. <if test="va_begindate != null">
  200. va_begindate = #{va_begindate,jdbcType=TIMESTAMP},
  201. </if>
  202. <if test="va_beginapamount != null">
  203. va_beginapamount = #{va_beginapamount,jdbcType=DOUBLE},
  204. </if>
  205. <if test="va_beginprepayamount != null">
  206. va_beginprepayamount = #{va_beginprepayamount,jdbcType=DOUBLE},
  207. </if>
  208. <if test="va_leftamount != null">
  209. va_leftamount = #{va_leftamount,jdbcType=DOUBLE},
  210. </if>
  211. <if test="updaterId != null">
  212. updaterId = #{updaterId,jdbcType=INTEGER},
  213. </if>
  214. <if test="updateTime != null">
  215. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  216. </if>
  217. <if test="updaterName != null">
  218. updaterName = #{updaterName,jdbcType=VARCHAR},
  219. </if>
  220. </set>
  221. where va_id = #{id}
  222. </update>
  223. <select id="checkBeginData" resultType="int">
  224. SELECT COUNT(*) FROM periodsdetail
  225. <where>
  226. pd_status = 99
  227. <if test="pd_detno!=null">
  228. and pd_detno=#{pd_detno}
  229. </if>
  230. <if test="companyId!=0 and companyId!=null">
  231. and COMPANYID=#{companyId}
  232. </if>
  233. </where>
  234. </select>
  235. <select id="hasVendNameByCode" resultType="int">
  236. SELECT COUNT(*) FROM vendor
  237. <where>
  238. ve_statuscode = 'ENABLE'
  239. <if test="vendCode!=null">
  240. and ve_code=#{vendCode}
  241. </if>
  242. <if test="vendName!=null">
  243. and ve_Name=#{vendName}
  244. </if>
  245. <if test="companyId!=0 and companyId!=null">
  246. and COMPANYID=#{companyId}
  247. </if>
  248. </where>
  249. </select>
  250. <select id="getVendApamount" resultMap="VendApamountResultMapper">
  251. SELECT * FROM vendapamount
  252. <where>
  253. <if test="id!=null">
  254. and va_id=#{id}
  255. </if>
  256. <if test="companyId!=0 and companyId!=null">
  257. and COMPANYID=#{companyId}
  258. </if>
  259. </where>
  260. </select>
  261. <select id="hasVendCode" resultType="int">
  262. SELECT COUNT(*) FROM vendor
  263. <where>
  264. ve_statuscode = 'ENABLE'
  265. <if test="name!=null">
  266. and VE_CODE=#{name}
  267. </if>
  268. <if test="companyId!=0 and companyId!=null">
  269. and COMPANYID=#{companyId}
  270. </if>
  271. </where>
  272. </select>
  273. <select id="hasCurrency" resultType="int">
  274. SELECT COUNT(*) FROM currencys
  275. <where>
  276. <if test="name!=null">
  277. and cr_name=#{name}
  278. </if>
  279. <if test="companyId!=0 and companyId!=null">
  280. and COMPANYID=#{companyId}
  281. </if>
  282. </where>
  283. </select>
  284. <select id="getVendApamountByVendCodeAndCurrency" resultMap="VendApamountResultMapper">
  285. SELECT * FROM vendapamount
  286. <where>
  287. <if test="vendcode!=null">
  288. and va_vendcode=#{vendcode}
  289. </if>
  290. <if test="currency!=null">
  291. and va_currency=#{currency}
  292. </if>
  293. <if test="id!=0">
  294. and va_id!=#{id}
  295. </if>
  296. <if test="companyId!=0 and companyId!=null">
  297. and COMPANYID=#{companyId}
  298. </if>
  299. </where>
  300. </select>
  301. <update id="updateCodeAndNameByVendid">
  302. update vendapamount inner join vendor on ve_id=va_vendid and vendor.companyid=vendapamount.companyid
  303. set va_vendcode=ve_Code ,
  304. va_vendname=ve_name
  305. where va_vendid=#{ve_id}
  306. </update>
  307. <delete id="deleteByVendid" parameterType="java.lang.Long">
  308. delete from vendapamount
  309. where va_vendid = #{ve_id}
  310. </delete>
  311. <insert id="batchInsert" parameterType="java.util.List">
  312. INSERT INTO vendapamount (va_vendid, va_vendcode, va_vendname, va_currency, va_begindate, va_beginapamount,
  313. va_beginprepayamount, va_payamount, va_preamount, va_leftamount, companyId, creatorName, creatorId, createTime)
  314. VALUES
  315. <foreach collection="list" item="item" index="index" open="" close="" separator=",">
  316. (
  317. #{item.va_vendid,jdbcType=INTEGER},
  318. #{item.va_vendcode,jdbcType=VARCHAR}, #{item.va_vendname,jdbcType=VARCHAR}, #{item.va_currency,jdbcType=VARCHAR},
  319. #{item.va_begindate,jdbcType=TIMESTAMP}, #{item.va_beginapamount,jdbcType=DOUBLE}, #{item.va_beginprepayamount,jdbcType=DOUBLE},
  320. #{item.va_payamount,jdbcType=DOUBLE},#{item.va_preamount,jdbcType=DOUBLE}, #{item.va_leftamount,jdbcType=DOUBLE},
  321. #{item.companyId,jdbcType=INTEGER},#{item.creatorName,jdbcType=VARCHAR}, #{item.creatorId,jdbcType=INTEGER},
  322. #{item.createTime,jdbcType=TIMESTAMP}
  323. )
  324. </foreach>
  325. </insert>
  326. <update id="batchUpdate" parameterType="com.usoftchina.saas.document.entities.VendApamount">
  327. <foreach collection="list" item="item" index="index" separator=";">
  328. update vendapamount
  329. <set>
  330. <if test="item.va_beginapamount != null">
  331. va_beginapamount = #{item.va_beginapamount,jdbcType=DOUBLE},
  332. </if>
  333. <if test="item.va_beginprepayamount != null">
  334. va_beginprepayamount = #{item.va_beginprepayamount,jdbcType=DOUBLE},
  335. </if>
  336. <if test="item.va_leftamount != null">
  337. va_leftamount = #{item.va_leftamount,jdbcType=DOUBLE},
  338. </if>
  339. <if test="item.updaterId != null">
  340. updaterId = #{item.updaterId,jdbcType=INTEGER},
  341. </if>
  342. <if test="item.updateTime != null">
  343. updateTime = #{item.updateTime,jdbcType=TIMESTAMP},
  344. </if>
  345. <if test="item.updaterName != null">
  346. updaterName = #{item.updaterName,jdbcType=VARCHAR},
  347. </if>
  348. </set>
  349. where va_id = #{item.id}
  350. </foreach>
  351. </update>
  352. <select id="checkVerification" resultType="java.lang.Integer">
  353. select count(1) from subledger
  354. where sl_kind='期初余额' and sl_vendid=#{ve_id} and sl_currency=#{currency}
  355. and (ifnull(sl_yamount,0)!=0
  356. or exists(select 1 from verificationdet where vd_slid=sl_id)
  357. or exists(select 1 from verificationdetail where vcd_slid=sl_id))
  358. </select>
  359. </mapper>