wangming преди 1 година
родител
ревизия
90e1d1ffb8

+ 10 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxInsideInspectionService.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
 import com.rongwei.bsentity.dto.inside.*;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * <p>
  * 内部报验-报验管理 服务类
@@ -67,4 +69,12 @@ public interface ZhcxInsideInspectionService extends IService<ZhcxInsideInspecti
      * @param req
      */
     void addModifyHistory(InsideInspectionModifyRecordRequest req);
+
+    /**
+     * 下载附件
+     *
+     * @param exportReq
+     * @param response
+     */
+    int downloadFile(ZhcxInsideExportRequest exportReq, HttpServletResponse response);
 }

+ 0 - 1
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionDispatchServiceImpl.java

@@ -8,7 +8,6 @@ import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDispatchDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionDispatchService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
-import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpSupervisionDispatchDo;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

+ 159 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionServiceImpl.java

@@ -2,9 +2,14 @@ package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.file.FileNameUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.ZipUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionDispatchService;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionOperLogService;
@@ -28,12 +33,21 @@ import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
 import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
+import com.rongwei.rwcommoncomponent.excel.aspose.ExcelFormData;
+import com.rongwei.rwcommoncomponent.excel.vo.FormData;
+import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -70,6 +84,12 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
     @Autowired
     private ZhcxInsideInspectionDao dao;
 
+    @Autowired
+    private SysFileItemService sysFileItemService;
+
+    @Value("${temp.filepath:#{null}}")
+    private String filepath;
+
     /**
      * 保存后操作
      *
@@ -270,6 +290,145 @@ public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspe
         operLogService.saveOperLog(req, operDto, descMap);
     }
 
+    /**
+     * 下载附件
+     *
+     * @param exportReq
+     * @param response
+     */
+    @Override
+    public int downloadFile(ZhcxInsideExportRequest exportReq, HttpServletResponse response) {
+        if(StringUtils.isEmpty(exportReq.getInsideId())){
+            return 0;
+        }
+        String insideId = exportReq.getInsideId();
+        ZhcxInsideInspectionDo inspection = getById(exportReq.getInsideId());
+        LambdaQueryWrapper<ZhcxInsideInspectionDispatchDo> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(ZhcxInsideInspectionDispatchDo::getInsideid, insideId);
+        ZhcxInsideInspectionDispatchDo dispatch = dispatchService.getOne(wrapper);
+        List<String> fileIds = new ArrayList<>();
+        if(ObjectUtil.isNotNull(dispatch)){
+            String sfiles = dispatch.getSfiles();
+            if(StringUtils.isNotBlank(sfiles)){
+                zhcxCommon.getIds(sfiles, fileIds);
+            }
+        }
+        String files = inspection.getFiles();
+        if(StringUtils.isNotBlank(files)){
+            zhcxCommon.getIds(files, fileIds);
+        }
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String classPath = filepath;
+        // 临时目录 以uuid+时间戳 为目录名称
+        String temp = classPath + File.separator + IdUtil.simpleUUID() + System.currentTimeMillis();
+        log.info("临时目录:"+temp);
+        // 临时目录如果存在则删除
+        File tempDir = new File(temp);
+        File zipFile = null;
+        log.info("临时目录是否存在:"+tempDir.exists());
+        try {
+            if (tempDir.exists()) {
+                FileUtil.del(tempDir);
+            }
+            // 创建临时目录
+            boolean mkdir = tempDir.mkdir();
+            log.info("临时目录是否创建:"+mkdir);
+            Map<String, Integer> fileNameCount = new HashMap<>();
+            String format = formatter.format(inspection.getReservationinspectiontime());
+            String fileFullName = inspection.getProjectcode()+"-"+inspection.getProjectname()+
+                    "-"+inspection.getStructurename()+"-"+inspection.getInspectionpoint()+
+                    "-"+format;
+            fileFullName = fileFullName.replaceAll("/","_");
+
+            //模板处理
+            ExcelFormData excelData = exportReq.getExcelData();
+            if(ObjectUtil.isNotEmpty(excelData.getTemplateId())) {
+                excelData.setExcelName(fileFullName+".pdf");
+                SysFileItemDo sysFileItemDo = sysFileItemService.getById(excelData.getTemplateId());
+                FormData formData = zhcxCommon.parseExcelPage2Data(excelData, sysFileItemDo);
+                zhcxCommon.parseTemplateByAspose(sysFileItemDo, excelData, temp, formData);
+            }
+
+            if(fileIds.size() > 0){
+                QueryWrapper<SysFileItemDo> qw = new QueryWrapper();
+                qw.in("ID", fileIds);
+                List<SysFileItemDo> list = sysFileItemService.list(qw);
+                log.info("下载数据数量:"+list.size());
+                if(list.size() > 0){
+                    if (mkdir) {
+                        list.forEach(item->{
+                            String filename = item.getFilename();
+                            boolean boo = fileNameCount.containsKey(filename);
+                            int i = 0;
+                            if(boo){
+                                i = fileNameCount.get(filename);
+                            }
+                            fileNameCount.put(filename,i+1);
+                            if(i > 0){
+                                String prefix = FileNameUtil.getPrefix(filename);
+                                String extName = FileNameUtil.extName(filename);
+                                filename = prefix+"("+i+")"+"."+extName;
+                            }
+                            FileUtil.copyFile(new File(item.getFullpath()),
+                                    new File(temp+File.separator+filename));
+                        });
+                    }
+                }
+            } else {
+                //没有附件且模板为空时
+                if(ObjectUtil.isEmpty(excelData.getTemplateId())) {
+                    return 0;
+                }
+            }
+
+            String encodedFileName = URLEncoder.encode(fileFullName+".zip", "UTF-8").replaceAll("\\+", "%20");
+            response.setContentType("application/octet-stream");
+            response.setHeader("content-type", "application/octet-stream");
+            response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", encodedFileName));
+
+            // 将临时目录压缩成zip
+            zipFile = ZipUtil.zip(temp);
+            byte[] buffer = new byte[1024];
+            FileInputStream fis = null;
+            BufferedInputStream bis = null;
+            try{
+                fis = new FileInputStream(zipFile);
+                bis = new BufferedInputStream(fis);
+                OutputStream os = response.getOutputStream();
+                int i = bis.read(buffer);
+                while (i != -1) {
+                    os.write(buffer, 0, i);
+                    i = bis.read(buffer);
+                }
+            } catch (IOException e) {
+                log.error("下载压缩资料报错:"+e);
+            }finally {
+                if (bis != null) {
+                    try {
+                        bis.close();
+                    } catch (IOException e) {
+
+                    }
+                }
+                if (fis != null) {
+                    try {
+                        fis.close();
+                    } catch (IOException e) {
+
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("下载资料报错, {}", e);
+            return 1;
+        }finally {
+            FileUtil.del(tempDir);
+            FileUtil.del(zipFile);
+        }
+
+        return 2;
+    }
+
     /**
      * 派单和执行
      *

+ 2 - 128
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpServiceImpl.java

@@ -22,20 +22,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.*;
 import com.rongwei.bsentity.vo.*;
 import com.rongwei.commonservice.serial.service.SysSerialNumberService;
-import com.rongwei.rwadmincommon.system.domain.PagePartDo;
-import com.rongwei.rwadmincommon.system.service.PagePartService;
 import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
-import com.rongwei.rwcommon.vo.MailDo;
 import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
-import com.rongwei.rwcommoncomponent.excel.aspose.DetailTable;
-import com.rongwei.rwcommoncomponent.excel.aspose.ExcelExportUtil;
 import com.rongwei.rwcommoncomponent.excel.aspose.ExcelFormData;
-import com.rongwei.rwcommoncomponent.excel.aspose.ParseFormParam;
 import com.rongwei.rwcommoncomponent.excel.vo.FormData;
 import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
@@ -91,11 +85,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
     @Autowired
     private ZhcxOutsideInspectionComponentTrackService inspectionComponentTrackService;
-    @Autowired
-    private PagePartService pagePartService;
 
-    @Autowired
-    private SysNotifyFeginService notifyFeginService;
     @Value("${temp.filepath:#{null}}")
     private String filepath;
 
@@ -958,8 +948,8 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
             ExcelFormData excelData = zhcxOutsideExportVo.getExcelData();
             excelData.setExcelName(fileFullName+".pdf");
             SysFileItemDo sysFileItemDo = sysFileItemService.getById(excelData.getTemplateId());
-            FormData formData = parseExcelPage2Data(excelData, sysFileItemDo);
-            parseTemplateByAspose(sysFileItemDo, excelData, temp, formData);
+            FormData formData = zhcxCommon.parseExcelPage2Data(excelData, sysFileItemDo);
+            zhcxCommon.parseTemplateByAspose(sysFileItemDo, excelData, temp, formData);
             String encodedFileName = URLEncoder.encode(fileFullName+".zip", "UTF-8").replaceAll("\\+", "%20");
             response.setContentType("application/octet-stream");
             response.setHeader("content-type", "application/octet-stream");
@@ -1044,122 +1034,6 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         List<OutsideInspactionSyncDto> inspection = dao.getInspection(req);
     }
 
-    /**
-     * 将doc文档输出到response中传给前端
-     *
-     * @param response
-     * @param filename
-     * @param doc
-     */
-    private void doc2Response(String tempPath,String filename, Document doc) {
-        try {
-            if (filename.indexOf("直打") >= 0 || filename.toLowerCase().indexOf("pdf") >= 0) {
-                doc.save(tempPath+File.separator+filename, com.aspose.words.SaveOptions.createSaveOptions(com.aspose.words.SaveFormat.PDF));
-            } else {
-                doc.save(tempPath+File.separator+filename, com.aspose.words.SaveOptions.createSaveOptions(com.aspose.words.SaveFormat.DOCX));
-            }
-        } catch (Exception e) {
-            log.error("填充失败:{}", e);
-            throw new CustomException("填充失败");
-        }
-    }
-
-    private  void wordTmplPrint(String tempPath,String filename,String templateFilePath, FormData formData)
-    {
-        log.info("准备开始填充 word 模板");
-        Document doc = ExcelExportUtil.fillWordDataByMap(templateFilePath, formData);
-        //doc保存至response
-        doc2Response(tempPath, filename, doc);
-    }
-    /**
-     * aspose 解析
-     *
-     * @param sysFileItemDo
-     * @param excelData
-     * @param response
-     * @param formData
-     */
-    private void parseTemplateByAspose(SysFileItemDo sysFileItemDo, ExcelFormData excelData, String tempPath, FormData formData) {
-        //word模板导出
-        if(sysFileItemDo.getFiletype().toLowerCase().equals("doc") || sysFileItemDo.getFiletype().toLowerCase().equals("docx")){
-            log.info("word模板导出开始");
-            this.wordTmplPrint(tempPath,excelData.getExcelName(),sysFileItemDo.getFullpath(), formData);
-        }
-    }
-    /**
-     * 解析配置获取数据
-     *
-     * @param excelData
-     * @param sysFileItemDo
-     * @return
-     */
-    private FormData parseExcelPage2Data(ExcelFormData excelData, SysFileItemDo sysFileItemDo) {
-        // 校验许可证
-//        ExcelUtils excelUtils = new ExcelUtils();
-        PagePartDo pagePartDo = pagePartService.getById(excelData.getPagepartId());
-        cn.hutool.json.JSONObject pagePartConfig = JSONUtil.parseObj(pagePartDo.getRoption());
-
-        ParseFormParam formParam = ParseFormParam.builder()
-                .formRoption(pagePartConfig)
-                .detailTables(excelData.getDetailTables())
-                .sysFileItemDo(sysFileItemDo)
-                .build();
-
-        return parsePage2Data(excelData.getFormId(), formParam);
-    }
-
-    /**
-     * 单个表单解析
-     *
-     * @param formId
-     * @param param
-     * @return
-     */
-    private FormData parsePage2Data(String formId, ParseFormParam param) {
-        //读取主表数据
-        String sqlMain = param.getFormRoption().getByPath("dataSource.formData.mainsql").toString();
-        List<Map<String,Object>> list = sysGeneralCRUDService.getDataBySql("select * from ("+sqlMain+") a where ID= '" + formId + "'");
-        list = ExcelExportUtil.convertFactData(list, param.getFormRoption(), param.getSysFileItemDo());
-        //明细数据
-        ArrayList<List<Map<String,Object>>> listall = new ArrayList<>();
-        //根据配置自动读取明细
-        for (DetailTable detailTable : param.getDetailTables()) {
-
-            if(ObjectUtil.isEmpty(detailTable.getMainRelKey())) {
-                detailTable.setMainRelKey("ID");
-            }
-
-            PagePartDo pagePartDetailDo = pagePartService.getById(detailTable.getPagepartid());
-            cn.hutool.json.JSONObject pagePartConfigDetail = JSONUtil.parseObj(pagePartDetailDo.getRoption());
-            String sqlDetailDetail = pagePartConfigDetail.getByPath("dataSource.formData.mainsql").toString();
-            List<Map<String, Object>> list1 = sysGeneralCRUDService.getDataBySql("select * from (" + sqlDetailDetail + ") a  where a.DELETED = '0' and " + detailTable.getRelationid() + "= '" + list.get(0).get(detailTable.getMainRelKey()) + "'");
-
-            // 为了处理aspose-cells模板打印bug,打印前要保证第一索引列有其所有字段,否则打印字段为空
-            // 如果list有多个map,则需要比较其他map中的所有字段
-            List<Map<String, Object>> finalList = list1;
-            if ((finalList.size() > 1)) {
-                for (int i = 1; i < finalList.size(); i++) {
-                    finalList.get(i).forEach((k, v)->{
-                        // 补上第一索引列缺失的key
-                        if (!finalList.get(0).containsKey(k)) {
-                            // TODO: 补上的value暂定为字符
-                            finalList.get(0).put(k, "");
-                        }
-                    });
-                }
-            }
-            list1 = finalList;
-            list1 = ExcelExportUtil.convertFactData(list1, pagePartConfigDetail, param.getSysFileItemDo());
-            listall.add(list1);
-        }
-
-        return FormData.builder()
-                .slaveTableDataList(listall)
-                .mainDataList(list)
-                .build();
-
-    }
-
     private void getIds(String files, List<String> fileIds) {
         String[] split = files.split("\\^_\\^");
         for(String fileItem : split){

+ 158 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/utils/ZhcxCommon.java

@@ -1,20 +1,37 @@
 package com.rongwei.bscommon.sys.utils;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONUtil;
+import com.aspose.words.Document;
 import com.rongwei.bscommon.sys.feign.SysNotifyFeginService;
 import com.rongwei.bsentity.dto.NotifyDto;
 import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.rwadmincommon.system.domain.PagePartDo;
+import com.rongwei.rwadmincommon.system.service.PagePartService;
+import com.rongwei.rwadmincommon.system.service.SysGeneralCRUDService;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.vo.MailDo;
+import com.rongwei.rwcommoncomponent.excel.aspose.DetailTable;
+import com.rongwei.rwcommoncomponent.excel.aspose.ExcelExportUtil;
+import com.rongwei.rwcommoncomponent.excel.aspose.ExcelFormData;
+import com.rongwei.rwcommoncomponent.excel.aspose.ParseFormParam;
+import com.rongwei.rwcommoncomponent.excel.vo.FormData;
+import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @Component
+@Slf4j
 public class ZhcxCommon {
 
     @Autowired
@@ -23,6 +40,12 @@ public class ZhcxCommon {
     @Autowired
     private SysNotifyFeginService notifyFeginService;
 
+    @Autowired
+    private PagePartService pagePartService;
+
+    @Autowired
+    private SysGeneralCRUDService sysGeneralCRUDService;
+
     public SysUserVo getCurrentUser() {
         // 获取当前登录人信息
         SysUserVo currUser = null;
@@ -61,4 +84,139 @@ public class ZhcxCommon {
         }
 
     }
+
+    /**
+     * aspose 解析
+     *
+     * @param sysFileItemDo
+     * @param excelData
+     * @param tempPath
+     * @param formData
+     */
+    public void parseTemplateByAspose(SysFileItemDo sysFileItemDo, ExcelFormData excelData, String tempPath, FormData formData) {
+        //word模板导出
+        if(sysFileItemDo.getFiletype().toLowerCase().equals("doc") || sysFileItemDo.getFiletype().toLowerCase().equals("docx")){
+            log.info("word模板导出开始");
+            this.wordTmplPrint(tempPath,excelData.getExcelName(),sysFileItemDo.getFullpath(), formData);
+        }
+    }
+
+
+    /**
+     * 解析配置获取数据
+     *
+     * @param excelData
+     * @param sysFileItemDo
+     * @return
+     */
+    public FormData parseExcelPage2Data(ExcelFormData excelData, SysFileItemDo sysFileItemDo) {
+        // 校验许可证
+//        ExcelUtils excelUtils = new ExcelUtils();
+        PagePartDo pagePartDo = pagePartService.getById(excelData.getPagepartId());
+        cn.hutool.json.JSONObject pagePartConfig = JSONUtil.parseObj(pagePartDo.getRoption());
+
+        ParseFormParam formParam = ParseFormParam.builder()
+                .formRoption(pagePartConfig)
+                .detailTables(excelData.getDetailTables())
+                .sysFileItemDo(sysFileItemDo)
+                .build();
+
+        return parsePage2Data(excelData.getFormId(), formParam);
+    }
+
+    /**
+     * 单个表单解析
+     *
+     * @param formId
+     * @param param
+     * @return
+     */
+    public FormData parsePage2Data(String formId, ParseFormParam param) {
+        //读取主表数据
+        String sqlMain = param.getFormRoption().getByPath("dataSource.formData.mainsql").toString();
+        List<Map<String,Object>> list = sysGeneralCRUDService.getDataBySql("select * from ("+sqlMain+") a where ID= '" + formId + "'");
+        list = ExcelExportUtil.convertFactData(list, param.getFormRoption(), param.getSysFileItemDo());
+        //明细数据
+        ArrayList<List<Map<String,Object>>> listall = new ArrayList<>();
+        //根据配置自动读取明细
+        for (DetailTable detailTable : param.getDetailTables()) {
+
+            if(ObjectUtil.isEmpty(detailTable.getMainRelKey())) {
+                detailTable.setMainRelKey("ID");
+            }
+
+            PagePartDo pagePartDetailDo = pagePartService.getById(detailTable.getPagepartid());
+            cn.hutool.json.JSONObject pagePartConfigDetail = JSONUtil.parseObj(pagePartDetailDo.getRoption());
+            String sqlDetailDetail = pagePartConfigDetail.getByPath("dataSource.formData.mainsql").toString();
+            List<Map<String, Object>> list1 = sysGeneralCRUDService.getDataBySql("select * from (" + sqlDetailDetail + ") a  where a.DELETED = '0' and " + detailTable.getRelationid() + "= '" + list.get(0).get(detailTable.getMainRelKey()) + "'");
+
+            // 为了处理aspose-cells模板打印bug,打印前要保证第一索引列有其所有字段,否则打印字段为空
+            // 如果list有多个map,则需要比较其他map中的所有字段
+            List<Map<String, Object>> finalList = list1;
+            if ((finalList.size() > 1)) {
+                for (int i = 1; i < finalList.size(); i++) {
+                    finalList.get(i).forEach((k, v)->{
+                        // 补上第一索引列缺失的key
+                        if (!finalList.get(0).containsKey(k)) {
+                            // TODO: 补上的value暂定为字符
+                            finalList.get(0).put(k, "");
+                        }
+                    });
+                }
+            }
+            list1 = finalList;
+            list1 = ExcelExportUtil.convertFactData(list1, pagePartConfigDetail, param.getSysFileItemDo());
+            listall.add(list1);
+        }
+
+        return FormData.builder()
+                .slaveTableDataList(listall)
+                .mainDataList(list)
+                .build();
+
+    }
+
+    /**
+     * 获取文件id
+     *
+     * @param files
+     * @param fileIds
+     */
+    public void getIds(String files, List<String> fileIds) {
+        String[] split = files.split("\\^_\\^");
+        for(String fileItem : split){
+            String id = fileItem.split("-;-")[1];
+            fileIds.add(id);
+        }
+    }
+
+    public void file2Zip() {}
+
+    private  void wordTmplPrint(String tempPath,String filename,String templateFilePath, FormData formData)
+    {
+        log.info("准备开始填充 word 模板");
+        Document doc = ExcelExportUtil.fillWordDataByMap(templateFilePath, formData);
+        //doc保存至response
+        doc2Response(tempPath, filename, doc);
+    }
+
+    /**
+     * 将doc文档输出到response中传给前端
+     *
+     * @param tempPath
+     * @param filename
+     * @param doc
+     */
+    private void doc2Response(String tempPath,String filename, Document doc) {
+        try {
+            if (filename.indexOf("直打") >= 0 || filename.toLowerCase().indexOf("pdf") >= 0) {
+                doc.save(tempPath+ File.separator+filename, com.aspose.words.SaveOptions.createSaveOptions(com.aspose.words.SaveFormat.PDF));
+            } else {
+                doc.save(tempPath+File.separator+filename, com.aspose.words.SaveOptions.createSaveOptions(com.aspose.words.SaveFormat.DOCX));
+            }
+        } catch (Exception e) {
+            log.error("填充失败:{}", e);
+            throw new CustomException("填充失败");
+        }
+    }
 }

+ 18 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/inside/ZhcxInsideExportRequest.java

@@ -0,0 +1,18 @@
+package com.rongwei.bsentity.dto.inside;
+
+import com.rongwei.rwcommoncomponent.excel.aspose.ExcelFormData;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class ZhcxInsideExportRequest {
+
+    private String insideId;
+
+    private ExcelFormData excelData;
+}

+ 27 - 8
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxInsideInspectionController.java

@@ -5,12 +5,15 @@ import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
 import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
 import com.rongwei.bsentity.dto.inside.*;
 import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.base.exception.CustomException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * <p>
  * 内部报验-报验管理 前端控制器
@@ -24,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
 public class ZhcxInsideInspectionController {
 
     @Autowired
-    private ZhcxInsideInspectionService zhcxInsideInspectionService;
+    private ZhcxInsideInspectionService service;
 
     /**
      * 发起
@@ -34,7 +37,7 @@ public class ZhcxInsideInspectionController {
      */
     @PostMapping("/launch")
     public R launch(@RequestBody InsideInspectionOperRequest req){
-        zhcxInsideInspectionService.launch(req);
+        service.launch(req);
         return R.ok();
     }
 
@@ -47,7 +50,7 @@ public class ZhcxInsideInspectionController {
     @PostMapping("/dispacth")
     public R dispacth(@RequestBody InsideInspectionDispatchRequest req){
         req.setDispatchFlag(1);
-        zhcxInsideInspectionService.dispatch(req);
+        service.dispatch(req);
         return R.ok("派单成功");
     }
 
@@ -60,7 +63,7 @@ public class ZhcxInsideInspectionController {
     @PostMapping("/reDispatch")
     public R reDispatch(@RequestBody InsideInspectionDispatchRequest req){
         req.setDispatchFlag(2);
-        zhcxInsideInspectionService.reDispatch(req);
+        service.reDispatch(req);
         return R.ok("改派成功");
     }
 
@@ -72,7 +75,7 @@ public class ZhcxInsideInspectionController {
      */
     @PostMapping("/execute")
     public R execute(@RequestBody InsideInspectionDispatchRequest req){
-        zhcxInsideInspectionService.execute(req);
+        service.execute(req);
         return R.ok("执行成功");
     }
 
@@ -84,7 +87,7 @@ public class ZhcxInsideInspectionController {
      */
     @PostMapping("/cancel")
     public R cancel(@RequestBody InsideInspectionRequest req){
-        zhcxInsideInspectionService.cancel(req);
+        service.cancel(req);
         return R.ok();
     }
 
@@ -96,7 +99,7 @@ public class ZhcxInsideInspectionController {
      */
     @PostMapping("/reInspection")
     public R reInspection(@RequestBody InsideInspectionReInspectionRequest req){
-        zhcxInsideInspectionService.reInspection(req);
+        service.reInspection(req);
         return R.ok();
     }
 
@@ -108,8 +111,24 @@ public class ZhcxInsideInspectionController {
      */
     @PostMapping("/addModifyHistory")
     public R addModifyHistory(@RequestBody InsideInspectionModifyRecordRequest req){
-        zhcxInsideInspectionService.addModifyHistory(req);
+        service.addModifyHistory(req);
         return R.ok();
     }
+
+    /**
+     * 下载
+     *
+     * @param exportReq
+     * @param response
+     */
+    @RequestMapping("/downloadFile")
+    public void downloadFile(@RequestBody ZhcxInsideExportRequest exportReq, HttpServletResponse response) {
+        int i = service.downloadFile(exportReq, response);
+        if(i == 0){
+            throw new CustomException("暂无相关附件");
+        }else if(i == 1){
+            throw new CustomException("下载附件失败");
+        }
+    }
 }