机构格式修改
This commit is contained in:
@@ -1,13 +1,63 @@
|
|||||||
package com.openhis.web.basedatamanage.appservice;
|
package com.openhis.web.basedatamanage.appservice;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Organization 应该服务类
|
* Organization 应该服务类
|
||||||
*/
|
*/
|
||||||
public interface IOrganizationAppService {
|
public interface IOrganizationAppService {
|
||||||
// 查询机构树
|
/**
|
||||||
Page<OrganizationQueryDto> getOrganizationTree(Integer pageNo, Integer pageSize);
|
* 查询机构树
|
||||||
|
*
|
||||||
|
* @param pageNo 当前页码
|
||||||
|
* @param pageSize 查询条数
|
||||||
|
* @param request 请求数据
|
||||||
|
* @return 机构树分页列表
|
||||||
|
*/
|
||||||
|
Page<OrganizationQueryDto> getOrganizationTree(Integer pageNo, Integer pageSize, HttpServletRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构信息详情
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 机构信息详情
|
||||||
|
*/
|
||||||
|
R<?> getOrgInfo(Long orgId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加/编辑机构信息
|
||||||
|
*
|
||||||
|
* @param organizationQueryDto 机构信息
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
R<?> addOrEditOrganization(OrganizationQueryDto organizationQueryDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构信息
|
||||||
|
*
|
||||||
|
* @param orgIds 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
R<?> deleteOrganization(String orgIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构启用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
R<?> activeOrg(Long orgId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构停用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
R<?> inactiveOrg(Long orgId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.openhis.web.basedatamanage.appservice.impl;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.openhis.administration.domain.Organization;
|
|
||||||
import com.openhis.administration.service.IOrganizationService;
|
|
||||||
import com.openhis.web.basedatamanage.appservice.IOrganizationAppService;
|
|
||||||
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class IOrganizationAppServiceImpl implements IOrganizationAppService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
IOrganizationService organizationService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<OrganizationQueryDto> getOrganizationTree(Integer pageNo, Integer pageSize) {
|
|
||||||
// 查询机构列表
|
|
||||||
Page<Organization> page = organizationService.page(new Page<>(pageNo, pageSize));
|
|
||||||
List<Organization> organizationList = page.getRecords();
|
|
||||||
// 将机构列表转为树结构
|
|
||||||
List<OrganizationQueryDto> orgTree = buildTree(organizationList);
|
|
||||||
Page<OrganizationQueryDto> orgQueryDtoPage = new Page<>(pageNo, pageSize, page.getTotal());
|
|
||||||
orgQueryDtoPage.setRecords(orgTree);
|
|
||||||
return orgQueryDtoPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将机构列表转换为树结构
|
|
||||||
*
|
|
||||||
* @param records 机构列表
|
|
||||||
* @return tree
|
|
||||||
*/
|
|
||||||
private List<OrganizationQueryDto> buildTree(List<Organization> records) {
|
|
||||||
// 按b_no的层级排序,确保父节点先处理
|
|
||||||
List<Organization> sortedRecords = records.stream()
|
|
||||||
.sorted(Comparator.comparingInt(r -> r.getBusNo().split("\\.").length)).collect(Collectors.toList());
|
|
||||||
|
|
||||||
Map<String, OrganizationQueryDto> nodeMap = new HashMap<>();
|
|
||||||
List<OrganizationQueryDto> tree = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Organization record : sortedRecords) {
|
|
||||||
String bNo = record.getBusNo();
|
|
||||||
String[] parts = bNo.split("\\.");
|
|
||||||
OrganizationQueryDto node = new OrganizationQueryDto();
|
|
||||||
BeanUtils.copyProperties(record, node);
|
|
||||||
// 将当前节点加入映射
|
|
||||||
nodeMap.put(bNo, node);
|
|
||||||
|
|
||||||
if (parts.length == 1) {
|
|
||||||
// 根节点
|
|
||||||
tree.add(node);
|
|
||||||
} else {
|
|
||||||
// 获取父节点的b_no(去掉最后一部分)
|
|
||||||
String parentBNo = String.join(".", Arrays.copyOf(parts, parts.length - 1));
|
|
||||||
OrganizationQueryDto parent = nodeMap.get(parentBNo);
|
|
||||||
|
|
||||||
if (parent != null) {
|
|
||||||
parent.getChildren().add(node);
|
|
||||||
} else {
|
|
||||||
// 处理父节点不存在的情况(例如数据缺失)
|
|
||||||
// 可根据需求调整为将节点加入根或抛出异常
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,7 @@ import com.openhis.web.basedatamanage.appservice.ILocationAppService;
|
|||||||
import com.openhis.web.basedatamanage.dto.LocationQueryDto;
|
import com.openhis.web.basedatamanage.dto.LocationQueryDto;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ILocationAppServiceImpl implements ILocationAppService {
|
public class LocationAppServiceImpl implements ILocationAppService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ILocationService locationService;
|
ILocationService locationService;
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
package com.openhis.web.basedatamanage.appservice.impl;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
|
import com.core.common.utils.MessageUtils;
|
||||||
|
import com.openhis.administration.domain.Organization;
|
||||||
|
import com.openhis.administration.service.IOrganizationService;
|
||||||
|
import com.openhis.common.constant.PromptMsgConstant;
|
||||||
|
import com.openhis.web.basedatamanage.appservice.IOrganizationAppService;
|
||||||
|
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OrganizationAppServiceImpl implements IOrganizationAppService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IOrganizationService organizationService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<OrganizationQueryDto> getOrganizationTree(Integer pageNo, Integer pageSize,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
// 查询机构列表
|
||||||
|
Page<Organization> page = organizationService.page(new Page<>(pageNo, pageSize));
|
||||||
|
List<Organization> organizationList = page.getRecords();
|
||||||
|
// 将机构列表转为树结构
|
||||||
|
List<OrganizationQueryDto> orgTree = buildTree(organizationList);
|
||||||
|
Page<OrganizationQueryDto> orgQueryDtoPage = new Page<>(pageNo, pageSize, page.getTotal());
|
||||||
|
orgQueryDtoPage.setRecords(orgTree);
|
||||||
|
return orgQueryDtoPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将机构列表转换为树结构
|
||||||
|
*
|
||||||
|
* @param records 机构列表
|
||||||
|
* @return tree
|
||||||
|
*/
|
||||||
|
private List<OrganizationQueryDto> buildTree(List<Organization> records) {
|
||||||
|
// 按b_no的层级排序,确保父节点先处理
|
||||||
|
List<Organization> sortedRecords = records.stream()
|
||||||
|
.sorted(Comparator.comparingInt(r -> r.getBusNo().split("\\.").length)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
Map<String, OrganizationQueryDto> nodeMap = new HashMap<>();
|
||||||
|
List<OrganizationQueryDto> tree = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Organization record : sortedRecords) {
|
||||||
|
String bNo = record.getBusNo();
|
||||||
|
String[] parts = bNo.split("\\.");
|
||||||
|
OrganizationQueryDto node = new OrganizationQueryDto();
|
||||||
|
BeanUtils.copyProperties(record, node);
|
||||||
|
// 将当前节点加入映射
|
||||||
|
nodeMap.put(bNo, node);
|
||||||
|
|
||||||
|
if (parts.length == 1) {
|
||||||
|
// 根节点
|
||||||
|
tree.add(node);
|
||||||
|
} else {
|
||||||
|
// 获取父节点的b_no(去掉最后一部分)
|
||||||
|
String parentBNo = String.join(".", Arrays.copyOf(parts, parts.length - 1));
|
||||||
|
OrganizationQueryDto parent = nodeMap.get(parentBNo);
|
||||||
|
|
||||||
|
if (parent != null) {
|
||||||
|
parent.getChildren().add(node);
|
||||||
|
} else {
|
||||||
|
// 处理父节点不存在的情况(例如数据缺失)
|
||||||
|
// 可根据需求调整为将节点加入根或抛出异常
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构信息详情
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 机构信息详情
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R<?> getOrgInfo(Long orgId) {
|
||||||
|
Organization organization = organizationService.getById(orgId);
|
||||||
|
return R.ok(organization, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息查询"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加/编辑机构
|
||||||
|
*
|
||||||
|
* @param organizationQueryDto 机构信息
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R<?> addOrEditOrganization(OrganizationQueryDto organizationQueryDto) {
|
||||||
|
|
||||||
|
// 新增organization信息
|
||||||
|
Organization organization = new Organization();
|
||||||
|
BeanUtils.copyProperties(organizationQueryDto, organization);
|
||||||
|
|
||||||
|
if (organizationQueryDto.getId() != null) {
|
||||||
|
// 更新机构信息
|
||||||
|
organizationService.updateById(organization);
|
||||||
|
} else {
|
||||||
|
// 生成待发送的机构信息
|
||||||
|
organizationService.save(organization);
|
||||||
|
}
|
||||||
|
// 返回机构id
|
||||||
|
return R.ok(organization.getId(), MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息更新添加"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除机构
|
||||||
|
*
|
||||||
|
* @param orgIds 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R<?> deleteOrganization(String orgIds) {
|
||||||
|
|
||||||
|
List<Long> orgIdList = new ArrayList<>();
|
||||||
|
if (orgIds != null) {
|
||||||
|
orgIdList = Arrays.stream(orgIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除机构信息
|
||||||
|
boolean deleteOrgSuccess = organizationService.removeByIds(orgIdList);
|
||||||
|
return deleteOrgSuccess ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"机构信息"}))
|
||||||
|
: R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构启用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R<?> activeOrg(Long orgId) {
|
||||||
|
// 机构启用
|
||||||
|
boolean result = organizationService.activeOrg(orgId);
|
||||||
|
return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息启用"}))
|
||||||
|
: R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息启用"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构停用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R<?> inactiveOrg(Long orgId) {
|
||||||
|
// 机构停用
|
||||||
|
boolean result = organizationService.inactiveOrg(orgId);
|
||||||
|
return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息停用"}))
|
||||||
|
: R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息停用"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,27 +3,25 @@
|
|||||||
*/
|
*/
|
||||||
package com.openhis.web.basedatamanage.controller;
|
package com.openhis.web.basedatamanage.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.core.common.core.domain.R;
|
import com.core.common.core.domain.R;
|
||||||
import com.core.common.utils.AssignSeqUtil;
|
|
||||||
import com.core.common.utils.MessageUtils;
|
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.constant.PromptMsgConstant;
|
||||||
import com.openhis.common.enums.OrganizationType;
|
import com.openhis.common.enums.OrganizationType;
|
||||||
import com.openhis.web.basedatamanage.appservice.IOrganizationAppService;
|
import com.openhis.web.basedatamanage.appservice.IOrganizationAppService;
|
||||||
import com.openhis.web.basedatamanage.dto.OrganizationInitDto;
|
import com.openhis.web.basedatamanage.dto.OrganizationInitDto;
|
||||||
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
import com.openhis.web.basedatamanage.dto.OrganizationQueryDto;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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 java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机构管理controller
|
* 机构管理controller
|
||||||
@@ -37,15 +35,8 @@ import java.util.stream.Collectors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class OrganizationController {
|
public class OrganizationController {
|
||||||
|
|
||||||
private final IOrganizationService organizationService;
|
|
||||||
private final IOrganizationAppService iOrganizationAppService;
|
private final IOrganizationAppService iOrganizationAppService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrganizationMapper organizationMapper;
|
|
||||||
|
|
||||||
@Autowired(required = false)
|
|
||||||
private AssignSeqUtil assignSeqUtil;
|
|
||||||
|
|
||||||
@GetMapping(value = "/init")
|
@GetMapping(value = "/init")
|
||||||
public R<?> init() {
|
public R<?> init() {
|
||||||
|
|
||||||
@@ -60,121 +51,74 @@ public class OrganizationController {
|
|||||||
/**
|
/**
|
||||||
* 机构分页列表
|
* 机构分页列表
|
||||||
*
|
*
|
||||||
* @param pageNo 当前页码
|
* @param pageNo 当前页码
|
||||||
* @param pageSize 查询条数
|
* @param pageSize 查询条数
|
||||||
* @return 机构分页列表
|
* @return 机构分页列表
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/organization")
|
@GetMapping(value = "/organization")
|
||||||
public R<?> getOrganizationPage(
|
public R<?> getOrganizationPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
|
||||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
Page<OrganizationQueryDto> organizationTree =
|
||||||
Page<OrganizationQueryDto> organizationTree = iOrganizationAppService.getOrganizationTree(pageNo, pageSize);
|
iOrganizationAppService.getOrganizationTree(pageNo, pageSize, request);
|
||||||
return R.ok(organizationTree,
|
return R.ok(organizationTree,
|
||||||
MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[]{"机构信息"}));
|
MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"机构信息"}));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加机构信息
|
|
||||||
*
|
|
||||||
* @param organizationQueryDto 机构信息
|
|
||||||
*/
|
|
||||||
@PostMapping("/organization")
|
|
||||||
public R<?> addOrganization(@Validated @RequestBody OrganizationQueryDto organizationQueryDto) {
|
|
||||||
|
|
||||||
// 新增organization信息
|
|
||||||
Organization organization = new Organization();
|
|
||||||
BeanUtils.copyProperties(organizationQueryDto, organization);
|
|
||||||
|
|
||||||
// 基础采番
|
|
||||||
// String code = assignSeqUtil.getSeq(AssignSeqEnum.TEST.getPrefix());
|
|
||||||
// organizationQueryDto.setBusNo(code);
|
|
||||||
|
|
||||||
boolean saveOrgSuccess = organizationService.save(organization);
|
|
||||||
|
|
||||||
return saveOrgSuccess
|
|
||||||
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[]{"机构信息"}))
|
|
||||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00003, new Object[]{"机构信息"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取机构需要编辑的信息
|
* 获取机构需要编辑的信息
|
||||||
*
|
*
|
||||||
* @param orgId 机构信息
|
* @param orgId 机构信息
|
||||||
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/organization-getById")
|
@GetMapping("/organization-getById")
|
||||||
public R<?> getOrganizationById(@Validated @RequestParam Long orgId) {
|
public R<?> getOrgInfo(@Validated @RequestParam Long orgId) {
|
||||||
|
return iOrganizationAppService.getOrgInfo(orgId);
|
||||||
Organization organization = organizationService.getById(orgId);
|
|
||||||
return R.ok(organization, MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[]{"机构信息"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑机构信息
|
* 添加/编辑机构信息
|
||||||
*
|
*
|
||||||
* @param organizationQueryDto 机构信息
|
* @param organizationQueryDto 机构信息
|
||||||
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
@PutMapping("/organization")
|
@PutMapping("/organization")
|
||||||
public R<?> editOrganization(@Validated @RequestBody OrganizationQueryDto organizationQueryDto) {
|
public R<?> addOrEditInventoryReceipt(@Validated @RequestBody OrganizationQueryDto organizationQueryDto) {
|
||||||
// 更新organization信息
|
return iOrganizationAppService.addOrEditOrganization(organizationQueryDto);
|
||||||
Organization organization = new Organization();
|
|
||||||
BeanUtils.copyProperties(organizationQueryDto, organization);
|
|
||||||
|
|
||||||
boolean updateOrgSuccess = organizationService.updateById(organization);
|
|
||||||
return updateOrgSuccess
|
|
||||||
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[]{"机构信息"}))
|
|
||||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[]{"机构信息"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除机构信息
|
* 删除机构信息
|
||||||
*
|
*
|
||||||
* @param orgIds 需要删除的Id
|
* @param orgIds 需要删除的Id
|
||||||
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/organization")
|
@DeleteMapping("/organization")
|
||||||
public R<?> deleteOrganization(@RequestParam String orgIds) {
|
public R<?> deleteOrganization(@RequestParam String orgIds) {
|
||||||
|
return iOrganizationAppService.deleteOrganization(orgIds);
|
||||||
List<Long> orgIdList = new ArrayList<>();
|
|
||||||
if (orgIds != null) {
|
|
||||||
orgIdList = Arrays.stream(orgIds.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 在service层做业务校验
|
|
||||||
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[]{"机构信息"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用
|
* 机构启用
|
||||||
*
|
*
|
||||||
* @param orgId 启用数据的Id
|
* @param orgId 启用数据的Id
|
||||||
|
* @return 操作结果
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@PutMapping("/organization-active")
|
@PutMapping("/organization-active")
|
||||||
public R<?> changeActive(@RequestParam Long orgId) {
|
public R<?> activeOrganization(@RequestParam Long orgId) {
|
||||||
|
return iOrganizationAppService.activeOrg(orgId);
|
||||||
boolean activeSuccess = organizationService.activeChange(orgId);
|
|
||||||
|
|
||||||
return activeSuccess
|
|
||||||
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[]{"启用"}))
|
|
||||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[]{"启用"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停用
|
* 机构停用
|
||||||
*
|
*
|
||||||
* @param orgId 停用数据的Id
|
* @param orgId 停用数据的Id
|
||||||
|
* @return 操作结果
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@PutMapping("/organization-inactive")
|
@PutMapping("/organization-inactive")
|
||||||
public R<?> changeInactive(@RequestParam Long orgId) {
|
public R<?> inactiveOrganization(@RequestParam Long orgId) {
|
||||||
|
return iOrganizationAppService.inactiveOrg(orgId);
|
||||||
boolean inActiveSuccess = organizationService.activeChange(orgId);
|
|
||||||
|
|
||||||
return inActiveSuccess
|
|
||||||
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[]{"停用"}))
|
|
||||||
: R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[]{"停用"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,21 @@ import com.openhis.administration.domain.Organization;
|
|||||||
* @date 2025-02-21
|
* @date 2025-02-21
|
||||||
*/
|
*/
|
||||||
public interface IOrganizationService extends IService<Organization> {
|
public interface IOrganizationService extends IService<Organization> {
|
||||||
boolean activeChange(Long orgId);
|
|
||||||
|
/**
|
||||||
|
* 机构启用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean activeOrg(Long orgId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构停用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
boolean inactiveOrg(Long orgId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.openhis.administration.service.impl;
|
package com.openhis.administration.service.impl;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.openhis.administration.domain.Organization;
|
import com.openhis.administration.domain.Organization;
|
||||||
import com.openhis.administration.mapper.OrganizationMapper;
|
import com.openhis.administration.mapper.OrganizationMapper;
|
||||||
@@ -19,29 +19,30 @@ import com.openhis.common.enums.AccountStatus;
|
|||||||
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization>
|
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization>
|
||||||
implements IOrganizationService {
|
implements IOrganizationService {
|
||||||
|
|
||||||
@Autowired
|
/**
|
||||||
private OrganizationMapper organizationMapper;
|
* 机构启用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean activeChange(Long orgId) {
|
public boolean activeOrg(Long orgId) {
|
||||||
if (orgId != null) {
|
int updateCount = baseMapper.update(null, new LambdaUpdateWrapper<Organization>().eq(Organization::getId, orgId)
|
||||||
Organization organization = organizationMapper.selectById(orgId);
|
.set(Organization::getActiveFlag, AccountStatus.ACTIVE.getValue()));
|
||||||
if (organization != null) {
|
return updateCount > 0;
|
||||||
Integer activeFlag = organization.getActiveFlag();
|
|
||||||
switch (activeFlag ) {
|
|
||||||
case 1:
|
|
||||||
organization.setActiveFlag(AccountStatus.INACTIVE.getValue());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
organization.setActiveFlag(AccountStatus.ACTIVE.getValue());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
organizationMapper.updateById(organization);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构停用
|
||||||
|
*
|
||||||
|
* @param orgId 机构信息id
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean inactiveOrg(Long orgId) {
|
||||||
|
int updateCount = baseMapper.update(null, new LambdaUpdateWrapper<Organization>().eq(Organization::getId, orgId)
|
||||||
|
.set(Organization::getActiveFlag, AccountStatus.INACTIVE.getValue()));
|
||||||
|
return updateCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user