dengsixing 5 months ago
parent
commit
a743ca4f49

+ 119 - 0
src/main/java/com/fdkankan/scene/Interceptor/CheckHaixinTokenAspect.java

@@ -0,0 +1,119 @@
+//package com.fdkankan.scene.Interceptor;
+//
+//import cn.hutool.core.util.StrUtil;
+//import com.fdkankan.common.constant.CommonStatus;
+//import com.fdkankan.common.constant.ErrorCode;
+//import com.fdkankan.common.constant.PayStatus;
+//import com.fdkankan.common.constant.SceneStatus;
+//import com.fdkankan.common.exception.BusinessException;
+//import com.fdkankan.redis.util.RedisUtil;
+//import com.fdkankan.scene.entity.SceneCooperation;
+//import com.fdkankan.scene.entity.ScenePlus;
+//import com.fdkankan.scene.service.ISceneCooperationService;
+//import com.fdkankan.scene.service.IScenePlusService;
+//import com.fdkankan.web.user.SSOLoginHelper;
+//import com.fdkankan.web.user.SSOUser;
+//import com.fdkankan.web.util.WebUtil;
+//import lombok.extern.log4j.Log4j2;
+//import org.aspectj.lang.JoinPoint;
+//import org.aspectj.lang.annotation.Aspect;
+//import org.aspectj.lang.annotation.Before;
+//import org.aspectj.lang.annotation.Pointcut;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.core.annotation.Order;
+//import org.springframework.stereotype.Component;
+//import org.springframework.web.context.request.RequestContextHolder;
+//import org.springframework.web.context.request.ServletRequestAttributes;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import java.io.IOException;
+//import java.util.Objects;
+//
+//@Log4j2
+//@Aspect
+//@Component
+//@Order(101)
+//public class CheckHaixinTokenAspect {
+//
+//	@Autowired
+//	private SSOLoginHelper ssoLoginHelper;
+//	@Autowired
+//	private RedisUtil redisUtil;
+//	@Autowired
+//	private IScenePlusService scenePlusService;
+//	@Autowired
+//	private ISceneCooperationService sceneCooperationService;
+//
+//
+//	@Pointcut("@annotation(com.fdkankan.scene.annotation.CheckPermit)")
+//	public void checkCooperationPermit() {
+//	}
+//
+//	/**
+//	 * 前置通知 用于判断用户协作场景是否有协作权限
+//	 *
+//	 * @param joinPoint
+//	 *            切点
+//	 * @throws IOException
+//	 */
+//	@Before("checkCooperationPermit()")
+//	public void doBefore(JoinPoint joinPoint) throws Exception {
+//		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+//		// 读取session中的用户
+//		SSOUser user = ssoLoginHelper.getSsoUser(request.getHeader("token"));
+//		if(Objects.isNull(user)){
+//			throw new BusinessException(ErrorCode.TOKEN_NOT_FOUND);
+//		}
+//		String num = WebUtil.getParameter("num", joinPoint, request);
+//		if(StrUtil.isEmpty(num)){
+//			throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+//		}
+//
+//        ScenePlus scenePlus= scenePlusService.getScenePlusByNum(num);
+//		if(Objects.isNull(scenePlus)){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//		}
+//		//如果是计算中或者计算出错,返回计算中
+//		if(SceneStatus.wait.code().equals(scenePlus.getSceneStatus())
+//			|| SceneStatus.FAILD.code().equals(scenePlus.getSceneStatus())){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5033);
+//		}
+//		if(!PayStatus.PAY.code().equals(scenePlus.getPayStatus())){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5034);
+//		}
+//
+//		//判断是否相机登录,是否场景的相机id和相机登录的相机id是否相等,如果都满足,则放行,否则判定为用户登录
+//		if(Objects.nonNull(user.getCameraLogin())
+//			&& CommonStatus.YES.code().byteValue() == user.getCameraLogin().intValue()){
+//			if(scenePlus.getCameraId().equals(user.getCameraId())){
+//				return;
+//			}else{
+//				throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//			}
+//		}
+//
+//		//走到这里代表是用户账号密码登录,如果查到的场景的userid是空,证明相机解绑了,需要返回无权操作
+//		if(Objects.isNull(scenePlus.getUserId())){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//		}
+//
+//        if(scenePlus.getUserId().equals(user.getId())){
+//            return;
+//        }
+//
+//        //如果不是用户自己的场景,判断是否有协作权限
+//        Long userId = null;
+//		SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
+//		if(Objects.nonNull(sceneCooperation)){
+//			userId = sceneCooperation.getUserId();
+//		}
+//
+//		if(Objects.isNull(userId)){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//        }
+//        if(!userId.equals(user.getId())){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//        }
+//	}
+//
+//}

+ 119 - 119
src/main/java/com/fdkankan/scene/Interceptor/CheckPermitAspect.java

@@ -1,119 +1,119 @@
-package com.fdkankan.scene.Interceptor;
-
-import cn.hutool.core.util.StrUtil;
-import com.fdkankan.common.constant.CommonStatus;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.constant.PayStatus;
-import com.fdkankan.common.constant.SceneStatus;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.redis.constant.RedisKey;
-import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.scene.entity.SceneCooperation;
-import com.fdkankan.scene.entity.ScenePlus;
-import com.fdkankan.scene.service.ISceneCooperationService;
-import com.fdkankan.scene.service.IScenePlusService;
-import com.fdkankan.web.user.SSOLoginHelper;
-import com.fdkankan.web.user.SSOUser;
-import com.fdkankan.web.util.WebUtil;
-import java.io.IOException;
-import java.util.Objects;
-import javax.servlet.http.HttpServletRequest;
-import lombok.extern.log4j.Log4j2;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.Pointcut;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-@Log4j2
-@Aspect
-@Component
-@Order(101)
-public class CheckPermitAspect {
-
-	@Autowired
-	private SSOLoginHelper ssoLoginHelper;
-	@Autowired
-	private RedisUtil redisUtil;
-	@Autowired
-	private IScenePlusService scenePlusService;
-	@Autowired
-	private ISceneCooperationService sceneCooperationService;
-
-
-	@Pointcut("@annotation(com.fdkankan.scene.annotation.CheckPermit)")
-	public void checkCooperationPermit() {
-	}
-
-	/**
-	 * 前置通知 用于判断用户协作场景是否有协作权限
-	 *
-	 * @param joinPoint
-	 *            切点
-	 * @throws IOException
-	 */
-	@Before("checkCooperationPermit()")
-	public void doBefore(JoinPoint joinPoint) throws Exception {
-		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
-		// 读取session中的用户
-		SSOUser user = ssoLoginHelper.getSsoUser(request.getHeader("token"));
-		if(Objects.isNull(user)){
-			throw new BusinessException(ErrorCode.TOKEN_NOT_FOUND);
-		}
-		String num = WebUtil.getParameter("num", joinPoint, request);
-		if(StrUtil.isEmpty(num)){
-			throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-		}
-
-        ScenePlus scenePlus= scenePlusService.getScenePlusByNum(num);
-		if(Objects.isNull(scenePlus)){
-			throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-		}
-		//如果是计算中或者计算出错,返回计算中
-		if(SceneStatus.wait.code().equals(scenePlus.getSceneStatus())
-			|| SceneStatus.FAILD.code().equals(scenePlus.getSceneStatus())){
-			throw new BusinessException(ErrorCode.FAILURE_CODE_5033);
-		}
-		if(!PayStatus.PAY.code().equals(scenePlus.getPayStatus())){
-			throw new BusinessException(ErrorCode.FAILURE_CODE_5034);
-		}
-
-		//判断是否相机登录,是否场景的相机id和相机登录的相机id是否相等,如果都满足,则放行,否则判定为用户登录
-		if(Objects.nonNull(user.getCameraLogin())
-			&& CommonStatus.YES.code().byteValue() == user.getCameraLogin().intValue()){
-			if(scenePlus.getCameraId().equals(user.getCameraId())){
-				return;
-			}else{
-				throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-			}
-		}
-
-		//走到这里代表是用户账号密码登录,如果查到的场景的userid是空,证明相机解绑了,需要返回无权操作
-		if(Objects.isNull(scenePlus.getUserId())){
-			throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-		}
-
-        if(scenePlus.getUserId().equals(user.getId())){
-            return;
-        }
-
-        //如果不是用户自己的场景,判断是否有协作权限
-        Long userId = null;
-		SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
-		if(Objects.nonNull(sceneCooperation)){
-			userId = sceneCooperation.getUserId();
-		}
-
-		if(Objects.isNull(userId)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-        }
-        if(!userId.equals(user.getId())){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
-        }
-	}
-
-}
+//package com.fdkankan.scene.Interceptor;
+//
+//import cn.hutool.core.util.StrUtil;
+//import com.fdkankan.common.constant.CommonStatus;
+//import com.fdkankan.common.constant.ErrorCode;
+//import com.fdkankan.common.constant.PayStatus;
+//import com.fdkankan.common.constant.SceneStatus;
+//import com.fdkankan.common.exception.BusinessException;
+//import com.fdkankan.redis.constant.RedisKey;
+//import com.fdkankan.redis.util.RedisUtil;
+//import com.fdkankan.scene.entity.SceneCooperation;
+//import com.fdkankan.scene.entity.ScenePlus;
+//import com.fdkankan.scene.service.ISceneCooperationService;
+//import com.fdkankan.scene.service.IScenePlusService;
+//import com.fdkankan.web.user.SSOLoginHelper;
+//import com.fdkankan.web.user.SSOUser;
+//import com.fdkankan.web.util.WebUtil;
+//import java.io.IOException;
+//import java.util.Objects;
+//import javax.servlet.http.HttpServletRequest;
+//import lombok.extern.log4j.Log4j2;
+//import org.aspectj.lang.JoinPoint;
+//import org.aspectj.lang.annotation.Aspect;
+//import org.aspectj.lang.annotation.Before;
+//import org.aspectj.lang.annotation.Pointcut;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.core.annotation.Order;
+//import org.springframework.stereotype.Component;
+//import org.springframework.web.context.request.RequestContextHolder;
+//import org.springframework.web.context.request.ServletRequestAttributes;
+//
+//@Log4j2
+//@Aspect
+//@Component
+//@Order(101)
+//public class CheckPermitAspect {
+//
+//	@Autowired
+//	private SSOLoginHelper ssoLoginHelper;
+//	@Autowired
+//	private RedisUtil redisUtil;
+//	@Autowired
+//	private IScenePlusService scenePlusService;
+//	@Autowired
+//	private ISceneCooperationService sceneCooperationService;
+//
+//
+//	@Pointcut("@annotation(com.fdkankan.scene.annotation.CheckPermit)")
+//	public void checkCooperationPermit() {
+//	}
+//
+//	/**
+//	 * 前置通知 用于判断用户协作场景是否有协作权限
+//	 *
+//	 * @param joinPoint
+//	 *            切点
+//	 * @throws IOException
+//	 */
+//	@Before("checkCooperationPermit()")
+//	public void doBefore(JoinPoint joinPoint) throws Exception {
+//		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+//		// 读取session中的用户
+//		SSOUser user = ssoLoginHelper.getSsoUser(request.getHeader("token"));
+//		if(Objects.isNull(user)){
+//			throw new BusinessException(ErrorCode.TOKEN_NOT_FOUND);
+//		}
+//		String num = WebUtil.getParameter("num", joinPoint, request);
+//		if(StrUtil.isEmpty(num)){
+//			throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+//		}
+//
+//        ScenePlus scenePlus= scenePlusService.getScenePlusByNum(num);
+//		if(Objects.isNull(scenePlus)){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//		}
+//		//如果是计算中或者计算出错,返回计算中
+//		if(SceneStatus.wait.code().equals(scenePlus.getSceneStatus())
+//			|| SceneStatus.FAILD.code().equals(scenePlus.getSceneStatus())){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5033);
+//		}
+//		if(!PayStatus.PAY.code().equals(scenePlus.getPayStatus())){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5034);
+//		}
+//
+//		//判断是否相机登录,是否场景的相机id和相机登录的相机id是否相等,如果都满足,则放行,否则判定为用户登录
+//		if(Objects.nonNull(user.getCameraLogin())
+//			&& CommonStatus.YES.code().byteValue() == user.getCameraLogin().intValue()){
+//			if(scenePlus.getCameraId().equals(user.getCameraId())){
+//				return;
+//			}else{
+//				throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//			}
+//		}
+//
+//		//走到这里代表是用户账号密码登录,如果查到的场景的userid是空,证明相机解绑了,需要返回无权操作
+//		if(Objects.isNull(scenePlus.getUserId())){
+//			throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//		}
+//
+//        if(scenePlus.getUserId().equals(user.getId())){
+//            return;
+//        }
+//
+//        //如果不是用户自己的场景,判断是否有协作权限
+//        Long userId = null;
+//		SceneCooperation sceneCooperation = sceneCooperationService.getByNum(num);
+//		if(Objects.nonNull(sceneCooperation)){
+//			userId = sceneCooperation.getUserId();
+//		}
+//
+//		if(Objects.isNull(userId)){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//        }
+//        if(!userId.equals(user.getId())){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5014);
+//        }
+//	}
+//
+//}

+ 61 - 61
src/main/java/com/fdkankan/scene/Interceptor/TokenInterceptor.java

@@ -1,61 +1,61 @@
-package com.fdkankan.scene.Interceptor;
-
-
-import cn.hutool.http.ContentType;
-import com.alibaba.fastjson.JSON;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.redis.constant.RedisKey;
-import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.web.response.ResultData;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpHeaders;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.web.servlet.HandlerInterceptor;
-
-@Component
-@Slf4j
-public class TokenInterceptor implements HandlerInterceptor {
-
-	@Autowired
-	private RedisUtil redisUtil;
-
-	@Override
-	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-		response.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.JSON.getValue());
-		response.setCharacterEncoding(StandardCharsets.UTF_8.name());
-		String token = request.getHeader("token");
-		if(StringUtils.isEmpty(token)){
-			this.needLogin(request,response);
-			return false;
-		}
-		try {
-			String redisKey = String.format(RedisKey.USER_TOKEN_KEY, token);
-			if(redisUtil.hasKey(redisKey)){
-				redisUtil.expire(redisKey,2 * 60 * 60);
-				return true;
-			}
-		}catch (Exception e){
-			log.error("校验token缓存出错", e);
-		}
-		this.needLogin(request,response);
-		return false;
-	}
-
-	private void needLogin(HttpServletRequest request, HttpServletResponse response) {
-		try {
-			ResultData error = ResultData.error(ErrorCode.TOKEN_NOT_FOUND);
-			response.getWriter().append(JSON.toJSONString(error));
-		} catch (IOException e) {
-			log.info("LoginInterceptor|needLogin|IOException|" + e);
-			e.printStackTrace();
-		}
-	}
-
-}
-
+//package com.fdkankan.scene.Interceptor;
+//
+//
+//import cn.hutool.http.ContentType;
+//import com.alibaba.fastjson.JSON;
+//import com.fdkankan.common.constant.ErrorCode;
+//import com.fdkankan.redis.constant.RedisKey;
+//import com.fdkankan.redis.util.RedisUtil;
+//import com.fdkankan.web.response.ResultData;
+//import java.io.IOException;
+//import java.nio.charset.StandardCharsets;
+//import javax.servlet.http.HttpServletRequest;
+//import javax.servlet.http.HttpServletResponse;
+//import lombok.extern.slf4j.Slf4j;
+//import org.apache.commons.lang3.StringUtils;
+//import org.apache.http.HttpHeaders;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//import org.springframework.web.servlet.HandlerInterceptor;
+//
+//@Component
+//@Slf4j
+//public class TokenInterceptor implements HandlerInterceptor {
+//
+//	@Autowired
+//	private RedisUtil redisUtil;
+//
+//	@Override
+//	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+//		response.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.JSON.getValue());
+//		response.setCharacterEncoding(StandardCharsets.UTF_8.name());
+//		String token = request.getHeader("token");
+//		if(StringUtils.isEmpty(token)){
+//			this.needLogin(request,response);
+//			return false;
+//		}
+//		try {
+//			String redisKey = String.format(RedisKey.USER_TOKEN_KEY, token);
+//			if(redisUtil.hasKey(redisKey)){
+//				redisUtil.expire(redisKey,2 * 60 * 60);
+//				return true;
+//			}
+//		}catch (Exception e){
+//			log.error("校验token缓存出错", e);
+//		}
+//		this.needLogin(request,response);
+//		return false;
+//	}
+//
+//	private void needLogin(HttpServletRequest request, HttpServletResponse response) {
+//		try {
+//			ResultData error = ResultData.error(ErrorCode.TOKEN_NOT_FOUND);
+//			response.getWriter().append(JSON.toJSONString(error));
+//		} catch (IOException e) {
+//			log.info("LoginInterceptor|needLogin|IOException|" + e);
+//			e.printStackTrace();
+//		}
+//	}
+//
+//}
+//

+ 35 - 35
src/main/java/com/fdkankan/scene/config/InterceptorConfig.java

@@ -1,38 +1,38 @@
-package com.fdkankan.scene.config;
-
-import com.fdkankan.scene.Interceptor.TokenInterceptor;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-
-@Configuration
-public class InterceptorConfig implements WebMvcConfigurer {
-
-	@Autowired
-	private TokenInterceptor tokenInterceptor;
-
+//package com.fdkankan.scene.config;
+//
+//import com.fdkankan.scene.Interceptor.TokenInterceptor;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.web.servlet.config.annotation.CorsRegistry;
+//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+//
+//
+//@Configuration
+//public class InterceptorConfig implements WebMvcConfigurer {
+//
+//	@Autowired
+//	private TokenInterceptor tokenInterceptor;
+//
+////	@Override
+////	public void addCorsMappings(CorsRegistry registry) {
+////		registry.addMapping("/**").allowCredentials(true).allowedHeaders("*").allowedOrigins("*").allowedMethods("*");
+////
+////	}
+//
 //	@Override
-//	public void addCorsMappings(CorsRegistry registry) {
-//		registry.addMapping("/**").allowCredentials(true).allowedHeaders("*").allowedOrigins("*").allowedMethods("*");
+//	public void addInterceptors(InterceptorRegistry registry) {
+//		registry.addInterceptor(tokenInterceptor).addPathPatterns("/service/scene/edit/**");
+////				.excludePathPatterns("/**/sso/**","/app/**","/test/**","/**/inner/**")
 //
+//		WebMvcConfigurer.super.addInterceptors(registry);
 //	}
-
-	@Override
-	public void addInterceptors(InterceptorRegistry registry) {
-		registry.addInterceptor(tokenInterceptor).addPathPatterns("/service/scene/edit/**");
-//				.excludePathPatterns("/**/sso/**","/app/**","/test/**","/**/inner/**")
-
-		WebMvcConfigurer.super.addInterceptors(registry);
-	}
-
-	@Override
-	public void addResourceHandlers(ResourceHandlerRegistry registry) {
-		WebMvcConfigurer.super.addResourceHandlers(registry);
-	}
-
-}
-
+//
+//	@Override
+//	public void addResourceHandlers(ResourceHandlerRegistry registry) {
+//		WebMvcConfigurer.super.addResourceHandlers(registry);
+//	}
+//
+//}
+//

+ 3 - 0
src/main/java/com/fdkankan/scene/entity/ScenePlus.java

@@ -122,5 +122,8 @@ public class ScenePlus implements Serializable {
     @TableField("other_type")
     private String otherType;
 
+    @TableField("task_id")
+    private String taskId;
+
 
 }

+ 19 - 0
src/main/java/com/fdkankan/scene/httpclient/HaixinClient.java

@@ -0,0 +1,19 @@
+package com.fdkankan.scene.httpclient;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.DataFile;
+import com.dtflys.forest.annotation.JSONBody;
+import com.dtflys.forest.annotation.Post;
+import com.dtflys.forest.annotation.Var;
+import com.fdkankan.web.response.ResultData;
+
+public interface HaixinClient {
+
+    @Post(url = "${url}", readTimeout = 60*60*1000, connectTimeout = 60*60*1000, timeout = 60*60*1000, maxRetryInterval = 5)
+    ResultData postJson(@Var("url") String url, @JSONBody Object param);
+
+    @Post(url="{url}", readTimeout = 60*60*1000, connectTimeout = 60*60*1000, timeout = 60*60*1000, maxRetryInterval = 5)
+    JSONObject uploadToFdfs(@Var("url")String url, @DataFile("file") String filePath);
+
+}

+ 10 - 0
src/main/java/com/fdkankan/scene/service/IHaixinService.java

@@ -0,0 +1,10 @@
+package com.fdkankan.scene.service;
+
+public interface IHaixinService {
+
+    void sendCadImgToHaixin(String num) throws Exception;
+
+    void sendResult(String taskId, String packetPath);
+
+
+}

+ 87 - 0
src/main/java/com/fdkankan/scene/service/impl/HaixinServiceImpl.java

@@ -0,0 +1,87 @@
+package com.fdkankan.scene.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.util.CmdUtils;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.UploadFilePath;
+import com.fdkankan.scene.entity.ScenePlus;
+import com.fdkankan.scene.httpclient.HaixinClient;
+import com.fdkankan.scene.service.IHaixinService;
+import com.fdkankan.scene.service.IScenePlusService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class HaixinServiceImpl implements IHaixinService {
+
+    private static final String  API_FDFS_UPLOAD = "/fdfs/api/file/upload";
+    private static final String  API_SUBMIT_RENDER_RESULT = "/ecs/api/panoramicImageService/submitRenderResult";
+
+    @Value("${haixin.host}")
+    private String haixinHost;
+
+    @Resource
+    private FYunFileServiceInterface fileServiceInterface;
+    @Resource
+    private HaixinClient haixinClient;
+    @Autowired
+    private IScenePlusService scenePlusService;
+
+
+    @Override
+    public void sendCadImgToHaixin(String num) throws Exception {
+
+        ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
+
+        String userViewPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
+        List<String> cadImgKeys = fileServiceInterface.listRemoteFiles(userViewPath + "cad-style-");
+        if(CollUtil.isEmpty(cadImgKeys)){
+            return;
+        }
+        String currentTimeMillis = String.valueOf(System.currentTimeMillis());
+        String tmpPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + currentTimeMillis + "/";
+        cadImgKeys.stream().forEach(key->{
+            fileServiceInterface.downloadFile(key, tmpPath + FileUtil.getName(key));
+        });
+        String zipPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + currentTimeMillis + ".zip";
+
+        //打压缩包
+        this.zip(tmpPath, zipPath);
+
+        //上传到fastdf
+        String url = haixinHost.concat(API_FDFS_UPLOAD);
+        JSONObject jsonObject = haixinClient.uploadToFdfs(url, zipPath);
+        JSONObject data = jsonObject.getJSONObject("data");
+
+        //通知计算结果
+        this.sendResult(scenePlus.getTaskId(), data.getString("fileNameRemote"));
+
+    }
+
+    private void zip(String sourcePath, String zipPath) throws Exception {
+        FileUtil.mkParentDirs(zipPath);
+        String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " *";
+        CmdUtils.callLineSh(cmd, 200);
+    }
+
+    @Override
+    public void sendResult(String taskId, String packetPath){
+        String url = haixinHost.concat(API_SUBMIT_RENDER_RESULT);
+        Map<String, String> params = new HashMap<>();
+        params.put("vendor","A0BF");
+        params.put("projectId", taskId);
+        params.put("packetPath", packetPath);
+        haixinClient.postJson(url, params);
+    }
+}

+ 5 - 0
src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -118,6 +118,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
     private ISceneDrawService sceneDrawService;
     @Autowired
     private ISceneDynamicPanelService sceneDynamicPanelService;
+    @Autowired
+    private IHaixinService haixinService;
 
     @Transactional
     @Override
@@ -314,6 +316,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         scenePlus.setHouseType(this.existsHouseType(bucket, num));
         scenePlusService.updateById(scenePlus);
 
+        //发送cad图给海鑫
+//        haixinService.sendCadImgToHaixin(num);
+
         return ResultData.ok();
     }