소스 검색

-添加:5s管理excel下载

jiangbiao 2 년 전
부모
커밋
f69d690817

+ 5 - 1
master/src/main/java/com/ruoyi/project/invoice/controller/TInvoiceBookingworkticketController.java

@@ -22,7 +22,6 @@ import com.ruoyi.project.invoice.domain.TInvoiceWorkcontent;
 import com.ruoyi.project.invoice.mapper.TInvoiceWorkcontentMapper;
 import com.ruoyi.project.invoice.service.ITApproveReserveInvoiceService;
 import com.ruoyi.project.invoice.service.ITInvoiceBookingworkticketService;
-import com.ruoyi.project.sems.domain.TSpecdevYlgd;
 import com.ruoyi.project.system.domain.SysDictData;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.service.ISysDictTypeService;
@@ -1090,3 +1089,8 @@ public class TInvoiceBookingworkticketController extends BaseController {
         return pathName;
     }
 }
+//1:地面无杂物
+//2:物品定置摆放
+//3:公共设施及安全设施完好
+//4:门保持常开
+//5:消防实施完好

+ 246 - 2
master/src/main/java/com/ruoyi/project/production/controller/TFivesRegionController.java

@@ -1,19 +1,34 @@
 package com.ruoyi.project.production.controller;
 
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.file.FileUploadUtils;
 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.plant.domain.TStaffmgr;
+import com.ruoyi.project.plant.service.ITStaffmgrService;
+import com.ruoyi.project.production.domain.TFivesFile;
 import com.ruoyi.project.production.domain.TFivesRegion;
+import com.ruoyi.project.production.service.ITFivesFileService;
 import com.ruoyi.project.production.service.ITFivesRegionService;
+import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
-import java.util.List;
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.*;
 
 /**
  * 区域列台账Controller
@@ -26,6 +41,10 @@ import java.util.List;
 public class TFivesRegionController extends BaseController {
     @Autowired
     private ITFivesRegionService tFivesRegionService;
+    @Autowired
+    private ITFivesFileService tFivesFileService;
+    @Autowired
+    private ITStaffmgrService tStaffmgrService;
 
     /**
      * 查询区域列台账列表
@@ -96,4 +115,229 @@ public class TFivesRegionController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tFivesRegionService.deleteTFivesRegionByIds(ids));
     }
+
+    @Log(title = "区域列台账", businessType = BusinessType.EXPORT)
+    @GetMapping("/generateExcel/{id}")
+    public AjaxResult generateExcel(@PathVariable Long id) {
+        try {
+            String templateFilePath = "static/template/production/regionMod.xlsx";
+            String filePath = RuoYiConfig.getProfile() + "/production/regionMod";
+            File fileDir = new File(filePath);
+            if (!fileDir.exists()) {
+                logger.info("不存在目录:{},开始创建。", fileDir);
+                fileDir.mkdirs();
+            }
+            TFivesRegion tFivesRegion = tFivesRegionService.selectTFivesRegionById(id);
+            InputStream fis = getClass().getClassLoader().getResourceAsStream(templateFilePath);
+            XSSFWorkbook wb = new XSSFWorkbook(fis);
+            XSSFSheet sheet = wb.getSheetAt(0);
+            Map<String, Object> param = new HashMap<>();
+            param.put("{personLiable}", tFivesRegion.getPersonLiable());
+            param.put("{position}", tFivesRegion.getPosition());
+            param.put("{deptName}", tFivesRegion.getDeptName());
+            int flag;
+            if (tFivesRegion.getPosition().contains("打印")) {
+                flag = 1;
+            } else if (tFivesRegion.getPosition().contains("洗手间") || tFivesRegion.getPosition().contains("更衣室") || tFivesRegion.getPosition().contains("浴室") || tFivesRegion.getPosition().contains("厕")) {
+                flag = 2;
+            } else if (tFivesRegion.getPosition().contains("吸烟室")) {
+                flag = 3;
+            } else if (tFivesRegion.getPosition().contains("危废库房")) {
+                flag = 4;
+            } else if (tFivesRegion.getPosition().contains("库房")) {
+                flag = 5;
+            } else {
+                flag = 6;
+            }
+            // 获取行数添加相关信息
+            int rowNum = sheet.getLastRowNum();
+            for (int i = 0; i < rowNum; i++) {
+                XSSFRow row = sheet.getRow(i);
+                // 获取行里面的总列数
+                int columnNum = 0;
+                if (row != null) {
+                    columnNum = row.getPhysicalNumberOfCells();
+                }
+                for (int j = 0; j < columnNum; j++) {
+                    XSSFCell cell = sheet.getRow(i).getCell(j);
+                    String cellValue = cell.getStringCellValue();
+                    for (Map.Entry<String, Object> entry : param.entrySet()) {
+                        String key = entry.getKey();
+                        if (key.equals(cellValue)) {
+                            String value = entry.getValue().toString();
+                            XSSFCell newCell = sheet.getRow(i).getCell(j);
+                            newCell.setCellValue(value);
+                        }
+                    }
+                    if (i == 5 && j == 0) {
+                        cell.setCellValue("1:无杂物及灰尘");
+                    }
+                    if (i == 6 && j == 0) {
+                        if (flag == 1 || flag == 2) {
+                            cell.setCellValue("2:物品定置摆放");
+                        } else {
+                            cell.setCellValue("2:仅限必要列具物品");
+                        }
+                    }
+                    if (i == 7 && j == 0) {
+                        if (flag == 1) {
+                            cell.setCellValue("3:标准化文档管理");
+                        } else if (flag == 2) {
+                            cell.setCellValue("3:公共设施及安全设施完好");
+                        } else {
+                            cell.setCellValue("3:办公室物品定置摆放");
+                        }
+                    }
+                    if (i == 8 && j == 0) {
+                        if (flag == 1) {
+                            cell.setCellValue("4:公共设施及安全设施完好");
+                        } else if (flag == 2) {
+                            cell.setCellValue("4:门保持常闭");
+                        } else {
+                            cell.setCellValue("4:流程设置合理有效");
+                        }
+                    }
+                    if (i == 9 && j == 0) {
+                        if (flag == 1 || flag == 2) {
+                            cell.setCellValue("5:保持空调系统运行正常");
+                        } else {
+                            cell.setCellValue("5:办公设施良好");
+                        }
+                    }
+                    if (i == 10 && j == 0) {
+                        if (flag == 1) {
+                            cell.setCellValue("6:严格遵守公司信息保密规定");
+                        } else if (flag == 2) {
+                            cell.setCellValue("");
+                        } else {
+                            cell.setCellValue("6:标准化文档管理,遵守公司信息保密规定");
+                        }
+                    }
+                    if (i == 11 && j == 0) {
+                        if (flag == 1) {
+                            cell.setCellValue("7:定期巡检");
+                        } else if (flag == 2) {
+                            cell.setCellValue("");
+                        } else {
+                            cell.setCellValue("7:无纸化与节俭办公");
+                        }
+                    }
+                    if (i == 12 && j == 0) {
+                        if (flag == 1) {
+                            cell.setCellValue("");
+                        } else if (flag == 2) {
+                            cell.setCellValue("");
+                        } else {
+                            cell.setCellValue("8:热情工作文明礼仪");
+                        }
+                    }
+                }
+            }
+            // 插入图片
+            // 区域标准照片
+            XSSFDrawing patriarch = sheet.createDrawingPatriarch();
+            if (StringUtils.isNotEmpty(tFivesRegion.getFileId())) {
+                List<String> urls = new ArrayList<>();
+                for (String fileId : tFivesRegion.getFileId().split(",")) {
+                    TFivesFile file = tFivesFileService.selectTFivesFileById(Long.valueOf(fileId));
+                    urls.add(file.getUrl());
+                }
+
+                for (int i = 0; i < urls.size(); i++) {
+                    String url = urls.get(i);
+                    ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+                    BufferedImage bufferImg = ImageIO.read(new File(RuoYiConfig.getProfile() + url.replaceFirst("/profile", "")));
+                    ImageIO.write(bufferImg, "jpg", byteArrayOut);
+                    int h = 0;
+                    int l = 0;
+                    int endh = 0;
+                    int endl = 0;
+                    if (urls.size() == 1) {
+                        endl = 5;
+                        endh = 10;
+                    }
+                    if (i == 0) {
+                        if (urls.size() == 2) {
+                            endl = 5;
+                        }
+                    } else if (i == 1) {
+                        if (urls.size() == 2) {
+                            h = 12;
+                            endh = 10;
+                        } else {
+                            l = 5;
+                        }
+                        endl = 5;
+                    } else if (i == 2) {
+                        h = 12;
+                        endh = 10;
+                    } else if (i == 3) {
+                        l = 5;
+                        endl = 5;
+                        h = 12;
+                        endh = 10;
+                    }
+                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 6 + l, 2 + h, 11 + endl, 14 + endh);
+                    // 插入图片
+                    patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
+                    byteArrayOut.close();
+                }
+            }
+            List<String> urls = new ArrayList<>();
+            if (tFivesRegion.getInSys().equals("否")) {
+                if (StringUtils.isNotEmpty(tFivesRegion.getPersonFile())) {
+                    for (String fileId : tFivesRegion.getPersonFile().split(",")) {
+                        TFivesFile file = tFivesFileService.selectTFivesFileById(Long.valueOf(fileId));
+                        urls.add(file.getUrl());
+                    }
+                }
+            } else {
+                if (StringUtils.isNotEmpty(tFivesRegion.getStaffId())) {
+                    for (String staffId : tFivesRegion.getStaffId().split(",")) {
+                        TStaffmgr tStaffmgr = tStaffmgrService.selectTStaffmgrByStaffId(staffId);
+                        urls.add(tStaffmgr.getPhoto());
+                    }
+                }
+            }
+            for (int i = 0; i < urls.size(); i++) {
+                String url = urls.get(i);
+                ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+                BufferedImage bufferImg = ImageIO.read(new File(RuoYiConfig.getProfile() + url.replaceFirst("/profile", "")));
+                ImageIO.write(bufferImg, "jpg", byteArrayOut);
+                int h = 0;
+                int l = 0;
+                int endh = 0;
+                int endl = 0;
+                if (urls.size() == 1) {
+                    endl = 1;
+                    endh = 2;
+                }
+                if (i == 1) {
+                    l = 1;
+                    endl = 1;
+                } else if (i == 2) {
+                    h = 2;
+                    endh = 2;
+                } else if (i == 3) {
+                    l = 1;
+                    endl = 1;
+                    h = 2;
+                    endh = 2;
+                }
+                XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 0 + l, 14 + h, 1 + endl, 16 + endh);
+                // 插入图片
+                patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
+                byteArrayOut.close();
+            }
+            String fileName = DateUtils.dateTimeNow() + "_" + tFivesRegion.getPersonLiable() + ".xlsx";
+            wb.write(Files.newOutputStream(Paths.get(filePath + "/" + fileName)));
+            fis.close();
+            wb.close();
+            String pathFileName = FileUploadUtils.getPathFileName(filePath, fileName);
+            return AjaxResult.success(pathFileName);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
 }

+ 0 - 5
master/src/main/java/com/ruoyi/project/production/domain/TFivesMonthlyInspection.java

@@ -126,27 +126,23 @@ public class TFivesMonthlyInspection extends BaseEntity {
     /**
      * 创建人
      */
-    @Excel(name = "创建人")
     private String createrCode;
 
     /**
      * 创建时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
-    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date createdate;
 
     /**
      * 修改人
      */
-    @Excel(name = "修改人")
     private String updaterCode;
 
     /**
      * 修改时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
-    @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date updatedate;
 
     /**
@@ -158,7 +154,6 @@ public class TFivesMonthlyInspection extends BaseEntity {
     /**
      * 部门编号
      */
-    @Excel(name = "部门编号")
     private Long deptId;
 
     /**

+ 3 - 3
master/src/main/resources/mybatis/production/TFivesRegionMapper.xml

@@ -117,7 +117,7 @@
             <if test="position != null">position = #{position},</if>
             <if test="personLiable != null">person_liable = #{personLiable},</if>
             <if test="roomNo != null">room_no = #{roomNo},</if>
-            <if test="fileId != null">file_id = #{fileId},</if>
+            <if test="fileId != null and fileId != ''">file_id = #{fileId},</if>
             <if test="remarks != null">remarks = #{remarks},</if>
             <if test="status != null">status = #{status},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
@@ -127,8 +127,8 @@
             <if test="updatedate != null">updatedate = #{updatedate},</if>
             <if test="deptId != null">dept_id = #{deptId},</if>
             <if test="inSys != null">in_sys = #{inSys},</if>
-            <if test="personFile != null">person_file = #{personFile},</if>
-            <if test="staffId != null">staff_id = #{staffId},</if>
+            <if test="personFile != null and personFile != ''">person_file = #{personFile},</if>
+            <if test="staffId != null and staffId != ''">staff_id = #{staffId},</if>
         </trim>
         where id = #{id}
     </update>

BIN
master/src/main/resources/static/template/production/regionMod.xlsx


+ 8 - 0
ui/src/api/production/region.js

@@ -59,3 +59,11 @@ export function exportRegion(query) {
     params: query
   })
 }
+
+// 导出区域
+export function generateExcel(id) {
+  return request({
+    url: '/production/region/generateExcel/'+id,
+    method: 'get',
+  })
+}

+ 24 - 12
ui/src/views/production/region/index.vue

@@ -124,18 +124,10 @@
           <el-button
             size="mini"
             type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
+            icon="el-icon-download"
+            @click="generateExcel(scope.row)"
             v-hasPermi="['production:region:edit']"
-          >修改
-          </el-button>
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
-            v-hasPermi="['production:region:remove']"
-          >删除
+          >下载
           </el-button>
         </template>
       </el-table-column>
@@ -277,7 +269,7 @@ import {
   addRegion,
   updateRegion,
   exportRegion,
-  importTemplate
+  importTemplate, generateExcel
 } from "@/api/production/region";
 import {treeselect} from "@/api/system/dept";
 import {getToken} from "@/utils/auth";
@@ -407,6 +399,26 @@ export default {
     this.getStaff();
   },
   methods: {
+    generateExcel(row) {
+      console.log(row.id)
+      this.$confirm('确认下载当前数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        return generateExcel(row.id);
+      }).then(response => {
+        var name = response.msg;
+        name = name.substring(name.lastIndexOf('/'),name.length);
+        var url = response.msg;
+        var suffix = url.substring(url.lastIndexOf("."), url.length);
+        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()
+      })
+    },
     getStaff() {
       listOgzStaffmgr({}).then(res => {
         this.staffList = res