소스 검색

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

humingfen 7 년 전
부모
커밋
e012c3ca87

+ 100 - 76
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/AsyncService.java

@ -221,20 +221,24 @@ public class AsyncService extends BaseService{
     * 推送信息
     */
    private void sendMessage(String content, Patient patient, PatientHealthIndex model) {
        logger.info("======start sendMessage======");
        String patientCode = patient.getCode();
        // 消息接收者
        List<String> receivers = new ArrayList<String>();
        // 查询病人家庭签约的健康管理师
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patientCode);
        logger.info("签约对象--全科医生code===="+signFamily.getDoctor());
        String healthDoctorFamily = "";
        String doctorFamily = "";
        if (signFamily != null) {
            healthDoctorFamily = signFamily.getDoctorHealth();
            doctorFamily = signFamily.getDoctor();
            logger.info("全科医生code======"+doctorFamily);
            if (StringUtils.isNotEmpty(healthDoctorFamily)) {
                // 添加到消息接收人列表
                receivers.add(healthDoctorFamily);
            } else if (StringUtils.isNotEmpty(doctorFamily)){
            }
            if (StringUtils.isNotEmpty(doctorFamily)){
                // 添加到消息接收人列表
                receivers.add(doctorFamily);
            }
@ -248,7 +252,7 @@ public class AsyncService extends BaseService{
                // 添加到消息接收人列表
                receivers.add(healthDoctorTeam);
            }
            if (StringUtils.isNotEmpty(signFamilySS.getDoctor())){
            if (StringUtils.isNotEmpty(signFamilySS.getDoctor())&& !StringUtils.equals(doctorFamily, signFamilySS.getDoctor())){
                receivers.add(signFamilySS.getDoctor());
            }
        }
@ -292,6 +296,7 @@ public class AsyncService extends BaseService{
            }
        }
        // 批量保存消息
        logger.info("消息数量---"+messages.size());
        messageDao.save(messages);
        // 推送消息给医生
        pushMsgTask.put(array);
@ -459,6 +464,73 @@ public class AsyncService extends BaseService{
        }
    }
    /**
     * 设置
     * @param patient
     * @return
     */
    public int setTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(swh.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    /**
     * 添加积分
     * @param deviceSn
@ -482,11 +554,11 @@ public class AsyncService extends BaseService{
                flagStr="GLU_MEASURE";
            }
            int dataUoloadCount = 0;
            PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType);
            boolean dataUoloadCount = true;
            if (patientDevice!=null){
                String today = DateUtil.getStringDateShort();
                String startTime = today+" 00:00:00";
                /*String startTime = today+" 00:00:00";
                String endTime = today+" 23:59:59";
                int dateType =1;
                if (deviceType==1){
@ -496,19 +568,38 @@ public class AsyncService extends BaseService{
                }
                String countSql = "SELECT count(*) num FROM device.wlyy_patient_health_index where `user`='"+patientDevice.getUser()+"' and type = "+dateType+" AND record_date >'"+startTime+"' and record_date <= '"+endTime+"'";
                Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql);
                dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num")));
                dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num")));*/
                //判断今天是否加过体征积分
                String urlSearch = wlyyService + "healthBank/selectByDate";
                List<NameValuePair> paramsSearch1 = new ArrayList<>();
                paramsSearch1.add(new BasicNameValuePair("objectStr", "{\"taskCode\":\"BP_MEASURE\",\"startTime\":\""+today+"\",\"endTime\":\""+today+"\",\"patientId\":\""+patientCode+"\"}"));
                String responseSearch1 = HttpClientUtil.post(urlSearch, paramsSearch1, "UTF-8");
                List<NameValuePair> paramsSearch2 = new ArrayList<>();
                paramsSearch2.add(new BasicNameValuePair("objectStr", "{\"taskCode\":\"GLU_MEASURE\",\"startTime\":\""+today+"\",\"endTime\":\""+today+"\",\"patientId\":\""+patientCode+"\"}"));
                String responseSearch2 = HttpClientUtil.post(urlSearch, paramsSearch2, "UTF-8");
                com.alibaba.fastjson.JSONObject object1 = com.alibaba.fastjson.JSONObject.parseObject(responseSearch1);
                com.alibaba.fastjson.JSONObject object2 = com.alibaba.fastjson.JSONObject.parseObject(responseSearch2);
                if(object1!=null && object2!=null){
                    com.alibaba.fastjson.JSONObject jsonObject1 = (com.alibaba.fastjson.JSONObject) object1.getJSONObject("data").getJSONArray("detailModelList").get(0);
                    com.alibaba.fastjson.JSONObject jsonObject2 = (com.alibaba.fastjson.JSONObject) object2.getJSONObject("data").getJSONArray("detailModelList").get(0);
                    if (jsonObject1.getJSONArray("creditsDetailDOS").size()==0 && jsonObject2.getJSONArray("creditsDetailDOS").size()==0){
                        dataUoloadCount = false;
                    }
                }
                logger.info("今日测量数量:"+dataUoloadCount);
            }
            //增加积分
            if (dataUoloadCount == 0 && "350205".equals(hospital.substring(0,6))){
            if (!dataUoloadCount && "350205".equals(hospital.substring(0,6))){
                logger.info("体征增加积分入口--------");
                String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
                if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){
                    logger.info("开始体征增加积分------");
                    String url = wlyyService + "healthBank/insertCredits";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"ACTIVITY_TASK\",\"flag\":\""+flagStr+"\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+patientCode+"\",\"hospital\":\"350205\"}"));
                    String response = HttpClientUtil.post(url, params, "UTF-8");
                    logger.info("增加积分返回结果"+response);
                    com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
                    String status = jsonObject.getString("status");
                    if (!"200".equals(status)){
@ -517,7 +608,7 @@ public class AsyncService extends BaseService{
                }
            }
            //增加活跃度
            if (dataUoloadCount == 0){
            if (!dataUoloadCount){
                String url = wlyyService + "healthBank/createActiveRecord";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("activeRecord", "{\"taskCode\":\""+flagStr+"\",\"patientId\":\""+patientCode+"\"}"));
@ -534,73 +625,6 @@ public class AsyncService extends BaseService{
        }
    }
    /**
     * 设置
     * @param patient
     * @return
     */
    public int setTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){
            return -1;
        }
        Patient p = patientDao.findByCode(patient);
        if(p==null){
            return -1;
        }
        //医生是否自动追踪居民
        DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
        DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
        if(sw!=null){
            if("1".equals(sw.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctor());
                    t.setDoctorName(signFamily.getDoctorName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        if(swh!=null){
            if("1".equals(swh.getAlertPatientSwitch())){
                //查询是否与医生建立重点跟踪关系,诺无关系则建立
                TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
                if(trackPatient == null){
                    TrackPatient t = new TrackPatient();
                    t.setCreateTime(new Date());
                    t.setDoctorCode(signFamily.getDoctorHealth());
                    t.setDoctorName(signFamily.getDoctorHealthName());
                    t.setIdcard(signFamily.getIdcard());
                    t.setSsc(signFamily.getSsc());
                    t.setTeamCode(signFamily.getAdminTeamId().intValue());
                    t.setPatientCode(patient);
                    t.setPatientName(p.getName());
                    t.setDel("1");
                    trackPatientDao.save(t);
                }else{
                    trackPatient.setDel("1");
                    trackPatientDao.save(trackPatient);
                }
            }
        }
        return 1;
    }
    public int cancalTrackPatientByDoctor(String patient){
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
        if(signFamily==null){

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -35,8 +35,8 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**","/third/juye/kit/**").excludePathPatterns("/wlyygc/doctor/**", "/wlyygc/patient/**");
        // excludePathPatterns 用户排除拦截 ,/third/juye/kit/**
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**").excludePathPatterns("/wlyygc/doctor/**", "/wlyygc/patient/**");
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**", "wlyygc/doctor/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**", "/wlyygc/patient/**");

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

@ -20,6 +20,9 @@ public interface KitDrugUseRecordDao extends PagingAndSortingRepository<KitDrugU
    @Query(" select count(1) from KitDrugUseRecord u where u.patientCode=?1 and u.useDrugStatus=?2 and u.deviceSn=?3 and u.useTime>=?4 and u.useTime<=?5")
    int findStatisticsCount(String patientCode,Integer useDrugStatus,String deviceSn,Date monthStart,Date monthEnd);
    @Query(" select count(1) from KitDrugUseRecord u where u.patientCode=?1 and u.useDrugStatus=?2 and u.useTime>=?3 and u.useTime<=?4")
    int findStatisticsCount(String patientCode,Integer useDrugStatus,Date monthStart,Date monthEnd);
    @Query(value = " select u.* from kit_drug_use_record u where u.patient_code=?1 and u.use_drug_status=?2 and u.device_sn=?3 and u.use_time>=?4 and u.use_time<=?5 order by DATE_FORMAT(u.use_time,'%c-%d') desc,u.use_drug_status desc",nativeQuery = true)
    List<KitDrugUseRecord> findStatistics(String patientCode,Integer useDrugStatus,String deviceSn,Date monthStart,Date monthEnd);

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

@ -765,4 +765,25 @@ public class CreditLogService {
        logger.info("一周内超过6000的次数"+count);
        return JSONObject.parseObject(response);
    }
    public JSONObject selectByDate(JSONObject object) throws Exception {
        String response = null;
        String patientId = object.getString("patientId");
        Patient patient = patientDao.findByCode(patientId);
        if (patient == null){
            throw new Exception("该居民不存在");
        }
        String url =getBaseUrl()+ "selectByDate";
        //String url = "http://192.168.5.106:10051/svr-health-bank/selectByDate";
        Map<String,String> params = new HashMap<>();
        params.put("object",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
}

+ 13 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/kit/KitService.java

@ -376,9 +376,19 @@ public class KitService extends BaseService {
//        Date monthEnd = new Date();
        Date monthStart = DateUtil.strToDate(month,"yyyy-MM");
        Date monthEnd = DateUtil.strToDate(DateUtil.getLastDayOfMonthThisDate(monthStart)+" 23:59:59");
        Integer onTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,1,deviceSn,monthStart,monthEnd);//按时次数
        Integer overTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,2,deviceSn,monthStart,monthEnd);//超时次数
        Integer leakageCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,3,deviceSn,monthStart,monthEnd);//漏用次数
        Integer onTimeCount = null;
        Integer overTimeCount = null;
        Integer leakageCount = null;
        if(StringUtils.isEmpty(deviceSn)){
            onTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,1,monthStart,monthEnd);//按时次数
            overTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,2,monthStart,monthEnd);//超时次数
            leakageCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,3,monthStart,monthEnd);//漏用次数
        }else{
            onTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,1,deviceSn,monthStart,monthEnd);//按时次数
            overTimeCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,2,deviceSn,monthStart,monthEnd);//超时次数
            leakageCount = kitDrugUseRecordDao.findStatisticsCount(patientCode,3,deviceSn,monthStart,monthEnd);//漏用次数
        }
        Specification specification = new Specification<KitDrugUseRecord>() {
            @Override
            public Predicate toPredicate(Root<KitDrugUseRecord> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/AccountController.java

@ -188,6 +188,19 @@ public class AccountController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/selectByDate",method = RequestMethod.POST)
    @ApiOperation("根据时间查询积分详情")
    public String selectByDate(@ApiParam(name = "objectStr",value = "参数json字符串")@RequestParam(name = "objectStr") String objectStr){
        try {
            JSONObject object = JSONObject.parseObject(objectStr);
            JSONObject object1 = service.selectByDate(object);
            return write(200,"获取成功","data",object1);
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 1 - 3
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -172,7 +172,5 @@ ylz:
  gateway:
    url: http://www.mstpay.com:1300/huangsb
juye:
#  url: http://api.zayata.com/index.php?s=/Company/Device/
  url: zayata.ocip.net:30080/index.php?s=/Company/Device/
  token: YTgzYjc2YWIzZjdjOTA1MTE0ODY2YjcyOGNkYWFmZWR6YXlhdGFjb21wYW55
  url: http://zayata.oicp.net:30080/index.php?s=/Company/Device/
  companyCode: 86350206000000001