qa-prevention-gwj/src/main/java/com/zcloud/service/system/impl/DictionariesServiceImpl.java

265 lines
7.7 KiB
Java
Raw Normal View History

2023-11-07 09:32:12 +08:00
package com.zcloud.service.system.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
2023-11-14 10:16:26 +08:00
import java.util.stream.Collectors;
2023-11-07 09:32:12 +08:00
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.entity.system.Department;
import com.zcloud.entity.system.Dictionaries;
import com.zcloud.mapper.datasource.system.DictionariesMapper;
import com.zcloud.service.system.DictionariesService;
/**
*
* luoxiaobao
* www.qdkjchina.com
*/
@Service
@Transactional //开启事物
public class DictionariesServiceImpl implements DictionariesService {
@Autowired
private DictionariesMapper dictionariesMapper;
/**
* ()
* @param MENU_ID
* @return
* @throws Exception
*/
public List<Dictionaries> listAllDict(String parentId) throws Exception {
List<Dictionaries> dictList = this.listSubDictByParentId(parentId);
for(Dictionaries dict : dictList){
dict.setTreeurl("dictionaries_list.html?DICTIONARIES_ID="+dict.getDICTIONARIES_ID());
dict.setSubDict(this.listAllDict(dict.getDICTIONARIES_ID()));
dict.setTarget("treeFrame");
}
return dictList;
}
/**
* ID
* @param parentId
* @return
* @throws Exception
*/
public List<Dictionaries> listSubDictByParentId(String parentId) throws Exception {
return dictionariesMapper.listSubDictByParentId(parentId);
}
/**
* ID
* @param parentId
* @return
* @throws Exception
*/
public List<Dictionaries> listSubDictByParentIdAndCourseware(PageData pd) throws Exception {
return dictionariesMapper.listSubDictByParentIdAndCourseware(pd);
}
2023-11-14 10:16:26 +08:00
@Override
public List<PageData> getTreeById(String id) throws Exception {
List<Dictionaries> _list = this.listSubDictByParentId(id); //用传过来的ID获取此ID下的子列表数据
return _list.stream().map(n -> {
PageData entity = new PageData();
entity.put("DICTIONARIES_ID", n.getDICTIONARIES_ID());
entity.put("BIANMA", n.getBIANMA());
entity.put("NAME", n.getNAME());
return entity;
}).collect(Collectors.toList());
}
2023-11-07 09:32:12 +08:00
/**
* ()
* @param MENU_ID
* @return
* @throws Exception
*/
public List<Dictionaries> listAllDictToCreateCode(String parentId) throws Exception {
List<Dictionaries> dictList = this.listSubDictByParentId(parentId);
for(Dictionaries dict : dictList){
dict.setTreeurl("setDID('"+dict.getDICTIONARIES_ID()+"');");
dict.setSubDict(this.listAllDictToCreateCode(dict.getDICTIONARIES_ID()));
dict.setTarget("treeFrame");
}
return dictList;
}
/**
* ()ztree
* @param MENU_ID
* @return
* @throws Exception
*/
public List<PageData> listAllDictToSelect(String parentId,List<PageData> zdicPdList) throws Exception {
List<PageData>[] arrayDep = this.listAllbyPd(parentId,zdicPdList);
List<PageData> dicPdList = arrayDep[1];
for(PageData pd : dicPdList){
this.listAllDictToSelect(pd.getString("id"),arrayDep[0]);
}
return arrayDep[0];
}
/**ztree
* @param parentId
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
public List<PageData>[] listAllbyPd(String parentId,List<PageData> zdicPdList) throws Exception {
List<Dictionaries> dicList = this.listSubDictByParentId(parentId);
List<PageData> dicPdList = new ArrayList<PageData>();
for(Dictionaries dic : dicList){
PageData pd = new PageData();
pd.put("id", dic.getDICTIONARIES_ID());
pd.put("parentId", dic.getPARENT_ID());
pd.put("name", dic.getNAME());
pd.put("icon", "../../../assets/images/user.gif");
dicPdList.add(pd);
zdicPdList.add(pd);
}
List<PageData>[] arrayDep = new List[2];
arrayDep[0] = zdicPdList;
arrayDep[1] = dicPdList;
return arrayDep;
}
/**
* @param page
* @throws Exception
*/
public List<PageData> list(Page page)throws Exception{
return dictionariesMapper.datalistPage(page);
}
/**id
* @param pd
* @throws Exception
*/
public PageData findById(PageData pd)throws Exception{
return dictionariesMapper.findById(pd);
}
/**
* @param pd
* @throws Exception
*/
public PageData findByName(PageData pd)throws Exception{
return dictionariesMapper.findByName(pd);
}
/**
* @param pd
* @throws Exception
*/
public PageData findByBianma(PageData pd)throws Exception{
return dictionariesMapper.findByBianma(pd);
}
/**
* @param pd
* @throws Exception
*/
public void save(PageData pd)throws Exception{
dictionariesMapper.save(pd);
}
/**
* @param pd
* @throws Exception
*/
public void edit(PageData pd)throws Exception{
dictionariesMapper.edit(pd);
}
/**
* @param pd
* @throws Exception
*/
public PageData findFromTbs(PageData pd)throws Exception{
return dictionariesMapper.findFromTbs(pd);
}
/**
* @param pd
* @throws Exception
*/
public void delete(PageData pd)throws Exception{
dictionariesMapper.delete(pd);
}
/**
* IDS
* @param dictionariesIds
* @return
* @throws Exception
*/
public List<Dictionaries> listSubDictByIds(String[] dictionariesIds) throws Exception {
return dictionariesMapper.listSubDictByIdS(dictionariesIds);
}
@Override
public List<Dictionaries> listSecondLevelDictByParentId(String parentId) throws Exception {
return dictionariesMapper.listSecondLevelDictByParentId(parentId);
}
public List<PageData> listSubDictByParentIdAndSunCount(String parentId) throws Exception {
return dictionariesMapper.listSubDictByParentIdAndSunCount(parentId);
}
/**
*
* @param dic
* @return
* @throws Exception
*/
public List<PageData> getTreeFromBelow(List<PageData> nextList, PageData dic) throws Exception{
List<PageData> dicList = dictionariesMapper.listBySameParent(dic.get("PARENT_ID").toString());
if(nextList != null && dicList != null && nextList.size() > 0 && dicList.size() > 0) {
for(PageData d : dicList) {
if(dic.getString("DICTIONARIES_ID").equals(d.getString("id"))) {
d.put("children", nextList);
}
}
}
PageData parDic = new PageData();
parDic.put("DICTIONARIES_ID", dic.get("PARENT_ID"));
parDic.put("NOROOT", "1");
parDic = dictionariesMapper.findById(parDic);
if(parDic != null && parDic.get("DICTIONARIES_ID") != null && !"0".equals(parDic.get("PARENT_ID").toString())) {
dicList = getTreeFromBelow(dicList,parDic);
}
return dicList;
}
public List<PageData> getIdsByRecuByParentId(String parentId) throws Exception {
return dictionariesMapper.getIdsByRecuByParentId(parentId);
}
/**
* parentID,map
* @param parentId
* @return
* @throws Exception
*/
public Map<String,Dictionaries> getMapByParId (String parentId) throws Exception{
List<Dictionaries> dictList = this.listSubDictByParentId(parentId);
Map<String,Dictionaries> dicMap = new HashMap<>();
for (Dictionaries dictionaries :dictList){
dicMap.put(dictionaries.getNAME(),dictionaries);
}
return dicMap;
}
public List<PageData> getIdsByParentIds(List<String> parentIds) throws Exception {
return dictionariesMapper.getIdsByParentIds(parentIds);
}
2024-06-27 13:18:49 +08:00
@Override
public List<PageData> findByCondition(PageData condition) throws Exception {
return dictionariesMapper.findByCondition(condition);
}
2023-11-07 09:32:12 +08:00
}