lizijie
2020-11-06 a613ae7c3165602fc8927c1ba6bb13edb25649c7
src/main/java/com/moral/controller/ScreenController.java
@@ -2,6 +2,7 @@
import java.io.*;
import java.lang.reflect.Array;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
@@ -166,6 +167,9 @@
    @Resource
    private ScreenVersionService screenVersionService;
    @Resource
    private DeviceAdjustValueTimingService deviceAdjustValueTimingService;
    /**
     * Screen login. 大屏登录
@@ -2023,7 +2027,7 @@
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MINUTE, (calendar.get(Calendar.MINUTE) - 2));
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String time = df.format(calendar.getTime()) + ":00";
        //String time = df.format(calendar.getTime()) + ":00";
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        String mon;
@@ -2033,7 +2037,7 @@
            mon = "" + month;
        }
        String table = "history_minutely_" + year + mon;
        List list = deviceService.byMonitorIdGetDeviceAndWind(monitorPointId, time, table);
        List list = deviceService.byMonitorIdGetDeviceAndWind(monitorPointId,table);
        return list;
    }
@@ -2054,7 +2058,7 @@
            mon = "" + month;
        }
        String table = "history_minutely_" + year + mon;
        List list = deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId, time, table);
        List list = deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId,table);
        return list;
    }
@@ -2550,4 +2554,46 @@
        List<Map<String, Object>> list = historyMinutelyService.getAllDeviceDataToExcel(parameters);
        return new ResultBean<List<Map<String, Object>>>(list);
    }
    /*@PostMapping("insertAdjustValue")
    @ApiOperation(value = "所有设备多因子数据报表", notes = "所有设备多因子数据报表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "设备id", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time", value = "时间(格式08:30:00)", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "dataArray", value = "公式", required = false, paramType = "query", dataType = "String")})
    public void insertAdjustValue(HttpServletRequest request) throws Exception {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        int device_id = Integer.parseInt(parameters.get("id").toString());
        String hour_minute_second = parameters.get("time").toString();
        String[] arr = hour_minute_second.split(":");
        int seconds = Integer.parseInt(arr[0])*3600+Integer.parseInt(arr[1])*60+Integer.parseInt(arr[2]);
        String value = parameters.get("dataArray").toString();
        deviceAdjustValueTimingService.insertData(device_id,seconds,value);;
    }*/
    @PostMapping("insertAdjustValue")
    public  int insertAdjustValue(@RequestBody HashMap map){
        try{
            int device_id = Integer.parseInt(map.get("id").toString());
            String time = map.get("time").toString();
            String[] arr = time.split(":");
            int seconds = Integer.parseInt(arr[0])*3600+Integer.parseInt(arr[1])*60+Integer.parseInt(arr[2]);
            //String t = URLEncoder.encode(参数,"UTF-8")
            List list = (List) map.get("dataArray");
            String val="";
            for (int i = 0; i <list.size() ; i++) {
                if (i==0){
                    val=val+list.get(i);
                }else {
                    val=val+","+list.get(i);
                }
            }
            String value = "{"+val+"}";
            deviceAdjustValueTimingService.insertData(device_id,seconds,value);
            return 1;
        }catch (Exception e){
            log.warn(e);
        }
        return 0;
    }
}