|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.moral.api.entity.DeviceAdjustValue; | 
|---|
|  |  |  | import com.moral.api.pojo.form.adjust.AdjustForm; | 
|---|
|  |  |  | import com.moral.api.service.DeviceAdjustValueService; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.WebUtils; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  | return ResultMessage.fail(Integer.parseInt(resultMap.get("code").toString()),resultMap.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "refreshRedis", method = RequestMethod.POST) | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public ResultMessage refreshRedis() { | 
|---|
|  |  |  | Map<String,Object> resultMap = deviceAdjustValueService.refreshRedis(); | 
|---|
|  |  |  | String msg = resultMap.get("msg").toString(); | 
|---|
|  |  |  | int code = Integer.parseInt(resultMap.get("code").toString()); | 
|---|
|  |  |  | if (code == 0){ | 
|---|
|  |  |  | return ResultMessage.ok(msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.fail(Integer.parseInt(resultMap.get("code").toString()),resultMap.get("msg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 批量查询校准值 | 
|---|
|  |  |  | * @param parameters | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("getAllAdjust") | 
|---|
|  |  |  | public ResultMessage getAllAdjust(@RequestBody Map<String, Object> parameters){ | 
|---|
|  |  |  | if (!parameters.containsKey("id")|| !parameters.containsKey("code")){ | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Map<String, Object>> allAdjust = deviceAdjustValueService.getAllAdjust(parameters); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(allAdjust)){ | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.TARGET_IS_NULL.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(allAdjust); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 批量修改校准值 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("updateAllAdjust") | 
|---|
|  |  |  | public ResultMessage updateAllAdjust( @RequestBody Map<String, List<AdjustForm>> parameters){ | 
|---|
|  |  |  | List<AdjustForm> o = parameters.get("AdjustForm"); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(o)){ | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.TARGET_IS_NULL.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, Object> map = deviceAdjustValueService.updateAllAdjust(o); | 
|---|
|  |  |  | int code = Integer.parseInt(map.get("code").toString()); | 
|---|
|  |  |  | if (code != 0){ | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.FAIL.getCode(),ResponseCodeEnum.FAIL.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.SUCCESS.getCode(),ResponseCodeEnum.SUCCESS.getMsg()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        return ResultMessage.ok(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|