|
@@ -5,13 +5,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import io.renren.common.utils.PageUtils;
|
|
|
import io.renren.common.utils.Query;
|
|
|
+import io.renren.common.utils.SubString;
|
|
|
import io.renren.datasource.annotation.DataSource;
|
|
|
+import io.renren.modules.dataSet.DataSetUtils.ToEnglish;
|
|
|
import io.renren.modules.levelManage.dao.UniversalTableDao;
|
|
|
+import io.renren.modules.levelManage.entity.LevelEntity;
|
|
|
+import io.renren.modules.levelManage.entity.LevelRelationEntity;
|
|
|
import io.renren.modules.levelManage.entity.UniversalTableEntity;
|
|
|
+import io.renren.modules.levelManage.service.LevelRelationService;
|
|
|
+import io.renren.modules.levelManage.service.LevelService;
|
|
|
+import io.renren.modules.levelManage.service.LevelTableService;
|
|
|
import io.renren.modules.levelManage.service.UniversalTableService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -23,6 +32,13 @@ public class UniversalTableServiceImpl extends ServiceImpl<UniversalTableDao, Un
|
|
|
@Autowired
|
|
|
UniversalTableDao universalTableDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ LevelRelationService levelRelationService;
|
|
|
+ @Autowired
|
|
|
+ LevelService levelService;
|
|
|
+ @Autowired
|
|
|
+ LevelTableService levelTableService;
|
|
|
+
|
|
|
@Override
|
|
|
public PageUtils queryPage(Map<String, Object> params) {
|
|
|
IPage<UniversalTableEntity> page = this.page(
|
|
@@ -141,4 +157,63 @@ public class UniversalTableServiceImpl extends ServiceImpl<UniversalTableDao, Un
|
|
|
return universalTableDao.listBySonIdsNotLimit(tableName,tableCols,sonIds);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getOtherLeafItem(Long tableId, Long id) {
|
|
|
+ //1.获取选中的item的相关子item
|
|
|
+ List<LevelRelationEntity> levelRelationEntities = levelRelationService.selectByParent(tableId, id);
|
|
|
+ //2.获取子表名
|
|
|
+ LevelEntity sonLevel = levelService.getEnabledSon(tableId);
|
|
|
+ if(sonLevel==null)
|
|
|
+ return null;
|
|
|
+ String sonTableName = sonLevel.getTableName();
|
|
|
+ //3.在表中获取对应的叶子节点信息
|
|
|
+ List<String> tableCols = levelTableService.listColsByLevelId(sonLevel.getId());
|
|
|
+ List<Map<String, Object>> candidateItem = listLeafItem(sonTableName, tableCols);
|
|
|
+ //4.通过检查levelRelationEntities和candidateItem中的重合部分,获取目标item,为了加速,用了HashMap
|
|
|
+ List<Map<String, Object>> data = new ArrayList<>();
|
|
|
+ //用一个map装所有的item,之后遍历关系,将其中的item信息取出,发给前端
|
|
|
+ HashMap<Object, Object> cItemId_lRelationSonId = new HashMap<>();
|
|
|
+ for (int i = 0; i < candidateItem.size(); i++) {
|
|
|
+ cItemId_lRelationSonId.put(candidateItem.get(i).get("id"), i);
|
|
|
+ }
|
|
|
+ for (LevelRelationEntity levelRelation : levelRelationEntities) {
|
|
|
+ if (cItemId_lRelationSonId.get(levelRelation.getSonRowId()) != null) {
|
|
|
+ int itemId = (int) cItemId_lRelationSonId.get(levelRelation.getSonRowId());
|
|
|
+ data.add(candidateItem.get(itemId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //data是<列名,具体值>的list
|
|
|
+ //对bool值需要修改为是/否,否则前端不显示
|
|
|
+ List<String> boolCols = levelTableService.listBoolColsById(sonLevel.getId());
|
|
|
+ modifyBool(data, boolCols);
|
|
|
+ //去除名字前面的随机数
|
|
|
+ SubString.subStringList(data);
|
|
|
+ //将测点名称转拼音返回前端
|
|
|
+ List<String> pinyin = new ArrayList<>();
|
|
|
+ for (Map<String, Object> datum : data) {
|
|
|
+ pinyin.add(ToEnglish.getPinYin((String) datum.get("name")));
|
|
|
+ }
|
|
|
+ HashMap<String,Object> result=new HashMap<>();
|
|
|
+ result.put("data",data);
|
|
|
+ result.put("levelId", sonLevel.getId());
|
|
|
+ result.put("pinyin", pinyin);
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+ private void modifyBool(List<Map<String,Object>> data,List<String> boolCols){
|
|
|
+ for(Map<String,Object> map :data)
|
|
|
+ {
|
|
|
+ for(String col: boolCols)
|
|
|
+ {
|
|
|
+ Byte a =1;
|
|
|
+ if(map.get(col)==a)
|
|
|
+ {
|
|
|
+ map.put(col,"是");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ map.put(col,"否");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|