package cn.com.lzt.dialogDeal.service.impl; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jeecgframework.core.common.service.impl.CommonServiceImpl; import org.jeecgframework.core.constant.Globals; import org.jeecgframework.core.util.JeecgDataAutorUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import cn.com.lzt.arrangeduty.dao.ArrangeDutyMinidao; import cn.com.lzt.arrangeduty.dao.MealsSubsidyMiniDao; import cn.com.lzt.arrangeduty.dao.ProjectDepartMinidao; import cn.com.lzt.arrangeduty.dao.UserOrgMinidao; import cn.com.lzt.arrangeduty.dto.ProjectDepartDto; import cn.com.lzt.arrangeduty.dto.UserOrgDto; import cn.com.lzt.arrangeduty.entity.ArrangeDutyEntity; import cn.com.lzt.dialogDeal.service.UserDepartOrgDealServiceI; @Service("userDepartOrgDealServiceI") @Transactional public class UserDepartOrgDealServiceImpl extends CommonServiceImpl implements UserDepartOrgDealServiceI { @Autowired ProjectDepartMinidao projectDepartMinidao; @Autowired UserOrgMinidao userOrgMinidao; @Override public void delete(ArrangeDutyEntity entity) throws Exception { // TODO Auto-generated method stub } @Override public Serializable save(ArrangeDutyEntity entity) throws Exception { // TODO Auto-generated method stub return null; } @Override public void saveOrUpdate(ArrangeDutyEntity entity) throws Exception { // TODO Auto-generated method stub } @Override public List getUserOrgDtoByUserId(UserOrgDto userOrgDto, String authSql) { // TODO Auto-generated method stub return userOrgMinidao.getUserOrgDtoByUserId(userOrgDto, authSql); } /** * 根据用户与组织机构关系表中的组织id查询项目id; * 业务逻辑 * 任意层节点的zTree,每一层有一个父id,顶级节点父节点为null,一个组织类型orgType,随机给一层的主键id,找到项目id,特征是orgType=3/5; * 根据是否是顶级父id判断是自上而下还是自下而上查找,当自下而上找到null时,再进行自下而上; * @author zbw * 2017-11-15 * @param projectDepartId * @return */ @Override public List getProjectDepartId(String projectDepartId){ // String newProjectDepartId=""; List newProjectDepartIdList=new ArrayList(); ProjectDepartDto projectDepartDto=new ProjectDepartDto(); projectDepartDto.getDepartIdList().add(projectDepartId); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); // 根据部门信息表id查询部门信息表数据 List projectDepartDtoList = getProjectDepartByListId(projectDepartDto, authSql); if(projectDepartDtoList.get(0).getParentdepartid()!=null){ if(!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_3)&&!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_5)){ //获取某个父节点下面的所有子节点 List childList = getAllChildrenList(projectDepartId, null, null); for (int i = 0; i < childList.size(); i++) { if(childList.get(i).getOrgType().equals(Globals.org_type_3)||childList.get(i).getOrgType().equals(Globals.org_type_5)){ // newProjectDepartId=childList.get(i).getId(); if(!newProjectDepartIdList.contains(childList.get(i).getId())){ newProjectDepartIdList.add(childList.get(i).getId()); } } } if(newProjectDepartIdList.size()==0){ //获取某个子节点上面的所有父节点 List parentList = getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null); for (int i = 0; i < parentList.size(); i++) { if(parentList.get(i).getOrgType().equals(Globals.org_type_3)||parentList.get(i).getOrgType().equals(Globals.org_type_5)){ // newProjectDepartId=parentList.get(i).getId(); if(!newProjectDepartIdList.contains(parentList.get(i).getId())){ newProjectDepartIdList.add(parentList.get(i).getId()); } } } } }else{ newProjectDepartIdList.add(projectDepartDtoList.get(0).getId()); // newProjectDepartId=projectDepartDtoList.get(0).getId(); } } // List childList = getAllChildrenList(post.getId(), null, null); // List childList = getAllParentList(post.getParentPostid(), null, null); return newProjectDepartIdList; } /** * 根据用户与组织机构关系表中的组织id查询项目id; * 业务逻辑 * 任意层节点的zTree,每一层有一个父id,顶级节点父节点为null,一个组织类型orgType,随机给一层的主键id,找到项目id,特征是orgType=3/5; * 根据是否是顶级父id判断是自上而下还是自下而上查找,当自下而上找到null时,再进行自下而上; * @author zbw * 2017-11-15 * @param projectDepartId * @return */ @Override public String getProjectDepartParentId(String projectDepartId){ String newProjectDepartId=""; ProjectDepartDto projectDepartDto=new ProjectDepartDto(); projectDepartDto.getDepartIdList().add(projectDepartId); //String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); // 根据部门信息表id查询部门信息表数据 List projectDepartDtoList = getProjectDepartByListId(projectDepartDto, null); if(projectDepartDtoList.get(0).getParentdepartid()!=null){ if(!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_3)&&!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_5)){ //获取某个父节点下面的所有子节点 /*List childList = getAllChildrenList(projectDepartId, null, null); for (int i = 0; i < childList.size(); i++) { if(childList.get(i).getOrgType().equals(Globals.org_type_3)||childList.get(i).getOrgType().equals(Globals.org_type_5)){ newProjectDepartId=childList.get(i).getId(); // break; } }*/ if(newProjectDepartId.length()==0){ //获取某个子节点上面的所有父节点 List parentList = getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null); for (int i = 0; i < parentList.size(); i++) { if(parentList.get(i).getOrgType().equals(Globals.org_type_3)||parentList.get(i).getOrgType().equals(Globals.org_type_5)){ newProjectDepartId=parentList.get(i).getId(); // break; } } } }else{ newProjectDepartId=projectDepartDtoList.get(0).getId(); } }else{ newProjectDepartId=null; } // List childList = getAllChildrenList(post.getId(), null, null); // List childList = getAllParentList(post.getParentPostid(), null, null); return newProjectDepartId; } @Override public List getProjectDepartByListId( ProjectDepartDto projectDepartDto, String authSql) { // TODO Auto-generated method stub return projectDepartMinidao.getProjectDepartByListId(projectDepartDto, authSql); } /** * 获取某个父节点下面的所有子节点 * * @param pid 父ID * @param entryList 当前节点的所有子节点列表(for循环用) * @param childList 所有子节点列表 * @return */ @Override public List getAllChildrenList(String pid, List entryList, List childList) { if(childList == null){ childList = new ArrayList(); } ProjectDepartDto projectDepartDto=new ProjectDepartDto(); projectDepartDto.getParentDepartIdList().add(pid); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); entryList = getProjectDepartByListParentId(projectDepartDto, authSql); // final String hql = "from PostEntity where parentPostid=? "; // entryList = postService.findHql(hql, pid); for (ProjectDepartDto entry : entryList) { // 遍历出父id等于参数的id,add进子节点集合 if (entry.getParentdepartid().equals(pid)) { // 递归遍历下一级 getAllChildrenList(entry.getId(), entryList, childList); childList.add(entry); } } return childList; } /** * 获取某个子节点上面的所有父节点 * * @param childId 父ID * @param entryList 当前节点的所有父节点列表(for循环用) * @param childList 所有父节点列表 * @return */ @Override public List getAllParentList(String pid, List entryList, List parentList) { if(parentList == null){ parentList = new ArrayList(); } ProjectDepartDto projectDepartDto=new ProjectDepartDto(); projectDepartDto.getChildDepartIdList().add(pid); //String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); entryList = getProjectDepartByListChildId(projectDepartDto, null); // final String hql = "from PostEntity where id=? "; // entryList = postService.findHql(hql, pid); for (ProjectDepartDto entry : entryList) { // 遍历出父id等于参数的id,add进父节点集合 if (entry.getId().equals(pid)) { // 递归遍历下一级 getAllParentList(entry.getParentdepartid(), entryList, parentList); parentList.add(entry); } } return parentList; } @Override public List getProjectDepartByListParentId( ProjectDepartDto projectDepartDto, String authSql) { // TODO Auto-generated method stub return projectDepartMinidao.getProjectDepartByListParentId(projectDepartDto, authSql); } @Override public List getProjectDepartByListChildId( ProjectDepartDto projectDepartDto, String authSql) { // TODO Auto-generated method stub return projectDepartMinidao.getProjectDepartByListChildId(projectDepartDto, authSql); } @Override public List getParentChildIdByProjectDepartId(String projectDepartId) { List parentChildIdList=new ArrayList(); parentChildIdList.add(projectDepartId); ProjectDepartDto projectDepartDto=new ProjectDepartDto(); projectDepartDto.getDepartIdList().add(projectDepartId); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List projectDepartDtoList = getProjectDepartByListId(projectDepartDto, authSql); if(projectDepartDtoList.get(0).getParentdepartid()!=null){ //获取某个父节点下面的所有子节点 List childList = getAllChildrenList(projectDepartId, null, null); for (int i = 0; i < childList.size(); i++) { parentChildIdList.add(childList.get(i).getId()); } //获取某个子节点上面的所有父节点 List parentList = getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null); for (int i = 0; i < parentList.size(); i++) { parentChildIdList.add(parentList.get(i).getId()); } }else{ //获取某个父节点下面的所有子节点 List childList = getAllChildrenList(projectDepartId, null, null); for (int i = 0; i < childList.size(); i++) { parentChildIdList.add(childList.get(i).getId()); } } return parentChildIdList; } @Override public List getChildIdByProjectDepartId(String projectDepartId) { List parentChildIdList=new ArrayList(); parentChildIdList.add(projectDepartId); //获取某个父节点下面的所有子节点 List childList = getAllChildrenList(projectDepartId, null, null); for (int i = 0; i < childList.size(); i++) { parentChildIdList.add(childList.get(i).getId()); } return parentChildIdList; } }