Browse Source

年龄计算调整

dev
yinzuomei 2 years ago
parent
commit
e1204cf30b
  1. 63
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

63
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -1558,31 +1558,35 @@
temp.CODE, temp.CODE,
count(temp.ID) as totalResi count(temp.ID) as totalResi
from ( from (
SELECT select
u.ID, temp1.id,
YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) as age,
( (
case when u.BIRTHDAY > DATE_SUB(CURDATE(),INTERVAL 50 year) then '0' case when temp1.age < 50 then '0'
when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 59 year) AND DATE_SUB(CURDATE(),INTERVAL 50 year) then '1' when temp1.age >= 50 and temp1.age <= 59 then '1'
when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 69 year) AND DATE_SUB(CURDATE(),INTERVAL 60 year) then '2' when temp1.age >= 60 and temp1.age <= 69 then '2'
when u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 79 year) AND DATE_SUB(CURDATE(),INTERVAL 70 year) then '3' when temp1.age >= 70 and temp1.age <= 79 then '3'
when u.BIRTHDAY <= DATE_SUB(CURDATE(),INTERVAL 80 year) then '4' when temp1.age >= 80 then '4'
end end
) as `code` ) as `code`
FROM from (
ic_resi_user u SELECT
WHERE u.ID,
u.DEL_FLAG = '0' YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) as age
AND u.CUSTOMER_ID = #{customerId} FROM
and u.`STATUS`='0' ic_resi_user u
and u.BIRTHDAY is not null WHERE
and u.BIRTHDAY !='' u.DEL_FLAG = '0'
<if test='orgType == "agency" '> AND u.CUSTOMER_ID = #{customerId}
AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') ) and u.`STATUS`='0'
</if> and u.BIRTHDAY is not null
<if test='orgType == "grid" '> and u.BIRTHDAY !=''
and u.GRID_ID = #{orgId} <if test='orgType == "agency" '>
</if> AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') )
</if>
<if test='orgType == "grid" '>
and u.GRID_ID = #{orgId}
</if>
)temp1
)temp )temp
group by temp.`code` group by temp.`code`
</select> </select>
@ -1601,8 +1605,7 @@
u.ID_CARD AS idCard, u.ID_CARD AS idCard,
u.GENDER AS gender, u.GENDER AS gender,
( CASE WHEN u.GENDER = '1' THEN '男' WHEN u.GENDER = '2' THEN '女' ELSE '未知' END ) AS genderName, ( CASE WHEN u.GENDER = '1' THEN '男' WHEN u.GENDER = '2' THEN '女' ELSE '未知' END ) AS genderName,
YEAR ( YEAR (NOW())- SUBSTR( u.BIRTHDAY, 1, 4 ) AS age,
NOW())- SUBSTR( u.BIRTHDAY, 1, 4 ) AS age,
u.CULTURE AS educationCode, u.CULTURE AS educationCode,
'' AS educationName, '' AS educationName,
IFNULL(u.CULTURE,'')AS educationCode, IFNULL(u.CULTURE,'')AS educationCode,
@ -1626,19 +1629,19 @@
</if> </if>
<if test='codeType == "age" '> <if test='codeType == "age" '>
<if test=" 0 == code"> <if test=" 0 == code">
and u.BIRTHDAY > DATE_SUB(CURDATE(),INTERVAL 50 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt; 50
</if> </if>
<if test=" 1 == code"> <if test=" 1 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 59 year) AND DATE_SUB(CURDATE(),INTERVAL 50 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;=50 and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt;=59
</if> </if>
<if test=" 2 == code"> <if test=" 2 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 69 year) AND DATE_SUB(CURDATE(),INTERVAL 60 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;= 60 and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt;= 69
</if> </if>
<if test=" 3 == code"> <if test=" 3 == code">
and u.BIRTHDAY BETWEEN DATE_SUB(CURDATE(),INTERVAL 79 year) AND DATE_SUB(CURDATE(),INTERVAL 70 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;=70 and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &lt;=79
</if> </if>
<if test=" 4 == code"> <if test=" 4 == code">
and u.BIRTHDAY &lt;= DATE_SUB(CURDATE(),INTERVAL 80 year) and YEAR(NOW())-SUBSTR(u.BIRTHDAY, 1, 4) &gt;=80
</if> </if>
</if> </if>
order by u.ID asc order by u.ID asc

Loading…
Cancel
Save