Browse Source

添加人员逻辑

origin/feature/monitoring
Jackwang 4 years ago
parent
commit
15df7525ef
  1. 95
      epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/PersonTestingServiceImpl.java
  2. 9
      epdc-cloud-vim-yushan/src/main/java/com/elink/esua/epdc/vaccine/epidemic/dao/EpidemicUserInfoDao.java
  3. 3
      epdc-cloud-vim-yushan/src/main/java/com/elink/esua/epdc/vaccine/epidemic/dto/EpidemicRecordListDTO.java
  4. 11
      epdc-cloud-vim-yushan/src/main/java/com/elink/esua/epdc/vaccine/epidemic/entity/EpidemicUserInfoEntity.java
  5. 14
      epdc-cloud-vim-yushan/src/main/resources/mapper/epidemic/EpidemicUserInfoDao.xml

95
epdc-cloud-custom/src/main/java/com/elink/esua/epdc/modules/epidemic/service/impl/PersonTestingServiceImpl.java

@ -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;
}
}

9
epdc-cloud-vim-yushan/src/main/java/com/elink/esua/epdc/vaccine/epidemic/dao/EpidemicUserInfoDao.java

@ -70,6 +70,15 @@ public interface EpidemicUserInfoDao extends BaseDao<EpidemicUserInfoEntity> {
*/
EpidemicUserInfoEntity selectByIdCard(@Param("id") Long id);
/**
* @describe: 根据身份证号查询信息
* @author wangtong
* @date 2021/8/21 16:15
* @params [idCard]
* @return com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserInfoEntity
*/
EpidemicUserInfoEntity selectInfoByIdCard(@Param("idCard") String idCard);
/**
* 根据身份证号查询基础信息表信息
*

3
epdc-cloud-vim-yushan/src/main/java/com/elink/esua/epdc/vaccine/epidemic/dto/EpidemicRecordListDTO.java

@ -215,4 +215,7 @@ public class EpidemicRecordListDTO implements Serializable {
// @ApiModelProperty(value = "接种状态")
private Integer vaccinationState;
// @ApiModelProperty(value = "核酸检测状态")
private String checkStateName;
}

11
epdc-cloud-vim-yushan/src/main/java/com/elink/esua/epdc/vaccine/epidemic/entity/EpidemicUserInfoEntity.java

@ -5,6 +5,8 @@ import com.elink.esua.epdc.vaccine.common.base.BasePingyinEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 疫情防控信息表
*
@ -167,4 +169,13 @@ public class EpidemicUserInfoEntity extends BasePingyinEntity {
* 网格名称
*/
private String gridName;
/**
* 核酸检测状态
*/
private String checkState;
/**
* 核酸检测时间
*/
private Date checkDate;
}

14
epdc-cloud-vim-yushan/src/main/resources/mapper/epidemic/EpidemicUserInfoDao.xml

@ -56,11 +56,18 @@
IFNULL(uir.RISK_GRADE,'') AS RISK_GRADE,
uir.ROOM_NO,
uir.OUT_LIVE_ADDRESS_NAME outLiveAddressName,
ui.HOUSEHOLD_REGISTER_NAME householdRegisterName
ui.HOUSEHOLD_REGISTER_NAME householdRegisterName,
if(ui.check_state='0','已检测','未检测') as checkStateName
from epidemic_user_info ui
left join epidemic_user_inout_record uir on ui.ID_CARD=uir.ID_CARD
where ui.DEL_FLAG='0'
and uir.DEL_FLAG='0'
<if test="chechState != null and chechState != '' and chechState== '0'">
and ui.check_state = #{chechState}
</if>
<if test="chechState != null and chechState != '' and chechState== '1'">
and ( ui.check_state = #{chechState} or ui.check_state is null)
</if>
<if test="idCard != null and idCard != ''">
and ui.ID_CARD = #{idCard}
</if>
@ -394,5 +401,10 @@
AND REVISION = '0'
AND LENGTH(ID_CARD) = 18
</update>
<select id="selectInfoByIdCard" resultMap="epidemicUserInfoMap">
select * from epidemic_user_info
where ID_CARD=#{idCard}
and del_flag='0'
</select>
</mapper>

Loading…
Cancel
Save