|
@@ -6,19 +6,17 @@ 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 org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
/**
|
|
@@ -32,10 +30,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDictionaryMapper, IndicatorDictionary> implements IIndicatorDictionaryService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private CacheContext cache;
|
|
|
|
|
|
- public List<IndicatorDictionary> list(String id,String indicatorId,String optionCode,String optionName){
|
|
|
+
|
|
|
+ public List<IndicatorDictionary> list(String id, String indicatorId, String optionCode, String optionName) {
|
|
|
QueryWrapper<IndicatorDictionary> qw = new QueryWrapper<>();
|
|
|
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
@@ -57,7 +54,6 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public boolean saveOrUpdate(IndicatorDictionary entity) {
|
|
|
|
|
@@ -78,6 +74,8 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public boolean dictionarySaveBatch(List<IndicatorDictionaryDTO> dictionarys) {
|
|
|
|
|
@@ -85,18 +83,26 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
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已存在");
|
|
|
+ if (null != i && (null == i.getId() || "".equals(i.getId().trim()))) {
|
|
|
+ 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()));
|
|
|
+ } else {
|
|
|
+ i.setChildCode(dto.getChildCode());
|
|
|
+ i.setChildName(dto.getChildName());
|
|
|
+ i.setOptionName(null == CacheContext.ddNameMap.get(i.getOptionCode()) ? "未知属性" : CacheContext.ddNameMap.get(i.getOptionCode()));
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
}
|
|
|
- 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);
|
|
|
}
|
|
|
}
|
|
@@ -106,7 +112,7 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
@Override
|
|
|
public List<IndicatorDictionaryDTO> list(String indicatorId, String optionCode, String optionName) {
|
|
|
|
|
|
- List<IndicatorDictionaryDTO> dtoList = new ArrayList<>();
|
|
|
+ List<IndicatorDictionaryDTO> dtoList = new ArrayList<>();
|
|
|
|
|
|
QueryWrapper<IndicatorDictionary> qw = new QueryWrapper<>();
|
|
|
if (StringUtils.isNotEmpty(indicatorId)) {
|
|
@@ -121,11 +127,11 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
|
|
|
|
|
|
List<IndicatorDictionary> list = baseMapper.selectList(qw);
|
|
|
|
|
|
- Map<String,List<IndicatorDictionary>> map = list.stream().collect(Collectors.groupingBy(ord -> ord.getChildCode()+","+ ord.getChildName()));
|
|
|
+ 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();
|
|
|
+ map.forEach((k, v) -> {
|
|
|
+ String[] zb = k.split(",");
|
|
|
+ IndicatorDictionaryDTO dto = new IndicatorDictionaryDTO();
|
|
|
dto.setChildCode(zb[0]);
|
|
|
dto.setChildName(zb[1]);
|
|
|
dto.setList(v);
|