浏览代码

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

Shi Kejing 4 年之前
父节点
当前提交
3de50084f0
共有 47 个文件被更改,包括 2740 次插入89 次删除
  1. 18 0
      business/base-service/src/main/java/com/yihu/jw/hospital/drugstore/dao/BaseDrugStoreDao.java
  2. 69 0
      business/base-service/src/main/java/com/yihu/jw/hospital/drugstore/service/BaseDrugStoreService.java
  3. 37 5
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 3 2
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyTemplateOptionDao.java
  5. 4 4
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java
  6. 93 22
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/service/SurveyService.java
  7. 10 0
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  8. 3 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientBusinessDao.java
  9. 32 0
      business/base-service/src/main/java/com/yihu/jw/utils/CountDistance.java
  10. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  11. 151 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseDrugStoreDO.java
  12. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/login/BaseLoginLogDO.java
  13. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyTemplateDO.java
  14. 10 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  15. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  16. 1 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/ResultStatus.java
  17. 30 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/survey/WlyySurveyTemplateVO.java
  18. 207 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/DeviceHealthIndexVO.java
  19. 288 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyDeviceVO.java
  20. 112 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyHealthStandardVO.java
  21. 167 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyPatientDeviceVO.java
  22. 26 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  23. 51 1
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  24. 18 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseLoginLogDao.java
  25. 87 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseLoginLogService.java
  26. 9 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/WlyyHospitalSysDictDao.java
  27. 3 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/login/dao/BaseLoginLogDao.java
  28. 45 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/login/service/BaseLoginLogService.java
  29. 0 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthYlzConfigService.java
  30. 1 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java
  31. 84 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/drugstore/BaseDrugStoreEndpoint.java
  32. 4 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  33. 9 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/survey/SurveyEndpoint.java
  34. 20 26
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java
  35. 2 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/QrcodeService.java
  36. 514 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/common/BaseController.java
  37. 111 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/WlyyDeviceController.java
  38. 14 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/common/OrgUserService.java
  39. 21 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java
  40. 17 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java
  41. 19 5
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java
  42. 29 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java
  43. 14 5
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java
  44. 13 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceTransfersService.java
  45. 16 3
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java
  46. 345 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/WlyyDeviceService.java
  47. 13 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotHospitalService.java

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/drugstore/dao/BaseDrugStoreDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.hospital.drugstore.dao;
import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseDrugStoreDao extends PagingAndSortingRepository<BaseDrugStoreDO, String>, JpaSpecificationExecutor<BaseDrugStoreDO> {
    @Query(value = " from  BaseDrugStoreDO  where (drugStoreName like %?1% or ?1 is null ) or ( hospitalName like %?1% or ?1 is null)")
    List<BaseDrugStoreDO> findDrugByName(String storeName);
    @Query(value = " from  BaseDrugStoreDO  where drugStoreCode =?1 and hospitalCode = ?2 ")
    BaseDrugStoreDO findDrugByNameAndCode(String drugStoreCode,String hospitalCode);
}

+ 69 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/drugstore/service/BaseDrugStoreService.java

@ -0,0 +1,69 @@
package com.yihu.jw.hospital.drugstore.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.j2objc.annotations.AutoreleasePool;
import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.CountDistance;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.provider.HibernateUtils;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class BaseDrugStoreService extends BaseJpaService<BaseDrugStoreDO, BaseDrugStoreDao> {
    @Autowired
    private BaseDrugStoreDao baseDrugStoreDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private HibenateUtils hibenateUtils;
   //根据经纬度计算距离通过代码
   public List<BaseDrugStoreDO> countDistanceListIncode(String latitude,String longitude,String drugStoreName,String hospitalName) throws ParseException {
       List<BaseDrugStoreDO> list = new ArrayList<>();
       if (StringUtils.isNotEmpty(drugStoreName)||StringUtils.isNotEmpty(hospitalName)){
           list = baseDrugStoreDao.findDrugByName(drugStoreName);
       }else {
           String filters= null;
           list= this.search(filters);
       }
       List<BaseDrugStoreDO> resultlist = new ArrayList<>();
       CountDistance countDistance = new CountDistance();
       latitude=StringUtils.isEmpty(latitude)?"0":latitude;
       longitude=StringUtils.isEmpty(longitude)?"0":longitude;
        for (BaseDrugStoreDO baseDrugStoreDO:list){
            double storeLatitude = Double.parseDouble(baseDrugStoreDO.getLatitude());
            double storeLongitude = Double.parseDouble(baseDrugStoreDO.getLongitude());
            double distance = countDistance.getDistance(Double.parseDouble(latitude),Double.parseDouble(longitude),storeLatitude,storeLongitude);
            baseDrugStoreDO.setDistance(distance);
        }
        list.stream().sorted((x,y)->Double.compare(x.getDistance(),y.getDistance()));
        return list;
   }
    public BaseDrugStoreDO getById(String id,String latitude,String longitude){
        BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findOne(id);
        CountDistance countDistance = new CountDistance();
        latitude=StringUtils.isEmpty(latitude)?"0":latitude;
        longitude=StringUtils.isEmpty(longitude)?"0":longitude;
        double storeLatitude = Double.parseDouble(baseDrugStoreDO.getLatitude());
        double storeLongitude = Double.parseDouble(baseDrugStoreDO.getLongitude());
        double distance = countDistance.getDistance(Double.parseDouble(latitude),Double.parseDouble(longitude),storeLatitude,storeLongitude);
        baseDrugStoreDO.setDistance(distance);
        return baseDrugStoreDO;
    }
}

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

@ -8,6 +8,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorPatientDao;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
import com.yihu.jw.entity.base.dict.DictDeptDescDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -40,6 +41,7 @@ import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.doctor.dao.WlyyDoctorOnlineTimeDao;
import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
@ -244,6 +246,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private BaseSensitiveFilterWordsService baseSensitiveFilterWordsService;
    @Autowired
    private BaseBannerDoctorDao baseBannerDoctorDao;
    @Autowired
    private BaseDrugStoreDao baseDrugStoreDao;
@ -822,10 +826,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
        expressageDO.setDel(1);
        expressageDO.setCreateTime(new Date());
        expressageDO.setOutpatientId(outpatient.getId());
        prescriptionExpressageDao.save(expressageDO);
        if (0==expressageDO.getOneselfPickupFlg()){
            System.out.println("进入物流信息");
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }else {
            System.out.println("写入自取信息");
            String drugStoreCode = expressageDO.getHospitalCode();
            BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findOne(drugStoreCode);
            if (null!=baseDrugStoreDO){
                expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                expressageDO.setCityName(baseDrugStoreDO.getCityName());
                expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }
        //3.创建候诊室
        createRoom(outpatient, chargeType);
@ -841,7 +868,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     */
    public Boolean createRoom(WlyyOutpatientDO outpatientDO, String chargeType) {
        System.out.println("进入创建候诊室");
        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
        waitingRoom.setDept(outpatientDO.getDept());
@ -851,6 +878,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //是否是有协同门诊医生
        if (StringUtils.isNotBlank(outpatientDO.getGeneralDoctor())) {
            System.out.println("是否是有协同门诊医生");
            waitingRoom.setGeneralDoctor(outpatientDO.getGeneralDoctor());
            waitingRoom.setGeneralDoctorName(outpatientDO.getGeneralDoctorName());
        }
@ -5884,6 +5912,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     */
    public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient,boolean payFlag) {
        System.out.println("发送新增门诊信息");
        SystemMessageDO systemMessageDO = new SystemMessageDO();
        String msg = "";
        JSONObject data = new JSONObject();
@ -7543,6 +7572,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    /**
     * 关注医生
     * @param doctorId

+ 3 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyTemplateOptionDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateOptionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -10,8 +11,8 @@ import java.util.List;
 * Created by Trick on 2019/9/6.
 */
public interface SurveyTemplateOptionDao extends PagingAndSortingRepository<WlyySurveyTemplateOptionDO, String>, JpaSpecificationExecutor<WlyySurveyTemplateOptionDO> {
    List<WlyySurveyTemplateOptionDO> findByQuestionCodeAndDelOrderBySortAsc(String questionCode,String del);
    @Query("From WlyySurveyTemplateOptionDO c WHERE c.questionCode = ?1 and c.templateCode = ?2 and c.del = ?3 order by c.sort asc ")
    List<WlyySurveyTemplateOptionDO> findByQuestionCodeAndDelOrderBySortAsc(String questionCode,String templateCode,String del);
    List<WlyySurveyTemplateOptionDO> findByTemplateCodeAndDelOrderBySortAsc(String templateCode,String del);

+ 4 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java

@ -18,11 +18,11 @@ public interface SurveyUserAnswerDao extends PagingAndSortingRepository<WlyySurv
    List<WlyySurveyUserAnswerDO> findBySurverUserId(String surverUserId);
    List<WlyySurveyUserAnswerDO> findByTempQuestionCode(String tempQuestionCode);
    @Query("From WlyySurveyUserAnswerDO c WHERE c.tempOptionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode,String surveyTempCode);
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode);
    @Query("SELECT DISTINCT c.patient from WlyySurveyUserAnswerDO c WHERE c.tempQuestionCode = ?1")
    List<WlyySurveyUserAnswerDO> findByTempQuestionCodeDistinctPatient(String tempQuestionCode);
    @Query("SELECT DISTINCT c.patient from WlyySurveyUserAnswerDO c WHERE c.tempQuestionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findByTempQuestionCodeDistinctPatient(String tempQuestionCode,String surveyTempCode );
}

+ 93 - 22
business/base-service/src/main/java/com/yihu/jw/hospital/survey/service/SurveyService.java

@ -1,10 +1,14 @@
package com.yihu.jw.hospital.survey.service;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.hospital.survey.*;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.survey.dao.*;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.survey.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -12,12 +16,13 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.PercentageUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -64,6 +69,21 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    private SurveyUserAnswerDao surveyUserAnswerDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientBusinessDao basePatientBusinessDao;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${wechat.flag}")
    private boolean flag;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Value("${im.im_list_get}")
    private String im_host;
    /**
     * 查询字典
     * 1.surveyLabel;2.surveyScreenLabel
@ -283,6 +303,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " t.template_comment AS templateComment, " +
                " t.organization, " +
                " t.creater, " +
                " t.creater_code, " +
                " t.create_time AS createTime, " +
                " t.del, " +
                " t.update_time AS updateTime" +
@ -300,7 +321,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            sql += " AND  i.label_code ='"+label+"'";
        }
        if (StringUtils.isNoneBlank(creater)){
            sql +=" AND  t.creater = '"+creater+"' ";
            sql +=" AND  t.creater_code = '"+creater+"' ";
        }
        sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
@ -363,13 +384,14 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        String sqlUsed = "select t.used as \"used\" from wlyy_knowledge_article_user t where t.relation_code = '"+templateCode +"'";
        if(StringUtils.isNotEmpty(userCode)){
            sqlUsed += " and t.user_code = '"+userCode+"'";
            System.out.println(sqlUsed);
            List<Map<String,Object>> listUsed = hibenateUtils.createSQLQuery(sqlUsed);
            if (listUsed.size()>0){
                String used = null!=listUsed.get(0).get("used")?listUsed.get(0).get("used").toString():"0";
                templateVO.setUsed(Integer.valueOf(used));
            }
        }
        System.out.println(sqlUsed);
        List<Map<String,Object>> listUsed = hibenateUtils.createSQLQuery(sqlUsed);
        if (listUsed.size()>0){
            String used = null!=listUsed.get(0).get("used")?listUsed.get(0).get("used").toString():"0";
            templateVO.setUsed(Integer.valueOf(used));
        }
        List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
        if(tqDOs!=null&&tqDOs.size()>0){
            //设置问题
@ -379,7 +401,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),tq.getTemplateCode(),"1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                tq.setOptionVOs(optionVOs);
@ -411,8 +433,8 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    public Boolean saveSurveyTemplate(String tempJson,String tempQJson,String tempOpJson,String labelJson,String labelInspJson)throws Exception{
        WlyySurveyTemplateDO temp = objectMapper.readValue(tempJson,WlyySurveyTemplateDO.class);
        String doctor = temp.getCreaterCode();
        temp = surveyTemplateDao.save(temp);
        //删除原有问题
        List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
        if(questionDODels!=null&&questionDODels.size()>0){
@ -615,6 +637,14 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                answerDO.setSurverUserId(surveyUserDO.getId());
            }
            surveyUserAnswerDao.save(answerDOs);
            BasePatientBusinessDO basePatientBusinessDO = basePatientBusinessDao.findByDoctorPatientRelationCode(surveyUserDO.getPatient(),surveyUserDO.getSurveyTempCode(),surveyUserDO.getDoctor());
            JSONObject object = new JSONObject();
            if (null!=basePatientBusinessDO){
                object.put("title",surveyUserDO.getSurveyTempTitle());
                object.put("content",answerDOs);
                object.put("id",surveyUserDO.getSurveyTempCode());
            }
            this.sendImMsg(basePatientBusinessDO.getPatient(), basePatientBusinessDO.getPatientName(), basePatientBusinessDO.getSessionId(), "36", object.toJSONString(),"1");
        }
        return true;
    }
@ -644,7 +674,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
        templateVO.setLabels(findSurveyTemplateLabel(tempId));
        templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
        BaseDoctorDO doctor = baseDoctorDao.findById(templateDO.getCreaterCode());
        if (null!=doctor){
            templateVO.setVisitDept(doctor.getVisitDept());
            templateVO.setVisitDeptName(doctor.getVisitDeptName());
        }
        //查询所有答题过的用户,计算答题总数
        List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(templateVO.getId(),1);
        Integer total =0;
@ -662,11 +696,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),tq.getTemplateCode(),"1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                int tpCount = 0;
                List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getId());
                List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getId(),tempId);
                if(answerQuestionDOs!=null&&answerQuestionDOs.size()>0){
                    tpCount = answerQuestionDOs.size();
                }
@ -677,7 +711,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                if(optionVOs!=null&&optionVOs.size()>0){
                    for(WlyySurveyTemplateOptionVO vo:optionVOs){
                        Integer answerCount =0;
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId());
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId(),vo.getTemplateCode());
                        if(answerDOs!=null&&answerDOs.size()>0){
                            answerCount = answerDOs.size();
                        }
@ -765,18 +799,18 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
     * 查询
     * @param title
     * @param page
     * @param size
     * @param
     * @param
     * @param
     * @return
     */
    public MixEnvelop findAnswerList(String tempId,String patient,String title,Integer page,Integer size){
    public MixEnvelop findAnswerList(String tempId,String patient,String patientName,String title,Integer page,Integer size){
        String totalSql ="SELECT " +
                " COUNT(1) AS total" +
                " FROM " +
                " wlyy_survey_user t " +
                " WHERE 1=1 ";
                " WHERE 1=1 and t.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            totalSql += " AND t.survey_temp_title like '%"+title+"%' ";
        }
@ -786,6 +820,9 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        if(StringUtils.isNotBlank(tempId)){
            totalSql += " AND t.survey_temp_code = '"+tempId+"' ";
        }
        if(StringUtils.isNotBlank(patientName)){
            totalSql += " AND t.patient_name like  '%"+patientName+"%' ";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
@ -811,18 +848,38 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " FROM " +
                " wlyy_survey_user t " +
                " JOIN base_patient p ON t.patient = p.id " +
                " WHERE 1=1 ";
                " WHERE 1=1 and t.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            sql += " AND t.survey_temp_title like '%"+title+"%' ";
        }
        if(StringUtils.isNotBlank(patient)){
            sql += " AND t.patient = '"+patient+"' ";
        }
        if(StringUtils.isNotBlank(patientName)){
            sql += " AND t.patient_name like  '%"+patientName+"%' ";
        }
        if(StringUtils.isNotBlank(tempId)){
            sql += " AND t.survey_temp_code = '"+tempId+"' ";
        }
        sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
        sql += " ORDER BY t.create_time DESC " ;
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                sql ="SELECT * FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "    ("+sql+") A \n" +
                        "    WHERE ROWNUM <= "+page*size+" ) \n" +
                        "       WHERE RN >= "+((page-1)*size+1);
            }else {
                sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            }
        } else {
            sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
        }
        System.out.println(sql);
        List<WlyySurveyUserVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserVO.class));
        if(list!=null&&list.size()>0){
@ -833,4 +890,18 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
    }
    public String sendImMsg(String from, String fromName, String sessionId, String contentType, String content, String businessType) {
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages";
        System.out.println("im地址"+imAddr);
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("content_type", contentType);
        params.put("content", content);
        params.put("session_id", sessionId);
        params.put("business_type", businessType);
        String response = HttpClientUtil.postBody(imAddr, params);
        return response;
    }
}

+ 10 - 0
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -430,6 +430,15 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (tradeType.equalsIgnoreCase("JSAPI")){
            map.put("openid", openId);
        }
        if (tradeType.equalsIgnoreCase("MWEB")){
            JSONObject jsonObject = new JSONObject();
            JSONObject object = new JSONObject();
            object.put("type","Wap");
            object.put("wap_url","");
            object.put("wap_name","");
            jsonObject.put("h5_info",object);
            map.put("scene_info",jsonObject.toJSONString());
        }
      /*  String token_url = "https://api.weixin.qq.com/cgi-bin/token";
        String params = "grant_type=client_credential&appid=" + wxWechatDO.getAppId() + "&secret=" + wxWechatDO.getAppSecret();
        String result = HttpUtil.sendGet(token_url, params);
@ -774,6 +783,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                 businessOrderDO = new BusinessOrderDO();
             }
        }
        System.out.println(relationCode+"----"+relationName+"----"+orderCategory+"----"+remark+"----"+patient+"----"+patientName+"----"+doctor+"----"+payPrice+"----");
        businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        businessOrderDO.setCreateTime(new Date());
        businessOrderDO.setUpdateTime(new Date());

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientBusinessDao.java

@ -16,4 +16,7 @@ public interface BasePatientBusinessDao extends PagingAndSortingRepository<BaseP
    @Query("select a from BasePatientBusinessDO a where a.del=1 and a.patient=?1 and a.relationCode=?2")
    BasePatientBusinessDO findByPatientAndRelationCodeAndDel(String patient,String relationCode);
    @Query("from BasePatientBusinessDO a where a.del=1 and a.patient=?1 and a.relationCode=?2 and a.doctor = ?3")
    BasePatientBusinessDO findByDoctorPatientRelationCode(String patient,String relationCode,String doctor);
}

+ 32 - 0
business/base-service/src/main/java/com/yihu/jw/utils/CountDistance.java

@ -0,0 +1,32 @@
package com.yihu.jw.utils;
public class CountDistance {
    private static double EARTH_RADIUS = 6378.137;// 6378.137赤道半径6378137
    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }
    /**
     * 通过经纬度计算两点之间的距离(单位:米)
     * @param latone
     * @param lngone
     * @param lattwo
     * @param lngtwo
     * @return
     */
    public  double getDistance(double latone, double lngone, double lattwo, double lngtwo) {
        double radlatone = rad(latone);
        double radlattwo = rad(lattwo);
        double a = radlatone - radlattwo;
        double b = rad(lngone) - rad(lngtwo);
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
                + Math.cos(radlatone) * Math.cos(radlattwo)
                * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000d) / 10000d;
        s = s*1000;
        return s;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -25,7 +25,7 @@ public abstract class IntegerIdentityEntity implements Serializable {
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
   /*@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
  /* @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 151 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/area/BaseDrugStoreDO.java

@ -0,0 +1,151 @@
package com.yihu.jw.entity.base.area;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "base_drug_store")
public class BaseDrugStoreDO extends UuidIdentityEntityWithOperator {
    private String hospitalCode;
    private String hospitalName;
    private String provinceCode;
    private String provinceName;
    private String cityCode;
    private String cityName;
    private String townCode;
    private String townName;
    private String longitude;
    private String latitude;
    private String address;
    private String drugStoreCode;
    private String drugStoreName;
    private Integer isDel;
    @Transient
    private double distance ;
    @Transient
    public double getDistance() {
        return distance;
    }
    public void setDistance(double distance) {
        this.distance = distance;
    }
    @Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "hospital_code")
    public String getHospitalCode() {
        return hospitalCode;
    }
    public void setHospitalCode(String hospitalCode) {
        this.hospitalCode = hospitalCode;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "province_code")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    @Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    @Column(name = "city_code")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
    @Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    @Column(name = "town_code")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    @Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    @Column(name = "longitude")
    public String getLongitude() {
        return longitude;
    }
    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }
    @Column(name = "latitude")
    public String getLatitude() {
        return latitude;
    }
    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }
    @Column(name = "drug_store_code")
    public String getDrugStoreCode() {
        return drugStoreCode;
    }
    public void setDrugStoreCode(String drugStoreCode) {
        this.drugStoreCode = drugStoreCode;
    }
    @Column(name = "drug_store_name")
    public String getDrugStoreName() {
        return drugStoreName;
    }
    public void setDrugStoreName(String drugStoreName) {
        this.drugStoreName = drugStoreName;
    }
    @Column(name = "is_del")
    public Integer getIsDel() {
        return isDel;
    }
    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/login/BaseLoginLogDO.java

@ -19,6 +19,15 @@ public class BaseLoginLogDO extends UuidIdentityEntity implements java.io.Serial
	private String userAgent;//wlyyusersimple json串
	private String openid;//微信openid
	private String loginType;
	private Date operateTime;
	@Column(name="operate_time")
	public Date getOperateTime() {
		return operateTime;
	}
	public void setOperateTime(Date operateTime) {
		this.operateTime = operateTime;
	}
	@Column(name="user_id")
	public String getUserId() {

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyTemplateDO.java

@ -20,12 +20,21 @@ public class WlyySurveyTemplateDO {
    private String title;//模板标题',
    private String templateComment;//模板说明',
    private String creater;//创建人',
    private String createrCode;//创建人code',
    private String organization;//发布机构',
    private String del;//删除标志(1正常,0删除)',
    private Integer used;//常用量',
    private Date createTime;//创建时间',
    private Date updateTime;//修改时间',
    public String getCreaterCode() {
        return createrCode;
    }
    public void setCreaterCode(String createrCode) {
        this.createrCode = createrCode;
    }
    @Id
    @Column(name = "id", unique = true, nullable = false)
    public String getId() {

+ 10 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -749,4 +749,14 @@ public class BaseRequestMapping {
        public static final String queryHealthIdCard  = "/queryHealthIdCard";
    }
    /**
     * 药店管理接口
     */
    public static class drugStoreManage extends Basic {
        public static final String PREFIX  = "/drugStore";
        public static final String findDrugstore  = "/findDrugstore";
        public static final String findDrugstoreByDistance  = "/findDrugstoreByDistance";
        public static final String findDrugstoreById  = "/findDrugstoreById";
    }
}

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

@ -1290,6 +1290,7 @@ public class BaseHospitalRequestMapping {
        public static final String findWorkTimeInfo="/findWorkTimeInfo";
        public static final String findLevelOneDoctorUpcoming="/findLevelOneDoctorUpcoming";
        public static final String getUpcomingByDoctor="/getUpcomingByDoctor";
        public static final String checkOperateTime="/checkOperateTime";
    }
    /**

+ 1 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/ResultStatus.java

@ -16,6 +16,7 @@ public class ResultStatus {
    public static final Integer INVALID_GRANT = 1102; //授权失败,看具体报错信息,如验证码错误,密码错误等,  [登陆时候,用户不存在/应用不存在,归位此类,方便前端判断]
    public static final Integer NO_PERMI = 1103; //无权限访问
    public static final Integer INVALID_TOKEN = 1104;//被踢了 ,账号在别处登陆
    public static final Integer OPERATE_TIME=1105;//长时间未操作
    /**

+ 30 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/survey/WlyySurveyTemplateVO.java

@ -21,6 +21,8 @@ public class WlyySurveyTemplateVO extends UuidIdentityVO {
    private String templateComment;//模板说明',
    @ApiModelProperty(value = "创建人", example = "模块1")
    private String creater;//创建人',
    @ApiModelProperty(value = "创建人code", example = "模块1")
    private String createrCode;//创建人name',
    @ApiModelProperty(value = "发布机构", example = "模块1")
    private String organization;//发布机构',
    @ApiModelProperty(value = "删除标志(1正常,0删除)", example = "模块1")
@ -41,6 +43,34 @@ public class WlyySurveyTemplateVO extends UuidIdentityVO {
    private Integer answerCount;//修改时间',
    @ApiModelProperty(value = "是否常用", example = "模块1")
    private Integer used;//是否常用1常用0不常用,
    @ApiModelProperty(value = "出诊科室code", example = "模块1")
    private String visitDept;
    @ApiModelProperty(value = "出诊科室名称", example = "模块1")
    private String visitDeptName;
    public String getCreaterCode() {
        return createrCode;
    }
    public void setCreaterCode(String createrCode) {
        this.createrCode = createrCode;
    }
    public String getVisitDept() {
        return visitDept;
    }
    public void setVisitDept(String visitDept) {
        this.visitDept = visitDept;
    }
    public String getVisitDeptName() {
        return visitDeptName;
    }
    public void setVisitDeptName(String visitDeptName) {
        this.visitDeptName = visitDeptName;
    }
    public Integer getUsed() {
        return used;

+ 207 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/DeviceHealthIndexVO.java

@ -0,0 +1,207 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 *  Created by ysj on 20120/7/29.
 * 体征数据表
 */
public class DeviceHealthIndexVO {
    private Long id;
    private Date czrq;
    private String del;
    private String deviceSn;
    private String idcard;
    private String intervene;
    private Date recordDate;
    private Date sortDate;
    private int type;
    private String user;
    private String userName;
    private Integer status;
    private String value1;
    private String value2;
    private String value3;
    private String value4;
    private String value5;
    private String value6;
    private String value7;
    private String healthStandard;
    private String button;
    public DeviceHealthIndexVO() {
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @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;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getIntervene() {
        return intervene;
    }
    public void setIntervene(String intervene) {
        this.intervene = intervene;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getRecordDate() {
        return recordDate;
    }
    public void setRecordDate(Date recordDate) {
        this.recordDate = recordDate;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getSortDate() {
        return sortDate;
    }
    public void setSortDate(Date sortDate) {
        this.sortDate = sortDate;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getValue1() {
        return value1;
    }
    public void setValue1(String value1) {
        this.value1 = value1;
    }
    public String getValue2() {
        return value2;
    }
    public void setValue2(String value2) {
        this.value2 = value2;
    }
    public String getValue3() {
        return value3;
    }
    public void setValue3(String value3) {
        this.value3 = value3;
    }
    public String getValue4() {
        return value4;
    }
    public void setValue4(String value4) {
        this.value4 = value4;
    }
    public String getValue5() {
        return value5;
    }
    public void setValue5(String value5) {
        this.value5 = value5;
    }
    public String getValue6() {
        return value6;
    }
    public void setValue6(String value6) {
        this.value6 = value6;
    }
    public String getValue7() {
        return value7;
    }
    public void setValue7(String value7) {
        this.value7 = value7;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getHealthStandard() {
        return healthStandard;
    }
    public void setHealthStandard(String healthStandard) {
        this.healthStandard = healthStandard;
    }
    public String getButton() {
        return button;
    }
    public void setButton(String button) {
        this.button = button;
    }
}

+ 288 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyDeviceVO.java

@ -0,0 +1,288 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import java.util.Date;
/**
 * Created by ysj on 20120/7/29.
 * 设备表
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "wlyy设备表", description = "wlyy设备表")
public class WlyyDeviceVO {
    private Long id;
    private String deviceName;//设备名称
    private String deviceModel;//型号
    private String deviceCode;//设备唯一标识
    private String manufacturer;//厂家名称
    private Date applyDate;//申请日期
    private String orgName;//(居民)机构名称
    private String linkman;//联系人(居民)
    private String tel;//联系人(居民)电话
    private String serverIp;//服务IP地址
    private String manufacturerCode;//厂商代码threeNod:三诺 urion:优瑞恩 bioland:爱奥乐 comvee:康为
    private String address;//厂家地址
    private String representative;//法人代表
    private String applicantName;//申请注册人(发放人/医生)
    private String applicantIdentity;//申请人(发放人/医生)身份证号
    private String applicantTel;//申请人(发放人/医生)手机
    private String applicantMail;//申请人(发放人/医生)邮箱
    //1.4.8版本新增字段
    private String sim;//SIM卡
    private String manufacturerId;//厂商表的业务关联code
    private Integer isGrant;//是否发放(0否1是)
    private String grantAdminTeam;//发放的患者所在团队
    private String grantOrgCode;//发放所在机构
    private Integer isBinding;//是否绑定(0否 1 绑定单端口 2 绑定双端口)
    private String bindingCount;//绑定次数({"1":"0", "2":"0"})
    private Date grantTime;//发放时间
    private String neighborhoodCommitteeCode;//居委会code
    private String neighborhoodCommitteeName;//居委会name
    /** default constructor */
    public WlyyDeviceVO() {
    }
    /** full constructor */
    public WlyyDeviceVO(String deviceName, String deviceModel, String deviceCode, String manufacturer, Date applyDate
            , String orgName, String linkman, String tel, String serverIp, String manufacturerCode, String address
            , String representative, String applicantName, String applicantIdentity, String applicantTel, String applicantMail) {
        this.deviceName = deviceName;
        this.deviceModel = deviceModel;
        this.deviceCode = deviceCode;
        this.manufacturer = manufacturer;
        this.applyDate = applyDate;
        this.orgName = orgName;
        this.linkman = linkman;
        this.tel = tel;
        this.serverIp = serverIp;
        this.manufacturerCode = manufacturerCode;
        this.address = address;
        this.representative = representative;
        this.applicantName = applicantName;
        this.applicantIdentity = applicantIdentity;
        this.applicantTel = applicantTel;
        this.applicantMail = applicantMail;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
    public String getDeviceModel() {
        return deviceModel;
    }
    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }
    public String getDeviceCode() {
        return deviceCode;
    }
    public void setDeviceCode(String deviceCode) {
        this.deviceCode = deviceCode;
    }
    public String getManufacturer() {
        return manufacturer;
    }
    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }
    public Date getApplyDate() {
        return applyDate;
    }
    public void setApplyDate(Date applyDate) {
        this.applyDate = applyDate;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getLinkman() {
        return linkman;
    }
    public void setLinkman(String linkman) {
        this.linkman = linkman;
    }
    public String getTel() {
        return tel;
    }
    public void setTel(String tel) {
        this.tel = tel;
    }
    public String getServerIp() {
        return serverIp;
    }
    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }
    public String getManufacturerCode() {
        return manufacturerCode;
    }
    public void setManufacturerCode(String manufacturerCode) {
        this.manufacturerCode = manufacturerCode;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getRepresentative() {
        return representative;
    }
    public void setRepresentative(String representative) {
        this.representative = representative;
    }
    public String getApplicantName() {
        return applicantName;
    }
    public void setApplicantName(String applicantName) {
        this.applicantName = applicantName;
    }
    public String getApplicantIdentity() {
        return applicantIdentity;
    }
    public void setApplicantIdentity(String applicantIdentity) {
        this.applicantIdentity = applicantIdentity;
    }
    public String getApplicantTel() {
        return applicantTel;
    }
    public void setApplicantTel(String applicantTel) {
        this.applicantTel = applicantTel;
    }
    public String getApplicantMail() {
        return applicantMail;
    }
    public void setApplicantMail(String applicantMail) {
        this.applicantMail = applicantMail;
    }
    public String getManufacturerId() {
        return manufacturerId;
    }
    public void setManufacturerId(String manufacturerId) {
        this.manufacturerId = manufacturerId;
    }
    public String getSim() {
        return sim;
    }
    public void setSim(String sim) {
        this.sim = sim;
    }
    public Integer getIsGrant() {
        return isGrant;
    }
    public void setIsGrant(Integer grant) {
        isGrant = grant;
    }
    public String getGrantAdminTeam() {
        return grantAdminTeam;
    }
    public void setGrantAdminTeam(String grantAdminTeam) {
        this.grantAdminTeam = grantAdminTeam;
    }
    public String getGrantOrgCode() {
        return grantOrgCode;
    }
    public void setGrantOrgCode(String grantOrgCode) {
        this.grantOrgCode = grantOrgCode;
    }
    public Integer getIsBinding() {
        return isBinding;
    }
    public void setIsBinding(Integer isBinding) {
        this.isBinding = isBinding;
    }
    public String getBindingCount() {
        return bindingCount;
    }
    public void setBindingCount(String bindingCount) {
        this.bindingCount = bindingCount;
    }
    public Date getGrantTime() {
        return grantTime;
    }
    public void setGrantTime(Date grantTime) {
        this.grantTime = grantTime;
    }
    public String getNeighborhoodCommitteeCode() {
        return neighborhoodCommitteeCode;
    }
    public void setNeighborhoodCommitteeCode(String neighborhoodCommitteeCode) {
        this.neighborhoodCommitteeCode = neighborhoodCommitteeCode;
    }
    public String getNeighborhoodCommitteeName() {
        return neighborhoodCommitteeName;
    }
    public void setNeighborhoodCommitteeName(String neighborhoodCommitteeName) {
        this.neighborhoodCommitteeName = neighborhoodCommitteeName;
    }
}

+ 112 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyHealthStandardVO.java

@ -0,0 +1,112 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import javax.persistence.Column;
import java.util.Date;
/**
 *
 * @author George
 *
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "患者健康指标预警值", description = "患者健康指标预警值")
public class WlyyHealthStandardVO {
	private Long id;
	// 患者标识
	private String patient;
	// 健康指标类型:1血糖,2血压,3体重,4腰围
	private Integer type;
	// 最低安全值(血糖餐前\收缩压\体重\腰围)
	private Double minValue1;
	// 最高安全值(血糖餐前\收缩压\体重\腰围)
	private Double maxValue1;
	// 最低安全值(血糖餐后\舒张压)
	private Double minValue2;
	// 最高安全值(血糖餐后\舒张压)
	private Double maxValue2;
	// 设置医生
	private String doctor;
	// 设置时间
	private Date czrq;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Double getMinValue1() {
		return minValue1;
	}
	public void setMinValue1(Double minValue) {
		this.minValue1 = minValue;
	}
	public Double getMaxValue1() {
		return maxValue1;
	}
	public void setMaxValue1(Double maxValue) {
		this.maxValue1 = maxValue;
	}
	public Double getMinValue2() {
		return minValue2;
	}
	public void setMinValue2(Double minValue) {
		this.minValue2 = minValue;
	}
	@Column(name = "max_value_2")
	public Double getMaxValue2() {
		return maxValue2;
	}
	public void setMaxValue2(Double maxValue) {
		this.maxValue2 = maxValue;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	@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;
	}
}

+ 167 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/WlyyPatientDeviceVO.java

@ -0,0 +1,167 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * 居民体征设备
 * @author yeshijie
 * @date 2020/7/29
 */
public class WlyyPatientDeviceVO {
	private Integer id;
	private Integer deviceId;
	private String user;
	private String userName;
	private String categoryCode;
	private String deviceName;
	private String deviceSn;
	private String sim;
	private String userType;
	private String userIdcard;
	private Date czrq;
	private String doctor;
	private String doctorName;
	private String hospital;
	private String hospitalName;
	private String doctorHealthName;
	private String doctorHealth;
	
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public Integer getDeviceId() {
		return deviceId;
	}
	
	public void setDeviceId(Integer deviceId) {
		this.deviceId = deviceId;
	}
	
	public String getUser() {
		return user;
	}
	
	public void setUser(String user) {
		this.user = user;
	}
	
	public String getUserName() {
		return userName;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public String getCategoryCode() {
		return categoryCode;
	}
	
	public void setCategoryCode(String categoryCode) {
		this.categoryCode = categoryCode;
	}
	
	public String getDeviceName() {
		return deviceName;
	}
	
	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}
	
	public String getDeviceSn() {
		return deviceSn;
	}
	
	public void setDeviceSn(String deviceSn) {
		this.deviceSn = deviceSn;
	}
	
	public String getSim() {
		return sim;
	}
	
	public void setSim(String sim) {
		this.sim = sim;
	}
	
	public String getUserType() {
		return userType;
	}
	
	public void setUserType(String userType) {
		this.userType = userType;
	}
	
	public String getUserIdcard() {
		return userIdcard;
	}
	
	public void setUserIdcard(String userIdcard) {
		this.userIdcard = userIdcard;
	}
	@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;
	}
	
	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 getHospital() {
		return hospital;
	}
	
	public void setHospital(String hospital) {
		this.hospital = hospital;
	}
	
	public String getHospitalName() {
		return hospitalName;
	}
	
	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}
	public String getDoctorHealthName() {
		return doctorHealthName;
	}
	public void setDoctorHealthName(String doctorHealthName) {
		this.doctorHealthName = doctorHealthName;
	}
	public String getDoctorHealth() {
		return doctorHealth;
	}
	public void setDoctorHealth(String doctorHealth) {
		this.doctorHealth = doctorHealth;
	}
}

+ 26 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -38,6 +38,32 @@ public class DateUtil {
        return new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss).parse(date);
    }
    private static ThreadLocal<SimpleDateFormat> simpleDateTimeFormat = new ThreadLocal<SimpleDateFormat>(){
        @Override
        protected synchronized SimpleDateFormat initialValue(){
            return new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
        }
    };
    private static ThreadLocal<SimpleDateFormat> simpleDateFormat = new ThreadLocal<SimpleDateFormat>(){
        @Override
        protected synchronized SimpleDateFormat initialValue(){
            return new SimpleDateFormat(YYYY_MM_DD);
        }
    };
    public static Date simpleDateParse(final String date) throws ParseException {
        if(StringUtils.isEmpty(date)) return null;
        Date parsedDate = simpleDateFormat.get().parse(date);
        return parsedDate;
    }
    public static String simpleDateTimeFormat(final Date date){
        String time = simpleDateTimeFormat.get().format(date);
        return time;
    }
    /**
     * 时间格式转中文格式
     */

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

@ -1,9 +1,13 @@
package com.yihu.jw.gateway.filter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.yihu.jw.gateway.methlog.BaseLoginLogService;
import com.yihu.jw.gateway.methlog.BaseMethodLogService;
import com.yihu.jw.gateway.useragent.UserAgent;
import com.yihu.jw.restmodel.ResultStatus;
import com.yihu.jw.restmodel.web.Envelop;
import org.slf4j.Logger;
@ -26,6 +30,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
@ -46,6 +51,13 @@ public class BasicZuulFilter extends ZuulFilter {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private BaseMethodLogService baseMethodLogService;
    @Autowired
    private BaseLoginLogService baseLoginLogService;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private RedisTokenStore redisTokenStore;
    @Override
    public String filterType() {
@ -97,6 +109,7 @@ public class BasicZuulFilter extends ZuulFilter {
                || url.contains("/image/")) {//获取默认图片
            return true;
        }
        System.out.println("进入token验证");
        return this.authenticate(ctx, request, url);
    }
@ -108,7 +121,9 @@ public class BasicZuulFilter extends ZuulFilter {
     * @return
     */
    private Object authenticate(RequestContext ctx, HttpServletRequest request, String path) {
        System.out.println("获取token");
        String accessToken = this.extractToken(request);
        System.out.println("获取token"+accessToken);
        if (null == accessToken) {
            return this.forbidden(ctx, ResultStatus.NULL_TOKEN, "token can not be null");
        }
@ -130,9 +145,21 @@ public class BasicZuulFilter extends ZuulFilter {
        }
        //获取所有token资源
        String resourceIds[] = urls.split(",");
        String platform = request.getHeader("platform");
        for (String resourceId : resourceIds) {
            if (resourceId.equals("/**")) {
                System.out.println("/**"+true);
                //判断用户操作间隔
                if (null!=platform&&"city-ihealth-admin-web".equalsIgnoreCase(platform)){
                    //判断用户操作间隔
                    String userId = userAgent.getUID();
                    System.out.println(userId);
                    Boolean checkTimeOut = baseLoginLogService.checkTime(userId);
                    System.out.println("即将进入验证操作时间接口");
                    if (!checkTimeOut){
                        return this.forbidden(ctx, ResultStatus.OPERATE_TIME, "expired token");
                    }
                }
                return true;
            }
            if (!resourceId.startsWith("/")) {
@ -141,9 +168,32 @@ public class BasicZuulFilter extends ZuulFilter {
            path = path.toLowerCase();
            if (path.startsWith(resourceId)
                    && (path.length() == resourceId.length() || path.charAt(resourceId.length()) == '/')) {
                System.out.println("158"+true);
                //判断用户操作间隔
                if (null!=platform&&"city-ihealth-admin-web".equalsIgnoreCase(platform)){
                    //判断用户操作间隔
                    String userId = userAgent.getUID();
                    System.out.println(userId);
                    Boolean checkTimeOut = baseLoginLogService.checkTime(userId);
                    System.out.println("即将进入验证操作时间接口");
                    if (!checkTimeOut){
                        return this.forbidden(ctx, ResultStatus.OPERATE_TIME, "expired token");
                    }
                }
                return true;
            }
        }
        if (null!=platform&&"city-ihealth-admin-web".equalsIgnoreCase(platform)){
            //判断用户操作间隔
            String userId = userAgent.getUID();
            System.out.println(userId);
            Boolean checkTimeOut = baseLoginLogService.checkTime(userId);
            System.out.println("即将进入验证操作时间接口");
            if (!checkTimeOut){
                return this.forbidden(ctx, ResultStatus.OPERATE_TIME, "expired token");
            }
        }
        return this.forbidden(ctx, ResultStatus.NO_PERMI, "invalid token does not contain request resource " + path);
    }

+ 18 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseLoginLogDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseLoginLogDao extends PagingAndSortingRepository<BaseLoginLogDO, String>, JpaSpecificationExecutor<BaseLoginLogDO> {
    @Query("from BaseLoginLogDO l where l.openid=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByOpenId(String openid);
    @Query("from BaseLoginLogDO l where l.userId=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByUserId(String openid);
}

+ 87 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseLoginLogService.java

@ -0,0 +1,87 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
@Service
@Transactional
public class BaseLoginLogService {
    @Autowired
    private BaseLoginLogDao baseLoginLogDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    /**
     * 根据openid 获取最新的一条数据
     * @param openid
     * @return
     */
    public BaseLoginLogDO findByOpenId(String openid) {
        List<BaseLoginLogDO> loginLogs = baseLoginLogDao.findByOpenId(openid);
        if(!CollectionUtils.isEmpty(loginLogs)){
            return loginLogs.get(0);
        }
        return null;
    }
    /*
     *根据userid获取数据
     *
     */
    public Boolean checkTime(String userId){
        List<BaseLoginLogDO> list = baseLoginLogDao.findByUserId(userId);
        long between = 0l;
        long timeOut = 1000*60*5;
        String idOperate = "OPERATE_TIME";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findOne(idOperate);
        if (null!=wlyyHospitalSysDictDO){
            String dictValue =wlyyHospitalSysDictDO.getDictValue()==null?"5":wlyyHospitalSysDictDO.getDictValue();
            timeOut = 1000*60*Integer.valueOf(dictValue);
        }
        if (list.size()>0){
            BaseLoginLogDO baseLoginLogDO = list.get(0);
            Date optiondate = baseLoginLogDO.getOperateTime();
            //如果操作时间为空则拿创建时间比较
            if (null==optiondate){
                optiondate = baseLoginLogDO.getCreateTime();
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }else {
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }
        }else {
            return false;
        }
    }
}

+ 9 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/WlyyHospitalSysDictDao.java

@ -0,0 +1,9 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface WlyyHospitalSysDictDao extends PagingAndSortingRepository<WlyyHospitalSysDictDO, String>, JpaSpecificationExecutor<WlyyHospitalSysDictDO> {
}

+ 3 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/login/dao/BaseLoginLogDao.java

@ -12,4 +12,7 @@ public interface BaseLoginLogDao extends PagingAndSortingRepository<BaseLoginLog
    @Query("from BaseLoginLogDO l where l.openid=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByOpenId(String openid);
    @Query("from BaseLoginLogDO l where l.userId=?1 order by l.createTime desc")
    List<BaseLoginLogDO> findByUserId(String openid);
}

+ 45 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/login/service/BaseLoginLogService.java

@ -3,13 +3,16 @@ package com.yihu.jw.security.login.service;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.security.login.dao.BaseLoginLogDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Date;
@Service
public class BaseLoginLogService<T, R extends CrudRepository> extends BaseJpaService<BaseLoginLogDO, BaseLoginLogDao> {
@ -27,6 +30,47 @@ public class BaseLoginLogService<T, R extends CrudRepository> extends BaseJpaSer
            return loginLogs.get(0);
        }
        return null;
    }
    /*
     *根据userid获取数据
     *
     */
    public Boolean checkTime(String userId){
        List<BaseLoginLogDO> list = baseLoginLogDao.findByUserId(userId);
        long between = 0l;
        long timeOut = 1000*60*5;
        if (list.size()>0){
            BaseLoginLogDO baseLoginLogDO = list.get(0);
            Date optiondate = baseLoginLogDO.getOperateTime();
            //如果操作时间为空则拿创建时间比较
            if (null==optiondate){
                optiondate = baseLoginLogDO.getCreateTime();
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }else {
                Date nowTime = new Date(System.currentTimeMillis());
                between = nowTime.getTime() - optiondate.getTime();
                if (between>timeOut){
                    return false;
                }else {
                    baseLoginLogDO.setOperateTime(new Date());
                    baseLoginLogDao.save(baseLoginLogDO);
                    return true;
                }
            }
        }else {
            return false;
        }
    }
}

+ 0 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthYlzConfigService.java

@ -44,8 +44,6 @@ public class OauthYlzConfigService {
    @Autowired
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private FileUploadService fileUploadService;
    @Autowired
    private BasePatientDao basePatientDao;
//    @Value("${fastDFS.fastdfs_file_url}")

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

@ -287,7 +287,7 @@ public class PrescriptionStatusUpdateService {
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                    //结束门诊
                    outpatientDO.setStatus("2");
                    outpatientDO.setStatus("3");
    
                    String consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                    if(StringUtils.isNoneBlank(consultCode)){

+ 84 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/drugstore/BaseDrugStoreEndpoint.java

@ -0,0 +1,84 @@
package com.yihu.jw.hospital.endpoint.drugstore;
import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
import com.yihu.jw.entity.base.area.BaseProvinceDO;
import com.yihu.jw.hospital.drugstore.service.BaseDrugStoreService;
import com.yihu.jw.restmodel.base.area.BaseProvinceVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.management.MXBean;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = BaseRequestMapping.drugStoreManage.PREFIX)
@Api(value = "药店管理", description = "药店管理接口", tags = {"药店管理接口"})
public class BaseDrugStoreEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseDrugStoreService baseDrugStoreService;
    @GetMapping(value = BaseRequestMapping.drugStoreManage.findDrugstore)
    @ApiOperation(value = "药店查询")
    public MixEnvelop findDrugstore (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @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) throws Exception {
        List<BaseDrugStoreDO> baseProvinces = baseDrugStoreService.search(fields, filters, sorts, page, size);
        int count = (int)baseDrugStoreService.getCount(filters);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(baseProvinces);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setTotalCount(count);
        mixEnvelop.setPageSize(size);
        return mixEnvelop;
    }
    @GetMapping(value = BaseRequestMapping.drugStoreManage.findDrugstoreByDistance)
    @ApiOperation(value = "药店距离查询")
    public MixEnvelop findDrugstoreBydistance (
            @ApiParam(name = "latitude", value = "经度")
            @RequestParam(value = "latitude", required = false) String latitude,
            @ApiParam(name = "longitude", value = "纬度")
            @RequestParam(value = "longitude", required = false) String longitude,
            @ApiParam(name = "drugStoreName", value = "药店名称")
            @RequestParam(value = "drugStoreName", required = false) String drugStoreName,
            @ApiParam(name = "hospitalName", value = "医院名称")
            @RequestParam(value = "hospitalName", required = false) String hospitalName) throws Exception {
        List<BaseDrugStoreDO> list = baseDrugStoreService.countDistanceListIncode(latitude,longitude,drugStoreName,hospitalName);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }
    @GetMapping(value = BaseRequestMapping.drugStoreManage.findDrugstoreById)
    @ApiOperation(value = "药店id查询")
    public Envelop findDrugStoreById(@ApiParam(name = "latitude", value = "经度")
                                         @RequestParam(value = "latitude", required = false) String latitude,
                                     @ApiParam(name = "longitude", value = "纬度")
                                         @RequestParam(value = "longitude", required = false) String longitude,
                                        @ApiParam(name = "id", value = "药店id")
                                     @RequestParam(value = "id", required = false) String id){
        BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreService.getById(id,latitude,longitude);
        if (null!=baseDrugStoreDO){
            return success(baseDrugStoreDO);
        }else {
            return failed("查询失败");
        }
    }
}

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

@ -42,6 +42,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.WechatDao;
@ -138,6 +139,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private WechatDao wechatDao;
    private String successxml = "SUCCESS";
    private String failedxml = "FALSE";
@ -728,4 +730,6 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        String uri = qrcodeService.makeSpecialistQrcode(doctor);
        return success("操作成功",uri);
    }
}

+ 9 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/survey/SurveyEndpoint.java

@ -107,7 +107,7 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop findSurveyTemplateById(@ApiParam(name = "tempId", value = "模板ID")
                                             @RequestParam(value = "tempId",required = true) String tempId,
                                             @ApiParam(name = "userCode", value = "当前用户id")
                                             @RequestParam(value = "userCode",required = true) String userCode ) throws Exception {
                                             @RequestParam(value = "userCode",required = false) String userCode ) throws Exception {
        return success(surveyService.findSurveyTemplateById(tempId,userCode));
    }
@ -159,6 +159,7 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
        return success(surveyService.findSurveyByDept(dept));
    }
    @GetMapping(value = BaseHospitalRequestMapping.WlyySurvey.findSurveyByDeptAndPatient)
    @ApiOperation(value = "模板-查询部门下发放的问卷用户答题情况")
    public ListEnvelop findSurveyByDeptAndPatient(@ApiParam(name = "dept", value = "科室")
@ -225,13 +226,15 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
                                     @RequestParam(value = "tempId",required = false) String tempId,
                                     @ApiParam(name = "patient", value = "标题")
                                     @RequestParam(value = "patient",required = false) String patient,
                                     @ApiParam(name = "patientName", value = "患者名字")
                                         @RequestParam(value = "patientName",required = false) String patientName,
                                     @ApiParam(name = "title", value = "标题")
                                     @RequestParam(value = "title",required = false) String title,
                                     @ApiParam(name = "page", value = "第几页,1开始")
                                     @RequestParam(value = "page",required = true)Integer page,
                                     @ApiParam(name = "size", value = "每页大小")
                                     @RequestParam(value = "size",required = true)Integer size)throws Exception {
        return surveyService.findAnswerList(tempId,patient,title,page,size);
        return surveyService.findAnswerList(tempId,patient,patientName,title,page,size);
    }
    //=================
@ -241,13 +244,15 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
                                     @RequestParam(value = "title",required = false) String title,
                               @ApiParam(name = "doctor", value = "医生id")
                                     @RequestParam(value = "doctor",required = false) String doctor,
                               @ApiParam(name = "used", value = "是否常用")
                               @ApiParam(name = "used", value = "used")
                                     @RequestParam(value = "used",required = false) Integer used,
                                  @ApiParam(name = "labelCode", value = "labelCode")
                                      @RequestParam(value = "labelCode",required = false) String labelCode,
                               @ApiParam(name = "page", value = "第几页,1开始",defaultValue = "1")
                                     @RequestParam(value = "page",required = true,defaultValue = "1")Integer page,
                               @ApiParam(name = "pageSize", value = "每页大小",defaultValue = "10")
                                     @RequestParam(value = "pageSize",required = true,defaultValue = "10")Integer pageSize)throws Exception {
        return businessService.getUsedList(title,doctor,used,page,pageSize);
        return businessService.getUsedList(title,doctor,labelCode,used,page,pageSize);
    }
    @GetMapping(value = BaseHospitalRequestMapping.WlyySurvey.setUsed)

+ 20 - 26
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java

@ -16,6 +16,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.survey.WlyySurveyLabelInfoVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -210,9 +211,10 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
		knowledgeArticleUserDao.save(knowledgeArticleUserDO);
		surveyTemplateDao.save(wlyySurveyTemplateDO);
	}
	public MixEnvelop getUsedList(String title, String doctor, Integer used, Integer page, Integer pageSize) {
	public MixEnvelop getUsedList(String title, String doctor,String labelCode,  Integer used, Integer page, Integer pageSize) {
		StringBuffer sql = new StringBuffer();
		MixEnvelop mixEnvelop = new MixEnvelop();
		sql.append("SELECT " +
				" t.id, " +
				" b.used as \"used\","+
@ -220,6 +222,7 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
				" t.template_comment AS templateComment, " +
				" t.organization, " +
				" t.creater, " +
				" t.creater_code, " +
				" t.create_time AS createTime, " +
				" t.del, " +
				" t.update_time AS updateTime" +
@ -228,17 +231,23 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
		//1为查询常用
		if (null != used) {
			if (1 == used) {
				sql.append("JOIN wlyy_knowledge_article_user b on t.id = b.relation_code ");
				sql.append("JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code where 1=1");
				if (StringUtils.isNotEmpty(labelCode)){
					sql.append(" JOIN wlyy_survey_label_info i on t.id = i.survey_temp_code ");
				}
				sql.append(" JOIN wlyy_knowledge_article_user b on t.id = b.relation_code where 1=1 ");
				sql.append(" and b.used = 1");
				if (StringUtils.isNotEmpty(doctor)) {
				if (StringUtils.isNotEmpty(title)) {
					sql.append(" and t.title like '%" + title + "%'");
				}
				if (StringUtils.isNotEmpty(doctor)) {
					sql.append(" and t.creater = '" + doctor + "'");
					sql.append(" and b.user_code ='"+doctor+"'");
				}
				if (StringUtils.isNotEmpty(labelCode)){
					sql.append(" and i.label_code = '"+labelCode+"'");
				}
				System.out.println(sql);
				String sqlCount = "select Count(1) as \"total\" from ("+sql+") l";
				List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql.toString(), page, pageSize);
				List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount);
@ -251,14 +260,9 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
						List<WlyySurveyLabelInfoVO>  wlyySurveyLabelInfoVOS= surveyService.findSurveyTemplateLabel(null==map.get("id")?"":map.get("id").toString());
						String createTime = null == map.get("createTime") ? "" : map.get("createTime").toString();
                        String updateTime = null == map.get("updateTime") ? "" : map.get("updateTime").toString();
						String creater = null == map.get("creater") ? "" : map.get("creater").toString();
						map.put("create_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime)));
                        map.put("update_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(updateTime)));
						map.put("createTime", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime)));
                        map.put("updateTime", DateUtil.dateToStrLong(DateUtil.strToDateLong(updateTime)));
						map.put("labels",wlyySurveyLabelInfoVOS);
						BaseDoctorDO doctorDO = doctorDao.findById(creater);
						if (null!=doctor){
							map.put("doctrName", doctorDO.getName());
						}
					}
				}
				mixEnvelop.setPageSize(pageSize);
@ -286,13 +290,8 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
						map.put("labels",wlyySurveyLabelInfoVOS);
                        String createTime = null == map.get("createTime") ? "" : map.get("createTime").toString();
                        String updateTime = null == map.get("updateTime") ? "" : map.get("updateTime").toString();
                        map.put("create_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime)));
                        map.put("update_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(updateTime)));
                        String creater = null == map.get("creater") ? "" : map.get("creater").toString();
						BaseDoctorDO doctorDO = doctorDao.findById(creater);
						if (null!=doctor){
							map.put("doctrName", doctorDO.getName());
						}
                        map.put("createTime", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime)));
                        map.put("updateTime", DateUtil.dateToStrLong(DateUtil.strToDateLong(updateTime)));
					}
				}
				mixEnvelop.setPageSize(pageSize);
@ -324,13 +323,8 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
					map.put("labels",wlyySurveyLabelInfoVOS);
                    String createTime = null == map.get("createTime") ? "" : map.get("createTime").toString();
                    String updateTime = null == map.get("updateTime") ? "" : map.get("updateTime").toString();
                    map.put("create_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime)));
                    map.put("update_time", DateUtil.dateToStrLong(DateUtil.strToDateLong(updateTime)));
					String creater = null == map.get("creater") ? "" : map.get("creater").toString();
					BaseDoctorDO doctorDO = doctorDao.findById(creater);
					if (null!=doctor){
						map.put("doctrName", doctorDO.getName());
					}
                    map.put("createTime", DateUtil.dateToStrLong(DateUtil.strToDateLong(createTime)));
                    map.put("updateTime", DateUtil.dateToStrLong(DateUtil.strToDateLong(updateTime)));
				}
			}

+ 2 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/QrcodeService.java

@ -86,8 +86,7 @@ public class QrcodeService {
        for (BaseDoctorDO doctorDO :doctors){
            if (null==doctorDO.getQrcode()||"".equals(doctorDO.getQrcode())){
                // 二维码内容
                String doctorname = doctorDO.getName().length()>4?doctorDO.getName().substring(0,4):doctorDO.getName();
                String content = "doctor_" + doctorDO.getId() +"_"+doctorname;
                String content = "doctor_" + doctorDO.getId() +"_"+doctorDO.getName();
                System.out.println("content"+content);
                // 二维码图片文件名
                String fileName = doctorDO.getId()+"_"+doctorDO.getMobile()+".png";
@ -134,8 +133,7 @@ public class QrcodeService {
        if (null!=baseDoctorDO){
            if (null==baseDoctorDO.getQrcode()||"".equals(baseDoctorDO.getQrcode())){
                // 二维码内容
                String doctorname = baseDoctorDO.getName().length()>4?baseDoctorDO.getName().substring(0,4):baseDoctorDO.getName();
                String content = "doctor_" + baseDoctorDO.getId() +"_"+doctorname;
                String content = "doctor_" + baseDoctorDO.getId() +"_"+baseDoctorDO.getName();
                System.out.println("content"+content);
                // 二维码图片文件名
                String fileName = baseDoctorDO.getId()+".png";

+ 514 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/common/BaseController.java

@ -0,0 +1,514 @@
package com.yihu.iot.controller.common;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
public class BaseController {
	private static Logger logger = LoggerFactory.getLogger(BaseController.class);
	@Autowired
	protected HttpServletRequest request;
	public void error(Exception e) {
		logger.error(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	public void warn(Exception e) {
		logger.warn(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	/**
	 * 返回接口处理结果
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String error(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 接口处理成功
	 * @param msg
	 * @return
	 */
	public String success(String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", 200);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	public String write(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, List<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, list);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONObject value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	
	/**
	 * 返回接口处理结果
	 *
	 *
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, com.alibaba.fastjson.JSONObject value) {
		try {
			com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toJSONString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param total 总数
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, int total, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put("total", total);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Object value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			// 是否为第一页
			map.put("isFirst", list.isFirst());
			// 是否为最后一页
			map.put("isLast", list.isLast());
			// 总条数
			map.put("total", list.getTotalElements());
			// 总页数
			map.put("totalPages", list.getTotalPages());
			map.put(key, list.getContent());
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", page.isFirst());
			// 是否为最后一页
			json.put("isLast", page.isLast());
			// 总条数
			json.put("total", page.getTotalElements());
			// 总页数
			json.put("totalPages", page.getTotalPages());
			json.put(key, array);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Map<?, ?> value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			System.out.println(mapper.writeValueAsString(map));
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	* 返回接口处理结果
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @param value 结果数据
	* @return
	*/
	public String write(int code, String msg, String key, String value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", isFirst);
			// 是否为最后一页
			json.put("isLast", isLast);
			// 总条数
			json.put("total", total);
			// 总页数
			json.put("totalPages", totalPages);
			json.put(key, values);
			return json.toString();
		} catch (Exception e) {
			logger.error("BaseController:", e.getMessage());
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	public String trimEnd(String param, String trimChars) {
		if (param.endsWith(trimChars)) {
			param = param.substring(0, param.length() - trimChars.length());
		}
		return param;
	}
	/**
	 * 无效用户消息返回
	 * @param e
	 * @param defaultCode
	 * @param defaultMsg
	 * @return
	 */
	public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
		try {
			// if (e instanceof UndeclaredThrowableException) {
			// UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
			// InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
			// if (iue != null) {
			// return error(iue.getCode(), iue.getMsg());
			// }
			// }
			return error(defaultCode, defaultMsg);
		} catch (Exception e2) {
			return null;
		}
	}
	/**
	 * 返回表格列表数据
	 * @param code 状态码:0成功,非0失败
	 * @param errorMsg 错误消息
	 * @param page 当前页码
	 * @param rows 分页大小
	 * @param list 查询的结果集
	 * @return
	 */
	public String write(int code, String errorMsg, int page, int rows, Page<?> list) {
		try {
			JSONObject object = new JSONObject();
			ObjectMapper mapper = new ObjectMapper();
			object.put("successFlg", code == 0);
			object.put("errorMsg", errorMsg);
			// 是否为第一页
			object.put("errorCode", code);
			// 是否为最后一页
			object.put("currPage", page);
			// 分页大小
			object.put("pageSize", rows);
			// 总条数
			object.put("totalCount", list.getTotalElements());
			// 总页数
			object.put("totalPage", list.getTotalPages());
			// 结果集
			object.put("detailModelList", list.getContent());
			 return object.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	
	public String write(int code, String errorMsg, int page, int rows, List<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("successFlg", code == 0);
			map.put("errorMsg", errorMsg);
			// 是否为第一页
			map.put("errorCode", code);
			// 是否为最后一页
			map.put("currPage", page);
			// 分页大小
			map.put("pageSize", rows);
			// 总条数
			map.put("totalCount", list.size());
			// 总页数
			map.put("totalPage", 1);
			// 结果集
			map.put("detailModelList", list);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	
	public String error(int code, String errorMsg, int page, int rows) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("successFlg", code == 0);
			map.put("errorMsg", errorMsg);
			// 是否为第一页
			map.put("errorCode", code);
			// 是否为最后一页
			map.put("currPage", page);
			// 分页大小
			map.put("pageSize", rows);
			// 总条数
			map.put("totalCount", 0);
			// 总页数
			map.put("totalPage", 0);
			// 结果集
			map.put("detailModelList", null);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
    //json串转集合
    public <T> Collection<T> jsonToEntities(String jsonDate, Collection<T> targets, Class<T> targetCls) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            List modelList = objectMapper.readValue(jsonDate,List.class);
            Iterator ex = modelList.iterator();
            while(ex.hasNext()) {
                Object aModelList = ex.next();
                String objJsonData = objectMapper.writeValueAsString(aModelList);
                T model = objectMapper.readValue(objJsonData, targetCls);
                targets.add(model);
            }
            return targets;
        } catch (Exception var8) {
            var8.printStackTrace();
            return null;
        }
    }
    public String write(int code, String errorMsg, int page, int rows, long total, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("successFlg", code == 0);
            map.put("errorMsg", errorMsg);
            // 是否为第一页
            map.put("errorCode", code);
            // 是否为最后一页
            map.put("currPage", page);
            // 分页大小
            map.put("pageSize", rows);
            // 总条数
            map.put("totalCount", total);
            // 总页数
            map.put("totalPage", Math.ceil((double)total/(rows)));
            // 结果集
            map.put("detailModelList", list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
}

+ 111 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/WlyyDeviceController.java

@ -0,0 +1,111 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.controller.common.BaseController;
import com.yihu.iot.service.device.WlyyDeviceService;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * Created by yeshijie on 2020/7/29.
 */
@RestController
@RequestMapping("svr-iot/wlyyDevice")
@Api(tags = "wlyy设备管理相关操作", description = "wlyy设备管理相关操作")
public class WlyyDeviceController extends BaseController {
    @Autowired
    private WlyyDeviceService wlyyDeviceService;
    @RequestMapping(value="deviceList",method = RequestMethod.GET)
    @ApiOperation("设备管理")
    public MixEnvelop<WlyyDeviceVO, WlyyDeviceVO> searchList(
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "orgName",required = false)String orgName,
            @RequestParam(value = "linkman",required = false) String linkman,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "size",required = false)Integer size){
        try {
            if(page==null){
                page =1;
            }
            if(size==null){
                size = 10;
            }
            return wlyyDeviceService.searchDeviceList(deviceName, deviceCode, orgName, linkman, page, size);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = "findDeviceById",method = RequestMethod.GET)
    @ApiOperation("根据设备id查找设备管理")
    public MixEnvelop<WlyyDeviceVO,WlyyDeviceVO> getDevice(@RequestParam(value = "id") Long id){
        try {
            return  wlyyDeviceService.findById(id);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value ="healthlist",method = RequestMethod.GET)
    @ApiOperation("体征数据查询")
    public String searchList(
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "date",required = false) String date,
            @RequestParam(value = "idcard",required = false) String idcard,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "indexType",required = false) String indexType,
            @RequestParam(value = "indexTypeMin1",required = false) Double indexTypeMin1,
            @RequestParam(value = "indexTypeMax1",required = false) Double indexTypeMax1,
            @RequestParam(value = "indexTypeMin2",required = false) Double indexTypeMin2,
            @RequestParam(value = "indexTypeMax2",required = false) Double indexTypeMax2,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "size",required = false) Integer size){
        try{
            Page<DeviceHealthIndexVO> deviceHealthIndexes = wlyyDeviceService.searchList(deviceSn,date, idcard, userName, indexType,page, size,indexTypeMin1, indexTypeMax1, indexTypeMin2,indexTypeMax2,doctorName);
            return write(200,"操作成功",page,size,deviceHealthIndexes);
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "patientDeviceList",method = RequestMethod.GET)
    @ApiOperation("居民设备查询")
    public String searchList(
            @RequestParam(value = "deviceName",required = false) String deviceName,
            @RequestParam(value = "categoryCode",required = false) String categoryCode,
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "userName",required = false) String userName,
            @RequestParam(value = "doctorName",required = false) String doctorName,
            @RequestParam(value = "hospitalName",required = false) String hospitalName,
            @RequestParam(value = "page") Integer page,
            @RequestParam(value = "size") Integer size) {
        try {
            String hospitalCode = "";
            List<WlyyPatientDeviceVO> patientDevices = wlyyDeviceService.searchListNew(deviceName, categoryCode, deviceSn, userName, doctorName, hospitalName, hospitalCode, page, size);
            Long totalcount = wlyyDeviceService.getCountSearchListNew(deviceName, categoryCode, deviceSn, userName, doctorName, hospitalName, hospitalCode);
            return write(200, "操作成功", page, size, totalcount, patientDevices);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败!");
        }
    }
}

+ 14 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/common/OrgUserService.java

@ -42,10 +42,23 @@ public class OrgUserService {
    public String getUserOrg(List<String> list){
        String res = "'";
        for (String s:list){
            res +=s+"'";
            res += s+"','";
        }
        if(res.length()==1){
            res +="'";
        }else{
            res = res.substring(0,res.length()-3);
        }
        return res;
    }
    public String getUserOrg2(List<String> list){
        String res = "";
        for (String s:list){
            res +=s+",";
        }
        if(res.length()>0){
            res = res.substring(0,res.length()-2);
        }
        return res;
    }

+ 21 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java

@ -8,6 +8,8 @@ import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceInventoryLogDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryLogDO;
import com.yihu.jw.entity.iot.device.IotDeviceOrderDO;
@ -43,6 +45,10 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
    private ObjectMapper objectMapper;
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 获取库存列表接口
@ -65,6 +71,13 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
        if (StringUtils.isNotBlank(hospitalName)) {
            sql += "and hospital_name like '%" + hospitalName + "%' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql += "GROUP BY d.product_id, d.manufacturer_id, d.hospital, d.category_code ";
        //判断是否需要分页
        if (page != null && pageSize != null) {
@ -83,7 +96,14 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
     * @return
     */
    public MixEnvelop getInventoryWarningHospital() {
        String sql = "select d.hospital,d.hospital_name FROM `iot_device` d where del=1 and is_grant=0 GROUP BY d.hospital";
        String sql = "select d.hospital,d.hospital_name FROM `iot_device` d where del=1 and is_grant=0 ";
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and d.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql+= " GROUP BY d.hospital";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, list);
    }

+ 17 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java

@ -6,6 +6,7 @@ import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
@ -58,6 +59,8 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
    private UserAgent userAgent;
    @Autowired
    private IotCompanyDao iotCompanyDao;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 查找采购清单
@ -247,6 +250,12 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
                filters+= ";supplier_id="+companyDO.getId();
            }
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            filters += " ;purchaseUnitCode ="+orgUserService.getUserOrg2(orgList);
        }
        String sorts = "-updateTime";
        //得到list数据
        List<IotDeviceOrderDO> list = search(null, filters, sorts, page, size);
@ -314,6 +323,14 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
            }
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql.append(" and c.purchase_unit_code in (?) ");
            sqlCount.append(" and c.purchase_unit_code in(").append(orgUserService.getUserOrg(orgList)).append(") ");
            args.add(orgUserService.getUserOrg(orgList));
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotDeviceOrderDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceOrderDO.class));

+ 19 - 5
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -5,12 +5,14 @@ import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceQualityInspectionPlanDao;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.device.IotOrderPurchaseDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.iot.device.IotDeviceQualityInspectionPlanVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
@ -21,7 +23,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author yeshijie on 2017/12/8.
@ -40,10 +44,12 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private IotDeviceDao iotDeviceDao;
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 新增
@ -228,7 +234,7 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
     * @return
     */
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> queryPage(String status, String orderNo, String startTime, String endTime, Integer page, Integer size){
        StringBuffer sql = new StringBuffer("SELECT  c.* from iot_device_quality_inspection_plan c  WHERE c.del=1 ");
        StringBuffer sql = new StringBuffer("SELECT  c.* from iot_device_quality_inspection_plan c left join iot_device_order d on d.del=1 and d.id=c.order_id  WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(status)){
@ -247,6 +253,14 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
            sql.append(" and c.plan_time<=? ");
            args.add(endTime);
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql.append(" and d.purchase_unit_code in (?) ");
            args.add(orgUserService.getUserOrg(orgList));
        }
        sql.append(" ORDER BY c.plan_time DESC ");
        StringBuffer sql1= new StringBuffer("SELECT  b.* FROM (");
        sql1.append(sql).append(") b GROUP BY b.order_no limit ").append((page-1)*size).append(",").append(size);

+ 29 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -5,7 +5,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.dao.device.*;
import com.yihu.iot.dao.product.IotProductDataTransmissionDao;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.util.excel.AExcelReader;
import com.yihu.iot.util.excel.reader.IotDeviceImportVOReader;
import com.yihu.jw.entity.iot.device.*;
@ -71,6 +73,10 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
    private IotDeviceOrderDao iotDeviceOrderDao;
    @Autowired
    private IotDeviceSimDao iotDeviceSimDao;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 新增
@ -250,6 +256,13 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
            filters += semicolon + "hospitalName?"+hospitalName+"";
            semicolon = ";";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            filters +=  semicolon +" hospital ="+orgUserService.getUserOrg2(orgList);
            semicolon = ";";
        }
        String sorts = "-updateTime";
        //得到list数据
        List<IotDeviceDO> list = search(null, filters, sorts, page, size);
@ -317,6 +330,13 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
            sqlCount.append("  and t.id is null ");
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql.append(" and c.hospital in (?) ");
            sqlCount.append(" and c.hospital in (").append(orgUserService.getUserOrg(orgList)).append(")");
            args.add(orgUserService.getUserOrg(orgList));
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
@ -340,7 +360,15 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
     * @return
     */
    public MixEnvelop<IotDeviceVO, IotDeviceVO> findDevice(Integer page, Integer size) {
        String sql ="SELECT DISTINCT c.* from iot_device c left join iot_patient_device t on t.del = 1 AND c.device_sn = t.device_sn  WHERE c.del=1 GROUP BY c.`name`";
        String sql ="SELECT DISTINCT c.* from iot_device c left join iot_patient_device t on t.del = 1 AND c.device_sn = t.device_sn  WHERE c.del=1 ";
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and c.hospital in ("+orgUserService.getUserOrg(orgList)+")";
        }
        sql += " GROUP BY c.`name`";
        List<IotDeviceDO> list = jdbcTempalte.query(sql,new BeanPropertyRowMapper(IotDeviceDO.class));
        //DO转VO

+ 14 - 5
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java

@ -5,16 +5,13 @@ import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceSimDao;
import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceQualityInspectionPlanDO;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.platform.IotInterfaceAuditDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
import com.yihu.jw.restmodel.iot.dict.IotSystemDictVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.http.HttpClientUtil;
@ -54,6 +51,10 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    @Autowired
    private HttpClientUtil httpClientUtil;
@ -144,6 +145,14 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
            sql.append(" and (c.device_sn like '%").append(sn).append("%')");
            sqlCount.append(" and (c.device_sn like '%").append(sn).append("%')");
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql.append(" and d.hospital in (").append(orgUserService.getUserOrg(orgList)).append(")");
            sqlCount.append(" and d.hospital in (").append(orgUserService.getUserOrg(orgList)).append(")");
        }
        sql.append(" order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
//        List<IotDeviceSimDO> list = jdbcTemplate.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceSimDO.class));

+ 13 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceTransfersService.java

@ -2,6 +2,8 @@ package com.yihu.iot.service.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.dao.device.IotDeviceTransfersDao;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.device.IotDeviceTransfersDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -28,6 +30,10 @@ public class IotDeviceTransfersService extends BaseJpaService<IotDeviceTransfers
    private ObjectMapper objectMapper;
    @Autowired
    private IotDeviceTransfersDao deviceTransfersDao;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 获取调拨申请列表
@ -46,6 +52,13 @@ public class IotDeviceTransfersService extends BaseJpaService<IotDeviceTransfers
        if (StringUtils.isNotBlank(categoryCode)) {
            sql += "and t.category_code = '" + categoryCode + "' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and d.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql += "ORDER BY t.update_time desc ";
        //判断是否需要分页
        if (page != null && pageSize != null) {

+ 16 - 3
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -472,6 +472,12 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
            sql+= " and c.ehr_user_id='"+userAgent.getUID()+"' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and p.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql +=" GROUP BY p.device_sn ORDER BY p.update_time desc ";
        if (page != null && pageSize != null) {
            Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
@ -514,6 +520,13 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        if(StringUtils.isNotBlank(patientName)){
            sql += "and d.patient_name like '%" + patientName + "%' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql +=" and d.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql += "order by o.update_time desc ";
        //判断是否需要分页
        if (page != null && pageSize != null) {
@ -549,9 +562,9 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
            sql += "and d.hospital_name like '%" + hospitalName + "%' ";
        }
        //数据权限过滤
        List<String> list = orgUserService.getUserOrgById(userAgent.getUID());
        if(!list.contains(userAgent.commonHospital)){
            sql += " and d.hospital in ("+orgUserService.getUserOrg(list)+") ";
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and d.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql += "order by d.update_time desc ";
        //判断是否需要分页

+ 345 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/WlyyDeviceService.java

@ -0,0 +1,345 @@
package com.yihu.iot.service.device;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.restmodel.iot.device.DeviceHealthIndexVO;
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
import com.yihu.jw.restmodel.iot.device.WlyyHealthStandardVO;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
/**
 * Created by ysj on 2020/07/29
 * device数据库
 */
@Service
public class WlyyDeviceService {
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;//3.9
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;//6.1
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;//4.4
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;//7.8
    // 舒张压最小值
    public static final double HEALTH_STANDARD_SZY_MIN = 60;//60
    // 舒张压最大值
    public static final double HEALTH_STANDARD_SZY_MAX = 90;//89
    // 收缩压最小值
    public static final double HEALTH_STANDARD_SSY_MIN = 90;//90
    // 收缩压最大值
    public static final double HEALTH_STANDARD_SSY_MAX = 140;//139
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    public MixEnvelop<WlyyDeviceVO,WlyyDeviceVO> searchDeviceList(String deviceName,String deviceCode,String orgName,String linkman,Integer page,Integer pageSize){
        String sql = "select * from device.wlyy_devices where 1=1 ";
        if(!StringUtils.isEmpty(orgName)){
            sql +=" and org_name like '%"+orgName+"%' ";
        }
        if(!StringUtils.isEmpty(deviceCode)){
            sql +=" and device_code = '"+deviceCode+"' ";
        }
        if(!StringUtils.isEmpty(deviceName)){
            sql +=" and device_name like '%"+deviceName+"%' ";
        }
        if(!StringUtils.isEmpty(linkman)){
            sql +=" and linkmam like '%"+linkman+"%' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgNameById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospitalName)){
            sql += " and org_name in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql += " order by id desc ";
        Long count = Long.valueOf(jdbcTemplate.queryForList(sql).size());
        sql += "limit " + (page - 1) * pageSize + "," + pageSize;
        List<WlyyDeviceVO> deviceVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WlyyDeviceVO.class));
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, deviceVOList, page, pageSize, count);
    }
    public MixEnvelop<WlyyDeviceVO,WlyyDeviceVO> findById(Long id){
        String sql = "select * from device.wlyy_devices where id = "+id;
        List<WlyyDeviceVO> deviceVOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WlyyDeviceVO.class));
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,deviceVOList.get(0));
    }
    public Page<DeviceHealthIndexVO> searchList(String deviceSn, String date, String idcard, String userName, String indexType, Integer page, Integer pageSize,
                                                 Double indexTypeMin1, Double indexTypeMax1, Double indexTypeMin2, Double indexTypeMax2, String doctorName)throws Exception{
        if (page == null){
            page = 1;
        }
        if(pageSize == null){
            pageSize = 15;
        }
        Pageable pageRequest = new PageRequest(page-1,pageSize);
        StringBuilder filter = new StringBuilder();
        String sql =" SELECT i.* ,p.name userName FROM device.wlyy_patient_health_index i left join wlyy.wlyy_sign_family s on i.`user` = s. patient and s.`status`>0, wlyy.wlyy_patient p WHERE i.user=p.code ";
        String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i left join wlyy.wlyy_sign_family s on i.`user` = s. patient and s.`status`>0, wlyy.wlyy_patient p WHERE i.user=p.code ";
        //根据患者名称过滤
        if(!StringUtils.isEmpty(userName)){
            filter.append(" AND p.name LIKE '%"+userName+"%' ");
        }
        if(!StringUtils.isEmpty(deviceSn)){
            filter.append(" and i.device_sn='"+deviceSn+"' ");
        }
        if(!StringUtils.isEmpty(idcard)){
            filter.append(" and i.idcard='"+idcard+"' ");
        }
        //体征数据创建时间
        if(!StringUtils.isEmpty(date)){
            Date startTimeTemp  =  DateUtil.simpleDateParse(date);
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(startTimeTemp);
            calendar.set(Calendar.HOUR,23);
            calendar.set(Calendar.MINUTE,59);
            calendar.set(Calendar.SECOND,59);
            calendar.set(Calendar.MILLISECOND,999);
            Date endTimeTemp = calendar.getTime();
            filter.append(" and i.czrq>='" + DateUtil.simpleDateTimeFormat(startTimeTemp)+"'");
            filter.append(" and i.czrq<='" + DateUtil.simpleDateTimeFormat(endTimeTemp)+"'");
        }
        //指标类型
        if(!StringUtils.isEmpty(indexType)){
            filter.append(" and i.type="+indexType);
        }
        //体征数据
        if(indexTypeMin1!=null){
            filter.append(" and value1>="+indexTypeMin1);
        }
        if(indexTypeMax1!=null){
            filter.append(" and value1<="+indexTypeMax1);
        }
        if(indexTypeMin2!=null){
            filter.append(" and value2>="+indexTypeMin2);
        }
        if(indexTypeMax2!=null){
            filter.append(" and value2<="+indexTypeMax2);
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and s.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        String f = filter.toString();
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql+f+" order by i.czrq desc "+" limit "+(page-1)*pageSize+","+pageSize);
        if(resultList.size()<=0){
            return new PageImpl<DeviceHealthIndexVO>(new ArrayList<>(), pageRequest, 0);
        }
        long count = 0;
        String regex = "(\\w{3})(\\w+)(\\w{3})";
        List<DeviceHealthIndexVO> listTemp = new ArrayList<>();
        if(resultList !=null && resultList.size()>0){
//            count = getCount(filter.toString());
            count = jdbcTemplate.queryForObject(countSql+filter.toString(),Long.class);
            for (Map<String, Object> info : resultList){
                DeviceHealthIndexVO bean = new DeviceHealthIndexVO();
                bean.setId(Long.getLong(info.get("id")+""));
                bean.setCzrq(info.get("czrq")!=null?(Date)info.get("czrq"):null);
                bean.setDel(info.get("del")!=null?info.get("del")+"":null);
                bean.setDeviceSn(info.get("device_sn")!=null?info.get("device_sn")+"":null);
                bean.setIdcard(info.get("idcard")!=null?info.get("idcard")+"":null);
                bean.setIntervene(info.get("intervene")!=null?info.get("intervene")+"":null);
                bean.setRecordDate(info.get("record_date")!=null?(Date)info.get("record_date"):null);
                bean.setSortDate(info.get("sort_date")!=null?(Date)info.get("sort_date"):null);
                bean.setStatus(info.get("status")!=null?(Integer)info.get("status"):null);
                bean.setType(info.get("type")!=null?(Integer)info.get("type"):0);
                bean.setUser(info.get("user")!=null?info.get("user")+"":null);
                bean.setUserName(info.get("userName")!=null?info.get("userName")+"":null);
                bean.setValue1(info.get("value1")!=null?info.get("value1")+"":null);
                bean.setValue2(info.get("value2")!=null?info.get("value2")+"":null);
                bean.setValue3(info.get("value3")!=null?info.get("value3")+"":null);
                bean.setValue4(info.get("value4")!=null?info.get("value4")+"":null);
                bean.setValue5(info.get("value5")!=null?info.get("value5")+"":null);
                bean.setValue6(info.get("value6")!=null?info.get("value6")+"":null);
                bean.setValue7(info.get("value7")!=null?info.get("value7")+"":null);
                if(StringUtils.isNotBlank(bean.getIdcard())){
                    bean.setIdcard(bean.getIdcard().replaceAll(regex, "$1****$3"));
                }
                bean.setHealthStandard(gethealthStandard(bean.getType(),bean.getUser()).toString());
                listTemp.add(bean);
            }
        }
        return new PageImpl<DeviceHealthIndexVO>(listTemp,pageRequest,count);
    }
    private WlyyHealthStandardVO findStandard(String patient,Integer type){
        String sql = "select id,type,patient,min_value_1 minValue1,doctor,czrq,max_value_1 maxValue1,min_value_2 minValue2,max_value_2 maxValue2" +
                " from wlyy.wlyy_patient_health_standard where patient = '"+patient+"' and type = "+type;
        List<WlyyHealthStandardVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WlyyHealthStandardVO.class));
        if(list.size()>0){
            return list.get(0);
        }
        return null;
    }
    public JSONObject gethealthStandard(Integer type, String patientCode) {
        //血糖校验
        JSONObject json = new JSONObject();
        if (type == 1) {
            // 血糖记录,查询患者血糖预警值
            WlyyHealthStandardVO standard = findStandard(patientCode, 1);
            Double maxValueBefore = HEALTH_STANDARD_ST_MAX_BEFORE;
            Double minValueBefore = HEALTH_STANDARD_ST_MIN_BEFORE;
            Double maxValueAfter = HEALTH_STANDARD_ST_MAX_AFTER;
            Double minValueAfter = HEALTH_STANDARD_ST_MIN_AFTER;
            if (standard != null) {
                if (standard.getMaxValue1() > 0) {
                    maxValueBefore = standard.getMaxValue1();
                }
                if (standard.getMinValue1() > 0) {
                    minValueBefore = standard.getMinValue1();
                }
                if (standard.getMaxValue2() > 0) {
                    maxValueAfter = standard.getMaxValue2();
                }
                if (standard.getMinValue2() > 0) {
                    minValueAfter = standard.getMinValue2();
                }
            }
            json.put("maxValueAfter", maxValueAfter);
            json.put("maxValueBefore", maxValueBefore);
            json.put("minValueBefore", minValueBefore);
            json.put("minValueAfter", minValueAfter);
        }
        //血压校验
        else if (type == 2) {
            // 血压记录,查询患者血压预警值
            WlyyHealthStandardVO standard = findStandard(patientCode, 2);
            Double maxValueSSY = HEALTH_STANDARD_SSY_MAX;
            Double minValueSSY = HEALTH_STANDARD_SSY_MIN;
            Double maxValueSZY = HEALTH_STANDARD_SZY_MAX;
            Double minValueSZY = HEALTH_STANDARD_SZY_MIN;
            if (standard != null) {
                if (standard.getMaxValue1() > 0) {
                    maxValueSSY = standard.getMaxValue1();
                }
                if (standard.getMinValue1() > 0) {
                    minValueSSY = standard.getMinValue1();
                }
                if (standard.getMaxValue2() > 0) {
                    maxValueSZY = standard.getMaxValue2();
                }
                if (standard.getMinValue2() > 0) {
                    minValueSZY = standard.getMinValue2();
                }
            }
            json.put("minValueSZY", minValueSZY);
            json.put("maxValueSZY", maxValueSZY);
            json.put("minValueSSY", minValueSSY);
            json.put("maxValueSSY", maxValueSSY);
        }
        return json;
    }
    public List<WlyyPatientDeviceVO> searchListNew(String deviceName,
                                                   String categoryCode,
                                                   String deviceSn,
                                                   String userName,
                                                   String doctorName,
                                                   String hospitalName,
                                                   String hospitalCode,
                                                   Integer page, Integer pageSize) throws Exception{
        List<WlyyPatientDeviceVO> list = new ArrayList<>();
        String sql = "SELECT d.id as id,d.device_id as deviceId,d.user as user,p.name as userName,d.category_code as categoryCode,d.device_name as deviceName," +
                "d.device_sn as deviceSn,d.sim as sim,d.user_type as userType,p.mobile," +
                "CONCAT(LEFT (p.idcard,6),'**********',RIGHT (p.idcard,2)) userIdcard,d.czrq as czrq,s.doctor,s.doctor_name doctorName " +
                "FROM wlyy.wlyy_patient_device d left join wlyy.wlyy_sign_family s on d.`user` = s. patient and s.`status`>0,wlyy.wlyy_patient p " +
                "WHERE d.`user`=p.CODE ";
        if(StringUtils.isNotBlank(userName)){
            sql = sql + "AND p.name like '%"+userName+"%' ";
        }
        if(StringUtils.isNotBlank(deviceSn)){
            sql = sql + "AND d.device_sn like '%"+deviceSn+"%' ";
        }
        if(StringUtils.isNotBlank(categoryCode)){
            sql = sql + "AND d.category_code like '%"+categoryCode+"%' ";
        }
        if(StringUtils.isNotBlank(deviceName)){
            sql = sql + "AND d.device_name like '%"+deviceName+"%' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and s.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        sql = sql+"ORDER BY d.id DESC limit " + (page-1)*pageSize+", "+pageSize;
        list =  jdbcTemplate.query(sql,new BeanPropertyRowMapper(WlyyPatientDeviceVO.class));
        return list ;
    }
    public Long getCountSearchListNew(String deviceName, String categoryCode, String deviceSn, String userName, String doctorName, String hospitalName,String hospitalCode) {
        String sql  = "SELECT count(d.id) " +
                "FROM " +
                " wlyy.wlyy_patient_device d left join wlyy.wlyy_sign_family s on d.`user` = s. patient and s.`status`>0," +
                " wlyy.wlyy_patient p " +
                "WHERE " +
                " d.`user`=p.CODE ";
        if(StringUtils.isNotBlank(userName)){
            sql = sql + "AND p.name like '%"+doctorName+"%' ";
        }
        if(StringUtils.isNotBlank(deviceSn)){
            sql = sql + "AND d.device_sn like '%"+deviceSn+"%' ";
        }
        if(StringUtils.isNotBlank(categoryCode)){
            sql = sql + "AND d.category_code like '%"+categoryCode+"%' ";
        }
        if(StringUtils.isNotBlank(deviceName)){
            sql = sql + "AND d.device_name like '%"+deviceName+"%' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " and s.hospital in ("+orgUserService.getUserOrg(orgList)+") ";
        }
        Long total = jdbcTemplate.queryForObject(sql, Long.class);
        return total ;
    }
}

+ 13 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotHospitalService.java

@ -1,6 +1,8 @@
package com.yihu.iot.service.dict;
import com.yihu.iot.dao.dict.IotHospitalDao;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.dict.IotHospitalDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -22,6 +24,10 @@ public class IotHospitalService extends BaseJpaService<IotHospitalDO, IotHospita
    private IotHospitalDao hospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private OrgUserService orgUserService;
    public MixEnvelop create(IotHospitalDO hospitalDO) {
        //判断该单位是否已添加
@ -43,6 +49,13 @@ public class IotHospitalService extends BaseJpaService<IotHospitalDO, IotHospita
        if(StringUtils.isNotBlank(level)){
            sql += "and h.level = '" + level + "' ";
        }
        //数据权限过滤
        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID());
        if(!orgList.contains(userAgent.commonHospital)){
            sql += " h.hospital in ("+orgUserService.getUserOrg(orgList)+")";
        }
        if(page != null && pageSize != null){
            Long count = Long.valueOf(jdbcTemplate.queryForList(sql).size());
            sql += "limit " + (page-1)*pageSize + "," + pageSize;