Commit 0e9d1466 by 王健飞

火化开放搜索接口

parent 8cea37bd
package com.zq.open.controller.api;
import cn.hutool.core.util.IdcardUtil;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo;
import com.zq.open.service.CremationService;
import com.zq.open.service.MarriageService;
import com.zq.open.vo.CremationSearchVo;
import com.zq.open.vo.MarriageSearchVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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;
@Api(tags = "火化相关接口")
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/open/api/cremation")
public class CremationApi {
private final CremationService cremationService;
@ApiOperation("火化信息搜素接口")
@PostMapping(value = "/search")
public ResultVo search(@RequestBody CremationSearchVo vo) {
AssertUtils.hasText(vo.getIdCard(), "缺少身份号");
AssertUtils.isTrue(IdcardUtil.isValidCard(vo.getIdCard()), "身份号不正确");
return ResultVo.success(cremationService.search(vo));
}
}
package com.zq.open.dao;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zq.common.constant.DBName;
import com.zq.open.entity.FisCremationInfoSum;
import com.zq.open.entity.Mrcase;
import org.springframework.stereotype.Repository;
/**
*fis_cremation_info_sum火化数据库访问层
*
* @author makejava
* @since 2021-09-23 10:49:09
*/
@DS(DBName.GXBZ)
@Repository
public interface FisCremationInfoSumDao extends BaseMapper<FisCremationInfoSum> {
}
\ No newline at end of file
package com.zq.open.service;
import cn.hutool.core.util.IdcardUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zq.common.utils.AssertUtils;
import com.zq.open.dao.FisCremationInfoSumDao;
import com.zq.open.entity.FisCremationInfoSum;
import com.zq.open.vo.CremationSearchVo;
import com.zq.open.vo.CremationVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
/**
* @author wilmiam
* @since 2021/9/23 10:27
*/
@Service
@RequiredArgsConstructor
public class CremationService {
private final FisCremationInfoSumDao cremationInfoSumDao;
public List<CremationVo> search(CremationSearchVo vo) {
if (vo.getSex() == null) {
vo.setSex(IdcardUtil.getGenderByIdCard(vo.getIdCard()));
}
List<FisCremationInfoSum> cremationInfoSumsList = cremationInfoSumDao.selectList(Wrappers.lambdaQuery(FisCremationInfoSum.builder().name(vo.getName()).idCard(vo.getIdCard()).cremationTime(vo.getCremationTime()).build()));
if (vo.getQueryType() == 2) {
Optional<FisCremationInfoSum> infoSum = cremationInfoSumsList.stream().max(Comparator.comparing(FisCremationInfoSum::getCremationTime));
cremationInfoSumsList = new ArrayList<>();
infoSum.ifPresent(cremationInfoSumsList::add);
}
AssertUtils.notEmpty(cremationInfoSumsList,"查询为空");
List<CremationVo> returnList = new ArrayList<>();
for (FisCremationInfoSum infoSum:cremationInfoSumsList){
CremationVo build = CremationVo.builder()
.name(infoSum.getName())
.sex(infoSum.getSex())
.cremationTime(infoSum.getCremationTime())
.familyAdd(infoSum.getFamilyAdd())
.populace(infoSum.getPopulace())
.useId(infoSum.getUseId())
.deadId(infoSum.getDeadId())
.deathCause(infoSum.getDeathCause())
.deathDate(infoSum.getDeathDate())
.idCard(infoSum.getIdCard())
.build();
returnList.add(build);
}
return returnList;
}
}
package com.zq.open.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CremationSearchVo {
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("身份证号码")
private String idCard;
@ApiModelProperty("性别: 0-女, 1-男")
private Integer sex;
@ApiModelProperty("火化时间")
private String cremationTime;
@ApiModelProperty("查找类型: 1-历史, 2-最新")
private Integer queryType = 2;
}
package com.zq.open.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CremationVo {
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("证件号码")
private String idCard;
@ApiModelProperty("去世时间")
private String deathDate;
@ApiModelProperty("性别")
private String sex;
@ApiModelProperty("家庭住址")
private String familyAdd;
@ApiModelProperty("户口所在地")
private String populace;
@ApiModelProperty("死亡原因")
private String deathCause;
@ApiModelProperty("火化时间")
private String cremationTime;
@ApiModelProperty("火化编号")
private String useId;
@ApiModelProperty("逝者编码")
private String deadId;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment