瀏覽代碼

项目日志上链开发

anderx 1 年之前
父節點
當前提交
c3e002dac1

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ProjectTaskController.java

@@ -429,4 +429,19 @@ public class ProjectTaskController extends BaseController {
         projectTaskService.saveProjectStaffRecordTianhe(id);
         return AjaxResult.success();
     }
+
+
+    /**
+     * 文字上传天河链
+     * @param content
+     * @return
+     */
+    @GetMapping("/saveText")
+    public AjaxResult saveText(@RequestParam("content") String content){
+        if (StringUtils.isEmpty(content)){
+            return AjaxResult.error("内容不能为空");
+        }
+        projectTaskService.saveText(content);
+        return AjaxResult.success();
+    }
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectTaskService.java

@@ -28,4 +28,6 @@ public interface ProjectTaskService {
     void saveProjectTaskTianhe(String id);
 
     void saveProjectStaffRecordTianhe(String id);
+
+    void saveText(String content) ;
 }

+ 34 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -369,6 +369,40 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
             throw new RuntimeException("上链异常,请稍后再试");
         }
     }
+
+    @Override
+    public void saveText(String content) {
+        String address = getAddress();
+        String  operateId ="text_"+DateUtils.dateTimeNow();
+        //文字导入
+        String s = tianheService.seveText(address, content, operateId);
+        JSONObject res = JSONObject.parseObject(s);
+        Integer code = (Integer) res.get("code");
+        String tianheCloudUrl=null;
+        if (code== HttpStatus.OK.value()){
+            try {
+                sleep(1000);
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
+            String certificate = tianheService.getCertificate(address, operateId);
+            JSONObject certificateData = JSONObject.parseObject(certificate);
+            Integer code2= (Integer) certificateData.get("code");
+            if (code2==HttpStatus.OK.value()){
+                log.debug(certificateData.toJSONString());
+                tianheCloudUrl=certificateData.getString("data");
+            }else {
+                String msg = certificateData.getString("msg");
+                log.error(msg);
+                throw new RuntimeException(msg);
+            }
+        }else {
+            String msg = res.getString("msg");
+            log.error(msg);
+            throw new RuntimeException(msg);
+        }
+    }
+
     public void saveRecordsText(Long id) throws InterruptedException {
         ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(Long.valueOf(id));
         Map<String,Object> map=new HashMap<>();