DeletionController.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package com.simuwang.manage.api.deletion;
  2. import com.simuwang.base.common.support.MybatisPage;
  3. import com.simuwang.base.common.util.EncodeUtil;
  4. import com.simuwang.base.common.util.ExcelUtil;
  5. import com.simuwang.base.pojo.dto.ExcelDeletionInfoDTO;
  6. import com.simuwang.base.pojo.dto.query.DeletionPageQuery;
  7. import com.simuwang.base.pojo.dto.query.FundDeletionPageQuery;
  8. import com.simuwang.base.pojo.vo.*;
  9. import com.simuwang.manage.service.DeletionService;
  10. import com.smppw.common.pojo.ResultVo;
  11. import jakarta.servlet.ServletOutputStream;
  12. import jakarta.servlet.http.HttpServletRequest;
  13. import jakarta.servlet.http.HttpServletResponse;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import java.io.FileInputStream;
  21. import java.io.IOException;
  22. import java.util.ArrayList;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Map;
  26. /**
  27. * 缺失管理
  28. * Author: chenjianhua
  29. * Date: 2024/9/17 18:16
  30. * Description: ${DESCRIPTION}
  31. */
  32. @RestController
  33. @RequestMapping("/v1/deletion")
  34. public class DeletionController {
  35. @Autowired
  36. private DeletionService deletionService;
  37. private static final Logger logger = LoggerFactory.getLogger(DeletionController.class);
  38. /**
  39. * 查询缺失页面展示数据
  40. * @param deletionPageQuery
  41. * @return
  42. */
  43. @RequestMapping("search-deletion-list")
  44. public MybatisPage<DeletionInfoVO> searchDeletionList(DeletionPageQuery deletionPageQuery){
  45. MybatisPage<DeletionInfoVO> result = deletionService.searchDeletionList(deletionPageQuery);
  46. return result;
  47. }
  48. /**
  49. * 查询基金缺失明细
  50. * @param fundDeletionPageQuery
  51. * @return
  52. */
  53. @RequestMapping("search-fund-deletion")
  54. public MybatisPage<FundDeletionInfoVO> searchFundDeletionList(FundDeletionPageQuery fundDeletionPageQuery){
  55. MybatisPage<FundDeletionInfoVO> result = deletionService.searchFundDeletionList(fundDeletionPageQuery);
  56. return result;
  57. }
  58. /**
  59. * 保存缺失备注
  60. * @param fundDeletionInfoVOList
  61. * @return
  62. */
  63. @RequestMapping("save-fund-deletion")
  64. public ResultVo saveFundDeletionList(@RequestBody List<FundDeletionInfoVO> fundDeletionInfoVOList){
  65. deletionService.saveFundDeletionList(fundDeletionInfoVOList);
  66. return new ResultVo<>(true);
  67. }
  68. /**
  69. * 批量添加缺失备注
  70. * @param fundDeletionRemarkVO
  71. * @return
  72. */
  73. @RequestMapping("batch-deletion-remark")
  74. public ResultVo saveBatchDeletionRemark(@RequestBody FundDeletionRemarkVO fundDeletionRemarkVO){
  75. deletionService.saveBatchDeletionRemark(fundDeletionRemarkVO);
  76. return new ResultVo<>(true);
  77. }
  78. /**
  79. * 下载数据缺失
  80. * @param fundDeletionListVO
  81. * @return
  82. */
  83. @PostMapping("/download-fund-deletion")
  84. public void downloadFundDeletion(@RequestBody FundDeletionListVO fundDeletionListVO, HttpServletResponse response){
  85. List<ExcelDeletionInfoDTO> fundDeletionInfoVOList = deletionService.selectFundDeletionInfoVOList(fundDeletionListVO);
  86. Map<String,List<List<String>>> values = new HashMap<>();
  87. List<String> head = new ArrayList<>();
  88. head.add("基金ID");
  89. head.add("基金全称");
  90. head.add("管理人");
  91. head.add("缺失类型");
  92. head.add("缺失日期");
  93. head.add("缺失备注");
  94. String sheetName = "缺失明细";
  95. List<List<String>> dataList = new ArrayList<>();
  96. for(ExcelDeletionInfoDTO dto : fundDeletionInfoVOList){
  97. List<String> data = new ArrayList<>();
  98. data.add(dto.getFundId());
  99. data.add(dto.getFundName());
  100. data.add(dto.getCompanyName());
  101. data.add(dto.getDeletionType());
  102. data.add(dto.getDeletionDate());
  103. data.add(dto.getRemark());
  104. dataList.add(data);
  105. }
  106. values.put(sheetName,dataList);
  107. HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName,head,values,null);
  108. try {
  109. response.setContentType("application/x-xls");
  110. response.setCharacterEncoding("gbk");
  111. response.addHeader("Content-Disposition", "attachment;filename=" + EncodeUtil.encodeUTF8("缺失明细.xls"));
  112. ServletOutputStream outputStream = response.getOutputStream();
  113. wb.write(outputStream);
  114. outputStream.flush();
  115. outputStream.close();
  116. } catch (Exception e) {
  117. logger.error(e.getMessage(),e);
  118. }
  119. }
  120. }