123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- package com.fdkankan.manage.controller;
- import cn.dev33.satoken.stp.StpUtil;
- import com.alibaba.fastjson.JSONObject;
- import com.fdkankan.manage.common.ResultCode;
- import com.fdkankan.manage.entity.*;
- import com.fdkankan.manage.exception.BusinessException;
- import com.fdkankan.manage.common.ResultData;
- import com.fdkankan.manage.httpClient.client.FdKKClient;
- import com.fdkankan.manage.httpClient.client.LaserClient;
- import com.fdkankan.manage.httpClient.param.LaserSceneParam;
- import com.fdkankan.manage.httpClient.vo.FdkkResponse;
- import com.fdkankan.manage.service.*;
- import com.fdkankan.manage.vo.request.SceneParam;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.HashMap;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * 相机场景管理
- */
- @RestController
- @RequestMapping("/service/manage/scene")
- @Slf4j
- public class SceneController {
- @Autowired
- ISceneProService sceneProService;
- @Autowired
- IScenePlusService scenePlusService;
- @Autowired
- IDownService downService;
- @Autowired
- FdKKClient fdKKClient;
- @Autowired
- LaserClient laserClient;
- @Autowired
- IJySceneUserAuthService jySceneUserAuthService;
- @Autowired
- ISysUserService sysUserService;
- @Autowired
- IJyUserService jyUserService;
- @Autowired
- ISceneCopyLogService sceneCopyLogService;
- @PostMapping("/list")
- public ResultData list(@RequestBody SceneParam param){
- return ResultData.ok(sceneProService.pageList(param));
- }
- @PostMapping("/authNumList")
- public ResultData authNumList(){
- SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString()));
- JyUser loginUser = jyUserService.getBySysId(byId.getId());
- List<JySceneUserAuth> byJyUserId = jySceneUserAuthService.getByJyUserId(loginUser.getId());
- List<String> collect = byJyUserId.stream().map(JySceneUserAuth::getNum).collect(Collectors.toList());
- return ResultData.ok(collect);
- }
- /**
- * 场景迁移
- * num 迁移场景码
- * snCode 迁移至相机snCode
- */
- @PostMapping("/move")
- public ResultData move(@RequestBody SceneParam param){
- if(StringUtils.isEmpty(param.getNum()) || StringUtils.isEmpty(param.getSnCode())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- sceneProService.move(param);
- return ResultData.ok();
- }
- /**
- * 场景复制
- * num 场景码
- */
- @PostMapping("/copy")
- public ResultData copy(@RequestBody SceneParam param) throws Exception {
- if(StringUtils.isEmpty(param.getNum())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- sceneProService.copy(param.getNum());
- return ResultData.ok();
- }
- /**
- * 场景删除
- * num 场景码
- */
- @PostMapping("/delete")
- public ResultData delete(@RequestBody SceneParam param){
- if(StringUtils.isEmpty(param.getNum())){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- sceneProService.deleteByNum(param.getNum());
- return ResultData.ok();
- }
- /**
- * 检查下载
- * num 场景码
- */
- @GetMapping("/checkDownLoad")
- public ResultData checkDownLoad(@RequestParam(required = false) String num,
- @RequestParam(required = false,defaultValue = "0") Integer isObj){
- return ResultData.ok(downService.checkDownLoad(num,isObj));
- }
- /**
- * 下载场景
- * num 场景码
- */
- @GetMapping("/downScene")
- public ResultData downScene(@RequestParam(required = false) String num,
- @RequestParam(required = false,defaultValue = "0") Integer isObj){
- return ResultData.ok(downService.down(num,isObj));
- }
- /**
- * 下载场景进度条
- * num 场景码
- */
- @GetMapping("/downloadProcess")
- public ResultData downloadProcess(@RequestParam(required = false) String num,
- @RequestParam(required = false,defaultValue = "0") Integer isObj){
- return ResultData.ok(downService.downloadProcess(num,isObj));
- }
- /**
- * 场景重算
- * num 场景码
- */
- @GetMapping("/rebuildScene")
- public ResultData rebuild(@RequestParam(required = false) String num){
- ScenePro scenePro = sceneProService.getByNum(num);
- if(scenePro!=null && scenePro.getSceneSource() != 4){
- throw new BusinessException(ResultCode.V3_SCENE_REBUILD);
- }
- ScenePlus scenePlus = scenePlusService.getByNum(num);
- if(scenePlus == null && scenePro == null){
- throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
- }
- HashMap<String,Object> paramMap = new HashMap<>();
- paramMap.put("num",num);
- try {
- JSONObject jsonObject = fdKKClient.rebuildScene(paramMap);
- Integer code = jsonObject.getInteger("code");
- if(code != 0){
- log.error("场景重算失败:{},{}",num,jsonObject);
- throw new BusinessException(ResultCode.SCENE_REBUILD_ERROR);
- }
- }catch (Exception e){
- throw new BusinessException(ResultCode.SCENE_REBUILD_ERROR);
- }
- return ResultData.ok();
- }
- @PostMapping("/sceneDetail")
- public ResultData sceneDetail(@RequestBody LaserSceneParam param){
- if(param.getId() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- FdkkResponse fdkkResponse = laserClient.sceneDetail(param, StpUtil.getTokenValue());
- if(fdkkResponse.getCode() != 200){
- throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());
- }
- return ResultData.ok(fdkkResponse.getData());
- }
- @PostMapping("/buildSceneObj")
- public ResultData buildSceneObj(@RequestBody LaserSceneParam param){
- if(param.getId() == null){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- if(StringUtils.isNotBlank(param.getSceneNum())){
- List<SceneCopyLog> byNewNum = sceneCopyLogService.getByNewNum(param.getSceneNum());
- if(byNewNum!=null && !byNewNum.isEmpty()){
- throw new BusinessException(ResultCode.COPY_NUM_NOT_GEN_OBJ);
- }
- }
- FdkkResponse fdkkResponse = laserClient.buildSceneObj(param, StpUtil.getTokenValue());
- if(fdkkResponse.getCode() != 200){
- throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());
- }
- return ResultData.ok();
- }
- }
|