Browse Source

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

LAPTOP-KB9HII50\70708 2 years ago
parent
commit
6bff5ffe7f
38 changed files with 2831 additions and 268 deletions
  1. 21 24
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java
  2. 1 1
      business/base-service/src/main/java/com/yihu/jw/healthCare/service/HealthCareService.java
  3. 14 14
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  5. 16 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/EnterpriseJsapiTicketDao.java
  6. 265 0
      business/base-service/src/main/java/com/yihu/jw/wechat/enterprise/EnterpriseService.java
  7. 31 8
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java
  8. 17 1
      common/common-entity/sql记录
  9. 73 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/EnterpriseJsApiTicket.java
  10. 12 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  11. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java
  12. 97 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitSignDO.java
  13. 13 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionInfoDO.java
  14. 3 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  15. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyHisPrescriptionVO.java
  16. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionInfoVO.java
  17. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/lifeCare/LifeCareService.java
  18. 4 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/message/BaseServiceNewsDao.java
  19. 13 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/visit/BaseVisitSignDao.java
  20. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/admin/AdminInfoEndpoint.java
  21. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java
  22. 7 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java
  23. 112 35
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  24. 202 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  25. 79 30
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  26. 41 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java
  27. 23 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  28. 25 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  29. 35 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java
  30. 56 43
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  31. 189 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  32. 833 61
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  33. 236 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  34. 68 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java
  35. 217 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HlsDownloader.java
  36. 78 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  37. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  38. 1 1
      wlyy-parent-pom/pom.xml

+ 21 - 24
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java

@ -8,6 +8,7 @@ import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.doctor.DoctorSpecialDiseaseDo;
import com.yihu.jw.entity.hospital.appointment.WlyySpecialDiseaseDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
@ -23,6 +24,7 @@ import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
@ -199,6 +201,7 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
    public Object queryById(String doctorId,String typeCode) {
        Map<String,Object> params = new HashedMap();
        String sql ="SELECT " +
                " a.id AS \"id\", " +
                " a.NAME AS \"name\", " +
                " a.job_title_name AS \"jobTitleName\", " +
                " a.introduce AS \"introduce\", " +
@ -208,8 +211,8 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
                " b.dept_name AS \"deptName\", " +
                " b.org_name AS \"orgName\", " +
                " c.mapping_code AS \"jobNumber\", " +
                " d.disease_name AS \"diseaseName\", " +
                " d.disease_code AS \"diseaseCode\", " +
/*                " d.disease_name AS \"diseaseName\", " +
                " d.disease_code AS \"diseaseCode\", " +*/
                " e.req_fee AS \"money\" ," +
                " h.dept_type_code AS \"deptTypeCode\" ," +
                "\tm.req_fee as \"twfzFee\",\n" +
@ -229,7 +232,7 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
                " LEFT JOIN base_doctor_hospital b ON a.id = b.doctor_code " +
                " LEFT JOIN base_doctor_mapping c ON a.id = c.doctor " +
                " LEFT JOIN dict_hospital_dept h ON b.dept_code = h.code " +
                " LEFT JOIN wlyy_doctor_special_disease d ON a.id = d.doctor_code " +
/*                " LEFT JOIN wlyy_doctor_special_disease d ON a.id = d.doctor_code " +*/
                " LEFT JOIN wlyy_charge_dict e ON a.charge_type = e.charge_type " +
                " LEFT JOIN wlyy_charge_dict m ON a.twfz_charge_type = m.charge_type and m.is_del='1'\n" +
                " LEFT JOIN wlyy_charge_dict n ON a.spfz_charge_type = n.charge_type and n.is_del='1'\n" +
@ -252,30 +255,24 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params);
        StringBuilder disease = new StringBuilder();
        StringBuilder code = new StringBuilder();
        String diseaseName = "";
        String diseaseCode = "";
        if (null != list && list.size() > 0){
            if (list.size() == 1){
                return  list.get(0);
            }else {
                for (int i=0;i<list.size();i++){
                    if (i == 0 ){
                        if (list.get(i).get("diseaseName")!=null){
                            disease.append(list.get(i).get("diseaseName"));
                            code.append(list.get(i).get("diseaseCode"));
                        }
                    }else {
                        if (list.get(i).get("diseaseName")!=null){
                            disease.append(","+list.get(i).get("diseaseName"));
                            code.append(","+list.get(i).get("diseaseCode"));
                        }
                    }
                }
                list.get(0).put("diseaseName",disease);
                list.get(0).put("diseaseCode",code);
                return  list.get(0);
            Map<String,Object> map = list.get(0);
            List<DoctorSpecialDiseaseDo> specialDiseaseDoList = specialDiseaseDao.findByDoctorCode(map.get("id").toString());
            for (DoctorSpecialDiseaseDo diseaseDo:specialDiseaseDoList){
                disease.append(diseaseDo.getDiseaseName()+",");
                code.append(diseaseDo.getDiseaseCode()+",");
            }
            logger.info("disease"+disease+"===code==="+disease);
            if (StringUtils.isNoneBlank(disease)){
                diseaseName = disease.substring(0,disease.length()-1);
                diseaseCode = code.substring(0,code.length()-1);
            }
            list.get(0).put("diseaseName",diseaseName);
            list.get(0).put("diseaseCode",diseaseCode);
            return  list.get(0);
        }
        return null;
    }

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

@ -1868,7 +1868,7 @@ public class HealthCareService {
    public String getSettlementResult(String code) throws Exception{
        String funid = "N20.17.04.08";
        JSONObject data = new JSONObject();
        data.put("code",code);//参保地区划代码
        data.put("code",code);//
        String result = requestYlz(data,funid,"获取医保结算结果");
        if (result==null){
            throw new Exception("获取医保结算结果失败!");

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

@ -3158,7 +3158,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            prescriptionDao.save(prescription);
            //记录开发失败日志
            prescriptionLogService.addPrescriptionLog(prescription.getId(), 13, 2, outpatientDO.getDoctor(), outpatientDO.getDoctorName(), "", new Date());
            return result;
        }
    }
@ -3258,6 +3257,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        json.put("unit", info.getUnit());
        json.put("usage", info.getUsageCode());
        json.put("supplyCode", info.getSupplyCode());
        json.put("sfybxm",info.getSfybxm());
        if (StringUtils.isNotBlank(info.getDays())) {
            json.put("days", info.getDays());
        } else {
@ -4780,13 +4780,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            //医保是否有处方权
            if(healthCareService.isHospitalFlag()){
                String doctorAuthenticationUrl = entranceHealthCareUrl + "doctorAuthentication?doctorId="+doctorDO.getId();
                String infoResponse = httpClientUtil.get(doctorAuthenticationUrl,"GBK");
                com.alibaba.fastjson.JSONObject doctorAuthentication = com.alibaba.fastjson.JSONObject.parseObject(infoResponse);
                if(doctorAuthentication.getInteger("status")==200){
                    rs.put("is_prescribe", doctorAuthentication.get("obj"));//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                    String doctorAuthenticationUrl = entranceHealthCareUrl + "doctorAuthentication?doctorId="+doctorDO.getId();
                    String infoResponse = httpClientUtil.get(doctorAuthenticationUrl,"GBK");
                    com.alibaba.fastjson.JSONObject doctorAuthentication = com.alibaba.fastjson.JSONObject.parseObject(infoResponse);
                    if(doctorAuthentication.getInteger("status")==200){
                        rs.put("is_prescribe", doctorAuthentication.get("obj"));//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                    }else {
                        rs.put("is_prescribe",0);
                    }
                }else {
                    rs.put("is_prescribe",0);
                    rs.put("is_prescribe", healthCareService.doctorAuthentication(doctorDO.getId()));//is_prescribe	是否具备处方权	1-有处方权,0无处方权
                }
            }else{
                rs.put("is_prescribe", 0);//is_prescribe	是否具备处方权	1-有处方权,0无处方权
@ -9719,7 +9723,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param prescriptionId
     * @return
     */
    public WlyyPrescriptionCheckDO saveCheck(String operate, String operateName, String reason, Integer status, String prescriptionId, String wxId,String ip) {
    public WlyyPrescriptionCheckDO saveCheck(String operate, String operateName, String reason, Integer status, String prescriptionId, String wxId,String ip) throws Exception {
        WlyyPrescriptionCheckDO prescriptionCheckDO = new WlyyPrescriptionCheckDO();
        prescriptionCheckDO.setCreateTime(new Date());
        prescriptionCheckDO.setOperate(operate);
@ -9743,7 +9747,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
                try {
                    //his处方拼接开方条件
                    com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
                    for (WlyyPrescriptionInfoDO info : infoDOS) {
@ -9830,9 +9833,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                    //sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                try {
@ -14421,11 +14421,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                }
                logger.info("电子发票开具开始");
                /*try {
                try {
                    entranceService.dzpjServer(patientMappingDO.getMappingCode(),realOrder);
                }catch (Exception e){
                    e.printStackTrace();
                }*/
                }
                logger.info("电子发票开具结束");
            }

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -1024,6 +1024,9 @@ public class EntranceService {
                if (StringUtils.isNotBlank(vo.getQuantity())) {
                    sbs.append(" quantity=\"" + vo.getQuantity() + "\"");
                }
                if (StringUtils.isNotBlank(vo.getSfybxm())) {
                    sbs.append(" sfybxm=\"" + vo.getSfybxm() + "\"");
                }
                if (StringUtils.isNotBlank(vo.getGroupNo())) {
                    sbs.append(" group_no=\"" + vo.getGroupNo() + "\"");
                }

+ 16 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/EnterpriseJsapiTicketDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.EnterpriseJsApiTicket;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface EnterpriseJsapiTicketDao extends PagingAndSortingRepository<EnterpriseJsApiTicket, Long> {
    @Query("select p from EnterpriseJsApiTicket p where p.acc_id = ?1 order by p.add_timestamp desc")
    Iterable<EnterpriseJsApiTicket> findJsapiTicket(String accId);
}

+ 265 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/enterprise/EnterpriseService.java

@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.wx.EnterpriseJsApiTicket;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.enterprise.WxEnterpriseDO;
import com.yihu.jw.entity.hospital.enterprise.WxEnterpriseTokenDO;
import com.yihu.jw.entity.hospital.enterprise.WxEnterpriseUserDO;
@ -14,17 +17,27 @@ import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseDao;
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseTokenDao;
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseUserDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
 * Created by Trick on 2020/2/8.
@ -42,6 +55,9 @@ public class EnterpriseService {
    private String agentId = "1000003";
    @Value("${FileTempPath.upload_temp_path}")
    private String upload_temp_path;
    @Autowired
    private WxEnterpriseTokenDao wxEnterpriseTokenDao;
    @Autowired
@ -52,6 +68,10 @@ public class EnterpriseService {
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    protected HttpServletRequest request;
    public String getToken(String enterpriseId)throws Exception{
@ -90,6 +110,12 @@ public class EnterpriseService {
        return token.getAccessToken();
    }
    /**
     * 小程序token
     * @param enterpriseId
     * @return
     * @throws Exception
     */
    public String getXCXToken(String enterpriseId)throws Exception{
        logger.info("getXCXToken");
@ -481,7 +507,245 @@ public class EnterpriseService {
        return "ok";
    }
    /**
     * 获取企业微信的jsapi_ticket
     *
     * @return
     */
    public String getEnterpriseJsapi_ticketByToken(String wxId) throws Exception {
        try {
            System.out.println("getEnterpriseJsapi_ticketByToken="+wxId);
            Iterable<EnterpriseJsApiTicket> jsapiTickets = null;
            WxWechatDO wxWechat = null;
            //中山医院互联网医院
            if("xm_zsyy_wx".equals(wxId) || "xm_xzzx_wx".equals(wxId) || "xm_ykyy_wx".equals(wxId)||"xm_hcyy_wx".equals(wxId)){
                jsapiTickets = wxAccessTokenService.findEnterpriseJsapiTicket(wxId);
            }else{
                wxWechat = wxAccessTokenService.getWxInfo(wxId);
                jsapiTickets = wxAccessTokenService.findEnterpriseJsapiTicket(wxWechat.getAppOriginId());
            }
            if (jsapiTickets != null) {
                for (EnterpriseJsApiTicket jsApiTicket : jsapiTickets) {
                    if ((System.currentTimeMillis() - jsApiTicket.getAdd_timestamp()) < (jsApiTicket.getExpires_in() * 1000)) {
                        return jsApiTicket.getJsapi_ticket();
                    } else {
                        wxAccessTokenService.delEnterpriseJsapiTicket(jsApiTicket);
                        break;
                    }
                }
            }
            String token = "";
            //中山医院互联网医院
            token = getToken(wxId);
            System.out.println("getticket_token:"+token);
            if (token != null) {
                String token_url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?";
                String params = "access_token=" + token ;
                String result = HttpUtil.sendGet(token_url, params);
                System.out.println("result:"+result);
                org.json.JSONObject json = new org.json.JSONObject(result);
                System.out.println("getticket:"+result);
                if (json.has("ticket")) {
                    String ticket = json.get("ticket").toString();
                    String expires_in = json.get("expires_in").toString();
                    EnterpriseJsApiTicket newJsApiTicket = new EnterpriseJsApiTicket();
                    newJsApiTicket.setJsapi_ticket(ticket);
                    newJsApiTicket.setExpires_in(Long.parseLong(expires_in));
                    if("xm_zsyy_wx".equals(wxId) || "xm_xzzx_wx".equals(wxId) || "xm_ykyy_wx".equals(wxId)||"xm_hcyy_wx".equals(wxId)){
                        newJsApiTicket.setAcc_id(wxId);
                    }else{
                        newJsApiTicket.setAcc_id(wxWechat.getAppOriginId());
                    }
                    wxAccessTokenService.addEnterpriseJsapiTicket(newJsApiTicket);
                    return ticket;
                } else {
                    return null;
                }
            } else {
                return null;
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
            throw new Exception(e.getMessage());
        }
    }
    /**
     * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
     *
     * @return
     */
    public InputStream getInputStream(String mediaId, String wechat_appid) throws Exception {
        String accessToken = getToken(wechat_appid);
        InputStream is = null;
        String url = "https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=" + accessToken + "&media_id=" + mediaId;
//		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=30_OBJbMMPW9TnyGHKf32bcjkXtxWnzBrtqWlSMBnNk8MWpJ6qis2TnsecRYNZImgahdx30WrsI1bGco6K67-j4sT1QkDxYKBrVvjaYF6QgbY8dgBMzuoARKoaxtX3ehiYvdCLSUHvogrpF3n0GANIfCHAHUP&media_id=R_060hnyXAFyHD9HaOLl15xhDIzDvcA61-Wz34GkXmCakdrsFJqxrPEBHewmAEK9";
        logger.info("media/get" + url);
        try {
            URL urlGet = new URL(url);
            HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
            http.setRequestMethod("GET"); // 必须是get方式请求
            http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            http.setDoOutput(true);
            http.setDoInput(true);
            System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
            System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
            http.connect();
            // 获取文件转化为byte流
            is = http.getInputStream();
            if (is.available() <= 200) {
                logger.info("下载多媒体文件 accessToken 过期");
                accessToken=getToken(wechat_appid);
                is = getInputStreamReLoad(mediaId, wechat_appid, accessToken);
                return is;
            }
        } catch (Exception e) {
            logger.info(e.getMessage());
            e.printStackTrace();
            throw new Exception("下载失败," + e.getMessage());
        }
        return is;
    }
    /**
     * accessToken 过期时重新下载多媒体文件
     * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
     *
     * @return
     */
    public InputStream getInputStreamReLoad(String mediaId, String wechat_appid, String accessToken) throws Exception {
        logger.info("accessToken 过期时重新下载多媒体文件:accessToken:" + accessToken);
        logger.info("accessToken 过期时重新下载多媒体文件:wechat_appid:" + wechat_appid);
        logger.info("accessToken 过期时重新下载多媒体文件:mediaId:" + mediaId);
        InputStream is = null;
        String url = "https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=" + accessToken + "&media_id=" + mediaId;
        logger.info("media/get" + url);
        try {
            URL urlGet = new URL(url);
            HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
            http.setRequestMethod("GET"); // 必须是get方式请求
            http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            http.setDoOutput(true);
            http.setDoInput(true);
            System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
            System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
            http.connect();
            // 获取文件转化为byte流
            is = http.getInputStream();
        } catch (Exception e) {
            logger.info(e.getMessage());
            e.printStackTrace();
            throw new Exception("下载失败," + e.getMessage());
        }
        return is;
    }
    /**
     * 获取下载语音信息(jpg)
     *
     * @param mediaId 文件的id
     * @throws Exception
     */
    public String saveVoiceToDisk(String mediaId, String wechat_appid) throws Exception {
        // 文件保存的临时路径
        String tempPath = upload_temp_path + File.separator;
        System.out.println("tempPath:" + tempPath);
        // 拼接年月日路径
        String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
        System.out.println("datePath:" + datePath);
        // 重命名文件
        String fileBase = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000);
        System.out.println("fileBase:" + fileBase);
        String newFileName = fileBase + ".amr";
        String mp3FileName = fileBase + ".mp3";
        System.out.println("newFileName:" + newFileName);
        System.out.println("mp3FileName:" + mp3FileName);
        // 保存路径
        File uploadFile = new File(tempPath + datePath + newFileName);
        InputStream inputStream = null;
        FileOutputStream fileOutputStream = null;
        try {
            if (!uploadFile.getParentFile().exists()) {
                uploadFile.getParentFile().mkdirs();
            }
            inputStream = getInputStream(mediaId, wechat_appid);
            byte[] data = new byte[1024];
            int len = 0;
            fileOutputStream = new FileOutputStream(uploadFile);
            while ((len = inputStream.read(data)) != -1) {
                fileOutputStream.write(data, 0, len);
            }
            String amrFilePath = tempPath + datePath + newFileName;
            String Mp3FilePath = tempPath + datePath + mp3FileName;
            System.out.println("amrFilePath:" + amrFilePath);
            System.out.println("Mp3FilePath:" + Mp3FilePath);
//			fileUtil.changeToMp3(amrFilePath,Mp3FilePath);
            // 返回保存路径
            return amrFilePath;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
    /**
     * 获取微信服务器语音
     *
     * @return
     */
    public String fetchWxVoices(String wecha_appid) {
        String voiceIds = "";
        try {
            String voices = request.getParameter("voices");
            System.out.println("voices" + voices);
            if (org.apache.commons.lang3.StringUtils.isEmpty(voices)) {
                return voices;
            }
            String[] mediaIds = voices.split(",");
            for (String mediaId : mediaIds) {
                if (org.apache.commons.lang3.StringUtils.isEmpty(mediaId)) {
                    continue;
                }
                String temp = saveVoiceToDisk(mediaId, wecha_appid);
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(temp)) {
                    if (voiceIds.length() == 0) {
                        voiceIds = temp;
                    } else {
                        voiceIds += "," + temp;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
//			error(e);
        }
        return voiceIds;
    }
//    public String send
//    public static void main(String args[])throws Exception{
@ -608,4 +872,5 @@ public class EnterpriseService {
//    }
}

+ 31 - 8
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java

@ -1,17 +1,11 @@
package com.yihu.jw.wechat.service;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxAppletsAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.wechat.dao.JsapiTicketDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.jw.wechat.dao.WxAppletsAccessTokenDao;
import com.yihu.jw.wechat.dao.*;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.network.HttpUtils;
import org.json.JSONObject;
@ -42,6 +36,8 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
    @Autowired
    private JsapiTicketDao jsapiTicketDao;
    @Autowired
    private EnterpriseJsapiTicketDao enterpriseJsapiTicketDao;
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
    @Autowired
    private WxAppletsAccessTokenDao wxAppletsAccessTokenDao;
@ -408,11 +404,29 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
        return jsapiTicketDao.findJsapiTicket(accId);
    }
    /**
     * 获取企业微信凭证
     * @param accId 企业微信原始id
     * @return
     */
    public Iterable<EnterpriseJsApiTicket> findEnterpriseJsapiTicket(String accId) {
        return enterpriseJsapiTicketDao.findJsapiTicket(accId);
    }
    public void delJsapiTicket(JsApiTicket jsApiTicket) {
        jsapiTicketDao.delete(jsApiTicket);
    }
    /**
     * 企业微信Jsapi
     *
     * @param jsApiTicket
     */
    public void delEnterpriseJsapiTicket(EnterpriseJsApiTicket jsApiTicket) {
        enterpriseJsapiTicketDao.delete(jsApiTicket);
    }
    /**
     * 添加JsapiTicket
     */
@ -421,4 +435,13 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
        jsApiTicket.setCzrq(new Date());
        jsapiTicketDao.save(jsApiTicket);
    }
    /**
     * 添加企业微信JsapiTicket
     */
    public void addEnterpriseJsapiTicket(EnterpriseJsApiTicket jsApiTicket) {
        jsApiTicket.setAdd_timestamp(System.currentTimeMillis());
        jsApiTicket.setCzrq(new Date());
        enterpriseJsapiTicketDao.save(jsApiTicket);
    }
}

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

@ -1804,4 +1804,20 @@ CREATE TABLE `base_patient_monitor_data` (
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_patient` (`patient`)
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8mb4 COMMENT='设备监测日志记录表';
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8mb4 COMMENT='设备监测日志记录表';
-- 2022-05-18
CREATE TABLE `base_visit_sign` (
  `id` varchar(50) NOT NULL,
  `visit_id` varchar(50) DEFAULT NULL COMMENT '走访id',
  `type` int(2) DEFAULT NULL COMMENT '签到方式1.定位,2.拍照',
  `doctor` varchar(50) DEFAULT NULL COMMENT '医生',
  `doctor_name` varchar(50) DEFAULT NULL COMMENT '医生姓名',
  `lon` varchar(20) DEFAULT NULL COMMENT '经度',
  `lat` varchar(20) DEFAULT NULL COMMENT '纬度',
  `address` varchar(255) DEFAULT NULL COMMENT '地址',
  `img` varchar(2500) DEFAULT NULL COMMENT '图片地址“,”分割',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `del` int(2) DEFAULT NULL COMMENT '是否删除1为删除,0.为正常',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=257 DEFAULT CHARSET=utf8mb4 COMMENT='日常走访签到';

+ 73 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/EnterpriseJsApiTicket.java

@ -0,0 +1,73 @@
package com.yihu.jw.entity.base.wx;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
/**
 * JavaScript API访问所需要的凭据
 */
@Entity
@Table(name = "wx_enterprise_jsapi_ticket")
@SequenceGenerator(name="id_generated", sequenceName="WX_ENTERPRISE_JSAPI_TICKET_SEQ")
public class EnterpriseJsApiTicket extends IntegerIdentityEntity {
    private static final long serialVersionUID = -3297644428262254694L;
    private String jsapi_ticket;
    private String acc_id;;
    private Long add_timestamp;
    private Long expires_in;
    private Date czrq;
    public String getAcc_id() {
        return acc_id;
    }
    public void setAcc_id(String acc_id) {
        this.acc_id = acc_id;
    }
    public String getJsapi_ticket() {
        return jsapi_ticket;
    }
    public void setJsapi_ticket(String jsapi_ticket) {
        this.jsapi_ticket = jsapi_ticket;
    }
    public Long getAdd_timestamp() {
        return add_timestamp;
    }
    public void setAdd_timestamp(Long add_timestamp) {
        this.add_timestamp = add_timestamp;
    }
    public Long getExpires_in() {
        return expires_in;
    }
    public void setExpires_in(Long expires_in) {
        this.expires_in = expires_in;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -78,6 +78,18 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private double distance;//医生与患者距离 单位km
    private String otherDoctorDistance;
    //居民绑定的设备code
    private String patientDevices;
    @Transient
    public String getPatientDevices() {
        return patientDevices;
    }
    public void setPatientDevices(String patientDevices) {
        this.patientDevices = patientDevices;
    }
    /**
     * 服务小结
     */

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java

@ -17,7 +17,7 @@ public class BaseVisitDO extends UuidIdentityEntityWithCreateTime {
    private String patient;
    private String patientName;
    private String type;//类型 1老人日常走访 2老人日常临时走访(管理端直接新增记录没有计划)
    private String status;//状态 0计划中 1 已完成 2计划超时
    private String status;//状态 0计划中 1 已完成 2计划超时 3 已签到
    private Date visitDate;//完成走访时间
    private Date visitPlanDate;//计划走访时间
    private String doctor;

+ 97 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitSignDO.java

@ -0,0 +1,97 @@
package com.yihu.jw.entity.care.visit;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2022/5/18.
 * 日常走访签到表
 */
@Entity
@Table(name = "base_visit_sign")
public class BaseVisitSignDO extends UuidIdentityEntityWithCreateTime {
    private String visitId; //走访id
    private Integer type;  // 签到方式1.定位,2.拍照
    private String doctor; //签到医生
    private String doctorName;
    private String lon; //经度
    private String lat; //纬度
    private String address;//签到地址
    private String img;//图片 多张逗号隔开
    private Integer del; //0无效 1有效
    public String getVisitId() {
        return visitId;
    }
    public void setVisitId(String visitId) {
        this.visitId = visitId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getLon() {
        return lon;
    }
    public void setLon(String lon) {
        this.lon = lon;
    }
    public String getLat() {
        return lat;
    }
    public void setLat(String lat) {
        this.lat = lat;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 13 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionInfoDO.java

@ -164,6 +164,19 @@ public class WlyyPrescriptionInfoDO extends UuidIdentityEntity {
     */
    private String pzwh;
    /**
     * sfybxm 是否医保项目 Y:是, N:否
     */
    private String sfybxm;
    @Column(name = "sfybxm")
    public String getSfybxm() {
        return sfybxm;
    }
    public void setSfybxm(String sfybxm) {
        this.sfybxm = sfybxm;
    }
    @Column(name = "prescription_id")
    public String getPrescriptionId() {

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

@ -973,6 +973,9 @@ public class BaseHospitalRequestMapping {
    
        //获取微信签名
        public static final String getSign ="/getSign";
        //获取企业微信签名
        public static final String getEnterpriseSign ="/getEnterpriseSign";
        
        //获取居民-导诊的咨询对话
        public static final String getPatientGuaidenceConsult = "getPatientGuaidenceConsult";

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

@ -147,6 +147,15 @@ public class WlyyHisPrescriptionVO extends UuidIdentityVOWithOperator {
    private String idnoType;
    private String sfybxm;
    public String getSfybxm() {
        return sfybxm;
    }
    public void setSfybxm(String sfybxm) {
        this.sfybxm = sfybxm;
    }
    public String getIdnoType() {
        return idnoType;

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

@ -160,6 +160,15 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
    private String pzwh;
    private String sfybxm;
    public String getSfybxm() {
        return sfybxm;
    }
    public void setSfybxm(String sfybxm) {
        this.sfybxm = sfybxm;
    }
    public String getPrescriptionId() {
        return prescriptionId;

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/lifeCare/LifeCareService.java

@ -48,7 +48,7 @@ public class LifeCareService {
        filter +=" GROUP BY dict.`code` ";
        filter += " order by dict.org_code,dict.sort asc ";
        filter += " order by dict.sort,dict.org_code ASC ";
        filter += " limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter);

+ 4 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/message/BaseServiceNewsDao.java

@ -1,12 +1,12 @@
package com.yihu.jw.care.dao.message;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.message.BaseServiceNews;
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 java.util.Date;
import java.util.List;
/**
@ -20,4 +20,7 @@ public interface BaseServiceNewsDao extends PagingAndSortingRepository<BaseServi
    @Query("select a from BaseServiceNews a ")
    List<BaseServiceNews> findNews(Pageable pageRequest);
    @Query("select a from BaseServiceNews a where a.createTime >= ?1 and a.createTime <= ?2 ")
    List<BaseServiceNews> findNewsByTime(Date beginTime, Date endTime, Pageable pageRequest);
}

+ 13 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/visit/BaseVisitSignDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.care.dao.visit;
import com.yihu.jw.entity.care.visit.BaseVisitSignDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2022/5/18.
 */
public interface BaseVisitSignDao extends PagingAndSortingRepository<BaseVisitSignDO,String>, JpaSpecificationExecutor<BaseVisitSignDO> {
    BaseVisitSignDO findByVisitId(String visitId);
}

+ 24 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/admin/AdminInfoEndpoint.java

@ -467,4 +467,28 @@ public class AdminInfoEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "statisticsOldAdd")
    @ApiOperation(value = "管理端首页智慧照护生活照料项目新增情况")
    public ObjEnvelop statisticsOldAdd(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) Integer level,
            @ApiParam(name="type",value="类型:1本周,2本月",defaultValue = "")@RequestParam(required = false) String type) {
        try {
            JSONObject param = new JSONObject();
            String doctorId =  permissionService.getUID();
            param.put("doctorId",doctorId);
            if(permissionService.noPermission(0,param)){
                return ObjEnvelop.getError("该操作没有权限");
            }
            JSONObject result = statisticsService.statisticsOldAdd(endDate,area,level, type);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(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,null, page, size);
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,null, page, size,null);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }

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

@ -90,10 +90,11 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
            @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 = "orgCode", value = "生活工单服务项所属机构") @RequestParam(value = "orgCode", required = false) String orgCode,
            @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,fedCode, page, size);
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,fedCode, page, size,orgCode);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }
@ -108,9 +109,10 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
    @ApiOperation(value = "查询工单数量")
    public ObjEnvelop infoCount(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode) {
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode,
            @ApiParam(name = "orgCode", value = "生活工单服务项所属机构") @RequestParam(value = "orgCode", required = false) String orgCode) {
        try {
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null,fedCode, 1, 5);
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null,fedCode, 1, 5,orgCode);
            if (allResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(allResult.getString(ResponseContant.resultMsg), -1);
            }
@ -118,14 +120,14 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
            JSONObject object = new JSONObject();
            object.put("allCount",allCount);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, fedCode,1, 5);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, fedCode,1, 5,orgCode);
            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, fedCode,1, 5);
            JSONObject wcResult = lifeCareOrderService.queryInfoList(patient, 2, fedCode,1, 5,orgCode);
            if (wcResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(wcResult.getString(ResponseContant.resultMsg), -1);
            }

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

@ -3,12 +3,12 @@ package com.yihu.jw.care.endpoint.statistics;
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;
import com.yihu.jw.care.service.statistics.DetectionPlatformService;
import com.yihu.jw.care.util.HlsDownloader;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -22,8 +22,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/***
 * @ClassName: DetectionPlatformEndpoint
 * @Description: 社区云照护平台--物联网健康监测展示平台 v1.0.0
@ -48,6 +46,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    private DeviceManageService deviceManageService;
    @ApiOperation("环境信息")
    @RequestMapping(value = "envMessage", method = RequestMethod.GET)
    public ObjEnvelop envMessage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "1")
@ -77,7 +76,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "设备物联率、失联率")
    public ObjEnvelop getDeviceCompany() {
        try {
            JSONObject o = platformService.getDeviceComapny(null,null);
            JSONObject o = platformService.getDeviceComapny(null, null);
            return success(o);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
@ -283,7 +282,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "物联网检测大屏,设备库存、使用、总备案、照护类型设备数量")
    public ObjEnvelop getServiceSituation() {
        try {
            return success("查询成功", 200, platformService.getServiceSituation(null,null));
            return success("查询成功", 200, platformService.getServiceSituation(null, null));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -339,21 +338,21 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        try {
            return ObjEnvelop.getSuccess("查询成功", networkCardService.getFlowPoolInfo());
        } catch (Exception e) {
           return failedObjEnvelopException2(e);
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("获取流量/语音使用趋势--折线")
    @ResponseBody
    @RequestMapping(value = "getFlowVoiceLineInfo", method = RequestMethod.GET)
    public ListEnvelop getFlowVoiceLineInfo(@ApiParam(name="type",value = "1月2日")
                                       @RequestParam(value ="type",required = true)String type,
                                       @ApiParam(name="data",value = "flow,voice")
                                       @RequestParam(value ="data",required = true)String data,
                                       @ApiParam(name="size",value = "返回大小")
                                       @RequestParam(value ="size",required = true)Integer size) {
    public ListEnvelop getFlowVoiceLineInfo(@ApiParam(name = "type", value = "1月2日")
                                            @RequestParam(value = "type", required = true) String type,
                                            @ApiParam(name = "data", value = "flow,voice")
                                            @RequestParam(value = "data", required = true) String data,
                                            @ApiParam(name = "size", value = "返回大小")
                                            @RequestParam(value = "size", required = true) Integer size) {
        try {
            return ListEnvelop.getSuccess("查询成功",networkCardService.getFlowVoiceLineInfo(type,data,size));
            return ListEnvelop.getSuccess("查询成功", networkCardService.getFlowVoiceLineInfo(type, data, size));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -362,14 +361,14 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation("获取流量/语音使用总数据表格-从统计初至今")
    @ResponseBody
    @RequestMapping(value = "getSimFlowVoiceLineInfo", method = RequestMethod.GET)
    public ListEnvelop getSimFlowVoiceLineInfo(@ApiParam(name="type",value = "1月2日")
                                            @RequestParam(value ="type",required = true)String type,
                                            @ApiParam(name="data",value = "flow,voice")
                                            @RequestParam(value ="data",required = true)String data,
                                            @ApiParam(name="day",value = "")
                                            @RequestParam(value ="day",required = false)String day) {
    public ListEnvelop getSimFlowVoiceLineInfo(@ApiParam(name = "type", value = "1月2日")
                                               @RequestParam(value = "type", required = true) String type,
                                               @ApiParam(name = "data", value = "flow,voice")
                                               @RequestParam(value = "data", required = true) String data,
                                               @ApiParam(name = "day", value = "")
                                               @RequestParam(value = "day", required = false) String day) {
        try {
            return ListEnvelop.getSuccess("查询成功",networkCardService.getSimFlowVoiceLineInfo(type,data,day));
            return ListEnvelop.getSuccess("查询成功", networkCardService.getSimFlowVoiceLineInfo(type, data, day));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -380,7 +379,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "getSimCounts", method = RequestMethod.GET)
    public ListEnvelop getSimCounts() {
        try {
            return ListEnvelop.getSuccess("查询成功",networkCardService.getSimCounts());
            return ListEnvelop.getSuccess("查询成功", networkCardService.getSimCounts());
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -391,29 +390,107 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "getTopicPeopleNums", method = RequestMethod.GET)
    public ObjEnvelop getTopicPeopleNums() {
        try {
            return ObjEnvelop.getSuccess("查询成功",platformService.getTopicPeopleNums(null,null));
            return ObjEnvelop.getSuccess("查询成功", platformService.getTopicPeopleNums(null, null));
        } catch (Exception e) {
            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){
    @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);
            return deviceManageService.getPatientMonitorData(patient, startTime, endTime, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return PageEnvelop.getError("系统繁忙");
        }
    }
    @GetMapping(value = "getVideoList")
    @ApiOperation(value = "获取监控点列表")
    public PageEnvelop getVideoList(@ApiParam(name = "page", required = false, defaultValue = "0")
                                    @RequestParam(value = "page",required = false,defaultValue = "0") Integer page,
                                    @ApiParam(name = "pageSize", required = false, defaultValue = "50")
                                    @RequestParam(value = "pageSize",required = false,defaultValue = "50") Integer pageSize) {
        try {
            return platformService.getVideoList(page, pageSize);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getVideoListByTreeNode")
    @ApiOperation(value = "获取监控点列表")
    public PageEnvelop getVideoListByTreeNode(@ApiParam(name = "treeNode", required = true, defaultValue = "0")
                                    @RequestParam(value = "treeNode",required = true,defaultValue = "0") String treeNode,
                                    @ApiParam(name = "page", required = false, defaultValue = "0")
                                    @RequestParam(value = "page",required = false,defaultValue = "0") Integer page,
                                    @ApiParam(name = "pageSize", required = false, defaultValue = "50")
                                    @RequestParam(value = "pageSize",required = false,defaultValue = "50") Integer pageSize) {
        try {
            return platformService.getVideoListByTreeNode(treeNode,page, pageSize);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getVideoUrlByCode")
    @ApiOperation(value = "根据编码获取流地址")
    public ObjEnvelop getVideoUrl(@ApiParam @RequestParam String indexCode) {
        try {
            String videoUrl = platformService.getVideoUrl(indexCode);
            if(StringUtils.isBlank(videoUrl)){
                return ObjEnvelop.getError("获取失败");
            }
            return ObjEnvelop.getSuccess("获取成功",videoUrl);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "testDownloadVideoUrl")
    @ApiOperation(value = "下载m3u8")
    public ObjEnvelop downM3u8Video(@RequestParam String url) {
        try {
            return platformService.downM3u8Video(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ObjEnvelop.getSuccess("1111","");
    }
//    public static void main(String[] args) {
//        String originUrlpath = "http://videocdn.renrenjiang.cn/Act-ss-m3u8-sd/1037359_1546064640169/1037359_1546064640169.m3u8";
//        String preUrlPath = originUrlpath.substring(0, originUrlpath.lastIndexOf("/")+1);
//        String rootPath = "E:\\videodir";
//        String fileName = "";
//        HlsDownloader downLoader = new HlsDownloader(originUrlpath, preUrlPath, rootPath);
//        //downLoader.setThreadQuantity(10);
//        try{
//            fileName = downLoader.download(true);
//        }
//        catch (Exception e) {
//            e.printStackTrace();
//        }
//
//        if(StringUtils.isBlank(fileName)){
//            System.out.println("下载失败");
//        }else{
//            System.err.println("下载成功"+fileName);
//            System.out.println("完整路径:"+rootPath+"\\"+fileName);
//        }
//
//    }
}

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

@ -20,6 +20,9 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
@ -132,6 +135,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {
        try {
            //机构和人员总数
            JSONObject result = statisticsService.serviceResources();
            return success(result);
        } catch (Exception e) {
@ -139,6 +143,33 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getOrgListByPage")
    @ApiOperation(value = "获取机构列表")
    public PageEnvelop getOrgListByPage(@ApiParam(name = "type",value = "类型。1医疗机构,3养老机构,4托育机构,6照料中心") @RequestParam String type,
                                        @ApiParam(name = "page",value = "页码") @RequestParam Integer page,
                                        @ApiParam(name = "pageSize",value = "每页大小") @RequestParam Integer pageSize,
                                        @ApiParam(name = "name",value = "模糊搜索") @RequestParam(name = "name",required = false)String name){
        try {
            return statisticsService.getOrgListByPage(type, page, pageSize,name);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getUserListByPage")
    @ApiOperation(value = "获取人员列表")
    public PageEnvelop getUserListByPage(@ApiParam(name = "type",value = "类型。1医生,2社工,3教师,4助老员") @RequestParam String type,
                                         @ApiParam(name = "page",value = "页码") @RequestParam Integer page,
                                         @ApiParam(name = "pageSize",value = "每页大小") @RequestParam Integer pageSize,
                                         @ApiParam(name = "name",value = "模糊搜索名字") @RequestParam(name = "name",required = false)String name,
                                         @ApiParam(name = "idCard",value = "模糊搜索身份证号") @RequestParam(name = "idCard",required = false)String idCard){
        try {
            return statisticsService.getUserListByPage(type, page, pageSize, name, idCard);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "realTimeDataNew")
    @ApiOperation(value = "实时数据v0.7.0")
    public ObjEnvelop realTimeDataNew() {
@ -152,10 +183,12 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getAllDynamics")
    @ApiOperation(value = "综合动态v0.7.0")
    public PageEnvelop getAllDynamics(
            @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) {
    public PageEnvelop getAllDynamics(@ApiParam @RequestParam Integer page,
                                      @ApiParam @RequestParam Integer size,
                                      @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                      @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime) {
        try {
            return statisticsService.getAllDynamics(page, size);
            return statisticsService.getAllDynamics(page, size,beginTime,endTime);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
@ -210,7 +243,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findUserByType")
    @ApiOperation(value = "人员实时动态搜索")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2签约老人,3社工,4医生,5老人家属 6助老员,7社区老人(未签约).不传返回四个类型的数据")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2已照护老人(签约+已绑定设备),3社工,4医生,5老人家属 6助老员,7街道老人(未签约)8 需招呼老人 原社区老人 .不传返回四个类型的数据")
                                  @RequestParam(value = "type", required = false) String type,
                                  @ApiParam(name = "name", value = "姓名")
                                  @RequestParam(value = "name", required = false) String name,
@ -456,18 +489,177 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findTendOld")
    @ApiOperation(value = "获取照护老人列表")
    public ObjEnvelop findTendOld(@ApiParam(name="page",value = "页码",required = false)
                                       @RequestParam(value = "page",required = true,defaultValue = "1") Integer page,
                                   @ApiParam(name="size",value = "分页大小",required = false)
                                       @RequestParam(value = "size",required = true,defaultValue = "5") Integer size){
        try {
            JSONObject tendOld = statisticsService.findTendOld(page, size);
    public ObjEnvelop findTendOld(@ApiParam(name = "page", value = "页码", required = false)
                                  @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
                                  @ApiParam(name = "size", value = "分页大小", required = false)
                                  @RequestParam(value = "size", required = true, defaultValue = "5") Integer size,
                                  @ApiParam(name = "type", value = "查询类型1老人,2幼儿,3街道老人", required = false)
                                  @RequestParam(value = "type", required = false) Integer type,
                                  @ApiParam(name = "idcard",value = "身份证",required = false)
                                  @RequestParam(value = "idcard",required = false)String idcard,
                                  @ApiParam(name = "name",value = "居民名字",required = false)
                                  @RequestParam(value = "name",required = false)String name,
                                  @ApiParam(name = "orgName",value = "社区名字",required = false)
                                  @RequestParam(value = "orgName",required = false)String  orgName) {
        try {
            JSONObject tendOld = statisticsService.findTendOld(type,page, size,idcard,name,orgName);
            return success(tendOld);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "findOldOrg")
    @ApiOperation(value = "获取照护老人社区")
    public ListEnvelop findOldOrg(){
        try {
            List<Map<String, Object>> oldOrg = statisticsService.findOldOrg();
            return success(oldOrg);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "findOverTimeOrder")
    @ApiOperation(value = "获取超时工单")
    public ObjEnvelop findOverTimeOrder(@ApiParam(name = "page", value = "页", required = true,defaultValue = "1")
                                        @RequestParam(value = "page", required = true) Integer page,
                                        @ApiParam(name = "size", value = "条", required = true,defaultValue = "10")
                                        @RequestParam(value = "size", required = true) Integer size,
                                        @ApiParam(name = "name", value = "居民名字", required = false)
                                        @RequestParam(value = "name", required = false) String name,
                                        @ApiParam(name = "idcard", value = "身份证", required = false)
                                        @RequestParam(value = "idcard", required = false) String idcard,
                                        @ApiParam(name = "orgCode", value = "机构code", required = false)
                                        @RequestParam(value = "orgCode", required = false) String orgCode,
                                        @ApiParam(name = "type", value = "查询类型1安防紧急工单 2生活照料", required = false)
                                        @RequestParam(value = "type", required = false) Integer type) {
        try {
            JSONObject jsonObject = statisticsService.overTimeOrderList(type, page, size, name, idcard, orgCode);
            return success(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "emeSecOrderList")
    @ApiOperation(value = "获取紧急安防工单列表")
    public ObjEnvelop emeSecOrderList(@ApiParam(name = "page", value = "页", required = true,defaultValue = "1")
                                      @RequestParam(value = "page", required = true) Integer page,
                                      @ApiParam(name = "size", value = "条", required = true,defaultValue = "10")
                                      @RequestParam(value = "size", required = true) Integer size,
                                      @ApiParam(name = "name", value = "居民名字", required = false)
                                      @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "idcard", value = "身份证", required = false)
                                      @RequestParam(value = "idcard", required = false) String idcard,
                                      @ApiParam(name = "orgCode", value = "机构code", required = false)
                                      @RequestParam(value = "orgCode", required = false) String orgCode,
                                      @ApiParam(name = "status",value = "工单状态",required = false)
                                      @RequestParam(value = "status",required = false)Integer status){
        try {
            JSONObject jsonObject = statisticsService.emeSecOrderList(status, name, idcard, orgCode, page, size);
            return success(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceNameList")
    @ApiOperation(value = "获取设备名字列表")
    public ListEnvelop deviceNameList(@ApiParam(name = "deviceType",value = "设备类型 0健康设备 1安防设备",required = false)
                                      @RequestParam(value = "deviceType",required = false)String deviceType){
        try {
            List<Map<String, Object>> list = statisticsService.deviceNameList(deviceType);
            return success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "healthySecurityDeviceList")
    @ApiOperation(value = "获取安防/健康设备列表")
    public PageEnvelop healthySecurityDeviceList(@ApiParam(name = "page", value = "页", required = true,defaultValue = "1")
                                                 @RequestParam(value = "page", required = true) Integer page,
                                                 @ApiParam(name = "size", value = "条", required = true,defaultValue = "10")
                                                 @RequestParam(value = "size", required = true) Integer size,
                                                 @ApiParam(name = "name", value = "居民名字", required = false)
                                                 @RequestParam(value = "name", required = false) String name,
                                                 @ApiParam(name = "deviceSn", value = "设备Sn码", required = false)
                                                 @RequestParam(value = "deviceSn", required = false) String deviceSn,
                                                 @ApiParam(name = "categoryCode", value = "设备类型Code", required = false)
                                                 @RequestParam(value = "categoryCode", required = false) String categoryCode,
                                                 @ApiParam(name = "contactStatus",value = "在线状态 1在线,0不在线",required = false)
                                                 @RequestParam(value = "contactStatus",required = false)String contactStatus,
                                                 @ApiParam(name = "type",value = "查询设备类型 af / jk",required = false)
                                                 @RequestParam(value = "type",required = false)String type){
        try {
            return statisticsService.healthySecurityDeviceList(name,deviceSn,categoryCode,contactStatus,type,page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceinfoStatisticsNum")
    @ApiOperation(value = "获取设备数量")
    public ObjEnvelop deviceinfoStatisticsNum(@ApiParam(name = "type",value = "设备类型0健康 1安防",required = true)
                                              @RequestParam(value = "type",required = true)String type){
        try {
            JSONObject jsonObject = statisticsService.deviceinfoStatisticsNum(type);
            return success(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "findByPatientHelper")
    @ApiOperation(value = "获取助老员")
    public ListEnvelop findByPatientHelper(@ApiParam(name = "patient", value = "居民code", required = false)
                                           @RequestParam(value = "patient", required = false) String patient) {
        try {
            List<Map<String, Object>> byPatientHelper = statisticsService.findByPatientHelper(patient);
            return success(byPatientHelper);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "getDoorCoachRank")
    @ApiOperation(value = "获取上门辅导排名")
    public ObjEnvelop getDoorCoachRank(@RequestParam(required = true) String endDate,
                                       @RequestParam(required = true) String area,
                                       @RequestParam(required = true) Integer level) {
        try {
            return ObjEnvelop.getSuccess("success",statisticsService.getDoorCoachRank(endDate,area,level));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "findDictEmeStatus")
    @ApiOperation(value = "紧急预警状态字典")
    public ListEnvelop findDictEmeStatus(){
        try {
            return success(statisticsService.findDictEmeStatus());
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }

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

@ -13,6 +13,7 @@ import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.third.PatientInfoPlatFormService;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -26,6 +27,8 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by Bing on 2021/6/16.
 * 管理端pc端 居民详情大屏
@ -77,11 +80,12 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "findUnSignPatientLocations")
    @ApiOperation("查找未签约老人坐标")
    @ApiOperation("查找未签约老人坐标 社区老人/街道老人")
    public PageEnvelop findUnSignPatientLocations(@ApiParam(name = "page")@RequestParam(value = "page")Integer page,
                                                  @ApiParam(name = "size")@RequestParam(value = "size")Integer size){
                                                  @ApiParam(name = "size")@RequestParam(value = "size")Integer size,
                                                  @ApiParam(name = "type",value = "类型1社区老人 2街道老人",required = false)@RequestParam(value = "type",required = false)Integer type){
        try {
            return baseServiceNewsService.findUnSignPatientLocations(page,size);
            return baseServiceNewsService.findUnSignPatientLocations(page,size,type);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -110,17 +114,32 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findNews")
    @ApiOperation("服务动态")
    public ListEnvelop findNews(@ApiParam(name="page",value = "页面大小",required = false)
                                @RequestParam(value = "page",required = false,defaultValue = "0")Integer page,
                                @ApiParam(name="size",value = "页面大小",required = true)
                                @RequestParam(value = "size")Integer size){
    public ListEnvelop findNews(@ApiParam(name="page",value = "页面大小",required = false) @RequestParam(value = "page",required = false,defaultValue = "0")Integer page,
                                @ApiParam(name="size",value = "页面大小",required = true) @RequestParam(value = "size")Integer size,
                                @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return ListEnvelop.getSuccess("查询成功",baseServiceNewsService.findNews(page,size));
            return ListEnvelop.getSuccess("查询成功",baseServiceNewsService.findNews(page,size,beginTime,endTime));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "findNewsByPage")
    @ApiOperation("服务动态分页")
    public PageEnvelop findNewsByPage(@ApiParam(name="page",value = "页面大小") @RequestParam Integer page,
                                      @ApiParam(name="pageSize",value = "页面大小") @RequestParam Integer pageSize,
                                      @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                      @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            List<BaseServiceNews> news = baseServiceNewsService.findNews(page, pageSize,beginTime,endTime);
            Long count = baseServiceNewsService.findNewsCount(beginTime, endTime);
            return PageEnvelop.getSuccessListWithPage("获取成功",news,page,pageSize,count);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPatientInfo")
    @ApiOperation("获取居民详情页--弃用")
    public ObjEnvelop getPatientInfo(@ApiParam(name="patient",value = "居民id",required = true)
@ -378,15 +397,13 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getEmergencyWarnOrderListNew")
    @ApiOperation(value = "安防监测列表 v0.7.0")//        疑似离开安全区域+疑似跌倒
    public PageEnvelop getEmergencyWarnOrderListNew(@ApiParam(name="page",value = "page")
                                                 @RequestParam(value = "page") Integer page,
                                                    @ApiParam(name="patient",value = "patient")
                                                    @RequestParam(value = "patient",required = false) String patient,
                                                 @ApiParam(name="pageSize",value = "pageSize")
                                                 @RequestParam(value = "pageSize") Integer pageSize
    ){
    public PageEnvelop getEmergencyWarnOrderListNew(@ApiParam(name="page",value = "page") @RequestParam(value = "page") Integer page,
                                                    @ApiParam(name="patient",value = "patient") @RequestParam(value = "patient",required = false) String patient,
                                                    @ApiParam(name="pageSize",value = "pageSize") @RequestParam(value = "pageSize") Integer pageSize,
                                                    @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                                    @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return patientInfoPlatFormService.getEmergencyWarnOrderListNew(page,pageSize,patient);
            return patientInfoPlatFormService.getEmergencyWarnOrderListNew(page,pageSize,patient,beginTime,endTime);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -394,15 +411,13 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getEmergencyWarningListNew")
    @ApiOperation(value = "紧急预警列表 v0.7.0")//        发起紧急救助
    public PageEnvelop getEmergencyWarningListNew(@ApiParam(name="page",value = "page")
                                                    @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="patient",value = "patient")
                                                  @RequestParam(value = "patient",required = false) String patient,
                                                    @ApiParam(name="pageSize",value = "pageSize")
                                                    @RequestParam(value = "pageSize") Integer pageSize
    ){
    public PageEnvelop getEmergencyWarningListNew(@ApiParam(name="page",value = "page") @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="patient",value = "patient") @RequestParam(value = "patient",required = false) String patient,
                                                  @ApiParam(name="pageSize",value = "pageSize") @RequestParam(value = "pageSize") Integer pageSize,
                                                  @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                                  @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return patientInfoPlatFormService.getEmergencyWarningListNew(page,pageSize,patient);
            return patientInfoPlatFormService.getEmergencyWarningListNew(page,pageSize,patient,beginTime,endTime);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -410,13 +425,12 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getHealthMonitoringListNew")
    @ApiOperation(value = "健康监测列表 v0.7.0")// 血糖+血压
    public PageEnvelop getHealthMonitoringListNew(@ApiParam(name="page",value = "page")
                                                  @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="pageSize",value = "pageSize")
                                                  @RequestParam(value = "pageSize") Integer pageSize
    ){
    public PageEnvelop getHealthMonitoringListNew(@ApiParam(name="page",value = "page") @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="pageSize",value = "pageSize") @RequestParam(value = "pageSize") Integer pageSize,
                                                  @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                                  @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return patientInfoPlatFormService.getHealthMonitoringListNew(page,pageSize);
            return patientInfoPlatFormService.getHealthMonitoringListNew(page,pageSize,beginTime,endTime);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -459,4 +473,39 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "getWarningCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取预警中的总数")
    public ObjEnvelop getWarningCount(@ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getWarningCount(patient);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "getWarningList", method = RequestMethod.GET)
    @ApiOperation(value = "获取紧急预警中的列表")
    public PageEnvelop getWarningList(@ApiParam(name="page",value = "页码") @RequestParam(value = "page") Integer page,
                                      @ApiParam(name="pageSize",value = "每页大小") @RequestParam(value = "pageSize") Integer pageSize,
                                      @ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getWarningList(page,pageSize,patient);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @RequestMapping(value = "getHealthWarningList", method = RequestMethod.GET)
    @ApiOperation(value = "获取体征预警中的列表")
    public PageEnvelop getHealthWarningList(@ApiParam(name="page",value = "页码") @RequestParam(value = "page") Integer page,
                                            @ApiParam(name="pageSize",value = "每页大小") @RequestParam(value = "pageSize") Integer pageSize,
                                            @ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getHealthWarningList(page,pageSize,patient);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
}

+ 41 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java

@ -1,9 +1,12 @@
package com.yihu.jw.care.endpoint.visit;
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.visit.BaseVisitService;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.entity.care.visit.BaseVisitDO;
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;
@ -13,7 +16,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -32,6 +34,9 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseVisitService baseVisitService;
    @Autowired
    private PermissionService permissionService;
    @ApiOperation("获取日常走访列表")
    @RequestMapping(value = "/getListByDoctor", method = RequestMethod.GET)
    public ListEnvelop getListByDoctor(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2021-11-11 00:00:00")
@ -137,7 +142,7 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("直接新增走访--管理员端")
    @ApiOperation("直接新增走访--管理员端--管理员端取消日常走访")
    @RequestMapping(value = "/adminAddVisit",method = RequestMethod.POST)
    public Envelop adminAddVisit(@ApiParam(name = "doctor", value = "医生id")
                                 @RequestParam(value = "doctor", required = true) String doctor,
@ -154,10 +159,43 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
                                 @ApiParam(name = "lifeConsult", value = "生活咨询")
                                 @RequestParam(value = "lifeConsult", required = false) String lifeConsult) {
        try {
            baseVisitService.adminAddVisit(doctor,patient,visitContent,visitImg,deviceMaintenance,health,lifeConsult);
//            baseVisitService.adminAddVisit(doctor,patient,visitContent,visitImg,deviceMaintenance,health,lifeConsult);
            return Envelop.getSuccess("操作成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @PostMapping("signIn")
    @ApiOperation(value = "日常走访签到")
    @ObserverRequired
    public ObjEnvelop signIn(
            @ApiParam(value = "走访id", name = "visitId")
            @RequestParam(value = "visitId", required = true) String visitId,
            @ApiParam(value = "签到方式:1.定位,2.拍照", name = "signWay")
            @RequestParam(value = "signWay", required = true) Integer signWay,
            @ApiParam(value = "签到纬度", name = "signLat")
            @RequestParam(value = "signLat", required = false) String signLat,
            @ApiParam(value = "签到经度", name = "signLon")
            @RequestParam(value = "signLon", required = false) String signLon,
            @ApiParam(value = "签到地址", name = "address")
            @RequestParam(value = "address", required = false) String address,
            @ApiParam(value = "签到照片", name = "signImg")
            @RequestParam(value = "signImg", required = false) String signImg) {
        try {
            String doctorId = permissionService.getUID();
            JSONObject param = new JSONObject();
            param.put("doctorId",doctorId);
            if(permissionService.noPermission(1,param)){
                return ObjEnvelop.getError("该操作没有权限");
            }
            JSONObject result = baseVisitService.signIn(visitId, signWay, signLat,signLon, address,signImg,doctorId);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("操作成功",result.getString(ResponseContant.resultMsg));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
}

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

@ -781,11 +781,34 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        sql.append(" order by ord.create_time "+sort+" limit "+page*pageSize+","+pageSize);
        List<EmergencyAssistanceDO> resultList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(EmergencyAssistanceDO.class));
        List<String> patientCodes = new ArrayList<>();
        for (EmergencyAssistanceDO obj:resultList){
            BasePatientDO patientDO = patientDao.findById(obj.getPatient());
            obj.setPatientPhoto(patientDO.getPhoto());
            obj.setPatientSex(patientDO.getSex());
            obj.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
            if(!patientCodes.contains(obj.getPatient())){
                patientCodes.add(obj.getPatient());
            }
        }
        String inSql = "";
        for (String code : patientCodes) {
            inSql += "'"+code+"',";
        }
        if(StringUtils.isNotBlank(inSql)){
            inSql = inSql.substring(0,inSql.lastIndexOf(","));
            //居民绑定的设备code
            String deviceSql = "SELECT user,GROUP_CONCAT( DISTINCT category_code SEPARATOR ',' ) code  " +
                    "from wlyy_patient_device where del = 0 and user in ("+inSql+") group by user";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(deviceSql);
            for (Map<String, Object> map : list) {
                for (EmergencyAssistanceDO em : resultList) {
                    if(map.get("user").toString().equals(em.getPatient())){
                        em.setPatientDevices(map.get("code").toString());
                    }
                }
            }
        }
        return resultList;
    }

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

@ -466,18 +466,19 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    }
    /**
     * 查找服务项字典
     *  查找服务项字典
     *   v1.7.1 机构的生活照料服务项目必须配置才有返回
     *   v1.7.6 一个生活照料对应多个机构
     * @return
     */
    public List<LifeCareItemDictDO> findItemDict(String orgCode){
        String sql = "select dict.id,dict.`code`,dict.`name`," +
                " GROUP_CONCAT( DISTINCT dict.org_code SEPARATOR ',' ) AS orgCode,dict.life_care_img,dict.pad_icon_img  " +
                " from base_life_care_item_dict dict LEFT JOIN base_org org  on dict.org_code = org.`code` where 1=1 " ;
                " from base_life_care_item_dict dict INNER JOIN base_org org  on dict.org_code = org.`code` where 1=1 " ;
        if (StringUtils.isNotBlank(orgCode)){
            sql += " and dict.org_code='"+orgCode+"' ";
        }
        sql+=  " and dict.del=1  GROUP BY dict.`code` order by dict.sort asc ";
        sql+=  " and dict.del=1 AND org.del = 1  GROUP BY dict.`code` order by dict.sort asc ";
        List<LifeCareItemDictDO> lifeCareItemDictList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(LifeCareItemDictDO.class));
@ -517,22 +518,29 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
     *
     * @return
     */
    public JSONObject queryInfoList(String patient,Integer status,String fedCode ,int page, int size) {
    public JSONObject queryInfoList(String patient,Integer status,String fedCode ,int page, int size,String orgCode) {
        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 = " ";
        String oOrgCodeSql ="";
        if (StringUtils.isNotBlank(fedCode)){
            String fedOrgCode ="";
            if (StringUtils.isNotBlank(orgCode)){
                fedOrgCode="  AND cid.org_code = '"+orgCode+"'";
                oOrgCodeSql = " AND o.hospital = '"+orgCode+"' ";
            }
            fedSql = " and EXISTS ( " +
                    " select 1 from base_life_care_fee_detail fed where fed.order_id = o.id and fed.code='"+fedCode+"' " +
                    " )  ";
                    " select 1 from base_life_care_fee_detail fed LEFT JOIN base_life_care_item_dict cid ON fed.code = cid.code where fed.order_id = o.id and fed.code='"+fedCode+"' " + fedOrgCode +
                    "  )  ";
        }
        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})" +fedSql+
                " AND (o.`status` = {status} or -100 = {status})"+ oOrgCodeSql + fedSql+
                "  group by o.id " +
                " ORDER BY o.create_time desc" +
                " LIMIT {start},{end} ";
@ -545,7 +553,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})"+fedSql;
                " AND (o.`status` = {status} or -100 = {status})"+oOrgCodeSql+fedSql;
        String finqlCountSql = countSql.replace("{patient}", patient)
                .replace("{status}", String.valueOf(status));
@ -822,7 +830,9 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        result.put("orderId",orderDO.getId());
        orderDO.setTotalFee(new BigDecimal(0));
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, orderDO);
@ -830,6 +840,12 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        //发起支付订单
        if (isNeedPay){
            payService.submitOrder(orderDO.getPatient(),"4",orderDO.getId(),orderDO.getTotalFee().doubleValue());
        }else {
            if(orderDO.getType() == 3){
                serviceNewsService.addServiceNews(orderDO.getProxyPatientName(),orderDO.getProxyPatient(),"4",orderDO.getPatientName(),orderDO.getId(),2);
            }else {
                serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"3",null,orderDO.getId(),1);
            }
        }
        //给签约医生发送预约短信

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

@ -13,6 +13,7 @@ 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 com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -182,11 +183,11 @@ public class BaseServiceNewsService {
    }
    /**
     * 查找所有未签约老人
     * 社区老人
     * 社区老人   需招呼老人(孤/独/空)   register = 1
     * 街道老人   第三方同步过来的朝晖街道老人数据  register = 2
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findUnSignPatientLocations(Integer page,Integer size){
    public PageEnvelop<List<Map<String,Object>>> findUnSignPatientLocations(Integer page,Integer size,Integer type){
        page = page>0?page-1:0;
        String filter =" ";
@ -200,12 +201,17 @@ public class BaseServiceNewsService {
            }
        }
        String typeSql =" p.register = 1";
        if (null!=type&&type==2) {
            typeSql = " p.register = 2";
        }
        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.register = 1 and p.lat_lon is not null "+filter+" limit "+page*size+","+size;
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and "+typeSql+" 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.register = 1 and  p.lat_lon is not null "+filter ;
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and "+typeSql+" 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){
@ -255,6 +261,7 @@ public class BaseServiceNewsService {
        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' ";
@ -277,7 +284,7 @@ public class BaseServiceNewsService {
     * @param size
     * @return
     */
    public List<BaseServiceNews> findNews(Integer page,Integer size){
    public List<BaseServiceNews> findNews(Integer page,Integer size,String beginTime,String endTime){
        if (null==page){
            page=0;
        }
@ -292,7 +299,13 @@ public class BaseServiceNewsService {
        List<BaseServiceNews> result = new ArrayList<>();
        List<BaseServiceNews> list = baseServiceNewsDao.findNews(pageRequest);
        List<BaseServiceNews> list =new ArrayList<>();
        if(StringUtils.isBlank(beginTime) && StringUtils.isBlank(endTime)){
            list = baseServiceNewsDao.findNews(pageRequest);
        }else {
            list = baseServiceNewsDao.findNewsByTime(DateUtil.strToDate(beginTime),DateUtil.strToDate(endTime),pageRequest);
        }
        for (BaseServiceNews tmp:list){
            if (jkzlPatients.contains(tmp.getCode())){
                continue;
@ -324,6 +337,21 @@ public class BaseServiceNewsService {
        return result;
    }
    /**
     * 获取综合服务的总数
     * @return
     */
    public Long findNewsCount(String beginTime,String endTime){
        String sql = "SELECT COUNT(*) FROM base_service_news\n" +
                "WHERE code NOT IN \n" +
                "(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older')";
        String timeSql = " ";
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            timeSql = " and create_time>='"+beginTime+"' and create_time<='"+endTime+"' ";
        }
        return jdbcTemplate.queryForObject(sql+timeSql, Long.class);
    }
    /**
     * 添加服务动态信息-大屏展示用
     * @param name

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

@ -805,7 +805,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            re.put("child",list);
            re.put("childTotal",findChildTotal(name,residentialArea,filter));
        }
        if("2".equals(type)||StringUtil.isBlank(type)){//老人
        if("2".equals(type)||"8".equals(type)||StringUtil.isBlank(type)){//老人  //1.7.7增加  需照护老人(孤/独/空)800 + 老人名单
            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);
@ -815,9 +815,9 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
                filter = " and a.id not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findOld(name,residentialArea,area,level,limit,filter);
            List<Map<String,Object>> list = findOld(type,name,residentialArea,area,level,limit,filter);
            re.put("old",list);
            re.put("oldTotal",findOldTotal(name,residentialArea,area,level,filter));
            re.put("oldTotal",findOldTotal(type,name,residentialArea,area,level,filter));
        }
        if("3".equals(type)||StringUtil.isBlank(type)){//社工
            filter = "";
@ -860,7 +860,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            re.put("helper4",list);
            re.put("helper4Total",findHelper4Total(name,area,level,filter));
        }
        if("7".equals(type)||StringUtils.isBlank(type)){//社区老人
        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);
@ -927,14 +927,36 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    /**
     * 查找签约老人 + 名单800
     * @param name
     * @param residentialArea
     * @param residentialArea 小区名称
     * @param type 2已照护老人(签约+已绑定设备) , 8 需招呼老人
     * @param limit
     * @return
     */
    public List<Map<String,Object>> findOld(String name,String residentialArea,String area,Integer level,String limit,String filter1){
    public List<Map<String,Object>> findOld(String type,String name,String residentialArea,String area,Integer level,String limit,String filter1){
        String sql = "SELECT DISTINCT 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=1 or a.register = '1')  ";
                " WHERE a.archive_type = 1 and a.del = '1'   ";
        if ("2".equals(type)){
            if(StringUtils.isNotBlank(area)&&5==level){
                sql += " and ((a.sign_status=1 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='"+area+"')" +
                        " or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) and a.saas_id='"+area+"' ))) ";
            }
            else {
                sql+=" and (a.sign_status=1 or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0))) ";
            }
        }
        if ("8".equals(type)){//需招呼老人
            sql+=" and a.register='1' and not EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) ";
            if (StringUtils.isNotBlank(area)&&5==level){
                if(StringUtils.isNotBlank(area)){
                    sql+= " and a.saas_id = '"+area+"' ";
                }
            }
        }
        //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
@ -944,23 +966,6 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        if (StringUtils.isNotBlank(area)&&5==level){
            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='"+area+"')  ";
            sql += " OR (a.saas_id = '"+area+"' ";
            if (StringUtils.isNotBlank(name)){
                sql+= " and a.name like '%"+name+"%' ";
            }
            if(StringUtils.isNotBlank(residentialArea)){
                sql+= " and a.residential_area = '"+residentialArea+"' ";
            }
            sql +=" )";
        }
        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";
@ -1007,35 +1012,43 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return list;
    }
    public Integer findOldTotal(String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(DISTINCT a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and (a.sign_status=1 or a.register = 1)";
    public Integer findOldTotal(String type,String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(DISTINCT a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' ";
        if ("2".equals(type)){
            if(StringUtils.isNotBlank(area)&&5==level){
                sql += " and ((a.sign_status=1 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='"+area+"')" +
                        " or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) and a.saas_id='"+area+"' ))) ";
            }
            else {
                sql+=" and (a.sign_status=1 or (EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0))) ";
            }
        }
        if ("8".equals(type)){//需招呼老人
            sql+=" and a.register='1' and not EXISTS (select 1 from wlyy_patient_device pd where pd.user = a.id and pd.del=0) ";
            if (StringUtils.isNotBlank(area)&&5==level){
                if(StringUtils.isNotBlank(area)){
                    sql+= " and a.saas_id = '"+area+"' ";
                }
            }
        }
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        if (StringUtils.isNotBlank(area)&&5==level){
            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='"+area+"' )  ";
            sql += "OR (a.saas_id = '"+area+"' ";
            if (StringUtils.isNotBlank(name)){
                sql+= " and a.name like '%"+name+"%' ";
            }
            if(StringUtils.isNotBlank(residentialArea)){
                sql+= " and a.residential_area = '"+residentialArea+"' ";
            }
            sql +=" )";
        }
        sql += filter;
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    /**
     * 查找签约老人
     * 街道老人
     * @param name
     * @param residentialArea
     * @param limit
@ -1044,7 +1057,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    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  ";
                " WHERE a.archive_type = 1 and a.del = '1' and a.register='2'  ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
@ -1102,7 +1115,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    }
    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 ";
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and a.register='2' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }

File diff suppressed because it is too large
+ 189 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java


File diff suppressed because it is too large
+ 833 - 61
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java


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

@ -29,16 +29,19 @@ import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
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.common.GpsUtil;
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.util.healthIndex.HealthIndexUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -87,6 +90,8 @@ public class PatientInfoPlatFormService {
    private YsDeviceService ysDeviceService;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    /**
@ -477,7 +482,7 @@ public class PatientInfoPlatFormService {
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient){
    public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient,String beginTime,String endTime){
        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' ";
@ -490,10 +495,13 @@ public class PatientInfoPlatFormService {
        String sql = " select  '22' as 'OrderType',p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient,p.name,ord.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_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id " ;
                "from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id where 1=1 " ;
        if (StringUtils.isNotBlank(patient)){
            sql +=" and ord.patient='"+patient+"' ";
        }
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            sql +=" and ord.create_time>='"+beginTime+"' and ord.create_time<='"+endTime+"' ";
        }
        sql+= filter +" order by create_time desc ";
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);
@ -639,7 +647,7 @@ public class PatientInfoPlatFormService {
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient){
    public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient,String beginTime,String endTime){
        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' ";
@ -657,6 +665,9 @@ public class PatientInfoPlatFormService {
        if (StringUtils.isNotBlank(patient)){
            filter +=" and ord.patient='"+patient+"' ";
        }
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            filter += " and ord.create_time>='"+beginTime+"' and ord.create_time<='"+endTime+"' ";
        }
        sql +=  filter + "  order by create_time desc";
        sqlCount  +=filter;
@ -666,7 +677,7 @@ public class PatientInfoPlatFormService {
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    public PageEnvelop getHealthMonitoringListNew(Integer page,Integer pageSize){
    public PageEnvelop getHealthMonitoringListNew(Integer page,Integer pageSize,String beginTime,String endTime){
        page = page>0?page-1:0;
        String filter=" ";
@ -677,9 +688,12 @@ public class PatientInfoPlatFormService {
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and idx.user not in ('"+orgCodes+"') ";
        }
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            filter+=" and idx.czrq>='"+beginTime+"' and idx.czrq<='"+endTime+"' ";
        }
        String sql = " SELECT idx.id,idx.user,idx.`name`,p.archive_type archiveType,p.residential_area residentialArea,'健康监测' as serve_desc, " +
                "idx.czrq,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index idx " +
                "idx.czrq,value1,value2,value3,value4,value5,value6,value7,type,DATE_FORMAT(idx.czrq,'%Y-%m-%d %H:%i:%S') createTime FROM wlyy_patient_health_index idx " +
                " INNER JOIN base_patient p on idx.user = p.id and p.del=1\n" +
                " WHERE idx.del = 1 AND idx.type < 3 "+filter+" ORDER BY idx.czrq desc ";
        String countSql = "select count(id) from ("+sql+")A ";
@ -1039,4 +1053,221 @@ public class PatientInfoPlatFormService {
        return detailInfo;
    }
    /**
     * 获取紧急预警和一般预警中的总数
     * @param patient
     * @return
     */
    public ObjEnvelop getWarningCount(String patient){
        String filter1=" ";
        String filter2=" ";
        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&&StringUtils.isBlank(patient)){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter1 = " and ord.patient not in ('"+orgCodes+"') ";
            filter2 = " and idx.user not in ('"+orgCodes+"') ";
        }
        //查紧急预警
        Long warningCount = this.getWarningCountByEmergencyAndSecurity(filter1);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("warningCount",warningCount);
        //查一般预警(体征预警)
        Long healthCount = this.getWarningCountByHealth(filter2);
        map.put("healthCount",healthCount);
        map.put("total",warningCount+healthCount);
        return ObjEnvelop.getSuccess("获取成功",map);
    }
    /**
     * 获取紧急预警中的列表
     * @param page
     * @param pageSize
     * @param patient
     * @return
     */
    public PageEnvelop getWarningList(Integer page,Integer pageSize,String patient){
        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&&StringUtils.isBlank(patient)){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and ord.patient not in ('"+orgCodes+"') ";
        }
        String sql1 = " SELECT\n" +
                " '20' AS OrderType,\n" +
                " p.archive_type archiveType,\n" +
                " p.residential_area residentialArea,\n" +
                " ord.id,\n" +
                " ord.patient,\n" +
                " p.name,\n" +
                " '紧急呼叫' AS serve_desc,\n" +
                " DATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
                " ord.`status`,\n" +
                " CASE \n" +
                " p.sex \n" +
                " WHEN 1 THEN\n" +
                " '男' \n" +
                " WHEN 2 THEN\n" +
                " '女' ELSE p.sex \n" +
                " END AS sex,\n" +
                " TIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
                " FROM \n" +
                " base_emergency_assistance_order ord\n" +
                " INNER JOIN base_patient p ON ord.patient = p.id \n" +
                " AND p.del = 1 \n" +
                " WHERE " +
                " ord.STATUS = 1 "+filter;
        String sql2 = " SELECT \n" +
                " '22' AS 'OrderType',\n" +
                " p.archive_type archiveType,\n" +
                " p.residential_area residentialArea,\n" +
                " ord.id,\n" +
                " ord.patient,\n" +
                " p.name,\n" +
                " ord.serve_desc,\n" +
                " DATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
                " ord.`status`,\n" +
                " CASE \n" +
                "  p.sex \n" +
                "  WHEN 1 THEN\n" +
                "  '男' \n" +
                "  WHEN 2 THEN\n" +
                " '女' ELSE p.sex \n" +
                " END AS sex,\n" +
                " TIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
                " FROM\n" +
                " base_security_monitoring_order ord \n" +
                " INNER JOIN base_patient p ON ord.patient = p.id \n" +
                " where ord.status = 1"+filter;
        String sql = "select * FROM (" +
                " "+sql1+" UNION "+sql2 +
                " ) t order by t.createTime desc limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByEmergencyAndSecurity(filter));
    }
    /**
     * 获取体征预警中的列表
     * @param page
     * @param pageSize
     * @param patient
     * @return
     */
    public PageEnvelop getHealthWarningList(Integer page,Integer pageSize,String patient){
        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"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and idx.user not in ('"+orgCodes+"') ";
        }
        String sql = " SELECT\n" +
                " idx.id,\n" +
                " idx.user,\n" +
                " idx.`name`,idx.type,\n" +
                " p.archive_type archiveType,\n" +
                " p.residential_area residentialArea,\n" +
                " '健康监测' AS serve_desc,\n" +
                " TIMESTAMPDIFF(YEAR,p.birthday,now()) AS age, \n" +
                " idx.czrq,\n" +
                " value1,\n" +
                " value2,\n" +
                " value3,\n" +
                " value4,\n" +
                " value5,\n" +
                " value6,\n" +
                " value7,\n" +
                " type,DATE_FORMAT( idx.czrq, '%Y-%m-%d %H:%i:%S' ) createTime, \n" +
                " CASE\n" +
                " p.sex \n" +
                " WHEN 1 THEN\n" +
                " '男' \n" +
                " WHEN 2 THEN\n" +
                " '女' ELSE p.sex \n" +
                " END AS sex\n" +
                " FROM\n" +
                " wlyy_patient_health_index idx\n" +
                " INNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
                " WHERE\n" +
                " idx.del = 1 \n" +
                " and idx.status=1 \n" +
                " AND idx.type < 3 "+filter+" ORDER By idx.czrq DESC limit "+page*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(!ObjectUtils.isEmpty(list)){
            //查体征预警信息,偏高偏低
            for (Map<String, Object> map : list) {
                com.alibaba.fastjson.JSONArray info = healthIndexUtil.verifyHealthIndex(
                        Integer.parseInt(map.get("type").toString()),
                        null==map.get("value1")?"":map.get("value1").toString(),
                        null==map.get("value2")?"":map.get("value2").toString(),
                        null==map.get("value3")?"":map.get("value3").toString());
                //去除正常的值
                Iterator it = info.iterator();
                while (it.hasNext()){
                    JSONObject next = (JSONObject)it.next();
                    if("0".equals(next.getString("error"))){
                        it.remove();
                    }
                }
                map.put("info",info);
            }
        }
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByHealth(filter));
    }
    /**
     * 获取紧急呼救和安防工单正在预警中的总数
     * @param filter
     * @return
     */
    Long getWarningCountByEmergencyAndSecurity(String filter){
        //紧急呼救
        String emergencySql = "SELECT count( ord.id ) warningCount \n" +
                " FROM " +
                " base_emergency_assistance_order ord " +
                " INNER JOIN base_patient p ON ord.patient = p.id and p.del=1  \n" +
                " WHERE\n" +
                "  ord.STATUS = 1"+filter;
        //安防监护
        String securitySql = "SELECT count( ord.id ) warningCount \n" +
                " FROM\n" +
                " base_security_monitoring_order ord\n" +
                " INNER JOIN base_patient p ON ord.patient = p.id and p.del=1 \n" +
                " AND ord.STATUS = 1"+filter;
        String sqlCount = "SELECT\n" +
                " sum( warningCount ) warningCount\n" +
                " FROM\n" +
                " ( " + emergencySql + " UNION ALL " + securitySql +
                " ) t";
        return jdbcTemplate.queryForObject(sqlCount, Long.class);
    }
    /**
     * 获取一般体征预警中的总数
     * @param filter
     * @return
     */
    Long getWarningCountByHealth(String filter){
        String healthSql = "SELECT\n" +
                " count( idx.id ) \n" +
                " FROM\n" +
                " wlyy_patient_health_index idx\n" +
                " INNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
                " WHERE\n" +
                " idx.status = 1 \n" +
                " AND idx.del = 1 \n" +
                " AND idx.type < 3 \n" + filter;
        return jdbcTemplate.queryForObject(healthSql, Long.class);
    }
}

+ 68 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java

@ -1,13 +1,18 @@
package com.yihu.jw.care.service.visit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.visit.BaseVisitDao;
import com.yihu.jw.care.dao.visit.BaseVisitSignDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.visit.BaseVisitDO;
import com.yihu.jw.entity.care.visit.BaseVisitSignDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
@ -31,6 +36,8 @@ public class BaseVisitService {
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseVisitSignDao baseVisitSignDao;
    /**
     * 获取走访列表-日历
@ -103,6 +110,9 @@ public class BaseVisitService {
        if("1".equals(visitDO.getStatus())){
            return "走访已完成不能删除";
        }
        if ("3".equals(visitDO.getStatus())){
            return "走访已签到不能删除";
        }
        baseVisitDao.delete(id);
        return null;
    }
@ -190,6 +200,9 @@ public class BaseVisitService {
    public Map<String, String> findVisitDetail(String id){
        Map<String, String> re = new HashMap<>();
        BaseVisitDO visitDO = baseVisitDao.findOne(id);
        if (null==visitDO){
            return null;
        }
        re.put("id", visitDO.getId());
        re.put("visitDate", DateUtil.dateToStrLong(visitDO.getVisitDate()));
        re.put("visitPlanDate", DateUtil.dateToStrLong(visitDO.getVisitPlanDate()));
@ -205,6 +218,13 @@ public class BaseVisitService {
        re.put("health",visitDO.getHealth());
        re.put("lifeConsult",visitDO.getLifeConsult());
        BaseVisitSignDO visitSignDO = baseVisitSignDao.findByVisitId(visitDO.getId());
        if (null!=visitSignDO){
            re.put("signInfo", JSON.toJSONStringWithDateFormat(visitSignDO,"yyyy-MM-dd HH:mm:ss"));
        }else {
            re.put("signInfo",null);
        }
        BasePatientDO patient = patientDao.findById(visitDO.getPatient());
        if (patient != null) {
            re.put("idcard", patient.getIdcard());
@ -215,7 +235,6 @@ public class BaseVisitService {
            re.put("photo", patient.getPhoto());
            re.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday())+"");
        }
        return re;
    }
@ -256,4 +275,52 @@ public class BaseVisitService {
        }
    }
    /**
     * 日常走访签到
     * @return
     */
    public JSONObject signIn(String visitId,Integer signWay,String signLat,String signLon,String address,String signImg,String doctorId){
        BaseVisitDO visitDO = baseVisitDao.findOne(visitId);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        JSONObject result = new JSONObject();
        if (null==doctorDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"当前登录用户不存在无法签到");
            return result;
        }
        if (null==visitDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"未找到走访计划");
            return result;
        }
        if ("3".equals(visitDO.getStatus())){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"已完成签到,无法重复签到");
            return result;
        }
        BaseVisitSignDO signDO = new BaseVisitSignDO();
        signDO.setVisitId(visitId);
        signDO.setDoctor(doctorId);
        signDO.setDoctorName(doctorDO.getName());
        signDO.setDel(1);
        signDO.setType(signWay);
        if (2==signWay){//拍照
            signDO.setImg(signImg);
        } else if (1==signWay) {//定位
            signDO.setAddress(address);
            signDO.setLat(signLat);
            signDO.setLon(signLon);
        }else {
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"签到方式错误");
            return result;
        }
        baseVisitSignDao.save(signDO);
        visitDO.setStatus("3");
        baseVisitDao.save(visitDO);
        result.put(ResponseContant.resultFlag,ResponseContant.success);
        result.put(ResponseContant.resultMsg,"success");
        return result;
    }
}

+ 217 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HlsDownloader.java

@ -0,0 +1,217 @@
package com.yihu.jw.care.util;

import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

// https://my.oschina.net/haitaohu/blog/1941179
public class HlsDownloader {

    private String uuid;
    private String originUrlpath;
    private String preUrlPath;
    private String rootPath;
    private String fileName;
    private String folderPath;
    private int threadQuantity = 10;

    public int getThreadQuantity() {
        return threadQuantity;
    }

    public void setThreadQuantity(int threadQuantity) {
        this.threadQuantity = threadQuantity;
    }


    public HlsDownloader(String originUrlpath, String preUrlPath, String rootPath){
        this.uuid = UUID.randomUUID().toString().replaceAll("-","");
        this.originUrlpath = originUrlpath;
        this.preUrlPath = preUrlPath;
        this.rootPath = rootPath;

        this.fileName = uuid+ ".mp4";

        this.folderPath = rootPath + File.separator + uuid;
        File file = new File(folderPath);
        if(!file.exists()) file.mkdirs();
    }

    public String download(boolean isAsync) throws Exception {

        String indexStr = getIndexFile();

        List urlList = analysisIndex(indexStr);

        HashMap<Integer,String> keyFileMap = new HashMap<>();

        if(isAsync){
            downLoadIndexFileAsync(urlList, keyFileMap);

            while (keyFileMap.size()<urlList.size()){
                //System.out.println("当前下载数量"+keyFileMap.size());
                Thread.sleep(3000);
            }
        }else{
            keyFileMap = downLoadIndexFile(urlList);
        }

        return composeFile(keyFileMap);
    }

    /* 下载索引文件 */
    public String getIndexFile() throws Exception{
        URL url = new URL(originUrlpath);

        /*File file = new File("E:\\JKZL\\1.m3u8");
        url = file.toURL();*/
        //下载资源
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));

        String content = "" ;
        String line;
        while ((line = in.readLine()) != null) {
            content += line + "\n";
        }
        in.close();

        return content;
    }

    /* 解析索引文件 */
    public List analysisIndex(String content) throws Exception{
        Pattern pattern = Pattern.compile(".*ts");
        Matcher ma = pattern.matcher(content);

        List<String> list = new ArrayList<String>();

        while(ma.find()){
            list.add(ma.group());
        }

        return list;
    }

    /* 下载视频片段 */
    public HashMap downLoadIndexFile(List<String> urlList){
        HashMap<Integer,String> keyFileMap = new HashMap<>();

        for(int i =0;i<urlList.size();i++){
            String subUrlPath = urlList.get(i);
            String fileOutPath = folderPath + File.separator + i + ".ts";
            keyFileMap.put(i, fileOutPath);
            try{
                downloadNet(preUrlPath + subUrlPath, fileOutPath);

                System.out.println("成功:"+ (i + 1) +"/" + urlList.size());
            }catch (Exception e){
                System.err.println("失败:"+ (i + 1) +"/" + urlList.size());
            }
        }

        return  keyFileMap;
    }

    public void downLoadIndexFileAsync(List<String> urlList, HashMap<Integer,String> keyFileMap) throws Exception{
        int downloadForEveryThread = (urlList.size() + threadQuantity - 1)/threadQuantity;
        if(downloadForEveryThread == 0) downloadForEveryThread = urlList.size();

        for(int i=0; i<urlList.size();i+=downloadForEveryThread){
            int startIndex = i;
            int endIndex = i + downloadForEveryThread - 1;
            if(endIndex >= urlList.size())
                endIndex = urlList.size() - 1;

            new DownloadThread(urlList, startIndex, endIndex, keyFileMap).start();
        }
    }
    /**
     * 视频片段合成
     */
    public String composeFile(HashMap<Integer,String> keyFileMap) throws Exception{

        if(keyFileMap.isEmpty()) return null;

        String fileOutPath = rootPath + File.separator + fileName;
        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
        byte[] bytes = new byte[1024];
        int length = 0;
        for(int i=0; i<keyFileMap.size(); i++){
            String nodePath = keyFileMap.get(i);
            File file = new File(nodePath);
            if(!file.exists())  continue;

            FileInputStream fis = new FileInputStream(file);
            while ((length = fis.read(bytes)) != -1) {
                fileOutputStream.write(bytes, 0, length);
            }
        }

        return fileName;
    }


    class DownloadThread extends Thread{
        private List<String> urlList;
        private int startIndex;
        private int endIndex;
        private HashMap<Integer,String> keyFileMap;

        public DownloadThread(List<String> urlList, int startIndex, int endIndex, HashMap<Integer,String> keyFileMap){
            this.urlList = urlList;
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            this.keyFileMap = keyFileMap;
        }
        @Override
        public void run(){
            for(int i=startIndex;i<=endIndex;i++){
                String subUrlPath = urlList.get(i);
                String fileOutPath = folderPath + File.separator + i + ".ts";
                keyFileMap.put(i, fileOutPath);
                String message = "%s: 线程 " + (startIndex/(endIndex - startIndex) + 1)
                        + ", "+ (i + 1) +"/" + urlList.size() +", 合计: %d";
                try{
                    downloadNet(preUrlPath + subUrlPath, fileOutPath);

                    System.out.println(String.format(message, "成功", keyFileMap.size()));
                }catch (Exception e){
                    System.err.println(String.format(message, "失败", keyFileMap.size()));
                }
            }
        }
    }

    private void downloadNet(String fullUrlPath, String fileOutPath) throws Exception {
        // 下载网络文件
//        DataInputStream dataInputStream = new DataInputStream(url.openStream());
//        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
//        byte[] bytes = new byte[1024];
//        int length = 0;
//        while ((length = dataInputStream.read(bytes)) != -1) {
//            fileOutputStream.write(bytes, 0, length);
//        }
//        dataInputStream.close();

        //int bytesum = 0;
        int byteread = 0;

        URL url = new URL(fullUrlPath);
        URLConnection conn = url.openConnection();
        InputStream inStream = conn.getInputStream();
        FileOutputStream fs = new FileOutputStream(fileOutPath);

        byte[] buffer = new byte[1204];
        while ((byteread = inStream.read(buffer)) != -1) {
            //bytesum += byteread;
            fs.write(buffer, 0, byteread);
        }
    }

}

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

@ -20,6 +20,8 @@ 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.enterprise.WxEnterpriseDO;
import com.yihu.jw.entity.hospital.enterprise.WxEnterpriseTokenDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
@ -75,6 +77,9 @@ import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseDao;
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseTokenDao;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import com.ylzinfo.onepay.sdk.OnepayClient;
@ -254,6 +259,10 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private YlzMedicailRelationDao ylzMedicailRelationDao;
    @Autowired
    private BaseDoctorHealthUploadService baseDoctorHealthUploadService;
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private WxEnterpriseDao wxEnterpriseDao;
@ -980,6 +989,34 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        return failed(PatientRequestMapping.Wechat.api_error);
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.getEnterpriseSign)
    @ApiOperation(value = "获取企业微信签名", notes = "获取企业微信签名")
    public Envelop getEnterpriseSign(@ApiParam(name = "pageUrl", value = "授权页面")
                           @RequestParam(value = "pageUrl", required = true)String pageUrl,
                           @ApiParam(name = "wxId", value = "微信id")
                           @RequestParam(value = "wxId", required = true)String wxId) throws Exception {
        logger.info("pageUrl="+pageUrl);
        logger.info("wxId="+wxId);
        String ticket = enterpriseService.getEnterpriseJsapi_ticketByToken(wxId);
        WxEnterpriseDO wxEnterpriseDO = wxEnterpriseDao.findOne(wxId);
        Map<Object, Object> map = new HashMap<Object, Object>();
        if (ticket != null) {
            String noncestr = UUID.randomUUID().toString();
            long timestamp = System.currentTimeMillis() / 1000;
            String url = pageUrl;
            logger.info("getSign.url="+url);
            String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
            logger.info("getSign.str="+str);
            // sha1加密
            String signature = SHA1(str);
            map.put("noncestr", noncestr);
            map.put("timestamp", timestamp);
            map.put("signature", signature);
            map.put("appid", wxEnterpriseDO.getCorpid());
            return success(PatientRequestMapping.Wechat.api_success,map);
        }
        return failed(PatientRequestMapping.Wechat.api_error);
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.setAllCode)
    @ApiOperation(value = "生成所有医生二维码")
@ -2079,6 +2116,47 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        logger.info("object"+object.toString());
        return success(object);
    }
    @PostMapping(value = "uploadFileToEnterprise")
    @ApiOperation(value = "上传企业微信语音文件或者视频")
    public Envelop appendEnterprise(
            @ApiParam(name = "type", value = "追问内容类型:1文字,2图片,3语音  ... (im消息类型)")
            @RequestParam(value = "type",required = true) Integer type,
            @ApiParam(name = "times", value = "")
            @RequestParam(value = "times",required = false) Integer times) throws Exception {
        JSONObject object = new JSONObject();
        UploadVO uploadVO = new UploadVO();
        //处理语音文件
        if(!org.springframework.util.StringUtils.isEmpty(wxId)){
            if(3 == type){//语音文件
                String voicepath = enterpriseService.fetchWxVoices(wxId);
                logger.info("voice_path:"+voicepath);
                JSONObject obj = new JSONObject();
                String voiceurl = "";
                // 将临时语音拷贝到正式存储路径下
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
                    if("xm_ihealth_wx".equals(wxId)){
                        logger.info("voice_wx_type:"+wxId);
                        voiceurl = fileUploadService.uploadWxVoice(voicepath);
//					uploadVO.setFullUri(map.get("accessory").toString());
                    }else {
                        if(isClose.equals("2")){
                            voiceurl = fileUploadService.uploadInLocalWxVoice(voicepath,remote_inner_url);
                        }else {
                            voiceurl = fileUtil.copyTempVoice(voicepath,fastdfs_file_url);
                        }
                    }
                    obj.put("path", voiceurl);
                    obj.put("times", times);
                }
                object.put("path",voiceurl);
            }
        }
        logger.info("object"+object.toString());
        return success(object);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.testJpush)
    @ApiOperation(value = "根据身份证号查询医生", notes = "")
    public Envelop testJPush(@ApiParam(name = "outpatientId", value = "")

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

@ -2666,7 +2666,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            String doctorId = getUID();
            if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
                return ObjEnvelop.getSuccess("ok", xzzxEntranceService.selectHistoryEmrFromEntrance(patient, null));
            } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
            } else if (wxId.equalsIgnoreCase("xm_hcyy_wx")) {
                return ObjEnvelop.getSuccess("ok", hcyyPrescriptionService.selectHistoryEmrFromEntrance(patient, null));
            } else {
                return ObjEnvelop.getSuccess("ok", prescriptionService.outpatient(patient, doctorId));

+ 1 - 1
wlyy-parent-pom/pom.xml

@ -85,7 +85,7 @@
        <!-- Version start -->
        <version.wlyy-common>2.0.0</version.wlyy-common>
        <version.jackson>2.8.1</version.jackson>
        <verion.fastjson>1.2.76</verion.fastjson>
        <verion.fastjson>1.2.83</verion.fastjson>
        <version.json>20160212</version.json>
        <version.net-json>2.4</version.net-json>
        <version.logback>1.2.3</version.logback>