DialogDealServiceImpl.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. package cn.com.lzt.dialogDeal.service.impl;
  2. import java.io.Serializable;
  3. import java.text.Collator;
  4. import java.util.ArrayList;
  5. import java.util.Collections;
  6. import java.util.Comparator;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Locale;
  10. import java.util.Map;
  11. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  12. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  13. import com.daju.common.constants.EleTypeEnum;
  14. import com.daju.mix.dao.entity.TBArchivesArea;
  15. import com.daju.mix.dao.entity.TBArchivesPlace;
  16. import com.daju.mix.dao.entity.TBArchivesRoadSection;
  17. import com.daju.mix.dao.entity.TBWorkRouteList;
  18. import com.daju.mix.dao.mapper.TBArchivesAreaMapper;
  19. import com.daju.mix.dao.service.impl.TBArchivesAreaServiceImpl;
  20. import com.daju.mix.dao.service.impl.TBArchivesPlaceServiceImpl;
  21. import com.daju.mix.dao.service.impl.TBArchivesRoadSectionServiceImpl;
  22. import com.daju.mix.dto.ElementDto;
  23. import org.jeecgframework.core.common.model.json.DataGrid;
  24. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  25. import org.jeecgframework.core.constant.Globals;
  26. import org.jeecgframework.core.util.JeecgDataAutorUtils;
  27. import org.jeecgframework.core.util.ResourceUtil;
  28. import org.jeecgframework.web.system.pojo.base.TSDepart;
  29. import org.jeecgframework.web.system.pojo.base.TSUser;
  30. import org.springframework.beans.factory.annotation.Autowired;
  31. import org.springframework.stereotype.Service;
  32. import org.springframework.transaction.annotation.Transactional;
  33. import cn.com.lzt.arrangeduty.dao.ArrangeDutyMinidao;
  34. import cn.com.lzt.arrangeduty.dao.MealsSubsidyMiniDao;
  35. import cn.com.lzt.arrangeduty.dao.ProjectDepartMinidao;
  36. import cn.com.lzt.arrangeduty.dao.UserOrgMinidao;
  37. import cn.com.lzt.arrangeduty.dto.ProjectDepartDto;
  38. import cn.com.lzt.arrangeduty.dto.UserOrgDto;
  39. import cn.com.lzt.arrangeduty.entity.ArrangeDutyEntity;
  40. import cn.com.lzt.dialogDeal.dao.UserDepartOrgDealMiniDao;
  41. import cn.com.lzt.dialogDeal.service.DialogDealServiceI;
  42. import cn.com.lzt.dialogDeal.service.UserDepartOrgDealServiceI;
  43. import javax.annotation.Resource;
  44. @Service("dialogDealService")
  45. @Transactional
  46. public class DialogDealServiceImpl extends CommonServiceImpl implements DialogDealServiceI {
  47. @Autowired
  48. ArrangeDutyMinidao arrangeDutyMinidao;
  49. @Autowired
  50. MealsSubsidyMiniDao mealsSubsidyMiniDao;
  51. @Autowired
  52. ProjectDepartMinidao projectDepartMinidao;
  53. @Autowired
  54. UserOrgMinidao userOrgMinidao;
  55. // 用户和项目关系处理
  56. @Autowired
  57. UserDepartOrgDealServiceI userDepartOrgDealServiceI;
  58. @Autowired
  59. UserDepartOrgDealMiniDao userDepartOrgDealMiniDao;
  60. @Resource
  61. TBArchivesPlaceServiceImpl tbArchivesPlaceService;
  62. @Resource
  63. TBArchivesRoadSectionServiceImpl tbArchivesRoadSectionService;
  64. @Resource
  65. TBArchivesAreaServiceImpl tbArchivesAreaService;
  66. @Resource
  67. TBArchivesAreaMapper tbArchivesAreaMapper;
  68. @Override
  69. public void delete(ArrangeDutyEntity entity) throws Exception {
  70. // TODO Auto-generated method stub
  71. }
  72. @Override
  73. public Serializable save(ArrangeDutyEntity entity) throws Exception {
  74. // TODO Auto-generated method stub
  75. return null;
  76. }
  77. @Override
  78. public void saveOrUpdate(ArrangeDutyEntity entity) throws Exception {
  79. // TODO Auto-generated method stub
  80. }
  81. @Override
  82. public List<ProjectDepartDto> getProjectDepartByUserId(){
  83. TSUser tSUser=ResourceUtil.getSessionUser();
  84. UserOrgDto userOrgDto=new UserOrgDto();
  85. userOrgDto.setUserId(tSUser.getId());
  86. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  87. // 根据当前登录用户id查询 用户与组织机构关系表数据
  88. List<UserOrgDto> userOrgDtoList = userDepartOrgDealServiceI.getUserOrgDtoByUserId(userOrgDto, authSql);
  89. ProjectDepartDto projectDepartDto =new ProjectDepartDto();
  90. List<Map<String, Object>> listMap=new ArrayList<Map<String, Object>>();
  91. List<String> projectDepartIdList=new ArrayList<String>();
  92. for (int i = 0; i < userOrgDtoList.size(); i++) {
  93. List<String> newProjectDepartIdList =userDepartOrgDealServiceI.getProjectDepartId(userOrgDtoList.get(i).getOrgId());
  94. if(newProjectDepartIdList.size()>0){
  95. for (int j = 0; j < newProjectDepartIdList.size(); j++) {
  96. Map<String, Object> myMap=new HashMap<String, Object>();
  97. myMap.put("projectDepartId", newProjectDepartIdList.get(j));
  98. myMap.put("ifpluralism", userOrgDtoList.get(i).getIfpluralism());
  99. myMap.put("status", userOrgDtoList.get(i).getStatus());
  100. if(!projectDepartIdList.contains(newProjectDepartIdList.get(j))){
  101. projectDepartIdList.add(newProjectDepartIdList.get(j));
  102. listMap.add(myMap);
  103. }
  104. }
  105. }
  106. }
  107. projectDepartDto.getDepartIdList().addAll(projectDepartIdList);
  108. authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  109. List<ProjectDepartDto> projectDepartDtoList = userDepartOrgDealServiceI.getProjectDepartByListId(projectDepartDto, authSql);
  110. for (int i = 0; i < projectDepartDtoList.size(); i++) {
  111. for (int j = 0; j < listMap.size(); j++) {
  112. if(projectDepartDtoList.get(i).getId().equals(listMap.get(j).get("projectDepartId"))){
  113. projectDepartDtoList.get(i).setIfpluralism(listMap.get(j).get("ifpluralism").toString());
  114. projectDepartDtoList.get(i).setStatus(listMap.get(j).get("status").toString());
  115. break;
  116. }
  117. /*for(Entry<String, Object> entryParam : listMap.get(j).entrySet()){
  118. //System.out.println("key="+entryParam.getKey()+",value="+entryParam.getValue());
  119. if(projectDepartDtoList.get(i).getId().equals(entryParam.getValue())){}
  120. }*/
  121. }
  122. }
  123. return projectDepartDtoList;
  124. }
  125. /* (non-Javadoc)
  126. * @see cn.com.lzt.dialogDeal.service.DialogDealServiceI#getProjectDepartChildByUserIdAndLikeDepartName(cn.com.lzt.arrangeduty.dto.ProjectDepartDto)
  127. */
  128. @Override
  129. public List<ProjectDepartDto> getProjectDepartChildByUserIdAndLikeDepartName(ProjectDepartDto projectDepartDto) {
  130. TSUser tSUser=ResourceUtil.getSessionUser();
  131. UserOrgDto userOrgDto=new UserOrgDto();
  132. userOrgDto.setUserId(tSUser.getId());
  133. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  134. // 根据当前登录用户id查询 用户与组织机构关系表数据
  135. List<UserOrgDto> userOrgDtoList = userDepartOrgDealServiceI.getUserOrgDtoByUserId(userOrgDto, authSql);
  136. Map<String, String> depargMap = getTSDepartByIdMap();
  137. List<ProjectDepartDto> projectDepartDtoList = new ArrayList<ProjectDepartDto>();
  138. for (int i = 0; i < userOrgDtoList.size(); i++) {
  139. List<ProjectDepartDto> newProjectDepartIdList =userDepartOrgDealServiceI.getAllChildrenList(userOrgDtoList.get(i).getOrgId(),null,null);
  140. if(newProjectDepartIdList.size()>0){
  141. for (int j = 0; j < newProjectDepartIdList.size(); j++) {
  142. if(userOrgDtoList.get(i).getOrgId().equals(newProjectDepartIdList.get(j).getId())) {
  143. continue;
  144. }
  145. String departname = depargMap.get(newProjectDepartIdList.get(j).getId());
  146. if(departname != null ) {
  147. newProjectDepartIdList.get(j).setDepartName(departname);
  148. }
  149. if(projectDepartDto.getDepartName() != null && departname.indexOf(projectDepartDto.getDepartName())<0) {
  150. continue;
  151. }
  152. projectDepartDtoList.add(newProjectDepartIdList.get(j));
  153. }
  154. }
  155. }
  156. return projectDepartDtoList;
  157. }
  158. private Map<String, String> getTSDepartByIdMap(){
  159. //查出部门信息表所有数据,获取主键id和名称
  160. StringBuffer hql = new StringBuffer(" from TSDepart ");
  161. List<TSDepart> TSDepartByIdMapList = this.findHql(hql.toString());
  162. Map<String, String> TSDepartNameByIdMap=new HashMap<String, String>();
  163. for (int i = 0; i < TSDepartByIdMapList.size(); i++) {
  164. TSDepart depart = TSDepartByIdMapList.get(i);
  165. String showname = depart.getDepartname();
  166. if(depart.getTSPDepart() != null && !Globals.SHENQIN_ID.equals(depart.getTSPDepart().getId())) {
  167. showname = depart.getTSPDepart().getDepartname() + "-" + showname;
  168. }
  169. TSDepartNameByIdMap.put(TSDepartByIdMapList.get(i).getId(),showname);
  170. }
  171. return TSDepartNameByIdMap;
  172. }
  173. @Override
  174. public List<ProjectDepartDto> getProjectDepartByUserIdAndLikeDepartName(ProjectDepartDto projectDepartDto){
  175. TSUser tSUser=ResourceUtil.getSessionUser();
  176. UserOrgDto userOrgDto=new UserOrgDto();
  177. userOrgDto.setUserId(tSUser.getId());
  178. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  179. // 根据当前登录用户id查询 用户与组织机构关系表数据
  180. List<UserOrgDto> userOrgDtoList = userDepartOrgDealServiceI.getUserOrgDtoByUserId(userOrgDto, authSql);
  181. // ProjectDepartDto projectDepartDto =new ProjectDepartDto();
  182. List<Map<String, Object>> listMap=new ArrayList<Map<String, Object>>();
  183. List<String> projectDepartIdList=new ArrayList<String>();
  184. for (int i = 0; i < userOrgDtoList.size(); i++) {
  185. List<String> newProjectDepartIdList =userDepartOrgDealServiceI.getProjectDepartId(userOrgDtoList.get(i).getOrgId());
  186. if(newProjectDepartIdList.size()>0){
  187. for (int j = 0; j < newProjectDepartIdList.size(); j++) {
  188. Map<String, Object> myMap=new HashMap<String, Object>();
  189. myMap.put("projectDepartId", newProjectDepartIdList.get(j));
  190. myMap.put("ifpluralism", userOrgDtoList.get(i).getIfpluralism());
  191. myMap.put("status", userOrgDtoList.get(i).getStatus());
  192. if(!projectDepartIdList.contains(newProjectDepartIdList.get(j))){
  193. projectDepartIdList.add(newProjectDepartIdList.get(j));
  194. listMap.add(myMap);
  195. }
  196. }
  197. }
  198. }
  199. projectDepartDto.getDepartIdList().addAll(projectDepartIdList);
  200. authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  201. List<ProjectDepartDto> projectDepartDtoList = userDepartOrgDealServiceI.getProjectDepartByListId(projectDepartDto, authSql);
  202. for (int i = 0; i < projectDepartDtoList.size(); i++) {
  203. for (int j = 0; j < listMap.size(); j++) {
  204. if(projectDepartDtoList.get(i).getId().equals(listMap.get(j).get("projectDepartId"))){
  205. projectDepartDtoList.get(i).setIfpluralism(listMap.get(j).get("ifpluralism").toString());
  206. projectDepartDtoList.get(i).setStatus(listMap.get(j).get("status").toString());
  207. break;
  208. }
  209. /*for(Entry<String, Object> entryParam : listMap.get(j).entrySet()){
  210. //System.out.println("key="+entryParam.getKey()+",value="+entryParam.getValue());
  211. if(projectDepartDtoList.get(i).getId().equals(entryParam.getValue())){}
  212. }*/
  213. }
  214. }
  215. return projectDepartDtoList;
  216. }
  217. @Override
  218. public List<ProjectDepartDto> getProjectDepartAll(
  219. ProjectDepartDto projectDepartDto) {
  220. // StringBuffer hql = new StringBuffer(" FROM ArrangeDutyOperateEntity where yearmonth=? ");
  221. // List<ArrangeDutyOperateEntity> arrangeDutyOperateEntityList = commonService.findHql(hql.toString(),yearmonth);
  222. List<String> orgTypeList=new ArrayList<String>();
  223. orgTypeList.add(Globals.org_type_3);
  224. orgTypeList.add(Globals.org_type_5);
  225. orgTypeList.add(Globals.org_type_2);
  226. projectDepartDto.getOrgTypeList().addAll(orgTypeList);
  227. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  228. List<ProjectDepartDto> projectDepartDtoList=userDepartOrgDealMiniDao.getProjectDepartAll(projectDepartDto, authSql);
  229. Collections.sort(projectDepartDtoList, new Comparator<ProjectDepartDto>() {
  230. @Override
  231. public int compare(ProjectDepartDto o1, ProjectDepartDto o2) {
  232. String o1name = "";
  233. String o2name = "";
  234. if(o1.getDepartName() != null) {
  235. o1name = o1.getDepartName();
  236. }
  237. if(o2.getDepartName() != null) {
  238. o2name = o2.getDepartName();
  239. }
  240. return Collator.getInstance(Locale.CHINESE).compare(o1name,o2name);
  241. }
  242. });
  243. return projectDepartDtoList;
  244. }
  245. /* (non-Javadoc)
  246. * @see cn.com.lzt.dialogDeal.service.DialogDealServiceI#getProjectDepartAllWithChild(cn.com.lzt.arrangeduty.dto.ProjectDepartDto)
  247. */
  248. @Override
  249. public List<ProjectDepartDto> getProjectDepartAllWithChildren(ProjectDepartDto projectDepartDto) {
  250. List<String> orgTypeList=new ArrayList<String>();
  251. List<ProjectDepartDto> projectDepartDtoList = new ArrayList<ProjectDepartDto>();
  252. orgTypeList.add(Globals.org_type_2);
  253. orgTypeList.add(Globals.org_type_3);
  254. orgTypeList.add(Globals.org_type_5);
  255. projectDepartDto.getOrgTypeList().addAll(orgTypeList);
  256. String likename = projectDepartDto.getDepartName();
  257. projectDepartDto.setDepartName(null);
  258. Map<String, String> depargMap = getTSDepartByIdMap();
  259. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  260. List<ProjectDepartDto> userOrgDtoList=userDepartOrgDealMiniDao.getProjectDepartAllWithChildren(projectDepartDto, authSql);
  261. for (int i = 0; i < userOrgDtoList.size(); i++) {
  262. String departname = depargMap.get(userOrgDtoList.get(i).getId());
  263. if(likename != null && likename.length() > 0 && departname.indexOf(likename)<0) {
  264. continue;
  265. }
  266. if(departname != null) {
  267. userOrgDtoList.get(i).setDepartName(departname);
  268. }
  269. projectDepartDtoList.add(userOrgDtoList.get(i));
  270. }
  271. Collections.sort(projectDepartDtoList, new Comparator<ProjectDepartDto>() {
  272. @Override
  273. public int compare(ProjectDepartDto o1, ProjectDepartDto o2) {
  274. String o1name = "";
  275. String o2name = "";
  276. if(o1.getDepartName() != null) {
  277. o1name = o1.getDepartName();
  278. }
  279. if(o2.getDepartName() != null) {
  280. o2name = o2.getDepartName();
  281. }
  282. return Collator.getInstance(Locale.CHINESE).compare(o1name,o2name);
  283. }
  284. });
  285. return projectDepartDtoList;
  286. }
  287. /*@Override
  288. public List<ElementDto> getElementAll(ElementDto elementDto) {
  289. List<ElementDto> elementDtos = new ArrayList<>();
  290. QueryWrapper<TBArchivesRoadSection> sectionQueryWrapper = new QueryWrapper<>();
  291. QueryWrapper<TBArchivesPlace> tbArchivesPlaceQueryWrapper = new QueryWrapper<>();
  292. if(elementDto.getCode()!= null){
  293. sectionQueryWrapper.lambda().like(TBArchivesRoadSection::getCode, elementDto.getCode());
  294. tbArchivesPlaceQueryWrapper.lambda().like(TBArchivesPlace::getCode, elementDto.getCode());
  295. }
  296. if(elementDto.getName()!= null){
  297. sectionQueryWrapper.lambda().like(TBArchivesRoadSection::getName, elementDto.getName());
  298. tbArchivesPlaceQueryWrapper.lambda().like(TBArchivesPlace::getName, elementDto.getName());
  299. }
  300. if("".equals(elementDto.getType()) || elementDto.getType() == null){
  301. List<TBArchivesRoadSection> archivesRoadSectionList = tbArchivesRoadSectionService.list(sectionQueryWrapper);
  302. archivesRoadSectionList.forEach((item)->{
  303. ElementDto dto = new ElementDto();
  304. dto.setCode(item.getCode());
  305. dto.setName(item.getName());
  306. dto.setType("路段");
  307. elementDtos.add(dto);
  308. });
  309. List<TBArchivesPlace> archivesPlaceList = tbArchivesPlaceService.list(tbArchivesPlaceQueryWrapper);
  310. archivesPlaceList.forEach((item)->{
  311. ElementDto dto = new ElementDto();
  312. dto.setCode(item.getCode());
  313. dto.setName(item.getName());
  314. dto.setType(String.valueOf(item.getType()));
  315. elementDtos.add(dto);
  316. });
  317. }else if("路段".equals(elementDto.getType())){
  318. List<TBArchivesRoadSection> archivesRoadSectionList = tbArchivesRoadSectionService.list(sectionQueryWrapper);
  319. archivesRoadSectionList.forEach((item)->{
  320. ElementDto dto = new ElementDto();
  321. dto.setCode(item.getCode());
  322. dto.setName(item.getName());
  323. dto.setType("路段");
  324. elementDtos.add(dto);
  325. });
  326. }else{
  327. tbArchivesPlaceQueryWrapper.lambda().eq(TBArchivesPlace::getType,elementDto.getType());
  328. List<TBArchivesPlace> archivesPlaceList = tbArchivesPlaceService.list(tbArchivesPlaceQueryWrapper);
  329. archivesPlaceList.forEach((item)->{
  330. ElementDto dto = new ElementDto();
  331. dto.setCode(item.getCode());
  332. dto.setName(item.getName());
  333. dto.setType(String.valueOf(item.getType()));
  334. elementDtos.add(dto);
  335. });
  336. }
  337. return elementDtos;
  338. }*/
  339. /**
  340. * 1123 由场所,路段 -> 作业元素表数据 (区域,路段) 1130 -> +场所
  341. * @param elementDto
  342. * @return
  343. */
  344. @Override
  345. public List<ElementDto> getElementAll(ElementDto elementDto) {
  346. List<ElementDto> elementDtos = new ArrayList<>();
  347. LambdaQueryWrapper<TBArchivesArea> wrapper = new LambdaQueryWrapper<>();
  348. if(elementDto.getCode() != null){
  349. wrapper.like(TBArchivesArea::getCode, elementDto.getCode());
  350. }
  351. if(elementDto.getName() != null){
  352. wrapper.like(TBArchivesArea::getName, elementDto.getName());
  353. }
  354. if(elementDto.getType() != null){
  355. wrapper.eq(TBArchivesArea::getAreaType, elementDto.getType());
  356. }
  357. List<TBArchivesArea> list = tbArchivesAreaMapper.selectList(wrapper);
  358. // List<TBArchivesArea> list = tbArchivesAreaService.list(wrapper);
  359. for (TBArchivesArea li : list) {
  360. ElementDto dto = new ElementDto();
  361. dto.setCode(li.getCode());
  362. dto.setName(li.getName());
  363. dto.setType(EleTypeEnum.nameForCode(li.getAreaType()));
  364. elementDtos.add(dto);
  365. }
  366. return elementDtos;
  367. }
  368. }