xufenglei
2018-03-12 6a1b28591ebe95ed9f26810fbf9677da5c87692d
大屏 报表接口
3 files modified
48 ■■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java 27 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java
@@ -424,4 +424,15 @@
        List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(orgId);
        return new ResultBean<List<MonitorPoint>>(monitorPoints);
    }
    @GetMapping("report_avg_datas")
    public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request) throws Exception {
        Map<String, Object> parameters = getParametersStartingWith(request, null);
        parameters.put("type", "month");
        parameters.put("format", "yyyy-MM");
        parameters.put("typeFormat", "%Y-%m-%d");
        List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
        return new ResultBean<List<Map<String, Object>>>(list);
    }
}
src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java
@@ -264,7 +264,7 @@
    
    @Override
    public List<Map<String, Object>> getMonitorPointOrDeviceAvgData(Map<String, Object> parameters) throws Exception {
        List<Map<String, Object>> resul ;
        List<Map<String, Object>> resultList ;
        String type = (String) parameters.get("type");
        String time = (String) parameters.get("time");
@@ -301,7 +301,7 @@
        //sensorKeys.clear();
        // 监控点平均值
        if (!parameters.containsKey("mac")) {
            resul = new ArrayList<Map<String,Object>>();
            resultList = new ArrayList<Map<String,Object>>();
            Integer monitorPointId = Integer.valueOf(parameters.get("monitorPoint").toString());
            List<Map<String, Object>> deviceVersions = deviceMapper.getDeviceVersionIdByMonitorPoint(monitorPointId);
            ExecutorService threadPool = Executors.newCachedThreadPool();
@@ -366,7 +366,7 @@
                for (String sensorKey : value.keySet()) {
                    resultMap.put(sensorKey, value.get(sensorKey)[2]);
                }
                resul.add(resultMap);
                resultList.add(resultMap);
            }
        // 设备 平均值    
        } else {
@@ -381,9 +381,9 @@
                parameters.put("sensorKeyColumn", sensorKeyColumn);
                
            }
            resul = historyMinutelyMapper.getMonitorPointOrDeviceAvgData(parameters);
            resultList = historyMinutelyMapper.getMonitorPointOrDeviceAvgData(parameters);
        }
        return resul;
        return resultList;
    }
    private String getSensorKeyColumnBySensors(List<Map<String, Object>> sensors,Map<String, Object> parameters) {
src/main/java/com/moral/service/impl/MonitorPointServiceImpl.java
@@ -8,18 +8,22 @@
import javax.annotation.Resource;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.Constants;
import com.moral.common.bean.PageBean;
import com.moral.common.util.*;
import com.moral.entity.Device;
import com.moral.mapper.DeviceMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.Constants;
import com.moral.common.bean.PageBean;
import com.moral.common.util.ExampleUtil;
import com.moral.common.util.RedisUtils;
import com.moral.common.util.StringUtils;
import com.moral.common.util.ValidateUtil;
import com.moral.entity.Device;
import com.moral.entity.MonitorPoint;
import com.moral.mapper.DeviceMapper;
import com.moral.mapper.MonitorPointMapper;
import com.moral.service.MonitorPointService;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
@@ -174,11 +178,14 @@
    @Override
    public List<MonitorPoint> getMonitorPointsByOrganizationId(Integer orgId) {
        MonitorPoint monitorPoint = new MonitorPoint();
        monitorPoint.setIsDelete(Constants.IS_DELETE_FALSE);
        Example example = new Example(MonitorPoint.class);
        Criteria criteria = example.createCriteria();
        criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
        if (Constants.isNotSpecialOrgId(orgId)) {
            monitorPoint.setOrganizationId(orgId);
            criteria.andEqualTo("organizationId", orgId);
        }
        return monitorPointMapper.select(monitorPoint);
        example.orderBy("name").asc();
        return monitorPointMapper.selectByExample(example);
    }
}