|  |  |  | 
|---|
|  |  |  | package com.doumee.cloud.openapi; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.emay.sdk.util.AES; | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.config.annotation.LoginNoRequired; | 
|---|
|  |  |  | import com.doumee.config.jwt.JwtTokenUtil; | 
|---|
|  |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DESUtil; | 
|---|
|  |  |  | import com.doumee.dao.openapi.request.*; | 
|---|
|  |  |  | import com.doumee.dao.openapi.response.*; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformJobService; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformLogService; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformService; | 
|---|
|  |  |  | import com.doumee.service.business.PlatformWaterGasService; | 
|---|
|  |  |  | import com.doumee.service.business.*; | 
|---|
|  |  |  | import com.doumee.service.system.SystemUserService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.net.URLDecoder; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | private PlatformJobService platformJobService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformWarnEventService platformWarnEventService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformWaterGasService platformWaterGasService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | @LoginNoRequired | 
|---|
|  |  |  | @ApiOperation("token解析") | 
|---|
|  |  |  | @GetMapping("/water/decodeToken") | 
|---|
|  |  |  | public ApiResponse<Map<String,Object>> decodeToken(@RequestParam String token) { | 
|---|
|  |  |  | public Map<String,Object> decodeToken(@RequestParam String token) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | token = URLDecoder.decode(token,"UTF-8"); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HkBaseTokenRequest hkBaseTokenRequest = new HkBaseTokenRequest(); | 
|---|
|  |  |  | hkBaseTokenRequest.setToken(token); | 
|---|
|  |  |  | return ApiResponse.success(this.decodeTokenForHk(hkBaseTokenRequest)); | 
|---|
|  |  |  | return this.decodeTokenForHk(hkBaseTokenRequest); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Map<String,Object> decodeTokenForHk(HkBaseTokenRequest hkBaseTokenRequest){ | 
|---|
|  |  |  | Map<String,Object> result = new HashMap<>(); | 
|---|
|  |  |  | result.put("code","0"); | 
|---|
|  |  |  | result.put("msg","success"); | 
|---|
|  |  |  | if(Objects.isNull(hkBaseTokenRequest)||StringUtils.isBlank(hkBaseTokenRequest.getToken())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"token参数为空"); | 
|---|
|  |  |  | result.put("code","-1"); | 
|---|
|  |  |  | result.put("msg","token参数为空"); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String redisToken = (String) redisTemplate.opsForValue().get(Constants.REDIS_HK_TOKEN_KEY+hkBaseTokenRequest.getToken()); | 
|---|
|  |  |  | if(StringUtils.isBlank(redisToken)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"token解析失败"); | 
|---|
|  |  |  | result.put("code","-1"); | 
|---|
|  |  |  | result.put("msg","token无效!"); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String userName = DESUtil.verifyHkToken(hkBaseTokenRequest.getToken()); | 
|---|
|  |  |  | if(StringUtils.isBlank(userName)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"token解析失败"); | 
|---|
|  |  |  | result.put("code","-1"); | 
|---|
|  |  |  | result.put("msg","token参数为空"); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询用户信息是否存在 | 
|---|
|  |  |  | SystemUser systemUser = new SystemUser(); | 
|---|
|  |  |  | 
|---|
|  |  |  | systemUser.setDeleted(Boolean.FALSE); | 
|---|
|  |  |  | SystemUser queryBean = systemUserService.findOne(systemUser); | 
|---|
|  |  |  | if(Objects.isNull(queryBean)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"token解析失败"); | 
|---|
|  |  |  | result.put("code","-1"); | 
|---|
|  |  |  | result.put("msg","token参数为空"); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(queryBean.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"用户已禁用"); | 
|---|
|  |  |  | result.put("code","-2"); | 
|---|
|  |  |  | result.put("msg","用户已禁用"); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | redisTemplate.delete(Constants.REDIS_HK_TOKEN_KEY+hkBaseTokenRequest.getToken()); | 
|---|
|  |  |  | Map<String,Object> result = new HashMap<>(); | 
|---|
|  |  |  | result.put("userId",userName); | 
|---|
|  |  |  | Map<String,Object> data = new HashMap<>(); | 
|---|
|  |  |  | data.put("userId",userName); | 
|---|
|  |  |  | result.put("data",data); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginNoRequired | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("【用水量】近12个月用水量信息列表") | 
|---|
|  |  |  | @PostMapping("/water/lastMonthsDataList") | 
|---|
|  |  |  | public ApiResponse<List<PlatformLastMonthListResponse>> lastMonthsWaterList() { | 
|---|
|  |  |  | return ApiResponse.success(platformWaterGasService.getPlatformLastMonthListResponse(Constants.ZERO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginNoRequired | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("【用气量】本月、上月和去年同月") | 
|---|
|  |  |  | @PostMapping("/gas/dataByMonth") | 
|---|
|  |  |  | public ApiResponse<GasByMonthResponse> gasDataByMonth(@RequestBody GasByMonthRequest param) { | 
|---|
|  |  |  | return ApiResponse.success(platformWaterGasService.gasDataByMonth(param)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginNoRequired | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("【用气量】近12个月用气量信息列表") | 
|---|
|  |  |  | @PostMapping("/gas/lastMonthsDataList") | 
|---|
|  |  |  | public ApiResponse<List<PlatformLastMonthListResponse>> lastMonthsGasList () { | 
|---|
|  |  |  | return ApiResponse.success(platformWaterGasService.getPlatformLastMonthListResponse(Constants.ONE)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginNoRequired | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("【月台】月台当前作业信息列表") | 
|---|
|  |  |  | @PostMapping("/platform/workingDataList") | 
|---|
|  |  |  | public ApiResponse<List<PlatformDataListResponse>> platformWorkingDataList(@RequestBody PlatformDataListRequest param) { | 
|---|
|  |  |  | public ApiResponse<List<PlatformDataListResponse>> workingDataList(@RequestBody PlatformDataListRequest param) { | 
|---|
|  |  |  | return ApiResponse.success(platformJobService.platformWorkingDataList(param)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("【月台】月台作业详情信息") | 
|---|
|  |  |  | @PostMapping("/platform/workDataInfo") | 
|---|
|  |  |  | public ApiResponse<PlatformDataInfoResponse> platformWorkingDataList(@RequestBody PlatformDataInfoRequest param) { | 
|---|
|  |  |  | public ApiResponse<PlatformDataInfoResponse> workDataInfo(@RequestBody PlatformDataInfoRequest param) { | 
|---|
|  |  |  | return ApiResponse.success(platformJobService.platformWorkingDataList(param)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiOperation("【月台】预警事件集合列表") | 
|---|
|  |  |  | @PostMapping("/platform/warningEventList") | 
|---|
|  |  |  | public ApiResponse<List<PlatformWarnEventListResponse>> warningEventList(@RequestBody PlatformWarnEventListRequest param) { | 
|---|
|  |  |  | return ApiResponse.success(new ArrayList<>()); | 
|---|
|  |  |  | return ApiResponse.success(platformWarnEventService.findListToHk()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @LoginNoRequired | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("【月台】月台状态") | 
|---|
|  |  |  | @PostMapping("/platform/getStatusList") | 
|---|
|  |  |  | public ApiResponse<List<PlatformStatusListResponse>> getStatusList() { | 
|---|
|  |  |  | return ApiResponse.success(platformService.getPlatformStatusList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|