DeletionController.java 5.1 KB

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