PtlAgreementMapper.xml 12 KB

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