ProjectTaskServiceImpl.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. package com.ruoyi.project.service.impl;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.ruoyi.common.core.domain.AjaxResult;
  5. import com.ruoyi.common.core.domain.entity.SysDept;
  6. import com.ruoyi.common.core.domain.entity.SysUser;
  7. import com.ruoyi.common.enums.UserRolesType;
  8. import com.ruoyi.common.exception.ServiceException;
  9. import com.ruoyi.common.utils.DateUtils;
  10. import com.ruoyi.common.utils.PageUtils;
  11. import com.ruoyi.common.utils.SecurityUtils;
  12. import com.ruoyi.common.utils.StringUtils;
  13. import com.ruoyi.common.utils.bean.BeanUtils;
  14. import com.ruoyi.common.utils.bean.BeanValidators;
  15. import com.ruoyi.common.utils.file.FileUtils;
  16. import com.ruoyi.project.bo.ProjectListInput;
  17. import com.ruoyi.project.bo.ProjectTaskListOut;
  18. import com.ruoyi.project.bo.ProjectTaskOut;
  19. import com.ruoyi.project.domain.ProjectStaff;
  20. import com.ruoyi.project.domain.ProjectStaffRecord;
  21. import com.ruoyi.project.domain.ProjectTask;
  22. import com.ruoyi.project.mapper.ProjectStaffMapper;
  23. import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
  24. import com.ruoyi.project.mapper.ProjectTaskMapper;
  25. import com.ruoyi.project.service.ProjectTaskService;
  26. import com.ruoyi.system.mapper.SysDeptMapper;
  27. import com.ruoyi.system.mapper.SysUserMapper;
  28. import com.ruoyi.system.service.ISysDeptService;
  29. import org.apache.poi.xwpf.usermodel.XWPFDocument;
  30. import org.apache.poi.xwpf.usermodel.XWPFParagraph;
  31. import org.apache.poi.xwpf.usermodel.XWPFRun;
  32. import org.slf4j.Logger;
  33. import org.slf4j.LoggerFactory;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35. import org.springframework.beans.factory.annotation.Value;
  36. import org.springframework.http.HttpStatus;
  37. import org.springframework.stereotype.Service;
  38. import org.springframework.transaction.annotation.Transactional;
  39. import javax.annotation.Resource;
  40. import javax.servlet.http.HttpServletResponse;
  41. import javax.validation.Validator;
  42. import java.io.ByteArrayOutputStream;
  43. import java.io.File;
  44. import java.io.FileOutputStream;
  45. import java.io.IOException;
  46. import java.util.*;
  47. import java.util.zip.ZipOutputStream;
  48. import static java.lang.Thread.sleep;
  49. @Service
  50. public class ProjectTaskServiceImpl implements ProjectTaskService {
  51. private static final Logger log = LoggerFactory.getLogger(ProjectTaskServiceImpl.class);
  52. @Resource
  53. private ProjectTaskMapper projectTaskMapper;
  54. @Resource
  55. private ProjectStaffMapper projectStaffMapper;
  56. @Resource
  57. private ISysDeptService deptService;
  58. @Resource
  59. private Validator validator;
  60. @Resource
  61. private SysUserMapper userMapper;
  62. @Resource
  63. private ProjectStaffRecordMapper projectStaffRecordMapper;
  64. @Resource
  65. private SysDeptMapper sysDeptMapper;
  66. @Resource
  67. private TianheService tianheService;
  68. @Value("${ruoyi.profile}")
  69. private String profile=null;
  70. @Override
  71. public AjaxResult addProjectTask(ProjectTask projectTask) {
  72. userMapper.updateUserProjectSum(projectTask.getAid(),0);
  73. projectTask.setCreateAid(SecurityUtils.getUserId());
  74. int i = projectTaskMapper.insertSelective(projectTask);
  75. if (StringUtils.isNotBlank(projectTask.getStaffObject())){
  76. String[] split = projectTask.getStaffObject().split(",");
  77. projectStaffMapper.updatePidByList(projectTask.getId(),split);
  78. projectTaskMapper.updateStaffName(projectTask.getId());
  79. }
  80. return AjaxResult.success(i);
  81. }
  82. @Override
  83. public AjaxResult deleteProject(ProjectTask in) {
  84. int i = projectTaskMapper.deleteByPrimaryKey(in.getId());
  85. userMapper.updateUserProjectSum(in.getAid(),0);
  86. if (i>0){
  87. projectStaffMapper.deleteBypid(in.getId());
  88. return AjaxResult.success();
  89. }
  90. return AjaxResult.error("项目编号不存在");
  91. }
  92. @Override
  93. public AjaxResult details(Long id) {
  94. ProjectTask projectTask = projectTaskMapper.selectByPrimaryKey(id);
  95. ProjectTaskOut out= new ProjectTaskOut();
  96. if (projectTask!=null){
  97. BeanUtils.copyBeanProp(out, projectTask);
  98. List<ProjectStaff> projectStaffs = projectStaffMapper.selectByPid(id);
  99. if (!projectStaffs.isEmpty())out.setList(projectStaffs);
  100. return AjaxResult.success(out);
  101. }
  102. return AjaxResult.error("项目不存在");
  103. }
  104. @Override
  105. public List<ProjectTaskListOut> list(ProjectListInput in) {
  106. pushRoleType(in);
  107. if (!SecurityUtils.isSuperAdmin()){
  108. in.setUid(SecurityUtils.getUserId());
  109. Long companyId = deptService.selectCompanyByDeptId();
  110. if (companyId!=null)in.setCompanyId(companyId);
  111. }
  112. if (in.getMyCreate()!=null&&in.getMyCreate()==1){
  113. in.setCreateAid(SecurityUtils.getUserId());
  114. }
  115. if (in.getEndTime()!=null)in.setEndTime(in.getEndTime()+" 23:59:59");
  116. PageUtils.startPage();
  117. return projectTaskMapper.selectList(in);
  118. }
  119. private void pushRoleType(ProjectListInput in) {
  120. if (in.getRoleType()==null){
  121. if (SecurityUtils.hashRoles(UserRolesType.CEO.getCode())){
  122. in.setRoleType(1);
  123. }else if (SecurityUtils.hashRoles(UserRolesType.ADMIN.getCode())){
  124. in.setRoleType(3);
  125. }else if (SecurityUtils.hashRoles(UserRolesType.MANAGE.getCode())){
  126. in.setRoleType(2);
  127. }else {
  128. in.setRoleType(0);
  129. }
  130. }
  131. }
  132. @Override
  133. public String importProject(List<ProjectTaskListOut> list, boolean updateSupport, String operName) {
  134. if (StringUtils.isNull(list) || list.size() == 0)
  135. {
  136. throw new ServiceException("导入用户数据不能为空!");
  137. }
  138. int successNum = 0;
  139. int failureNum = 0;
  140. StringBuilder successMsg = new StringBuilder();
  141. StringBuilder failureMsg = new StringBuilder();
  142. Long company = deptService.selectCompanyByDeptId();
  143. List<Long> pids = new ArrayList<Long>();
  144. for (ProjectTaskListOut p : list)
  145. {
  146. try
  147. {
  148. if (p.getProjectYear()==null||p.getProjectYear()==""){
  149. throw new ServiceException("项目年份不能为空");
  150. }else if (p.getCreateYear()==null||p.getCreateYear()==""){
  151. throw new ServiceException("创建年份不能为空");
  152. }
  153. // 验证是否存在这个用户
  154. ProjectTask projectTask = projectTaskMapper.selectByProjectNumber(p.getProjectNumber(),company);
  155. if (StringUtils.isNull(projectTask)){
  156. BeanValidators.validateWithException(validator, p);
  157. if (checkProjectNumber(p)){
  158. throw new ServiceException(String.format("项目编号[%s]已存在", p.getProjectNumber()));
  159. }
  160. if(StringUtils.isNotBlank(p.getAdminName())) {
  161. SysUser sysUser = userMapper.selectByNikeName(p.getAdminName(),company);
  162. if (sysUser == null) {
  163. throw new ServiceException(String.format("负责人[%s]不存在", p.getAdminName()));
  164. }
  165. p.setAid(sysUser.getUserId());
  166. p.setAdminName(sysUser.getNickName());
  167. }
  168. p.setProjectStatus(0);
  169. projectTaskMapper.insertSelective(p);
  170. pushProjectStaffName(p, company);
  171. successNum++;
  172. successMsg.append("<br/>" + successNum + "、项目: " + p.getName() + " 导入成功");
  173. }else if (updateSupport){
  174. BeanValidators.validateWithException(validator, p);
  175. p.setId(projectTask.getId());
  176. if(StringUtils.isNotBlank(p.getStaffName())) {
  177. addStaffAndDelete( p);
  178. }
  179. if (p.getAdminName()!=null&&!projectTask.getAdminName().equals(p.getAdminName())){
  180. SysUser sysUser = userMapper.selectByNikeName(p.getAdminName(),company);
  181. if (sysUser == null) {
  182. throw new ServiceException(String.format("负责人[%s]不存在", p.getAdminName()));
  183. }
  184. List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(p.getId(), projectTask.getAid());
  185. if (projectStaffRecords.size()>0){
  186. throw new ServiceException(String.format("负责人[%s]存在打卡,不允许切换.", projectTask.getAdminName()));
  187. }
  188. p.setAid(sysUser.getUserId());
  189. p.setAdminName(sysUser.getNickName());
  190. }
  191. projectTaskMapper.updateByPrimaryKeySelective(p);
  192. if (!pids.contains(p.getId())){
  193. pids.add(p.getId());
  194. }
  195. successNum++;
  196. successMsg.append("<br/>" + successNum + "、项目: " + projectTask.getName() + " 更新成功");
  197. }
  198. else
  199. {
  200. failureNum++;
  201. failureMsg.append("<br/>" + failureNum + "、项目: " + projectTask.getName() + " 已存在");
  202. }
  203. }
  204. catch (Exception e)
  205. {
  206. failureNum++;
  207. String msg = "<br/>" + failureNum + "、项目: " + p.getName() + " 导入失败:";
  208. failureMsg.append(msg + e.getMessage());
  209. log.error(msg, e);
  210. }
  211. }
  212. if (failureNum > 0)
  213. {
  214. failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
  215. throw new ServiceException(failureMsg.toString());
  216. }
  217. else
  218. {
  219. successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
  220. }
  221. if (!pids.isEmpty()){
  222. for (Long pid : pids) {
  223. projectStaffRecordMapper.updateSumDurationProject(pid);
  224. projectStaffRecordMapper.updateSumDurationStaff(pid);
  225. }
  226. }
  227. return successMsg.toString();
  228. }
  229. private void pushProjectStaffName(ProjectTaskListOut p, Long company) {
  230. if(StringUtils.isNotBlank(p.getStaffName())) {
  231. String[] split = StringUtils.splitString(p.getStaffName());
  232. for (String s : split) {
  233. ProjectStaff newPs = new ProjectStaff();
  234. SysUser sysUser = userMapper.selectByNikeName(s, company);
  235. if (sysUser == null) {
  236. throw new ServiceException("[" + s + "]不存在");
  237. }
  238. newPs.setAid(sysUser.getUserId());
  239. newPs.setName(sysUser.getNickName());
  240. newPs.setPid(p.getId());
  241. projectStaffMapper.insertSelective(newPs);
  242. }
  243. }
  244. projectTaskMapper.updateStaffName(p.getId());
  245. }
  246. @Override
  247. public AjaxResult updateProjectTask(ProjectTask in) {
  248. ProjectTask use = projectTaskMapper.selectByPrimaryKey(in.getId());
  249. if (!in.getAid().equals(use.getAid())){
  250. List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(in.getId(), use.getAid());
  251. if (projectStaffRecords.size()>0){
  252. throw new ServiceException(String.format("负责人[%s]存在打卡,不允许切换.", use.getAdminName()));
  253. }
  254. }
  255. return AjaxResult.success(projectTaskMapper.updateByPrimaryKeySelective(in));
  256. }
  257. @Override
  258. public AjaxResult selectProjectImg(Long pid) {
  259. return AjaxResult.success(projectTaskMapper.selectProjectImg(pid));
  260. }
  261. @Override
  262. public boolean checkProjectNumber(ProjectTask projectTask) {
  263. Long companyId = deptService.selectCompanyByDeptId();
  264. ProjectTask projectTask1 = projectTaskMapper.selectByProjectNumber(projectTask.getProjectNumber(),companyId);
  265. if (projectTask.getId()==null){
  266. if (projectTask1!=null){
  267. return true;
  268. }
  269. }else {
  270. if (projectTask1!=null&&!projectTask.getId().equals(projectTask1.getId())){
  271. return true;
  272. }
  273. }
  274. return false;
  275. }
  276. private void addStaffAndDelete( ProjectTaskListOut p) {
  277. String[] split = p.getStaffName().split(",");
  278. List<ProjectStaff> projectStaffs = projectStaffMapper.selectByPid(p.getId());
  279. deleteStaff( split, projectStaffs);
  280. addStaff( p, split, projectStaffs);
  281. //再从新获取统计名字
  282. projectTaskMapper.updateStaffName(p.getId());
  283. }
  284. private void deleteStaff( String[] split, List<ProjectStaff> projectStaffs) {
  285. //预设需要删除,如果找到相同名字的就无需删除
  286. for (ProjectStaff ps : projectStaffs) {
  287. boolean flag = true;
  288. for (String s : split) {
  289. s=s.trim();
  290. if (ps.getName().equals(s)) {
  291. flag = false;
  292. }
  293. }
  294. if (flag) {
  295. int sum = projectStaffRecordMapper.selectById(ps.getId());
  296. if (sum > 0) {
  297. throw new ServiceException("[" + ps.getName() + "]存在打卡不能删除");
  298. }
  299. projectStaffMapper.deleteByPrimaryKey(ps.getId());
  300. }
  301. }
  302. }
  303. private void addStaff( ProjectTaskListOut p, String[] split, List<ProjectStaff> projectStaffs) {
  304. Long company = deptService.selectCompanyByDeptId();
  305. for (String s : split) {
  306. s=s.trim();
  307. boolean flag = true;
  308. for (ProjectStaff ps : projectStaffs) {
  309. if (ps.getName().equals(s)) {
  310. flag = false;
  311. }
  312. }
  313. if (flag) {
  314. ProjectStaff newPs = new ProjectStaff();
  315. SysUser sysUser = userMapper.selectByNikeName(s,company);
  316. if (sysUser == null) {
  317. throw new ServiceException("[" + s + "]不存在");
  318. }
  319. newPs.setAid(sysUser.getUserId());
  320. newPs.setName(sysUser.getNickName());
  321. newPs.setPid(p.getId());
  322. projectStaffMapper.insertSelective(newPs);
  323. }
  324. }
  325. }
  326. @Override
  327. public void saveProjectTaskTianhe(String ids) {
  328. String[] split = ids.split(",");
  329. try {
  330. for (String id : split) {
  331. saveProjectText(Long.valueOf(id));
  332. Thread.sleep(1000);
  333. }
  334. } catch (InterruptedException e) {
  335. throw new RuntimeException("上链异常,请稍后再试");
  336. }
  337. }
  338. @Override
  339. public void saveProjectStaffRecordTianhe(String ids) {
  340. String[] split = ids.split(",");
  341. try {
  342. for (String id : split) {
  343. saveRecordsText(Long.valueOf(id));
  344. Thread.sleep(1000);
  345. }
  346. } catch (InterruptedException e) {
  347. throw new RuntimeException("上链异常,请稍后再试");
  348. }
  349. }
  350. @Override
  351. public void saveText(String content) {
  352. String address = getAddress();
  353. String operateId ="text_"+DateUtils.dateTimeNow();
  354. //文字导入
  355. String s = tianheService.seveText(address, content, operateId);
  356. JSONObject res = JSONObject.parseObject(s);
  357. Integer code = (Integer) res.get("code");
  358. String tianheCloudUrl=null;
  359. if (code== HttpStatus.OK.value()){
  360. try {
  361. sleep(1000);
  362. } catch (InterruptedException e) {
  363. throw new RuntimeException(e);
  364. }
  365. String certificate = tianheService.getCertificate(address, operateId);
  366. JSONObject certificateData = JSONObject.parseObject(certificate);
  367. Integer code2= (Integer) certificateData.get("code");
  368. if (code2==HttpStatus.OK.value()){
  369. log.debug(certificateData.toJSONString());
  370. tianheCloudUrl=certificateData.getString("data");
  371. }else {
  372. String msg = certificateData.getString("msg");
  373. log.error(msg);
  374. throw new RuntimeException(msg);
  375. }
  376. }else {
  377. String msg = res.getString("msg");
  378. log.error(msg);
  379. throw new RuntimeException(msg);
  380. }
  381. }
  382. public void saveRecordsText(Long id) throws InterruptedException {
  383. ProjectStaffRecord projectStaffRecord = projectStaffRecordMapper.selectByPrimaryKey(Long.valueOf(id));
  384. Map<String,Object> map=new HashMap<>();
  385. map.put("projectStaffRecord",projectStaffRecord);
  386. map.put("date", DateUtils.getTime());
  387. saveTianhe(map,null,null,projectStaffRecord);
  388. }
  389. public void saveProjectText(Long id) throws InterruptedException {
  390. ProjectTask projectTask = projectTaskMapper.selectByPrimaryKey(id);
  391. List<ProjectStaffRecord> projectStaffRecords = projectStaffRecordMapper.selectByPidAndAid(id, null);
  392. Map<String,Object> map=new HashMap<>();
  393. map.put("projectTask",projectTask);
  394. map.put("projectStaffRecords",projectStaffRecords);
  395. map.put("date", DateUtils.getTime());
  396. saveTianhe(map,projectTask,projectStaffRecords,null);
  397. }
  398. private void saveTianhe(Map<String, Object> map, ProjectTask projectTask,
  399. List<ProjectStaffRecord> projectStaffRecords,
  400. ProjectStaffRecord projectStaffRecord) throws InterruptedException {
  401. String json = JSONObject.toJSONString(map);
  402. String address = getAddress();
  403. String operateId =null;
  404. if (projectTask!=null){
  405. operateId = "yfdk_"+DateUtils.dateTimeNow();
  406. }else {
  407. operateId = "yfdk_records_"+DateUtils.dateTimeNow();
  408. }
  409. String docx = createDocx(json, operateId);
  410. File file = new File(docx);
  411. String s = tianheService.seveFile(address,operateId,file);
  412. //文字导入
  413. // String s = tianheService.seveText(address, json, operateId);
  414. JSONObject res = JSONObject.parseObject(s);
  415. Integer code = (Integer) res.get("code");
  416. String tianheCloudUrl=null;
  417. if (code== HttpStatus.OK.value()){
  418. sleep(1000);
  419. String certificate = tianheService.getCertificate(address, operateId);
  420. JSONObject certificateData = JSONObject.parseObject(certificate);
  421. Integer code2= (Integer) certificateData.get("code");
  422. if (code2==HttpStatus.OK.value()){
  423. log.debug(certificateData.toJSONString());
  424. tianheCloudUrl=certificateData.getString("data");
  425. if (projectTask!=null){
  426. if (StringUtils.isNotEmpty(tianheCloudUrl)){
  427. ProjectTask newPT=new ProjectTask();
  428. newPT.setTianheUrl(tianheCloudUrl);
  429. newPT.setId(projectTask.getId());
  430. projectTaskMapper.updateByPrimaryKeySelective(newPT);
  431. }
  432. pushProjectStaffRecord(projectStaffRecords);
  433. }
  434. if (projectStaffRecord!=null){
  435. ProjectStaffRecord newPSR=new ProjectStaffRecord();
  436. newPSR.setTianheUrl(tianheCloudUrl);
  437. newPSR.setId(projectStaffRecord.getId());
  438. projectStaffRecordMapper.updateByPrimaryKeySelective(newPSR);
  439. }
  440. FileUtils.deleteFile(docx);
  441. }else {
  442. String msg = certificateData.getString("msg");
  443. log.error(msg);
  444. throw new RuntimeException(msg);
  445. }
  446. }else {
  447. String msg = res.getString("msg");
  448. log.error(msg);
  449. throw new RuntimeException(msg);
  450. }
  451. }
  452. private String createDocx(String json, String operateId) {
  453. String url=profile+"/"+ operateId +".docx";
  454. XWPFDocument document = new XWPFDocument();
  455. XWPFParagraph paragraph = document.createParagraph();
  456. XWPFRun run = paragraph.createRun();
  457. run.setText(json);
  458. try {
  459. // 保存文档到指定路径
  460. FileOutputStream out = new FileOutputStream(url);
  461. document.write(out);
  462. out.close();
  463. System.out.println("Word文档已成功创建!");
  464. } catch (IOException e) {
  465. e.printStackTrace();
  466. } finally {
  467. // 关闭文档对象
  468. try {
  469. document.close();
  470. } catch (IOException e) {
  471. throw new RuntimeException(e);
  472. }
  473. }
  474. return url;
  475. }
  476. /**
  477. * 处理日志跟随项目上链
  478. */
  479. private void pushProjectStaffRecord(List<ProjectStaffRecord> projectStaffRecords) {
  480. int count=50;
  481. int i=0;
  482. List<ProjectStaffRecord> newList=new ArrayList<>();
  483. for (ProjectStaffRecord projectStaffRecord : projectStaffRecords) {
  484. i++;
  485. newList.add(projectStaffRecord);
  486. if (newList.size()==count||i==projectStaffRecords.size()){
  487. projectStaffRecordMapper.updateTianheType(newList);
  488. newList.clear();
  489. }
  490. }
  491. }
  492. private String getAddress() {
  493. String address = null;
  494. SysUser user = SecurityUtils.getLoginUser().getUser();
  495. SysUser sysUser = userMapper.selectUserById(user.getUserId());
  496. if (sysUser.getTianheId()==null){
  497. try {
  498. String userId=user.getUserId().toString();
  499. String s = tianheService.addUser( userId, "123456");
  500. JSONObject jsonObject = JSONObject.parseObject(s);
  501. JSONObject data = (JSONObject) jsonObject.get("data");
  502. JSONObject pubKey = (JSONObject) data.get("pubKey");
  503. address= (String) pubKey.get("address");
  504. }catch (Exception e ){
  505. log.error("天河账号创建失败!");
  506. throw new RuntimeException("天河账号创建失败");
  507. }
  508. if (address!=null){
  509. user.setTianheId(address);
  510. userMapper.updateUser(user);
  511. }
  512. }else {
  513. address=sysUser.getTianheId();
  514. }
  515. if (address==null){
  516. throw new ServiceException("天河账号不存在,请稍后再试");
  517. }
  518. return address;
  519. }
  520. @Override
  521. public Object getCompanyData(Integer deptId) {
  522. //获取部门信息
  523. SysDept sysDept = new SysDept();
  524. sysDept.setAncestors(deptId.toString());
  525. List<SysDept> sysDepts = sysDeptMapper.selectDeptList(sysDept);
  526. sysDepts.stream().forEach(System.out::println);
  527. //获取部门下的用户信息
  528. List<SysUser> sysUsers = new ArrayList<>();
  529. List<ProjectTask> projectTasks=new ArrayList<>();
  530. sysDepts.stream().forEach(sysDept1 -> {
  531. sysUsers.addAll(userMapper.selectByDeptId(sysDept1.getDeptId()));
  532. });
  533. sysUsers.stream().forEach(sysUser -> {
  534. projectTasks.addAll(projectTaskMapper.selectByUserId(sysUser.getUserId()));
  535. });
  536. Map<String,Object> map=new HashMap();
  537. map.put("projectTasks",projectTasks);
  538. map.put("sysUsers",sysUsers);
  539. map.put("sysDepts",sysDepts);
  540. return map;
  541. }
  542. }