|
@@ -25,6 +25,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.junit.Test;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
@@ -34,6 +35,10 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.BlockingQueue;
|
|
|
+import java.util.concurrent.LinkedBlockingQueue;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
|
* Created by Hb_zzZ on 2020/3/2.
|
|
@@ -50,14 +55,15 @@ public class PersonalCenterController extends BaseController {
|
|
|
private SceneService sceneService;
|
|
|
|
|
|
@Autowired
|
|
|
- private SceneProEditService sceneProEditService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private CameraService cameraService;
|
|
|
|
|
|
@Autowired
|
|
|
private CameraDetailService cameraDetailService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ApplicationContext applicationContext;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 2020-12-22
|
|
@@ -67,152 +73,11 @@ public class PersonalCenterController extends BaseController {
|
|
|
@WebControllerLog(description = "个人中心-我的场景/发送文件")
|
|
|
@ApiOperation("发送文件")
|
|
|
@GetMapping("scene/send/{id}")
|
|
|
- public ResultJson send(@PathVariable Long id) throws Exception {
|
|
|
-
|
|
|
- SceneProEntity proEntity = sceneService.findById(id);
|
|
|
-
|
|
|
- if (proEntity == null) {
|
|
|
- return new ResultJson(MsgCode.e_COMMON_3001, MsgCode.msg_COMMON_3001);
|
|
|
- }
|
|
|
-
|
|
|
- saveLog("我的场景", "发送文件:"+ proEntity.getSceneName());
|
|
|
-
|
|
|
- if (proEntity.getDownloadStatus() == 1) {
|
|
|
- String api = REMOTE_API + "?sceneNum=" + proEntity.getNum();
|
|
|
- int i = HttpRequestorUtil.fileRemote(api, SERVER_PACKAGE_RESULT + proEntity.getNum() + ".zip");
|
|
|
- if (i == 200) {
|
|
|
- log.info("文件发送成功");
|
|
|
- proEntity.setDownloadStatus(2);
|
|
|
-
|
|
|
- // 成功后还需要调用仕彬的两个接口
|
|
|
- JSONObject proJson = insertSceneProInfo(proEntity);
|
|
|
- String code = proJson.getString("code");
|
|
|
- if (!"0".equals(code)) {
|
|
|
- log.error("发送insertSceneProInfo接口失败");
|
|
|
- return new ResultJson(MsgCode.e_COMMON_3001, "发送insertSceneProInfo接口失败");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- SceneProEditEntity proEditEntity = sceneProEditService.findByProId(id);
|
|
|
- // 将返回值id更新
|
|
|
- log.info("proId 准备更新");
|
|
|
- JSONObject dataJson = proJson.getJSONObject("data");
|
|
|
- Integer proId = dataJson.getInteger("id");
|
|
|
- log.info("proId: {}", proId);
|
|
|
- proEditEntity.setProId(Long.valueOf(proId));
|
|
|
- String s = insertSceneProEditInfo(proEditEntity);
|
|
|
- if (!"0".equals(s)){
|
|
|
- log.error("发送insertSceneProEditInfo接口失败");
|
|
|
- return new ResultJson(MsgCode.e_COMMON_3001, "发送insertSceneProEditInfo接口失败");
|
|
|
- }
|
|
|
-
|
|
|
- proEntity.setUpdateTime(new Date());
|
|
|
- sceneService.update(proEntity);
|
|
|
-
|
|
|
- } else {
|
|
|
- log.error("发送失败");
|
|
|
- return new ResultJson(MsgCode.e_COMMON_3001, "文件发送失败");
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- return new ResultJson(MsgCode.e_COMMON_3001, "文件未打包");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.msg_SUCCESS);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private JSONObject insertSceneProInfo(SceneProEntity proEntity) throws Exception {
|
|
|
- // /api/scene/insertSceneProInfo
|
|
|
- String api = REMOTE_DOMIAN + "/api/scene/insertSceneProInfo";
|
|
|
-
|
|
|
- proEntity.setWebSite(editDomain(proEntity.getWebSite()));
|
|
|
- proEntity.setThumb(editDomain(proEntity.getThumb()));
|
|
|
-
|
|
|
+ public ResultJson sendFile(@PathVariable Long id) {
|
|
|
|
|
|
- String post = HttpRequestorUtil.postJson(api, JSON.toJSONString(proEntity), "POST");
|
|
|
- log.info("response: {}", post);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
-
|
|
|
- return jsonObject;
|
|
|
+ return sceneService.sendFile(id);
|
|
|
}
|
|
|
|
|
|
- private String insertSceneProEditInfo(SceneProEditEntity proEditEntity) throws Exception {
|
|
|
- // /api/scene/insertSceneProEditInfo
|
|
|
- String api = SERVER_DOMIAN + "/api/scene/insertSceneProEditInfo";
|
|
|
-
|
|
|
- String post = HttpRequestorUtil.postJson(api, JSON.toJSONString(proEditEntity), "POST");
|
|
|
- log.info("response: {}", post);
|
|
|
-
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
-
|
|
|
- return jsonObject.getString("code");
|
|
|
- }
|
|
|
-
|
|
|
- // 编辑远程域名
|
|
|
- private String editDomain(String url){
|
|
|
- url = StringUtils.substringAfterLast(url, ":");
|
|
|
- url = StringUtils.substringAfter(url, "/");
|
|
|
- return REMOTE_DOMIAN + "/" + url;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void tes(){
|
|
|
- String aa = "http://192.168.0.163:8088/smobile.html?m=xa-JHoB90HUS";
|
|
|
-
|
|
|
- String s = StringUtils.substringAfterLast(aa, ":");
|
|
|
- String s1 = StringUtils.substringAfterLast(s, "/");
|
|
|
- System.out.println(s);
|
|
|
- System.out.println(s1);
|
|
|
- }
|
|
|
-
|
|
|
-// private String insertSceneProInfo(SceneProEntity proEntity) throws Exception {
|
|
|
-// // /api/scene/insertSceneProInfo
|
|
|
-// String api = SERVER_DOMIAN + "/api/scene/insertSceneProInfo";
|
|
|
-//
|
|
|
-// Map<String, Object> stringObjectMap = BeanUtil.beanToMap(proEntity);
|
|
|
-// log.info("map: {}", stringObjectMap);
|
|
|
-//
|
|
|
-// String post = HttpUtil.post(api, stringObjectMap);
|
|
|
-// log.info("s: {}", post);
|
|
|
-// JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
-//
|
|
|
-// return jsonObject.getString("code");
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// private String insertSceneProEditInfo(SceneProEditEntity proEditEntity) throws Exception {
|
|
|
-// // /api/scene/insertSceneProEditInfo
|
|
|
-// String api = SERVER_DOMIAN + "/api/scene/insertSceneProEditInfo";
|
|
|
-//
|
|
|
-// Map<String, Object> stringObjectMap = BeanUtil.beanToMap(proEditEntity);
|
|
|
-// log.info("map: {}", stringObjectMap);
|
|
|
-//
|
|
|
-// String post = HttpUtil.post(api, stringObjectMap);
|
|
|
-// log.info("s: {}", post);
|
|
|
-// JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
-//
|
|
|
-// return jsonObject.getString("code");
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// @RequiresPermissions("admin:scene:list")
|
|
|
-// @WebControllerLog(description = "个人中心-我的场景/搜索")
|
|
|
-// @ApiOperation("测试用户")
|
|
|
-// @PostMapping("scene/testUser")
|
|
|
-// public ResultJson testUser() throws Exception {
|
|
|
-//
|
|
|
-// insertSceneProInfo();
|
|
|
-// return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.msg_SUCCESS);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
@RequiresPermissions("admin:scene:list")
|