|
@@ -6,14 +6,20 @@ import com.ims.common.utils.StringUtils;
|
|
|
import com.ims.eval.cache.CacheContext;
|
|
|
import com.ims.eval.dao.IndicatorDictionaryMapper;
|
|
|
import com.ims.eval.config.CustomException;
|
|
|
+import com.ims.eval.entity.DataDictionary;
|
|
|
import com.ims.eval.entity.IndicatorDictionary;
|
|
|
+import com.ims.eval.entity.dto.request.IndicatorDictionaryDTO;
|
|
|
import com.ims.eval.service.IIndicatorDictionaryService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -50,6 +56,8 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public boolean saveOrUpdate(IndicatorDictionary entity) {
|
|
|
|
|
@@ -70,4 +78,60 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean dictionarySaveBatch(List<IndicatorDictionaryDTO> dictionarys) {
|
|
|
+
|
|
|
+
|
|
|
+ boolean b = false;
|
|
|
+ for (IndicatorDictionaryDTO dto : dictionarys) {
|
|
|
+ for (IndicatorDictionary i : dto.getList()) {
|
|
|
+ QueryWrapper<IndicatorDictionary> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(IndicatorDictionary::getIndicatorId, i.getIndicatorId());
|
|
|
+ qw.lambda().eq(IndicatorDictionary::getChildCode, dto.getChildCode());
|
|
|
+ qw.lambda().eq(IndicatorDictionary::getOptionCode, i.getOptionCode());
|
|
|
+ List<IndicatorDictionary> list = baseMapper.selectList(qw);
|
|
|
+ if (null != list && list.size() > 0) {
|
|
|
+ throw new CustomException("当前属性code已存在");
|
|
|
+ }
|
|
|
+ i.setChildCode(dto.getChildCode());
|
|
|
+ i.setChildName(dto.getChildName());
|
|
|
+ i.setCreateTime(new Date());
|
|
|
+ i.setOptionName(null == CacheContext.ddNameMap.get(i.getOptionCode()) ? "未知属性" : CacheContext.ddNameMap.get(i.getOptionCode()));
|
|
|
+ b = super.saveOrUpdate(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IndicatorDictionaryDTO> list(String indicatorId, String optionCode, String optionName) {
|
|
|
+
|
|
|
+ List<IndicatorDictionaryDTO> dtoList = new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<IndicatorDictionary> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(indicatorId)) {
|
|
|
+ qw.lambda().eq(IndicatorDictionary::getIndicatorId, indicatorId);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(optionCode)) {
|
|
|
+ qw.lambda().eq(IndicatorDictionary::getOptionCode, optionCode);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(optionName)) {
|
|
|
+ qw.lambda().like(IndicatorDictionary::getOptionName, optionName);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<IndicatorDictionary> list = baseMapper.selectList(qw);
|
|
|
+
|
|
|
+ Map<String,List<IndicatorDictionary>> map = list.stream().collect(Collectors.groupingBy(ord -> ord.getChildCode()+","+ ord.getChildName()));
|
|
|
+
|
|
|
+ map.forEach((k,v)->{
|
|
|
+ String [] zb = k.split(",");
|
|
|
+ IndicatorDictionaryDTO dto = new IndicatorDictionaryDTO();
|
|
|
+ dto.setChildCode(zb[0]);
|
|
|
+ dto.setChildName(zb[1]);
|
|
|
+ dto.setList(v);
|
|
|
+ dtoList.add(dto);
|
|
|
+ });
|
|
|
+
|
|
|
+ return dtoList;
|
|
|
+ }
|
|
|
}
|