|
@@ -0,0 +1,102 @@
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.QuestionPageDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.ScaleContent;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.ScaleContentService;
|
|
|
+import com.diagbot.service.impl.ScaleContentServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.vo.QuestionPageVO;
|
|
|
+import com.diagbot.vo.ScaleContentSaveVO;
|
|
|
+import com.diagbot.vo.ScaleContentVO;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zhoutg
|
|
|
+ * @Description
|
|
|
+ * @time 2018年12月5日下午4:53:59
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class ScaleContentFacade extends ScaleContentServiceImpl {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("scaleContentServiceImpl")
|
|
|
+ ScaleContentService scaleContentService;
|
|
|
+ @Autowired
|
|
|
+ UserServiceClient userServiceClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 量表内容新增或更新
|
|
|
+ *
|
|
|
+ * @param scaleContentSaveVO
|
|
|
+ */
|
|
|
+ public void insertOrUpdate(ScaleContentSaveVO scaleContentSaveVO) {
|
|
|
+ Long scaleId = scaleContentSaveVO.getScaleId();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ String userId = "ddd";
|
|
|
+ //删除原关联内容
|
|
|
+ if(scaleId != null) {
|
|
|
+ this.update(new ScaleContent(), new UpdateWrapper<ScaleContent>()
|
|
|
+ .eq("scale_id", scaleId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .set("gmt_modified", now)
|
|
|
+ .set("modifier", userId)
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey()));
|
|
|
+ }
|
|
|
+ //新增关联内容
|
|
|
+ List<ScaleContent> list = new ArrayList<>();
|
|
|
+ List<ScaleContentVO> scaleContentVOS = scaleContentSaveVO.getContent();
|
|
|
+ for(ScaleContentVO scaleContentVO : scaleContentVOS) {
|
|
|
+ ScaleContent bean = new ScaleContent();
|
|
|
+ BeanUtil.copyProperties(scaleContentVO, bean);
|
|
|
+ bean.setScaleId(scaleId);
|
|
|
+ bean.setModifier(userId);
|
|
|
+ bean.setCreator(userId);
|
|
|
+ bean.setGmtCreate(now);
|
|
|
+ bean.setGmtModified(now);
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
+ scaleContentService.saveBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 量表列表
|
|
|
+ *
|
|
|
+ * @param questionPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<QuestionPageDTO> getListFac(QuestionPageVO questionPageVO) {
|
|
|
+ IPage<QuestionPageDTO> res = this.getList(questionPageVO);
|
|
|
+ if (res.getTotal() <= 0) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ List<String> personIds = res.getRecords().stream().map(row -> row.getModifier()).collect(Collectors.toList());
|
|
|
+ RespDTO<Map<String, String>> mapRespDTO = userServiceClient.getUserInfoByIds(personIds);
|
|
|
+ if (mapRespDTO == null || !CommonErrorCode.OK.getCode().equals(mapRespDTO.code)) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "获取操作人失败");
|
|
|
+ }
|
|
|
+ for (QuestionPageDTO bean : res.getRecords()) {
|
|
|
+ bean.setModifier(mapRespDTO.data.get(bean.getModifier()));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+}
|