|
@@ -0,0 +1,134 @@
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+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.RespDTO;
|
|
|
+import com.diagbot.dto.ScaleContentPageDTO;
|
|
|
+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.util.RespDTOUtil;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.DeleteScaleVO;
|
|
|
+import com.diagbot.vo.ScaleContentPageVO;
|
|
|
+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 conceptId = scaleContentSaveVO.getConceptId();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+
|
|
|
+ // 删除原关联内容(物理删除)
|
|
|
+ if (conceptId != null) {
|
|
|
+ this.remove(new QueryWrapper<ScaleContent>()
|
|
|
+ .eq("concept_id", conceptId));
|
|
|
+ }
|
|
|
+ // 新增关联内容
|
|
|
+ List<ScaleContent> list = new ArrayList<>();
|
|
|
+ List<ScaleContentVO> scaleContentVOS = scaleContentSaveVO.getContent();
|
|
|
+ for (ScaleContentVO scaleContentVO : scaleContentVOS) {
|
|
|
+ ScaleContent bean = new ScaleContent();
|
|
|
+ BeanUtil.copyProperties(scaleContentVO, bean);
|
|
|
+ bean.setConceptId(conceptId);
|
|
|
+ bean.setModifier(userId);
|
|
|
+ bean.setCreator(userId);
|
|
|
+ bean.setGmtCreate(now);
|
|
|
+ bean.setGmtModified(now);
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
+ scaleContentService.saveBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 量表分页
|
|
|
+ *
|
|
|
+ * @param scaleContentPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<ScaleContentPageDTO> getListFac(ScaleContentPageVO scaleContentPageVO) {
|
|
|
+ IPage<ScaleContentPageDTO> res = this.getList(scaleContentPageVO);
|
|
|
+ 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);
|
|
|
+ RespDTOUtil.respNGDeal(mapRespDTO, "远程调用获取操作人失败");
|
|
|
+ for (ScaleContentPageDTO bean : res.getRecords()) {
|
|
|
+ bean.setModifier(mapRespDTO.data.get(bean.getModifier()));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 量表列表
|
|
|
+// *
|
|
|
+// * @param scaleId
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// public List<ScaleContentDTO> getByParamFac(Long scaleId) {
|
|
|
+// return this.getByParam(scaleId);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 量表删除
|
|
|
+ *
|
|
|
+ * @param deleteScaleVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void delete(DeleteScaleVO deleteScaleVO) {
|
|
|
+ if (!(IsDeleteEnum.N.getKey().equals(deleteScaleVO.getStatus())
|
|
|
+ || IsDeleteEnum.Y.getKey().equals(deleteScaleVO.getStatus()))) {
|
|
|
+ throw new CommonException(CommonErrorCode.STATUS_IS_ERROR, "状态值错误【Y】或【N】");
|
|
|
+ }
|
|
|
+ String person = UserUtils.getCurrentPrincipleID();
|
|
|
+ List<Long> ids = deleteScaleVO.getIds();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ this.update(new ScaleContent(), new UpdateWrapper<ScaleContent>()
|
|
|
+ .in("concept_id", ids)
|
|
|
+ .set("gmt_modified", now)
|
|
|
+ .set("modifier", person)
|
|
|
+ .set("is_deleted", deleteScaleVO.getStatus()));
|
|
|
+ }
|
|
|
+}
|