package com.example.server.teamGroup.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.example.client.dto.JComboBoxItem; import com.example.client.entity.MapData; import com.example.client.service.BaseService; import com.example.server.teamGroup.dao.SysTeamGroupClassDao; import com.example.server.teamGroup.model.SysTeamGroupClass; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * DJ_SYS_TEAMGROUP_CLASS * * @author zt generator * @since 1.0.0 2020-08-30 */ @Service public class SysTeamGroupClassService extends BaseService { @Value("${zt.oss.local-area}") private String localArea; /** * 树形结构 * * @return */ /* public List tree() { List list = new ArrayList<>(); list.addAll(this.getWithDescendant(0L)); return TreeUtils.build(list); }*/ /** * 树形结构 * * @return */ /* public List tree2(String area) { List list = new ArrayList<>(); list.addAll(this.getWithDescendant2(0L,area)); return TreeUtils.build(list); }*/ /** * 树形结构 * 依据dictType,model进行查询 * * @return */ /* public List treeByCriteria(Map criteria) { List list = new ArrayList<>(); list.addAll(this.getWithDescendantByCriteria(0L, criteria)); return TreeUtils.build(list); }*/ /** * 获取自己和下一级 * 依据dictType,model进行查询 * * @param id * @return */ /* public List getWithDescendantByCriteria(Long id, Map criteria) { return TreeUtils.getWithDescendant(getAllByCriteria(criteria), id); } */ /** * @return */ public List getAllByCriteria(Map criteria) { List all = baseDao.getAllByCriteria(criteria,localArea); return all.stream().map(teamGroupClass -> { try { return teamGroupClass.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; }).collect(Collectors.toList()); } /** * 获取自己和下一级 * * @param id * @return */ /* public List getWithDescendant(Long id) { return TreeUtils.getWithDescendant(getAll(), id); } */ /* public List getWithDescendant2(Long id, String area) { return TreeUtils.getWithDescendant(getAll2(area), id); } */ /** * @return */ public List getAll() { List all = baseDao.getAll(localArea); return all.stream().map(teamGroupClass -> { try { return teamGroupClass.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; }).collect(Collectors.toList()); } public List getAll2(String area) { List all = baseDao.getAll(area); return all.stream().map(teamGroupClass -> { try { return teamGroupClass.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; }).collect(Collectors.toList()); } /** * 删除 * * @param ids */ public void delete(Long[] ids) { super.deleteLogic(ids); } /** * 通过ID查询班组信息 * * @param stgcId * @return */ public SysTeamGroupClass getBySysTeamGroupClassId(Long stgcId) { return baseDao.selectOne(new QueryWrapper().lambda().eq(SysTeamGroupClass::getId, stgcId)); } /** * 通过班组名称查询班组id */ public List getTeamGroupIdByNames(List list, String area) { return baseDao.getTeamGroupIdByNames(list,area); } /** * 通过班组名称查询班组id */ public List getTeamGroupIdByName(String name, String area) { return baseDao.getTeamGroupIdByName(name,area); } public Long getBzTeamGroupIdByName(String name, String area) { return baseDao.getBzTeamGroupIdByName(name,area); } public Map getMapGroup(Boolean idToName, String area) { Map result = new HashMap<>(); List list = baseDao.getMapAll(area); for (MapData item : list) { if (idToName) result.put(item.getId().toString(), item.getName()); else result.put(item.getName(), item.getId().toString()); } return result; } public List getTeamGroupClassList() { return baseDao.getTeamGroupClassList(); } public JComboBoxItem[] getList() { return baseDao.getList(); } public JComboBoxItem[] getTeamList(Long pid) { return baseDao.getTeamList(pid); } public JComboBoxItem[] getDeptList() { return baseDao.getDeptList(); } public List getListByTree() { return baseDao.getListByTree(); } public Integer getSortMax(Long pid) { return baseDao.getSortMax(pid); } public void save(SysTeamGroupClass data) { if (data.getId()!=null){ this.update(data); }else{ this.insert(data); } } }