Ver Fonte

党员年龄、党龄统计

pengjing há 4 meses atrás
pai
commit
a8ab662251
2 ficheiros alterados com 29 adições e 2 exclusões
  1. 24 0
      lib/数据更新脚本.txt
  2. 5 2
      src/main/resources/mapping/BigDataCQuery.xml

+ 24 - 0
lib/数据更新脚本.txt

@@ -601,3 +601,27 @@ INSERT INTO `cf_menu` (`MENUID`, `APPLICATIONID`, `PARENTMENUID`, `MNUSYSTEM`, `
 INSERT INTO `cf_menu` (`MENUID`, `APPLICATIONID`, `PARENTMENUID`, `MNUSYSTEM`, `MENUORDER`, `MENUNO`, `MENUNAME`, `MENUPROGRAM`, `MENUPIC`, `MENUDESC`, `ISVISIBLE`, `ISLEAF`, `ISBLANK`) VALUES ('a30bc101-0008-0003-0001-557a666c7ff8', 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', 'a30bc101-0000-0003-0001-557a666c7ff8', NULL, 2, 'home.leaderAssessEdit2', '编辑干部试用期届满考核', '', '', '', 0, 0, NULL);
 INSERT INTO `cf_menu` (`MENUID`, `APPLICATIONID`, `PARENTMENUID`, `MNUSYSTEM`, `MENUORDER`, `MENUNO`, `MENUNAME`, `MENUPROGRAM`, `MENUPIC`, `MENUDESC`, `ISVISIBLE`, `ISLEAF`, `ISBLANK`) VALUES ('a30bc101-0009-0003-0001-557a666c7ff8', 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', 'a30bc101-0000-0003-0001-557a666c7ff8', NULL, 3, 'home.leaderAssessDetail2', '查看干部试用期届满考核详情', '', '', '', 0, 0, NULL);
 INSERT INTO `cf_menu` (`MENUID`, `APPLICATIONID`, `PARENTMENUID`, `MNUSYSTEM`, `MENUORDER`, `MENUNO`, `MENUNAME`, `MENUPROGRAM`, `MENUPIC`, `MENUDESC`, `ISVISIBLE`, `ISLEAF`, `ISBLANK`) VALUES ('a30bc101-0000-0003-0001-557a666c7ff8', 'f0c4fa7f9f3c4fb6bd56aac608b7ad3f', 'a30bc101-0000-0000-0001-557a666c7ff8', NULL, 3, 'home.leaderAssessList2', '干部试用期届满考核', '', '', '', 1, 0, NULL);
+
+
+-- 年龄计算函数
+set global log_bin_trust_function_creators=TRUE;
+
+DELIMITER $$
+CREATE FUNCTION `calculate_age` (birthdate DATE)
+RETURNS INTEGER
+BEGIN
+
+declare age int;
+set age =0;
+if month(current_date) > MONTH(birthdate) then
+  set age= year(current_date) - YEAR(birthdate) ;
+  elseif month(current_date) = MONTH(birthdate) and day(current_date) > DAY(birthdate) then
+  set age = year(current_date) - YEAR(birthdate);
+  else set age = year(current_date) - YEAR(birthdate) - 1;
+end if;
+
+return age;
+
+END$$
+
+DELIMITER ;

+ 5 - 2
src/main/resources/mapping/BigDataCQuery.xml

@@ -182,7 +182,9 @@
         else 5
         end) AGETYPE
         from (
-        select distinct us.RYJBXXBS,us.RYBM,fb.NL AS AGE
+        select distinct us.RYJBXXBS,us.RYBM
+                      -- ,fb.NL AS AGE
+        ,calculate_age(STR_TO_DATE(us.csrq, '%Y%m%d')) as AGE
         from VM_RYJBXX us
         inner join ZZ_ZZQKXX zz on us.SZDZBDM = zz.DZZDM
         inner join RS_RYJBXXFB fb on us.RYBM = fb.RYBM
@@ -233,8 +235,9 @@
         else 5
         end) ageType
         from (
-        select distinct us.RYJBXXBS,us.RYBM,(date_format(sysdate(),'%Y%m%d') - us.sqrdrq) /10000 AS age
+        select distinct us.RYJBXXBS,us.RYBM,calculate_age(STR_TO_DATE(dj.JRZGZZRQ, '%Y%m%d')) AS age
         from VM_RYJBXX us
+        inner join ZZ_DJXX dj on us.RYBM=dj.RYBM
         inner join ZZ_ZZQKXX zz on us.SZDZBDM = zz.DZZDM
         where 1=1 and us.SZDZBDM like concat('',#{gddwdm},'%')
         <if test="dzzdm != null and dzzdm != ''">