AssetMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  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.dk.finance.mapper.fia.AssetMapper">
  4. <!-- **************************************** 数据库基础列映射 **************************************** -->
  5. <resultMap id="Pojo_ResultMap" type="com.dk.finance.model.pojo.fia.Asset">
  6. <id column="doc_id" property="docId"/>
  7. <result column="doc_no" property="docNo"/>
  8. <result column="kind_code" property="kindCode"/>
  9. <result column="status_invoice" property="statusInvoice"/>
  10. <result column="status_flow" property="statusFlow"/>
  11. <result column="org_id" property="orgId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  12. <result column="staff_id" property="staffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  13. <result column="asset_name" property="assetName"/>
  14. <result column="asset_type_id" property="assetTypeId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  15. <result column="calc_method" property="calcMethod"/>
  16. <result column="summary" property="summary"/>
  17. <result column="sum_amt_asset" property="sumAmtAsset"/>
  18. <result column="sum_amt_net_worth" property="sumAmtNetWorth"/>
  19. <result column="sum_amt_net_salvage" property="sumAmtNetSalvage"/>
  20. <result column="total_calc_no" property="totalCalcNo"/>
  21. <result column="sum_amt_calc_month" property="sumAmtCalcMonth"/>
  22. <result column="acc_calc_begin" property="accCalcBegin" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  23. <result column="acc_calc_end" property="accCalcEnd" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  24. <result column="happen_calc_no" property="happenCalcNo"/>
  25. <result column="sum_amt_happen_calc" property="sumAmtHappenCalc"/>
  26. <result column="sum_amt_loss" property="sumAmtLoss"/>
  27. <result column="sum_amt_clear" property="sumAmtClear"/>
  28. <result column="asset_subject_id" property="assetSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  29. <result column="calc_subject_id" property="calcSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  30. <result column="tax_rate" property="taxRate"/>
  31. <result column="sum_amt_tax" property="sumAmtTax"/>
  32. <result column="sum_amt_should" property="sumAmtShould"/>
  33. <result column="mac_id" property="macId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  34. <result column="sum_amt_cash" property="sumAmtCash"/>
  35. <result column="sum_amt_total_cash" property="sumAmtTotalCash"/>
  36. <result column="sum_amt_charge" property="sumAmtCharge"/>
  37. <result column="obj_type" property="objType"/>
  38. <result column="obj_id" property="objId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  39. <result column="flg_init" property="flgInit"/>
  40. <result column="external_no" property="externalNo"/>
  41. <result column="external_system" property="externalSystem"/>
  42. <result column="print_times" property="printTimes"/>
  43. <result column="apv_submit_id" property="apvSubmitId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  44. <result column="apv_staff_ids" property="apvStaffIds" typeHandler="com.dk.common.infrastructure.handler.UuidListTypeHandler"/>
  45. <result column="apv_result_time" property="apvResultTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  46. <result column="annex_paths" property="annexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
  47. <result column="other_annex_paths" property="otherAnnexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
  48. <result column="remarks" property="remarks"/>
  49. <result column="acc_date" property="accDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  50. <result column="make_staff" property="makeStaff" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  51. <result column="make_time" property="makeTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  52. <result column="flg_valid" property="flgValid"/>
  53. <result column="own_cp_id" property="ownCpId"/>
  54. <result column="ctr_cp_id" property="ctrCpId"/>
  55. <result column="op_create_time" property="opCreateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  56. <result column="op_update_time" property="opUpdateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  57. <result column="op_update_staff_id" property="opUpdateStaffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  58. <result column="due_date" property="dueDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  59. </resultMap>
  60. <!-- **************************************** 查询映射结果 **************************************** -->
  61. <resultMap id="Response_ResultMap" type="com.dk.finance.model.response.fia.AssetResponse">
  62. <!-- **************************************** 当前表映射 **************************************** -->
  63. <id column="doc_id" property="docId"/>
  64. <result column="doc_no" property="docNo"/>
  65. <result column="kind_code" property="kindCode"/>
  66. <result column="status_invoice" property="statusInvoice"/>
  67. <result column="status_flow" property="statusFlow"/>
  68. <result column="org_id" property="orgId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  69. <result column="staff_id" property="staffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  70. <result column="asset_name" property="assetName"/>
  71. <result column="asset_type_id" property="assetTypeId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  72. <result column="calc_method" property="calcMethod"/>
  73. <result column="summary" property="summary"/>
  74. <result column="sum_amt_asset" property="sumAmtAsset"/>
  75. <result column="sum_amt_net_worth" property="sumAmtNetWorth"/>
  76. <result column="sum_amt_net_salvage" property="sumAmtNetSalvage"/>
  77. <result column="total_calc_no" property="totalCalcNo"/>
  78. <result column="sum_amt_calc_month" property="sumAmtCalcMonth"/>
  79. <result column="acc_calc_begin" property="accCalcBegin" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  80. <result column="acc_calc_end" property="accCalcEnd" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  81. <result column="happen_calc_no" property="happenCalcNo"/>
  82. <result column="sum_amt_happen_calc" property="sumAmtHappenCalc"/>
  83. <result column="sum_amt_loss" property="sumAmtLoss"/>
  84. <result column="sum_amt_clear" property="sumAmtClear"/>
  85. <result column="asset_subject_id" property="assetSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  86. <result column="calc_subject_id" property="calcSubjectId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  87. <result column="tax_rate" property="taxRate"/>
  88. <result column="sum_amt_tax" property="sumAmtTax"/>
  89. <result column="sum_amt_total_cash" property="sumAmtTotalCash"/>
  90. <result column="sum_amt_should" property="sumAmtShould"/>
  91. <result column="mac_id" property="macId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  92. <result column="sum_amt_cash" property="sumAmtCash"/>
  93. <result column="sum_amt_charge" property="sumAmtCharge"/>
  94. <result column="obj_type" property="objType"/>
  95. <result column="obj_id" property="objId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  96. <result column="flg_init" property="flgInit"/>
  97. <result column="external_no" property="externalNo"/>
  98. <result column="external_system" property="externalSystem"/>
  99. <result column="print_times" property="printTimes"/>
  100. <result column="apv_submit_id" property="apvSubmitId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  101. <result column="apv_staff_ids" property="apvStaffIds" typeHandler="com.dk.common.infrastructure.handler.UuidListTypeHandler"/>
  102. <result column="apv_result_time" property="apvResultTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  103. <result column="annex_paths" property="annexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
  104. <result column="other_annex_paths" property="otherAnnexPaths" typeHandler="com.dk.common.infrastructure.handler.JsonTypeHandler"/>
  105. <result column="remarks" property="remarks"/>
  106. <result column="acc_date" property="accDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  107. <result column="make_staff" property="makeStaff" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  108. <result column="make_time" property="makeTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  109. <result column="flg_valid" property="flgValid"/>
  110. <result column="own_cp_id" property="ownCpId"/>
  111. <result column="ctr_cp_id" property="ctrCpId"/>
  112. <result column="op_create_time" property="opCreateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  113. <result column="op_update_time" property="opUpdateTime" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  114. <result column="op_update_staff_id" property="opUpdateStaffId" typeHandler="com.dk.common.infrastructure.handler.UuidTypeHandler"/>
  115. <result column="due_date" property="dueDate" typeHandler="com.dk.common.infrastructure.handler.TimestampTypeHandler"/>
  116. <!-- **************************************** 关联表映射 **************************************** -->
  117. <result column="op_update_staff_name" property="opUpdateStaffName"/>
  118. <result column="status_invoice_name" property="statusInvoiceName"/>
  119. <result column="status_flow_name" property="statusFlowName"/>
  120. <result column="org_name" property="orgName"/>
  121. <result column="make_staff_name" property="makeStaffName"/>
  122. <result column="staff_name" property="staffName"/>
  123. <result column="type_name" property="typeName"/>
  124. <result column="assetTaxRate" property="assetTaxRate"/>
  125. <result column="calc_method_name" property="calcMethodName"/>
  126. <result column="ass_sub_name" property="assSubName"/>
  127. <result column="loss_sub_name" property="lossSubName"/>
  128. <result column="calc_sub_name" property="calcSubName"/>
  129. <result column="clear_sub_name" property="clearSubName"/>
  130. <result column="un_happen_calc_no" property="unHappenCalcNo"/>
  131. <result column="mac_name" property="macName"/>
  132. <result column="pay_status" property="payStatus"/>
  133. <result column="un_sum_amt_total_cash" property="unSumAmtTotalCash"/>
  134. <result column="obj_name" property="objName"/>
  135. </resultMap>
  136. <!-- **************************************** 当前表列 **************************************** -->
  137. <sql id="Base_Columns">
  138. t.doc_id,
  139. t.doc_no,
  140. t.kind_code,
  141. t.status_invoice,
  142. t.status_flow,
  143. t.org_id,
  144. t.staff_id,
  145. t.asset_name,
  146. t.asset_type_id,
  147. t.calc_method,
  148. t.summary,
  149. t.sum_amt_asset,
  150. t.sum_amt_net_worth,
  151. t.sum_amt_net_salvage,
  152. t.total_calc_no,
  153. t.sum_amt_calc_month,
  154. t.acc_calc_begin,
  155. t.acc_calc_end,
  156. t.happen_calc_no,
  157. t.sum_amt_happen_calc,
  158. t.sum_amt_loss,
  159. t.sum_amt_clear,
  160. t.asset_subject_id,
  161. t.calc_subject_id,
  162. t.tax_rate,
  163. t.sum_amt_tax,
  164. t.sum_amt_should,
  165. t.mac_id,
  166. t.sum_amt_cash,
  167. t.sum_amt_charge,
  168. t.obj_type,
  169. t.obj_id,
  170. t.flg_init,
  171. t.external_no,
  172. t.external_system,
  173. t.print_times,
  174. t.apv_submit_id,
  175. t.apv_staff_ids,
  176. t.apv_result_time,
  177. t.annex_paths,
  178. t.other_annex_paths,
  179. t.remarks,
  180. t.acc_date,
  181. t.make_staff,
  182. t.make_time,
  183. t.flg_valid,
  184. t.own_cp_id,
  185. t.ctr_cp_id,
  186. t.op_create_time,
  187. t.op_update_time,
  188. t.op_update_staff_id,
  189. t.sum_amt_total_cash,
  190. t.sum_amt_asset - t.sum_amt_total_cash as un_sum_amt_total_cash,
  191. t.total_calc_no - happen_calc_no as un_happen_calc_no,
  192. case when t.sum_amt_should > t.sum_amt_total_cash and t.sum_amt_total_cash>0 then '部分付款'
  193. when t.sum_amt_total_cash = 0 then '未付款'
  194. when t.sum_amt_should = t.sum_amt_total_cash then '付款完成'
  195. end as pay_status,
  196. t.due_date,
  197. </sql>
  198. <!-- **************************************** 当前表查询条件 **************************************** -->
  199. <sql id="Base_Conditions">
  200. <if test="docNo != null and docNo != ''">
  201. AND t.doc_no LIKE concat('%',pgex.likequery(#{docNo}),'%')
  202. </if>
  203. <if test="kindCode != null and kindCode != ''">
  204. AND t.kind_code LIKE concat('%',pgex.likequery(#{kindCode}),'%')
  205. </if>
  206. <if test="statusInvoice != null and statusInvoice != ''">
  207. AND t.status_invoice LIKE concat('%',pgex.likequery(#{statusInvoice}),'%')
  208. </if>
  209. <if test="statusFlow != null and statusFlow != ''">
  210. AND t.status_flow LIKE concat('%',pgex.likequery(#{statusFlow}),'%')
  211. </if>
  212. <if test="orgId != null">
  213. AND t.org_id = #{orgId}::uuid
  214. </if>
  215. <if test="staffId != null">
  216. AND t.staff_id = #{staffId}::uuid
  217. </if>
  218. <if test="assetName != null and assetName != ''">
  219. AND t.asset_name LIKE concat('%',pgex.likequery(#{assetName}),'%')
  220. </if>
  221. <if test="assetTypeId != null">
  222. AND t.asset_type_id = #{assetTypeId}::uuid
  223. </if>
  224. <if test="calcMethod != null and calcMethod != ''">
  225. AND t.calc_method LIKE concat('%',pgex.likequery(#{calcMethod}),'%')
  226. </if>
  227. <if test="summary != null and summary != ''">
  228. AND t.summary LIKE concat('%',pgex.likequery(#{summary}),'%')
  229. </if>
  230. <if test="sumAmtAsset != null">
  231. AND t.sum_amt_asset = #{sumAmtAsset}
  232. </if>
  233. <if test="sumAmtNetWorth != null">
  234. AND t.sum_amt_net_worth = #{sumAmtNetWorth}
  235. </if>
  236. <if test="sumAmtNetSalvage != null">
  237. AND t.sum_amt_net_salvage = #{sumAmtNetSalvage}
  238. </if>
  239. <if test="totalCalcNo != null">
  240. AND t.total_calc_no = #{totalCalcNo}
  241. </if>
  242. <if test="sumAmtCalcMonth != null">
  243. AND t.sum_amt_calc_month = #{sumAmtCalcMonth}
  244. </if>
  245. <if test="happenCalcNo != null">
  246. AND t.happen_calc_no = #{happenCalcNo}
  247. </if>
  248. <if test="sumAmtHappenCalc != null">
  249. AND t.sum_amt_happen_calc = #{sumAmtHappenCalc}
  250. </if>
  251. <if test="sumAmtLoss != null">
  252. AND t.sum_amt_loss = #{sumAmtLoss}
  253. </if>
  254. <if test="sumAmtClear != null">
  255. AND t.sum_amt_clear = #{sumAmtClear}
  256. </if>
  257. <if test="assetSubjectId != null">
  258. AND t.asset_subject_id = #{assetSubjectId}::uuid
  259. </if>
  260. <if test="calcSubjectId != null">
  261. AND t.calc_subject_id = #{calcSubjectId}::uuid
  262. </if>
  263. <if test="taxRate != null">
  264. AND t.tax_rate = #{taxRate}
  265. </if>
  266. <if test="sumAmtTax != null">
  267. AND t.sum_amt_tax = #{sumAmtTax}
  268. </if>
  269. <if test="sumAmtShould != null">
  270. AND t.sum_amt_should = #{sumAmtShould}
  271. </if>
  272. <if test="macId != null">
  273. AND t.mac_id = #{macId}::uuid
  274. </if>
  275. <if test="sumAmtCash != null">
  276. AND t.sum_amt_cash = #{sumAmtCash}
  277. </if>
  278. <if test="sumAmtCharge != null">
  279. AND t.sum_amt_charge = #{sumAmtCharge}
  280. </if>
  281. <if test="objType != null">
  282. AND t.obj_type = #{objType}
  283. </if>
  284. <if test="objId != null">
  285. AND t.obj_id = #{objId}::uuid
  286. </if>
  287. <if test="flgInit != null">
  288. AND t.flg_init = #{flgInit}
  289. </if>
  290. <if test="externalNo != null and externalNo != ''">
  291. AND t.external_no LIKE concat('%',pgex.likequery(#{externalNo}),'%')
  292. </if>
  293. <if test="externalSystem != null and externalSystem != ''">
  294. AND t.external_system LIKE concat('%',pgex.likequery(#{externalSystem}),'%')
  295. </if>
  296. <if test="printTimes != null">
  297. AND t.print_times = #{printTimes}
  298. </if>
  299. <if test="apvSubmitId != null">
  300. AND t.apv_submit_id = #{apvSubmitId}::uuid
  301. </if>
  302. <if test="apvStaffIds != null">
  303. AND t.apv_staff_ids = #{apvStaffIds}
  304. </if>
  305. <if test="annexPaths != null">
  306. AND t.annex_paths = #{annexPaths}
  307. </if>
  308. <if test="otherAnnexPaths != null">
  309. AND t.other_annex_paths = #{otherAnnexPaths}
  310. </if>
  311. <if test="remarks != null and remarks != ''">
  312. AND t.remarks LIKE concat('%',pgex.likequery(#{remarks}),'%')
  313. </if>
  314. <if test="makeStaff != null">
  315. AND t.make_staff = #{makeStaff}::uuid
  316. </if>
  317. <if test="flgValid != null">
  318. AND t.flg_valid = #{flgValid}
  319. </if>
  320. <if test="ownCpId != null">
  321. AND t.own_cp_id = #{ownCpId}
  322. </if>
  323. <if test="ctrCpId != null">
  324. AND t.ctr_cp_id = #{ctrCpId}
  325. </if>
  326. <if test="opUpdateStaffId != null">
  327. AND t.op_update_staff_id = #{opUpdateStaffId}::uuid
  328. </if>
  329. <!-- **************************************** 自动生成其他查询条件 **************************************** -->
  330. <if test="accCalcBeginStart != null">
  331. AND t.acc_calc_begin &gt;= #{accCalcBeginStart}
  332. </if>
  333. <if test="accCalcBeginEnd != null">
  334. AND t.acc_calc_begin &lt;= #{accCalcBeginEnd}
  335. </if>
  336. <if test="accCalcEndStart != null">
  337. AND t.acc_calc_end &gt;= #{accCalcEndStart}
  338. </if>
  339. <if test="accCalcEndEnd != null">
  340. AND t.acc_calc_end &lt;= #{accCalcEndEnd}
  341. </if>
  342. <if test="apvResultTimeStart != null">
  343. AND t.apv_result_time &gt;= #{apvResultTimeStart}::timestamp with time zone
  344. </if>
  345. <if test="apvResultTimeEnd != null">
  346. AND t.apv_result_time &lt; #{apvResultTimeEnd}::timestamp with time zone + interval '1 day'
  347. </if>
  348. <if test="accDateStart != null">
  349. AND t.acc_date &gt;= #{accDateStart}
  350. </if>
  351. <if test="accDateEnd != null">
  352. AND t.acc_date &lt;= #{accDateEnd}
  353. </if>
  354. <if test="makeTimeStart != null">
  355. AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
  356. </if>
  357. <if test="makeTimeEnd != null">
  358. AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
  359. </if>
  360. <if test="flgValidList != null and flgValidList.size()>0">
  361. AND t.flg_valid = any(#{flgValidList, typeHandler= BooleanListTypeHandler})
  362. </if>
  363. <if test="ownCpIdList != null and ownCpIdList.size()>0">
  364. AND t.own_cp_id = any(#{ownCpIdList, typeHandler= BigIntListTypeHandler})
  365. </if>
  366. <if test="opCreateTimeStart != null">
  367. AND t.op_create_time &gt;= #{opCreateTimeStart}::timestamp with time zone
  368. </if>
  369. <if test="opCreateTimeEnd != null">
  370. AND t.op_create_time &lt; #{opCreateTimeEnd}::timestamp with time zone + interval '1 day'
  371. </if>
  372. <if test="opUpdateTimeStart != null">
  373. AND t.op_update_time &gt;= #{opUpdateTimeStart}::timestamp with time zone
  374. </if>
  375. <if test="opUpdateTimeEnd != null">
  376. AND t.op_update_time &lt; #{opUpdateTimeEnd}::timestamp with time zone + interval '1 day'
  377. </if>
  378. <if test="staffIdList != null and staffIdList.size()>0">
  379. AND t.staff_id = any(#{staffIdList, typeHandler= UUidListTypeHandler})
  380. </if>
  381. <if test="orgIdList != null and orgIdList.size()>0">
  382. AND t.org_id = any(#{orgIdList, typeHandler= UUidListTypeHandler})
  383. </if>
  384. <if test="statusInvoiceList!=null and statusInvoiceList.size()>0">
  385. AND t.status_invoice = any(#{statusInvoiceList, typeHandler= StringListTypeHandler})
  386. </if>
  387. <if test="sumAmtCashFlag!=null and sumAmtCashFlag != ''">
  388. AND t.sum_amt_cash != t.sum_amt_should
  389. </if>
  390. <if test="itemOrgIdList != null and itemOrgIdList.size()>0
  391. or calcSubjectList != null and calcSubjectList.size()>0">
  392. AND EXISTS(
  393. SELECT
  394. 1
  395. FROM
  396. dkscu_b.t_fia_asset_item AS item
  397. WHERE
  398. flg_valid
  399. AND item.doc_id = T.doc_id
  400. <if test="itemOrgIdList != null and itemOrgIdList.size()>0">
  401. AND item.org_id = any(#{itemOrgIdList, typeHandler= UUidListTypeHandler})
  402. </if>
  403. <if test="calcSubjectList != null and calcSubjectList.size()>0">
  404. AND item.calc_subject_id = any(#{calcSubjectList, typeHandler= UUidListTypeHandler})
  405. </if>
  406. )
  407. </if>
  408. <if test="payStatusList != null and payStatusList.size()>0">
  409. AND (
  410. (1= any(#{payStatusList, typeHandler= BigIntListTypeHandler}) and t.sum_amt_cash = 0)
  411. or (2= any(#{payStatusList, typeHandler= BigIntListTypeHandler}) and t.sum_amt_cash = t.sum_amt_should)
  412. or (3= any(#{payStatusList, typeHandler= BigIntListTypeHandler}) and t.sum_amt_cash != t.sum_amt_should and t.sum_amt_cash >0)
  413. )
  414. </if>
  415. <if test="assetStatusList!=null and assetStatusList.size()>0">
  416. AND t.status_flow = any(#{assetStatusList, typeHandler= StringListTypeHandler})
  417. </if>
  418. </sql>
  419. <!-- **************************************** 关联表列 **************************************** -->
  420. <sql id="Join_Columns">
  421. update_staff.staff_name AS op_update_staff_name,
  422. org.org_name,
  423. mStaff.staff_name AS make_staff_name,
  424. myex.f_get_name_i18n(dks.kind_name_i18n,#{i18n}) as status_invoice_name,
  425. myex.f_get_name_i18n(dkf.kind_name_i18n,#{i18n}) as status_flow_name,
  426. staff.staff_name,
  427. assType.type_name,
  428. assType.tax_rate as "assetTaxRate",
  429. myex.f_get_name_i18n(dkm.kind_name_i18n,#{i18n}) as calc_method_name,
  430. assSub.subject_name AS ass_sub_name,
  431. lossSub.subject_name AS loss_sub_name,
  432. calcSub.subject_name AS calc_sub_name,
  433. clearSub.subject_name AS clear_sub_name,
  434. ma.mac_name,
  435. obj.obj_name,
  436. </sql>
  437. <!-- **************************************** 关联表 **************************************** -->
  438. <sql id="Join_Tables">
  439. LEFT JOIN dkscu_b.t_mst_staff AS update_staff ON t.op_update_staff_id = update_staff.staff_id
  440. LEFT JOIN dkscu_bs.t_data_kind dks on t.status_invoice = dks.kind_code
  441. LEFT JOIN dkscu_bs.t_data_kind dkf on t.status_flow = dkf.kind_code
  442. LEFT JOIN dkscu_b.t_mst_organization org ON t.org_id = org.org_id
  443. LEFT JOIN dkscu_b.t_mst_staff mStaff ON t.make_staff = mStaff.staff_id
  444. LEFT JOIN dkscu_b.t_mst_staff staff ON t.staff_id = staff.staff_id
  445. LEFT JOIN dkscu_bs.t_fia_asset_type assType ON t.asset_type_id =assType.type_id
  446. LEFT JOIN dkscu_bs.t_data_kind dkm on t.calc_method = dkm.kind_code
  447. LEFT JOIN dkscu_b.t_fnc_subject AS assSub ON assSub.subject_id = t.asset_subject_id
  448. LEFT JOIN dkscu_b.t_fnc_subject AS lossSub ON lossSub.subject_id = t.loss_subject_id
  449. LEFT JOIN dkscu_b.t_fnc_subject AS calcSub ON calcSub.subject_id = t.calc_subject_id
  450. LEFT JOIN dkscu_b.t_fnc_subject AS clearSub ON clearSub.subject_id = t.clear_subject_id
  451. LEFT JOIN dkscu_b.t_mst_money_account AS ma ON T.mac_id = ma.mac_id
  452. LEFT JOIN dkscu_b.t_mst_obj as obj ON t.obj_id = obj.obj_id
  453. </sql>
  454. <!-- **************************************** 关联表查询条件 **************************************** -->
  455. <sql id="Join_Conditions">
  456. </sql>
  457. <!-- 查询表t_fia_asset,(条件查询+分页)列表 -->
  458. <select id="selectByCond" resultMap="Response_ResultMap">
  459. SELECT
  460. <trim suffixOverrides=",">
  461. <include refid="Base_Columns"/>
  462. <include refid="Join_Columns"/>
  463. </trim>
  464. FROM dkscu_b.t_fia_asset t
  465. <include refid="Join_Tables"/>
  466. <where>
  467. <include refid="Base_Conditions"/>
  468. <include refid="Join_Conditions"/>
  469. </where>
  470. order by t.make_time desc
  471. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  472. limit #{end} offset #{start}
  473. </if>
  474. </select>
  475. <!-- 查询表t_fia_asset,(条件查询)个数 -->
  476. <select id="countByCond" resultType="Long">
  477. SELECT
  478. count(1)
  479. FROM dkscu_b.t_fia_asset t
  480. <include refid="Join_Tables"/>
  481. <where>
  482. <include refid="Base_Conditions"/>
  483. <include refid="Join_Conditions"/>
  484. </where>
  485. </select>
  486. <!-- 根据主键查询表t_fia_asset的一行数据 -->
  487. <select id="selectById" resultMap="Response_ResultMap">
  488. SELECT
  489. <trim suffixOverrides=",">
  490. <include refid="Base_Columns"/>
  491. <include refid="Join_Columns"/>
  492. </trim>
  493. FROM dkscu_b.t_fia_asset t
  494. <include refid="Join_Tables"/>
  495. WHERE t.doc_id = #{id}::uuid
  496. </select>
  497. <!-- 根据主键docId批量操作 -->
  498. <sql id="idList">
  499. WHERE t.doc_id in
  500. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  501. #{item}::uuid
  502. </foreach>
  503. </sql>
  504. <!-- 根据主键锁定表t_fia_asset的一行数据 -->
  505. <select id="selectByIdForUpdate" resultMap="Pojo_ResultMap">
  506. SELECT
  507. <trim suffixOverrides=",">
  508. <include refid="Base_Columns"/>
  509. </trim>
  510. FROM dkscu_b.t_fia_asset t
  511. WHERE t.doc_id = #{id}::uuid
  512. for update
  513. </select>
  514. <!-- 根据主键锁定表t_fia_asset的多行数据 -->
  515. <select id="selectByIdsForUpdate" resultMap="Pojo_ResultMap">
  516. SELECT
  517. <trim suffixOverrides=",">
  518. <include refid="Base_Columns"/>
  519. </trim>
  520. FROM dkscu_b.t_fia_asset t
  521. <include refid="idList"/>
  522. for update
  523. </select>
  524. <!-- 批量新建 -->
  525. <insert id="insertBatch" useGeneratedKeys="true" keyProperty="docId">
  526. <include refid="insertBatchSql"/>
  527. </insert>
  528. <sql id="insertBatchSql">
  529. insert into dkscu_b.t_fia_asset
  530. (
  531. <trim suffixOverrides=",">
  532. doc_id,
  533. doc_no,
  534. kind_code,
  535. status_invoice,
  536. status_flow,
  537. org_id,
  538. staff_id,
  539. asset_name,
  540. asset_type_id,
  541. calc_method,
  542. summary,
  543. sum_amt_asset,
  544. sum_amt_net_worth,
  545. sum_amt_net_salvage,
  546. total_calc_no,
  547. sum_amt_calc_month,
  548. acc_calc_begin,
  549. acc_calc_end,
  550. happen_calc_no,
  551. sum_amt_happen_calc,
  552. sum_amt_loss,
  553. sum_amt_clear,
  554. asset_subject_id,
  555. calc_subject_id,
  556. tax_rate,
  557. sum_amt_tax,
  558. sum_amt_should,
  559. mac_id,
  560. sum_amt_cash,
  561. sum_amt_charge,
  562. obj_type,
  563. obj_id,
  564. flg_init,
  565. external_no,
  566. external_system,
  567. print_times,
  568. apv_submit_id,
  569. apv_staff_ids,
  570. apv_result_time,
  571. annex_paths,
  572. other_annex_paths,
  573. remarks,
  574. acc_date,
  575. make_staff,
  576. make_time,
  577. own_cp_id,
  578. ctr_cp_id,
  579. sum_amt_total_cash,
  580. due_date,
  581. </trim>
  582. )
  583. values
  584. <foreach collection="list" index="index" item="item" separator=",">
  585. (
  586. <trim suffixOverrides=",">
  587. #{item.docId}::uuid,
  588. #{item.docNo},
  589. #{item.kindCode},
  590. #{item.statusInvoice},
  591. #{item.statusFlow},
  592. #{item.orgId}::uuid,
  593. #{item.staffId}::uuid,
  594. #{item.assetName},
  595. #{item.assetTypeId}::uuid,
  596. #{item.calcMethod},
  597. #{item.summary},
  598. <choose>
  599. <when test="item.sumAmtAsset != null">
  600. #{item.sumAmtAsset},
  601. </when>
  602. <otherwise>
  603. DEFAULT,
  604. </otherwise>
  605. </choose>
  606. <choose>
  607. <when test="item.sumAmtNetWorth != null">
  608. #{item.sumAmtNetWorth},
  609. </when>
  610. <otherwise>
  611. DEFAULT,
  612. </otherwise>
  613. </choose>
  614. <choose>
  615. <when test="item.sumAmtNetSalvage != null">
  616. #{item.sumAmtNetSalvage},
  617. </when>
  618. <otherwise>
  619. DEFAULT,
  620. </otherwise>
  621. </choose>
  622. <choose>
  623. <when test="item.totalCalcNo != null">
  624. #{item.totalCalcNo},
  625. </when>
  626. <otherwise>
  627. DEFAULT,
  628. </otherwise>
  629. </choose>
  630. <choose>
  631. <when test="item.sumAmtCalcMonth != null">
  632. #{item.sumAmtCalcMonth},
  633. </when>
  634. <otherwise>
  635. DEFAULT,
  636. </otherwise>
  637. </choose>
  638. #{item.accCalcBegin},
  639. #{item.accCalcEnd},
  640. <choose>
  641. <when test="item.happenCalcNo != null">
  642. #{item.happenCalcNo},
  643. </when>
  644. <otherwise>
  645. DEFAULT,
  646. </otherwise>
  647. </choose>
  648. <choose>
  649. <when test="item.sumAmtHappenCalc != null">
  650. #{item.sumAmtHappenCalc},
  651. </when>
  652. <otherwise>
  653. DEFAULT,
  654. </otherwise>
  655. </choose>
  656. <choose>
  657. <when test="item.sumAmtLoss != null">
  658. #{item.sumAmtLoss},
  659. </when>
  660. <otherwise>
  661. DEFAULT,
  662. </otherwise>
  663. </choose>
  664. <choose>
  665. <when test="item.sumAmtClear != null">
  666. #{item.sumAmtClear},
  667. </when>
  668. <otherwise>
  669. DEFAULT,
  670. </otherwise>
  671. </choose>
  672. #{item.assetSubjectId}::uuid,
  673. #{item.calcSubjectId}::uuid,
  674. <choose>
  675. <when test="item.taxRate != null">
  676. #{item.taxRate},
  677. </when>
  678. <otherwise>
  679. DEFAULT,
  680. </otherwise>
  681. </choose>
  682. <choose>
  683. <when test="item.sumAmtTax != null">
  684. #{item.sumAmtTax},
  685. </when>
  686. <otherwise>
  687. DEFAULT,
  688. </otherwise>
  689. </choose>
  690. <choose>
  691. <when test="item.sumAmtShould != null">
  692. #{item.sumAmtShould},
  693. </when>
  694. <otherwise>
  695. DEFAULT,
  696. </otherwise>
  697. </choose>
  698. #{item.macId}::uuid,
  699. <choose>
  700. <when test="item.sumAmtCash != null">
  701. #{item.sumAmtCash},
  702. </when>
  703. <otherwise>
  704. DEFAULT,
  705. </otherwise>
  706. </choose>
  707. <choose>
  708. <when test="item.sumAmtCharge != null">
  709. #{item.sumAmtCharge},
  710. </when>
  711. <otherwise>
  712. DEFAULT,
  713. </otherwise>
  714. </choose>
  715. <choose>
  716. <when test="item.objType != null">
  717. #{item.objType},
  718. </when>
  719. <otherwise>
  720. DEFAULT,
  721. </otherwise>
  722. </choose>
  723. #{item.objId}::uuid,
  724. <choose>
  725. <when test="item.flgInit != null">
  726. #{item.flgInit},
  727. </when>
  728. <otherwise>
  729. DEFAULT,
  730. </otherwise>
  731. </choose>
  732. #{item.externalNo},
  733. #{item.externalSystem},
  734. <choose>
  735. <when test="item.printTimes != null">
  736. #{item.printTimes},
  737. </when>
  738. <otherwise>
  739. DEFAULT,
  740. </otherwise>
  741. </choose>
  742. #{item.apvSubmitId}::uuid,
  743. #{item.apvStaffIds,typeHandler=UuidListTypeHandler},
  744. #{item.apvResultTime},
  745. #{item.annexPaths,typeHandler=JsonTypeHandler},
  746. #{item.otherAnnexPaths,typeHandler=JsonTypeHandler},
  747. #{item.remarks},
  748. #{item.accDate},
  749. #{item.makeStaff}::uuid,
  750. <choose>
  751. <when test="item.makeTime != null">
  752. #{item.makeTime},
  753. </when>
  754. <otherwise>
  755. DEFAULT,
  756. </otherwise>
  757. </choose>
  758. #{item.ownCpId},
  759. #{item.ctrCpId},
  760. <choose>
  761. <when test="item.sumAmtTotalCash != null">
  762. #{item.sumAmtTotalCash},
  763. </when>
  764. <otherwise>
  765. DEFAULT,
  766. </otherwise>
  767. </choose>
  768. #{item.dueDate},
  769. </trim>
  770. )
  771. </foreach>
  772. </sql>
  773. <!-- 批量保存 - 有id则编辑无id则新建 -->
  774. <insert id="saveBatch" useGeneratedKeys="true" keyProperty="docId">
  775. <include refid="insertBatchSql"/>
  776. on conflict (doc_id) do update set
  777. <trim suffixOverrides=",">
  778. doc_no = excluded."doc_no",
  779. kind_code = excluded."kind_code",
  780. status_invoice = excluded."status_invoice",
  781. status_flow = excluded."status_flow",
  782. org_id = excluded."org_id",
  783. staff_id = excluded."staff_id",
  784. asset_name = excluded."asset_name",
  785. asset_type_id = excluded."asset_type_id",
  786. calc_method = excluded."calc_method",
  787. summary = excluded."summary",
  788. sum_amt_asset = excluded."sum_amt_asset",
  789. sum_amt_net_worth = excluded."sum_amt_net_worth",
  790. sum_amt_net_salvage = excluded."sum_amt_net_salvage",
  791. total_calc_no = excluded."total_calc_no",
  792. sum_amt_calc_month = excluded."sum_amt_calc_month",
  793. acc_calc_begin = excluded."acc_calc_begin",
  794. acc_calc_end = excluded."acc_calc_end",
  795. happen_calc_no = excluded."happen_calc_no",
  796. sum_amt_happen_calc = excluded."sum_amt_happen_calc",
  797. sum_amt_loss = excluded."sum_amt_loss",
  798. sum_amt_clear = excluded."sum_amt_clear",
  799. asset_subject_id = excluded."asset_subject_id",
  800. calc_subject_id = excluded."calc_subject_id",
  801. tax_rate = excluded."tax_rate",
  802. sum_amt_tax = excluded."sum_amt_tax",
  803. sum_amt_should = excluded."sum_amt_should",
  804. mac_id = excluded."mac_id",
  805. sum_amt_cash = excluded."sum_amt_cash",
  806. sum_amt_charge = excluded."sum_amt_charge",
  807. obj_type = excluded."obj_type",
  808. obj_id = excluded."obj_id",
  809. flg_init = excluded."flg_init",
  810. external_no = excluded."external_no",
  811. external_system = excluded."external_system",
  812. print_times = excluded."print_times",
  813. apv_submit_id = excluded."apv_submit_id",
  814. apv_staff_ids = excluded."apv_staff_ids",
  815. apv_result_time = excluded."apv_result_time",
  816. annex_paths = excluded."annex_paths",
  817. other_annex_paths = excluded."other_annex_paths",
  818. remarks = excluded."remarks",
  819. acc_date = excluded."acc_date",
  820. make_staff = excluded."make_staff",
  821. make_time = excluded."make_time",
  822. own_cp_id = excluded."own_cp_id",
  823. ctr_cp_id = excluded."ctr_cp_id",
  824. </trim>
  825. </insert>
  826. <!-- 校验名称是否重复 -->
  827. <select id="checkNameDuplicated" resultType="java.lang.Long">
  828. SELECT COUNT(doc_id)
  829. FROM dkscu_b.t_fia_asset
  830. WHERE
  831. own_cp_id = #{ownCpId}
  832. <!-- 通过判断id是否存在判断为新增操作还是修改操作 -->
  833. <if test="docId != null and docId != ''">
  834. AND doc_id != #{docId}::uuid
  835. </if>
  836. <if test="assetName != null and assetName != ''">
  837. AND asset_name = #{assetName}
  838. </if>
  839. </select>
  840. <!-- 查询资产类别 -->
  841. <select id="getAssetType" resultType="java.util.Map">
  842. SELECT
  843. fat.type_id ,
  844. fat.type_code
  845. FROM
  846. dkscu_bs.t_fia_asset_type as fat
  847. WHERE
  848. fat.type_name = #{typeName}
  849. </select>
  850. <!-- 查询经手人 -->
  851. <select id="getStaffByName" resultType="java.util.Map">
  852. SELECT
  853. staff_id,
  854. staff_name
  855. FROM
  856. dkscu_b.t_mst_staff staff
  857. WHERE
  858. flg_valid
  859. AND staff.own_cp_id = #{ownCpId}
  860. AND staff.staff_name = #{staffName}
  861. </select>
  862. <!-- 查询经手部门 -->
  863. <select id="getOrgByName" resultType="java.util.Map">
  864. SELECT
  865. org.org_id,
  866. org.org_name
  867. FROM
  868. dkscu_b.t_mst_organization org
  869. WHERE
  870. flg_valid
  871. AND org.org_name = #{orgName}
  872. AND org.own_cp_id = #{ownCpId}
  873. </select>
  874. <!-- 折旧方法 -->
  875. <select id="getCalcMethod" resultType="java.util.Map">
  876. SELECT
  877. kind_code
  878. FROM
  879. dkscu_bs.t_data_kind dk
  880. WHERE
  881. dk.flg_valid
  882. AND myex.f_get_name_i18n (dk.kind_name_i18n,#{i18n} ) = #{kindName}
  883. </select>
  884. <!-- 会计科目 -->
  885. <select id="getSubject" resultType="java.util.Map">
  886. SELECT
  887. sub.subject_id
  888. FROM
  889. dkscu_b.t_fnc_subject sub
  890. WHERE
  891. sub.flg_valid
  892. AND sub.subject_name =#{subjectName}
  893. AND sub.own_cp_id = #{ownCpId}
  894. </select>
  895. </mapper>