提交 230fc96d 编写于 作者: yongbo.wang's avatar yongbo.wang

批量获取数据

上级 34720cf5
流水线 #26674 已失败 于阶段
in 0 second
......@@ -2,7 +2,7 @@ package com.pica.cloud.account.account.common.resp;
import io.swagger.annotations.ApiModel;
import java.util.List;
import java.util.Map;
/**
*
......@@ -10,24 +10,13 @@ import java.util.List;
@ApiModel(description = "建立微信与账号关联关系-resp")
public class AcctPatIdResp {
private List<Integer> acctPatIds;
private Map<Integer, Integer> patFamId;
/*
private List<AcctPatId> acctPatId;
public List<AcctPatId> getAcctPatIds() {
return acctPatIds;
}
public void setAcctPatIds(List<AcctPatId> acctPatIds) {
this.acctPatIds = acctPatIds;
}*/
public List<Integer> getAcctPatIds() {
return acctPatIds;
public Map<Integer, Integer> getPatFamId() {
return patFamId;
}
public void setAcctPatIds(List<Integer> acctPatIds) {
this.acctPatIds = acctPatIds;
public void setPatFamId(Map<Integer, Integer> patFamId) {
this.patFamId = patFamId;
}
}
......@@ -3,7 +3,6 @@ package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.common.req.*;
import com.pica.cloud.account.account.common.resp.AcctPatId;
import com.pica.cloud.account.account.common.resp.AcctPatIdResp;
import com.pica.cloud.account.account.common.resp.PatBindResp;
import com.pica.cloud.account.account.common.resp.PatFamilyResp;
......@@ -18,7 +17,6 @@ import com.pica.cloud.account.account.server.mapper.AcctPatFamilyMapper;
import com.pica.cloud.account.account.server.mapper.AcctPatInfoMapper;
import com.pica.cloud.account.account.server.mapper.AcctPatUnionMapper;
import com.pica.cloud.account.account.server.service.PatHealthPackService;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.entity.PicaException;
......@@ -32,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import static com.pica.cloud.account.account.server.enums.AccountTypeEnum.union_login_blog;
import static java.util.stream.Collectors.toList;
/**
......@@ -83,21 +80,20 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
}
/**
* @Description
* 父亲(监护人)、母亲
* @Description 父亲(监护人)、母亲
* 儿子、女儿---(儿媳 女媳 非家庭成员)
* 孙子、孙女、外孙、外孙女
*
* <p>
* 儿子(监护人)、儿媳
* 孙子、孙女
*
* <p>
* 女儿(监护人)、女媳
* 外孙、外孙女
*
*
* <p>
* <p>
* 查询:儿子 patId查
* 返回:父亲,儿媳,孙子,孙女 patId
*
* <p>
* 查询:父亲
* 返回:父亲、母亲、儿子、女儿
* @Author peijun.zhao
......@@ -117,24 +113,24 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
List<Integer> query = new ArrayList<>();
query.add(patientId);
List<AcctPatFamily> memberList = patFamilyMapper.getListByPatIds(query);
if(CollectionUtils.isEmpty(memberList)){
if (CollectionUtils.isEmpty(memberList)) {
//该居民id作为成员无 家庭成员记录
return patIds;
}
//自身监护人
AcctPatFamily self = patFamilyMapper.getByPatIdSelf(patientId);
if(null != self){
if (null != self) {
//自己存在监护人身份,家庭关系成员add
List<AcctPatFamily> sonFamilyList = patFamilyMapper.getListByAcctId(self.getAcctId());
patIds.addAll(sonFamilyList.stream().map(obj -> obj.getPatientId()).collect(toList()));
}
//自身成员
AcctPatFamily member = patFamilyMapper.getByPatIdNotSelf(patientId);
if(null != member){
if (null != member) {
//存在自己作为成员身份记录,add 上级监护人
AcctPatFamily parentAcct = patFamilyMapper.getSelfByAcctId(member.getAcctId());
if(null != parentAcct){
if (null != parentAcct) {
patIds.add(parentAcct.getPatientId());
//监护人组内所有成员 包括自身
......@@ -162,31 +158,31 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
PatFamilyResp resp = new PatFamilyResp();
List<AcctPatFamily> patFamilyList = patFamilyMapper.getListByAcctId(acctId);
List<AcctPatFamilyDto> dtos = new ArrayList<>();
List<Integer> allPadIds = patFamilyList.stream().map(obj ->obj.getPatientId()).collect(toList());
if(CollectionUtils.isEmpty(allPadIds)){
List<Integer> allPadIds = patFamilyList.stream().map(obj -> obj.getPatientId()).collect(toList());
if (CollectionUtils.isEmpty(allPadIds)) {
return resp;
}
if(1 == containAcct){
if (1 == containAcct) {
resp.setMemberPatIds(allPadIds);
for(AcctPatFamily family : patFamilyList){
for (AcctPatFamily family : patFamilyList) {
AcctPatFamilyDto dto = new AcctPatFamilyDto();
dto.setPatientId(family.getPatientId());
dto.setRelation(family.getRelation());
dtos.add(dto);
}
}else if(0 == containAcct){
} else if (0 == containAcct) {
//不包含建立acct账户的pat数据
List<AcctPatFamily> acctList = patFamilyMapper.getByPatIdSelfList(allPadIds);
List<Integer> acctPatIds = acctList.stream().map(obj -> obj.getPatientId()).collect(toList());
for(AcctPatFamily family : patFamilyList){
if(!acctPatIds.contains(family.getPatientId())){
for (AcctPatFamily family : patFamilyList) {
if (!acctPatIds.contains(family.getPatientId())) {
AcctPatFamilyDto dto = new AcctPatFamilyDto();
dto.setPatientId(family.getPatientId());
dto.setRelation(family.getRelation());
dtos.add(dto);
}
}
resp.setMemberPatIds(dtos.stream().distinct().map(obj ->obj.getPatientId()).filter(x -> x!=null).collect(toList()));
resp.setMemberPatIds(dtos.stream().distinct().map(obj -> obj.getPatientId()).filter(x -> x != null).collect(toList()));
}
resp.setMemberList(dtos);
......@@ -196,9 +192,9 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
@Transactional
@Override
public Integer saveAcct(AcctPatInfoReq patInfoReq) {
logger.info("saveAcct:{}",JSONObject.toJSONString(patInfoReq));
if(Objects.isNull(patInfoReq.getPatientId()) || patInfoReq.getPatientId() == 0 || Objects.isNull(patInfoReq.getName())
|| Objects.isNull(patInfoReq.getMobile()) ){
logger.info("saveAcct:{}", JSONObject.toJSONString(patInfoReq));
if (Objects.isNull(patInfoReq.getPatientId()) || patInfoReq.getPatientId() == 0 || Objects.isNull(patInfoReq.getName())
|| Objects.isNull(patInfoReq.getMobile())) {
throw new PicaException(AccountExceptionEnum.PAT_SAVE_PARAM_ERROR.getCode(), AccountExceptionEnum.PAT_SAVE_PARAM_ERROR.getMessage());
}
......@@ -243,7 +239,7 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
@Transactional
@Override
public PatBindResp bindUnion(AcctPatInfoReq patInfoReq) {
logger.info("bindUnion:{}",JSONObject.toJSONString(patInfoReq));
logger.info("bindUnion:{}", JSONObject.toJSONString(patInfoReq));
PatBindResp resp = new PatBindResp();
//unionid是否已被其他账号绑定
AcctPatUnion patUnion = patUnionMapper.selectByUnionId(patInfoReq.getUnionId());
......@@ -302,8 +298,8 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
List<Integer> patIds = memberList.stream().map(obj -> obj.getPatientId()).collect(toList());
List<AcctPatFamilyDto> relatedPats = new ArrayList<>();
List<AcctPatFamily> members = patFamilyMapper.getMemberListByPatIds(patIds);
for(AcctPatFamily member : members){
if(!familyReqReq.getAcctId().equals(member.getAcctId())){
for (AcctPatFamily member : members) {
if (!familyReqReq.getAcctId().equals(member.getAcctId())) {
//居民已被其他账户绑定为家庭成员
AcctPatFamilyDto failOne = new AcctPatFamilyDto();
failOne.setPatientId(member.getPatientId());
......@@ -311,7 +307,7 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
failList.add(failOne);
successFlag = false;
resp.setFailMsg(AccountExceptionEnum.PAT_MEMBER_HAS_MORE.getMessage());
}else {
} else {
//居民已被传入acctId关联为家庭成员,不需要再保存
AcctPatFamilyDto failOneRelated = new AcctPatFamilyDto();
failOneRelated.setRelation(member.getRelation());
......@@ -323,15 +319,15 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
}
//已关联自身居民list
if(relatedPats.size() > 0){
if (relatedPats.size() > 0) {
successFlag = false;
failList.addAll(relatedPats);
}
//通过后 再建立家庭关系
if(successFlag){
if (successFlag) {
AcctPatFamily acct = patFamilyMapper.getSelfByAcctId(familyReqReq.getAcctId());
for(AcctPatFamilyDto member : memberList){
for (AcctPatFamilyDto member : memberList) {
AcctPatFamily entity = new AcctPatFamily();
entity.setAcctId(familyReqReq.getAcctId());
entity.setPatientId(member.getPatientId());
......@@ -355,59 +351,81 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
public Integer getFamilyAcctPatId(Integer patId) {
Integer rtnPatId = patId;
AcctPatFamily acctMember = patFamilyMapper.getByPatIdSelf(patId);
if(null != acctMember){
if (null != acctMember) {
//本人为监护人 返回自身patId
rtnPatId = acctMember.getPatientId();
}else {
} else {
//查询是否存在 作为成员的记录
AcctPatFamily member = patFamilyMapper.getByPatIdNotSelf(patId);
if(null != member){
if (null != member) {
//本人为成员时记录存在
AcctPatFamily acctPat = patFamilyMapper.getSelfByAcctId(member.getAcctId());
rtnPatId = acctPat.getPatientId();
}else {
} else {
//传入patId不存在家庭记录
}
}
return rtnPatId;
}
/**
* @Description 根据居民id批量获取对应的主账号对应的patId
* @Author wangyongbo
* @Date 2020/6/15 上午11:58
* @ModifyDate 2020/6/15 上午11:58
* @Params
* @Return
*/
@Override
public AcctPatIdResp getFamilyAcctPatIds(AcctPatIdReq acctPatIdReq) {
AcctPatIdResp resp = new AcctPatIdResp();
List<Integer> acctPatIds = new ArrayList<>();
// List<AcctPatId> rtnAcctPatIds = new ArrayList<>();
Map<Integer, Integer> patFamId = new HashMap<>();
if(acctPatIdReq != null && acctPatIdReq.getPatIds().size() > 1000){
if (acctPatIdReq != null && acctPatIdReq.getPatIds().size() > 1000) {
throw new AccountException(AccountExceptionEnum.PAT_QUERY_MAX);
}
/**先获取是主账号本人的居民id*/
List<AcctPatFamily> acctMembers = patFamilyMapper.getListByPatIdSelfs(acctPatIdReq.getPatIds());
for (AcctPatFamily family : acctMembers){
//本人为监护人 返回自身patId映射
/*AcctPatId acctPatId = new AcctPatId();
acctPatId.setReqPatId(family.getPatientId());
acctPatId.setAcctPatId(family.getPatientId());
rtnAcctPatIds.add(acctPatId);*/
acctPatIds.add(family.getPatientId());
}
// 本人为监护人的patIds
List<Integer> acctMemberPatIds = acctMembers.stream().map(o-> o.getPatientId()).collect(toList());
// 作为成员的记录
for (AcctPatFamily family : acctMembers) {
patFamId.put(family.getPatientId(), family.getPatientId());
}
/** 本人为监护人的patIds*/
List<Integer> acctMemberPatIds = acctMembers.stream().map(o -> o.getPatientId()).collect(toList());
/**作为成员的记录*/
List<Integer> memberIds = acctPatIdReq.getPatIds().stream().filter(reqPatId -> acctMemberPatIds.stream().noneMatch(patId -> reqPatId.equals(patId))).collect(toList());
if(CollectionUtils.isNotEmpty(memberIds)){
if (CollectionUtils.isNotEmpty(memberIds)) {
/**获取不是本人的主账号的本人居民id*/
List<AcctPatFamily> members = patFamilyMapper.getListByPatIdNotSelfs(memberIds);
List<Integer> memberAcctIds = members.stream().map(o->o.getAcctId()).collect(toList());
if(CollectionUtils.isNotEmpty(memberAcctIds)){
if (CollectionUtils.isNotEmpty(members)) {
List<Integer> memberAcctIds = members.stream().map(o -> o.getAcctId()).collect(toList());
if (CollectionUtils.isNotEmpty(memberAcctIds)) {
List<AcctPatFamily> acctPats = patFamilyMapper.getSelfListByAcctIds(memberAcctIds);
for(AcctPatFamily family : acctPats){
acctPatIds.add(family.getPatientId());
for (AcctPatFamily family : acctPats) {
for (AcctPatFamily member : members) {
if (StringUtils.equals(String.valueOf(family.getAcctId()), String.valueOf(member.getAcctId()))) {
patFamId.put(member.getPatientId(), family.getPatientId());
}
}
}
}
/**没有主账号的patIds*/
memberIds.removeAll(members.stream().map(o -> o.getPatientId()).collect(toList()));
if (CollectionUtils.isNotEmpty(memberIds)) {
for(Integer member : memberIds) {
patFamId.put(member, member);
}
}
resp.setAcctPatIds(acctPatIds);
}
}
resp.setPatFamId(patFamId);
return resp;
}
......@@ -421,18 +439,18 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
// List<String> mobiles = list.stream().map(obj -> obj.getMobile()).collect(toList());
List<String> encryMobiles = list.stream().map(obj -> obj.getEncryMobile()).collect(toList());
List<AcctPatFamily> checkPatIdList = patFamilyMapper.getByPatIdSelfList(patIds);
if(CollectionUtils.isNotEmpty(checkPatIdList)){
if (CollectionUtils.isNotEmpty(checkPatIdList)) {
//病人id在成员表中 作为主账户不应该存在
throw new PicaException(AccountExceptionEnum.PAT_HAS_CREATE_ACCT.getCode(), AccountExceptionEnum.PAT_HAS_CREATE_ACCT.getMessage());
}
List<AcctPatInfo> checkMobileList = patInfoMapper.getListByMobiles(encryMobiles);
if(CollectionUtils.isNotEmpty(checkMobileList)){
if (CollectionUtils.isNotEmpty(checkMobileList)) {
throw new PicaException(AccountExceptionEnum.PAT_HAS_CREATE_ACCT.getCode(), AccountExceptionEnum.PAT_HAS_CREATE_ACCT.getMessage());
}
//初始主账户数据
List<AcctPatInfo> infoList = new ArrayList<>();
for(InitAcctReq initAcctReq : list){
for (InitAcctReq initAcctReq : list) {
AcctPatInfo patInfo = new AcctPatInfo();
patInfo.setMobilePhone(initAcctReq.getEncryMobile());
patInfo.setName(initAcctReq.getName());
......@@ -443,10 +461,10 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
//获取入库账户ID 关联成员表;
// List<AcctPatInfo> saveAccts = patInfoMapper.getListByMobiles(encryMobiles);
List<AcctPatFamily> saveList = new ArrayList<>();
for(AcctPatInfo acct : infoList){
for(InitAcctReq req : list){
for (AcctPatInfo acct : infoList) {
for (InitAcctReq req : list) {
AcctPatFamily family = new AcctPatFamily();
if(req.getEncryMobile().equals(acct.getMobilePhone())){
if (req.getEncryMobile().equals(acct.getMobilePhone())) {
family.setRelation(1);
family.setPatientId(req.getPatId());
family.setAcctId(acct.getId());
......@@ -459,11 +477,11 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
//初始 账户联合表
List<AcctPatUnion> unionList = new ArrayList<>();
for(AcctPatInfo acct : infoList){
for(InitAcctReq req : list){
for (AcctPatInfo acct : infoList) {
for (InitAcctReq req : list) {
AcctPatUnion patUnion = new AcctPatUnion();
if(req.getEncryMobile().equals(acct.getMobilePhone())){
if(StringUtils.isNotEmpty(req.getUnionId())){
if (req.getEncryMobile().equals(acct.getMobilePhone())) {
if (StringUtils.isNotEmpty(req.getUnionId())) {
patUnion.setAcctId(acct.getId());
patUnion.setUnionType(AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
patUnion.setUnionId(req.getUnionId());
......@@ -482,16 +500,16 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
public List<Integer> queryByPage(AcctPatPageReq patPageReq) {
Integer pageNo = 1;
Integer pageSize = 100;
if(null != patPageReq.getPageNo() || 0 != patPageReq.getPageNo()){
if (null != patPageReq.getPageNo() || 0 != patPageReq.getPageNo()) {
pageNo = patPageReq.getPageNo();
}
if(null != patPageReq.getPageSize() && 0 != patPageReq.getPageSize()){
if (null != patPageReq.getPageSize() && 0 != patPageReq.getPageSize()) {
pageSize = patPageReq.getPageSize();
}
Map query = new HashMap();
query.put("begin",(pageNo-1) * pageSize);
query.put("end",pageSize);
query.put("begin", (pageNo - 1) * pageSize);
query.put("end", pageSize);
return patFamilyMapper.queryPatIdByPage(query);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册