From 6468cb0a88ee288d260f3be2f56e847e450e3666 Mon Sep 17 00:00:00 2001 From: dhy1725534722 <1725534722@qq.com> Date: Mon, 6 May 2024 08:41:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=92=8C=E6=B4=BE=E5=8F=91?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=85=AC=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BmsDeclarationRecordsController.java | 61 ++++++++- .../mapper/BmsDeclarationRecordsMapper.java | 2 + .../IBmsDeclarationRecordsService.java | 11 +- .../BmsDeclarationRecordsServiceImpl.java | 121 ++++++++++++++++-- .../impl/BmsTemplateRecordServiceImpl.java | 45 ++++--- .../BmsDeclarationRecordsMapper.xml | 40 ++++++ 6 files changed, 247 insertions(+), 33 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/controller/BmsDeclarationRecordsController.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/controller/BmsDeclarationRecordsController.java index c7fd479..0efe894 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/controller/BmsDeclarationRecordsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/controller/BmsDeclarationRecordsController.java @@ -1,5 +1,8 @@ package com.ruoyi.jjh.declaration.controller; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.ZipUtil; +import cn.hutool.http.HttpUtil; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -14,14 +17,25 @@ import com.ruoyi.jjh.declaration.entity.dto.BmsDeclarationRecordsDto; import com.ruoyi.jjh.declaration.entity.vo.ApprovalDeclarationRecordsQueryVo; import com.ruoyi.jjh.declaration.entity.vo.BmsDeclarationRecordsQueryVo; import com.ruoyi.jjh.declaration.entity.vo.BmsMunicipalBureauReviewQueryVo; +import com.ruoyi.jjh.declaration.mapper.BmsDeclarationRecordsMapper; import com.ruoyi.jjh.declaration.service.IBmsDeclarationRecordsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.List; /** @@ -34,10 +48,14 @@ import java.util.List; @RequestMapping("/system/declarationRecords") @Api(tags = "在线申报记录") public class BmsDeclarationRecordsController extends BaseController { - @Autowired + @Resource private IBmsDeclarationRecordsService bmsDeclarationRecordsService; + @Value("${ruoyi.profile}") + private String fileAddress; + @Resource + private BmsDeclarationRecordsMapper bmsDeclarationRecordsMapper; /** * 审核列表 * @@ -76,8 +94,43 @@ public class BmsDeclarationRecordsController extends BaseController { // @RequiresPermissions("system:declarationRecords:list") @GetMapping("/fileList") @ApiOperation("根据列表id集合压缩所有文件") - public AjaxResult fileList(@RequestParam(name = "list") List list) { - return AjaxResult.success(bmsDeclarationRecordsService.fileList(list)); + public ResponseEntity fileList(@RequestParam(name = "list") List list) throws FileNotFoundException, UnsupportedEncodingException { + List rd = bmsDeclarationRecordsMapper.selectDeclarationRecordsToIdList(list); + // 创建父文件目录 + String fatherFile = fileAddress + "/" + "项目压缩文件"; + FileUtil.mkdir(fatherFile); + for (BmsDeclarationRecordsQueryVo item : rd) { + String itemsFileName = fatherFile + "/" +item.getProjectName()+item.getEnterpriseName(); + FileUtil.mkdir(itemsFileName); + String[] splitList = bmsDeclarationRecordsService.getAllFile(item.getTemplateId(), item.getDetailId()).split(","); + for (String s : splitList) { + // 下载文件 + try { + HttpUtil.downloadFile(s, itemsFileName); + } catch (Exception e) { + throw new RuntimeException(itemsFileName+"某文件下载失败"); + } + } + } + // 压缩后的文件路径 + String zipFilePath = fatherFile + ".zip"; + // 使用Hutool压缩文件夹 + ZipUtil.zip(fatherFile, zipFilePath); + // 从本地读取压缩文件 + File zipFile = FileUtil.file(zipFilePath); +// FileSystemResource resource = new FileSystemResource(zipFile); + // 读取本地压缩文件并转为字节数组 + byte[] bytes = FileUtil.readBytes(zipFile); + // 设置响应头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); + headers.setContentDispositionFormData("attachment", URLEncoder.encode("项目压缩文件.zip","UTF-8")); + // 删除压缩之前的文件夹 + FileUtil.del(zipFilePath); + // 删除压缩包 + FileUtil.del(fatherFile); + // 创建响应实体 + return new ResponseEntity<>(bytes, headers, HttpStatus.OK); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/mapper/BmsDeclarationRecordsMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/mapper/BmsDeclarationRecordsMapper.java index bec43b5..cd11464 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/mapper/BmsDeclarationRecordsMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/mapper/BmsDeclarationRecordsMapper.java @@ -82,4 +82,6 @@ public interface BmsDeclarationRecordsMapper extends BaseMapper selectDeclarationRecordsToIdList(@Param("list") List list); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/IBmsDeclarationRecordsService.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/IBmsDeclarationRecordsService.java index e14eade..4463392 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/IBmsDeclarationRecordsService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/IBmsDeclarationRecordsService.java @@ -2,11 +2,7 @@ package com.ruoyi.jjh.declaration.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.jjh.declaration.entity.BmsDeclarationRecords; -import com.ruoyi.jjh.declaration.entity.dto.ApprovalDeclarationRecordsQueryDto; -import com.ruoyi.jjh.declaration.entity.dto.BmsApprovalInfoUpdateDto; -import com.ruoyi.jjh.declaration.entity.dto.BmsDeclarationRecordsAddDto; -import com.ruoyi.jjh.declaration.entity.dto.BmsDeclarationRecordsDto; -import com.ruoyi.jjh.declaration.entity.dto.MunicipalReviewDto; +import com.ruoyi.jjh.declaration.entity.dto.*; import com.ruoyi.jjh.declaration.entity.vo.ApprovalDeclarationRecordsQueryVo; import com.ruoyi.jjh.declaration.entity.vo.BmsDeclarationRecordsQueryVo; import com.ruoyi.jjh.declaration.entity.vo.BmsMunicipalBureauReviewQueryVo; @@ -105,5 +101,8 @@ public interface IBmsDeclarationRecordsService extends IService list); + /** + * 根据id集合压缩所有文件使用类 + */ + String getAllFile(Long args,Long id); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsDeclarationRecordsServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsDeclarationRecordsServiceImpl.java index 9ef0148..c492074 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsDeclarationRecordsServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsDeclarationRecordsServiceImpl.java @@ -2,8 +2,6 @@ package com.ruoyi.jjh.declaration.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.context.SecurityContextHolder; @@ -19,8 +17,8 @@ import com.ruoyi.jjh.declaration.mapper.BmsDeclarationRecordsMapper; import com.ruoyi.jjh.declaration.service.*; import com.ruoyi.jjh.ent.entity.JProject; import com.ruoyi.jjh.ent.service.JProjectService; -import org.apache.ibatis.annotations.Param; 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; @@ -60,9 +58,67 @@ public class BmsDeclarationRecordsServiceImpl extends ServiceImpl list) { - List rd = baseMapper.selectBatchIds(list); - System.out.println(rd); - return null; + + /** + * 根据id集合压缩所有文件使用类 + */ + public String getAllFile(Long args,Long id) { + if (args == 1) { + BmsProjectSettlementAward lh = bmsProjectSettlementAwardService.getById(id); + return lh.getAgreement() + "," + + lh.getReport() + "," + + lh.getBusinessLicense() + "," + + lh.getOtherMaterials(); + } else if (args == 2) { + BmsBigStrongAward zdzq = bmsBigStrongAwardService.getById(id); + return zdzq.getDevelopmentPlan(); + }else if (args == 3) { + BmsCarrierConstructionAward ztjs = bmsCarrierConstructionAwardService.getById(id); + return ztjs.getSupportingMaterials() + "," + + ztjs.getBusinessLicense() + "," + + ztjs.getFireReport(); + }else if (args == 4) { + BmsPlatformConstructionAward ptjs = bmsPlatformConstructionAwardService.getById(id); + return ptjs.getAgreement(); + }else if (args == 5) { + BmsBrandingAward ppdz = bmsBrandingAwardService.getById(id); + return ppdz.getEvidence(); + }else if (args == 6) { + BmsSceneOpeningAward cjkf = bmsSceneOpeningAwardService.getById(id); + return cjkf.getMaterial(); + }else if (args == 7) { + BmsCreditManagement xygl = bmsCreditManagementService.getById(id); + return xygl.getProjectPlan() + "," + xygl.getUsesFunds() + "," + xygl.getAuditReport() ; + }else if (args == 8) { + BmsIndustrialInternetAward g5 = bmsIndustrialInternetAwardService.getById(id); + return g5.getMaterial(); + }else if (args == 9) { + BmsManufacturingServicesAward zzfw = bmsManufacturingServicesAwardService.getById(id); + return zzfw.getFilingNotice() + "," + zzfw.getInvoice() + "," + zzfw.getAuditReport() + ","+ zzfw.getFinancialStatements() ; + }else if (args == 10) { + BmsLogisticsDevelopmentAward wl = bmsLogisticsDevelopmentAwardService.getById(id); + return wl.getFilingNotice() + "," + wl.getHonorCertificate() + "," + wl.getAuditReport() + ","+ wl.getPlatformName(); + }else if (args == 11) { + BmsIntegrationIndustries ly = bmsIntegrationIndustriesService.getById(id); + return ly.getEvidence() + ","+ + ly.getBusinessLicense() + "," + + ly.getTaxPaymentCertificate() + "," + + ly.getAuditReport() + "," + + ly.getEquityStructureChart() + "," + + ly.getDeclarationReport() + "," + + ly.getIndependentAccounting() + "," + + ly.getCapitalVerificationReport() + "," + + ly.getOtherEvidence(); + }else { + return null; + } } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsTemplateRecordServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsTemplateRecordServiceImpl.java index 082b525..b1235b9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsTemplateRecordServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/jjh/declaration/service/impl/BmsTemplateRecordServiceImpl.java @@ -21,25 +21,29 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; /** * 在线模板Service业务层处理 - * + * * @author farben * @date 2023-09-07 */ @Service -public class BmsTemplateRecordServiceImpl extends ServiceImpl implements IBmsTemplateRecordService { +public class BmsTemplateRecordServiceImpl extends ServiceImpl implements IBmsTemplateRecordService { @Autowired private IBmsEnterpriseDirectoryService enterpriseDirectoryService; @Autowired private IBmsEnterpriseBasicInfoService iBmsEnterpriseBasicInfoService; + /** * 查询在线模板 - * + * * @param id 在线模板主键 * @return 在线模板 */ @@ -54,7 +58,7 @@ public class BmsTemplateRecordServiceImpl extends ServiceImpl selectBmsTemplateNameList(BmsTemplateQueryDto bmsTemplateQueryDto) { Long enterpriseId = bmsTemplateQueryDto.getEnterpriseId(); BmsEnterpriseBasicInfo bmsEnterpriseBasicInfo = iBmsEnterpriseBasicInfoService.selectBmsEnterpriseBasicInfoById(enterpriseId); - if (BeanUtil.isNotEmpty(bmsEnterpriseBasicInfo)){ + if (BeanUtil.isNotEmpty(bmsEnterpriseBasicInfo)) { bmsTemplateQueryDto.setCreditCode(bmsEnterpriseBasicInfo.getCreditCode()); return baseMapper.selectBmsTemplateNameList(bmsTemplateQueryDto); } @@ -81,7 +85,7 @@ public class BmsTemplateRecordServiceImpl extends ServiceImpl enterpriseDirectoryList = bmsTemplateRecordAddDto .getEnterpriseDirectoryList(); - if (null != enterpriseDirectoryList && enterpriseDirectoryList.size()>0){ - enterpriseDirectoryList.forEach(x->{ + if (null != enterpriseDirectoryList && enterpriseDirectoryList.size() > 0) { + enterpriseDirectoryList.forEach(x -> { x.setTemplateRecordId(bmsTemplateRecordAddDto.getId()); }); enterpriseDirectoryService.saveOrUpdateBatch(enterpriseDirectoryList); + } else { + List list = iBmsEnterpriseBasicInfoService.list(); + Collection copyList = new ArrayList<>(); + for (BmsEnterpriseBasicInfo items : list) { + BmsEnterpriseDirectory bms = new BmsEnterpriseDirectory(); + bms.setTemplateRecordId(bmsTemplateRecordAddDto.getId()); + bms.setEnterpriseName(items.getEnterpriseName()); + bms.setCreditCode(items.getCreditCode()); + copyList.add(bms); + } + enterpriseDirectoryService.saveBatch(copyList); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } return num; @@ -108,7 +123,7 @@ public class BmsTemplateRecordServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("template_record_id",bmsTemplateRecordUpdateDto.getId()); + queryWrapper.eq("template_record_id", bmsTemplateRecordUpdateDto.getId()); enterpriseDirectoryService.remove(queryWrapper); // 新增企业相关列表 List enterpriseDirectoryList = bmsTemplateRecordUpdateDto .getEnterpriseDirectoryList(); - if (null != enterpriseDirectoryList && enterpriseDirectoryList.size()>0){ - enterpriseDirectoryList.forEach(x->{ + if (null != enterpriseDirectoryList && enterpriseDirectoryList.size() > 0) { + enterpriseDirectoryList.forEach(x -> { x.setTemplateRecordId(bmsTemplateRecordUpdateDto.getId()); }); enterpriseDirectoryService.saveOrUpdateBatch(enterpriseDirectoryList); @@ -135,7 +150,7 @@ public class BmsTemplateRecordServiceImpl extends ServiceImpl +