|  | @@ -1,90 +1,89 @@
 | 
	
		
			
				|  |  | -/*
 | 
	
		
			
				|  |  | -package com.xunmei.mediator.api.controller;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | -import com.isp.mediator.api.dto.DataPageDto;
 | 
	
		
			
				|  |  | -import com.isp.mediator.api.dto.protection.ReceiveErrorDto;
 | 
	
		
			
				|  |  | -import com.isp.mediator.upsandloop.dto.BreakerDeviceDataDto;
 | 
	
		
			
				|  |  | -import com.isp.mediator.upsandloop.dto.BreakerDeviceDto;
 | 
	
		
			
				|  |  | -import com.isp.mediator.upsandloop.service.IBreakerDeviceService;
 | 
	
		
			
				|  |  | -import com.isp.mediator.utils.LogUtils;
 | 
	
		
			
				|  |  | -import com.isp.mediator.utils.RedisCheckRepeatDataUtil;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +package com.xunmei.mediator.api.breaker.controller;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson2.JSON;
 | 
	
		
			
				|  |  | +import com.xunmei.mediator.api.breaker.dto.BreakerDeviceDataDto;
 | 
	
		
			
				|  |  | +import com.xunmei.mediator.api.breaker.dto.BreakerDeviceDto;
 | 
	
		
			
				|  |  | +import com.xunmei.mediator.api.breaker.service.IotBreakerDeviceService;
 | 
	
		
			
				|  |  | +import com.xunmei.mediator.util.RedisCheckRepeatDataUtil;
 | 
	
		
			
				|  |  | +import com.xunmei.system.api.dto.DataPageDto;
 | 
	
		
			
				|  |  | +import com.xunmei.system.api.dto.protection.ReceiveErrorDto;
 | 
	
		
			
				|  |  | +import com.xunmei.system.api.util.LogUtils;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | -import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | -import org.springframework.data.redis.core.RedisTemplate;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.PostMapping;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RequestBody;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -*/
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * <p>
 | 
	
		
			
				|  |  | - * 8小时回路信息同步表 前端控制器
 | 
	
		
			
				|  |  | + * 8小时回路信息同步表 前端控制器i
 | 
	
		
			
				|  |  |   * </p>
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   * @author oygj
 | 
	
		
			
				|  |  |   * @since 2022-11-28
 | 
	
		
			
				|  |  | - *//*
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @RestController
 | 
	
		
			
				|  |  |  @RequestMapping
 | 
	
		
			
				|  |  |  public class BreakerController {
 | 
	
		
			
				|  |  |      @Resource
 | 
	
		
			
				|  |  | -    IBreakerDeviceService breakerDeviceService;
 | 
	
		
			
				|  |  | -    @Autowired
 | 
	
		
			
				|  |  | -    private RedisTemplate redisTemplate;
 | 
	
		
			
				|  |  | -    @Resource
 | 
	
		
			
				|  |  | -    private RedisCheckRepeatDataUtil redisCheckRepeatDataUtil;
 | 
	
		
			
				|  |  | +    IotBreakerDeviceService breakerDeviceService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation("接受8小时回路信息同步")
 | 
	
		
			
				|  |  | -    @PostMapping({"/api/{branchId}/data/breakerDeviceList"})
 | 
	
		
			
				|  |  | -    public ReceiveErrorDto breakerDeviceList(@PathVariable String branchId, String msgId, @RequestBody DataPageDto<BreakerDeviceDto> request) {
 | 
	
		
			
				|  |  | -        LogUtils.BASE_INFO_BREAKER_DEVICE.info("【北向接口-{}】【branchId:{}】【msgId:{}】【接收参数:{}】", "接受8小时回路信息同步:/api/data/breakerDeviceList", branchId, msgId, JSON.toJSONString(request));
 | 
	
		
			
				|  |  | +    @PostMapping({"/api/data/breakerDeviceList"})
 | 
	
		
			
				|  |  | +    public ReceiveErrorDto breakerDeviceList(String msgId, @RequestBody DataPageDto<BreakerDeviceDto> request) {
 | 
	
		
			
				|  |  | +        LogUtils.BASE_INFO_BREAKER_DEVICE.info("【北向接口-{}】msgId:{}】【接收参数:{}】", "接受8小时回路信息同步:/api/data/breakerDeviceList", msgId, JSON.toJSONString(request));
 | 
	
		
			
				|  |  |          ReceiveErrorDto errorDto = ReceiveErrorDto.success();
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  | -            errorDto = this.breakerDeviceService.saveBreakerDevice(request, msgId, branchId);
 | 
	
		
			
				|  |  | +            errorDto = this.breakerDeviceService.saveBreakerDevice(request, msgId);
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  |              LogUtils.BASE_INFO_BREAKER_DEVICE.error("保存失败,{}", e);
 | 
	
		
			
				|  |  | -            return ReceiveErrorDto.error("保存失败:"+ e);
 | 
	
		
			
				|  |  | +            return ReceiveErrorDto.error("保存失败:" + e);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        LogUtils.BASE_INFO_BREAKER_DEVICE.info("【北向接口-{}】【branchId:{}】【msgId:{}】【返回参数:{}】", "接受8小时回路信息同步:/api/data/breakerDeviceList", branchId, msgId, JSON.toJSONString(errorDto));
 | 
	
		
			
				|  |  | +        LogUtils.BASE_INFO_BREAKER_DEVICE.info("【北向接口-{}】msgId:{}】【返回参数:{}】", "接受8小时回路信息同步:/api/data/breakerDeviceList", msgId, JSON.toJSONString(errorDto));
 | 
	
		
			
				|  |  |          return errorDto;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation("8小时回路实时状态信息")
 | 
	
		
			
				|  |  | -    @PostMapping({"/api/{branchId}/status/breaker"})
 | 
	
		
			
				|  |  | -    public ReceiveErrorDto statusBreaker(@PathVariable String branchId, String msgId, @RequestBody BreakerDeviceDataDto request) {
 | 
	
		
			
				|  |  | -        LogUtils.BASE_INFO_BREAKER_DEVICE_DATA.info("【北向接口-{}】【branchId:{}】【msgId:{}】【接收参数:{}】", "8小时回路实时状态信息:/api/status/breaker", branchId, msgId, JSON.toJSONString(request));
 | 
	
		
			
				|  |  | +    @PostMapping({"/api/status/breaker"})
 | 
	
		
			
				|  |  | +    public ReceiveErrorDto statusBreaker(String msgId, @RequestBody BreakerDeviceDataDto request) {
 | 
	
		
			
				|  |  | +        LogUtils.BASE_INFO_BREAKER_DEVICE_DATA.info("【北向接口-{}】【branchId:{}】接收参数:{}】", "8小时回路实时状态信息:/api/status/breaker", msgId, JSON.toJSONString(request));
 | 
	
		
			
				|  |  |          ReceiveErrorDto errorDto = ReceiveErrorDto.success();
 | 
	
		
			
				|  |  | -        String value = request.getStatus()+"";
 | 
	
		
			
				|  |  | +        String value = request.getStatus() + "";
 | 
	
		
			
				|  |  |          //String key =request.getOrgCode()+request.getDeviceCode()+"breakerdata"+ DateUtil.format(new Date(),"yyyyMMdd");
 | 
	
		
			
				|  |  | -        String key =request.getOrgCode()+request.getDeviceCode()+"breakerdata";
 | 
	
		
			
				|  |  | +        String key = request.getOrgCode() + request.getDeviceCode() + "breakerdata";
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              //目前对数据不做拦截
 | 
	
		
			
				|  |  | -             */
 | 
	
		
			
				|  |  | -/*if(redisCheckRepeatDataUtil.checkData(key,value,24*60*60*1000)){*//*
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            //修改为状态不变用不接受
 | 
	
		
			
				|  |  | -            if(redisCheckRepeatDataUtil.checkData(key,value,-1)){
 | 
	
		
			
				|  |  | -                 errorDto = this.breakerDeviceService.saveBreakerData(request, msgId, branchId);
 | 
	
		
			
				|  |  | -            }else{
 | 
	
		
			
				|  |  | -                 //保存拦截数据
 | 
	
		
			
				|  |  | -                 this.breakerDeviceService.saveBreakerDataLog(request, msgId, branchId);
 | 
	
		
			
				|  |  | -                errorDto.setSuccess(true);
 | 
	
		
			
				|  |  | -                errorDto.setErrorMsg("数据已接受,短时间内收到相同的回路数据,处理结果忽略:拒绝处理该数据");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (RedisCheckRepeatDataUtil.checkData(key, value, 24 * 60 * 60 * 1000)) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //修改为状态不变用不接受
 | 
	
		
			
				|  |  | +                if (RedisCheckRepeatDataUtil.checkData(key, value, -1)) {
 | 
	
		
			
				|  |  | +                    errorDto = this.breakerDeviceService.saveBreakerData(request, msgId);
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    //保存拦截数据
 | 
	
		
			
				|  |  | +                    this.breakerDeviceService.saveBreakerDataLog(request, msgId);
 | 
	
		
			
				|  |  | +                    errorDto.setSuccess(true);
 | 
	
		
			
				|  |  | +                    errorDto.setErrorMsg("数据已接受,短时间内收到相同的回路数据,处理结果忽略:拒绝处理该数据");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  |              LogUtils.BASE_INFO_BREAKER_DEVICE_DATA.error("保存失败,{}", e);
 | 
	
		
			
				|  |  | -            return ReceiveErrorDto.error("保存失败:"+ e);
 | 
	
		
			
				|  |  | +            return ReceiveErrorDto.error("保存失败:" + e);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        LogUtils.BASE_INFO_BREAKER_DEVICE_DATA.info("【北向接口-{}】【branchId:{}】【msgId:{}】【返回参数:{}】", "8小时回路实时状态信息:/api/status/breaker", branchId, msgId, JSON.toJSONString(errorDto));
 | 
	
		
			
				|  |  | +        LogUtils.BASE_INFO_BREAKER_DEVICE_DATA.info("【北向接口-{}】【msgId:{}】【返回参数:{}】", "8小时回路实时状态信息:/api/status/breaker", msgId, JSON.toJSONString(errorDto));
 | 
	
		
			
				|  |  |          return errorDto;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -*/
 | 
	
		
			
				|  |  | +
 |