Browse Source

人员年龄性别生成

yanliming 2 years ago
parent
commit
e274894575

+ 7 - 6
common/src/main/java/com/jpsoft/employment/modules/base/entity/PersonInfo.java

@@ -7,6 +7,7 @@ import java.math.BigDecimal;
 
 
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
+import org.springframework.data.annotation.Transient;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 
@@ -40,12 +41,6 @@ public class PersonInfo {
 	@ApiModelProperty(value = "照片")
 	@ApiModelProperty(value = "照片")
 	private String photo;
 	private String photo;
 
 
-	@ApiModelProperty(value = "性别")
-	private String gender;
-
-	@ApiModelProperty(value = "年龄")
-	private Integer age;
-
 	@ApiModelProperty(value = "关联企业")
 	@ApiModelProperty(value = "关联企业")
 	private String enterpriseId;
 	private String enterpriseId;
 
 
@@ -70,4 +65,10 @@ public class PersonInfo {
 
 
 	@ApiModelProperty(value = "是否删除")
 	@ApiModelProperty(value = "是否删除")
 	private Boolean delFlag;
 	private Boolean delFlag;
+
+	@ApiModelProperty(value = "性别")
+	private String gender;
+
+	@ApiModelProperty(value = "年龄")
+	private Integer age;
 }
 }

+ 5 - 0
common/src/main/java/com/jpsoft/employment/modules/common/utils/IdCardUtils.java

@@ -3,6 +3,9 @@ package com.jpsoft.employment.modules.common.utils;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 @Slf4j
 @Slf4j
 public class IdCardUtils {
 public class IdCardUtils {
     public static String decrypt(String idCard){
     public static String decrypt(String idCard){
@@ -34,4 +37,6 @@ public class IdCardUtils {
 
 
         return result;
         return result;
     }
     }
+
+
 }
 }

+ 11 - 0
web/src/main/java/com/jpsoft/employment/modules/base/controller/PersonInfoController.java

@@ -1,5 +1,6 @@
 package com.jpsoft.employment.modules.base.controller;
 package com.jpsoft.employment.modules.base.controller;
 
 
+import cn.hutool.core.util.IdcardUtil;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.Page;
 import com.jpsoft.employment.config.OSSConfig;
 import com.jpsoft.employment.config.OSSConfig;
 import com.jpsoft.employment.modules.common.dto.MessageResult;
 import com.jpsoft.employment.modules.common.dto.MessageResult;
@@ -7,6 +8,7 @@ import com.jpsoft.employment.modules.common.utils.DES3;
 import com.jpsoft.employment.modules.common.utils.OSSUtil;
 import com.jpsoft.employment.modules.common.utils.OSSUtil;
 import com.jpsoft.employment.modules.common.utils.POIUtils;
 import com.jpsoft.employment.modules.common.utils.POIUtils;
 import com.jpsoft.employment.modules.common.utils.PojoUtils;
 import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import com.jpsoft.employment.modules.common.utils.IdCardUtils;
 import com.jpsoft.employment.modules.common.dto.Sort;
 import com.jpsoft.employment.modules.common.dto.Sort;
 import com.jpsoft.employment.modules.base.entity.PersonInfo;
 import com.jpsoft.employment.modules.base.entity.PersonInfo;
 import com.jpsoft.employment.modules.base.service.PersonInfoService;
 import com.jpsoft.employment.modules.base.service.PersonInfoService;
@@ -460,6 +462,15 @@ public class PersonInfoController {
             personInfo.setUpdateBy(subject);
             personInfo.setUpdateBy(subject);
             personInfo.setUpdateTime(new Date());
             personInfo.setUpdateTime(new Date());
 
 
+            if(StringUtils.isNotEmpty(personInfo.getIdCard())){
+                int gender = IdcardUtil.getGenderByIdCard(personInfo.getIdCard());
+                int age = IdcardUtil.getAgeByIdCard(personInfo.getIdCard());
+
+                personInfo.setGender(String.valueOf(gender));
+                personInfo.setAge(age);
+            }
+
+
             int affectCount = personInfoService.update(personInfo);
             int affectCount = personInfoService.update(personInfo);
 
 
             if (affectCount > 0) {
             if (affectCount > 0) {