版本更新
This commit is contained in:
@@ -38,8 +38,9 @@ public interface IDocStatisticsDefinitionAppService {
|
||||
*/
|
||||
public List<DocStatisticsDefinitionDto> getList(Integer isStatistics);
|
||||
|
||||
List<DocStatisticsDefinitionDto> getListWithOptionList(Integer isStatistics);
|
||||
/**
|
||||
* 获取文档统计定义选项列表并按指定格式返回
|
||||
* 过时obsolete 获取文档统计定义选项列表并按指定格式返回 (key-value)
|
||||
*
|
||||
* @return 封装了处理结果的响应对象
|
||||
*/
|
||||
@@ -53,22 +54,4 @@ public interface IDocStatisticsDefinitionAppService {
|
||||
|
||||
public R<?> deleteDocStatisticsDefinition(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据id获取文档统计定义
|
||||
*
|
||||
* @param id
|
||||
* @return 封装了处理结果的响应对象
|
||||
*/
|
||||
public R<?> getDocStatisticsDefinitionById(Long id);
|
||||
|
||||
/**
|
||||
* 根据code获取文档统计定义
|
||||
*
|
||||
* @param code
|
||||
* @return 封装了处理结果的响应对象
|
||||
*/
|
||||
public R<?> getDocStatisticsDefinitionByCode(String code);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.openhis.web.document.appservice;
|
||||
|
||||
|
||||
import com.core.common.core.domain.AjaxResult;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.document.dto.DocStatisticsDefinitionOptionDto;
|
||||
import com.openhis.web.document.dto.DocStatisticsDefinitionOptionList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档模板 业务接口
|
||||
*/
|
||||
public interface IDocStatisticsDefinitionOptionAppService {
|
||||
|
||||
|
||||
/**
|
||||
* 新增、修改文档模板 统计项选项
|
||||
*
|
||||
* @param docStatisticsDefinitionOptionList
|
||||
*/
|
||||
public R<?> add(DocStatisticsDefinitionOptionList docStatisticsDefinitionOptionList);
|
||||
|
||||
public R<?> createOrEdit(DocStatisticsDefinitionOptionList docStatisticsDefinitionOptionList);
|
||||
|
||||
public R<?> deleteDocStatisticsDefinitionOptionById(Long id);
|
||||
|
||||
public DocStatisticsDefinitionOptionList getDocStatisticsDefinitionOptionByDefinitionId(Long docStatisticsDefinitionId);
|
||||
|
||||
/**
|
||||
* 获取文档模板 统计项选项列表
|
||||
*/
|
||||
public AjaxResult getDocStatisticsDefinitionOptionList();
|
||||
|
||||
|
||||
}
|
||||
@@ -3,7 +3,10 @@ package com.openhis.web.document.appservice.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.constant.CacheConstants;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.core.domain.entity.SysDictData;
|
||||
import com.core.common.core.redis.RedisCache;
|
||||
import com.core.common.utils.bean.BeanUtils;
|
||||
import com.openhis.common.utils.HisPageUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
@@ -11,13 +14,11 @@ import com.openhis.document.domain.DocStatisticsDefinition;
|
||||
import com.openhis.document.mapper.DocStatisticsDefinitionMapper;
|
||||
import com.openhis.document.service.IDocStatisticsDefinitionService;
|
||||
import com.openhis.web.document.appservice.IDocStatisticsDefinitionAppService;
|
||||
import com.openhis.web.document.appservice.IDocStatisticsDefinitionOptionAppService;
|
||||
import com.openhis.web.document.dto.DocDefinitionOrganizationDto;
|
||||
import com.openhis.web.document.dto.DocStatisticsDefinitionDto;
|
||||
import com.openhis.web.document.dto.DocStatisticsDefinitionOptionList;
|
||||
import com.openhis.web.document.dto.OptionDto;
|
||||
import com.openhis.web.document.mapper.DocStatisticsDefinitionAppMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -35,12 +36,11 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
@Resource
|
||||
private IDocStatisticsDefinitionService iDocStatisticsDefinitionService;
|
||||
@Resource
|
||||
private IDocStatisticsDefinitionOptionAppService iDocStaticsDefinitionOptionAppService;
|
||||
@Resource
|
||||
private DocStatisticsDefinitionMapper docStatisticsDefinitionMapper;
|
||||
@Resource
|
||||
private DocStatisticsDefinitionAppMapper docStatisticsDefinitionAppMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@Override
|
||||
public R<?> createOrEdit(DocStatisticsDefinitionDto docStatisticsDefinitionDto) {
|
||||
if (docStatisticsDefinitionDto == null) {
|
||||
@@ -95,15 +95,10 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
docStatisticsDefinition.setIsStatistics(docStatisticsDefinitionDto.getIsStatistics());
|
||||
docStatisticsDefinition.setDisplayOrder(docStatisticsDefinitionDto.getDisplayOrder());
|
||||
docStatisticsDefinition.setUnit(docStatisticsDefinitionDto.getUnit());
|
||||
|
||||
|
||||
docStatisticsDefinition.setDictType(docStatisticsDefinitionDto.getDictType());
|
||||
docStatisticsDefinition.setDictName(docStatisticsDefinitionDto.getDictName());
|
||||
boolean saveResult = iDocStatisticsDefinitionService.save(docStatisticsDefinition);
|
||||
if (saveResult) {
|
||||
// 同步保存选项列表(如有)
|
||||
if (docStatisticsDefinitionDto.getOptionList() != null && !docStatisticsDefinitionDto.getOptionList().getOptions().isEmpty()) {
|
||||
docStatisticsDefinitionDto.getOptionList().setDocStatisticsDefinitionId(docStatisticsDefinition.getId());
|
||||
return iDocStaticsDefinitionOptionAppService.add(docStatisticsDefinitionDto.getOptionList());
|
||||
}
|
||||
return R.ok("文档统计定义新增成功");
|
||||
} else {
|
||||
return R.fail("文档统计定义新增失败");
|
||||
@@ -131,10 +126,12 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
existingData.setIsStatistics(docStatisticsDefinitionDto.getIsStatistics());
|
||||
existingData.setDisplayOrder(docStatisticsDefinitionDto.getDisplayOrder());
|
||||
existingData.setUnit(docStatisticsDefinitionDto.getUnit());
|
||||
existingData.setDictType(docStatisticsDefinitionDto.getDictType());
|
||||
existingData.setDictName(docStatisticsDefinitionDto.getDictName());
|
||||
boolean updateResult = iDocStatisticsDefinitionService.updateById(existingData);
|
||||
if (updateResult) {
|
||||
// 同步更新选项列表
|
||||
return iDocStaticsDefinitionOptionAppService.createOrEdit(docStatisticsDefinitionDto.getOptionList());
|
||||
return R.ok("文档统计定义更新成功");
|
||||
} else {
|
||||
return R.fail("文档统计定义更新失败");
|
||||
}
|
||||
@@ -168,12 +165,12 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
*/
|
||||
@Override
|
||||
public R<?> getPageList(Integer pageNo, Integer pageSize, String searchKey, HttpServletRequest request) {
|
||||
// Map<String, Object> keyMap = redisCache.getAllDictDataWithKeys(CacheConstants.SYS_DICT_KEY);
|
||||
// 构建查询条件(支持多字段搜索)
|
||||
QueryWrapper<DocStatisticsDefinition> queryWrapper = HisQueryUtils.buildQueryWrapper(
|
||||
null, searchKey, new HashSet<>(Arrays.asList("name", "code")), request);
|
||||
// 按记录时间倒序(最新记录在前)
|
||||
queryWrapper.lambda().orderByDesc(DocStatisticsDefinition::getDisplayOrder);
|
||||
|
||||
Page<DocStatisticsDefinitionDto> recordPage = HisPageUtils.selectPage(
|
||||
docStatisticsDefinitionMapper, queryWrapper, pageNo, pageSize, DocStatisticsDefinitionDto.class);
|
||||
// 转换为分页结果
|
||||
@@ -181,13 +178,14 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档统计定义列表(不分页)
|
||||
* 获取文档统计定义列表(不分页,不包含options)
|
||||
*
|
||||
* @param isStatistics 是否统计
|
||||
* @return 文档统计定义列表
|
||||
*/
|
||||
@Override
|
||||
public List<DocStatisticsDefinitionDto> getList(Integer isStatistics) {
|
||||
Map<String, Object> keyMap = redisCache.getAllDictDataWithKeys(CacheConstants.SYS_DICT_KEY);
|
||||
LambdaQueryWrapper<DocStatisticsDefinition> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (isStatistics != null) {
|
||||
queryWrapper.eq(DocStatisticsDefinition::getIsStatistics, isStatistics);
|
||||
@@ -201,7 +199,28 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocStatisticsDefinitionDto> getListWithOptionList(Integer isStatistics) {
|
||||
//从redis中获取所有字典数据
|
||||
Map<String, Object> keyMap = redisCache.getAllDictDataWithKeys(CacheConstants.SYS_DICT_KEY);
|
||||
LambdaQueryWrapper<DocStatisticsDefinition> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (isStatistics != null) {
|
||||
queryWrapper.eq(DocStatisticsDefinition::getIsStatistics, isStatistics);
|
||||
}
|
||||
List<DocStatisticsDefinition> dataList = iDocStatisticsDefinitionService.list(queryWrapper);
|
||||
List<DocStatisticsDefinitionDto> resultList = new ArrayList<>();
|
||||
for (DocStatisticsDefinition data : dataList) {
|
||||
DocStatisticsDefinitionDto dto = new DocStatisticsDefinitionDto();
|
||||
BeanUtils.copyProperties(data, dto);
|
||||
if(keyMap.containsKey(CacheConstants.SYS_DICT_KEY+data.getDictType()))
|
||||
{
|
||||
List<SysDictData> dictData = (List<SysDictData>) keyMap.get(CacheConstants.SYS_DICT_KEY+data.getDictType());
|
||||
dto.setOptionList(dictData);
|
||||
}
|
||||
resultList.add(dto);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
/**
|
||||
* 获取文档统计定义选项列表并按指定格式返回
|
||||
*
|
||||
@@ -276,62 +295,12 @@ public class DocStatisticsDefinitionAppServiceImpl implements IDocStatisticsDefi
|
||||
}
|
||||
boolean deleteResult = iDocStatisticsDefinitionService.removeById(id);
|
||||
if (deleteResult) {
|
||||
// 同步删除选项列表
|
||||
iDocStaticsDefinitionOptionAppService.deleteDocStatisticsDefinitionOptionById(id);
|
||||
return R.ok("文档统计定义删除成功");
|
||||
} else {
|
||||
return R.fail("文档统计定义删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档统计定义详情
|
||||
*
|
||||
* @param id 文档统计定义ID
|
||||
* @return 封装了处理结果的响应对象
|
||||
*/
|
||||
@Override
|
||||
public R<?> getDocStatisticsDefinitionById(Long id) {
|
||||
if (id == null) {
|
||||
return R.fail("获取文档统计定义,参数ID不能为空");
|
||||
}
|
||||
DocStatisticsDefinition data = iDocStatisticsDefinitionService.getById(id);
|
||||
if (data == null) {
|
||||
return R.fail("获取文档统计定义失败,目标数据不存在");
|
||||
}
|
||||
// 转换为DTO返回
|
||||
DocStatisticsDefinitionDto dto = new DocStatisticsDefinitionDto();
|
||||
BeanUtils.copyProperties(data, dto);
|
||||
DocStatisticsDefinitionOptionList optionList = iDocStaticsDefinitionOptionAppService.getDocStatisticsDefinitionOptionByDefinitionId(id);
|
||||
dto.setOptionList(optionList);
|
||||
return R.ok(dto, "文档统计定义获取成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据代码获取文档统计定义详情
|
||||
*
|
||||
* @param code 文档统计定义代码
|
||||
* @return 封装了处理结果的响应对象
|
||||
*/
|
||||
@Override
|
||||
public R<?> getDocStatisticsDefinitionByCode(String code) {
|
||||
if (code == null || code.trim().isEmpty()) {
|
||||
return R.fail("获取文档统计定义,参数代码不能为空");
|
||||
}
|
||||
// 按代码查询
|
||||
LambdaQueryWrapper<DocStatisticsDefinition> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(DocStatisticsDefinition::getCode, code);
|
||||
DocStatisticsDefinition data = iDocStatisticsDefinitionService.getOne(queryWrapper);
|
||||
if (data == null) {
|
||||
return R.fail("获取文档统计定义失败,目标数据不存在");
|
||||
}
|
||||
DocStatisticsDefinitionDto dto = new DocStatisticsDefinitionDto();
|
||||
if (data != null) {
|
||||
BeanUtils.copyProperties(data, dto);
|
||||
}
|
||||
DocStatisticsDefinitionOptionList optionList = iDocStaticsDefinitionOptionAppService.getDocStatisticsDefinitionOptionByDefinitionId(data.getId());
|
||||
dto.setOptionList(optionList);
|
||||
return R.ok(dto, "文档统计定义获取成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,229 +0,0 @@
|
||||
package com.openhis.web.document.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.domain.AjaxResult;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.bean.BeanUtils;
|
||||
import com.openhis.document.domain.DocStatisticsDefinitionOption;
|
||||
import com.openhis.document.mapper.DocStatisticsDefinitionOptionMapper;
|
||||
import com.openhis.document.service.IDocStatisticsDefinitionOptionService;
|
||||
import com.openhis.web.document.appservice.IDocStatisticsDefinitionOptionAppService;
|
||||
import com.openhis.web.document.dto.DocStatisticsDefinitionOptionDto;
|
||||
import com.openhis.web.document.dto.DocStatisticsDefinitionOptionList;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 文档统计定义选项 业务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DocStatisticsDefinitionOptionAppServiceImpl implements IDocStatisticsDefinitionOptionAppService {
|
||||
|
||||
@Resource
|
||||
private DocStatisticsDefinitionOptionMapper docStatisticsDefinitonOptionMapper;
|
||||
@Resource
|
||||
private IDocStatisticsDefinitionOptionService docStatisticsDefinitionOptionService;
|
||||
|
||||
/**
|
||||
* 新增文档统计定义选项
|
||||
*
|
||||
* @param docStatisticsDefinitionOptionList 选项列表DTO
|
||||
*/
|
||||
@Override
|
||||
public R<?> add(DocStatisticsDefinitionOptionList docStatisticsDefinitionOptionList) {
|
||||
// 参数校验
|
||||
if (docStatisticsDefinitionOptionList == null) {
|
||||
return R.fail("统计项选项列表为空,请选择统计项选项");
|
||||
}
|
||||
if (docStatisticsDefinitionOptionList.getOptions() == null || docStatisticsDefinitionOptionList.getOptions().isEmpty()) {
|
||||
return R.fail("统计项选项不允许为空,请正确填写统计项选项");
|
||||
}
|
||||
if (docStatisticsDefinitionOptionList.getDocStatisticsDefinitionId() == null) {
|
||||
return R.fail("统计项定义ID为空,请选择统计项定义ID");
|
||||
}
|
||||
|
||||
// DTO转实体
|
||||
List<DocStatisticsDefinitionOption> optionList = new ArrayList<>();
|
||||
for (DocStatisticsDefinitionOptionDto dto : docStatisticsDefinitionOptionList.getOptions()) {
|
||||
DocStatisticsDefinitionOption option = new DocStatisticsDefinitionOption();
|
||||
option.setDocStatisticsDefinitionId(docStatisticsDefinitionOptionList.getDocStatisticsDefinitionId());
|
||||
option.setOption(dto.getOption());
|
||||
option.setDisplayOrder(dto.getDisplayOrder());
|
||||
optionList.add(option);
|
||||
}
|
||||
|
||||
// 批量新增
|
||||
boolean saveSuccess = docStatisticsDefinitionOptionService.saveBatch(optionList);
|
||||
if (saveSuccess) {
|
||||
return R.ok(optionList, "统计项选项保存成功");
|
||||
} else {
|
||||
return R.fail("统计项选项保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增/编辑文档统计定义选项(区分增删改)
|
||||
*
|
||||
* @param docStatisticsDefinitionOptionList 选项列表DTO
|
||||
*/
|
||||
@Override
|
||||
public R<?> createOrEdit(DocStatisticsDefinitionOptionList docStatisticsDefinitionOptionList) {
|
||||
// 参数校验
|
||||
if (docStatisticsDefinitionOptionList == null) {
|
||||
return R.fail("统计项选项列表为空,请选择统计项选项");
|
||||
}
|
||||
Long definitionId = docStatisticsDefinitionOptionList.getDocStatisticsDefinitionId();
|
||||
if (definitionId == null) {
|
||||
return R.fail("统计项定义ID为空,请选择统计项定义ID");
|
||||
}
|
||||
|
||||
// 1. 查询原数据列表(按统计定义ID关联)
|
||||
List<DocStatisticsDefinitionOption> oldList = docStatisticsDefinitonOptionMapper.selectList(
|
||||
new LambdaQueryWrapper<DocStatisticsDefinitionOption>()
|
||||
.eq(DocStatisticsDefinitionOption::getDocStatisticsDefinitionId, definitionId));
|
||||
oldList = oldList == null ? Collections.emptyList() : oldList;
|
||||
|
||||
// 2. 处理新数据列表(DTO转实体,避免空指针)
|
||||
List<DocStatisticsDefinitionOption> newList = new ArrayList<>();
|
||||
if (docStatisticsDefinitionOptionList.getOptions() != null && !docStatisticsDefinitionOptionList.getOptions().isEmpty()) {
|
||||
for (DocStatisticsDefinitionOptionDto dto : docStatisticsDefinitionOptionList.getOptions()) {
|
||||
DocStatisticsDefinitionOption option = new DocStatisticsDefinitionOption();
|
||||
BeanUtils.copyProperties(dto, option); // 改用BeanUtils简化赋值
|
||||
option.setDocStatisticsDefinitionId(definitionId); // 强制关联父ID,确保数据一致性
|
||||
newList.add(option);
|
||||
}
|
||||
}
|
||||
newList = newList == null ? Collections.emptyList() : newList;
|
||||
|
||||
// 3. 构建原数据ID映射(快速查找)
|
||||
Map<Long, DocStatisticsDefinitionOption> oldIdMap = oldList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> item.getId() != null)
|
||||
.collect(Collectors.toMap(DocStatisticsDefinitionOption::getId, item -> item));
|
||||
|
||||
// 4. 提取新数据中的有效ID集合
|
||||
Set<Long> newIds = newList.stream()
|
||||
.map(DocStatisticsDefinitionOption::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 5. 确定需要删除的项(原数据存在但新数据不存在)
|
||||
List<Long> deleteIds = oldList.stream()
|
||||
.map(DocStatisticsDefinitionOption::getId)
|
||||
.filter(id -> !newIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 6. 区分新增和修改的项
|
||||
List<DocStatisticsDefinitionOption> addList = new ArrayList<>();
|
||||
List<DocStatisticsDefinitionOption> updateList = new ArrayList<>();
|
||||
for (DocStatisticsDefinitionOption newItem : newList) {
|
||||
Long newItemId = newItem.getId();
|
||||
if (newItemId != null && oldIdMap.containsKey(newItemId)) {
|
||||
// 有ID且原数据存在 → 修改
|
||||
updateList.add(newItem);
|
||||
} else {
|
||||
// 无ID或原数据不存在 → 新增
|
||||
addList.add(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 执行删除操作
|
||||
if (!deleteIds.isEmpty()) {
|
||||
boolean deleteSuccess = docStatisticsDefinitionOptionService.removeByIds(deleteIds);
|
||||
if (!deleteSuccess) {
|
||||
return R.fail("统计项选项删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 8. 执行修改操作
|
||||
if (!updateList.isEmpty()) {
|
||||
boolean updateSuccess = docStatisticsDefinitionOptionService.updateBatchById(updateList);
|
||||
if (!updateSuccess) {
|
||||
return R.fail("统计项选项更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 9. 执行新增操作
|
||||
if (!addList.isEmpty()) {
|
||||
boolean addSuccess = docStatisticsDefinitionOptionService.saveBatch(addList);
|
||||
if (!addSuccess) {
|
||||
return R.fail("统计项选项新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok("统计项选项更新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个统计项选项
|
||||
*
|
||||
* @param id 选项ID
|
||||
*/
|
||||
@Override
|
||||
public R<?> deleteDocStatisticsDefinitionOptionById(Long id) {
|
||||
if (id == null) {
|
||||
return R.fail("统计项选项ID为空,请选择要删除的统计项选项");
|
||||
}
|
||||
|
||||
// 先校验数据是否存在
|
||||
DocStatisticsDefinitionOption existingOption = docStatisticsDefinitionOptionService.getById(id);
|
||||
if (existingOption == null) {
|
||||
return R.fail("统计项选项不存在,删除失败");
|
||||
}
|
||||
// 执行删除
|
||||
boolean deleteSuccess = docStatisticsDefinitionOptionService.removeById(id);
|
||||
if (deleteSuccess) {
|
||||
return R.ok("统计项选项删除成功");
|
||||
} else {
|
||||
return R.fail("统计项选项删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据统计定义ID查询选项列表
|
||||
*
|
||||
* @param docStatisticsDefinitionId 统计定义ID
|
||||
*/
|
||||
@Override
|
||||
public DocStatisticsDefinitionOptionList getDocStatisticsDefinitionOptionByDefinitionId(Long docStatisticsDefinitionId) {
|
||||
|
||||
// 修复原查询条件错误:原逻辑用ID查ID,改为用统计定义ID查关联选项
|
||||
LambdaQueryWrapper<DocStatisticsDefinitionOption> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(DocStatisticsDefinitionOption::getDocStatisticsDefinitionId, docStatisticsDefinitionId)
|
||||
.orderByAsc(DocStatisticsDefinitionOption::getDisplayOrder); // 按显示顺序排序
|
||||
|
||||
List<DocStatisticsDefinitionOption> optionList = docStatisticsDefinitonOptionMapper.selectList(queryWrapper);
|
||||
if (optionList == null || optionList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// 实体转DTO
|
||||
List<DocStatisticsDefinitionOptionDto> dtoList = new ArrayList<>();
|
||||
for (DocStatisticsDefinitionOption option : optionList) {
|
||||
DocStatisticsDefinitionOptionDto dto = new DocStatisticsDefinitionOptionDto();
|
||||
dto.setId(option.getId());
|
||||
dto.setOption(option.getOption());
|
||||
dto.setDisplayOrder(option.getDisplayOrder());
|
||||
dtoList.add(dto);
|
||||
}
|
||||
|
||||
// 封装返回结果
|
||||
DocStatisticsDefinitionOptionList resultList = new DocStatisticsDefinitionOptionList();
|
||||
resultList.setDocStatisticsDefinitionId(docStatisticsDefinitionId);
|
||||
resultList.setOptions(dtoList);
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档模板 统计项选项列表
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getDocStatisticsDefinitionOptionList() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -78,29 +79,6 @@ public class DocStatisticsDefinitionController {
|
||||
public R<?> deleteDocStatisticsDefinition(Long id) {
|
||||
return docStatisticsDefinitionAppService.deleteDocStatisticsDefinition(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取统计定义详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDocStatisticsDefinitionById")
|
||||
public R<?> getDocStatisticsDefinitionById(Long id) {
|
||||
return docStatisticsDefinitionAppService.getDocStatisticsDefinitionById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取统计定义详情
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDocStatisticsDefinitionByCode")
|
||||
public R<?> getDocStatisticsDefinitionByCode(String code) {
|
||||
return docStatisticsDefinitionAppService.getDocStatisticsDefinitionByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询列表-不包含options
|
||||
*
|
||||
@@ -116,9 +94,30 @@ public class DocStatisticsDefinitionController {
|
||||
@RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
|
||||
return docStatisticsDefinitionAppService.getPageList(pageNo, pageSize, searchKey, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档统计定义选项列表并按指定格式返回
|
||||
* 获取文档统计定义列表-不包含options,即字典数据
|
||||
*
|
||||
* @param isStatistics 文档统计定义是否启用 0:不统计 1:统计 可不传
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public R<?> getList(Integer isStatistics){
|
||||
List<DocStatisticsDefinitionDto> list = docStatisticsDefinitionAppService.getList(isStatistics);
|
||||
return R.ok(list);
|
||||
}
|
||||
/**
|
||||
* 获取文档统计定义列表(包含options,即字典数据)
|
||||
*
|
||||
* @param isStatistics 文档统计定义是否启用 0:不统计 1:统计 可不传
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getListWithOptionList")
|
||||
public R<?>getListWithOptionList(Integer isStatistics){
|
||||
List<DocStatisticsDefinitionDto> list = docStatisticsDefinitionAppService.getListWithOptionList(isStatistics);
|
||||
return R.ok(list);
|
||||
}
|
||||
/**
|
||||
* 获取文档统计定义选项列表并按指定格式返回-已作废
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.openhis.web.document.controller;
|
||||
|
||||
import com.openhis.web.document.appservice.IDocRecordAppService;
|
||||
import com.openhis.web.document.appservice.IDocStatisticsDefinitionOptionAppService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 文文统计选项 controller
|
||||
*
|
||||
* @author wanghaiming
|
||||
* @date 2025-08-12
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/document/statisticsOption")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class DocStatisticsOptionController {
|
||||
|
||||
private final IDocStatisticsDefinitionOptionAppService docStatisticsDefinitionOptionAppService;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.openhis.web.document.dto;
|
||||
|
||||
import com.core.common.annotation.Excel;
|
||||
import com.core.common.core.domain.entity.SysDictData;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -48,9 +50,16 @@ public class DocStatisticsDefinitionDto {
|
||||
*/
|
||||
private Integer displayOrder;
|
||||
|
||||
/*
|
||||
统计类型定义选项值
|
||||
*/
|
||||
private DocStatisticsDefinitionOptionList optionList;
|
||||
private String defaultValue;
|
||||
|
||||
// /*
|
||||
// 统计类型定义选项值
|
||||
// */
|
||||
private List<SysDictData> optionList;
|
||||
/** 字典名称 */
|
||||
private String dictName;
|
||||
|
||||
/** 字典类型 */
|
||||
private String dictType;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user