xufenglei
2019-03-25 1830f5429730a40f7d2f17ca748a80a4b1046c21
update
3 files modified
20 ■■■■ changed files
src/main/java/com/moral/common/bean/Constants.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/ScreenController.java 13 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/common/bean/Constants.java
@@ -58,5 +58,6 @@
    public static final String DEVICE_STATE_MIDDLE ="2";
    public static final String DEVICE_STATE_SERIOUS ="3";
    public static final String DEVICE_STATE_OFFLINE ="4";
    public static final String DEVICE_STATE_MAINTENANCE ="9";
}
src/main/java/com/moral/controller/ScreenController.java
@@ -872,11 +872,20 @@
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "mac",defaultValue = "p5dnd7a0391956", value = "设备mac码", required = true, paramType = "query", dataType = "String")
    })
    public ResultBean<Map<String, Object>> getLimitDataByDevice(HttpServletRequest request) throws Exception {
    public ResultBean<List<Map<String, Object>>> getLimitDataByDevice(HttpServletRequest request) throws Exception {
        Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
        String density = deviceService.getLimitDataByDevice(parameters);
        JSONObject parseObject = JSONObject.parseObject(density);
        return new ResultBean<Map<String, Object>>(parseObject);
        List<Map<String, Object>> resuList = new ArrayList<Map<String,Object>>();
        for (Map.Entry entry : parseObject.entrySet()) {
            resuList.add(new HashMap<String, Object>() {
                {
                    put("key",entry.getKey());
                    put("limit", entry.getValue());
                }
            });
        }
        return new ResultBean<List<Map<String, Object>>>(resuList);
    }
}
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -563,11 +563,11 @@
        ValidateUtil.notNull(parameters.get("old_state"), "param.is.null");
        ValidateUtil.notNull(parameters.get("new_state"), "param.is.null");
        int count = 0;
        if ("4".equals(parameters.get("old_state")) && "9".equals(parameters.get("new_state"))) {
        if (Constants.DEVICE_STATE_OFFLINE.equals(parameters.get("old_state")) && Constants.DEVICE_STATE_MAINTENANCE.equals(parameters.get("new_state"))) {
            Device device = new Device();
            Example example = new Example(ENTITY_CLASS);
            example.and().andEqualTo("id", new Integer(parameters.get("id").toString())).andEqualTo("state", "4");
            device.setState("9");
            example.and().andEqualTo("id", new Integer(parameters.get("id").toString())).andEqualTo("state", Constants.DEVICE_STATE_OFFLINE);
            device.setState(Constants.DEVICE_STATE_MAINTENANCE);
            count = deviceMapper.updateByExampleSelective(device, example);
        } 
        if (count == 0) {