PtlAgreementCostMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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.jzg.organization.mapper.PtlAgreementCostMapper">
  6. <resultMap id="BaseResultMap" type="com.jzg.commons.entity.vo.PtlAgreementCostVo">
  7. <id column="id" property="id" jdbcType="BIGINT"/>
  8. <result column="ptl_agreement_id" property="ptlAgreementId" jdbcType="VARCHAR"/>
  9. <result column="product_name" property="productName" jdbcType="VARCHAR"/>
  10. <result column="product_id" property="productId" jdbcType="VARCHAR"/>
  11. <result column="effective_time" property="effectiveTime" jdbcType="TIMESTAMP"/>
  12. <result column="failure_time" property="failureTime" jdbcType="TIMESTAMP"/>
  13. <result column="audit_method" property="auditMethod" jdbcType="VARCHAR"/>
  14. <result column="cost_describe" property="costDescribe" jdbcType="VARCHAR"/>
  15. <result column="approved" property="approved" jdbcType="VARCHAR"/>
  16. <result column="is_valid" property="isValid" jdbcType="VARCHAR"/>
  17. <result column="is_enabled" property="isEnabled" jdbcType="VARCHAR"/>
  18. <result column="audit_person" property="auditPerson" jdbcType="VARCHAR"/>
  19. <result column="audit_time" property="auditTime" jdbcType="VARCHAR"/>
  20. <result column="review_description" property="reviewDescription" jdbcType="VARCHAR"/>
  21. <result column="agreement_code" property="ptlAgreementCode" jdbcType="VARCHAR"/>
  22. <result column="agreement_title" property="ptlAgreementName" jdbcType="VARCHAR"/>
  23. <result column="jq_entrance_fee_ratio" property="jqEntranceFeeRatio" jdbcType="VARCHAR"/>
  24. <result column="sy_entrance_fee_ratio" property="syEntranceFeeRatio" jdbcType="VARCHAR"/>
  25. <result column="jy_entrance_fee_ratio" property="jyEntranceFeeRatio" jdbcType="VARCHAR"/>
  26. <result column="priority_level" property="priorityLevel" jdbcType="INTEGER"/>
  27. <collection property="ptlAgreementCostTypeList" column="{costId=id}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo" select="selectCostType" />
  28. <collection property="ruleConditions" column="{costId=id}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostRuleVo" select="selectCostRule" />
  29. </resultMap>
  30. <resultMap id="RulesDictLabalMap" type="com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal">
  31. <id column="id" property="id" jdbcType="BIGINT"/>
  32. <result column="dict_id" property="dictId" jdbcType="INTEGER"/>
  33. <result column="name" property="name" jdbcType="VARCHAR"/>
  34. <result column="code" property="code" jdbcType="VARCHAR"/>
  35. <result column="sort" property="sort" jdbcType="VARCHAR"/>
  36. </resultMap>
  37. <resultMap id="CostResultMap" type="com.jzg.commons.entity.vo.PtlAgreementCostVo">
  38. <id column="id" property="id" jdbcType="BIGINT"/>
  39. <result column="ptl_agreement_id" property="ptlAgreementId" jdbcType="VARCHAR"/>
  40. <result column="product_name" property="productName" jdbcType="VARCHAR"/>
  41. <result column="product_id" property="productId" jdbcType="VARCHAR"/>
  42. <result column="effective_time" property="effectiveTime" jdbcType="TIMESTAMP"/>
  43. <result column="failure_time" property="failureTime" jdbcType="TIMESTAMP"/>
  44. <result column="audit_method" property="auditMethod" jdbcType="VARCHAR"/>
  45. <result column="cost_describe" property="costDescribe" jdbcType="VARCHAR"/>
  46. <result column="cost_rules" property="costRules" jdbcType="VARCHAR"/>
  47. <result column="approved" property="approved" jdbcType="VARCHAR"/>
  48. <result column="is_valid" property="isValid" jdbcType="VARCHAR"/>
  49. <result column="is_enabled" property="isEnabled" jdbcType="VARCHAR"/>
  50. <collection property="ptlAgreementCostTypeList" column="{costId=id}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo" select="selectCostType" />
  51. </resultMap>
  52. <resultMap id="costType" type="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo">
  53. <id column="id" property="id" jdbcType="BIGINT"/>
  54. <result column="ptl_agreement_cost_id" property="ptlAgreementCostId" jdbcType="INTEGER"/>
  55. <result column="cost_type" property="costType" jdbcType="VARCHAR"/>
  56. <result column="inlet" property="inlet" jdbcType="DECIMAL"/>
  57. <result column="export" property="export" jdbcType="DECIMAL"/>
  58. <result column="add_throw" property="addThrow" jdbcType="DECIMAL"/>
  59. <result column="keep_point_ratio" property="keepPointRatio" jdbcType="DECIMAL"/>
  60. <result column="export_keep_point_ratio" property="exportKeepPointRatio" jdbcType="DECIMAL"/>
  61. </resultMap>
  62. <resultMap id="costRule" type="com.jzg.commons.entity.vo.PtlAgreementCostRuleVo">
  63. <id column="id" property="id" jdbcType="BIGINT"/>
  64. <result column="ptl_agreement_cost_id" property="ptlAgreementCostId" jdbcType="INTEGER"/>
  65. <result column="rules_id" property="rulesId" jdbcType="VARCHAR"/>
  66. <result column="attr_Id" property="attrId" jdbcType="VARCHAR"/>
  67. <result column="attr_code" property="attrCode" jdbcType="VARCHAR"/>
  68. <result column="attr_type" property="attrType" jdbcType="VARCHAR"/>
  69. <result column="attr_group" property="attrGroup" jdbcType="VARCHAR"/>
  70. <result column="attr_name" property="attrName" jdbcType="VARCHAR"/>
  71. <result column="dict_id" property="dictId" jdbcType="VARCHAR"/>
  72. <result column="min" property="min" jdbcType="VARCHAR"/>
  73. <result column="max" property="max" jdbcType="VARCHAR"/>
  74. <result column="operator" property="operator" jdbcType="VARCHAR"/>
  75. <result column="batch" property="batch" jdbcType="VARCHAR"/>
  76. <collection property="dictLabal" column="{dictId = dict_id}" ofType="com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal" select="selectDictLabal"/>
  77. </resultMap>
  78. <resultMap id="CostListMap" type="com.jzg.commons.entity.vo.CostListVo">
  79. <result column="ids" property="ids" jdbcType="VARCHAR"/>
  80. <result column="product_name" property="productName" jdbcType="VARCHAR"/>
  81. <result column="product_id" property="productId" jdbcType="VARCHAR"/>
  82. <collection property="ptlAgreementCostVoList" column="{costId = ids}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostVo" select="selectCostById" />
  83. </resultMap>
  84. <resultMap id="CostsList" type="com.jzg.commons.entity.vo.CostsListVo">
  85. <result column="id" property="id" jdbcType="VARCHAR"/>
  86. <result column="product_name" property="productName" jdbcType="VARCHAR"/>
  87. <result column="product_id" property="productId" jdbcType="VARCHAR"/>
  88. <result column="priority_level" property="priorityLevel" jdbcType="VARCHAR"/>
  89. <collection property="ptlAgreementCostRuleList" ofType="com.jzg.commons.entity.po.PtlAgreementCostRule">
  90. <result column="rule_id" property="id" jdbcType="VARCHAR"/>
  91. <result column="ptl_agreement_cost_id" property="ptlAgreementCostId" jdbcType="VARCHAR"/>
  92. <result column="attr_code" property="attrCode" jdbcType="VARCHAR"/>
  93. <result column="min" property="min" jdbcType="VARCHAR"/>
  94. <result column="max" property="max" jdbcType="VARCHAR"/>
  95. <result column="operator" property="operator" jdbcType="VARCHAR"/>
  96. <result column="batch" property="batch" jdbcType="VARCHAR"/>
  97. </collection>
  98. </resultMap>
  99. <resultMap id="CostManagementVoMap" type="com.jzg.commons.entity.dto.CostManagementVo">
  100. <result column="ptlAgreementId" property="ptlAgreementId" jdbcType="VARCHAR"/>
  101. <result column="agreement_code" property="agreementCode" jdbcType="VARCHAR"/>
  102. <result column="agreement_title" property="agreementTitle" jdbcType="VARCHAR"/>
  103. <result column="agreement_abbreviation" property="agreementAbbreviation" jdbcType="VARCHAR"/>
  104. <result column="is_enabled" property="isEnabled" jdbcType="VARCHAR"/>
  105. <result column="is_valid" property="isValid" jdbcType="VARCHAR"/>
  106. <result column="approved" property="approved" jdbcType="VARCHAR"/>
  107. <result column="cost_describe" property="costDescribe" jdbcType="VARCHAR"/>
  108. <result column="rule_description" property="ruleDescription" jdbcType="VARCHAR"/>
  109. <result column="product_id" property="productId" jdbcType="VARCHAR"/>
  110. <result column="product_name" property="productName" jdbcType="VARCHAR"/>
  111. <result column="cost_rules" property="costRules" jdbcType="VARCHAR"/>
  112. <result column="effective_time" property="effectiveTime" jdbcType="VARCHAR"/>
  113. <result column="failure_time" property="failureTime" jdbcType="VARCHAR"/>
  114. <result column="priority_level" property="priorityLevel" jdbcType="INTEGER"/>
  115. <result column="costId" property="costId" jdbcType="VARCHAR"/>
  116. <result column="create_time" property="createTime" jdbcType="VARCHAR"/>
  117. <result column="company_name" property="companyName" jdbcType="VARCHAR"/>
  118. <result column="company_id" property="companyId" jdbcType="VARCHAR"/>
  119. <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
  120. <collection property="ruleConditions" column="{costId=costId}" ofType="com.jzg.commons.entity.vo.PtlAgreementCostTypeVo" select="selectCostType" />
  121. </resultMap>
  122. <select id="queryByAgreementIdAndCoverRuleId" resultMap="CostListMap">
  123. SELECT
  124. c.product_name,
  125. c.product_id,
  126. GROUP_CONCAT(c.id) as ids
  127. FROM
  128. ptl_agreement_cost c
  129. <where>
  130. c.is_delete = 0
  131. <if test="ptlAgreementId != null">
  132. AND c.ptl_agreement_id = #{ptlAgreementId}
  133. </if>
  134. <if test="coverRuleId != null">
  135. AND c.cover_rule_id = #{coverRuleId}
  136. </if>
  137. </where>
  138. GROUP BY c.product_id, c.product_name
  139. </select>
  140. <select id="queryByAgreementIdAndProductId" resultMap="CostsList">
  141. SELECT
  142. c.id,
  143. c.product_name,
  144. c.product_id,
  145. c.priority_level,
  146. r.id as rule_id,
  147. r.ptl_agreement_cost_id as ptl_agreement_cost_id,
  148. r.attr_code as attr_code,
  149. r.min as min,
  150. r.max as max,
  151. r.operator as operator,
  152. r.batch as batch
  153. FROM
  154. ptl_agreement_cost c
  155. left join ptl_agreement_cost_rule r on c.id = r.ptl_agreement_cost_id AND r.is_delete = 0
  156. <where>
  157. c.is_delete = 0
  158. AND
  159. c.approved = 1
  160. <if test="ptlAgreementId != null">
  161. AND c.ptl_agreement_id = #{ptlAgreementId}
  162. </if>
  163. <if test="productId != null">
  164. AND c.product_id = #{productId}
  165. </if>
  166. AND
  167. NOW() BETWEEN c.effective_time AND c.failure_time
  168. </where>
  169. </select>
  170. <select id="selectCostById" resultMap="CostResultMap">
  171. SELECT
  172. t.id,
  173. t.priority_level,
  174. t.ptl_agreement_id,
  175. t.product_name,
  176. t.product_id,
  177. t.effective_time,
  178. t.failure_time,
  179. t.audit_method,
  180. t.cost_rules,
  181. t.cost_describe,
  182. t.approved,
  183. t.is_valid,
  184. t.is_enabled
  185. FROM
  186. ptl_agreement_cost t
  187. <where>
  188. t.is_delete = 0
  189. AND t.id IN (${costId})
  190. </where>
  191. order by t.create_time desc
  192. </select>
  193. <select id="queryById" resultMap="BaseResultMap">
  194. SELECT
  195. t.id,
  196. t.ptl_agreement_id,
  197. t.cover_rule_id,
  198. t.product_name,
  199. t.product_id,
  200. t.effective_time,
  201. t.failure_time,
  202. t.audit_method,
  203. t.cost_describe,
  204. t.approved,
  205. t.is_delete,
  206. t.create_by,
  207. t.create_time,
  208. t.update_by,
  209. t.update_time,
  210. t.audit_person,
  211. t.review_description,
  212. t.audit_time,
  213. t.priority_level,
  214. pa.agreement_code,
  215. pa.agreement_title,
  216. pa.jq_entrance_fee_ratio,
  217. pa.sy_entrance_fee_ratio,
  218. pa.jy_entrance_fee_ratio
  219. FROM
  220. ptl_agreement_cost t
  221. LEFT JOIN ptl_agreement pa ON pa.id = t.ptl_agreement_id AND pa.is_delete = 0
  222. <where>
  223. t.is_delete = 0
  224. <if test="id != null">
  225. AND t.id = #{id}
  226. </if>
  227. </where>
  228. </select>
  229. <select id="queryByAgreementId" resultMap="BaseResultMap">
  230. SELECT
  231. t.id,
  232. t.ptl_agreement_id,
  233. t.product_name,
  234. t.product_id,
  235. t.cover_rule_id,
  236. t.effective_time,
  237. t.failure_time,
  238. t.audit_method,
  239. t.cost_describe,
  240. t.is_delete,
  241. t.approved,
  242. t.is_valid,
  243. t.is_enabled,
  244. t.create_by,
  245. t.create_time,
  246. t.update_by,
  247. t.update_time
  248. FROM
  249. ptl_agreement_cost t
  250. <where>
  251. t.is_delete = 0
  252. <if test="ptlAgreementId != null">
  253. AND t.ptl_agreement_id = #{ptlAgreementId}
  254. </if>
  255. <if test="coverRuleId != null">
  256. AND t.cover_rule_id = #{coverRuleId}
  257. </if>
  258. </where>
  259. </select>
  260. <select id="selectCostRule" resultMap="costRule">
  261. SELECT
  262. tr.id,
  263. tr.ptl_agreement_cost_id,
  264. tr.rules_id,
  265. tr.attr_id,
  266. tr.attr_code,
  267. tr.min,
  268. tr.max,
  269. tr.operator,
  270. tr.batch,
  271. a.attr_name,
  272. a.attr_type,
  273. a.attr_group,
  274. a.dict_id
  275. FROM
  276. ptl_agreement_cost_rule tr
  277. left join ptl_agreement_undwrt_rules_attr a on tr.attr_code = a.attr_code AND a.is_delete = 0
  278. <where>
  279. tr.is_delete = 0
  280. AND tr.ptl_agreement_cost_id = #{costId}
  281. </where>
  282. GROUP BY tr.id,
  283. tr.ptl_agreement_cost_id,
  284. tr.rules_id,
  285. tr.attr_id,
  286. tr.attr_code,
  287. tr.min,
  288. tr.max,
  289. tr.operator,
  290. tr.batch,
  291. a.attr_name,
  292. a.attr_type,
  293. a.attr_group,
  294. a.dict_id
  295. </select>
  296. <select id="selectCostType" resultMap="costType">
  297. SELECT
  298. tt.id,
  299. tt.ptl_agreement_cost_id,
  300. tt.cost_type,
  301. tt.inlet,
  302. tt.export,
  303. tt.add_throw,
  304. tt.keep_point_ratio,
  305. tt.export_keep_point_ratio,
  306. CASE
  307. WHEN tt.cost_type = '交强险' THEN pa.jq_entrance_fee_ratio
  308. WHEN tt.cost_type = '商业险' THEN pa.sy_entrance_fee_ratio
  309. WHEN tt.cost_type = '驾意险' THEN pa.jy_entrance_fee_ratio
  310. ELSE NULL
  311. END AS commission
  312. FROM
  313. ptl_agreement_cost_type tt
  314. left join ptl_agreement_cost pac on pac.id = tt.ptl_agreement_cost_id AND pac.is_delete = 0
  315. left join ptl_agreement pa on pa.id = pac.ptl_agreement_id AND pa.is_delete = 0
  316. <where>
  317. tt.is_delete = 0
  318. AND tt.ptl_agreement_cost_id = #{costId}
  319. </where>
  320. </select>
  321. <select id="selectDictLabal" resultMap="RulesDictLabalMap">
  322. <if test="dictId != null and dictId != ''">
  323. select * from ptl_agreement_undwrt_rules_dict_labal
  324. <where>
  325. is_delete = 0
  326. AND dict_id = #{dictId}
  327. </where>
  328. </if>
  329. </select>
  330. <select id="pageList" resultMap="CostManagementVoMap">
  331. SELECT
  332. pa.attribution_id,
  333. (select paa.user_abbr from ptl_agreement_attribution paa where paa.id = pa.attribution_id ) as user_abbr,
  334. pc.id as cost_id,
  335. pr_raw.id as ruld_id,
  336. pc.audit_time,
  337. pc.audit_person,
  338. pc.product_id,
  339. pc.product_name,
  340. pc.cost_rules,
  341. pc.effective_time,
  342. pc.failure_time,
  343. pc.id costId,
  344. pc.ptl_agreement_id,
  345. pc.cover_rule_id,
  346. pc.approved,
  347. pc.cost_describe,
  348. pc.priority_level,
  349. pc.is_enabled,
  350. pc.create_time,
  351. pc.create_by,
  352. pa.agreement_code,
  353. pa.agreement_name,
  354. pa.agreement_title,
  355. pa.agreement_abbreviation,
  356. pa.id as ptlAgreementId,
  357. CASE
  358. WHEN pr_raw.parent_id IS NOT NULL AND pr_raw.parent_id != ''
  359. THEN (SELECT GROUP_CONCAT(child.rule_description ORDER BY child.order_num ASC SEPARATOR ',')
  360. FROM ptl_agreement_undwrt_rules child
  361. WHERE child.parent_id = pr_raw.parent_id AND child.is_delete = 0)
  362. ELSE pr_raw.rule_description
  363. END AS rule_description,
  364. eic.name as company_name,
  365. pa.company_id as company_id,
  366. pa.docking_person,
  367. pc.update_time,
  368. CASE
  369. WHEN NOW() >= pc.effective_time
  370. AND (pc.failure_time IS NULL OR NOW() &lt;= pc.failure_time)
  371. THEN 0
  372. ELSE 1
  373. END AS is_valid
  374. FROM
  375. ptl_agreement_cost pc
  376. LEFT JOIN ptl_agreement pa ON pa.id = pc.ptl_agreement_id and pa.is_delete = 0
  377. LEFT JOIN ptl_agreement_undwrt_rules pr_raw ON pr_raw.id = pc.cover_rule_id AND pr_raw.is_delete = 0
  378. LEFT JOIN esm_ins_company eic on eic.id = pa.company_id AND eic.is_delete = 0
  379. <where>
  380. pc.is_delete = 0
  381. <if test="costParam.costDescribes != null and costParam.costDescribes.length >0 ">
  382. and (
  383. <foreach collection="costParam.costDescribes" close=")" open="(" separator="and " item="costDescribe">
  384. pc.cost_describe like concat('%', #{costDescribe} ,'%')
  385. </foreach>
  386. )
  387. </if>
  388. <if test="costParam.auditTimeBegin != null and costParam.auditTimeBegin != ''">
  389. and pc.audit_time &gt;= #{costParam.auditTimeBegin}
  390. </if>
  391. <if test="costParam.auditTimeEnd != null and costParam.auditTimeEnd != ''">
  392. and pc.audit_time &lt; #{costParam.auditTimeEnd}
  393. </if>
  394. <if test="costParam.agreement != null and costParam.agreement != ''">
  395. AND (pa.agreement_title like concat('%',#{costParam.agreement},'%') or
  396. pa.agreement_code like concat('%',#{costParam.agreement},'%') or
  397. pa.agreement_abbreviation like concat('%',#{costParam.agreement},'%') or
  398. pa.id = #{costParam.agreement})
  399. </if>
  400. <if test="costParam.companyIdList != null and costParam.companyIdList.size() >0">
  401. and pa.partner_company_id in
  402. <foreach collection="costParam.companyIdList" item="partnerCompnayId" open="(" close=")" separator=",">
  403. #{partnerCompnayId}
  404. </foreach>
  405. </if>
  406. <if test="costParam.agreementIds != null and costParam.agreementIds.length >0 ">
  407. AND pa.id in
  408. <foreach collection="costParam.agreementIds" item="agreementId" separator="," open="(" close=")">
  409. #{agreementId}
  410. </foreach>
  411. </if>
  412. <if test="costParam.productIds != null and costParam.productIds.length > 0 ">
  413. AND pc.product_id in
  414. <foreach collection="costParam.productIds" item="productId" separator="," open="(" close=")">
  415. #{productId}
  416. </foreach>
  417. </if>
  418. <if test="costParam.productId != null and costParam.productId != '' ">
  419. AND pc.product_id = #{costParam.productId}
  420. </if>
  421. <if test="costParam.agreementId != null and costParam.agreementId != ''">
  422. AND pc.ptl_agreement_id = #{costParam.agreementId}
  423. </if>
  424. <if test="costParam.coverRuleId != null and costParam.coverRuleId != ''">
  425. AND pc.cover_rule_id = #{costParam.coverRuleId}
  426. </if>
  427. <if test="costParam.rulesName != null and costParam.rulesName != ''">
  428. AND (
  429. (pr_raw.parent_id IS NOT NULL AND pr_raw.parent_id != ''
  430. AND EXISTS (SELECT 1 FROM ptl_agreement_undwrt_rules child
  431. WHERE child.parent_id = pr_raw.parent_id
  432. AND child.is_delete = 0
  433. AND child.rule_description LIKE concat('%',#{costParam.rulesName},'%')))
  434. OR (pr_raw.parent_id IS NULL OR pr_raw.parent_id = '')
  435. AND pr_raw.rule_description LIKE concat('%',#{costParam.rulesName},'%')
  436. )
  437. </if>
  438. <if test="costParam.costRulesList != null and costParam.costRulesList.size() > 0">
  439. AND
  440. <foreach collection="costParam.costRulesList" item="keyword" separator="AND">
  441. pc.cost_rules LIKE CONCAT('%', #{keyword}, '%')
  442. </foreach>
  443. </if>
  444. <if test="costParam.costRules != null and costParam.costRules.length > 0">
  445. AND
  446. <foreach collection="costParam.costRules" item="keyword" separator="AND">
  447. pc.cost_rules LIKE CONCAT('%', #{keyword}, '%')
  448. </foreach>
  449. </if>
  450. <if test="costParam.agreementStatus != null and costParam.agreementStatus != ''">
  451. AND pc.is_enabled = #{costParam.agreementStatus}
  452. </if>
  453. <if test="costParam.auditStatus != null and costParam.auditStatus != ''">
  454. AND pc.approved = #{costParam.auditStatus}
  455. </if>
  456. <if test="costParam.validState != null and costParam.validState != ''">
  457. <choose>
  458. <!-- 有效 -->
  459. <when test="costParam.validState == 0">
  460. AND NOW() >= pc.effective_time
  461. AND (pc.failure_time IS NULL OR NOW() &lt;= pc.failure_time)
  462. </when>
  463. <!-- 无效 -->
  464. <when test="costParam.validState == 1">
  465. AND ( (pc.failure_time IS NOT NULL AND NOW() > pc.failure_time)
  466. )
  467. </when>
  468. </choose>
  469. </if>
  470. <if test="costParam.effectiveTime != null and costParam.effectiveTime.size() > 0">
  471. AND pc.effective_time BETWEEN #{costParam.effectiveTime[0]} AND #{costParam.effectiveTime[1]}
  472. </if>
  473. <if test="costParam.failureTime != null and costParam.failureTime.size() > 0">
  474. AND pc.failure_time BETWEEN #{costParam.failureTime[0]} AND #{costParam.failureTime[1]}
  475. </if>
  476. <if test="costParam.createTimeArr != null and costParam.createTimeArr.size() > 0">
  477. AND pc.create_time BETWEEN #{costParam.createTimeArr[0]} AND #{costParam.createTimeArr[1]}
  478. </if>
  479. <if test="costParam.companyId != null and costParam.companyId != ''">
  480. AND pa.company_id = #{costParam.companyId}
  481. </if>
  482. <if test="costParam.contactPerson != null and costParam.contactPerson != ''">
  483. AND pa.docking_person = #{costParam.contactPerson}
  484. </if>
  485. <if test="costParam.isEnabled != null and costParam.isEnabled != ''">
  486. AND pc.is_enabled = #{costParam.isEnabled}
  487. </if>
  488. <if test="costParam.updateTimeArr != null and costParam.updateTimeArr.size() > 0">
  489. AND pc.update_time BETWEEN #{costParam.updateTimeArr[0]} AND #{costParam.updateTimeArr[1]}
  490. </if>
  491. <if test="costParam.auditPerson != null and costParam.auditPerson != '' ">
  492. and pc.audit_person = #{costParam.auditPerson}
  493. </if>
  494. <if test="costParam.newCostIds != null and costParam.newCostIds.size() &gt; 0">
  495. AND pc.id IN
  496. <foreach collection="costParam.newCostIds" item="v" open="(" separator="," close=")">#{v}</foreach>
  497. </if>
  498. </where>
  499. order by pc.create_time desc
  500. </select>
  501. </mapper>