ly 3 anos atrás
pai
commit
20f055bdce

+ 16 - 3
master/src/main/java/com/ruoyi/project/common/controller/WordController.java

@@ -5,6 +5,9 @@ import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
 import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
 import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
 import com.deepoove.poi.XWPFTemplate;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.config.RuoYiConfig;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
@@ -40,7 +43,7 @@ public class WordController extends BaseController
      * @param paramMap     参数集合
      * @return 返回word生成的路径
      */
-    public String createWord(String templatePath, String fileDir, String fileName, Map<String, Object> paramMap) {
+    public String createWord(String templatePath, String fileDir, String fileName, Map<String, Object> paramMap) throws IOException {
         Assert.notNull(templatePath, "word模板文件路径不能为空");
         Assert.notNull(fileDir, "生成的文件存放地址不能为空");
         Assert.notNull(fileName, "生成的文件名不能为空");
@@ -49,7 +52,8 @@ public class WordController extends BaseController
             logger.info("目录不存在,创建文件夹{}!", fileDir);
             dir.mkdirs();
         }
-        String filePath = fileDir +"\\"+ fileName;
+        String filePath = fileDir +"/"+ fileName;
+        logger.info("目录{}!", filePath);
         // 读取模板渲染参数
         InputStream is = getClass().getClassLoader().getResourceAsStream(templatePath);
         XWPFTemplate template = XWPFTemplate.compile(is).render(paramMap);
@@ -61,7 +65,8 @@ public class WordController extends BaseController
             logger.error("生成word异常{}", e.getMessage());
             e.printStackTrace();
         }
-        return filePath;
+        String pathFileName = getPathFileName(RuoYiConfig.getFilePath("/"+ "ticketWord"), fileName);
+        return pathFileName;
     }
 
     /**
@@ -144,4 +149,12 @@ public class WordController extends BaseController
         System.out.println("转换完成!");
     }
 
+    private static final String getPathFileName(String uploadDir, String fileName) throws IOException
+    {
+        int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
+        String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
+        String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
+        return pathFileName;
+    }
+
 }

+ 20 - 10
master/src/main/java/com/ruoyi/project/ticket/controller/THazardWorkPermitController.java

@@ -15,6 +15,8 @@ import com.ruoyi.project.ticket.service.ITPermitRelationService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -108,14 +110,13 @@ public class THazardWorkPermitController extends BaseController {
      */
     @Log(title = "危害工作许可证", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody THazardWorkPermit tHazardWorkPermit) {
+    public AjaxResult add(@RequestBody THazardWorkPermit tHazardWorkPermit) throws IOException {
         Long ticketId =  tTicketIdController.createId();
         logger.info("ticketId:" + ticketId);
         tHazardWorkPermit.setaId(ticketId);
         //生成word
-        Map<String, Object> params = new HashMap<>();
-        // 渲染文本
-        params.put("aId",ticketId);
+        //渲染文本
+        Map<String, Object> params = getWordData(tHazardWorkPermit);
         // 模板路径
         String templatePath = "static/word/ticket.docx";
         // 生成word的路径
@@ -130,7 +131,6 @@ public class THazardWorkPermitController extends BaseController {
         permitRelation.setPermitId(tHazardWorkPermit.getaId());
         permitRelation.setPermitType("A");
         permitRelation.setPermitStatus(1L);
-
         this.itPermitRelationService.add(permitRelation);
         return AjaxResult.success(tHazardWorkPermit.getaId());
     }
@@ -140,15 +140,14 @@ public class THazardWorkPermitController extends BaseController {
      */
     @Log(title = "危害工作许可证", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody THazardWorkPermit tHazardWorkPermit) {
+    public AjaxResult edit(@RequestBody THazardWorkPermit tHazardWorkPermit) throws IOException {
         //生成word
-        Map<String, Object> params = new HashMap<>();
-        // 渲染文本
-        params.put("aId",tHazardWorkPermit.getaId());
+        //渲染文本
+        Map<String, Object> params = getWordData(tHazardWorkPermit);
         // 模板路径
         String templatePath = "static/word/ticket.docx";
         // 生成word的路径
-        String fileDir = RuoYiConfig.getProfile();
+        String fileDir = RuoYiConfig.getProfile() + "/"+ "ticketWord";
         // 生成word的文件
         String fileName = "A" + tHazardWorkPermit.getaId() + ".docx";
         String wordPath = this.wordController.createWord(templatePath, fileDir, fileName, params);
@@ -164,4 +163,15 @@ public class THazardWorkPermitController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] aIds) {
         return toAjax(tHazardWorkPermitService.deleteTHazardWorkPermitByIds(aIds));
     }
+
+    public Map<String, Object> getWordData (THazardWorkPermit tHazardWorkPermit){
+        Map<String, Object> params = new HashMap<>();
+        // 渲染文本
+        params.put("aId",tHazardWorkPermit.getaId());
+        params.put("aEquipmentName" , tHazardWorkPermit.getaEquipmentName());
+        params.put("aEquipmentLeader" , tHazardWorkPermit.getaEquipmentLeader());
+        params.put("aEquipmentTel" , tHazardWorkPermit.getaEquipmentTel());
+        params.put("aEquipmentOffice" , tHazardWorkPermit.getaEquipmentOffice());
+        return params;
+    }
 }

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

@@ -14,12 +14,21 @@ public class PermitRelation extends BaseEntity {
     private String chVNoOne;
     private String delayCount;
     private String delayNo;
+    private String wordUrl;
     private List<PermitRelation> children;
 
     private Long permitId;
     private String permitType;
     private Long permitStatus;
 
+    public String getWordUrl() {
+        return wordUrl;
+    }
+
+    public void setWordUrl(String wordUrl) {
+        this.wordUrl = wordUrl;
+    }
+
     public Long getPermitId() {
         return permitId;
     }

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

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

+ 1 - 0
master/src/main/resources/mybatis/ticket/TPermitRelationMapper.xml

@@ -20,6 +20,7 @@
     <sql id="selectPermitRelationVo">
         SELECT t.id,
                a.a_id           AS aId,
+               a.word_url           AS wordUrl,
                c.c_id           AS cId,
                a.B_WORK_CONTENT AS bWorkContent,
                c.B_WORK_CONTENT AS cbWorkContent,

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


+ 60 - 27
ui/src/views/invoicing/hazardwork/index.vue

@@ -2007,21 +2007,21 @@ export default {
       signCardVisible: false,
       //TODO 模拟生产装置获取后台数据
       aEquipments: [{
-        value: '1',
+        value: 'CTM',
         label: 'CTM'
       }, {
-        value: '2',
-        label: 'CTA'
+        value: 'BCC',
+        label: 'BCC'
       }],
       aConstructions: [],
       aConstructionsQuery: {
         parentId: 500
       },
       aContractors: [{
-        value: '1',
+        value: 'CTM',
         label: 'CTM'
       }, {
-        value: '2',
+        value: 'CTA',
         label: 'CTA'
       }],
       aSafeLiaisons: [{
@@ -2054,89 +2054,89 @@ export default {
       }],
       otherDangers: [
         {
-          id: '1',
+          id: '坠落',
           name: '坠落'
         },
         {
-          id: '2',
+          id: '高空坠物',
           name: '高空坠物'
         },
         {
-          id: '3',
+          id: '灰尘',
           name: '灰尘'
         }
       ],
       dClears: [
         {
-          id: '1',
+          id: '',
           name: '水'
         },
         {
-          id: '2',
+          id: '空气',
           name: '空气'
         },
         {
-          id: '3',
+          id: '氮气',
           name: '氮气'
         },
         {
-          id: '4',
+          id: '蒸汽',
           name: '蒸汽'
         }
       ],
       dFlushs: [
         {
-          id: '1',
+          id: '',
           name: '水'
         },
         {
-          id: '2',
+          id: '空气',
           name: '空气'
         },
         {
-          id: '3',
+          id: '氮气',
           name: '氮气'
         },
         {
-          id: '4',
+          id: '蒸汽',
           name: '蒸汽'
         }
       ],
       dSiteDemarcations: [
         {
-          id: '1',
+          id: '警戒绳',
           name: '警戒绳'
         },
         {
-          id: '2',
+          id: '警戒锥桶',
           name: '警戒锥桶'
         }
       ],
       eFallArrestContents: [
         {
-          id: '1',
+          id: '腰部护带',
           name: '腰部护带'
         },
         {
-          id: '2',
+          id: '全身护带',
           name: '全身护带'
         }
       ],
       eAnalyzeAirIntervals: [
         {
-          id: '1',
+          id: '1h/次',
           name: '1h/次'
         },
         {
-          id: '2',
+          id: '2h/次',
           name: '2h/次'
         },
         {
-          id: '3',
+          id: '6h/次',
           name: '6h/次'
         },
         {
-          id: '4',
+          id: '12h/次',
           name: '12h/次'
         }
       ],
@@ -3144,16 +3144,49 @@ export default {
       console.log(res)
       if (res.signType == 'hSafeMesSign') {
         this.form.hSafeMesSign = res.cardId
-        this.form.hSafeMesDate = new Date();
+        this.form.hSafeMesDate = this.dateformat('y-M-d h:m:s')
         console.log('chuanguolai' + this.form.hSafeMesSign)
       }
       if (res.signType == 'kConfirmSign') {
         this.form.kConfirmSign = res.cardId
-        this.form.kConfirmDate = new Date();
+        this.form.kConfirmDate = this.dateformat('y-M-d h:m:s')
         this.$set(this.value1, 0, this.form.kConfirmDate);
         console.log('chuanguolai' + this.form.kConfirmSign)
       }
-    }
+    },
+    dateformat(params) {
+      var date = new Date(),
+        year = date.getFullYear(),
+        month = date.getMonth() + 1,
+        day = date.getDate(),
+        hour = date.getHours(),
+        minute = date.getMinutes(),
+        second = date.getSeconds()
+      var arr = params.split('')
+      var result = ''
+      for(var i = 0; i < arr.length; i += 2){
+        var tem = arr[i+1] === undefined ? '' : arr[i+1]
+        switch(arr[i]){
+          case 'y': result += this.addZero(year) + tem
+            break
+          case 'M': result += this.addZero(month) + tem
+            break
+          case 'd': result += this.addZero(day) + tem
+            break
+          case 'h': result += this.addZero(hour) + tem
+            break
+          case 'm': result += this.addZero(minute) + tem
+            break
+          case 's': result += this.addZero(second)
+            break
+        }
+      }
+      return result
+    },
+    // 如果时间是个位数,就补0
+    addZero(obj){
+        return obj < 10 ? '0' + obj : obj
+      }
   }
 };
 </script>

+ 1 - 1
ui/src/views/invoicing/signcard/index.vue

@@ -96,7 +96,7 @@ export default {
           this.cardId = resultData.RePara_Str;
           this.websocketsend("145|halt|" + this.paramStr + "");
         } else {
-          this.cardId = this.cardId + "..."
+          this.cardId = "..."
           this.findCard()
         }
       } else if (resultData.FunctionID == "45") {

+ 19 - 1
ui/src/views/invoicing/ticketList/index.vue

@@ -42,7 +42,7 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
-          >修改
+          >查看
           </el-button>
           <el-button
             size="mini"
@@ -51,6 +51,12 @@
             @click="delay(scope.row)"
           >延期
           </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-download"
+            @click="handleDownload(scope.row)"
+          >{{ $t('下载') }}</el-button>
           <!--          <el-button
                       size="mini"
                       type="text"
@@ -148,6 +154,18 @@ export default {
       console.log(row.permitStatus);
       return this.selectDictLabel(this.permitStatusOptions, row.permitStatus);
     },
+    // 文件下载处理
+    handleDownload(row) {
+      var name = row.permitType + row.aId + '.docx';
+      var url = row.wordUrl;
+      var suffix = url.substring(url.lastIndexOf("."), url.length);
+      console.log(url)
+      const a = document.createElement('a')
+      a.setAttribute('download', name)
+      a.setAttribute('target', '_blank')
+      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
+      a.click()
+    },
   },
 }
 </script>