|
|
@@ -146,8 +146,8 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
|
|
|
|
|
|
@Override
|
|
|
public boolean handleBindResult(HandleBindResult source) {
|
|
|
- //todo 发送处理结果信息
|
|
|
AssistantUserBindEntity userBind = this.findById(source.getBindId());
|
|
|
+ Boolean isDefault=false;
|
|
|
if(source.getAgree()){
|
|
|
//判断是否重复绑定
|
|
|
AssistantUserBindEntity existBind = this.getOne(new QueryWrapper<AssistantUserBindEntity>()
|
|
|
@@ -158,29 +158,65 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
|
|
|
if(existBind!=null){
|
|
|
throw new CustomException("该用户已被看护,请勿重复绑定");
|
|
|
}
|
|
|
+ //判断当前看护是否可设置为默认看护
|
|
|
+ String assistId = userBind.getAssistId();
|
|
|
+ AssistantUserBindEntity defaultAssistant = this.getOne(new QueryWrapper<AssistantUserBindEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(AssistantUserBindEntity::getAssistId, assistId)
|
|
|
+ .eq(AssistantUserBindEntity::getDefault_,true)
|
|
|
+ .eq(AssistantUserBindEntity::getStatus, BindEnum.SUCCESS)
|
|
|
+ .last("limit 1"));
|
|
|
+ //当没有默认看护时,设置当前看护为默认看护
|
|
|
+ isDefault=defaultAssistant==null;
|
|
|
}
|
|
|
boolean result = this.update(new UpdateWrapper<AssistantUserBindEntity>()
|
|
|
.lambda()
|
|
|
.eq(AssistantUserBindEntity::getId, source.getBindId())
|
|
|
.set(AssistantUserBindEntity::getDoctorId, source.getDoctorId())
|
|
|
.set(AssistantUserBindEntity::getStatus, source.getAgree() ? BindEnum.SUCCESS : BindEnum.REFUSE)
|
|
|
+ .set(source.getAgree(),AssistantUserBindEntity::getDefault_,isDefault)
|
|
|
.set(!source.getAgree(), AssistantUserBindEntity::getRefuseReason, source.getRefuseReason()));
|
|
|
if(result&&source.getAgree()&&StrUtil.isNotEmpty(userBind.getInviteCode())){
|
|
|
//绑定成功后删除邀请码
|
|
|
patientClient.delInviteCode(userBind.getInviteCode());
|
|
|
}
|
|
|
+
|
|
|
+ SpringUtil.publishEvent(new SaveMsgEvent(
|
|
|
+ this,
|
|
|
+ MsgBean.builder()
|
|
|
+ .msgType(source.getAgree()?
|
|
|
+ MsgEnum.BIND_SUCCESS:MsgEnum.BIND_FAIL)
|
|
|
+ .payload(source.getBindId())
|
|
|
+ .senderId(source.getDoctorId())
|
|
|
+ .senderNickname(source.getDoctorName())
|
|
|
+ .patientId(userBind.getPatientId())
|
|
|
+ .patientCode(userBind.getPatientCode())
|
|
|
+ .patientName(userBind.getPatientName())
|
|
|
+ .patientAge(userBind.getPatientAge())
|
|
|
+ .patientSex(userBind.getPatientSex())
|
|
|
+ .receiverId(userBind.getAssistId())
|
|
|
+ .receiverName(userBind.getAssistNickname())
|
|
|
+ .extend(userBind.getInviteCode())
|
|
|
+ .sys(false)
|
|
|
+ .build()
|
|
|
+ ));
|
|
|
//查询是否存在默认看护
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean liftBind(String bindId, String doctorId) {
|
|
|
+ public boolean liftBind(String bindId, String doctorId,String assistId) {
|
|
|
+ if((StrUtil.isNotEmpty(doctorId)&&StrUtil.isNotEmpty(assistId))
|
|
|
+ ||((StrUtil.isEmpty(doctorId)&&StrUtil.isEmpty(assistId)))){
|
|
|
+ throw new CustomException("医生id和看护人员id不可同时为空或同时不为空");
|
|
|
+ }
|
|
|
boolean result = this
|
|
|
.update(new UpdateWrapper<AssistantUserBindEntity>()
|
|
|
.lambda()
|
|
|
.eq(AssistantUserBindEntity::getId, bindId)
|
|
|
- .eq(AssistantUserBindEntity::getDoctorId, doctorId)
|
|
|
- .set(AssistantUserBindEntity::getStatus, BindEnum.MANUAL_LIFTED));
|
|
|
+ .eq(StrUtil.isNotEmpty(doctorId),AssistantUserBindEntity::getDoctorId, doctorId)
|
|
|
+ .eq(StrUtil.isNotEmpty(assistId),AssistantUserBindEntity::getAssistId, assistId)
|
|
|
+ .set(AssistantUserBindEntity::getStatus,StrUtil.isEmpty(doctorId)? BindEnum.ASSIST_MANUAL_LIFTED: BindEnum.DOCTOR_MANUAL_LIFTED));
|
|
|
if (result) {
|
|
|
//todo 发送断开消息
|
|
|
}
|
|
|
@@ -193,6 +229,7 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
|
|
|
.lambda()
|
|
|
.eq(AssistantUserBindEntity::getTenantId,tenantId)
|
|
|
.eq(AssistantUserBindEntity::getPatientCode,patientCode)
|
|
|
+ .eq(AssistantUserBindEntity::getStatus,BindEnum.SUCCESS)
|
|
|
.last("limit 1"))!=null;
|
|
|
}
|
|
|
|
|
|
@@ -207,6 +244,22 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
|
|
|
return BeanUtil.copyToList(list(new QueryWrapper<AssistantUserBindEntity>()
|
|
|
.lambda()
|
|
|
.eq(AssistantUserBindEntity::getAssistId,assistId)
|
|
|
- .eq(AssistantUserBindEntity::getStatus,BindEnum.SUCCESS)),AssistPatientResult.class);
|
|
|
+ .eq(AssistantUserBindEntity::getStatus,BindEnum.SUCCESS)
|
|
|
+ .orderByDesc(AssistantUserBindEntity::getDefault_)
|
|
|
+ .orderByDesc(AssistantUserBindEntity::getCreateTime)),AssistPatientResult.class)
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean setDefault(String bindId, String assistId) {
|
|
|
+ this.update(new UpdateWrapper<AssistantUserBindEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(AssistantUserBindEntity::getAssistId,assistId)
|
|
|
+ .set(AssistantUserBindEntity::getDefault_,false));
|
|
|
+ this.update(new UpdateWrapper<AssistantUserBindEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(AssistantUserBindEntity::getId,bindId)
|
|
|
+ .set(AssistantUserBindEntity::getDefault_,true));
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|