Browse Source

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

mengkang 5 years ago
parent
commit
650fb673d1
37 changed files with 1023 additions and 28 deletions
  1. 19 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 3 3
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  3. 6 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  4. 32 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/SurveyScreenResultVo.java
  5. 13 1
      gateway/ag-basic/src/main/resources/application.yml
  6. 7 0
      gateway/ag-basic/src/main/resources/bootstrap.yml
  7. 25 0
      server/svr-authentication/src/main/resources/application.yml
  8. 8 0
      server/svr-authentication/src/main/resources/bootstrap.yml
  9. 14 0
      server/svr-configuration/src/main/resources/bootstrap.yml
  10. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java
  11. 45 0
      svr/svr-base/src/main/resources/application.yml
  12. 8 0
      svr/svr-base/src/main/resources/bootstrap.yml
  13. 24 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  14. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  15. 1 1
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/DeviceQualityPlanJob.java
  16. 32 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/InventoryWarningJob.java
  17. 1 2
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/SimBalanceJob.java
  18. 1 2
      svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/SimSetMealJob.java
  19. 11 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/repository/product/ProductBaseInfoDao.java
  20. 1 1
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/DeviceQualityPlanService.java
  21. 44 0
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/device/InventoryWarningService.java
  22. 1 1
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/SimBalanceService.java
  23. 1 3
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/SimSetMealService.java
  24. 3 3
      svr/svr-iot-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  25. 15 1
      svr/svr-iot-job/src/main/resources/application.yml
  26. 8 0
      svr/svr-iot-job/src/main/resources/bootstrap.yml
  27. 17 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/common/IotSystemDictController.java
  28. 208 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java
  29. 13 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java
  30. 3 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/dict/IotSystemDictDao.java
  31. 1 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/product/IotProductBaseInfoDao.java
  32. 1 2
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java
  33. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotSystemDictService.java
  34. 392 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java
  35. 9 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoService.java
  36. 32 1
      svr/svr-iot/src/main/resources/application.yml
  37. 11 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java

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

@ -3292,7 +3292,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        
        //获取今天的排班列表
        String doctorsql ="SELECT doctor,doctor_name,dept,dept_name FROM wlyy_doctor_work_time WHERE date='"+date+"'";
        String doctorsql ="SELECT doctor AS \"doctor\",doctor_name as \"doctor_name\",dept as \"dept\",dept_name as \"dept_name\" FROM wlyy_doctor_work_time WHERE work_date='"+date+"'";
        
        if(StringUtils.isNoneBlank(dept)){
            doctorsql = doctorsql + " and dept = '"+dept+"' ";
@ -4843,9 +4843,24 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param patient
     * @return
     */
	public List<Map<String,Object>> getTodayOutpatinetList(String patient) {
        String sql ="SELECT date_format(p.register_date ,'%Y-%m-%d %H:%i:%S' ) AS time,d.NAME as doctorName,d.job_title_name,d.photo AS photo,p.id as outpatientid FROM wlyy_outpatient p,base_doctor d " +
                "WHERE p.patient='"+patient+"' AND p.doctor=d.id AND p.status=0 AND p.register_date BETWEEN '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' AND '"+DateUtil.dateToStrShort(new Date())+" 23:59:59'";
	public List<Map<String,Object>> getTodayOutpatinetList(String patient,String wxId) {
	    String condition = "";
        if("xm_ykyy_wx".equals(wxId)){
            condition = "to_char(p.register_date,'YYYY-MM-DD hh24:mi:ss')  AS \"time\",";
        }else{
            condition ="date_format(p.register_date,'%Y-%m-%d %H:%i:%S' )  AS \"time\",";
        }
        String sql ="SELECT "+condition+"d.NAME as \"doctorName\",d.job_title_name as \"job_title_name\",d.photo AS \"photo\",p.id as \"outpatientid\" FROM wlyy_outpatient p,base_doctor d " +
                "WHERE p.patient='"+patient+"' AND p.doctor=d.id AND p.status=0 ";
        if("xm_ykyy_wx".equals(wxId)){
            sql +=" AND p.register_date >= to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
            sql +=" AND p.register_date <= to_date('"+DateUtil.dateToStrShort(new Date())+" 23:59:59','YYYY-MM-DD HH24:MI:SS')";
        }else {
            sql +=" BETWEEN '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' AND '"+DateUtil.dateToStrShort(new Date())+" 23:59:59' ";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
	}

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

@ -19,13 +19,13 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
/*    @GeneratedValue(generator = "generator")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)*/
    @Column(name = "id", unique = true, nullable = false)
//==========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;

+ 6 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -27,6 +27,7 @@ public class IotRequestMapping {
        public static final String workType = api_iot_common + "/workType";
        public static final String hospital = api_iot_common + "/hospital";
        public static final String interfaceAudit = api_iot_common + "/interfaceAudit";
        public static final String monitorPlatform = api_iot_common + "/monitorPlatform";
        public static final String sim = api_iot_common + "/sim";
@ -48,6 +49,7 @@ public class IotRequestMapping {
    public static class System{
        public static final String findDictByCode = "findDictByCode";
        public static final String createDict = "createDict";
        public static final String getListByParentCode = "getListByParentCode";
    }
    /**
@ -123,6 +125,9 @@ public class IotRequestMapping {
    }
    public static class MonitorPlatform{
    }
    /**
     * 产品模块常量
@ -139,6 +144,7 @@ public class IotRequestMapping {
        public static final String maintenanceUnitById = "maintenanceUnitById";
        public static final String setInventoryById = "setInventoryById";
        public static final String findAll = "findAll";
        public static final String findListByCategoryCode = "findListByCategoryCode";
    }

+ 32 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/SurveyScreenResultVo.java

@ -120,6 +120,14 @@ public class SurveyScreenResultVo{
    @ApiModelProperty("第三方返回的筛查建议")
    private String thirdAdvice;
    //转诊信息
    @ApiModelProperty("预约医生")
    private String doctorNameReservation;
    @ApiModelProperty("挂号时间")
    private String czrqReservation;
    @ApiModelProperty("就诊时间")
    private String startTimeReservation;
    public SurveyScreenResultVo() {
    }
@ -410,4 +418,28 @@ public class SurveyScreenResultVo{
    public void setIsThird(String isThird) {
        this.isThird = isThird;
    }
    public String getDoctorNameReservation() {
        return doctorNameReservation;
    }
    public void setDoctorNameReservation(String doctorNameReservation) {
        this.doctorNameReservation = doctorNameReservation;
    }
    public String getCzrqReservation() {
        return czrqReservation;
    }
    public void setCzrqReservation(String czrqReservation) {
        this.czrqReservation = czrqReservation;
    }
    public String getStartTimeReservation() {
        return startTimeReservation;
    }
    public void setStartTimeReservation(String startTimeReservation) {
        this.startTimeReservation = startTimeReservation;
    }
}

+ 13 - 1
gateway/ag-basic/src/main/resources/application.yml

@ -176,4 +176,16 @@ spring:
  redis:
    host: 59.61.92.90 # Redis server host.
    port: 9054  # Redis server port.
    password: jkzlehr
    password: jkzlehr
---
spring:
  profiles: iotprod
  datasource:
     url: jdbc:mysql://59.61.92.90:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     username: wlyy
     password: jkzlehr@123
  redis:
     host: 59.61.92.90 # Redis server host.
     port: 9054  # Redis server port.
     password: jkzlehr

+ 7 - 0
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -89,4 +89,11 @@ spring:
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://10.95.22.193:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.174:1221}
      label: ${wlyy.spring.config.label:master}

+ 25 - 0
server/svr-authentication/src/main/resources/application.yml

@ -234,4 +234,29 @@ wlyy:
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 1
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://59.61.92.90:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy
    password: jkzlehr@123
  redis:
    host: 59.61.92.90 # Redis server host.
    port: 9054  # Redis server port.
    password: jkzlehr
  ##发现服务
## i健康用户信息接口,开放出来给互联网医院登录同步用户信息用
iHealth:
  user-info-uri: http://ehr.yihu.com/wlyy/iHealth/userInfo
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
wlyy:
  url: http://www.xmtyw.cn/wlyy/
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream

+ 8 - 0
server/svr-authentication/src/main/resources/bootstrap.yml

@ -91,3 +91,11 @@ spring:
    config:
      uri: ${wlyy.pring.config.uri:http://10.95.22.193:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.174:1221}
      label: ${wlyy.spring.config.label:master}

+ 14 - 0
server/svr-configuration/src/main/resources/bootstrap.yml

@ -125,4 +125,18 @@ spring:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.120.210:3000/jkzl/config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:master}
---
## 物联网
spring:
  profiles: iotprod
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.120.216:10010/jkzl/config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:master}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -234,7 +234,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
    }
    
    public com.alibaba.fastjson.JSONObject findDoctorPwlimitDate(String user){
        String key = "base:authPw:iser:" + user;
        String key = "base:authPw:user:" + user;
        String authPw = redisTemplate.opsForValue().get(key);
        com.alibaba.fastjson.JSONObject valueJson = null;
        if(org.apache.commons.lang3.StringUtils.isNotBlank(authPw)){

+ 45 - 0
svr/svr-base/src/main/resources/application.yml

@ -284,6 +284,51 @@ wlyy:
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://59.61.92.90:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
#    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
#    username: root
#    password: 123456
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 59.61.92.90:20010,59.61.92.90:20012 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://59.61.92.90:20009,http://59.61.92.90:20011
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://172.19.103.87:61616
    user: admin
    password: admin
  redis:
    host: 59.61.92.90 # Redis server host.
    port: 9054  # Redis server port.
    password: jkzlehr
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream

+ 8 - 0
svr/svr-base/src/main/resources/bootstrap.yml

@ -57,3 +57,11 @@ spring:
    config:
      uri: ${wlyy.pring.config.uri:http://10.95.22.193:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.109:1221}
      label: ${wlyy.spring.config.label:master}

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

@ -3,7 +3,9 @@ package com.yihu.jw.hospital.endpoint.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dict.service.BaseDictJobTitleService;
import com.yihu.jw.dict.service.HospitalDeptService;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
@ -80,6 +82,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private HospitalDeptService hospitalDeptService;
@ -137,7 +141,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "居民获取当日就诊列表", notes = "居民获取当日就诊列表")
    public ListEnvelop getTodayOutpatinetList(@ApiParam(name = "patient", value = "居民ID")
                                              @RequestParam(value = "patient", required = true) String patient){
        return success(prescriptionService.getTodayOutpatinetList(patient));
        return success(prescriptionService.getTodayOutpatinetList(patient,wxId));
    }
@ -189,6 +193,25 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        return success("请求成功",consultCode);
    }
    /**
     * 根据机构编码获取部门列表信息
     * @param orgCode
     * @return
     */
    @GetMapping(value = "/getDeptByOrgCode")
    @ApiOperation(value = "根据机构编码获取部门列表信息", notes = "基础数据获取")
    public Envelop getDeptByOrgCode(
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "consultDeptFlag", value = "是否是就诊科室,1为查询门诊,不传为全部")
            @RequestParam(value = "consultDeptFlag", required = false) String consultDeptFlag)  {
        List<DictHospitalDeptDO> res =  hospitalDeptService.getHosDeptByCode(orgCode,consultDeptFlag);
        if(res != null && res.size() > 0 ){
            return  success(res);
        }else{
            return success("无法获取该机构的部门列表信息!");
        }
    }
    /**
     * 获取机构职称信息

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

@ -796,7 +796,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "居民获取当日就诊列表", notes = "居民获取当日就诊列表")
    public ListEnvelop getTodayOutpatinetList(@ApiParam(name = "patient", value = "居民ID")
                                                  @RequestParam(value = "patient", required = true) String patient){
        return success(prescriptionService.getTodayOutpatinetList(patient));
        return success(prescriptionService.getTodayOutpatinetList(patient,wxId));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDoctorMapping)

+ 1 - 1
svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/DeviceQualityPlanJob.java

@ -1,6 +1,6 @@
package com.yihu.jw.job.wlw;
import com.yihu.jw.service.channel.DeviceQualityPlanService;
import com.yihu.jw.service.device.DeviceQualityPlanService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

+ 32 - 0
svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/InventoryWarningJob.java

@ -0,0 +1,32 @@
package com.yihu.jw.job.wlw;
import com.yihu.jw.service.device.InventoryWarningService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 库存预警提醒
 * create by hmf on 2020/5/13
 */
public class InventoryWarningJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(InventoryWarningJob.class);
    @Autowired
    private InventoryWarningService inventoryWarningService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========InventoryWarningJob========");
        try {
            inventoryWarningService.remind();
            logger.info("END========InventoryWarningJob========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===InventoryWarningJob,message:"+e.getMessage());
        }
    }
}

+ 1 - 2
svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/SimBalanceJob.java

@ -1,7 +1,6 @@
package com.yihu.jw.job.wlw;
import com.yihu.jw.service.channel.DeviceQualityPlanService;
import com.yihu.jw.service.channel.SimBalanceService;
import com.yihu.jw.service.device.SimBalanceService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

+ 1 - 2
svr/svr-iot-job/src/main/java/com/yihu/jw/job/wlw/SimSetMealJob.java

@ -1,7 +1,6 @@
package com.yihu.jw.job.wlw;
import com.yihu.jw.service.channel.DeviceQualityPlanService;
import com.yihu.jw.service.channel.SimSetMealService;
import com.yihu.jw.service.device.SimSetMealService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

+ 11 - 0
svr/svr-iot-job/src/main/java/com/yihu/jw/repository/product/ProductBaseInfoDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.repository.product;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface ProductBaseInfoDao extends PagingAndSortingRepository<IotProductBaseInfoDO,String>,
        JpaSpecificationExecutor<IotProductBaseInfoDO> {
}

+ 1 - 1
svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/DeviceQualityPlanService.java

@ -1,4 +1,4 @@
package com.yihu.jw.service.channel;
package com.yihu.jw.service.device;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.message.IotMessageDao;

+ 44 - 0
svr/svr-iot-job/src/main/java/com/yihu/jw/service/device/InventoryWarningService.java

@ -0,0 +1,44 @@
package com.yihu.jw.service.device;
import com.yihu.iot.dao.message.IotMessageDao;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/*
 * 库存预警提醒相关逻辑
 * create by hmf on 2020/5/13
 */
@Service
public class InventoryWarningService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private IotMessageDao iotMessageDao;
    public void remind() {
        String sql = "select d.product_id,d.`name`,d.category_code,d.category_name,d.manufacturer_id,d.manufacturer_name,d.hospital,d.hospital_name,count(d.id) inventoryCount ,p.inventory_floor,p.inventory_upper " +
                "FROM `iot_device` d LEFT JOIN iot_product_base_info p on d.product_id = p.id and p.del = 1 where p.del=1 and is_grant=0 GROUP BY d.product_id, d.manufacturer_id, d.hospital, d.category_code ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : list){
            Integer inventoryCount = map.get("inventoryCount") == null ? 0: Integer.parseInt(map.get("inventoryCount") + "");
            Integer inventoryFloor = map.get("inventory_floor") == null ? 0: Integer.parseInt(map.get("inventory_floor") + "");
            Integer inventoryUpper = map.get("inventory_upper") == null ? 0: Integer.parseInt(map.get("inventory_upper") + "");
            if(inventoryCount < inventoryFloor || inventoryCount > inventoryUpper){
                IotMessageDO iotMessageDO = new IotMessageDO();
                iotMessageDO.setTitle("库存预警提醒");
                iotMessageDO.setContent("您的库存" + map.get("name") + "设备已达到预警数量,当前数量为:" + inventoryCount + "台,请及时维护库存。");
                iotMessageDO.setReadMsg(0);
                iotMessageDO.setDel(0);
                iotMessageDO.setType(2);
                iotMessageDao.save(iotMessageDO);
            }
        }
    }
}

+ 1 - 1
svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/SimBalanceService.java

@ -1,4 +1,4 @@
package com.yihu.jw.service.channel;
package com.yihu.jw.service.device;
import com.yihu.iot.dao.device.IotDeviceSimDao;
import com.yihu.iot.dao.dict.IotSystemDictDao;

+ 1 - 3
svr/svr-iot-job/src/main/java/com/yihu/jw/service/channel/SimSetMealService.java

@ -1,9 +1,7 @@
package com.yihu.jw.service.channel;
package com.yihu.jw.service.device;
import com.yihu.iot.dao.device.IotDeviceSimDao;
import com.yihu.jw.entity.iot.device.IotDeviceSimDO;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.message.IotMessageDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

+ 3 - 3
svr/svr-iot-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -9,9 +9,9 @@ import com.yihu.jw.job.wlw.DeviceQualityPlanJob;
import com.yihu.jw.job.wlw.SimBalanceJob;
import com.yihu.jw.job.wlw.SimSetMealJob;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.channel.DeviceQualityPlanService;
import com.yihu.jw.service.channel.SimBalanceService;
import com.yihu.jw.service.channel.SimSetMealService;
import com.yihu.jw.service.device.DeviceQualityPlanService;
import com.yihu.jw.service.device.SimBalanceService;
import com.yihu.jw.service.device.SimSetMealService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.web.BaseController;

+ 15 - 1
svr/svr-iot-job/src/main/resources/application.yml

@ -93,7 +93,7 @@ wechat:
---
spring:
  profiles: jwtest
  profiles: iottest
  datasource:
    url: jdbc:mysql://172.26.0.104/xmiot?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: ssgg
@ -285,3 +285,17 @@ wlyy:
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
---
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://59.61.92.90:20002/xmiot?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
  redis:
    host: 59.61.92.90 # Redis server host.
    port: 9054  # Redis server port.
    password: jkzlehr
wlyy:
  url: http://www.xmtyw.cn/wlyy/

+ 8 - 0
svr/svr-iot-job/src/main/resources/bootstrap.yml

@ -59,3 +59,11 @@ spring:
    config:
      uri: ${wlyy.pring.config.uri:http://172.16.100.63:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.174:1221}
      label: ${wlyy.spring.config.label:master}

+ 17 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/common/IotSystemDictController.java

@ -1,5 +1,6 @@
package com.yihu.iot.controller.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -39,6 +40,21 @@ public class IotSystemDictController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = IotRequestMapping.System.getListByParentCode)
    @ApiOperation(value = "查询子类字典")
    public MixEnvelop<JSONObject, JSONObject> getListByParentCode(
            @ApiParam(name = "parentCode", value = "父类字典id", defaultValue = "402803f271b9583b0171b95b34e10001")
            @RequestParam(value = "parentCode", required = true) String parentCode) throws Exception {
        try {
            List<JSONObject> doList = iotSystemDictService.getListByParentCode("'"+parentCode.replace(",","','")+"'");
            return MixEnvelop.getSuccessList(IotRequestMapping.Company.message_success_find_functions,doList);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = IotRequestMapping.System.createDict)
    @ApiOperation(value = "创建字典", notes = "创建字典")
    public MixEnvelop<IotSystemDictDO, IotSystemDictDO> create(@ApiParam(name = "jsonData", value = "字典json", defaultValue = "{\"value\":\"血糖仪\", \"dictName\":\"DEVICE_TYPE\"}")
@ -52,4 +68,5 @@ public class IotSystemDictController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 208 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -0,0 +1,208 @@
package com.yihu.iot.controller.monitorPlatform;
import com.yihu.iot.service.monitorPlatform.MonitorPlatformService;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2020/5/11.
 */
@RestController
@RequestMapping(IotRequestMapping.Common.monitorPlatform)
@Api(tags = "健康监测平台相关操作", description = "大屏数据相关操作")
public class MonitorPlatformController extends EnvelopRestEndpoint {
    @Autowired
    private MonitorPlatformService monitorPlatformService;
    @RequestMapping(value = "/smartDeviceDistribution",method = RequestMethod.GET)
    @ApiOperation("智能设备发放")
    public MixEnvelop smartDeviceDistribution(@ApiParam(name="type",value="设备类型")
                                              @RequestParam(value="type",required = false) String type,
                                              @ApiParam(name="name",value="产品名称")
                                              @RequestParam(value="name",required = false) String name){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.smartDeviceDistribution(type,name));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/datafiltering",method = RequestMethod.GET)
    @ApiOperation("数据筛选")
    public MixEnvelop datafiltering(@ApiParam(name="name",value="设备sn码或居民姓名")
                                @RequestParam(value="name",required = false) String name){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.datafiltering(name));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/deviceUsageAnalysis",method = RequestMethod.GET)
    @ApiOperation("设备使用情况分析")
    public MixEnvelop deviceUsageAnalysis(@ApiParam(name="type",value="设备类型")
                                              @RequestParam(value="type",required = false) String type,
                                          @ApiParam(name="name",value="产品名称")
                                              @RequestParam(value="name",required = false) String name){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.deviceUsageAnalysis(type,name));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/warningInformationAlarm_new",method = RequestMethod.GET)
    @ApiOperation("预警信息警报")
    public MixEnvelop warningInformationAlarm_new(
            @ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
            @RequestParam(value="page",required = false) Integer page,
            @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
            @RequestParam(value="pageSize",required = false) Integer pageSize,
            @ApiParam(name="startTime",value="开始时间",defaultValue = "")
            @RequestParam(value="startTime",required = false) String startTime,
            @ApiParam(name="endTime",value="结束时间",defaultValue = "")
            @RequestParam(value="endTime",required = false) String endTime,
            @ApiParam(name="deviceType",value="设备类型",defaultValue = "")
            @RequestParam(value="deviceType",required = false) String deviceType,
            @ApiParam(name="area",value="地区",defaultValue = "")
            @RequestParam(value="area",required = false) String area,
            @ApiParam(name="hospital",value="机构",defaultValue = "")
            @RequestParam(value="hospital",required = false) String hospital){
        try {
            if(page==null){
                page = 1;
            }
            if(pageSize==null){
                pageSize = 20;
            }
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.warningInformationAlarm_new(page,pageSize,startTime,endTime,deviceType,area,hospital));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/yellowAndRedRange",method = RequestMethod.GET)
    @ApiOperation("红标黄标率")
    public MixEnvelop yellowAndRedRange(
            @ApiParam(name="startTime",value="开始时间",defaultValue = "")
            @RequestParam(value="startTime",required = false) String startTime,
            @ApiParam(name="endTime",value="结束时间",defaultValue = "")
            @RequestParam(value="endTime",required = false) String endTime,
            @ApiParam(name="deviceType",value="设备类型",defaultValue = "")
            @RequestParam(value="deviceType",required = false) String deviceType,
            @ApiParam(name="area",value="地区",defaultValue = "")
            @RequestParam(value="area",required = false) String area,
            @ApiParam(name="hospital",value="机构",defaultValue = "")
            @RequestParam(value="hospital",required = false) String hospital){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.yellowAndRedRange(startTime,endTime,deviceType,area,hospital));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/deviceUseData",method = RequestMethod.GET)
    @ApiOperation("设备使用数据")
    public MixEnvelop deviceUseData(@ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
                                @RequestParam(value="page",required = false) Integer page,
                                @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
                                @RequestParam(value="pageSize",required = false) Integer pageSize,
                                @ApiParam(name="deviceSn",value="开始时间",defaultValue = "")
                                @RequestParam(value="deviceSn",required = false) String deviceSn){
        try {
            if(page==null){
                page = 1;
            }
            if(pageSize==null){
                pageSize = 10;
            }
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.deviceUseData(page,pageSize,deviceSn));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/deviceInfo",method = RequestMethod.GET)
    @ApiOperation("设备信息")
    public MixEnvelop deviceInfo(@ApiParam(name="deviceSn",value="设备sn码")
                             @RequestParam(value="deviceSn",required = true) String deviceSn,
                             @ApiParam(name="patient",value="居民code")
                             @RequestParam(value="patient",required = true) String patient){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.deviceInfo(deviceSn,patient));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/deviceOverhaulList",method = RequestMethod.GET)
    @ApiOperation("质控情况")
    public MixEnvelop deviceOverhaulList(@ApiParam(name="page",value="第几页(默认第一页)",defaultValue = "1")
                                     @RequestParam(value="page",required = false) Integer page,
                                 @ApiParam(name="pageSize",value="每页几行(默认10条记录)",defaultValue = "10")
                                     @RequestParam(value="pageSize",required = false) Integer pageSize,
                                 @ApiParam(name="deviceSn",value="开始时间",defaultValue = "")
                                     @RequestParam(value="deviceSn",required = true) String deviceSn){
        try {
            if(page==null){
                page = 1;
            }
            if(pageSize==null){
                pageSize = 10;
            }
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.deviceOverhaulList(page,pageSize,deviceSn));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/residentUserType",method = RequestMethod.GET)
    @ApiOperation("入住情况")
    public MixEnvelop residentUserType(){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.residentUserType());
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    @RequestMapping(value = "/intefaceLogList",method = RequestMethod.GET)
    @ApiOperation("接口调用情况")
    public MixEnvelop intefaceLogList(@ApiParam(name="startTime",value="开始时间",defaultValue = "2019-01-01")
                                         @RequestParam(value="startTime",required = false) String startTime,
                                         @ApiParam(name="endTime",value="结束时间",defaultValue = "2020-06-01")
                                         @RequestParam(value="endTime",required = false) String endTime,
                                         @ApiParam(name="type",value="统计类型",defaultValue = "month")
                                         @RequestParam(value="type",required = true) String type){
        try {
            return MixEnvelop.getSuccess("查询成功",monitorPlatformService.intefaceLogList(startTime,endTime,type));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
}

+ 13 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -1,5 +1,6 @@
package com.yihu.iot.controller.product;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.product.IotProductBaseInfoService;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
@ -223,5 +224,17 @@ public class IotProductController extends EnvelopRestEndpoint {
        return iotProductBaseInfoService.findAll();
    }
    @GetMapping(value = IotRequestMapping.Product.findListByCategoryCode)
    @ApiOperation(value = "根据分类查找产品信息")
    public MixEnvelop<JSONObject, JSONObject> findListByCategoryCode(@ApiParam(name = "categoryCode", value = "分类code", defaultValue = "1")
                                                              @RequestParam(value = "categoryCode", required = true)String categoryCode) {
        try {
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, iotProductBaseInfoService.findListByCategoryCode("'"+categoryCode.replace(",","','")+"'"));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/dict/IotSystemDictDao.java

@ -20,4 +20,7 @@ public interface IotSystemDictDao extends PagingAndSortingRepository<IotSystemDi
    List<IotSystemDictDO> getAllByDictNameAndOrderByCodeDesc(String dictName);
    IotSystemDictDO findByDictNameAndCodeAndDel(String dictName, String code, Integer del);
    @Query("from IotSystemDictDO w where w.parentCode in (?1) and w.del = 1 ")
    List<IotSystemDictDO> findByParentCode(String parentCode);
}

+ 1 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/product/IotProductBaseInfoDao.java

@ -18,4 +18,5 @@ public interface IotProductBaseInfoDao extends PagingAndSortingRepository<IotPro
    @Query("from IotProductBaseInfoDO w where w.del = 1")
    List<IotProductBaseInfoDO> findAllByDel();
}

+ 1 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -402,8 +402,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        sql +=" GROUP BY p.device_sn ORDER BY p.update_time desc ";
        if (page != null && pageSize != null) {
            String sqlCount = "SELECT count(DISTINCT p.device_sn) " + sql.substring(sql.indexOf("FROM"), sql.length());
            Long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
            Long count = Long.valueOf(jdbcTempalte.queryForList(sql).size());
            sql += "limit " +(page-1)* pageSize + "," +pageSize;
            List<IotPatientDeviceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(IotPatientDeviceVO.class));
            return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Device.message_success_find, list,page, pageSize,count);

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/dict/IotSystemDictService.java

@ -84,4 +84,15 @@ public class IotSystemDictService extends BaseJpaService<IotSystemDictDO,IotSyst
        }
        return systemDictDOList;
    }
    /**
     * 查找子类字典
     * @param parentCode
     * @return
     */
    public List<JSONObject> getListByParentCode(String parentCode){
        String sql = "SELECT code,value from iot_system_dict WHERE parent_code in ("+parentCode+") and del = 1 ORDER BY sort";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return list;
    }
}

+ 392 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -0,0 +1,392 @@
package com.yihu.iot.service.monitorPlatform;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.ApiParam;
import iot.device.LocationDataVO;
import org.apache.http.Consts;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.*;
/**
 * Created by yeshijie on 2020/5/11.
 */
@Service
public class MonitorPlatformService  {
    @Value("${spring.wlyy.url}")
    private String wlyyUrl;
    @Value("${spring.wlyy.appid}")
    private String appid;
    @Value("${spring.wlyy.appsecret}")
    private String appSecret;
    public static Map<String,String> tokenMap = new HashMap<>();
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private IotPatientDeviceService iotPatientDeviceService;
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    /**
     * 质控情况
     * @param page
     * @param pageSize
     * @param deviceSn
     * @return
     */
    public List<JSONObject> deviceOverhaulList(Integer page,Integer pageSize,String deviceSn){
        String sql = "SELECT o.time,o.`status`,o.remark from iot_patient_device d,iot_device_overhaul o" +
                " WHERE d.device_sn = '"+deviceSn+"' and d.id = o.patient_device_id ORDER BY o.time desc limit ?,?";
        return myJdbcTemplate.queryJson(sql.toString(),new Object[]{(page-1)*pageSize,pageSize});
    }
    /**
     * 入住情况
     * @return
     */
    public JSONObject residentUserType(){
        String sql = "SELECT IFNULL(enter_type,'0') type,COUNT(id) num from iot_company WHERE del =1 GROUP BY enter_type";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
        int total = 0;
        int manufacturer = 0;//厂商
        int supplier = 0;// 供应商
        int agent = 0;//代理商
        int platform = 0;//接入平台
        for(JSONObject json:list){
            switch (json.getString("type")){
                case "0":
                    platform = json.getInteger("num");
                    break;
                case "3":
                    manufacturer = json.getInteger("num");
                    break;
                case "1":
                    supplier = json.getInteger("num");
                    break;
                case "2":
                    agent = json.getInteger("num");
                    break;
            }
        }
        total = manufacturer+supplier+agent+platform;
        JSONObject json = new JSONObject();
        json.put("total",total);
        json.put("manufacturer",manufacturer);
        json.put("supplier",supplier);
        json.put("agent",agent);
        json.put("platform",platform);
        if(total>0){
            DecimalFormat df = new DecimalFormat("0.00");
            json.put("manufacturerRange", df.format(manufacturer > 0.0 ? (manufacturer/ (total * 1.0000) * 100) : 0.0) + "%");
            json.put("supplierRange", df.format(supplier > 0.0 ? (supplier/ (total * 1.0000) * 100) : 0.0) + "%");
            json.put("agentRange", df.format(agent > 0.0 ? (agent/ (total * 1.0000) * 100) : 0.0) + "%");
            json.put("platformRange", df.format(platform > 0.0 ? (platform/ (total * 1.0000) * 100) : 0.0) + "%");
        }else {
            json.put("manufacturerRange","0.0%");
            json.put("supplierRange","0.0%");
            json.put("agentRange","0.0%");
            json.put("platformRange","0.0%");
        }
        return json;
    }
    /**
     * 接口调用情况
     * @param startTime
     * @param endTime
     * @param type
     * @return
     */
    public List<JSONObject> intefaceLogList(String startTime,String endTime,String type){
        String sql = "SELECT ";
        switch (type){
            case "month":
                sql+= " date_format(time,'%m') ";
                break;
            case "year":
                sql+= " date_format(time,'%Y') ";
                break;
            case "day":
                sql+= " date_format(time,'%j') ";
                break;
            case "week":
                sql+= " date_format(time,'%u') ";
                break;
        }
        sql+= " date ,COUNT(*) num from iot_interface_log where 1=1 ";
        if(StringUtils.isEmpty(startTime)){
            sql+= " and time>='"+startTime+"'";
        }
        if(StringUtils.isEmpty(endTime)){
            sql+= " and time>='"+endTime+"'";
        }
        sql+=" GROUP BY date ";
        return myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
    }
    /**
     * 智能设备发放
     */
    public JSONArray smartDeviceDistribution(String type,String name){
        String url = "/wlyygc/iot_monitoring/smartDeviceDistribution";
        Map<String, Object> params = new HashMap<>();
        params.put("type",type);
        params.put("name",name);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            return json.getJSONArray("data");
        }
        return new JSONArray();
    }
    /**
     * 设备使用数据
     * @param page
     * @param pageSize
     * @param deviceSn
     * @return
     */
    public JSONArray deviceUseData(Integer page,Integer pageSize,String deviceSn){
        String url = "/wlyygc/iot_monitoring/deviceUseData";
        Map<String, Object> params = new HashMap<>();
        params.put("page",page);
        params.put("pageSize",pageSize);
        params.put("deviceSn",deviceSn);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            return json.getJSONArray("data");
        }
        return new JSONArray();
    }
    /**
     * 设备使用数据
     * @param patient
     * @param deviceSn
     * @return
     */
    public JSONObject deviceInfo(String deviceSn,String patient){
        String url = "/wlyygc/iot_monitoring/deviceInfo";
        Map<String, Object> params = new HashMap<>();
        params.put("patient",patient);
        params.put("deviceSn",deviceSn);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            return json.getJSONObject("data");
        }
        return new JSONObject();
    }
    /**
     * 设备使用情况分析
     * @param type
     * @param name
     * @return
     */
    public JSONObject deviceUsageAnalysis(String type,String name){
        String url = "/wlyygc/iot_monitoring/deviceUsageAnalysis";
        Map<String, Object> params = new HashMap<>();
        params.put("type",type);
        params.put("name",name);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            return json.getJSONObject("data");
        }
        return new JSONObject();
    }
    /**
     * 预警信息警报
     * @param page
     * @param pageSize
     * @param startTime
     * @param endTime
     * @param deviceType
     * @param area
     * @param hospital
     * @return
     */
    public JSONArray warningInformationAlarm_new(Integer page,Integer pageSize,String startTime,String endTime,
                                                  String deviceType,String area,String hospital){
        String url = "/wlyygc/iot_monitoring/warningInformationAlarm_new";
        Map<String, Object> params = new HashMap<>();
        params.put("page",page);
        params.put("pageSize",pageSize);
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        params.put("deviceType",deviceType);
        params.put("area",area);
        params.put("hospital",hospital);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            return json.getJSONArray("data");
        }
        return new JSONArray();
    }
    /**
     * 预警信息警报
     * @param startTime
     * @param endTime
     * @param deviceType
     * @param area
     * @param hospital
     * @return
     */
    public JSONObject yellowAndRedRange(String startTime,String endTime,
                                                 String deviceType,String area,String hospital){
        String url = "/wlyygc/iot_monitoring/yellowAndRedRange";
        Map<String, Object> params = new HashMap<>();
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        params.put("deviceType",deviceType);
        params.put("area",area);
        params.put("hospital",hospital);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            return json.getJSONObject("data");
        }
        return new JSONObject();
    }
    /**
     * 数据筛选
     * @param name
     * @return
     */
    public JSONArray datafiltering(String name){
        String url = "/wlyygc/iot_monitoring/datafiltering";
        Map<String, Object> params = new HashMap<>();
        params.put("name",name);
        String response = sendGet(url,params);
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            JSONArray jsonArray = json.getJSONArray("data");
            for(int i=0;i<jsonArray.size();i++){
                JSONObject data = jsonArray.getJSONObject(i);
                String deviceSn = data.getString("deviceSn");
                JSONArray jsonArray1 = new JSONArray();
                JSONObject json1 = new JSONObject();
                json1.put("andOr","and");
                json1.put("field","deviceSn");
                json1.put("condition","=");
                json1.put("value",deviceSn);
                jsonArray1.add(json1);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("filter",jsonArray1);
                jsonObject.put("page",1);
                jsonObject.put("size",5);
                List<LocationDataVO> list = null;
                try {
                    list = iotPatientDeviceService.findDeviceLocationsBySn(jsonObject.toString());
                    if(list.size()>0){
                        data.put("locationData",list.get(0).getLocation());
                    }else{
                        data.put("locationData","{}");
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            return jsonArray;
        }
        return new JSONArray();
    }
    /**
     * 访问i健康接口,自带登录信息
     * @param url
     * @return
     */
    private String sendGet(String url,Map<String, Object> params){
        String response = null;
        try{
            params.put("accesstoken",getAccessToken());
            List<BasicNameValuePair> jsonParams = new ArrayList<>();
            //配置参数
            if(params!=null) {
                for (String key : params.keySet()) {
                    if (!StringUtils.isEmpty(String.valueOf(params.get(key))) && !"null".equals( String.valueOf(params.get(key)))) {
                        jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
                    }
                }
            }
            response = httpClientUtil.get(wlyyUrl+url+"?"+ URLEncodedUtils.format(jsonParams, Consts.UTF_8),"utf-8");
        }catch (Exception e){
            e.printStackTrace();
        }
        return response;
    }
    /**
     * 返回accessToken
     * @return
     * @throws IOException
     */
    private synchronized String getAccessToken(){
        String token = "";
        if(tokenMap.get("token")!=null){
            token = tokenMap.get("token");
            Long outTime = Long.valueOf(tokenMap.get("outTime"));
            if(new Date().getTime()<outTime){
                return token;
            }
        }
        try {
            Map params = new HashMap();
            params.put("appid", appid);
            params.put("appSecret", appSecret);
            String url = "/gc/accesstoken";
            String response = httpClientUtil.httpPost(wlyyUrl + url, params);
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getInteger("status")==10000){
                String accesstoken = jsonObject.getJSONObject("result").getString("accesstoken");
                tokenMap.put("token",accesstoken);
                tokenMap.put("outTime", jsonObject.getJSONObject("result").getLong("outTime")+"");
                return accesstoken;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}

+ 9 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoService.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.device.IotOrderPurchaseDao;
import com.yihu.iot.dao.product.*;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.jw.entity.iot.product.*;
import com.yihu.jw.restmodel.iot.product.*;
@ -42,6 +43,8 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private IotOrderPurchaseDao iotOrderPurchaseDao;
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    /**
@ -360,6 +363,12 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
        return list;
    }
    public List<JSONObject> findListByCategoryCode(String categoryCode){
        String sql = "SELECT id,name,category_code from iot_product_base_info WHERE category_code in ("+categoryCode+") and del = 1 ORDER BY category_code";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return list;
    }
    /**
     * 获取所有产品信息
     * @return

+ 32 - 1
svr/svr-iot/src/main/resources/application.yml

@ -72,6 +72,8 @@ spring:
      uris: http://172.26.0.202:9200
  wlyy:
    url: http://www.xmtyw.cn/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 172.26.0.200:22122 #服务器地址
fastDFS:
@ -91,6 +93,8 @@ spring:
      uris: http://172.26.0.202:9200
  wlyy:
    url: http://www.xmtyw.cn/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 172.26.0.200:22122 #服务器地址
fastDFS:
@ -110,6 +114,8 @@ spring:
      uris: http://172.19.103.45:9200,http://172.19.103.68:9200
  wlyy:
    url: http://ehr.yihu.com/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee62
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee62
fast-dfs:
  tracker-server: 172.19.103.54:22122 #服务器地址
fastDFS:
@ -129,6 +135,8 @@ spring:
      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
  wlyy:
    url: http://ehr.yihu.com/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee62
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee62
fast-dfs:
  tracker-server: 172.19.103.54:22122 #服务器地址
fastDFS:
@ -149,6 +157,8 @@ spring:
      uris: http://59.61.92.90:9208, http://59.61.92.90:9210
  wlyy:
    url: http://www.xmtyw.cn/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 10.95.22.139:22122 #服务器地址
fastDFS:
@ -168,7 +178,28 @@ spring:
      uris: http://59.61.92.90:9208,http://59.61.92.90:9210
  wlyy:
    url: http://www.xmtyw.cn/wlyy/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee61
    appsecret: 915d0345-5b1d-11e6-8344-fa163e8aee57
fast-dfs:
  tracker-server: 10.95.22.139:22122 #服务器地址
fastDFS:
  fastdfs_file_url: http://www.xmtyw.cn/
  fastdfs_file_url: http://www.xmtyw.cn/
---
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://59.61.92.90:20002/xmiot?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
  elasticsearch:
    cluster-name: jkzl #默认即为elasticsearch  集群名
    cluster-nodes: 59.61.92.90:20010,59.61.92.90:20012 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    jest:
      uris: http://59.61.92.90:20009,http://59.61.92.90:20011
  wlyy:
    url: http://ehr.yihu.com/wlyy/
fast-dfs:
  tracker-server: 172.19.103.54:22122 #服务器地址
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/

+ 11 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java

@ -134,6 +134,17 @@ public class SpecialistScreenResultService {
        String templateSql = "select t.is_third from "+basedb+".wlyy_survey_templates t where t.code = '" + templateCode + "' and t.del = 1 ";
        String thirdId = jdbcTemplate.queryForObject(templateSql, String.class);
        surveyScreenResultVo.setIsThird(thirdId);
        //获取转诊信息
        String reservationSql = "SELECT * FROM " + basedb + ".`wlyy_patient_reservation` r where r.relation_code = '" + code + "' and r.`status` = 1 ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(reservationSql);
        if (list.size() > 0) {
            Map<String, Object> m = list.get(0);
            surveyScreenResultVo.setDoctorNameReservation(m.get("doctor_name").toString());
            String czrq = m.get("czrq").toString();
            String startTime = m.get("start_time").toString();
            surveyScreenResultVo.setCzrqReservation(czrq.substring(0, czrq.length() - 2));
            surveyScreenResultVo.setStartTimeReservation(startTime.substring(0, startTime.length() - 2));
        }
        map.put("info",surveyScreenResultVo);
        //json.put("info",surveyScreenResultVo);