Pārlūkot izejas kodu

下载资料调整

zhuang 1 gadu atpakaļ
vecāks
revīzija
c46ac06b98

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

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 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.json.JSONUtil;
@@ -32,6 +33,7 @@ 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.Isolation;
 import org.springframework.transaction.annotation.Transactional;
@@ -83,6 +85,8 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
     @Autowired
     private SysNotifyFeginService notifyFeginService;
+    @Value("${temp.filepath}")
+    private String filepath;
 
     /**
      * 拆单
@@ -240,12 +244,16 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
             }
             /* 取消 */
             if ("10".equals(operType)) {
+                String cancelSource = vo.get(i).getSource();
                 //监理检验员在执行任务页面只能操作自己的数据 PageType--页面入口 task -- 执行任务页面
                 if("task".equals(vo.get(i).getPageType()) && !user.getId().equals(dispatchDo.getSupervisionuserid())){
                     sb.append("单据号:"+inspectioncode+"已被改派,不能取消,请刷新数据查看<br>");
                     continue;
                 }
-
+                if("10".equals(cancelSource) && hasDispatch){
+                    sb.append("单据号:"+inspectioncode+"已被派单,不能取消,请刷新数据查看<br>");
+                    continue;
+                }
                 //获取邮件发送信息
                 NotifyDto mailInfo4Cancel = getMailInfo4Cancel(vo.get(i), inspectionItpDo, dispatchDo, user);
                 if(ObjectUtil.isNotNull(mailInfo4Cancel)) {
@@ -254,7 +262,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
                 /* 10: QC 20: 监理 */
                 /* 10: 派单前监理取消 20: 派单后监理取消 30: 派单前QC取消 40: 派单后QC取消 */
-                String cancelSource = vo.get(i).getSource();
+
                 switch (cancelSource) {
                     case "10":
                         dispatchDo.setCanceltype(hasDispatch ? "40" : "30");
@@ -529,26 +537,43 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
             QueryWrapper<SysFileItemDo> qw = new QueryWrapper();
             qw.in("ID", fileIds);
             List<SysFileItemDo> list = sysFileItemService.list(qw);
+            log.info("下载数据数量:"+list.size());
             if(list.size() > 0){
                 // 获取类路径
-                String classPath = ResourceUtils.getURL("classpath:").getPath();
+                String classPath = filepath;
                 // 临时目录 以uuid+时间戳 为目录名称
-                String temp = classPath + IdUtil.simpleUUID() + System.currentTimeMillis();
+                String temp = classPath +File.separator + IdUtil.simpleUUID() + System.currentTimeMillis();
+                log.info("临时目录:"+temp);
                 // 临时目录如果存在则删除
                 File tempDir = new File(temp);
                 File zipFile = null;
                 try {
-
+                    log.info("临时目录是否存在:"+tempDir.exists());
                     if (tempDir.exists()) {
                         FileUtil.del(tempDir);
                     }
                     // 创建临时目录
                     boolean mkdir = tempDir.mkdir();
+                    log.info("临时目录是否创建:"+mkdir);
+                    Map<String, Integer> fileNameCount = new HashMap<>();
                     if (mkdir) {
 
-                        list.forEach(item->
+                        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+item.getFilename()))
+                                new File(temp+File.separator+filename));
+                            }
                         );
                         // 设置响应的一些格式
                         String encodedFileName = URLEncoder.encode(inspectionItpDo.getInspectioncode()+".zip", "UTF-8").replaceAll("\\+", "%20");
@@ -594,7 +619,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
                     }
                 } catch (Exception e) {
-                    //throw new CustomException("下载附件失败");
+                    e.printStackTrace();
                     return 1;
                 }finally {
                     // 删除临时目录和压缩后的文件

+ 26 - 9
business-entity/src/main/java/com/rongwei/bsentity/vo/ZhcxOutsideInspectionVo.java

@@ -58,17 +58,34 @@ public class ZhcxOutsideInspectionVo {
     private String structureid;
     private String inspectioncontentid;
     private String inspectionlocationsupplement;
+//    private String LAUNCHSOURCE;
+//    private String SOURCEID;
+//    private String SOURCECODE;
+//    private String LIFECYCLE;
+    private String structuremachineid;
+    private String structuremachineno;
+//    private String SELFTESTERID;
+//    private Date INSPECTIONCOMPLATETIME;
+    private String laboratoryname;
+    private String teamgroupid;
+    private String teamgroupname;
+    private String laboratoryid;
+//    private String TEAMGROUPPATHID;
+//    private String LABORATORYPATHID;
+
     private String itpid;
     private String inspectionconclusion;
     private String supervisionid;
     private String supervision;
-    private String SUPERVISIONPHONE;
-    private Date CHECKSTARTTIME;
-    private Date CHECKENDTIME;
-    private String CANCELTYPE;
-    private String CANCELREASON;
-    private String DISPATCHID;
-    private String SFILES;
-    private String REFUSEREASON;
-    private String DISPATCHSTATUS;
+    private String supervisionphone;
+    private Date checkstarttime;
+    private Date checkendtime;
+    private String canceltype;
+    private String cancelreason;
+    private String dispatchid;
+    private String sfiles;
+    private String refusereason;
+    private String dispatchstatus;
+
+
 }