InvSourceMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. revenue_time,
  126. revenue_name,
  127. update_name,
  128. update_userid,
  129. inv_source_type,
  130. CASE WHEN DATEDIFF(NOW(), signing_time) > 90 AND clearing_state = 0 THEN 2 ELSE inv_source.clearing_state END as clearing_state,
  131. insurance_clearing_state
  132. from inv_source
  133. ) a
  134. where 1=1
  135. <if test="param.licenseno != null and param.licenseno != ''">
  136. and a.licenseno in
  137. <foreach item="licenseno" collection="param.licenseno.split(',')" open="(" separator="," close=")">
  138. #{licenseno}
  139. </foreach>
  140. </if>
  141. <if test="param.jqPolicyId != null and param.jqPolicyId != ''">
  142. and a.jq_policy_id in
  143. <foreach item="jqPolicyId" collection="param.jqPolicyId.split(',')" open="(" separator="," close=")">
  144. #{jqPolicyId}
  145. </foreach>
  146. </if>
  147. <if test="param.syPolicyId != null and param.syPolicyId != ''">
  148. and a.sy_policy_id in
  149. <foreach item="syPolicyId" collection="param.syPolicyId.split(',')" open="(" separator="," close=")">
  150. #{syPolicyId}
  151. </foreach>
  152. </if>
  153. <if test="param.nonCarPolicyId != null and param.nonCarPolicyId != ''">
  154. and a.non_car_policy_id in
  155. <foreach item="nonCarPolicyId" collection="param.nonCarPolicyId.split(',')" open="(" separator="," close=")">
  156. #{nonCarPolicyId}
  157. </foreach>
  158. </if>
  159. <if test="param.insuranceId != null and param.insuranceId != ''">
  160. and a.insurance_id = #{param.insuranceId}
  161. </if>
  162. <if test="param.risk != null and param.risk != ''">
  163. and a.risk = #{param.risk}
  164. </if>
  165. <if test="param.insuranceName != null and param.insuranceName != ''">
  166. and a.insurance_name = #{param.insuranceName}
  167. </if>
  168. <if test="param.clearingTimeStartTime != null and param.clearingTimeStartTime != ''">
  169. and a.clearing_time between #{param.clearingTimeStartTime} and #{param.clearingTimeEndTime]}
  170. </if>
  171. <if test="param.signingTimeStartTime != null and param.signingTimeStartTime != ''">
  172. and a.signing_time between #{param.signingTimeStartTime} and #{param.signingTimeEndTime}
  173. </if>
  174. <if test="param.insuranceDept != null and param.insuranceDept != ''">
  175. and a.insurance_dept = #{param.insuranceDept}
  176. </if>
  177. <if test="param.clearingState != null and param.clearingState != ''">
  178. and a.clearing_state = #{param.clearingState}
  179. </if>
  180. <if test="param.insuranceClearingState != null and param.insuranceClearingState != ''">
  181. and a.insurance_clearing_state = #{param.insuranceClearingState}
  182. </if>
  183. <if test="param.insuredName != null and param.insuredName != ''">
  184. and a.insured_name = #{param.insuredName}
  185. </if>
  186. <if test="param.revenueTimeStartTime != null and param.revenueTimeStartTime != ''">
  187. and a.revenue_time <![CDATA[ >= ]]> CAST(CONCAT(#{param.revenueTimeStartTime},' 00:00:00') AS datetime)
  188. </if>
  189. <if test="param.revenueTimeEndTime != null and param.revenueTimeEndTime != '' " >
  190. and a.revenue_time <![CDATA[ <= ]]> CAST(CONCAT(#{param.revenueTimeEndTime},' 23:59:59') AS datetime)
  191. </if>
  192. <if test="param.revenueName != null and param.revenueName != ''">
  193. and a.revenue_name = #{param.revenueName}
  194. </if>
  195. <if test="param.invSourceType != null and param.invSourceType != ''">
  196. and a.inv_source_type = #{param.invSourceType}
  197. </if>
  198. </select>
  199. <select id="getRecivableList" resultType="com.ydtech.modules.inv.model.po.InvSource">
  200. select * from (select
  201. id,
  202. insurance_id,
  203. insurance_name,
  204. insurance_dept,
  205. insurance_dept_id,
  206. risk,
  207. jq_policy_id,
  208. jq_premium_tax,
  209. jq_premium,
  210. sy_policy_id,
  211. sy_premium_tax,
  212. sy_premium,
  213. non_car_policy_id,
  214. non_car_premium_tax,
  215. non_car_premium,
  216. insured_name,
  217. licenseno,
  218. signing_time,
  219. clearing_time,
  220. taxamount,
  221. jq_receivable_ratio,
  222. jq_premium_ratio,
  223. jq_non_copying_ratio,
  224. sy_receivable_ratio,
  225. sy_premium_ratio,
  226. sy_non_copying_ratio,
  227. non_car_receivable_ratio,
  228. non_car_premium_ratio,
  229. non_car_non_copying_ratio,
  230. premium,
  231. non_copying,
  232. receivable,
  233. subsidy_ratio,
  234. subsidy_amount,
  235. total_receivable_amount,
  236. max_jq_receivable_ratio,
  237. max_sy_receivable_ratio,
  238. max_non_car_receivable_ratio,
  239. max_receivable,
  240. revenue_time,
  241. revenue_name,
  242. update_name,
  243. update_userid,
  244. inv_source_type,
  245. CASE WHEN DATEDIFF(NOW(), signing_time) > 90 AND clearing_state = 0 THEN 2 ELSE inv_source.clearing_state END as clearing_state,
  246. insurance_clearing_state
  247. from inv_source
  248. ) a
  249. where 1=1
  250. <if test="param.licenseno != null and param.licenseno != ''">
  251. and a.licenseno = #{param.licenseno}
  252. </if>
  253. <if test="param.jqPolicyId != null and param.jqPolicyId != ''">
  254. and a.jq_policy_id = #{param.jqPolicyId}
  255. </if>
  256. <if test="param.syPolicyId != null and param.syPolicyId != ''">
  257. and a.sy_policy_id = #{param.syPolicyId}
  258. </if>
  259. <if test="param.nonCarPolicyId != null and param.nonCarPolicyId != ''">
  260. and a.non_car_policy_id = #{param.nonCarPolicyId}
  261. </if>
  262. <if test="param.insuranceId != null and param.insuranceId != ''">
  263. and a.insurance_id = #{param.insuranceId}
  264. </if>
  265. <if test="param.risk != null and param.risk != ''">
  266. and a.risk = #{param.risk}
  267. </if>
  268. <if test="param.insuranceName != null and param.insuranceName != ''">
  269. and a.insurance_name = #{param.insuranceName}
  270. </if>
  271. <if test="param.clearingTimeStartTime != null and param.clearingTimeStartTime != ''">
  272. and a.clearing_time between #{param.clearingTimeStartTime} and #{param.clearingTimeEndTime]}
  273. </if>
  274. <if test="param.signingTimeStartTime != null and param.signingTimeStartTime != ''">
  275. and a.signing_time between #{param.signingTimeStartTime} and #{param.signingTimeEndTime}
  276. </if>
  277. <if test="param.insuranceDept != null and param.insuranceDept != ''">
  278. and a.insurance_dept = #{param.insuranceDept}
  279. </if>
  280. <if test="param.clearingState != null and param.clearingState != ''">
  281. and a.clearing_state = #{param.clearingState}
  282. </if>
  283. <if test="param.insuranceClearingState != null and param.insuranceClearingState != ''">
  284. and a.insurance_clearing_state = #{param.insuranceClearingState}
  285. </if>
  286. <if test="param.revenueTimeEndTime != null and param.revenueTimeEndTime != '' " >
  287. and a.revenue_time <![CDATA[ <= ]]> CAST(CONCAT(#{param.revenueTimeEndTime},' 23:59:59') AS datetime)
  288. </if>
  289. <if test="param.revenueName != null and param.revenueName != ''">
  290. and a.revenue_name = #{revenueName}
  291. </if>
  292. <if test="param.invSourceType != null and param.invSourceType != ''">
  293. and a.inv_source_type = #{invSourceType}
  294. </if>
  295. </select>
  296. </mapper>