Browse Source

合并new

new-ays
wzz 3 months ago
parent
commit
e114c2bd87
  1. 15
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/system/SysUserController.java
  2. 6
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminDataSourceController.java
  3. 93
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminDmsUserController.java
  4. 28
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminPmsTreatmentController.java
  5. 6
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminTenantsController.java
  6. 91
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/DmsLoginController.java
  7. 10
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ExternalController.java
  8. 15
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupController.java
  9. 17
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ScreeningController.java
  10. 422
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/TaskController.java
  11. 2
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/WxQrCodeController.java
  12. 664
      acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java
  13. 56
      acupuncture-framework/src/main/java/com/acupuncture/framework/aspectj/AdminGlobalDataSourceAspect.java
  14. 1
      acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/UserDetailsServiceImpl.java
  15. 2
      acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java
  16. 20
      acupuncture-generator/src/main/resources/mbg.xml
  17. 25
      acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/AdminTenantUserDto.java
  18. 17
      acupuncture-system/src/main/java/com/acupuncture/system/domain/po/DmsUser.java
  19. 80
      acupuncture-system/src/main/java/com/acupuncture/system/domain/po/DmsUserExample.java
  20. 2
      acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/AdminTenantUserVo.java
  21. 5
      acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/DmsLoginUserVo.java
  22. 2
      acupuncture-system/src/main/java/com/acupuncture/system/mapper/SysRoleMapper.java
  23. 7
      acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/DmsUserDao.java
  24. 4
      acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/DmsUserMapper.java
  25. 1
      acupuncture-system/src/main/java/com/acupuncture/system/service/AdminTenantUserService.java
  26. 9
      acupuncture-system/src/main/java/com/acupuncture/system/service/DmsLoginService.java
  27. 1
      acupuncture-system/src/main/java/com/acupuncture/system/service/FmsFollowupQueueService.java
  28. 10
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/AdminTenantUserServiceImpl.java
  29. 28
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/DmsLoginServiceImpl.java
  30. 1
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupQueueServiceImpl.java
  31. 3
      acupuncture-system/src/main/resources/mapper/dao/AdminDmsUserDao.xml
  32. 18
      acupuncture-system/src/main/resources/mapper/dao/DmsUserDao.xml
  33. 57
      acupuncture-system/src/main/resources/mapper/system/DmsUserMapper.xml
  34. 6
      acupuncture-system/src/main/resources/mapper/system/SysUserMapper.xml

15
acupuncture-admin/src/main/java/com/acupuncture/web/controller/system/SysUserController.java

@ -165,7 +165,6 @@ public class SysUserController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user) public AjaxResult edit(@Validated @RequestBody SysUser user)
{ {
// changeDataSource(user.getTenantId());
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
deptService.checkDeptDataScope(user.getDeptId()); deptService.checkDeptDataScope(user.getDeptId());
@ -186,20 +185,6 @@ public class SysUserController extends BaseController
return toAjax(userService.updateUser(user)); return toAjax(userService.updateUser(user));
} }
private void changeDataSource(Long tenantId) {
DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(tenantId);
if (dmsTenant != null) {
UmsDataSource umsDataSource = umsDataSourceMapper.selectByPrimaryKey(dmsTenant.getDataSourceId());
if (umsDataSource != null) {
try {
DynamicDataSourceContextHolder.setDataSourceType(umsDataSource.getDataSourceKey());
}finally {
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
}
}
/** /**
* 删除用户 * 删除用户
*/ */

6
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminDataSourceController.java

@ -1,7 +1,9 @@
package com.acupuncture.web.controller.web; package com.acupuncture.web.controller.web;
import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.system.domain.dto.AdminDataSourceDto; import com.acupuncture.system.domain.dto.AdminDataSourceDto;
import com.acupuncture.system.domain.vo.AdminDataSourceVo; import com.acupuncture.system.domain.vo.AdminDataSourceVo;
@ -34,6 +36,7 @@ public class AdminDataSourceController {
@ApiOperation("添加数据源") @ApiOperation("添加数据源")
@PostMapping("/add") @PostMapping("/add")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> insert(@RequestBody @Validated AdminDataSourceDto.AddDto dto) { public JsonResponse<Integer> insert(@RequestBody @Validated AdminDataSourceDto.AddDto dto) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
return JsonResponse.ok().fail("无权限"); return JsonResponse.ok().fail("无权限");
@ -43,6 +46,7 @@ public class AdminDataSourceController {
@ApiOperation("修改数据源") @ApiOperation("修改数据源")
@PostMapping("/upd") @PostMapping("/upd")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> update(@RequestBody @Validated AdminDataSourceDto.UpdDto dto) { public JsonResponse<Integer> update(@RequestBody @Validated AdminDataSourceDto.UpdDto dto) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
return JsonResponse.ok().fail("无权限"); return JsonResponse.ok().fail("无权限");
@ -52,6 +56,7 @@ public class AdminDataSourceController {
@ApiOperation("删除数据源") @ApiOperation("删除数据源")
@PostMapping("/del") @PostMapping("/del")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> delete(@RequestBody @Validated AdminDataSourceDto.DeleteDto dto) { public JsonResponse<Integer> delete(@RequestBody @Validated AdminDataSourceDto.DeleteDto dto) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
return JsonResponse.ok().fail("无权限"); return JsonResponse.ok().fail("无权限");
@ -61,6 +66,7 @@ public class AdminDataSourceController {
@ApiOperation("查询数据源") @ApiOperation("查询数据源")
@PostMapping("/list") @PostMapping("/list")
@DataSource(DataSourceType.MASTER)
public JsonResponse<PageInfo<AdminDataSourceVo.Result>> query(@RequestBody @Validated BaseDto<AdminDataSourceDto.Query> dto) { public JsonResponse<PageInfo<AdminDataSourceVo.Result>> query(@RequestBody @Validated BaseDto<AdminDataSourceDto.Query> dto) {
return JsonResponse.ok(new PageInfo<>(adminDataSourceService.query(dto.getParam()))); return JsonResponse.ok(new PageInfo<>(adminDataSourceService.query(dto.getParam())));
} }

93
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminDmsUserController.java

@ -2,10 +2,15 @@ package com.acupuncture.web.controller.web;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.annotation.Log;
import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.common.core.domain.entity.SysUser; import com.acupuncture.common.core.domain.entity.SysUser;
import com.acupuncture.common.enums.BusinessType;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.common.utils.StringUtils; import com.acupuncture.common.utils.StringUtils;
import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder;
@ -30,11 +35,9 @@ import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -68,6 +71,7 @@ public class AdminDmsUserController {
@ApiOperation("添加租户用户") @ApiOperation("添加租户用户")
@PostMapping("/add") @PostMapping("/add")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> insert(@RequestBody @Validated AdminTenantUserDto.AddDto dto) { public JsonResponse<Integer> insert(@RequestBody @Validated AdminTenantUserDto.AddDto dto) {
//判定租户及数据源是否存在 //判定租户及数据源是否存在
DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(dto.getTenantId()); DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(dto.getTenantId());
@ -85,11 +89,12 @@ public class AdminDmsUserController {
} else if (StringUtils.isNotEmpty(dto.getPhonenumber()) && !dmsLoginService.checkPhoneUnique(dto)) { } else if (StringUtils.isNotEmpty(dto.getPhonenumber()) && !dmsLoginService.checkPhoneUnique(dto)) {
return JsonResponse.ok().fail("新增用户'" + dto.getUserName() + "'失败,手机号码已存在"); return JsonResponse.ok().fail("新增用户'" + dto.getUserName() + "'失败,手机号码已存在");
} }
dto.setId(IdUtil.getSnowflakeNextId());
dto.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); dto.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
adminTenantUserService.insert(dto); adminTenantUserService.insert(dto);
//切换至从库 //切换至从库
changeDataSource(umsDataSource.getDataSourceKey()); DynamicDataSourceContextHolder.setDataSourceType(umsDataSource.getDataSourceKey());
//新增从库数据 //新增从库数据
SysUser user = BeanUtil.copyProperties(dto, SysUser.class); SysUser user = BeanUtil.copyProperties(dto, SysUser.class);
@ -100,6 +105,7 @@ public class AdminDmsUserController {
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return JsonResponse.ok().fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); return JsonResponse.ok().fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
} }
user.setUserId(dto.getId());
user.setTenantId(dto.getTenantId()); user.setTenantId(dto.getTenantId());
user.setCreateBy(SecurityUtils.getUsername()); user.setCreateBy(SecurityUtils.getUsername());
user.setPhonenumber(dto.getContactPhone()); user.setPhonenumber(dto.getContactPhone());
@ -107,49 +113,46 @@ public class AdminDmsUserController {
int insert = userService.insertUser(user); int insert = userService.insertUser(user);
//销毁切换数据源 //销毁切换数据源
removeDataSource(); DynamicDataSourceContextHolder.clearDataSourceType();
return JsonResponse.ok(insert); return JsonResponse.ok(insert);
} }
@ApiOperation("修改租户用户") @ApiOperation("修改租户用户")
@PostMapping("/upd") @PostMapping("/upd")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> update(@RequestBody @Validated AdminTenantUserDto.UpdDto dto) { public JsonResponse<Integer> update(@RequestBody @Validated AdminTenantUserDto.UpdDto dto) {
updSysUser(dto); //判定租户及数据源是否存在
return JsonResponse.ok(adminTenantUserService.update(dto)); DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(dto.getTenantId());
} if (dmsTenant == null) {
return JsonResponse.ok().fail("租户不存在");
private void updSysUser(AdminTenantUserDto.UpdDto dto) {
//查询租户数据源,删除分库数据
DmsUserExample dmsUserExample = new DmsUserExample();
dmsUserExample.createCriteria().andDelFlagEqualTo((byte) 0).andIdEqualTo(dto.getId());
List<DmsUser> dmsUsers = dmsUserMapper.selectByExample(dmsUserExample);
if (CollectionUtil.isNotEmpty(dmsUsers)) {
DmsUser dmsUser = dmsUsers.get(0);
AdminTenantsDto.Query query = new AdminTenantsDto.Query();
query.setId(dmsUser.getTenantId());
List<AdminTenantsVo.Result> tenantList = adminTenantsService.query(query);
if (CollectionUtil.isNotEmpty(tenantList)) {
for (AdminTenantsVo.Result result : tenantList) {
//切换数据源 删除分库数据
changeDataSource(result.getDataSourceKey());
//修改分库用户
SysUser sysUser = BeanUtil.copyProperties(dto, SysUser.class);
sysUser.setPhonenumber(dto.getContactPhone());
userService.updateUser(sysUser);
}
}
} }
UmsDataSource umsDataSource = umsDataSourceMapper.selectByPrimaryKey(dmsTenant.getDataSourceId());
if (umsDataSource == null || StrUtil.isEmpty(umsDataSource.getDataSourceKey())) {
return JsonResponse.ok().fail("数据源不存在");
}
//修改主库租户用户
int rows = adminTenantUserService.update(dto);
//切换至从库
DynamicDataSourceContextHolder.setDataSourceType(umsDataSource.getDataSourceKey());
//修改从库用户信息
SysUser sysUser = BeanUtil.copyProperties(dto, SysUser.class);
sysUser.setPhonenumber(dto.getContactPhone());
userService.updateUser(sysUser);
//销毁切换数据源
DynamicDataSourceContextHolder.clearDataSourceType();
return JsonResponse.ok(rows);
} }
@ApiOperation("删除租户用户") @ApiOperation("删除租户用户")
@PostMapping("/del") @PostMapping("/del")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> delete(@RequestBody @Validated AdminTenantUserDto.DeleteDto dto) { public JsonResponse<Integer> delete(@RequestBody @Validated AdminTenantUserDto.DeleteDto dto) {
delSysUser(dto);
return JsonResponse.ok(adminTenantUserService.delete(dto));
}
private void delSysUser(AdminTenantUserDto.DeleteDto dto) {
//查询租户数据源,删除分库数据 //查询租户数据源,删除分库数据
DmsUserExample dmsUserExample = new DmsUserExample(); DmsUserExample dmsUserExample = new DmsUserExample();
dmsUserExample.createCriteria().andDelFlagEqualTo((byte) 0).andIdIn(dto.getIdList()); dmsUserExample.createCriteria().andDelFlagEqualTo((byte) 0).andIdIn(dto.getIdList());
@ -162,17 +165,21 @@ public class AdminDmsUserController {
if (CollectionUtil.isNotEmpty(tenantList)) { if (CollectionUtil.isNotEmpty(tenantList)) {
for (AdminTenantsVo.Result result : tenantList) { for (AdminTenantsVo.Result result : tenantList) {
//切换数据源 删除分库数据 //切换数据源 删除分库数据
changeDataSource(result.getDataSourceKey()); DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey());
//删除分库用户 //删除分库用户
userService.deleteUserByUsername(dmsUser.getUserName()); userService.deleteUserByUsername(dmsUser.getUserName());
//销毁切换数据源
DynamicDataSourceContextHolder.clearDataSourceType();
} }
} }
} }
} }
return JsonResponse.ok(adminTenantUserService.delete(dto));
} }
@ApiOperation("查询租户用户") @ApiOperation("查询租户用户")
@PostMapping("/list") @PostMapping("/list")
@DataSource(DataSourceType.MASTER)
public JsonResponse<PageInfo<AdminTenantUserVo.Result>> query(@RequestBody @Validated BaseDto<AdminTenantUserDto.Query> dto) { public JsonResponse<PageInfo<AdminTenantUserVo.Result>> query(@RequestBody @Validated BaseDto<AdminTenantUserDto.Query> dto) {
if (dto.getPageNum() > 0) { if (dto.getPageNum() > 0) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
@ -180,11 +187,15 @@ public class AdminDmsUserController {
return JsonResponse.ok(new PageInfo<>(adminTenantUserService.query(dto.getParam()))); return JsonResponse.ok(new PageInfo<>(adminTenantUserService.query(dto.getParam())));
} }
private static void changeDataSource(String key) {
DynamicDataSourceContextHolder.setDataSourceType(key);
}
private static void removeDataSource() { /**
DynamicDataSourceContextHolder.clearDataSourceType(); * 重置密码
*/
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> resetPwd(@RequestBody @Validated AdminTenantUserDto.ResetPwd dto) {
//只修改主库密码,修改从库密码没有任何意义。
return JsonResponse.ok(adminTenantUserService.resetPwd(dto));
} }
} }

28
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminPmsTreatmentController.java

@ -67,27 +67,13 @@ public class AdminPmsTreatmentController {
treatmentService.adminExportTreatment(response, dto); treatmentService.adminExportTreatment(response, dto);
} }
@ApiOperation("修改诊疗档案") // @ApiOperation("修改诊疗档案")
@PostMapping("/upd") // @PostMapping("/upd")
public JsonResponse<Integer> updateTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentUpdateDTO dto) { // public JsonResponse<Integer> updateTreatment(@RequestBody @Validated PmsTreatmentDto.TreatmentUpdateDTO dto) {
DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(dto.getTenantId()); // treatmentService.updateTreatment(dto);
if (dmsTenant != null) { // return JsonResponse.ok();
UmsDataSource umsDataSource = umsDataSourceMapper.selectByPrimaryKey(dmsTenant.getDataSourceId()); // }
if (umsDataSource != null) { //
changeDataSource(umsDataSource.getDataSourceKey());
}
}
treatmentService.updateTreatment(dto);
return JsonResponse.ok();
}
private static void changeDataSource(String dataSourceKey) {
try {
DynamicDataSourceContextHolder.setDataSourceType(dataSourceKey);
}finally {
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
// @ApiOperation("导出诊疗档案评估报告") // @ApiOperation("导出诊疗档案评估报告")
// @PostMapping("/exportTreatmentPg") // @PostMapping("/exportTreatmentPg")

6
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/AdminTenantsController.java

@ -1,7 +1,9 @@
package com.acupuncture.web.controller.web; package com.acupuncture.web.controller.web;
import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.system.domain.dto.AdminTenantsDto; import com.acupuncture.system.domain.dto.AdminTenantsDto;
import com.acupuncture.system.domain.vo.AdminTenantsVo; import com.acupuncture.system.domain.vo.AdminTenantsVo;
@ -37,6 +39,7 @@ public class AdminTenantsController {
@ApiOperation("添加租户") @ApiOperation("添加租户")
@PostMapping("/add") @PostMapping("/add")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> insert(@RequestBody @Validated AdminTenantsDto.AddDto dto) { public JsonResponse<Integer> insert(@RequestBody @Validated AdminTenantsDto.AddDto dto) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
return JsonResponse.ok().fail("无权限"); return JsonResponse.ok().fail("无权限");
@ -46,6 +49,7 @@ public class AdminTenantsController {
@ApiOperation("修改租户") @ApiOperation("修改租户")
@PostMapping("/upd") @PostMapping("/upd")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> update(@RequestBody @Validated AdminTenantsDto.UpdDto dto) { public JsonResponse<Integer> update(@RequestBody @Validated AdminTenantsDto.UpdDto dto) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
return JsonResponse.ok().fail("无权限"); return JsonResponse.ok().fail("无权限");
@ -55,6 +59,7 @@ public class AdminTenantsController {
@ApiOperation("删除租户") @ApiOperation("删除租户")
@PostMapping("/del") @PostMapping("/del")
@DataSource(DataSourceType.MASTER)
public JsonResponse<Integer> delete(@RequestBody @Validated AdminTenantsDto.DeleteDto dto) { public JsonResponse<Integer> delete(@RequestBody @Validated AdminTenantsDto.DeleteDto dto) {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) { if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
return JsonResponse.ok().fail("无权限"); return JsonResponse.ok().fail("无权限");
@ -64,6 +69,7 @@ public class AdminTenantsController {
@ApiOperation("查询租户") @ApiOperation("查询租户")
@PostMapping("/list") @PostMapping("/list")
@DataSource(DataSourceType.MASTER)
public JsonResponse<PageInfo<AdminTenantsVo.Result>> query(@RequestBody @Validated BaseDto<AdminTenantsDto.Query> dto) { public JsonResponse<PageInfo<AdminTenantsVo.Result>> query(@RequestBody @Validated BaseDto<AdminTenantsDto.Query> dto) {
if (dto.getPageNum() > 0) { if (dto.getPageNum() > 0) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); PageHelper.startPage(dto.getPageNum(), dto.getPageSize());

91
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/DmsLoginController.java

@ -1,28 +1,40 @@
package com.acupuncture.web.controller.web; package com.acupuncture.web.controller.web;
import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.annotation.Log; import com.acupuncture.common.annotation.Log;
import com.acupuncture.common.constant.Constants; import com.acupuncture.common.constant.Constants;
import com.acupuncture.common.core.domain.AjaxResult; import com.acupuncture.common.core.domain.AjaxResult;
import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.common.core.domain.entity.SysUser; import com.acupuncture.common.core.domain.entity.SysUser;
import com.acupuncture.common.core.domain.model.LoginBody; import com.acupuncture.common.core.domain.model.LoginBody;
import com.acupuncture.common.core.domain.model.LoginUser; import com.acupuncture.common.core.domain.model.LoginUser;
import com.acupuncture.common.enums.BusinessType; import com.acupuncture.common.enums.BusinessType;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.framework.web.service.SysPermissionService; import com.acupuncture.framework.web.service.SysPermissionService;
import com.acupuncture.framework.web.service.TokenService; import com.acupuncture.framework.web.service.TokenService;
import com.acupuncture.framework.web.service.WebDmsLoginService; import com.acupuncture.framework.web.service.WebDmsLoginService;
import com.acupuncture.system.domain.dto.FmsFollowupDto;
import com.acupuncture.system.domain.po.DmsTenant; import com.acupuncture.system.domain.po.DmsTenant;
import com.acupuncture.system.domain.vo.DmsLoginUserVo; import com.acupuncture.system.domain.vo.DmsLoginUserVo;
import com.acupuncture.system.domain.vo.FmsFollowupVo;
import com.acupuncture.system.service.DmsLoginService; import com.acupuncture.system.service.DmsLoginService;
import com.acupuncture.system.service.FmsFollowupQueueService;
import com.acupuncture.system.service.FmsFollowupService;
import com.acupuncture.system.service.ISysUserService; import com.acupuncture.system.service.ISysUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
@ -45,6 +57,8 @@ public class DmsLoginController {
private DmsLoginService dmsLoginService; private DmsLoginService dmsLoginService;
@Resource @Resource
private ISysUserService sysUserService; private ISysUserService sysUserService;
@Resource
private FmsFollowupQueueService fmsFollowupQueueService;
/** /**
* 登录方法 * 登录方法
@ -53,6 +67,7 @@ public class DmsLoginController {
* @return 结果 * @return 结果
*/ */
@PostMapping("/login") @PostMapping("/login")
@DataSource(DataSourceType.MASTER)
public AjaxResult login(@RequestBody LoginBody loginBody) { public AjaxResult login(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
// 生成令牌 // 生成令牌
@ -63,33 +78,81 @@ public class DmsLoginController {
} }
/** /**
* 获取用户信息 * 重置密码
* */
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
@DataSource(DataSourceType.MASTER)
public AjaxResult updatePwd(@RequestBody Map<String, String> params)
{
String oldPassword = params.get("oldPassword");
String newPassword = params.get("newPassword");
LoginUser loginUser = SecurityUtils.getLoginUser();
Long userId = loginUser.getUserId();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
return AjaxResult.error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password))
{
return AjaxResult.error("新密码不能与旧密码相同");
}
newPassword = SecurityUtils.encryptPassword(newPassword);
if (dmsLoginService.resetPwd(userId, userName, newPassword) > 0)
{
// 更新缓存用户密码
loginUser.getUser().setPassword(newPassword);
tokenService.setLoginUser(loginUser);
return AjaxResult.success("操作成功");
}
return AjaxResult.error("修改密码异常,请联系管理员");
}
@ApiOperation("查询公共队列")
@PostMapping("/commonQueue")
@DataSource(DataSourceType.MASTER)
public JsonResponse<PageInfo<FmsFollowupVo.FollowupQueueVO>> queryCommonQueue(@RequestBody @Validated BaseDto<FmsFollowupDto.QueueQuery> dto) {
if (dto.getPageNum() > 0) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
}
return JsonResponse.ok(new PageInfo<>(fmsFollowupQueueService.queryCommonQueue(dto.getParam().getName())));
}
/**
* 获取用户信息暂时先从主库获取
* @return 用户信息 * @return 用户信息
*/ */
@GetMapping("getInfo") @ApiOperation("用户信息")
@GetMapping("/getInfo")
@DataSource(DataSourceType.MASTER)
public AjaxResult getInfo() { public AjaxResult getInfo() {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
//获取用户从库信息 //获取用户从库信息
SysUser user = sysUserService.selectUserByTenantId(loginUser.getTenantId(), loginUser.getUsername()); DmsLoginUserVo.DmsUserVo tenantUser = dmsLoginService.selectTenantUserById(loginUser.getUserId());
SysUser user = new SysUser();
user.setUserId(tenantUser.getId());
user.setUserName(tenantUser.getUserName());
user.setNickName(tenantUser.getNickName());
user.setTenantId(tenantUser.getTenantId());
user.setTenantName(tenantUser.getTenantName());
user.setTenantPhone(tenantUser.getTenantPhone());
user.setSlaverAdmin(tenantUser.getSlaverAdmin());
//刷新token //刷新token
tokenService.refreshToken(loginUser); tokenService.refreshToken(loginUser);
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("user", user); ajax.put("user", user);
ajax.put("tenantId", loginUser.getTenantId());
ajax.put("scoreId", loginUser.getScoreId());
return ajax; return ajax;
} }
@PutMapping("/resetPwd") /**
public JsonResponse<Integer> resetPwd(@RequestBody DmsLoginUserVo.DmsUserVo user) { * 筛查接口此接口已添加白名单所以不需要@annomous
// webDmsLoginService.checkUserAllowed(user); * @param dto
// webDmsLoginService.checkUserDataScope(user.getUserId()); * @return
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); */
return JsonResponse.ok(dmsLoginService.resetPwd(user));
}
@PostMapping("/queryTenantById") @PostMapping("/queryTenantById")
@DataSource(DataSourceType.MASTER)
public JsonResponse<DmsTenant> queryTenantById(@RequestBody DmsLoginUserVo.Query dto){ public JsonResponse<DmsTenant> queryTenantById(@RequestBody DmsLoginUserVo.Query dto){
return JsonResponse.ok(dmsLoginService.queryById(dto.getId())); return JsonResponse.ok(dmsLoginService.queryById(dto.getId()));
} }

10
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ExternalController.java

@ -80,21 +80,13 @@ public class ExternalController {
throw new BaseException("查询不到社区"); throw new BaseException("查询不到社区");
} }
//切换数据源查询 //切换数据源查询
changeDataSource(dataSourceList.get(0).getDataSourceKey()); DynamicDataSourceContextHolder.setDataSourceType(dataSourceList.get(0).getDataSourceKey());
}catch (Exception e) { }catch (Exception e) {
throw new BaseException("UUID错误:{}", from); throw new BaseException("UUID错误:{}", from);
} }
} }
private static void changeDataSource(String key) {
try {
DynamicDataSourceContextHolder.setDataSourceType(key);
}finally {
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
// @Anonymous // @Anonymous
// @ApiOperation("上传数据") // @ApiOperation("上传数据")
// @PostMapping("/http/uploadMemberInfo") // @PostMapping("/http/uploadMemberInfo")

15
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupController.java

@ -4,8 +4,10 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.acupuncture.common.annotation.Anonymous; import com.acupuncture.common.annotation.Anonymous;
import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.common.utils.SecurityUtils; import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder;
import com.acupuncture.system.domain.dto.FmsFollowupDto; import com.acupuncture.system.domain.dto.FmsFollowupDto;
@ -47,22 +49,9 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/followup") @RequestMapping("/followup")
public class FmsFollowupController { public class FmsFollowupController {
@Resource
private FmsFollowupQueueService fmsFollowupQueueService;
@Resource @Resource
private FmsFollowupService fmsFollowupService; private FmsFollowupService fmsFollowupService;
@ApiOperation("查询公共队列")
@PostMapping("/commonQueue")
@Anonymous
public JsonResponse<PageInfo<FmsFollowupVo.FollowupQueueVO>> queryCommonQueue(@RequestBody @Validated BaseDto<FmsFollowupDto.QueueQuery> dto) {
if (dto.getPageNum() > 0) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
}
return JsonResponse.ok(new PageInfo<>(fmsFollowupQueueService.queryCommonQueue(dto.getParam().getName())));
}
@ApiOperation("查询随访队列") @ApiOperation("查询随访队列")
@PostMapping("/query") @PostMapping("/query")
public JsonResponse<PageInfo<FmsFollowupVo.FollowupQueueVO>> queryQueue(@RequestBody @Validated BaseDto<FmsFollowupDto.FollowupQueueQueryDTO> dto) { public JsonResponse<PageInfo<FmsFollowupVo.FollowupQueueVO>> queryQueue(@RequestBody @Validated BaseDto<FmsFollowupDto.FollowupQueueQueryDTO> dto) {

17
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/ScreeningController.java

@ -82,26 +82,11 @@ public class ScreeningController {
@RequestMapping(value = "/createNoToken", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/createNoToken", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<QuestionnaireVo.DetailInfo> createNoToken(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.CreateDetail> params) throws Exception { public JsonResponse<QuestionnaireVo.DetailInfo> createNoToken(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.CreateDetail> params) throws Exception {
log.info("创建筛查详情{}", params); log.info("创建筛查详情{}", params);
// changeDataSource(params.getParam().getTenantId());
QuestionnaireVo.DetailInfo detailInfo = screeningService.createDetail(params.getParam(), params.getParam().getUserId(), params.getParam().getTenantId()); QuestionnaireVo.DetailInfo detailInfo = screeningService.createDetail(params.getParam(), params.getParam().getUserId(), params.getParam().getTenantId());
log.info("创建筛查详情结束"); log.info("创建筛查详情结束");
return JsonResponse.ok(detailInfo); return JsonResponse.ok(detailInfo);
} }
private void changeDataSource(Long tenantId) {
DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(tenantId);
if (dmsTenant != null) {
UmsDataSource umsDataSource = umsDataSourceMapper.selectByPrimaryKey(dmsTenant.getDataSourceId());
if (umsDataSource != null) {
try {
DynamicDataSourceContextHolder.setDataSourceType(umsDataSource.getDataSourceKey());
}finally {
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
}
}
@ApiOperation(value = "提交筛查", notes = "") @ApiOperation(value = "提交筛查", notes = "")
@RequestMapping(value = "/submit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/submit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse submitQuestionnaire(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.SubmitScreeningQuestionnaire> params) throws Exception { public JsonResponse submitQuestionnaire(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.SubmitScreeningQuestionnaire> params) throws Exception {
@ -115,7 +100,6 @@ public class ScreeningController {
@RequestMapping(value = "/submitNoToken", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/submitNoToken", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse submitNoToken(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.SubmitScreeningQuestionnaire> params) throws Exception { public JsonResponse submitNoToken(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.SubmitScreeningQuestionnaire> params) throws Exception {
log.info("提交筛查开始{}", params); log.info("提交筛查开始{}", params);
// changeDataSource(params.getParam().getTenantId());
screeningService.submitQuestionnaire(params.getParam(), 0L); screeningService.submitQuestionnaire(params.getParam(), 0L);
return JsonResponse.ok(); return JsonResponse.ok();
} }
@ -125,7 +109,6 @@ public class ScreeningController {
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse saveQuestionnaire(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.SaveQuestionnaire> params) throws Exception { public JsonResponse saveQuestionnaire(@ApiParam @Validated @RequestBody BaseDto<ScreeningDto.SaveQuestionnaire> params) throws Exception {
log.info("保存调查筛查开始{}", params); log.info("保存调查筛查开始{}", params);
// changeDataSource(params.getParam().getTenantId());
screeningService.saveQuestionnaire(params.getParam(), params.getParam().getUserId()); screeningService.saveQuestionnaire(params.getParam(), params.getParam().getUserId());
log.info("保存调查筛查结束"); log.info("保存调查筛查结束");
return JsonResponse.ok(); return JsonResponse.ok();

422
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/TaskController.java

@ -1,211 +1,211 @@
package com.acupuncture.web.controller.web; //package com.acupuncture.web.controller.web;
//
import cn.hutool.core.bean.BeanUtil; //import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; //import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; //import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; //import cn.hutool.core.util.IdUtil;
import com.acupuncture.common.annotation.Anonymous; //import com.acupuncture.common.annotation.Anonymous;
import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; //import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder;
import com.acupuncture.system.domain.po.FmsFollowupTask; //import com.acupuncture.system.domain.po.FmsFollowupTask;
import com.acupuncture.system.domain.po.FmsPatientQueueRelation; //import com.acupuncture.system.domain.po.FmsPatientQueueRelation;
import com.acupuncture.system.domain.vo.FmsFollowupVo; //import com.acupuncture.system.domain.vo.FmsFollowupVo;
import com.acupuncture.system.domain.vo.UmsDataSourceVo; //import com.acupuncture.system.domain.vo.UmsDataSourceVo;
import com.acupuncture.system.persist.dao.FmsFollowupDao; //import com.acupuncture.system.persist.dao.FmsFollowupDao;
import com.acupuncture.system.persist.dao.UmsDataSourceDao; //import com.acupuncture.system.persist.dao.UmsDataSourceDao;
import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper; //import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper;
import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper; //import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.quartz.TriggerUtils; //import org.quartz.TriggerUtils;
import org.quartz.impl.triggers.CronTriggerImpl; //import org.quartz.impl.triggers.CronTriggerImpl;
import org.springframework.scheduling.annotation.Scheduled; //import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Propagation; //import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; //import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
//
import javax.annotation.Resource; //import javax.annotation.Resource;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Calendar; //import java.util.Calendar;
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
//
/** ///**
* @Author zzc // * @Author zzc
* @Package com.acupuncture.web.controller.web // * @Package com.acupuncture.web.controller.web
* @Date 2025/2/13 8:50 // * @Date 2025/2/13 8:50
* @description: // * @description:
*/ // */
@Slf4j //@Slf4j
@Api(tags = "定时任务相关") //@Api(tags = "定时任务相关")
@RestController //@RestController
@RequestMapping("/task") //@RequestMapping("/task")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) //@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class TaskController { //public class TaskController {
//
@Resource // @Resource
private FmsFollowupDao fmsFollowupDao; // private FmsFollowupDao fmsFollowupDao;
@Resource // @Resource
private FmsFollowupTaskMapper fmsFollowupTaskMapper; // private FmsFollowupTaskMapper fmsFollowupTaskMapper;
@Resource // @Resource
private UmsDataSourceDao umsDataSourceDao; // private UmsDataSourceDao umsDataSourceDao;
@Resource // @Resource
private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper; // private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper;
//
@ApiOperation("定时任务添加随访工单") // @ApiOperation("定时任务添加随访工单")
@PostMapping("/task") // @PostMapping("/task")
// @Scheduled(fixedRate = 10000) //// @Scheduled(fixedRate = 10000)
@Anonymous // @Anonymous
public void task() { // public void task() {
// TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 ) // // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 )
//
//查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单 // //查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单
// UmsDataSourceVo.Result result1 = new UmsDataSourceVo.Result(); //// UmsDataSourceVo.Result result1 = new UmsDataSourceVo.Result();
// result1.setDataSourceKey("MASTER"); //// result1.setDataSourceKey("MASTER");
// changeDataSource(result1); //// changeDataSource(result1);
List<UmsDataSourceVo.Result> query = umsDataSourceDao.query(null); // List<UmsDataSourceVo.Result> query = umsDataSourceDao.query(null);
if (CollectionUtil.isEmpty(query)) { // if (CollectionUtil.isEmpty(query)) {
return; // return;
} // }
//查询公共队列 // //查询公共队列
List<FmsFollowupVo.FollowupQueueVO> queueResults = fmsFollowupDao.queryCommonQueue(null); // List<FmsFollowupVo.FollowupQueueVO> queueResults = fmsFollowupDao.queryCommonQueue(null);
//切换数据源 // //切换数据源
for (UmsDataSourceVo.Result result : query) { // for (UmsDataSourceVo.Result result : query) {
if ("MASTER".equals(result.getDataSourceKey())) { // if ("MASTER".equals(result.getDataSourceKey())) {
continue; // continue;
} // }
changeDataSource(result); // changeDataSource(result);
{ // {
//获取随访患者列表,根据患者出院日时间和队列添加工单 // //获取随访患者列表,根据患者出院日时间和队列添加工单
//1. 查询队列 // //1. 查询队列
List<FmsFollowupVo.FollowupQueueVO> queueList = fmsFollowupDao.selectQueueList(null, null, null, result.getTenantId()); // List<FmsFollowupVo.FollowupQueueVO> queueList = fmsFollowupDao.selectQueueList(null, null, null, result.getTenantId());
//
if (CollectionUtil.isEmpty(queueList)) { // if (CollectionUtil.isEmpty(queueList)) {
queueList = queueResults; // queueList = queueResults;
} else { // } else {
queueList.addAll(queueResults); // queueList.addAll(queueResults);
} // }
for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) { // for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) {
//2. 查询队列随访患者列表 // //2. 查询队列随访患者列表
List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), (byte) 0, null, followupQueueVO.getTenantId()); // List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), (byte) 0, null, followupQueueVO.getTenantId());
if (CollectionUtil.isEmpty(patientList)) { // if (CollectionUtil.isEmpty(patientList)) {
continue; // continue;
} // }
//随访总月数 // //随访总月数
Integer followupMonth = followupQueueVO.getFollowupMonth(); // Integer followupMonth = followupQueueVO.getFollowupMonth();
for (FmsFollowupVo.FollowupPatient followupPatient : patientList) { // for (FmsFollowupVo.FollowupPatient followupPatient : patientList) {
//获取随访到期时间 出院时间+随访总月数 = 到期时间 // //获取随访到期时间 出院时间+随访总月数 = 到期时间
Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
calendar.setTime(followupPatient.getDischargeTime()); // calendar.setTime(followupPatient.getDischargeTime());
calendar.set(Calendar.MONTH, followupMonth); // calendar.set(Calendar.MONTH, followupMonth);
Date time = calendar.getTime(); // Date time = calendar.getTime();
//
//获取队列信息 // //获取队列信息
String frequency = followupQueueVO.getFrequency(); // String frequency = followupQueueVO.getFrequency();
List<Date> dateList = new ArrayList<>(); // List<Date> dateList = new ArrayList<>();
try { // try {
CronTriggerImpl cronTrigger = new CronTriggerImpl(); // CronTriggerImpl cronTrigger = new CronTriggerImpl();
cronTrigger.setCronExpression(frequency); // cronTrigger.setCronExpression(frequency);
//TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点); // //TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点);
dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time); // dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time);
if (CollectionUtil.isEmpty(dateList)) { // if (CollectionUtil.isEmpty(dateList)) {
continue; // continue;
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//3. 判断随访类型 // //3. 判断随访类型
if (followupQueueVO.getFollowupType() == 0) { // if (followupQueueVO.getFollowupType() == 0) {
//单次 // //单次
FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); // FmsFollowupTask fmsFollowupTask = new FmsFollowupTask();
BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); // BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask);
fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); // fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
fmsFollowupTask.setName(followupPatient.getName()); // fmsFollowupTask.setName(followupPatient.getName());
fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); // fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull());
fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); // fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple());
fmsFollowupTask.setGender(followupPatient.getGender()); // fmsFollowupTask.setGender(followupPatient.getGender());
if (followupPatient.getBirthDate() != null) { // if (followupPatient.getBirthDate() != null) {
fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); // fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date()));
} // }
fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); // fmsFollowupTask.setEthnicity(followupPatient.getEthnicity());
fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); // fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
fmsFollowupTask.setPhone(followupPatient.getPhone()); // fmsFollowupTask.setPhone(followupPatient.getPhone());
fmsFollowupTask.setTenantId(followupPatient.getTenantId()); // fmsFollowupTask.setTenantId(followupPatient.getTenantId());
fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); // fmsFollowupTask.setIdCardType(followupPatient.getIdCardType());
fmsFollowupTask.setIdCard(followupPatient.getIdCard()); // fmsFollowupTask.setIdCard(followupPatient.getIdCard());
fmsFollowupTask.setTimes(1); // fmsFollowupTask.setTimes(1);
fmsFollowupTask.setQueueId(followupQueueVO.getId()); // fmsFollowupTask.setQueueId(followupQueueVO.getId());
fmsFollowupTask.setPatientId(followupPatient.getId()); // fmsFollowupTask.setPatientId(followupPatient.getId());
fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); // fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
fmsFollowupTask.setDelFlag((byte) 0); // fmsFollowupTask.setDelFlag((byte) 0);
fmsFollowupTask.setCreateTime(new Date()); // fmsFollowupTask.setCreateTime(new Date());
fmsFollowupTask.setStatus((byte) 0); // fmsFollowupTask.setStatus((byte) 0);
fmsFollowupTask.setStartTime(dateList.get(0)); // fmsFollowupTask.setStartTime(dateList.get(0));
fmsFollowupTask.setEndTime(dateList.get(0)); // fmsFollowupTask.setEndTime(dateList.get(0));
fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); // fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge());
fmsFollowupTask.setFollowupTime(dateList.get(0)); // fmsFollowupTask.setFollowupTime(dateList.get(0));
changeDataSource(result); // changeDataSource(result);
fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); // fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
//
} else { // } else {
//周期 // //周期
//4. 根据频次和总月数添加 // //4. 根据频次和总月数添加
int i = 0; // int i = 0;
for (Date date : dateList) { // for (Date date : dateList) {
i+=1; // i+=1;
//单次 // //单次
FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); // FmsFollowupTask fmsFollowupTask = new FmsFollowupTask();
BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); // BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask);
fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); // fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
fmsFollowupTask.setName(followupPatient.getName()); // fmsFollowupTask.setName(followupPatient.getName());
fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); // fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull());
fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); // fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple());
fmsFollowupTask.setGender(followupPatient.getGender()); // fmsFollowupTask.setGender(followupPatient.getGender());
if (followupPatient.getBirthDate() != null) { // if (followupPatient.getBirthDate() != null) {
fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); // fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date()));
} // }
fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); // fmsFollowupTask.setEthnicity(followupPatient.getEthnicity());
fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); // fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
fmsFollowupTask.setTimes(i); // fmsFollowupTask.setTimes(i);
fmsFollowupTask.setPhone(followupPatient.getPhone()); // fmsFollowupTask.setPhone(followupPatient.getPhone());
fmsFollowupTask.setTenantId(followupPatient.getTenantId()); // fmsFollowupTask.setTenantId(followupPatient.getTenantId());
fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); // fmsFollowupTask.setIdCardType(followupPatient.getIdCardType());
fmsFollowupTask.setIdCard(followupPatient.getIdCard()); // fmsFollowupTask.setIdCard(followupPatient.getIdCard());
fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); // fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
fmsFollowupTask.setQueueId(followupQueueVO.getId()); // fmsFollowupTask.setQueueId(followupQueueVO.getId());
fmsFollowupTask.setDelFlag((byte) 0); // fmsFollowupTask.setDelFlag((byte) 0);
fmsFollowupTask.setCreateTime(new Date()); // fmsFollowupTask.setCreateTime(new Date());
fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); // fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
fmsFollowupTask.setStatus((byte) 0); // fmsFollowupTask.setStatus((byte) 0);
fmsFollowupTask.setStartTime(date); // fmsFollowupTask.setStartTime(date);
fmsFollowupTask.setEndTime(date); // fmsFollowupTask.setEndTime(date);
fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); // fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge());
fmsFollowupTask.setFollowupTime(date); // fmsFollowupTask.setFollowupTime(date);
changeDataSource(result); // changeDataSource(result);
fmsFollowupTask.setPatientId(followupPatient.getId()); // fmsFollowupTask.setPatientId(followupPatient.getId());
fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); // fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
} // }
} // }
changeDataSource(result); // changeDataSource(result);
//将患者设置为已生成工单 // //将患者设置为已生成工单
FmsPatientQueueRelation fmsPatientQueueRelation = BeanUtil.copyProperties(followupPatient, FmsPatientQueueRelation.class); // FmsPatientQueueRelation fmsPatientQueueRelation = BeanUtil.copyProperties(followupPatient, FmsPatientQueueRelation.class);
fmsPatientQueueRelation.setTaskFlag((byte) 1); // fmsPatientQueueRelation.setTaskFlag((byte) 1);
fmsPatientQueueRelation.setPatientId(followupPatient.getId()); // fmsPatientQueueRelation.setPatientId(followupPatient.getId());
fmsPatientQueueRelationMapper.updateByPrimaryKeySelective(fmsPatientQueueRelation); // fmsPatientQueueRelationMapper.updateByPrimaryKeySelective(fmsPatientQueueRelation);
} // }
} // }
//
} // }
} // }
} // }
//
private static void changeDataSource(UmsDataSourceVo.Result result) { // private static void changeDataSource(UmsDataSourceVo.Result result) {
try { // try {
DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey()); // DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey());
}finally { // }finally {
DynamicDataSourceContextHolder.clearDataSourceType(); // DynamicDataSourceContextHolder.clearDataSourceType();
} // }
} // }
} //}

2
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/WxQrCodeController.java

@ -1,7 +1,5 @@
package com.acupuncture.web.controller.web; package com.acupuncture.web.controller.web;
import cn.hutool.core.bean.BeanUtil;
import com.acupuncture.common.annotation.Anonymous;
import com.acupuncture.common.core.domain.BaseDto; import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse; import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.system.domain.dto.AmsWxQrCodeDto; import com.acupuncture.system.domain.dto.AmsWxQrCodeDto;

664
acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java

@ -1,343 +1,361 @@
//package com.acupuncture.web.controller.web; package com.acupuncture.web.task;
//
//import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
//import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
//import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
//import com.acupuncture.common.annotation.Anonymous; import cn.hutool.core.util.StrUtil;
//import com.acupuncture.common.core.redis.RedisCache; import com.acupuncture.common.annotation.Anonymous;
//import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; import com.acupuncture.common.core.redis.RedisCache;
//import com.acupuncture.system.domain.dto.FmsFollowupDto; import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder;
//import com.acupuncture.system.domain.po.FmsFollowupTask; import com.acupuncture.system.domain.dto.FmsFollowupDto;
//import com.acupuncture.system.domain.po.FmsFollowupTaskExample; import com.acupuncture.system.domain.po.FmsFollowupTask;
//import com.acupuncture.system.domain.po.FmsPatientQueueRelation; import com.acupuncture.system.domain.po.FmsFollowupTaskExample;
//import com.acupuncture.system.domain.vo.FmsFollowupVo; import com.acupuncture.system.domain.po.FmsPatientQueueRelation;
//import com.acupuncture.system.domain.vo.UmsDataSourceVo; import com.acupuncture.system.domain.vo.FmsFollowupVo;
//import com.acupuncture.system.persist.dao.FmsFollowupDao; import com.acupuncture.system.domain.vo.UmsDataSourceVo;
//import com.acupuncture.system.persist.dao.UmsDataSourceDao; import com.acupuncture.system.persist.dao.FmsFollowupDao;
//import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper; import com.acupuncture.system.persist.dao.UmsDataSourceDao;
//import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper; import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper;
//import com.acupuncture.system.service.FmsFollowupQueueService; import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper;
//import com.acupuncture.system.service.FmsFollowupService; import com.acupuncture.system.service.FmsFollowupQueueService;
//import io.swagger.annotations.Api; import com.acupuncture.system.service.FmsFollowupService;
//import io.swagger.annotations.ApiOperation; import io.swagger.annotations.Api;
//import lombok.Data; import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j; import lombok.Data;
//import org.apache.catalina.connector.Response; import lombok.extern.slf4j.Slf4j;
//import org.quartz.TriggerUtils; import org.quartz.TriggerUtils;
//import org.quartz.impl.triggers.CronTriggerImpl; import org.quartz.impl.triggers.CronTriggerImpl;
//import org.quartz.spi.OperableTrigger; import org.quartz.spi.OperableTrigger;
//import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource; import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest; import java.util.*;
//import javax.servlet.http.HttpServletResponse; import java.util.stream.Collectors;
//import java.util.*;
//import java.util.regex.Matcher; /**
//import java.util.regex.Pattern; * @Author zzc
// * @Package com.acupuncture.web.controller.web
///** * @Date 2025/2/13 8:50
// * @Author zzc * @description:
// * @Package com.acupuncture.web.controller.web */
// * @Date 2025/2/13 8:50 @Slf4j
// * @description: @Api(tags = "定时任务相关")
// */ @RestController
//@Slf4j @RequestMapping("/task")
//@Api(tags = "定时任务相关") @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
//@RestController public class TaskController {
//@RequestMapping("/task")
//@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Resource
//public class TaskController { private FmsFollowupDao fmsFollowupDao;
// @Resource
// @Resource private FmsFollowupService fmsFollowupService;
// private FmsFollowupDao fmsFollowupDao; @Resource
// @Resource private FmsFollowupTaskMapper fmsFollowupTaskMapper;
// private FmsFollowupService fmsFollowupService; @Resource
// @Resource private UmsDataSourceDao umsDataSourceDao;
// private FmsFollowupTaskMapper fmsFollowupTaskMapper; @Resource
// @Resource private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper;
// private UmsDataSourceDao umsDataSourceDao; @Resource
// @Resource private RedisCache redisCache;
// private RedisCache redisCache; @Resource
// @Resource private FmsFollowupQueueService fmsFollowupQueueService;
// private FmsFollowupQueueService fmsFollowupQueueService;
// /**
// @ApiOperation("定时任务添加随访工单") * 处理业务
// @PostMapping("/task") *
// @Scheduled(fixedDelay = 10000) * @param tenandId 租户用户
// @Anonymous * @param commonQueue 公共队列
// public void task() { */
// // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 ) public void doTask(Long tenandId, List<FmsFollowupVo.FollowupQueueVO> commonQueue) {
// //查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单 //查询从库队列
//// UmsDataSourceVo.Result result1 = new UmsDataSourceVo.Result(); //1. 查询队列
//// result1.setDataSourceKey("MASTER"); List<FmsFollowupVo.FollowupQueueVO> slavelQueueList = fmsFollowupDao.selectQueueList(null, null, null, null);
//// changeDataSource(result1);
//// List<UmsDataSourceVo.Result> query = umsDataSourceDao.query(null); //合并公共队列和从库的队列
//// if (CollectionUtil.isEmpty(query)) { slavelQueueList.addAll(commonQueue);
//// return;
//// } //查询每个队列的对象
// //查询公共队列 for (FmsFollowupVo.FollowupQueueVO queue : slavelQueueList) {
// List<Object> queueResults = redisCache.getCacheList("common_followup_queue"); FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO();
// List<FmsFollowupVo.FollowupQueueVO> followupQueueVOS = new ArrayList<>(); followupPatientQueryDTO.setQueueId(queue.getId());
// if (CollectionUtil.isEmpty(queueResults)) { followupPatientQueryDTO.setTenantId(queue.getTenantId());
// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO);
// followupQueueVOS = fmsFollowupQueueService.queryCommonQueue(null); log.info("查询每个队列的对象:{}", patientList);
// } }
//// List<FmsFollowupVo.FollowupQueueVO> queueResults = fmsFollowupDao.queryCommonQueue(null);
// //切换数据源 //定时任务
//// for (UmsDataSourceVo.Result result : query) {
//// if ("MASTER".equals(result.getDataSourceKey()) || "PROD_YY".equals(result.getDataSourceKey())) { // //循环租户
//// continue; // for (UmsDataSourceVo.Result tenant : tenantList) {
//// } // if ("MASTER".equals(tenant.getDataSourceKey())) {
//// changeDataSource(result); // continue;
// { // }
// //获取随访患者列表,根据患者出院日时间和队列添加工单 // changeDataSource(tenant);
// //1. 查询队列 // {
// List<FmsFollowupVo.FollowupQueueVO> queueList = fmsFollowupDao.selectQueueList(null, null, null, null); // //获取随访患者列表,根据患者出院日时间和队列添加工单
// //1. 查询队列
// List<FmsFollowupVo.FollowupQueueVO> queueList = fmsFollowupDao.selectQueueList(null, null, null, null);
// //
// if (CollectionUtil.isEmpty(queueList)) { // if (CollectionUtil.isEmpty(queueList)) {
// if (CollectionUtil.isEmpty(queueResults)) {
// queueList = followupQueueVOS; // queueList = followupQueueVOS;
// } else {
// if (CollectionUtil.isEmpty(followupQueueVOS)) {
// queueList.addAll(followupQueueVOS);
// }
// } // }
// } else { // for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) {
// if (CollectionUtil.isEmpty(queueResults)) { // Integer followWindowAdys = followupQueueVO.getFollowWindowAdys();
// queueList.addAll(followupQueueVOS);
// }
// }
// for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) {
// Integer followWindowAdys = followupQueueVO.getFollowWindowAdys();
// //
// //2. 查询队列随访患者列表 // //2. 查询队列随访患者列表
//// changeDataSource(result); //// changeDataSource(result);
// FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO(); // FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO();
// followupPatientQueryDTO.setQueueId(followupQueueVO.getId()); // followupPatientQueryDTO.setQueueId(followupQueueVO.getId());
// followupPatientQueryDTO.setTenantId(followupQueueVO.getTenantId()); // followupPatientQueryDTO.setTenantId(followupQueueVO.getTenantId());
//// changeDataSource(result); // changeDataSource(result);
// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupService.queryTaskPatient(followupPatientQueryDTO);
//// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), null, null);
// if (CollectionUtil.isEmpty(patientList)) {
// continue;
// }
// //随访总月数
// Integer followupMonth = followupQueueVO.getFollowupMonth();
// for (FmsFollowupVo.FollowupPatient followupPatient : patientList) {
// //获取随访到期时间 出院时间+随访总月数 = 到期时间
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(followupPatient.getDischargeTime());
// calendar.set(Calendar.MONTH, followupMonth);
// Date time = calendar.getTime();
// //
// //获取队列信息 // List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO);
// String frequency = followupQueueVO.getFrequency(); //// List<FmsFollowupVo.FollowupPatient> patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), null, null);
// List<Date> dateList = new ArrayList<>(); // if (CollectionUtil.isEmpty(patientList)) {
// try { // continue;
// CronTriggerImpl cronTrigger = new CronTriggerImpl();
// cronTrigger.setCronExpression(frequency);
// //TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点);
// dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time);
// if (CollectionUtil.isEmpty(dateList)) {
// continue;
// }
// } catch (Exception e) {
// e.printStackTrace();
// } // }
// //3. 判断随访类型 // //随访总月数
// if (followupQueueVO.getFollowupType() == 0) { // Integer followupMonth = followupQueueVO.getFollowupMonth();
// //单次 // for (FmsFollowupVo.FollowupPatient followupPatient : patientList) {
// //判断是否已有该次随访 // //获取随访到期时间 出院时间+随访总月数 = 到期时间
// FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); // Calendar calendar = Calendar.getInstance();
// fmsFollowupTaskExample.createCriteria().andTimesEqualTo(1).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); // calendar.setTime(followupPatient.getDischargeTime());
// List<FmsFollowupTask> fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); // calendar.set(Calendar.MONTH, followupMonth);
// if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { // Date time = calendar.getTime();
// continue;
// }
// FmsFollowupTask fmsFollowupTask = new FmsFollowupTask();
// BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask);
// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
// fmsFollowupTask.setName(followupPatient.getName());
// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull());
// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple());
// fmsFollowupTask.setGender(followupPatient.getGender());
// if (followupPatient.getBirthDate() != null) {
// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date()));
// }
// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setPhone(followupPatient.getPhone());
// fmsFollowupTask.setTenantId(followupPatient.getTenantId());
// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType());
// fmsFollowupTask.setIdCard(followupPatient.getIdCard());
// fmsFollowupTask.setTimes(1);
// fmsFollowupTask.setQueueId(followupQueueVO.getId());
// fmsFollowupTask.setPatientId(followupPatient.getId());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setDelFlag((byte) 0);
// fmsFollowupTask.setCreateTime(new Date());
// fmsFollowupTask.setStatus((byte) 0);
// //
// //计算第一次随访的时间 // //获取队列信息
// DateComparator dateComparator = getDate(dateList); // String frequency = followupQueueVO.getFrequency();
// if (dateComparator.getDate() != null) { // List<Date> dateList = new ArrayList<>();
// fmsFollowupTask.setStartTime(dateComparator.getDate()); // try {
// } else { // CronTriggerImpl cronTrigger = new CronTriggerImpl();
// Calendar instance = Calendar.getInstance(); // cronTrigger.setCronExpression(frequency);
// instance.setTime(dateList.get(0)); // //TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点);
// instance.add(Calendar.DATE, -followWindowAdys / 2); // dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time);
// fmsFollowupTask.setStartTime(instance.getTime()); // if (CollectionUtil.isEmpty(dateList)) {
// continue;
// }
// } catch (Exception e) {
// e.printStackTrace();
// } // }
// Calendar instance1 = Calendar.getInstance(); // //3. 判断随访类型
// instance1.setTime(dateList.get(0)); // if (followupQueueVO.getFollowupType() == 0) {
// instance1.add(Calendar.DATE, followWindowAdys / 2); // //单次
// fmsFollowupTask.setEndTime(instance1.getTime());
// fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge());
// fmsFollowupTask.setFollowupTime(dateList.get(0));
//// changeDataSource(result);
// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
// //
// } else { // //判断是否已有该次随访
// //周期 // FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample();
// //4. 根据频次和总月数添加 // fmsFollowupTaskExample.createCriteria().andTimesEqualTo(1).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId());
// DateComparator dateComparator = getDate(dateList); // List<FmsFollowupTask> fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample);
// if (dateComparator.getDate() == null || dateComparator.getIndex() == null) { // if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) {
// continue; // continue;
// } // }
// Date date = dateComparator.getDate(); // FmsFollowupTask fmsFollowupTask = new FmsFollowupTask();
// Integer index = dateComparator.getIndex(); // BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask);
// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
// fmsFollowupTask.setName(followupPatient.getName());
// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull());
// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple());
// fmsFollowupTask.setGender(followupPatient.getGender());
// if (followupPatient.getBirthDate() != null) {
// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date()));
// }
// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setPhone(followupPatient.getPhone());
// fmsFollowupTask.setTenantId(followupPatient.getTenantId());
// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType());
// fmsFollowupTask.setIdCard(followupPatient.getIdCard());
// fmsFollowupTask.setTimes(1);
// fmsFollowupTask.setQueueId(followupQueueVO.getId());
// fmsFollowupTask.setPatientId(followupPatient.getId());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setDelFlag((byte) 0);
// fmsFollowupTask.setCreateTime(new Date());
// fmsFollowupTask.setStatus((byte) 0);
// //
// //判断是否已有该次随访 // //计算第一次随访的时间
// FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); // DateComparator dateComparator = getDate(dateList);
// fmsFollowupTaskExample.createCriteria().andTimesEqualTo(index).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); // if (dateComparator.getDate() != null) {
// List<FmsFollowupTask> fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); // fmsFollowupTask.setStartTime(dateComparator.getDate());
// if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { // } else {
// continue; // Calendar instance = Calendar.getInstance();
// } // instance.setTime(dateList.get(0));
// // instance.add(Calendar.DATE, -followWindowAdys / 2);
// FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); // fmsFollowupTask.setStartTime(instance.getTime());
// BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); // }
// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); // Calendar instance1 = Calendar.getInstance();
// fmsFollowupTask.setName(followupPatient.getName()); // instance1.setTime(dateList.get(0));
// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); // instance1.add(Calendar.DATE, followWindowAdys / 2);
// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); // fmsFollowupTask.setEndTime(instance1.getTime());
// fmsFollowupTask.setGender(followupPatient.getGender()); // fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge());
// if (followupPatient.getBirthDate() != null) { // fmsFollowupTask.setFollowupTime(dateList.get(0));
// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); // changeDataSource(result);
// } // fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setTimes(index);
// fmsFollowupTask.setPhone(followupPatient.getPhone());
// fmsFollowupTask.setTenantId(followupPatient.getTenantId());
// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType());
// fmsFollowupTask.setIdCard(followupPatient.getIdCard());
// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
// fmsFollowupTask.setQueueId(followupQueueVO.getId());
// fmsFollowupTask.setDelFlag((byte) 0);
// fmsFollowupTask.setCreateTime(new Date());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setStatus((byte) 0);
//
// fmsFollowupTask.setStartTime(date);
// Calendar instance = Calendar.getInstance();
// instance.setTime(date);
// instance.add(Calendar.DATE, followWindowAdys / 2);
//
// fmsFollowupTask.setEndTime(instance.getTime());
//// changeDataSource(result);
// fmsFollowupTask.setPatientId(followupPatient.getId());
// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
// }
// }
// }
// }
// }
// //
// private static void changeDataSource(UmsDataSourceVo.Result result) { // } else {
// try { // //周期
// DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey()); // //4. 根据频次和总月数添加
// } finally { // DateComparator dateComparator = getDate(dateList);
// DynamicDataSourceContextHolder.clearDataSourceType(); // if (dateComparator.getDate() == null || dateComparator.getIndex() == null) {
// } // continue;
// } // }
// Date date = dateComparator.getDate();
// Integer index = dateComparator.getIndex();
// //
// public String getName(String url) { // //判断是否已有该次随访
// Pattern pattern = Pattern.compile("jdbc:mysql://[^/]+/([^?]+)"); // FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample();
// Matcher matcher = pattern.matcher(url); // fmsFollowupTaskExample.createCriteria().andTimesEqualTo(index).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId());
// if (matcher.find()) { // List<FmsFollowupTask> fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample);
// String dbName = matcher.group(1); // 输出 acupuncture_yfyy // if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) {
// System.out.println("数据库名称: " + dbName); // continue;
// return dbName; // }
// }
// return "";
// }
// //
// /** // FmsFollowupTask fmsFollowupTask = new FmsFollowupTask();
// * 法用于计算在指定时间范围内触发器的触发时间点。具体步骤如下: // BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask);
// * 初始化一个空列表 lst 存储触发时间点。 // fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
// * 克隆传入的触发器 trigg,并检查其下一个触发时间是否为空。如果为空,则设置开始时间和结束时间,并计算首次触发时间。 // fmsFollowupTask.setName(followupPatient.getName());
// * 使用 while 循环遍历触发器的触发时间点,直到没有更多触发时间或超出指定范围。 // fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull());
// * 如果触发时间在指定范围内,则将其添加到列表中,并更新触发器状态。 // fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple());
// * // fmsFollowupTask.setGender(followupPatient.getGender());
// * @param trigg cron表达式 // if (followupPatient.getBirthDate() != null) {
// * @param from 患者出院时间 // fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date()));
// * @param to 患者出院时间 + 随访总月数 // }
// * @return // fmsFollowupTask.setEthnicity(followupPatient.getEthnicity());
// */ // fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// public static List<Date> computeFireTimesBetween(OperableTrigger trigg, org.quartz.Calendar cal, Date from, Date to) { // fmsFollowupTask.setTimes(index);
// LinkedList<Date> lst = new LinkedList(); // fmsFollowupTask.setPhone(followupPatient.getPhone());
// OperableTrigger t = (OperableTrigger) trigg.clone(); // fmsFollowupTask.setTenantId(followupPatient.getTenantId());
// if (t.getNextFireTime() == null) { // fmsFollowupTask.setIdCardType(followupPatient.getIdCardType());
// t.setStartTime(from); // fmsFollowupTask.setIdCard(followupPatient.getIdCard());
// t.setEndTime(to); // fmsFollowupTask.setId(IdUtil.getSnowflakeNextId());
// t.computeFirstFireTime(cal); // fmsFollowupTask.setQueueId(followupQueueVO.getId());
// } // fmsFollowupTask.setDelFlag((byte) 0);
// fmsFollowupTask.setCreateTime(new Date());
// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears());
// fmsFollowupTask.setStatus((byte) 0);
// //
// while (true) { // fmsFollowupTask.setStartTime(date);
// Date d = t.getNextFireTime(); // Calendar instance = Calendar.getInstance();
// if (d == null) { // instance.setTime(date);
// break; // instance.add(Calendar.DATE, followWindowAdys / 2);
// }
// //
// if (d.before(from)) { // fmsFollowupTask.setEndTime(instance.getTime());
// t.triggered(cal); // changeDataSource(result);
// } else { // fmsFollowupTask.setPatientId(followupPatient.getId());
// if (d.after(to)) { // fmsFollowupTaskMapper.insertSelective(fmsFollowupTask);
// break; // }
// }
// } // }
// lst.add(d);
// t.triggered(cal);
// }
// }
// return Collections.unmodifiableList(lst);
// }
// //
// /**
// * 返回当前时间之后的第一个date及对应顺序
// *
// * @param dateList key 为顺序,value 为时间
// * @return
// */
// public static DateComparator getDate(List<Date> dateList) {
// Date today = new Date();
// DateComparator dateComparator = new DateComparator();
// for (int i = 0; i < dateList.size(); i++) {
// Date date = dateList.get(i);
// if (date.after(today)) {
// dateComparator.setDate(date);
// dateComparator.setIndex(i + 1);
// return dateComparator;
// } // }
// } // }
// return dateComparator; }
// }
// @ApiOperation("定时任务添加随访工单")
// @Data @PostMapping("/task")
// public static class DateComparator { @Scheduled(cron = "0 0 0 * * ?")
// private Date date; @Anonymous
// private Integer index; public void task() {
// } // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 )
//}
//查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单
List<UmsDataSourceVo.Result> tenantList = umsDataSourceDao.query(null);
if (CollectionUtil.isEmpty(tenantList)) {
return;
}
//过滤掉没有数据源的租户
tenantList = tenantList.stream().filter(result -> StrUtil.isNotEmpty(result.getDataSourceKey())).collect(Collectors.toList());
//查询公共队列
List<FmsFollowupVo.FollowupQueueVO> followupQueueVOS = fmsFollowupQueueService.queryCommonQueue(null);
//循环租户
for (UmsDataSourceVo.Result tenant : tenantList) {
//切换数据源
DynamicDataSourceContextHolder.setDataSourceType(tenant.getDataSourceKey());
//处理从库业务
doTask(tenant.getTenantId(), followupQueueVOS);
//销毁数据源
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
/**
* 法用于计算在指定时间范围内触发器的触发时间点具体步骤如下
* 初始化一个空列表 lst 存储触发时间点
* 克隆传入的触发器 trigg并检查其下一个触发时间是否为空如果为空则设置开始时间和结束时间并计算首次触发时间
* 使用 while 循环遍历触发器的触发时间点直到没有更多触发时间或超出指定范围
* 如果触发时间在指定范围内则将其添加到列表中并更新触发器状态
*
* @param trigg cron表达式
* @param from 患者出院时间
* @param to 患者出院时间 + 随访总月数
* @return
*/
public static List<Date> computeFireTimesBetween(OperableTrigger trigg, org.quartz.Calendar cal, Date from, Date to) {
LinkedList<Date> lst = new LinkedList();
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.setStartTime(from);
t.setEndTime(to);
t.computeFirstFireTime(cal);
}
while (true) {
Date d = t.getNextFireTime();
if (d == null) {
break;
}
if (d.before(from)) {
t.triggered(cal);
} else {
if (d.after(to)) {
break;
}
lst.add(d);
t.triggered(cal);
}
}
return Collections.unmodifiableList(lst);
}
/**
* 返回当前时间之后的第一个date及对应顺序
*
* @param dateList key 为顺序value 为时间
* @return
*/
public static DateComparator getDate(List<Date> dateList) {
Date today = new Date();
DateComparator dateComparator = new DateComparator();
for (int i = 0; i < dateList.size(); i++) {
Date date = dateList.get(i);
if (date.after(today)) {
dateComparator.setDate(date);
dateComparator.setIndex(i + 1);
return dateComparator;
}
}
return dateComparator;
}
@Data
public static class DateComparator {
private Date date;
private Integer index;
}
}

56
acupuncture-framework/src/main/java/com/acupuncture/framework/aspectj/AdminGlobalDataSourceAspect.java

@ -37,8 +37,6 @@ import javax.servlet.http.HttpServletRequest;
public class AdminGlobalDataSourceAspect { public class AdminGlobalDataSourceAspect {
protected Logger logger = LoggerFactory.getLogger(getClass()); protected Logger logger = LoggerFactory.getLogger(getClass());
// @Autowired
// private UmsDataSourceMapper umsDataSourceMapper;
@Resource @Resource
private DmsLoginService dmsLoginService; private DmsLoginService dmsLoginService;
@ -51,10 +49,16 @@ public class AdminGlobalDataSourceAspect {
@Around("dsPointCut()") @Around("dsPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable { public Object around(ProceedingJoinPoint point) throws Throwable {
String dataSourceKey = getDataSource(point); //获取datasource
try {
if (StringUtils.isNotNull(dataSourceKey)) { String dataSourceKey = getDataSource(point);
DataSourceManager.setDataSourceKey(dataSourceKey); if (StringUtils.isNotEmpty(dataSourceKey)) {
DataSourceManager.setDataSourceKey(dataSourceKey);
} else {
DataSourceManager.setDataSourceKey(null);
}
}catch (Exception e){
throw new BaseException(StrUtil.format("获取数据源错误:{}", e));
} }
try { try {
@ -70,41 +74,25 @@ public class AdminGlobalDataSourceAspect {
*/ */
public String getDataSource(ProceedingJoinPoint point) { public String getDataSource(ProceedingJoinPoint point) {
// 获取请求携带的令牌 // 获取请求携带的令牌
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) HttpServletRequest request = ((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes(); RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletRequest request; Long tenantId = null;
if (requestAttributes == null) {
DynamicDataSourceContextHolder.getDataSourceType();
return DynamicDataSourceContextHolder.getDataSourceType();
}
request = requestAttributes.getRequest();
//token为空
Long tenantId;
String header = request.getHeader(UserConstants.DEPT); String header = request.getHeader(UserConstants.DEPT);
if(StrUtil.isNotEmpty(header)){ if(StrUtil.isNotEmpty(header)){
tenantId = Long.parseLong(header); tenantId = Long.parseLong(header);
}else { }else {
// String deptId = request.getHeader(WebConstant.HEADER_KEY_DEPT_ID); if (StrUtil.isNotEmpty(request.getHeader(UserConstants.HEADER_KEY_TOKEN))) {
String authHeader = request.getHeader(UserConstants.HEADER_KEY_TOKEN); tenantId = SecurityUtils.getTenantId();
if (StrUtil.isEmpty(authHeader)) {
return null;
}
tenantId = SecurityUtils.getTenantId();
if (tenantId == null) {
return null;
} }
} }
//设置所属医院和数据源l
// LoginUser loginUser = SecurityUtils.getLoginUser();
// if(ObjectUtil.isNull(loginUser) || loginUser.getUser().isAdmin()){
// return null;
// }
//根据组织ID查询数据源 //根据组织ID查询数据源
UmsDataSource dataSource = dmsLoginService.getDataSourceByTenantId(tenantId); if(tenantId !=null) {
if (dataSource == null) { UmsDataSource dataSource = dmsLoginService.getDataSourceByTenantId(tenantId);
throw new BaseException(DATASOURCE_NOT_FOUND); if (dataSource == null) {
throw new BaseException(DATASOURCE_NOT_FOUND);
}
return dataSource.getDataSourceKey();
} }
return dataSource.getDataSourceKey(); return null;
} }
} }

1
acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/UserDetailsServiceImpl.java

@ -100,6 +100,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
{ {
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserName(user.getUsername()); sysUser.setUserName(user.getUsername());
sysUser.setPassword(user.getPassword());
sysUser.setUserId(user.getDmsUserId()); sysUser.setUserId(user.getDmsUserId());
return new LoginUser(user.getDmsUserId(), user.getHospitalId(), sysUser, CollUtil.newHashSet(), user.getTenantId() ,user.getScoreId()); return new LoginUser(user.getDmsUserId(), user.getHospitalId(), sysUser, CollUtil.newHashSet(), user.getTenantId() ,user.getScoreId());
} }

2
acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/WebDmsLoginService.java

@ -62,7 +62,7 @@ public class WebDmsLoginService
public String login(String username, String password, String code, String uuid) public String login(String username, String password, String code, String uuid)
{ {
// 验证码校验 // 验证码校验
// validateCaptcha(username, code, uuid); validateCaptcha(username, code, uuid);
// 登录前置校验 // 登录前置校验
loginPreCheck(username, password); loginPreCheck(username, password);
// 用户验证 // 用户验证

20
acupuncture-generator/src/main/resources/mbg.xml

@ -20,7 +20,7 @@
</commentGenerator> </commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" <jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://sd.tall.wiki:3306/acupuncture_yfyy?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=GMT%2B8&amp;tinyInt1isBit=false" connectionURL="jdbc:mysql://sd.tall.wiki:3306/acupuncture?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=GMT%2B8&amp;tinyInt1isBit=false"
userId="root" userId="root"
password="po3OynBO[M3579p6L7)o"> password="po3OynBO[M3579p6L7)o">
<!--仅仅查询当前库的表,不查询其他库--> <!--仅仅查询当前库的表,不查询其他库-->
@ -57,16 +57,16 @@
<property name="enableSubPackages" value="false"/> <property name="enableSubPackages" value="false"/>
</javaClientGenerator> </javaClientGenerator>
<table tableName="upl_rtcf_info" domainObjectName="UplRtcfInfo" enableDeleteByExample="false"/> <!-- <table tableName="upl_rtcf_info" domainObjectName="UplRtcfInfo" enableDeleteByExample="false"/>-->
<table tableName="upl_report_image" domainObjectName="UplReportImage" enableDeleteByExample="false"/> <!-- <table tableName="upl_report_image" domainObjectName="UplReportImage" enableDeleteByExample="false"/>-->
<table tableName="scr_screening" domainObjectName="ScrScreening" enableDeleteByExample="false"/> <!-- <table tableName="scr_screening" domainObjectName="ScrScreening" enableDeleteByExample="false"/>-->
<table tableName="scr_screening_detail" domainObjectName="ScrScreeningDetail" enableDeleteByExample="false"/> <!-- <table tableName="scr_screening_detail" domainObjectName="ScrScreeningDetail" enableDeleteByExample="false"/>-->
<table tableName="scr_screening_draw" domainObjectName="ScrScreeningDraw" enableDeleteByExample="false"/> <!-- <table tableName="scr_screening_draw" domainObjectName="ScrScreeningDraw" enableDeleteByExample="false"/>-->
<table tableName="scr_screening_record" domainObjectName="ScrScreeningRecord" enableDeleteByExample="false"/> <!-- <table tableName="scr_screening_record" domainObjectName="ScrScreeningRecord" enableDeleteByExample="false"/>-->
<table tableName="scr_screening_sound" domainObjectName="ScrScreeningSound" enableDeleteByExample="false"/> <!-- <table tableName="scr_screening_sound" domainObjectName="ScrScreeningSound" enableDeleteByExample="false"/>-->
<table tableName="ams_screen_wx_qr_code" domainObjectName="AmsScreenWxQrCode" enableDeleteByExample="false"/> <!-- <table tableName="ams_screen_wx_qr_code" domainObjectName="AmsScreenWxQrCode" enableDeleteByExample="false"/>-->
<!-- <table tableName="dms_user" domainObjectName="DmsUser" enableDeleteByExample="false"/>--> <table tableName="dms_user" domainObjectName="DmsUser" enableDeleteByExample="false"/>
<!-- <table tableName="fms_followup_queue" domainObjectName="FmsFollowupQueue" enableDeleteByExample="false"/>--> <!-- <table tableName="fms_followup_queue" domainObjectName="FmsFollowupQueue" enableDeleteByExample="false"/>-->
<!-- <table tableName="fms_followup_task" domainObjectName="FmsFollowupTask" enableDeleteByExample="false"/>--> <!-- <table tableName="fms_followup_task" domainObjectName="FmsFollowupTask" enableDeleteByExample="false"/>-->
<!-- <table tableName="fms_patient_queue_relation" domainObjectName="FmsPatientQueueRelation" enableDeleteByExample="false"/>--> <!-- <table tableName="fms_patient_queue_relation" domainObjectName="FmsPatientQueueRelation" enableDeleteByExample="false"/>-->

25
acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/AdminTenantUserDto.java

@ -5,7 +5,10 @@ import com.acupuncture.system.domain.po.DmsUser;
import com.acupuncture.system.service.AdminTenantUserService; import com.acupuncture.system.service.AdminTenantUserService;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
@ -18,7 +21,7 @@ public class AdminTenantUserDto {
@Data @Data
public static class AddDto { public static class AddDto {
private Integer id; private Long id;
private Long tenantId; private Long tenantId;
@ -37,17 +40,14 @@ public class AdminTenantUserDto {
private String status; private String status;
private String contactPhone; private String contactPhone;
@ApiModelProperty("是否具有审核权限(0不具有; 1具有)") @ApiModelProperty("是否具有审核权限(0不具有; 1具有)")
private Byte slaverAdmin; private Byte slaverAdmin = 0;
//
// public Long getTenantId() {
// return SecurityUtils.getTenantId();
// }
} }
@Data @Data
public static class UpdDto { public static class UpdDto {
private Integer id; private Long id;
private Long tenantId; private Long tenantId;
@ -71,14 +71,21 @@ public class AdminTenantUserDto {
@Data @Data
public static class DeleteDto { public static class DeleteDto {
private List<Integer> idList; private List<Long> idList;
} }
@Data @Data
public static class Query { public static class Query {
private Long tenantId; private Long tenantId;
private String tenantName; private String tenantName;
} }
@Data
public static class ResetPwd {
@NotNull
private Long id;
@NotBlank
@Length(min = 6, max = 20)
private String password;
}
} }

17
acupuncture-system/src/main/java/com/acupuncture/system/domain/po/DmsUser.java

@ -4,7 +4,7 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
public class DmsUser implements Serializable { public class DmsUser implements Serializable {
private Integer id; private Long id;
private Long tenantId; private Long tenantId;
@ -20,6 +20,8 @@ public class DmsUser implements Serializable {
private String sex; private String sex;
private Byte slaverAdmin;
private String status; private String status;
private Byte delFlag; private Byte delFlag;
@ -36,11 +38,11 @@ public class DmsUser implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer getId() { public Long getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
@ -100,6 +102,14 @@ public class DmsUser implements Serializable {
this.sex = sex == null ? null : sex.trim(); this.sex = sex == null ? null : sex.trim();
} }
public Byte getSlaverAdmin() {
return slaverAdmin;
}
public void setSlaverAdmin(Byte slaverAdmin) {
this.slaverAdmin = slaverAdmin;
}
public String getStatus() { public String getStatus() {
return status; return status;
} }
@ -170,6 +180,7 @@ public class DmsUser implements Serializable {
sb.append(", email=").append(email); sb.append(", email=").append(email);
sb.append(", phonenumber=").append(phonenumber); sb.append(", phonenumber=").append(phonenumber);
sb.append(", sex=").append(sex); sb.append(", sex=").append(sex);
sb.append(", slaverAdmin=").append(slaverAdmin);
sb.append(", status=").append(status); sb.append(", status=").append(status);
sb.append(", delFlag=").append(delFlag); sb.append(", delFlag=").append(delFlag);
sb.append(", createBy=").append(createBy); sb.append(", createBy=").append(createBy);

80
acupuncture-system/src/main/java/com/acupuncture/system/domain/po/DmsUserExample.java

@ -115,52 +115,52 @@ public class DmsUserExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdEqualTo(Integer value) { public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id"); addCriterion("id =", value, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdNotEqualTo(Integer value) { public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id"); addCriterion("id <>", value, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdGreaterThan(Integer value) { public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id"); addCriterion("id >", value, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdGreaterThanOrEqualTo(Integer value) { public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id"); addCriterion("id >=", value, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdLessThan(Integer value) { public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id"); addCriterion("id <", value, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdLessThanOrEqualTo(Integer value) { public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id"); addCriterion("id <=", value, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdIn(List<Integer> values) { public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id"); addCriterion("id in", values, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdNotIn(List<Integer> values) { public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id"); addCriterion("id not in", values, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdBetween(Integer value1, Integer value2) { public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id"); addCriterion("id between", value1, value2, "id");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIdNotBetween(Integer value1, Integer value2) { public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id"); addCriterion("id not between", value1, value2, "id");
return (Criteria) this; return (Criteria) this;
} }
@ -645,6 +645,66 @@ public class DmsUserExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andSlaverAdminIsNull() {
addCriterion("slaver_admin is null");
return (Criteria) this;
}
public Criteria andSlaverAdminIsNotNull() {
addCriterion("slaver_admin is not null");
return (Criteria) this;
}
public Criteria andSlaverAdminEqualTo(Byte value) {
addCriterion("slaver_admin =", value, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminNotEqualTo(Byte value) {
addCriterion("slaver_admin <>", value, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminGreaterThan(Byte value) {
addCriterion("slaver_admin >", value, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminGreaterThanOrEqualTo(Byte value) {
addCriterion("slaver_admin >=", value, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminLessThan(Byte value) {
addCriterion("slaver_admin <", value, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminLessThanOrEqualTo(Byte value) {
addCriterion("slaver_admin <=", value, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminIn(List<Byte> values) {
addCriterion("slaver_admin in", values, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminNotIn(List<Byte> values) {
addCriterion("slaver_admin not in", values, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminBetween(Byte value1, Byte value2) {
addCriterion("slaver_admin between", value1, value2, "slaverAdmin");
return (Criteria) this;
}
public Criteria andSlaverAdminNotBetween(Byte value1, Byte value2) {
addCriterion("slaver_admin not between", value1, value2, "slaverAdmin");
return (Criteria) this;
}
public Criteria andStatusIsNull() { public Criteria andStatusIsNull() {
addCriterion("status is null"); addCriterion("status is null");
return (Criteria) this; return (Criteria) this;

2
acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/AdminTenantUserVo.java

@ -38,6 +38,8 @@ public class AdminTenantUserVo {
private Date createTime; private Date createTime;
private String tenantName; private String tenantName;
private Byte slaverAdmin;
} }
} }

5
acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/DmsLoginUserVo.java

@ -22,8 +22,10 @@ public class DmsLoginUserVo {
} }
@Data @Data
public static class DmsUserVo { public static class DmsUserVo {
private Integer id; private Long id;
private Long tenantId; private Long tenantId;
private String tenantName;
private String tenantPhone;
private String userName; private String userName;
private String password; private String password;
@ -33,6 +35,7 @@ public class DmsLoginUserVo {
private String email; private String email;
private String phonenumber; private String phonenumber;
private Byte slaverAdmin;
private String sex; private String sex;

2
acupuncture-system/src/main/java/com/acupuncture/system/mapper/SysRoleMapper.java

@ -27,7 +27,7 @@ public interface SysRoleMapper
* @param userId 用户ID * @param userId 用户ID
* @return 角色列表 * @return 角色列表
*/ */
@DataSource(DataSourceType.MASTER) // @DataSource(DataSourceType.MASTER)
public List<SysRole> selectRolePermissionByUserId(Long userId); public List<SysRole> selectRolePermissionByUserId(Long userId);
/** /**

7
acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/DmsUserDao.java

@ -45,4 +45,11 @@ public interface DmsUserDao {
DmsLoginUserVo.DmsUserVo checkUserNameUnique(String userName); DmsLoginUserVo.DmsUserVo checkUserNameUnique(String userName);
DmsLoginUserVo.DmsUserVo checkPhoneUnique(String phonenumber); DmsLoginUserVo.DmsUserVo checkPhoneUnique(String phonenumber);
/**
* 根据租户用户id查询租户用户信息
* @param userId
* @return
*/
DmsLoginUserVo.DmsUserVo queryTenantUserById(Long userId);
} }

4
acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/DmsUserMapper.java

@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
public interface DmsUserMapper { public interface DmsUserMapper {
long countByExample(DmsUserExample example); long countByExample(DmsUserExample example);
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Long id);
int insert(DmsUser record); int insert(DmsUser record);
@ -16,7 +16,7 @@ public interface DmsUserMapper {
List<DmsUser> selectByExample(DmsUserExample example); List<DmsUser> selectByExample(DmsUserExample example);
DmsUser selectByPrimaryKey(Integer id); DmsUser selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") DmsUser record, @Param("example") DmsUserExample example); int updateByExampleSelective(@Param("record") DmsUser record, @Param("example") DmsUserExample example);

1
acupuncture-system/src/main/java/com/acupuncture/system/service/AdminTenantUserService.java

@ -21,4 +21,5 @@ public interface AdminTenantUserService {
List<AdminTenantUserVo.Result> query(AdminTenantUserDto.Query dto); List<AdminTenantUserVo.Result> query(AdminTenantUserDto.Query dto);
int resetPwd(AdminTenantUserDto.ResetPwd dto);
} }

9
acupuncture-system/src/main/java/com/acupuncture/system/service/DmsLoginService.java

@ -34,10 +34,11 @@ public interface DmsLoginService {
/** /**
* 重置用户密码 * 重置用户密码
* *
* @param user 用户信息 * @param username 用户信息
* @param password 密码
* @return 结果 * @return 结果
*/ */
public int resetPwd(DmsLoginUserVo.DmsUserVo user); public int resetPwd(Long userId, String username, String password);
/** /**
* 根据租户ID获取数据源 * 根据租户ID获取数据源
@ -49,4 +50,8 @@ public interface DmsLoginService {
boolean checkPhoneUnique(AdminTenantUserDto.AddDto dto); boolean checkPhoneUnique(AdminTenantUserDto.AddDto dto);
DmsTenant queryById(Long id); DmsTenant queryById(Long id);
DmsLoginUserVo.DmsUserVo selectTenantUserById(Long userId);
int updateTenantUserById(AdminTenantUserDto.UpdDto updDto);
} }

1
acupuncture-system/src/main/java/com/acupuncture/system/service/FmsFollowupQueueService.java

@ -19,7 +19,6 @@ public interface FmsFollowupQueueService {
* 查询公共队列 * 查询公共队列
* @return * @return
*/ */
@DataSource(DataSourceType.MASTER)
List<FmsFollowupVo.FollowupQueueVO> queryCommonQueue(String name); List<FmsFollowupVo.FollowupQueueVO> queryCommonQueue(String name);
} }

10
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/AdminTenantUserServiceImpl.java

@ -35,7 +35,7 @@ public class AdminTenantUserServiceImpl implements AdminTenantUserService {
@Override @Override
public int insert(AdminTenantUserDto.AddDto dto) { public int insert(AdminTenantUserDto.AddDto dto) {
DmsUser dmsUser = BeanUtil.copyProperties(dto, DmsUser.class); DmsUser dmsUser = BeanUtil.copyProperties(dto, DmsUser.class);
dmsUser.setId((int) IdUtil.getSnowflakeNextId()); dmsUser.setId(dto.getId());
dmsUser.setCreateBy(SecurityUtils.getUsername()); dmsUser.setCreateBy(SecurityUtils.getUsername());
dmsUser.setCreateTime(new Date()); dmsUser.setCreateTime(new Date());
return dmsUserMapper.insertSelective(dmsUser); return dmsUserMapper.insertSelective(dmsUser);
@ -62,4 +62,12 @@ public class AdminTenantUserServiceImpl implements AdminTenantUserService {
public List<AdminTenantUserVo.Result> query(AdminTenantUserDto.Query dto) { public List<AdminTenantUserVo.Result> query(AdminTenantUserDto.Query dto) {
return adminDmsUserDao.query(dto); return adminDmsUserDao.query(dto);
} }
@Override
public int resetPwd(AdminTenantUserDto.ResetPwd dto) {
DmsUser dmsUser = new DmsUser();
dmsUser.setId(dto.getId());
dmsUser.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
return dmsUserMapper.updateByPrimaryKeySelective(dmsUser);
}
} }

28
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/DmsLoginServiceImpl.java

@ -1,5 +1,6 @@
package com.acupuncture.system.service.impl; package com.acupuncture.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.acupuncture.common.constant.UserConstants; import com.acupuncture.common.constant.UserConstants;
import com.acupuncture.common.core.domain.entity.SysUser; import com.acupuncture.common.core.domain.entity.SysUser;
import com.acupuncture.common.utils.StringUtils; import com.acupuncture.common.utils.StringUtils;
@ -10,6 +11,7 @@ import com.acupuncture.system.domain.po.UmsDataSource;
import com.acupuncture.system.domain.vo.DmsLoginUserVo; import com.acupuncture.system.domain.vo.DmsLoginUserVo;
import com.acupuncture.system.persist.dao.DmsUserDao; import com.acupuncture.system.persist.dao.DmsUserDao;
import com.acupuncture.system.persist.mapper.DmsTenantMapper; import com.acupuncture.system.persist.mapper.DmsTenantMapper;
import com.acupuncture.system.persist.mapper.DmsUserMapper;
import com.acupuncture.system.persist.mapper.UmsDataSourceMapper; import com.acupuncture.system.persist.mapper.UmsDataSourceMapper;
import com.acupuncture.system.service.DmsLoginService; import com.acupuncture.system.service.DmsLoginService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,6 +30,9 @@ public class DmsLoginServiceImpl implements DmsLoginService {
@Resource @Resource
private DmsUserDao dmsUserDao; private DmsUserDao dmsUserDao;
@Resource
private DmsUserMapper dmsUserMapper;
@Resource @Resource
private DmsTenantMapper dmsTenantMapper; private DmsTenantMapper dmsTenantMapper;
@ -54,7 +59,11 @@ public class DmsLoginServiceImpl implements DmsLoginService {
} }
@Override @Override
public int resetPwd(DmsLoginUserVo.DmsUserVo user) { public int resetPwd(Long userId, String username, String password) {
DmsLoginUserVo.DmsUserVo user = new DmsLoginUserVo.DmsUserVo();
user.setId(userId);
user.setUserName(username);
user.setPassword(password);
return dmsUserDao.updateUser(user); return dmsUserDao.updateUser(user);
} }
@ -97,5 +106,22 @@ public class DmsLoginServiceImpl implements DmsLoginService {
return dmsTenantMapper.selectByPrimaryKey(id); return dmsTenantMapper.selectByPrimaryKey(id);
} }
@Override
public DmsLoginUserVo.DmsUserVo selectTenantUserById(Long userId) {
return dmsUserDao.queryTenantUserById(userId);
}
@Override
public int updateTenantUserById(AdminTenantUserDto.UpdDto updDto) {
DmsUser dmsUser = new DmsUser();
dmsUser.setId(updDto.getId());
dmsUser.setUserName(updDto.getUserName());
dmsUser.setNickName(updDto.getNickName());
dmsUser.setEmail(updDto.getEmail());
dmsUser.setPhonenumber(updDto.getPhonenumber());
dmsUser.setSex(updDto.getSex());
dmsUser.setTenantId(updDto.getTenantId());
dmsUser.setSlaverAdmin(updDto.getSlaverAdmin());
return dmsUserMapper.updateByPrimaryKeySelective(dmsUser);
}
} }

1
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupQueueServiceImpl.java

@ -29,7 +29,6 @@ public class FmsFollowupQueueServiceImpl implements FmsFollowupQueueService {
public static String COMMON_FOLLOWUP_QUEUE = "common_followup_queue"; public static String COMMON_FOLLOWUP_QUEUE = "common_followup_queue";
@Override @Override
@DataSource(DataSourceType.MASTER)
public List<FmsFollowupVo.FollowupQueueVO> queryCommonQueue(String name) { public List<FmsFollowupVo.FollowupQueueVO> queryCommonQueue(String name) {
redisCache.deleteObject(COMMON_FOLLOWUP_QUEUE); redisCache.deleteObject(COMMON_FOLLOWUP_QUEUE);
List<FmsFollowupVo.FollowupQueueVO> followupQueueVOS = fmsFollowupDao.queryCommonQueue(name); List<FmsFollowupVo.FollowupQueueVO> followupQueueVOS = fmsFollowupDao.queryCommonQueue(name);

3
acupuncture-system/src/main/resources/mapper/dao/AdminDmsUserDao.xml

@ -20,6 +20,7 @@
u.update_by as updateBy, u.update_by as updateBy,
u.update_time as updateTime, u.update_time as updateTime,
u.remark, u.remark,
u.slaver_admin as slaverAdmin,
t.name as tenantName t.name as tenantName
FROM FROM
dms_user u dms_user u
@ -34,7 +35,7 @@
AND t.name like concat('%',#{dto.tenantName},'%') AND t.name like concat('%',#{dto.tenantName},'%')
</if> </if>
</where> </where>
order by u.create_time desc order by u.tenant_id desc, u.id desc
</select> </select>
</mapper> </mapper>

18
acupuncture-system/src/main/resources/mapper/dao/SysPowerDao.xml → acupuncture-system/src/main/resources/mapper/dao/DmsUserDao.xml

@ -86,4 +86,22 @@
<select id="checkPhoneUnique" parameterType="String" resultType="com.acupuncture.system.domain.vo.DmsLoginUserVo$DmsUserVo"> <select id="checkPhoneUnique" parameterType="String" resultType="com.acupuncture.system.domain.vo.DmsLoginUserVo$DmsUserVo">
select id, user_name from dms_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1 select id, user_name from dms_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
</select> </select>
<select id="queryTenantUserById" resultType="com.acupuncture.system.domain.vo.DmsLoginUserVo$DmsUserVo">
select
u.id,
u.nick_name as nickName,
u.user_name as userName,
u.tenant_id as tenantId,
u.phonenumber as phonenumber,
u.email as email,
u.sex as sex,
t.`name` as tenantName,
t.contact_phone as tenantPhone,
u.slaver_admin as slaverAdmin
from
dms_user u join dms_tenant t on u.tenant_id = t.id
WHERE
u.del_flag = 0
and u.id = #{userId}
</select>
</mapper> </mapper>

57
acupuncture-system/src/main/resources/mapper/system/DmsUserMapper.xml

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.acupuncture.system.persist.mapper.DmsUserMapper"> <mapper namespace="com.acupuncture.system.persist.mapper.DmsUserMapper">
<resultMap id="BaseResultMap" type="com.acupuncture.system.domain.po.DmsUser"> <resultMap id="BaseResultMap" type="com.acupuncture.system.domain.po.DmsUser">
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="user_name" jdbcType="VARCHAR" property="userName" /> <result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="password" jdbcType="VARCHAR" property="password" /> <result column="password" jdbcType="VARCHAR" property="password" />
@ -10,6 +10,7 @@
<result column="email" jdbcType="VARCHAR" property="email" /> <result column="email" jdbcType="VARCHAR" property="email" />
<result column="phonenumber" jdbcType="VARCHAR" property="phonenumber" /> <result column="phonenumber" jdbcType="VARCHAR" property="phonenumber" />
<result column="sex" jdbcType="CHAR" property="sex" /> <result column="sex" jdbcType="CHAR" property="sex" />
<result column="slaver_admin" jdbcType="TINYINT" property="slaverAdmin" />
<result column="status" jdbcType="CHAR" property="status" /> <result column="status" jdbcType="CHAR" property="status" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" /> <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> <result column="create_by" jdbcType="VARCHAR" property="createBy" />
@ -77,8 +78,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, tenant_id, user_name, password, nick_name, email, phonenumber, sex, status, del_flag, id, tenant_id, user_name, password, nick_name, email, phonenumber, sex, slaver_admin,
create_by, create_time, update_by, update_time, remark status, del_flag, create_by, create_time, update_by, update_time, remark
</sql> </sql>
<select id="selectByExample" parameterType="com.acupuncture.system.domain.po.DmsUserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.acupuncture.system.domain.po.DmsUserExample" resultMap="BaseResultMap">
select select
@ -94,29 +95,29 @@
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from dms_user from dms_user
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from dms_user delete from dms_user
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT}
</delete> </delete>
<insert id="insert" parameterType="com.acupuncture.system.domain.po.DmsUser"> <insert id="insert" parameterType="com.acupuncture.system.domain.po.DmsUser">
insert into dms_user (id, tenant_id, user_name, insert into dms_user (id, tenant_id, user_name,
password, nick_name, email, password, nick_name, email,
phonenumber, sex, status, phonenumber, sex, slaver_admin,
del_flag, create_by, create_time, status, del_flag, create_by,
update_by, update_time, remark create_time, update_by, update_time,
) remark)
values (#{id,jdbcType=INTEGER}, #{tenantId,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR}, values (#{id,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
#{phonenumber,jdbcType=VARCHAR}, #{sex,jdbcType=CHAR}, #{status,jdbcType=CHAR}, #{phonenumber,jdbcType=VARCHAR}, #{sex,jdbcType=CHAR}, #{slaverAdmin,jdbcType=TINYINT},
#{delFlag,jdbcType=TINYINT}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=CHAR}, #{delFlag,jdbcType=TINYINT}, #{createBy,jdbcType=VARCHAR},
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR} #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
) #{remark,jdbcType=VARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.acupuncture.system.domain.po.DmsUser"> <insert id="insertSelective" parameterType="com.acupuncture.system.domain.po.DmsUser">
insert into dms_user insert into dms_user
@ -145,6 +146,9 @@
<if test="sex != null"> <if test="sex != null">
sex, sex,
</if> </if>
<if test="slaverAdmin != null">
slaver_admin,
</if>
<if test="status != null"> <if test="status != null">
status, status,
</if> </if>
@ -169,7 +173,7 @@
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
#{id,jdbcType=INTEGER}, #{id,jdbcType=BIGINT},
</if> </if>
<if test="tenantId != null"> <if test="tenantId != null">
#{tenantId,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT},
@ -192,6 +196,9 @@
<if test="sex != null"> <if test="sex != null">
#{sex,jdbcType=CHAR}, #{sex,jdbcType=CHAR},
</if> </if>
<if test="slaverAdmin != null">
#{slaverAdmin,jdbcType=TINYINT},
</if>
<if test="status != null"> <if test="status != null">
#{status,jdbcType=CHAR}, #{status,jdbcType=CHAR},
</if> </if>
@ -225,7 +232,7 @@
update dms_user update dms_user
<set> <set>
<if test="record.id != null"> <if test="record.id != null">
id = #{record.id,jdbcType=INTEGER}, id = #{record.id,jdbcType=BIGINT},
</if> </if>
<if test="record.tenantId != null"> <if test="record.tenantId != null">
tenant_id = #{record.tenantId,jdbcType=BIGINT}, tenant_id = #{record.tenantId,jdbcType=BIGINT},
@ -248,6 +255,9 @@
<if test="record.sex != null"> <if test="record.sex != null">
sex = #{record.sex,jdbcType=CHAR}, sex = #{record.sex,jdbcType=CHAR},
</if> </if>
<if test="record.slaverAdmin != null">
slaver_admin = #{record.slaverAdmin,jdbcType=TINYINT},
</if>
<if test="record.status != null"> <if test="record.status != null">
status = #{record.status,jdbcType=CHAR}, status = #{record.status,jdbcType=CHAR},
</if> </if>
@ -276,7 +286,7 @@
</update> </update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update dms_user update dms_user
set id = #{record.id,jdbcType=INTEGER}, set id = #{record.id,jdbcType=BIGINT},
tenant_id = #{record.tenantId,jdbcType=BIGINT}, tenant_id = #{record.tenantId,jdbcType=BIGINT},
user_name = #{record.userName,jdbcType=VARCHAR}, user_name = #{record.userName,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR}, password = #{record.password,jdbcType=VARCHAR},
@ -284,6 +294,7 @@
email = #{record.email,jdbcType=VARCHAR}, email = #{record.email,jdbcType=VARCHAR},
phonenumber = #{record.phonenumber,jdbcType=VARCHAR}, phonenumber = #{record.phonenumber,jdbcType=VARCHAR},
sex = #{record.sex,jdbcType=CHAR}, sex = #{record.sex,jdbcType=CHAR},
slaver_admin = #{record.slaverAdmin,jdbcType=TINYINT},
status = #{record.status,jdbcType=CHAR}, status = #{record.status,jdbcType=CHAR},
del_flag = #{record.delFlag,jdbcType=TINYINT}, del_flag = #{record.delFlag,jdbcType=TINYINT},
create_by = #{record.createBy,jdbcType=VARCHAR}, create_by = #{record.createBy,jdbcType=VARCHAR},
@ -319,6 +330,9 @@
<if test="sex != null"> <if test="sex != null">
sex = #{sex,jdbcType=CHAR}, sex = #{sex,jdbcType=CHAR},
</if> </if>
<if test="slaverAdmin != null">
slaver_admin = #{slaverAdmin,jdbcType=TINYINT},
</if>
<if test="status != null"> <if test="status != null">
status = #{status,jdbcType=CHAR}, status = #{status,jdbcType=CHAR},
</if> </if>
@ -341,7 +355,7 @@
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
</if> </if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.acupuncture.system.domain.po.DmsUser"> <update id="updateByPrimaryKey" parameterType="com.acupuncture.system.domain.po.DmsUser">
update dms_user update dms_user
@ -352,6 +366,7 @@
email = #{email,jdbcType=VARCHAR}, email = #{email,jdbcType=VARCHAR},
phonenumber = #{phonenumber,jdbcType=VARCHAR}, phonenumber = #{phonenumber,jdbcType=VARCHAR},
sex = #{sex,jdbcType=CHAR}, sex = #{sex,jdbcType=CHAR},
slaver_admin = #{slaverAdmin,jdbcType=TINYINT},
status = #{status,jdbcType=CHAR}, status = #{status,jdbcType=CHAR},
del_flag = #{delFlag,jdbcType=TINYINT}, del_flag = #{delFlag,jdbcType=TINYINT},
create_by = #{createBy,jdbcType=VARCHAR}, create_by = #{createBy,jdbcType=VARCHAR},
@ -359,6 +374,6 @@
update_by = #{updateBy,jdbcType=VARCHAR}, update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR} remark = #{remark,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT}
</update> </update>
</mapper> </mapper>

6
acupuncture-system/src/main/resources/mapper/system/SysUserMapper.xml

@ -168,7 +168,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="slaverAdmin != null ">slaver_admin,</if> <if test="slaverAdmin != null">slaver_admin,</if>
create_time create_time
)values( )values(
<if test="userId != null and userId != ''">#{userId},</if> <if test="userId != null and userId != ''">#{userId},</if>
@ -184,7 +184,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="slaverAdmin != null ">#{slaverAdmin},</if> <if test="slaverAdmin != null">#{slaverAdmin},</if>
sysdate() sysdate()
) )
</insert> </insert>
@ -192,6 +192,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateUser" parameterType="SysUser"> <update id="updateUser" parameterType="SysUser">
update sys_user update sys_user
<set> <set>
<if test="tenantId != null and tenantId != 0">tenant_id = #{tenantId},</if>
<if test="slaverAdmin != null">slaver_admin = #{slaverAdmin},</if>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if> <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if> <if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if> <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>

Loading…
Cancel
Save