DeletionController.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. @SystemLog(value = "缺失管理")
  35. @RestController
  36. @RequestMapping("/v1/deletion")
  37. public class DeletionController {
  38. @Autowired
  39. private DeletionService deletionService;
  40. private static final Logger logger = LoggerFactory.getLogger(DeletionController.class);
  41. /**
  42. * 查询缺失页面展示数据
  43. * @param deletionPageQuery
  44. * @return
  45. */
  46. @SystemLog(value = "缺失管理查询")
  47. @RequestMapping("search-deletion-list")
  48. public MybatisPage<DeletionInfoVO> searchDeletionList(DeletionPageQuery deletionPageQuery){
  49. MybatisPage<DeletionInfoVO> result = deletionService.searchDeletionList(deletionPageQuery);
  50. return result;
  51. }
  52. /**
  53. * 查询基金缺失明细
  54. * @param fundDeletionPageQuery
  55. * @return
  56. */
  57. @SystemLog(value = "查询基金缺失明细")
  58. @RequestMapping("search-fund-deletion")
  59. public MybatisPage<FundDeletionInfoVO> searchFundDeletionList(FundDeletionPageQuery fundDeletionPageQuery){
  60. MybatisPage<FundDeletionInfoVO> result = deletionService.searchFundDeletionList(fundDeletionPageQuery);
  61. return result;
  62. }
  63. /**
  64. * 保存缺失备注
  65. * @param fundDeletionInfoVOList
  66. * @return
  67. */
  68. @SystemLog(value = "保存缺失备注")
  69. @RequestMapping("save-fund-deletion")
  70. public ResultVo saveFundDeletionList(@RequestBody List<FundDeletionInfoVO> fundDeletionInfoVOList){
  71. deletionService.saveFundDeletionList(fundDeletionInfoVOList);
  72. return new ResultVo<>(true);
  73. }
  74. /**
  75. * 批量添加缺失备注
  76. * @param fundDeletionRemarkVO
  77. * @return
  78. */
  79. @SystemLog(value = "批量修改缺失备注")
  80. @RequestMapping("batch-deletion-remark")
  81. public ResultVo saveBatchDeletionRemark(@RequestBody FundDeletionRemarkVO fundDeletionRemarkVO){
  82. deletionService.saveBatchDeletionRemark(fundDeletionRemarkVO);
  83. return new ResultVo<>(true);
  84. }
  85. /**
  86. * 下载数据缺失
  87. * @param fundDeletionListVO
  88. * @return
  89. */
  90. @SystemLog(value = "下载缺失数据")
  91. @ExcludeGlobalResult
  92. @PostMapping("/download-fund-deletion")
  93. public void downloadFundDeletion(@RequestBody FundDeletionListVO fundDeletionListVO, HttpServletResponse response){
  94. List<ExcelDeletionInfoDTO> fundDeletionInfoVOList = deletionService.selectFundDeletionInfoVOList(fundDeletionListVO);
  95. Map<String,List<List<String>>> values = new HashMap<>();
  96. List<String> head = new ArrayList<>();
  97. head.add("基金ID");
  98. head.add("基金全称");
  99. head.add("管理人");
  100. head.add("缺失类型");
  101. head.add("缺失日期");
  102. head.add("缺失备注");
  103. String sheetName = "缺失明细";
  104. List<List<String>> dataList = new ArrayList<>();
  105. for(ExcelDeletionInfoDTO dto : fundDeletionInfoVOList){
  106. List<String> data = new ArrayList<>();
  107. data.add(dto.getFundId());
  108. data.add(dto.getFundName());
  109. data.add(dto.getCompanyName());
  110. data.add(dto.getDeletionType());
  111. data.add(dto.getDeletionDate());
  112. data.add(dto.getRemark());
  113. dataList.add(data);
  114. }
  115. values.put(sheetName,dataList);
  116. HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName,head,values,null);
  117. try {
  118. response.setContentType("application/x-xls");
  119. response.setCharacterEncoding("utf-8");
  120. response.addHeader("Content-Disposition", "attachment;filename=" + EncodeUtil.encodeUTF8("缺失明细.xls"));
  121. ServletOutputStream outputStream = response.getOutputStream();
  122. wb.write(outputStream);
  123. outputStream.flush();
  124. outputStream.close();
  125. } catch (Exception e) {
  126. logger.error(e.getMessage(),e);
  127. } finally {
  128. try {
  129. wb.close();
  130. } catch (IOException e) {
  131. e.printStackTrace();
  132. }
  133. }
  134. }
  135. }