ScrbController.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.fdkankan.download.controller;
  2. import cn.hutool.core.exceptions.ExceptionUtil;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.fdkankan.common.constant.CommonSuccessStatus;
  5. import com.fdkankan.download.service.ISceneBuildProcessLogService;
  6. import com.fdkankan.download.service.IScrbService;
  7. import com.fdkankan.web.response.ResultData;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import java.util.concurrent.CompletableFuture;
  15. /**
  16. * <p>
  17. * pro场景表 前端控制器
  18. * </p>
  19. *
  20. * @author
  21. * @since 2022-10-17
  22. */
  23. @Slf4j
  24. @RestController
  25. @RequestMapping("/download/scrb")
  26. public class ScrbController {
  27. @Autowired
  28. private IScrbService scrbService;
  29. @Autowired
  30. private ISceneBuildProcessLogService sceneBuildProcessLogService;
  31. @PostMapping("/syncScene")
  32. public ResultData syncScene(@RequestBody JSONObject param){
  33. String num = param.getString("num");
  34. String key = param.getString("key");
  35. CompletableFuture.runAsync(() -> {
  36. try {
  37. sceneBuildProcessLogService.clearSceneBuildProcessLog(num, "sync", "sync", null);
  38. sceneBuildProcessLogService.saveSceneBuildProcessLog(num, "sync", "sync", CommonSuccessStatus.WAITING.code(), null, null);
  39. scrbService.syncScene(param);
  40. sceneBuildProcessLogService.saveSceneBuildProcessLog(num, "sync", "sync", CommonSuccessStatus.SUCCESS.code(), null, null);
  41. } catch (Exception e) {
  42. log.error("场景同步失败,num:{}, key:{}", num, key, e);
  43. sceneBuildProcessLogService.saveSceneBuildProcessLog(num, "sync", "sync", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000), null);
  44. }
  45. });
  46. return ResultData.ok();
  47. }
  48. }