|
@@ -2,12 +2,18 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.QuestionShortDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.dto.VitalInfoDTO;
|
|
|
+import com.diagbot.dto.VitalOrderDTO;
|
|
|
import com.diagbot.entity.QuestionInfo;
|
|
|
import com.diagbot.entity.VitalOrder;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.QuestionTypeEnum;
|
|
|
import com.diagbot.service.VitalOrderService;
|
|
|
import com.diagbot.service.impl.VitalOrderServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
@@ -19,6 +25,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -33,6 +40,8 @@ public class VitalOrderFacade extends VitalOrderServiceImpl {
|
|
|
VitalOrderService vitalOrderService;
|
|
|
@Autowired
|
|
|
QuestionInfoFacade questionInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ UserServiceClient userServiceClient;
|
|
|
|
|
|
public Boolean saveAll(List<VitalOrderVO> vitalOrderVOList) {
|
|
|
//先删除现有排序
|
|
@@ -63,24 +72,87 @@ public class VitalOrderFacade extends VitalOrderServiceImpl {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<VitalInfoDTO> getAll() {
|
|
|
+ public VitalOrderDTO getVitalOrderList() {
|
|
|
+ VitalOrderDTO vitalOrderDTO = new VitalOrderDTO();
|
|
|
+
|
|
|
QueryWrapper<VitalOrder> vitalOrderQueryWrapper = new QueryWrapper<>();
|
|
|
- vitalOrderQueryWrapper.orderByAsc("order_no");
|
|
|
- List<VitalOrder> vitalOrderLis = this.list(vitalOrderQueryWrapper);
|
|
|
- Map<Long, VitalOrder> orderMap = EntityUtil.makeEntityMap(vitalOrderLis, "id");
|
|
|
- List<QuestionInfo> vitals = Lists.newArrayList(questionInfoFacade.listByIds(orderMap.keySet()));
|
|
|
+ vitalOrderQueryWrapper.orderByAsc("order_no")
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ List<VitalOrder> vitalOrderList = this.list(vitalOrderQueryWrapper);
|
|
|
+ List<Long> vitalIds = vitalOrderList.stream().map(vitalOrder -> vitalOrder.getQuestionId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //操作人
|
|
|
+ if (vitalOrderList.size() > 0) {
|
|
|
+ String userId = vitalOrderList.get(0).getModifier();
|
|
|
+ vitalOrderDTO.setGmtOperate(vitalOrderList.get(0).getGmtModified());
|
|
|
+ vitalOrderDTO.setOperator(userId);
|
|
|
+ List<String> userIds = Lists.newArrayList();
|
|
|
+ userIds.add(userId);
|
|
|
+ RespDTO<Map<String, String>> userInfoMap = userServiceClient.getUserInfoByIds(userIds);
|
|
|
+ vitalOrderDTO.setOperatorName(userInfoMap.data.get(userId));
|
|
|
+ }
|
|
|
+
|
|
|
+ //已排序查体标签
|
|
|
+ List<QuestionInfo> vitals = Lists.newArrayList(questionInfoFacade.listByIds(vitalIds));
|
|
|
Map<Long, QuestionInfo> vitalMap = EntityUtil.makeEntityMap(vitals, "id");
|
|
|
- List<VitalInfoDTO> vitalInfoDTOList = Lists.newArrayList();
|
|
|
- for (Map.Entry<Long, VitalOrder> entry : orderMap.entrySet()) {
|
|
|
- if (vitalMap.get(entry.getKey()) != null) {
|
|
|
- VitalInfoDTO vitalInfoDTO = new VitalInfoDTO();
|
|
|
- vitalInfoDTO.setId(vitalMap.get(entry.getKey()).getId());
|
|
|
- vitalInfoDTO.setTagName(vitalMap.get(entry.getKey()).getTagName());
|
|
|
- vitalInfoDTO.setOrderNo(entry.getValue().getOrderNo());
|
|
|
- vitalInfoDTOList.add(vitalInfoDTO);
|
|
|
+
|
|
|
+ List<VitalInfoDTO> vitalInfoDTOList = Lists.newLinkedList();
|
|
|
+ for (VitalOrder vitalOrder : vitalOrderList) {
|
|
|
+ VitalInfoDTO vitalInfoDTO = new VitalInfoDTO();
|
|
|
+ QuestionInfo questionInfo = vitalMap.get(vitalOrder.getQuestionId());
|
|
|
+ if (questionInfo != null) {
|
|
|
+ BeanUtil.copyProperties(questionInfo, vitalInfoDTO);
|
|
|
}
|
|
|
+ vitalInfoDTO.setOrderNo(vitalOrder.getOrderNo());
|
|
|
+ vitalInfoDTOList.add(vitalInfoDTO);
|
|
|
+ }
|
|
|
+ vitalOrderDTO.setVitals(vitalInfoDTOList);
|
|
|
+
|
|
|
+ //未排序查体标签
|
|
|
+ QueryWrapper<QuestionInfo> unOrderedVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ unOrderedVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("type", QuestionTypeEnum.Vital.getKey())
|
|
|
+ .eq("sub_type", 0)
|
|
|
+ .notIn("id", vitalIds);
|
|
|
+ List<QuestionInfo> unOrderVitals = questionInfoFacade.list(unOrderedVitalQueryWrapper);
|
|
|
+ List<QuestionShortDTO> unOrderedVitalList = Lists.newLinkedList();
|
|
|
+ for (QuestionInfo questionInfo : unOrderVitals) {
|
|
|
+ QuestionShortDTO questionShortDTO = new QuestionShortDTO();
|
|
|
+ BeanUtil.copyProperties(questionInfo, questionShortDTO);
|
|
|
+ unOrderedVitalList.add(questionShortDTO);
|
|
|
+ }
|
|
|
+ vitalOrderDTO.setUnOrderedVitals(unOrderedVitalList);
|
|
|
+
|
|
|
+ return vitalOrderDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取未排序查体标签
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<QuestionShortDTO> getUnOrderedVitalList() {
|
|
|
+ //已排序查体标签
|
|
|
+ QueryWrapper<VitalOrder> vitalOrderQueryWrapper = new QueryWrapper<>();
|
|
|
+ vitalOrderQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ List<VitalOrder> vitalOrderList = this.list(vitalOrderQueryWrapper);
|
|
|
+ List<Long> vitalIds = vitalOrderList.stream().map(vitalOrder -> vitalOrder.getQuestionId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //未排序查体标签
|
|
|
+ QueryWrapper<QuestionInfo> unOrderedVitalQueryWrapper = new QueryWrapper<>();
|
|
|
+ unOrderedVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("type", QuestionTypeEnum.Vital.getKey())
|
|
|
+ .eq("sub_type", 0)
|
|
|
+ .notIn("id", vitalIds);
|
|
|
+ List<QuestionInfo> vitals = questionInfoFacade.list(unOrderedVitalQueryWrapper);
|
|
|
+
|
|
|
+ List<QuestionShortDTO> questionShortDTOList = Lists.newLinkedList();
|
|
|
+ for (QuestionInfo questionInfo : vitals) {
|
|
|
+ QuestionShortDTO questionShortDTO = new QuestionShortDTO();
|
|
|
+ BeanUtil.copyProperties(questionInfo, questionShortDTO);
|
|
|
+ questionShortDTOList.add(questionShortDTO);
|
|
|
}
|
|
|
- return vitalInfoDTOList;
|
|
|
+ return questionShortDTOList;
|
|
|
}
|
|
|
|
|
|
/**
|