Merge remote-tracking branch 'origin/0424_数据权限' into 0418_小程序开发

This commit is contained in:
haown 2024-04-29 15:19:49 +08:00
commit 1d26f3c421
23 changed files with 173 additions and 161 deletions

View File

@ -62,7 +62,6 @@ public class SysUserController extends BaseController {
* 获取用户列表
*/
@ApiOperation("获取用户列表")
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/getList")
public R<List<SysUser>> getList(SysUser user) {
List<SysUser> list = userService.selectUserList(user);

View File

@ -11,6 +11,10 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataScope {
/**
* 机构表别名
*/
public String anencyAlias() default "";
/**
* 部门表的别名
*/

View File

@ -142,7 +142,7 @@ public class SysUser extends BaseEntity {
/**
* 机构id
*/
private Long agencyId;
private Long hospitalAgencyId;
/**
* 机构id
@ -170,15 +170,15 @@ public class SysUser extends BaseEntity {
this.userId = userId;
}
public Long getAgencyId() {
return agencyId;
}
public Long getHospitalAgencyId() {
return hospitalAgencyId;
}
public void setAgencyId(Long agencyId) {
this.agencyId = agencyId;
}
public void setHospitalAgencyId(Long hospitalAgencyId) {
this.hospitalAgencyId = hospitalAgencyId;
}
public Long getDepartmentId() {
public Long getDepartmentId() {
return departmentId;
}

View File

@ -45,6 +45,11 @@ public class DataScopeAspect {
*/
public static final String DATA_SCOPE_SELF = "5";
/**
* 机构数据权限
*/
public static final String DATA_SCOPE_AGENCY = "6";
/**
* 数据权限过滤关键字
*/
@ -63,7 +68,7 @@ public class DataScopeAspect {
SysUser currentUser = loginUser.getUser();
// 如果是超级管理员则不过滤数据
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
dataScopeFilter(joinPoint, currentUser, controllerDataScope.anencyAlias(), controllerDataScope.deptAlias(),
controllerDataScope.userAlias());
}
}
@ -76,7 +81,7 @@ public class DataScopeAspect {
* @param user 用户
* @param userAlias 别名
*/
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) {
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String anencyAlias, String deptAlias, String userAlias) {
StringBuilder sqlString = new StringBuilder();
for (SysRole role : user.getRoles()) {
@ -84,23 +89,14 @@ public class DataScopeAspect {
if (DATA_SCOPE_ALL.equals(dataScope)) {
sqlString = new StringBuilder();
break;
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { // 自定数据权限
sqlString.append(StringUtils.format(
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
" OR {}.department_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
role.getRoleId()));
} else if (DATA_SCOPE_DEPT.equals(dataScope)) {
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
sqlString.append(StringUtils.format(
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
deptAlias, user.getDeptId(), user.getDeptId()));
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
if (StringUtils.isNotBlank(userAlias)) {
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
} else {
// 数据权限为仅本人且没有userAlias别名不查询任何数据
sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
}
} else if(DATA_SCOPE_AGENCY.equals(dataScope)){ // 机构数据权限
sqlString.append(StringUtils.format(" OR {}.hospital_agency_id = {} ", anencyAlias, user.getHospitalAgencyId()));
} else if (DATA_SCOPE_DEPT.equals(dataScope)) { // 部门数据权限
sqlString.append(StringUtils.format(" OR {}.department_id = {} ", deptAlias, user.getDepartmentId()));
}
}

View File

@ -45,7 +45,6 @@ public class PatientInfoController extends BaseController {
@PreAuthorize("@ss.hasPermi('manage:patientInfo:list')")
@GetMapping("/list")
public TableDataInfo list(PatientInfoDto patientInfo) {
// 根据用户权限判断查询数据权限
startPage();
List<PatientInfo> list = patientInfoService.selectPatientInfoList(patientInfo);
return getDataTable(list);

View File

@ -45,14 +45,14 @@ public class Department extends BaseEntity {
*/
@ApiModelProperty(value = "所属机构id")
@Excel(name = "所属机构id")
private Long agencyId;
private Long hospitalAgencyId;
/**
* 所属机构名称
*/
@ApiModelProperty(value = "所属机构名称")
@Excel(name = "所属机构名称")
private String agencyName;
private String hospitalAgencyName;
/**
* 科室名称
@ -179,8 +179,8 @@ public class Department extends BaseEntity {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("parentDepartmentId", getParentDepartmentId())
.append("agencyId", getAgencyId())
.append("agencyName", getAgencyName())
.append("hospitalAgencyId", getHospitalAgencyId())
.append("hospitalAgencyName", getHospitalAgencyName())
.append("departmentName", getDepartmentName())
.append("departmentCode", getDepartmentCode())
.append("departmentType", getDepartmentType())

View File

@ -1,5 +1,6 @@
package com.xinelu.manage.dto.patientblacklist;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -9,7 +10,7 @@ import lombok.Data;
* @create: 2024-02-28 13:15
**/
@Data
public class PatientBlacklistDto {
public class PatientBlacklistDto extends BaseEntity {
/** 患者id */
private Long patientId;

View File

@ -1,5 +1,6 @@
package com.xinelu.manage.dto.patientinfo;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDate;
@ -13,7 +14,7 @@ import org.springframework.format.annotation.DateTimeFormat;
**/
@ApiModel("患者列表查询传输对象")
@Data
public class PatientInfoDto {
public class PatientInfoDto extends BaseEntity {
@ApiModelProperty("居民信息表主键")
private Long residentId;

View File

@ -18,7 +18,7 @@ public interface PatientBlacklistMapper {
* @param id 患者-黑明单关系主键
* @return 患者-黑明单关系
*/
public PatientBlacklistVo selectPatientBlacklistById(Long id);
PatientBlacklistVo selectPatientBlacklistById(Long id);
/**
* 查询患者-黑明单关系列表
@ -26,7 +26,7 @@ public interface PatientBlacklistMapper {
* @param patientBlacklist 患者-黑明单关系
* @return 患者-黑明单关系集合
*/
public List<PatientBlacklistVo> selectPatientBlacklistList(PatientBlacklistDto patientBlacklist);
List<PatientBlacklistVo> selectPatientBlacklistList(PatientBlacklistDto patientBlacklist);
/**
* 新增患者-黑明单关系
@ -34,7 +34,7 @@ public interface PatientBlacklistMapper {
* @param patientBlacklist 患者-黑明单关系
* @return 结果
*/
public int insertPatientBlacklist(PatientBlacklist patientBlacklist);
int insertPatientBlacklist(PatientBlacklist patientBlacklist);
/**
* 修改患者-黑明单关系
@ -42,7 +42,7 @@ public interface PatientBlacklistMapper {
* @param patientBlacklist 患者-黑明单关系
* @return 结果
*/
public int updatePatientBlacklist(PatientBlacklist patientBlacklist);
int updatePatientBlacklist(PatientBlacklist patientBlacklist);
/**
* 删除患者-黑明单关系
@ -50,7 +50,7 @@ public interface PatientBlacklistMapper {
* @param id 患者-黑明单关系主键
* @return 结果
*/
public int deletePatientBlacklistById(Long id);
int deletePatientBlacklistById(Long id);
/**
* 批量删除患者-黑明单关系
@ -58,5 +58,5 @@ public interface PatientBlacklistMapper {
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePatientBlacklistByIds(Long[] ids);
int deletePatientBlacklistByIds(Long[] ids);
}

View File

@ -247,7 +247,7 @@ public class AgencyServiceImpl implements IAgencyService {
hospitalVO.setCampusList(campusList);
Department department = new Department();
department.setNodeType(NodeTypeEnum.DEPARTMENT.getInfo());
department.setAgencyId(hospitalDTO.getHospitalId());
department.setHospitalAgencyId(hospitalDTO.getHospitalId());
List<Department> departmentList = departmentMapper.selectDepartmentList(department);
hospitalVO.setDepartmentList(departmentList);
department.setNodeType(NodeTypeEnum.WARD.getInfo());
@ -258,7 +258,7 @@ public class AgencyServiceImpl implements IAgencyService {
if (StringUtils.isNotBlank(hospitalDTO.getNodeType()) && NodeTypeEnum.CAMPUS.getInfo().equals(hospitalDTO.getNodeType()) && Objects.nonNull(hospitalDTO.getCampusId())) {
Department department = new Department();
department.setNodeType(NodeTypeEnum.DEPARTMENT.getInfo());
department.setAgencyId(hospitalDTO.getCampusId());
department.setHospitalAgencyId(hospitalDTO.getCampusId());
List<Department> departmentList = departmentMapper.selectDepartmentList(department);
hospitalVO.setDepartmentList(departmentList);
department.setNodeType(NodeTypeEnum.WARD.getInfo());

View File

@ -77,9 +77,9 @@ public class DepartmentServiceImpl implements IDepartmentService {
public AjaxResult selectUserDepartment() {
SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId());
List<Department> departments = new ArrayList<>();
if (Objects.nonNull(sysUser) && Objects.nonNull(sysUser.getAgencyId())) {
if (Objects.nonNull(sysUser) && Objects.nonNull(sysUser.getHospitalAgencyId())) {
Department department = new Department();
department.setAgencyId(sysUser.getAgencyId());
department.setHospitalAgencyId(sysUser.getHospitalAgencyId());
departments = departmentMapper.selectDepartmentList(department);
}
return AjaxResult.success(departments);
@ -93,7 +93,7 @@ public class DepartmentServiceImpl implements IDepartmentService {
*/
@Override
public AjaxResult selectDepartmentByAgencyIdList(Department department) {
if (Objects.isNull(department) || (Objects.isNull(department.getAgencyId()) && Objects.isNull(department.getParentDepartmentId()))) {
if (Objects.isNull(department) || (Objects.isNull(department.getHospitalAgencyId()) && Objects.isNull(department.getParentDepartmentId()))) {
return AjaxResult.success();
}
return AjaxResult.success(departmentMapper.selectDepartmentList(department));

View File

@ -1,5 +1,6 @@
package com.xinelu.manage.service.patientblacklist.impl;
import com.xinelu.common.annotation.DataScope;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.manage.domain.patientblacklist.PatientBlacklist;
@ -49,6 +50,7 @@ public class PatientBlacklistServiceImpl implements IPatientBlacklistService {
* @return 患者-黑明单关系
*/
@Override
@DataScope(anencyAlias = "b")
public List<PatientBlacklistVo> selectPatientBlacklistList(PatientBlacklistDto patientBlacklist) {
return patientBlacklistMapper.selectPatientBlacklistList(patientBlacklist);
}

View File

@ -1,5 +1,6 @@
package com.xinelu.manage.service.patientinfo.impl;
import com.xinelu.common.annotation.DataScope;
import com.xinelu.common.constant.SignRecordServiceStatusConstants;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.BaseUtil;
@ -62,6 +63,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
* @return 患者信息
*/
@Override
@DataScope(anencyAlias = "p")
public List<PatientInfo> selectPatientInfoList(PatientInfoDto patientInfo) {
return patientInfoMapper.selectPatientInfoList(patientInfo);
}

View File

@ -1,5 +1,6 @@
package com.xinelu.manage.service.patientprehospitalization.impl;
import com.xinelu.common.annotation.DataScope;
import com.xinelu.common.constant.NodeTypeConstants;
import com.xinelu.common.constant.PatientTypeConstants;
import com.xinelu.common.core.domain.AjaxResult;
@ -110,6 +111,7 @@ public class PatientPreHospitalizationServiceImpl implements IPatientPreHospital
}
@Override
@DataScope(anencyAlias = "p")
public List<PatientPreHospitalization> selectList(PatientInfoDto patientInfo) {
return preHospitalizationMapper.selectList(patientInfo);
}
@ -166,7 +168,7 @@ public class PatientPreHospitalizationServiceImpl implements IPatientPreHospital
if (CollectionUtils.isEmpty(patientList)) {
return AjaxResult.error("请添加预住院患者导入信息!");
}
if (SecurityUtils.getLoginUser().getUser().getAgencyId() == null) {
if (SecurityUtils.getLoginUser().getUser().getHospitalAgencyId() == null) {
return AjaxResult.error("您未设置机构信息,导入失败");
}
// 根据患者身份证号做去重处理
@ -181,8 +183,8 @@ public class PatientPreHospitalizationServiceImpl implements IPatientPreHospital
PatientPreHospitalization preHospitalization = new PatientPreHospitalization();
BeanUtils.copyProperties(item, preHospitalization);
// 设置机构/院区为当前登录用户机构信息
preHospitalization.setHospitalAgencyId(SecurityUtils.getLoginUser().getUser().getAgencyId());
Agency agencyData = agencyMapper.selectAgencyById(SecurityUtils.getLoginUser().getUser().getAgencyId());
preHospitalization.setHospitalAgencyId(SecurityUtils.getLoginUser().getUser().getHospitalAgencyId());
Agency agencyData = agencyMapper.selectAgencyById(SecurityUtils.getLoginUser().getUser().getHospitalAgencyId());
if (ObjectUtils.isNotEmpty(agencyData)) {
if (StringUtils.equals(NodeTypeConstants.HOSPITAL, agencyData.getNodeType())) { // 节点类型为机构
preHospitalization.setHospitalAgencyName(agencyData.getAgencyName());
@ -199,7 +201,7 @@ public class PatientPreHospitalizationServiceImpl implements IPatientPreHospital
// 查询科室id
Department department = new Department();
if (StringUtils.isNotBlank(item.getDepartmentName())) {
department.setAgencyName(preHospitalization.getHospitalAgencyName());
department.setHospitalAgencyName(preHospitalization.getHospitalAgencyName());
department.setDepartmentName(item.getDepartmentName());
department.setNodeType(NodeTypeConstants.DEPARTMENT);
List<Department> deptList = departmentMapper.selectDepartmentList(department);
@ -209,7 +211,7 @@ public class PatientPreHospitalizationServiceImpl implements IPatientPreHospital
}
// 查询病区
if (StringUtils.isNotBlank(item.getWardName())) {
department.setAgencyName(item.getHospitalAgencyName());
department.setHospitalAgencyName(item.getHospitalAgencyName());
department.setDepartmentName(item.getWardName());
department.setNodeType(NodeTypeConstants.WARD);
List<Department> deptList = departmentMapper.selectDepartmentList(department);

View File

@ -339,8 +339,8 @@ public class PatientVisitRecordServiceImpl implements IPatientVisitRecordService
patientVisitRecord.setHospitalAgencyId(agencyList.get(0).getId());
}
} else {
patientVisitRecord.setHospitalAgencyId(SecurityUtils.getLoginUser().getUser().getAgencyId());
Agency agencyData = agencyMapper.selectAgencyById(SecurityUtils.getLoginUser().getUser().getAgencyId());
patientVisitRecord.setHospitalAgencyId(SecurityUtils.getLoginUser().getUser().getHospitalAgencyId());
Agency agencyData = agencyMapper.selectAgencyById(SecurityUtils.getLoginUser().getUser().getHospitalAgencyId());
if (ObjectUtils.isNotEmpty(agencyData)) {
patientVisitRecord.setHospitalAgencyName(agencyData.getAgencyName());
}
@ -358,7 +358,7 @@ public class PatientVisitRecordServiceImpl implements IPatientVisitRecordService
// 查询科室id
Department department = new Department();
if (StringUtils.isNotBlank(item.getDepartmentName())) {
department.setAgencyName(item.getHospitalAgencyName());
department.setHospitalAgencyName(item.getHospitalAgencyName());
department.setDepartmentName(item.getDepartmentName());
department.setNodeType(NodeTypeConstants.DEPARTMENT);
List<Department> deptList = departmentMapper.selectDepartmentList(department);
@ -374,7 +374,7 @@ public class PatientVisitRecordServiceImpl implements IPatientVisitRecordService
}
// 查询病区
if (StringUtils.isNotBlank(item.getWardName())) {
department.setAgencyName(item.getHospitalAgencyName());
department.setHospitalAgencyName(item.getHospitalAgencyName());
department.setDepartmentName(item.getWardName());
department.setNodeType(NodeTypeConstants.WARD);
List<Department> deptList = departmentMapper.selectDepartmentList(department);

View File

@ -7,8 +7,8 @@
<resultMap type="Department" id="DepartmentResult">
<result property="id" column="id"/>
<result property="parentDepartmentId" column="parent_department_id"/>
<result property="agencyId" column="agency_id"/>
<result property="agencyName" column="agency_name"/>
<result property="hospitalAgencyId" column="hospital_agency_id"/>
<result property="hospitalAgencyName" column="hospital_agency_name"/>
<result property="departmentName" column="department_name"/>
<result property="departmentCode" column="department_code"/>
<result property="departmentType" column="department_type"/>
@ -35,8 +35,8 @@
<sql id="selectDepartmentVo">
select id,
parent_department_id,
agency_id,
agency_name,
hospital_agency_id,
hospital_agency_name,
department_name,
department_code,
department_type,
@ -67,11 +67,11 @@
<if test="parentDepartmentId != null ">
and parent_department_id =#{parentDepartmentId}
</if>
<if test="agencyId != null ">
and agency_id =#{agencyId}
<if test="hospitalAgencyId != null ">
and hospital_agency_id =#{hospitalAgencyId}
</if>
<if test="agencyName != null and agencyName != ''">
and agency_name like concat('%',#{agencyName},'%')
<if test="hospitalAgencyName != null and hospitalAgencyName != ''">
and hospital_agency_name like concat('%',#{hospitalAgencyName},'%')
</if>
<if test="departmentName != null and departmentName != ''">
and department_name like concat('%',#{departmentName},'%')
@ -136,8 +136,8 @@
<select id="selectDepartment" resultType="com.xinelu.manage.vo.department.DepartmentListVO">
select id,
dt.parent_department_id,
agency_id,
agency_name,
hospital_agency_id,
hospital_agency_name,
department_name,
department_code,
department_type,
@ -255,8 +255,8 @@
<select id="getAllDepartmentInfo" resultType="com.xinelu.manage.domain.department.Department">
select id,
parent_department_id,
agency_id,
agency_name,
hospital_agency_id,
hospital_agency_name,
department_name,
department_code,
department_type,
@ -311,9 +311,9 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentDepartmentId != null">parent_department_id,
</if>
<if test="agencyId != null">agency_id,
<if test="hospitalAgencyId != null">hospital_agency_id,
</if>
<if test="agencyName != null">agency_name,
<if test="hospitalAgencyName != null">hospital_agency_name,
</if>
<if test="departmentName != null">department_name,
</if>
@ -361,9 +361,9 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentDepartmentId != null">#{parentDepartmentId},
</if>
<if test="agencyId != null">#{agencyId},
<if test="hospitalAgencyId != null">#{hospitalAgencyId},
</if>
<if test="agencyName != null">#{agencyName},
<if test="hospitalAgencyName != null">#{hospitalAgencyName},
</if>
<if test="departmentName != null">#{departmentName},
</if>
@ -413,8 +413,8 @@
<insert id="insertDepartmentList">
insert into department(
parent_department_id,
agency_id,
agency_name,
hospital_agency_id,
hospital_agency_name,
department_name,
department_code,
department_type,
@ -438,8 +438,8 @@
<foreach item="Department" index="index" collection="list" separator=",">
(
#{Department.parentDepartmentId},
#{Department.agencyId},
#{Department.agencyName},
#{Department.hospitalAgencyId},
#{Department.hospitalAgencyName},
#{Department.departmentName},
#{Department.departmentCode},
#{Department.departmentType},
@ -469,11 +469,11 @@
<if test="parentDepartmentId != null">parent_department_id =
#{parentDepartmentId},
</if>
<if test="agencyId != null">agency_id =
#{agencyId},
<if test="hospitalAgencyId != null">hospital_agency_id =
#{hospitalAgencyId},
</if>
<if test="agencyName != null">agency_name =
#{agencyName},
<if test="hospitalAgencyName != null">hospital_agency_name =
#{hospitalAgencyName},
</if>
<if test="departmentName != null">department_name =
#{departmentName},
@ -546,8 +546,8 @@
update department
<trim prefix="SET" suffixOverrides=",">
parent_department_id = #{parentDepartmentId},
agency_id = #{agencyId},
agency_name = #{agencyName},
hospital_agency_id = #{hospitalAgencyId},
hospital_agency_name = #{hospitalAgencyName},
<if test="departmentName != null">department_name = #{departmentName},</if>
department_code =#{departmentCode},
department_type =#{departmentType},

View File

@ -62,6 +62,8 @@
<if test="blacklistSource != null and blacklistSource != ''">
and b.blacklist_source = #{blacklistSource}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</where>
</select>

View File

@ -53,116 +53,118 @@
</resultMap>
<sql id="selectPatientInfoVo">
select id,resident_id,
patient_name,
patient_phone,
family_member_phone,
birth_date,
card_no,
sex,
address,
patient_type,
sign_status,sign_patient_record_id,service_status,
sign_time,
visit_method, attending_physician_id, attending_physician_name, main_diagnosis,
hospital_agency_id, hospital_agency_name, campus_agency_id, campus_agency_name, department_id, department_name, ward_id, ward_name,
responsible_nurse, patient_visit_record_id, visit_serial_number,
admission_time, patient_pre_hospitalization_id, discharge_time, patient_pre_hospitalization_id, appointment_treatment_group,
registration_no, registration_date, appointment_date, in_hospital_number, visit_date, discharge_method,
patient_source, surgical_name, del_flag, create_by, create_time, update_by, update_time
from patient_info
select p.id,p.resident_id,
p.patient_name,
p.patient_phone,
p.family_member_phone,
p.birth_date,
p.card_no,
p.sex,
p.address,
p.patient_type,
p.sign_status,p.sign_patient_record_id,p.service_status,
p.sign_time,
p.visit_method, p.attending_physician_id, p.attending_physician_name, p.main_diagnosis,
p.hospital_agency_id, p.hospital_agency_name, p.campus_agency_id, p.campus_agency_name, p.department_id, p.department_name, p.ward_id, p.ward_name,
p.responsible_nurse, p.patient_visit_record_id, p.visit_serial_number,
p.admission_time, p.patient_pre_hospitalization_id, p.discharge_time, p.patient_pre_hospitalization_id, p.appointment_treatment_group,
p.registration_no, p.registration_date, p.appointment_date, p.in_hospital_number, p.visit_date, p.discharge_method,
p.patient_source, p.surgical_name, p.del_flag, p.create_by, p.create_time, p.update_by, p.update_time
from patient_info p
</sql>
<select id="selectPatientInfoList" parameterType="com.xinelu.manage.dto.patientinfo.PatientInfoDto"
resultMap="PatientInfoResult">
<include refid="selectPatientInfoVo"/>
<where>
del_flag = 0
p.del_flag = 0
<if test="residentId != null">
and resident_id = #{residentId}
and p.resident_id = #{residentId}
</if>
<if test="patientName != null and patientName != ''">
and patient_name = #{patientName}
and p.patient_name = #{patientName}
</if>
<if test="patientPhone != null and patientPhone != ''">
and patient_phone like concat('%', #{patientPhone}, '%')
and p.patient_phone like concat('%', #{patientPhone}, '%')
</if>
<if test="cardNo != null and cardNo != ''">
and card_no = #{cardNo}
and p.card_no = #{cardNo}
</if>
<if test="patientType != null and patientType != ''">
<choose>
<when test="patientType == 'OUTPATIENT_DISCHARGE'.toString()">
and (patient_type = 'OUTPATIENT' or patient_type = 'DISCHARGED_PATIENT')
and (p.patient_type = 'OUTPATIENT' or p.patient_type = 'DISCHARGED_PATIENT')
</when>
<otherwise>
and patient_type = #{patientType}
and p.patient_type = #{patientType}
</otherwise>
</choose>
</if>
<if test="attendingPhysicianId != null">
and attending_physician_id = #{attendingPhysicianId}
and p.attending_physician_id = #{attendingPhysicianId}
</if>
<if test="mainDiagnosis != null and mainDiagnosis != ''">
and main_diagnosis like concat('%', #{mainDiagnosis}, '%')
and p.main_diagnosis like concat('%', #{mainDiagnosis}, '%')
</if>
<if test="hospitalAgencyId != null ">
and hospital_agency_id = #{hospitalAgencyId}
and p.hospital_agency_id = #{hospitalAgencyId}
</if>
<if test="campusAgencyId != null ">
and campus_agency_id = #{campusAgencyId}
and p.campus_agency_id = #{campusAgencyId}
</if>
<if test="departmentId != null ">
and department_id = #{departmentId}
and p.department_id = #{departmentId}
</if>
<if test="wardId != null ">
and ward_id = #{wardId}
and p.ward_id = #{wardId}
</if>
<if test="visitMethod != null and visitMethod != ''">
and visit_method = #{visitMethod}
and p.visit_method = #{visitMethod}
</if>
<if test="visitDateStart != null ">
and date_format(visit_date, '%y%m%d') >= date_format(#{visitDateStart}, '%y%m%d')
and date_format(p.visit_date, '%y%m%d') >= date_format(#{visitDateStart}, '%y%m%d')
</if>
<if test="visitDateEnd != null ">
and date_format(visit_date, '%y%m%d') &lt;= date_format(#{visitDateEnd}, '%y%m%d')
and date_format(p.visit_date, '%y%m%d') &lt;= date_format(#{visitDateEnd}, '%y%m%d')
</if>
<if test="admissionTimeStart != null ">
and date_format(admission_time,'%y%m%d') >= date_format(#{admissionTimeStart}, '%y%m%d')
and date_format(p.admission_time,'%y%m%d') >= date_format(#{admissionTimeStart}, '%y%m%d')
</if>
<if test="admissionTimeEnd != null ">
and date_format(admission_time,'%y%m%d') &lt;= date_format(#{admissionTimeEnd}, '%y%m%d')
and date_format(p.admission_time,'%y%m%d') &lt;= date_format(#{admissionTimeEnd}, '%y%m%d')
</if>
<if test="dischargeTimeStart != null ">
and date_format(discharge_time,'%y%m%d') >= date_format(#{dischargeTimeStart}, '%y%m%d')
and date_format(p.discharge_time,'%y%m%d') >= date_format(#{dischargeTimeStart}, '%y%m%d')
</if>
<if test="dischargeTimeEnd != null ">
and date_format(discharge_time,'%y%m%d') &lt;= date_format(#{dischargeTimeEnd}, '%y%m%d')
and date_format(p.discharge_time,'%y%m%d') &lt;= date_format(#{dischargeTimeEnd}, '%y%m%d')
</if>
<if test="appointmentDateStart != null ">
and date_format(appointment_date, '%y%m%d') >= date_format(#{appointmentDateStart}, '%y%m%d')
and date_format(p.appointment_date, '%y%m%d') >= date_format(#{appointmentDateStart}, '%y%m%d')
</if>
<if test="appointmentDateEnd != null ">
and date_format(appointment_date, '%y%m%d') &lt;= date_format(#{appointmentDateEnd}, '%y%m%d')
and date_format(p.appointment_date, '%y%m%d') &lt;= date_format(#{appointmentDateEnd}, '%y%m%d')
</if>
<if test="appointmentTreatmentGroup != null and appointmentTreatmentGroup != ''">
and appointment_treatment_group = #{appointmentTreatmentGroup}
and p.appointment_treatment_group = #{appointmentTreatmentGroup}
</if>
<if test="registrationNo != null and registrationNo != ''">
and registration_no = #{registrationNo}
and p.registration_no = #{registrationNo}
</if>
<if test="visitSerialNumber != null and visitSerialNumber != ''">
and visit_serial_number = #{visitSerialNumber}
and p.visit_serial_number = #{visitSerialNumber}
</if>
<if test="responsibleNurse != null and responsibleNurse != ''">
and responsible_nurse = #{responsibleNurse}
and p.responsible_nurse = #{responsibleNurse}
</if>
<if test="patientSource != null and patientSource != ''">
and patient_source = #{patientSource}
and p.patient_source = #{patientSource}
</if>
<if test="surgicalName != null and surgicalName != ''">
and surgical_name = #{surgicalName}
and p.surgical_name = #{surgicalName}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</where>
</select>

View File

@ -338,6 +338,8 @@
<if test="registrationNo != null and registrationNo != ''">
and p.registration_no = #{registrationNo}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</where>
order by p.appointment_date
</select>

View File

@ -14,7 +14,7 @@ public class AgencyNameVO {
/**
* 主键id
*/
private Long agencyId;
private Long hospitalAgencyId;
/**
* 机构名称

View File

@ -146,28 +146,28 @@ public interface SysUserMapper {
* 剩余机构信息
*
* @param agencyName 机构搜索信息
* @param agencyId 机构id
* @param hospitalAgencyId 机构id
* @return AgencyNameVO
*/
List<AgencyNameVO> selectAgencyList(@Param("agencyName") String agencyName, @Param("agencyId") Long agencyId);
List<AgencyNameVO> selectAgencyList(@Param("agencyName") String agencyName, @Param("hospitalAgencyId") Long hospitalAgencyId);
/**
* 机构查询
*
* @param agencyId 机构id
* @param hospitalAgencyId 机构id
* @return
*/
List<AgencyNameVO> selectBelongAgencyList(Long agencyId);
List<AgencyNameVO> selectBelongAgencyList(Long hospitalAgencyId);
/**
* 剩余科室信息
*
* @param departmentName 科室搜索条件
* @param departmentId 科室id
* @param agencyId 机构id
* @param hospitalAgencyId 机构id
* @return AgencyNameVO
*/
List<AgencyNameVO> selectDepartmentList(@Param("departmentName") String departmentName, @Param("departmentId") Long departmentId, @Param("agencyId") Long agencyId);
List<AgencyNameVO> selectDepartmentList(@Param("departmentName") String departmentName, @Param("departmentId") Long departmentId, @Param("hospitalAgencyId") Long hospitalAgencyId);
/**
* 科室信息

View File

@ -71,7 +71,7 @@ public class SysUserServiceImpl implements ISysUserService {
* @return 用户信息集合信息
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
@DataScope(deptAlias = "d", userAlias = "u", anencyAlias = "u")
public List<SysUser> selectUserList(SysUser user) {
return userMapper.selectUserList(user);
}
@ -508,7 +508,7 @@ public class SysUserServiceImpl implements ISysUserService {
public TableDataInfo selectUserAgency(String userName, String agencyName) {
SysUser sysUser = userMapper.selectUserByUserName(userName);
pageServiceUtil.startPage();
List<AgencyNameVO> agencyList = userMapper.selectAgencyList(agencyName, sysUser.getAgencyId());
List<AgencyNameVO> agencyList = userMapper.selectAgencyList(agencyName, sysUser.getHospitalAgencyId());
if (CollectionUtils.isNotEmpty(agencyList)) {
return pageServiceUtil.getDataTable(agencyList);
}
@ -524,8 +524,8 @@ public class SysUserServiceImpl implements ISysUserService {
@Override
public List<AgencyNameVO> selectUserBelongAgency(String userName) {
SysUser sysUser = userMapper.selectUserByUserName(userName);
if (Objects.nonNull(sysUser) && Objects.nonNull(sysUser.getAgencyId())) {
return userMapper.selectBelongAgencyList(sysUser.getAgencyId());
if (Objects.nonNull(sysUser) && Objects.nonNull(sysUser.getHospitalAgencyId())) {
return userMapper.selectBelongAgencyList(sysUser.getHospitalAgencyId());
}
return new ArrayList<AgencyNameVO>();
}
@ -539,11 +539,11 @@ public class SysUserServiceImpl implements ISysUserService {
@Override
public TableDataInfo selectUserDepartment(String userName, String departmentName) {
SysUser sysUser = userMapper.selectUserByUserName(userName);
if (Objects.isNull(sysUser) || Objects.isNull(sysUser.getAgencyId())) {
if (Objects.isNull(sysUser) || Objects.isNull(sysUser.getHospitalAgencyId())) {
return pageServiceUtil.getDataTable(new ArrayList<>());
}
pageServiceUtil.startPage();
List<AgencyNameVO> agencyList = userMapper.selectDepartmentList(departmentName, sysUser.getDepartmentId(), sysUser.getAgencyId());
List<AgencyNameVO> agencyList = userMapper.selectDepartmentList(departmentName, sysUser.getDepartmentId(), sysUser.getHospitalAgencyId());
if (CollectionUtils.isNotEmpty(agencyList)) {
return pageServiceUtil.getDataTable(agencyList);
}

View File

@ -25,7 +25,7 @@
<result property="remark" column="remark"/>
<result property="userCardNo" column="user_card_no"/>
<result property="userBirthDate" column="user_birth_date"/>
<result property="agencyId" column="agency_id"/>
<result property="hospitalAgencyId" column="hospital_agency_id"/>
<result property="departmentId" column="department_id"/>
<result property="postName" column="post_name"/>
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult"/>
@ -70,7 +70,7 @@
u.remark,
u.user_card_no,
u.user_birth_date,
u.agency_id,
u.hospital_agency_id,
u.department_id,
u.post_name,
d.dept_id,
@ -95,7 +95,7 @@
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.user_card_no,u.user_birth_date,
u.agency_id,u.department_id,u.post_name,d.dept_name, d.leader from sys_user u
u.hospital_agency_id,u.department_id,u.post_name,d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
@ -107,8 +107,8 @@
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="agencyId != null">
AND u.agency_id = #{agencyId}
<if test="hospitalAgencyId != null">
AND u.hospital_agency_id = #{hospitalAgencyId}
</if>
<if test="userCardNo != null and userCardNo != ''">
AND u.user_card_no = #{userCardNo}
@ -138,7 +138,7 @@
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status,
u.create_time,u.agency_id
u.create_time,u.hospital_agency_id
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -156,7 +156,7 @@
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status,
u.create_time,u.agency_id
u.create_time,u.hospital_agency_id
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -218,7 +218,7 @@
<if test="remark != null and remark != ''">remark,</if>
<if test="userCardNo != null and userCardNo != ''">user_card_no,</if>
<if test="userBirthDate != null">user_birth_date,</if>
<if test="agencyId != null">agency_id,</if>
<if test="hospitalAgencyId != null">hospital_agency_id,</if>
<if test="departmentId != null">department_id,</if>
<if test="postName != null">post_name,</if>
create_time
@ -237,7 +237,7 @@
<if test="remark != null and remark != ''">#{remark},</if>
<if test="userCardNo != null and userCardNo != ''">#{userCardNo},</if>
<if test="userBirthDate != null">#{userBirthDate},</if>
<if test="agencyId != null">#{agencyId},</if>
<if test="hospitalAgencyId != null">#{hospitalAgencyId},</if>
<if test="departmentId != null">#{departmentId},</if>
<if test="postName != null">#{postName},</if>
sysdate()
@ -262,7 +262,7 @@
<if test="remark != null">remark = #{remark},</if>
<if test="userCardNo != null and userCardNo != ''">user_card_no = #{userCardNo},</if>
<if test="userBirthDate != null">user_birth_date = #{userBirthDate},</if>
<if test="agencyId != null">agency_id =#{agencyId},</if>
<if test="hospitalAgencyId != null">hospital_agency_id =#{hospitalAgencyId},</if>
<if test="departmentId != null">department_id = #{departmentId},</if>
<if test="postName != null">post_name = #{postName},</if>
update_time = sysdate()
@ -272,7 +272,7 @@
<update id="updateUserAgency" parameterType="SysUser">
update sys_user
set agency_id =#{agencyId},
set hospital_agency_id =#{hospitalAgencyId},
department_id = #{departmentId},
update_time = sysdate()
where user_id = #{userId}
@ -317,7 +317,7 @@
</delete>
<select id="selectAgencyList" resultType="com.xinelu.system.domain.vo.AgencyNameVO">
select id agencyId,
select id hospitalAgencyId,
agency_name,
agency_code,
(select COUNT(1)
@ -327,8 +327,8 @@
and agency_name = #{agencyName}
or agency_code = #{agencyName}
</if>
<if test="agencyId != null ">
and id &lt;&gt; #{agencyId}
<if test="hospitalAgencyId != null ">
and id &lt;&gt; #{hospitalAgencyId}
</if>
) as agencyNum
from agency
@ -337,22 +337,22 @@
and agency_name = #{agencyName}
or agency_code = #{agencyName}
</if>
<if test="agencyId != null ">
and id &lt;&gt; #{agencyId}
<if test="hospitalAgencyId != null ">
and id &lt;&gt; #{hospitalAgencyId}
</if>
</select>
<select id="selectBelongAgencyList" resultType="com.xinelu.system.domain.vo.AgencyNameVO">
select id agencyId,
select id hospitalAgencyId,
agency_name,
agency_code,
(select COUNT(1)
from agency
where id = #{agencyId}
where id = #{hospitalAgencyId}
and agency_status = 'ON'
and node_type = 'HOSPITAL') as agencyNum
from agency
where id = #{agencyId}
where id = #{hospitalAgencyId}
and agency_status = 'ON'
and node_type = 'HOSPITAL'
</select>
@ -371,8 +371,8 @@
<if test="departmentId != null ">
and id &lt;&gt; #{departmentId}
</if>
<if test="agencyId != null ">
and agency_id = #{agencyId}
<if test="hospitalAgencyId != null ">
and hospital_agency_id = #{hospitalAgencyId}
</if>
) as departmentNum
from department
@ -384,8 +384,8 @@
<if test="departmentId != null ">
and id &lt;&gt; #{departmentId}
</if>
<if test="agencyId != null ">
and agency_id = #{agencyId}
<if test="hospitalAgencyId != null ">
and hospital_agency_id = #{hospitalAgencyId}
</if>
</select>