UserDepartOrgDealServiceImpl.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. package cn.com.lzt.dialogDeal.service.impl;
  2. import java.io.Serializable;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  8. import org.jeecgframework.core.constant.Globals;
  9. import org.jeecgframework.core.util.JeecgDataAutorUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import cn.com.lzt.arrangeduty.dao.ArrangeDutyMinidao;
  14. import cn.com.lzt.arrangeduty.dao.MealsSubsidyMiniDao;
  15. import cn.com.lzt.arrangeduty.dao.ProjectDepartMinidao;
  16. import cn.com.lzt.arrangeduty.dao.UserOrgMinidao;
  17. import cn.com.lzt.arrangeduty.dto.ProjectDepartDto;
  18. import cn.com.lzt.arrangeduty.dto.UserOrgDto;
  19. import cn.com.lzt.arrangeduty.entity.ArrangeDutyEntity;
  20. import cn.com.lzt.dialogDeal.service.UserDepartOrgDealServiceI;
  21. @Service("userDepartOrgDealServiceI")
  22. @Transactional
  23. public class UserDepartOrgDealServiceImpl extends CommonServiceImpl implements UserDepartOrgDealServiceI {
  24. @Autowired
  25. ProjectDepartMinidao projectDepartMinidao;
  26. @Autowired
  27. UserOrgMinidao userOrgMinidao;
  28. @Override
  29. public void delete(ArrangeDutyEntity entity) throws Exception {
  30. // TODO Auto-generated method stub
  31. }
  32. @Override
  33. public Serializable save(ArrangeDutyEntity entity) throws Exception {
  34. // TODO Auto-generated method stub
  35. return null;
  36. }
  37. @Override
  38. public void saveOrUpdate(ArrangeDutyEntity entity) throws Exception {
  39. // TODO Auto-generated method stub
  40. }
  41. @Override
  42. public List<UserOrgDto> getUserOrgDtoByUserId(UserOrgDto userOrgDto,
  43. String authSql) {
  44. // TODO Auto-generated method stub
  45. return userOrgMinidao.getUserOrgDtoByUserId(userOrgDto, authSql);
  46. }
  47. /**
  48. * 根据用户与组织机构关系表中的组织id查询项目id;
  49. * 业务逻辑
  50. * 任意层节点的zTree,每一层有一个父id,顶级节点父节点为null,一个组织类型orgType,随机给一层的主键id,找到项目id,特征是orgType=3/5;
  51. * 根据是否是顶级父id判断是自上而下还是自下而上查找,当自下而上找到null时,再进行自下而上;
  52. * @author zbw
  53. * 2017-11-15
  54. * @param projectDepartId
  55. * @return
  56. */
  57. @Override
  58. public List<String> getProjectDepartId(String projectDepartId){
  59. // String newProjectDepartId="";
  60. List<String> newProjectDepartIdList=new ArrayList<String>();
  61. ProjectDepartDto projectDepartDto=new ProjectDepartDto();
  62. projectDepartDto.getDepartIdList().add(projectDepartId);
  63. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  64. // 根据部门信息表id查询部门信息表数据
  65. List<ProjectDepartDto> projectDepartDtoList = getProjectDepartByListId(projectDepartDto, authSql);
  66. if(projectDepartDtoList.get(0).getParentdepartid()!=null){
  67. if(!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_3)&&!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_5)){
  68. //获取某个父节点下面的所有子节点
  69. List<ProjectDepartDto> childList = getAllChildrenList(projectDepartId, null, null);
  70. for (int i = 0; i < childList.size(); i++) {
  71. if(childList.get(i).getOrgType().equals(Globals.org_type_3)||childList.get(i).getOrgType().equals(Globals.org_type_5)){
  72. // newProjectDepartId=childList.get(i).getId();
  73. if(!newProjectDepartIdList.contains(childList.get(i).getId())){
  74. newProjectDepartIdList.add(childList.get(i).getId());
  75. }
  76. }
  77. }
  78. if(newProjectDepartIdList.size()==0){
  79. //获取某个子节点上面的所有父节点
  80. List<ProjectDepartDto> parentList = getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null);
  81. for (int i = 0; i < parentList.size(); i++) {
  82. if(parentList.get(i).getOrgType().equals(Globals.org_type_3)||parentList.get(i).getOrgType().equals(Globals.org_type_5)){
  83. // newProjectDepartId=parentList.get(i).getId();
  84. if(!newProjectDepartIdList.contains(parentList.get(i).getId())){
  85. newProjectDepartIdList.add(parentList.get(i).getId());
  86. }
  87. }
  88. }
  89. }
  90. }else{
  91. newProjectDepartIdList.add(projectDepartDtoList.get(0).getId());
  92. // newProjectDepartId=projectDepartDtoList.get(0).getId();
  93. }
  94. }
  95. // List<PostEntity> childList = getAllChildrenList(post.getId(), null, null);
  96. // List<PostEntity> childList = getAllParentList(post.getParentPostid(), null, null);
  97. return newProjectDepartIdList;
  98. }
  99. /**
  100. * 根据用户与组织机构关系表中的组织id查询项目id;
  101. * 业务逻辑
  102. * 任意层节点的zTree,每一层有一个父id,顶级节点父节点为null,一个组织类型orgType,随机给一层的主键id,找到项目id,特征是orgType=3/5;
  103. * 根据是否是顶级父id判断是自上而下还是自下而上查找,当自下而上找到null时,再进行自下而上;
  104. * @author zbw
  105. * 2017-11-15
  106. * @param projectDepartId
  107. * @return
  108. */
  109. @Override
  110. public String getProjectDepartParentId(String projectDepartId){
  111. String newProjectDepartId="";
  112. ProjectDepartDto projectDepartDto=new ProjectDepartDto();
  113. projectDepartDto.getDepartIdList().add(projectDepartId);
  114. //String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  115. // 根据部门信息表id查询部门信息表数据
  116. List<ProjectDepartDto> projectDepartDtoList = getProjectDepartByListId(projectDepartDto, null);
  117. if(projectDepartDtoList.get(0).getParentdepartid()!=null){
  118. if(!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_3)&&!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_5)){
  119. //获取某个父节点下面的所有子节点
  120. /*List<ProjectDepartDto> childList = getAllChildrenList(projectDepartId, null, null);
  121. for (int i = 0; i < childList.size(); i++) {
  122. if(childList.get(i).getOrgType().equals(Globals.org_type_3)||childList.get(i).getOrgType().equals(Globals.org_type_5)){
  123. newProjectDepartId=childList.get(i).getId();
  124. // break;
  125. }
  126. }*/
  127. if(newProjectDepartId.length()==0){
  128. //获取某个子节点上面的所有父节点
  129. List<ProjectDepartDto> parentList = getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null);
  130. for (int i = 0; i < parentList.size(); i++) {
  131. if(parentList.get(i).getOrgType().equals(Globals.org_type_3)||parentList.get(i).getOrgType().equals(Globals.org_type_5)){
  132. newProjectDepartId=parentList.get(i).getId();
  133. // break;
  134. }
  135. }
  136. }
  137. }else{
  138. newProjectDepartId=projectDepartDtoList.get(0).getId();
  139. }
  140. }else{
  141. newProjectDepartId=null;
  142. }
  143. // List<PostEntity> childList = getAllChildrenList(post.getId(), null, null);
  144. // List<PostEntity> childList = getAllParentList(post.getParentPostid(), null, null);
  145. return newProjectDepartId;
  146. }
  147. @Override
  148. public List<ProjectDepartDto> getProjectDepartByListId(
  149. ProjectDepartDto projectDepartDto, String authSql) {
  150. // TODO Auto-generated method stub
  151. return projectDepartMinidao.getProjectDepartByListId(projectDepartDto, authSql);
  152. }
  153. /**
  154. * 获取某个父节点下面的所有子节点
  155. *
  156. * @param pid 父ID
  157. * @param entryList 当前节点的所有子节点列表(for循环用)
  158. * @param childList 所有子节点列表
  159. * @return
  160. */
  161. @Override
  162. public List<ProjectDepartDto> getAllChildrenList(String pid, List<ProjectDepartDto> entryList, List<ProjectDepartDto> childList) {
  163. if(childList == null){
  164. childList = new ArrayList<ProjectDepartDto>();
  165. }
  166. ProjectDepartDto projectDepartDto=new ProjectDepartDto();
  167. projectDepartDto.getParentDepartIdList().add(pid);
  168. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  169. entryList = getProjectDepartByListParentId(projectDepartDto, authSql);
  170. // final String hql = "from PostEntity where parentPostid=? ";
  171. // entryList = postService.findHql(hql, pid);
  172. for (ProjectDepartDto entry : entryList) {
  173. // 遍历出父id等于参数的id,add进子节点集合
  174. if (entry.getParentdepartid().equals(pid)) {
  175. // 递归遍历下一级
  176. getAllChildrenList(entry.getId(), entryList, childList);
  177. childList.add(entry);
  178. }
  179. }
  180. return childList;
  181. }
  182. /**
  183. * 获取某个子节点上面的所有父节点
  184. *
  185. * @param childId 父ID
  186. * @param entryList 当前节点的所有父节点列表(for循环用)
  187. * @param childList 所有父节点列表
  188. * @return
  189. */
  190. @Override
  191. public List<ProjectDepartDto> getAllParentList(String pid, List<ProjectDepartDto> entryList, List<ProjectDepartDto> parentList) {
  192. if(parentList == null){
  193. parentList = new ArrayList<ProjectDepartDto>();
  194. }
  195. ProjectDepartDto projectDepartDto=new ProjectDepartDto();
  196. projectDepartDto.getChildDepartIdList().add(pid);
  197. //String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  198. entryList = getProjectDepartByListChildId(projectDepartDto, null);
  199. // final String hql = "from PostEntity where id=? ";
  200. // entryList = postService.findHql(hql, pid);
  201. for (ProjectDepartDto entry : entryList) {
  202. // 遍历出父id等于参数的id,add进父节点集合
  203. if (entry.getId().equals(pid)) {
  204. // 递归遍历下一级
  205. getAllParentList(entry.getParentdepartid(), entryList, parentList);
  206. parentList.add(entry);
  207. }
  208. }
  209. return parentList;
  210. }
  211. @Override
  212. public List<ProjectDepartDto> getProjectDepartByListParentId(
  213. ProjectDepartDto projectDepartDto, String authSql) {
  214. // TODO Auto-generated method stub
  215. return projectDepartMinidao.getProjectDepartByListParentId(projectDepartDto, authSql);
  216. }
  217. @Override
  218. public List<ProjectDepartDto> getProjectDepartByListChildId(
  219. ProjectDepartDto projectDepartDto, String authSql) {
  220. // TODO Auto-generated method stub
  221. return projectDepartMinidao.getProjectDepartByListChildId(projectDepartDto, authSql);
  222. }
  223. @Override
  224. public List<String> getParentChildIdByProjectDepartId(String projectDepartId) {
  225. List<String> parentChildIdList=new ArrayList<String>();
  226. parentChildIdList.add(projectDepartId);
  227. ProjectDepartDto projectDepartDto=new ProjectDepartDto();
  228. projectDepartDto.getDepartIdList().add(projectDepartId);
  229. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  230. List<ProjectDepartDto> projectDepartDtoList = getProjectDepartByListId(projectDepartDto, authSql);
  231. if(projectDepartDtoList.get(0).getParentdepartid()!=null){
  232. //获取某个父节点下面的所有子节点
  233. List<ProjectDepartDto> childList = getAllChildrenList(projectDepartId, null, null);
  234. for (int i = 0; i < childList.size(); i++) {
  235. parentChildIdList.add(childList.get(i).getId());
  236. }
  237. //获取某个子节点上面的所有父节点
  238. List<ProjectDepartDto> parentList = getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null);
  239. for (int i = 0; i < parentList.size(); i++) {
  240. parentChildIdList.add(parentList.get(i).getId());
  241. }
  242. }else{
  243. //获取某个父节点下面的所有子节点
  244. List<ProjectDepartDto> childList = getAllChildrenList(projectDepartId, null, null);
  245. for (int i = 0; i < childList.size(); i++) {
  246. parentChildIdList.add(childList.get(i).getId());
  247. }
  248. }
  249. return parentChildIdList;
  250. }
  251. @Override
  252. public List<String> getChildIdByProjectDepartId(String projectDepartId) {
  253. List<String> parentChildIdList=new ArrayList<String>();
  254. parentChildIdList.add(projectDepartId);
  255. //获取某个父节点下面的所有子节点
  256. List<ProjectDepartDto> childList = getAllChildrenList(projectDepartId, null, null);
  257. for (int i = 0; i < childList.size(); i++) {
  258. parentChildIdList.add(childList.get(i).getId());
  259. }
  260. return parentChildIdList;
  261. }
  262. }