|
|
@ -32,6 +32,8 @@ import com.elink.esua.epdc.modules.epidemic.entity.PersonTestingEntity; |
|
|
|
import com.elink.esua.epdc.modules.epidemic.feign.OssFeignClient; |
|
|
|
import com.elink.esua.epdc.modules.epidemic.redis.PersonTestingRedis; |
|
|
|
import com.elink.esua.epdc.modules.epidemic.service.PersonTestingService; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dao.EpidemicUserInfoDao; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserInfoEntity; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -39,10 +41,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 核酸检测记录 |
|
|
@ -59,6 +58,10 @@ public class PersonTestingServiceImpl extends BaseServiceImpl<PersonTestingDao, |
|
|
|
@Autowired |
|
|
|
private OssFeignClient ossFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpidemicUserInfoDao epidemicUserInfoDao; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<PersonTestingPageDTO> page(Map<String, Object> params) { |
|
|
|
// IPage<PersonTestingEntity> page = baseDao.selectPage(
|
|
|
@ -153,6 +156,10 @@ public class PersonTestingServiceImpl extends BaseServiceImpl<PersonTestingDao, |
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
public Result saveScanningInfo(PersonTestingDTO dto) { |
|
|
|
//检测时间
|
|
|
|
Date date = new Date(); |
|
|
|
dto.setTestingTime(date); |
|
|
|
saveScanningInfoForUser(dto); |
|
|
|
UploadFormDTO form = new UploadFormDTO(); |
|
|
|
form.setBase64String("data:image/png;base64,"+dto.getImgCode()); |
|
|
|
PersonTestingEntity entity = ConvertUtils.sourceToTarget(dto, PersonTestingEntity.class); |
|
|
@ -163,9 +170,87 @@ public class PersonTestingServiceImpl extends BaseServiceImpl<PersonTestingDao, |
|
|
|
if(StringUtils.isNotBlank(uploadResult.getData())){ |
|
|
|
entity.setImgUrl(uploadResult.getData()); |
|
|
|
} |
|
|
|
entity.setTestingTime(new Date()); |
|
|
|
entity.setTestingTime(date); |
|
|
|
insert(entity); |
|
|
|
return new Result().ok("录入成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @describe: 匹配到更新人员的核酸检测状态和最后一次核酸检测时间,匹配不到用户新增一条人员信息 |
|
|
|
* @author wangtong |
|
|
|
* @date 2021/8/21 15:12 |
|
|
|
* @params [dto] |
|
|
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|
|
|
*/ |
|
|
|
|
|
|
|
private Result saveScanningInfoForUser(PersonTestingDTO dto){ |
|
|
|
EpidemicUserInfoEntity en = epidemicUserInfoDao.selectInfoByIdCard(dto.getIdcard()); |
|
|
|
if(en != null){ |
|
|
|
en.setCheckDate(dto.getTestingTime()); |
|
|
|
en.setCheckState("0"); |
|
|
|
epidemicUserInfoDao.updateById(en); |
|
|
|
}else{ |
|
|
|
EpidemicUserInfoEntity entity = new EpidemicUserInfoEntity(); |
|
|
|
entity.setUserName(dto.getName()); |
|
|
|
entity.setGender(dto.getSex()); |
|
|
|
entity.setNation(dto.getNation()); |
|
|
|
entity.setHouseholdRegisterDetail(dto.getAddress()); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
entity.setBirthday(sdf.format(dto.getBirthday())); |
|
|
|
entity.setIdCard(dto.getIdcard()); |
|
|
|
entity.setCheckDate(dto.getTestingTime()); |
|
|
|
entity.setCheckState("0"); |
|
|
|
entity.setAge(getAgeByDateString(sdf.format(dto.getBirthday()))); |
|
|
|
epidemicUserInfoDao.insert(entity); |
|
|
|
} |
|
|
|
return new Result().ok(""); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
*根据生日计算年龄 |
|
|
|
* dateStr 这样格式的生日 1990-01-01 |
|
|
|
*/ |
|
|
|
|
|
|
|
public int getAgeByDateString(String dateStr) { |
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
try { |
|
|
|
Date birthday = simpleDateFormat.parse(dateStr); |
|
|
|
return getAgeByDate(birthday); |
|
|
|
} catch (ParseException e) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getAgeByDate(Date birthday) { |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
//calendar.before()有的点bug
|
|
|
|
if (calendar.getTimeInMillis() - birthday.getTime() < 0L) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int yearNow = calendar.get(Calendar.YEAR); |
|
|
|
int monthNow = calendar.get(Calendar.MONTH); |
|
|
|
int dayOfMonthNow = calendar.get(Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
calendar.setTime(birthday); |
|
|
|
|
|
|
|
|
|
|
|
int yearBirthday = calendar.get(Calendar.YEAR); |
|
|
|
int monthBirthday = calendar.get(Calendar.MONTH); |
|
|
|
int dayOfMonthBirthday = calendar.get(Calendar.DAY_OF_MONTH); |
|
|
|
|
|
|
|
int age = yearNow - yearBirthday; |
|
|
|
|
|
|
|
|
|
|
|
if (monthNow <= monthBirthday && monthNow == monthBirthday && dayOfMonthNow < dayOfMonthBirthday || monthNow < monthBirthday) { |
|
|
|
age--; |
|
|
|
} |
|
|
|
|
|
|
|
return age; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |