Browse Source

眼科医院处方物流

ysj 5 years ago
parent
commit
f3b7c71745

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

@ -49,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";
    }
    /**
@ -140,6 +141,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";
    }

+ 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());
        }
    }
}

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

@ -1,11 +1,16 @@
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;
/**
@ -20,6 +25,184 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    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();
}

+ 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;
    }
}

+ 345 - 20
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -1,17 +1,26 @@
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.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.text.DecimalFormat;
import java.util.*;
/**
 * Created by yeshijie on 2020/5/11.
@ -29,8 +38,323 @@ public class MonitorPlatformService  {
    @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
@ -40,28 +364,29 @@ public class MonitorPlatformService  {
        String token = "";
        if(tokenMap.get("token")!=null){
            token = tokenMap.get("token");
            String time = tokenMap.get("time");
            Date start = DateUtil.strToDate(time);
            long m = (System.currentTimeMillis()-start.getTime())/1000;
            long overTime = 15*6*60;//1.5小时
            if(m<overTime){
            Long outTime = Long.valueOf(tokenMap.get("outTime"));
            if(new Date().getTime()<outTime){
                return token;
            }
        }
        JSONObject params = new JSONObject();
        params.put("appid", appid);
        params.put("appSecret", appSecret);
        String url = "/gc/accesstoken";
        String response = httpClientUtil.sendPost(wlyyUrl + url, params.toString());
        JSONObject jsonObject = JSON.parseObject(response);
        if(jsonObject.getInteger("status")==10000){
            String accesstoken = jsonObject.getJSONObject("result").getString("accesstoken");
            tokenMap.put("token",accesstoken);
            tokenMap.put("time", DateUtil.dateToStrLong(new Date()));
            return accesstoken;
        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