From 3e9a6da99aae968123ee7bca352fc08becd7f1f2 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 29 八月 2024 17:29:21 +0800
Subject: [PATCH] 工单过程图接口更换

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
index e716c53..aa4c25c 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
@@ -1,6 +1,7 @@
 package com.ycl.platform.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ycl.platform.domain.entity.Platform;
 import com.ycl.platform.domain.form.PlatformForm;
@@ -18,6 +19,8 @@
 import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -43,12 +46,18 @@
     public Result add(PlatformForm form) {
         Platform entity = PlatformForm.getEntityByForm(form, null);
         entity.setParentId(0);
+        Date now = new Date();
+        entity.setCreateTime(now);
+        entity.setUpdateTime(now);
         baseMapper.insert(entity);
         if (! CollectionUtils.isEmpty(form.getDeployList())) {
             List<Platform> childList = form.getDeployList().stream().map(deploy -> {
                 Platform child = new Platform();
                 BeanUtils.copyProperties(deploy, child);
+                child.setPlatformName(entity.getPlatformName());
                 child.setParentId(entity.getId());
+                child.setCreateTime(now);
+                child.setUpdateTime(now);
                 return child;
             }).collect(Collectors.toList());
             this.saveBatch(childList);
@@ -101,9 +110,18 @@
      */
     @Override
     public Result page(PlatformQuery query) {
-        IPage<PlatformVO> page = PageUtil.getPage(query, PlatformVO.class);
-        baseMapper.getPage(page, query);
-        return Result.ok().data(page.getRecords()).total(page.getTotal());
+        List<PlatformVO> list = baseMapper.getPage(query);
+        List<PlatformVO> parentList = list.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList());
+        List<PlatformVO> resultList = new ArrayList<>(4);
+        for (PlatformVO parent : parentList) {
+            List<PlatformVO> childList = list.stream().filter(item -> item.getParentId().equals(parent.getId())).collect(Collectors.toList());
+
+            parent.setChildNum(childList.size());
+            resultList.add(parent);
+            resultList.addAll(childList);
+        }
+        // 鍓嶇涓嶇敤灞曠ず鍒嗛〉
+        return Result.ok().data(resultList).total(0);
     }
 
     /**

--
Gitblit v1.8.0