|
|
@ -1,11 +1,24 @@ |
|
|
|
package com.epmet.modules.partyOrg.controller; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.modules.partyOrg.excel.IcPartyActExpoprtExcel; |
|
|
|
import com.epmet.modules.partyOrg.service.IcPartyActService; |
|
|
|
import com.epmet.resi.partymember.dto.icpartyact.form.BatchAddPartyActFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.icpartyact.form.IcPartyActAddOrUpdateFormDTO; |
|
|
@ -19,13 +32,19 @@ import com.epmet.resi.partymember.dto.partyOrg.form.YearSearchFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.ActAndScheduleListResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.HomeMonthTotalResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.YearSearchResultDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.PrintWriter; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -34,6 +53,7 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2022-08-18 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("icPartyAct") |
|
|
|
public class IcPartyActController { |
|
|
@ -47,6 +67,7 @@ public class IcPartyActController { |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("addOrUpdate") |
|
|
|
public Result<Map<String,String>> addOrUpdate(@LoginUser TokenDto tokenDto,@RequestBody IcPartyActAddOrUpdateFormDTO formDTO){ |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
@ -68,6 +89,7 @@ public class IcPartyActController { |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("batch-add") |
|
|
|
public Result batchAdd(@LoginUser TokenDto tokenDto,@RequestBody BatchAddPartyActFormDTO formDTO){ |
|
|
|
formDTO.getActList().forEach(dto->{ |
|
|
@ -178,6 +200,7 @@ public class IcPartyActController { |
|
|
|
* @param icPartyActId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("publish/{icPartyActId}") |
|
|
|
public Result publicshIcPartyAct(@LoginUser TokenDto tokenDto,@PathVariable("icPartyActId")String icPartyActId){ |
|
|
|
icPartyActService.publicshIcPartyAct(tokenDto.getUserId(),icPartyActId); |
|
|
@ -193,6 +216,7 @@ public class IcPartyActController { |
|
|
|
* @param icPartyActIds |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("del") |
|
|
|
public Result deleteIcPartyAct(@LoginUser TokenDto tokenDto,@RequestBody List<String> icPartyActIds){ |
|
|
|
if(CollectionUtils.isNotEmpty(icPartyActIds)){ |
|
|
@ -215,4 +239,45 @@ public class IcPartyActController { |
|
|
|
return new Result<List<YearSearchResultDTO>>().ok(icPartyActService.yearSearch(formDTO)); |
|
|
|
} |
|
|
|
|
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("/export-act") |
|
|
|
public void export(@LoginUser TokenDto tokenDto, @RequestBody IcPartyActPageFormDTO formDTO, HttpServletResponse response) throws IOException { |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
formDTO.setPublishStaffId(tokenDto.getUserId()); |
|
|
|
formDTO.setIsPage(false); |
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
formDTO.setPageNo(NumConstant.ONE); |
|
|
|
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
try { |
|
|
|
String fileName = "党组织活动" + DateUtils.format(new Date()) + ".xlsx"; |
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcPartyActExpoprtExcel.class).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); |
|
|
|
PageData<IcPartyActPageResultDTO> data = null; |
|
|
|
List<IcPartyActExpoprtExcel> list = null; |
|
|
|
do { |
|
|
|
data = icPartyActService.pageList(formDTO); |
|
|
|
list = ConvertUtils.sourceToTarget(data.getList(), IcPartyActExpoprtExcel.class); |
|
|
|
list.forEach(l->{ |
|
|
|
List<String> orgNameList = l.getJoinOrgList().stream().map(m -> m.getJoinOrgName()).distinct().collect(Collectors.toList()); |
|
|
|
l.setJoinOrgNameStr(orgNameList.stream().map(String::valueOf).collect(Collectors.joining(","))); |
|
|
|
}); |
|
|
|
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); |
|
|
|
excelWriter.write(list, writeSheet); |
|
|
|
} while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); |
|
|
|
} catch (EpmetException e) { |
|
|
|
response.reset(); |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.setHeader("content-type", "application/json; charset=UTF-8"); |
|
|
|
PrintWriter printWriter = response.getWriter(); |
|
|
|
Result<Object> result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),e.getMsg()); |
|
|
|
printWriter.write(JSON.toJSONString(result)); |
|
|
|
printWriter.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("export exception", e); |
|
|
|
} finally { |
|
|
|
if (excelWriter != null) { |
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|