ly 3 years ago
parent
commit
e5a4858f10

+ 0 - 1
master/src/main/java/com/ruoyi/project/common/controller/WordController.java

@@ -84,7 +84,6 @@ public class WordController extends BaseController
         String wordPath = createWord(templatePath, fileDir, fileName, params);
 
         try {
-
             //读取word文档
             XWPFDocument document = null;
             try (InputStream in = Files.newInputStream(Paths.get("D:/ticket/demo/sems.docx"))) {

+ 32 - 5
master/src/main/java/com/ruoyi/project/ticket/controller/THazardWorkPermitController.java

@@ -1,25 +1,24 @@
 package com.ruoyi.project.ticket.controller;
 
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.config.RuoYiConfig;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.framework.web.page.TableDataInfo;
+import com.ruoyi.project.common.controller.WordController;
 import com.ruoyi.project.ticket.domain.PermitRelation;
 import com.ruoyi.project.ticket.domain.THazardWorkPermit;
 import com.ruoyi.project.ticket.service.ITHazardWorkPermitService;
 import com.ruoyi.project.ticket.service.ITPermitRelationService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
-
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 危害工作许可证Controller
@@ -38,6 +37,8 @@ public class THazardWorkPermitController extends BaseController {
     private ITPermitRelationService itPermitRelationService;
     @Autowired
     private TTicketIdController tTicketIdController;
+    @Autowired
+    private WordController wordController;
     /**
      * 查询危害工作许可证列表
      */
@@ -109,13 +110,27 @@ public class THazardWorkPermitController extends BaseController {
     @PostMapping
     public AjaxResult add(@RequestBody THazardWorkPermit tHazardWorkPermit) {
         Long ticketId =  tTicketIdController.createId();
+        logger.info("ticketId:" + ticketId);
         tHazardWorkPermit.setaId(ticketId);
+        //生成word
+        Map<String, Object> params = new HashMap<>();
+        // 渲染文本
+        params.put("aId",ticketId);
+        // 模板路径
+        String templatePath = "static/word/ticket.docx";
+        // 生成word的路径
+        String fileDir = RuoYiConfig.getProfile();
+        // 生成word的文件
+        String fileName = "A" + ticketId + ".docx";
+        String wordPath = this.wordController.createWord(templatePath, fileDir, fileName, params);
+        tHazardWorkPermit.setWordUrl(wordPath);
         tHazardWorkPermitService.insertTHazardWorkPermit(tHazardWorkPermit);
         //保存危害工作许可证关联数据
         PermitRelation permitRelation = new PermitRelation();
         permitRelation.setPermitId(tHazardWorkPermit.getaId());
         permitRelation.setPermitType("A");
         permitRelation.setPermitStatus(1L);
+
         this.itPermitRelationService.add(permitRelation);
         return AjaxResult.success(tHazardWorkPermit.getaId());
     }
@@ -126,6 +141,18 @@ public class THazardWorkPermitController extends BaseController {
     @Log(title = "危害工作许可证", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody THazardWorkPermit tHazardWorkPermit) {
+        //生成word
+        Map<String, Object> params = new HashMap<>();
+        // 渲染文本
+        params.put("aId",tHazardWorkPermit.getaId());
+        // 模板路径
+        String templatePath = "static/word/ticket.docx";
+        // 生成word的路径
+        String fileDir = RuoYiConfig.getProfile();
+        // 生成word的文件
+        String fileName = "A" + tHazardWorkPermit.getaId() + ".docx";
+        String wordPath = this.wordController.createWord(templatePath, fileDir, fileName, params);
+        tHazardWorkPermit.setWordUrl(wordPath);
         return toAjax(tHazardWorkPermitService.updateTHazardWorkPermit(tHazardWorkPermit));
     }
 

+ 10 - 0
master/src/main/java/com/ruoyi/project/ticket/domain/THazardWorkPermit.java

@@ -1310,6 +1310,16 @@ public class THazardWorkPermit extends BaseEntity {
     @Excel(name = "M 其他相关许可证3")
     private Long mOtherLicenceThree;
 
+    private String wordUrl;
+
+    public String getWordUrl() {
+        return wordUrl;
+    }
+
+    public void setWordUrl(String wordUrl) {
+        this.wordUrl = wordUrl;
+    }
+
     public void setaId(Long aId) {
         this.aId = aId;
     }

+ 9 - 0
master/src/main/java/com/ruoyi/project/ticket/domain/TTicketId.java

@@ -28,6 +28,8 @@ public class TTicketId extends BaseEntity
     @Excel(name = "部门id")
     private Long deptId;
 
+    /** 部门 */
+    private String deptName;
     /** 装置 */
     @Excel(name = "装置")
     private String plantCode;
@@ -174,6 +176,13 @@ public class TTicketId extends BaseEntity
         return remarks;
     }
 
+    public String getDeptName() {
+        return deptName;
+    }
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 1 - 1
master/src/main/resources/application.yml

@@ -9,7 +9,7 @@ ruoyi:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /data/cpmsfile/uploadPath)
-  profile: /data/jobticketFile/uploadPath
+  profile: D:/ruoyi/uploadPath
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数组计算 char 字符验证

+ 7 - 3
master/src/main/resources/mybatis/ticket/THazardWorkPermitMapper.xml

@@ -249,6 +249,7 @@
         <result property="mOtherLicenceOne" column="m_other_licence_one"/>
         <result property="mOtherLicenceTwo" column="m_other_licence_two"/>
         <result property="mOtherLicenceThree" column="m_other_licence_three"/>
+        <result property="wordUrl" column="word_url"/>
     </resultMap>
 
     <sql id="selectTHazardWorkPermitVo">
@@ -495,7 +496,8 @@
                d.m_assess_d_date,
                d.m_other_licence_one,
                d.m_other_licence_two,
-               d.m_other_licence_three
+               d.m_other_licence_three,
+               d.word_url
         from t_hazard_work_permit d
     </sql>
 
@@ -508,7 +510,7 @@
         where a_id = #{aId}
     </select>
 
-    <insert id="insertTHazardWorkPermit" parameterType="THazardWorkPermit" useGeneratedKeys="true" keyColumn="aId">
+    <insert id="insertTHazardWorkPermit" parameterType="THazardWorkPermit" >
         <!--<selectKey keyProperty="aId" resultType="long" order="BEFORE">
             SELECT seq_t_hazard_work_permit.NEXTVAL as aId FROM DUAL
         </selectKey>-->
@@ -758,6 +760,7 @@
             <if test="mOtherLicenceOne != null">m_other_licence_one,</if>
             <if test="mOtherLicenceTwo != null">m_other_licence_two,</if>
             <if test="mOtherLicenceThree != null">m_other_licence_three,</if>
+            <if test="wordUrl != null">word_url,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="aId != null">#{aId},</if>
@@ -1004,6 +1007,7 @@
             <if test="mOtherLicenceOne != null">#{mOtherLicenceOne},</if>
             <if test="mOtherLicenceTwo != null">#{mOtherLicenceTwo},</if>
             <if test="mOtherLicenceThree != null">#{mOtherLicenceThree},</if>
+            <if test="wordUrl != null">#{wordUrl},</if>
         </trim>
     </insert>
 
@@ -1253,6 +1257,7 @@
             <if test="mOtherLicenceOne != null">m_other_licence_one = #{mOtherLicenceOne},</if>
             <if test="mOtherLicenceTwo != null">m_other_licence_two = #{mOtherLicenceTwo},</if>
             <if test="mOtherLicenceThree != null">m_other_licence_three = #{mOtherLicenceThree},</if>
+            <if test="wordUrl != null">word_url = #{wordUrl},</if>
         </trim>
         where a_id = #{aId}
     </update>
@@ -1269,5 +1274,4 @@
             #{aId}
         </foreach>
     </update>
-
 </mapper>

BIN
master/src/main/resources/static/word/ticket.docx


BIN
master/src/main/resources/static/word/ticket1.docx


+ 6 - 3
ui/src/views/invoicing/hazardwork/index.vue

@@ -30,7 +30,7 @@
           </td>
           <td>
             <el-form-item>
-              <el-button type="primary" @click="onSubmit">提交当前数据</el-button>
+              <el-button type="primary" v-show="form.aId" @click="onSubmit">提交当前数据</el-button>
             </el-form-item>
           </td>
         </tr>
@@ -358,7 +358,7 @@
                                    @change="otherDangerChange"/>
                     </td>
                     <td colspan="5">其他危害:
-                      <el-select style="width: 400px;" multiple v-model="form.cOtherDangerContent" filterable
+                      <el-select style="width: 400px;" v-model="form.cOtherDangerContent" filterable
                                  :disabled="this.form.cIsOtherDanger==true?false:true">
                         <el-option v-for="item in otherDangers" :key="item.id" :label="item.name" :value="item.id">
                         </el-option>
@@ -1306,7 +1306,7 @@
                     </td>
                     <td colspan="6">
                       参与交底人签名/日期
-                      <el-select style="width: 600px;" multiple v-model="form.dPartakeBriefingSign" filterable
+                      <el-select style="width: 600px;"  v-model="form.dPartakeBriefingSign" filterable
                                  :disabled="this.form.dIsSafeBriefing==1?false:true">
                         <el-option v-for="item in users" :key="item.value" :label="item.label" :value="item.value">
                         </el-option>
@@ -2602,6 +2602,9 @@ export default {
       updateTicket(this.form).then(response => {
         this.msgSuccess(this.$t('票据数据已更新'));
       });
+      // addTicket(this.form).then(response => {
+      //   this.msgSuccess(this.$t('票据数据已更新'));
+      // });
     },
     //点击生成ID
     aIdClick() {