|
|
@ -33,6 +33,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
@ -51,11 +53,14 @@ public class PersonTestingServiceImpl extends BaseServiceImpl<PersonTestingDao, |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<PersonTestingDTO> page(Map<String, Object> params) { |
|
|
|
IPage<PersonTestingEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, PersonTestingDTO.class); |
|
|
|
// IPage<PersonTestingEntity> page = baseDao.selectPage(
|
|
|
|
// getPage(params, FieldConstant.CREATED_TIME, false),
|
|
|
|
// getWrapper(params)
|
|
|
|
// );
|
|
|
|
// return getPageData(page, PersonTestingDTO.class);
|
|
|
|
IPage<PersonTestingDTO> page = getPage(params); |
|
|
|
List<PersonTestingDTO> list = baseDao.getTestingPage(params); |
|
|
|
return new PageData<>(list, page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -82,11 +87,47 @@ public class PersonTestingServiceImpl extends BaseServiceImpl<PersonTestingDao, |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(PersonTestingDTO dto) { |
|
|
|
public void save(PersonTestingDTO dto) throws ParseException { |
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
PersonTestingEntity entity = ConvertUtils.sourceToTarget(dto, PersonTestingEntity.class); |
|
|
|
String bir = getBirthday(entity.getIdcard()); |
|
|
|
entity.setBirthday(format.parse( bir )); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取出生日期 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() == 15){ |
|
|
|
// 身份证上的年份(15位身份证为1980年前的)
|
|
|
|
year = "19" + IDCard.substring(6, 8); |
|
|
|
//身份证上的月份
|
|
|
|
month = IDCard.substring(8, 10); |
|
|
|
//身份证上的日期
|
|
|
|
day= IDCard.substring(10, 12); |
|
|
|
//18位身份证号
|
|
|
|
}else if(IDCard.length() == 18){ |
|
|
|
// 身份证上的年份
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(PersonTestingDTO dto) { |
|
|
|