Kaynağa Gözat

fix 新增常驻人口身份证查询信息

tjf 3 yıl önce
ebeveyn
işleme
c79e13e209

+ 12 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/CzrkController.java

@@ -6,6 +6,7 @@ import com.boman.common.log.annotation.Log;
 import com.boman.common.log.enums.BusinessType;
 import com.boman.domain.Czrk;
 import com.boman.domain.TableDataInfo;
+import com.boman.domain.VaccineInfoOperation;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.web.core.service.czrk.ICzrkService;
 import org.checkerframework.checker.units.qual.C;
@@ -142,4 +143,15 @@ public class CzrkController extends BaseController {
     public AjaxResult stsByCzrkHomePage() {
         return AjaxResult.success("成功", czrkService.stsByCzrkHomePage());
     }
+
+
+
+    /**
+     * 根据身份证号查询用户信息
+     */
+    @PostMapping("/findHjInfo")
+    public AjaxResult findHjInfo(@RequestBody Czrk czrk) {
+        Czrk hjInfo = czrkService.findHjInfo(czrk);
+        return AjaxResult.success(hjInfo);
+    }
 }

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/CzrkMapper.java

@@ -86,4 +86,12 @@ public interface CzrkMapper {
     List<Czrk> listIsRl(@Param("type") int type, @Param("areaId") Long areaId, @Param("userName") String userName);
 
 //    int stsByWrl(@Param("deptIdList") List<Long> deptIdList, @Param("userName") String userName);
+
+
+    /**
+     *根据身份证号查询用户信息
+     * @param czrk
+     * @return
+     */
+   Czrk findHjInfo(Czrk czrk);
 }

+ 27 - 0
boman-web-core/src/main/java/com/boman/web/core/service/czrk/CzrkServiceImpl.java

@@ -16,6 +16,7 @@ import com.boman.domain.utils.ThreadPoolService;
 import com.boman.system.api.RemoteDeptService;
 import com.boman.web.core.mapper.CzrkMapper;
 import com.boman.web.core.utils.AuthUtils;
+import com.boman.web.core.utils.IdCardUtils;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.BooleanUtils;
@@ -33,6 +34,8 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 import static com.boman.common.core.utils.StringUtils.isNotEmpty;
+import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getAge;
+import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getSex;
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.common.redis.RedisKey.STS_CZRK_;
 import static com.google.common.base.Strings.nullToEmpty;
@@ -649,6 +652,30 @@ public class CzrkServiceImpl implements ICzrkService {
         return result;
     }
 
+    /**
+     * 根据身份证号查询用户信息
+     * @param czrk
+     * @return
+     */
+    @Override
+    public Czrk findHjInfo(Czrk czrk) {
+        Czrk hjInfo = czrkMapper.findHjInfo(czrk);
+        if (hjInfo == null) {
+            String idCard = czrk.getIdCard();
+            if (StringUtils.isNotBlank(idCard)) {
+                //根据身份证提取出生日和性别,年龄
+                String sex = getSex(idCard);
+                Integer age = getAge(idCard);
+                String birthday = IdCardUtils.getBirthday(idCard);
+                hjInfo.setAge(age);
+                hjInfo.setGender(sex);
+                hjInfo.setBirthday(birthday);
+                return hjInfo;
+            }
+        }
+        return hjInfo;
+    }
+
     private void townSts(JSONObject result, Czrk condition, Long deptId, String deptName, boolean percent) {
         // 乡镇以下的所有部门
         List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);

+ 7 - 0
boman-web-core/src/main/java/com/boman/web/core/service/czrk/ICzrkService.java

@@ -80,4 +80,11 @@ public interface ICzrkService {
     JSONObject stsByCzrk();
     JSONObject stsByCzrkHomePage();
 
+    /**
+     * 根据身份证号查询用户信息
+     * @param czrk
+     * @return
+     */
+    Czrk findHjInfo(Czrk czrk);
+
 }

+ 74 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/IdCardUtils.java

@@ -115,4 +115,78 @@ public class IdCardUtils {
         return true;
     }
 
+
+
+    /**
+     * 15位身份证号
+     */
+    private static final Integer FIFTEEN_ID_CARD = 15;
+    /**
+     * 18位身份证号
+     */
+    private static final Integer EIGHTEEN_ID_CARD = 18;
+
+    /**
+     * 根据身份证号获取性别
+     *
+     * @param IDCard
+     * @return
+     */
+    public static String getSex(String IDCard) {
+        String sex = "";
+        if (StringUtils.isNotBlank(IDCard)) {
+            //15位身份证号
+            if (IDCard.length() == FIFTEEN_ID_CARD) {
+                if (Integer.parseInt(IDCard.substring(14, 15)) % 2 == 0) {
+                    sex = "女";
+                } else {
+                    sex = "男";
+                }
+                //18位身份证号
+            } else if (IDCard.length() == EIGHTEEN_ID_CARD) {
+                // 判断性别
+                if (Integer.parseInt(IDCard.substring(16).substring(0, 1)) % 2 == 0) {
+                    sex = "女";
+                } else {
+                    sex = "男";
+                }
+            }
+        }
+        return sex;
+    }
+
+    /**
+     * 获取出生日期  yyyy年MM月dd日
+     *
+     * @param IDCard
+     * @return
+     */
+    public static String getBirthday(String IDCard) {
+        String birthday = "";
+        String year = "";
+        String month = "";
+        String day = "";
+        if (StringUtils.isNotBlank(IDCard)) {
+            //15位身份证号
+            if (IDCard.length() == FIFTEEN_ID_CARD) {
+                // 身份证上的年份(15位身份证为1980年前的)
+                year = "19" + IDCard.substring(6, 8);
+                //身份证上的月份
+                month = IDCard.substring(8, 10);
+                //身份证上的日期
+                day = IDCard.substring(10, 12);
+                //18位身份证号
+            } else if (IDCard.length() == EIGHTEEN_ID_CARD) {
+                // 身份证上的年份
+                year = IDCard.substring(6).substring(0, 4);
+                // 身份证上的月份
+                month = IDCard.substring(10).substring(0, 2);
+                //身份证上的日期
+                day = IDCard.substring(12).substring(0, 2);
+            }
+            birthday = year + "-" + month + "-" + day;
+        }
+        return birthday;
+    }
+
 }

+ 28 - 0
boman-web-core/src/main/resources/mapper/CzrkMapper.xml

@@ -42,6 +42,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="isDel"    column="is_del"    />
         <result property="deleteReason"    column="delete_reason"    />
+        <collection  property="czrkJzdzList"   javaType="java.util.List"        resultMap="CzrkJzdzResult" />
+    </resultMap>
+
+    <resultMap type="com.boman.domain.CzrkJzdz" id="CzrkJzdzResult">
+        <result property="provinceId"    column="province_id_jzdz"    />
+        <result property="province"    column="province_jzdz"    />
+        <result property="cityId"    column="city_id_jzdz"    />
+        <result property="city"    column="city_jzdz"    />
+        <result property="regionId"    column="region_id_jzdz"    />
+        <result property="region"    column="region_jzdz"    />
+        <result property="townId"    column="town_id_jzdz"    />
+        <result property="town"    column="town_jzdz"    />
+        <result property="villageId"    column="village_id_jzdz"    />
+        <result property="village"    column="village_jzdz"    />
+        <result property="nowIn"    column="now_in_jzdz"    />
     </resultMap>
 
     <sql id="selectCzrkVo">
@@ -542,4 +557,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           , update_time   = sysdate()
         where id = #{id}
     </update>
+
+
+    <select id="findHjInfo"  resultMap="CzrkResult">
+        select c.id, c.user_name ,c.gender, c.birthday,c.age,c.code,c.phone_num,c.key_industries,c.province_id,c.province,c.city_id,c.city,c.region_id,c.region,c.village_towns_id,c.village_towns,c.village_id,c.village,c.villager_group_id,c.villager_group,
+        c.now_in,c.house_type,c.code,c.yhzgx,c.remark,
+        cj.province_id as province_id_jzdz,cj.province as province_jzdz,cj.city_id as city_id_jzdz,cj.city as city_jzdz,cj.region_id as region_id_jzdz,cj.region as region_jzdz,cj.town_id as town_id_jzdz,cj.town as town_jzdz,cj.village_id as village_id_jzdz,cj.village as village_jzdz,cj.now_in as now_in_jzdz
+         from czrk c left join czrk_jzdz cj on c.id_card = cj.id_card
+        <where>
+            c.is_del = 'N'
+            and cj.status = 'Y'
+            <if test="idCard != null and idCard != '' "> and c.id_card = #{idCard}</if>
+        </where>
+    </select>
 </mapper>