Просмотр исходного кода

新增装置审计记录数据时自动生成进度跟踪表带出章节、细分章节、二级细分章节

wangggziwen 8 месяцев назад
Родитель
Сommit
4004afb321

+ 31 - 1
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TAuditController.java

@@ -354,17 +354,47 @@ public class TAuditController extends BaseController
                 TProgress progress = new TProgress();
                 progress.setAuditId(tAudit.getId());
                 progress.setQuestionnaireId(questionnaire.getId());
-                progress.setChapName(chapter.getName());
                 progress.setCode(questionnaire.getCode()+"");
                 progress.setName(questionnaire.getName());
                 progress.setPreparation("1");
                 progress.setApplyStatus("1");
+                String name = chapter.getName();
+                String code = chapter.getCode();
+                if (StringUtils.isNotNull(code) && StringUtils.isNotNull(name)) {
+                    int dotNum = this.getDotNum(code);
+                    if (dotNum == 0) {//章节
+                        progress.setSecSubChapName("-");
+                        progress.setSubChapName("-");
+                        progress.setChapName(code + " " + name);
+                    } else if (dotNum == 1) {//细分章节
+                        progress.setSecSubChapName("-");
+                        progress.setSubChapName(code + " " + name);
+                        String chapCode = code.substring(0, code.indexOf("."));
+                        progress.setChapName(chapCode + " " + tChapterTemplateService.selectNameByCode(chapCode));
+                    } else {//二级细分章节
+                        progress.setSecSubChapName(code + " " + name);
+                        String subChapCode = code.substring(0, code.lastIndexOf("."));
+                        progress.setSubChapName(subChapCode + " " + tChapterTemplateService.selectNameByCode(subChapCode));
+                        String chapCode = subChapCode.substring(0, subChapCode.indexOf("."));
+                        progress.setChapName(chapCode + " " + tChapterTemplateService.selectNameByCode(chapCode));
+                    }
+                }
                 tProgressService.insertTProgress(progress);
             }
         }
         return toAjax(result);
     }
 
+    public int getDotNum(String code) {
+        int num = 0;
+        int i = code.indexOf(".");
+        if (i != -1) {
+            String[] split = code.split("\\.");
+            num = split.length - 1;
+        }
+        return num;
+    }
+
     /**
      * 修改审计记录
      */

+ 3 - 0
rc-buisness/src/main/java/com/ruoyi/rc/mapper/TChapterTemplateMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.rc.mapper;
 
 import java.util.List;
 import com.ruoyi.rc.domain.TChapterTemplate;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 章节模板Mapper接口
@@ -11,6 +12,8 @@ import com.ruoyi.rc.domain.TChapterTemplate;
  */
 public interface TChapterTemplateMapper 
 {
+    public String selectNameByCode(@Param("code") String code);
+
     /**
      * 查询章节模板
      * 

+ 2 - 0
rc-buisness/src/main/java/com/ruoyi/rc/service/ITChapterTemplateService.java

@@ -11,6 +11,8 @@ import com.ruoyi.rc.domain.TChapterTemplate;
  */
 public interface ITChapterTemplateService 
 {
+    public String selectNameByCode(String code);
+
     /**
      * 查询章节模板
      * 

+ 4 - 0
rc-buisness/src/main/java/com/ruoyi/rc/service/impl/TChapterTemplateServiceImpl.java

@@ -19,6 +19,10 @@ public class TChapterTemplateServiceImpl implements ITChapterTemplateService
     @Autowired
     private TChapterTemplateMapper tChapterTemplateMapper;
 
+    public String selectNameByCode(String code) {
+        return tChapterTemplateMapper.selectNameByCode(code);
+    }
+
     /**
      * 查询章节模板
      * 

+ 4 - 0
rc-buisness/src/main/resources/mapper/rc/TChapterTemplateMapper.xml

@@ -24,6 +24,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
         order by (IF(INSTR(code, '.') > 0, SUBSTR(code, 1, INSTR(code, '.') - 1), code) + 0) asc, code asc
     </select>
+
+    <select id="selectNameByCode" parameterType="String" resultType="String">
+        select name from t_chapter_template where code = #{code}
+    </select>
     
     <select id="selectTChapterTemplateById" parameterType="Long" resultMap="TChapterTemplateResult">
         <include refid="selectTChapterTemplateVo"/>

+ 4 - 5
ruoyi-ui/src/views/rc/audit/index.vue

@@ -513,11 +513,10 @@ export default {
               this.getList();
             });
           } else {
-            addAudit(this.form).then(response => {
-              this.$modal.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
+            addAudit(this.form).then(response => {});
+            this.$modal.msgSuccess("新增成功");
+            this.open = false;
+            this.getList();
           }
         }
       });