|
|
@ -6,19 +6,25 @@ import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.IdcardUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.carbasics.bean.dto.FirstAidDto; |
|
|
|
import com.ccsens.carbasics.bean.dto.PatientDto; |
|
|
|
import com.ccsens.carbasics.bean.po.*; |
|
|
|
import com.ccsens.carbasics.bean.vo.FirstAidLogVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.FirstAidVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.OrganizationVo; |
|
|
|
import com.ccsens.carbasics.bean.vo.PatientVo; |
|
|
|
import com.ccsens.carbasics.persist.dao.FirstAidDao; |
|
|
|
import com.ccsens.carbasics.persist.dao.FirstAidLogDao; |
|
|
|
|
|
|
|
import com.ccsens.carbasics.persist.dao.FirstAidMemberDao; |
|
|
|
import com.ccsens.carbasics.persist.dao.OrganizationDao; |
|
|
|
import com.ccsens.carbasics.persist.dao.OrganizationMemberDao; |
|
|
|
import com.ccsens.carbasics.persist.mapper.*; |
|
|
|
import com.ccsens.carbasics.util.Constant; |
|
|
|
import com.ccsens.carbasics.util.DefaultCodeError; |
|
|
|
import com.ccsens.common.bean.dto.CProjectDto; |
|
|
|
import com.ccsens.common.bean.vo.CProjectVo; |
|
|
|
import com.ccsens.common.service.IProjectService; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
@ -54,6 +60,10 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
@Resource |
|
|
|
private FirstAidLogMapper firstAidLogMapper; |
|
|
|
@Resource |
|
|
|
private FirstAidMemberDao firstAidMemberDao; |
|
|
|
@Resource |
|
|
|
private IProjectService projectService; |
|
|
|
@Resource |
|
|
|
private OrganizationTemplateMapper templateMapper; |
|
|
|
@Resource |
|
|
|
private FirstAidRecordMapper firstAidRecordMapper; |
|
|
@ -316,4 +326,217 @@ public class FirstAidService implements IFirstAidService{ |
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public FirstAidVo.ProjectInfo joinFirstAid(FirstAidDto.JoinFirstAid param, Long userId) { |
|
|
|
//判断角色是否神内/神外医生
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
|
if(ObjectUtil.isNull(memberPosition)){ |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
//部门
|
|
|
|
Byte position = null; |
|
|
|
if (Constant.Department.SHEN_NEI.equals(memberPosition.getDepartmentCode()) || Constant.Department.SHEN_WAI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
if (Constant.Position.YI_SHENG.equals(memberPosition.getPositionCode())) { |
|
|
|
position = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
if (ObjectUtil.isNull(position)) { |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
|
|
|
|
//判断病例是否已有医生加入
|
|
|
|
FirstAidMember firstAidMember = firstAidMemberDao.findByAidId(param.getFirstAidId()); |
|
|
|
if (ObjectUtil.isNotNull(firstAidMember)) { |
|
|
|
throw new BaseException(DefaultCodeError.DOCTOR_HAS_JOINED); |
|
|
|
} |
|
|
|
|
|
|
|
//根据模板类型创建项目
|
|
|
|
|
|
|
|
FirstAid firstAidInfo = firstAidDao.selectByPrimaryKey(param.getFirstAidId()); |
|
|
|
CProjectVo.CopyProjectInfo copyProjectInfo = new CProjectVo.CopyProjectInfo(); |
|
|
|
//如果已有项目则不创建,使用旧项目
|
|
|
|
if (firstAidInfo.getType().equals(param.getType()) && ObjectUtil.isNotNull(firstAidInfo.getProjectId())) { |
|
|
|
copyProjectInfo.setId(firstAidInfo.getProjectId()); |
|
|
|
}else { |
|
|
|
CProjectDto.CopyProject copyProject = new CProjectDto.CopyProject(); |
|
|
|
if (0 == param.getType()){ |
|
|
|
//TODO 设置项目id为神内模板 和 项目名字
|
|
|
|
}else{ |
|
|
|
//TODO 设置项目id为神外模板 和 项目名字
|
|
|
|
} |
|
|
|
log.info("加入急救-开始创建项目{}",copyProject); |
|
|
|
copyProjectInfo = projectService.copyProject(copyProject, userId); |
|
|
|
log.info("加入急救-创建项目结束{}",copyProjectInfo); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//将医生添加为项目成员
|
|
|
|
CProjectDto.MemberForProject memberForProject = new CProjectDto.MemberForProject(); |
|
|
|
List<CProjectDto.MemberInfo> memberInfoList = new ArrayList<>(); |
|
|
|
CProjectDto.MemberInfo memberInfo = new CProjectDto.MemberInfo(); |
|
|
|
memberInfo.setUserId(userId); |
|
|
|
memberInfo.setMemberName(memberPosition.getName()); |
|
|
|
memberInfo.setPhone(memberPosition.getContact()); |
|
|
|
if (0 == param.getType()){ |
|
|
|
memberInfo.setRoleName(Constant.RoleName.SHEN_NEI); |
|
|
|
}else{ |
|
|
|
memberInfo.setRoleName(Constant.RoleName.SHEN_WAI); |
|
|
|
} |
|
|
|
memberInfoList.add(memberInfo); |
|
|
|
memberForProject.setProjectId(copyProjectInfo.getId()); |
|
|
|
memberForProject.setMemberInfoList(memberInfoList); |
|
|
|
log.info("加入急救-开始添加成员{}",memberForProject); |
|
|
|
projectService.addMemberForCopy(memberForProject,userId); |
|
|
|
log.info("加入急救-添加成员结束"); |
|
|
|
|
|
|
|
//添加医生为病例的录入者 t_qcp_first_aid_member
|
|
|
|
FirstAidMember newFirstAidMember = new FirstAidMember(); |
|
|
|
newFirstAidMember.setId(snowflake.nextId()); |
|
|
|
newFirstAidMember.setFirstAidId(param.getFirstAidId()); |
|
|
|
newFirstAidMember.setCreateUserId(userId); |
|
|
|
newFirstAidMember.setRecordUserId(userId); |
|
|
|
firstAidMemberDao.insertSelective(newFirstAidMember); |
|
|
|
|
|
|
|
//急救信息和项目关联
|
|
|
|
FirstAid firstAid = new FirstAid(); |
|
|
|
firstAid.setId(param.getFirstAidId()); |
|
|
|
firstAid.setProjectId(copyProjectInfo.getId()); |
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
|
|
|
|
//添加急救日志(类型:加入)
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
firstAidLog.setFirstAidId(param.getFirstAidId()); |
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
firstAidLog.setOperationType((byte)7); |
|
|
|
if (0 == param.getType()){ |
|
|
|
firstAidLog.setOperationRole((byte)1); |
|
|
|
}else{ |
|
|
|
firstAidLog.setOperationRole((byte)2); |
|
|
|
} |
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
//返回项目id
|
|
|
|
FirstAidVo.ProjectInfo projectInfo = new FirstAidVo.ProjectInfo(); |
|
|
|
projectInfo.setProjectId(copyProjectInfo.getId()); |
|
|
|
return projectInfo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void quitFirstAid(FirstAidDto.QuitFirstAid param, Long userId) { |
|
|
|
FirstAidMember byAidId = firstAidMemberDao.findByAidId(param.getFirstAidId()); |
|
|
|
if (ObjectUtil.isNull(byAidId)) { |
|
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
|
} |
|
|
|
if (!userId.equals(byAidId.getRecordUserId())) { |
|
|
|
throw new BaseException(DefaultCodeError.REPEAT_QUIT); |
|
|
|
} |
|
|
|
|
|
|
|
//添加急救日志(退出)
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
firstAidLog.setFirstAidId(param.getFirstAidId()); |
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
firstAidLog.setOperationType((byte)8); |
|
|
|
//判断角色是否神内/神外医生
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
|
if (Constant.Department.SHEN_NEI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
if (Constant.Position.YI_SHENG.equals(memberPosition.getPositionCode())) { |
|
|
|
firstAidLog.setOperationRole((byte)1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (Constant.Department.SHEN_WAI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
if (Constant.Position.YI_SHENG.equals(memberPosition.getPositionCode())) { |
|
|
|
firstAidLog.setOperationRole((byte)2); |
|
|
|
} |
|
|
|
} |
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
//修改录入者userId为0
|
|
|
|
byAidId.setRecordUserId(0L); |
|
|
|
firstAidMemberDao.updateByPrimaryKeySelective(byAidId); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateStatus(FirstAidDto.UpdateStatus param, Long userId) { |
|
|
|
//修改病例状态
|
|
|
|
FirstAid firstAid = firstAidDao.selectByPrimaryKey(param.getFirstAidId()); |
|
|
|
if (ObjectUtil.isNull(firstAid)) { |
|
|
|
throw new BaseException(DefaultCodeError.NOT_FIRST_AID_ID); |
|
|
|
} |
|
|
|
//判断权限
|
|
|
|
OrganizationVo.MemberPosition memberPosition = organizationMemberDao.getMemberPosition(userId); |
|
|
|
log.info("当前用户的科室职位信息:{}",memberPosition); |
|
|
|
if (!Constant.Position.ZHI_KONG.equals(memberPosition.getPositionCode())) { |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
if (0 == firstAid.getType()) { |
|
|
|
if (!Constant.Department.SHEN_NEI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
} |
|
|
|
if (1 == firstAid.getType()) { |
|
|
|
if (!Constant.Department.SHEN_WAI.equals(memberPosition.getDepartmentCode())) { |
|
|
|
throw new BaseException(DefaultCodeError.NO_POWER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
switch (param.getDataStatus()) { |
|
|
|
case 1: |
|
|
|
if (0 != firstAid.getDataStatus() && 2 != firstAid.getDataStatus() && 4 != firstAid.getDataStatus()) { |
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
if (0 != firstAid.getDataStatus()) { |
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
if (0 != firstAid.getDataStatus() && 1 != firstAid.getDataStatus() && 2 != firstAid.getDataStatus() && 4 != firstAid.getDataStatus()) { |
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
if (0 != firstAid.getDataStatus() && 1 != firstAid.getDataStatus() && 2 != firstAid.getDataStatus()) { |
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
if (1 != firstAid.getDataStatus() && 3 != firstAid.getDataStatus() && 6 != firstAid.getDataStatus()) { |
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
} |
|
|
|
Integer updateNumber = firstAidLogDao.countUpdateNumber(param.getFirstAidId()); |
|
|
|
if (updateNumber >= Constant.MAX_UPDATE_NUMBER) { |
|
|
|
throw new BaseException(DefaultCodeError.SURPASS_MAX_NUMBER); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new BaseException(DefaultCodeError.DATA_STATUS_ERROR); |
|
|
|
} |
|
|
|
firstAid.setDataStatus(param.getDataStatus()); |
|
|
|
firstAidDao.updateByPrimaryKeySelective(firstAid); |
|
|
|
//添加日志
|
|
|
|
FirstAidLog firstAidLog = new FirstAidLog(); |
|
|
|
firstAidLog.setId(snowflake.nextId()); |
|
|
|
firstAidLog.setFirstAidId(param.getFirstAidId()); |
|
|
|
firstAidLog.setOperationTime(System.currentTimeMillis()); |
|
|
|
firstAidLog.setOperationUserId(userId); |
|
|
|
if (1 == param.getDataStatus() || 3 == param.getDataStatus()){ |
|
|
|
firstAidLog.setOperationType((byte)1); |
|
|
|
} |
|
|
|
if (2 == param.getDataStatus() || 4 == param.getDataStatus()){ |
|
|
|
firstAidLog.setOperationType((byte)2); |
|
|
|
} |
|
|
|
if (5 == param.getDataStatus()){ |
|
|
|
firstAidLog.setOperationType((byte)3); |
|
|
|
} |
|
|
|
firstAidLog.setOperationRole((byte)3); |
|
|
|
firstAidLogDao.insertSelective(firstAidLog); |
|
|
|
} |
|
|
|
} |
|
|
|