PtlAgreementMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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.protocol.dao.PtlAgreementMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.protocol.entity.po.PtlAgreement">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="companiesType" column="companies_type" jdbcType="INTEGER"/>
  9. <result property="agreementType" column="agreement_type" jdbcType="VARCHAR"/>
  10. <result property="agreementCode" column="agreement_code" jdbcType="VARCHAR"/>
  11. <result property="agreementName" column="agreement_name" jdbcType="VARCHAR"/>
  12. <result property="agreementAbbreviation" column="agreement_abbreviation" jdbcType="VARCHAR"/>
  13. <result property="insuranceCompany" column="insurance_company" jdbcType="VARCHAR"/>
  14. <result property="insuranceCompanyId" column="insurance_company_id" jdbcType="VARCHAR"/>
  15. <result property="partnerCompaniesId" column="partner_companies_id" jdbcType="VARCHAR"/>
  16. <result property="associationCompaniesId" column="association_companies_id" jdbcType="VARCHAR"/>
  17. <result property="startDate" column="start_date" jdbcType="DATE"/>
  18. <result property="endDate" column="end_date" jdbcType="DATE"/>
  19. <result property="moneyTime" column="money_time" jdbcType="INTEGER"/>
  20. <result property="matchType" column="match_type" jdbcType="VARCHAR"/>
  21. <result property="dockingPerson" column="docking_person" jdbcType="VARCHAR"/>
  22. <result property="dockingPhone" column="docking_phone" jdbcType="VARCHAR"/>
  23. <result property="withTax" column="with_tax" jdbcType="VARCHAR"/>
  24. <result property="moneyType" column="money_type" jdbcType="VARCHAR"/>
  25. <result property="validStatus" column="valid_status" jdbcType="VARCHAR"/>
  26. <result property="fileId" column="file_id" jdbcType="VARCHAR"/>
  27. <result property="auditContent" column="audit_content" jdbcType="VARCHAR"/>
  28. <result property="auditStatus" column="audit_status" jdbcType="TINYINT"/>
  29. <result property="creator" column="creator" jdbcType="VARCHAR"/>
  30. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  31. <result property="modifiedBy" column="modified_by" jdbcType="VARCHAR"/>
  32. <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
  33. </resultMap>
  34. <resultMap id="AgreementCompanyResultMap" type="com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto">
  35. <id property="id" column="id" jdbcType="VARCHAR"/>
  36. <result property="name" column="name" jdbcType="VARCHAR"/>
  37. <result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
  38. <result property="namesimple" column="namesimple" jdbcType="VARCHAR"/>
  39. <result property="remark" column="remark" jdbcType="VARCHAR"/>
  40. <result property="orderNum" column="order_num" jdbcType="INTEGER"/>
  41. <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
  42. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  43. <result property="lastUpdateBy" column="last_update_by" jdbcType="VARCHAR"/>
  44. <result property="lastUpdateTime" column="last_update_time" jdbcType="TIMESTAMP"/>
  45. <result property="cnName" column="cn_name" jdbcType="VARCHAR"/>
  46. <result property="logo" column="logo" jdbcType="VARCHAR"/>
  47. <collection property="agreement" ofType="com.ydtech.modules.protocol.entity.dto.PtlAgreementDto">
  48. <id property="id" column="agreement_id"/>
  49. <result property="agreementName" column="agreement_name"/>
  50. <result property="underwritingDescription" column="underwriting_description"/>
  51. <result property="apiType" column="api_type"/>
  52. <result property="productsCode" column="products_code"/>
  53. </collection>
  54. </resultMap>
  55. <sql id="Base_Column_List">
  56. id,agreement_type,agreement_code,
  57. agreement_name,agreement_abbreviation,insurance_company,
  58. start_date,end_date,money_time,
  59. match_type,docking_person,docking_phone,
  60. with_tax,money_type,cooperation_channels,
  61. valid_status,file_id,audit_status,
  62. creator,create_time,modified_by,
  63. update_time
  64. </sql>
  65. <select id="getAgreementCompany" resultMap="AgreementCompanyResultMap">
  66. select eic.*, pa.id as agreement_id, pa.agreement_name,pa.products_code, paa.api_type, pa.underwriting_description
  67. from esm_ins_company as eic
  68. left join ptl_agreement as pa on pa.insurance_company_id = eic.id
  69. left join ptl_agreement_attribution as paa on paa.id = pa.id
  70. where (#{localDate} between start_date and end_date)
  71. and (paa.template_id is not null)
  72. and pa.valid_status = 1
  73. and pa.id in (select distinct agreement_id
  74. from ptl_agreement_dept
  75. <if test="deptId != null and deptId != ''">
  76. where dept_id = #{deptId}
  77. </if>
  78. )
  79. order by pa.serial_number
  80. </select>
  81. <select id="getAgreementCompanyExternal" resultMap="AgreementCompanyResultMap">
  82. select eic.*, pa.id as agreement_id, pa.agreement_name,pa.products_code, paa.api_type, pa.underwriting_description
  83. from esm_ins_company as eic
  84. left join ptl_agreement as pa on pa.insurance_company_id = eic.id
  85. left join ptl_agreement_attribution as paa on paa.id = pa.id
  86. where (#{localDate} between start_date and end_date)
  87. and (paa.template_id is not null)
  88. and pa.valid_status = 1
  89. and pa.is_external = 1
  90. and pa.id in (select distinct agreement_id
  91. from ptl_agreement_dept
  92. <if test="deptId != null and deptId != ''">
  93. where dept_id = #{deptId}
  94. </if>
  95. )
  96. order by pa.serial_number
  97. </select>
  98. <select id="getAgreementCompanyByCompanyId" resultMap="AgreementCompanyResultMap">
  99. select eic.*, pa.id as agreement_id, pa.agreement_name, paa.api_type, pa.underwriting_description
  100. from esm_ins_company as eic
  101. left join ptl_agreement as pa on pa.insurance_company_id = eic.id
  102. left join ptl_agreement_attribution as paa on paa.id = pa.id
  103. where (#{localDate} between start_date and end_date)
  104. and (paa.template_id is not null)
  105. and pa.valid_status = 1
  106. and pa.id in (select distinct agreement_id
  107. from ptl_agreement_dept
  108. <if test="deptId != null and deptId != ''">
  109. where dept_id = #{deptId}
  110. </if>
  111. <if test="companyId != null and companyId != ''">
  112. and company_id = #{companyId}
  113. </if>
  114. )
  115. order by pa.serial_number
  116. </select>
  117. <select id="getByAgreementIdNew" resultType="com.ydtech.modules.protocol.entity.po.PtlAgreement">
  118. select
  119. *
  120. from ptl_agreement
  121. <where>
  122. <if test="agreementId!=null and agreementId !=''">
  123. id=#{agreementId}
  124. </if>
  125. </where>
  126. </select>
  127. <select id="getDockingPersonList" resultType="java.util.HashMap">
  128. SELECT docking_person
  129. FROM `ptl_agreement`
  130. GROUP BY docking_person
  131. </select>
  132. <select id="selectAgreeId" resultType="com.ydtech.modules.protocol.entity.po.PtlAgreement">
  133. select
  134. *
  135. from ptl_agreement a
  136. <where>
  137. <if test="companyId !=null and companyId !=''" >
  138. a.insurance_company_id =#{companyId}
  139. </if>
  140. <if test="partnerCompaniesId !=null and partnerCompaniesId !=''" >
  141. and a.partner_companies_id =#{partnerCompaniesId}
  142. </if>
  143. <if test="agreeId !=null and agreeId !=''" >
  144. and a.id =#{agreeId}
  145. </if>
  146. </where>
  147. limit 1
  148. </select>
  149. <select id="queryReportPage" resultType="com.ydtech.modules.admin.model.report.user.agree.AgreeReportDto">
  150. SELECT
  151. eic.id AS companyId,
  152. eic.NAME AS companyName,
  153. pa.id AS agreeId,
  154. eic_hz.id AS partnerCompaniesId,
  155. eic_hz.NAME AS partnerCompaniesName,
  156. pa.partner_companies_id,
  157. pa.agreement_name AS agreeName,
  158. pa.agreement_abbreviation AS agreeSimpleName,
  159. pa.start_date AS agreeStartDate,
  160. pa.end_date AS agreeEndDate,
  161. DATEDIFF(
  162. end_date,
  163. NOW()) AS dayStr,
  164. area.area_cname as areaName
  165. FROM
  166. esm_ins_company AS eic
  167. LEFT JOIN ptl_agreement AS pa ON pa.insurance_company_id = eic.id
  168. LEFT JOIN ptl_agreement_attribution AS paa ON paa.id = pa.id
  169. LEFT JOIN esm_ins_company eic_hz ON pa.partner_companies_id = eic_hz.id
  170. left join sys_area area on RPAD(SUBSTRING( pa.partner_companies_id, 6, 4 ),6,0)= area.area_code
  171. <where>
  172. ( now() BETWEEN pa.start_date AND pa.end_date )
  173. AND ( paa.template_id IS NOT NULL )
  174. AND pa.valid_status = 1
  175. <if test="vo.deptId !=null and vo.deptId !=''" >
  176. AND pa.id IN ( SELECT DISTINCT agreement_id FROM ptl_agreement_dept WHERE dept_id LIKE concat(#{vo.deptId},'%') )
  177. </if>
  178. <if test="vo.warningDay !=null and vo.warningDay !=''" >
  179. <choose>
  180. <when test="warningDay==1">
  181. DATEDIFF(pa.end_date,NOW()) &lt;= 30
  182. </when>
  183. <when test="warningDay==2">
  184. DATEDIFF(pa.end_date,NOW()) &lt;= 60
  185. </when>
  186. </choose>
  187. </if>
  188. <if test="vo.warningStatus !=null and vo.warningStatus !=''" >
  189. <choose>
  190. <when test="warningStatus==1">
  191. DATEDIFF(pa.end_date,NOW()) &lt;= 30
  192. </when>
  193. <when test="warningStatus==2">
  194. DATEDIFF(pa.end_date,NOW()) > 30
  195. </when>
  196. </choose>
  197. </if>
  198. <if test="vo.areaId !=null and vo.areaId !=''" >
  199. AND ( pa.companies_type = 1 AND RPAD(SUBSTRING( pa.partner_companies_id, 6, 4 ),6,0) = #{vo.areaId})
  200. </if>
  201. <if test="vo.partnerCompaniesId !=null and vo.partnerCompaniesId !=''" >
  202. and pa.partner_companies_id =#{vo.partnerCompaniesId}
  203. </if>
  204. </where>
  205. ORDER BY
  206. pa.serial_number
  207. </select>
  208. </mapper>