Pārlūkot izejas kodu

大屏应用服务

Shi Kejing 4 gadi atpakaļ
vecāks
revīzija
bb2547ecbd

+ 3 - 7
svr/svr-iot/src/main/java/com/yihu/iot/controller/platform/IotInterfaceController.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.platform.IotAppInterfacesVO;
import com.yihu.jw.restmodel.iot.platform.IotInterfaceLogVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -418,14 +419,9 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
    @ApiOperation("大屏应用服务")
    @RequestMapping(value = "/getAppService" , method = RequestMethod.GET)
    public MixEnvelop getAppService() {
    public Envelop getAppService() {
        try {
            List<AppServiceCount> appServiceCount = iotCompanyService.getAppService(0);
            List<AppServiceCount> appServiceCountList = iotCompanyService.getAppService(3);
            List list = new ArrayList();
            list.add(0,appServiceCount.size());
            list.add(1,appServiceCountList);
            return MixEnvelop.getSuccess("查询成功", list);
            return success(iotCompanyService.getAppService());
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");

+ 13 - 5
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -1,5 +1,6 @@
package com.yihu.iot.service.company;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.company.*;
import com.yihu.iot.dao.platform.IotCompanyAppInterfaceDao;
import com.yihu.iot.dao.platform.IotInterfaceLogDao;
@ -1159,17 +1160,24 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    }
    public List<AppServiceCount> getAppService(Integer size){
    public JSONObject getAppService(){
        JSONObject object = new JSONObject();
        String str = "SELECT SUM(b.count) count,b.app_name appName\n" +
                "FROM (SELECT COUNT(id) fali,app_name,interface_name FROM xmiot.iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c\n" +
                "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM xmiot.iot_interface_log WHERE app_name IS NOT NULL\n" +
                "GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name\n" +
                "GROUP BY b.app_name ORDER BY count DESC";
        if (size > 0){
            str += " LIMIT 0,3";
        }
        String str1 = "SELECT SUM(b.count) count,b.app_name appName\n" +
                "FROM (SELECT COUNT(id) fali,app_name,interface_name FROM xmiot.iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c\n" +
                "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM xmiot.iot_interface_log WHERE app_name IS NOT NULL\n" +
                "GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name\n" +
                "GROUP BY b.app_name ORDER BY count DESC limit 0,3";
        List<AppServiceCount> counts = jdbcTemplate.query(str,new BeanPropertyRowMapper<>(AppServiceCount.class));
        return counts;
        List<AppServiceCount> counts1 = jdbcTemplate.query(str1,new BeanPropertyRowMapper<>(AppServiceCount.class));
        object.put("appcount",counts.size());
        object.put("sortList",counts1);
        return object;
    }
}