Forráskód Böngészése

Merge branch 'dev' of zd_123/patient-co-management into dev

huangwenjie 7 éve
szülő
commit
59b8ab8ca2

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceLogDao.java

@ -17,4 +17,7 @@ public interface PatientDeviceLogDao extends PagingAndSortingRepository<PatientD
    
    @Query("select pdl from PatientDeviceLog pdl where pdl.patient=?1 group by deviceSn ")
    List<PatientDeviceLog> findByPatientGroupByDeviceSn(String patient);
    @Query("select a from PatientDeviceLog a")
    List<PatientDeviceLog> findAllList();
}

+ 36 - 19
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

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