InvSourceMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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="com.ydtech.modules.inv.dao.InvSourceMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.inv.model.po.InvSource">
  7. <id property="insuranceId" column="insurance_id" jdbcType="BIGINT"/>
  8. <id property="id" column="id" jdbcType="BIGINT"/>
  9. <result property="insuranceName" column="insurance_name" jdbcType="VARCHAR"/>
  10. <result property="insuranceDept" column="insurance_dept" jdbcType="VARCHAR"/>
  11. <result property="insuranceDeptId" column="insurance_dept_id" jdbcType="BIGINT"/>
  12. <result property="risk" column="risk" jdbcType="VARCHAR"/>
  13. <result property="jqPolicyId" column="jq_policy_id" jdbcType="BIGINT"/>
  14. <result property="jqPremiumTax" column="jq_premium_tax" jdbcType="DECIMAL"/>
  15. <result property="jqPremium" column="jq_premium" jdbcType="DECIMAL"/>
  16. <result property="syPolicyId" column="sy_policy_id" jdbcType="BIGINT"/>
  17. <result property="syPremiumTax" column="sy_premium_tax" jdbcType="DECIMAL"/>
  18. <result property="syPremium" column="sy_premium" jdbcType="DECIMAL"/>
  19. <result property="nonCarPolicyId" column="non_car_policy_id" jdbcType="BIGINT"/>
  20. <result property="nonCarPremiumTax" column="non_car_premium_tax" jdbcType="DECIMAL"/>
  21. <result property="nonCarPremium" column="non_car_premium" jdbcType="DECIMAL"/>
  22. <result property="insuredName" column="insured_name" jdbcType="VARCHAR"/>
  23. <result property="licenseno" column="licenseno" jdbcType="VARCHAR"/>
  24. <result property="signingTime" column="signing_time" jdbcType="TIMESTAMP"/>
  25. <result property="clearingTime" column="clearing_time" jdbcType="TIMESTAMP"/>
  26. <result property="taxamount" column="taxamount" jdbcType="DECIMAL"/>
  27. <result property="jqReceivableRatio" column="jq_receivable_ratio" jdbcType="INTEGER"/>
  28. <result property="jqPremiumRatio" column="jq_premium_ratio" jdbcType="INTEGER"/>
  29. <result property="jqNonCopyingRatio" column="jq_non_copying_ratio" jdbcType="INTEGER"/>
  30. <result property="syReceivableRatio" column="sy_receivable_ratio" jdbcType="INTEGER"/>
  31. <result property="syPremiumRatio" column="sy_premium_ratio" jdbcType="INTEGER"/>
  32. <result property="syNonCopyingRatio" column="sy_non_copying_ratio" jdbcType="INTEGER"/>
  33. <result property="nonCarReceivableRatio" column="non_car_receivable_ratio" jdbcType="INTEGER"/>
  34. <result property="nonCarPremiumRatio" column="non_car_premium_ratio" jdbcType="INTEGER"/>
  35. <result property="nonCarNonCopyingRatio" column="non_car_non_copying_ratio" jdbcType="INTEGER"/>
  36. <result property="premium" column="premium" jdbcType="DECIMAL"/>
  37. <result property="nonCopying" column="non_copying" jdbcType="DECIMAL"/>
  38. <result property="receivable" column="receivable" jdbcType="DECIMAL"/>
  39. <result property="maxJqReceivableRatio" column="max_jq_receivable_ratio" jdbcType="INTEGER"/>
  40. <result property="maxSyReceivableRatio" column="max_sy_receivable_ratio" jdbcType="INTEGER"/>
  41. <result property="maxNonCarReceivableRatio" column="max_non_car_receivable_ratio" jdbcType="INTEGER"/>
  42. <result property="maxReceivable" column="max_receivable" jdbcType="VARCHAR"/>
  43. <result property="clearingState" column="clearing_state" jdbcType="CHAR"/>
  44. </resultMap>
  45. <sql id="Base_Column_List">
  46. insurance_id,id,insurance_name,
  47. insurance_dept,insurance_dept_id,risk,
  48. jq_policy_id,jq_premium_tax,jq_premium,
  49. sy_policy_id,sy_premium_tax,sy_premium,
  50. non_car_policy_id,non_car_premium_tax,non_car_premium,
  51. insured_name,licenseno,signing_time,
  52. clearing_time,taxamount,jq_receivable_ratio,
  53. jq_premium_ratio,jq_non_copying_ratio,sy_receivable_ratio,
  54. sy_premium_ratio,sy_non_copying_ratio,non_car_receivable_ratio,
  55. non_car_premium_ratio,non_car_non_copying_ratio,premium,
  56. non_copying,receivable,max_jq_receivable_ratio,
  57. max_sy_receivable_ratio,max_non_car_receivable_ratio,max_receivable,
  58. clearing_state
  59. </sql>
  60. <update id="syncStatus">
  61. UPDATE inv_source ins
  62. JOIN inv_settlement_source iss ON ins.jq_policy_id = iss.jq_policy_id
  63. AND ins.sy_policy_id = iss.sy_policy_id
  64. AND ins.non_car_policy_id = iss.non_car_policy_id
  65. AND ins.licenseno = iss.licenseno
  66. SET ins.clearing_state = 1,
  67. ins.clearing_time = iss.agency_settlement_time;
  68. </update>
  69. <select id="dataMatching" resultType="HashMap">
  70. SELECT
  71. iss.licenseno
  72. FROM
  73. inv_settlement_source iss
  74. WHERE
  75. NOT EXISTS (
  76. SELECT
  77. ivs.licenseno
  78. FROM
  79. inv_source ivs
  80. WHERE
  81. ivs.licenseno = iss.licenseno
  82. )
  83. </select>
  84. <select id="getRecivablePage" resultType="com.ydtech.modules.inv.model.po.InvSource">
  85. select * from (select
  86. id,
  87. insurance_id,
  88. insurance_name,
  89. insurance_dept,
  90. insurance_dept_id,
  91. risk,
  92. jq_policy_id,
  93. jq_premium_tax,
  94. jq_premium,
  95. sy_policy_id,
  96. sy_premium_tax,
  97. sy_premium,
  98. non_car_policy_id,
  99. non_car_premium_tax,
  100. non_car_premium,
  101. insured_name,
  102. licenseno,
  103. signing_time,
  104. clearing_time,
  105. taxamount,
  106. jq_receivable_ratio,
  107. jq_premium_ratio,
  108. jq_non_copying_ratio,
  109. sy_receivable_ratio,
  110. sy_premium_ratio,
  111. sy_non_copying_ratio,
  112. non_car_receivable_ratio,
  113. non_car_premium_ratio,
  114. non_car_non_copying_ratio,
  115. premium,
  116. non_copying,
  117. receivable,
  118. subsidy_ratio,
  119. subsidy_amount,
  120. total_receivable_amount,
  121. max_jq_receivable_ratio,
  122. max_sy_receivable_ratio,
  123. max_non_car_receivable_ratio,
  124. max_receivable,
  125. CASE WHEN DATEDIFF(NOW(), signing_time) > 90 THEN 2 ELSE inv_source.clearing_state END as clearing_state,
  126. insurance_clearing_state
  127. from inv_source
  128. ) a
  129. where 1=1
  130. <if test="param.licenseno != null and param.licenseno != ''">
  131. and a.licenseno = #{param.licenseno}
  132. </if>
  133. <if test="param.jqPolicyId != null and param.jqPolicyId != ''">
  134. and a.jq_policy_id = #{param.jqPolicyId}
  135. </if>
  136. <if test="param.syPolicyId != null and param.syPolicyId != ''">
  137. and a.sy_policy_id = #{param.syPolicyId}
  138. </if>
  139. <if test="param.nonCarPolicyId != null and param.nonCarPolicyId != ''">
  140. and a.non_car_policy_id = #{param.nonCarPolicyId}
  141. </if>
  142. <if test="param.insuranceId != null and param.insuranceId != ''">
  143. and a.insurance_id = #{param.insuranceId}
  144. </if>
  145. <if test="param.risk != null and param.risk != ''">
  146. and a.risk = #{param.risk}
  147. </if>
  148. <if test="param.insuranceName != null and param.insuranceName != ''">
  149. and a.insurance_name = #{param.insuranceName}
  150. </if>
  151. <if test="param.clearingTimeStartTime != null and param.clearingTimeStartTime != ''">
  152. and a.clearing_time between #{param.clearingTimeStartTime} and #{param.clearingTimeEndTime]}
  153. </if>
  154. <if test="param.signingTimeStartTime != null and param.signingTimeStartTime != ''">
  155. and a.signing_time between #{param.signingTimeStartTime} and #{param.signingTimeEndTime}
  156. </if>
  157. <if test="param.insuranceDept != null and param.insuranceDept != ''">
  158. and a.insurance_dept = #{param.insuranceDept}
  159. </if>
  160. <if test="param.clearingState != null and param.clearingState != ''">
  161. and a.clearing_state = #{param.clearingState}
  162. </if>
  163. <if test="param.insuranceClearingState != null and param.insuranceClearingState != ''">
  164. and a.insurance_clearing_state = #{param.insuranceClearingState}
  165. </if>
  166. <if test="param.insuredName != null and param.insuredName != ''">
  167. and a.insured_name = #{insuredName}
  168. </if>
  169. </select>
  170. <select id="getRecivableList" resultType="com.ydtech.modules.inv.model.po.InvSource">
  171. select * from (select
  172. id,
  173. insurance_id,
  174. insurance_name,
  175. insurance_dept,
  176. insurance_dept_id,
  177. risk,
  178. jq_policy_id,
  179. jq_premium_tax,
  180. jq_premium,
  181. sy_policy_id,
  182. sy_premium_tax,
  183. sy_premium,
  184. non_car_policy_id,
  185. non_car_premium_tax,
  186. non_car_premium,
  187. insured_name,
  188. licenseno,
  189. signing_time,
  190. clearing_time,
  191. taxamount,
  192. jq_receivable_ratio,
  193. jq_premium_ratio,
  194. jq_non_copying_ratio,
  195. sy_receivable_ratio,
  196. sy_premium_ratio,
  197. sy_non_copying_ratio,
  198. non_car_receivable_ratio,
  199. non_car_premium_ratio,
  200. non_car_non_copying_ratio,
  201. premium,
  202. non_copying,
  203. receivable,
  204. subsidy_ratio,
  205. subsidy_amount,
  206. total_receivable_amount,
  207. max_jq_receivable_ratio,
  208. max_sy_receivable_ratio,
  209. max_non_car_receivable_ratio,
  210. max_receivable,
  211. CASE WHEN DATEDIFF(NOW(), signing_time) > 90 THEN 2 ELSE inv_source.clearing_state END as clearing_state,
  212. insurance_clearing_state
  213. from inv_source
  214. ) a
  215. where 1=1
  216. <if test="param.licenseno != null and param.licenseno != ''">
  217. and a.licenseno = #{param.licenseno}
  218. </if>
  219. <if test="param.jqPolicyId != null and param.jqPolicyId != ''">
  220. and a.jq_policy_id = #{param.jqPolicyId}
  221. </if>
  222. <if test="param.syPolicyId != null and param.syPolicyId != ''">
  223. and a.sy_policy_id = #{param.syPolicyId}
  224. </if>
  225. <if test="param.nonCarPolicyId != null and param.nonCarPolicyId != ''">
  226. and a.non_car_policy_id = #{param.nonCarPolicyId}
  227. </if>
  228. <if test="param.insuranceId != null and param.insuranceId != ''">
  229. and a.insurance_id = #{param.insuranceId}
  230. </if>
  231. <if test="param.risk != null and param.risk != ''">
  232. and a.risk = #{param.risk}
  233. </if>
  234. <if test="param.insuranceName != null and param.insuranceName != ''">
  235. and a.insurance_name = #{param.insuranceName}
  236. </if>
  237. <if test="param.clearingTimeStartTime != null and param.clearingTimeStartTime != ''">
  238. and a.clearing_time between #{param.clearingTimeStartTime} and #{param.clearingTimeEndTime]}
  239. </if>
  240. <if test="param.signingTimeStartTime != null and param.signingTimeStartTime != ''">
  241. and a.signing_time between #{param.signingTimeStartTime} and #{param.signingTimeEndTime}
  242. </if>
  243. <if test="param.insuranceDept != null and param.insuranceDept != ''">
  244. and a.insurance_dept = #{param.insuranceDept}
  245. </if>
  246. <if test="param.clearingState != null and param.clearingState != ''">
  247. and a.clearing_state = #{param.clearingState}
  248. </if>
  249. <if test="param.insuranceClearingState != null and param.insuranceClearingState != ''">
  250. and a.insurance_clearing_state = #{param.insuranceClearingState}
  251. </if>
  252. </select>
  253. </mapper>