|
@@ -0,0 +1,175 @@
|
|
|
|
+package com.diagbot.facade;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.diagbot.dto.QcCasesAllDTO;
|
|
|
|
+import com.diagbot.dto.QcInputcasesAllDTO;
|
|
|
|
+import com.diagbot.dto.QcInputcasesMappingDTO;
|
|
|
|
+import com.diagbot.entity.QcCasesEntry;
|
|
|
|
+import com.diagbot.entity.QcInputcases;
|
|
|
|
+import com.diagbot.entity.QcInputcasesMapping;
|
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
|
+import com.diagbot.mapper.QcInputcasesMappingMapper;
|
|
|
|
+import com.diagbot.service.QcInputcasesMappingService;
|
|
|
|
+import com.diagbot.service.QcInputcasesService;
|
|
|
|
+import com.diagbot.service.impl.QcInputcasesServiceImpl;
|
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.vo.QcInputMappingSaveVO;
|
|
|
|
+import com.diagbot.vo.QcInputcasesSaveVO;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import javax.swing.text.Utilities;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author wangfeng
|
|
|
|
+ * @Description:
|
|
|
|
+ * @date 2020-03-10 17:17
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class QcInputcasesFacade extends QcInputcasesServiceImpl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ QcInputcasesService qcInputcasesService;
|
|
|
|
+ @Autowired
|
|
|
|
+ QcInputcasesMappingService qcInputcasesMappingService;
|
|
|
|
+
|
|
|
|
+ public List<QcInputcasesAllDTO> getInputcasesAlls(Long textId) {
|
|
|
|
+ //查出所有病例
|
|
|
|
+ QueryWrapper<QcInputcases> qcInputcasesQuery = new QueryWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .orderByDesc("gmt_modified");
|
|
|
|
+ if (textId != null && textId != 0) {
|
|
|
|
+ qcInputcasesQuery.eq("id", textId);
|
|
|
|
+ }
|
|
|
|
+ List<QcInputcases> data = list(qcInputcasesQuery);
|
|
|
|
+ List<QcInputcasesAllDTO> dataNew = new ArrayList<QcInputcasesAllDTO>();
|
|
|
|
+ dataNew = BeanUtil.listCopyTo(data, QcInputcasesAllDTO.class);
|
|
|
|
+ // 查出所有病例病例类型
|
|
|
|
+ List<QcInputcasesMappingDTO> qcInputcasesMapping = qcInputcasesMappingService.getQcInputMappings(textId);
|
|
|
|
+ // 然后把所有病例类型放进去
|
|
|
|
+ Map<Long, List<QcInputcasesMappingDTO>> map
|
|
|
|
+ = EntityUtil.makeEntityListMap(qcInputcasesMapping, "textId");
|
|
|
|
+ if (dataNew.size() > 0) {
|
|
|
|
+ for (QcInputcasesAllDTO ts : dataNew) {
|
|
|
|
+ List<QcInputcasesMappingDTO> tmp = map.get(ts.getId());
|
|
|
|
+ if (ListUtil.isNotEmpty(tmp)) {
|
|
|
|
+ ts.setQcInputcasesMapping(tmp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return dataNew;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param qcInputcasesSaveVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean saveAndUpdatas(QcInputcasesSaveVO qcInputcasesSaveVO) {
|
|
|
|
+ boolean res = false;
|
|
|
|
+ if (qcInputcasesSaveVO.getId() != null && qcInputcasesSaveVO.getId() != 0) {
|
|
|
|
+ //校验数据是否存在
|
|
|
|
+ QueryWrapper<QcInputcases> qcQuery = new QueryWrapper<>();
|
|
|
|
+ Map<String, Object> mapAll = new HashMap<>();
|
|
|
|
+ mapAll.put("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ mapAll.put("id", qcInputcasesSaveVO.getId());
|
|
|
|
+ qcQuery.allEq(mapAll);
|
|
|
|
+ int sum = count(qcQuery);
|
|
|
|
+ if (sum == 0) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例不存在");
|
|
|
|
+ }
|
|
|
|
+ UpdateWrapper<QcInputcases> qcInputcasesQuery = new UpdateWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", qcInputcasesSaveVO.getId())
|
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
|
+ .set("text", qcInputcasesSaveVO.getText());
|
|
|
|
+ res = update(qcInputcasesQuery);
|
|
|
|
+ UpdateWrapper<QcInputcasesMapping> qcMappingQuery = new UpdateWrapper<>();
|
|
|
|
+ qcMappingQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("text_id", qcInputcasesSaveVO.getId())
|
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = qcInputcasesMappingService.update(qcMappingQuery);
|
|
|
|
+ List<QcInputMappingSaveVO> inputMapping = qcInputcasesSaveVO.getQcInputMappingSaveVO();
|
|
|
|
+
|
|
|
|
+ List<QcInputcasesMapping> qcMappingList = new ArrayList<>();
|
|
|
|
+ for (QcInputMappingSaveVO t : inputMapping) {
|
|
|
|
+ QcInputcasesMapping qcList = new QcInputcasesMapping();
|
|
|
|
+ qcList.setCasesEntryId(t.getCasesEntryId());
|
|
|
|
+ qcList.setCasesId(t.getCasesId());
|
|
|
|
+ qcList.setPass(t.getPass());
|
|
|
|
+ qcList.setTextId(qcInputcasesSaveVO.getId());
|
|
|
|
+ qcList.setGmtModified(DateUtil.now());
|
|
|
|
+ qcMappingList.add(qcList);
|
|
|
|
+ }
|
|
|
|
+ res = qcInputcasesMappingService.saveBatch(qcMappingList);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ QueryWrapper<QcInputcases> qcInputcasesQuery = new QueryWrapper<>();
|
|
|
|
+ Map<String, Object> mapAll = new HashMap<>();
|
|
|
|
+ mapAll.put("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ mapAll.put("text", qcInputcasesSaveVO.getText());
|
|
|
|
+ qcInputcasesQuery.allEq(mapAll);
|
|
|
|
+ int sum = count(qcInputcasesQuery);
|
|
|
|
+ if (sum != 0) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该病例存在");
|
|
|
|
+ }
|
|
|
|
+ QcInputcases qcInputcases = new QcInputcases();
|
|
|
|
+ qcInputcases.setText(qcInputcasesSaveVO.getText());
|
|
|
|
+ res = save(qcInputcases);
|
|
|
|
+ List<QcInputMappingSaveVO> inputMapping = qcInputcasesSaveVO.getQcInputMappingSaveVO();
|
|
|
|
+ if (res) {
|
|
|
|
+ List<QcInputcasesMapping> qcMappingList = new ArrayList<>();
|
|
|
|
+ for (QcInputMappingSaveVO t : inputMapping) {
|
|
|
|
+ QcInputcasesMapping qcList = new QcInputcasesMapping();
|
|
|
|
+ qcList.setCasesEntryId(t.getCasesEntryId());
|
|
|
|
+ qcList.setCasesId(t.getCasesId());
|
|
|
|
+ qcList.setPass(t.getPass());
|
|
|
|
+ qcList.setTextId(qcInputcases.getId());
|
|
|
|
+ qcMappingList.add(qcList);
|
|
|
|
+ }
|
|
|
|
+ res = qcInputcasesMappingService.saveBatch(qcMappingList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean cancelByIds(Long id) {
|
|
|
|
+ boolean res = false;
|
|
|
|
+ UpdateWrapper<QcInputcases> qcInputcasesQuery = new UpdateWrapper<>();
|
|
|
|
+ qcInputcasesQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("id", id)
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = update(qcInputcasesQuery);
|
|
|
|
+ if (res) {
|
|
|
|
+ UpdateWrapper<QcInputcasesMapping> qcMappingQuery = new UpdateWrapper<>();
|
|
|
|
+ qcMappingQuery
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("text_id", id)
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey());
|
|
|
|
+ res = qcInputcasesMappingService.update(qcMappingQuery);
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+}
|