kaiyu
2020-09-22 30d07fbe902f3013a65a7c00fa141b119610a8f7
src/main/java/com/moral/controller/ScreenController.java
@@ -34,26 +34,7 @@
import com.moral.entity.alarm.AlarmSensorLevel;
import com.moral.entity.charts.DataSortCondition;
import com.moral.entity.layout.RealTimeDeviceLayout;
import com.moral.service.AccountService;
import com.moral.service.AlarmConfigService;
import com.moral.service.AlarmDailyService;
import com.moral.service.AreaService;
import com.moral.service.DeviceService;
import com.moral.service.DeviceVersionService;
import com.moral.service.DictionaryDataService;
import com.moral.service.HangzhouAqiService;
import com.moral.service.HistoryDailyService;
import com.moral.service.HistoryHourlyService;
import com.moral.service.HistoryMinutelyService;
import com.moral.service.HistoryService;
import com.moral.service.MachineActivateService;
import com.moral.service.MonitorPointService;
import com.moral.service.OrganizationLayoutService;
import com.moral.service.OrganizationService;
import com.moral.service.QualityDailyService;
import com.moral.service.SensorService;
import com.moral.service.SensorUnitService;
import com.moral.service.WeatherService;
import com.moral.service.*;
import com.moral.util.*;
import com.rabbitmq.client.*;
@@ -86,10 +67,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView;
import org.xml.sax.InputSource;
import static com.moral.common.util.ResourceUtil.getValue;
import static com.moral.common.util.WebUtils.getParametersStartingWith;
import static java.util.Calendar.*;
@@ -117,6 +96,9 @@
    MonitorPointService monitorPointService;
    @Resource
    DeviceVersionService deviceVersionService;
  /*  @Resource
    HistorySpecialService historySpecialService;*/
    /**
     * The screen service.
@@ -177,8 +159,6 @@
    @Resource
    private QualityDailyService qualityDailyService;
    @Resource
    private RestTemplate restTemplate;
    /**
     * Screen login. 大屏登录
@@ -695,28 +675,43 @@
        return new ResultBean<List<MonitorPoint>>(monitorPoints);
    }
    /*
    * 参数:monitorPoint=368&mac=p5dnd7a0392018&sensorKey=e92&time=2020-08-11
    * 获取传感器均值接口
    * */
    @GetMapping("report_avg_datas")
    public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request)
            throws Exception {
        Map<String, Object> parameters = getParametersStartingWith(request, null);
        //该方法用于判断时间是具体到年月日
        ParameterUtils.getTimeType4Time(parameters);
        parameters.put("monitorPointId", parameters.remove("monitorPoint"));
        Object sensorKey = parameters.remove("sensorKey");
        parameters.put("sensors", Arrays.asList(sensorKey));
        // monitorPointService.isCompensateCalculation(parameters);
        List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
        for (Map<String, Object> map : list) {
            String time = map.get("time").toString();
            time = time.substring(time.length() - 2);
            map.put("time", Integer.valueOf(time));
            if(parameters.get("type").equals("day")){
                map.put("time", Integer.valueOf(time)+1);
        String time1= (String) parameters.get("time");
        String mac1= (String) parameters.get("mac");
        List<Map<String, Object>> list=null;
        if (mac1.equals("p5dnd7a0392018") && time1.substring(0,4).equals("2019") ){
                list=null;
        }else {
            parameters.put("monitorPointId", parameters.remove("monitorPoint"));
            Object sensorKey = parameters.remove("sensorKey");
            parameters.put("sensors", Arrays.asList(sensorKey));
            // monitorPointService.isCompensateCalculation(parameters);
            list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
            for (Map<String, Object> map : list) {
                String time = map.get("time").toString();
                time = time.substring(time.length() - 2);
                map.put("time", Integer.valueOf(time));
                if (parameters.get("type").equals("day")) {
                    map.put("time", Integer.valueOf(time) + 1);
                }
                map.put("value", map.remove(sensorKey));
            }
            map.put("value", map.remove(sensorKey));
        }
        return new ResultBean<List<Map<String, Object>>>(list);
    }
    @GetMapping("report_alarm_datas")
    public ResultBean<List<Map<String, Object>>> getAlarmData(HttpServletRequest request) throws Exception {
@@ -1504,13 +1499,15 @@
        String startHour = st.substring(st.lastIndexOf("-") + 1);
        String startTime = startYearAndDay + " " + startHour + ":00:00";
        String et = parameters.get("endTime").toString();
        String endYearAndDay = et.substring(0, st.lastIndexOf("-"));
        String endHour = et.substring(et.lastIndexOf("-") + 1);
        int endHourValue = Integer.valueOf(endHour);
        String endTime=endYearAndDay + " " + endHour + ":00:00";
       /* int endHourValue = Integer.valueOf(endHour);
        int startHourValue = Integer.valueOf(startHour);
        if (endHourValue <= startHourValue) {
            endHourValue = startHourValue + 1;
        }
        String endTime = startYearAndDay + " " + endHourValue + ":00:00";
        String endTime = startYearAndDay + " " + endHourValue + ":00:00";*/
        parameters.put("startTime", startTime);
        parameters.put("endTime", endTime);
        String mac = parameters.get("mac").toString();
@@ -1525,6 +1522,7 @@
            params.put("sensorInfo", sensorList);
            params.put("sensorsMap", sensorsMap);
            String paramsJson = params.toJSONString();
            //System.out.println(paramsJson);
            model.addObject("carTrajectoryParams", paramsJson);
            model.setViewName("cartrajectory");
            return model;
@@ -2219,7 +2217,7 @@
    @GetMapping("contrastFactor")
    @GetMapping("/contrastFactor")
    @ApiOperation(value = "因子对比", notes = "因子对比")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),