机构Org修改
This commit is contained in:
@@ -3,20 +3,34 @@
|
||||
*/
|
||||
package com.openhis.web.basedatamanage.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.enums.AssignSeqEnum;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.MessageUtils;
|
||||
import com.openhis.administration.domain.Organization;
|
||||
import com.openhis.administration.mapper.OrganizationMapper;
|
||||
import com.openhis.administration.service.IOrganizationService;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.OrganizationType;
|
||||
import com.openhis.common.utils.HisPageUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.web.basedatamanage.dto.OrgQueryParam;
|
||||
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
||||
import com.openhis.web.basedatamanage.dto.OrganizationInitDto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -35,24 +49,68 @@ public class OrganizationController {
|
||||
|
||||
private final IOrganizationService organizationService;
|
||||
|
||||
@Autowired
|
||||
private OrganizationMapper organizationMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AssignSeqUtil assignSeqUtil;
|
||||
|
||||
@GetMapping(value = "/init")
|
||||
public R<?> init() {
|
||||
|
||||
List<OrganizationInitDto> initDto = new ArrayList<>();
|
||||
|
||||
for (OrganizationType type : OrganizationType.values()) {
|
||||
initDto.add(new OrganizationInitDto(type.getValue(), type.getCode()));
|
||||
}
|
||||
return R.ok(initDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 机构分页列表
|
||||
*
|
||||
* @param orgQueryParam 查询字段
|
||||
* @param searchKey 模糊查询关键字
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 查询条数
|
||||
* @param request 请求数据
|
||||
* @return 机构分页列表
|
||||
*/
|
||||
@GetMapping(value = "/organization")
|
||||
public R<?> getOrganizationPage(@RequestBody OrgQueryParam orgQueryParam,
|
||||
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
||||
|
||||
// 构建查询条件
|
||||
QueryWrapper<Organization> queryWrapper = HisQueryUtils.buildQueryWrapper(orgQueryParam, searchKey,
|
||||
new HashSet<>(Arrays.asList("name", "py_str", "wb_str")), request);
|
||||
|
||||
// 设置排序
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
// 执行分页查询并转换为 orgQueryDtoPage
|
||||
Page<OrganizationQueryDto> orgQueryDtoPage =
|
||||
HisPageUtils.selectPage(organizationMapper, queryWrapper, pageNo, pageSize, OrganizationQueryDto.class);
|
||||
|
||||
return R.ok(orgQueryDtoPage,
|
||||
MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"机构信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加机构信息
|
||||
*
|
||||
* @param organization 机构信息
|
||||
* @param organizationQueryDto 机构信息
|
||||
*/
|
||||
@PostMapping("/organization")
|
||||
public R<?> addOrganization(@Validated @RequestBody Organization organization) {
|
||||
public R<?> addOrganization(@Validated @RequestBody OrganizationQueryDto organizationQueryDto) {
|
||||
|
||||
// 新增organization信息
|
||||
// Organization organization = new Organization();
|
||||
// BeanUtils.copyProperties(organizationdto, organization);
|
||||
Organization organization = new Organization();
|
||||
BeanUtils.copyProperties(organizationQueryDto, organization);
|
||||
|
||||
// 基础采番
|
||||
String code = assignSeqUtil.getSeq(AssignSeqEnum.TEST.getPrefix());
|
||||
organization.setBusNo(code);
|
||||
// String code = assignSeqUtil.getSeq(AssignSeqEnum.TEST.getPrefix());
|
||||
// organizationQueryDto.setBusNo(code);
|
||||
|
||||
boolean saveOrgSuccess = organizationService.save(organization);
|
||||
|
||||
@@ -61,16 +119,28 @@ public class OrganizationController {
|
||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00003, new Object[] {"机构信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机构需要编辑的信息
|
||||
*
|
||||
* @param orgId 机构信息
|
||||
*/
|
||||
@GetMapping("/organization-editById")
|
||||
public R<?> getOrganizationById(@Validated @RequestParam Long orgId) {
|
||||
|
||||
Organization organization = organizationService.getById(orgId);
|
||||
return R.ok(organization, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"机构信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑机构信息
|
||||
*
|
||||
* @param organization 机构信息
|
||||
* @param organizationQueryDto 机构信息
|
||||
*/
|
||||
@PutMapping("/organization")
|
||||
public R<?> editOrganization(@Validated @RequestBody Organization organization) {
|
||||
public R<?> editOrganization(@Validated @RequestBody OrganizationQueryDto organizationQueryDto) {
|
||||
// 更新organization信息
|
||||
// Organization organization = new Organization();
|
||||
// BeanUtils.copyProperties(organizationdto, organization);
|
||||
Organization organization = new Organization();
|
||||
BeanUtils.copyProperties(organizationQueryDto, organization);
|
||||
|
||||
boolean updateOrgSuccess = organizationService.updateById(organization);
|
||||
return updateOrgSuccess
|
||||
@@ -81,39 +151,37 @@ public class OrganizationController {
|
||||
/**
|
||||
* 删除机构信息
|
||||
*
|
||||
* @param orgId 主表id
|
||||
* @param orgIds 需要删除的Id
|
||||
*/
|
||||
@DeleteMapping("/organization")
|
||||
public R<?> deleteSupplyRequest(@RequestParam Long orgId) {
|
||||
public R<?> deleteOrganization(@RequestParam String orgIds) {
|
||||
|
||||
List<Long> orgIdList = new ArrayList<>();
|
||||
if (orgIds != null) {
|
||||
orgIdList = Arrays.stream(orgIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 在service层做业务校验
|
||||
boolean deleteOrgSuccess = organizationService.removeById(orgId);
|
||||
boolean deleteOrgSuccess = organizationService.removeByIds(orgIdList);
|
||||
|
||||
return deleteOrgSuccess
|
||||
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"机构信息"}))
|
||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] {"机构信息删除失败"}));
|
||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] {"机构信息"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 机构分页列表
|
||||
* 停用启用
|
||||
*
|
||||
* @param classEnum 机构分类枚举
|
||||
* @param activeFlag 活动标识
|
||||
* @param pageNo 当前页码
|
||||
* @param pageSize 查询条数
|
||||
* @param request 请求数据
|
||||
* @return 机构分页列表
|
||||
* @param orgId 主表id
|
||||
*/
|
||||
@GetMapping(value = "/organization")
|
||||
public R<?> getOrganizationPage(Integer classEnum, Integer activeFlag,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
||||
@PutMapping("/organization-flag")
|
||||
public R<?> changeOrgFlag(@RequestParam Long orgId) {
|
||||
|
||||
// 查询【机构】分页列表
|
||||
Page<Organization> organizationPage =
|
||||
organizationService.getOrganizationPage(classEnum, activeFlag, pageNo, pageSize);
|
||||
return R.ok(organizationPage,
|
||||
MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息"}));
|
||||
boolean flagChangeSuccess = organizationService.changeOrgFlag(orgId);
|
||||
|
||||
return flagChangeSuccess
|
||||
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构活动标识"}))
|
||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构活动标识"}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.basedatamanage.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.openhis.common.enums.OrganizationClass;
|
||||
import com.openhis.common.enums.OrganizationType;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 科室分页查询条件
|
||||
*
|
||||
* @author
|
||||
* @date 2025-02-21
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrgQueryParam implements Serializable {
|
||||
|
||||
/** 活动标识 */
|
||||
private Integer activeFlag;
|
||||
|
||||
/** 机构类型枚举 */
|
||||
private OrganizationType typeEnum;
|
||||
|
||||
/** 机构分类枚举 */
|
||||
private OrganizationClass classEnum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.basedatamanage.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 科室初始化 dto
|
||||
*
|
||||
* @author
|
||||
* @date 2025-02-25
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrganizationInitDto {
|
||||
|
||||
private Integer value;
|
||||
private String code;
|
||||
|
||||
public OrganizationInitDto(Integer value, String code) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.basedatamanage.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.openhis.common.enums.OrganizationClass;
|
||||
import com.openhis.common.enums.OrganizationType;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025-02-21
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrganizationQueryDto {
|
||||
|
||||
/** ID */
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/** 编码 */
|
||||
private String busNo;
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 活动标识 */
|
||||
private Integer activeFlag;
|
||||
|
||||
/** 机构类型枚举 */
|
||||
private OrganizationType typeEnum;
|
||||
|
||||
/** 机构分类枚举 */
|
||||
private OrganizationClass classEnum;
|
||||
|
||||
/** 拼音码 */
|
||||
private String pyStr;
|
||||
|
||||
/** 五笔码 */
|
||||
private String wbStr;
|
||||
|
||||
/** 医保码 */
|
||||
private String ybNo;
|
||||
|
||||
/** 医保名称 */
|
||||
private String ybName;
|
||||
|
||||
/** 显示顺序 */
|
||||
private Integer displayOrder;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.openhis.administration.domain.Organization;
|
||||
* @date 2025-02-21
|
||||
*/
|
||||
public interface IOrganizationService extends IService<Organization> {
|
||||
Page<Organization> getOrganizationPage(Integer classEnum, Integer activeFlag, Integer pageNo, Integer pageSize);
|
||||
// Page<Organization> getOrganizationPage(Integer classEnum, Integer activeFlag, Integer pageNo, Integer pageSize);
|
||||
|
||||
boolean changeOrgFlag(Long orgId);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.openhis.administration.service.impl;
|
||||
|
||||
import com.openhis.common.enums.ActiveFlag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -24,31 +25,48 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Org
|
||||
@Autowired
|
||||
private OrganizationMapper organizationMapper;
|
||||
|
||||
/**
|
||||
* 查询机构列表
|
||||
*
|
||||
* @param classEnum 机构分类枚举
|
||||
* @param activeFlag 活动标识
|
||||
* @return 机构列表
|
||||
*/
|
||||
// /**
|
||||
// * 查询机构列表
|
||||
// *
|
||||
// * @param classEnum 机构分类枚举
|
||||
// * @param activeFlag 活动标识
|
||||
// * @return 机构列表
|
||||
// */
|
||||
// @Override
|
||||
// public Page<Organization> getOrganizationPage(Integer classEnum, Integer activeFlag, Integer pageNo,
|
||||
// Integer pageSize) {
|
||||
//
|
||||
// LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
//
|
||||
// if (classEnum != null) {
|
||||
// queryWrapper.eq(Organization::getTypeEnum, classEnum);
|
||||
// }
|
||||
//
|
||||
// if (activeFlag != null) {
|
||||
// queryWrapper.eq(Organization::getActiveFlag, activeFlag);
|
||||
// }
|
||||
//
|
||||
// Page<Organization> organizationPage = organizationMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
//
|
||||
// // 返回机构信息列表
|
||||
// return organizationPage;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Page<Organization> getOrganizationPage(Integer classEnum, Integer activeFlag, Integer pageNo,
|
||||
Integer pageSize) {
|
||||
public boolean changeOrgFlag(Long orgId) {
|
||||
|
||||
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (classEnum != null) {
|
||||
queryWrapper.eq(Organization::getTypeEnum, classEnum);
|
||||
if (orgId != null) {
|
||||
Organization organization = organizationMapper.selectById(orgId);
|
||||
if (organization.getActiveFlag().equals(ActiveFlag.YES.getValue())) {
|
||||
organization.setActiveFlag(ActiveFlag.NO.getValue());
|
||||
return true;
|
||||
} else {
|
||||
organization.setActiveFlag(ActiveFlag.YES.getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (activeFlag != null) {
|
||||
queryWrapper.eq(Organization::getActiveFlag, activeFlag);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Page<Organization> organizationPage = organizationMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
// 返回机构信息列表
|
||||
return organizationPage;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user