dcs 1 週間 前
コミット
64b9dec40d

+ 21 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/DifyCompletion.java

@@ -18,6 +18,9 @@ public class DifyCompletion {
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date date;
 
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endDate;
+
     private long userId;
 
     private String status;
@@ -28,6 +31,8 @@ public class DifyCompletion {
 
     private String messageId;
 
+    private String error;
+
     public Long getId() {
         return id;
     }
@@ -60,6 +65,14 @@ public class DifyCompletion {
         this.date = date;
     }
 
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
+    }
+
     public long getUserId() {
         return userId;
     }
@@ -99,4 +112,12 @@ public class DifyCompletion {
     public void setMessageId(String messageId) {
         this.messageId = messageId;
     }
+
+    public String getError() {
+        return error;
+    }
+
+    public void setError(String error) {
+        this.error = error;
+    }
 }

+ 8 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/DifyService.java

@@ -244,11 +244,19 @@ public class DifyService {
                 @Override
                 public void onError(ErrorEvent event) {
                     System.err.println("错误: " + event.getMessage());
+                    DifyCompletion difyCompletion = difyCompletionDao.getSimpleUUID(simpleUUID);
+                    difyCompletion.setStatus("error");
+                    difyCompletion.setError(event.getMessage());
+                    difyCompletionDao.update(difyCompletion);
                 }
 
                 @Override
                 public void onException(Throwable throwable) {
                     System.err.println("异常: " + throwable.getMessage());
+                    DifyCompletion difyCompletion = difyCompletionDao.getSimpleUUID(simpleUUID);
+                    difyCompletion.setStatus("error");
+                    difyCompletion.setError(throwable.getMessage());
+                    difyCompletionDao.update(difyCompletion);
                 }
             });
         } catch (IOException e) {

+ 2 - 0
virgo.api/src/main/resources/mapper/DifyCompletionMapper.xml

@@ -29,6 +29,8 @@
             <if test="status != null">status = #{status},</if>
             <if test="outputs != null">outputs = #{outputs},</if>
             <if test="messageId != null">messageId = #{messageId},</if>
+            <if test="error != null">error = #{error},</if>
+            endDate = now(),
         </trim>
         WHERE id=#{id}
     </update>