浏览代码

修改居民绑定设备判断是否存在设备;总体分析中设备绑定列表改为绑定人

zd_123 7 年之前
父节点
当前提交
b3396e1f43

+ 35 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/device/PatientDevice.java

@ -50,7 +50,16 @@ public class PatientDevice extends IdEntity {
    //上传的协议图片地址
    private String agreementPhoto;
    //========================非表字段======================
    //居民签约所在社区
    private String hospital;
    //居民签约所在社区名字
    private String hospitalName;
    //登记医生名字
    private String checkDoctorName;
  //========================非表字段======================
    //患者居住地址
    private String address;
    ///**
@ -237,7 +246,32 @@ public class PatientDevice extends IdEntity {
        this.agreementPhoto = agreementPhoto;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "check_doctor_name")
    public String getCheckDoctorName() {
        return checkDoctorName;
    }
    public void setCheckDoctorName(String checkDoctorName) {
        this.checkDoctorName = checkDoctorName;
    }
    @Transient
    public String getAddress() {

+ 34 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/device/PatientDeviceLog.java

@ -37,6 +37,13 @@ public class PatientDeviceLog extends IdEntity {
    private int isDel;
    //上传的协议图片地址
    private String agreementPhoto;
    //居民签约所在社区
    private String hospital;
    //居民签约所在社区名字
    private String hospitalName;
    //登记医生名字
    private String checkDoctorName;
    @Column(name = "device_id")
    public long getDeviceId() {
@ -147,6 +154,33 @@ public class PatientDeviceLog extends IdEntity {
        this.agreementPhoto = agreementPhoto;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "check_doctor_name")
    public String getCheckDoctorName() {
        return checkDoctorName;
    }
    public void setCheckDoctorName(String checkDoctorName) {
        this.checkDoctorName = checkDoctorName;
    }
    public PatientDeviceLog() {
    }

+ 15 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceLogService.java

@ -3,6 +3,8 @@ package com.yihu.wlyy.service.app.device;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientDeviceLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientDeviceLogDao;
import com.yihu.wlyy.service.BaseService;
@ -32,6 +34,8 @@ public class PatientDeviceLogService extends BaseService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    /**
     * 绑定和解绑的时候会保存一条数据
@ -58,8 +62,17 @@ public class PatientDeviceLogService extends BaseService {
            patientDeviceLog.setOperatorName(patientDevice.getDoctorName());
            patientDeviceLog.setOperator(patientDevice.getDoctor());
        }else if (role==2){
            patientDeviceLog.setOperatorName(patientDevice.getAgentName());
            patientDeviceLog.setOperator(patientDevice.getAgent());
            if(StringUtils.isEmpty(patientDevice.getAgent())){
                Patient patient = patientDao.findByCode(patientDevice.getUser());
                if (patient!=null){
                    patientDeviceLog.setOperatorName(patient.getName());
                    patientDeviceLog.setOperator(patient.getCode());
                }
            }else {
                patientDeviceLog.setOperatorName(patientDevice.getAgentName());
                patientDeviceLog.setOperator(patientDevice.getAgent());
            }
        }
        patientDeviceLog.setCreateTime(new Date());
        patientDeviceLog.setIsDel(1);

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java

@ -166,6 +166,7 @@ public class CreditLogService {
        object.put("openId",patient.getOpenid());
        object.put("unionId",patient.getUnionid());
        String url =getBaseUrl() + "createCreditsDetail";
        //String url ="http://192.168.5.109:10051/svr-health-bank/createCreditsDetail";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        try {
@ -775,7 +776,7 @@ public class CreditLogService {
        }
        String url =getBaseUrl()+ "selectByDate";
        //String url = "http://192.168.5.106:10051/svr-health-bank/selectByDate";
        //String url = "http://192.168.5.109:10051/svr-health-bank/selectByDate";
        Map<String,String> params = new HashMap<>();
        params.put("object",object.toJSONString());
        try {

+ 114 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.app.statisticsES;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
@ -6130,4 +6131,117 @@ public class StatisticsESService {
        return rsJs;
    }*/
    public JSONArray getDeviceLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (date.compareTo(dateFormat.format(new Date())) >= 0) {
            date = elasticsearchUtil.getQuotaTime();
        }
        List<SaveModel> esModelList = new ArrayList<>();
        if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
            String time = getStatisticsTime();
            String sql ="SELECT" +
                    " pd.doctor team," +
                    " pd.doctor_name teamName," +
                    " COUNT(1) result1" +
                    " FROM" +
                    " wlyy_patient_device pd," +
                    " wlyy_sign_family sf" +
                    " WHERE" +
                    " pd.user_idcard = sf.idcard" +
                    " AND sf.type = 2" +
                    " AND pd.del = 0" +
                    " AND sf. STATUS IN (1, 2)" +
                    " AND pd.czrq < '"+time+"'" +
                    " AND sf.sign_year = '"+year+"'";
            if(level==3){
                sql +=" AND LEFT(sf.hospital,6)= '"+area+"'";
            }else if (level==4){
                sql +=" AND sf.hospital = '"+area+"'";
            }
            sql +=" GROUP BY team,teamName";
            esModelList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SaveModel.class));
        }else {
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date, area, level, index, SaveModel.timeLevel_DDL, low_level);
        }
        if (esModelList != null && esModelList.size() > 0) {
            for (SaveModel one : esModelList) {
                Map<String, Object> maps = new HashMap<String, Object>();
                maps.put("amount", one.getResult1().intValue());
                if (low_level.equals("3")) {
                    maps.put("code", one.getTown());
                    maps.put("name", one.getTownName());
                } else if (low_level.equals("4")) {
                    maps.put("code", one.getHospital());
                    maps.put("name", one.getHospitalName());
                } else if (low_level.equals("5")) {
                    if ( StringUtils.isNotEmpty(one.getTeam()) && StringUtils.isEmpty(one.getTownName())){
                        maps.put("code", one.getTeam());
                        Doctor doctor = doctorDao.findByCode(one.getTeam());
                        if (doctor!=null){
                            maps.put("name", doctor.getName());
                        }
                    }
                    if (StringUtils.isEmpty(one.getTeam())){
                        maps.put("code","0");
                        maps.put("name", "其他");
                    }
                }
                resultList.add(maps);
            }
        }
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = getLowLevelMapKey(level, low_level, area);
        }
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                if (!low_level.equals("5")) {
                    PopulationBase peopleNum = getPopulationBase(area, year);
                    if (peopleNum != null) {
                        map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                        map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
                        map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
                        map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
                        map.put("taskRateString", map.get("amount") + "/" + peopleNum.getTaskNum());
                        map.put("targetRateString", peopleNum.getTaskNum() + "/" + peopleNum.getNum());
                        map.put("num", peopleNum.getNum());
                        map.put("task", peopleNum.getTaskNum());
                    }
                }
            }
            /*if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
                translateTeamLeaderName(resultList);
            }*/
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    long map1value = (long) o1.get("amount");
                    long map2value = (long) o2.get("amount");
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -383,6 +383,9 @@ public class PatientDeviceController extends BaseController {
                                @ApiParam(name = "device_sn", value = "设备SN码", defaultValue = "15L000002")
                                @RequestParam(value = "device_sn", required = true) String deviceSn) {
        try {
            if (deviceDetailService.findByDeviceSn(deviceSn)==null){
                return write(-1,"设备不存在!");
            }
//            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getUID(), deviceSn, type);
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getRepUID(), deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -591,7 +591,9 @@ public class EsStatisticsController extends BaseController {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel, year));
                    } else if (idx.equals("72")) {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalOnlineTeamLeader(date, area, level, idx, sort, lowLevel, year, ""));
                    } else {
                    }else if (idx.equals("20")){
                        result.put("index_" + idx, statisticsESService.getDeviceLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                    }else {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                    }
                }