|
@@ -1,32 +1,36 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.client.UserServiceClient;
|
|
|
-import com.diagbot.dto.GetLibraryDetailDTO;
|
|
|
import com.diagbot.dto.GetLibraryDetailListDTO;
|
|
|
+import com.diagbot.dto.LibraryDetailDTO;
|
|
|
+import com.diagbot.dto.LibraryIndexDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.LibraryDetail;
|
|
|
-import com.diagbot.entity.LibraryInfo;
|
|
|
-import com.diagbot.enums.LexiconTypeEnum;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.LibraryDetailService;
|
|
|
import com.diagbot.service.impl.LibraryDetailServiceImpl;
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.AddLibraryDetailVO;
|
|
|
import com.diagbot.vo.GetLibraryDetailListVO;
|
|
|
import com.diagbot.vo.GetLibraryDetailVO;
|
|
|
+import com.diagbot.vo.LibraryIndexVO;
|
|
|
import com.diagbot.vo.RemoveLibraryDetailVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 术语基本信息查询业务层
|
|
@@ -36,112 +40,118 @@ import com.diagbot.vo.RemoveLibraryDetailVO;
|
|
|
@Component
|
|
|
public class LibraryDetailFacade extends LibraryDetailServiceImpl {
|
|
|
|
|
|
- @Autowired
|
|
|
- private LibraryInfoFacade libraryInfoFacade;
|
|
|
@Autowired
|
|
|
private UserServiceClient userServiceClient;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("libraryDetailServiceImpl")
|
|
|
+ private LibraryDetailService libraryDetailService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取医学术语命名列表
|
|
|
- * @param getMedicalInfoListVO
|
|
|
+ *
|
|
|
+ * @param getLibraryDetailListVO
|
|
|
* @return
|
|
|
*/
|
|
|
public IPage<GetLibraryDetailListDTO> getLibraryDetailList(GetLibraryDetailListVO getLibraryDetailListVO) {
|
|
|
- IPage<GetLibraryDetailListDTO> ipage = this.baseMapper.getLibraryDetailList(getLibraryDetailListVO);
|
|
|
- List<String> ids = ipage.getRecords().stream().map(i->i.getModifier()).distinct().collect(Collectors.toList());
|
|
|
- if(ids.size()>0){
|
|
|
- RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
|
|
|
- if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
|
+ IPage<GetLibraryDetailListDTO> ipage = this.baseMapper.getLibraryDetailList(getLibraryDetailListVO);
|
|
|
+ List<String> ids = ipage.getRecords().stream().map(i -> i.getModifier()).distinct().collect(Collectors.toList());
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
|
|
|
+ if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"获取用户信息失败");
|
|
|
}
|
|
|
- ipage.getRecords().forEach(i->{
|
|
|
- i.setModifier(respDTO.data.get(i.getModifier()));
|
|
|
- });
|
|
|
- }
|
|
|
+ ipage.getRecords().forEach(i -> {
|
|
|
+ i.setModifier(respDTO.data.get(i.getModifier()));
|
|
|
+ });
|
|
|
+ }
|
|
|
return ipage;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 医学术语静态知识删除
|
|
|
+ *
|
|
|
* @param removeLibraryDetailVO
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean removeLibraryDetail(RemoveLibraryDetailVO removeLibraryDetailVO) {
|
|
|
- LibraryDetail libraryDetail = this.getById(removeLibraryDetailVO.getId());
|
|
|
- if(libraryDetail==null||libraryDetail.getIsDeleted().equals("Y")){
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
- }
|
|
|
-
|
|
|
- libraryDetail.setIsDeleted("Y");
|
|
|
- libraryDetail.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
- libraryDetail.setGmtModified(DateUtil.now());
|
|
|
- return updateById(libraryDetail);
|
|
|
+ if (!(IsDeleteEnum.N.getKey().equals(removeLibraryDetailVO.getStatus())
|
|
|
+ || IsDeleteEnum.Y.getKey().equals(removeLibraryDetailVO.getStatus()))) {
|
|
|
+ throw new CommonException(CommonErrorCode.STATUS_IS_ERROR, "状态值错误【Y】或【N】");
|
|
|
+ }
|
|
|
+ String person = UserUtils.getCurrentPrincipleID();
|
|
|
+ List<Long> ids = removeLibraryDetailVO.getConceptId();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ this.update(new LibraryDetail(), new UpdateWrapper<LibraryDetail>()
|
|
|
+ .in("concept_id", ids)
|
|
|
+ .set("gmt_modified", now)
|
|
|
+ .set("modifier", person)
|
|
|
+ .set("is_deleted", removeLibraryDetailVO.getStatus()));
|
|
|
+ return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取医学术语静态知识详情
|
|
|
+ *
|
|
|
* @param getLibraryDetailVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public GetLibraryDetailDTO getLibraryDetail(GetLibraryDetailVO getLibraryDetailVO){
|
|
|
- LibraryDetail libraryDetail = this.getById(getLibraryDetailVO.getId());
|
|
|
- if(libraryDetail==null||libraryDetail.getIsDeleted().equals("Y")){
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
- }
|
|
|
-
|
|
|
- QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<>();
|
|
|
- libraryInfoQe.eq("is_deleted", "N");
|
|
|
- libraryInfoQe.eq("is_concept", "1");
|
|
|
- libraryInfoQe.eq("concept_id", libraryDetail.getConceptId());
|
|
|
- LibraryInfo libraryInfo = libraryInfoFacade.getOne(libraryInfoQe);
|
|
|
- if(libraryInfo==null){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"术语医学属性所属概念不存在!");
|
|
|
- }
|
|
|
-
|
|
|
- GetLibraryDetailDTO getLibraryDetailDTO = new GetLibraryDetailDTO();
|
|
|
- BeanUtil.copyProperties(libraryDetail, getLibraryDetailDTO);
|
|
|
- getLibraryDetailDTO.setConceptName(libraryInfo.getName());
|
|
|
- getLibraryDetailDTO.setConceptType(LexiconTypeEnum.getName(libraryInfo.getTypeId().intValue()));
|
|
|
-
|
|
|
- return getLibraryDetailDTO;
|
|
|
+ public List<LibraryDetailDTO> getLibraryDetail(GetLibraryDetailVO getLibraryDetailVO) {
|
|
|
+ return this.getByParam(getLibraryDetailVO.getConceptId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 医学术语静态知识添加或者编辑
|
|
|
- * @param addLibraryDetailVO
|
|
|
+ *
|
|
|
+ * @param libraryDetailVOList
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean addLibraryDetail(AddLibraryDetailVO addLibraryDetailVO){
|
|
|
- QueryWrapper<LibraryDetail> libraryDetailQe = new QueryWrapper<>();
|
|
|
- libraryDetailQe.eq("concept_id", addLibraryDetailVO.getConceptId());
|
|
|
- libraryDetailQe.eq("source", addLibraryDetailVO.getSource());
|
|
|
- libraryDetailQe.eq("title", addLibraryDetailVO.getTitle());
|
|
|
- LibraryDetail libraryDetail = getOne(libraryDetailQe);
|
|
|
-
|
|
|
- if(libraryDetail!=null&&libraryDetail.getIsDeleted().equals("N")){
|
|
|
- if(addLibraryDetailVO.getIsTip()==1){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"根据(术语、术语来源、标题名称)该静态知识已经建立,确定要覆盖该内容吗?确定,覆盖内容,取消,不覆盖。");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ public Boolean addLibraryDetail(List<AddLibraryDetailVO> libraryDetailVOList) {
|
|
|
+ if (ListUtil.isEmpty(libraryDetailVOList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "静态知识明细内容不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除原明细信息
|
|
|
+ Long conceptId = libraryDetailVOList.get(0).getConceptId();
|
|
|
+ if (conceptId != null) {
|
|
|
+ this.remove(new QueryWrapper<LibraryDetail>()
|
|
|
+ .eq("concept_id", conceptId));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新增明细信息
|
|
|
String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
- Date now = DateUtil.now();
|
|
|
-
|
|
|
- if(libraryDetail==null){
|
|
|
- libraryDetail = new LibraryDetail();
|
|
|
- libraryDetail.setGmtCreated(now);
|
|
|
- libraryDetail.setCreator(currentUser);
|
|
|
- }else{
|
|
|
- libraryDetail.setIsDeleted("N");
|
|
|
- }
|
|
|
-
|
|
|
- libraryDetail.setGmtModified(now);
|
|
|
- libraryDetail.setModifier(currentUser);
|
|
|
- BeanUtil.copyProperties(addLibraryDetailVO, libraryDetail);
|
|
|
-
|
|
|
- return saveOrUpdate(libraryDetail);
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ List<LibraryDetail> list = new ArrayList<>();
|
|
|
+ for (AddLibraryDetailVO detailVO : libraryDetailVOList) {
|
|
|
+ LibraryDetail bean = new LibraryDetail();
|
|
|
+ bean.setConceptId(detailVO.getConceptId());
|
|
|
+ bean.setGmtModified(now);
|
|
|
+ bean.setGmtCreate(now);
|
|
|
+ bean.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
+ bean.setModifier(currentUser);
|
|
|
+ bean.setCreator(currentUser);
|
|
|
+ bean.setContent(detailVO.getContent());
|
|
|
+ bean.setIsReason(detailVO.getIsReason());
|
|
|
+ bean.setOrderNo(detailVO.getOrderNo());
|
|
|
+ bean.setPosition(detailVO.getPosition());
|
|
|
+ bean.setText(detailVO.getText());
|
|
|
+ bean.setTitle(detailVO.getTitle());
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
+ libraryDetailService.saveBatch(list);
|
|
|
+ return true;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检索
|
|
|
+ *
|
|
|
+ * @param libraryIndexVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<LibraryIndexDTO> indexFac(LibraryIndexVO libraryIndexVO) {
|
|
|
+ return this.index(libraryIndexVO);
|
|
|
+ }
|
|
|
+
|
|
|
}
|