Browse Source

新增死亡人员调整,获取年龄调整

dev
Jackwang 3 years ago
parent
commit
c2df6e90f0
  1. 61
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/IdCardNoValidatorUtils.java
  2. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/ChangeDeathDTO.java
  3. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ChangeDeathEntity.java
  4. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ChangeDeathServiceImpl.java

61
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/IdCardNoValidatorUtils.java

@ -4,15 +4,17 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.*;
import static java.util.regex.Pattern.compile;
/**
* 身份证号校验
@ -24,6 +26,15 @@ public class IdCardNoValidatorUtils {
private static Logger logger = LoggerFactory.getLogger(IdCardNoValidatorUtils.class);
/**
* 15位身份证号
*/
private static final Integer FIFTEEN_ID_CARD = 15;
/**
* 18位身份证号
*/
private static final Integer EIGHTEEN_ID_CARD = 18;
/**
* 身份证验证
*
@ -216,15 +227,15 @@ public class IdCardNoValidatorUtils {
int nowMonth = now.getMonthValue();
int cardYear = 0;
int cardMonth = 0;
if (StringUtils.isNotBlank(IDCard) && checkIsIdCardNo(IDCard)) {
if (IDCard.length() == 15) {
if (StringUtils.isNotBlank(IDCard) && isValid(IDCard)) {
if (IDCard.length() == FIFTEEN_ID_CARD) {
// 身份证上的年份(15位身份证为1980年前的)
String uyear = "19" + IDCard.substring(6, 8);
cardYear = Integer.parseInt(uyear);
// 身份证上的月份
String uyue = IDCard.substring(8, 10);
cardMonth = Integer.parseInt(uyue);
} else if (IDCard.length() == 18) {
} else if (IDCard.length() == EIGHTEEN_ID_CARD) {
// 身份证上的年份
String year = IDCard.substring(6).substring(0, 4);
cardYear = Integer.parseInt(year);
@ -243,5 +254,47 @@ public class IdCardNoValidatorUtils {
return age;
}
/**
* 身份证验证是否有效
*
* @param id 号码内容
* @return boolean
* @author
* @date
*/
public static boolean isValid(String id) {
Boolean validResult = true;
//校验长度只能为15或18
int len = id.length();
if (len != FIFTEEN_ID_CARD && len != EIGHTEEN_ID_CARD) {
validResult = false;
}
//校验生日
if (!validDate(id)) {
validResult = false;
}
return validResult;
}
/**
* 校验生日
*
* @param id
* @return
*/
private static boolean validDate(String id) {
try {
String birth = id.length() == FIFTEEN_ID_CARD ? "19" + id.substring(6, 12) : id.substring(6, 14);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date birthDate = sdf.parse(birth);
if (!birth.equals(sdf.format(birthDate))) {
return false;
}
} catch (ParseException e) {
return false;
}
return true;
}
}

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/ChangeDeathDTO.java

@ -64,6 +64,11 @@ public class ChangeDeathDTO implements Serializable {
*/
private String type;
/**
* 死亡时间
*/
private Date deathDate;
/**
* 加入时间
*/

7
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/ChangeDeathEntity.java

@ -5,6 +5,8 @@ import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 死亡名单表
*
@ -53,6 +55,11 @@ public class ChangeDeathEntity extends BaseEpmetEntity {
*/
private String type;
/**
* 死亡时间
*/
private Date deathDate;
/**
* 加入时间
*/

4
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/ChangeDeathServiceImpl.java

@ -148,10 +148,10 @@ public class ChangeDeathServiceImpl extends BaseServiceImpl<ChangeDeathDao, Chan
IcResiUserTransferFormDTO icResiUserTransferFormDTO=new IcResiUserTransferFormDTO();
icResiUserTransferFormDTO.setIcUserId(dto.getUserId());
icResiUserTransferFormDTO.setType("out");
icResiUserTransferFormDTO.setCustomerId(dto.getCustomerId());
icResiUserTransferFormDTO.setCustomerId(loginUserUtil.getLoginUserCustomerId());
icResiUserTransferFormDTO.setStaffId(dto.getStaffId());
//死亡日期即为取当前时间,视作变更时间 todo 待确认
icResiUserTransferFormDTO.setTransferTime(new Date());
icResiUserTransferFormDTO.setTransferTime(dto.getDeathDate());
// icResiUserTransferFormDTO.setMoveType(IcResiUserConstant.DIED);
icResiUserTransferFormDTO.setOrigin(IcResiUserConstant.DIED);
//死亡原因

Loading…
Cancel
Save