|
@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.device.PatientDeviceLog;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.manage.User;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.health.repository.DeviceDetailDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.manage.UserDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
@ -64,6 +65,8 @@ public class DataHandingService {
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private CreditLogService creditLogService;
|
|
|
@Autowired
|
|
|
private DeviceDetailDao deviceDetailDao;
|
|
|
|
|
|
@Transactional
|
|
|
public String producePatientAndDoctorPassword() {
|
|
@ -506,6 +509,89 @@ public class DataHandingService {
|
|
|
logger.info("添加积分失败!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导入药盒绑定设备的数据
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<String> importKitInfo(Integer batch)throws Exception{
|
|
|
|
|
|
String sql = " select * from wlyy.kit_bind_info_temp where batch="+batch;
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
List<String> errorList = new ArrayList<>();
|
|
|
for(Map<String,Object> one:mapList){
|
|
|
String name = one.get("name").toString();//居民名称
|
|
|
String idcard = one.get("idcard").toString();//居民身份证
|
|
|
String kitSn = one.get("kit_sn").toString();//药盒sn码
|
|
|
String deviceType = one.get("device_type").toString();//药盒设备型号
|
|
|
Patient patient = patientDao.findByIdcard(idcard);
|
|
|
if(patient==null){//身份证不匹配
|
|
|
errorList.add(kitSn);
|
|
|
continue;
|
|
|
}
|
|
|
DeviceDetail deviceDetail = deviceDetailDao.findBySn(kitSn);
|
|
|
if(deviceDetail==null){
|
|
|
|
|
|
//添加设备
|
|
|
deviceDetail = new DeviceDetail();
|
|
|
}
|
|
|
deviceDetail.setDeviceModel(deviceType);//设备型号
|
|
|
deviceDetail.setDeviceName("巨烨科技智能药盒");
|
|
|
deviceDetail.setDeviceCode(kitSn);
|
|
|
deviceDetail.setLinkman(patient.getName());
|
|
|
//通过签约关系获取团队信息,有则添加。
|
|
|
String sql2 = " select f.* from wlyy_sign_family f where f.idcard='"+idcard+"' and f.status=1 ";
|
|
|
List<Map<String, Object>> signFamilys1 = jdbcTemplate.queryForList(sql2);
|
|
|
if(signFamilys1.size()>0){
|
|
|
deviceDetail.setOrgName(signFamilys1.get(0).get("hospital_name")+"");
|
|
|
deviceDetail.setGrantAdminTeam(signFamilys1.get(0).get("admin_team_code")+"");
|
|
|
deviceDetail.setGrantOrgCode(signFamilys1.get(0).get("hospital")+"");
|
|
|
}
|
|
|
deviceDetail.setTel(patient.getMobile());
|
|
|
deviceDetail.setGrantTime(new Date());
|
|
|
deviceDetail = deviceDetailDao.save(deviceDetail);
|
|
|
//添加设备绑定关系
|
|
|
List<PatientDevice> patientDeviceList = patientDeviceDao.findByPatientAndDeviceSn(patient.getCode(),kitSn);
|
|
|
PatientDevice patientDevice = null;
|
|
|
if(patientDeviceList.size()>0){
|
|
|
patientDevice = patientDeviceList.get(0);
|
|
|
}else{
|
|
|
patientDevice = new PatientDevice();
|
|
|
}
|
|
|
patientDevice.setDeviceId(7L);
|
|
|
patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
|
|
|
patientDevice.setDeviceName(deviceDetail.getDeviceName());
|
|
|
patientDevice.setUser(patient.getCode());
|
|
|
patientDevice.setCategoryCode("3");
|
|
|
patientDevice.setUserType("-1");
|
|
|
patientDevice.setUserIdcard(patient.getIdcard());
|
|
|
patientDevice.setCzrq(new Date());
|
|
|
patientDevice.setDel(0);
|
|
|
patientDeviceDao.save(patientDevice);
|
|
|
//由于PatientDevice绑定关系是物理删除,所以添加PatientDeviceLog绑定记录
|
|
|
PatientDeviceLog patientDeviceLog = new PatientDeviceLog();
|
|
|
patientDeviceLog.setDeviceId(7L);
|
|
|
patientDeviceLog.setPatient(patientDevice.getUser());
|
|
|
patientDeviceLog.setCategoryCode(patientDevice.getCategoryCode());
|
|
|
patientDeviceLog.setDeviceName(patientDevice.getDeviceName());
|
|
|
patientDeviceLog.setDeviceSn(patientDevice.getDeviceSn());
|
|
|
patientDeviceLog.setRole(1);
|
|
|
patientDeviceLog.setOperateCode(1);
|
|
|
patientDeviceLog.setAgreementPhoto(patientDevice.getAgreementPhoto());
|
|
|
// if (role==1){
|
|
|
// patientDeviceLog.setOperatorName(patientDevice.getDoctorName());
|
|
|
// patientDeviceLog.setOperator(patientDevice.getDoctor());
|
|
|
// }else if (role==2){
|
|
|
// patientDeviceLog.setOperatorName(patientDevice.getAgentName());
|
|
|
// patientDeviceLog.setOperator(patientDevice.getAgent());
|
|
|
// }
|
|
|
patientDeviceLog.setCreateTime(new Date());
|
|
|
patientDeviceLog.setIsDel(1);
|
|
|
patientDeviceLogDao.save(patientDeviceLog);
|
|
|
String sqlUpdate = " update wlyy.kit_bind_info_temp set import=1 where kit_sn='"+kitSn+"'";
|
|
|
jdbcTemplate.execute(sqlUpdate);
|
|
|
}
|
|
|
return errorList;
|
|
|
}
|
|
|
}
|