|
|
@ -1,30 +1,54 @@ |
|
|
|
package com.epmet.modules.partymember.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.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.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.dto.IcFollowUpRecordDTO; |
|
|
|
import com.epmet.dto.result.IcMoveInListResultDTO; |
|
|
|
import com.epmet.dto.result.IcVaccineListResultDTO; |
|
|
|
import com.epmet.modules.partymember.entity.IcPartyMemberPointEntity; |
|
|
|
import com.epmet.modules.partymember.excel.IcPartyMemberExcel; |
|
|
|
import com.epmet.modules.partymember.excel.IcPartyMemberPointExcel; |
|
|
|
import com.epmet.modules.partymember.service.IcPartyMemberPointService; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.IcPartyMemberPointDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.PartyMemberPointListCountDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberExportFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberPointEchoFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.form.PartyMemberPointListFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.result.IcPartyMemberResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.result.PartyMemberPointEchoResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.result.PartyMemberPointExportResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partymember.result.PartyMemberPointListResultDTO; |
|
|
|
import jdk.nashorn.internal.parser.Token; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.PrintWriter; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -35,6 +59,7 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@RequestMapping("icPartyMemberPoint") |
|
|
|
@Slf4j |
|
|
|
public class IcPartyMemberPointController { |
|
|
|
|
|
|
|
@Autowired |
|
|
@ -54,7 +79,7 @@ public class IcPartyMemberPointController { |
|
|
|
|
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("save") |
|
|
|
public Result save(@RequestBody IcPartyMemberPointDTO dto,@LoginUser TokenDto tokenDto) { |
|
|
|
public Result save(@RequestBody IcPartyMemberPointDTO dto, @LoginUser TokenDto tokenDto) { |
|
|
|
dto.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|
|
@ -64,7 +89,7 @@ public class IcPartyMemberPointController { |
|
|
|
|
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("update") |
|
|
|
public Result update(@RequestBody IcPartyMemberPointDTO dto,@LoginUser TokenDto tokenDto) { |
|
|
|
public Result update(@RequestBody IcPartyMemberPointDTO dto, @LoginUser TokenDto tokenDto) { |
|
|
|
dto.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|
|
@ -80,10 +105,53 @@ public class IcPartyMemberPointController { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("export") |
|
|
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|
|
|
List<IcPartyMemberPointDTO> list = icPartyMemberPointService.list(params); |
|
|
|
ExcelUtils.exportExcelToTarget(response, null, list, IcPartyMemberPointExcel.class); |
|
|
|
/** |
|
|
|
* 量化积分统计导出 |
|
|
|
* |
|
|
|
* @param formDto |
|
|
|
* @param response |
|
|
|
* @return void |
|
|
|
* @author LZN |
|
|
|
* @date 2022/5/24 14:26 |
|
|
|
*/ |
|
|
|
@PostMapping("export") |
|
|
|
public void export(@RequestBody PartyMemberExportFormDTO formDto, HttpServletResponse response) throws Exception { |
|
|
|
|
|
|
|
formDto.setIsPage(false); |
|
|
|
formDto.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
AtomicInteger i = new AtomicInteger(1); |
|
|
|
|
|
|
|
try { |
|
|
|
String fileName = "lhjf.xlsx"; |
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcPartyMemberPointExcel.class).build(); |
|
|
|
PageData<PartyMemberPointExportResultDTO> page = null; |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("量化积分").registerWriteHandler(new FreezeAndFilter()).build(); |
|
|
|
do { |
|
|
|
page = icPartyMemberPointService.getExport(formDto); |
|
|
|
List<IcPartyMemberPointExcel> list = ConvertUtils.sourceToTarget(page.getList(), IcPartyMemberPointExcel.class); |
|
|
|
list.forEach(item -> { |
|
|
|
item.setIndex(i.getAndIncrement()); |
|
|
|
}); |
|
|
|
excelWriter.write(list, writeSheet); |
|
|
|
formDto.setPageNo(formDto.getPageNo() + NumConstant.ONE); |
|
|
|
} while (CollectionUtils.isNotEmpty(page.getList()) && page.getList().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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -109,9 +177,9 @@ public class IcPartyMemberPointController { |
|
|
|
* @date 2022/5/18 18:18 |
|
|
|
*/ |
|
|
|
@PostMapping("echoPartyMemberPoint") |
|
|
|
public Result<PartyMemberPointEchoResultDTO> getEchoPartyMemberPoint(@RequestBody PartyMemberPointEchoFormDTO form,@LoginUser TokenDto tokenDto) { |
|
|
|
public Result<PartyMemberPointEchoResultDTO> getEchoPartyMemberPoint(@RequestBody PartyMemberPointEchoFormDTO form, @LoginUser TokenDto tokenDto) { |
|
|
|
ValidatorUtils.validateEntity(form); |
|
|
|
List<PartyMemberPointEchoResultDTO> dto = icPartyMemberPointService.getEchoPartyMemberPoint(form,tokenDto.getCustomerId()); |
|
|
|
List<PartyMemberPointEchoResultDTO> dto = icPartyMemberPointService.getEchoPartyMemberPoint(form, tokenDto.getCustomerId()); |
|
|
|
return new Result().ok(dto); |
|
|
|
} |
|
|
|
|
|
|
|