caishunfeng commented on code in PR #13184:
URL: 
https://github.com/apache/dolphinscheduler/pull/13184#discussion_r1063342035


##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java:
##########
@@ -241,4 +241,6 @@ void sendStartTask2Master(ProcessInstance processInstance, 
int taskId,
     void forceProcessInstanceSuccessByTaskInstanceId(Integer taskInstanceId);
 
     Integer queryTestDataSourceId(Integer onlineDataSourceId);
+
+    void saveCommandTrigger(Integer commandId, Integer processInstanceId);

Review Comment:
   Can we use the `commandDao`? And then we can put the command operation into 
it.



##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TriggerRelation.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+@Data
+@TableName("t_ds_trigger_relation")
+public class TriggerRelation {
+
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * trigger code
+     */
+    private long triggerCode;
+
+    /**
+     * triggerType
+     */
+    private int triggerType;
+
+    /**
+     * jobId
+     */
+    private Integer jobId;
+
+    /**
+     * create time
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
+    private Date createTime;
+
+    /**
+     * update time
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
+    private Date updateTime;
+
+    @Override
+    public String toString() {

Review Comment:
   remove this method because you had use `@Data`



##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml:
##########
@@ -335,4 +335,15 @@
         where id = #{runningInstanceId}
           and next_process_instance_id = 0
     </update>
+
+    <select id="queryByTriggerCode" 
resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
+        select
+        <include refid="baseSql"/>
+        from(
+        select job_id from t_ds_trigger_relation where trigger_type = 0 and 
trigger_code = #{triggerCode}
+        ) a
+        left join   t_ds_process_instance b
+        on a.job_id  = b.id
+        where b.id is not null
+    </select>

Review Comment:
   ```suggestion
       <select id="queryByTriggerCode" 
resultType="org.apache.dolphinscheduler.dao.entity.ProcessInstance">
           select
           <include refid="baseSql"/>
           from t_ds_trigger_relation a
           left join   t_ds_process_instance b
           on a.job_id  = b.id
           where b.id is not null and a.trigger_type = 0 and a.trigger_code = 
#{triggerCode}
       </select>
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java:
##########
@@ -222,6 +222,15 @@ List<ProcessInstance> 
queryByProcessDefineCodeAndStatus(Long processDefinitionCo
     List<ProcessInstance> queryByProcessDefineCode(Long processDefinitionCode,
                                                    int size);
 
+    /**
+     * query process instance list bt trigger code
+     *
+     * @param loginUser
+     * @param projectCode
+     * @param triggerCode
+     * @return
+     */
+    Map<String, Object> queryByTriggerCode(User loginUser, long projectCode, 
Long triggerCode);
     void deleteProcessInstanceByWorkflowDefinitionCode(long 
workflowDefinitionCode);

Review Comment:
   ```suggestion
       Map<String, Object> queryByTriggerCode(User loginUser, long projectCode, 
Long triggerCode);
       
       void deleteProcessInstanceByWorkflowDefinitionCode(long 
workflowDefinitionCode);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to