|
@ -248,28 +248,45 @@ public class DataHandingService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateToPaitentDevcieLog()throws Exception{
|
|
|
List<PatientDevice> patientDeviceList = patientDeviceDao.findAll();
|
|
|
String sql = "SELECT * FROM `wlyy_patient_device_log` where operate_code = 1";
|
|
|
List<PatientDeviceLog> patientDeviceLogs = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(PatientDeviceLog.class));
|
|
|
List<PatientDeviceLog> patientDeviceLogList = new ArrayList<>();
|
|
|
for (PatientDevice patientDevice : patientDeviceList){
|
|
|
PatientDeviceLog patientDeviceLog = new PatientDeviceLog();
|
|
|
patientDeviceLog.setDeviceId(patientDevice.getDeviceId());
|
|
|
patientDeviceLog.setAgreementPhoto(patientDevice.getAgreementPhoto());
|
|
|
if (!StringUtils.isEmpty(patientDevice.getDoctor())){
|
|
|
patientDeviceLog.setOperator(patientDevice.getDoctor());
|
|
|
patientDeviceLog.setOperatorName(patientDevice.getDoctorName());
|
|
|
patientDeviceLog.setRole(1);
|
|
|
}else if (!StringUtils.isEmpty(patientDevice.getAgent())){
|
|
|
patientDeviceLog.setOperator(patientDevice.getAgent());
|
|
|
patientDeviceLog.setOperatorName(patientDevice.getAgentName());
|
|
|
patientDeviceLog.setRole(2);
|
|
|
int i = 0 ;
|
|
|
for (PatientDeviceLog patientDeviceLog : patientDeviceLogs){
|
|
|
if (patientDevice.getDeviceSn().equals(patientDeviceLog.getDeviceSn()) && patientDevice.getUser().equals(patientDeviceLog.getPatient())){
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
if (i==0){
|
|
|
PatientDeviceLog patientDeviceLog = new PatientDeviceLog();
|
|
|
patientDeviceLog.setDeviceId(patientDevice.getDeviceId());
|
|
|
patientDeviceLog.setAgreementPhoto(patientDevice.getAgreementPhoto());
|
|
|
if (!StringUtils.isEmpty(patientDevice.getDoctor())){
|
|
|
patientDeviceLog.setOperator(patientDevice.getDoctor());
|
|
|
patientDeviceLog.setOperatorName(patientDevice.getDoctorName());
|
|
|
patientDeviceLog.setRole(1);
|
|
|
}else if (!StringUtils.isEmpty(patientDevice.getAgent())){
|
|
|
patientDeviceLog.setOperator(patientDevice.getAgent());
|
|
|
patientDeviceLog.setOperatorName(patientDevice.getAgentName());
|
|
|
patientDeviceLog.setRole(2);
|
|
|
}else {
|
|
|
patientDeviceLog.setRole(2);
|
|
|
patientDeviceLog.setOperator(patientDevice.getUser());
|
|
|
Patient pa = patientDao.findByCode(patientDevice.getUser());
|
|
|
if (pa!=null){
|
|
|
patientDeviceLog.setOperatorName(pa.getName());
|
|
|
}
|
|
|
}
|
|
|
patientDeviceLog.setCreateTime(patientDevice.getCzrq());
|
|
|
patientDeviceLog.setDeviceSn(patientDevice.getDeviceSn());
|
|
|
patientDeviceLog.setDeviceName(patientDevice.getDeviceName());
|
|
|
patientDeviceLog.setCategoryCode(patientDevice.getCategoryCode());
|
|
|
patientDeviceLog.setPatient(patientDevice.getUser());
|
|
|
patientDeviceLog.setOperateCode(1);
|
|
|
patientDeviceLog.setIsDel(1);
|
|
|
patientDeviceLogList.add(patientDeviceLog);
|
|
|
}
|
|
|
patientDeviceLog.setCreateTime(patientDevice.getCzrq());
|
|
|
patientDeviceLog.setDeviceSn(patientDevice.getDeviceSn());
|
|
|
patientDeviceLog.setDeviceName(patientDevice.getDeviceName());
|
|
|
patientDeviceLog.setCategoryCode(patientDevice.getCategoryCode());
|
|
|
patientDeviceLog.setPatient(patientDevice.getUser());
|
|
|
patientDeviceLog.setOperateCode(1);
|
|
|
patientDeviceLog.setIsDel(1);
|
|
|
patientDeviceLogList.add(patientDeviceLog);
|
|
|
}
|
|
|
patientDeviceLogDao.save(patientDeviceLogList);
|
|
|
}
|