富文本标签解析

This commit is contained in:
zhangheng 2024-05-21 09:06:19 +08:00
parent 17a349abf9
commit fcd69a94e0
4 changed files with 46 additions and 3 deletions

View File

@ -95,4 +95,12 @@ public class SpecialDiseaseRouteController extends BaseController {
public AjaxResult editReleaseStatus(@RequestBody SpecialDiseaseRoute specialDiseaseRoute) {
return specialDiseaseRouteService.editReleaseStatus(specialDiseaseRoute);
}
/**
* 富文本解析
*/
@GetMapping("/jsoupParse")
public List<String> jsoupParse(Long specialDiseaseNodeId) {
return specialDiseaseRouteService.jsoupParse(specialDiseaseNodeId);
}
}

View File

@ -2,10 +2,11 @@ package com.xinelu.manage.dto.signpatientmanageroutenode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDate;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
/**
* @description: 患者任务查询传输对象
* @author: haown

View File

@ -77,4 +77,12 @@ public interface ISpecialDiseaseRouteService {
* @return AjaxResult
*/
AjaxResult editReleaseStatus(SpecialDiseaseRoute specialDiseaseRoute);
/**
* 富文本解析
*
* @param specialDiseaseNodeId 节点id
* @return List<String>
*/
List<String> jsoupParse(Long specialDiseaseNodeId);
}

View File

@ -8,6 +8,7 @@ import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.SecurityUtils;
import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.common.utils.codes.GenerateSystemCodeUtil;
import com.xinelu.manage.domain.specialdiseasenode.SpecialDiseaseNode;
import com.xinelu.manage.domain.specialdiseaseroute.SpecialDiseaseRoute;
import com.xinelu.manage.domain.specialdiseaseroutepackage.SpecialDiseaseRoutePackage;
import com.xinelu.manage.dto.specialdiseaseroute.SpecialDiseaseRouteDTO;
@ -21,6 +22,10 @@ import com.xinelu.manage.vo.specialdiseaseroute.SpecialDiseaseRouteVO;
import com.xinelu.manage.vo.specialdiseaseroutepackage.SpecialDiseaseRoutePackageVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -192,12 +197,12 @@ public class SpecialDiseaseRouteServiceImpl implements ISpecialDiseaseRouteServi
* @return AjaxResult
*/
@Override
public AjaxResult departmentRouteCount(String departmentName,String releaseStatus,Long servicePackageId) {
public AjaxResult departmentRouteCount(String departmentName, String releaseStatus, Long servicePackageId) {
DepartmentVO departmentVO = new DepartmentVO();
List<DepartmentVO> department = new ArrayList<>();
departmentVO.setDepartmentName("全部");
departmentVO.setCountNum(0);
List<DepartmentVO> departmentVOS = specialDiseaseRouteMapper.departmentRouteByDepartmentName(departmentName,releaseStatus,servicePackageId);
List<DepartmentVO> departmentVOS = specialDiseaseRouteMapper.departmentRouteByDepartmentName(departmentName, releaseStatus, servicePackageId);
if (CollectionUtils.isNotEmpty(departmentVOS)) {
Integer result = departmentVOS.stream().mapToInt(DepartmentVO::getCountNum).sum();
departmentVO.setCountNum(result);
@ -229,4 +234,25 @@ public class SpecialDiseaseRouteServiceImpl implements ISpecialDiseaseRouteServi
specialDiseaseRoute.setUpdateBy(SecurityUtils.getUsername());
return AjaxResult.success(specialDiseaseRouteMapper.updateSpecialDiseaseRoute(specialDiseaseRoute));
}
/**
* 富文本解析
*
* @param specialDiseaseNodeId 节点id
* @return List<String>
*/
public List<String> jsoupParse(Long specialDiseaseNodeId) {
SpecialDiseaseNode specialDiseaseNode = specialDiseaseNodeMapper.selectSpecialDiseaseNodeById(specialDiseaseNodeId);
if (Objects.isNull(specialDiseaseNode) || StringUtils.isBlank(specialDiseaseNode.getNodeContent())) {
return new ArrayList<>();
}
String xmlString = specialDiseaseNode.getNodeContent();
Document doc = Jsoup.parse(xmlString);
Elements select = doc.select("span[data-w-e-type]");
List<String> strings = new ArrayList<>();
for (Element element : select) {
strings.add(String.valueOf(element));
}
return strings;
}
}