Ver Fonte

feat:产品要素导出

chenjianhua há 2 semanas atrás
pai
commit
0d528418b0

+ 330 - 0
service-base/src/main/java/com/simuwang/base/common/util/ExcelUtil.java

@@ -10,6 +10,7 @@ import com.github.junrar.exception.RarException;
 import com.github.junrar.rarfile.FileHeader;
 import com.simuwang.base.common.conts.DateConst;
 import com.simuwang.base.common.conts.EmailDataDirectionConst;
+import com.simuwang.base.pojo.vo.*;
 import org.apache.commons.io.FileUtils;
 import org.apache.pdfbox.Loader;
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -536,4 +537,333 @@ public class ExcelUtil {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         return localDate.format(formatter);
     }
+
+    public static HSSFWorkbook getProductHSSFWorkbook(List<ProductDataVO> productDataVOList) {
+
+        // 第一步,创建一个HSSFWorkbook,对应一个Excel文件
+        HSSFWorkbook  wb = new HSSFWorkbook();
+        try {
+            createProductInfoSheet(wb,productDataVOList);
+            createProductContractSheet(wb,productDataVOList);
+            createProductDetailSheet(wb,productDataVOList);
+            createInvestmentManagerSheet(wb,productDataVOList);
+        }catch (Exception e) {
+            logger.error(e.getMessage(),e);
+        }
+        return wb;
+    }
+
+    private static void createInvestmentManagerSheet(HSSFWorkbook wb, List<ProductDataVO> productDataVOList) {
+        try{
+            HSSFSheet sheet = wb.createSheet("投资经理信息");
+            List<String> title = new ArrayList<>();
+            title.add("编号");
+            title.add("中基协基金编号");
+            title.add("投资经理任职起始时间");
+            title.add("投资经理任职结束时间");
+            title.add("投资经理");
+            // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
+            HSSFRow row = sheet.createRow(0);
+            // 第四步,创建单元格,并设置值表头 设置表头居中
+            HSSFCellStyle style = wb.createCellStyle();
+            style.setAlignment(HorizontalAlignment.LEFT);
+            style.setWrapText(true);
+            sheet.setColumnWidth(0, 1000);
+            sheet.setColumnWidth(1, 5000);
+            sheet.setColumnWidth(2, 5000);
+            sheet.setColumnWidth(3, 8000);
+            sheet.setColumnWidth(4, 10000);
+            //声明列对象
+            HSSFCell cell = null;
+            //创建标题
+            for (int i = 0; i < title.size(); i++) {
+                cell = row.createCell(i);
+                cell.setCellValue(title.get(i));
+                cell.setCellStyle(style);
+            }
+            int count = 65500;
+            List<List<String>> values = new ArrayList<>();
+            for (ProductDataVO productDataVO : productDataVOList) {
+                List<InvestmentManagerVO> investmentManagerVOList = productDataVO.getInvestmentManagerVOList();
+                for (InvestmentManagerVO investmentManagerVO : investmentManagerVOList) {
+                    List<String> valueList = new ArrayList<>();
+                    valueList.add(String.valueOf(investmentManagerVO.getId()));
+                    valueList.add(investmentManagerVO.getRegisterNumber());
+                    valueList.add(investmentManagerVO.getStartDate());
+                    valueList.add(investmentManagerVO.getEndDate());
+                    valueList.add(investmentManagerVO.getManagerName());
+                    values.add(valueList);
+                }
+            }
+            //创建内容
+            for (int i = 0; i < values.size(); i++) {
+                row = sheet.createRow(i + 1);
+                for (int j = 0; j < values.get(i).size(); j++) {
+                    //将内容按顺序赋给对应的列对象
+                    row.createCell(j).setCellValue(values.get(i).get(j));
+                }
+                if(i > count){
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+    private static void createProductContractSheet(HSSFWorkbook wb, List<ProductDataVO> productDataVOList) {
+        try{
+            HSSFSheet sheet = wb.createSheet("产品合同信息");
+            List<String> title = new ArrayList<>();
+            title.add("编号");
+            title.add("中基协基金编号");
+            title.add("基金产品全名");
+            title.add("基金合同");
+            title.add("投资范围");
+            title.add("投资限制");
+            title.add("投资策略");
+            title.add("投资方式");
+            title.add("业绩比较基准");
+            title.add("业绩报酬计提方式");
+            title.add("备注");
+            // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
+            HSSFRow row = sheet.createRow(0);
+            // 第四步,创建单元格,并设置值表头 设置表头居中
+            HSSFCellStyle style = wb.createCellStyle();
+            style.setAlignment(HorizontalAlignment.LEFT);
+            style.setWrapText(true);
+            sheet.setColumnWidth(0, 1000);
+            sheet.setColumnWidth(1, 5000);
+            sheet.setColumnWidth(2, 10000);
+            sheet.setColumnWidth(3, 8000);
+            sheet.setColumnWidth(4, 8000);
+            sheet.setColumnWidth(5, 5000);
+            sheet.setColumnWidth(6, 5000);
+            sheet.setColumnWidth(7, 5000);
+            sheet.setColumnWidth(8, 5000);
+            sheet.setColumnWidth(9, 5000);
+            sheet.setColumnWidth(10, 5000);
+            //声明列对象
+            HSSFCell cell = null;
+            //创建标题
+            for (int i = 0; i < title.size(); i++) {
+                cell = row.createCell(i);
+                cell.setCellValue(title.get(i));
+                cell.setCellStyle(style);
+            }
+            int count = 65500;
+            List<List<String>> values = new ArrayList<>();
+            for (ProductDataVO productDataVO : productDataVOList) {
+                ProductContractVO productContractVO = productDataVO.getProductContractVO();
+                List<String> valueList = new ArrayList<>();
+                valueList.add(String.valueOf(productContractVO.getId()));
+                valueList.add(productContractVO.getRegisterNumber());
+                valueList.add(productContractVO.getProductName());
+                valueList.add(productContractVO.getProductContract());
+                valueList.add(productContractVO.getInvestmentScope());
+                valueList.add(productContractVO.getInvestmentLimit());
+                valueList.add(productContractVO.getInvestmentStrategy());
+                valueList.add(productContractVO.getInvestmentMethod());
+                valueList.add(productContractVO.getPerformanceBasic());
+                valueList.add(productContractVO.getAccruedMethod());
+                valueList.add(productContractVO.getRemark());
+                values.add(valueList);
+            }
+            //创建内容
+            for (int i = 0; i < values.size(); i++) {
+                row = sheet.createRow(i + 1);
+                for (int j = 0; j < values.get(i).size(); j++) {
+                    //将内容按顺序赋给对应的列对象
+                    row.createCell(j).setCellValue(values.get(i).get(j));
+                }
+                if(i > count){
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+    private static void createProductDetailSheet(HSSFWorkbook wb, List<ProductDataVO> productDataVOList) {
+        try{
+            HSSFSheet sheet = wb.createSheet("产品其他信息");
+            List<String> title = new ArrayList<>();
+            title.add("编号");
+            title.add("中基协基金编号");
+            title.add("基金产品全名");
+            title.add("成立分红拆分清算公告");
+            title.add("复权净值");
+            title.add("产品份额");
+            title.add("产品总资产");
+            title.add("估值表");
+            title.add("投资经理投资年限起始日(即最早对外募集资金并投资之日)");
+            title.add("投资经理从业经历");
+            title.add("投资经理在管数量");
+            title.add("公司总管理规模");
+            title.add("申购/赎回费率");
+            title.add("管理人费率");
+            title.add("托管费率");
+            title.add("外包费率");
+            // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
+            HSSFRow row = sheet.createRow(0);
+            // 第四步,创建单元格,并设置值表头 设置表头居中
+            HSSFCellStyle style = wb.createCellStyle();
+            style.setAlignment(HorizontalAlignment.LEFT);
+            style.setWrapText(true);
+            sheet.setColumnWidth(0, 1000);
+            sheet.setColumnWidth(1, 5000);
+            sheet.setColumnWidth(2, 10000);
+            sheet.setColumnWidth(3, 8000);
+            sheet.setColumnWidth(4, 8000);
+            sheet.setColumnWidth(5, 5000);
+            sheet.setColumnWidth(6, 5000);
+            sheet.setColumnWidth(7, 5000);
+            sheet.setColumnWidth(8, 15000);
+            sheet.setColumnWidth(9, 5000);
+            sheet.setColumnWidth(10, 5000);
+            sheet.setColumnWidth(11, 5000);
+            sheet.setColumnWidth(12, 5000);
+            sheet.setColumnWidth(13, 5000);
+            sheet.setColumnWidth(14, 5000);
+            sheet.setColumnWidth(15, 5000);
+            //声明列对象
+            HSSFCell cell = null;
+            //创建标题
+            for (int i = 0; i < title.size(); i++) {
+                cell = row.createCell(i);
+                cell.setCellValue(title.get(i));
+                cell.setCellStyle(style);
+            }
+            int count = 65500;
+            List<List<String>> values = new ArrayList<>();
+            for (ProductDataVO productDataVO : productDataVOList) {
+                ProductDerivativeVO productDerivativeVO = productDataVO.getProductDerivativeVO();
+                List<String> valueList = new ArrayList<>();
+                valueList.add(String.valueOf(productDerivativeVO.getId()));
+                valueList.add(productDerivativeVO.getRegisterNumber());
+                valueList.add(productDerivativeVO.getProductName());
+                valueList.add(productDerivativeVO.getDistributeReport());
+                valueList.add(productDerivativeVO.getCumulativeNav());
+                valueList.add(productDerivativeVO.getProductShare());
+                valueList.add(productDerivativeVO.getProductAsset());
+                valueList.add(productDerivativeVO.getProductValuation());
+                valueList.add(productDerivativeVO.getStartDate());
+                valueList.add(productDerivativeVO.getInvestmentManagerDesc());
+                valueList.add(productDerivativeVO.getProductCount());
+                valueList.add(productDerivativeVO.getManageAsset());
+                valueList.add(productDerivativeVO.getFeeNote());
+                valueList.add(productDerivativeVO.getManagementfeeTrust());
+                valueList.add(productDerivativeVO.getManagementfeeBank());
+                valueList.add(productDerivativeVO.getOutsourceFee());
+                values.add(valueList);
+            }
+            //创建内容
+            for (int i = 0; i < values.size(); i++) {
+                row = sheet.createRow(i + 1);
+                for (int j = 0; j < values.get(i).size(); j++) {
+                    //将内容按顺序赋给对应的列对象
+                    row.createCell(j).setCellValue(values.get(i).get(j));
+                }
+                if(i > count){
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+
+    private static void createProductInfoSheet(HSSFWorkbook wb, List<ProductDataVO> productDataVOList) {
+       try{
+            HSSFSheet sheet = wb.createSheet("产品基本信息");
+            List<String> title = new ArrayList<>();
+            title.add("编号");
+            title.add("中基协基金编号");
+            title.add("基金产品全名");
+            title.add("成立日期");
+            title.add("清盘日期");
+            title.add("母子基金标签");
+            title.add("是否结构化产品");
+            title.add("基金一级分类");
+            title.add("基金二级分类");
+            title.add("基金三级分类");
+            title.add("投资策略变更情况说明");
+            title.add("现任投资经理");
+            title.add("任职起始日期");
+            title.add("净值数据提供频率");
+            title.add("基金资产净值提供频率");
+            title.add("定期报告");
+            title.add("备注");
+            // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
+            HSSFRow row = sheet.createRow(0);
+            // 第四步,创建单元格,并设置值表头 设置表头居中
+            HSSFCellStyle style = wb.createCellStyle();
+            style.setAlignment(HorizontalAlignment.LEFT);
+            style.setWrapText(true);
+            sheet.setColumnWidth(0, 1000);
+            sheet.setColumnWidth(1, 5000);
+            sheet.setColumnWidth(2, 10000);
+            sheet.setColumnWidth(3, 8000);
+            sheet.setColumnWidth(4, 8000);
+            sheet.setColumnWidth(5, 5000);
+            sheet.setColumnWidth(6, 5000);
+            sheet.setColumnWidth(7, 5000);
+            sheet.setColumnWidth(8, 5000);
+            sheet.setColumnWidth(9, 5000);
+            sheet.setColumnWidth(10, 15000);
+            sheet.setColumnWidth(11, 5000);
+            sheet.setColumnWidth(12, 5000);
+            sheet.setColumnWidth(13, 5000);
+            sheet.setColumnWidth(14, 5000);
+            sheet.setColumnWidth(15, 5000);
+            sheet.setColumnWidth(16, 5000);
+            //声明列对象
+            HSSFCell cell = null;
+            //创建标题
+            for (int i = 0; i < title.size(); i++) {
+                cell = row.createCell(i);
+                cell.setCellValue(title.get(i));
+                cell.setCellStyle(style);
+            }
+            int count = 65500;
+            List<List<String>> values = new ArrayList<>();
+            for (ProductDataVO productDataVO : productDataVOList) {
+                ProductInformationVO productInformationVO = productDataVO.getProductInformationVO();
+                List<String> valueList = new ArrayList<>();
+                valueList.add(String.valueOf(productInformationVO.getId()));
+                valueList.add(productInformationVO.getRegisterNumber());
+                valueList.add(productInformationVO.getProductName());
+                valueList.add(productInformationVO.getInceptionDate());
+                valueList.add(productInformationVO.getLiquidateDate());
+                valueList.add(productInformationVO.getMsLabel());
+                valueList.add(productInformationVO.getIsStruct());
+                valueList.add(productInformationVO.getFirstStrategy());
+                valueList.add(productInformationVO.getSecondStrategy());
+                valueList.add(productInformationVO.getThirdStrategy());
+                valueList.add(productInformationVO.getInvestmentStrategyDesc());
+                valueList.add(productInformationVO.getInvestmentManager());
+                valueList.add(productInformationVO.getStartDate());
+                valueList.add(productInformationVO.getNavFrequency());
+                valueList.add(productInformationVO.getAssetFrequency());
+                valueList.add(productInformationVO.getReportFrequency());
+                valueList.add(productInformationVO.getRemark());
+                values.add(valueList);
+            }
+            //创建内容
+            for (int i = 0; i < values.size(); i++) {
+                row = sheet.createRow(i + 1);
+                for (int j = 0; j < values.get(i).size(); j++) {
+                    //将内容按顺序赋给对应的列对象
+                    row.createCell(j).setCellValue(values.get(i).get(j));
+                }
+                if(i > count){
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
 }

+ 4 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/ProductInformationMapper.java

@@ -15,4 +15,8 @@ public interface ProductInformationMapper extends BaseMapper<ProductInformationD
     long countProductList(ProductPageQuery productPageQuery);
 
     ProductInformationDO selectByNameAndRegisterNumber(@Param("registerNumber") String registerNumber,@Param("productName")String productName);
+
+    List<ProductInformationDO> selectAllRecord();
+
+    List<ProductInformationDO> selectByIdList(@Param("idList") List<Integer> idList);
 }

+ 12 - 1
service-base/src/main/resources/mapper/daq/ProductInformationMapper.xml

@@ -85,7 +85,7 @@
       and report_frequency like concat(#{reportFrequency},'%')
     </if>
   </select>
-  <select id="selectByNameAndRegisterNumber" resultType="com.simuwang.base.pojo.dos.ProductInformationDO">
+  <select id="selectByNameAndRegisterNumber" resultMap="BaseResultMap">
     select <include refid="Base_Column_List"></include>
     from product_information where isvalid=1
     <if test="registerNumber != '' and registerNumber != null">
@@ -103,4 +103,15 @@
     order by createtime
     limit 1
   </select>
+  <select id="selectAllRecord" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"></include>
+    from product_information where isvalid=1
+  </select>
+  <select id="selectByIdList" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"></include>
+    from product_information where isvalid=1 and id in
+    <foreach item="id" collection="idList" open="(" separator="," close=")">
+      #{id}
+    </foreach>
+  </select>
 </mapper>

+ 47 - 2
service-manage/src/main/java/com/simuwang/manage/api/product/ProductController.java

@@ -1,19 +1,32 @@
 package com.simuwang.manage.api.product;
 
+import com.simuwang.base.ano.ExcludeGlobalResult;
 import com.simuwang.base.common.support.MybatisPage;
+import com.simuwang.base.common.util.EncodeUtil;
+import com.simuwang.base.common.util.ExcelUtil;
+import com.simuwang.base.pojo.dto.ExcelDeletionInfoDTO;
 import com.simuwang.base.pojo.dto.query.ProductPageQuery;
-import com.simuwang.base.pojo.vo.IdVO;
-import com.simuwang.base.pojo.vo.ProductInformationVO;
+import com.simuwang.base.pojo.vo.*;
 import com.simuwang.logging.SystemLog;
 import com.simuwang.manage.service.ProductService;
 import com.simuwang.manage.service.impl.DistributionServiceImpl;
+import com.simuwang.manage.service.impl.ProductServiceImpl;
 import com.smppw.common.pojo.ResultVo;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @SystemLog(value = "产品要素管理")
 @RestController
 @RequestMapping("/v1/product")
@@ -21,6 +34,8 @@ public class ProductController {
     @Autowired
     public ProductService productService;
 
+
+    private static final Logger logger = LoggerFactory.getLogger(ProductController.class);
     /**
      * 查询基金要素列表
      * @param prductPageQuery
@@ -50,4 +65,34 @@ public class ProductController {
     public ResultVo productDetail( IdVO idVO) {
         return productService.productDetail(idVO);
     }
+
+    /**
+     * 下载数据缺失
+     * @param idListVO
+     * @return
+     */
+    @SystemLog(value = "导出产品要素数据", type = SystemLog.Type.DOWNLOAD_OR_EXPORT)
+    @ExcludeGlobalResult
+    @PostMapping("/export")
+    public void exportProductInfomration(@RequestBody IdListVO idListVO, HttpServletResponse response ) {
+        List<ProductDataVO> productDataVOList = productService.selectProuctInformationByIdList(idListVO.getIdList());
+        HSSFWorkbook wb = ExcelUtil.getProductHSSFWorkbook(productDataVOList);
+        try {
+            response.setContentType("application/x-xls");
+            response.setCharacterEncoding("utf-8");
+            response.addHeader("Content-Disposition", "attachment;filename=" + EncodeUtil.encodeUTF8("产品要素.xls"));
+            ServletOutputStream outputStream = response.getOutputStream();
+            wb.write(outputStream);
+            outputStream.flush();
+            outputStream.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+        } finally {
+            try {
+                wb.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 }

+ 5 - 0
service-manage/src/main/java/com/simuwang/manage/service/ProductService.java

@@ -3,14 +3,19 @@ package com.simuwang.manage.service;
 import com.simuwang.base.common.support.MybatisPage;
 import com.simuwang.base.pojo.dto.query.ProductPageQuery;
 import com.simuwang.base.pojo.vo.IdVO;
+import com.simuwang.base.pojo.vo.ProductDataVO;
 import com.simuwang.base.pojo.vo.ProductInformationVO;
 import com.smppw.common.pojo.ResultVo;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+
 public interface ProductService {
     MybatisPage<ProductInformationVO> searchProductList(ProductPageQuery prductPageQuery);
 
     ResultVo uploadProduct(MultipartFile file);
 
     ResultVo productDetail(IdVO idVO);
+
+    List<ProductDataVO> selectProuctInformationByIdList(List<Integer> idList);
 }

+ 41 - 0
service-manage/src/main/java/com/simuwang/manage/service/impl/ProductServiceImpl.java

@@ -115,6 +115,47 @@ public class ProductServiceImpl implements ProductService {
         return new ResultVo(ResultCode.SUCCESS,productDataVO);
     }
 
+    @Override
+    public List<ProductDataVO> selectProuctInformationByIdList(List<Integer> idList) {
+        List<ProductDataVO> result = new ArrayList<>();
+        List<ProductInformationDO> productInformationDOList = new ArrayList<>();
+        if(idList.isEmpty()){
+            productInformationDOList = productInformationMapper.selectAllRecord();
+        }else{
+            productInformationDOList = productInformationMapper.selectByIdList(idList);
+        }
+        for (ProductInformationDO productInformationDO : productInformationDOList) {
+            ProductDataVO productDataVO = new ProductDataVO();
+            ProductInformationVO productInformationVO = new ProductInformationVO();
+            BeanUtils.copyProperties(productInformationDO,productInformationVO);
+            productDataVO.setProductInformationVO(productInformationVO);
+            ProductContractDO productContractDO = productContractMapper.selectByProductId(productInformationDO.getId());
+            if(productContractDO!=null){
+                ProductContractVO productContractVO = new ProductContractVO();
+                BeanUtils.copyProperties(productContractDO,productContractVO);
+                productDataVO.setProductContractVO(productContractVO);
+            }
+            ProductDerivativeDO productDerivativeDO = productDerivativeMapper.selectByProductId(productInformationDO.getId());
+            if(productDerivativeDO != null){
+                ProductDerivativeVO productDerivativeVO = new ProductDerivativeVO();
+                BeanUtils.copyProperties(productDerivativeDO,productDerivativeVO);
+                productDataVO.setProductDerivativeVO(productDerivativeVO);
+            }
+            List<InvestmentManagerDO> investmentManagerDOList = investmentManagerMapper.selectByRegisterNumber(productInformationDO.getRegisterNumber());
+            if(!investmentManagerDOList.isEmpty()){
+                List<InvestmentManagerVO> investmentManagerVOS = new ArrayList<>();
+                for (InvestmentManagerDO investmentManagerDO : investmentManagerDOList) {
+                    InvestmentManagerVO investmentManagerVO = new InvestmentManagerVO();
+                    BeanUtils.copyProperties(investmentManagerDO,investmentManagerVO);
+                    investmentManagerVOS.add(investmentManagerVO);
+                }
+                productDataVO.setInvestmentManagerVOList(investmentManagerVOS);
+            }
+            result.add(productDataVO);
+        }
+        return result;
+    }
+
     private ProductUploadResult parseResult(ProductData productData) {
         ProductUploadResult result = new ProductUploadResult();
         int productStartRow = 8;