Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan 3 years ago
parent
commit
467af77814
20 changed files with 861 additions and 277 deletions
  1. 186 125
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 5 3
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  3. 4 0
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  4. 50 133
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  5. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java
  6. 4 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  7. 8 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java
  8. 52 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/device/PDeviceController.java
  9. 30 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  10. 2 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  11. 84 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java
  12. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  13. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  14. 1 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java
  15. 2 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/SvrCloudTransforApplication.java
  16. 42 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/config/AsyncConfig.java
  17. 111 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/BaseController.java
  18. 104 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/OnenetController.java
  19. 26 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/OnenetService.java
  20. 138 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/util/HttpClientUtil.java

+ 186 - 125
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -3231,8 +3231,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param size
     * @return
     */
    public MixEnvelop findExpressageList2(String status, String oneselfPickupFlg, String nameKey, String startTime, String endTime, Integer page, Integer size, String wxId,String patientName) {
        String totalSql = "SELECT " +
    public MixEnvelop  findExpressageList2(String status, String oneselfPickupFlg, String nameKey, String startTime, String endTime, Integer page, Integer size, String wxId,String patientName) {
        /*String totalSql = "SELECT " +
                " COUNT(1) AS \"total\" " +
                " FROM " +
                " wlyy_outpatient o " +
@ -3282,6 +3282,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (rstotal != null && rstotal.size() > 0) {
            count = Long.parseLong(rstotal.get(0).get("total").toString());
        }
        String sql = "SELECT  ";
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
@ -3317,108 +3320,192 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql = sql +
                    "p.id AS \"prescriptionId\",\n" +
                    "p.create_time AS \"time\",\n" +
                    "\te. NAME AS \"name\",\n" +
                    "\te.name AS \"name\",\n" +
                    "\tp.pay_time AS \"pay_time\",\n" +
                    "\tp.real_order AS \"realOrder\",\n" +
                    " o.icd10_name AS \"icd10Name\", " +
                    " e.id AS \"expressageId\" ,"+
                    "\to.patient_name AS \"patientName\",\n" +
                    "\tp.create_time AS \"create_time\",\n" +
                    "\te.oneself_pickup_flg AS \"oneself_pickup_flg\",\n" +
                    "\tp. STATUS AS \"status\"\n" +
                    "\tp.status AS \"status\"\n" +
                    "FROM\n" +
                    "\twlyy_outpatient o\n" +
                    "JOIN wlyy_prescription p ON p.outpatient_id = o.id\n" +
                    "JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id\n" +
                    "WHERE\n" +
                    "\t1 = 1\n";//oracle
            if (StringUtils.isNotBlank(status)) {
                totalSql += " AND p.status in(" + status + ") ";
            }
            if (StringUtils.isNotBlank(oneselfPickupFlg)) {
                totalSql += " AND e.oneself_pickup_flg = " + oneselfPickupFlg+" ";
            }
            if (StringUtils.isNotBlank(nameKey)) {
                totalSql += " AND e.name like '%" + nameKey + "%' ";
            }
            if (StringUtils.isNotBlank(patientName)) {
                totalSql += " AND o.patient_name like '%" + patientName + "%' ";
            }
            if (StringUtils.isNotBlank(startTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    totalSql += " AND p.create_time >='" + startTime + " 00:00:00'";
                }
            }
            if (StringUtils.isNotBlank(endTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    sql += " AND p.create_time <='" + endTime + " 23:59:59'";
                }
            }
        } else {
            sql = sql +
                    "p.id AS \"prescriptionId\",\n" +
                    "\tp.create_time AS \"time\",\n" +
                    "\te. NAME AS \"name\",\n" +
                    "\te.name AS \"name\",\n" +
                    "\tp.pay_time AS \"pay_time\",\n" +
                    "\tp.real_order AS \"realOrder\",\n" +
                    " o.icd10_name AS \"icd10Name\", " +
                    " e.id AS \"expressageId\" ,"+
                    "\to.patient_name AS \"patientName\",\n" +
                    "\tp.create_time AS \"create_time\",\n" +
                    "\te.oneself_pickup_flg AS \"oneself_pickup_flg\",\n" +
                    "\tp. STATUS AS \"status\"\n" +
                    "\tp.status AS \"status\"\n" +
                    "FROM\n" +
                    "\twlyy_outpatient o\n" +
                    "JOIN wlyy_prescription p ON p.outpatient_id = o.id\n" +
                    "JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id\n" +
                    "WHERE\n" +
                    "\t1 = 1\n";//MySQL
            if (StringUtils.isNotBlank(status)) {
                totalSql += " AND p.status in(" + status + ") ";
                    "\t1 = 1\n";
        }
        if (StringUtils.isNotBlank(status)) {
            sql += " AND p.status in(" + status + ") ";
        }
        if (StringUtils.isNotBlank(oneselfPickupFlg)) {
            sql += " AND e.oneself_pickup_flg =" + oneselfPickupFlg+" ";
        }
        if (StringUtils.isNotBlank(nameKey)) {
            sql += " AND e.name like '%" + nameKey + "%' ";
        }
        if (StringUtils.isNotBlank(patientName)) {
            sql += " AND o.patient_name like '%" + patientName + "%' ";
        }
        if (StringUtils.isNotBlank(startTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    sql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    sql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " AND p.create_time >='" + startTime + " 00:00:00'";
            }
            if (StringUtils.isNotBlank(oneselfPickupFlg)) {
                totalSql += " AND e.oneself_pickup_flg = " + oneselfPickupFlg+" ";
        }
        if (StringUtils.isNotBlank(endTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    sql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    sql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " AND p.create_time <='" + endTime + " 23:59:59'";
            }
            if (StringUtils.isNotBlank(nameKey)) {
                totalSql += " AND e.name like '%" + nameKey + "%' ";
        }
        sql +=" order by p.create_time desc ";
        *//*       sql += " LIMIT " + (page - 1) * size + "," + size + "";*//*
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> map : mapList) {
            if (map.get("prescriptionId") != null) {
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(map.get("prescriptionId").toString(), 1);
                map.put("info", wlyyPrescriptionInfoDOS);
                String infoName = "";
                for (WlyyPrescriptionInfoDO info:wlyyPrescriptionInfoDOS) {
                    infoName += info.getDrugName() + "*" + info.getQuantity() + ",";
                }
                map.put("infooName",infoName);
            }
            if (StringUtils.isNotBlank(patientName)) {
                totalSql += " AND o.patient_name like '%" + patientName + "%' ";
        }*/
        String totalSql = "SELECT " +
                " COUNT(1) AS \"total\" " +
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id" +
                " WHERE" +
                " 1=1 ";
        if (StringUtils.isNotBlank(status)) {
            totalSql += " AND p.status in(" + status + ") ";
        }
        if (StringUtils.isNotBlank(oneselfPickupFlg)) {
            totalSql += " AND e.oneself_pickup_flg = " + oneselfPickupFlg+" ";
        }
        if (StringUtils.isNotBlank(nameKey)) {
            totalSql += " AND e.name like '%" + nameKey + "%' ";
        }
        if (StringUtils.isNotBlank(patientName)) {
            totalSql += " AND o.patient_name like '%" + patientName + "%' ";
        }
        if (StringUtils.isNotBlank(startTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    totalSql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    totalSql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                totalSql += " AND p.create_time >='" + startTime + " 00:00:00'";
            }
            if (StringUtils.isNotBlank(startTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time >= str_to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time >= to_date('" + startTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    totalSql += " AND p.create_time >='" + startTime + " 00:00:00'";
        }
        if (StringUtils.isNotBlank(endTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    totalSql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    totalSql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                totalSql += " AND p.create_time <='" + endTime + " 23:59:59'";
            }
        }
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = Long.parseLong(rstotal.get(0).get("total").toString());
        }
        String sql = "SELECT  ";
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                sql = sql + "date_format(e.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"expressCreateTime\",";
            }else {
                sql = sql + "to_char(e.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"expressCreateTime\",";
            }
            if (StringUtils.isNotBlank(endTime)) {
                if ("xm_ykyy_wx".equals(wxId)) {
                    if (flag){
                        totalSql += " and p.create_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }else {
                        totalSql += " and p.create_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                    }
                } else {
                    sql += " AND p.create_time <='" + endTime + " 23:59:59'";
                }
        } else {
            sql = sql + "date_format(e.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"expressCreateTime\",";
        }
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                sql = sql + "date_format(p.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"createTime\",";
            }else {
                sql = sql + "to_char(p.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"createTime\",";
            }
        } else {
            sql = sql + "date_format(p.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"createTime\",";
        }
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                sql = sql + "date_format(p.pay_time,'YYYY-MM-DD hh24:mi:ss')  AS \"payTime\",";
            }else {
                sql = sql + "to_char(p.pay_time,'YYYY-MM-DD hh24:mi:ss')  AS \"payTime\",";
            }
        } else {
            sql = sql + "date_format(p.pay_time,'%Y-%m-%d %H:%i:%S' )  AS \"payTime\",";
        }
        sql = sql + " e.name as \"name\", " +
                " e.oneself_pickup_flg AS \"oneselfPickupFlg\", " +
                " o.id AS \"outpatientId\", " +
                " o.icd10_name AS \"icd10Name\", " +
                " p.status as \"status\", " +
                " p.id AS \"prescriptionId\" ," +
                " e.id AS \"expressageId\" ,"+
                " p.real_order AS \"realOrder\" ,"+
                " p.origin_real_order AS \"originRealOrder\"," +
                " o.patient_name as \"patientName\" "+
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id " +
                " WHERE" +
                " 1=1";
        if (StringUtils.isNotBlank(status)) {
            sql += " AND p.status in(" + status + ") ";
        }
@ -3431,6 +3518,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (StringUtils.isNotBlank(patientName)) {
            sql += " AND o.patient_name like '%" + patientName + "%' ";
            /*sql += " and (a.patient_name like '" + title + "' OR a.doctor_name like '" + title + "' OR a.dept_name like '" + title + "' )"*/
        }
        if (StringUtils.isNotBlank(startTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
@ -3459,16 +3547,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        sql +=" order by p.create_time desc ";
        /*       sql += " LIMIT " + (page - 1) * size + "," + size + "";*/
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql, page, size);
        for (Map<String, Object> map : mapList) {
            if (map.get("prescriptionId") != null) {
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(map.get("prescriptionId").toString(), 1);
                map.put("info", wlyyPrescriptionInfoDOS);
                String infoName = "";
                for (WlyyPrescriptionInfoDO info:wlyyPrescriptionInfoDOS) {
                    infoName += info.getDrugName() + "*" + info.getQuantity() + ",";
                }
                map.put("infooName",infoName);
            }
        }
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
@ -3837,31 +3920,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            for (Map<String, Object> m : list) {
                /*Object status = m.get("status");
                String statuss = "";
                if (status == null) {
                    statuss += " ";
                }else if (status.equals("0")) {
                    statuss += "未支付";
                }else if (status.equals("1")) {
                    statuss += "已支付";
                }else if (status.equals("2")) {
                    statuss += "交易关闭";
                }else if (status.equals("3")) {
                    statuss += "支付超时";
                }else if (status.equals("4")) {
                    statuss += "交易完成";
                }else if (status.equals("5")) {
                    statuss += "交易进行中";
                }else if (status.equals("6")) {
                    statuss += "退款申请";
                }else if (status.equals("9")) {
                    statuss += "退款完成";
                }else {
                    statuss += " ";
                }*/
                String odry = "";
                String orderCategory = "";
                String odte = "";
@ -3871,34 +3929,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if (m.get("orderCategory")==null){
                    odry = null;
                }else {
                    orderCategory = m.get("orderCategory").toString();
                    if (orderCategory.equals("1")) {
                        odry += "专家咨询";
                    }else if (orderCategory.equals("2")) {
                        odry += "复诊";
                    }else if (orderCategory.equals("3")) {
                        odry += "视频诊室";
                    }else if (orderCategory.equals("4")) {
                        odry += "处方";
                        odte += "处方";
                    }else if (orderCategory.equals("5")) {
                        odry += "就诊卡充值";
                        odte += "就诊卡充值";
                    }else {
                        odry += " ";
                    if(m.get("orderType") == null) {
                        odte = null;
                    }else{
                        String orderType =  m.get("orderType").toString();
                        orderCategory = m.get("orderCategory").toString();
                        if (orderCategory.equals("1")) {
                            odry += "专家咨询";
                            if (orderType.equalsIgnoreCase("1")) {
                                odte += "图文";
                            }else if (orderType.equalsIgnoreCase("3")) {
                                odte += "视频";
                            }
                        }else if (orderCategory.equals("2")) {
                            odry += "在线复诊";
                            if (orderType.equalsIgnoreCase("1")) {
                                odte += "图文";
                            }else if (orderType.equalsIgnoreCase("3")) {
                                odte += "视频";
                            }
                        }else if (orderCategory.equals("4")) {
                            odry += "处方";
                            odte += "处方";
                        }else if (orderCategory.equals("5")) {
                            odry += "就诊卡充值";
                            odte += "就诊卡充值";
                        }else {
                            odry += " ";
                        }
                    }
                }
                if(m.get("orderType") == null) {
                    odte = null;
                }else{
                    String orderType =  m.get("orderType").toString();
                    if (orderType.equalsIgnoreCase("1")) {
                        odte += "图文";
                    }else if (orderType.equalsIgnoreCase("3")) {
                        odte += "视频";
                    }
                }
                if (m.get("status") == null) {
                    status = null;

+ 5 - 3
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -2114,15 +2114,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (StringUtils.isNoneBlank(idCard)){
            sql+=" and b.idcard like '%"+idCard+"%'";
        }
        if (StringUtils.isNoneBlank(medicard)){
            sql+=" and t.relation_code like '%"+medicard+"%'";
        }
        if (status!=null){
            sql+=" and t.status ="+status+"";
        }
        if (StringUtils.isNoneBlank(orderType)){
            sql+=" and t.order_type like %"+orderType+"%";
            sql+=" and t.order_type ="+orderType+"";
        }
        if (StringUtils.isNoneBlank(orderCategory)){
            if (orderCategory.equalsIgnoreCase("2")){
                sql+=" and t.order_category IN ('2','3') ";

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -179,6 +179,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                "\t'未知'\n" +
                "END AS \"sex\",\n" +
                " mobile AS \"phone\",\n" +
                " ykt_id AS \"yktId\",\n" +
                " committee_name AS \"committeeName\",\n" +
                " province_name AS \"provinceName\"," +
                " city_name AS \"cityName\", " +
@ -340,6 +341,9 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            basePatientDO1.setResidentialArea(basePatientDO.getResidentialArea());
            basePatientDO1.setCommitteeCode(basePatientDO.getCommitteeCode());
            basePatientDO1.setCommitteeName(basePatientDO.getCommitteeName());
            if(StringUtils.isNotBlank(basePatientDO.getYktId())){
                basePatientDO1.setYktId(basePatientDO.getYktId());
            }
            // 保存修改的居民信息
            basePatientDao.save(basePatientDO1);
        }

+ 50 - 133
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -4316,81 +4316,60 @@ public class ImService {
    public MixEnvelop recordByDoctor(String doctor, String id,String type, Integer status,String title, String start_time, String end_time, String patient) { //
        String sql = "";
        sql = "SELECT " +
                "a.id AS \"id\"," +
                "op.pay_status AS \"payStatus\"," +
                "op.type as \"type\"," +
                "op.outpatient_type as \"outpatientType\"," +
                "op.description AS \"title\"," +
                "op.description AS \"symptoms\",";
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag) {
                sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
                sql = sql + "date_format(op.end_time,'%Y-%m-%d %H:%i:%S' )  AS \"endTime\", ";
            } else {
                sql = sql + "to_char(op.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"czrq\",";
                sql = sql + "to_char(op.end_time,'YYYY-MM-DD hh24:mi:ss')  AS \"endTime\",";
            }
        } else {
            sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
            sql = sql + "date_format(op.end_time,'%Y-%m-%d %H:%i:%S' )  AS \"endTime\",";
        }
        sql = sql + "op.status AS \"status\"," +
                "b.evaluate AS \"evaluate\"," +
                "d.name AS \"patientName\"," +
                "d.id as \"patientId\"," +
                "d.idcard as \"patientIdcard\"," +
                "d.sex as \"patientSex\"," +
                "op.consumer as \"consumer\"," +
                "op.consumer_name as \"consumerName\"," +
                "op.consumer_mobile as \"consumerMobile\"," +
                "op.id as \"outpatientId\"," +
                "op.type as \"consultType\"," +
                "op.general_doctor as \"generalDoctor\"," +
                "op.icd10_name as \"icd10Name\"," +
                "d.photo AS \"patientPhoto\" , " +
                "op.doctor as \"doctor\" ," +
                "op.source as \"source\"  ," +
                "op.card_no as \"cardNo\"  ," +
                "op.patient_cancel_value as \"patientCancelValue\" ," +
                "op.patient_cancel_remark as \"patient_cancel_remark\"  " +
                "FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
                " LEFT join wlyy_consult_team b on a.id = b.consult" +
                " LEFT JOIN base_patient d on op.patient = d.id " +
                " WHERE 1=1 ";
        if (status == null) {
            sql += " and op.status = 0 and op.pay_status =1 and op.pay_status =2 and op.pay_status =3";
        sql ="SELECT\n" +
                        "\ta.patient_name AS \"pname\",\n" +
                        "\ta.doctor_name AS \"dname\",\n" +
                        "\ta.dept_name AS \"dept\",\n" +
                        "\ta.outpatient_type AS \"type\",\n" +
                        "\ta.create_time AS \"ctime\",\n" +
                        "\ta.register_date AS \"rtime\",\n" +
                        "\ta.end_time AS \"etime\",\n" +
                        "\ta.description AS \"des\",\n" +
                        "\tb. STATUS AS \"pay\",\n" +
                        "\ta. STATUS AS \"STATUS\"\n" +
                        "FROM\n" +
                        "\twlyy_outpatient a\n" +
                        "LEFT JOIN wlyy_prescription b ON a.id = b.outpatient_id\n" +
                        "LEFT JOIN wlyy_consult c ON c.relation_code = a.id\n" +
                        "LEFT JOIN wlyy_consult_team d ON c.id = d.consult\n" +
                        "LEFT JOIN base_patient e ON a.patient = e.id\n" +
                        "WHERE\n" +
                        "\t1 = 1 ";
        if (status == null){
        }else if (status == 1) {
            sql += " and a.status = 0 and a.pay_status =1 ";
        } else if (status == 0) {
        } else if (status == 1) {
            sql += " and op.status = 0 and op.pay_status =1 ";
        } else if (status == 2){
            sql += " and op.status = 1";
        } else if (status == 3) {
            sql += " and op.status = 2";
        } else if (status == 2) {
            sql += " and a.status = 1";
        } else {
            sql += " and a.status = " + status;
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
            sql += " AND op.doctor='" + doctor + "' ";
            sql += " AND a.doctor='" + doctor + "' ";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(patient)) {
            sql += " AND (op.consumer='" + patient + "' or op.patient ='" + patient + "')";
            sql += " AND (a.consumer='" + patient + "' or a.patient ='" + patient + "')";
        }
        if (!StringUtils.isEmpty(title)) {
            title = "%" + title + "%";
            sql += " and (op.patient_name like '" + title + "' OR op.doctor_name like '" + title + "' OR op.dept_name like '" + title + "' )";
            sql += " and (a.patient_name like '" + title + "' OR a.doctor_name like '" + title + "' OR a.dept_name like '" + title + "' )";
        }
        if (!StringUtils.isEmpty(start_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                    sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time >= '" + start_time + "'";
                sql += " and a.create_time >= '" + start_time + "'";
            }
        }
@ -4398,13 +4377,13 @@ public class ImService {
        if (!StringUtils.isEmpty(end_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                } else {
                    sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                    sql += " and a.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " and op.create_time <= '" + end_time + "'";
                sql += " and a.create_time <= '" + end_time + "'";
            }
        }
@ -4412,27 +4391,29 @@ public class ImService {
        //咨询类型
        if (!StringUtils.isEmpty(type)) {
            if (type.equalsIgnoreCase("9")) {
                sql += " AND op.type =1 and op.outpatient_type = 1";
                sql += " AND a.type =1 and a.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("16")) {
                sql += " AND op.type =2 and op.outpatient_type = 1";
                sql += " AND a.type =2 and a.outpatient_type = 1";
            } else if (type.equalsIgnoreCase("1")) {
                sql += " AND op.type =1 and op.outpatient_type = 3";
                sql += " AND a.type =1 and a.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("15")) {
                sql += " AND op.type =3 and op.outpatient_type = 3";
                sql += " AND a.type =3 and a.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("17")) {
                sql += " AND op.type =2 and op.outpatient_type = 3";
                sql += " AND a.type =2 and a.outpatient_type = 3";
            } else if (type.equalsIgnoreCase("12")) {
                sql += " AND op.outpatient_type = 2";
                sql += " AND a.outpatient_type = 2";
            } else {
                sql += " AND op.type in (1,2,3) ";
                sql += " AND a.type in (1,2,3) ";
            }
        }
        if (!StringUtils.isEmpty(id)) {
            sql += " and a.id = '" + id + "'";
        }
        sql += " ORDER BY op.create_time desc ";
        List<Map<String, Object>> List = hibenateUtils.createSQLQuery(sql);//
        for (Map<String, Object> map : List) {
        sql = sql + "\tORDER BY a.create_time desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(sql);
        for (Map<String, Object> map : mapList) {
            if (map.get("patientIdcard") != null) {
                String idcard = map.get("patientIdcard").toString();
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
@ -4503,73 +4484,9 @@ public class ImService {
                }
            }
        }
        String pushSql = "";
        pushSql =
                "SELECT\n" +
                        "\ta.patient_name AS \"pname\",\n" +
                        "\ta.consumer_name AS \"dname\",\n" +
                        "\ta.dept_name AS \"dept\",\n" +
                        "\ta.outpatient_type AS \"type\",\n" +
                        "\ta.create_time AS \"ctime\",\n" +
                        "\ta.register_date AS \"rtime\",\n" +
                        "\ta.end_time AS \"etime\",\n" +
                        "\ta.description AS \"des\",\n" +
                        "\tb. STATUS AS \"pay\",\n" +
                        "\ta. STATUS AS \"STATUS\"\n" +
                        "FROM\n" +
                        "\twlyy_outpatient a\n" +
                        "LEFT JOIN wlyy_prescription b ON a.id = b.outpatient_id\n" +
                        "WHERE\n" +
                        "\t1 = 1";
        if (status != null) {
            pushSql += " AND a. STATUS in(" + status + ") ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(type)) {
            if (type.equals("0")) {
            }else {
                pushSql += " AND a.type = " + type +" ";
            }
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(doctor)) {
            pushSql += " AND a.doctor_name like '%" + doctor + "%' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(patient)) {
            pushSql += " AND a.patient_name like '%" + patient + "%' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(start_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    pushSql += " and a.create_time >= str_to_date('" + start_time + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    pushSql += " and a.create_time >= to_date('" + start_time + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                pushSql += " AND a.create_time >='" + start_time + " 00:00:00'";
            }
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(end_time)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    pushSql += " and a.create_time <= str_to_date('" + end_time + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }else {
                    pushSql += " and a.create_time <= to_date('" + end_time + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
                }
            } else {
                sql += " AND a.create_time <='" + end_time + " 23:59:59'";
            }
        }
        pushSql = pushSql + "\tORDER BY ctime desc ";
        List<Map<String, Object>> mapList = hibenateUtils.createSQLQuery(pushSql);
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);
    }
    public List<Map<String, Object>> doctorUpcomingList2(String doctorCode, String type) {
        String sql = "";
        if ("1,15,17".equals(type)) {

+ 9 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java

@ -54,6 +54,7 @@ public class EmergencyOrderVO {
    private List<PatientSosContactsDO> sosContacts;//紧急联系人
    private List<Map<String,Object>> securityDevices;//安防设备列表
    private String overTimeNotResponse;
    private Integer orderType;//20紧急 22安防
    public String getId() {
        return id;
@ -294,4 +295,12 @@ public class EmergencyOrderVO {
    public void setOverTimeNotResponse(String overTimeNotResponse) {
        this.overTimeNotResponse = overTimeNotResponse;
    }
    public Integer getOrderType() {
        return orderType;
    }
    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }
}

+ 4 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java

@ -67,9 +67,11 @@ public class DoctorHealthController extends BaseController {
											   @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
											   @RequestParam(value="begin",required = true) String begin,
											   @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
												   @RequestParam(value="end",required = true) String end) {
												   @RequestParam(value="end",required = true) String end,
											   @ApiParam(name = "deviceSn",required = false)
												   @RequestParam(value = "deviceSn",required = false) String deviceSn) {
		try {
			JSONArray jsonArray = healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);
			JSONArray jsonArray = healthIndexService.findChartByPatient(patient,type,gi_type,begin,end,deviceSn);
			if (jsonArray.length()==0) {
				return success("查询成功!");
			}

+ 8 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java

@ -359,10 +359,12 @@ public class PatientHealthController extends BaseController {
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
                                               @RequestParam(value = "end", required = true) String end,
                                               @ApiParam(name = "deviceSn",required = false)
                                                   @RequestParam(value = "deviceSn",required = false) String deviceSn) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(getUID(),type,gi_type,begin,end);
            JSONArray jsonArray = healthIndexService.findChartByPatient(getUID(),type,gi_type,begin,end,deviceSn);
            if (jsonArray.length()==0) {
                return success("查询成功!");
            }
@ -384,10 +386,12 @@ public class PatientHealthController extends BaseController {
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
                                               @RequestParam(value = "end", required = true) String end,
                                               @ApiParam(name = "deviceSn",required = false)
                                               @RequestParam(value = "deviceSn",required = false) String deviceSn) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end,deviceSn);
//            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
            if (jsonArray.length()==0) {

+ 52 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/device/PDeviceController.java

@ -1,5 +1,6 @@
package com.yihu.jw.care.endpoint.third.device;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
@ -7,6 +8,7 @@ import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.care.service.device.YsDeviceService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
@ -15,7 +17,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -43,6 +45,8 @@ public class PDeviceController extends BaseController {
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private YsDeviceService ysDeviceService;
    @ApiOperation("获取居民的设备任务信息")
@ -135,4 +139,51 @@ public class PDeviceController extends BaseController {
            return error(-1,"安全区域设置失败");
        }
    }
    @ApiOperation("设备云台控制开始")//操作后都需要调用停止接口 才会停止转动
    @RequestMapping(value = "ptzStart", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String ptzStart(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
            @RequestParam(value = "channelNo",required = true) Integer channelNo,
            @ApiParam(name="direction",required = true,value="0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距")
            @RequestParam(value = "direction",required = true) Integer direction,
            @ApiParam(name="speed",required = true,value="云台速度:0-慢,1-适中,2-快,海康设备参数不可为0")
            @RequestParam(value = "speed",required = true) Integer speed,
            HttpServletRequest request){
        try {
            com.alibaba.fastjson.JSONObject result = ysDeviceService.ptzStart(deviceSerial,channelNo,direction,speed,request);
            if ("200".equals(result.getString("code"))){
                return write(200,"查询成功","data",result);
            }else {
                return write(-1,result.getString("msg"));
            }
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("设备云台控制结束")
    @RequestMapping(value = "ptzStop", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String ptzStop(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
            @RequestParam(value = "channelNo",required = true) Integer channelNo,
            @ApiParam(name="direction",required = true,value="0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距")
            @RequestParam(value = "direction",required = true) Integer direction,
            HttpServletRequest request){
        try {
            JSONObject result = ysDeviceService.ptzStop(deviceSerial,channelNo,direction,request);
            if ("200".equals(result.getString("code"))){
                return write(200,"查询成功","data",result);
            }else {
                return write(-1,result.getString("msg"));
            }
        }catch (Exception e){
            return errorResult(e);
        }
    }
}

+ 30 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
@ -58,6 +59,8 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    private BaseServiceNewsService baseServiceNewsService;
    @Autowired
    private DictService dictService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    private BaseController baseController = new BaseController();
@ -162,10 +165,32 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getHealthIndexInfoWithAvg")
    @ApiOperation("获取居民体征信息--带体征平均值")
    public String getHealthIndexInfoWithAvg(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
                                     @RequestParam(value="patient",required = false) String patient,
                                     @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                     @RequestParam(value="type",required = true) Integer type,
                                     @ApiParam(name="gi_type",value="就餐类型",defaultValue = "0")
                                     @RequestParam(value = "gi_type",required = false) Integer gi_type,
                                     @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
                                     @RequestParam(value="begin",required = true) String begin,
                                     @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
                                     @RequestParam(value="end",required = true) String end,
                                     @ApiParam(name = "deviceSn",required = false)
                                     @RequestParam(value = "deviceSn",required = false) String deviceSn){
        try {
            return baseController.write(200,"查询成功","data",healthIndexService.findChartByPatientWithAvg(patient,type,gi_type,begin,end,deviceSn));
        }catch (Exception e){
            return baseController.errorResult(e);
        }
    }
    @GetMapping(value = "getHealthIndexInfo")
    @ApiOperation("获取居民体征信息")
    public String getHealthIndexInfo(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
                                     @RequestParam(value="patient",required = true) String patient,
                                     @RequestParam(value="patient",required = false) String patient,
                                     @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                     @RequestParam(value="type",required = true) Integer type,
                                     @ApiParam(name="gi_type",value="就餐类型",defaultValue = "0")
@ -173,9 +198,11 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
                                     @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
                                     @RequestParam(value="begin",required = true) String begin,
                                     @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
                                     @RequestParam(value="end",required = true) String end){
                                     @RequestParam(value="end",required = true) String end,
                                     @ApiParam(name = "deviceSn",required = false)
                                     @RequestParam(value = "deviceSn",required = false) String deviceSn){
        try {
            return baseController.write (200,"查询成功","data",patientInfoPlatFormService.getHealthIndexInfo(patient,type,gi_type,begin,end));
            return baseController.write (200,"查询成功","data",patientInfoPlatFormService.getHealthIndexInfo(patient,type,gi_type,begin,end,deviceSn));
        }catch (Exception e){
            return baseController.errorResult(e);
        }

+ 2 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -126,7 +126,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    /**
@ -374,6 +374,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        emergencyOrderVO.setPatientName(assistanceDO.getPatientName());
        emergencyOrderVO.setSex(patientDO.getSex());
        emergencyOrderVO.setPhone(assistanceDO.getPatientPhone());
        emergencyOrderVO.setOrderType(20);
        List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(assistanceDO.getId());
        for (BaseEmergencyWarnLogDO tmp:logDOS){

+ 84 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java

@ -798,7 +798,7 @@ public class PatientHealthIndexService extends BaseJpaService<DevicePatientHealt
     * @param end     结束时间
     * @return
     */
    public JSONArray findChartByPatient(String patient, int type, int gi_type, String begin, String end) {
    public JSONArray findChartByPatient(String patient, int type, int gi_type, String begin, String end,String deviceSn) {
        JSONArray re = new JSONArray();
        String sql = "SELECT " +
                "MIN(id) id" +
@ -816,11 +816,17 @@ public class PatientHealthIndexService extends BaseJpaService<DevicePatientHealt
                ",sort_date" +
                ",min(czrq) czrq " +
                " from wlyy_patient_health_index " +
                " WHERE `user` = '" + patient + "' " +
                " WHERE 1=1 "+
                " and type =" + type +
                " and record_date >= '" + begin + "'" +
                " and record_date <= '" + end + "' " +
                " and del = '1' ";
        if (StringUtils.isNotBlank(patient)){
            sql+=" and user = '" + patient + "' ";
        }
        if (StringUtils.isNotBlank(deviceSn)){
            sql += " and device_sn='"+deviceSn+"' ";
        }
        String conditionApp = "";
        if (gi_type != 0) {
            conditionApp = " and value2 = '" + gi_type + "' ";
@ -857,7 +863,82 @@ public class PatientHealthIndexService extends BaseJpaService<DevicePatientHealt
        }
        return re;
    }
    
    public JSONObject findChartByPatientWithAvg(String patient, int type, int gi_type, String begin, String end,String deviceSn) {
        JSONObject result = new JSONObject();
        JSONArray re = new JSONArray();
        String sql = "SELECT " +
                "MIN(id) id" +
                ", user" +
                ",value1" +
                ",value2" +
                ",value3" +
                ",value4" +
                ",value5" +
                ",value6" +
                ",value7" +
                ",device_sn" +
                ",type" +
                ",record_date" +
                ",sort_date" +
                ",min(czrq) czrq " +
                " from wlyy_patient_health_index " +
                " WHERE 1=1 "+
                " and type =" + type +
                " and record_date >= '" + begin + "'" +
                " and record_date <= '" + end + "' " +
                " and del = '1' ";
        if (StringUtils.isNotBlank(patient)){
            sql+=" and user = '" + patient + "' ";
        }
        if (StringUtils.isNotBlank(deviceSn)){
            sql += " and device_sn='"+deviceSn+"' ";
        }
        String conditionApp = "";
        if (gi_type != 0) {
            conditionApp = " and value2 = '" + gi_type + "' ";
        }
        sql = sql + conditionApp +
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by record_date desc ,sort_date desc limit " + 0 + " ," + 1000 + " ";
//        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = findByPatientAndTime(sql,patient,type,1000,gi_type,begin,end);
        for (Map<String, Object> map : list) {
            JSONObject json = new JSONObject();
            json.put("id", map.get("id"));
            json.put("patient", map.get("user"));
            json.put("value1", map.get("value1"));
            json.put("value2", map.get("value2"));
            json.put("value3", map.get("value3"));
            json.put("value4", map.get("value4"));
            json.put("value5", map.get("value5"));
            json.put("value6", map.get("value6"));
            json.put("value7", map.get("value7"));
            json.put("deviceSn", map.get("device_sn") == null ? "" : map.get("device_sn"));
            json.put("type", map.get("type"));
            Date date = (Date) map.get("record_date");
            if (type == 2) {
                json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
            } else {
                json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
            }
            json.put("sortDate", map.get("sort_date"));
            json.put("czrq", map.get("czrq"));
            re.put(json);
        }
        result.put("list",re);
        OptionalDouble avg =  list.stream().mapToDouble(t -> t.get("value1") == null ? 0.0 :Double.parseDouble(t.get("value1").toString())).average();
        result.put("avg",0.0);
        try {
            result.put("avg",avg.getAsDouble());
        }catch (Exception e){}
        return result;
    }
    /**
     * 按时间段查询患者健康指标
     *

+ 1 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -357,6 +357,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        emergencyOrderVO.setPatientName(orderDO.getPatientName());
        emergencyOrderVO.setSex(patientDO.getSex());
        emergencyOrderVO.setTopicItem(orderDO.getTopicItem());
        emergencyOrderVO.setOrderType(22);
        if (StringUtils.isNotBlank(orderDO.getSceneImg())){
            emergencyOrderVO.setSceneImg(orderDO.getSceneImg());
        }

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -215,8 +215,8 @@ public class PatientInfoPlatFormService {
     * @param patient
     * @return
     */
    public JSONArray getHealthIndexInfo(String patient, int type, int gi_type, String begin, String end){
       return healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);//图表
    public JSONArray getHealthIndexInfo(String patient, int type, int gi_type, String begin, String end,String deviceSn){
       return healthIndexService.findChartByPatient(patient,type,gi_type,begin,end,deviceSn);//图表
    }
    /**

+ 1 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java

@ -154,6 +154,7 @@ public class OnenetService {
                    String psk = jsonObject.getJSONObject("data").getString("psk");
                    device.setDeviceId(deviceId);
                    device.setPsk(psk);
                    device.setCreateTime(new Date());
                    onenetDevices.add(device);
                }
            }catch (Exception e){

+ 2 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/SvrCloudTransforApplication.java

@ -5,12 +5,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
/**
 * Created by yeshijie on 2021/10/14.
 */
@SpringBootApplication
@ComponentScan("com.yihu")
@EnableAsync
public class SvrCloudTransforApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {

+ 42 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/config/AsyncConfig.java

@ -0,0 +1,42 @@
package com.yihu.jw.care.config;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/30
 * @Description: 异步线程配置
 */
@Configuration
public class AsyncConfig {
    @Bean
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        // 设置核心线程数
        executor.setCorePoolSize(5);
        // 设置最大线程数
        executor.setMaxPoolSize(20);
        // 设置队列容量
        executor.setQueueCapacity(200);
        // 设置线程活跃时间(秒)
        executor.setKeepAliveSeconds(60);
        // 设置默认线程名称
        executor.setThreadNamePrefix("user-transfor-");
        // 设置拒绝策略
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//        // 等待所有任务结束后再关闭线程池
//        executor.setWaitForTasksToCompleteOnShutdown(true);
        executor.initialize();
        return executor;
    }
}

+ 111 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/BaseController.java

@ -0,0 +1,111 @@
package com.yihu.jw.care.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 *
 */
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger("error_logger");
    /**
     * 获取request中body数据
     */
    public String getRequestBodyData(HttpServletRequest request) throws IOException {
        BufferedReader bufferReader = new BufferedReader(request.getReader());
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = bufferReader.readLine()) != null) {
            sb.append(line);
        }
        return sb.toString();
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", code);
            map.put("msg", msg);
            map.put("success", false);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 接口处理成功
     * @return
     */
    public String success() {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", 200);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", code);
            map.put("msg", msg);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public void error(Exception e) {
        e.printStackTrace();
    }
}

+ 104 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/OnenetController.java

@ -0,0 +1,104 @@
package com.yihu.jw.care.controller;
import com.yihu.jw.care.service.OnenetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created with IntelliJ IDEA.
 * onenet平台验证无法请求杭州服务器 只能转发
 * @Author: yeshijie
 * @Date: 2021/10/20
 * @Description:
 */
@RestController
@RequestMapping("/siterwelldevice")
@Api(value = "onenet设备相关服务", description = "onenet设备相关服务")
public class OnenetController extends BaseController{
    private static Logger logger = LoggerFactory.getLogger(OnenetController.class);
    @Autowired
    private OnenetService onenetService;
    /**
     * 功能描述:第三方平台数据接收。<p>
     *           <ul>注:
     *               <li>1.OneNet平台为了保证数据不丢失,有重发机制,如果重复数据对业务有影响,数据接收端需要对重复数据进行排除重复处理。</li>
     *               <li>2.OneNet每一次post数据请求后,等待客户端的响应都设有时限,在规定时限内没有收到响应会认为发送失败。
     *                    接收程序接收到数据时,尽量先缓存起来,再做业务逻辑处理。</li>
     *           </ul>
     * @param body 数据消息
     * @return 任意字符串。OneNet平台接收到http 200的响应,才会认为数据推送成功,否则会重发。
     */
    @RequestMapping(value = "receive",method = RequestMethod.POST)
    public String receive(@RequestBody String body) throws Exception {
        logger.info("data receive:  body String --- " +body);
        /************************************************
         *  解析数据推送请求,非加密模式。
         *  如果是明文模式使用以下代码
         **************************************************/
        /*************明文模式  start****************/
        onenetService.receive(body);
        /*************明文模式  end****************/
        /********************************************************
         *  解析数据推送请求,加密模式
         *
         *  如果是加密模式使用以下代码
         ********************************************************/
        /*************加密模式  start****************/
//        Util.BodyObj obj1 = Util.resolveBody(body, true);
//        logger.info("data receive:  body Object--- " +obj1);
//        if (obj1 != null){
//            boolean dataRight1 = Util.checkSignature(obj1, token);
//            if (dataRight1){
//                String msg = Util.decryptMsg(obj1, aeskey);
//                logger.info("data receive: content" + msg);
//            }else {
//                logger.info("data receive:  signature error " );
//            }
//        }else {
//            logger.info("data receive: body empty error" );
//        }
        /*************加密模式  end****************/
        return "ok";
    }
    /**
     * 功能说明: URL&Token验证接口。如果验证成功返回msg的值,否则返回其他值。
     * @param msg 验证消息
     * @param nonce 随机串
     * @param signature 签名
     * @return msg值
     */
    @RequestMapping(value = "receive", method = RequestMethod.GET)
    public String check(@RequestParam(value = "msg") String msg,
                        @RequestParam(value = "nonce") String nonce,
                        @RequestParam(value = "signature") String signature) throws Exception {
        logger.info("url&token check: msg:{} nonce{} signature:{}",msg,nonce,signature);
        return msg;
    }
    @ApiOperation("触发器消息通知接收--废弃")
    @RequestMapping(value = "triggerMessage",method = {RequestMethod.POST,RequestMethod.GET})
    public String triggerMessage(@RequestBody String body) {
        try {
            logger.info("======================:"+body);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
}

+ 26 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/OnenetService.java

@ -0,0 +1,26 @@
package com.yihu.jw.care.service;
import com.yihu.jw.care.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
 * Created by yeshijie on 2021/10/20.
 */
@Service
public class OnenetService {
    private Logger logger = LoggerFactory.getLogger(AqgService.class);
    private static final String baseUrl = "https://zhyzh.gongshu.gov.cn/device/";
//    private static final String baseUrl = "http://ehr.yihu.com/wlyy/aqg";
    @Async
    public void receive(String body){
        String url = baseUrl + "siterwelldevice/receive";
        String result = HttpClientUtil.postBodyStr(url,body);
        logger.info(url+","+result);
    }
}

+ 138 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/util/HttpClientUtil.java

@ -0,0 +1,138 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class HttpClientUtil {
	/**
	 * 发送post请求
	 * @param url 请求地址
	 * @param params 请求参数
	 * @param chatSet 编码格式
	 * @return
	 */
	public static String post(String url, List<NameValuePair> params, String chatSet) {
		// 创建默认的httpClient实例.
		CloseableHttpClient httpclient = HttpClients.createDefault();
		// 创建httppost
		HttpPost httppost = new HttpPost(url);
		UrlEncodedFormEntity uefEntity;
		try {
			uefEntity = new UrlEncodedFormEntity(params, chatSet);
			httppost.setEntity(uefEntity);
			CloseableHttpResponse response = httpclient.execute(httppost);
			try {
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	/**
	 * 发送get请求
	 * @param url 请求地址
	 * @param chatSet 编码格式
	 * @return
	 */
	public static String get(String url, String chatSet) {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		try {
			// 创建httpget.
			HttpGet httpget = new HttpGet(url);
			// 执行get请求.
			CloseableHttpResponse response = httpclient.execute(httpget);
			try {
				// 获取响应实体
				HttpEntity entity = response.getEntity();
				if (entity != null) {
					return EntityUtils.toString(entity, chatSet);
				}
			} finally {
				response.close();
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			// 关闭连接,释放资源
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
	public static String postBodyStr(String url, String params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params, headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	public static String postBody(String url, JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		String ret = restTemplate.postForObject(url, formEntity, String.class);
		return ret;
	}
	public static void putBody(String url,JSONObject params){
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
		headers.setContentType(type);
		headers.add("Accept", MediaType.APPLICATION_JSON.toString());
		org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
		restTemplate.put(url, formEntity, String.class);
	}
}