| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.annotation.CloudRequiredPermission; |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.config.jwt.JwtProperties; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.*; |
| | | import com.doumee.core.haikang.model.param.request.event.acs.EventAcsRequest; |
| | | import com.doumee.core.haikang.model.param.request.event.parks.EventParkRequest; |
| | | import com.doumee.core.haikang.model.param.request.event.parks.EventPlatformCarsRequest; |
| | | import com.doumee.core.haikang.model.param.request.event.parks.EventPlatformRequest; |
| | | import com.doumee.core.haikang.model.param.request.event.visit.EventVisitIccmRequest; |
| | | import com.doumee.core.haikang.model.param.request.event.visit.EventVisitRequest; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.service.business.third.model.ApiResponse; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DESUtil; |
| | | import com.doumee.dao.business.model.Device; |
| | | import com.doumee.service.business.DeviceService; |
| | | import com.doumee.service.business.impl.hksync.*; |
| | | import com.doumee.service.business.impl.hksync.ferp.HkSyncOrgUserToHKServiceImpl; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | 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 javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Api(tags = "æµ·åº·æ°æ®åæ¥æ¥å£") |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/business/hksync") |
| | | public class HkSyncCloudController extends BaseController { |
| | | |
| | | @Autowired |
| | | private HkSyncPlatformsServiceImpl hkSyncPlatformsService; |
| | | @Autowired |
| | | private HkSyncDeviceServiceImpl hkSyncDeviceService; |
| | | @Autowired |
| | | private HkSyncParkServiceImpl hkSyncParkService; |
| | | @Autowired |
| | | private HkSyncPrivilegeServiceImpl hkSyncPrivilegeService; |
| | | @Autowired |
| | | private HkSyncPushServiceImpl hkSyncPushService; |
| | | @Autowired |
| | | private HkSyncOrgUserToHKServiceImpl hkSyncOrgUserToHKService; |
| | | @Autowired |
| | | private HkSyncNoticeServiceImpl hkSyncNoticeService; |
| | | @Autowired |
| | | private HkSyncLoginAuthServiceImpl hkSyncLoginAuthService; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String,Object> redisTemplate; |
| | | |
| | | @Autowired |
| | | private JwtProperties jwtProperties; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãå
¨é忥æå°ä¿¡æ¯æ¥å£") |
| | | @PostMapping("/syncPlatforms") |
| | | @CloudRequiredPermission("business:hksync:platforms") |
| | | public ApiResponse syncPlatforms(@RequestBody PlatformsListRequest param) { |
| | | String result = hkSyncPlatformsService.syncPlatforms(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãå
¨é忥æå°ç¶æä¿¡æ¯æ¥å£") |
| | | @PostMapping("/syncPlatformStatus") |
| | | @CloudRequiredPermission("business:hksync:platforms") |
| | | public ApiResponse syncPlatformStatus(@RequestBody PlatformStatusRequest param) { |
| | | String result = hkSyncPlatformsService.getPlatformStatus(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãå
¨é忥é¨ç¦è®¾å¤æ¥å£") |
| | | @PostMapping("/syncDevices") |
| | | @CloudRequiredPermission("business:hksync:device") |
| | | public ApiResponse syncHkDevices(@RequestBody Device param, @RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | String result = null; |
| | | if(Constants.equalsInteger(param.getType(),Constants.ZERO)){ |
| | | result = hkSyncDeviceService.syncHkDevices(param); |
| | | }else if(Constants.equalsInteger(param.getType(),Constants.TWO)){ |
| | | //忥LED |
| | | result = hkSyncDeviceService.syncHkLed(param); |
| | | }else if(Constants.equalsInteger(param.getType(),Constants.THREE)){ |
| | | //åæ¥å¹¿æ |
| | | result = hkSyncDeviceService.syncHkBroadcast(param); |
| | | } |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãä¿åæµ·åº·ç¨æ·ç»å®openid") |
| | | @PostMapping("/saveHkUserOpenid") |
| | | public ApiResponse syncHkUserOpenid( @RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | String result = hkSyncOrgUserToHKService.syncHkUserOpenid(this.getLoginUser(token).getId()); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãæ¸
ç©ºæµ·åº·ç¨æ·ç»å®openid") |
| | | @PostMapping("/delHkUserOpenid") |
| | | @LoginNoRequired |
| | | public ApiResponse delHkUserOpenid( @RequestBody UserOpenidSaveRequest param){ |
| | | String result = hkSyncOrgUserToHKService.delHkUserOpenid(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãè·åç»ä»¶ææç»å½å°åæ¥å£") |
| | | @PostMapping("/getServiceUrl") |
| | | public ApiResponse getServiceUrl(@RequestBody HKGetServiceLoginUrlRequest param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | param.setUsername(this.getLoginUser(token).getUsername()); |
| | | String result = hkSyncLoginAuthService.getServiceUrl(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãå
¨é忥åè½¦åºæ¥å£") |
| | | @PostMapping("/syncParks") |
| | | @CloudRequiredPermission("business:hksync:park") |
| | | public ApiResponse syncHkParks(@RequestBody ParkListRequest param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | String result = hkSyncParkService.syncHkParks(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãå
¨éåæ¥è®¿å®¢æéç»æ¥å£") |
| | | @PostMapping("/syncPrivilege") |
| | | @CloudRequiredPermission("business:hksync:privilege") |
| | | public ApiResponse syncPrivilege(@RequestBody PrivilegeGroupRequest param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | String result = hkSyncPrivilegeService.syncPrivilege(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | // @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãé¨ç¦äºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/acs") |
| | | @LoginNoRequired |
| | | public ApiResponse pushAcs( HttpServletRequest request,@RequestBody EventAcsRequest param, HttpServletResponse response ){ |
| | | String result = hkSyncPushService.dealAcsEvent(param,response); |
| | | return ApiResponse.success(result); |
| | | } |
| | | // @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ã访客äºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/visit") |
| | | @LoginNoRequired |
| | | public ApiResponse pushVisit(@RequestBody EventVisitRequest param, HttpServletResponse response){ |
| | | String result = hkSyncPushService.dealVisitEvent(param,response); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ã访客ICCMäºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/visitIccm") |
| | | @LoginNoRequired |
| | | public ApiResponse pushVisitIccm(@RequestBody EventVisitIccmRequest param, HttpServletResponse response) { |
| | | String result = hkSyncPushService.dealVisitEventIccm(param,response); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ãæµè¯LEDæ¾ç¤ºå±") |
| | | @PostMapping("/testLed") |
| | | @LoginNoRequired |
| | | public ApiResponse<BaseResponse> testLed(@RequestBody TransparentChannelBodyRequest request, HttpServletResponse response) { |
| | | TransparentChannelHeadRequest head = new TransparentChannelHeadRequest(); |
| | | head.setAbility("cld");//åºå®å¼ |
| | | head.setTreatyType("haixuan_led_net");//åºå®å¼ |
| | | head.setDeviceIndexCode("6a5498e9df924befbb9530e467e5e809"); |
| | | return ApiResponse.success(HKService.transparentchannel(head,request)); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ãæµè¯å¹¿æææ¥") |
| | | @PostMapping("/testBroadcast") |
| | | @LoginNoRequired |
| | | public ApiResponse<BaseResponse> testBroadcast(@RequestBody CustomBroadcastRequest request, HttpServletResponse response) { |
| | | return ApiResponse.success( HKService.customBroadcast(request)); |
| | | } |
| | | // @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãå车åºäºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/parks") |
| | | @LoginNoRequired |
| | | public ApiResponse pushParks(@RequestBody EventParkRequest param, HttpServletResponse response ){ |
| | | String result = hkSyncPushService.dealParkEvent(param,response); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ãæå°å·¥ä½ç¶æäºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/platform/workstatus") |
| | | @LoginNoRequired |
| | | public ApiResponse pushPlatformStatus(@RequestBody EventPlatformRequest param, HttpServletResponse response ){ |
| | | String result = hkSyncPushService.dealPlatformStatusEvent(param,response); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ãæå°è½¦è¾ç¶æäºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/platform/carstatus") |
| | | @LoginNoRequired |
| | | public ApiResponse pushPlatformCarStatus(@RequestBody EventPlatformCarsRequest param, HttpServletResponse response ){ |
| | | String result = hkSyncPushService.dealPlatformCarsEvent(param,response); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @ApiOperation("ãæµ·åº·testãæå°è½¦è¾ç¶æäºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£") |
| | | @PostMapping("/push/platform/carstatusTest") |
| | | @LoginNoRequired |
| | | public ApiResponse pushPlatformCarStatus(HttpServletRequest request, HttpServletResponse response ){ |
| | | doPringParam(request,"ãæµ·åº·testãæå°è½¦è¾ç¶æäºä»¶è®¢é
æ¨é对æ¥å¤çæ¥å£:\n"); |
| | | return ApiResponse.success(null); |
| | | } |
| | | public void doPringParam(HttpServletRequest request,String name) { |
| | | try { |
| | | StringBuilder data =new StringBuilder(); |
| | | String line; |
| | | BufferedReader reader =request.getReader(); |
| | | while(null !=(line = reader.readLine())) { |
| | | data.append(line); |
| | | } |
| | | if(StringUtils.isNotBlank( data.toString())){ |
| | | log.info(name+"=================åæ°ï¼"+ data.toString()); |
| | | }else { |
| | | log.info(name+"=================ï¼åæ°ä¸ºç©º"); |
| | | } |
| | | }catch (Exception e){ |
| | | |
| | | log.info(name+"================= åæ°å¼å¸¸ï¼"+e.getMessage()); |
| | | } |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("ãæµ·åº·ãåæ¶è®¢é
äºä»¶") |
| | | @PostMapping("/cancelEventSub") |
| | | @LoginNoRequired |
| | | public ApiResponse cancelEventSub(@RequestBody EventSubRequest param, HttpServletResponse response){ |
| | | hkSyncPushService.cancelEventSub(); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | /** |
| | | * è·åå®é²å¹³å°ç³»ç»å
å¯èåè°æ´å°å |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "è·åå®é²å¹³å°ç³»ç»å
å¯èåè°æ´å°å" ) |
| | | @PostMapping("/getHkMenuLink/{type}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "type",example = "0",value = "èåç±»å", required = true), |
| | | }) |
| | | public ApiResponse<String> getHkMenuLink(@PathVariable Integer type,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | LoginUserInfo loginUserInfo = this.getLoginUser(token); |
| | | String hkToken = DESUtil.generateTokenToHk(loginUserInfo.getUsername(),Integer.valueOf( |
| | | systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_TOKEN_VALIDITY).getCode() |
| | | ),redisTemplate); |
| | | String url = systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_HTTPS).getCode() + |
| | | systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.HK_HOST).getCode() |
| | | + HKService.getMenuUrl(type,hkToken); |
| | | try { |
| | | if(redisTemplate!=null&& jwtProperties!=null){ |
| | | loginUserInfo.setHkMenuToken(hkToken); |
| | | redisTemplate.opsForValue().set(Constants.REDIS_TOKEN_KEY+token, JSONObject.toJSONString(loginUserInfo),jwtProperties.getExpiration(), TimeUnit.MILLISECONDS); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return ApiResponse.success( url); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åå®é²å¹³å°ç³»ç»å
å¯èåé
ç½®" ) |
| | | @GetMapping("/getHkMenuConfig") |
| | | public ApiResponse<List<Integer>> getHkMenuConfig(@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | LoginUserInfo loginUserInfo = getLoginUser(token); |
| | | List<Integer> menuConfigList = new ArrayList<>(); |
| | | if(Objects.nonNull(loginUserInfo) && StringUtils.isNotBlank(loginUserInfo.getUsername())){ |
| | | menuConfigList = hkSyncPlatformsService.getMenuConfig(loginUserInfo.getUsername()); |
| | | } |
| | | return ApiResponse.success(menuConfigList); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("ãæµ·åº·ãä»£åæ¶æ¯æ°æ®éå对æ¥å¤çæ¥å£") |
| | | @PostMapping("/notice/getList") |
| | | public ApiResponse getNoticeList( HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token ){ |
| | | String result = hkSyncNoticeService.syncHkNotices(this.getLoginUser(token).getUsername()); |
| | | return ApiResponse.success(result); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("ãæµ·åº·ã设置LED屿æ¡") |
| | | @PostMapping("/setLedContent") |
| | | public ApiResponse<List<Map<String,Object>>> setLedContent(@RequestBody TransparentChannelSingleRequest body , HttpServletResponse response) { |
| | | deviceService.setLedContent(body); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | } |