提交 e2bce3ad authored 作者: zhu's avatar zhu

1.develop 科室导入

2.fix bug
上级 e2ec619c
......@@ -71,6 +71,9 @@ dependencies {
implementation 'com.tencentcloudapi:tencentcloud-sdk-java:3.1.874'
implementation 'org.redisson:redisson-spring-boot-starter:3.23.5'
implementation 'com.github.tencentyun:tls-sig-api-v2:2.0'
implementation 'org.apache.poi:poi-ooxml:5.2.3'
implementation 'cn.hutool:hutool-all:5.8.16'
......
......@@ -21,6 +21,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.xwd.hospital.server.base.BaseDomain;
import com.xwd.hospital.server.enums.YesNoEnum;
import com.xwd.hospital.server.domain.UserInfo;
@Data
......@@ -85,6 +86,12 @@ public class UserAddressInfo extends BaseDomain {
@TableField(value = "detail_address")
@Schema(description = "详细地址", nullable = false)
private String detailAddress;
/**
* 是否默认
*/
@TableField(value = "default_flag")
@Schema(description = "是否默认", nullable = false)
private YesNoEnum defaultFlag;
/**
* 操作人Id
*/
......@@ -117,6 +124,9 @@ public class UserAddressInfo extends BaseDomain {
*/
@Override
public UserAddressInfo setDefault() {
if (this.getDefaultFlag() == null) {
this.setDefaultFlag(YesNoEnum.NO);
}
if (this.getEditorId() == null) {
this.setEditorId(1L);
}
......@@ -179,6 +189,12 @@ public class UserAddressInfo extends BaseDomain {
}
return false;
}
if (this.getDefaultFlag() == null) {
if (throwException) {
throw new ApiCode.ApiException(-1, "是否默认不能为空!");
}
return false;
}
if (this.getEditorId() == null) {
if (throwException) {
throw new ApiCode.ApiException(-1, "操作人Id不能为空!");
......
......@@ -9,6 +9,7 @@ import java.util.List;
public class DepartmentDto {
private Long id;
private String departmentName;
private String departmentIntroduce;
private Long parentId;
private List<DepartmentDto> childList;
}
package com.xwd.hospital.server.dto;
import lombok.Data;
@Data
public class ExcelDepartment extends DepartmentDto{
private Long excelId;
private Long excelParentId;
}
package com.xwd.hospital.server.rest;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.xwd.hospital.server.annotation.AuthUser;
import com.xwd.hospital.server.domain.DepartmentInfo;
import com.xwd.hospital.server.domain.FamilyDoctor;
import com.xwd.hospital.server.domain.User;
import com.xwd.hospital.server.dto.DepartmentDto;
import com.xwd.hospital.server.dto.ExcelDepartment;
import com.xwd.hospital.server.enums.DepartmentLevelEnum;
import com.xwd.hospital.server.rest.res.ApiResponse;
import com.xwd.hospital.server.service.DepartmentInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@RestController
@Tag(name = "ExcelController", description = "excel导入")
@RequestMapping("/v1/pms/excel")
public class ExcelController {
@Resource
private DepartmentInfoService departmentInfoService;
/**
* 导入科室
*/
@PostMapping("/importDepartments")
@Operation(summary = "导入科室")
public ApiResponse<FamilyDoctor> importDepartments(@RequestParam MultipartFile multipartFile) {
try {
File file = convertMultipartFileToFile(multipartFile);
ExcelReader reader = ExcelUtil.getReader(file,"Sheet1");
List<Map<String,Object>> allData = reader.readAll();
//将 allData 转换为 ExcelDepartment 的list
List<ExcelDepartment> excelDepartmentList = allData.stream().map(map -> {
ExcelDepartment excelDepartment = new ExcelDepartment();
excelDepartment.setDepartmentName(map.get("科室名称").toString());
excelDepartment.setDepartmentIntroduce(null== map.get("科室描述")?"":map.get("科室描述").toString());
//excel中临时序号
excelDepartment.setExcelId(Long.parseLong(map.get("序号").toString()));
excelDepartment.setExcelParentId(Long.parseLong(map.get("上级科室序号").toString()));
return excelDepartment;
}).collect(Collectors.toList());
// 使用Collectors.groupingBy进行分组
Map<Long, List<ExcelDepartment>> excelDepartmentGroups = excelDepartmentList.stream()
.collect(Collectors.groupingBy(ExcelDepartment::getExcelParentId));
// 获取一级部门列表
List<ExcelDepartment> topLevelDepartments = excelDepartmentGroups.get(0L);
topLevelDepartments.forEach(excelDepartment -> {
DepartmentInfo departmentInfo = new DepartmentInfo();
departmentInfo.setDepartmentName(excelDepartment.getDepartmentName());
departmentInfo.setDepartmentIntroduce(excelDepartment.getDepartmentIntroduce());
departmentInfo.setDepartmentLevel(DepartmentLevelEnum.FIRST_LEVEL);
departmentInfo.setParentId(0L);
departmentInfoService.save(departmentInfo);
//插入所有一级科室数据,同时返回记录数据库中的id
excelDepartment.setId(departmentInfo.getId());
//根据excelParentId获取当前一级科室下所有的科室
List<ExcelDepartment> secondeDepartmentList = excelDepartmentGroups.get(excelDepartment.getExcelId());
secondeDepartmentList.forEach(secondeDepartment -> {
DepartmentInfo secondeDepartmentInfo = new DepartmentInfo();
secondeDepartmentInfo.setDepartmentName(secondeDepartment.getDepartmentName());
secondeDepartmentInfo.setDepartmentIntroduce(secondeDepartment.getDepartmentIntroduce());
secondeDepartmentInfo.setDepartmentLevel(DepartmentLevelEnum.SECOND_LEVEL);
secondeDepartmentInfo.setParentId(departmentInfo.getId());
departmentInfoService.save(secondeDepartmentInfo);
});
});
}catch (IOException e){
return ApiResponse.fail(-1,"文件导入失败");
}
return ApiResponse.ok(null);
}
public File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException {
File file = new File(multipartFile.getOriginalFilename());
FileUtils.writeByteArrayToFile(file, multipartFile.getBytes());
return file;
}
}
......@@ -22,11 +22,14 @@ import com.xwd.hospital.server.annotation.ApiCommon;
import com.xwd.hospital.server.annotation.AuthUser;
import com.xwd.hospital.server.base.BaseController;
import com.xwd.hospital.server.domain.User;
import com.xwd.hospital.server.domain.UserInfo;
import com.xwd.hospital.server.enums.YesNoEnum;
import com.xwd.hospital.server.rest.res.ApiCode;
import com.xwd.hospital.server.domain.UserAddressInfo;
import com.xwd.hospital.server.rest.req.UserAddressInfoParam;
import com.xwd.hospital.server.rest.res.ApiResponse;
import com.xwd.hospital.server.service.UserAddressInfoService;
import com.xwd.hospital.server.service.UserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
......@@ -47,6 +50,8 @@ import java.util.Map;
@RequestMapping("/v1/pms/user-address-info")
public class UserAddressInfoController extends BaseController<UserAddressInfoService, UserAddressInfo, UserAddressInfoParam> {
@Resource
private UserInfoService userInfoService;
@Resource
public void setService(UserAddressInfoService service) {
this.service = service;
......@@ -62,9 +67,20 @@ public class UserAddressInfoController extends BaseController<UserAddressInfoSer
@Operation(summary = "新增")
@Override
public ApiResponse<UserAddressInfo> add(@RequestBody UserAddressInfo entity, @AuthUser User user) {
UserInfo userInfo = userInfoService.getOne(Wrappers.<UserInfo>query().eq("user_id", user.getId()));
entity.setEditorId(user.getId());
entity.setEditorName(user.getUsername());
entity.setDefault().validate(true);
if(entity.getDefaultFlag() == YesNoEnum.YES){
//先查询出默认状态为yes的数据
UserAddressInfo userAddressInfo = this.service.getOne(Wrappers.<UserAddressInfo>lambdaQuery().eq(UserAddressInfo::getUserInfoId,userInfo.getId()).eq(UserAddressInfo::getDefaultFlag, YesNoEnum.YES));
if (userAddressInfo != null){
userAddressInfo.setDefaultFlag(YesNoEnum.NO);
this.service.updateById(userAddressInfo);
}
}
this.service.save(entity);
return ApiResponse.ok(this.service.getById(entity.getId()));
}
......@@ -87,5 +103,38 @@ public class UserAddressInfoController extends BaseController<UserAddressInfoSer
return ApiResponse.ok(this.service.saveBatch(entityList));
}
/**
* 更新
*
* @param entity 要更新的对象
* @return 更新后的对象
*/
@PutMapping("/")
@Operation(summary = "更新")
@ApiCommon
@Override
public ApiResponse<UserAddressInfo> update(
@RequestBody UserAddressInfo entity,
@RequestParam(value = "updateAllFields", defaultValue = "false") boolean updateAllFields,
@AuthUser User user) {
UserInfo userInfo = userInfoService.getOne(Wrappers.<UserInfo>query().eq("user_id", user.getId()));
if(entity.getDefaultFlag() == YesNoEnum.YES){
//先查询出默认状态为yes的数据
UserAddressInfo userAddressInfo = this.service.getOne(Wrappers.<UserAddressInfo>lambdaQuery().eq(UserAddressInfo::getUserInfoId,userInfo.getId()).eq(UserAddressInfo::getDefaultFlag, YesNoEnum.YES));
if (userAddressInfo != null){
userAddressInfo.setDefaultFlag(YesNoEnum.NO);
this.service.updateById(userAddressInfo);
}
}
if (updateAllFields) {
this.service.updateAllFieldsById(entity);
} else {
this.service.updateById(entity);
}
return ApiResponse.ok(this.service.getById(entity.getId()));
}
}
......@@ -227,7 +227,7 @@ public class UserController extends BaseController<UserService, User, UserParam>
}
var loginModel = new SaLoginModel();
loginModel.setExtra("userId", userDto.getUser().getId());
StpUtil.login(userDto.getUser().getUsername(), loginModel);
StpUtil.login(userDto.getUser().getId(), loginModel);
result.put("token", StpUtil.getTokenValue());
return ApiResponse.ok(result);
......@@ -248,7 +248,7 @@ public class UserController extends BaseController<UserService, User, UserParam>
result.put("userDto", userDto);
var loginModel = new SaLoginModel();
loginModel.setExtra("userId", userDto.getUser().getId());
StpUtil.login(userDto.getUser().getUsername(), loginModel);
StpUtil.login(userDto.getUser().getId(), loginModel);
result.put("token", StpUtil.getTokenValue());
return ApiResponse.ok(result);
......
......@@ -17,6 +17,7 @@ import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import com.xwd.hospital.server.base.BaseParam;
import com.xwd.hospital.server.enums.YesNoEnum;
import com.xwd.hospital.server.domain.UserAddressInfo;
@Data
......@@ -70,6 +71,16 @@ public class UserAddressInfoParam extends BaseParam<UserAddressInfo> {
*/
@Parameter(description = "详细地址")
private String detailAddress;
/**
* 是否默认
*/
@Parameter(description = "是否默认")
private YesNoEnum defaultFlag;
/**
* 是否默认 IN值List
*/
@Parameter(description = "是否默认 IN值List")
private List<String> defaultFlagList;
/**
* 操作人Id
*/
......@@ -201,6 +212,8 @@ public class UserAddressInfoParam extends BaseParam<UserAddressInfo> {
wrapper.eq(columnPrefix + "detail_address", this.getDetailAddress());
}
}
wrapper.eq(this.getDefaultFlag() != null, columnPrefix + "default_flag", this.getDefaultFlag());
wrapper.in(this.getDefaultFlagList() != null && this.getDefaultFlagList().size() > 0, columnPrefix + "default_flag", this.getDefaultFlagList());
wrapper.eq(this.getEditorId() != null, columnPrefix + "editor_id", this.getEditorId());
if (this.getEditorName() != null) {
if (this.getEditorName().startsWith("%") && this.getEditorName().endsWith("%")) {
......
......@@ -227,6 +227,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
user.setRegisterSource(RegisterSourceEnum.WX);
user.setPhone(loginDto.getPhoneNumber());
user.setImUserId(IdUtil.getSnowflakeNextIdStr());
//添加用户信息到IM系统
addUserToIMSystem(user.getImUserId(),user.getUsername(),user.getAvatar());
super.save(user);
//分配角色
String roleName = "";
......@@ -375,6 +378,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
user.setPhone(registserDto.getPhoneNumber());
user.setOpenId(openid);
user.setImUserId(IdUtil.getSnowflakeNextIdStr());
addUserToIMSystem(user.getImUserId(),user.getUsername(),user.getAvatar());
this.saveOrUpdate(user);
//分配用户角色role
String roleName = "";
......@@ -429,6 +433,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
userInfo = new UserInfo();
}
userInfo.setUserId(userId);
//更新IM系统用户信息
if(!userInfo.getName().equals(updateUserDto.getName())){
updateIMUserProfile(user.getImUserId(),updateUserDto.getName());
}
userInfo.setName(updateUserDto.getName());
userInfo.setSex(updateUserDto.getSex());
userInfo.setIdNo(updateUserDto.getIdNo());
......@@ -437,6 +446,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
userInfo.setIdCardPictureBack(updateUserDto.getIdCardPictureBack());
userInfo.setIdCardPictureFront(updateUserDto.getIdCardPictureFront());
userInfo.setPersonalInfoFilled(YesNoEnum.NO);
if(checkInfoFilled(userInfo)){
userInfo.setPersonalInfoFilled(YesNoEnum.YES);
}
......@@ -468,6 +479,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
doctorInfo = new DoctorInfo();
}
doctorInfo.setUserId(userId);
//更新IM系统用户信息
if(!doctorInfo.getDoctorName().equals(updateUserDto.getName())){
updateIMUserProfile(user.getImUserId(),updateUserDto.getName());
}
doctorInfo.setDoctorName(updateUserDto.getName());
doctorInfo.setSex(updateUserDto.getSex());
doctorInfo.setIdNo(updateUserDto.getIdNo());
......
......@@ -59,7 +59,7 @@
left join pms_order o on o.doctor_id = di.id
left join pms_doctor_service_info s on s.doctor_id = di.id
left join pms_user_attention_info ua on ua.doctor_id = di.id
where di.doctor_state = 'NORMAL' and pmq.audit_state = 'AUDIT_SUCCESS' and pdi.hidden_status = 'NO'
where di.doctor_state = 'NORMAL' and pmq.audit_state = 'AUDIT_SUCCESS' and pdi.hidden_status = 'NO' and u.user_type = 'DOCTOR' and s.service_name = 'ONLINE_INQUIRY'
<if test="sickness != null and sickness != ''">
AND di.expertise_area LIKE CONCAT('%', #{sickness}, '%')
</if>
......
......@@ -10,6 +10,7 @@
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="district" jdbcType="VARCHAR" property="district" />
<result column="detail_address" jdbcType="VARCHAR" property="detailAddress" />
<result column="default_flag" jdbcType="VARCHAR" property="defaultFlag" />
<result column="editor_id" jdbcType="BIGINT" property="editorId" />
<result column="editor_name" jdbcType="VARCHAR" property="editorName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
......@@ -20,19 +21,19 @@
select="com.xwd.hospital.server.repository.UserInfoMapper.selectById" />
</resultMap>
<sql id="Base_Column_List">
`id`, `user_info_id`, `name`, `phone_number`, `province`, `city`, `district`, `detail_address`, `editor_id`, `editor_name`, `create_time`, `update_time`
`id`, `user_info_id`, `name`, `phone_number`, `province`, `city`, `district`, `detail_address`, `default_flag`, `editor_id`, `editor_name`, `create_time`, `update_time`
</sql>
<sql id="Base_Column_List_With_Prefix">
t.`id`, t.`user_info_id`, t.`name`, t.`phone_number`, t.`province`, t.`city`, t.`district`, t.`detail_address`, t.`editor_id`, t.`editor_name`, t.`create_time`, t.`update_time`
t.`id`, t.`user_info_id`, t.`name`, t.`phone_number`, t.`province`, t.`city`, t.`district`, t.`detail_address`, t.`default_flag`, t.`editor_id`, t.`editor_name`, t.`create_time`, t.`update_time`
</sql>
<insert id="batchInsert">
insert into pms_user_address_info (
`user_info_id`, `name`, `phone_number`, `province`, `city`, `district`, `detail_address`, `editor_id`, `editor_name`
`user_info_id`, `name`, `phone_number`, `province`, `city`, `district`, `detail_address`, `default_flag`, `editor_id`, `editor_name`
)
values
<foreach collection="records" item="record" separator=",">
(
#{record.userInfoId, jdbcType=BIGINT}, #{record.name, jdbcType=VARCHAR}, #{record.phoneNumber, jdbcType=VARCHAR}, #{record.province, jdbcType=VARCHAR}, #{record.city, jdbcType=VARCHAR}, #{record.district, jdbcType=VARCHAR}, #{record.detailAddress, jdbcType=VARCHAR}, #{record.editorId, jdbcType=BIGINT}, #{record.editorName, jdbcType=VARCHAR}
#{record.userInfoId, jdbcType=BIGINT}, #{record.name, jdbcType=VARCHAR}, #{record.phoneNumber, jdbcType=VARCHAR}, #{record.province, jdbcType=VARCHAR}, #{record.city, jdbcType=VARCHAR}, #{record.district, jdbcType=VARCHAR}, #{record.detailAddress, jdbcType=VARCHAR}, #{record.defaultFlag, jdbcType=VARCHAR}, #{record.editorId, jdbcType=BIGINT}, #{record.editorName, jdbcType=VARCHAR}
)
</foreach>
</insert>
......@@ -46,6 +47,7 @@
city = #{et.city, jdbcType=VARCHAR},
district = #{et.district, jdbcType=VARCHAR},
detail_address = #{et.detailAddress, jdbcType=VARCHAR},
default_flag = #{et.defaultFlag, jdbcType=VARCHAR},
editor_id = #{et.editorId, jdbcType=BIGINT},
editor_name = #{et.editorName, jdbcType=VARCHAR},
</trim>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论