Browse Source

用户绑定角色

hnzxyjhyy
ccsens_zhengzhichuan 2 weeks ago
parent
commit
17e0097015
  1. 141
      ruisi_java/ruisi-system/src/main/java/com/ccsens/system/service/impl/DockServiceImpl.java
  2. 8
      ruisi_java/ruisi-web-client/src/main/resources/application-dev.yml
  3. 10
      ruisi_java/ruisi-web-client/src/main/resources/application-prod.yml

141
ruisi_java/ruisi-system/src/main/java/com/ccsens/system/service/impl/DockServiceImpl.java

@ -15,6 +15,8 @@ import com.ccsens.common.enums.DataSourceType;
import com.ccsens.common.exception.base.BaseException;
import com.ccsens.common.utils.DateUtils;
import com.ccsens.common.utils.SecurityUtils;
import com.ccsens.common.utils.StringUtils;
import com.ccsens.system.domain.SysUserRole;
import com.ccsens.system.domain.dto.DockDto;
import com.ccsens.system.domain.po.*;
import com.ccsens.system.persist.dao.DockDao;
@ -66,13 +68,15 @@ public class DockServiceImpl implements DockService {
@Resource
private PmsPatientBodyMapper pmsPatientBodyMapper;
@Resource
private PmsPatientDiagnosisMapper pmsPatientDiagnosisMapper;
private PmsPatientDiagnosisMapper pmsPatientDiagnosisMapper;
@Resource
private PmsPatientParentIllnessMapper pmsPatientParentIllnessMapper;
@Resource
private SysDeptMapper sysDeptMapper;
@Resource
private SysUserMapper sysUserMapper;
@Resource
private SysUserRoleMapper userRoleMapper;
@Value("${hospitalId:}")
private Long hospitalId;
@ -265,7 +269,7 @@ public class DockServiceImpl implements DockService {
}
}
}else {
} else {
//不存在新增
PmsPatient pmsPatient = BeanUtil.copyProperties(dockPatientBaseInfo, PmsPatient.class);
pmsPatient.setId(IdUtil.getSnowflake().nextId());
@ -274,30 +278,30 @@ public class DockServiceImpl implements DockService {
}
}
public void syncHospitalData(){
public void syncHospitalData() {
//患者信息
try {
syncPmsPatient();
}catch (Exception e){
log.error("患者信息同步失败",e);
} catch (Exception e) {
log.error("患者信息同步失败", e);
}
//就诊信息
try {
syncPmsPatientVisitInfo();
}catch (Exception e){
log.error("就诊信息同步失败",e);
} catch (Exception e) {
log.error("就诊信息同步失败", e);
}
//诊断信息
try {
syncPmsPatientDiagnosis();
}catch (Exception e){
log.error("诊断信息同步失败",e);
} catch (Exception e) {
log.error("诊断信息同步失败", e);
}
//用药信息
try {
syncPmsPatientParentIllness();
}catch (Exception e){
log.error("用药信息同步失败",e);
} catch (Exception e) {
log.error("用药信息同步失败", e);
}
}
@ -305,20 +309,21 @@ public class DockServiceImpl implements DockService {
@DataSource(value = DataSourceType.MASTER)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void syncUmsUserMaster(List<SysUser> sysUsers) {
if(CollUtil.isNotEmpty(sysUsers)){
if (CollUtil.isNotEmpty(sysUsers)) {
for (SysUser sysUser : sysUsers) {
//根据code查找用户
SysUser user = new SysUser();
user.setEmplCode(sysUser.getEmplCode());
List<SysUser> users = sysUserMapper.selectUserList(user);
if (CollUtil.isEmpty(users)) {
sysUser.setDeptId(hospitalId);
sysUserMapper.insertUser(sysUser);
}
}
}
}
// @DataSource(value = DataSourceType.SLAVE)
// @DataSource(value = DataSourceType.SLAVE)
// @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public List<SysUser> syncUmsUserSlave() {
List<SysUser> returnUsers = new ArrayList<>();
@ -335,7 +340,7 @@ public class DockServiceImpl implements DockService {
List<SysDept> sysDepts = sysDeptMapper.selectDeptList(sysDept);
if (CollUtil.isEmpty(sysDepts)) {
continue;
}else {
} else {
sysDept = sysDepts.get(0);
}
SysUser sysUser = new SysUser();
@ -350,6 +355,13 @@ public class DockServiceImpl implements DockService {
//获取一年后的日期
sysUser.setValidDate(DateUtil.offset(new Date(), DateField.YEAR, 1));
sysUserMapper.insertUser(sysUser);
// 新增用户与角色管理
SysUserRole ur = new SysUserRole();
ur.setUserId(sysUser.getUserId());
ur.setRoleId(104L);
userRoleMapper.batchUserRole(CollUtil.newArrayList(ur));
returnUsers.add(sysUser);
dockEmpl.setSync("1");
dockEmplMapper.updateByPrimaryKeySelective(dockEmpl);
@ -358,7 +370,7 @@ public class DockServiceImpl implements DockService {
return returnUsers;
}
// @DataSource(value = DataSourceType.SLAVE)
// @DataSource(value = DataSourceType.SLAVE)
// @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public List<SysDept> syncUmsDeptSlave() {
List<SysDept> returnDepts = new ArrayList<>();
@ -381,7 +393,7 @@ public class DockServiceImpl implements DockService {
sysDept.setDeptCode(dockDept.getDeptCode());
sysDeptMapper.insertDept(sysDept);
returnDepts.add(sysDept);
}else {
} else {
sysDept = sysDepts.get(0);
sysDept.setParentId(hospitalId);
sysDept.setAncestors("0," + hospitalId);
@ -399,7 +411,7 @@ public class DockServiceImpl implements DockService {
@DataSource(value = DataSourceType.MASTER)
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void syncUmsDeptMaster(List<SysDept> sysDepts) {
if(CollUtil.isNotEmpty(sysDepts)){
if (CollUtil.isNotEmpty(sysDepts)) {
sysDepts.forEach(sysDept -> {
//根据code查找系统的部门信息
SysDept dept = new SysDept();
@ -407,7 +419,7 @@ public class DockServiceImpl implements DockService {
List<SysDept> depts = sysDeptMapper.selectDeptList(dept);
if (CollUtil.isEmpty(depts)) {
sysDeptMapper.insertDept(sysDept);
}else {
} else {
SysDept sysDept1 = depts.get(0);
sysDept.setDeptId(sysDept1.getDeptId());
sysDeptMapper.updateDept(sysDept);
@ -417,8 +429,6 @@ public class DockServiceImpl implements DockService {
}
private void syncPmsPatient() {
DockPatientBaseInfoExample dockPatientBaseInfoExample = new DockPatientBaseInfoExample();
dockPatientBaseInfoExample.createCriteria().andSyncEqualTo("0").andDelFlagEqualTo((byte) 0);
@ -427,7 +437,7 @@ public class DockServiceImpl implements DockService {
return;
}
for (DockPatientBaseInfo dockPatientBaseInfo : dockPatientBaseInfos) {
if(ObjectUtil.isNull(dockPatientBaseInfo.getPatientNo())){
if (ObjectUtil.isNull(dockPatientBaseInfo.getPatientNo())) {
continue;
}
//根据患者患者唯一编号查询业务表内患者信息
@ -440,7 +450,7 @@ public class DockServiceImpl implements DockService {
pmsPatient = pmsPatients.get(0);
disposePmsPatient(dockPatientBaseInfo, pmsPatient);
pmsPatientMapper.updateByPrimaryKeySelective(pmsPatient);
}else {
} else {
//不存在则插入
pmsPatient = new PmsPatient();
pmsPatient.setId(IdUtil.getSnowflake().nextId());
@ -458,7 +468,7 @@ public class DockServiceImpl implements DockService {
DockPatientVisitInfoExample dockPatientVisitInfoExample = new DockPatientVisitInfoExample();
dockPatientVisitInfoExample.createCriteria().andSyncEqualTo("0");
List<DockPatientVisitInfo> dockPatientVisitInfos = dockPatientVisitInfoMapper.selectByExample(dockPatientVisitInfoExample);
if(CollUtil.isEmpty(dockPatientVisitInfos)){
if (CollUtil.isEmpty(dockPatientVisitInfos)) {
return;
}
for (DockPatientVisitInfo dockPatientVisitInfo : dockPatientVisitInfos) {
@ -486,11 +496,11 @@ public class DockServiceImpl implements DockService {
pmsPatient.setId(IdUtil.getSnowflake().nextId());
disposePmsPatient(dockPatientBaseInfos.get(0), pmsPatient);
pmsPatientMapper.insertSelective(pmsPatient);
}else {
} else {
//不存在表示患者确实不存在,直接跳过这个就诊信息
return null;
}
}else {
} else {
pmsPatient = pmsPatients.get(0);
}
//根据就诊流水号查询业务表内患者就诊信息
@ -503,7 +513,7 @@ public class DockServiceImpl implements DockService {
pmsPatientBody.setPatientId(pmsPatient.getId());
disposePmsPatientBody(dockPatientVisitInfo, pmsPatientBody);
pmsPatientBodyMapper.updateByPrimaryKeySelective(pmsPatientBody);
}else {
} else {
pmsPatientBody = new PmsPatientBody();
pmsPatientBody.setId(IdUtil.getSnowflake().nextId());
pmsPatientBody.setPatientId(pmsPatient.getId());
@ -542,7 +552,7 @@ public class DockServiceImpl implements DockService {
if (pmsPatientBody == null) {
continue;
}
}else {
} else {
//不存在则跳过
continue;
}
@ -588,17 +598,17 @@ public class DockServiceImpl implements DockService {
List<PmsPatientBody> pmsPatientBodies = pmsPatientBodyMapper.selectByExample(pmsPatientBodyExample);
if (CollUtil.isNotEmpty(pmsPatientBodies)) {
pmsPatientBody = pmsPatientBodies.get(0);
}else {
} else {
//不存在则查找同步表的就诊信息
DockPatientVisitInfoExample dockPatientVisitInfoExample = new DockPatientVisitInfoExample();
dockPatientVisitInfoExample.createCriteria().andVisitNoEqualTo(key).andDelFlagEqualTo((byte) 0);
List<DockPatientVisitInfo> dockPatientVisitInfos = dockPatientVisitInfoMapper.selectByExample(dockPatientVisitInfoExample);
if (CollUtil.isNotEmpty(dockPatientVisitInfos)){
if (CollUtil.isNotEmpty(dockPatientVisitInfos)) {
pmsPatientBody = savePatientBady(dockPatientVisitInfos.get(0));
if (pmsPatientBody == null) {
continue;
}
}else {
} else {
//不存在则跳过
continue;
}
@ -657,7 +667,6 @@ public class DockServiceImpl implements DockService {
}
private void disposePmsPatient(DockPatientBaseInfo dockPatientBaseInfo, PmsPatient pmsPatient) {
pmsPatient.setPatientNo(dockPatientBaseInfo.getPatientNo());
@ -673,15 +682,15 @@ public class DockServiceImpl implements DockService {
// 性别转换:将"男"/"女"转换为 0/1
String sex = dockPatientBaseInfo.getSex();
if ("男".equals(sex)) {
pmsPatient.setSex((byte)0);
pmsPatient.setSex((byte) 0);
} else if ("女".equals(sex)) {
pmsPatient.setSex((byte)1);
pmsPatient.setSex((byte) 1);
} else {
// 如果已经有数字代码,直接转换
try {
pmsPatient.setSex(Byte.parseByte(sex));
} catch (NumberFormatException e) {
pmsPatient.setSex((byte)0); // 默认值
pmsPatient.setSex((byte) 0); // 默认值
}
}
@ -691,57 +700,57 @@ public class DockServiceImpl implements DockService {
// 教育程度转换
String educationalStatus = dockPatientBaseInfo.getEducationalStatus();
if ("文盲".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)1);
pmsPatient.setEducationalStatus((byte) 1);
} else if ("小学".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)2);
pmsPatient.setEducationalStatus((byte) 2);
} else if ("初中".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)3);
pmsPatient.setEducationalStatus((byte) 3);
} else if ("高中".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)4);
pmsPatient.setEducationalStatus((byte) 4);
} else if ("大学".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)5);
pmsPatient.setEducationalStatus((byte) 5);
} else if ("大学以上".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)6);
pmsPatient.setEducationalStatus((byte) 6);
} else if ("其他".equals(educationalStatus)) {
pmsPatient.setEducationalStatus((byte)7);
pmsPatient.setEducationalStatus((byte) 7);
} else {
try {
pmsPatient.setEducationalStatus(Byte.parseByte(educationalStatus));
} catch (NumberFormatException e) {
pmsPatient.setEducationalStatus((byte)7); // 默认其他
pmsPatient.setEducationalStatus((byte) 7); // 默认其他
}
}
// 职业转换
String career = dockPatientBaseInfo.getCareer();
if ("农林牧渔水利生产人员".equals(career)) {
pmsPatient.setCareer((byte)1);
pmsPatient.setCareer((byte) 1);
} else if ("教师".equals(career)) {
pmsPatient.setCareer((byte)2);
pmsPatient.setCareer((byte) 2);
} else if ("医务工作者".equals(career)) {
pmsPatient.setCareer((byte)3);
pmsPatient.setCareer((byte) 3);
} else if ("专业技术人员".equals(career)) {
pmsPatient.setCareer((byte)4);
pmsPatient.setCareer((byte) 4);
} else if ("生产、运输设备操作人员及有关人员".equals(career)) {
pmsPatient.setCareer((byte)5);
pmsPatient.setCareer((byte) 5);
} else if ("商业、服务业人员".equals(career)) {
pmsPatient.setCareer((byte)6);
pmsPatient.setCareer((byte) 6);
} else if ("国家机关、事业单位、企业负责人".equals(career)) {
pmsPatient.setCareer((byte)7);
pmsPatient.setCareer((byte) 7);
} else if ("国家机关、事业单位、企业办事人员和有关人员".equals(career)) {
pmsPatient.setCareer((byte)8);
pmsPatient.setCareer((byte) 8);
} else if ("军人".equals(career)) {
pmsPatient.setCareer((byte)9);
pmsPatient.setCareer((byte) 9);
} else if ("媒体、文体类工作人员".equals(career)) {
pmsPatient.setCareer((byte)10);
pmsPatient.setCareer((byte) 10);
} else if ("在校学生".equals(career)) {
pmsPatient.setCareer((byte)11);
pmsPatient.setCareer((byte) 11);
} else if ("未就业".equals(career)) {
pmsPatient.setCareer((byte)12);
pmsPatient.setCareer((byte) 12);
} else if ("家务".equals(career)) {
pmsPatient.setCareer((byte)13);
pmsPatient.setCareer((byte) 13);
} else if ("其他".equals(career)) {
pmsPatient.setCareer((byte)14);
pmsPatient.setCareer((byte) 14);
} else {
try {
pmsPatient.setCareer(Byte.parseByte(career));
@ -753,19 +762,19 @@ public class DockServiceImpl implements DockService {
// 婚姻状况转换
String maritalStatus = dockPatientBaseInfo.getMaritalStatus();
if ("未婚".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)1);
pmsPatient.setMaritalStatus((byte) 1);
} else if ("已婚".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)2);
pmsPatient.setMaritalStatus((byte) 2);
} else if ("离异".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)3);
pmsPatient.setMaritalStatus((byte) 3);
} else if ("分居".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)4);
pmsPatient.setMaritalStatus((byte) 4);
} else if ("丧偶".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)5);
pmsPatient.setMaritalStatus((byte) 5);
} else if ("同居".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)6);
pmsPatient.setMaritalStatus((byte) 6);
} else if ("其他".equals(maritalStatus)) {
pmsPatient.setMaritalStatus((byte)7);
pmsPatient.setMaritalStatus((byte) 7);
} else {
try {
pmsPatient.setMaritalStatus(Byte.parseByte(maritalStatus));
@ -782,11 +791,11 @@ public class DockServiceImpl implements DockService {
// 居住状态转换
String dwellingState = dockPatientBaseInfo.getDwellingState();
if ("独居".equals(dwellingState)) {
pmsPatient.setDwellingState((byte)1);
pmsPatient.setDwellingState((byte) 1);
} else if ("与配偶或对象或子女".equals(dwellingState)) {
pmsPatient.setDwellingState((byte)2);
pmsPatient.setDwellingState((byte) 2);
} else if ("与亲戚或朋友居住".equals(dwellingState)) {
pmsPatient.setDwellingState((byte)3);
pmsPatient.setDwellingState((byte) 3);
} else {
try {
pmsPatient.setDwellingState(Byte.parseByte(dwellingState));

8
ruisi_java/ruisi-web-client/src/main/resources/application-dev.yml

@ -11,14 +11,14 @@ spring:
# password: po3OynBO[M3579p6L7)o
url: jdbc:mysql://127.0.0.1:3306/ruisi_cga?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: q7510327
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: true
url: jdbc:mysql://127.0.0.1:3306/ruisi_cga_yf1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://127.0.0.1:3306/ruisi_cga_hnszyyy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: q7510327
# driverClassName: oracle.jdbc.driver.OracleDriver
# url: jdbc:oracle:thin:@200.1.8.115:1521:hisdb
# username: interface_lnpg
@ -126,6 +126,6 @@ informed:
clientVersion: v1.8.3.0
# 医院id,不同医院部署的时候需要修改
hospitalId: 174
hospitalId: 178
generalPassword: cga123#

10
ruisi_java/ruisi-web-client/src/main/resources/application-prod.yml

@ -12,10 +12,10 @@ spring:
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
url: jdbc:mysql://172.16.21.24:23306/ruisi_cga_hnszyyy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: xian#2024!!!
# 初始连接数
initialSize: 5
# 最小连接池数量
@ -131,5 +131,5 @@ informed:
clientVersion: v1.8.3.0
# 医院id,不同医院部署的时候需要修改
hospitalId: 174
hospitalId: 178
generalPassword: cga123#
Loading…
Cancel
Save