Переглянути джерело

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

吴世龙 3 роки тому
батько
коміт
097b013658
100 змінених файлів з 7091 додано та 929 видалено
  1. 4 0
      business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorDao.java
  2. 11 0
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java
  3. 1 1
      business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java
  4. 237 118
      business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareService.java
  5. 48 0
      business/base-service/src/main/java/com/yihu/jw/healthUpload/dao/BaseDoctorHealthUploadDao.java
  6. 37 0
      business/base-service/src/main/java/com/yihu/jw/healthUpload/dao/BaseDoctorMemberDao.java
  7. 1149 0
      business/base-service/src/main/java/com/yihu/jw/healthUpload/service/BaseDoctorHealthUploadService.java
  8. 8 2
      business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationDao.java
  9. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  10. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  11. 17 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PayInfoNoticeService.java
  12. 1 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java
  13. 425 92
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  14. 343 51
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  15. 7 5
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
  16. 93 12
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  17. 217 2
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  18. 0 1
      business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java
  19. 23 12
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  20. 15 3
      business/base-service/src/main/java/com/yihu/jw/utils/YkyySMSService.java
  21. 4 0
      business/base-service/src/mqConfig/esbmq-config.xml
  22. 2 2
      business/sms-service/src/main/java/com/yihu/jw/sms/service/YkyyINSMSService.java
  23. 16 1
      common/common-entity/sql记录
  24. 31 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java
  25. 4 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  26. 99 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BasePatientMonitorDataDO.java
  27. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  28. 448 0
      common/common-entity/src/main/java/com/yihu/jw/entity/healthUpload/BaseDoctorHealthUploadDO.java
  29. 95 0
      common/common-entity/src/main/java/com/yihu/jw/entity/healthUpload/BaseDoctorMemberDO.java
  30. 245 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java
  31. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java
  32. 2 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  33. 528 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyHisSettleVO.java
  34. 45 1
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  35. 64 63
      common/common-web/src/main/resources/logback-spring.xml
  36. 63 64
      common/common-web/src/main/resources/logback-spring.xml-bak
  37. 1 1
      gateway/ag-basic/pom.xml
  38. 1 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  39. 6 2
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java
  40. 8 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  41. 4 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  42. 121 140
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  43. 8 7
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/HcyyService.java
  44. 12 12
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAEncrypt.java
  45. 5 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  46. 8 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/menu/BaseMenuManageService.java
  47. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BasePatientMonitorDataDao.java
  48. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceDataPushLogDao.java
  49. 18 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java
  50. 31 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java
  51. 32 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  52. 17 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java
  53. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java
  54. 24 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java
  55. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java
  56. 35 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  57. 23 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  58. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  59. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  60. 6 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  61. 59 67
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/common/CommomService.java
  62. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  63. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceManageService.java
  64. 13 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  65. 31 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  66. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  67. 24 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  68. 79 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java
  69. 268 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  70. 221 69
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  71. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  72. 25 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  73. 58 24
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  74. 57 46
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  75. 137 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java
  76. 116 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java
  77. 0 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DingdingUtil.java
  78. 350 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/JczdPersonVo.java
  79. 12 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BasePatientMonitorDataDao.java
  80. 19 4
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  81. 8 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java
  82. 8 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/HvDeviceService.java
  83. 14 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java
  84. 33 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java
  85. 1 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java
  86. 11 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/DeviceSosLogDao.java
  87. 23 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientSafeAreaDao.java
  88. 10 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  89. 82 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/DailyWaterJob.java
  90. 292 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java
  91. 7 1
      svr/svr-cloud-job/src/main/resources/application.yml
  92. 3 1
      svr/svr-cloud-job/src/main/resources/system.properties
  93. 4 2
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java
  94. 21 21
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/healthCare/HealthCareEndPoint.java
  95. 1 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  96. 17 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/config/DoctorServiceEndPoint.java
  97. 9 15
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthCare/HealthCareEndPoint.java
  98. 330 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthUpload/HealthUploadPoint.java
  99. 32 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  100. 0 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorDao.java

@ -38,6 +38,10 @@ public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO,
    @Query("update BaseDoctorDO p set p.del = ?2 where p.id = ?1")
    void updateStatus(String doctorId,String status);
    @Modifying
    @Query("update BaseDoctorDO p set p.sort = ?2 where p.id = ?1")
    void updateSort(String doctorId,Integer sort);
    List<BaseDoctorDO> findByIdcard(String idcard);
    @Query("from BaseDoctorDO d where d.name = ?1 AND d.del ='1'")

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java

@ -137,6 +137,7 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
                " e.req_fee AS \"money\", " +
                " a.charge_type as \"chargeType\", "+
                " c.mapping_code as \"mappingCode\", "+
                " a.sort AS \"sort\", " +
                "\tm.req_fee as \"twfzFee\",\n" +
                "\tn.req_fee as \"spfzFee\",\n" +
                "\tp.req_fee as \"spzxFee\",\n" +
@ -182,6 +183,7 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
        if(StringUtils.isNotBlank(dept)){
            sql += " AND b.dept_code =:dept";
        }
        sql +=" order by a.sort asc ";
        logger.info("queryList sql:"+sql);
@ -418,6 +420,15 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
    public void updateStatus(String doctorId,String status)throws Exception{
        baseDoctorDao.updateStatus(doctorId,status);
    }
    /**
     * 修改医生排名
     * @param doctorId
     * @param sort
     */
    public void updateSort(String doctorId,Integer sort)throws Exception{
        baseDoctorDao.updateSort(doctorId,sort);
    }
    /**修改眼科通密码信息
     *
     * @param doctorId

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -678,7 +678,7 @@ public class FileUploadService {
            type = type.substring(type.lastIndexOf("."),type.length()-1);
        }
        logger.info(type);
        List img = new ArrayList(Arrays.asList("jpeg","bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp","xls","xlsx","text/plain","mp4","m4v","avi","ogm","wmv","mpg","webm","ogv","mov","asx","mpeg","image/png"));
        List img = new ArrayList(Arrays.asList("jpeg","bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp","xls","xlsx","text/plain","mp4","m4v","avi","ogm","wmv","mpg","webm","ogv","mov","asx","mpeg","image/png","amr"));
        if (!img.contains(type)) {
            return false;
        }

+ 237 - 118
business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareService.java

@ -30,6 +30,7 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.ylzinfo.ehc.common.utils.DateUtils;
import net.sf.json.util.JSONTokener;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -637,69 +638,90 @@ public class HealthCareService {
        if (outpatientDO == null){
            throw new Exception("门诊信息不存在");
        }
        JSONObject data = new JSONObject();
        data.put("order_code","");//订单号
        data.put("order_time",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));//订单时间
        List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
        if(wlyyPrescriptionDOS.size()==0){
            throw new Exception("处方信息不存在");
        }
        data.put("prescription_code",wlyyPrescriptionDOS.get(0).getRealOrder());//医院处方编号
        data.put("channel","1");//1、微信公众号,2、app,3、web
//        data.put("insurance_ticket_no","");//医保收费单据号	String	N	订单结算后的收费单据号
        data.put("order_state","");//订单状态    --1待发货、2配送中、3已签收、4已取消	String	Y
        List<WlyyPrescriptionExpressageDO> expressageDOList = prescriptionExpressageDao.findByOutpatientId(outpatientId);
        if(expressageDOList.size()==0){
            throw new Exception("收获信息不存在");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
        if(patientDO==null){
            throw new Exception("居民信息不存在");
        }
        WlyyPrescriptionExpressageDO expressageDO = expressageDOList.get(0);
        data.put("order_addr_detail",expressageDO.getAddress());//订单详细地址
        data.put("order_owner",expressageDO.getName());
        data.put("order_owner_idcard",patientDO.getIdcard());
        data.put("order_owner_phone",patientDO.getMobile());
        Map<String,String> map = LatitudeUtils.getGeocoderLatitude(expressageDO.getAddress());
        data.put("addr_lat",map.get("lat"));//收货地址纬度
        data.put("addr_lng",map.get("lng"));//收货地址经度
        if(expressageDO.getOneselfPickupFlg()==1){
            //自取
            data.put("delivery_way","2");//1.网订配送,2.网订自取
            data.put("qrcode_check_time","");//扫码校验时间
            data.put("receiving_time","");//药品签收时间
        }else {
            //非自取
            data.put("delivery_way","1");//配送方式 1.网订配送,2.网订自取
            data.put("delivery_number",expressageDO.getMailno());//配送单号
            data.put("delivery_org","");//配送单位
            data.put("delivery_take_time","");//配送接单时间
            data.put("delivery_name","");//配送人姓名
            data.put("delivery_id_card","");//配送人身份证
        logger.info("电子处方订单接收:1");
        List<YlzMedicalRelationDO> ylzMedicalRelationDOList = ylzMedicailRelationDao.findByOutpatientStatus(outpatientId);
        for (YlzMedicalRelationDO ylzMedicalRelationDO:ylzMedicalRelationDOList){
            logger.info("电子处方订单接收:2");
            JSONObject data = new JSONObject();
            data.put("order_time",DateUtil.dateToStrLong(expressageDO.getCreateTime()));//订单时间
            List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByRealOrderList(ylzMedicalRelationDO.getLogNo());
            if(wlyyPrescriptionDOS.size()==0){
                throw new Exception("处方信息不存在");
            }
            data.put("order_code",ylzMedicalRelationDO.getLogNo());//订单号
            WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
            data.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
            data.put("channel","1");//1、微信公众号,2、app,3、web
            data.put("insurance_ticket_no",ylzMedicalRelationDO.getBillSerial());//医保收费单据号	String	N	订单结算后的收费单据号
            String order_state = "";
            if (wlyyPrescriptionDO.getStatus()==30){
                order_state = "1";
            }else if (wlyyPrescriptionDO.getStatus()==31){
                order_state = "2";
            }else if (wlyyPrescriptionDO.getStatus()==100){
                order_state = "3";
            }
            logger.info("电子处方订单接收:3"+order_state);
            data.put("order_state",order_state);//订单状态    --1待发货、2配送中、3已签收、4已取消	String	Y
            data.put("order_addr_detail",expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress());//订单详细地址
            data.put("order_owner",expressageDO.getName());
            data.put("order_owner_idcard",patientDO.getIdcard());
            data.put("order_owner_phone",patientDO.getMobile());
            Map<String,String> map = LatitudeUtils.getGeocoderLatitude(expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress());
            data.put("addr_lat",map.get("lat"));//收货地址纬度
            data.put("addr_lng",map.get("lng"));//收货地址经度
            if(expressageDO.getOneselfPickupFlg()==1){
                //自取
                data.put("delivery_way","2");//1.网订配送,2.网订自取
                data.put("qrcode_check_time","");//扫码校验时间
                data.put("receiving_time","");//药品签收时间
            }else {
                //非自取
                data.put("delivery_way","1");//配送方式 1.网订配送,2.网订自取
                data.put("delivery_number",expressageDO.getMailno());//配送单号
                data.put("delivery_org","顺丰");//配送单位
                data.put("delivery_take_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//配送接单时间
                data.put("delivery_name","顺丰");//配送人姓名
                data.put("delivery_id_card","顺丰");//配送人身份证
//            data.put("delivery_phone","");//配送人联系电话 N
            data.put("getmedical_time","");//骑手取药记录
            data.put("delivery_money","");//配送费
                data.put("getmedical_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//骑手取药记录
                data.put("delivery_money","");//配送费
        }
            }
//        apothecary_name	药师姓名	String	N
//        apothecary_id_card	药师身份证	String	N
//        apothecary_audit	药师审核时间	String	N
        data.put("money","");//商品金额
        data.put("settlement_time","");//结算时间
        data.put("data_source","");//数据来源
        data.put("delivery_time","");//发单时间
            data.put("money",ylzMedicalRelationDO.getTotalAmount());//商品金额
            data.put("settlement_time",DateUtil.dateToStrLong(ylzMedicalRelationDO.getPayDate()));//结算时间
            data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
            data.put("delivery_time",DateUtil.dateToStrLong(wlyyPrescriptionDO.getPayTime()));//发单时间
        data.put("elec_prescription_code",wlyyPrescriptionDOS.get(0).getId());//平台处方编号
        data.put("prescription_code",wlyyPrescriptionDOS.get(0).getRealOrder());//医院处方编号
            data.put("elec_prescription_code",wlyyPrescriptionDO.getId());//平台处方编号
            data.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
//        data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保门诊流水号
        data.put("his_serial","");//门诊业务流水号
            data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//门诊业务流水号
            JSONArray array = new JSONArray();
            List<YlzMedicalMxDO> ylzMedicalMxDOS = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
            for (YlzMedicalMxDO ylzMedicalMxDO:ylzMedicalMxDOS){
                JSONObject object = new JSONObject();
                object.put("order_id",ylzMedicalRelationDO.getLogNo());
                object.put("settlement_no",ylzMedicalRelationDO.getHisBillSerial());
                object.put("item_name",ylzMedicalMxDO.getItemName());
                object.put("item_code",ylzMedicalMxDO.getItemCode());
                array.add(object);
            }
            data.put("MXLIST",array);
//        mxlist	药品明细	MXLIST	N
//        MXLIST
//        order_id	订单号	String	Y
@ -708,17 +730,18 @@ public class HealthCareService {
//        item_code	医保项目编码	String	Y
//        supervision_code	药品电子监管码	String	N	非必填
        String result = requestYlz(data,"N20.17.05.02","电子处方订单接收");
        if(result == null){
            throw new Exception("医保请求失败");
        }
        logger.info("电子处方订单接收:"+result);
        JSONObject object = JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            return encryptData.toJSONString();
            String result = requestYlz(data,"N20.17.05.02","电子处方订单接收");
            if(result == null){
                throw new Exception("医保请求失败");
            }
            logger.info("电子处方订单接收:"+result);
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                logger.info("encryptData=="+encryptData);
            }
        }
        return result;
        return "上传成功";
    }
    /**
@ -1144,13 +1167,13 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 系统id
     * @return
     * @throws Exception
     */
    public String register(String registerNo) throws Exception{
    public String register(String outpatientId) throws Exception{
        String funid = "N20.17.04.01";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("上传医保挂号失败:结算信息为空!");
        }
@ -1166,7 +1189,7 @@ public class HealthCareService {
        data.put("his_dept_name",ylzMedicalRelationDO.getHisDeptName());//his内部科室名称
        data.put("emergency_sign",ylzMedicalRelationDO.getEmergencySign());//急诊标志0 否,1 是
        data.put("trauma_sign",ylzMedicalRelationDO.getTraumaSign());//外伤标志0 否,1 是
        data.put("date", DateUtil.dateToStrLong(ylzMedicalRelationDO.getDate()));//实际门诊/入院日期 若为空,默认取系统时间
        data.put("date", DateUtil.dateToStrFormatLong(ylzMedicalRelationDO.getDate()));//实际门诊/入院日期 若为空,默认取系统时间
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        String result = requestYlz(data,funid,"医保挂号");
        if (result==null){
@ -1177,6 +1200,8 @@ public class HealthCareService {
            JSONObject encryptData = object.getJSONObject("encrypt_data");
            String insuranceSerial = encryptData.getString("insurance_serial");
            ylzMedicalRelationDO.setInsuranceSerial(insuranceSerial);
            ylzMedicalRelationDO.setInsuranceType(encryptData.getString("insurance_type"));
            ylzMedicalRelationDO.setInsuranceTypeName(encryptData.getString("insurance_type_name"));
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            logger.info("医保挂号流水号保存成功");
        }
@ -1188,14 +1213,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public String registerToEntrance(String registerNo) throws Exception{
    public String registerToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"register?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"register?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1210,13 +1235,13 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String registerBack(String registerNo) throws Exception{
    public String registerBack(String outpatientId) throws Exception{
        String funid = "N20.17.04.02";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保挂号冲销失败:结算信息为空!");
        }
@ -1249,14 +1274,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String registerBackToEntrance(String registerNo) throws Exception{
    public String registerBackToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"registerBack?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"registerBack?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1269,13 +1294,13 @@ public class HealthCareService {
    /**
     * 2.5.3医保费用明细上传(N20.17.04.03)
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailUpload(String registerNo) throws Exception{
    public String feeDetailUpload(String outpatientId) throws Exception{
        String funid = "N20.17.04.03";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
@ -1345,7 +1370,7 @@ public class HealthCareService {
            String detailSerial = encryptData.getString("detail_serial");
            ylzMedicalRelationDO.setDetailSerial(detailSerial);
            ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            logger.info("医保费用明细上传失败保存成功");
            logger.info("医保费用明细上传保存成功");
        }
        return result;
    }
@ -1353,14 +1378,14 @@ public class HealthCareService {
    /**
     * 2.5.3医保费用明细上传(N20.17.04.03)
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailUploadToEntrance(String registerNo) throws Exception{
    public String feeDetailUploadToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailUpload?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"feeDetailUpload?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1375,13 +1400,13 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String feeDetailRefund(String registerNo,String remark) throws Exception{
    public String feeDetailRefund(String outpatientId,String remark) throws Exception{
        String funid = "N20.17.04.04";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
@ -1413,14 +1438,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public String feeDetailRefundToEntrance(String registerNo,String remark) throws Exception{
    public String feeDetailRefundToEntrance(String outpatientId,String remark) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailRefund?registerNo="+registerNo+"&remark="+remark;
        String url = entranceHealthCareUrl+"feeDetailRefund?outpatientId="+outpatientId+"&remark="+remark;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1435,13 +1460,13 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlement(String registerNo) throws Exception{
    public YlzMedicalRelationDO preSettlement(String outpatientId) throws Exception{
        String funid = "N20.17.04.05";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
@ -1455,7 +1480,7 @@ public class HealthCareService {
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("settlement_sign",0);//结算标识
        data.put("date",DateUtil.dateToStrLong(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
@ -1465,12 +1490,78 @@ public class HealthCareService {
        data.put("trt_fee_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("dept_code",ylzMedicalRelationDO.getDeptCode());//科室编码
        data.put("charge_qty",1);//本次收费次数
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
        array.add(object);
        data.put("cflist",array);
        String result = requestYlz(data,funid,"医保预结算服务");
        if (result==null){
            throw new Exception("医保预结算服务失败!");
        }
        }else {
            JSONObject resObj = JSONObject.parseObject(result);
            if (resObj.getString("flag").equalsIgnoreCase("1")){
                JSONObject jsonObject = resObj.getJSONObject("encrypt_data");
                ylzMedicalRelationDO.setAccountBalance(jsonObject.getString("account_balance"));
                ylzMedicalRelationDO.setBillSerial(jsonObject.getString("bill_serial"));
                ylzMedicalRelationDO.setPersonalCode(jsonObject.getString("personal_code"));
                ylzMedicalRelationDO.setSex(jsonObject.getString("sex"));
                ylzMedicalRelationDO.setSexMc(jsonObject.getString("sex_mc"));
                ylzMedicalRelationDO.setPersonCash(jsonObject.getString("person_cash"));
                ylzMedicalRelationDO.setPersonAccount(jsonObject.getString("person_account"));
                ylzMedicalRelationDO.setFundPrice(jsonObject.getString("fund_price"));
                ylzMedicalRelationDO.setJkzhPay(jsonObject.getString("own_jkzh_pay"));
                ylzMedicalRelationDO.setOwnPay(jsonObject.getString("own_pay"));
                ylzMedicalRelationDO.setCardNo(jsonObject.getString("card_no"));
                ylzMedicalRelationDO.setHospitalizationQty(jsonObject.getString("hospitalization_times"));
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                ylzMedicalRelationDO.setInvoiceJj(jsonObject.getString("invoice_jj"));
                ylzMedicalRelationDO.setInvoiceXj(jsonObject.getString("invoice_xj"));
                ylzMedicalRelationDO.setInvoiceZh(jsonObject.getString("invoice_zh"));
                ylzMedicalRelationDO.setDiseaseCode(jsonObject.getString("disease_code"));
                ylzMedicalRelationDO.setTreatmentType(jsonObject.getString("treatment_type"));
                ylzMedicalRelationDO.setTreatmentTypeName(jsonObject.getString("treatment_type_name"));
                ylzMedicalRelationDO.setAllopatryType(jsonObject.getString("allopatry_type"));
                ylzMedicalRelationDO.setAllopatryTypeName(jsonObject.getString("allopatry_type_name"));
                ylzMedicalRelationDO.setAdministrativeArea(jsonObject.getString("administrative_area"));
                ylzMedicalRelationDO.setPayStandard(jsonObject.getString("pay_standard"));
                ylzMedicalRelationDO.setTcjjPay(jsonObject.getString("tcjj_pay"));
                ylzMedicalRelationDO.setSbjjPay(jsonObject.getString("sbjj_pay"));
                ylzMedicalRelationDO.setGwyPay(jsonObject.getString("gwy_pay"));
                ylzMedicalRelationDO.setJzfpPay(jsonObject.getString("jzfp_pay"));
                ylzMedicalRelationDO.setYljzPay(jsonObject.getString("yljz_pay"));
                ylzMedicalRelationDO.setOtherPay(jsonObject.getString("other_pay"));
                ylzMedicalRelationDO.setEnterpriseSupplement(jsonObject.getString("enterprise_supplement"));
                ylzMedicalRelationDO.setJtgjPay(jsonObject.getString("jtgj_pay"));
                ylzMedicalRelationDO.setCollector(jsonObject.getString("collector"));
                Double price= Double.parseDouble(ylzMedicalRelationDO.getTcjjPay())+Double.parseDouble(ylzMedicalRelationDO.getSbjjPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getJzfpPay())+Double.parseDouble(ylzMedicalRelationDO.getYljzPay())+
                        Double.parseDouble(ylzMedicalRelationDO.getOtherPay())+Double.parseDouble(ylzMedicalRelationDO.getEnterpriseSupplement());
                ylzMedicalRelationDO.setMedicalPrice(price+"");
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                JSONArray jsonArray = jsonObject.getJSONArray("fplist");
                for (int i=0;i<jsonArray.size();i++){
                    JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                    YlzMedicalBillDO ylzMb = new YlzMedicalBillDO();
                    ylzMb.setMedicalId(ylzMedicalRelationDO.getId());
                    ylzMb.setInvoicePay(jsonObject1.getString("invoice_pay"));
                    ylzMb.setInvoiceType(jsonObject1.getString("invoice_type"));
                    ylzMb.setInvoiceTypeName(jsonObject1.getString("invoice_type_name"));
                    ylzMb.setProjectPay(jsonObject1.getString("project_pay"));
                    ylzMb.setOwnPay(jsonObject1.getString("own_pay"));
                    ylzMb.setSpecialPay(jsonObject1.getString("special_pay"));
                    ylzMb.setUninsurancePay(jsonObject1.getString("uninsurance_pay"));
                    ylzMb.setCreateTime(new Date());
                    ylzMedicailBillDao.save(ylzMb);
                }
            }
        }
        List<YlzMedicalIcdDO> icdDOList = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
        List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
        ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOList);
        ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
        return ylzMedicalRelationDO;
    }
@ -1479,12 +1570,12 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 门诊id
     * @return
     * @throws Exception
     */
    public YlzMedicalRelationDO preSettlementToEntrance(String registerNo) throws Exception{
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
    public YlzMedicalRelationDO preSettlementToEntrance(String outpatientId) throws Exception{
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保费用明细上传:结算信息为空!");
        }
@ -1498,7 +1589,7 @@ public class HealthCareService {
        }
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"preSettlement?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"preSettlement?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1552,14 +1643,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String preSettlementRefundToEntrance(String registerNo) throws Exception{
    public String preSettlementRefundToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"feeDetailRefund?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"feeDetailRefund?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1574,13 +1665,13 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String preSettlementRefund(String registerNo) throws Exception{
    public String preSettlementRefund(String outpatientId) throws Exception{
        String funid = "N20.17.04.06";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("医保结算冲销上传:结算信息为空!");
        }
@ -1591,7 +1682,7 @@ public class HealthCareService {
        data.put("cert_type",ylzMedicalRelationDO.getCertType());//证件类型
        data.put("medical_mode",ylzMedicalRelationDO.getMedicalMode());//医疗就诊方式
        data.put("bill_serial",ylzMedicalRelationDO.getBillSerial());//医保收费流水号
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisSerial());//his收费单据流水号
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisSettleNo());//his收费单据流水号
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//医保流水号
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("refund_serial",ylzMedicalRelationDO.getHisSerial());//医院退费操作流水号
@ -1612,14 +1703,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrl(String registerNo) throws Exception{
    public String getSettlementResultUrl(String outpatientId) throws Exception{
        String funid = "N20.17.04.07";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
@ -1635,20 +1726,35 @@ public class HealthCareService {
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("date",ylzMedicalRelationDO.getDate());//实际就诊日期
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金)
        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额
        data.put("fund_price",ylzMedicalRelationDO.getFundPrice());//基金支付总额
        data.put("fund_price",ylzMedicalRelationDO.getMedicalPrice());//基金支付总额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,funid,"获取医保结算结果");
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        object.put("detail_serial",ylzMedicalRelationDO.getDetailSerial());
        array.add(object);
        data.put("cflist",array);
        String result = requestYlz(data,funid,"获取医保结算页面地址");
        if (result==null){
            throw new Exception("获取医保结算结果失败!");
            throw new Exception("获取医保结算页面地址失败!");
        }else {
            JSONObject resObj = JSONObject.parseObject(result);
            if (resObj.getString("flag").equalsIgnoreCase("1")){
                JSONObject jsonObject = resObj.getJSONObject("encrypt_data");
                String link_url = jsonObject.getString("link_url");
                String str1=link_url.substring(0, link_url.indexOf("="));
                String str2=link_url.substring(str1.length()+1, link_url.length());
                ylzMedicalRelationDO.setPageCode(str2);
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            }
        }
        return result;
    }
@ -1659,14 +1765,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlToEntrance(String registerNo) throws Exception{
    public String getSettlementResultUrlToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrl?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"getSettlementResultUrl?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1683,14 +1789,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64(String registerNo) throws Exception{
    public String getSettlementResultUrlBase64(String outpatientId) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(registerNo);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO==null){
            throw new Exception("获取医保结算页面地址:结算信息为空!");
        }
@ -1706,20 +1812,20 @@ public class HealthCareService {
        data.put("medical_type",ylzMedicalRelationDO.getMedicalType());//医疗类别
        data.put("insurance_serial",ylzMedicalRelationDO.getInsuranceSerial());//
        data.put("his_bill_serial",ylzMedicalRelationDO.getHisBillSerial());//his收费单据流水号
        data.put("date",ylzMedicalRelationDO.getDate());//实际就诊日期
        data.put("date",DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate()));//实际就诊日期
        data.put("leave_method","09");//离院方式
        data.put("pre_count",ylzMedicalRelationDO.getPreCount());//处方项目数
        data.put("total_amount",ylzMedicalRelationDO.getTotalAmount());//医疗费总金额
        data.put("person_cash",ylzMedicalRelationDO.getPersonCash());//个人现金支付金额(实付现金)
        data.put("person_account",ylzMedicalRelationDO.getPersonAccount());//个人账户支付金额
        data.put("fund_price",ylzMedicalRelationDO.getFundPrice());//基金支付总额
        data.put("fund_price",ylzMedicalRelationDO.getMedicalPrice());//基金支付总额
        data.put("data_source",ylzMedicalRelationDO.getDataSource());//数据来源
        data.put("his_serial",ylzMedicalRelationDO.getHisSerial());//his流水号
        data.put("doctor_level",ylzMedicalRelationDO.getDoctorLevel());//医师诊查费等级
        data.put("redirect_url",wlyyHospitalSysDictDO.getDictValue());//回调地址
        String result = requestYlz(data,funid,"获取医保结算结果");
        String result = requestYlz(data,funid,"获取医保结算页面地址");
        if (result==null){
            throw new Exception("获取医保结算结果失败!");
            throw new Exception("获取医保结算页面地址失败!");
        }
        return result;
    }
@ -1730,14 +1836,14 @@ public class HealthCareService {
     *
     * 返回值
     *
     * @param registerNo 挂号号
     * @param outpatientId 挂号号
     * @return
     * @throws Exception
     */
    public String getSettlementResultUrlBase64ToEntrance(String registerNo) throws Exception{
    public String getSettlementResultUrlBase64ToEntrance(String outpatientId) throws Exception{
        String result = "";
        String response="";
        String url = entranceHealthCareUrl+"getSettlementResultUrlBase64?registerNo="+registerNo;
        String url = entranceHealthCareUrl+"getSettlementResultUrlBase64?outpatientId="+outpatientId;
        response = httpClientUtil.get(url,"GBK");
        logger.info("response:"+response);
        JSONObject object = JSONObject.parseObject(response);
@ -1767,6 +1873,19 @@ public class HealthCareService {
        if (result==null){
            throw new Exception("获取医保结算结果失败!");
        }
        com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
        if (object.getString("flag").equalsIgnoreCase("1")){
            JSONObject jsonObject = object.getJSONObject("encrypt_data");
            String insuranceSerial = jsonObject.getString("insurance_serial");
            String billSerial = jsonObject.getString("bill_serial");
            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByInsuranceSerial(insuranceSerial);
            if (ylzMedicalRelationDO!=null){
                ylzMedicalRelationDO.setStatus(1);
                ylzMedicalRelationDO.setBillSerial(billSerial);
                ylzMedicalRelationDO.setPayDate(DateUtil.strToDate(jsonObject.getString("pay_date")+jsonObject.getString("pay_time")));
                ylzMedicailRelationDao.save(ylzMedicalRelationDO);
            }
        }
        return result;
    }

+ 48 - 0
business/base-service/src/main/java/com/yihu/jw/healthUpload/dao/BaseDoctorHealthUploadDao.java

@ -0,0 +1,48 @@
package com.yihu.jw.healthUpload.dao;
import com.yihu.jw.entity.healthUpload.BaseDoctorHealthUploadDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
import com.yihu.jw.entity.patient.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
 *
 * 医生成员表
 *
 * @version
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
@Transactional
public interface BaseDoctorHealthUploadDao extends PagingAndSortingRepository<BaseDoctorHealthUploadDO, String>, JpaSpecificationExecutor<BaseDoctorHealthUploadDO>  {
    @Query("from BaseDoctorHealthUploadDO d where d.id = ?1 ")
    BaseDoctorHealthUploadDO findById(String id);
    @Query("from BaseDoctorHealthUploadDO d where d.doctorId = ?1 ")
    List<BaseDoctorHealthUploadDO> findByDoctorId(String doctorId);
    @Query("from BaseDoctorHealthUploadDO d where d.doctorId = ?1 and d.consumer= ?2 order by d.createTime desc")
    List<BaseDoctorHealthUploadDO> findByDoctorIdAndConsumer(String doctorId,String consumer);
    @Query("select a from BaseDoctorHealthUploadDO a where a.doctorId=?1 order by a.createTime desc")
    List<BaseDoctorHealthUploadDO> selectHealthUploadInfoByDoctorId(String doctorId, Pageable pageRequest);
    @Query("select a from BaseDoctorHealthUploadDO a where a.doctorId=?1 and a.createTime>=?2 and a.createTime<=?3 order by a.createTime desc")
    List<BaseDoctorHealthUploadDO> selectHealthUploadInfoByDoctorIdAndDate(String doctorId, Date startDate,Date endDate,Pageable pageRequest);
}

+ 37 - 0
business/base-service/src/main/java/com/yihu/jw/healthUpload/dao/BaseDoctorMemberDao.java

@ -0,0 +1,37 @@
package com.yihu.jw.healthUpload.dao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
 *
 * 医生成员表
 *
 * @version
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
@Transactional
public interface BaseDoctorMemberDao extends PagingAndSortingRepository<BaseDoctorMemberDO, String>, JpaSpecificationExecutor<BaseDoctorMemberDO>  {
    @Query("from BaseDoctorMemberDO d where d.id = ?1 AND d.del ='1'")
    BaseDoctorMemberDO findById(String id);
    @Query("from BaseDoctorMemberDO d where  d.del ='1' and d.doctorId=?1")
    List<BaseDoctorMemberDO> findByDoctorIdAndDel(String doctorId);
    @Query("from BaseDoctorMemberDO d where  d.del ='1' and d.doctorId=?1 and d.memberId=?2 ")
    BaseDoctorMemberDO findByDoctorIdAndMemberIdAndDel(String doctorId,String memberId);
}

+ 1149 - 0
business/base-service/src/main/java/com/yihu/jw/healthUpload/service/BaseDoctorHealthUploadService.java

@ -0,0 +1,1149 @@
package com.yihu.jw.healthUpload.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorHealthUploadDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
import com.yihu.jw.entity.hospital.DmHospitalDO;
import com.yihu.jw.entity.hospital.dict.BaseDeptDict;
import com.yihu.jw.healthUpload.dao.BaseDoctorHealthUploadDao;
import com.yihu.jw.healthUpload.dao.BaseDoctorMemberDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.common.PwdUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.idcard.IdCardUtil;
import com.yihu.mysql.query.BaseJpaService;
import jxl.format.*;
import jxl.write.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
@Transactional
public class BaseDoctorHealthUploadService extends BaseJpaService<BaseDoctorHealthUploadDO, BaseDoctorHealthUploadDao> {
    private static Logger logger = LoggerFactory.getLogger(BaseDoctorHealthUploadService.class);
    @Autowired
    private BaseDoctorMemberDao doctorMemberDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseDoctorHealthUploadDao baseDoctorHealthUploadDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
    /**
     * 新增医生成员关系
     * @param doctorId
     * @param ids 逗号隔开
     * @return
     */
    public List<BaseDoctorMemberDO> saveAndCreateMember(String doctorId,String ids){
        String str[] =ids.split(",");
        List<BaseDoctorMemberDO> baseDoctorMemberDOList = new ArrayList<>();
        for (int i=0;i<str.length;i++){
            String memberId = str[i];
            BaseDoctorMemberDO memberDO = doctorMemberDao.findByDoctorIdAndMemberIdAndDel(doctorId,memberId);
            if (memberDO==null){
                BaseDoctorMemberDO baseDoctorMemberDO = new BaseDoctorMemberDO();
                baseDoctorMemberDO.setDel(1);
                baseDoctorMemberDO.setDoctorId(doctorId);
                baseDoctorMemberDO.setMemberId(memberId);
                baseDoctorMemberDO.setCreateTime(new Date());
                baseDoctorMemberDO.setUpdateTime(new Date());
                baseDoctorMemberDO= doctorMemberDao.save(baseDoctorMemberDO);
                baseDoctorMemberDOList.add(baseDoctorMemberDO);
            }
        }
        return baseDoctorMemberDOList;
    }
    /**
     * 查询医生的成员列表
     * @param doctorId
     * @return
     */
    public List<BaseDoctorMemberDO> selectByDoctorId(String doctorId){
       List<BaseDoctorMemberDO> baseDoctorMemberDOList = doctorMemberDao.findByDoctorIdAndDel(doctorId);
        BaseDoctorMemberDO memberDO1 = doctorMemberDao.findByDoctorIdAndMemberIdAndDel(doctorId,doctorId);
        //添加本人
        if (memberDO1==null){
            BaseDoctorMemberDO baseDoctorMemberDO = new BaseDoctorMemberDO();
            baseDoctorMemberDO.setDel(1);
            baseDoctorMemberDO.setDoctorId(doctorId);
            baseDoctorMemberDO.setMemberId(doctorId);
            baseDoctorMemberDO.setCreateTime(new Date());
            baseDoctorMemberDO.setUpdateTime(new Date());
            baseDoctorMemberDO= doctorMemberDao.save(baseDoctorMemberDO);
        }
       for (BaseDoctorMemberDO memberDO:baseDoctorMemberDOList){
           BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(memberDO.getMemberId());
           if (baseDoctorDO!=null){
               memberDO.setBaseDoctorDO(baseDoctorDO);
           }
       }
       return baseDoctorMemberDOList;
    }
    /**
     * 查询医生的成员列表带有已上报次数
     * @param doctorId
     * @return
     */
    public List<BaseDoctorMemberDO> selectCountByDoctorId(String doctorId){
        List<BaseDoctorMemberDO> baseDoctorMemberDOList = doctorMemberDao.findByDoctorIdAndDel(doctorId);
        for (BaseDoctorMemberDO memberDO:baseDoctorMemberDOList){
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(memberDO.getMemberId());
            if (baseDoctorDO!=null){
                memberDO.setBaseDoctorDO(baseDoctorDO);
            }
            List<BaseDoctorHealthUploadDO> baseDoctorHealthUploadDOList = baseDoctorHealthUploadDao.findByDoctorIdAndConsumer(memberDO.getMemberId(),doctorId);
            memberDO.setCount(baseDoctorHealthUploadDOList.size()+"");
        }
        return baseDoctorMemberDOList;
    }
    /**
     * 查询某一个成员id
     * @param id 成员id
     * @return
     */
    public BaseDoctorMemberDO selectById(String id){
        BaseDoctorMemberDO baseDoctorMemberDO = doctorMemberDao.findById(id);
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(baseDoctorMemberDO.getMemberId());
        if (baseDoctorDO!=null){
            baseDoctorMemberDO.setBaseDoctorDO(baseDoctorDO);
        }
        List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorMemberDO.getMemberId());
        baseDoctorMemberDO.setDoctorHospitalDOS(doctorHospitalDOS);
        return baseDoctorMemberDO;
    }
    /**
     * 删除某个成员
     * @param id 成员id
     * @return
     */
    public BaseDoctorMemberDO delDoctorMember(String id){
        BaseDoctorMemberDO baseDoctorMemberDO = doctorMemberDao.findById(id);
        baseDoctorMemberDO.setDel(0);
        baseDoctorMemberDO = doctorMemberDao.save(baseDoctorMemberDO);
        return baseDoctorMemberDO;
    }
    /**
     * 提交健康信息
     * @param baseDoctorHealthUploadDO 健康信息实体类
     * @return
     */
    public BaseDoctorHealthUploadDO createHealthUploadInfo(BaseDoctorHealthUploadDO baseDoctorHealthUploadDO){
        baseDoctorHealthUploadDO.setCreateTime(new Date());
        return baseDoctorHealthUploadDao.save(baseDoctorHealthUploadDO);
    }
    /**
     * 查询成员的健康上报记录
     *
     * @param doctorId 医生id
     * @return
     */
    public MixEnvelop selectHealthUploadInfoByDoctorId(String doctorId,String startDate,String endDate,Integer page,Integer pageSize){
        PageRequest pageRequest = new PageRequest(page-1,pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        List<BaseDoctorHealthUploadDO> list = new ArrayList<>();
        if (StringUtils.isNoneBlank(startDate)) {
            Date startTime = DateUtil.strToDateLong(startDate);
            Date endTime = DateUtil.strToDateLong(endDate);
            list = baseDoctorHealthUploadDao.selectHealthUploadInfoByDoctorIdAndDate(doctorId,startTime,endTime,pageRequest);
        }else {
            list =baseDoctorHealthUploadDao.selectHealthUploadInfoByDoctorId(doctorId,pageRequest);
        }
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setTotalCount(list==null?0:list.size());
        return mixEnvelop;
    }
    public BaseDoctorHealthUploadDO selectHealthInfoById(String id){
        BaseDoctorHealthUploadDO baseDoctorHealthUploadDO = baseDoctorHealthUploadDao.findById(id);
        return baseDoctorHealthUploadDO;
    }
    /**
     * 新增加医生信息
     * @param photo
     * @param name
     * @param idcard
     * @param sex
     * @param mobile
     * @param dept
     * @param deptName
     * @param idCardType
     * @param idType
     * @return
     */
    public BaseDoctorDO  saveDoctorInfo(String id,String photo,String name,String idcard,String sex,String mobile,String dept,String deptName,String idCardType,String idType) throws Exception {
        BaseDoctorDO baseDoctorDO = new BaseDoctorDO();
        if (StringUtils.isNoneBlank(id)) {
            baseDoctorDO = baseDoctorDao.findById(id);
            baseDoctorDO.setIdCardType(idCardType);
            baseDoctorDO.setIdType(idType);
            baseDoctorDO.setPhoto(photo);
            baseDoctorDO.setName(name);
            baseDoctorDO.setIdcard(idcard);
            baseDoctorDO.setSex(Integer.parseInt(sex));
            baseDoctorDO.setMobile(mobile);
            String deptCode = dept;
            baseDoctorDO.setChargeType("1");
            baseDoctorDO = baseDoctorDao.save(baseDoctorDO);
            List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorDO.getId());
            if (null != baseDoctorHospitalDOS && baseDoctorHospitalDOS.size() > 0) {
                baseDoctorHospitalDao.delete(baseDoctorHospitalDOS);
                BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
                baseDoctorHospitalDO.setOrgCode("350211A1002");
                baseDoctorHospitalDO.setOrgName("马銮湾医院");
                baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }else {
                BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
                baseDoctorHospitalDO.setOrgCode("350211A1002");
                baseDoctorHospitalDO.setOrgName("马銮湾医院");
                baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }
        } else {
            baseDoctorDO.setIdcard(idcard);
            baseDoctorDO.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
            baseDoctorDO.setSex(Integer.parseInt(sex));
            baseDoctorDO.setLocked(0);
            baseDoctorDO.setEnabled(1);
            String disableFlag = "0";
            //互联网医院:1停用,0使用  转 i健康:1正常,0作废
            baseDoctorDO.setDel("1".equals(disableFlag) ? "0" : "1");
            baseDoctorDO.setMobile("0");
            baseDoctorDO.setName(name);
            baseDoctorDO.setIsFamous(0);
            baseDoctorDO.setCreateTime(new Date());
            baseDoctorDO.setUpdateTime(new Date());
            baseDoctorDO.setIdCardType(idCardType);
            baseDoctorDO.setIdType(idType);
            baseDoctorDO.setPhoto(photo);
            baseDoctorDO.setMobile(mobile);
            baseDoctorDO.setChargeType("1");
            if (StringUtils.isNotBlank(mobile)) {
                baseDoctorDO.setSalt(PwdUtil.randomString(5));
                try {
                    baseDoctorDO.setPassword(com.yihu.utils.security.MD5.md5Hex(baseDoctorDO.getMobile().substring(baseDoctorDO.getMobile().length() - 6) + "{" + baseDoctorDO.getSalt() + "}"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                baseDoctorDO.setPassword(com.yihu.utils.security.MD5.md5Hex("123456" + "{" + baseDoctorDO.getSalt() + "}"));
            }
            // 用医生和机构id、部门判断数据是否存在,若不存在则保存医生机构关联关系
            String deptCode = dept;
            baseDoctorDO = baseDoctorDao.save(baseDoctorDO);
            List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorDO.getId());
            if (null != baseDoctorHospitalDOS && baseDoctorHospitalDOS.size() > 0) {
                baseDoctorHospitalDao.delete(baseDoctorHospitalDOS);
                BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
                baseDoctorHospitalDO.setOrgCode("350211A1002");
                baseDoctorHospitalDO.setOrgName("马銮湾医院");
                baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }else {
                BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
                baseDoctorHospitalDO.setOrgCode("350211A1002");
                baseDoctorHospitalDO.setOrgName("马銮湾医院");
                baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                baseDoctorHospitalDO.setDeptCode(deptCode);
                baseDoctorHospitalDO.setDeptName(deptName);
                baseDoctorHospitalDO.setDel("1");
                baseDoctorHospitalDO.setCreateTime(new Date());
                baseDoctorHospitalDao.save(baseDoctorHospitalDO);
            }
        }
        return baseDoctorDO;
    }
    /**
     *
     * @param dept
     * @param level 1院级管理员,2科室管理员
     * @param doctorId
     * @return
     */
    public JSONObject selectHealthByRole(String dept,int level,String doctorId){
        String nowDate = DateUtil.getStringDateShort();
        //今日本人提交
        String benrenSql = "select count(1) as total from base_doctor_health_upload where consumer='"+doctorId+"' and consumer in(doctor_id) and  create_time >='"+nowDate+" 00:00:00' and create_time<='"+nowDate+" 23:59:59'";
        //今日提交
        String personSql = "select count(1) as total from base_doctor_health_upload where consumer='"+doctorId+"' and  create_time >='"+nowDate+" 00:00:00' and create_time<='"+nowDate+" 23:59:59'";
        //代上报
        String daishangbaoSql = "select count(1) as total from base_doctor_health_upload where consumer='"+doctorId+"' and consumer not in(doctor_id)";
        //本人上报
        String benrenshangbaoSql = "select count(1) as total from base_doctor_health_upload where consumer='"+doctorId+"' and consumer in(doctor_id)";
        String doctorSql ="";
        String sql = "";
        if (level==1){
            //总人次
            doctorSql =" select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
            //今日上报人次
            sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and d.create_time >='"+nowDate+" 00:00:00' and d.create_time<='"+nowDate+" 23:59:59'";
        }else if (level==2){
            //总人次
           doctorSql =" select COUNT(1) as \"total\" from base_doctor d where d.del=1 and id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+dept+"' and dh.del=1 )";
            //今日上报人次
            sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+dept+"' and dh.del=1 ) and d.create_time >='"+nowDate+" 00:00:00' and d.create_time<='"+nowDate+" 23:59:59'";
        }
        //今日提交
        int personTotal = 0;
        //代上报
        int daishangbaoTotal = 0;
        //本人上报
        int benrenshangbaoTotal = 0;
        //总人次
        int doctorTotal = 0;
        //今日上报人次
        int sqlTotal = 0;
        //今日未上报人次
        int notUploadTotal = 0;
        Map<String,Object> personMap = jdbcTemplate.queryForMap(personSql);
        if (personMap!=null){
            if (personMap.get("total")!=null){
                personTotal = Integer.parseInt(personMap.get("total").toString());
            }
        }
        Map<String,Object> daishangbaoMap = jdbcTemplate.queryForMap(daishangbaoSql);
        if (daishangbaoMap!=null){
            if (daishangbaoMap.get("total")!=null){
                daishangbaoTotal = Integer.parseInt(daishangbaoMap.get("total").toString());
            }
        }
        Map<String,Object> benrenshangbaoMap = jdbcTemplate.queryForMap(benrenshangbaoSql);
        if (benrenshangbaoMap!=null){
            if (benrenshangbaoMap.get("total")!=null){
                benrenshangbaoTotal = Integer.parseInt(benrenshangbaoMap.get("total").toString());
            }
        }
        Map<String,Object> doctorMap = jdbcTemplate.queryForMap(doctorSql);
        if (doctorMap!=null){
            if (doctorMap.get("total")!=null){
                doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
            }
        }
        Map<String,Object> sqlMap = jdbcTemplate.queryForMap(sql);
        if (sqlMap!=null){
            if (sqlMap.get("total")!=null){
                sqlTotal = Integer.parseInt(sqlMap.get("total").toString());
            }
        }
        int benrenTotal=0;
        Map<String,Object> benrenMap = jdbcTemplate.queryForMap(benrenSql);
        if (benrenMap!=null){
            if (benrenMap.get("total")!=null){
                benrenTotal = Integer.parseInt(benrenMap.get("total").toString());
            }
        }
        JSONObject object = new JSONObject();
        object.put("personTotal",personTotal);//今日上报人数
        object.put("daishangbaoTotal",daishangbaoTotal);//代上报
        object.put("benrenshangbaoTotal",benrenshangbaoTotal);//已上报
        object.put("doctorTotal",doctorTotal);//总人次
        object.put("sqlTotal",sqlTotal);//今日上报人数
        object.put("notUploadTotal",doctorTotal-sqlTotal);//今日未上报人数
        object.put("benrenTotal",benrenTotal);//今日本人提交
        return object;
    }
    /**
     * 首页统计
     *
     * @param dept
     * @param idType
     * @param status 上报状态
     * @param state 健康状态
     * @param startDate
     * @param endDate
     * @return
     */
    public JSONObject selectHeaderTotal(String dept,String idType,String status,String state,String startDate,String endDate,String name){
        JSONObject object =new JSONObject();
        String day = DateUtil.getTwoDay(endDate,startDate);
        String doctorSql =" select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
        Integer total = 0;//总人次
        String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 ";
        String deptCondition = "";
        if (StringUtils.isNoneBlank(dept)){
            deptCondition +=" (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+dept+"' and dh.del=1 )";
        }
        String idTypeCondition = " ";
        if (StringUtils.isNoneBlank(idType)){
            idTypeCondition +="  (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '"+idType+"')";
        }
        if (StringUtils.isNoneBlank(deptCondition)){
            doctorSql+=" and d.id IN "+deptCondition;
        }
        if (StringUtils.isNoneBlank(idTypeCondition)){
            doctorSql+=" and d.id IN "+idTypeCondition ;
        }
        if (StringUtils.isNoneBlank(name)){
            doctorSql+=" and d.name like '%"+name+"%' " ;
        }
        Map<String,Object> map = jdbcTemplate.queryForMap(doctorSql);
        String doctorTotal = "";
        if (map!=null){
             doctorTotal = map.get("total").toString();
        }
        if (StringUtils.isNoneBlank(doctorTotal)){
            //总人次
            if (!day.equalsIgnoreCase("0")){
                total = Integer.parseInt(doctorTotal)*Integer.parseInt(day);
            }else {
                total= Integer.parseInt(doctorTotal);
            }
        }
        Integer yishangbaoTotal = 0;
        Integer weishangbaoTotal =0;
        Integer zhengchangTotal = 0;
        Integer yichangTotal = 0;
        if (StringUtils.isNoneBlank(startDate)){
            sql +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
        }
        if (StringUtils.isNoneBlank(state)){
            if (state.equalsIgnoreCase("1")){
                sql +=" and (d.health_code not in(2,3) and CAST(d.temperature as DECIMAL)<37.3 and  d.is_symptoms=2 and d.is_epidemic=2) ";
            }else if (state.equalsIgnoreCase("2")){
                sql +=" and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1) ";
            }
        }
        if (StringUtils.isNoneBlank(deptCondition)){
            sql+=" and d.doctor_id IN "+deptCondition;
        }
        if (StringUtils.isNoneBlank(idTypeCondition)){
            sql+=" and d.doctor_id IN "+idTypeCondition ;
        }
        if (StringUtils.isNoneBlank(name)){
            sql+=" and d.doctor_name like '%"+name+"%'" ;
        }
        //已上传
        Map<String,Object> yishangchaungMap = jdbcTemplate.queryForMap(sql);
        if (yishangchaungMap!=null){
            if (yishangchaungMap.get("total")!=null){
                yishangbaoTotal = Integer.parseInt(yishangchaungMap.get("total").toString());
            }
        }
        //未上报
        weishangbaoTotal=total-yishangbaoTotal;
        //上传总次数
        Integer shangchuanTotal= 0;
        String shangchuanTotalSql = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1  ";
        if (StringUtils.isNoneBlank(startDate)){
            shangchuanTotalSql +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
        }
        if (StringUtils.isNoneBlank(deptCondition)){
            shangchuanTotalSql +=" and d.doctor_id IN "+deptCondition;
        }
        if (StringUtils.isNoneBlank(idTypeCondition)){
            shangchuanTotalSql +=" and d.doctor_id IN "+idTypeCondition ;
        }
        if (StringUtils.isNoneBlank(name)){
            shangchuanTotalSql+=" and d.doctor_name like '%"+name+"%'" ;
        }
        Map<String,Object> shangchuanMap = jdbcTemplate.queryForMap(shangchuanTotalSql);
        if (shangchuanMap!=null){
            if (shangchuanMap.get("total")!=null){
                shangchuanTotal = Integer.parseInt(shangchuanMap.get("total").toString());
            }
        }
        //正常、异常
        String sqlZhengchang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code not in(2,3) AND CAST(d.temperature as DECIMAL)<37.3 AND  d.is_symptoms=2 and  d.is_epidemic=2) ";
        if (StringUtils.isNoneBlank(startDate)){
            sqlZhengchang +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
        }
        if (StringUtils.isNoneBlank(deptCondition)){
            sqlZhengchang +=" and d.doctor_id IN "+deptCondition;
        }
        if (StringUtils.isNoneBlank(idTypeCondition)){
            sqlZhengchang +=" and d.doctor_id IN "+idTypeCondition ;
        }
        if (StringUtils.isNoneBlank(name)){
            sqlZhengchang+=" and d.doctor_name like '%"+name+"%'" ;
        }
        //正常
        Map<String,Object> zhengchangMap = jdbcTemplate.queryForMap(sqlZhengchang);
        if (zhengchangMap!=null){
            if (zhengchangMap.get("total")!=null){
                zhengchangTotal = Integer.parseInt(zhengchangMap.get("total").toString());
            }
        }
        String sqlYichang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1)  ";
        if (StringUtils.isNoneBlank(startDate)){
            sqlYichang +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
        }
        if (StringUtils.isNoneBlank(deptCondition)){
            sqlYichang +=" and d.doctor_id IN "+deptCondition;
        }
        if (StringUtils.isNoneBlank(idTypeCondition)){
            sqlYichang +=" and d.doctor_id IN "+idTypeCondition ;
        }
        if (StringUtils.isNoneBlank(name)){
            sqlYichang+=" and d.doctor_name like '%"+name+"%'" ;
        }
        //正常
        Map<String,Object> yichangMap = jdbcTemplate.queryForMap(sqlYichang);
        if (yichangMap!=null){
            if (yichangMap.get("total")!=null){
                yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
            }
        }
        object.put("total",total);//总人次
        object.put("yishangbaoTotal",yishangbaoTotal);//已上报
        object.put("weishangbaoTotal",weishangbaoTotal);//未上报
        object.put("zhengchangTotal",zhengchangTotal);//上报正常
        object.put("yichangTotal",yichangTotal);//上报异常
        object.put("shangchuanTotal",shangchuanTotal);//上传总次数
        return object;
    }
    /**
     * 首页按照科室列表统计
     *
     * @param dept
     * @param idType
     * @param status 上报状态
     * @param state 健康状态
     * @param startDate
     * @param endDate
     * @return
     */
    public List<Map<String,Object>> selectHeaderList(String dept,String idType,String status,String state,String startDate,String endDate,String name){
        String deptSql = " select code,name from dict_hospital_dept hd where hd.consult_dept_flag=1 ";
        if (StringUtils.isNoneBlank(name)){
            deptSql += " and hd.code IN(SELECT dha.dept_code FROM base_doctor_hospital dha LEFT JOIN base_doctor da ON da.id=dha.doctor_code where da.name LIKE '%"+name+"%') ";
        }
        if (StringUtils.isNoneBlank(dept)){
            deptSql +=" and hd.code = '"+dept+"' ";
        }
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(deptSql);
        for (Map<String,Object> deptmap:mapList){
            String deptCode = deptmap.get("code").toString();
            JSONObject object =new JSONObject();
            String day = DateUtil.getTwoDay(endDate,startDate);
            String doctorSql =" select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
            Integer total = 0;//总人次
            String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 ";
            String deptCondition = "";
            if (StringUtils.isNoneBlank(deptCode)){
                deptCondition +=" (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+deptCode+"' and dh.del=1 )";
            }
            String idTypeCondition = " ";
            if (StringUtils.isNoneBlank(idType)){
                idTypeCondition +="  (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '"+idType+"')";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                doctorSql+=" and d.id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                doctorSql+=" and d.id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                doctorSql+=" and d.name like '%"+name+"%' " ;
            }
            Map<String,Object> map = jdbcTemplate.queryForMap(doctorSql);
            String doctorTotal = "";
            if (map!=null){
                doctorTotal = map.get("total").toString();
            }
            if (StringUtils.isNoneBlank(doctorTotal)){
                //总人次
                if (!day.equalsIgnoreCase("0")){
                    total = Integer.parseInt(doctorTotal)*Integer.parseInt(day);
                }else {
                    total= Integer.parseInt(doctorTotal);
                }
            }
            Integer yishangbaoTotal = 0;
            Integer weishangbaoTotal =0;
            Integer zhengchangTotal = 0;
            Integer yichangTotal = 0;
            if (StringUtils.isNoneBlank(startDate)){
                sql +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(state)){
                if (state.equalsIgnoreCase("1")){
                    sql +=" and (d.health_code not in(2,3) and CAST(d.temperature as DECIMAL)<37.3 and  d.is_symptoms=2 and d.is_epidemic=2) ";
                }else if (state.equalsIgnoreCase("2")){
                    sql +=" and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1) ";
                }
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                sql+=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                sql+=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                sql+=" and d.doctor_name like '%"+name+"%'" ;
            }
            //已上传
            Map<String,Object> yishangchaungMap = jdbcTemplate.queryForMap(sql);
            if (yishangchaungMap!=null){
                if (yishangchaungMap.get("total")!=null){
                    yishangbaoTotal = Integer.parseInt(yishangchaungMap.get("total").toString());
                }
            }
            //未上报
            weishangbaoTotal=total-yishangbaoTotal;
            //上传总次数
            Integer shangchuanTotal= 0;
            String shangchuanTotalSql = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1  ";
            if (StringUtils.isNoneBlank(startDate)){
                shangchuanTotalSql +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                shangchuanTotalSql +=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                shangchuanTotalSql +=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                shangchuanTotalSql+=" and d.doctor_name like '%"+name+"%'" ;
            }
            Map<String,Object> shangchuanMap = jdbcTemplate.queryForMap(shangchuanTotalSql);
            if (shangchuanMap!=null){
                if (shangchuanMap.get("total")!=null){
                    shangchuanTotal = Integer.parseInt(shangchuanMap.get("total").toString());
                }
            }
            //正常、异常
            String sqlZhengchang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code not in(2,3) AND CAST(d.temperature as DECIMAL)<37.3 AND  d.is_symptoms=2 and  d.is_epidemic=2) ";
            if (StringUtils.isNoneBlank(startDate)){
                sqlZhengchang +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                sqlZhengchang +=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                sqlZhengchang +=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                sqlZhengchang+=" and d.doctor_name like '%"+name+"%'" ;
            }
            //正常
            Map<String,Object> zhengchangMap = jdbcTemplate.queryForMap(sqlZhengchang);
            if (zhengchangMap!=null){
                if (zhengchangMap.get("total")!=null){
                    zhengchangTotal = Integer.parseInt(zhengchangMap.get("total").toString());
                }
            }
            String sqlYichang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1)  ";
            if (StringUtils.isNoneBlank(startDate)){
                sqlYichang +=" and d.create_time >='"+startDate+" 00:00:00' and d.create_time<='"+endDate+" 23:59:59' ";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                sqlYichang +=" and d.doctor_id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                sqlYichang +=" and d.doctor_id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(name)){
                sqlYichang+=" and d.doctor_name like '%"+name+"%'" ;
            }
            //正常
            Map<String,Object> yichangMap = jdbcTemplate.queryForMap(sqlYichang);
            if (yichangMap!=null){
                if (yichangMap.get("total")!=null){
                    yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
                }
            }
            object.put("total",total);//总人次
            object.put("yishangbaoTotal",yishangbaoTotal);//已上报
            object.put("weishangbaoTotal",weishangbaoTotal);//未上报
            object.put("zhengchangTotal",zhengchangTotal);//上报正常
            object.put("yichangTotal",yichangTotal);//上报异常
            object.put("shangchuanTotal",shangchuanTotal);//上传总次数
            deptmap.put("tongyishuju",object);
        }
        return mapList;
    }
    /**
     * 具体每一个统计时间列表
     *
     * @param dept
     * @param idType
     * @param status
     * @param state
     * @param startDate
     * @param endDate
     * @return
     */
    public JSONArray selectListByTotal(String dept,String idType,String status,String state,String startDate,String endDate,String name){
        long days = DateUtil.getDays(endDate,startDate);
        List<String> list = new ArrayList<>();
        Date startTime = DateUtil.strToDateShort(startDate);
        for (int i=0;i<=days;i++){
            Date date = DateUtil.getPreDays(startTime,i);
            String str = DateUtil.dateToStrShort(date);
            list.add(str);
        }
        JSONArray array = new JSONArray();
        for (int i=0;i<list.size();i++){
            String date = list.get(i);
            String doctorSql =" select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
            String deptCondition = "";
            if (StringUtils.isNoneBlank(dept)){
                deptCondition +=" (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+dept+"' and dh.del=1 )";
            }
            String idTypeCondition = " ";
            if (StringUtils.isNoneBlank(idType)){
                idTypeCondition +="  (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '"+idType+"')";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                doctorSql+=" and d.id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                doctorSql+=" and d.id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(status)){
                if (status.equalsIgnoreCase("1")){
                    doctorSql +=" and d.id in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' )";
                }else if (status.equalsIgnoreCase("2")){
                    doctorSql +=" and d.id not in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' )";
                }
            }
            if (StringUtils.isNoneBlank(state)){
                if (state.equalsIgnoreCase("1")){
                    doctorSql +=" and d.id in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' and (d1.health_code not in(2,3) and CAST(d1.temperature as DECIMAL)<37.3 and  d1.is_symptoms=2 and d1.is_epidemic=2))  ";
                }else if (state.equalsIgnoreCase("2")){
                    doctorSql +=" and d.id in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' and (d1.health_code in(2,3) OR CAST(d1.temperature as DECIMAL)>=37.3 OR  d1.is_symptoms=1 OR d1.is_epidemic=1)) ";
                }
            }
            if (StringUtils.isNoneBlank(name)){
                doctorSql +=" and d.name LIKE  '%"+name+"%' ";
            }
            Map<String,Object> map = jdbcTemplate.queryForMap(doctorSql);
            Integer total = 0;
            if (map!=null){
                if (map.get("total")!=null){
                    total = Integer.parseInt(map.get("total").toString());
                }
            }
            JSONObject object = new JSONObject();
            object.put("time",date);
            object.put("total",total);
            array.add(object);
        }
        return array;
    }
    /**
     * 具体每一个统计时间的详情
     *
     * @param dept
     * @param idType
     * @param status
     * @param state
     * @param startDate
     * @param endDate
     * @param name total
     * @return
     */
    public JSONArray selectListInfoByTotal(String dept,String idType,String status,String state,String startDate,String endDate,String name){
        long days = DateUtil.getDays(endDate,startDate);
        List<String> list = new ArrayList<>();
        Date startTime = DateUtil.strToDateShort(startDate);
        for (int i=0;i<=days;i++){
            Date date = DateUtil.getPreDays(startTime,i);
            String str = DateUtil.dateToStrShort(date);
            list.add(str);
        }
        JSONArray array = new JSONArray();
        for (int i=0;i<list.size();i++){
            String date = list.get(i);
            String doctorSql =" select d.name,d.id,d.job_title_name as jobTitleName,d.photo from base_doctor d where d.del=1 ";
            String deptCondition = "";
            if (StringUtils.isNoneBlank(dept)){
                deptCondition +=" (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '"+dept+"' and dh.del=1 )";
            }
            String idTypeCondition = " ";
            if (StringUtils.isNoneBlank(idType)){
                idTypeCondition +="  (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '"+idType+"')";
            }
            if (StringUtils.isNoneBlank(deptCondition)){
                doctorSql+=" and d.id IN "+deptCondition;
            }
            if (StringUtils.isNoneBlank(idTypeCondition)){
                doctorSql+=" and d.id IN "+idTypeCondition ;
            }
            if (StringUtils.isNoneBlank(status)){
                if (status.equalsIgnoreCase("1")){
                    doctorSql +=" and d.id in (select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59')";
                }else if (status.equalsIgnoreCase("2")){
                    doctorSql +=" and d.id not in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59')";
                }
            }
            if (StringUtils.isNoneBlank(state)){
                if (state.equalsIgnoreCase("1")){
                    doctorSql +=" and d.id in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' and (d1.health_code not in(2,3) and CAST(d1.temperature as DECIMAL)<37.3 and  d1.is_symptoms=2 and d1.is_epidemic=2) )  ";
                }else if (state.equalsIgnoreCase("2")){
                    doctorSql +=" and d.id in(select d1.doctor_id from base_doctor_health_upload d1 where 1=1 and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' and (d1.health_code in(2,3) OR CAST(d1.temperature as DECIMAL)>=37.3 OR  d1.is_symptoms=1 OR d1.is_epidemic=1)) ";
                }
            }
            if (StringUtils.isNoneBlank(name)){
                doctorSql +=" and d.NAME  LIKE '%"+name+"%'";
            }
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(doctorSql);
            for (Map<String,Object> map:mapList){
                String id = map.get("id").toString();
                List<BaseDoctorHospitalDO> hospitalDOList = baseDoctorHospitalDao.findByDoctorCode(id);
                map.put("deptInfo",hospitalDOList);
                String stateCondition = "";
                if (StringUtils.isNoneBlank(state)){
                    if (state.equalsIgnoreCase("1")){
                        stateCondition +=" and (d1.health_code not in(2,3) and CAST(d1.temperature as DECIMAL)<37.3 and  d1.is_symptoms=2 and d1.is_epidemic=2)  ";
                    }else if (state.equalsIgnoreCase("2")){
                        stateCondition +=" and (d1.health_code in(2,3) OR CAST(d1.temperature as DECIMAL)>=37.3 OR  d1.is_symptoms=1 OR d1.is_epidemic=1) ";
                    }
                }
                String sql = "select d1.health_code,d1.temperature,d1.is_symptoms as isSymptoms,d1.is_epidemic as isEpidemic,d1.id,d1.consumer,d1.consumer_name as consumerName,date_format(d1.create_time ,'%Y-%m-%d %H:%i:%S' ) AS createTime from base_doctor_health_upload d1 where 1=1 "+stateCondition+" and d1.create_time >='"+date+" 00:00:00' and d1.create_time<='"+date+" 23:59:59' and d1.doctor_id = '"+id+"' order by d1.create_time desc ";
                List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sql);
                if (mapList1!=null&&mapList1.size()!=0){
                    for (Map<String,Object> map1:mapList1){
                        String healthCode = map1.get("health_code").toString();
                        Double temperature = Double.parseDouble(map1.get("temperature").toString());
                        String isSymptoms = map1.get("isSymptoms").toString();
                        String isEpidemic = map1.get("isEpidemic").toString();
                        if (healthCode.equalsIgnoreCase("2")||healthCode.equalsIgnoreCase("3")||
                                temperature>=37.3||isSymptoms.equalsIgnoreCase("1")||isEpidemic.equalsIgnoreCase("1")){
                            map1.put("healthState","异常");
                        }else {
                            map1.put("healthState","正常");
                        }
                        map.put("uploadState","已上报");
                        map.put("uploadId",map1.get("id").toString());
                    }
                    map.put("recordList",mapList1);
                }else {
                    map.put("healthState","未知");
                    map.put("uploadState","未上报");
                    map.put("uploadId","");
                    map.put("consumer","");
                    map.put("consumerName","");
                    map.put("createTime","");
                    map.put("recordList",mapList1);
                }
            }
            JSONObject object = new JSONObject();
            object.put("time",date);
            object.put("list",mapList);
            array.add(object);
        }
        return array;
    }
    /**
     * 报表导出
     *
     * @param startDate
     * @param endDate
     * @return
     */
    public JSONArray selectListInfoExcelByTotal(OutputStream os,String startDate,String endDate) throws Exception {
        long days = DateUtil.getDays(endDate,startDate);
        List<String> list = new ArrayList<>();
        Date startTime = DateUtil.strToDateShort(startDate);
        for (int i=0;i<=days;i++){
            Date date = DateUtil.getPreDays(startTime,i);
            String str = DateUtil.dateToStrShort(date);
            list.add(str);
        }
        JSONArray array = new JSONArray();
        for (int i=0;i<list.size();i++){
            String date = list.get(i);
            String doctorSql ="SELECT\n" +
                    "\td.idcard as idcard,\n" +
                    "\td.name as name,\n" +
                    "\td.mobile as mobile,\n" +
                    "\td.id_type as idType,\n" +
                    "\td.id as id,\n" +
                    "\tdhu.province_name as provinceName,\n" +
                    "\tdhu.city_name as cityName,\n" +
                    "\tdhu.town_name as townName,\n" +
                    "\tdhu.street_name as streetName,\n" +
                    "\tdhu.address as address,\n" +
                    "\tdhu.temperature as temperature,\n" +
                    "\tdhu.health_code as healthCode,\n" +
                    "\tdhu.tour_code as tourCode,\n" +
                    "\tdhu.is_symptoms as isSymtoms,\n" +
                    "\tdhu.is_epidemic as isEpidemic,\n" +
                    "\tdhu.is_outside as isOutside,\n" +
                    "\tdhu.is_nucleate as isNucleate,\n" +
                    "\tdhu.is_outside_high as isOutsideHigh, \n" +
                    "date_format(dhu.create_time ,'%Y-%m-%d %H:%i:%S' ) AS createTime "+
                    " FROM\n" +
                    "\tbase_doctor d\n" +
                    "LEFT JOIN /* (SELECT * FROM base_doctor_health_upload dhu1*/ base_doctor_health_upload dhu ON dhu.doctor_id = d.id WHERE dhu.create_time >= '"+date+" 00:00:00' AND dhu.create_time <= '"+date+" 23:59:59'   ";
            List<Map<String,Object>> mapList = jdbcTemplate.queryForList(doctorSql);
            for (Map<String,Object> map:mapList){
                String id = map.get("id").toString();
                List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(id);
                if (baseDoctorHospitalDOS!=null&&baseDoctorHospitalDOS.size()!=0){
                    map.put("deptName",baseDoctorHospitalDOS.get(0).getDeptName());
                }
            }
            JSONObject object = new JSONObject();
            object.put("time",date);
            object.put("list",mapList);
            array.add(object);
        }
        pushListWritePriceTotal(os,array,startDate,endDate);
        return array;
    }
    /**
     *
     * mergeCells(a,b,c,d)
     * a 单元格的列号
     b 单元格的行号
     c 从单元格[a,b]起,向左合并到c列
     d 从单元格[a,b]起,向下合并到d行
     * 收入日报导出
     * @param os
     * @param ls
     * @param startTime
     * @param endTime
     * @throws Exception
     */
    public void pushListWritePriceTotal(OutputStream os,JSONArray ls,String startTime, String endTime) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
        for (int i=0;i<ls.size();i++){
            JSONObject jsonObject = ls.getJSONObject(i);
            String time = jsonObject.getString("time");
            WritableSheet ws;
            ws = wwb.createSheet(time, i+1);
            String[] header = {"互联网综合服务平台健康上报情况","","","","","","","","","","","","","",""};//
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            String[] header2 = {"科室","姓名","电话","身份类别","上报状态","所在地","体温","健康码","行程码","异常症状","涉疫人员","14天内从外地返","核酸检测","14天内有同往人从中高风险返厦","健康状态","上报时间"};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 1, k2, h);//表名,行,列,header
                k2++;
            }
            int j= 1;
            JSONArray array = jsonObject.getJSONArray("list");
            for (int z=0;z<array.size();z++){
                j=j+1;
                JSONObject object = array.getJSONObject(z);
                addCell(ws, j, 0, object.getString("deptName"));//表名,行,列,header
                addCell(ws, j, 1, object.getString("name"));//表名,行,列,header
                addCell(ws, j, 2, object.getString("mobile"));//表名,行,列,header
                if (StringUtils.isNoneBlank(object.getString("idType"))){
                    addCell(ws, j, 3, object.getString("idType"));//表名,行,列,header
                }else {
                    addCell(ws, j, 3, "");//表名,行,列,header
                }
                if (StringUtils.isNoneBlank(object.getString("temperature"))){
                    String address = "";
                    if ( StringUtils.isNoneBlank(object.getString("provinceName"))){
                        address +=object.getString("provinceName");
                    }
                    if ( StringUtils.isNoneBlank(object.getString("cityName"))){
                        address +=object.getString("cityName");
                    }
                    if ( StringUtils.isNoneBlank(object.getString("townName"))){
                        address +=object.getString("townName");
                    }
                    addCell(ws, j, 4, "已上报");//表名,行,列,header
                    addCell(ws, j, 5,address);//表名,行,列,header
                    addCell(ws, j, 6, object.getString("temperature"));//表名,行,列,header
                    String healthCodeName="";
                    String healthStateName= "";
                    if (object.getString("healthCode").equalsIgnoreCase("1")){
                        healthCodeName="绿码";
                    }else if (object.getString("healthCode").equalsIgnoreCase("2")){
                        healthCodeName="红码";
                    }else if (object.getString("healthCode").equalsIgnoreCase("3")){
                        healthCodeName="黄码";
                    }
                    if (object.getString("healthCode").equalsIgnoreCase("2")||object.getString("healthCode").equalsIgnoreCase("3")||
                            object.getDouble("temperature")>=37.3||object.getString("isSymtoms").equalsIgnoreCase("1")||object.getString("isEpidemic").equalsIgnoreCase("1")){
                        healthStateName="异常";
                    }else {
                        healthStateName="正常";
                    }
                    String tourCodeName = "";
                    if (object.getString("tourCode").equalsIgnoreCase("1")){
                        tourCodeName="带星";
                    }else if (object.getString("tourCode").equalsIgnoreCase("2")){
                        tourCodeName="不带星";
                    }
                    String isSymtomsName="";
                    if (object.getString("isSymtoms").equalsIgnoreCase("1")){
                        isSymtomsName="是";
                    }else if (object.getString("isSymtoms").equalsIgnoreCase("2")){
                        isSymtomsName="否";
                    }
                    String isEpidemicName="";
                    if (object.getString("isEpidemic").equalsIgnoreCase("1")){
                        isEpidemicName="是";
                    }else if (object.getString("isEpidemic").equalsIgnoreCase("2")){
                        isEpidemicName="否";
                    }
                    String isOutsideName="";
                    if (object.getString("isOutside").equalsIgnoreCase("1")){
                        isOutsideName="是";
                    }else if (object.getString("isOutside").equalsIgnoreCase("2")){
                        isOutsideName="否";
                    }
                    String isNucleateName="";
                    if (object.getString("isNucleate").equalsIgnoreCase("1")){
                        isNucleateName="未做";
                    }else if (object.getString("isNucleate").equalsIgnoreCase("2")){
                        isNucleateName="已做(院内)";
                    }else if (object.getString("isNucleate").equalsIgnoreCase("3")){
                        isNucleateName="已做(院外)";
                    }
                    String isOutsideHighName="";
                    if (object.getString("isOutsideHigh").equalsIgnoreCase("1")){
                        isOutsideHighName="是";
                    }else if (object.getString("isOutsideHigh").equalsIgnoreCase("2")){
                        isOutsideHighName="否";
                    }
                    String createTime= "";
                    if (object.get("createTime")!=null){
                        createTime = object.getString("createTime");
                    }
                    addCell(ws, j, 7, healthCodeName);//表名,行,列,header
                    addCell(ws, j, 8, tourCodeName);//表名,行,列,header
                    addCell(ws, j, 9, isSymtomsName);//表名,行,列,header
                    addCell(ws, j, 10, isEpidemicName);//表名,行,列,header
                    addCell(ws, j, 11, isOutsideName);//表名,行,列,header
                    addCell(ws, j, 12, isNucleateName);//表名,行,列,header
                    addCell(ws, j, 13, isOutsideHighName);//表名,行,列,header
                    addCell(ws, j, 14, healthStateName);//表名,行,列,header
                    addCell(ws, j, 15, createTime);//表名,行,列,header
                }else {
                    addCell(ws, j, 4, "未上报");//表名,行,列,header
                    addCell(ws, j, 5, "");//表名,行,列,header
                    addCell(ws, j, 6, "");//表名,行,列,header
                    addCell(ws, j, 7, "");//表名,行,列,header
                    addCell(ws, j, 8, "");//表名,行,列,header
                    addCell(ws, j, 9, "");//表名,行,列,header
                    addCell(ws, j, 10, "");//表名,行,列,header
                    addCell(ws, j, 11, "");//表名,行,列,header
                    addCell(ws, j, 12, "");//表名,行,列,header
                    addCell(ws, j, 13, "");//表名,行,列,header
                    addCell(ws, j, 14, "");//表名,行,列,header
                    addCell(ws, j, 15, "");//表名,行,列,header
                }
            }
            ws.mergeCells(0,0,15,0);
        }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
        Label label = new Label(column, row, data);
        WritableCellFormat cellFormat = new WritableCellFormat();
        cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
        cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        ws.addCell(label);
    }
    /**
     * 查下最新一次记录
     * @param doctorId
     * @param consumer
     * @return
     */
    public BaseDoctorHealthUploadDO selectRecordByDoctorIdAndConsumer(String doctorId,String consumer){
        BaseDoctorHealthUploadDO baseDoctorHealthUploadDO = null;
        List<BaseDoctorHealthUploadDO> doctorHealthUploadDOList = baseDoctorHealthUploadDao.findByDoctorIdAndConsumer(doctorId,consumer);
        if (doctorHealthUploadDOList!=null&&doctorHealthUploadDOList.size()!=0){
            baseDoctorHealthUploadDO = doctorHealthUploadDOList.get(0);
        }
        return baseDoctorHealthUploadDO;
    }
}

+ 8 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/healthCare/YlzMedicailRelationDao.java

@ -15,9 +15,15 @@ import java.util.List;
 */
public interface YlzMedicailRelationDao extends PagingAndSortingRepository<YlzMedicalRelationDO, String>, JpaSpecificationExecutor<YlzMedicalRelationDO> {
    @Query("from YlzMedicalRelationDO a where a.relationCode = ?1 ")
    YlzMedicalRelationDO findByOutpatient(String relationCode);
    @Query("from YlzMedicalRelationDO a where   a.relationCode = ?1 and a.state=0 ")
    YlzMedicalRelationDO findByOutpatient(String outpatientId);
    @Query("from YlzMedicalRelationDO a where   a.relationCode = ?1 and a.state=1 ")
    List<YlzMedicalRelationDO> findByOutpatientStatus(String outpatientId);
    @Query("from YlzMedicalRelationDO a where a.logNo = ?1 ")
    YlzMedicalRelationDO findByLog_no(String logNo);
    @Query("from YlzMedicalRelationDO a where a.insuranceSerial = ?1 ")
    YlzMedicalRelationDO findByInsuranceSerial(String insuranceSerial);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java

@ -86,7 +86,7 @@ public class PatientMappingService {
            return patient;
        }
        logger.info("patientDO:"+patientDO.toString());
        PatientMappingDO patientMappingDO = patientMappingDao.findByIdcardAndSource(patientDO.getIdcard(),"1");
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        if(patientMappingDO!=null){
            return patientMappingDO.getMappingCode();

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java

@ -60,6 +60,8 @@ public interface PrescriptionDao extends PagingAndSortingRepository<WlyyPrescrip
    @Query("select a from WlyyPrescriptionDO a where a.outpatientId = ?1 and a.status>=20 and a.status<30 ")
    List<WlyyPrescriptionDO> findByOutPatientIdList(String outpatientId);
    @Query("select a from WlyyPrescriptionDO a where a.realOrder = ?1 and a.status>=20 and a.status<30 ")
    List<WlyyPrescriptionDO> findByRealOrderAndStatusList(String realOrder);
    List<WlyyPrescriptionDO> findByDoctorAndCreateTimeAndRemark(String doctor,Date createTime,String remark);
    @Query("select a from WlyyPrescriptionDO a where a.createTime>?1 and  a.createTime <?2 and a.status <30 and a.status>=0")

+ 17 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PayInfoNoticeService.java

@ -53,6 +53,23 @@ public class PayInfoNoticeService {
        return null;
    }
    public String pushPrescriptionPayMedicare(String patient,String doctorName,String orderNo,String outpatientId,String prescriptionId,String total,String mipay,String selfPay,String title,String url){
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO!=null){
            String userName = patientDO.getName();
            String idcard = patientDO.getIdcard();
            String phone = patientDO.getMobile();
            if (!StringUtils.isNotBlank(url)){
                url = "https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+prescriptionId;
            }
            String remark = "结算方式:微信结算" +
                    "点击查看取药\n物流信息";
            return paySuccessNotice(userName,idcard,phone,title,url,doctorName,total,mipay,selfPay,orderNo,remark);
        }
        return null;
    }
    public String pushPrescriptionPayAndHsjc(String patient,String doctorName,String orderNo,String id,String total,String title,String url,String realOrder){
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO!=null){

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java

@ -599,6 +599,7 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatusByOutPatientId( 100,new Date(),sfexpress.getOutpatientId());
                prescriptionService.electronicPrescriptionReceiving(sfexpress.getOutpatientId());
                /*List<WlyyPrescriptionDO> wlyyPrescriptionDOs = prescriptionDao.findByOutpatientId(sfexpress.getOutpatientId());
                if (wlyyPrescriptionDOs.size()>0){
                    WlyyPrescriptionDO wlyyPrescriptionDO=wlyyPrescriptionDOs.get(0);

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

@ -41,6 +41,8 @@ import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorOnlineTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalIcdDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
@ -61,6 +63,8 @@ import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.doctor.dao.WlyyDoctorOnlineTimeDao;
import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao;
import com.yihu.jw.hospital.family.dao.WlyyNatPatientFamilyMemberDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailMxDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.httplog.service.BaseOperateLogService;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
@ -326,8 +330,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private HcyyPrescriptionService hcyyPrescriptionService;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private YlzMedicailMxDao ylzMedicailMxDao;
    @Autowired
    private WlyyNatPatientFamilyMemberDao natPatientFamilyMemberDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    public static String entranceUrl = "http://172.16.100.240:10023/xzzx/";
    public static String entranceHealthCareUrl = "http://127.0.0.1:10023/healthCare/";
@ -706,6 +715,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("doctorCancelType", outpatientDO.getDoctorCancelType());
        rs.put("doctorCancelValue", outpatientDO.getDoctorCancelValue());
        rs.put("doctorCancelRemark", outpatientDO.getDoctorCancelRemark());
        rs.put("medicalState",outpatientDO.getMedicalState());
        rs.put("payStatus", outpatientDO.getPayStatus());
        rs.put("patientCancelType", outpatientDO.getPatientCancelType());
        rs.put("patientCancelValue", outpatientDO.getPatientCancelValue());
@ -1584,7 +1594,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " h.dept_name AS \"deptName\","+
                " h.org_code AS \"orgCode\","+
                " h.org_name AS \"orgName\","+
                " t.photo AS \"hosptialphoto\""+
                " t.photo AS \"hosptialphoto\","+
                " d.id_type AS \"idType\","+
                " d.id_card_type AS \"idCardType\" "+
                " FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
@ -3537,7 +3549,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " e.id AS \"expressageId\" ,"+
                " p.real_order AS \"realOrder\" ,"+
                " p.origin_real_order AS \"originRealOrder\"," +
                " o.patient_name as \"patientName\" "+
                " o.patient_name as \"patientName\", "+
                " p.check_status as \"checkStatus\", "+
                " p.check_reason as \"checkReason\"  "+
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
@ -3783,7 +3797,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"序号","充值时间","商户订单号","医院订单号","患者姓名","证件号码","就诊卡号","手机号码","金额","状态","业务类型","咨询方式"};
            String[] header = {"序号","充值时间","商户订单号","医院订单号","患者姓名","证件号码","就诊卡号","手机号码","金额","状态","业务类型","咨询方式","代问诊人","问诊医生"};
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
@ -3873,12 +3887,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }else {
                    time = m.get("payTime").toString();
                }
                String consumerName = "";
                if (m.get("consumerName") == null){
                    consumerName = null;
                }else {
                    consumerName= m.get("consumerName").toString();
                }
                String doctorName ="";
                if (m.get("doctorName") == null){
                    doctorName = null;
                }else {
                    doctorName= m.get("doctorName").toString();
                }
                addCell(ws, i, 0, m.get("id")!=null?m.get("id").toString():n);
                addCell(ws, i, 1, time!=null?time:n);
                addCell(ws, i, 2, (String) m.get("orderNo")!=null?(String) m.get("orderNo"):n);
                addCell(ws, i, 3, (String) m.get("ykOrderNo")!=null?(String) m.get("ykOrderNo"):n);
                addCell(ws, i, 4, (String) m.get("patientName")!=null?(String) m.get("patientName"):n);
                addCell(ws, i, 4, consumerName!=null?consumerName:n);
                addCell(ws, i, 5, (String) m.get("idcard")!=null?(String) m.get("idcard"):n);
                addCell(ws, i, 6, (String) m.get("medicard")!=null?(String) m.get("medicard"):n);
                addCell(ws, i, 7, (String) m.get("mobile")!=null?(String) m.get("mobile"):n);
@ -3886,6 +3914,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                addCell(ws, i, 9, status!=null?status:n);
                addCell(ws, i, 10, odry!=null?odry:n);
                addCell(ws, i, 11, odte!=null?odte:n);
                addCell(ws, i, 12, (String) m.get("patientName")!=null?(String) m.get("patientName"):n);
                addCell(ws, i, 13, doctorName!=null?doctorName:n);
                i++;
            }
            wwb.write();
@ -4359,6 +4389,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            rs.put("popularity",doctorDO.getPopularity());
            rs.put("qrcode",doctorDO.getQrcode());
            rs.put("appletQrcode",doctorDO.getAppletQrCode());
            rs.put("idType",doctorDO.getIdType());
            rs.put("idCard",doctorDO.getIdcard());
            rs.put("idCardType",doctorDO.getIdCardType());
            List<Map<String,Object>> chargeDictDOLists = new ArrayList<>();
            String sqlCharge = "SELECT\n" +
                    "\tm.req_fee as \"twfzFee\",\n" +
@ -4431,7 +4464,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " base_doctor_role r " +
                    " JOIN base_doctor_role_dict t ON t.code = r.role_code " +
                    " WHERE " +
                    " r.doctor_code = '" + doctor + "'";
                    " r.doctor_code = '" + doctorDO.getId() + "'";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
            if (list != null && list.size() > 0) {
@ -4440,14 +4474,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                rs.put("roles", null);
            }
            //医生预约量
            List<WlyyPatientRegisterTimeDO> registerTimeDOs = patientRegisterTimeDao.findByDoctor(doctor);
            List<WlyyPatientRegisterTimeDO> registerTimeDOs = patientRegisterTimeDao.findByDoctor(doctorDO.getId());
            if (registerTimeDOs != null && registerTimeDOs.size() > 0) {
                rs.put("registerCount", registerTimeDOs.size());
            } else {
                rs.put("registerCount", 0);
            }
            //医生问诊量
            List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByDoctorList(doctor);
            List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByDoctorList(doctorDO.getId());
            if (wlyyOutpatientDOs != null && wlyyOutpatientDOs.size() > 0) {
                rs.put("outpatientCount", wlyyOutpatientDOs.size());
            } else {
@ -4459,7 +4493,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
//            rs.put("coordinationCout",coordinationCout);
            //医生关注
            if(StringUtils.isNotBlank(patient)){
                List<BaseDoctorPatientFollowDO> doctorPatientFollowDOS = baseOrgPatientDao.findByDoctorAndPatient(doctor,patient);
                List<BaseDoctorPatientFollowDO> doctorPatientFollowDOS = baseOrgPatientDao.findByDoctorAndPatient(doctorDO.getId(),patient);
                if (doctorPatientFollowDOS != null && doctorPatientFollowDOS.size() > 0) {
                    rs.put("attention", "1");
                } else {
@ -4480,7 +4514,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            //专家咨询
            String zjCountsql = "SELECT id AS \"id\" FROM wlyy_consult_team WHERE doctor='" + doctor + "' AND (type=1 OR type=15)";
            String zjCountsql = "SELECT id AS \"id\" FROM wlyy_consult_team WHERE doctor='" + doctorDO.getId() + "' AND (type=1 OR type=15)";
            List<Map<String, Object>> zjList = jdbcTemplate.queryForList(zjCountsql);
            if (zjList != null && zjList.size() > 0) {
                rs.put("zjCount", zjList.size());
@ -4495,7 +4529,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    "FROM base_evaluate a,base_evaluate_score b " +
                    "WHERE " +
                    "a.relation_code=b.id " +
                    "AND b.doctor='" + doctor + "' " +
                    "AND b.doctor='" + doctorDO.getId() + "' " +
                    "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
            List<Map<String, Object>> listscore = jdbcTemplate.queryForList(sqlscore);
@ -4514,7 +4548,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            } else {
                rs.put("scoreDoctor", null);
            }
            int count = baseBannerDoctorDao.getTotalBannerCount(doctor);
            int count = baseBannerDoctorDao.getTotalBannerCount(doctorDO.getId());
            rs.put("bannerCount",count);
            //查询评价明细
@ -4532,8 +4566,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    "FROM " +
                    "base_evaluate a " +
                    "LEFT JOIN base_evaluate_score b ON b.id=a.relation_code " +
                    "LEFT JOIN wlyy_consult_team c ON c.consult=b.relation_code AND c.doctor='" + doctor + "' " +
                    "WHERE a.relation_code=b.id AND b.doctor='" + doctor + "' order by b.create_time DESC ";
                    "LEFT JOIN wlyy_consult_team c ON c.consult=b.relation_code AND c.doctor='" + doctorDO.getId() + "' " +
                    "WHERE a.relation_code=b.id AND b.doctor='" + doctorDO.getId() + "' order by b.create_time DESC ";
            List<Map<String, Object>> scoreList = jdbcTemplate.queryForList(sqlScoreList);
            if (scoreList != null && scoreList.size() > 0) {
//                Set<String> datelist = new HashSet<>();
@ -6837,17 +6871,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            params.put("consultStatus", consultStatus);
        }
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if (flag){
                sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort+",dw.workTotal DESC";
            }else{
                sql += " and d.del='1' order by d.consult_status desc nulls last ,evaluate.score desc nulls last ,a.total " + consutlSort;
                sql+=" NULLS LAST,\n" +
                        "\tD.id DESC,dw.workTotal DESC NULLS LAST";
            }
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isSort");//isSort:1按照后台顺序,0按照系统排序
        if (hospitalSysDictDO!=null&&hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
            sql +=" and d.del='1' order by d.sort asc  ";
        }else {
            sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort+"";
            if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                if (flag){
                    sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort+",dw.workTotal DESC";
                }else{
                    sql += " and d.del='1' order by d.consult_status desc nulls last ,evaluate.score desc nulls last ,a.total " + consutlSort;
                    sql+=" NULLS LAST,\n" +
                            "\tD.id DESC,dw.workTotal DESC NULLS LAST";
                }
            }else {
                sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort+"";
            }
        }
        String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
        /*list.stream().forEach(e->{
@ -7318,19 +7358,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        Boolean flag = healthCareService.isHospitalFlag();
        if (flag){
            try{
                String result = healthCareService.authorizedToEntrace(basePatientDO.getId());
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                if (object.getString("flag").equalsIgnoreCase("1")){
                    com.alibaba.fastjson.JSONObject encryptData = object.getJSONObject("encrypt_data");
                    String state = encryptData.getString("state");
                    String auth_date = encryptData.getString("auth_date");
                    basePatientDO.setMedicalState(state);
                    basePatientDO = basePatientDao.save(basePatientDO);
                if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                    String result = healthCareService.authorizedToEntrace(basePatientDO.getId());
                    com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
                        com.alibaba.fastjson.JSONObject encryptData = object.getJSONObject("encrypt_data");
                        String state = encryptData.getString("state");
                        String auth_date = encryptData.getString("auth_date");
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }else {
                    String result = healthCareService.authorized(basePatientDO.getId());
                    com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                    if (object.getString("flag").equalsIgnoreCase("1")){
                        com.alibaba.fastjson.JSONObject encryptData = object.getJSONObject("encrypt_data");
                        String state = encryptData.getString("state");
                        String auth_date = encryptData.getString("auth_date");
                        basePatientDO.setMedicalState(state);
                        basePatientDO = basePatientDao.save(basePatientDO);
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01", patient, "1");
        List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
@ -8649,6 +8700,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                room.setDeptName(outpatientDO.getDeptName());
                room.setDoctor(outpatientDO.getDoctor());
                room.setDoctorName(outpatientDO.getDoctorName());
                room.setReservationTime(outpatientDO.getRegisterDate());
                room.setConsultType(Integer.parseInt(outpatientDO.getType()));
                room.setChargeType(chargeType);
            }
@ -11416,6 +11468,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                logger.info("作废处方开始" + prescriptionDO.getCheckStatus());
                WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
                WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
                List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByOutPatientIdList(prescriptionDO.getOutpatientId());
                DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
                List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
                List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
@ -11456,8 +11509,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                wlyyHttpLogDO.setCreateTime(new Date());
                wlyyHttpLogDO.setCode(outpatientDO.getId());
                wlyyHttpLogDao.save(wlyyHttpLogDO);
                for (WlyyPrescriptionDO wlyyPrescriptionDO:prescriptionDOList){
                    wlyyPrescriptionDO.setStatus(-4);
                    wlyyPrescriptionDO.setDisableTime(new Date());
                    wlyyPrescriptionDO.setCheckStatus(5);
                    wlyyPrescriptionDO.setCheckReason("已作废");
                    prescriptionDao.save(wlyyPrescriptionDO);
                }
            }
            prescriptionDO.setStatus(-4);
            prescriptionDO.setDisableTime(new Date());
            prescriptionDO.setCheckStatus(5);
@ -13981,36 +14040,35 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    public JSONObject getSettlementInfo(String outpatientId,Integer flag) throws Exception {
    public com.alibaba.fastjson.JSONObject getSettlementInfo(String outpatientId,Integer flag) throws Exception {
        logger.info("获取患者待结算信息开始!");
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO==null){
            throw new Exception("门诊信息为空");
        }
        String registerNo = outpatientDO.getRegisterNo();
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("ylzConfigOrgCode");
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            xzzxEntranceService.getSettleInfHospital(outpatientDO.getCardNo(),registerNo,sysDictDO.getDictValue());
            xzzxEntranceService.getSettleInfHospital(outpatientDO.getCardNo(),outpatientId,sysDictDO.getDictValue());
            logger.info("获取患者待结算信息结束!");
            logger.info("医保挂号开始!");
            String register = healthCareService.registerToEntrance(registerNo);
            String register = healthCareService.registerToEntrance(outpatientId);
            logger.info("医保挂号结束!");
            logger.info("医保费用明细上传开始!");
            String feeDetailUpload= healthCareService.feeDetailUploadToEntrance(registerNo);
            String feeDetailUpload= healthCareService.feeDetailUploadToEntrance(outpatientId);
            logger.info("医保费用明细上传结束!");
            logger.info("医保预结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO =  healthCareService.preSettlementToEntrance(registerNo);
            YlzMedicalRelationDO ylzMedicalRelationDO =  healthCareService.preSettlementToEntrance(outpatientId);
            logger.info("医保预结算信息结束!");
            JSONObject object = new JSONObject();
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            if (flag==1){
                logger.info("获取医保结算页面地址开始!");
                String getSettlementResultUrl = healthCareService.getSettlementResultUrlToEntrance(registerNo);
                String getSettlementResultUrl = healthCareService.getSettlementResultUrlToEntrance(outpatientId);
                logger.info("获取医保结算页面地址结束!");
                object.put("getSettlementResultUrl",getSettlementResultUrl);
            }else if (flag==2){
                logger.info("获取医保结算页面地址开始!");
                String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64ToEntrance(registerNo);
                String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64ToEntrance(outpatientId);
                logger.info("获取医保结算页面地址结束!");
                object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
            }
@ -14022,47 +14080,118 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            object.put("deptName",outpatientDO.getPatientName());
            return object;
        }else {
            /*entranceService.BS10108()*/
            /*entrance(outpatientDO.getCardNo(),registerNo,sysDictDO.getDictValue());*/
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            logger.info("获取患者待结算信息开始!");
            entranceService.getSettleInfo(outpatientDO.getCardNo(),outpatientDO.getIdcard(),outpatientDO.getId());
            YlzMedicalRelationDO ylzMedicalRelationDO = new YlzMedicalRelationDO();
            ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
            if (ylzMedicalRelationDO!=null&&ylzMedicalRelationDO.getStatus()==1){
                //医保已结算直接返回数据
                List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
                ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                Double totalPirce=b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:"+totalPirce);
                if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                    object.put("code","403");
                    object.put("message","金额不对无法结算!");
                }else {
                    object.put("code","200");
                    object.put("message","核对金额无误!");
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }
            try {
                ylzMedicalRelationDO = entranceService.getSettleInfo(outpatientDO.getCardNo(),outpatientDO.getIdcard(),outpatientDO.getId());
            }catch (Exception e){
                throw new Exception(e.getMessage());
            }
            if (ylzMedicalRelationDO==null){
                throw new Exception("无待结算信息");
            }
            logger.info("获取患者待结算信息结束!");
            logger.info("医保挂号开始!");
            String register = healthCareService.register(registerNo);
            logger.info("医保挂号结束!");
            logger.info("医保费用明细上传开始!");
            String feeDetailUpload= healthCareService.feeDetailUpload(registerNo);
            logger.info("医保费用明细上传结束!");
            if(outpatientDO!=null&&outpatientDO.getMedicalState().equalsIgnoreCase("1")){
                logger.info("医保挂号开始!");
                String register = healthCareService.register(outpatientId);
                logger.info("医保挂号结束!");
                logger.info("医保费用明细上传开始!");
                String feeDetailUpload= healthCareService.feeDetailUpload(outpatientId);
                logger.info("医保费用明细上传结束!");
                logger.info("医保预结算信息开始!");
                ylzMedicalRelationDO =  healthCareService.preSettlement(outpatientId);
                logger.info("医保预结算信息结束!");
                if (flag==1){
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrl = healthCareService.getSettlementResultUrl(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrl",getSettlementResultUrl);
                }else if (flag==2){
                    logger.info("获取医保结算页面地址开始!");
                    String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64(outpatientId);
                    logger.info("获取医保结算页面地址结束!");
                    object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
                }
                if (ylzMedicalRelationDO.getPersonCash()!=null){
                    BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                    BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                    BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                    Double totalPirce=b1.add(b2).add(b3).doubleValue();
                    logger.info("总费用:"+totalPirce);
                    if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                        object.put("code","403");
                        object.put("message","金额不对无法结算!");
                    }else {
                        object.put("code","200");
                        object.put("message","核对金额无误!");
                    }
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }else {
                BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getPersonCash());//个人现金
                BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
                BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
                Double totalPirce=b1.add(b2).add(b3).doubleValue();
                logger.info("总费用:"+totalPirce);
                if (totalPirce!=Double.parseDouble(ylzMedicalRelationDO.getTotalAmount())){
                    object.put("code","403");
                    object.put("message","金额不对无法结算!");
                }else {
                    object.put("code","200");
                    object.put("message","核对金额无误!");
                }
                object.put("getSettleInfo",ylzMedicalRelationDO);
                return object;
            }
        }
    }
            logger.info("医保预结算信息开始!");
            YlzMedicalRelationDO ylzMedicalRelationDO =  healthCareService.preSettlement(registerNo);
            logger.info("医保预结算信息结束!");
            JSONObject object = new JSONObject();
            if (flag==1){
                logger.info("获取医保结算页面地址开始!");
                String getSettlementResultUrl = healthCareService.getSettlementResultUrl(registerNo);
                logger.info("获取医保结算页面地址结束!");
                object.put("getSettlementResultUrl",getSettlementResultUrl);
            }else if (flag==2){
                logger.info("获取医保结算页面地址开始!");
                String getSettlementResultUrlBase64 = healthCareService.getSettlementResultUrlBase64(registerNo);
                logger.info("获取医保结算页面地址结束!");
                object.put("getSettlementResultUrlBase64",getSettlementResultUrlBase64);
    public YlzMedicalRelationDO selectByOutpatientId(String outpatientId){
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        return ylzMedicalRelationDO;
    }
    public String electronicPrescriptionReceiving(String outpatientId) {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if (outpatientDO.getMedicalState()!=null&&outpatientDO.getMedicalState().equalsIgnoreCase("1")){
            try {
                healthCareService.electronicPrescriptionReceiving(outpatientId);
                return "上传成功";
            }catch (Exception e){
                e.printStackTrace();
            }
            object.put("register",register);
            object.put("feeDetailUpload",feeDetailUpload);
            object.put("preSettlement",ylzMedicalRelationDO);
            object.put("cardNo",outpatientDO.getCardNo());
            object.put("deptName",outpatientDO.getPatientName());
            return object;
        }
        return null;
    }
    /**
     * 医保结算页面
     * 医保结算结果
     * @param outpatientId
     * @return
     * @throws Exception
@ -14079,15 +14208,210 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            result = healthCareService.getSettlementResult(code);
            logger.info("医保结算结果获取end!");
        }else{
        }/*else{
            logger.info("医保结算页面start!");
            String registerNo = outpatientDO.getRegisterNo();
            result = healthCareService.getSettlementResultUrl(registerNo);
            logger.info("医保结算页面end!");
        }
        }*/
        return result;
    }
    /**
     * 医保结算后确认his结算
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String confirmSettlementService(String outpatientId) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if (outpatientDO==null){
            throw new Exception("未找到待结算记录");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        if (ylzMedicalRelationDO.getState()!=null&&ylzMedicalRelationDO.getState()==1){
            return "已结算";
        }
        //用医保结算直接调用确认结算
        confirmSettlement(outpatientId);
        return "结算成功";
    }
    /**
     * 费用结算
     *
     * @param outpatientId
     * @return
     * @throws Exception
     */
    public String confirmSettlement(String outpatientId) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if (outpatientDO==null){
            throw new Exception("未找到待结算记录");
        }
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getPatient());
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
        String depositType = "";
        String depositAmount = "";
        String outChargeNo = "";
        if (businessOrderDO!=null){
            depositType = businessOrderDO.getDepositType();
            depositAmount = businessOrderDO.getPayPrice()+"";
            outChargeNo = businessOrderDO.getTraceNo();
        }
        JSONArray jsonArray = new JSONArray();
        if (ylzMedicalRelationDO.getMedicalState()==null||(ylzMedicalRelationDO.getMedicalState()!=null&&ylzMedicalRelationDO.getMedicalState()==0)){
            WlyyHisSettleVO wlyyHisSettleVO = new WlyyHisSettleVO();
            wlyyHisSettleVO.setCardNo(ylzMedicalRelationDO.getCardNo());
            wlyyHisSettleVO.setXtgzh0(ylzMedicalRelationDO.getHisSettleNo());
            wlyyHisSettleVO.setDepositType(depositType);
            wlyyHisSettleVO.setDepositAmount(depositAmount);
            wlyyHisSettleVO.setOutChargeNo(outChargeNo);
            wlyyHisSettleVO.setOrgCode("6");
            wlyyHisSettleVO.setXyzf00("0");
            wlyyHisSettleVO.setChannelType("09");
            wlyyHisSettleVO.setDjlsh0("");
            wlyyHisSettleVO.setMzlsh0("");
            wlyyHisSettleVO.setZhzfe0("");
            wlyyHisSettleVO.setGrzfe0("");
            wlyyHisSettleVO.setJjzfe0("");
            wlyyHisSettleVO.setGwybz0("");
            wlyyHisSettleVO.setFybfy0("");
            wlyyHisSettleVO.setCfdxje("");
            wlyyHisSettleVO.setBjjjzf("");
            wlyyHisSettleVO.setSybxzf("");
            wlyyHisSettleVO.setBcbxf0("");
            wlyyHisSettleVO.setSfrq00("");
            wlyyHisSettleVO.setSfsj00("");
            wlyyHisSettleVO.setSfrxm0("");
            wlyyHisSettleVO.setBzjjzf("");
            wlyyHisSettleVO.setGrzhye("");
            wlyyHisSettleVO.setYlzfje("");
            wlyyHisSettleVO.setJkzhye("");
            wlyyHisSettleVO.setJkzhye("");
            wlyyHisSettleVO.setGrzhye("");
            wlyyHisSettleVO.setYbmxls("");
            wlyyHisSettleVO.setBdgjzf("");
            wlyyHisSettleVO.setYdgjzf("");
            wlyyHisSettleVO.setBckbcs("");
            jsonArray = entranceService.BS15039(wlyyHisSettleVO,false);
        }
        if (ylzMedicalRelationDO!=null&&ylzMedicalRelationDO.getStatus()==1){
            WlyyHisSettleVO wlyyHisSettleVO = new WlyyHisSettleVO();
            wlyyHisSettleVO.setCardNo(ylzMedicalRelationDO.getCardNo());
            wlyyHisSettleVO.setXtgzh0(ylzMedicalRelationDO.getHisSettleNo());
            wlyyHisSettleVO.setDepositType(depositType);
            wlyyHisSettleVO.setDepositAmount(depositAmount);
            wlyyHisSettleVO.setOutChargeNo(outChargeNo);
            wlyyHisSettleVO.setOrgCode("6");
            wlyyHisSettleVO.setXyzf00("0");
            wlyyHisSettleVO.setChannelType("09");
            wlyyHisSettleVO.setDjlsh0(ylzMedicalRelationDO.getBillSerial());
            wlyyHisSettleVO.setMzlsh0(ylzMedicalRelationDO.getInsuranceSerial());
            wlyyHisSettleVO.setZhzfe0(ylzMedicalRelationDO.getPersonAccount());
            wlyyHisSettleVO.setGrzfe0(ylzMedicalRelationDO.getPersonCash());
            wlyyHisSettleVO.setJjzfe0(ylzMedicalRelationDO.getMedicalPrice());
            wlyyHisSettleVO.setGwybz0(ylzMedicalRelationDO.getGwyPay());
            wlyyHisSettleVO.setFybfy0(ylzMedicalRelationDO.getPersonCash());
            wlyyHisSettleVO.setCfdxje("0");
            wlyyHisSettleVO.setBjjjzf("0");
            wlyyHisSettleVO.setSybxzf(ylzMedicalRelationDO.getSbjjPay());
            wlyyHisSettleVO.setBcbxf0(ylzMedicalRelationDO.getTotalAmount());
            wlyyHisSettleVO.setSfrq00(DateUtil.dateToStrLong(ylzMedicalRelationDO.getPayDate()));
            wlyyHisSettleVO.setSfsj00("");
            wlyyHisSettleVO.setSfrxm0("");
            wlyyHisSettleVO.setBzjjzf(ylzMedicalRelationDO.getYljzPay());
            wlyyHisSettleVO.setGrzhye(ylzMedicalRelationDO.getAccountBalance());
            wlyyHisSettleVO.setYlzfje(ylzMedicalRelationDO.getOwnPay());
            wlyyHisSettleVO.setJkzhye(ylzMedicalRelationDO.getJkzhPay());
            wlyyHisSettleVO.setYbmxls(ylzMedicalRelationDO.getDetailSerial());
            wlyyHisSettleVO.setBdgjzf(ylzMedicalRelationDO.getJtgjPay());
            wlyyHisSettleVO.setYdgjzf(ylzMedicalRelationDO.getJtgjPay());
            wlyyHisSettleVO.setBckbcs(ylzMedicalRelationDO.getHospitalizationQty());
            wlyyHisSettleVO.setPsnNo(ylzMedicalRelationDO.getPersonalCode());
            wlyyHisSettleVO.setAab301(ylzMedicalRelationDO.getAdministrativeArea());
            wlyyHisSettleVO.setInsutype(ylzMedicalRelationDO.getInsuranceType());
            wlyyHisSettleVO.setSetlTime(DateUtil.dateToStrLong(ylzMedicalRelationDO.getPayDate()));
            jsonArray = entranceService.BS15039(wlyyHisSettleVO,false);
        }
        if (jsonArray!=null&&jsonArray.size()!=0){
            net.sf.json.JSONObject object = jsonArray.getJSONObject(0);
            net.sf.json.JSONObject jsonObject = object.getJSONObject("retInfo");
            net.sf.json.JSONObject msgInfoJson = object.getJSONObject("msgInfo");
            if (jsonObject.getString("retCode").equalsIgnoreCase("00")){
                ylzMedicalRelationDO.setState(1);
                ylzMedicalRelationDO.setHisBillSerial(msgInfoJson.getString("callSn"));
                ylzMedicalRelationDO.setHisDesc(msgInfoJson.getString("jsxxts"));
                ylzMedicalRelationDO.setSettleDate(new Date());
                ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
                List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
                boolean hisState = false;
                for (YlzMedicalMxDO mxDO:mxDOList){
                    if (mxDO.getItemName().contains("互联网医院复诊诊查费")){
                        hisState = true;
                    }
                }
                logger.info("变更医保结算状态成功");
                String realOrder = msgInfoJson.getString("xtgzh0");
                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByRealOrderAndStatusList(realOrder);
                for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS){
                    WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
                    String title = "";
                    if (wlyyOutpatientDO.getHisStatus()==null){
                        title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!结算费用包含本次在线问诊的复诊诊查费:"+wlyyOutpatientDO.getFee()+"元。";
                    }else {
                        title="您在厦门大学附属中山医院有一笔诊察/处方费用已支付完成!";
                    }
                    if (hisState){
                        wlyyOutpatientDO.setHisStatus(1);
                        outpatientDao.save(wlyyOutpatientDO);
                    }
                    WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
                    prescriptionLogDO.setCreateTime(new Date());
                    prescriptionLogDO.setStatus(30);
                    prescriptionLogDO.setOutpatientId(prescriptionDO.getOutpatientId());
                    prescriptionLogDO.setPrescriptionCode(prescriptionDO.getId());
                    prescriptionLogDO.setUserCode(prescriptionDO.getPatientCode());
                    prescriptionLogDO.setUserName(prescriptionDO.getPatientName());
                    prescriptionLogDO.setUserType(1);
                    prescriptionLogDO.setDatajson("处方结算");
                    prescriptionLogDao.save(prescriptionLogDO);
                    prescriptionDO.setStatus(30);
                    prescriptionDO.setPayTime(new Date());
                    prescriptionDao.save(prescriptionDO);
                    logger.info("变更处方结算状态成功");
                    String fee = ylzMedicalRelationDO.getTotalAmount();
                    String pushPayLog =  payInfoNoticeService.pushPrescriptionPayMedicare(wlyyOutpatientDO.getConsumer(),prescriptionDO.getDoctorName(),prescriptionDO.getVoucherNo(),prescriptionDO.getOutpatientId(),prescriptionDO.getId(),fee,ylzMedicalRelationDO.getMedicalPrice(),ylzMedicalRelationDO.getPersonCash(),title,null);
                    logger.info("处方结算成功"+pushPayLog+"====="+realOrder);
                    //2.6.1	电子处方订单接收
                    logger.info("医保电子处方订单");
                    if (ylzMedicalRelationDO.getMedicalState()!=null&&ylzMedicalRelationDO.getMedicalState()==0){
                        List<WlyyPrescriptionExpressageDO> expressageDOList = prescriptionExpressageDao.findByOutpatientId(ylzMedicalRelationDO.getRelationCode());
                        if (expressageDOList!=null&&expressageDOList.size()!=0){
                            WlyyPrescriptionExpressageDO expressageDO = expressageDOList.get(0);
                            if (expressageDO.getOneselfPickupFlg()==1){
                                healthCareService.electronicPrescriptionReceiving(ylzMedicalRelationDO.getRelationCode());
                            }
                        }
                    }
                }
                logger.info("电子发票开具开始");
                /*try {
                    entranceService.dzpjServer(patientMappingDO.getMappingCode(),realOrder);
                }catch (Exception e){
                    e.printStackTrace();
                }*/
                logger.info("电子发票开具结束");
            }
        }
        return jsonArray.toString();
    }
    /**
     *
@ -14514,6 +14838,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            com.alibaba.fastjson.JSONObject objectString = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.toJSON(prescriptionDO);
            List<WlyyPrescriptionInfoDO> infoDOList = prescriptionInfoDao.findByPrescriptionId(prescriptionDO.getId(),1);
            objectString.put("info",infoDOList);
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
            if (outpatientDO!=null){
                objectString.put("consumerName",outpatientDO.getConsumerName());
            }else {
                objectString.put("consumerName","");
            }
            Map<String,Object> map = new HashedMap();
            map.put("prescription",objectString);
            mapList.add(map);
@ -14524,7 +14854,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    /**
     * 药品明细表导出
     * @param os
     * @param osmergeCells(a,b,c,d)
     * @param ls
     * @param startTime
     * @param endTime
@ -14548,7 +14878,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                addCell(ws, 1, k1, h);//表名,行,列,header
                k1++;
            }
            String[] header2 = {"患者名称","订单药品","规格","总量","单位","进价","零售价","进货金额","零售金额","发药时间","审方时间","开方时间","开方医生"};//
            String[] header2 = {"患者名称","代问诊人","订单药品","规格","总量","单位","进价","零售价","进货金额","零售金额","发药时间","审方时间","开方时间","开方医生"};//
            int k2 = 0;
            for (String h : header2) {
                addCell(ws, 2, k2, h);//表名,行,列,header
@ -14563,31 +14893,34 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                com.alibaba.fastjson.JSONArray array = jsonObject.getJSONArray("info");
                int j = i;
                addCell(ws, i, 0,jsonObject.get("patientName")!=null?jsonObject.get("patientName").toString():n);
                addCell(ws, i, 1,jsonObject.get("consumerName")!=null?jsonObject.get("consumerName").toString():n);
                DecimalFormat df = new DecimalFormat("#.00");
                if(array!=null&&array.size()!=0){
                    for (int z=0;z<array.size();z++){
                        com.alibaba.fastjson.JSONObject object = array.getJSONObject(z);
                        addCell(ws, i, 1, object.get("drugName")!=null?object.get("drugName").toString():n);
                        addCell(ws, i, 2, object.get("specification")!=null?object.get("specification").toString():n);
                        addCell(ws, i, 3, object.get("quantity")!=null?object.get("quantity").toString():n);
                        addCell(ws, i, 4, object.get("packUnitName")!=null?object.get("packUnitName").toString():n);
                        addCell(ws, i, 5, "无");
                        addCell(ws, i, 6, object.get("packRetprice")!=null?object.get("packRetprice").toString():n);
                        addCell(ws, i, 7, "无");
                        addCell(ws, i, 2, object.get("drugName")!=null?object.get("drugName").toString():n);
                        addCell(ws, i, 3, object.get("specification")!=null?object.get("specification").toString():n);
                        addCell(ws, i, 4, object.get("quantity")!=null?object.get("quantity").toString():n);
                        addCell(ws, i, 5, object.get("packUnitName")!=null?object.get("packUnitName").toString():n);
                        addCell(ws, i, 6, "无");
                        addCell(ws, i, 7, object.get("packRetprice")!=null?object.get("packRetprice").toString():n);
                        addCell(ws, i, 8, "无");
                        if (object.get("quantity")!=null){
                            Double quantity = Double.parseDouble(object.get("quantity").toString());
                            Double packRetprice = Double.parseDouble(object.get("packRetprice").toString());
                            addCell(ws, i, 8,df.format(packRetprice*quantity));
                            addCell(ws, i, 9,df.format(packRetprice*quantity));
                        }else {
                            addCell(ws, i, 8,"");
                            addCell(ws, i, 9,"");
                        }
                        addCell(ws, i, 9,jsonObject.get("dispDate")!=null?DateUtil.stampToString(jsonObject.get("dispDate").toString()):n);
                        addCell(ws, i, 10,jsonObject.get("checkTime")!=null?DateUtil.stampToString(jsonObject.get("checkTime").toString()):n);
                        addCell(ws, i, 11,jsonObject.get("createTime")!=null?DateUtil.stampToString(jsonObject.get("createTime").toString()):n);
                        addCell(ws, i, 12,jsonObject.get("doctorName")!=null?jsonObject.get("doctorName").toString():n);
                        addCell(ws, i, 10,jsonObject.get("dispDate")!=null?DateUtil.stampToString(jsonObject.get("dispDate").toString()):n);
                        addCell(ws, i, 11,jsonObject.get("checkTime")!=null?DateUtil.stampToString(jsonObject.get("checkTime").toString()):n);
                        addCell(ws, i, 12,jsonObject.get("createTime")!=null?DateUtil.stampToString(jsonObject.get("createTime").toString()):n);
                        addCell(ws, i, 13,jsonObject.get("doctorName")!=null?jsonObject.get("doctorName").toString():n);
                        i++;
                    }
                    ws.mergeCells(0,j,0,i-1);
                    ws.mergeCells(1,j,1,i-1);
                }else {
                    i++;
                }
@ -14595,8 +14928,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
            ws.mergeCells(0,0,12,0);
            ws.mergeCells(0,1,12,1);
            ws.mergeCells(0,0,13,0);
            ws.mergeCells(0,1,13,1);
            wwb.write();
            wwb.close();
        } catch (IOException e) {

Різницю між файлами не показано, бо вона завелика
+ 343 - 51
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java


+ 7 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -2444,7 +2444,7 @@ public class XzzxEntranceService{
     * @return
     * @throws Exception
     */
    public String confirmSettle(String his_serial,String icCardNo,String org_code)throws Exception{
    public String confirmSettle(String his_serial,String icCardNo,String org_code,String outpatientId)throws Exception{
        String api = "confirmSettle";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
@ -2453,7 +2453,7 @@ public class XzzxEntranceService{
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(his_serial);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        String condition ="";
        JSONObject jsonObject = new JSONObject();
@ -2485,8 +2485,8 @@ public class XzzxEntranceService{
            if (!StringUtils.isEmpty(ylzMedicalRelationDO.getPersonAccount())){
                jsonObject.put("person_account",ylzMedicalRelationDO.getPersonAccount());
            }
            if (!StringUtils.isEmpty(ylzMedicalRelationDO.getFundPrice())){
                jsonObject.put("fund_amount",ylzMedicalRelationDO.getFundPrice());
            if (!StringUtils.isEmpty(ylzMedicalRelationDO.getMedicalPrice())){
                jsonObject.put("fund_amount",ylzMedicalRelationDO.getMedicalPrice());
            }
            if (!StringUtils.isEmpty(ylzMedicalRelationDO.getJkzhPay())){
                jsonObject.put("jkzh_pay",ylzMedicalRelationDO.getJkzhPay());
@ -2749,8 +2749,10 @@ public class XzzxEntranceService{
     * @param org_code 医院编码
     * @return
     */
    public JSONObject getSettleInfHospital(String icCardNo,String his_serial,String org_code){
    public JSONObject getSettleInfHospital(String icCardNo,String outpatientId,String org_code){
        JSONObject jsonObject= new JSONObject();
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
        String his_serial = wlyyOutpatientDO.getRegisterNo();
        String response="";
        String url = entranceUrl+"getSettleInfo?icCardNo="+icCardNo+"&his_serial="+his_serial+"&org_code="+org_code;
        response = httpClientUtil.get(url,"GBK");

+ 93 - 12
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -59,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.CriteriaBuilder;
import java.io.InputStream;
import java.math.BigDecimal;
import java.rmi.server.ExportException;
import java.util.*;
/**
@ -1760,7 +1761,7 @@ public class YkyyEntranceService {
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\t(x.jzkh = '"+ssc+"' or x.MZHM='"+ssc+"') and x.sfzh ='"+idcard+"'";
                "\t(UPPER(x.jzkh) = UPPER('"+ssc+"') or UPPER(x.MZHM)=UPPER('"+ssc+"')) ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -1787,9 +1788,67 @@ public class YkyyEntranceService {
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
                if (array==null||array.size()==0){
                    String sqlSfzh = "SELECT\n" +
                            "\tx.brid AS \"brid\",\n" +
                            "\tx.mzhm AS \"mzhm\",\n" +
                            "\tx.brxm AS \"brxm\",\n" +
                            "\tx.sfzh AS \"sfzh\",\n" +
                            "\tx.brxz AS \"brxz\",\n" +
                            "\tx.brxb AS \"brxb\",\n" +
                            "\tx.csny as \"csny\",\n" +
                            "\tx.jzkh AS \"jzkh\",\n" +
                            "\tx.jdsj AS \"jdsj\",\n" +
                            "\tx.sjhm AS \"sjhm\",\n" +
                            "\tx.fzxmc AS \"fzxmc\",\n" +
                            "\tx.gzztmc AS \"gzztmc\",\n" +
                            "\tx.lxdz AS \"lxdz\"\n" +
                            "FROM\n" +
                            "\tV_ZKSG_BRCX x\n" +
                            "WHERE\n" +
                            " UPPER(x.sfzh) =UPPER('"+idcard+"')";
                    Map<String,Object> paramsSfzh = new HashedMap();
                    paramsSfzh.put("sql",sqlSfzh);
                    HttpResponse response1 = HttpUtils.doGet(url,paramsSfzh);
                    String content1 = response1.getContent();
                    logger.info("response1:"+content1);
                    JSONObject rs1 = JSON.parseObject(content1);
                    Integer status1 = rs1.getInteger("status");
                    if (status1==200){
                        array = rs1.getJSONArray("detailModelList");
                    }
                }else if (array!=null&&array.size()>1){
                    String sqlSfzh = "SELECT\n" +
                            "\tx.brid AS \"brid\",\n" +
                            "\tx.mzhm AS \"mzhm\",\n" +
                            "\tx.brxm AS \"brxm\",\n" +
                            "\tx.sfzh AS \"sfzh\",\n" +
                            "\tx.brxz AS \"brxz\",\n" +
                            "\tx.brxb AS \"brxb\",\n" +
                            "\tx.csny as \"csny\",\n" +
                            "\tx.jzkh AS \"jzkh\",\n" +
                            "\tx.jdsj AS \"jdsj\",\n" +
                            "\tx.sjhm AS \"sjhm\",\n" +
                            "\tx.fzxmc AS \"fzxmc\",\n" +
                            "\tx.gzztmc AS \"gzztmc\",\n" +
                            "\tx.lxdz AS \"lxdz\"\n" +
                            "FROM\n" +
                            "\tV_ZKSG_BRCX x\n" +
                            "WHERE\n" +
                            " UPPER(x.sfzh) =UPPER('"+idcard+"') and (UPPER(x.jzkh) = UPPER('"+ssc+"') or UPPER(x.MZHM)=UPPER('"+ssc+"')) ";
                    Map<String,Object> paramsSfzh = new HashedMap();
                    paramsSfzh.put("sql",sqlSfzh);
                    HttpResponse response1 = HttpUtils.doGet(url,paramsSfzh);
                    String content1 = response1.getContent();
                    logger.info("response1:"+content1);
                    JSONObject rs1 = JSON.parseObject(content1);
                    Integer status1 = rs1.getInteger("status");
                    if (status1==200){
                        array = rs1.getJSONArray("detailModelList");
                    }
                }
            }
        }
        return array;
    }
@ -1817,7 +1876,7 @@ public class YkyyEntranceService {
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.sfzh = '"+idcard+"' ";
                "\tUPPER(x.sfzh) = UPPER('"+idcard+"') ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -1874,11 +1933,11 @@ public class YkyyEntranceService {
                "\tV_ZKSG_BRCX x\n" +
                "WHERE 1=1" ;
        if (StringUtils.isNotBlank(medicare)&&StringUtils.isNotBlank(mzhm)){
            sql+=" and (x.jzkh = '"+medicare+"' or x.mzhm = '"+mzhm+"')";
            sql+=" and (UPPER(x.jzkh) = UPPER('"+medicare+"') or UPPER(x.mzhm) = UPPER('"+mzhm+"'))";
        }else if (StringUtils.isNotBlank(medicare)&&!StringUtils.isNotBlank(mzhm)){
            sql+=" and x.jzkh = '"+medicare+"' ";
            sql+=" and UPPER(x.jzkh) = UPPER('"+medicare+"') ";
        }else if (!StringUtils.isNotBlank(medicare)&&StringUtils.isNotBlank(mzhm)){
            sql+=" and x.mzhm = '"+mzhm+"' ";
            sql+=" and UPPER(x.mzhm) = UPPER('"+mzhm+"') ";
        }else {
            sql+=" and x.brid is null";
        }
@ -2520,12 +2579,31 @@ public class YkyyEntranceService {
        String doctor = wlyyPrescriptionVO.getDoctor();
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
        String patient = wlyyPrescriptionVO.getPatientCode();
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        BasePatientDO patientDO = basePatientDao.findById(patient);
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        if (patientMedicareCardDO==null){
            patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_02",patient,"1");
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if (patientMappingDO==null){
            JSONArray jsonArray = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
            if(jsonArray!=null&&jsonArray.size()>0){
                //获取居民信息
                JSONObject json = jsonArray.getJSONObject(0);
                String brid = json.getString("brid");
                patientMappingDO = new PatientMappingDO();
                patientMappingDO.setCreateTime(new Date());
                patientMappingDO.setIdcard(patientDO.getIdcard());
                patientMappingDO.setMappingCode(brid);
                patientMappingDO.setPatient(patient);
                patientMappingDO.setPatientName(patientDO.getName());
                patientMappingDO.setSource("1");
                patientMappingDao.save(patientMappingDO);
            }else {
                throw new Exception("该名患者,在院信息有误,请告知患者核对(身份证号、社保卡号)!");
            }
        }
        Integer GHXH = 0;
        //挂号明细表HLW_GHMX
        HlwGhmxDO hlwGhmxDO = new HlwGhmxDO();
@ -2761,6 +2839,9 @@ public class YkyyEntranceService {
                hlwCf01DO.setSCDDH(wlyyPrescriptionVO.getOrderNo());
                String patient = wlyyPrescriptionVO.getPatientCode();
                PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
                if (patientMappingDO==null){
                    throw new Exception("该名患者,在院信息有误,请告知患者核对(身份证号、社保卡号)!");
                }
                hlwCf01DO.setBRID(Integer.parseInt(patientMappingDO.getMappingCode()));
                hlwCf01DO.setBRXM(wlyyPrescriptionVO.getPatientName());
                hlwCf01DO.setKSDM(Integer.parseInt(wlyyPrescriptionVO.getDept()));
@ -3543,7 +3624,7 @@ public class YkyyEntranceService {
        res.put("status", 200);
        Float brid = null;
        //根据身份证查询是否建档
        String sfzhSql = "SELECT jzkh \"jzkh\" ,brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where sfzh = '" + idcard + "' order by JDSJ ";
        String sfzhSql = "SELECT jzkh \"jzkh\" ,brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where UPPER(sfzh) = UPPER('" + idcard + "') order by JDSJ ";
        //根据社保卡查询是否建档
        String jzkhSql = "SELECT brid \"brid\",sfzh \"sfzh\" from portal_his.V_ZKSG_BRCX@xec_link where UPPER(jzkh) = UPPER('" + medicare + "')  order by JDSJ ";
        JSONArray sfzhArray = getSqlResult(sfzhSql);
@ -3575,11 +3656,11 @@ public class YkyyEntranceService {
                }
            }
        } else*/ if (size > 1) {//如果存在多条数据,查看是否有跟当前社保卡号一致的,如果有则跳过,如果社保卡都为空则取其中一条更新,否则就提示与预留卡号不一致
            String sql = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where sfzh = '" + idcard + "' and  UPPER(jzkh) = UPPER('" + medicare + "') ";
            String sql = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where UPPER(sfzh) = UPPER('" + idcard + "') and  UPPER(jzkh) = UPPER('" + medicare + "') ";
            JSONArray array = getSqlResult(sql);
            logger.info("查询身份证和社保卡:" + array.toString());
            String sql1 = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where sfzh = '" + idcard + "' and  mzhm = '" + clinicId + "' ";
            String sql1 = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where UPPER(sfzh) = UPPER('" + idcard + "') and  mzhm = '" + clinicId + "' ";
            JSONArray array1 = getSqlResult(sql1);
            logger.info("查询身份证和门诊号:" + array1.toString());
            /*if (array==null||array.size()==0){
@ -3640,9 +3721,9 @@ public class YkyyEntranceService {
            params1.put("csny", IdCardUtil.getBirthdayForIdcardStr(idcard));
            params1.put("brxb", IdCardUtil.getSexForIdcard_new(idcard));
            params1.put("czgh", "1996");
            params1.put("sfzh", idcard);
            params1.put("sfzh", idcard.toUpperCase());
            params1.put("sjhm", phoneNum);
            params1.put("ybkh", medicare);
            params1.put("ybkh", medicare.toUpperCase());
            params1.put("lxdz", 0);
            params1.put("zy", 0);
            HttpResponse response1 = HttpUtils.doGet(saveJdxxUrl, params1);

+ 217 - 2
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -12,6 +12,7 @@ import com.yihu.jw.entity.base.wx.WxPayLogDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
@ -19,6 +20,7 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
@ -37,6 +39,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.util.common.BeanUtils;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.common.XMLUtil;
@ -146,6 +149,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    private HibenateUtils hibenateUtils;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    /**
@ -186,7 +191,9 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                businessOrderDO.setDoctor(wlyyPrescriptionDO.getDoctor());
                businessOrderDO.setPatient(outpatientDO.getConsumer());
                businessOrderDO.setPatientName(outpatientDO.getConsumerName());
                BigDecimal b = new BigDecimal(String.valueOf(wlyyPrescriptionDO.getDrugFee()==null?0:wlyyPrescriptionDO.getDrugFee()));
                String a = String.valueOf(wlyyPrescriptionDO.getDrugFee()==null?0:String.format("%.2f",wlyyPrescriptionDO.getDrugFee()));
                logger.info("");
                BigDecimal b = new BigDecimal(a);
                BigDecimal c = new BigDecimal(String.valueOf(100));
                BigDecimal bc = b.multiply(c);
                BigDecimal dc = new BigDecimal(0);
@ -257,7 +264,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                    }
                }
            }else {
                BigDecimal b = new BigDecimal(String.valueOf(wlyyPrescriptionDO.getDrugFee()==null?0:wlyyPrescriptionDO.getDrugFee()));
                String a = String.valueOf(wlyyPrescriptionDO.getDrugFee()==null?0:String.format("%.2f",wlyyPrescriptionDO.getDrugFee()));
                BigDecimal b = new BigDecimal(a);
                BigDecimal c = new BigDecimal(String.valueOf(100));
                BigDecimal bc = b.multiply(c);
                BigDecimal dc = new BigDecimal(0);
@ -1592,6 +1600,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        }
        businessOrderDO.setUpdateTime(new Date());
        businessOrderDO.setStatus(1);
        businessOrderDO.setPayTime(new Date());
        businessOrderDao.save(businessOrderDO);
        return businessOrderDO;
@ -1907,6 +1916,180 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    }
    /**
     * 预交金处方支付
     * @param code
     * @param depositType
     * @param wechatId
     * @return
     * @throws Exception
     */
    public String ylzRechargePre(String code,String depositType,String wechatId,String cardType,String cardNo,boolean demoFlag) throws Exception {
        String response = null;
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if(wxWechatDO==null){
            throw new Exception("can't find wechat:the wxId is "+wechatId);
        }
        WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL");
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(code);
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(code);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
        BigDecimal b1 = new BigDecimal(ylzMedicalRelationDO.getTotalAmount());//总金额
        BigDecimal b2 = new BigDecimal(ylzMedicalRelationDO.getPersonAccount());//个人账户
        BigDecimal b3 = new BigDecimal(ylzMedicalRelationDO.getMedicalPrice());//医保总金额
        Double fee = b1.subtract(b2).subtract(b3).doubleValue();
        if (businessOrderDO!=null){
            BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
            String idcard = "";
            if (patientDO!=null){
                idcard = patientDO.getIdcard();
            }
            logger.info("开始1"+idcard);
            String openId = "";
            net.sf.json.JSONObject object1 = entranceService.qutpatientBalance(cardNo, demoFlag);
            Double cardFee = object1.getDouble("ZHYE");
            BigDecimal b = new BigDecimal(String.valueOf(cardFee));
            BigDecimal c = new BigDecimal(String.valueOf(fee));
            if (b.compareTo(c) == 1){
                return "无需线上支付";
            }
            BigDecimal balance = c.subtract(b);
            businessOrderDO.setPayPrice(balance.doubleValue());
            businessOrderDO.setPayType(4);
            businessOrderDO.setHistoryOrder(businessOrderDO.getOrderNo());
            businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
            businessOrderDO.setDepositType(depositType);
            businessOrderDao.save(businessOrderDO);
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                openId = patientWechatDo.getOpenid();
            }
            String price = businessOrderDO.getPayPrice().toString();
            String notifyUrl = hospitalSysDictDO.getDictCode();
            String operatorId =null;
            String operatorName = null;
            if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                operatorId = "123456";
                operatorName =businessOrderDO.getPatientName();
            }else if(wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                operatorId = "hlwyy";
                operatorName = "互联网医院";
            }else if(wechatId.equalsIgnoreCase("xm_hcyy_wx")){
                operatorId = "hlwyy";
                operatorName = "互联网医院";
            }
            response = ylzPayService.recharge(operatorId,operatorName,cardType,"01",cardNo,idcard,depositType,price,businessOrderDO.getOrderNo(),openId,patientDO.getName(),notifyUrl);
            if (depositType.equalsIgnoreCase("WX_QR")){
                JSONObject object = JSONObject.parseObject(response);
                if (object!=null){
                    JSONObject jsonObject = object.getJSONObject("param");
                    if (object.getString("respCode").equalsIgnoreCase("000000")){
                        InputStream qrcode = QrcodeUtil.createQrcode(jsonObject.getString("qrcode"),300,"jpg");
                        ByteToInputStream byteToInputStream = new ByteToInputStream();
                        String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                        jsonObject.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                        String traceNo = jsonObject.getString("traceNo");
                        businessOrderDO.setTraceNo(traceNo);
                        businessOrderDao.save(businessOrderDO);
                    }
                    response = object.toJSONString();
                }
            }else {
                JSONObject object = JSONObject.parseObject(response);
                if (object!=null){
                    JSONObject jsonObject = object.getJSONObject("param");
                    if (object.getString("respCode").equalsIgnoreCase("000000")){
                        String traceNo = jsonObject.getString("traceNo");
                        businessOrderDO.setTraceNo(traceNo);
                        businessOrderDao.save(businessOrderDO);
                    }
                }
            }
        }else {
            businessOrderDO = new BusinessOrderDO();
            BasePatientDO patientDO = patientDao.findById(wlyyOutpatientDO.getPatient());
            String idcard = "";
            if (patientDO!=null){
                idcard = patientDO.getIdcard();
            }
            logger.info("开始1"+idcard);
            String openId = "";
            net.sf.json.JSONObject object1 = entranceService.qutpatientBalance(cardNo, demoFlag);
            Double cardFee = object1.getDouble("ZHYE");
            BigDecimal b = new BigDecimal(String.valueOf(cardFee));
            BigDecimal c = new BigDecimal(String.valueOf(fee));
            BigDecimal balance = c.subtract(b);
            businessOrderDO.setPayPrice(balance.doubleValue());
            businessOrderDO.setPayType(4);
            businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
            businessOrderDO.setDepositType(depositType);
            businessOrderDO.setRelationCode(ylzMedicalRelationDO.getId());
            businessOrderDO.setRelationName("费用结算");
            businessOrderDO.setPatientName(patientDO.getName());
            businessOrderDO.setPatient(patientDO.getId());
            businessOrderDO.setDoctor(wlyyOutpatientDO.getDoctor());
            businessOrderDO.setOrderCategory("6");
            businessOrderDO.setOrderType(6);
            businessOrderDO.setStatus(0);
            businessOrderDO.setDescription("费用结算");
            businessOrderDO.setCreateTime(new Date());
            businessOrderDO.setUpdateTime(new Date());
            businessOrderDao.save(businessOrderDO);
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                openId = patientWechatDo.getOpenid();
            }
            String price = businessOrderDO.getPayPrice().toString();
            String notifyUrl = hospitalSysDictDO.getDictCode();
            String operatorId =null;
            String operatorName = null;
            if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                operatorId = "123456";
                operatorName =businessOrderDO.getPatientName();
            }else if(wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                operatorId = "hlwyy";
                operatorName = "互联网医院";
            }else if(wechatId.equalsIgnoreCase("xm_hcyy_wx")){
                operatorId = "hlwyy";
                operatorName = "互联网医院";
            }
            response = ylzPayService.recharge(operatorId,operatorName,cardType,"01",cardNo,idcard,depositType,price,businessOrderDO.getOrderNo(),openId,patientDO.getName(),notifyUrl);
            if (depositType.equalsIgnoreCase("WX_QR")){
                JSONObject object = JSONObject.parseObject(response);
                if (object!=null){
                    JSONObject jsonObject = object.getJSONObject("param");
                    if (object.getString("respCode").equalsIgnoreCase("000000")){
                        InputStream qrcode = QrcodeUtil.createQrcode(jsonObject.getString("qrcode"),300,"jpg");
                        ByteToInputStream byteToInputStream = new ByteToInputStream();
                        String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                        jsonObject.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                        String traceNo = jsonObject.getString("traceNo");
                        businessOrderDO.setTraceNo(traceNo);
                        businessOrderDao.save(businessOrderDO);
                    }
                    response = object.toJSONString();
                }
            }else {
                JSONObject object = JSONObject.parseObject(response);
                if (object!=null){
                    JSONObject jsonObject = object.getJSONObject("param");
                    if (object.getString("respCode").equalsIgnoreCase("000000")){
                        String traceNo = jsonObject.getString("traceNo");
                        businessOrderDO.setTraceNo(traceNo);
                        businessOrderDao.save(businessOrderDO);
                    }
                }
            }
        }
        return response;
    }
    /**
     * 咨询退费
     * @param consult
@ -2042,11 +2225,21 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        for (Map<String,Object> map:list){
            if (map.get("orderCategory")!=null){
                String orderCategoryFlag = map.get("orderCategory").toString();
                String relationCode =map.get("relationCode").toString();
                if (!orderCategoryFlag.equalsIgnoreCase("5")){
                    Double price = Double.parseDouble(map.get("payPrice").toString());
                    Double prie = price/100;
                    logger.info("price"+prie);
                    map.put("payPrice",prie);
                }if (orderCategoryFlag.equalsIgnoreCase("1")||orderCategoryFlag.equalsIgnoreCase("2")||orderCategoryFlag.equalsIgnoreCase("3")){
                    WlyyOutpatientDO outpatientDO = outpatientDao.findById(relationCode);
                    map.put("doctorName",outpatientDO.getDoctorName());
                    map.put("consumerName",outpatientDO.getConsumerName());
                }else if (orderCategoryFlag.equalsIgnoreCase("4")){
                    WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(relationCode);
                    WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
                    map.put("doctorName",outpatientDO.getDoctorName());
                    map.put("consumerName",outpatientDO.getConsumerName());
                }
            }
        }
@ -2152,12 +2345,34 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        for (Map<String,Object> map:mapList){
            if (map.get("orderCategory")!=null){
                String orderCategoryFlag = map.get("orderCategory").toString();
                String relationCode =map.get("relationCode").toString();
                if (!orderCategoryFlag.equalsIgnoreCase("5")){
                    Double price = Double.parseDouble(map.get("payPrice").toString());
                    Double prie = price/100;
                    logger.info("price"+prie);
                    map.put("payPrice",prie);
                }
                if (orderCategoryFlag.equalsIgnoreCase("1")||orderCategoryFlag.equalsIgnoreCase("2")||orderCategoryFlag.equalsIgnoreCase("3")){
                    WlyyOutpatientDO outpatientDO = outpatientDao.findById(relationCode);
                    if (outpatientDO!=null){
                        map.put("doctorName",outpatientDO.getDoctorName());
                        map.put("consumerName",outpatientDO.getPatientName());
                    }else {
                        map.put("doctorName","");
                        map.put("consumerName","");
                    }
                }else if (orderCategoryFlag.equalsIgnoreCase("4")){
                    WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(relationCode);
                    WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
                    if (outpatientDO!=null){
                        map.put("doctorName",outpatientDO.getDoctorName());
                        map.put("consumerName",outpatientDO.getPatientName());
                    }else {
                        map.put("doctorName","");
                        map.put("consumerName","");
                    }
                }
            }
        }
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mapList);

+ 0 - 1
business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java

@ -22,7 +22,6 @@ public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrd
    @Query("from BusinessOrderDO w where w.relationCode = ?1 ")
    BusinessOrderDO selectByRelationCode(String relationCode);
    @Query("from BusinessOrderDO w where w.relationCode = ?1 order by createTime desc ")
    List<BusinessOrderDO> selectListByRelationCode(String relationCode);

+ 23 - 12
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -404,16 +404,27 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        }
        Boolean flag = healthCareService.isHospitalFlag();
        if (flag){
            String result = healthCareService.authorizedToEntrace(basePatientDO.getId());
            JSONObject object = JSONObject.parseObject(result);
            if (object.getString("flag").equalsIgnoreCase("1")){
                JSONObject encryptData = object.getJSONObject("encrypt_data");
                String state = encryptData.getString("state");
                String auth_date = encryptData.getString("auth_date");
                basePatientDO.setMedicalState(state);
                basePatientDO = basePatientDao.save(basePatientDO);
            if(wxId.equalsIgnoreCase("xm_xzzx_wx")){
                String result = healthCareService.authorizedToEntrace(basePatientDO.getId());
                JSONObject object = JSONObject.parseObject(result);
                if (object.getString("flag").equalsIgnoreCase("1")){
                    JSONObject encryptData = object.getJSONObject("encrypt_data");
                    String state = encryptData.getString("state");
                    String auth_date = encryptData.getString("auth_date");
                    basePatientDO.setMedicalState(state);
                    basePatientDO = basePatientDao.save(basePatientDO);
                }
            }else {
                String result = healthCareService.authorized(basePatientDO.getId());
                JSONObject object = JSONObject.parseObject(result);
                if (object.getString("flag").equalsIgnoreCase("1")){
                    JSONObject encryptData = object.getJSONObject("encrypt_data");
                    String state = encryptData.getString("state");
                    String auth_date = encryptData.getString("auth_date");
                    basePatientDO.setMedicalState(state);
                    basePatientDO = basePatientDao.save(basePatientDO);
                }
            }
        }
        return basePatientDO;
    }
@ -809,13 +820,13 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
                dictName="jiaoshinv";
                break;
            case "2-4-1"://助老员男
                dictName="shegongnan";
                dictName="zhulaoyuannan";
                break;
            case "2-4-2"://助老员女
                dictName="shegongnv";
                dictName="zhulaoyuannv";
                break;
            default:
                dictName="jiashunan";
                dictName="zhulaoyuannan";
                break;
        }
        String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='hz_default_avatar' and dict_code='"+dictName+"' ";

+ 15 - 3
business/base-service/src/main/java/com/yihu/jw/utils/YkyySMSService.java

@ -7,10 +7,12 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.dao.WlyyInspectionDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
@ -38,9 +40,9 @@ import java.util.Map;
@Service
public class YkyySMSService {
    private static final Logger logger = LoggerFactory.getLogger(YkyySMSService.class);
    private final String usrCode ="300643";
    private final String usrCode ="301312";
    private final String pw ="T9IHN69DDF";
    private final String pw ="3PRCADHD2M";
    private final String urlSms ="https://smsapp.wlwx.com";
    private final static String url="http://192.168.20.55:10023/ykyy/createSQLQuery";
@ -54,6 +56,8 @@ public class YkyySMSService {
    private WxPushLogDao wxPushLogDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    /**
     * 发送短信验证码
@ -63,7 +67,15 @@ public class YkyySMSService {
     */
    public ResultMsg ykyySendSMS(String mobile, String content){
        SmsClient smsClient = new SmsClient();
        return smsClient.sendSms("ykyy",usrCode, content,mobile,"yes","","8",urlSms,pw);
        WlyyHttpLogDO httpLogDO = new WlyyHttpLogDO();
        ResultMsg resultMsg= smsClient.sendSms("ykyy",usrCode, content,mobile,"yes","","8",urlSms,pw);
        httpLogDO.setCode("sendSms");
        httpLogDO.setRequest(mobile+content);
        httpLogDO.setResponse(resultMsg.getMsg()+resultMsg.getCode()+resultMsg.getData());
        httpLogDO.setCreateTime(new Date());
        httpLogDO.setName("短信发送");
        wlyyHttpLogDao.save(httpLogDO);
        return resultMsg;
    }
    public void sendSmsByTempcode(String temlateCode, WlyyOutpatientDO wlyyOutpatientDO, WlyyPrescriptionDO wlyyPrescriptionDO,String doctorMobile){
        SmsTemplateDO smsTemplateDO =  null;

+ 4 - 0
business/base-service/src/mqConfig/esbmq-config.xml

@ -97,6 +97,10 @@
				<BS15051_0>EwellQ.S60.BS15051.PUT</BS15051_0>
				<BS15051_1>EwellQ.S60.BS15051.GET</BS15051_1>
				<!--his确认结算接口-->
				<BS15039_0>EwellQ.S60.BS15039.PUT</BS15039_0>
				<BS15039_1>EwellQ.S60.BS15039.GET</BS15039_1>
				<!--检查检验start-->
				<BS20030_0>EwellQ.S60.BS20030.PUT</BS20030_0>
				<BS20030_1>EwellQ.S60.BS20030.GET</BS20030_1>

+ 2 - 2
business/sms-service/src/main/java/com/yihu/jw/sms/service/YkyyINSMSService.java

@ -14,9 +14,9 @@ import org.springframework.stereotype.Service;
@Service
public class YkyyINSMSService {
    private static final Logger logger = LoggerFactory.getLogger(YkyyINSMSService.class);
    private final String usrCode ="300643";
    private final String usrCode ="301312";
    private final String pw ="T9IHN69DDF";
    private final String pw ="3PRCADHD2M";
    private final String urlSms ="https://smsapp.wlwx.com";
    @Autowired

+ 16 - 1
common/common-entity/sql记录

@ -1789,4 +1789,19 @@ ALTER TABLE base_device_health_index add `power_value` varchar(20) DEFAULT NULL
ALTER TABLE base_device_health_index add `at_id` varchar(50) DEFAULT NULL COMMENT 'at';
--2022-04-12
ALTER TABLE wlyy_role add column `level` tinyint(2) DEFAULT NULL COMMENT '1省2市3区县4机构5团队6医生'
ALTER TABLE wlyy_role add column `level` tinyint(2) DEFAULT NULL COMMENT '1省2市3区县4机构5团队6医生'
-- 2022-04-24
CREATE TABLE `base_patient_monitor_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民code',
  `patient_name` varchar(50) DEFAULT NULL COMMENT '姓名',
  `category_code` varchar(50) DEFAULT NULL COMMENT '设备类型标识1血糖仪,2.血压计,4智能手表..',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '设备SN码',
  `type` int(1) DEFAULT NULL COMMENT '检测类型',
  `device_info` varchar(2000) DEFAULT NULL COMMENT '设备数据内容',
  `relation_code` varchar(50) DEFAULT NULL COMMENT '关联id',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_patient` (`patient`)
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8mb4 COMMENT='设备监测日志记录表';

+ 31 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -298,6 +298,37 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    private String appletQrCode;
    private Integer sort;//排序
    private String idCardType;//证件类别
    private String idType;//身份类别
    public String getIdCardType() {
        return idCardType;
    }
    public void setIdCardType(String idCardType) {
        this.idCardType = idCardType;
    }
    public String getIdType() {
        return idType;
    }
    public void setIdType(String idType) {
        this.idType = idType;
    }
    @Column(name = "sort")
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @Column(name = "applet_qr_code")
    public String getAppletQrCode() {
        return appletQrCode;

+ 4 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -236,6 +236,10 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
     */
    private Date loginDate;
    /**
     * 互联网医院 眼科通userId
     * 医养项目 水表户号
     */
    private String userId;
    /**

+ 99 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BasePatientMonitorDataDO.java

@ -0,0 +1,99 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2022/4/25.
 * 居民设备监测日志
 */
@Entity
@Table(name = "base_patient_monitor_data")
@SequenceGenerator(name="id_generated", sequenceName="seq_base_patient_monitor_data")
public class BasePatientMonitorDataDO extends IdEntity {
    private String patient;
    private String patientName;
    private String categoryCode;
    private String deviceSn;
    /**
     * 当前已用TYPE类型:
     *  1血糖测量 2血压测量,5心率,7呼吸,8步数,9定位上传,10温度(烟感),11床带状态更新(睡眠带),14燃气浓度,15烟雾浓度,
     *  20紧急呼叫 22安防预警
     */
    private Integer type;
    private String deviceInfo;
    private String relationCode;
    private Date createTime;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getDeviceInfo() {
        return deviceInfo;
    }
    public void setDeviceInfo(String deviceInfo) {
        this.deviceInfo = deviceInfo;
    }
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -318,7 +318,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String serviceStatus;//服务类型 1-预约项目 2-即时项目
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    private String doctorConfirmFinishImg;
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带 6气感报警器 7 烟感报警器 8拐杖发起
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带 6气感报警器 7 烟感报警器 8拐杖发起 9智慧水表
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片

+ 448 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/healthUpload/BaseDoctorHealthUploadDO.java

@ -0,0 +1,448 @@
package com.yihu.jw.entity.healthUpload;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 医生成员表
 *
 * @author Administrator on  2018年09月05日
 *
 */
@Entity
@Table(name = "base_doctor_health_upload")
public class BaseDoctorHealthUploadDO extends UuidIdentityEntityWithOperator {
    public String provinceName;
    public String cityName;
    public String townName;
    public String streetName;
    public String address;
    public String temperature;
    public Integer healthCode;
    public String healthCodeUrl;
    public Integer tourCode;
    public String tourCodeUrl;
    public Integer isSymptoms;
    public String abnormalSymptoms;
    public Integer isEpidemic;
    public String epidemicPerson;
    public Integer  isOutside;
    public String outsideProvinceCode;
    public String outsideProvinceName;
    public String outsideCityCode;
    public String outsideCityName;
    public String outsideTownCode;
    public String outsideTownName;
    public String outsideStreetName;
    public String outsideStreetCode;
    public String outsideAddress;
    public Date outsideDate;
    public Integer isNucleate;
    public String nucleateCodeUrl;
    public Integer  isOutsideHigh;
    public String outsideHighProvinceCode;
    public String outsideHighProvinceName;
    public String outsideHighCityCode;
    public String outsideHighCityName;
    public String outsideHighTownCode;
    public String outsideHighTownName;
    public String outsideHighStreetName;
    public String outsideHighStreetCode;
    public String outsideHighAddress;
    public Date outsideHighDate;
    public String doctorId;
    public String doctorName;
    public String idCard;
    public String mobile;
    public String consumer;
    public String consumerName;
    public String healthCodeDesc;
    public Integer outsideHighNucleate;
    public String abnormalSymptomsOther;
    public String getAbnormalSymptomsOther() {
        return abnormalSymptomsOther;
    }
    public void setAbnormalSymptomsOther(String abnormalSymptomsOther) {
        this.abnormalSymptomsOther = abnormalSymptomsOther;
    }
    public Integer getOutsideHighNucleate() {
        return outsideHighNucleate;
    }
    public void setOutsideHighNucleate(Integer outsideHighNucleate) {
        this.outsideHighNucleate = outsideHighNucleate;
    }
    public String getHealthCodeDesc() {
        return healthCodeDesc;
    }
    public void setHealthCodeDesc(String healthCodeDesc) {
        this.healthCodeDesc = healthCodeDesc;
    }
    public String getNucleateCodeUrl() {
        return nucleateCodeUrl;
    }
    public void setNucleateCodeUrl(String nucleateCodeUrl) {
        this.nucleateCodeUrl = nucleateCodeUrl;
    }
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getTemperature() {
        return temperature;
    }
    public void setTemperature(String temperature) {
        this.temperature = temperature;
    }
    public Integer getHealthCode() {
        return healthCode;
    }
    public void setHealthCode(Integer healthCode) {
        this.healthCode = healthCode;
    }
    public String getHealthCodeUrl() {
        return healthCodeUrl;
    }
    public void setHealthCodeUrl(String healthCodeUrl) {
        this.healthCodeUrl = healthCodeUrl;
    }
    public Integer getTourCode() {
        return tourCode;
    }
    public void setTourCode(Integer tourCode) {
        this.tourCode = tourCode;
    }
    public String getTourCodeUrl() {
        return tourCodeUrl;
    }
    public void setTourCodeUrl(String tourCodeUrl) {
        this.tourCodeUrl = tourCodeUrl;
    }
    public Integer getIsSymptoms() {
        return isSymptoms;
    }
    public void setIsSymptoms(Integer isSymptoms) {
        this.isSymptoms = isSymptoms;
    }
    public String getAbnormalSymptoms() {
        return abnormalSymptoms;
    }
    public void setAbnormalSymptoms(String abnormalSymptoms) {
        this.abnormalSymptoms = abnormalSymptoms;
    }
    public Integer getIsEpidemic() {
        return isEpidemic;
    }
    public void setIsEpidemic(Integer isEpidemic) {
        this.isEpidemic = isEpidemic;
    }
    public String getEpidemicPerson() {
        return epidemicPerson;
    }
    public void setEpidemicPerson(String epidemicPerson) {
        this.epidemicPerson = epidemicPerson;
    }
    public Integer getIsOutside() {
        return isOutside;
    }
    public void setIsOutside(Integer isOutside) {
        this.isOutside = isOutside;
    }
    public String getOutsideProvinceCode() {
        return outsideProvinceCode;
    }
    public void setOutsideProvinceCode(String outsideProvinceCode) {
        this.outsideProvinceCode = outsideProvinceCode;
    }
    public String getOutsideProvinceName() {
        return outsideProvinceName;
    }
    public void setOutsideProvinceName(String outsideProvinceName) {
        this.outsideProvinceName = outsideProvinceName;
    }
    public String getOutsideCityCode() {
        return outsideCityCode;
    }
    public void setOutsideCityCode(String outsideCityCode) {
        this.outsideCityCode = outsideCityCode;
    }
    public String getOutsideCityName() {
        return outsideCityName;
    }
    public void setOutsideCityName(String outsideCityName) {
        this.outsideCityName = outsideCityName;
    }
    public String getOutsideTownCode() {
        return outsideTownCode;
    }
    public void setOutsideTownCode(String outsideTownCode) {
        this.outsideTownCode = outsideTownCode;
    }
    public String getOutsideTownName() {
        return outsideTownName;
    }
    public void setOutsideTownName(String outsideTownName) {
        this.outsideTownName = outsideTownName;
    }
    public String getOutsideStreetName() {
        return outsideStreetName;
    }
    public void setOutsideStreetName(String outsideStreetName) {
        this.outsideStreetName = outsideStreetName;
    }
    public String getOutsideStreetCode() {
        return outsideStreetCode;
    }
    public void setOutsideStreetCode(String outsideStreetCode) {
        this.outsideStreetCode = outsideStreetCode;
    }
    public String getOutsideAddress() {
        return outsideAddress;
    }
    public void setOutsideAddress(String outsideAddress) {
        this.outsideAddress = outsideAddress;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "outside_date", nullable = false, length = 0,updatable = false)
    public Date getOutsideDate() {
        return outsideDate;
    }
    public void setOutsideDate(Date outsideDate) {
        this.outsideDate = outsideDate;
    }
    public Integer getIsNucleate() {
        return isNucleate;
    }
    public void setIsNucleate(Integer isNucleate) {
        this.isNucleate = isNucleate;
    }
    public Integer getIsOutsideHigh() {
        return isOutsideHigh;
    }
    public void setIsOutsideHigh(Integer isOutsideHigh) {
        this.isOutsideHigh = isOutsideHigh;
    }
    public String getOutsideHighProvinceCode() {
        return outsideHighProvinceCode;
    }
    public void setOutsideHighProvinceCode(String outsideHighProvinceCode) {
        this.outsideHighProvinceCode = outsideHighProvinceCode;
    }
    public String getOutsideHighProvinceName() {
        return outsideHighProvinceName;
    }
    public void setOutsideHighProvinceName(String outsideHighProvinceName) {
        this.outsideHighProvinceName = outsideHighProvinceName;
    }
    public String getOutsideHighCityCode() {
        return outsideHighCityCode;
    }
    public void setOutsideHighCityCode(String outsideHighCityCode) {
        this.outsideHighCityCode = outsideHighCityCode;
    }
    public String getOutsideHighCityName() {
        return outsideHighCityName;
    }
    public void setOutsideHighCityName(String outsideHighCityName) {
        this.outsideHighCityName = outsideHighCityName;
    }
    public String getOutsideHighTownCode() {
        return outsideHighTownCode;
    }
    public void setOutsideHighTownCode(String outsideHighTownCode) {
        this.outsideHighTownCode = outsideHighTownCode;
    }
    public String getOutsideHighTownName() {
        return outsideHighTownName;
    }
    public void setOutsideHighTownName(String outsideHighTownName) {
        this.outsideHighTownName = outsideHighTownName;
    }
    public String getOutsideHighStreetName() {
        return outsideHighStreetName;
    }
    public void setOutsideHighStreetName(String outsideHighStreetName) {
        this.outsideHighStreetName = outsideHighStreetName;
    }
    public String getOutsideHighStreetCode() {
        return outsideHighStreetCode;
    }
    public void setOutsideHighStreetCode(String outsideHighStreetCode) {
        this.outsideHighStreetCode = outsideHighStreetCode;
    }
    public String getOutsideHighAddress() {
        return outsideHighAddress;
    }
    public void setOutsideHighAddress(String outsideHighAddress) {
        this.outsideHighAddress = outsideHighAddress;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "outside_high_date", nullable = false, length = 0,updatable = false)
    public Date getOutsideHighDate() {
        return outsideHighDate;
    }
    public void setOutsideHighDate(Date outsideHighDate) {
        this.outsideHighDate = outsideHighDate;
    }
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getIdCard() {
        return idCard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getConsumer() {
        return consumer;
    }
    public void setConsumer(String consumer) {
        this.consumer = consumer;
    }
    public String getConsumerName() {
        return consumerName;
    }
    public void setConsumerName(String consumerName) {
        this.consumerName = consumerName;
    }
}

+ 95 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/healthUpload/BaseDoctorMemberDO.java

@ -0,0 +1,95 @@
package com.yihu.jw.entity.healthUpload;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * 医生成员表
 *
 * @author Administrator on  2018年09月05日
 *
 */
@Entity
@Table(name = "base_doctor_member")
public class BaseDoctorMemberDO extends UuidIdentityEntityWithOperator {
    private String doctorId;//医生id
    private String memberId;//成员id
    private Integer del;//删除标志(1正常,0删除)
    private Integer memberRelation;//成员关系
    private BaseDoctorDO baseDoctorDO;
    private String count;
    private List<BaseDoctorHospitalDO> doctorHospitalDOS;
    @Transient
    public List<BaseDoctorHospitalDO> getDoctorHospitalDOS() {
        return doctorHospitalDOS;
    }
    public void setDoctorHospitalDOS(List<BaseDoctorHospitalDO> doctorHospitalDOS) {
        this.doctorHospitalDOS = doctorHospitalDOS;
    }
    @Transient
    public String getCount() {
        return count;
    }
    public void setCount(String count) {
        this.count = count;
    }
    @Transient
    public BaseDoctorDO getBaseDoctorDO() {
        return baseDoctorDO;
    }
    public void setBaseDoctorDO(BaseDoctorDO baseDoctorDO) {
        this.baseDoctorDO = baseDoctorDO;
    }
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    public String getMemberId() {
        return memberId;
    }
    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public Integer getMemberRelation() {
        return memberRelation;
    }
    public void setMemberRelation(Integer memberRelation) {
        this.memberRelation = memberRelation;
    }
}

+ 245 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/healthCare/YlzMedicalRelationDO.java

@ -65,6 +65,107 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    private Date createTime;//创建时间',
    private String detailSerial;//医保明细流水号
    private Integer status;//结算状态
    private String diseaseCode;//病种编码
    private String treatmentType;//人员待遇类别
    private String treatmentTypeName;//人员待遇类别名称
    private String treatmentStatus;//医疗待遇状态
    private String treatmentStatusName;//医疗待遇状态名称
    private String allopatryType;//异地就医类型
    private String allopatryTypeName;//异地就医类型名称
    private String administrativeArea;//参保地行政区划
    private String payStandard;//统筹支付医保费用起付标准
    private String tcjjPay;//其中:统筹基金支付
    private String sbjjPay;//其中:商保基金支付(大额补充)
    private String gwyPay;//其中:公务员医疗补助
    private String jzfpPay;//其中:精准扶贫医疗叠加
    private String yljzPay;//其中:医疗救助基金
    private String otherPay;//其中:其他基金支付
    private String enterpriseSupplement;//其中:企业补充
    private String jtgjPay;//家庭共济账户支付
    private String collector;//收费人
    private String pageCode;//结算code
    private String insuranceType;//险种类型(医保类型)
    private String insuranceTypeName;//险种类型名称
    private Integer state;//his结算状态(1结算0未结算)
    private Integer medicalState;//0自费1医保
    private String hisDesc;//his结算描述
    private String balance;//预交金余额
    private String medicalPrice;//医保基金总额
    private Date settleDate;//his结算时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name="settle_date")
    public Date getSettleDate() {
        return settleDate;
    }
    public void setSettleDate(Date settleDate) {
        this.settleDate = settleDate;
    }
    public String getMedicalPrice() {
        return medicalPrice;
    }
    public void setMedicalPrice(String medicalPrice) {
        this.medicalPrice = medicalPrice;
    }
    public String getBalance() {
        return balance;
    }
    public void setBalance(String balance) {
        this.balance = balance;
    }
    public String getHisDesc() {
        return hisDesc;
    }
    public void setHisDesc(String hisDesc) {
        this.hisDesc = hisDesc;
    }
    public Integer getMedicalState() {
        return medicalState;
    }
    public void setMedicalState(Integer medicalState) {
        this.medicalState = medicalState;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public String getInsuranceType() {
        return insuranceType;
    }
    public void setInsuranceType(String insuranceType) {
        this.insuranceType = insuranceType;
    }
    public String getInsuranceTypeName() {
        return insuranceTypeName;
    }
    public void setInsuranceTypeName(String insuranceTypeName) {
        this.insuranceTypeName = insuranceTypeName;
    }
    public String getPageCode() {
        return pageCode;
    }
    public void setPageCode(String pageCode) {
        this.pageCode = pageCode;
    }
    public Integer getStatus() {
        return status;
@ -485,4 +586,148 @@ public class YlzMedicalRelationDO extends UuidIdentityEntity {
    public void setDoctorLevel(String doctorLevel) {
        this.doctorLevel = doctorLevel;
    }
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    public String getTreatmentType() {
        return treatmentType;
    }
    public void setTreatmentType(String treatmentType) {
        this.treatmentType = treatmentType;
    }
    public String getTreatmentTypeName() {
        return treatmentTypeName;
    }
    public void setTreatmentTypeName(String treatmentTypeName) {
        this.treatmentTypeName = treatmentTypeName;
    }
    public String getTreatmentStatus() {
        return treatmentStatus;
    }
    public void setTreatmentStatus(String treatmentStatus) {
        this.treatmentStatus = treatmentStatus;
    }
    public String getTreatmentStatusName() {
        return treatmentStatusName;
    }
    public void setTreatmentStatusName(String treatmentStatusName) {
        this.treatmentStatusName = treatmentStatusName;
    }
    public String getAllopatryType() {
        return allopatryType;
    }
    public void setAllopatryType(String allopatryType) {
        this.allopatryType = allopatryType;
    }
    public String getAllopatryTypeName() {
        return allopatryTypeName;
    }
    public void setAllopatryTypeName(String allopatryTypeName) {
        this.allopatryTypeName = allopatryTypeName;
    }
    public String getAdministrativeArea() {
        return administrativeArea;
    }
    public void setAdministrativeArea(String administrativeArea) {
        this.administrativeArea = administrativeArea;
    }
    public String getPayStandard() {
        return payStandard;
    }
    public void setPayStandard(String payStandard) {
        this.payStandard = payStandard;
    }
    public String getTcjjPay() {
        return tcjjPay;
    }
    public void setTcjjPay(String tcjjPay) {
        this.tcjjPay = tcjjPay;
    }
    public String getSbjjPay() {
        return sbjjPay;
    }
    public void setSbjjPay(String sbjjPay) {
        this.sbjjPay = sbjjPay;
    }
    public String getGwyPay() {
        return gwyPay;
    }
    public void setGwyPay(String gwyPay) {
        this.gwyPay = gwyPay;
    }
    public String getJzfpPay() {
        return jzfpPay;
    }
    public void setJzfpPay(String jzfpPay) {
        this.jzfpPay = jzfpPay;
    }
    public String getYljzPay() {
        return yljzPay;
    }
    public void setYljzPay(String yljzPay) {
        this.yljzPay = yljzPay;
    }
    public String getOtherPay() {
        return otherPay;
    }
    public void setOtherPay(String otherPay) {
        this.otherPay = otherPay;
    }
    public String getEnterpriseSupplement() {
        return enterpriseSupplement;
    }
    public void setEnterpriseSupplement(String enterpriseSupplement) {
        this.enterpriseSupplement = enterpriseSupplement;
    }
    public String getJtgjPay() {
        return jtgjPay;
    }
    public void setJtgjPay(String jtgjPay) {
        this.jtgjPay = jtgjPay;
    }
    public String getCollector() {
        return collector;
    }
    public void setCollector(String collector) {
        this.collector = collector;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java

@ -57,6 +57,7 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private String historyOrder;
    private String depositType; //原充值类型
    @Column(name = "history_order")
    public String getHistoryOrder() {
        return historyOrder;

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -496,6 +496,7 @@ public class BaseHospitalRequestMapping {
        public static final String selectOrderByRelationCode = "/selectOrderByRelationCode";
        public static final String ylzRechargeJson="ylzRechargeJson";
        public static final String ylzRechargePre="ylzRechargePre";
        public static final String yktMedicalCardTopUp="/yktMedicalCardTopUp";
@ -1474,6 +1475,7 @@ public class BaseHospitalRequestMapping {
        public static final String update  = "/update";
        public static final String updateList  = "/updateList";
        public static final String updateStatus  = "/updateStatus";
        public static final String updateSort  = "/updateSort";
        public static final String updateDoctorPw  = "/updateDoctorPw";
    }

+ 528 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyHisSettleVO.java

@ -0,0 +1,528 @@
package com.yihu.jw.restmodel.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionEmrDO;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import java.util.List;
/**
 * 
 * 在线结算确认实体VO
 *
 *
 *
 */
@ApiModel(value = "WlyyHisSettleVO", description = "在线结算确认")
public class WlyyHisSettleVO extends UuidIdentityVOWithOperator {
    /**
     * 患者卡号
     */
    @ApiModelProperty(value = "患者卡号", example = "患者卡号")
    private String cardNo;
    /**
     * HIS 系统跟踪号
     */
    @ApiModelProperty(value = "HIS 系统跟踪号",example = "HIS 系统跟踪号")
    private String xtgzh0;
    /**
     * 机构编号(医院编号)
     */
    @ApiModelProperty(value = "机构编号(医院编号)",example = "机构编号(医院编号)")
    private String orgCode;
    /**
     * 充值方式(自费金额支付方式)
     */
    @ApiModelProperty(value = "充值方式(自费金额支付方式)",example = "充值方式(自费金额支付方式)")
    private String depositType;
    /**
     * 充值金额
     */
    @ApiModelProperty(value = "充值金额",example = "充值金额")
    private String depositAmount;
    /**
     * 信用支付 0-否 1-是
     */
    @ApiModelProperty(value = "信用支付 0-否 1-是",example = "信用支付 0-否 1-是")
    private String xyzf00;
    /**
     * 渠道类型
     */
    @ApiModelProperty(value = "渠道类型",example = "渠道类型")
    private String channelType;
    /**
     * 平台结算流水号
     */
    @ApiModelProperty(value = "平台结算流水号",example = "平台结算流水号")
    private String outChargeNo;
    /**
     * 单据流水号(医保收费流水号)
     */
    @ApiModelProperty(value = "单据流水号(医保收费流水号)",example = "单据流水号(医保收费流水号)")
    private String djlsh0;
    /**
     * 门诊流水号(医保挂号流水号)
     */
    @ApiModelProperty(value = "门诊流水号(医保挂号流水号)",example = "门诊流水号(医保挂号流水号)")
    private String mzlsh0;
    /**
     * 帐户支付额
     */
    @ApiModelProperty(value = "帐户支付额",example = "帐户支付额")
    private String zhzfe0;
    /**
     * 个人支付额
     */
    @ApiModelProperty(value = "个人支付额",example = "个人支付额")
    private String grzfe0;
    /**
     * 基金支付额
     */
    @ApiModelProperty(value = "基金支付额",example = "基金支付额")
    private String jjzfe0;
    /**
     * 公务员补助
     */
    @ApiModelProperty(value = "公务员补助",example = "公务员补助")
    private String gwybz0;
    /**
     * 非医保费用
     */
    @ApiModelProperty(value = "非医保费用",example = "非医保费用")
    private String fybfy0;
    /**
     * 超封顶线金额
     */
    @ApiModelProperty(value = "超封顶线金额",example = "超封顶线金额")
    private String cfdxje;
    /**
     * 保健基金支付
     */
    @ApiModelProperty(value = "保健基金支付",example = "保健基金支付")
    private String bjjjzf;
    /**
     * 本次报销总额
     */
    @ApiModelProperty(value = "本次报销总额",example = "本次报销总额")
    private String bcbxf0;
    /**
     * 收费日期
     */
    @ApiModelProperty(value = "收费日期",example = "收费日期")
    private String sfrq00;
    /**
     * 收费时间
     */
    @ApiModelProperty(value = "收费时间",example = "收费时间")
    private String sfsj00;
    /**
     * 收费人姓名
     */
    @ApiModelProperty(value = "收费人姓名",example = "收费人姓名")
    private String sfrxm0;
    /**
     * 医保帐户余额
     */
    @ApiModelProperty(value = "医保帐户余额",example = "医保帐户余额")
    private String grzhye;
    /**
     * 乙类支付额
     */
    @ApiModelProperty(value = "乙类支付额",example = "乙类支付额")
    private String ylzfje;
    /**
     * 健康账户支付
     */
    @ApiModelProperty(value = "健康账户支付",example = "健康账户支付")
    private String jkzhzf;
    /**
     * 健康账户余额
     */
    @ApiModelProperty(value = "健康账户余额",example = "健康账户余额")
    private String jkzhye;
    /**
     * 医保明细上传流水号
     */
    @ApiModelProperty(value = "医保明细上传流水号",example = "医保明细上传流水号")
    private String ybmxls;
    /**
     * 对账数据分类
     */
    @ApiModelProperty(value = "对账数据分类",example = "对账数据分类")
    private String dzsjfl;
    /**
     * 商业保险支付
     */
    @ApiModelProperty(value = "商业保险支付",example = "商业保险支付")
    private String sybxzf;
    /**
     * 本地共计账户支付
     */
    @ApiModelProperty(value = "本地共计账户支付",example = "本地共计账户支付")
    private String bdgjzf;
    /**
     * 异地共计账户支付
     */
    @ApiModelProperty(value = "异地共计账户支付",example = "异地共计账户支付")
    private String ydgjzf;
    /**
     * 本次看病次数
     */
    @ApiModelProperty(value = "本次看病次数",example = "本次看病次数")
    private String bckbcs;
    /**
     * 补助基金支付
     */
    @ApiModelProperty(value = "补助基金支付",example = "补助基金支付")
    private String bzjjzf;
    /**
     * 人员编号
     */
    @ApiModelProperty(value = "人员编号",example = "人员编号")
    private String psnNo;
    /**
     * 参保地行政区号
     */
    @ApiModelProperty(value = "参保地行政区号",example = "参保地行政区号")
    private String aab301;
    /**
     * 险种
     */
    @ApiModelProperty(value = "险种",example = "险种")
    private String insutype;
    /**
     * 医保结算时间
     */
    @ApiModelProperty(value = "医保结算时间",example = "医保结算时间")
    private String setlTime;
    public String getSetlTime() {
        return setlTime;
    }
    public void setSetlTime(String setlTime) {
        this.setlTime = setlTime;
    }
    public String getPsnNo() {
        return psnNo;
    }
    public void setPsnNo(String psnNo) {
        this.psnNo = psnNo;
    }
    public String getAab301() {
        return aab301;
    }
    public void setAab301(String aab301) {
        this.aab301 = aab301;
    }
    public String getInsutype() {
        return insutype;
    }
    public void setInsutype(String insutype) {
        this.insutype = insutype;
    }
    public String getBzjjzf() {
        return bzjjzf;
    }
    public void setBzjjzf(String bzjjzf) {
        this.bzjjzf = bzjjzf;
    }
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    public String getXtgzh0() {
        return xtgzh0;
    }
    public void setXtgzh0(String xtgzh0) {
        this.xtgzh0 = xtgzh0;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getDepositType() {
        return depositType;
    }
    public void setDepositType(String depositType) {
        this.depositType = depositType;
    }
    public String getDepositAmount() {
        return depositAmount;
    }
    public void setDepositAmount(String depositAmount) {
        this.depositAmount = depositAmount;
    }
    public String getXyzf00() {
        return xyzf00;
    }
    public void setXyzf00(String xyzf00) {
        this.xyzf00 = xyzf00;
    }
    public String getChannelType() {
        return channelType;
    }
    public void setChannelType(String channelType) {
        this.channelType = channelType;
    }
    public String getOutChargeNo() {
        return outChargeNo;
    }
    public void setOutChargeNo(String outChargeNo) {
        this.outChargeNo = outChargeNo;
    }
    public String getDjlsh0() {
        return djlsh0;
    }
    public void setDjlsh0(String djlsh0) {
        this.djlsh0 = djlsh0;
    }
    public String getMzlsh0() {
        return mzlsh0;
    }
    public void setMzlsh0(String mzlsh0) {
        this.mzlsh0 = mzlsh0;
    }
    public String getZhzfe0() {
        return zhzfe0;
    }
    public void setZhzfe0(String zhzfe0) {
        this.zhzfe0 = zhzfe0;
    }
    public String getGrzfe0() {
        return grzfe0;
    }
    public void setGrzfe0(String grzfe0) {
        this.grzfe0 = grzfe0;
    }
    public String getJjzfe0() {
        return jjzfe0;
    }
    public void setJjzfe0(String jjzfe0) {
        this.jjzfe0 = jjzfe0;
    }
    public String getGwybz0() {
        return gwybz0;
    }
    public void setGwybz0(String gwybz0) {
        this.gwybz0 = gwybz0;
    }
    public String getFybfy0() {
        return fybfy0;
    }
    public void setFybfy0(String fybfy0) {
        this.fybfy0 = fybfy0;
    }
    public String getCfdxje() {
        return cfdxje;
    }
    public void setCfdxje(String cfdxje) {
        this.cfdxje = cfdxje;
    }
    public String getBjjjzf() {
        return bjjjzf;
    }
    public void setBjjjzf(String bjjjzf) {
        this.bjjjzf = bjjjzf;
    }
    public String getSybxzf() {
        return sybxzf;
    }
    public void setSybxzf(String sybxzf) {
        this.sybxzf = sybxzf;
    }
    public String getBdgjzf() {
        return bdgjzf;
    }
    public void setBdgjzf(String bdgjzf) {
        this.bdgjzf = bdgjzf;
    }
    public String getYdgjzf() {
        return ydgjzf;
    }
    public void setYdgjzf(String ydgjzf) {
        this.ydgjzf = ydgjzf;
    }
    public String getBckbcs() {
        return bckbcs;
    }
    public void setBckbcs(String bckbcs) {
        this.bckbcs = bckbcs;
    }
    public String getBcbxf0() {
        return bcbxf0;
    }
    public void setBcbxf0(String bcbxf0) {
        this.bcbxf0 = bcbxf0;
    }
    public String getSfrq00() {
        return sfrq00;
    }
    public void setSfrq00(String sfrq00) {
        this.sfrq00 = sfrq00;
    }
    public String getSfsj00() {
        return sfsj00;
    }
    public void setSfsj00(String sfsj00) {
        this.sfsj00 = sfsj00;
    }
    public String getSfrxm0() {
        return sfrxm0;
    }
    public void setSfrxm0(String sfrxm0) {
        this.sfrxm0 = sfrxm0;
    }
    public String getGrzhye() {
        return grzhye;
    }
    public void setGrzhye(String grzhye) {
        this.grzhye = grzhye;
    }
    public String getYlzfje() {
        return ylzfje;
    }
    public void setYlzfje(String ylzfje) {
        this.ylzfje = ylzfje;
    }
    public String getJkzhzf() {
        return jkzhzf;
    }
    public void setJkzhzf(String jkzhzf) {
        this.jkzhzf = jkzhzf;
    }
    public String getJkzhye() {
        return jkzhye;
    }
    public void setJkzhye(String jkzhye) {
        this.jkzhye = jkzhye;
    }
    public String getYbmxls() {
        return ybmxls;
    }
    public void setYbmxls(String ybmxls) {
        this.ybmxls = ybmxls;
    }
    public String getDzsjfl() {
        return dzsjfl;
    }
    public void setDzsjfl(String dzsjfl) {
        this.dzsjfl = dzsjfl;
    }
}

+ 45 - 1
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -34,6 +34,7 @@ public class DateUtil {
    public static final String YYYY_MM_DD_HH_MM_SS_ = "yyyy/MM/dd HH:mm:ss";
    public static final String YYYYMMddHHmmssSSS  = "yyyyMMddHHmmssSSS";
    public static final String YYYY_MM ="yyyy-MM";
    public static final String YYYYMMDD_HH_MM_SS = "yyyyMMdd HH:mm:ss";
    public static Date dateTimeParse(String date) throws ParseException {
        return new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss).parse(date);
@ -257,6 +258,21 @@ public class DateUtil {
        return formatter.parse(strDate, pos);
    }
    /**
     * 将长时间格式字符串转换为时间 yyyyMMdd HH:mm:ss
     *
     * @param strDate
     * @return
     */
    public static Date strToYmdDateLong(String strDate) {
        if (StringUtils.isEmpty(strDate)) {
            return null;
        }
        SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDD_HH_MM_SS);
        ParsePosition pos = new ParsePosition(0);
        return formatter.parse(strDate, pos);
    }
    public static Date strToDateShort(String strDate) {
        if (StringUtils.isEmpty(strDate)) {
            return null;
@ -279,6 +295,20 @@ public class DateUtil {
        SimpleDateFormat formatter = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
        return formatter.format(dateDate);
    }
    /**
     * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
     *
     * @param dateDate
     * @return
     */
    public static String dateToStrFormatLong(java.util.Date dateDate) {
        if (dateDate == null) {
            return "";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDDHHMMSS);
        return formatter.format(dateDate);
    }
    public static String dateToStrNoSecond(java.util.Date dateDate) {
        if (dateDate == null) {
            return "";
@ -287,7 +317,21 @@ public class DateUtil {
        return formatter.format(dateDate);
    }
    /**
     * 将长时间格式时间转换为字符串 yyyy-MM-dd
     * 将长时间格式时间转换为字符串 YYYYMMDD
     *
     * @param dateDate
     * @return
     */
    public static String dateToStrFormatShort(java.util.Date dateDate) {
        if (dateDate == null) {
            return "";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDD);
        return formatter.format(dateDate);
    }
    /**
     * 将长时间格式时间转换为字符串 yyyyMMdd
     *
     * @param dateDate
     * @return

+ 64 - 63
common/common-web/src/main/resources/logback-spring.xml

@ -26,7 +26,8 @@
	</appender>
    <!-- Api Log Start -->
    <appender name="ApiInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 先注释调,不生成日志文件,只在控制台生成
   <appender name="ApiInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/api/info/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
@ -36,7 +37,7 @@
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <level>OFF</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
@ -52,7 +53,7 @@
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <level>OFF</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
@ -68,61 +69,61 @@
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <level>OFF</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    </appender>-->
    <!-- Api Log End -->
    <!-- Business Log Start -->
    <appender name="BusinessInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/business/info/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender name="BusinessWarnFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/business/warn/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender name="BusinessErrorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/business/error/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
<!--    <appender name="BusinessInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--            <fileNamePattern>${log_home}/business/info/%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--            <maxHistory>${max_history}</maxHistory>-->
<!--        </rollingPolicy>-->
<!--        <encoder>-->
<!--            <pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--            <charset class="java.nio.charset.Charset">UTF-8</charset>-->
<!--        </encoder>-->
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>OFF</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->
<!--        </filter>-->
<!--    </appender>-->
<!--    <appender name="BusinessWarnFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--            <fileNamePattern>${log_home}/business/warn/%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--            <maxHistory>${max_history}</maxHistory>-->
<!--        </rollingPolicy>-->
<!--        <encoder>-->
<!--            <pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--            <charset class="java.nio.charset.Charset">UTF-8</charset>-->
<!--        </encoder>-->
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>OFF</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->
<!--        </filter>-->
<!--    </appender>-->
<!--    <appender name="BusinessErrorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--            <fileNamePattern>${log_home}/business/error/%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--            <maxHistory>${max_history}</maxHistory>-->
<!--        </rollingPolicy>-->
<!--        <encoder>-->
<!--            <pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--            <charset class="java.nio.charset.Charset">UTF-8</charset>-->
<!--        </encoder>-->
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>OFF</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->
<!--        </filter>-->
<!--    </appender>-->
    <!-- Business Log End -->
    <!-- 如果微服务纳入全局异常处理,请勿修改以上代码,有新的日志处理请在以下追加!!! -->
@ -130,19 +131,19 @@
    <!-- Other Log End -->
    <!-- 针对接口调用出错日志(单独记录) -->
    <logger name="com.yihu.jw.web.handler.GlobalExceptionHandler" level="WARN" additivity="false">
        <appender-ref ref="console" />
        <appender-ref ref="ApiInfoFile" />
        <appender-ref ref="ApiWarnFile" />
        <appender-ref ref="ApiErrorFile" />
    </logger>
<!--    <logger name="com.yihu.jw.web.handler.GlobalExceptionHandler" level="OFF" additivity="false">-->
<!--        <appender-ref ref="console" />-->
<!--        <appender-ref ref="ApiInfoFile" />-->
<!--        <appender-ref ref="ApiWarnFile" />-->
<!--        <appender-ref ref="ApiErrorFile" />-->
<!--    </logger>-->
    <!-- 业务日志 -->
    <logger name="com.yihu.jw">
        <appender-ref ref="BusinessInfoFile" />
        <appender-ref ref="BusinessWarnFile" />
        <appender-ref ref="BusinessErrorFile" />
    </logger>
<!--    <logger name="com.yihu.jw">-->
<!--        <appender-ref ref="BusinessInfoFile" />-->
<!--        <appender-ref ref="BusinessWarnFile" />-->
<!--        <appender-ref ref="BusinessErrorFile" />-->
<!--    </logger>-->
    <!-- 基础日志 -->
	<root level="INFO">

+ 63 - 64
common/common-web/src/main/resources/logback-spring.xml-bak

@ -26,8 +26,7 @@
	</appender>
    <!-- Api Log Start -->
<!-- 先注释调,不生成日志文件,只在控制台生成
   <appender name="ApiInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <appender name="ApiInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/api/info/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
@ -37,7 +36,7 @@
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>OFF</level>
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
@ -53,7 +52,7 @@
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>OFF</level>
            <level>WARN</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
@ -69,61 +68,61 @@
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>OFF</level>
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>-->
    </appender>
    <!-- Api Log End -->
    <!-- Business Log Start -->
<!--    <appender name="BusinessInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--            <fileNamePattern>${log_home}/business/info/%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--            <maxHistory>${max_history}</maxHistory>-->
<!--        </rollingPolicy>-->
<!--        <encoder>-->
<!--            <pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--            <charset class="java.nio.charset.Charset">UTF-8</charset>-->
<!--        </encoder>-->
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>OFF</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->
<!--        </filter>-->
<!--    </appender>-->
<!--    <appender name="BusinessWarnFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--            <fileNamePattern>${log_home}/business/warn/%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--            <maxHistory>${max_history}</maxHistory>-->
<!--        </rollingPolicy>-->
<!--        <encoder>-->
<!--            <pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--            <charset class="java.nio.charset.Charset">UTF-8</charset>-->
<!--        </encoder>-->
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>OFF</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->
<!--        </filter>-->
<!--    </appender>-->
<!--    <appender name="BusinessErrorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--            <fileNamePattern>${log_home}/business/error/%d{yyyy-MM-dd}.log</fileNamePattern>-->
<!--            <maxHistory>${max_history}</maxHistory>-->
<!--        </rollingPolicy>-->
<!--        <encoder>-->
<!--            <pattern>${FILE_LOG_PATTERN}</pattern>-->
<!--            <charset class="java.nio.charset.Charset">UTF-8</charset>-->
<!--        </encoder>-->
<!--        <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--            <level>OFF</level>-->
<!--            <onMatch>ACCEPT</onMatch>-->
<!--            <onMismatch>DENY</onMismatch>-->
<!--        </filter>-->
<!--    </appender>-->
    <appender name="BusinessInfoFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/business/info/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender name="BusinessWarnFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/business/warn/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>WARN</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <appender name="BusinessErrorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log_home}/business/error/%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>${max_history}</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>
    <!-- Business Log End -->
    <!-- 如果微服务纳入全局异常处理,请勿修改以上代码,有新的日志处理请在以下追加!!! -->
@ -131,19 +130,19 @@
    <!-- Other Log End -->
    <!-- 针对接口调用出错日志(单独记录) -->
<!--    <logger name="com.yihu.jw.web.handler.GlobalExceptionHandler" level="OFF" additivity="false">-->
<!--        <appender-ref ref="console" />-->
<!--        <appender-ref ref="ApiInfoFile" />-->
<!--        <appender-ref ref="ApiWarnFile" />-->
<!--        <appender-ref ref="ApiErrorFile" />-->
<!--    </logger>-->
    <logger name="com.yihu.jw.web.handler.GlobalExceptionHandler" level="WARN" additivity="false">
        <appender-ref ref="console" />
        <appender-ref ref="ApiInfoFile" />
        <appender-ref ref="ApiWarnFile" />
        <appender-ref ref="ApiErrorFile" />
    </logger>
    <!-- 业务日志 -->
<!--    <logger name="com.yihu.jw">-->
<!--        <appender-ref ref="BusinessInfoFile" />-->
<!--        <appender-ref ref="BusinessWarnFile" />-->
<!--        <appender-ref ref="BusinessErrorFile" />-->
<!--    </logger>-->
    <logger name="com.yihu.jw">
        <appender-ref ref="BusinessInfoFile" />
        <appender-ref ref="BusinessWarnFile" />
        <appender-ref ref="BusinessErrorFile" />
    </logger>
    <!-- 基础日志 -->
	<root level="INFO">

+ 1 - 1
gateway/ag-basic/pom.xml

@ -12,7 +12,7 @@
    <artifactId>ag-basic</artifactId>
    <version>${parent.version}</version>
    <packaging>jar</packaging>
    <packaging>war</packaging>
    <dependencies>
        <!-- 支持Tomcat启动 -->

+ 1 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -112,6 +112,7 @@ public class BasicZuulFilter extends ZuulFilter {
                url.contains("/prescription/pushListWrite")||
                url.contains("/prescription/pushListDrug")||
                url.contains("/open/noLogin/pushYkCardCharge")||
                url.contains("/open/noLogin/pushListWriteHealthInfo")||
                url.contains("/prescription/searchRecordWrite")||
                url.contains("/Funds/reconciliationExcel")||
                url.contains("/Funds/deviceInfoExcel"))){

+ 6 - 2
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java

@ -63,6 +63,7 @@ public class PostFilter extends ZuulFilter {
        if (url.contains("/excelControl")||url.contains("/prescription/pushListWrite")||
                url.contains("/prescription/pushListDrug")||
                url.contains("/open/noLogin/pushYkCardCharge")||
                url.contains("/open/noLogin/pushListWriteHealthInfo")||
                url.contains("/prescription/searchRecordWrite")||
                url.contains("/Funds/reconciliationExcel")||
                url.contains("/Funds/deviceInfoExcel")){
@ -79,6 +80,7 @@ public class PostFilter extends ZuulFilter {
            bytes = StreamUtils.copyToByteArray(stream);
        }
        String body = new String(bytes,"UTF8");
        /*String serviceId="";
        String responseCode="";
        String exceptionType="";
@ -126,7 +128,7 @@ public class PostFilter extends ZuulFilter {
        }catch (Exception e){
            e.printStackTrace();
        }*/
        logger.info("body",body);
        logger.info("body",body+"=====status====="+ctx.getResponseStatusCode());
        JSONObject object = new JSONObject();
        object.put("status","200");
        object.put("data", AesEncryptUtils.encrypt(body));
@ -141,6 +143,7 @@ public class PostFilter extends ZuulFilter {
                url.contains("/prescription/pushListWrite")||
                url.contains("/prescription/pushListDrug")||
                url.contains("/open/noLogin/pushYkCardCharge")||
                url.contains("/open/noLogin/pushListWriteHealthInfo")||
                url.contains("/prescription/searchRecordWrite")||
                url.contains("/Funds/reconciliationExcel")||
                url.contains("/Funds/deviceInfoExcel")||url.contains("/open/noEntry"))){
@ -148,7 +151,8 @@ public class PostFilter extends ZuulFilter {
        }else {
            RequestContext.getCurrentContext().setResponseBody(body);
        }
        logger.info(ctx.getResponseBody()+"");
        logger.info("请求返回参数:"+ctx.getResponseBody()+"");
        } catch (Exception e) {
            e.printStackTrace();
        }

+ 8 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -1022,6 +1022,14 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                    patient1.setUpdateTime(new Date());
                    patient1.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
                    patient1 = patientDao.save(patient1);
                    List<BasePatientWechatDo> patientWechatDoList = basePatientWechatDao.findByWechatIdAndPatientId("xm_hcyy_wx",patient1.getId());
                    basePatientWechatDao.delete(patientWechatDoList);
                    BasePatientWechatDo patientWechatDo = new BasePatientWechatDo();
                    patientWechatDo.setOpenid(openid);
                    patientWechatDo.setPatientId(patient1.getId());
                    patientWechatDo.setWechatId("xm_hcyy_wx");
                    patientWechatDo.setCreateTime(new Date());
                    basePatientWechatDao.save(patientWechatDo);
                    logger.info("结束同步患者数据");
                }
            }

+ 4 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -1,5 +1,6 @@
package com.yihu.jw.security.oauth2.provider;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
@ -428,7 +429,9 @@ public class WlyyTokenGranter implements TokenGranter {
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
            OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(storedOAuth2Request, userAuth);
            logger.info("username===oAuth2Authentication==="+ JSONObject.toJSONString(oAuth2Authentication));
            return oAuth2Authentication;
        }
    }

+ 121 - 140
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -262,164 +262,144 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
     */
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
            logger.info("login:登录进入1");
            //图形验证码验证
            String key = parameters.get("key");
            String text = parameters.get("text");
        logger.info("login:登录进入1");
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
                throw new ImgCaptchaException("img_captcha error");
            if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
                if(!verifyCaptcha(key,text)){
                    throw new ImgCaptchaException("验证码错误!");
                }
            }
        }
        logger.info("login:登录进入2");
            logger.info("login:登录进入2");
        String flag = parameters.get("flag");
            String flag = parameters.get("flag");
        String username = parameters.get("username");
        logger.info(username);
            String username = parameters.get("username");
            logger.info(username);
        if (StringUtils.isEmpty(username)&&StringUtils.isEmpty(flag)) {
            throw new InvalidRequestException("username");
        }
        String client_id = parameters.get("client_id");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if("alipay".equals(flag)||"family".equals(flag)){
            //支付宝登录||家人登录
            parameters.put("grant_type", flag);
            String encdata = parameters.get("encdata");
            if("alipay".equals(flag)){
                encdata = AES.decrypt(encdata);
            }else{
                encdata = AesEncryptUtils.agDecrypt(encdata);
            }
            String data[] = encdata.split(":");
            username = data[1];
            parameters.put("username", username);
        }else if("dingTalk".equals(flag)){
            //钉钉免登录
            parameters.put("grant_type", "dingTalk");
            String authCode = parameters.get("authCode");
            if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                throw new InvalidRequestException("请求参数错误");
            }
            String registerRes= httpClientUtil.get("http://127.0.0.1:10301/doctor/dingtalk_app_user?authCode="+authCode,"UTF-8");
            JSONObject jsonObject= JSONObject.parseObject(registerRes);
            if (jsonObject.getInteger("status") == 200){
                parameters.put("username", jsonObject.getString("message"));
            }else{
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("message"), -1, null);
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
        }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            //解密密码
            if (parameters.get("password") != null) {
                KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                parameters.put("password", password);
            } else {
                //第三方同步账号模式登录
                parameters.put("grant_type", "ihealthCode");
            if (StringUtils.isEmpty(username)&&StringUtils.isEmpty(flag)) {
                throw new InvalidRequestException("username");
            }
        } else {
            parameters.put("grant_type", "captcha");
        }
        logger.info("login:登录进入3");
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        if (null == authenticatedClient) {
            throw new InvalidRequestException("client_id");
        }
        logger.info("login:登录进入4"+authenticatedClient.getClientId());
            String client_id = parameters.get("client_id");
            if (StringUtils.isEmpty(client_id)) {
                throw new InvalidRequestException("client_id");
            }
            if("alipay".equals(flag)||"family".equals(flag)){
                //支付宝登录||家人登录
                parameters.put("grant_type", flag);
                String encdata = parameters.get("encdata");
                if("alipay".equals(flag)){
                    encdata = AES.decrypt(encdata);
                }else{
                    encdata = AesEncryptUtils.agDecrypt(encdata);
                }
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
    /*如果是移动端登陆则移除之前的token,
    在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
    实现同一账号只能在一处登陆*/
        if("1".equals(kickEachOther)){
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                if (tokenStore.readAccessToken(token.getValue())!=null){
                    tokenStore.removeAccessToken(token.getValue());
                    tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                    token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                String data[] = encdata.split(":");
                username = data[1];
                parameters.put("username", username);
            }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
                parameters.put("grant_type", "password");
                //解密密码
                if (parameters.get("password") != null) {
                    KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
                    String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
                    parameters.put("password", password);
                } else {
                    //第三方同步账号模式登录
                    parameters.put("grant_type", "ihealthCode");
                }
            } else {
                parameters.put("grant_type", "captcha");
            }
            logger.info("login:登录进入3");
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            if (null == authenticatedClient) {
                throw new InvalidRequestException("client_id");
            }
            logger.info("login:登录进入4"+authenticatedClient.getClientId());
            TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
            OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
        }
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
            if("1".equals(kickEachOther)){
                HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
                if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                    if (tokenStore.readAccessToken(token.getValue())!=null){
                        tokenStore.removeAccessToken(token.getValue());
                        tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                        token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
                    }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
            throw new InvalidGrantException("不允许登录该平台");
        }
        logger.info("wlyyUserSimple::"+wlyyUserSimple);
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        String wechatId = parameters.get("wechatId");
        logger.info("login:登录进入7");
        //更新患者openId
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        logger.info("gengxin开始");
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(openid);
            logger.info("gengxin进入"+openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                logger.info("gengxin进入"+wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
                }
                if (token == null) {
                    throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
                }
            }
        }
        if (parameters.get("password") != null) {
            //使用密码登录成功后, 更新失败次数为 0
            userDetailsService.addFailureCount(username, 0);
        }
        logger.info("login:登录进入8");
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        logger.info("login:登录进入9");
        String clientType = parameters.get("clientType");
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
        baseLoginLogDO.setCreateTime(new Date());
        String userAgent = JSONObject.toJSONString(wlyyUserSimple);
        baseLoginLogDO.setUserAgent(userAgent);
        baseLoginLogDO.setLoginType(loginType);
        baseLoginLogDO.setName(wlyyUserSimple.getName());
        baseLoginLogDO.setClientType(clientType);
        baseLoginLogDO.setToken(token.getValue());
        baseLoginLogService.save(baseLoginLogDO);
        logger.info("login:登录进入10");
            WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
            if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
                throw new InvalidGrantException("不允许登录该平台");
            }
            logger.info("wlyyUserSimple::"+wlyyUserSimple);
            wlyyUserSimple.setAccessToken(token.getValue());
            wlyyUserSimple.setTokenType(token.getTokenType());
            wlyyUserSimple.setExpiresIn(token.getExpiresIn());
            wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
            wlyyUserSimple.setUser(parameters.get("username"));
            wlyyUserSimple.setState(parameters.get("state"));
            String loginType = parameters.get("login_type");
            String openid = parameters.get("openid");
            String wechatId = parameters.get("wechatId");
            logger.info("login:登录进入7");
            //更新患者openId
            BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
            logger.info("gengxin开始");
            if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
                baseLoginLogDO.setOpenid(openid);
                logger.info("gengxin进入"+openid);
                userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
                if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                    logger.info("gengxin进入"+wechatId);
                    userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
                }
            }
            if (parameters.get("password") != null) {
                //使用密码登录成功后, 更新失败次数为 0
                userDetailsService.addFailureCount(username, 0);
            }
            logger.info("login:登录进入8");
        //个推 clientId
        String clientId = parameters.get("getuiClientId");
        String getuiClientType = parameters.get("getuiClientType");
        String padImei = parameters.get("padImei");
        //客户端类型 app,wx,pad,pc
        userDetailsService.updateInfo(clientId,getuiClientType,padImei,loginType,wlyyUserSimple.getId(),baseLoginLogDO);
            userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        return getResponse(wlyyUserSimple);
            logger.info("login:登录进入9");
            String clientType = parameters.get("clientType");
            baseLoginLogDO.setUserId(wlyyUserSimple.getId());
            baseLoginLogDO.setCreateTime(new Date());
            String userAgent = JSONObject.toJSONString(wlyyUserSimple);
            baseLoginLogDO.setUserAgent(userAgent);
            baseLoginLogDO.setLoginType(loginType);
            baseLoginLogDO.setName(wlyyUserSimple.getName());
            baseLoginLogDO.setClientType(clientType);
            baseLoginLogDO.setToken(token.getValue());
            baseLoginLogService.save(baseLoginLogDO);
            logger.info("login:登录进入10");
            //个推 clientId
            String clientId = parameters.get("getuiClientId");
            String getuiClientType = parameters.get("getuiClientType");
            String padImei = parameters.get("padImei");
            //客户端类型 app,wx,pad,pc
            userDetailsService.updateInfo(clientId,getuiClientType,padImei,loginType,wlyyUserSimple.getId(),baseLoginLogDO);
            return getResponse(wlyyUserSimple);
    }
@ -2057,6 +2037,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                basePatientDO.setDel("1");
                basePatientDO.setEnabled(1);
                basePatientDO.setLocked(0);
                basePatientDO.setName(name);
                basePatientDO.setCreateTime(new Date());
                basePatientDO.setUpdateTime(new Date());

+ 8 - 7
server/svr-authentication/src/main/java/com/yihu/jw/security/service/HcyyService.java

@ -17,6 +17,7 @@ import com.yihu.jw.security.utils.WebserviceUtil;
import com.yihu.utils.security.MD5;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -51,7 +52,7 @@ public class HcyyService {
    @Autowired
    private OauthRsaKeyDao rsaKeyDao;
    private static String caKey ="";
    private static String caKey ="bvvsf3JA0mUXMU+mVnMaOQ==";
    static {
        System.setProperty("kasite.appId", APP_ID);
        System.setProperty("kasite.appSecret", APP_SECRET);
@ -84,7 +85,7 @@ public class HcyyService {
        logger.info("url"+url);
        List<WlyyHospitalSysDictDO> xzzxNamespaces =  wlyyHospitalSysDictDao.findByDictName("hcyyCaNamespace");
        List<WlyyHospitalSysDictDO> xzzxNamespaces =  wlyyHospitalSysDictDao.findByDictName("hcyyNamespace");
        String xzzxNamespace = xzzxNamespaces.get(0).getDictCode();
@ -120,7 +121,7 @@ public class HcyyService {
                "   <callOperator></callOperator> " +
                "   <certificate>"+caKey+"</certificate> " +
                "</root>";
        String condition ="{\"apiName\":\""+apiCode+"\",\"version\":\"v1\",\"jsonData\":\""+jsonData+"\"}";
        String condition ="{\"apiName\":\""+apiCode+"\",\"version\":\"v1\",\"jsonData\":\""+ StringEscapeUtils.escapeJson(jsonData)+"\"}";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
@ -147,7 +148,7 @@ public class HcyyService {
     * @throws Exception
     */
    public String token() throws Exception {
        String businessSystemId = "";
        String businessSystemId = "1518527107887804418";
        Long timestamp = new Date().getTime();
        List<OauthRsaKeyDO> oauthRsaKeyDOs = rsaKeyDao.findByCodeAndAppId("hcyyCa","hcyyCa");
        if (oauthRsaKeyDOs==null||oauthRsaKeyDOs.size()==0){
@ -155,11 +156,11 @@ public class HcyyService {
        }
        OauthRsaKeyDO oauthRsaKeyDO = oauthRsaKeyDOs.get(0);
        String res = "businessSystemId="+businessSystemId+"&timestamp="+timestamp;
        String signature = RSAEncrypt.encrypt(res,oauthRsaKeyDO.getPrivateKey());
        String signature = RSAEncrypt.encrypt(res,oauthRsaKeyDO.getPublicKey());
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("businessSystemId",businessSystemId);
        jsonObject.put("timestamp",timestamp);
        jsonObject.put("signature",signature);
        jsonObject.put("timestamp",timestamp+"");
        jsonObject.put("signature","");
        String result = XMCA_DCS_UnifiedInterface("获取访问令牌接口","authorize/token",jsonObject.toJSONString());
        if (StringUtils.isNoneBlank(result)){
            JSONObject object = JSONObject.parseObject(result);

+ 12 - 12
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAEncrypt.java

@ -85,17 +85,17 @@ public class RSAEncrypt {
    }
//    public static void main(String[] args) throws Exception {
//        //生成公钥和私钥
//        Map<Integer, String> keyMap = genKeyPair();
//        //加密字符串
//        String message = "test";
//        System.out.println("随机生成的公钥为:" + keyMap.get(0));
//        System.out.println("随机生成的私钥为:" + keyMap.get(1));
//        String messageEn = encrypt(message,keyMap.get(0));
//        System.out.println(message + "\t加密后的字符串为:" + messageEn);
//        String messageDe = decrypt(messageEn,keyMap.get(1));
//        System.out.println("还原后的字符串为:" + messageDe);
//    }
    public static void main(String[] args) throws Exception {
        //生成公钥和私钥
        Map<Integer, String> keyMap = genKeyPair();
        //加密字符串
        String message = "test";
        System.out.println("随机生成的公钥为:" + keyMap.get(0));
        System.out.println("随机生成的私钥为:" + keyMap.get(1));
        String messageEn = encrypt(message,keyMap.get(0));
        System.out.println(message + "\t加密后的字符串为:" + messageEn);
        String messageDe = decrypt(messageEn,keyMap.get(1));
        System.out.println("还原后的字符串为:" + messageDe);
    }
}

+ 5 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -168,9 +168,11 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            return result;
        }
        List<WlyyHospitalSysDictDO> list = wlyyHospitalSysDictDao.findByDictName("doctor_level");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
            if (doctors.getLevel().equals(wlyyHospitalSysDictDO.getDictCode())){
                doctors.setLevelName(wlyyHospitalSysDictDO.getDictValue());
        if (null!=doctors.getLevel()){
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
                if (doctors.getLevel().equals(wlyyHospitalSysDictDO.getDictCode())){
                    doctors.setLevelName(wlyyHospitalSysDictDO.getDictValue());
                }
            }
        }
        //医生归属业务模块角色信息,非必填,数据可有可没有

+ 8 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/menu/BaseMenuManageService.java

@ -23,6 +23,7 @@ import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
@ -680,6 +681,13 @@ public class BaseMenuManageService {
        System.out.print("menuId"+menuId);
        List<KnowledgeArticleDictDO> list=knowledgeArticleDictDao.findByCategorySecondAndPage(menuIds,pageRequest);
        List<KnowledgeArticleDictDO> listnew = new ArrayList<>();
        BeanUtils.copyProperties(listnew,list);
        for (KnowledgeArticleDictDO dictDO:list){
            dictDO.setContent(null);
        }
        Integer count = knowledgeArticleDictDao.getCountByCategorySecond(menuIds);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setTotalCount(count);

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BasePatientMonitorDataDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BasePatientMonitorDataDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2022/4/25.
 */
public interface BasePatientMonitorDataDao extends PagingAndSortingRepository<BasePatientMonitorDataDO,Long>,
        JpaSpecificationExecutor<BasePatientMonitorDataDO> {
}

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceDataPushLogDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceDataPushLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/9/2.
 */
public interface DeviceDataPushLogDao extends PagingAndSortingRepository<DeviceDataPushLog,Long>,
        JpaSpecificationExecutor<DeviceDataPushLog> {
}

+ 18 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.admin;
import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
import com.yihu.jw.care.service.common.CommomService;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.care.util.DingdingUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
@ -47,6 +48,20 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
    private CommomService commomService;
    @Autowired
    private DingdingUtil dingdingUtil;
    @Autowired
    private CarePatientService carePatientService;
    @GetMapping(value = "open/initJczdPerson")
    @ApiOperation(value = "初始化杭州老人")
    public Envelop initJczdPerson(Integer size) {
        try {
            //start=133480 size=10000
            carePatientService.initJczdPerson(size);
            return success("初始化成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @GetMapping(value = "open/testZzd")
    @ApiOperation(value = "测试浙政钉")
@ -180,11 +195,11 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "open/WXtempleateSendTest")
    @ApiOperation(value = "微信模板消息推送")
    @GetMapping(value = "open/shuiBiaoInit")
    @ApiOperation(value = "水表用户初始化")
    public Envelop setRedisEnable() {
        try {
            commomService.WXtempleateSendTest();
            commomService.shuiBiaoInit();
            return success("success");
        } catch (Exception e) {
            return failedException2(e);

+ 31 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java

@ -13,6 +13,7 @@ import com.yihu.jw.care.useragent.UserAgent;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.patient.BaseDeviceRepairEntity;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -236,7 +237,7 @@ public class DoctorDeviceController extends BaseController {
        try {
            JSONObject param = new JSONObject();
            param.put("doctorId",doctor);
            if(permissionService.noPermission(2,param)){
            if(permissionService.noPermission(1,param)){
                return write(-1,"该操作没有权限");
            }
            return write(200,"成功","data",deviceManageService.getRepairList(doctor,categoryCode,patientName,page,pageSize,status));
@ -253,7 +254,7 @@ public class DoctorDeviceController extends BaseController {
        try {
			JSONObject param = new JSONObject();
			param.put("doctorId",permissionService.getUID());
			if(permissionService.noPermission(2,param)){
			if(permissionService.noPermission(1,param)){
				return write(-1,"该操作没有权限");
			}
            return write(200,"成功","data",deviceManageService.getRepairInfo(orderId));
@ -270,8 +271,8 @@ public class DoctorDeviceController extends BaseController {
        try {
			String doctor = permissionService.getUID();
			JSONObject param = new JSONObject();
			param.put("doctorId",userAgent.getUID());
			if(permissionService.noPermission(2,param)){
			param.put("doctorId",doctor);
			if(permissionService.noPermission(1,param)){
				return write(-1,"该操作没有权限");
			}
			BaseDeviceRepairEntity baseDeviceRepairEntity = JSON.parseObject(repairJson, BaseDeviceRepairEntity.class);
@ -286,6 +287,31 @@ public class DoctorDeviceController extends BaseController {
			return errorResult(e);
        }
    }
	
	@RequestMapping(value = "/getPatientMonitorData",method = RequestMethod.GET)
	@ApiOperation(value="获取居民设备监护数据")
	public PageEnvelop getPatientMonitorData(@ApiParam(name = "patient",value = "patient")
							   				@RequestParam(value = "patient")String patient,
											 @ApiParam(name = "startTime",value = "开始时间yyyy-MM-dd HH:mm:ss")
											 @RequestParam(value = "startTime")String startTime,
											 @ApiParam(name = "endTime",value = "endTime")
											 @RequestParam(value = "endTime")String endTime,
											 @ApiParam(name = "page",value = "page")
											 @RequestParam(value = "page")Integer page,
											 @ApiParam(name = "size",value = "size")
											 @RequestParam(value = "size")Integer size){
		try {
			String doctor = permissionService.getUID();
			JSONObject param = new JSONObject();
			param.put("doctorId",doctor);
			if(permissionService.noPermission(1,param)){
				return PageEnvelop.getSuccess("该操作没有权限");
			}
			return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size);
		} catch (Exception e) {
			e.printStackTrace();
			return PageEnvelop.getError("系统繁忙");
		}
	}
}

+ 32 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -5,7 +5,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.common.PermissionService;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.DeviceManageService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -14,6 +16,7 @@ import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -55,6 +58,10 @@ public class PatientDeviceController extends BaseController {
    private DeviceDetailService deviceDetailService;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    DeviceManageService deviceManageService;
    @Autowired
    PermissionService permissionService;
@ -489,6 +496,30 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @RequestMapping(value = "/getPatientMonitorData",method = RequestMethod.GET)
    @ApiOperation(value="获取居民设备监护数据")
    public PageEnvelop getPatientMonitorData(@ApiParam(name = "patient",value = "patient")
                                             @RequestParam(value = "patient")String patient,
                                             @ApiParam(name = "startTime",value = "开始时间yyyy-MM-dd HH:mm:ss")
                                             @RequestParam(value = "startTime")String startTime,
                                             @ApiParam(name = "endTime",value = "endTime")
                                             @RequestParam(value = "endTime")String endTime,
                                             @ApiParam(name = "page",value = "page")
                                             @RequestParam(value = "page")Integer page,
                                             @ApiParam(name = "size",value = "size")
                                             @RequestParam(value = "size")Integer size){
        try {
			String perPatient = permissionService.getUID();
            com.alibaba.fastjson.JSONObject param = new com.alibaba.fastjson.JSONObject();
			param.put("patient",perPatient);
			if(permissionService.noPermission(1,param)){
				return PageEnvelop.getSuccess("该操作没有权限");
			}
            return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return PageEnvelop.getError("系统繁忙");
        }
    }
}

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java

@ -8,6 +8,7 @@ import com.yihu.jw.care.service.org.BaseOrgService;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -233,4 +234,20 @@ public class DoctorLifeCareEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientItemDict")
    @ApiOperation(value = "查找居民已预约的服务项")
    public ListEnvelop findPatientItemDict(@ApiParam(value = "patient", name = "patient")
                                           @RequestParam(value = "patient", required = false) String patient) {
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("doctorId",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return ListEnvelop.getError("该操作没有权限");
            }
            return ListEnvelop.getSuccess("查询成功",lifeCareOrderService.findPatientItemDict(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java

@ -89,7 +89,7 @@ public class PadLifeCareEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status, page, size);
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,null, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }

+ 24 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java

@ -89,10 +89,11 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
    public PageEnvelop page(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status, page, size);
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,fedCode, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }
@ -106,9 +107,10 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
    @GetMapping(value = "infoCount")
    @ApiOperation(value = "查询工单数量")
    public ObjEnvelop infoCount(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode) {
        try {
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null, 1, 5);
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null,fedCode, 1, 5);
            if (allResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(allResult.getString(ResponseContant.resultMsg), -1);
            }
@ -116,14 +118,14 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
            JSONObject object = new JSONObject();
            object.put("allCount",allCount);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, 1, 5);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, fedCode,1, 5);
            if (qxResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(qxResult.getString(ResponseContant.resultMsg), -1);
            }
            int qxCount = qxResult.getIntValue(ResponseContant.count);
            object.put("qxCount",qxCount);
            JSONObject wcResult = lifeCareOrderService.queryInfoList(patient, 2, 1, 5);
            JSONObject wcResult = lifeCareOrderService.queryInfoList(patient, 2, fedCode,1, 5);
            if (wcResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(wcResult.getString(ResponseContant.resultMsg), -1);
            }
@ -136,7 +138,7 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "findItemDict")
    @ApiOperation(value = "查找服务项字典")
    @ApiOperation(value = "查找所有服务项字典")
    public ListEnvelop findItemDict(@ApiParam(value = "orgCode", name = "orgCode")
                                   @RequestParam(value = "orgCode", required = false) String orgCode) {
        try {
@ -146,6 +148,22 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientItemDict")
    @ApiOperation(value = "查找居民已预约的服务项")
    public ListEnvelop findPatientItemDict(@ApiParam(value = "patient", name = "patient")
                                    @RequestParam(value = "patient", required = false) String patient) {
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("patient",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return ListEnvelop.getError("该操作没有权限");
            }
            return ListEnvelop.getSuccess("查询成功",lifeCareOrderService.findPatientItemDict(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping("getByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单")
    public ObjEnvelop getByOrderId(

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -113,9 +113,9 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
                                               @ApiParam(name = "deviceName",value = "设备名字",required = false)
                                               @RequestParam(value = "deviceName",required = false)String deviceName,
                                               @ApiParam(name = "area")
                                                   @RequestParam(value = "area") String area,
                                               @RequestParam(value = "area",required = false) String area,
                                               @ApiParam(name = "level")
                                                   @RequestParam(value = "level") String level
                                               @RequestParam(value = "level",required = false) String level
                                               ){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorMessageService.getDeviceLostMessageList(doctor,deviceCode,deviceName,area,level));

+ 35 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.security;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.common.PermissionService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import com.yihu.jw.restmodel.ResponseContant;
@ -28,6 +29,8 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @Autowired
    private PermissionService permissionService;
    @PostMapping(value = "createOrder")
    @ApiOperation(value = "创建安防服务工单")
@ -523,4 +526,36 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "patient/getPatientDeviceTopic")
    @ApiOperation(value = "居民获取智慧安防专题")
    public ListEnvelop getPatientDeviceTopicP(@ApiParam(name="patient",value = "patient")
                                            @RequestParam(value = "patient") String patient){
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("patient",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return ListEnvelop.getError("该操作没有权限");
            }
            return ListEnvelop.getSuccess("获取成功",securityMonitoringOrderService.getPatientDeviceTopic(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "doctor/getPatientDeviceTopic")
    @ApiOperation(value = "医生获取居民智慧安防专题")
    public ListEnvelop getPatientDeviceTopicD(@ApiParam(name="patient",value = "patient")
                                           @RequestParam(value = "patient") String patient){
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("doctorId",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return ListEnvelop.getError("该操作没有权限");
            }
            return ListEnvelop.getSuccess("获取成功",securityMonitoringOrderService.getPatientDeviceTopic(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 23 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.DeviceManageService;
import com.yihu.jw.care.service.device.NetworkCardService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
@ -43,6 +44,8 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @Autowired
    private NetworkCardService networkCardService;
    @Autowired
    private DeviceManageService deviceManageService;
    @ApiOperation("环境信息")
@ -393,4 +396,24 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "/getPatientMonitorData",method = RequestMethod.GET)
    @ApiOperation(value="获取居民设备监护数据")
    public PageEnvelop getPatientMonitorData(@ApiParam(name = "patient",value = "patient")
                                             @RequestParam(value = "patient")String patient,
                                             @ApiParam(name = "startTime",value = "开始时间")
                                             @RequestParam(value = "startTime")String startTime,
                                             @ApiParam(name = "endTime",value = "endTime")
                                             @RequestParam(value = "endTime")String endTime,
                                             @ApiParam(name = "page",value = "page")
                                             @RequestParam(value = "page")Integer page,
                                             @ApiParam(name = "size",value = "size")
                                             @RequestParam(value = "size")Integer size){
        try {
            return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return PageEnvelop.getError("系统繁忙");
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -214,7 +214,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findUserByType")
    @ApiOperation(value = "人员实时动态搜索")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2老人,3社工,4医生,5老人家属。不传返回四个类型的数据")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2签约老人,3社工,4医生,5老人家属 6助老员,7社区老人(未签约).不传返回四个类型的数据")
                                  @RequestParam(value = "type", required = false) String type,
                                  @ApiParam(name = "name", value = "姓名")
                                  @RequestParam(value = "name", required = false) String name,

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

@ -76,6 +76,17 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findUnSignPatientLocations")
    @ApiOperation("查找未签约老人坐标")
    public PageEnvelop findUnSignPatientLocations(@ApiParam(name = "page")@RequestParam(value = "page")Integer page,
                                                  @ApiParam(name = "size")@RequestParam(value = "size")Integer size){
        try {
            return baseServiceNewsService.findUnSignPatientLocations(page,size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getLatLon")
    @ApiOperation("查询所有社工坐标")
    public ListEnvelop getLatLon(){

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

@ -23,10 +23,7 @@ import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.message.BaseServiceNewsService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.care.util.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -142,6 +139,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    private BaseServiceNewsService baseServiceNewsService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DeviceDataPushLogUtil deviceDataPushLogUtil;
    /**
     * 获取百度天气
@ -318,7 +317,9 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            emergencyAssistanceDao.save(assistanceDO);
            result.put("resultFlag", ResponseContant.success);
            result.put("resultMsg",assistanceDO);
            if (StringUtils.isNotBlank(assistanceDO.getDeviceSn())){
                deviceDataPushLogUtil.savePatientMonitorData(assistanceDO.getDeviceSn(),20,"发起紧急呼叫",assistanceDO.getId());
            }
            baseServiceNewsService.addServiceNews(patientDO.getName(),patientDO.getId(),"5",null,assistanceDO.getId(),1);
            return result;
        }

+ 59 - 67
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/common/CommomService.java

@ -1,8 +1,14 @@
package com.yihu.jw.care.service.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
@ -12,6 +18,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -30,73 +37,58 @@ public class CommomService {
    private MessageUtil messageUtil;
    @Value("${wechat.id}")
    private String wxId;
    //模板消息测试
    public void WXtempleateSendTest(){
        String patient="808080eb78d3ce030178edeb4346002b";
        BasePatientDO patientDO = basePatientDao.findById(patient);
        //获取家属
        String  sql = " select  t2.id,t2.name,t2.openid,'family3' as 'user' from  base_patient_family_member t1,  base_patient t2 where  " +
                "t2.id in (select family_member from base_patient_family_member where patient = '"+patient+"' )  " +
                " and t1.patient = '"+patient+"'  and t1.family_member = t2.id  " +
                " and t2.archive_type=3 GROUP BY t2.id " ;
        List<Map<String,Object>> relatives = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> docTmp:relatives){
            if ("family3".equals(docTmp.get("user").toString())){//设备离线推送给家属
                if(null!=docTmp.get("openid")&& StringUtils.isNotBlank(docTmp.get("openid").toString())){
                    String first = patientDO.getName()+" 血糖仪设备疑似离线";
                    String keyword1 = "【"+ DateUtil.getStringDate()+"】";
                    String keyword2 = "【设备离线】";
                    String keyword3 = patientDO.getName()+" 血糖仪设备疑似离线,请及时跟进";
                    messageUtil.putTemplateWxMessage(wxId,"template_error_notice","sblxtz",
                            docTmp.get("openid").toString(),first,null,null,38,new JSONObject(),keyword1,keyword2,keyword3);
                    first=patientDO.getName()+"已离家";
                    keyword2="【离家提醒】";
                    keyword3 = patientDO.getName()+"已离家,请及时跟进";
                    boolean success = messageUtil.putTemplateWxMessage(wxId,"template_error_notice","lrjjztgxtz",docTmp.get("openid").toString(),first,null,null,3,new JSONObject(),DateUtil.getStringDate(),keyword2,keyword3);
                    first=patientDO.getName()+"已到家";
                    keyword2="【到家提醒】";
                    keyword3 = patientDO.getName()+"已到家,请知悉";
                    messageUtil.putTemplateWxMessage(wxId,"template_error_notice","lrjjztgxtz",docTmp.get("openid").toString(),first,null,null,3,new JSONObject(),DateUtil.getStringDate(),keyword2,keyword3);
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("patientId",patient);
                    first = patientDO.getName()+"血糖超7天未测量";
                    keyword2="【血糖测量】";
                    keyword3=patientDO.getName()+"血糖超7天未测量,请及时跟进";
                    jsonObject.put("type","1");
                    messageUtil.putTemplateWxMessage(wxId,"template_error_notice","xyxtwcltz",docTmp.get("openid").toString(),first,null,null,3,jsonObject,keyword1,keyword2,keyword3);
                    jsonObject = new JSONObject();
                    first = patientDO.getName()+"血压未测量";
                    keyword2="【血压测量】";
                    keyword3=patientDO.getName()+"昨日未测量血压,请及时跟进";
                    jsonObject.put("type","2");
                    messageUtil.putTemplateWxMessage(wxId,"template_error_notice","xyxtwcltz",docTmp.get("openid").toString(),first,null,null,3,jsonObject,keyword1,keyword2,keyword3);
                    first = patientDO.getName()+"最新测量血糖值反馈";
                    keyword1 = DateUtil.getStringDate();
                    keyword2 = "早餐前血糖";
                    keyword3 = "【5.5mmol/L】";
                    String keyword4 = "请注意日常饮食";
                    messageUtil.putTemplateWxMessage(wxId,"template_measure_result_notice","jktzcljgtz",patientDO.getOpenid(),first,null,null,3,new JSONObject(),keyword1,keyword2,keyword3,keyword4);
                    first= patientDO.getName()+" 最新测量血压值反馈";
                    keyword1 =  DateUtil.getStringDate();
                    keyword2 = "血压";
                    keyword3 = "【收缩压:106mmgh 舒张压:65mmgh】";
                    keyword4 = "请注意日常饮食";
                    messageUtil.putTemplateWxMessage(wxId,"template_measure_result_notice","jktzcljgtz",patientDO.getOpenid(),first,null,null,3,new JSONObject(),keyword1,keyword2,keyword3,keyword4);
                }
            }
    @Autowired
    private DeviceDao deviceDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    //水表用户初始化
    public void shuiBiaoInit(){
        String sql = " select id,user_id,idcard from base_patient where user_id is NOT null and user_id<>'' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<DeviceDetail> deviceDetails = new ArrayList<>();
        List<DevicePatientDevice> patientDevices = new ArrayList<>();
        List<Device> dmDevices = deviceDao.findByCategoryCode("18");
        Device deviceDo = dmDevices.get(0);
        for (Map<String,Object> tmp:list){
            String patient = tmp.get("id").toString();
            String deviceSn = tmp.get("user_id").toString();
            String idcard = tmp.get("idcard").toString();
            DeviceDetail deviceDetail = new DeviceDetail();
            deviceDetail.setDeviceName(deviceDo.getName());
            deviceDetail.setDeviceCode(deviceSn);
            deviceDetail.setDeviceModel(deviceDo.getModel());
            deviceDetail.setCategoryCode(deviceDo.getCategoryCode());
            deviceDetail.setBindingCount("{\"1\":\"1\",\"2\":\"0\"}");
            deviceDetail.setContactStatus(1);
            deviceDetail.setDeviceType(1);
            deviceDetail.setIsGrant(1);
            deviceDetail.setGrantAdminTeam("0");
            deviceDetail.setManufacturer("泰安泰山金石机械有限责任公司");
            deviceDetail.setApplyDate(DateUtil.getStringDate());
            deviceDetails.add(deviceDetail);
            DevicePatientDevice patientDevice = new DevicePatientDevice();
            patientDevice.setDel(0);
            patientDevice.setUser(patient);
            patientDevice.setCategoryCode(deviceDo.getCategoryCode());
            patientDevice.setDeviceId(deviceDo.getId());
            patientDevice.setDeviceName(deviceDo.getName());
            patientDevice.setDeviceSn(deviceSn);
            patientDevice.setUserIdcard(idcard);
            patientDevice.setUserType("-1");
            patientDevice.setCzrq(new Date());
            patientDevice.setDeviceType(1);
            patientDevices.add(patientDevice);
        }
        if (patientDevices.size()>0){
            patientDeviceDao.save(patientDevices);
        }
        if (deviceDetails.size()>0){
            deviceDetailDao.save(deviceDetails);
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -248,7 +248,7 @@ public class ContactsService {
                    }
                }
                String[] numTmp = num.split("_");
                String sql = " select pd.device_sn,wd.iccid from  wlyy_patient_device pd inner join wlyy_devices wd  " +
                String sql = " select pd.device_sn,wd.iccid sim from  wlyy_patient_device pd inner join wlyy_devices wd  " +
                        "on pd.device_sn = wd.device_code and pd.del=0 and wd.iccid is not null and pd.category_code in('7','4')  " +
                        "where pd.user='"+patient+"' ";
                List<Map<String,Object>> sims = jdbcTemplate.queryForList(sql);

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

@ -11,6 +11,7 @@ import com.yihu.jw.entity.patient.BaseDeviceRepairEntity;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -232,4 +233,27 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
        return "success";
    }
    /**
     * 获取居民设备监测日志
     * @param patient
     * @param startTime
     * @param endTime
     * @param page
     * @param size
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> getPatientMonitorData(String patient,String startTime,String endTime,Integer page,Integer size){
        page = page>0?page-1:0;
        String sql = " select dm.name,dm.photo,dm.category_code,modata.patient,modata.patient_name,modata.device_info,modata.relation_code, " +
                "modata.type,DATE_FORMAT(modata.create_time,'%Y-%m-%d %H:%i:%S') create_time  " ;
        String sqlFilter =  " from base_patient_monitor_data modata INNER JOIN wlyy_patient_device pd on modata.device_sn = pd.device_sn and pd.del=0 " +
                "INNER JOIN dm_device dm on pd.device_id = dm.id " +
                "where patient='"+patient+"' and create_time>='"+startTime+"' and create_time<='"+endTime+"' ";
        String sqlCount = " select count(modata.id) ";
        sql = sql+sqlFilter +" ORDER BY modata.id desc limit "+page*size+","+size;
        Long total = jdbcTemplate.queryForObject(sqlCount+sqlFilter,Long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,total);
    }
}

+ 13 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -609,6 +609,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    }
    public List<Map<String,Object>> patientDeviceListByTopic(String patient,String serviceTopic){
        List<Map<String,Object>> result = new ArrayList<>();
        String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime,dd.device_type as deviceType " +
                "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                "where 1=1 and  pd.del=0 ";
@ -619,7 +621,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            sql+= " and dd.service_topic like '%"+serviceTopic+"%' ";
        }
        sql+=" order by pd.czrq asc ";
        return jdbcTemplate.queryForList(sql);
        result =  jdbcTemplate.queryForList(sql);
        return result;
    }
    public List<Map<String,Object>> patientEmeDeviceList(String patient){
@ -2035,10 +2038,15 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    }
    public com.alibaba.fastjson.JSONObject getSleepDeviceInfo(String deviceSn){
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("mac", deviceSn);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(AqgConfig.sleepDevice_info, param, HttpMethod.GET, getCookie());
        return response.getBody();
        try {
            MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
            param.add("mac", deviceSn);
            HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(AqgConfig.sleepDevice_info, param, HttpMethod.GET, getCookie());
            return response.getBody();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public com.alibaba.fastjson.JSONObject sleepDeviceEdit(String deviceSn,Integer heart_check_enable,Integer breath_check_enable,Integer offbed_check_enable,

+ 31 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -83,6 +83,11 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
     * @return
     */
    public Map<String,Object> doctorSimpleInfo(String doctorId){
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
        if (doctorDO==null){
            return null;
        }
        String sql = "SELECT d.id,d.name,d.photo,d.sex ";
        sql += " ,h.org_code orgCode,h.org_name orgName from base_doctor d left join base_doctor_hospital h on d.id = h.doctor_code  and h.del = 1" +
                "  WHERE d.id = '"+doctorId+"' limit 1 ";
@ -90,16 +95,33 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        Map<String,Object> map = list.get(0);
        //签约老人数、紧急救助完成数、生活照料完成数、安防监护完成数
        String sql1 = "SELECT COUNT(DISTINCT sr.patient) FROM " +
                " base_service_package_sign_record sr, base_service_package_record r, base_team_member m " +
                " WHERE  sr.id = r.sign_id and sr.status=1 " +
                "  and m.team_code = r.team_code " +
                "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
        String sql1 = "";
        String sqlLife = "";
        String sqlEmergency = "";
        String sqlSecurity = "";
        String filter = "";
        if (2==doctorDO.getLevel()){//社工
             sql1 = "SELECT COUNT(DISTINCT sr.patient) FROM " +
                    " base_service_package_sign_record sr, base_service_package_record r, base_team_member m " +
                    " WHERE  sr.id = r.sign_id and sr.status=1 " +
                    "  and m.team_code = r.team_code " +
                    "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
             sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
             sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
             sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
             filter = " and doctor = '"+doctorId+"'";
        }else if (4==doctorDO.getLevel()){
            sql1 = " SELECT count(DISTINCT p.id) from base_patient_helper ph INNER JOIN base_patient p " +
                    " on ph.patient = p.id and p.del=1 " +
                    "where ph.doctor='"+doctorId+"' and ph.del=1 ";
            sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
            sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
            sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
            filter = " and doctor = '"+doctorId+"'";
        }else {
            return null;
        }
        Integer signNum = jdbcTemplate.queryForObject(sql1,Integer.class);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
        String filter = " and doctor = '"+doctorId+"'";
        Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
        Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
        Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -513,6 +513,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
            obj.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
            obj.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
            obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
            obj.put("age", StringUtils.isBlank(p.getIdcard())?null:IdCardUtil.getAgeForIdcard(p.getIdcard()));
            obj.put("familyRelation", "-1");
            obj.put("familyRelationName", "自己");
            obj.put("isAuthorize", 1);//0:未授权,1:已授权
@ -575,6 +576,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("age", null==map.get("idcard")?null:IdCardUtil.getAgeForIdcard(map.get("idcard").toString()));
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));

+ 24 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -481,21 +481,42 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        return list;
    }
    /**
     * 获取居民已预约生活照料项目
     * @param patient
     * @return
     */
    public List<Map<String,Object>> findPatientItemDict(String patient){
        String sql = " select distinct dict.* from base_life_care_item_dict dict " +
                "INNER JOIN base_org org  on dict.org_code = org.`code` " +
                "INNER JOIN base_life_care_fee_detail fed on fed.`code` = dict.`code` " +
                "INNER join base_life_care_order ord on fed.order_id = ord.id " +
                " where ord.patient='"+patient+"' and ord.`status` >0 ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 居民端-查询生活照料工单列表
     *
     * @return
     */
    public JSONObject queryInfoList(String patient,Integer status, int page, int size) {
    public JSONObject queryInfoList(String patient,Integer status,String fedCode ,int page, int size) {
        JSONObject result = new JSONObject();
        status = null == status ? -100 : status;
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        String fedSql = " ";
        if (StringUtils.isNotBlank(fedCode)){
            fedSql = " and EXISTS ( " +
                    " select 1 from base_life_care_fee_detail fed where fed.order_id = o.id and fed.code='"+fedCode+"' " +
                    " )  ";
        }
        String sql = "SELECT *  FROM  base_life_care_order o " +
                " WHERE (o.patient = '{patient}' or o.proxy_patient = '{patient}') "+
                " AND (o.`status` = {status} or -100 = {status})" +
                " AND (o.`status` = {status} or -100 = {status})" +fedSql+
                "  group by o.id " +
                " ORDER BY o.create_time desc" +
                " LIMIT {start},{end} ";
@ -508,7 +529,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        String countSql = "SELECT count(DISTINCT o.id) FROM base_life_care_order o " +
                " WHERE  " +
                "  (o.patient = '{patient}' or o.proxy_patient = '{patient}') " +
                " AND (o.`status` = {status} or -100 = {status})";
                " AND (o.`status` = {status} or -100 = {status})"+fedSql;
        String finqlCountSql = countSql.replace("{patient}", patient)
                .replace("{status}", String.valueOf(status));

+ 79 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -64,7 +65,8 @@ public class BaseServiceNewsService {
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and code not in ('"+orgCodes+"')";
        }
        String sql = "SELECT code,name,brief,address,photo,mobile,longitude,latitude,type from base_org WHERE type in ('3','4') and del =1";
        String sql = "SELECT code,name,brief,address,photo,mobile,longitude,latitude,type from base_org WHERE type in ('3','4','6') and del =1 " +
                " and code not in ('zdjsylfwyxgszhfgs') ";
        sql += filter;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
@ -75,7 +77,7 @@ public class BaseServiceNewsService {
     * @return
     */
    public List<Map<String,Object>> findPatinetByName(String name){
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,p.pad_imei,p.openid,CAST(archive_type AS char) type from base_patient p\n" +
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,p.pad_imei,p.openid,CAST(archive_type AS char) type,p.sign_status as signStatus from base_patient p\n" +
                "WHERE p.del = 1 and p.name like '%"+name+"%'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<DevicePatientDevice> feeDetail = patientDeviceDao.findByAll();
@ -130,7 +132,7 @@ public class BaseServiceNewsService {
                "WHERE t.patient = p.id and t.del=1 and t.`status`=1 and p.del =1  " +filter+
                "UNION  " +
                "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid from base_service_package_sign_record t,base_patient p " +
                "WHERE t.patient = p.id and t.`status`=1 and p.del =1"+filter;
                "WHERE t.patient = p.id and t.`status`=1 and p.del =1 and p.sign_status=1 "+filter;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            String patient = map.get("id").toString();
@ -179,6 +181,80 @@ public class BaseServiceNewsService {
        return list;
    }
    /**
     * 查找所有未签约老人
     * 社区老人
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findUnSignPatientLocations(Integer page,Integer size){
        page = page>0?page-1:0;
        String filter =" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            if (StringUtils.isNotBlank(orgCodes)){
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and p.id not in ('"+orgCodes+"') ";
            }
        }
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid " +
                " from base_patient p " +
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and p.lat_lon is not null "+filter+" limit "+page*size+","+size;
        String sqlCount = "SELECT count(p.id) " +
                " from base_patient p " +
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and p.lat_lon is not null "+filter ;
        Long count = jdbcTemplate.queryForObject(sqlCount,Long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            String patient = map.get("id").toString();
            sql = "select label_code,label_name from wlyy_patient_label where label_type=1 and patient='"+patient+"' ";
            List<Map<String,Object>> labels = jdbcTemplate.queryForList(sql);
            if (labels.size()>0){
                map.put("label_code",labels.get(0).get("label_code"));
                map.put("label_name",labels.get(0).get("label_name"));
            }
            else {
                map.put("label_code",null);
                map.put("label_name",null);
            }
            String devices= deviceService.getPatientDeviceCategoryCode(map.get("id").toString());
            if ("0".equals(devices)){
                map.put("devices",new ArrayList<>());
            }else {
                String[] ss = devices.split(",");
                map.put("devices",ss);
            }
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            sql = " select CONCAT(o.serve_lat,',',o.serve_lon) latLon,'紧急呼叫' as serverDesc,o.org_code orgCode,o.device_sn from base_emergency_assistance_order o where o.patient='"+patient+"' and `status`=1 " +
                    " UNION All  " +
                    "select CONCAT(o.serve_lat,',',o.serve_lon) latLon,o.serve_desc serverDesc,o.hospital orgCode,o.device_sn from base_security_monitoring_order o where o.patient='"+patient+"' and `status`=1 ";
            List<Map<String,Object>> orderPoints = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> tmp:orderPoints){
                if (null!=tmp.get("device_sn")){
                    String device_sn = tmp.get("device_sn").toString();
                    if (StringUtils.isNotBlank(device_sn)){
                        DeviceDetail deviceDetail = deviceDetailDao.findBySn(device_sn);
                        if (null!=deviceDetail){
                            tmp.put("contactStatus",deviceDetail.getContactStatus());
                            tmp.put("categoryCode",deviceDetail.getCategoryCode());
                        }
                    }
                }
                String orgCode = tmp.get("orgCode").toString();
                BaseOrgDO orgDO = orgDao.findByCode(orgCode);
                if (null!=orgDO){
                    tmp.put("orgType",orgDO.getType());
                }
            }
            map.put("orderPoints",orderPoints);
        }
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    public List<Map<String , Object>> getLatLon(){
        String filter =" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_helper' or dict_name = 'jkzl_teacher' ";

+ 268 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -3,7 +3,10 @@ package com.yihu.jw.care.service.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.aop.RedisLockAOP;
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
@ -12,27 +15,35 @@ import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.vo.JczdPersonVo;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.sms.dao.HospitalSysDictDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -56,12 +67,12 @@ import java.util.stream.Collectors;
 */
@Service
public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatientDao> {
    private static final Logger logger = LoggerFactory.getLogger(CarePatientService.class);
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BasePatientMedicardCardService basePatientMedicardCardService;
    private BasePatientMedicareCardDao basePatientMedicareCardDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
@ -73,6 +84,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    @Autowired
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Value("${wechat.id}")
    private String wxId;
@ -87,6 +100,72 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    @Autowired
    private BasePatientService basePatientService;
    /**
     * 初始化杭州老人,只保存有身份证且有手机号的数据
     */
    public void initJczdPerson(Integer size){
        Map<String,String> lableCodeMap = new HashMap<>();
        Map<String,String> lableCodeNameMap = new HashMap<>();
        lableCodeMap.put("1","1");//低保
        lableCodeMap.put("9","2");//低边
        lableCodeMap.put("41","3");//独居
        lableCodeMap.put("73","3");//独居
        lableCodeMap.put("40","4");//孤寡
        lableCodeMap.put("10","7");//特困
        lableCodeNameMap.put("1","低保");//低保
        lableCodeNameMap.put("2","低边");//低边
        lableCodeNameMap.put("3","独居");//独居
        lableCodeNameMap.put("4","孤寡");//孤寡
        lableCodeNameMap.put("7","特困");//特困
        String sql = "select * from base_patient where openid = 'jczd' limit ?";
        List<BasePatientDO> list = jdbcTemplate.query(sql,new Object[]{size},new BeanPropertyRowMapper<>(BasePatientDO.class));
        for (BasePatientDO patient:list){
            String idcard = patient.getIdcard();
            String persionTags = patient.getSsc();
            String salt = UUID.randomUUID().toString().substring(0,5);
            patient.setPassword(MD5.md5Hex(idcard + "{" + salt + "}"));
            patient.setSalt(salt);
            patient.setOpenid(null);
            patient.setSsc(null);
            String address = patient.getAddress();
            patient.setAddress(address);
            if(StringUtils.isNotBlank(address)){
                if(!address.contains("杭州市")){
                    address = "杭州市"+address;
                }
                Map<String,String> map = LatitudeUtils.getGeocoderLatitude(address);
                if(map!=null){
                    String latlon = map.get("lat")+","+map.get("lng");
                    patient.setLatLon(latlon);
                }
            }
            patientDao.save(patient);
            String pateintId = patient.getId();
            if(StringUtils.isNotBlank(persionTags)){
                String pertags[] = persionTags.split(",");
                for (String tag:pertags){
                    String label = lableCodeMap.get(tag);
                    if(StringUtils.isNotBlank(label)){
                        WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
                        patientLabelDO.setCzrq(new Date());
                        patientLabelDO.setLabelType("3");
                        patientLabelDO.setPatient(pateintId);
                        patientLabelDO.setLabelCode(label);
                        patientLabelDO.setLabelName(lableCodeNameMap.get(label));
                        patientLabelDao.save(patientLabelDO);
                    }
                }
            }
            logger.info("idcard=="+patient.getIdcard());
        }
        logger.info("新增人数="+list.size());
    }
    /**
     * 获取能力状况
     * @param patient
@ -216,11 +295,13 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if (patientDO.getMarriage()!=null){
            patientDO.setMarriageName(dictService.fingByNameAndCode(ConstantUtil.DICT_MARRIAGE_STATUS,String.valueOf(patientDO.getMarriage())));
        }
        String deviceSql = "select COUNT(*) from wlyy_patient_device a where a.`user` = '"+patientId+"'";
        Integer deviceFlag = jdbcTemplate.queryForObject(deviceSql, Integer.class);
        patientDO.setDeviceFlag(deviceFlag);
        res.put("patient",patientDO);
        Map<String, Object> patientInfo = JSONObject.parseObject(JSON.toJSONString(patientDO,SerializerFeature.WriteMapNullValue), Map.class);
        patientInfo.put("birthday",DateUtil.dateToStrShort(patientDO.getBirthday()));
        res.put("patient",patientInfo);
        String sql = "select * from base_service_package_sign_record where patient = '"+patientId+"' and status = 1 ";
        List<ServicePackageSignRecordDO> signRecordDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ServicePackageSignRecordDO.class));
@ -515,7 +596,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    /**
     *
     * @param type 类型:1幼儿,2老人,3社工,4医生。5家属 不传返回四个类型的数据
     * @param type 类型:1幼儿,2签约老人,3社工,4医生,5老人家属 6助老员,7社区老人(未签约) 不传返回四个类型的数据
     * @param name 姓名
     * @param area 查询区域 目前仅支持查询老人、社工、家属
     * @param level 区域等级 2市3区4机构5团队6医生
@ -587,6 +668,34 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            re.put("oldFamily",list);
            re.put("oldFamilyCount",findOlderFamilyTotal(name,area,level,filter));
        }
        if("6".equals(type)||StringUtils.isBlank(type)){//助老员
            filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and h.org_code not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findHelper4(name,area,level,limit,filter);
            re.put("helper4",list);
            re.put("helper4Total",findHelper4Total(name,area,level,filter));
        }
        if("7".equals(type)||StringUtils.isBlank(type)){//社区老人
            filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and a.id not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findUnSignOld(name,residentialArea,area,level,limit,filter);
            re.put("unSignOld",list);
            re.put("unSignOldCount",findUnSignOldTotal(name,residentialArea,area,level,filter));
        }
        return re;
    }
@ -638,7 +747,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    }
    /**
     * 查找老人
     * 查找签约老人
     * @param name
     * @param residentialArea
     * @param limit
@ -647,7 +756,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    public List<Map<String,Object>> findOld(String name,String residentialArea,String area,Integer level,String limit,String filter1){
        String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ",a.ykt_id yktId, case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
                " WHERE a.archive_type = 1 and a.del = '1' ";
                " WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=1  ";
        //case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online
        //if(openid is null,0,1) onlineWx,IFNULL(a.on_line,0) onlinePad
@ -710,7 +819,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    }
    public Integer findOldTotal(String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' ";
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=1 ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
@ -727,6 +836,88 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    /**
     * 查找签约老人
     * @param name
     * @param residentialArea
     * @param limit
     * @return
     */
    public List<Map<String,Object>> findUnSignOld(String name,String residentialArea,String area,Integer level,String limit,String filter1){
        String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ",a.ykt_id yktId, case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
                " WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=0  ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        if (StringUtils.isNotBlank(area)&&5==level){
            return null;
        }
        sql += filter1;
        sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex,a.ykt_id,online,signStatus ";
        sql += " ORDER BY online desc,a.ykt_id desc,signStatus desc";
        sql += limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order ";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order ";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order  ";
        String sqlDevice = "SELECT pd.category_code deviceFlag, IFNULL(d.contact_status,0) status from wlyy_patient_device pd,wlyy_devices d";
        for (Map<String,Object> map:list){
            String paientId = map.get("id").toString();
            String filterDevice = " WHERE pd.device_sn = d.device_code and pd.user = '"+paientId+"' ORDER BY deviceFlag,status desc";
            String idcardNo = map.get("idcard") + "";
            Date birthday = DateUtil.strToDate(map.get("birthday").toString());
            Integer age = IdCardUtil.getAgeByIdcardOrBirthday(idcardNo,birthday);
            map.put("age",age);
            String filter = " where patient = '"+paientId+"'";
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
            Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
            List<Map<String,Object>> deviceList = jdbcTemplate.queryForList(sqlDevice+filterDevice);
            Iterator it = deviceList.listIterator();
            Map<Object,Object> deviceMap = new HashedMap();
            while (it.hasNext()){
                Map<String,Object> tmp = (Map<String,Object>)it.next();
                if(deviceMap.containsKey(tmp.get("deviceFlag"))){
                    it.remove();
                }else{
                    deviceMap.put(tmp.get("deviceFlag"),tmp.get("deviceFlag"));
                }
            }
            map.put("lifeCare",lifeCare);
            map.put("emergency",emergency);
            map.put("security",security);
            map.put("devices",deviceList);
            sql = " select sum(total) from ( " +
                    "select count(id) total from  base_emergency_assistance_order o where o.patient ='"+paientId+"' and o.`status`=1 " +
                    "UNION All " +
                    "select count(id) total from  base_security_monitoring_order o where o.patient ='"+paientId+"' and o.`status`=1 " +
                    ")A  ";
            Integer warnTotal = jdbcTemplate.queryForObject(sql,Integer.class);
            map.put("warnFlag",warnTotal>0?true:false);
        }
        return list;
    }
    public Integer findUnSignOldTotal(String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=0 ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        if (StringUtils.isNotBlank(area)&&5==level){
            return 0;
        }
        sql += filter;
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    /**
     * 查找社工
     * @param name
@ -749,7 +940,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 7 ";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 0 ";
        for (Map<String,Object> map:list){
            String doctorId = map.get("id").toString();
            List<BaseDoctorHospitalDO> hospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
@ -785,6 +976,74 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    /**
     * 查找助老员
     * @param name
     * @param limit
     * @return
     */
    public List<Map<String,Object>> findHelper4(String name,String area,Integer level,String limit,String fileter){
        String sql = "SELECT a.id,a.name,a.photo,a.sex,IFNULL(a.on_line,0) online from base_doctor a,base_doctor_hospital h" +
                "  WHERE a.id=h.doctor_code and a.doctor_level = 4 and a.del = '1' and h.del = '1' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and a.name like '%"+name+"%' ";
        }
        if (StringUtils.isNotBlank(area)&&5==level){
            sql += " and EXISTS ( select 1 from base_patient_helper ph,base_service_package_sign_record sr, " +
                    " base_service_package_record r, base_service_package_item i,base_service_package pack  " +
                    " where ph.del=1 and ph.doctor = a.id and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                    " and r.service_package_id = pack.id and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8) = ph.patient " +
                    " and r.team_code='"+area+"') ";
        }
        sql += fileter;
        sql += " ORDER BY online desc";
        sql+=limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlLife= " SELECT COUNT(distinct ord.id) from base_life_care_order ord,base_doctor_hospital h where ord.`status` = 2 " +
                " and ord.hospital = h.org_code and h.del='1' ";
        String sqlEmergency= " SELECT COUNT(distinct ord.id) from base_emergency_assistance_order ord,base_patient_helper h where ord.`status` = 0 " +
                " and ord.patient = h.patient and h.del=1 ";
        String sqlSecurity= " SELECT COUNT(distinct ord.id) from base_security_monitoring_order ord,base_patient_helper h where ord.`status` = 0 " +
                " and ord.patient = h.patient and h.del=1 ";
        for (Map<String,Object> map:list){
            String doctorId = map.get("id").toString();
            List<BaseDoctorHospitalDO> hospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
            if (hospitalDOS.size()>0){
                map.put("residentialArea",hospitalDOS.get(0).getOrgName());
                map.put("org_code",hospitalDOS.get(0).getOrgCode());
            }else {
                map.put("residentialArea",null);
                map.put("org_code",null);
            }
            String filter = " and h.doctor_code = '"+doctorId+"'";
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            filter = " and h.doctor = '"+doctorId+"'";
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
            Integer security = jdbcTemplate.queryForObject(sqlSecurity+filter,Integer.class);
            map.put("lifeCare",lifeCare);
            map.put("emergency",emergency);
            map.put("security",security);
        }
        return list;
    }
    public Integer findHelper4Total(String name,String area,Integer level,String filter){
        String sql = "SELECT count(a.id) from base_doctor a,base_doctor_hospital h WHERE  a.id=h.doctor_code and a.doctor_level = 4 and a.del = '1' and h.del = '1'  ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        if (StringUtils.isNotBlank(area)&&5==level){
            sql += " and EXISTS ( select 1 from base_patient_helper ph,base_service_package_sign_record sr, " +
                    " base_service_package_record r, base_service_package_item i,base_service_package pack  " +
                    " where ph.del=1 and ph.doctor = a.id and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                    " and r.service_package_id = pack.id and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8) = ph.patient " +
                    " and r.team_code='"+area+"') ";
        }
        sql += filter;
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    public List<Map<String,Object>> findOlderFamily(String name,String limit,String area,Integer level,String fileter){
        String sql = "select t2.id,t2.name,t2.sex,t2.mobile,t2.idcard,if(t2.openid is null,0,1) online,t2.photo,t1.family_relation,t1.patient older,t3.name olderName " +
                "from base_patient t2 left JOIN base_patient_family_member t1 on t1.family_member = t2.id " +

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

@ -21,6 +21,7 @@ import com.yihu.jw.care.service.message.BaseServiceNewsService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.DeviceDataPushLogUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -150,6 +151,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private PermissionService permissionService;
    @Autowired
    private BaseServiceNewsService baseServiceNewsService;
    @Autowired
    private DeviceDataPushLogUtil deviceDataPushLogUtil;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -304,7 +307,6 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                if (StringUtils.isNotBlank(doctorDO.getMobile())) {
                    messageUtil.sendTXYSJson("1141719", doctorDO.getMobile(), orderDO.getPatientName(), orderDO.getServeDesc());
                }
            } catch (Exception e) {
            }
            String body = "您好," + orderDO.getPatientName() + "居民" + orderDO.getServeDesc() + ",请关注并及时处理。";
@ -316,7 +318,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        imUtil.sendPcManageMessageToPc("cloudCare_pcManage", message.toString());
        result.put("resultFlag", 1);
        result.put("resultMsg", orderDO);
        if (StringUtils.isNotBlank(orderDO.getDeviceSn())){
            deviceDataPushLogUtil.savePatientMonitorData(orderDO.getDeviceSn(),22,orderDO.getServeDesc(),orderDO.getId());
        }
        baseServiceNewsService.addServiceNews(patientDO.getName(),patientDO.getId(),"6",null,orderDO.getId(),1);
        return result;
@ -504,6 +508,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                e.printStackTrace();
            }
        }
        if (9 == orderDO.getOrderSource()){
            Map<String, Object> map = new HashMap<>();
            map.put("infoDetail", orderDO.getWarnInfo());
            emergencyOrderVO.setInformation(map);
        }
        //通知对象
        List<Map<String, Object>> noticePersons = new ArrayList<>();
@ -721,6 +730,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                case "preventOutOfBed":
                    categoryCode = "'13'";
                    break;
                case "dailyWater":
                    categoryCode = "'18'";
                    break;
            }
            if (StringUtils.isNotBlank(doctor)) {//日常监护医生必传
                BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
@ -890,6 +902,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                case "preventOutOfBed":
                    categoryCode = "'13'";
                    break;
                case "dailyWater":
                    categoryCode = "'18'";
                    break;
            }
            if (StringUtils.isNotBlank(doctor)) {//日常监护医生必传
                BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
@ -1659,6 +1674,24 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        }
                    }
                    break;
                case "dailyWater":
                    if (patientDeviceService.patientDeviceListByTopic(patient,"dailyWater").size()==0){
                        result.put("dailyWater", null);
                    }else {
                        Integer count = Integer.parseInt(tmp.get("total").toString());
                        if (count > 0) {
                            result.put("dailyWater", true);
                            sql = " select serve_desc from base_security_monitoring_order where topic_item='dailyWater' " +
                                    "and patient='" + patient + "' and `status`=1 order by create_time desc limit 1 ";
                            List<String> serveDesces = jdbcTemplate.queryForList(sql, String.class);
                            if (serveDesces.size() > 0) {
                                result.put("dailyWaterOrderInfo", serveDesces.get(0));
                            }
                        } else {
                            result.put("dailyWater", false);
                        }
                    }
                    break;
            }
        }
        sql = " select count(id) from base_emergency_assistance_order  where patient='" + patient + "' and status=" + EmergencyAssistanceDO.Status.apply.getType();
@ -1733,6 +1766,16 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        tmp.put("devices", null);
                    }
                    break;
                case "dailyWater":
                    devices = patientDeviceService.patientDeviceListByTopic(patient,"dailyWater");
                    if (devices.size()>0){
                        tmp.put("band", true);
                        tmp.put("devices", devices);
                    }else {
                        tmp.put("band", false);
                        tmp.put("devices", null);
                    }
                    break;
            }
        }
        sql = " select 'emeAssistance' as code,ord.id,ord.patient,'20' as OrderType,'紧急呼叫' as serveDesc " +
@ -1826,6 +1869,21 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        result.put("sleep", false);
                    }
                    break;
                case "dailyWater":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count > 0) {
                        result.put("dailyWater", true);
                        sql = " select serve_desc from base_security_monitoring_order where topic_item='dailyWater' " +
                                "and patient='" + patient + "' and `status`=1 order by create_time desc limit 1 ";
                        List<String> serveDesces = jdbcTemplate.queryForList(sql, String.class);
                        if (serveDesces.size() > 0) {
                            result.put("dailyWaterOrderInfo", serveDesces.get(0));
                        }
                    } else {
                        result.put("dailyWater", false);
                    }
                    break;
            }
        }
        sql = " select count(id) from base_emergency_assistance_order  where patient='" + patient + "' and status=" + EmergencyAssistanceDO.Status.apply.getType();
@ -1932,6 +1990,24 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient, "4");//手表
                devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient, "16");//拐杖
            }
            if(devicePatientDeviceDos.size()==0&&devicePatientDeviceDos2.size()==0){
                BasePatientDO patientDO = basePatientDao.findById(patient);
                JSONObject tmp = new JSONObject();
                tmp.put("city",null);
                tmp.put("province", null);
                tmp.put("address", patientDO.getAddress());
                if (StringUtils.isNotBlank(patientDO.getLatLon())) {
                    String[] latLon = patientDO.getLatLon().split(",");
                    if (StringUtils.isNotBlank(patientDO.getHomeLatLon()) && latLon.length == 2) {
                        String homeLatLon = patientDO.getHomeLatLon();
                        String homeLat = homeLatLon.split(",")[0];
                        String homeLon = homeLatLon.split(",")[1];
                        tmp.put("lon", homeLon);
                        tmp.put("lat", homeLat+"");
                    }
                }
                result.put("location", tmp);
            }
            if (devicePatientDeviceDos.size() > 0 && (4 == categoryCode || 0 == categoryCode)) {//手表
                DevicePatientDevice device = devicePatientDeviceDos.get(0);
                result.put("deviceSn", device.getDeviceSn());
@ -1953,6 +2029,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        tmp.put("city", response.getString("last_city"));
                        tmp.put("province", response.getString("last_province"));
                        tmp.put("address", response.getString("last_address"));
                        if (response.containsKey("location_updated_at") && response.get("location_updated_at") != null) {
                            JSONObject locationTimeObj = response.getJSONObject("location_updated_at");
                            Long locationTime =  locationTimeObj.getLongValue("$date");
                            tmp.put("locationTime", DateUtil.dateToStrLong( new Date(locationTime)));
                        }
                        result.put("location", tmp);
                        BasePatientDO patientDO = basePatientDao.findById(patient);
                        if (null != patientDO) {
@ -2013,13 +2094,15 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                DevicePatientDevice deviceDO = devicePatientDeviceDos2.get(0);
                double dulat = 0l;
                double dulon = 0l;
                String locationTime=null;
                //获取当前定位
                String sql = " SELECT * FROM base_yxdevice_index WHERE sn = '" + deviceDO.getDeviceSn() + "' " +
                String sql = " SELECT *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time FROM base_yxdevice_index WHERE sn = '" + deviceDO.getDeviceSn() + "' " +
                        "AND create_time LIKE '" + DateUtil.getStringDateShort() + "%' AND lon != 0 AND lat != 0 ORDER BY create_time DESC  ";
                List<Map<String, Object>> pointTmp = jdbcTemplate.queryForList(sql);
                if (pointTmp.size() > 0) {
                    dulat = Double.parseDouble(pointTmp.get(0).get("lat").toString());
                    dulon = Double.parseDouble(pointTmp.get(0).get("lon").toString());
                    locationTime = pointTmp.get(0).get("create_time").toString();
                }
                if ((dulat == 0.0 && dulon == 0.0)) {
                    BasePatientDO patientDO = basePatientDao.findById(deviceDO.getUser());
@ -2053,6 +2136,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                            Double areaLat = Double.parseDouble(areaPoint[1]);
                            positionTmp.put("lat", areaLat);
                            positionTmp.put("lon", areaLon);
                            positionTmp.put("locationTime", locationTime);
                            fenceLocation.add(positionTmp);
                        }
                        if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size() > 0) {
@ -2064,6 +2148,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                    obj.put("address", address);
                                    obj.put("lon", dulon);
                                    obj.put("lat", dulat);
                                    obj.put("locationTime", locationTime);
                                }
                            }
                        } else if (devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
@ -2075,6 +2160,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                location.put("city", "");
                                location.put("lon", dulon);
                                location.put("lat", dulat);
                                location.put("locationTime", locationTime);
                                result.put("location", location);
                                JSONArray fences = new JSONArray();
                                JSONObject fence = new JSONObject();
@ -2102,78 +2188,83 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        } else {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
            JSONObject deviceInfo = patientDeviceService.getSleepDeviceInfo(deviceDo.getDeviceSn());
            if (deviceInfo.getBooleanValue("success")) {
                result.put("patientAddress", deviceDo.getSosAddress());
                JSONArray objInfo = deviceInfo.getJSONArray("objs");
                if (objInfo.size() > 0) {
                    result.put("sleepStatus", true);
                    JSONObject tmp = objInfo.getJSONObject(0);
                    JSONObject sleepInfo = new JSONObject();
                    if (StringUtils.isBlank(dayTime)) {
                        dayTime = getSleepMonitoringDay(new Date(), patient);
                    }
                    List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient, dayTime);
                    BaseSleepPlanDetail planDetail = new BaseSleepPlanDetail();
                    if (planDetails.size() > 0) {
                        planDetail = planDetails.get(0);
                        List<BaseSleepNightRecord> sleepNightRecordList = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient, dayTime);
                        planDetail.setSleepNightRecordList(sleepNightRecordList);
                    }
                    String jsonStr = JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
                    sleepInfo = JSONObject.parseObject(jsonStr);
                    sleepInfo.put("day", dayTime);
                    List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
                    if (sleepPlans.size() > 0) {
                        BaseSleepPlan sleepPlan = sleepPlans.get(0);
                        String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(), -1);
                        sleepInfo.put("sleepPlan", true);
                        sleepInfo.put("getUpTime", sleepPlan.getGetUpTime());
                        sleepInfo.put("siestaTime", sleepPlan.getNapTime());
                        sleepInfo.put("nightRestTime", sleepPlan.getNightRestTime());
                        sleepInfo.put("nightRecordTime", sleepPlan.getNightRestTime() + "-隔日" + endTime);
                    } else {
                        sleepInfo.put("sleepPlan", false);
                    }
                    sleepInfo.put("online", tmp.getBooleanValue("online"));
                    if(tmp.getBooleanValue("online")){
                        sleepInfo.put("contactStatus", 1);
                    }
                    else {
                        sleepInfo.put("contactStatus", 0);
                    }
            if (null!=deviceInfo){
                if (deviceInfo.getBooleanValue("success")) {
                    result.put("patientAddress", deviceDo.getSosAddress());
                    JSONArray objInfo = deviceInfo.getJSONArray("objs");
                    if (objInfo.size() > 0) {
                        result.put("sleepStatus", true);
                        JSONObject tmp = objInfo.getJSONObject(0);
                        JSONObject sleepInfo = new JSONObject();
                        if (StringUtils.isBlank(dayTime)) {
                            dayTime = getSleepMonitoringDay(new Date(), patient);
                        }
                        List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient, dayTime);
                        BaseSleepPlanDetail planDetail = new BaseSleepPlanDetail();
                        if (planDetails.size() > 0) {
                            planDetail = planDetails.get(0);
                            List<BaseSleepNightRecord> sleepNightRecordList = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient, dayTime);
                            planDetail.setSleepNightRecordList(sleepNightRecordList);
                        }
                        String jsonStr = JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
                        sleepInfo = JSONObject.parseObject(jsonStr);
                        sleepInfo.put("day", dayTime);
                        List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
                        if (sleepPlans.size() > 0) {
                            BaseSleepPlan sleepPlan = sleepPlans.get(0);
                            String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(), -1);
                            sleepInfo.put("sleepPlan", true);
                            sleepInfo.put("getUpTime", sleepPlan.getGetUpTime());
                            sleepInfo.put("siestaTime", sleepPlan.getNapTime());
                            sleepInfo.put("nightRestTime", sleepPlan.getNightRestTime());
                            sleepInfo.put("nightRecordTime", sleepPlan.getNightRestTime() + "-隔日" + endTime);
                        } else {
                            sleepInfo.put("sleepPlan", false);
                        }
                        sleepInfo.put("online", tmp.getBooleanValue("online"));
                        if(tmp.getBooleanValue("online")){
                            sleepInfo.put("contactStatus", 1);
                        }
                        else {
                            sleepInfo.put("contactStatus", 0);
                        }
                    if (tmp.getBooleanValue("onbed")) {
                        sleepInfo.put("bedStatus", 1);
                        sleepInfo.put("heartRate", tmp.getString("heartrate"));
                        sleepInfo.put("breath", tmp.getString("breathrate"));
                    } else {
                        sleepInfo.put("bedStatus", 0);
                        sleepInfo.put("heartRate", null);
                        sleepInfo.put("breath", null);
                    }
                    BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient, deviceDo.getDeviceSn(), 0);
                    if (null != outBed) {
                        String outBedTime = "";
                        Date date = new Date();
                        long millisecondsDiff = date.getTime() - outBed.getCreateTime().getTime();
                        long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
                        long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
                        long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
                        if (hoursDiff > 0L) {
                            outBedTime += String.format("%d小时", hoursDiff);
                        if (tmp.getBooleanValue("onbed")) {
                            sleepInfo.put("bedStatus", 1);
                            sleepInfo.put("heartRate", tmp.getString("heartrate"));
                            sleepInfo.put("breath", tmp.getString("breathrate"));
                        } else {
                            sleepInfo.put("bedStatus", 0);
                            sleepInfo.put("heartRate", null);
                            sleepInfo.put("breath", null);
                        }
                        if (minuteFieldDiff > 0) {
                            outBedTime += String.format("%d分钟", minuteFieldDiff);
                        BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient, deviceDo.getDeviceSn(), 0);
                        if (null != outBed) {
                            String outBedTime = "";
                            Date date = new Date();
                            long millisecondsDiff = date.getTime() - outBed.getCreateTime().getTime();
                            long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
                            long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
                            long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
                            if (hoursDiff > 0L) {
                                outBedTime += String.format("%d小时", hoursDiff);
                            }
                            if (minuteFieldDiff > 0) {
                                outBedTime += String.format("%d分钟", minuteFieldDiff);
                            }
                            sleepInfo.put("outBedTimeCrzq", outBed.getCreateTime());
                            sleepInfo.put("outBedTime", outBedTime);
                        } else {
                            sleepInfo.put("outBedTime", "无");
                        }
                        sleepInfo.put("outBedTimeCrzq", outBed.getCreateTime());
                        sleepInfo.put("outBedTime", outBedTime);
                    } else {
                        sleepInfo.put("outBedTime", "无");
                        result.put("sleepInfo", sleepInfo);
                    }
                    result.put("sleepInfo", sleepInfo);
                } else {
                    result.put("sleepStatus", false);
                    result.put("sleepInfo", "获取睡眠带数据失败");
                }
            } else {
            }else {
                result.put("sleepStatus", false);
                result.put("sleepInfo", "获取睡眠带数据失败");
            }
@ -2516,6 +2607,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            case "preventOutOfBed":
                categoryCode = "'13'";
                break;
            case "dailyWater":
                categoryCode = "'18'";
                break;
        }
        fliter = " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id  " +
@ -2648,6 +2742,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            case "preventOutOfBed":
                categoryCode = "'13'";
                break;
            case "dailyWater":
                categoryCode = "'18'";
                break;
            case "emergencyAssistance":
                categoryCode = "'7','4'";
                break;
@ -2835,5 +2932,60 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        return result;
    }
    /**
     * 获取居民专题 已绑定
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getPatientDeviceTopic(String patient){
        List<Map<String,Object>> result = new ArrayList<>();
        String sql = " select distinct pd.device_sn,pd.category_code from wlyy_patient_device pd where pd.del=0  " +
                " and pd.category_code in (4,7,12,13,14,15,18) and pd.`user`='"+patient+"' " +
                " group by pd.category_code ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:list){
            Map<String,Object> mapTmp = new HashMap<>();
            mapTmp.put("categoryCode",tmp.get("category_code").toString());
            switch (tmp.get("category_code").toString()){
                case "4":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","preventLost");
                    result.add(mapTmp);
                    break;
                case "7":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","emergencyAssistance");
                    result.add(mapTmp);
                    break;
                case "12":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","preventFall");
                    result.add(mapTmp);
                    break;
                case "13":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","preventOutOfBed");
                    result.add(mapTmp);
                    break;
                case "14":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","preventGasLeakage");
                    result.add(mapTmp);
                    break;
                case "15":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","preventFire");
                    result.add(mapTmp);
                    break;
                case "18":
                    mapTmp.put("deviceSn",tmp.get("device_sn").toString());
                    mapTmp.put("topic","dailyWater");
                    result.add(mapTmp);
                    break;
            }
        }
        return  result;
    }
}

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -398,8 +398,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @return
     */
    public int getSignTotal(String doctorId){
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id " +
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_team_member m,base_patient p " +
                "WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id and p.id = sr.patient and p.del=1  " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        return jdbcTemplate.queryForObject(sql,Integer.class);

+ 25 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java

@ -9,6 +9,8 @@ import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
@ -67,6 +69,8 @@ public class DetectionPlatformService  {
    private ServicePackageService servicePackageService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
@ -549,27 +553,27 @@ public class DetectionPlatformService  {
    }
    public List<Map<String,Object >> findSignOlder(String doctorId){
        /*String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                " and m.del = '1' and  p.del = '1' " +
                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";*/
        String sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and  p.del = '1' " +
                " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                " ORDER BY online desc,p.ykt_id desc,signStatus desc ";
//        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei,p.residential_area residentialArea  " +
//                " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
//                "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
//                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        if (doctorDO==null){
            return null;
        }
        String sql = "";
        if (2==doctorDO.getLevel()){//社工
            sql=  "SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea,p.sex, " +
                    " p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus "+
                    " from base_service_package_sign_record sr,base_patient p,base_service_package_record r,base_team_member m " +
                    "WHERE sr.status=1 and sr.patient = p.id and m.team_code = r.team_code and sr.id=r.sign_id " +
                    "and m.doctor_code = '"+doctorId+"' and m.del = '1' and  p.del = '1' " +
                    " GROUP BY p.id,p.name,p.photo,p.idcard,p.birthday,p.residential_area,p.sex,p.ykt_id,online,signStatus" +
                    " ORDER BY online desc,p.ykt_id desc,signStatus desc ";
        }else if (4==doctorDO.getLevel()){//助老员
            sql = " SELECT p.id,p.name,p.photo,p.idcard,CAST(IFNULL(p.birthday,'') AS char ) birthday,p.residential_area residentialArea, " +
                  " p.sex,p.ykt_id yktId, case 1 WHEN p.openid is not null then 1 WHEN p.on_line = '1' then 1 ELSE 0 end as online,IFNULL(p.sign_status,0) signStatus " +
                  " from base_patient p,base_patient_helper ph " +
                  " where p.id = ph.patient and p.del=1 and ph.del=1 and ph.doctor='"+doctorId+"' ";
        }else {
            return null;
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order ";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order ";

+ 58 - 24
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -330,7 +330,7 @@ public class StatisticsService {
        JSONObject res = new JSONObject();
        String medicalInstitutionSql = "SELECT COUNT(1) FROM base_org WHERE (type = 1 OR type = 2) AND del = 1 " + orgFilter;
        String elderlyCarServiceSql = "SELECT COUNT(1) FROM base_org WHERE type = 3 AND del = 1" + orgFilter;
        String elderlyCarServiceSql = "SELECT COUNT(1) FROM base_org WHERE type = 3 AND del = 1 and code not in ('zdjsylfwyxgszhfgs') " + orgFilter;
        String childcareInstitutionsssSql = "SELECT COUNT(1) FROM base_org WHERE type = 4 AND del = 1" + orgFilter;
        String careCenterNumSql = "SELECT COUNT(1) FROM base_org WHERE type = 6 AND del = 1" + orgFilter;
@ -685,6 +685,14 @@ public class StatisticsService {
        Integer olderFamilyOn = 0;
        Integer olderFamilyOff = 0;
        Integer olderFamilyBinding = 0;//家属绑定老人数量
        Integer helper4On=0;
        Integer helper4Off=0;
        Integer helper4Total=0;
        Integer unSignOlderTotal=0;
        Integer unSignOlderOff=0;
        Integer unSignOlderOn=0;
        //儿童注册人数
        String childFilter = "";
        String sqlChildtmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older'  ";
@ -706,7 +714,6 @@ public class StatisticsService {
                childOff += num;
            }
        }
        //老人
        String oldFilter = "";
        String sqlOldtmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
@ -723,7 +730,7 @@ public class StatisticsService {
                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+area+"') ";
        }
        String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 " +
        String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and sign_status=1 " +
                " and del='1' "+areaFilter+" " + oldFilter + " GROUP BY online";
        List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
        for (Map<String, Object> map : list1) {
@ -738,6 +745,20 @@ public class StatisticsService {
        olderTotal = olderOff + olderOn;
        childTotal = childOff + childOn;
        sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and (sign_status=0 or sign_status is null ) " +
                " and del='1' " + oldFilter + " GROUP BY online";
        list1 = jdbcTemplate.queryForList(sql1);
        for (Map<String, Object> map : list1) {
            Integer num = Integer.valueOf(map.get("c").toString());
            Integer online = Integer.valueOf(map.get("online").toString());
            if (online == 1) {
                unSignOlderOn += num;
            } else {
                unSignOlderOff += num;
            }
        }
        unSignOlderTotal = unSignOlderOff+unSignOlderOn;
        //社工和教师注册人数
        if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
            areaFilter = " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
@ -768,9 +789,17 @@ public class StatisticsService {
                    teacherOff += num;
                }
            }
            if ("4".equals(archive_type)) {
                if (online == 1) {
                    helper4On += num;
                } else {
                    helper4Off += num;
                }
            }
        }
        helperTotal = helperOff + helperOn;
        teacherTotal = teacherOff + teacherOn;
        helper4Total = helper4On + helper4Off;
        //老人家属
        String olderRelativeFilter = "";
@ -821,20 +850,27 @@ public class StatisticsService {
        olderFamilyBinding = jdbcTemplate.queryForObject(sql2,Integer.class);
        //helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板
        //helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板 olderFamily老人家属
        //helper4助老员 unSignOlder社区老人
        result.put("olderTotal", olderTotal);
        result.put("olderOn", olderOn);
        result.put("olderOff", olderOff);
        result.put("childTotal", childTotal);
        result.put("helperTotal", helperTotal);
        result.put("teacherTotal", teacherTotal);
        result.put("helperOn", helperOn);
        result.put("teacherOn", teacherOn);
        result.put("childOn", childOn);
        result.put("olderOn", olderOn);
        result.put("childOff", childOff);
        result.put("unSignOlderTotal", unSignOlderTotal);
        result.put("unSignOlderOff", unSignOlderOff);
        result.put("unSignOlderOn", unSignOlderOn);
        result.put("helperTotal", helperTotal);
        result.put("helperOff", helperOff);
        result.put("helperOn", helperOn);
        result.put("teacherTotal", teacherTotal);
        result.put("teacherOff", teacherOff);
        result.put("olderOff", olderOff);
        result.put("teacherOn", teacherOn);
        result.put("helper4Total", helper4Total);
        result.put("helper4On", helper4On);
        result.put("helper4Off", helper4Off);
        //老人家属
        result.put("olderFamilyTotal", olderFamilyTotal);
@ -2329,11 +2365,10 @@ public class StatisticsService {
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            map.put("doctorCount",count);
            sql = " SELECT count(o.bussiness_id) " +
                    "FROM ( SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time " +
                    "FROM base_security_monitoring_order o UNION ALL  " +
                    "SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time " +
                    "FROM base_emergency_assistance_order o " +
                    ") o WHERE 1=1  and dept='"+teamId+"' and `status` in (-2,0,1) ";
                    "FROM (  SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_security_monitoring_order o  " +
                    " where o.team_code='"+teamId+"' and o.`status` in (-2,0,1)  " +
                    " UNION ALL  SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_emergency_assistance_order o " +
                    " where o.team_code='"+teamId+"' and o.`status` in (-2,0,1)  )o  ";
            Long emeAssistanceCount = jdbcTemplate.queryForObject(sql,Long.class);
            map.put("emeAssistanceCount",emeAssistanceCount);
            sql = " SELECT count(o.id) FROM base_life_care_order o WHERE o.status<>0 and o.status<>-1  and EXISTS ( " +
@ -2365,11 +2400,11 @@ public class StatisticsService {
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and a.id not in ('"+orgCodes+"')";
            }
            sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' ";
            sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' ";
            sql += " and EXISTS ( select 1 from " +
                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+teamId+"' ) "+filter;
                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+teamId+"' ) "+filter;
            count =  jdbcTemplate.queryForObject(sql,Integer.class);
            map.put("oldTotal",count);
            //照护老人数量
@ -2428,11 +2463,10 @@ public class StatisticsService {
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            map.put("doctorCount",count);
            sql = " SELECT count(o.bussiness_id) " +
                    "FROM ( SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time " +
                    "FROM base_security_monitoring_order o UNION ALL  " +
                    "SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time " +
                    "FROM base_emergency_assistance_order o " +
                    ") o WHERE 1=1  and dept='"+teamId+"' and `status` in (-2,0,1) ";
                    "FROM (  SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_security_monitoring_order o  " +
                    " where o.team_code='"+teamId+"' and o.`status` in (-2,0,1)  " +
                    " UNION ALL  SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_emergency_assistance_order o " +
                    " where o.team_code='"+teamId+"' and o.`status` in (-2,0,1)  )o  ";
            Long emeAssistanceCount = jdbcTemplate.queryForObject(sql,Long.class);
            map.put("emeAssistanceCount",emeAssistanceCount);//救助服务
            sql = " SELECT count(o.id) FROM base_life_care_order o WHERE o.status<>0 and o.status<>-1  and EXISTS ( " +
@ -2465,7 +2499,7 @@ public class StatisticsService {
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and a.id not in ('"+orgCodes+"')";
            }
            sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' ";
            sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' ";
            sql += " and EXISTS ( select 1 from " +
                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +

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

@ -649,17 +649,18 @@ public class PatientInfoPlatFormService {
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and ord.patient not in ('"+orgCodes+"') ";
        }
        String sqlCount = " select count(ord.id) from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id where 1=1 ";
        String sql = " select '20' as OrderType,p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient, " +
                "p.name,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status`," +
                " case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex,TIMESTAMPDIFF(YEAR,p.birthday,now()) as age \n" +
                "from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id " ;
                "from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id and p.del=1 where 1=1 " ;
        if (StringUtils.isNotBlank(patient)){
            sql +=" and ord.patient='"+patient+"' ";
            filter +=" and ord.patient='"+patient+"' ";
        }
        sql +=  filter + "  order by create_time desc ";
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);
        sql +=  filter + "  order by create_time desc";
        sqlCount  +=filter;
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        sql +=" limit "+page*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
@ -703,7 +704,7 @@ public class PatientInfoPlatFormService {
            sql += " and pd.device_sn = '"+deviceSn+"' ";
        }
        sql+=" order by pd.czrq asc ";
        sql+=" order by dd.device_type desc,pd.czrq asc ";
        list =  jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp :list){
            String category_code = tmp.get("category_code").toString();
@ -777,19 +778,25 @@ public class PatientInfoPlatFormService {
                }
                JSONObject response = patientDeviceService.getAqgDeviceInfo2(deviceSn);
                //手表佩戴状态
                if (response.containsKey("wear_flag") && response.get("wear_flag") != null) {
                    detailInfo.put("wear_flag", response.get("wear_flag"));
                    detailInfo.put("wear_flagName", 1==response.getInteger("wear_flag")?"未佩戴":"已佩戴");
                }
                //电量
                if (response.containsKey("remaining_power") && response.get("remaining_power") != null) {
                    detailInfo.put("remaining_power", response.get("remaining_power"));
                }
                //在线状态实时获取
                if (!response.getBoolean("online")) {//设备在线状态
                    detailInfo.put("contact_status",0);
                } else {
                    detailInfo.put("contact_status",1);
                if (null!=response){
                    if (response.containsKey("wear_flag") && response.get("wear_flag") != null) {
                        detailInfo.put("wear_flag", response.get("wear_flag"));
                        detailInfo.put("wear_flagName", 1==response.getInteger("wear_flag")?"未佩戴":"已佩戴");
                    }
                    //电量
                    if (response.containsKey("remaining_power") && response.get("remaining_power") != null) {
                        detailInfo.put("remaining_power", response.get("remaining_power"));
                    }
                    //在线状态实时获取
                    if (!response.getBoolean("online")) {//设备在线状态
                        detailInfo.put("contact_status",0);
                    } else {
                        detailInfo.put("contact_status",1);
                    }
                }else {
                    detailInfo.put("wear_flag",null);
                    detailInfo.put("wear_flagName", null);
                    detailInfo.put("remaining_power",null);
                }
                sql = "select *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time from base_patient_step where 1=1  and device_sn='"+deviceSn+"' order by create_time desc limit 1";
                sqlResult = jdbcTemplate.queryForList(sql);
@ -838,15 +845,17 @@ public class PatientInfoPlatFormService {
                    detailInfo.put("warnStatus",false);
                }
                response = patientDeviceService.getAqgDeviceInfo2(deviceSn);
                //电量
                if (response.containsKey("remaining_power") && response.get("remaining_power") != null) {
                    detailInfo.put("remaining_power", response.get("remaining_power"));
                }
                //在线状态实时获取
                if (!response.getBoolean("online")) {//设备在线状态
                    detailInfo.put("contact_status",0);
                } else {
                    detailInfo.put("contact_status",1);
                if (null!=response){
                    //电量
                    if (response.containsKey("remaining_power") && response.get("remaining_power") != null) {
                        detailInfo.put("remaining_power", response.get("remaining_power"));
                    }
                    //在线状态实时获取
                    if (!response.getBoolean("online")) {//设备在线状态
                        detailInfo.put("contact_status",0);
                    } else {
                        detailInfo.put("contact_status",1);
                    }
                }
                break;
            case "12"://监控
@ -884,23 +893,25 @@ public class PatientInfoPlatFormService {
                    detailInfo.put("warnStatus",false);
                }
                JSONObject deviceInfo = patientDeviceService.getSleepDeviceInfo(deviceSn);
                if (deviceInfo.getBooleanValue("success")) {
                    com.alibaba.fastjson.JSONArray objInfo = deviceInfo.getJSONArray("objs");
                    if (objInfo.size() > 0) {
                        response = objInfo.getJSONObject(0);
                        if (!response.getBoolean("online")) {//设备在线状态
                            detailInfo.put("contact_status",0);
                        } else {
                            detailInfo.put("contact_status",1);
                        }
                        if (response.getBooleanValue("onbed")) {//当前在床状态
                            detailInfo.put("bedStatus", 1);
                            detailInfo.put("heartRate", response.getString("heartrate"));
                            detailInfo.put("breath", response.getString("breathrate"));
                        } else {
                            detailInfo.put("bedStatus", 0);
                            detailInfo.put("heartRate", null);
                            detailInfo.put("breath", null);
                if (null!=deviceInfo){
                    if (deviceInfo.getBooleanValue("success")) {
                        com.alibaba.fastjson.JSONArray objInfo = deviceInfo.getJSONArray("objs");
                        if (objInfo.size() > 0) {
                            response = objInfo.getJSONObject(0);
                            if (!response.getBoolean("online")) {//设备在线状态
                                detailInfo.put("contact_status",0);
                            } else {
                                detailInfo.put("contact_status",1);
                            }
                            if (response.getBooleanValue("onbed")) {//当前在床状态
                                detailInfo.put("bedStatus", 1);
                                detailInfo.put("heartRate", response.getString("heartrate"));
                                detailInfo.put("breath", response.getString("breathrate"));
                            } else {
                                detailInfo.put("bedStatus", 0);
                                detailInfo.put("heartRate", null);
                                detailInfo.put("breath", null);
                            }
                        }
                    }
                }

+ 137 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java

@ -0,0 +1,137 @@
package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.BasePatientMonitorDataDao;
import com.yihu.jw.care.dao.device.DeviceDataPushLogDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BasePatientMonitorDataDO;
import com.yihu.jw.entity.care.device.DeviceDataPushLog;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/9/2.
 * 设备数据推送日志保存
 */
@Component
public class DeviceDataPushLogUtil {
    @Autowired
    private DeviceDataPushLogDao deviceDataPushLogDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private DeviceLostMessageUtil deviceLostMessageUtil;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private BasePatientMonitorDataDao basePatientMonitorDataDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public void savePushLog(String sn,String data,String apiName){
        try {
            DeviceDataPushLog pushLog = new DeviceDataPushLog();
            pushLog.setDeviceSn(sn);
            pushLog.setData(data);
            pushLog.setApiName(apiName);
            pushLog.setCreateTime(new Date());
            List<DevicePatientDevice> devices= patientDeviceDao.findByDeviceSn(sn);
            if (devices.size()>0){
                DevicePatientDevice tmp = devices.get(0);
                BasePatientDO patientDO = patientDao.findById(tmp.getUser());
                if (null!=patientDO){
                    pushLog.setPatient(tmp.getUser());
                    pushLog.setPatientName(patientDO.getName());
                }
                pushLog.setDeviceName(tmp.getDeviceName());
                pushLog.setDeviceCategory(tmp.getCategoryCode());
            }
            deviceDataPushLogDao.save(pushLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 更新在线状态 及次数
     * @param sn
     * @param status
     * @param flag 状态 true 异常 false 正常 null其他
     */
    @Transactional
    public void updContactStatus(String sn,Integer status,Boolean flag){
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(sn);
        if(deviceDetail!=null){
            deviceDetail.setContactStatus(status);
            if(0==status){
                List<String> sns =  new ArrayList<String>();
                sns.add(sn);
                deviceLostMessageUtil.deviceLostMessage(sns);
            }
            else if(1==status){
                //设备在线清除原有的离线消息
                List<String> sns = new ArrayList<String>();
                sns.add(sn);
                systemMessageDao.delMessageByRelationCode(sns);
            }
            deviceDetail.setContactStatusTime(new Date());
            if(deviceDetail.getCollectNum()==null){
                deviceDetail.setCollectNum(0L);
            }
            if(deviceDetail.getAbnormalNum()==null){
                deviceDetail.setAbnormalNum(0L);
            }
            if(flag!=null){
                deviceDetail.setCollectNum(deviceDetail.getCollectNum()+1L);
                if(flag){
                    deviceDetail.setAbnormalNum(deviceDetail.getAbnormalNum()+1L);
                }
            }
            deviceDetailDao.save(deviceDetail);
        }
    }
    /**
     */
    @Async
    public void savePatientMonitorData(String deviceSn,Integer type,String deviceInfo,String relationCode){
        BasePatientMonitorDataDO basePatientMonitorDataDO = new BasePatientMonitorDataDO();
        String sql = " select `user`,category_code from wlyy_patient_device where device_sn='"+deviceSn+"' and del=0 ";
        List<Map<String,Object>> patients = jdbcTemplate.queryForList(sql);
        if (patients.size()>0){
            String patient = patients.get(0).get("user").toString();
            String categoryCode = patients.get(0).get("category_code").toString();
            BasePatientDO patientDO = patientDao.findById(patient);
            basePatientMonitorDataDO.setPatient(patientDO.getId());
            basePatientMonitorDataDO.setPatientName(patientDO.getName());
            basePatientMonitorDataDO.setCategoryCode(categoryCode);
            basePatientMonitorDataDO.setDeviceSn(deviceSn);
            basePatientMonitorDataDO.setType(type);
            basePatientMonitorDataDO.setDeviceInfo(deviceInfo);
            basePatientMonitorDataDO.setRelationCode(relationCode);
            basePatientMonitorDataDO.setCreateTime(new Date());
            basePatientMonitorDataDao.save(basePatientMonitorDataDO);
        }
    }
}

+ 116 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java

@ -0,0 +1,116 @@
package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/9/13.
 */
@Component
public class DeviceLostMessageUtil {
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientDao patientDao;
    /**
     * 设备离线通知
     * @param devices
     */
    public void deviceLostMessage(List<String> devices){
        List<SystemMessageDO> messageDOS = new ArrayList<>();
        for (String id:devices){
            List<SystemMessageDO> sendMessageBefore = systemMessageDao.queryByRelationCodeAndTypeIn(id,new String[]{"43"});
            if (sendMessageBefore.size()>0){//删除之前的离线消息
                systemMessageDao.delete(sendMessageBefore);
            }
            List<DevicePatientDevice> pds =  patientDeviceDao.findByDeviceSn(id);
            if (pds.size()>0){
                DevicePatientDevice deviceDO = pds.get(0);
                String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor d  " +
                        "               WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id and m.doctor_code = d.id " +
                        "               and m.del = '1' and sr.patient = '"+deviceDO.getUser()+"' " ;
                List<Map<String,Object>> doctors = jdbcTemplate.queryForList(sql);
                // 家属
                sql = " select  t2.id,t2.name from  base_patient_family_member t1,  base_patient t2 where  " +
                        "t2.id in (select family_member from base_patient_family_member where patient = '"+deviceDO.getUser()+"' )  " +
                        " and t1.patient = '"+deviceDO.getUser()+"'  and t1.family_member = t2.id  " +
                        " and t2.archive_type=3 GROUP BY t2.id " ;
                List<Map<String,Object>> relatives = jdbcTemplate.queryForList(sql);
                doctors.addAll(relatives);
                String deviceName="";
                for (Map<String,Object> docTmp:doctors){
                    switch (deviceDO.getCategoryCode()){
                        case "1":
                            deviceName="血糖仪离线";
                            break;
                        case "2":
                            deviceName="血压计离线";
                            break;
                        case "4":
                            deviceName="智能手表离线";
                            break;
                        case "7":
                            deviceName="居家安全报警器离线";
                            break;
                        case "12":
                            deviceName="监控器离线";
                            break;
                        case "13":
                            deviceName="睡眠带离线";
                            break;
                        case "14":
                            deviceName="气感报警器离线";
                            break;
                        case "15":
                            deviceName="烟感报警器离线";
                            break;
                        case "16":
                            deviceName="智能拐杖离线";
                            break;
                        case "17":
                            deviceName="随身WiFi离线";
                            break;
                    }
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                    SystemMessageDO messageDO = new SystemMessageDO();
                    messageDO.setTitle("设备离线通知");
                    messageDO.setType("43");
                    messageDO.setIsRead("0");
                    messageDO.setSender(deviceDO.getUser());
                    messageDO.setSenderName(patientDO.getName());
                    messageDO.setRelationCode(id);
                    messageDO.setReceiver(docTmp.get("id").toString());
                    messageDO.setReceiverName(docTmp.get("name").toString());
                    messageDO.setOver("1");
                    messageDO.setData(deviceName);
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    messageDO.setSenderPhoto(patientDO.getPhoto());
                    messageDOS.add(messageDO);
                }
            }
        }
        if (messageDOS.size()>0){
            systemMessageDao.save(messageDOS);
        }
    }
}

+ 0 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/DingdingUtil.java

@ -11,7 +11,6 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

+ 350 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/JczdPersonVo.java

@ -0,0 +1,350 @@
package com.yihu.jw.care.vo;
import java.io.Serializable;
import java.util.Date;
/**
 * 杭州居民信息
 * Created by yeshijie on 2022/4/25.
 */
public class JczdPersonVo implements Serializable {
    private Long id;//主键
    private Long tenantId;//租户ID
    private Long oldGridId;//老的网格id
    private Integer status;//人员状态
    private String personName;//姓名
    private String photoFilePath;//头像图片地址
    private String nationality;//国籍
    private String usedName;//曾用名
    private Integer certificateType;//证件类型:0-身份证,1-护照
    private String certificateNumber;//证件号码
    private Date certificateTermStart;//证件有效期起
    private Date certificateTermEnd;//证件有效期止
    private String personPhone;//手机号
    private Integer sex;//性别 0-女,1-男
    private String liveAddress;//居住地
    private Integer hasResidence;//有无住所,0-无,1-有
    private Integer permanentResidence;//是否常住,0-无,1-是
    private Integer isFloating;//1 户籍人口 2流动人口 3境外人口
    private Date birthday;//生日
    private Integer dataFlag;//0-已删除,1-有效
    private String unifyAddress_code;//统一地址编码
    private String familyCode;//关联家庭(户号)
    private String telephone;//电话号码
    private String personTags;//人员属性
    private Long oldRegistryGridId;//老的网格id
    private String liveAddressCode;//居住地址code
    private String registryAddressCode;//户籍地址code
    private String registryAddress;//户籍地址
    private String liveHouseType;//居住类型, 1:自住,2:租住
    private String licensePlate;//车牌号
    private String gridId;//新的网格id
    private String registryGridId;//新的网格id
    private String familyCodeId;//户号id
    private Date lastVisitTime;//最新访问时间
    private String lastVisitor;//最新采访人
    private Date deadDate;// 死亡时间
    private String personMobile;//电话号码(本系统维护的号码)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getTenantId() {
        return tenantId;
    }
    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }
    public Long getOldGridId() {
        return oldGridId;
    }
    public void setOldGridId(Long oldGridId) {
        this.oldGridId = oldGridId;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getPersonName() {
        return personName;
    }
    public void setPersonName(String personName) {
        this.personName = personName;
    }
    public String getPhotoFilePath() {
        return photoFilePath;
    }
    public void setPhotoFilePath(String photoFilePath) {
        this.photoFilePath = photoFilePath;
    }
    public String getNationality() {
        return nationality;
    }
    public void setNationality(String nationality) {
        this.nationality = nationality;
    }
    public String getUsedName() {
        return usedName;
    }
    public void setUsedName(String usedName) {
        this.usedName = usedName;
    }
    public Integer getCertificateType() {
        return certificateType;
    }
    public void setCertificateType(Integer certificateType) {
        this.certificateType = certificateType;
    }
    public String getCertificateNumber() {
        return certificateNumber;
    }
    public void setCertificateNumber(String certificateNumber) {
        this.certificateNumber = certificateNumber;
    }
    public Date getCertificateTermStart() {
        return certificateTermStart;
    }
    public void setCertificateTermStart(Date certificateTermStart) {
        this.certificateTermStart = certificateTermStart;
    }
    public Date getCertificateTermEnd() {
        return certificateTermEnd;
    }
    public void setCertificateTermEnd(Date certificateTermEnd) {
        this.certificateTermEnd = certificateTermEnd;
    }
    public String getPersonPhone() {
        return personPhone;
    }
    public void setPersonPhone(String personPhone) {
        this.personPhone = personPhone;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    public String getLiveAddress() {
        return liveAddress;
    }
    public void setLiveAddress(String liveAddress) {
        this.liveAddress = liveAddress;
    }
    public Integer getHasResidence() {
        return hasResidence;
    }
    public void setHasResidence(Integer hasResidence) {
        this.hasResidence = hasResidence;
    }
    public Integer getPermanentResidence() {
        return permanentResidence;
    }
    public void setPermanentResidence(Integer permanentResidence) {
        this.permanentResidence = permanentResidence;
    }
    public Integer getIsFloating() {
        return isFloating;
    }
    public void setIsFloating(Integer isFloating) {
        this.isFloating = isFloating;
    }
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public Integer getDataFlag() {
        return dataFlag;
    }
    public void setDataFlag(Integer dataFlag) {
        this.dataFlag = dataFlag;
    }
    public String getUnifyAddress_code() {
        return unifyAddress_code;
    }
    public void setUnifyAddress_code(String unifyAddress_code) {
        this.unifyAddress_code = unifyAddress_code;
    }
    public String getFamilyCode() {
        return familyCode;
    }
    public void setFamilyCode(String familyCode) {
        this.familyCode = familyCode;
    }
    public String getTelephone() {
        return telephone;
    }
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }
    public String getPersonTags() {
        return personTags;
    }
    public void setPersonTags(String personTags) {
        this.personTags = personTags;
    }
    public Long getOldRegistryGridId() {
        return oldRegistryGridId;
    }
    public void setOldRegistryGridId(Long oldRegistryGridId) {
        this.oldRegistryGridId = oldRegistryGridId;
    }
    public String getLiveAddressCode() {
        return liveAddressCode;
    }
    public void setLiveAddressCode(String liveAddressCode) {
        this.liveAddressCode = liveAddressCode;
    }
    public String getRegistryAddressCode() {
        return registryAddressCode;
    }
    public void setRegistryAddressCode(String registryAddressCode) {
        this.registryAddressCode = registryAddressCode;
    }
    public String getRegistryAddress() {
        return registryAddress;
    }
    public void setRegistryAddress(String registryAddress) {
        this.registryAddress = registryAddress;
    }
    public String getLiveHouseType() {
        return liveHouseType;
    }
    public void setLiveHouseType(String liveHouseType) {
        this.liveHouseType = liveHouseType;
    }
    public String getLicensePlate() {
        return licensePlate;
    }
    public void setLicensePlate(String licensePlate) {
        this.licensePlate = licensePlate;
    }
    public String getGridId() {
        return gridId;
    }
    public void setGridId(String gridId) {
        this.gridId = gridId;
    }
    public String getRegistryGridId() {
        return registryGridId;
    }
    public void setRegistryGridId(String registryGridId) {
        this.registryGridId = registryGridId;
    }
    public String getFamilyCodeId() {
        return familyCodeId;
    }
    public void setFamilyCodeId(String familyCodeId) {
        this.familyCodeId = familyCodeId;
    }
    public Date getLastVisitTime() {
        return lastVisitTime;
    }
    public void setLastVisitTime(Date lastVisitTime) {
        this.lastVisitTime = lastVisitTime;
    }
    public String getLastVisitor() {
        return lastVisitor;
    }
    public void setLastVisitor(String lastVisitor) {
        this.lastVisitor = lastVisitor;
    }
    public Date getDeadDate() {
        return deadDate;
    }
    public void setDeadDate(Date deadDate) {
        this.deadDate = deadDate;
    }
    public String getPersonMobile() {
        return personMobile;
    }
    public void setPersonMobile(String personMobile) {
        this.personMobile = personMobile;
    }
    
}

+ 12 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BasePatientMonitorDataDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BasePatientMonitorDataDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2022/4/25.
 */
public interface BasePatientMonitorDataDao extends PagingAndSortingRepository<BasePatientMonitorDataDO,Long>,
        JpaSpecificationExecutor<BasePatientMonitorDataDO> {
}

+ 19 - 4
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -109,6 +109,7 @@ public class DeviceService {
    private String wxId;
    @Autowired
    private PatientFamilyService patientFamilyService;
    @Autowired
    /**
     * 获取爱牵挂管理员cookie
@ -382,6 +383,11 @@ public class DeviceService {
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                    JSONObject position = gpsUtil.gcj02_To_Bd09(lat,lon);
                    patientDO.setLatLon(position.getDouble("lat")+","+position.getDouble("lon"));
                    JSONObject logTmp = new JSONObject();
                    logTmp.put("lat",position.getDouble("lat")+"");
                    logTmp.put("lon",position.getDouble("lon")+"");
                    logTmp.put("address",address);
                    dataPushLogUtil.savePatientMonitorData(imei,9,logTmp.toJSONString(),null);
                    if (StringUtils.isNotBlank(patientDO.getHomeLatLon())){
                        String homeLatLon = patientDO.getHomeLatLon();
                        double homeLat = Double.parseDouble(homeLatLon.split(",")[0]);
@ -455,7 +461,6 @@ public class DeviceService {
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setDel("1");
                    SystemMessageDO messageDO = new SystemMessageDO();
                    String typeName = "您有新的心率测量记录。心率:" + patientHealthIndex.getValue1() + "次/min";
                    messageDO.setTitle(typeName);
@ -498,7 +503,8 @@ public class DeviceService {
                        dataPushLogUtil.updContactStatus(imei,1,true);
                    }
                    dataPushLogUtil.updContactStatus(imei,1,false);
                    healthIndexDao.save(patientHealthIndex);
                    patientHealthIndex = healthIndexDao.save(patientHealthIndex);
                    dataPushLogUtil.savePatientMonitorData(imei,5,heartrate+"",patientHealthIndex.getId()+"");
                    //心率不做异常消息推送
//                    systemMessageDao.save(messageDO);
//                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
@ -584,6 +590,7 @@ public class DeviceService {
                    }
                    dataPushLogUtil.updContactStatus(imei,1,false);
                    healthIndexDao.save(patientHealthIndex);
                    dataPushLogUtil.savePatientMonitorData(imei,2,JSON.toJSONString(patientHealthIndex, SerializerFeature.WriteMapNullValue),patientHealthIndex.getId()+"");
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
@ -650,7 +657,6 @@ public class DeviceService {
                    sleepX1device.setTotal(total);
                    sleepX1device.setCreateTime(DateUtil.strToDate(time_begin));
                    sleepX1device.setEndTime(DateUtil.strToDate(time_end));
                    baseSleepX1deviceDao.save(sleepX1device);
                }
            }
@ -680,7 +686,8 @@ public class DeviceService {
                    Date createTime = DateUtil.strToDate(time_begin,DateUtil.yyyy_MM_dd_HH_mm_ss);
                    basePatientStepDo.setCreateTime(createTime);
                    basePatientStepDo.setDay(DateUtil.dateToStr(createTime,DateUtil.YYYY_MM_DD));
                    stepDao.save(basePatientStepDo);
                    basePatientStepDo =  stepDao.save(basePatientStepDo);
                    dataPushLogUtil.savePatientMonitorData(imei,8,value+"",basePatientStepDo.getId()+"");
                }
            }
        } catch (Exception e) {
@ -993,6 +1000,14 @@ public class DeviceService {
                return;
            }
        }
        if (outBed.getStatus()==null||(status!=outBed.getStatus())){
            if (1==status){
                dataPushLogUtil.savePatientMonitorData(device,11,"老人上床",null);
            }
            if (0==status){
                dataPushLogUtil.savePatientMonitorData(device,11,"老人离床",null);
            }
        }
        outBed.setPatient(patient);
        outBed.setDeviceSn(device);
        outBed.setStatus(status);

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

@ -414,6 +414,9 @@ public class DeviceUploadService {
            }
            obj = patientHealthIndexDao.save(obj);
            if ("1".equals(type)||"2".equals(type)){
                dataPushLogUtil.savePatientMonitorData(deviceSn,Integer.parseInt(type),JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue),obj.getId()+"");
            }
            return obj;
        }
        return null;
@ -554,6 +557,11 @@ public class DeviceUploadService {
                            DevicePatientDevice patientDevice = null;
                            if (patientDeviceList.size()>0){
                                patientDevice = patientDeviceList.get(0);
                                com.alibaba.fastjson.JSONObject logTmp = new com.alibaba.fastjson.JSONObject();
                                logTmp.put("lat",position.getDouble("lat")+"");
                                logTmp.put("lon",position.getDouble("lon")+"");
                                logTmp.put("address",LatitudeUtils.getLocationAddress(dulat+"",dulon+""));
                                dataPushLogUtil.savePatientMonitorData(sn,9,logTmp.toJSONString(),null);
                            }
                            if (null!=patientDevice){//存在围栏地址 判断是否超出围栏,
                                List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(patientDevice.getUser());

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

@ -188,6 +188,14 @@ public class HvDeviceService {
        }
        if(list.size()>0){
            deviceHealthIndexDao.save(list);
            for (DeviceHealthIndex tmp :list){
                if ("1".equals(tmp.getDeviceType())){
                    dataPushLogUtil.savePatientMonitorData(tmp.getDeviceSn(),14,tmp.getValue()+" "+tmp.getUnit(),null);
                }
                if ("2".equals(tmp.getDeviceType())){
                    dataPushLogUtil.savePatientMonitorData(tmp.getDeviceSn(),15,tmp.getValue()+" "+tmp.getUnit(),null);
                }
            }
        }
    }

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

@ -255,6 +255,12 @@ public class OnenetService {
        index.setValue(monitorValue);
        index.setRecordTime(time);
        index.setDeviceType(deviceType);
        if ("1".equals(deviceType)){
            dataPushLogUtil.savePatientMonitorData(resourceSerial,14,monitorValue+" "+unit,null);
        }
        if ("2".equals(deviceType)){
            dataPushLogUtil.savePatientMonitorData(resourceSerial,15,monitorValue+" "+unit,null);
        }
        deviceHealthIndexDao.save(index);
    }
@ -408,6 +414,7 @@ public class OnenetService {
            index.setDeviceType("2");
            index.setValue(value);
            deviceHealthIndexDao.save(index);
            dataPushLogUtil.savePatientMonitorData(deviceSn,15,value+" "+"%",null);
            if (smokeValue>=70){
                if (StringUtils.isNotBlank(index.getTemperaturValue())){
                    if (50<=Integer.valueOf(index.getTemperaturValue())){ //查询温度是否>=50
@ -428,6 +435,7 @@ public class OnenetService {
                }
            }
            index.setTemperaturValue(temperatureValue+"");
            dataPushLogUtil.savePatientMonitorData(deviceSn,10,temperatureValue+"",null);
            deviceHealthIndexDao.save(index);
        }
        if ("5501".equals(msgId)){//当前剩余电量
@ -502,10 +510,15 @@ public class OnenetService {
                index.setUnit("%");
                index.setDeviceType("2");
            }
            index.setValue(gas+"");
            index.setRecordTime(DateUtil.getStringDate());
            deviceHealthIndexDao.save(index);
            if ("1".equals(index.getDeviceType())){
                dataPushLogUtil.savePatientMonitorData(deviceSn,14,index.getValue()+" "+index.getUnit(),null);
            }
            if ("2".equals(index.getDeviceType())){
                dataPushLogUtil.savePatientMonitorData(deviceSn,15,index.getValue()+" "+index.getUnit(),null);
            }
        }
        return flag;

+ 33 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java

@ -1,21 +1,26 @@
package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.BasePatientMonitorDataDao;
import com.yihu.jw.care.dao.device.DeviceDataPushLogDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BasePatientMonitorDataDO;
import com.yihu.jw.entity.care.device.DeviceDataPushLog;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/9/2.
@ -36,6 +41,10 @@ public class DeviceDataPushLogUtil {
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private BasePatientMonitorDataDao basePatientMonitorDataDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public void savePushLog(String sn,String data,String apiName){
@ -102,4 +111,28 @@ public class DeviceDataPushLogUtil {
            deviceDetailDao.save(deviceDetail);
        }
    }
    /**
     * 保存居民设备监测日志
     */
    @Async
    public void savePatientMonitorData(String deviceSn,Integer type,String deviceInfo,String relationCode){
        BasePatientMonitorDataDO basePatientMonitorDataDO = new BasePatientMonitorDataDO();
        String sql = " select `user`,category_code from wlyy_patient_device where device_sn='"+deviceSn+"' and del=0 ";
        List<Map<String,Object>> patients = jdbcTemplate.queryForList(sql);
        if (patients.size()>0){
            String patient = patients.get(0).get("user").toString();
            String categoryCode = patients.get(0).get("category_code").toString();
            BasePatientDO patientDO = patientDao.findById(patient);
            basePatientMonitorDataDO.setPatient(patientDO.getId());
            basePatientMonitorDataDO.setPatientName(patientDO.getName());
            basePatientMonitorDataDO.setCategoryCode(categoryCode);
            basePatientMonitorDataDO.setDeviceSn(deviceSn);
            basePatientMonitorDataDO.setType(type);
            basePatientMonitorDataDO.setDeviceInfo(deviceInfo);
            basePatientMonitorDataDO.setRelationCode(relationCode);
            basePatientMonitorDataDO.setCreateTime(new Date());
            basePatientMonitorDataDao.save(basePatientMonitorDataDO);
        }
    }
}

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

@ -94,6 +94,7 @@ public class SecurityOrderUtil {
                }
                String serveDesc = "";
                /**字典控制某一预警类型是否触发**/
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict' and saas_id=1 ";
                List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
                if (listTmp!=null&&listTmp.size()>0){

+ 11 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/DeviceSosLogDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/5/8.
 */
public interface DeviceSosLogDao extends PagingAndSortingRepository<DeviceSosLogDO, Long>, JpaSpecificationExecutor<DeviceSosLogDO> {
}

+ 23 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientSafeAreaDao.java

@ -0,0 +1,23 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.PatientSafeAreaDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/8/31.
 */
public interface PatientSafeAreaDao extends PagingAndSortingRepository<PatientSafeAreaDO,Long>,
        JpaSpecificationExecutor<PatientSafeAreaDO> {
    @Query(value = " select p from PatientSafeAreaDO p where p.patient=?1 and p.del='1' and p.manageStatus=1 ")
    List<PatientSafeAreaDO> findByPatient(String patient);
    @Modifying
    void deleteByPatient(String patient);
}

+ 10 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java

@ -11,6 +11,7 @@ import com.yihu.jw.care.job.device.PressureGlucoseNotJob;
import com.yihu.jw.care.job.message.DoctorSendUnreadJob;
import com.yihu.jw.care.job.message.PatientSendUnreadJob;
import com.yihu.jw.care.job.order.CancelPayOrderJob;
import com.yihu.jw.care.job.order.DailyWaterJob;
import com.yihu.jw.care.job.order.EmeWarnOrderDayJob;
import com.yihu.jw.care.job.order.EmeWarnOrderJob;
import com.yihu.jw.care.job.sim.GetSimsVoiceFlowDayJob;
@ -183,6 +184,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("BIRTHDAY_WISHES_NOT_PUSH_JOB success");
            }
            //#智慧水表工单触发
            if (!quartzHelper.isExistJob("DAILY_WATER_JOB")){
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("DAILY_WATER_JOB");
                quartzHelper.addJob(DailyWaterJob.class, trigger, "DAILY_WATER_JOB", new HashMap<String, Object>());
                logger.info("DAILY_WATER_JOB success");
            }else {
                logger.info("DAILY_WATER_JOB success");
            }
        } catch (Exception e) {
            logger.info(" job start failed");
        }

+ 82 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/order/DailyWaterJob.java

@ -0,0 +1,82 @@
package com.yihu.jw.care.job.order;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.yihu.jw.care.util.DateUtil;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2022/4/25.
 */
@DisallowConcurrentExecution
public class DailyWaterJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(DailyWaterJob.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SecurityOrderUtil securityOrderUtil;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("DAILY_WATER_JOB start");
        String nowTime = DateUtil.getStringDate();
        Map<String,String> typeInfo = new HashMap<>();
        typeInfo.put("3","4至16点持续不用水");
        typeInfo.put("4","2小时持续大流量");
        typeInfo.put("5","4小时持续用水");
        typeInfo.put("6","8小时持续小流量");
        typeInfo.put("7","16至次日8点持续不用水");
        try {
            String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='DAILY_WATER_LAST_TIME' and dict_code='DAILY_WATER_LAST_TIME' ";
            String lastTime = jdbcTemplate.queryForObject(sql,String.class);
            sql = " select distinct * from hz.m_water_alarm where alarm_time >='"+lastTime+"' ";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> tmp:list){
                try {
                    String deviceSN = tmp.get("card_no").toString();
                    sql = " select id from base_patient where user_id='"+deviceSN+"' ";
                    List<String> patients = jdbcTemplate.queryForList(sql,String.class);
                    if (patients.size()>0){
                        String alarm_type = tmp.get("alarm_type").toString();
                        String addressStr = tmp.get("alarm_address").toString();
                        String alarm_content = tmp.get("alarm_content").toString();
                        JSONObject addressInfo = new JSONObject();
                        Map<String, String> json = LatitudeUtils.getGeocoderLatitude("杭州市拱墅区"+addressStr);
                        if (json != null) {
                            String lat = json.get("lat").toString();
                            String lon = json.get("lng").toString();
                            addressInfo.put("lat",lat);
                            addressInfo.put("lon",lon);
                            addressInfo.put("address",addressStr);
                        }
                        securityOrderUtil.createSecurityOrderWithoutDevice(patients.get(0),deviceSN,null,new JSONObject(),addressInfo, 9, "12", "dailyWater", typeInfo.get(alarm_type));
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            sql = " update set dict_value='"+nowTime+"' from wlyy_hospital_sys_dict where dict_name='DAILY_WATER_LAST_TIME' and dict_code='DAILY_WATER_LAST_TIME'  ";
            jdbcTemplate.execute(sql);
            logger.info("DAILY_WATER_JOB end");
        }catch (Exception e){
            String sql = " update set dict_value='"+nowTime+"' from wlyy_hospital_sys_dict where dict_name='DAILY_WATER_LAST_TIME' and dict_code='DAILY_WATER_LAST_TIME'  ";
            jdbcTemplate.execute(sql);
            logger.error("DAILY_WATER_JOB error....."+e.getMessage());
        }
    }
}

+ 292 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/SecurityOrderUtil.java

@ -0,0 +1,292 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.PatientSafeAreaDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
import com.yihu.jw.entity.care.device.PatientSafeAreaDO;
import com.yihu.jw.exception.business.file_upload.*;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.csource.common.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/8/28.
 */
@Component
public class SecurityOrderUtil {
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private DeviceSosLogDao sosLogDao;
    @Autowired
    private PatientSafeAreaDao safeAreaDao;
    /***创建安防工单***/
    public JSONObject createSecurityOrder(String deviceSN, String sceneUrl, JSONObject result,JSONObject addressInfo, Integer orderSource, String dictCode, String topicItem, String warnInfo){
        try {
            String lat = "";
            String lon = "";
            String address=" ";
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceSN);
            if (devicePatientDeviceDos.size()>0){
                DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                if (null!=addressInfo){
                    lat = addressInfo.getString("lat");
                    lon = addressInfo.getString("lon");
                    address = addressInfo.getString("address");
                }else {
                    Map<String, String> json = null;
                    if (org.apache.commons.lang.StringUtils.isNotBlank(deviceDO.getSosAddress())) {
                        json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                    }
                    if (json != null) {
                        lat = json.get("lat").toString();
                        lon = json.get("lng").toString();
                        address = deviceDO.getSosAddress();
                    }
                }
                BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                String hospital = "";
                String sql ="select DISTINCT pack.org_code,pack.org_name " +
                        " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack " +
                        "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id and  item.`code`='"+topicItem+"'  and item.service_package_id = pack.id " +
                        "  and pack.del=1";
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                if(sqlResult.size()>0){
                    hospital = sqlResult.get(0).get("org_code")+"";
                }
                String serveDesc = "";
                /**字典控制某一预警类型是否触发**/
                String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict' and saas_id=1 ";
                List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
                if (listTmp!=null&&listTmp.size()>0){
                    serveDesc = listTmp.get(0).get("dict_value")+"";
                }else{
                    return new JSONObject();
                }
                if ("1".equals(dictCode)){//疑似离开安全区域 v1.5电子围栏为确认管理时触发
                    List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(patientDO.getId());
                    if (safeAreaDOS.size()==0){
                        return new JSONObject();
                    }
                }
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("patient",patientDO.getId());
                jsonObject.put("patientName",patientDO.getName());
                jsonObject.put("patientPhone",patientDO.getMobile());
                jsonObject.put("serveDesc",serveDesc);
                jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                jsonObject.put("serveAddress",address);
                jsonObject.put("serveLat",lat);
                jsonObject.put("serveLon",lon);
                jsonObject.put("topicItem",topicItem);
                jsonObject.put("deviceSn",deviceSN);
                jsonObject.put("warnInfo",warnInfo);
                if (StringUtils.isNotBlank(sceneUrl)){
                    jsonObject.put("sceneImg",sceneUrl);
                }
                JSONObject jsonObjectParam = new JSONObject();
                jsonObjectParam.put("order", jsonObject);
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("jsonData", jsonObjectParam.toJSONString()));
                params.add(new BasicNameValuePair("warnStr", serveDesc));
                params.add(new BasicNameValuePair("orderSource", orderSource+""));
                String response = httpClientUtil.post(url, params,"UTF-8");
                System.out.println(response);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
    /***创建安防工单***/
    public JSONObject createSecurityOrderWithoutDevice(String patient,String deviceSN, String sceneUrl, JSONObject result,JSONObject addressInfo, Integer orderSource, String dictCode, String topicItem, String warnInfo){
        try {
            String lat = "";
            String lon = "";
            String address=" ";
            lat = addressInfo.getString("lat");
            lon = addressInfo.getString("lon");
            address = addressInfo.getString("address");
            BasePatientDO patientDO = patientDao.findById(patient);
            String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
            String hospital = "";
            String sql ="select DISTINCT pack.org_code,pack.org_name " +
                    " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack " +
                    "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id and  item.`code`='"+topicItem+"'  and item.service_package_id = pack.id " +
                    "  and pack.del=1";
            List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
            if(sqlResult.size()>0){
                hospital = sqlResult.get(0).get("org_code")+"";
            }
            String serveDesc = "";
            /**字典控制某一预警类型是否触发**/
            String sqlDesc = "SELECT dict_value from wlyy_hospital_sys_dict WHERE dict_code = '"+dictCode+"' and dict_name = 'security_server_dict' and saas_id=1 ";
            List<Map<String,Object>> listTmp = jdbcTemplate.queryForList(sqlDesc);
            if (listTmp!=null&&listTmp.size()>0){
                serveDesc = listTmp.get(0).get("dict_value")+"";
            }else{
                return new JSONObject();
            }
            if ("1".equals(dictCode)){//疑似离开安全区域 v1.5电子围栏为确认管理时触发
                List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(patientDO.getId());
                if (safeAreaDOS.size()==0){
                    return new JSONObject();
                }
            }
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("patient",patientDO.getId());
            jsonObject.put("patientName",patientDO.getName());
            jsonObject.put("patientPhone",patientDO.getMobile());
            jsonObject.put("serveDesc",serveDesc);
            jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
            jsonObject.put("serveAddress",address);
            jsonObject.put("serveLat",lat);
            jsonObject.put("serveLon",lon);
            jsonObject.put("topicItem",topicItem);
            jsonObject.put("deviceSn",deviceSN);
            jsonObject.put("warnInfo",warnInfo);
            if (StringUtils.isNotBlank(sceneUrl)){
                jsonObject.put("sceneImg",sceneUrl);
            }
            JSONObject jsonObjectParam = new JSONObject();
            jsonObjectParam.put("order", jsonObject);
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("jsonData", jsonObjectParam.toJSONString()));
            params.add(new BasicNameValuePair("warnStr", serveDesc));
            params.add(new BasicNameValuePair("orderSource", orderSource+""));
            String response = httpClientUtil.post(url, params,"UTF-8");
            System.out.println(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
    /***创建紧急工单****/
    public void createEmeOrder(DeviceSosLogDO logDO, String orderSource){
        String sql =" select Distinct pack.org_code,pack.org_name\n" +
                "from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
                "on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
                "INNER JOIN base_service_package pack on pr.service_package_id = pack.id where item.code='emergencyAssistance' and sr.patient='"+logDO.getPatient()+"'";
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
        if (sqlResult.size()>0){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("serveAddress",logDO.getSosAddress());
            jsonObject.put("serveLon",logDO.getSosLon());
            jsonObject.put("serveLat",logDO.getSosLat());
            jsonObject.put("orgCode",sqlResult.get(0).get("org_code").toString());
            jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
            jsonObject.put("patient",logDO.getPatient());
            jsonObject.put("patientName",logDO.getPatientName());
            jsonObject.put("deviceSn",logDO.getDeviceSn());
            String url = cloudCareUrl+"cloudCare/noLogin/emergency_assistance/newOrder";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("jsonData", jsonObject.toJSONString()));
            params.add(new BasicNameValuePair("patientId", logDO.getPatient()));
            params.add(new BasicNameValuePair("orderSource", orderSource));//工单来源工单发起来源状态 1APP 2手环 3居家报警 4拐杖
            String response = httpClientUtil.post(url, params,"UTF-8");
            JSONObject result = JSONObject.parseObject(response);
            logDO.setSosSendStatus(result.getInteger("status").toString());
            if (result.containsKey("message")){
                logDO.setSosSendMessage(result.getString("message"));
            }
            if (result.containsKey("msg")){
                logDO.setSosSendMessage(result.getString("msg"));
            }
            System.out.println(response);
        }
        sosLogDao.save(logDO);
    }
    public UploadVO uploadImg(MultipartFile file)throws Exception{
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = uploadImg2(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return uploadVO;
    }
    public UploadVO uploadImg2(InputStream inputStream, String originalFileName,long fileSize,String fastdfs_file_url) throws NoSuchAlgorithmException, IOException, MyException {
        // 得到文件的完整名称  xxx.txt
        if( null == inputStream){
            throw new FileInputStreamEmptyException("图片文件流不可为空!");
        }
        if(StringUtils.isBlank(originalFileName)){
            throw new FileNameEmptyException("图片文件名不可为空!");
        }
        if(StringUtils.isBlank(fastdfs_file_url)){
            throw new FastfdsFileURLEmptyException("fastdfs url不可为空!");
        }
        //得到文件类型
        String fileType = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase();
        if(StringUtils.isBlank(fileType)||!"jpg,jpeg,png".contains(fileType)){
            throw new FileWrongFormatException("图片文件格式不正确,请上传jpg,jpeg,png等任一格式!");
        }
        long max = 5*1024*1024;
        if(fileSize > max){
            throw new FileTooLargeSizeException("图片文件过大,请不要超过5M!");
        }
        String fileName = originalFileName.substring(0, originalFileName.lastIndexOf("."));
        //上传到fastdfs
        ObjectNode objectNode = fastDFSHelper.upload(inputStream, fileType, "");
        //解析返回的objectNode
        UploadVO uploadVO = new UploadVO();
        uploadVO.setFileName(fileName);
        uploadVO.setFileType(fileType);
        uploadVO.setFullUri(objectNode.get("fileId").toString().replaceAll("\"", ""));
        uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fileId").toString().replaceAll("\"", ""));
        return uploadVO;
    }
}

+ 7 - 1
svr/svr-cloud-job/src/main/resources/application.yml

@ -123,6 +123,8 @@ cloudServer:
  server_url: http://172.26.0.107:10301/
pay:
  flag: true
cloudCare:
  url: http://172.26.0.107:10301/
##是否发送短信消息 无测试公众号测试线也不发送模板消息
sendTXMessage:
@ -177,6 +179,8 @@ pay:
##是否发送短信消息
sendTXMessage:
  flag: true
cloudCare:
  url: 1
---
spring:
  profiles: hzprod
@ -230,4 +234,6 @@ pay:
  flag: true
##是否发送短信消息
sendTXMessage:
  flag: true
  flag: true
cloudCare:
  url: http://127.0.0.1:10301/

+ 3 - 1
svr/svr-cloud-job/src/main/resources/system.properties

@ -29,4 +29,6 @@ GET_SIMS_VOICE_FLOW_MONTH_JOB= 0 15 6 * * ?
#\u6BCF\u5929\u65E9\u4E0A10\u70B9\u53D1\u9001\u8840\u538B(1\u5929)\u8840\u7CD6(7\u5929)\u672A\u6D4B\u91CF\u901A\u77E5
BLOOD_PRESSURE_GLUCOSE_NOT_MEASURED= 0 0 10 * * ?
#\u751F\u65E5\u795D\u798F\u672A\u53D1\u751F\u8BB0\u5F55
BIRTHDAY_WISHES_NOT_PUSH_JOB= 0 0 3 * * ?
BIRTHDAY_WISHES_NOT_PUSH_JOB= 0 0 3 * * ?
#\u667A\u6167\u6C34\u8868\u5DE5\u5355\u89E6\u53D1
DAILY_WATER_JOB= 0 15 * * * ?

+ 4 - 2
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java

@ -738,9 +738,11 @@ public class XzzxCotroller extends EnvelopRestEndpoint {
                                    @ApiParam(name = "his_serial", value = "HIS挂号号", required = false)
                                    @RequestParam(value = "his_serial",required = false) String his_serial,
                                    @ApiParam(name = "org_code", value = "医院编码", required = false)
                                    @RequestParam(value = "org_code",required = false) String org_code)throws Exception{
                                    @RequestParam(value = "org_code",required = false) String org_code,
                                    @ApiParam(name = "outpatientId", value = "patientId", required = false)
                                        @RequestParam(value = "outpatientId",required = false) String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.confirmSettle(his_serial,icCardNo,org_code));
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.confirmSettle(his_serial,icCardNo,org_code,outpatientId));
    }
    /**

+ 21 - 21
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/healthCare/HealthCareEndPoint.java

@ -152,32 +152,32 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "/register")
    @ApiOperation(value = "2.5.1医保挂号(N20.17.04.01)", notes = "2.5.1医保挂号(N20.17.04.01)")
    public ObjEnvelop register(@ApiParam(name = "registerNo", value = "挂号号", required = true)
                               @RequestParam(value = "registerNo", required = true)String registerNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.register(registerNo));
    public ObjEnvelop register(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                               @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.register(outpatientId));
    }
    @GetMapping(value = "/registerBack")
    @ApiOperation(value = " 2.5.2医保挂号冲销(N20.17.04.02)", notes = " 2.5.2医保挂号冲销(N20.17.04.02)")
    public ObjEnvelop registerBack(@ApiParam(name = "registerNo", value = "挂号号", required = true)
                                   @RequestParam(value = "registerNo", required = true)String registerNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.registerBack(registerNo));
    public ObjEnvelop registerBack(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                   @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.registerBack(outpatientId));
    }
    @GetMapping(value = "/feeDetailUpload")
    @ApiOperation(value = " 2.5.3医保费用明细上传(N20.17.04.03)", notes = " 2.5.3医保费用明细上传(N20.17.04.03)")
    public ObjEnvelop feeDetailUpload(@ApiParam(name = "registerNo", value = "挂号号", required = true)
                                      @RequestParam(value = "registerNo", required = true)String registerNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailUpload(registerNo));
    public ObjEnvelop feeDetailUpload(@ApiParam(name = "outpatientId", value = "挂号号", required = true)
                                      @RequestParam(value = "outpatientId", required = true)String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailUpload(outpatientId));
    }
    @GetMapping(value = "/feeDetailRefund")
    @ApiOperation(value = " 2.5.4医保费用明细上传冲销(N20.17.04.04)", notes = " 2.5.4医保费用明细上传冲销(N20.17.04.04)")
    public ObjEnvelop feeDetailRefund(@ApiParam(name = "registerNo", value = "挂号号", required = true)
                                      @RequestParam(value = "registerNo", required = false)String registerNo,
    public ObjEnvelop feeDetailRefund(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                      @RequestParam(value = "outpatientId", required = false)String outpatientId,
                                      @ApiParam(name = "remark", value = "作废原因", required = false)
                                      @RequestParam(value = "remark", required = true)String remark)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailRefund(registerNo,remark));
        return ObjEnvelop.getSuccess("ok",healthCareService.feeDetailRefund(outpatientId,remark));
    }
    @GetMapping(value = "/preSettlement")
@ -189,23 +189,23 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @GetMapping(value = "/preSettlementRefund")
    @ApiOperation(value = " 2.5.6医保结算冲销服务(N20.17.04.06)", notes = " 2.5.6医保结算冲销服务(N20.17.04.06)")
    public ObjEnvelop preSettlementRefund(@ApiParam(name = "registerNo", value = "门诊id", required = true)
                                          @RequestParam(value = "registerNo", required = false)String registerNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.preSettlementRefund(registerNo));
    public ObjEnvelop preSettlementRefund(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                          @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.preSettlementRefund(outpatientId));
    }
    @GetMapping(value = "/getSettlementResultUrl")
    @ApiOperation(value = " 2.5.7获取医保结算页面地址(N20.17.04.07)", notes = " 2.5.7获取医保结算页面地址(N20.17.04.07)")
    public ObjEnvelop getSettlementResultUrl(@ApiParam(name = "registerNo", value = "门诊id", required = true)
                                             @RequestParam(value = "registerNo", required = false)String registerNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrl(registerNo));
    public ObjEnvelop getSettlementResultUrl(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                             @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrl(outpatientId));
    }
    @GetMapping(value = "/getSettlementResultUrlBase64")
    @ApiOperation(value = " 2.5.7获取医保结算页面地址(N20.17.04.08)", notes = " 2.5.7获取医保结算页面地址(N20.17.04.08)")
    public ObjEnvelop getSettlementResultUrlBase64(@ApiParam(name = "registerNo", value = "门诊id", required = true)
                                             @RequestParam(value = "registerNo", required = false)String registerNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrlBase64(registerNo));
    public ObjEnvelop getSettlementResultUrlBase64(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                             @RequestParam(value = "outpatientId", required = false)String outpatientId)throws Exception{
        return ObjEnvelop.getSuccess("ok",healthCareService.getSettlementResultUrlBase64(outpatientId));
    }
    @GetMapping(value = "/getSettlementResult")

+ 1 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -283,7 +283,7 @@ public class UnSettledHISPrescriptionService {
                                wxPushLogDao.save(wxPushLogDO);
                                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
                                wlyyPrescriptionDO.setPrescribeTime(new Date());
                                wlyyPrescriptionDO.setCheckStatus(0);
                                wlyyPrescriptionDO.setCheckStatus(2);
                                wlyyPrescriptionDO.setCheckReason("审核通过");
                                prescriptionDao.save(wlyyPrescriptionDO);
                                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);

+ 17 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/config/DoctorServiceEndPoint.java

@ -130,6 +130,23 @@ public class DoctorServiceEndPoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.DoctorSetting.updateSort)
    @ApiOperation(value = "修改医生排名")
    public Envelop updateSort(
            @ApiParam(name = "doctorId", value = "状态")
            @RequestParam(value = "doctorId", required = true) String doctorId,
            @ApiParam(name = "sort", value = "排名")
            @RequestParam(value = "sort", required = true) Integer sort)throws Exception{
        try {
            baseDoctorService.updateSort(doctorId,sort);
            return success("修改成功");
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.DoctorSetting.updateDoctorPw)
    @ApiOperation(value = "修改医生账号密码")
    public Envelop updateDoctorPw(@ApiParam(name = "id", value = "医生ID")

+ 9 - 15
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthCare/HealthCareEndPoint.java

@ -204,23 +204,17 @@ public class HealthCareEndPoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "电子处方订单接收", notes = "电子处方订单接收")
    public ObjEnvelop electronicPrescriptionReceiving(@ApiParam(name = "outpatientId", value = "门诊id", required = true)
                                                     @RequestParam(value = "outpatientId",required = true) String outpatientId)throws Exception{
        try {
            if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                String url = entranceHealthCareUrl + "electronicPrescriptionReceiving?outpatientId="+outpatientId;
                String infoResponse = httpClientUtil.get(url,"GBK");
                JSONObject jsonObject = JSONObject.parseObject(infoResponse);
                if(jsonObject.getInteger("status")==200){
                    return ObjEnvelop.getSuccess("ok",jsonObject.get("obj"));
                }else {
                    return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
                }
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
            String url = entranceHealthCareUrl + "electronicPrescriptionReceiving?outpatientId="+outpatientId;
            String infoResponse = httpClientUtil.get(url,"GBK");
            JSONObject jsonObject = JSONObject.parseObject(infoResponse);
            if(jsonObject.getInteger("status")==200){
                return ObjEnvelop.getSuccess("ok",jsonObject.get("obj"));
            }else {
                return ObjEnvelop.getSuccess("ok",healthCareService.electronicPrescriptionReceiving(outpatientId));
                return ObjEnvelop.getError("调用内网接口失败:"+jsonObject.getString("message"));
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedObjEnvelopException(e);
        }else {
            return ObjEnvelop.getSuccess("ok",healthCareService.electronicPrescriptionReceiving(outpatientId));
        }
    }

+ 330 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/healthUpload/HealthUploadPoint.java

@ -0,0 +1,330 @@
package com.yihu.jw.hospital.endpoint.healthUpload;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorHealthUploadDO;
import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
import com.yihu.jw.entity.hospital.prescription.BaseNationalDrugDictDO;
import com.yihu.jw.healthUpload.service.BaseDoctorHealthUploadService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 *
 * Created at 20211003
 */
@RestController
@RequestMapping(value = "healthUpload")
@Api(value = "马銮湾医院健康上报功能", description = "马銮湾医院健康上报功能")
public class HealthUploadPoint extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(HealthUploadPoint.class);
    @Autowired
    private BaseDoctorHealthUploadService baseDoctorHealthUploadService;
    @PostMapping(value = "saveAndCreateMember")
    @ApiOperation(value = "新增医生成员关系")
    public ListEnvelop saveAndCreateMember(@ApiParam(name = "doctorId", value = "医生id")
                                              @RequestParam(value = "doctorId", required = true) String doctorId,
                                           @ApiParam(name = "ids", value = "成员id,逗号隔开")
                                          @RequestParam(value = "ids", required = true) String ids) {
        try {
            List<BaseDoctorMemberDO> doctorHealthUploadDOS = baseDoctorHealthUploadService.saveAndCreateMember(doctorId,ids);
            return success(doctorHealthUploadDOS);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "selectByDoctorId")
    @ApiOperation(value = "查询医生的成员列表")
    public ListEnvelop selectByDoctorId(@ApiParam(name = "doctorId", value = "医生id")
                                           @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<BaseDoctorMemberDO> memberDOList = baseDoctorHealthUploadService.selectByDoctorId(doctorId);
            return success(memberDOList);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "selectCountByDoctorId")
    @ApiOperation(value = "查询医生的成员列表带有已上报次数")
    public ListEnvelop selectCountByDoctorId(@ApiParam(name = "doctorId", value = "医生id")
                                        @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<BaseDoctorMemberDO> memberDOList = baseDoctorHealthUploadService.selectCountByDoctorId(doctorId);
            return success(memberDOList);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "selectById")
    @ApiOperation(value = "查询某一个成员信息")
    public ObjEnvelop selectById(@ApiParam(name = "id", value = "成员列表id")
                                             @RequestParam(value = "id", required = true) String id) {
        try {
            BaseDoctorMemberDO memberDO = baseDoctorHealthUploadService.selectById(id);
            return success(memberDO);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value = "delDoctorMember")
    @ApiOperation(value = "删除某个成员")
    public ObjEnvelop delDoctorMember(@ApiParam(name = "id", value = "成员列表id")
                                 @RequestParam(value = "id", required = true) String id) {
        try {
            BaseDoctorMemberDO memberDO = baseDoctorHealthUploadService.delDoctorMember(id);
            return success(memberDO);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @PostMapping(value = "createHealthUploadInfo")
    @ApiOperation(value = "提交健康信息")
    public ObjEnvelop createHealthUploadInfo(@ApiParam(name = "jsonData", value = "健康信息实体")
                                      @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            BaseDoctorHealthUploadDO healthUploadDO = objectMapper.readValue(jsonData, BaseDoctorHealthUploadDO.class);
            healthUploadDO = baseDoctorHealthUploadService.createHealthUploadInfo(healthUploadDO);
            return success(healthUploadDO);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "selectHealthUploadInfoByDoctorId")
    @ApiOperation(value = "查询成员的健康上报记录")
    public MixEnvelop selectHealthUploadInfoByDoctorId(@ApiParam(name = "doctorId", value = "医生id")
                                                        @RequestParam(value = "doctorId", required = true) String doctorId,
                                                       @ApiParam(name = "startDate", value = "开始时间")
                                                       @RequestParam(value = "startDate", required = false) String startDate,
                                                       @ApiParam(name = "endDate", value = "结束时间")
                                                           @RequestParam(value = "endDate", required = false) String endDate,
                                                       @ApiParam(name = "page", value = "页码")
                                                           @RequestParam(value = "page", required = false) Integer page,
                                                       @ApiParam(name = "pageSize", value = "大小")
                                                           @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            MixEnvelop mixEnvelop = baseDoctorHealthUploadService.selectHealthUploadInfoByDoctorId(doctorId,startDate,endDate,page,pageSize);
            return mixEnvelop;
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = "selectHealthInfoById")
    @ApiOperation(value = "根据id查询健康上报情况")
    public ObjEnvelop selectHealthUploadInfoByDoctorId(@ApiParam(name = "id", value = "医生id")
                                                       @RequestParam(value = "id", required = true) String id) {
        try {
            BaseDoctorHealthUploadDO healthUploadDO = baseDoctorHealthUploadService.selectHealthInfoById(id);
            return success(healthUploadDO);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "saveDoctorInfo")
    @ApiOperation(value = "新增加医生信息")
    public ObjEnvelop saveDoctorInfo(@ApiParam(name = "photo", value = "医生头像")
                                                       @RequestParam(value = "photo", required = false) String photo,
                                                       @ApiParam(name = "name", value = "姓名")
                                                       @RequestParam(value = "name", required = false) String name,
                                                       @ApiParam(name = "idcard", value = "证件号码")
                                                       @RequestParam(value = "idcard", required = false) String idcard,
                                                       @ApiParam(name = "sex", value = "性别")
                                                       @RequestParam(value = "sex", required = false) String sex,
                                                       @ApiParam(name = "mobile", value = "手机号")
                                                       @RequestParam(value = "mobile", required = false) String mobile,
                                                        @ApiParam(name = "dept", value = "科室编码")
                                                         @RequestParam(value = "dept", required = false) String dept,
                                                         @ApiParam(name = "deptName", value = "科室名称")
                                                             @RequestParam(value = "deptName", required = false) String deptName,
                                                         @ApiParam(name = "idCardType", value = "证件类别")
                                                             @RequestParam(value = "idCardType", required = false) String idCardType,
                                                         @ApiParam(name = "idType", value = "身份类别")
                                                             @RequestParam(value = "idType", required = false) String idType,
                                     @ApiParam(name = "id", value = "医生id")
                                         @RequestParam(value = "id", required = false) String id) {
        try {
             BaseDoctorDO baseDoctorDO = baseDoctorHealthUploadService.saveDoctorInfo(id,photo,name,idcard,sex,mobile,dept,deptName,idCardType,idType);
            return success(baseDoctorDO);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    /**
     *
     * @param dept
     * @param level
     * @param doctorId
     * @return
     */
    @GetMapping(value = "selectHealthByRole")
    @ApiOperation(value = "医生首页")
    public ObjEnvelop selectHeaderTotal(@ApiParam(name = "dept", value = "院级管理员无需传科室code")
                                        @RequestParam(value = "dept", required = false) String dept,
                                        @ApiParam(name = "level", value = "1院级管理员,2科室管理员")
                                        @RequestParam(value = "level", required = false) Integer level,
                                        @ApiParam(name = "doctorId", value = "上报状态")
                                        @RequestParam(value = "doctorId", required = false) String doctorId) {
        try {
            JSONObject jsonObject = baseDoctorHealthUploadService.selectHealthByRole(dept,level,doctorId);
            return success(jsonObject);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "selectHeaderTotal")
    @ApiOperation(value = "首页统计")
    public ObjEnvelop selectHeaderTotal(@ApiParam(name = "dept", value = "科室code")
                                                       @RequestParam(value = "dept", required = false) String dept,
                                                       @ApiParam(name = "idType", value = "身份类别")
                                                       @RequestParam(value = "idType", required = false) String idType,
                                                       @ApiParam(name = "status", value = "上报状态")
                                                       @RequestParam(value = "status", required = false) String status,
                                                       @ApiParam(name = "state", value = "健康状态")
                                                       @RequestParam(value = "state", required = false) String state,
                                                       @ApiParam(name = "startDate", value = "开始时间")
                                                       @RequestParam(value = "startDate", required = false) String startDate,
                                        @ApiParam(name = "endDate", value = "结束时间")
                                            @RequestParam(value = "endDate", required = false) String endDate,
                                        @ApiParam(name = "name", value = "姓名")
                                            @RequestParam(value = "name", required = false) String name) {
        try {
            JSONObject jsonObject = baseDoctorHealthUploadService.selectHeaderTotal(dept,idType,status,state,startDate,endDate,name);
            return success(jsonObject);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "selectHeaderList")
    @ApiOperation(value = "首页按照科室统计")
    public ListEnvelop selectHeaderList(@ApiParam(name = "dept", value = "科室code")
                                        @RequestParam(value = "dept", required = false) String dept,
                                        @ApiParam(name = "idType", value = "身份类别")
                                        @RequestParam(value = "idType", required = false) String idType,
                                        @ApiParam(name = "status", value = "上报状态")
                                        @RequestParam(value = "status", required = false) String status,
                                        @ApiParam(name = "state", value = "健康状态")
                                        @RequestParam(value = "state", required = false) String state,
                                        @ApiParam(name = "startDate", value = "开始时间")
                                        @RequestParam(value = "startDate", required = false) String startDate,
                                        @ApiParam(name = "endDate", value = "结束时间")
                                        @RequestParam(value = "endDate", required = false) String endDate,
                                        @ApiParam(name = "name", value = "姓名")
                                        @RequestParam(value = "name", required = false) String name) {
        try {
            return success(baseDoctorHealthUploadService.selectHeaderList(dept,idType,status,state,startDate,endDate,name));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "selectListByTotal")
    @ApiOperation(value = "获取列表的时间及数量")
    public ListEnvelop selectListByTotal(@ApiParam(name = "dept", value = "科室code")
                                        @RequestParam(value = "dept", required = false) String dept,
                                        @ApiParam(name = "idType", value = "身份类别")
                                        @RequestParam(value = "idType", required = false) String idType,
                                        @ApiParam(name = "status", value = "上报状态")
                                        @RequestParam(value = "status", required = false) String status,
                                        @ApiParam(name = "state", value = "健康状态")
                                        @RequestParam(value = "state", required = false) String state,
                                        @ApiParam(name = "startDate", value = "开始时间")
                                        @RequestParam(value = "startDate", required = false) String startDate,
                                         @ApiParam(name = "endDate", value = "结束时间")
                                             @RequestParam(value = "endDate", required = false) String endDate,
                                         @ApiParam(name = "name", value = "名字搜索")
                                             @RequestParam(value = "name", required = false) String name) {
        try {
            JSONArray jsonArray = baseDoctorHealthUploadService.selectListByTotal(dept,idType,status,state,startDate,endDate,name);
            return success(jsonArray);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "selectListInfoByTotal")
    @ApiOperation(value = "获取列表的具体人员信息")
    public ListEnvelop selectListInfoByTotal(@ApiParam(name = "dept", value = "科室code")
                                         @RequestParam(value = "dept", required = false) String dept,
                                         @ApiParam(name = "idType", value = "身份类别")
                                         @RequestParam(value = "idType", required = false) String idType,
                                         @ApiParam(name = "status", value = "上报状态")
                                         @RequestParam(value = "status", required = false) String status,
                                         @ApiParam(name = "state", value = "健康状态")
                                         @RequestParam(value = "state", required = false) String state,
                                         @ApiParam(name = "startDate", value = "开始时间")
                                         @RequestParam(value = "startDate", required = false) String startDate,
                                         @ApiParam(name = "endDate", value = "结束时间")
                                         @RequestParam(value = "endDate", required = false) String endDate,
                                             @ApiParam(name = "name", value = "具体医生姓名")
                                                 @RequestParam(value = "name", required = false) String name) {
        try {
            JSONArray jsonArray = baseDoctorHealthUploadService.selectListInfoByTotal(dept,idType,status,state,startDate,endDate,name);
            return success(jsonArray);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "pushListWriteHealthInfo")
    @ApiOperation(value = "健康上报数据导出", notes = "健康上报数据导出")
    public Envelop pushListWrite(@ApiParam(name = "startDate", value = "开始时间")
                                 @RequestParam(value = "startDate", required = false) String startDate,
                                 @ApiParam(name = "endDate", value = "结束时间")
                                 @RequestParam(value = "endDate", required = false) String endDate,
                                 HttpServletResponse response) throws Exception {
        try{
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("健康上报报表")+".xls"));
            OutputStream os = response.getOutputStream();
            return success(baseDoctorHealthUploadService.selectListInfoExcelByTotal(os, startDate,endDate));
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = "selectRecordByDoctorIdAndConsumer")
    @ApiOperation(value = "查下上报最新一次记录", notes = "查下上报最新一次记录")
    public Envelop selectRecordByDoctorIdAndConsumer(@ApiParam(name = "doctdorId", value = "医生id")
                                 @RequestParam(value = "doctorId", required = false) String doctdorId,
                                 @ApiParam(name = "consumer", value = "代上报人")
                                 @RequestParam(value = "consumer", required = false) String consumer) throws Exception {
        try{
            return success(baseDoctorHealthUploadService.selectRecordByDoctorIdAndConsumer(doctdorId,consumer));
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
}

+ 32 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -20,6 +20,7 @@ import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
@ -29,8 +30,10 @@ import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.es.service.StatisticsEsService;
import com.yihu.jw.es.service.yqfk.YqfkService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.healthUpload.service.BaseDoctorHealthUploadService;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.httplog.service.WlyyHttpLogService;
import com.yihu.jw.hospital.message.service.BaseBannerDoctorService;
@ -94,6 +97,7 @@ import org.apache.poi.util.IOUtils;
import org.apache.tomcat.util.http.fileupload.FileItem;
import org.apache.tomcat.util.http.fileupload.FileItemFactory;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.hibernate.validator.constraints.SafeHtml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -246,6 +250,10 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private String remote_inner_url;
    @Autowired
    private WechatInfoService wechatInfoService;
    @Autowired
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private BaseDoctorHealthUploadService baseDoctorHealthUploadService;
@ -729,6 +737,9 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                            systemMessageDO.setSender(businessOrderDO.getPatient());
                            //发送IM消息
                            hospitalSystemMessageService.sendImMessage(systemMessageDO);
                        }else if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("6")){
                            YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findOne(businessOrderDO.getRelationCode());
                            prescriptionService.confirmSettlementService(ylzMedicalRelationDO.getRelationCode());
                        }
                    }
                    businessOrderService.updatePayStatus(traceNo);
@ -1158,7 +1169,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                //判断处方
                                List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findByRealOrderList(waitPayDetailVO.getRecipeNo());
                                for (WlyyPrescriptionDO prescriptionDO:prescriptionDOList){
                                    if (prescriptionDO.getStatus()!=30){
                                    if (prescriptionDO.getStatus()!=30&&prescriptionDO.getStatus()>=20){
                                        String fee=null;
                                        String title = null;
                                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
@ -1190,6 +1201,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                        prescriptionLogDO.setUserType(1);
                                        prescriptionLogDO.setDatajson("处方结算");
                                        prescriptionLogDao.save(prescriptionLogDO);
                                        /*prescriptionService.electronicPrescriptionReceiving(wlyyOutpatientDO.getId());*/
                                        BusinessOrderDO orderDO = businessOrderDao.selectByRelationCode(prescriptionDO.getId());
                                        orderDO.setStatus(1);
                                        businessOrderDao.save(orderDO);
@ -1289,6 +1301,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                                logger.info("更新门诊结算状态");
                                            }
                                        }
                                        /*prescriptionService.electronicPrescriptionReceiving(wlyyOutpatientDO.getId());*/
                                    }else {
                                        WlyyOutpatientDO wlyyOutpatientDO1 = outpatientDao.findByRealOrder(waitPayDetailVO.getRecipeNo());
                                        if (wlyyOutpatientDO1!=null){
@ -1299,6 +1312,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                    }
                                }
                                prescriptionDao.updateStatusByRealOrder(waitPayDetailVO.getRecipeNo(),30,new Date());
                            }
                            logger.info("更新系统处方支付状态");
                        }
@ -2163,6 +2177,23 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "pushListWriteHealthInfo")
    @ApiOperation(value = "健康上报数据导出", notes = "健康上报数据导出")
    public Envelop pushListWrite(@ApiParam(name = "startDate", value = "开始时间")
                                 @RequestParam(value = "startDate", required = false) String startDate,
                                 @ApiParam(name = "endDate", value = "结束时间")
                                 @RequestParam(value = "endDate", required = false) String endDate,
                                 HttpServletResponse response) throws Exception {
        try{
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String(URLEncoder.encode("健康上报报表")+".xls"));
            OutputStream os = response.getOutputStream();
            return success(baseDoctorHealthUploadService.selectListInfoExcelByTotal(os, startDate,endDate));
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    /**
     * 咨询列表
     * @param startDate

+ 0 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java


Деякі файли не було показано, через те що забагато файлів було змінено