You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

271 lines
10 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.modules.partymember.dao.IcPartyMemberDao">
<resultMap type="com.epmet.modules.partymember.entity.IcPartyMemberEntity" id="icPartyMemberMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="orgPids" column="ORG_PIDS"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="agencyPids" column="AGENCY_PIDS"/>
<result property="icResiUser" column="IC_RESI_USER"/>
<result property="name" column="NAME"/>
<result property="mobile" column="MOBILE"/>
<result property="idCard" column="ID_CARD"/>
<result property="address" column="ADDRESS"/>
<result property="rdsj" column="RDSJ"/>
<result property="sszb" column="SSZB"/>
<result property="isLd" column="IS_LD"/>
<result property="ldzh" column="LDZH"/>
<result property="partyZw" column="PARTY_ZW"/>
<result property="isTx" column="IS_TX"/>
<result property="isDyzxh" column="IS_DYZXH"/>
<result property="isMxx" column="IS_MXX"/>
<result property="culture" column="CULTURE"/>
<result property="remark" column="REMARK"/>
<result property="field1" column="FIELD1"/>
<result property="field2" column="FIELD2"/>
<result property="field3" column="FIELD3"/>
<result property="field4" column="FIELD4"/>
<result property="field5" column="FIELD5"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="selectList" resultType="com.epmet.resi.partymember.dto.partymember.result.IcPartyMemberResultDTO">
SELECT
*
FROM (
SELECT
a.ID,
a.`NAME`,
a.MOBILE,
a.ID_CARD,
a.RDSJ,
d.PARTY_ORG_NAME AS sszb,
a.IS_LD,
a.LDZH,
a.PARTY_ZW,
a.ADDRESS,
IF( e.MONEY IS NULL, 0, 1 ) AS isPay,
b.PAY_DATE,
a.CULTURE,
a.TOTAL_SCORE AS point,
a.VOLUNTEER_CATEGORY,
a.REMARK
FROM
ic_party_member a
LEFT JOIN (
SELECT
CUSTOMER_ID,
PARTY_MEMBER_ID,
MAX(PAY_DATE) AS PAY_DATE
FROM
ic_party_member_pay_record
WHERE
DEL_FLAG = 0
GROUP BY
PARTY_MEMBER_ID ) b ON a.ID = b.PARTY_MEMBER_ID
AND b.CUSTOMER_ID = #{customerId}
INNER JOIN ic_party_org d ON a.SSZB = d.ID
AND d.DEL_FLAG = 0
LEFT JOIN ic_party_member_pay_record_detail e ON a.ID = e.PARTY_MEMBER_ID
AND e.DEL_FLAG = 0 AND e.`YEAR` = #{year} AND e.`MONTH` = #{month}
WHERE
a.DEL_FLAG = 0
AND a.CUSTOMER_ID = #{customerId}
AND (a.SSZB = #{partyOrgId} OR a.ORG_PIDS LIKE concat('%', #{partyOrgId}, '%'))
<if test='null != name and "" != name.trim()'>
AND a.NAME LIKE concat('%', #{name}, '%')
</if>
<if test='null != mobile and "" != mobile.trim()'>
AND a.MOBILE LIKE concat('%', #{mobile}, '%')
</if>
<if test='null != idCard and "" != idCard.trim()'>
AND a.ID_CARD LIKE concat('%', #{idCard}, '%')
</if>
<if test='null != address and "" != address.trim()'>
AND a.ADDRESS LIKE concat('%', #{address}, '%')
</if>
<if test='null != isLd and "" != isLd.trim()'>
AND a.IS_LD = #{address}
</if>
<if test='null != ldzh and "" != ldzh.trim()'>
AND a.LDZH LIKE concat('%', #{ldzh}, '%')
</if>
<if test='null != partyZw and "" != partyZw.trim()'>
AND a.PARTY_ZW = #{partyZw}
</if>
<if test='null != isDyzxh and "" != isDyzxh.trim()'>
AND a.IS_DYZXH = #{isDyzxh}
</if>
<if test='null != isMxx and "" != isMxx.trim()'>
AND a.IS_MXX = #{isMxx}
</if>
<if test='null != culture and "" != culture.trim()'>
AND a.CULTURE = #{culture}
</if>
<if test='null != rdsjStartDate and "" != rdsjStartDate.trim()'>
AND a.RDSJ &gt;= #{rdsjStartDate}
</if>
<if test='null != rdsjEndDate and "" != rdsjEndDate.trim()'>
AND a.RDSJ &lt;= #{rdsjEndDate}
</if>
<if test='null != payStatrDate and "" != payStatrDate.trim()'>
AND b.PAY_DATE &gt;= #{payStatrDate}
</if>
<if test='null != payEndDate and "" != payEndDate.trim()'>
AND b.PAY_DATE &lt;= #{payEndDate}
</if>
ORDER BY CONVERT(d.PARTY_ORG_NAME USING gbk), a.CREATED_TIME DESC
) t
WHERE
1=1
<if test='null != isPay and "" != isPay.trim()'>
AND isPay = #{isPay}
</if>
</select>
<select id="selectAllByOrgId" resultType="com.epmet.modules.partymember.entity.IcPartyMemberEntity">
SELECT * FROM `ic_party_member`
where DEL_FLAG='0'
AND (SSZB = #{orgId} or ORG_PIDS LIKE concat('%',#{orgId}, '%' ))
</select>
<select id="getPartyMemberEducationStatistics"
resultType="com.epmet.commons.tools.dto.result.OptionDataResultDTO">
SELECT
CULTURE AS "code",
count(ID) AS "value"
FROM
ic_party_member
WHERE
DEL_FLAG = '0'
AND CULTURE IS NOT NULL
<choose>
<when test='orgId != "" and orgId != null'>
AND (SSZB = #{orgId} OR ORG_PIDS LIKE CONCAT('%',#{orgId},'%'))
</when>
<otherwise>
AND (AGENCY_ID = #{agencyId} OR AGENCY_PIDS LIKE CONCAT('%',#{agencyId},'%'))
</otherwise>
</choose>
GROUP BY CULTURE
</select>
<select id="getPartyMemberAgeList" resultType="com.epmet.dto.result.PartyMemberAgeResultDTO">
SELECT
ID AS "userId",
NAME,
MOBILE,
age,
IC_RESI_USER
FROM
(
SELECT
ID,
NAME,
MOBILE,
age,
CASE
WHEN age &lt; 50 THEN '0'
WHEN age &gt;= 50 AND age &lt;= 59 THEN '1'
WHEN age &gt;= 60 AND age &lt;= 69 THEN '2'
WHEN age &gt;= 70 AND age &lt;= 79 THEN '3'
ELSE '4'
END AS ageGroup,
IC_RESI_USER
FROM
(
SELECT
ID,
NAME,
MOBILE,
YEAR (FROM_DAYS(DATEDIFF(NOW(),SUBSTRING( ID_CARD, 7, 8 )))) AS age,
IC_RESI_USER
FROM
ic_party_member
WHERE
DEL_FLAG = '0'
<choose>
<when test='orgId != "" and orgId != null'>
AND (SSZB = #{orgId} OR ORG_PIDS LIKE CONCAT('%',#{orgId},'%'))
</when>
<otherwise>
AND (AGENCY_ID = #{agencyId} OR AGENCY_PIDS LIKE CONCAT('%',#{agencyId},'%'))
</otherwise>
</choose>
) a
) a
<if test="null != code and '' != code">
WHERE ageGroup = #{code}
</if>
ORDER BY CONVERT(NAME USING GBK) ASC
</select>
<select id="getPartyMemberEducationList" resultType="com.epmet.dto.result.PartyMemberEducationResultDTO">
SELECT
ID AS "userId",
NAME,
MOBILE,
CULTURE AS education,
IC_RESI_USER
FROM
ic_party_member
WHERE
DEL_FLAG = '0'
AND CULTURE IS NOT NULL
<if test="null != code and '' != code">
AND CULTURE = #{code}
</if>
<choose>
<when test='orgId != "" and orgId != null'>
AND (SSZB = #{orgId} OR ORG_PIDS LIKE CONCAT('%',#{orgId},'%'))
</when>
<otherwise>
AND (AGENCY_ID = #{agencyId} OR AGENCY_PIDS LIKE CONCAT('%',#{agencyId},'%'))
</otherwise>
</choose>
ORDER BY CONVERT(NAME USING GBK) ASC
</select>
<select id="getPartyMemberAgeStatistics"
resultType="com.epmet.commons.tools.dto.result.OptionDataResultDTO">
SELECT
ageGroup AS "code",
COUNT(ID) AS "value"
FROM
(
SELECT
ID,
CASE
WHEN age &lt; 50 THEN '0'
WHEN age &gt;= 50 AND age &lt;= 59 THEN '1'
WHEN age &gt;= 60 AND age &lt;= 69 THEN '2'
WHEN age &gt;= 70 AND age &lt;= 79 THEN '3'
ELSE '4'
END AS ageGroup
FROM
(
SELECT
ID,
YEAR (FROM_DAYS(DATEDIFF(NOW(),SUBSTRING( ID_CARD, 7, 8 )))) AS age
FROM
ic_party_member
WHERE
DEL_FLAG = '0'
<choose>
<when test='orgId != "" and orgId != null'>
AND (SSZB = #{orgId} OR ORG_PIDS LIKE CONCAT('%',#{orgId},'%'))
</when>
<otherwise>
AND (AGENCY_ID = #{agencyId} OR AGENCY_PIDS LIKE CONCAT('%',#{agencyId},'%'))
</otherwise>
</choose>
) a
) a
GROUP BY ageGroup
</select>
</mapper>