|
|
|
package com.epmet.controller;
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.annotation.LoginUser;
|
|
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit;
|
|
|
|
import com.epmet.commons.tools.constant.StrConstant;
|
|
|
|
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.ExcelUtils;
|
|
|
|
import com.epmet.commons.tools.utils.Result;
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
|
|
import com.epmet.dto.form.CollectListFormDTO;
|
|
|
|
import com.epmet.dto.form.IcResiCollectFormDTO;
|
|
|
|
import com.epmet.dto.form.LatestSubmitCollectFormDTO;
|
|
|
|
import com.epmet.dto.form.ResiCollectFormDTO;
|
|
|
|
import com.epmet.dto.result.CollectListExcelResultDTO;
|
|
|
|
import com.epmet.dto.result.CollectListMemberExcelResultDTO;
|
|
|
|
import com.epmet.dto.result.CollectListResultDTO;
|
|
|
|
import com.epmet.dto.result.LatestCollectResDTO;
|
|
|
|
import com.epmet.service.IcResiCollectService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 居民信息采集表
|
|
|
|
*
|
|
|
|
* @author generator generator@elink-cn.com
|
|
|
|
* @since v1.0.0 2022-03-18
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("icresicollect")
|
|
|
|
public class IcResiCollectController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IcResiCollectService icResiCollectService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 居民信息采集_提交
|
|
|
|
*
|
|
|
|
* @param formDTO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("save")
|
|
|
|
public Result save(@RequestBody IcResiCollectFormDTO formDTO) {
|
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(formDTO, IcResiCollectFormDTO.AddUserInternalGroup.class);
|
|
|
|
// 内部:internal;外部:external
|
|
|
|
if ("internal".equals(formDTO.getOrigin())) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, IcResiCollectFormDTO.InternalShowGroup.class);
|
|
|
|
} else if ("external".equals(formDTO.getOrigin())) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, IcResiCollectFormDTO.ExternalShowGroup.class);
|
|
|
|
}
|
|
|
|
icResiCollectService.save(formDTO);
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Desc: 查询采集居民信息
|
|
|
|
* @param formDTO
|
|
|
|
* @param tokenDto
|
|
|
|
* @author zxc
|
|
|
|
* @date 2022/3/18 19:23
|
|
|
|
*/
|
|
|
|
@PostMapping("list")
|
|
|
|
public Result<PageData<CollectListResultDTO>> getCollectList(@RequestBody CollectListFormDTO formDTO, @LoginUser TokenDto tokenDto){
|
|
|
|
ValidatorUtils.validateEntity(formDTO,CollectListFormDTO.CollectListForm.class);
|
|
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
return new Result<PageData<CollectListResultDTO>>().ok(icResiCollectService.getCollectList(formDTO));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Desc: 查询采集居民信息
|
|
|
|
* @param formDTO
|
|
|
|
* @param tokenDto
|
|
|
|
* @author zxc
|
|
|
|
* @date 2022/3/18 19:23
|
|
|
|
*/
|
|
|
|
@PostMapping("export")
|
|
|
|
public void export(@RequestBody CollectListFormDTO formDTO, @LoginUser TokenDto tokenDto, HttpServletResponse response) throws Exception {
|
|
|
|
//ValidatorUtils.validateEntity(formDTO,CollectListFormDTO.CollectListForm.class);
|
|
|
|
//tokenDto.setUserId("73ae6280e46a6653a5605d51d5462725");
|
|
|
|
//tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc");
|
|
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
formDTO.setIsPage(false);
|
|
|
|
PageData<CollectListResultDTO> collectList = icResiCollectService.getCollectList(formDTO);
|
|
|
|
List<CollectListExcelResultDTO> list =new ArrayList<>();
|
|
|
|
|
|
|
|
collectList.getList().forEach(o->{
|
|
|
|
List<CollectListMemberExcelResultDTO> children = new ArrayList<>();
|
|
|
|
o.getList().forEach(item->{
|
|
|
|
CollectListMemberExcelResultDTO resultDTO = ConvertUtils.sourceToTarget(item, CollectListMemberExcelResultDTO.class);
|
|
|
|
resultDTO.setYmjz(item.getYmjz() == null? StrConstant.EPMETY_STR:String.valueOf(item.getYmjz()));
|
|
|
|
children.add(resultDTO);
|
|
|
|
});
|
|
|
|
CollectListExcelResultDTO resultDTO = ConvertUtils.sourceToTarget(o, CollectListExcelResultDTO.class);
|
|
|
|
resultDTO.setListP(children);
|
|
|
|
list.add(resultDTO);
|
|
|
|
});
|
|
|
|
|
|
|
|
ExcelUtils.exportExcelToTarget(response, null, list, CollectListExcelResultDTO.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 居民端小程序:社区居民信息登记-提交
|
|
|
|
*
|
|
|
|
* @param tokenDto
|
|
|
|
* @param formDTO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("save-resi")
|
|
|
|
public Result saveResi(@LoginUser TokenDto tokenDto, @RequestBody ResiCollectFormDTO formDTO) {
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
|
|
ValidatorUtils.validateEntity(formDTO, ResiCollectFormDTO.InternalShowGroup.class, ResiCollectFormDTO.AddUserInternalGroup.class);
|
|
|
|
icResiCollectService.saveResi(formDTO);
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 居民端小程序:社区居民信息登记-查询
|
|
|
|
* @param tokenDto
|
|
|
|
* @param formDTO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("latest-submit")
|
|
|
|
public Result<LatestCollectResDTO> latestSubmit(@LoginUser TokenDto tokenDto, @RequestBody LatestSubmitCollectFormDTO formDTO){
|
|
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
ValidatorUtils.validateEntity(formDTO,LatestSubmitCollectFormDTO.AddUserInternalGroup.class);
|
|
|
|
return new Result<LatestCollectResDTO>().ok(icResiCollectService.latestSubmit(formDTO));
|
|
|
|
}
|
|
|
|
}
|