| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.openapi; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.service.business.third.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.*; |
| | | import com.doumee.service.system.SystemUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Api(tags = "æä¾å®é²å¹³å°å¯¹æ¥æ¥å£ï¼æ°æ®å¤§å±åºç¡æ°æ®çï¼") |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/hk/api") |
| | | public class HkOpenApiController extends BaseController { |
| | | |
| | | @Autowired |
| | | private PlatformService platformService; |
| | | @Autowired |
| | | private InterfaceLogService interfaceLogService; |
| | | |
| | | @Autowired |
| | | private PlatformLogService platformLogService; |
| | | |
| | | @Autowired |
| | | private PlatformJobService platformJobService; |
| | | |
| | | @Autowired |
| | | private PlatformWarnEventService platformWarnEventService; |
| | | |
| | | @Autowired |
| | | private PlatformWaterGasService platformWaterGasService; |
| | | |
| | | @Autowired |
| | | private SystemUserService systemUserService; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String,Object> redisTemplate; |
| | | |
| | | @LoginNoRequired |
| | | @ApiOperation("tokenè§£æ") |
| | | @GetMapping("/water/decodeToken") |
| | | public Map<String,Object> decodeToken(@RequestParam String token) { |
| | | log.info("ãå®é²å¹³å°åç¹ç»å½tokenè§£æã================="+token); |
| | | int success = Constants.ZERO; |
| | | Map<String,Object> result = new HashMap<>() ; |
| | | try { |
| | | HkBaseTokenRequest hkBaseTokenRequest = new HkBaseTokenRequest(); |
| | | hkBaseTokenRequest.setToken(token); |
| | | result = this.decodeTokenForHk(hkBaseTokenRequest); |
| | | }catch (BusinessException e){ |
| | | log.error("ãå®é²å¹³å°ãåç¹ç»å½tokenè§£===失败ï¼"+e.getMessage()); |
| | | success = Constants.ONE; |
| | | }catch (Exception e){ |
| | | log.error("ãå®é²å¹³å°ãåç¹ç»å½tokenè§£æ===失败ï¼"+e.getMessage()); |
| | | e.printStackTrace(); |
| | | success = Constants.ONE; |
| | | }finally { |
| | | interfaceLogService.saveInterfaceLog("/hk/api/water/decodeToken", "ãå®é²å¹³å°ãåç¹ç»å½tokenè§£æ",token, |
| | | success, JSONObject.toJSONString(result),Constants.ZERO); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | 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())){ |
| | | 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)){ |
| | | result.put("code","-1"); |
| | | result.put("msg","tokenæ æ!"); |
| | | return result; |
| | | } |
| | | String userName = DESUtil.verifyHkToken( redisToken);; |
| | | if(StringUtils.isBlank(userName)){ |
| | | result.put("code","-1"); |
| | | result.put("msg","tokenåæ°ä¸ºç©º"); |
| | | return result; |
| | | } |
| | | //æ¥è¯¢ç¨æ·ä¿¡æ¯æ¯å¦åå¨ |
| | | SystemUser systemUser = new SystemUser(); |
| | | systemUser.setUsername(userName); |
| | | systemUser.setDeleted(Boolean.FALSE); |
| | | SystemUser queryBean = systemUserService.findOne(systemUser); |
| | | if(Objects.isNull(queryBean)){ |
| | | result.put("code","-1"); |
| | | result.put("msg","tokenåæ°ä¸ºç©º"); |
| | | return result; |
| | | } |
| | | if(Constants.equalsInteger(queryBean.getStatus(),Constants.ONE)){ |
| | | result.put("code","-2"); |
| | | result.put("msg","ç¨æ·å·²ç¦ç¨"); |
| | | return result; |
| | | } |
| | | redisTemplate.delete(Constants.REDIS_HK_TOKEN_KEY+hkBaseTokenRequest.getToken()); |
| | | Map<String,Object> data = new HashMap<>(); |
| | | data.put("userId",userName); |
| | | result.put("data",data); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãç¨æ°´éãæ¬æã䏿åå»å¹´åæ") |
| | | @PostMapping("/water/dataByMonth") |
| | | public ApiResponse<WaterByMonthResponse> waterDataByMonth(@RequestBody WaterByMonthRequest param) { |
| | | return ApiResponse.success(platformWaterGasService.waterDataByMonth(param)); |
| | | } |
| | | |
| | | @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/orderNumByDate") |
| | | public ApiResponse<PlatformOrderNumByDateResponse> orderNumByDate(@RequestBody PlatformOrderNumByDateRequest param) { |
| | | return ApiResponse.success(platformJobService.orderNumByDate(param)); |
| | | } |
| | | |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãæå°ç¶ææ°éç»è®¡") |
| | | @PostMapping("/platform/totalNumByStatus") |
| | | public ApiResponse<PlatformNumByStatusResponse> totalNumByStatus(@RequestBody PlatformNumByStatusRequest param) { |
| | | return ApiResponse.success(platformService.getPlatformNumByStatusResponse()); |
| | | } |
| | | |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãæå°å½åä½ä¸ä¿¡æ¯å表") |
| | | @PostMapping("/platform/workingDataList") |
| | | public ApiResponse<List<PlatformDataListResponse>> workingDataList(@RequestBody PlatformDataListRequest param) { |
| | | return ApiResponse.success(platformJobService.platformWorkingDataList(param)); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãæå°ä½ä¸è¯¦æ
ä¿¡æ¯") |
| | | @PostMapping("/platform/workDataInfo") |
| | | public ApiResponse<PlatformDataInfoResponse> workDataInfo(@RequestBody PlatformDataInfoRequest param) { |
| | | return ApiResponse.success(platformJobService.platformWorkingDataList(param)); |
| | | } |
| | | |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãå½å车è¾ç¶ææ°éç»è®¡") |
| | | @PostMapping("/platform/carStatusNum") |
| | | public ApiResponse<CarNumByStatusResponse> carStatusNum(@RequestBody CarNumByStatusRequest param) { |
| | | return ApiResponse.success(platformJobService.carStatusNum(param)); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ã车è¾äºä»¶åè¡¨æ°æ®éåï¼ææ°Næ¡ï¼") |
| | | @PostMapping("/platform/carLogsList") |
| | | public ApiResponse<List<CarLogsListResponse>> carLogsList(@RequestBody CarLogsListRequest param) { |
| | | return ApiResponse.success(platformLogService.getCarLogsListResponse(param)); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãæééåå表éå") |
| | | @PostMapping("/platform/queueList") |
| | | public ApiResponse<PlatformQueuingListResponse> queueList(@RequestBody PlatformQueuingListRequest param) { |
| | | return ApiResponse.success(platformJobService.queueList(param)); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãé¢è¦äºä»¶éåå表") |
| | | @PostMapping("/platform/warningEventList") |
| | | public ApiResponse<List<PlatformWarnEventListResponse>> warningEventList(@RequestBody PlatformWarnEventListRequest param) { |
| | | return ApiResponse.success(platformWarnEventService.findListToHk()); |
| | | } |
| | | |
| | | @LoginNoRequired |
| | | @PreventRepeat |
| | | @ApiOperation("ãæå°ãæå°ç¶æ") |
| | | @PostMapping("/platform/getStatusList") |
| | | public ApiResponse<List<PlatformStatusListResponse>> getStatusList() { |
| | | return ApiResponse.success(platformService.getPlatformStatusList()); |
| | | } |
| | | |
| | | } |