|
|
@ -2,8 +2,12 @@ package com.epmet.controller; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.annotation.MaskResponse; |
|
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.enums.DictTypeEnum; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
@ -12,11 +16,15 @@ import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.dto.PovertyManageDTO; |
|
|
|
import com.epmet.dto.form.povertyManage.PovertyManageFormDto; |
|
|
|
import com.epmet.excel.PovertyManageExcel; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.remote.EpmetUserRemoteService; |
|
|
|
import com.epmet.service.PovertyManageService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -25,6 +33,7 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2023-06-16 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("povertyManage") |
|
|
|
public class PovertyManageController { |
|
|
@ -35,6 +44,9 @@ public class PovertyManageController { |
|
|
|
@Autowired |
|
|
|
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserRemoteService userRemoteService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("page") |
|
|
|
@MaskResponse(fieldNames = {"mobile", "idCard"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) |
|
|
@ -57,7 +69,12 @@ public class PovertyManageController { |
|
|
|
public Result save(@RequestBody PovertyManageFormDto dto) { |
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|
|
|
povertyManageService.save(dto); |
|
|
|
Boolean flag = povertyManageService.isExist(dto.getResiUserId()); |
|
|
|
if (!flag) { |
|
|
|
povertyManageService.save(dto); |
|
|
|
} else { |
|
|
|
return new Result().error(8000, "该人员已经是贫困户,请勿重复添加!"); |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
@ -78,6 +95,25 @@ public class PovertyManageController { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/exportExcel") |
|
|
|
public void exportExcelByEasyExcel(@RequestBody PovertyManageFormDto formDTO, HttpServletResponse response) throws Exception { |
|
|
|
formDTO.setPageNo(NumConstant.ONE); |
|
|
|
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
AgencyInfoCache agency = CustomerOrgRedis.getAgencyInfo(userRemoteService.getLoginUserDetails().getAgencyId()); |
|
|
|
String agencyName = agency.getOrganizationName(); |
|
|
|
PageData<PovertyManageDTO> data = povertyManageService.search(formDTO); |
|
|
|
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); |
|
|
|
if (null != data && data.getList().size() > 0) { |
|
|
|
buildData(data.getList()); |
|
|
|
for (PovertyManageDTO dto : data.getList()) { |
|
|
|
dto.setAgencyId(agencyName); |
|
|
|
dto.setGridId(CustomerOrgRedis.getGridInfo(dto.getGridId()).getGridName()); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtils.exportExcelToTarget(response, "贫困人员名单.xls", data.getList(), PovertyManageExcel.class); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("search") |
|
|
|
@MaskResponse(fieldNames = {"mobile", "idCard"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) |
|
|
|
public Result<PageData<PovertyManageDTO>> search(@RequestBody PovertyManageFormDto formDto) { |
|
|
|