CustomActivityApplyController.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package com.crm.manager.controller;
  2. import com.crm.manager.dto.export.CustomActivityApplyExportDto;
  3. import com.crm.manager.service.activity.CustomActivityApplyFeignService;
  4. import com.crm.rely.backend.core.dto.base.BaseResultDto;
  5. import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
  6. import com.crm.rely.backend.core.dto.custom.activity.CustomActivityApplySearchDto;
  7. import com.crm.rely.backend.core.entity.base.SingleLongEntity;
  8. import com.crm.rely.backend.core.entity.custom.activity.CustomActivityApplyApproveEntity;
  9. import com.crm.rely.backend.core.entity.custom.activity.CustomActivityApplyDeleteEntity;
  10. import com.crm.rely.backend.core.entity.custom.activity.CustomActivityApplySearchEntity;
  11. import com.crm.rely.backend.core.entity.custom.activity.CustomActivityApplyUpdateEntity;
  12. import com.crm.rely.backend.core.pojo.view.CustomActivityApplyExportView;
  13. import com.crm.rely.backend.util.ExportUtil;
  14. import com.crm.rely.backend.util.StringUtil;
  15. import com.google.common.base.Strings;
  16. import com.google.common.collect.Lists;
  17. import org.springframework.beans.BeanUtils;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.validation.annotation.Validated;
  20. import org.springframework.web.bind.annotation.*;
  21. import javax.servlet.http.HttpServletRequest;
  22. import javax.servlet.http.HttpServletResponse;
  23. import java.text.SimpleDateFormat;
  24. import java.util.List;
  25. /**
  26. * @description: 客户活动控制器
  27. * @author: houn
  28. * @create: 2020-06-13 18:01
  29. **/
  30. @RestController
  31. @RequestMapping("/custom/activity")
  32. public class CustomActivityApplyController {
  33. @Autowired
  34. private CustomActivityApplyFeignService customActivityApplyFeignService;
  35. @PostMapping("/approve")
  36. public BaseResultDto approve(@RequestBody @Validated CustomActivityApplyApproveEntity entity) throws Exception {
  37. return customActivityApplyFeignService.approve(entity);
  38. }
  39. @PostMapping("/de/complete")
  40. public BaseResultDto deComplete(@RequestBody @Validated SingleLongEntity entity) throws Exception {
  41. return customActivityApplyFeignService.deComplete(entity);
  42. }
  43. @PostMapping("/complete")
  44. public BaseResultDto complete(@RequestBody @Validated CustomActivityApplyApproveEntity entity) throws Exception {
  45. return customActivityApplyFeignService.complete(entity);
  46. }
  47. @PostMapping("/delete")
  48. public BaseResultDto delete(@RequestBody @Validated CustomActivityApplyDeleteEntity entity) throws Exception {
  49. return customActivityApplyFeignService.delete(entity);
  50. }
  51. @PostMapping("/update")
  52. public BaseResultDto update(@RequestBody @Validated CustomActivityApplyUpdateEntity entity) throws Exception {
  53. return customActivityApplyFeignService.update(entity);
  54. }
  55. @PostMapping("/searcher/list")
  56. public BaseResultDto searcherList(@RequestBody @Validated CustomActivityApplySearchEntity entity) throws Exception {
  57. ResultWithPagerDto<CustomActivityApplySearchDto> resultWithPagerDto =
  58. customActivityApplyFeignService.searcherList(entity);
  59. return resultWithPagerDto;
  60. }
  61. @PostMapping("/searcher/passed/list")
  62. public BaseResultDto searcherPassedList(@RequestBody @Validated CustomActivityApplySearchEntity entity) throws Exception {
  63. ResultWithPagerDto<CustomActivityApplySearchDto> resultWithPagerDto =
  64. customActivityApplyFeignService.searcherPassedList(entity);
  65. return resultWithPagerDto;
  66. }
  67. @GetMapping(value = {"/export", "/passed/export"})
  68. public void exportList(@RequestParam(name = "login") Long login,
  69. @RequestParam(name = "cId") Long cId,
  70. @RequestParam(name = "startDate") String startDate,
  71. @RequestParam(name = "endDate") String endDate,
  72. @RequestParam(name = "status") Integer status,
  73. @RequestParam(name = "completeStatus") Integer completeStatus,
  74. HttpServletRequest request,
  75. HttpServletResponse response) throws Exception {
  76. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
  77. CustomActivityApplySearchEntity entity = new CustomActivityApplySearchEntity();
  78. entity.setLogin(login);
  79. entity.setCId(cId);
  80. entity.setStatus(status);
  81. entity.setCompleteStatus(completeStatus);
  82. entity.setStartDate(Strings.isNullOrEmpty(startDate) ? null : simpleDateFormat.parse(startDate));
  83. entity.setEndDate(Strings.isNullOrEmpty(endDate) ? null : simpleDateFormat.parse(endDate));
  84. BaseResultDto<List<CustomActivityApplyExportView>> resultDto = null;
  85. switch (request.getRequestURI()) {
  86. case "/custom/activity/export":
  87. resultDto = customActivityApplyFeignService.exportList(entity);
  88. break;
  89. case "/custom/activity/passed/export":
  90. resultDto = customActivityApplyFeignService.exportPassedList(entity);
  91. break;
  92. }
  93. if (resultDto != null && resultDto.getCode() == 200) {
  94. List<CustomActivityApplyExportDto> dtos = Lists.newArrayList();
  95. resultDto.getData().forEach((item) -> {
  96. CustomActivityApplyExportDto dto = new CustomActivityApplyExportDto();
  97. BeanUtils.copyProperties(item, dto);
  98. dto.setCID(item.getCId());
  99. dto.setPIBNO(item.getPIbNo());
  100. dtos.add(dto);
  101. });
  102. ExportUtil.transferToResponse(StringUtil.getXlsxFileName("CUSTOM_ACTIVITY", true), dtos,
  103. CustomActivityApplyExportDto.class, response);
  104. }
  105. }
  106. @PostMapping("/searcher/single")
  107. public BaseResultDto searcherSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
  108. CustomActivityApplySearchDto customActivityApplySearchDto =
  109. customActivityApplyFeignService.searcherSingle(entity);
  110. return BaseResultDto.success(customActivityApplySearchDto);
  111. }
  112. }