提交 62c2c8c4 编写于 作者:  Peijun.zhao's avatar Peijun.zhao

codeReview

上级 9a2ff976
流水线 #25660 已失败 于阶段
in 0 second
......@@ -20,6 +20,16 @@ public class InitAcctReq {
private String encryMobile;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEncryMobile() {
return encryMobile;
}
......
......@@ -189,7 +189,8 @@ public class AccountController extends AccountBaseController {
@ApiOperation("H5端一键登录功能,无需完善信息")
@PostMapping("/login-register/v1")
// @RepeatForbidden(uniqueKey = "content") 当前版本存在性能问题 luo优化后上
// @RepeatForbidden(uniqueKey = "content")
//当前版本存在性能问题 luo优化后上
public PicaResponse loginRegister(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
this.checkMobilePhone(request.getMobile());
......
......@@ -43,13 +43,13 @@ public class PatHealthPackController {
return PicaResponse.toResponse(packService.getAcctIdByPatId(patientId));
}
@ApiOperation("上级的监护人 + 下级所有成员 patientId list")
@ApiOperation("所在家庭组的监护人 + 同级家庭成员 + 下级所有成员 patientId list,去除自身、去重;")
@GetMapping(value = "/directPatIds/{patientId}")
public PicaResponse<List<Integer>> getDirectPatIdsByPatId(@PathVariable("patientId") Integer patientId) throws Exception {
return PicaResponse.toResponse(packService.getDirectPatIdsByPatId(patientId));
}
@ApiOperation("根据accid获取家庭关系idList")
@ApiOperation("根据accid获取自身家庭成员List;containAcct:0 包含自身 1 不包含自身")
@GetMapping(value = "/familyPats/{acctId}/containAcct/{containAcct}")
public PicaResponse<PatFamilyResp> getFamilyPatsByAcctId(@PathVariable("acctId") Integer acctId,@PathVariable("containAcct") Integer containAcct) throws Exception {
return PicaResponse.toResponse(packService.getFamilyPatsByAcctId(acctId,containAcct));
......
......@@ -14,6 +14,7 @@ public enum SourceTypeEnum {
SAAS(3, "saas"),
H5(4, "h5"),
ADMIN(5, "admin"),
INIT(6, "初始生成-居民账户"),
XXX(10, "xxxxxx");
......
......@@ -18,15 +18,15 @@ public interface AcctPatFamilyMapper {
int updateByPrimaryKey(AcctPatFamily record);
/** 获取居民id是本人的家庭组记录- 作为家庭主账户、本人居民id,单条ok 多条异常数据 */
List<AcctPatFamily> getByPatIdSelf(Integer patId);
AcctPatFamily getByPatIdSelf(Integer patId);
/** 查询居民id所在家庭组监护人- 作为家庭成员、非主账户本人居民id,单条ok 多条异常数据 */
List<AcctPatFamily> getByPatIdNotSelf(Integer patId);
AcctPatFamily getByPatIdNotSelf(Integer patId);
/** 获取主账户下所有家庭成员 */
List<AcctPatFamily> getListByAcctId(Integer acctId);
/** 根据账户id 获取主账户居民id */
/** 根据账户id 获取主账户居民 */
AcctPatFamily getSelfByAcctId(Integer acctId);
List<AcctPatFamily> getListByPatIds(List<Integer> patIds);
......
......@@ -11,6 +11,8 @@ import com.pica.cloud.account.account.server.entity.AcctPatFamily;
import com.pica.cloud.account.account.server.entity.AcctPatInfo;
import com.pica.cloud.account.account.server.entity.AcctPatUnion;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
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;
......@@ -28,6 +30,7 @@ import java.util.Date;
import java.util.List;
import java.util.Objects;
import static com.pica.cloud.account.account.server.enums.AccountTypeEnum.union_login_blog;
import static java.util.stream.Collectors.toList;
/**
......@@ -67,16 +70,12 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
*/
@Override
public Integer getAcctIdByPatId(Integer patientId) {
List<AcctPatFamily> patFamilyList = patFamilyMapper.getByPatIdSelf(patientId);
if (CollectionUtils.isEmpty(patFamilyList)) {
AcctPatFamily patFamilyAcct = patFamilyMapper.getByPatIdSelf(patientId);
if (null == patFamilyAcct) {
//该居民id无 家庭成员记录,返回0
return 0;
}
if (patFamilyList.size() > 1) {
//db中数据有异常,log 异常
throw new PicaException(AccountExceptionEnum.PAT_ACCT_HAS_MORE.getCode(), AccountExceptionEnum.PAT_ACCT_HAS_MORE.getMessage());
}
return patFamilyList.get(0).getAcctId();
return patFamilyAcct.getAcctId();
}
/**
......@@ -96,29 +95,27 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
@Override
public List<Integer> getDirectPatIdsByPatId(Integer patientId) {
List<Integer> patIds = new ArrayList<>();
List<AcctPatFamily> memberList = patFamilyMapper.getByPatIdNotSelf(patientId);
if (CollectionUtils.isEmpty(memberList)) {
AcctPatFamily member = patFamilyMapper.getByPatIdNotSelf(patientId);
if (null == member) {
//该居民id无 家庭成员记录,返回null
return patIds;
}
if (memberList.size() > 1) {
//db中数据有异常,log 抛异常
throw new PicaException(AccountExceptionEnum.PAT_MEMBER_HAS_MORE.getCode(), AccountExceptionEnum.PAT_MEMBER_HAS_MORE.getMessage());
}
//add 病人id所在家庭组的监护人- patId
/*AcctPatFamily parentMember = patFamilyMapper.getSelfByAcctId(memberList.get(0).getAcctId());
patIds.add(parentMember.getPatientId());*/
//同级所有成员 包括自身
List<AcctPatFamily> patFamilyList = patFamilyMapper.getListByAcctId(memberList.get(0).getAcctId());
List<AcctPatFamily> patFamilyList = patFamilyMapper.getListByAcctId(member.getAcctId());
patIds.addAll(patFamilyList.stream().map(obj -> obj.getPatientId()).collect(toList()));
//下级所有成员
List<AcctPatFamily> selfs = patFamilyMapper.getByPatIdSelf(memberList.get(0).getPatientId());
if(CollectionUtils.isNotEmpty(selfs)){
//自身监护人
AcctPatFamily self = patFamilyMapper.getByPatIdSelf(member.getPatientId());
if(null != self){
//自己存在监护人身份
List<AcctPatFamily> sonFamilyList = patFamilyMapper.getListByAcctId(selfs.get(0).getAcctId());
List<AcctPatFamily> sonFamilyList = patFamilyMapper.getListByAcctId(self.getAcctId());
patIds.addAll(sonFamilyList.stream().map(obj -> obj.getPatientId()).collect(toList()));
}
......@@ -178,18 +175,18 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
String mobileEncrypt = EncryptUtils.encryptContent(patInfoReq.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE);
//check 手机号是否已是主账户
List<AcctPatFamily> patFamilyList = patFamilyMapper.getByPatIdSelf(patInfoReq.getPatientId());
if (CollectionUtils.isNotEmpty(patFamilyList)) {
AcctPatFamily acctPatFamily = patFamilyMapper.getByPatIdSelf(patInfoReq.getPatientId());
if (null != acctPatFamily) {
// 重复时返回已有账户
return patFamilyList.get(0).getAcctId();
return acctPatFamily.getAcctId();
}
//手机号无重复时创建
AcctPatInfo patInfo = new AcctPatInfo();
patInfo.setName(patInfoReq.getName());
patInfo.setMobilePhone(mobileEncrypt);
patInfo.setRegisterProduct(1);
patInfo.setRegisterSource(1);
patInfo.setRegisterProduct(AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode());
patInfo.setRegisterSource(SourceTypeEnum.H5.getCode());
patInfo.setRegTime(new Date());
patInfo.setDeleteFlag(1);
......@@ -241,14 +238,16 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
}
} else {
//未绑定 新增绑定记录
AcctPatFamily acct = patFamilyMapper.getSelfByAcctId(patInfoReq.getAcctId());
AcctPatUnion entity = new AcctPatUnion();
entity.setAcctId(patInfoReq.getAcctId());
entity.setUnionId(patInfoReq.getUnionId());
entity.setUnionType(1);
entity.setUnionType(AccountTypeEnum.UNION_LOGIN_WE_CHAT.getCode());
entity.setDeleteFlag(1);
entity.setCreatedId(patInfoReq.getAcctId());
entity.setModifiedId(patInfoReq.getAcctId());
entity.setCreatedId(acct.getPatientId());
entity.setModifiedId(acct.getPatientId());
entity.setCreatedTime(new Date());
entity.setModifiedTime(new Date());
......@@ -300,6 +299,7 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
//通过后 再建立家庭关系
if(successFlag){
AcctPatFamily acct = patFamilyMapper.getSelfByAcctId(familyReqReq.getAcctId());
for(AcctPatFamilyDto member : memberList){
AcctPatFamily entity = new AcctPatFamily();
entity.setAcctId(familyReqReq.getAcctId());
......@@ -307,8 +307,8 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
entity.setRelation(member.getRelation());
entity.setDeleteFlag(1);
entity.setCreatedId(familyReqReq.getAcctId());
entity.setModifiedId(familyReqReq.getAcctId());
entity.setCreatedId(acct.getPatientId());
entity.setModifiedId(acct.getPatientId());
entity.setCreatedTime(new Date());
entity.setModifiedTime(new Date());
patFamilyMapper.insert(entity);
......@@ -323,16 +323,16 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
@Override
public Integer getFamilyAcctPatId(Integer patId) {
Integer rtnPatId = patId;
List<AcctPatFamily> acctMembers = patFamilyMapper.getByPatIdSelf(patId);
if(CollectionUtils.isNotEmpty(acctMembers)){
AcctPatFamily acctMember = patFamilyMapper.getByPatIdSelf(patId);
if(null != acctMember){
//本人为监护人 返回自身patId
rtnPatId = acctMembers.get(0).getPatientId();
rtnPatId = acctMember.getPatientId();
}else {
//查询是否存在 作为成员的记录
List<AcctPatFamily> members = patFamilyMapper.getByPatIdNotSelf(patId);
if(CollectionUtils.isNotEmpty(members)){
AcctPatFamily member = patFamilyMapper.getByPatIdNotSelf(patId);
if(null != member){
//本人为成员时记录存在
AcctPatFamily acctPat = patFamilyMapper.getSelfByAcctId(members.get(0).getAcctId());
AcctPatFamily acctPat = patFamilyMapper.getSelfByAcctId(member.getAcctId());
rtnPatId = acctPat.getPatientId();
}else {
//传入patId不存在家庭记录
......@@ -344,26 +344,28 @@ public class PatHealthPackServiceIml implements PatHealthPackService {
@Transactional
@Override
public Integer initAccts(List<InitAcctReq> list) {
for(InitAcctReq initAcctReq : list){
/*for(InitAcctReq initAcctReq : list){
initAcctReq.setEncryMobile(EncryptUtils.encryptContent(initAcctReq.getMobile(),EncryptConstants.ENCRYPT_TYPE_MOBILE));
}
}*/
List<Integer> patIds = list.stream().map(obj -> obj.getPatId()).collect(toList());
List<String> mobiles = list.stream().map(obj -> obj.getMobile()).collect(toList());
// 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)){
//病人id在成员表中 作为主账户不存在
//病人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)){
throw new PicaException(AccountExceptionEnum.PAT_HAS_CREATE_ACCT.getCode(), AccountExceptionEnum.PAT_HAS_CREATE_ACCT.getMessage());
}
//初始主账户数据
List<AcctPatInfo> infoList = new ArrayList<>();
for(InitAcctReq initAcctReq : list){
AcctPatInfo patInfo = new AcctPatInfo();
patInfo.setMobilePhone(initAcctReq.getEncryMobile());
patInfo.setName(initAcctReq.getName());
infoList.add(patInfo);
}
patInfoMapper.initBatch(infoList);
......
......@@ -254,7 +254,7 @@
values
<foreach collection="list" item="item" index="index" separator=",">
(
null,#{item.mobilePhone},
#{item.name},#{item.mobilePhone},
null,1,6,
null,null,null,null,now(),
1,99999999,now(),
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册