Browse Source

Merge branch 'dev_xlk'

allen 2 năm trước cách đây
mục cha
commit
a89c47f7a5

+ 29 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/TBuildFlowController.java

@@ -19,7 +19,8 @@ import com.kgraph.common.enums.BusinessType;;
 import com.kgraph.graph.suport.domain.TBuildFlow;
 import com.kgraph.graph.suport.service.ITBuildFlowService;
 import com.kgraph.common.utils.poi.ExcelUtil;;
-import com.kgraph.common.core.page.TableDataInfo;;
+import com.kgraph.common.core.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;;
 
 /**
  * 构建流程Controller
@@ -101,4 +102,31 @@ public class TBuildFlowController extends BaseController
     {
         return toAjax(tBuildFlowService.deleteTBuildFlowByIds(ids));
     }
+
+    /**
+     * 查看构建结果
+     */
+    @GetMapping("/getFlow/{subTaskId}")
+    public AjaxResult getFlow(@PathVariable("subTaskId") Long subtaskId)
+    {
+        return success(tBuildFlowService.getFlow(subtaskId));
+    }
+
+    @Log(title = "排故流程导入", businessType = BusinessType.IMPORT)
+    @PreAuthorize("@ss.hasPermi('showInfo:breakdown:add')")
+    @PostMapping("/importData")
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
+    {
+        ExcelUtil<TBuildFlow> util = new ExcelUtil<>(TBuildFlow.class);
+        List<TBuildFlow> TBuildFlowList = util.importExcel(file.getInputStream());
+        String message = tBuildFlowService.excelImport(TBuildFlowList);
+        return AjaxResult.success(message);
+    }
+
+    @PostMapping("/importTemplate")
+    public void importTemplate(HttpServletResponse response)
+    {
+        ExcelUtil<TBuildFlow> util = new ExcelUtil<>(TBuildFlow.class);
+        util.importTemplateExcel(response, "排故流程");
+    }
 }

+ 21 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/TCheckPiontController.java

@@ -2,6 +2,7 @@ package com.kgraph.graph.suport.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -19,7 +20,8 @@ import com.kgraph.common.enums.BusinessType;;
 import com.kgraph.graph.suport.domain.TCheckPiont;
 import com.kgraph.graph.suport.service.ITCheckPiontService;
 import com.kgraph.common.utils.poi.ExcelUtil;;
-import com.kgraph.common.core.page.TableDataInfo;;
+import com.kgraph.common.core.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;;
 
 /**
  * 检查点管理Controller
@@ -101,4 +103,22 @@ public class TCheckPiontController extends BaseController
     {
         return toAjax(tCheckPiontService.deleteTCheckPiontByIds(ids));
     }
+
+    @Log(title = "排故流程导入", businessType = BusinessType.IMPORT)
+    @PreAuthorize("@ss.hasPermi('showInfo:breakdown:add')")
+    @PostMapping("/importData")
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
+    {
+        ExcelUtil<TCheckPiont> util = new ExcelUtil<>(TCheckPiont.class);
+        List<TCheckPiont> TCheckPiontList = util.importExcel(file.getInputStream());
+        String message = tCheckPiontService.excelImport(TCheckPiontList);
+        return AjaxResult.success(message);
+    }
+
+    @PostMapping("/importTemplate")
+    public void importTemplate(HttpServletResponse response)
+    {
+        ExcelUtil<TCheckPiont> util = new ExcelUtil<>(TCheckPiont.class);
+        util.importTemplateExcel(response, "检查点管理");
+    }
 }

+ 12 - 53
kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/TBuildFlow.java

@@ -1,5 +1,6 @@
 package com.kgraph.graph.suport.domain;
 
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.kgraph.common.annotation.Excel;
@@ -11,6 +12,7 @@ import com.kgraph.common.core.domain.BaseEntity;;
  * @author kgraph
  * @date 2023-05-28
  */
+@Data
 public class TBuildFlow extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -18,8 +20,16 @@ public class TBuildFlow extends BaseEntity
     /** 序号 */
     private Long id;
 
+    /** 子任务id */
+    @Excel(name = "子任务id")
+    private Long subTaskId;
+
+    /** 故障编码 */
+    @Excel(name = "故障名称")
+    private String errorAppearance;
+
     /** 故障编码 */
-    @Excel(name = "故障编码")
+    /*@Excel(name = "故障编码")*/
     private String errorCode;
 
     /** 流程数据 */
@@ -27,57 +37,6 @@ public class TBuildFlow extends BaseEntity
     private String flowEncode;
 
     /** 流程树json */
-    @Excel(name = "流程树json")
+    /*@Excel(name = "流程树json")*/
     private String flowTreeJson;
-
-    public void setId(Long id) 
-    {
-        this.id = id;
-    }
-
-    public Long getId() 
-    {
-        return id;
-    }
-    public void setErrorCode(String errorCode) 
-    {
-        this.errorCode = errorCode;
-    }
-
-    public String getErrorCode() 
-    {
-        return errorCode;
-    }
-    public void setFlowEncode(String flowEncode) 
-    {
-        this.flowEncode = flowEncode;
-    }
-
-    public String getFlowEncode() 
-    {
-        return flowEncode;
-    }
-    public void setFlowTreeJson(String flowTreeJson) 
-    {
-        this.flowTreeJson = flowTreeJson;
-    }
-
-    public String getFlowTreeJson() 
-    {
-        return flowTreeJson;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("errorCode", getErrorCode())
-            .append("flowEncode", getFlowEncode())
-            .append("flowTreeJson", getFlowTreeJson())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .toString();
-    }
 }

+ 4 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/TBuildFlowMapper.java

@@ -1,6 +1,8 @@
 package com.kgraph.graph.suport.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.kgraph.graph.suport.domain.TBuildFlow;
 
 /**
@@ -58,4 +60,6 @@ public interface TBuildFlowMapper
      * @return 结果
      */
     public int deleteTBuildFlowByIds(Long[] ids);
+
+    public Map getFlow(Long subtaskId);
 }

+ 6 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/ITBuildFlowService.java

@@ -1,6 +1,8 @@
 package com.kgraph.graph.suport.service;
 
 import java.util.List;
+import java.util.Map;
+
 import com.kgraph.graph.suport.domain.TBuildFlow;
 
 /**
@@ -58,4 +60,8 @@ public interface ITBuildFlowService
      * @return 结果
      */
     public int deleteTBuildFlowById(Long id);
+
+    Map getFlow(Long subtaskId);
+
+    String excelImport(List<TBuildFlow> tBuildFlowList);
 }

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/ITCheckPiontService.java

@@ -58,4 +58,6 @@ public interface ITCheckPiontService
      * @return 结果
      */
     public int deleteTCheckPiontById(Long id);
+
+    String excelImport(List<TCheckPiont> tCheckPiontList);
 }

+ 38 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/TBuildFlowServiceImpl.java

@@ -1,12 +1,17 @@
 package com.kgraph.graph.suport.service.impl;
 
+import java.util.Date;
 import java.util.List;
-import com.kgraph.common.utils.DateUtils;;
+import java.util.Map;
+
+import com.kgraph.common.utils.DateUtils;
+import com.kgraph.graph.suport.mapper.BuildEntityRelationMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.kgraph.graph.suport.mapper.TBuildFlowMapper;
 import com.kgraph.graph.suport.domain.TBuildFlow;
 import com.kgraph.graph.suport.service.ITBuildFlowService;
+import com.kgraph.graph.suport.mapper.ExtractKnowledgeSubTaskMapper;
 
 /**
  * 构建流程Service业务层处理
@@ -20,6 +25,9 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     @Autowired
     private TBuildFlowMapper tBuildFlowMapper;
 
+    @Autowired
+    private ExtractKnowledgeSubTaskMapper extractKnowledgeSubTaskMapper;
+
     /**
      * 查询构建流程
      * 
@@ -54,6 +62,12 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     public int insertTBuildFlow(TBuildFlow tBuildFlow)
     {
         tBuildFlow.setCreateTime(DateUtils.getNowDate());
+        if(tBuildFlow.getSubTaskId() != null) {
+            // 更新子任务状态
+            extractKnowledgeSubTaskMapper.updateSubTaskStatusById(tBuildFlow.getSubTaskId(), "3", null, new Date());
+            // 更新任务状态
+            extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(tBuildFlow.getSubTaskId());
+        }
         return tBuildFlowMapper.insertTBuildFlow(tBuildFlow);
     }
 
@@ -67,6 +81,12 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     public int updateTBuildFlow(TBuildFlow tBuildFlow)
     {
         tBuildFlow.setUpdateTime(DateUtils.getNowDate());
+        if(tBuildFlow.getSubTaskId() != null) {
+            // 更新子任务状态
+            extractKnowledgeSubTaskMapper.updateSubTaskStatusById(tBuildFlow.getSubTaskId(), "3", null, new Date());
+            // 更新任务状态
+            extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(tBuildFlow.getSubTaskId());
+        }
         return tBuildFlowMapper.updateTBuildFlow(tBuildFlow);
     }
 
@@ -93,4 +113,21 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     {
         return tBuildFlowMapper.deleteTBuildFlowById(id);
     }
+
+    @Override
+    public Map getFlow(Long subtaskId) {
+        return tBuildFlowMapper.getFlow(subtaskId);
+    }
+
+    @Override
+    public String excelImport(List<TBuildFlow> TBuildFlowList) {
+        for (TBuildFlow tbuildflow : TBuildFlowList) {
+            if (tbuildflow.getId() == null) {
+                tBuildFlowMapper.insertTBuildFlow(tbuildflow);
+            } else {
+                tBuildFlowMapper.updateTBuildFlow(tbuildflow);
+            }
+        }
+        return "上传成功";
+    }
 }

+ 13 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/TCheckPiontServiceImpl.java

@@ -2,6 +2,7 @@ package com.kgraph.graph.suport.service.impl;
 
 import java.util.List;
 import com.kgraph.common.utils.DateUtils;;
+import com.kgraph.graph.suport.domain.TBuildFlow;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.kgraph.graph.suport.mapper.TCheckPiontMapper;
@@ -93,4 +94,16 @@ public class TCheckPiontServiceImpl implements ITCheckPiontService
     {
         return tCheckPiontMapper.deleteTCheckPiontById(id);
     }
+
+    @Override
+    public String excelImport(List<TCheckPiont> TCheckPiontList) {
+        for (TCheckPiont tcheckpiont : TCheckPiontList) {
+            if (tcheckpiont.getId() == null) {
+                tCheckPiontMapper.insertTCheckPiont(tcheckpiont);
+            } else {
+                tCheckPiontMapper.updateTCheckPiont(tcheckpiont);
+            }
+        }
+        return "上传成功";
+    }
 }

+ 22 - 2
kgraph-graph/src/main/resources/mapper/suport/TBuildFlowMapper.xml

@@ -6,6 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="TBuildFlow" id="TBuildFlowResult">
         <result property="id"    column="id"    />
+        <result property="subTaskId"    column="sub_task_id"    />
+        <result property="errorAppearance"    column="error_appearance"    />
         <result property="errorCode"    column="error_code"    />
         <result property="flowEncode"    column="flow_encode"    />
         <result property="flowTreeJson"    column="flow_tree_json"    />
@@ -16,13 +18,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTBuildFlowVo">
-        select id, error_code, flow_encode, flow_tree_json, create_by, create_time, update_by, update_time from t_build_flow
+        select id, sub_task_id, error_appearance, error_code, flow_encode, flow_tree_json, create_by, create_time, update_by, update_time from t_build_flow
     </sql>
 
     <select id="selectTBuildFlowList" parameterType="TBuildFlow" resultMap="TBuildFlowResult">
         <include refid="selectTBuildFlowVo"/>
         <where>  
-            <if test="errorCode != null  and errorCode != ''"> and error_code = #{errorCode}</if>
+            <if test="errorAppearance != null  and errorAppearance != ''"> and error_appearance = #{errorAppearance}</if>
             <if test="flowEncode != null  and flowEncode != ''"> and flow_encode = #{flowEncode}</if>
             <if test="flowTreeJson != null  and flowTreeJson != ''"> and flow_tree_json = #{flowTreeJson}</if>
         </where>
@@ -36,6 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertTBuildFlow" parameterType="TBuildFlow" useGeneratedKeys="true" keyProperty="id">
         insert into t_build_flow
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="subTaskId != null">sub_task_id,</if>
+            <if test="errorAppearance != null">error_appearance,</if>
             <if test="errorCode != null">error_code,</if>
             <if test="flowEncode != null">flow_encode,</if>
             <if test="flowTreeJson != null">flow_tree_json,</if>
@@ -45,6 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="subTaskId != null">#{subTaskId},</if>
+            <if test="errorAppearance != null">#{errorAppearance},</if>
             <if test="errorCode != null">#{errorCode},</if>
             <if test="flowEncode != null">#{flowEncode},</if>
             <if test="flowTreeJson != null">#{flowTreeJson},</if>
@@ -58,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateTBuildFlow" parameterType="TBuildFlow">
         update t_build_flow
         <trim prefix="SET" suffixOverrides=",">
+            <if test="subTaskId != null">sub_task_id = #{subTaskId},</if>
+            <if test="errorAppearance != null">error_appearance = #{errorAppearance},</if>
             <if test="errorCode != null">error_code = #{errorCode},</if>
             <if test="flowEncode != null">flow_encode = #{flowEncode},</if>
             <if test="flowTreeJson != null">flow_tree_json = #{flowTreeJson},</if>
@@ -79,4 +87,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <select id="getFlow" resultType="Map">
+        select
+            id,
+            sub_task_id subTaskId,
+            error_appearance errorAppearance,
+            error_code errorCode,
+            flow_encode flowEncode,
+            flow_tree_json flowTreeJson
+        from
+            t_build_flow tbf where tbf.sub_task_id = #{subTaskId}
+    </select>
 </mapper>