From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/ProjectGanttController.java |  302 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 302 insertions(+), 0 deletions(-)

diff --git a/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/ProjectGanttController.java b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/ProjectGanttController.java
new file mode 100644
index 0000000..21078e8
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-controller/src/main/java/jnpf/controller/ProjectGanttController.java
@@ -0,0 +1,302 @@
+package jnpf.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import io.swagger.v3.oas.annotations.Parameter;
+import jnpf.annotation.EncryptApi;
+import jnpf.base.controller.SuperController;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
+import jnpf.constant.MsgCode;
+import jnpf.exception.DataException;
+import jnpf.model.projectgantt.*;
+import jnpf.permission.entity.UserEntity;
+import jnpf.service.ProjectGanttService;
+import jnpf.entity.ProjectGanttEntity;
+import jnpf.util.JsonUtil;
+import jnpf.base.ActionResult;
+import jnpf.base.vo.ListVO;
+import jnpf.base.Page;
+import jnpf.util.UploaderUtil;
+import jnpf.util.treeutil.ListToTreeUtil;
+import jnpf.util.treeutil.SumTree;
+import jnpf.util.treeutil.TreeDotUtils;
+import jnpf.permission.UserApi;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import jakarta.validation.Valid;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 椤圭洰璁″垝
+ *
+ * @author JNPF寮�鍙戝钩鍙扮粍
+ * @version V3.1.0
+ * @copyright 寮曡繄淇℃伅鎶�鏈湁闄愬叕鍙革紙https://www.jnpfsoft.com锛�
+ * @date 2019骞�9鏈�26鏃� 涓婂崍9:18
+ */
+@Tag(name = "椤圭洰璁″垝", description = "ProjectGantt")
+@RestController
+@RequestMapping("/ProjectGantt")
+@RequiredArgsConstructor
+public class ProjectGanttController extends SuperController<ProjectGanttService, ProjectGanttEntity> {
+
+    private final ProjectGanttService projectGanttService;
+
+    private final UserApi usersApi;
+
+
+    /**
+     * 椤圭洰鍒楄〃
+     *
+     * @param page 鍒嗛〉妯″瀷
+     * @return
+     */
+    @Operation(summary = "鑾峰彇椤圭洰绠$悊鍒楄〃")
+    @GetMapping
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<ListVO<ProjectGanttListVO>> list(Page page) {
+        List<ProjectGanttEntity> data = projectGanttService.getList(page);
+        List<ProjectGanttListVO> list = JsonUtil.getJsonToList(data, ProjectGanttListVO.class);
+        //鑾峰彇鐢ㄦ埛缁欓」鐩弬涓庝汉鍛樺垪琛ㄨ祴鍊�
+        List<String> userId = new ArrayList<>();
+        list.forEach(t -> {
+            String[] ids = t.getManagerIds().split(",");
+            Collections.addAll(userId, ids);
+        });
+        List<UserEntity> userList = usersApi.getUserName(userId);
+        for (ProjectGanttListVO vo : list) {
+            List<String> managerList = new ArrayList<>();
+            Collections.addAll(managerList, vo.getManagerIds().split(","));
+            List<UserEntity> user = userList.stream().filter(t -> managerList.contains(t.getId())).collect(Collectors.toList());
+            List<ProjectGanttManagerIModel> list1 = new ArrayList<>();
+            user.forEach(t -> {
+                ProjectGanttManagerIModel model1 = new ProjectGanttManagerIModel();
+                model1.setAccount(t.getRealName() + "/" + t.getAccount());
+                model1.setHeadIcon(UploaderUtil.uploaderImg(t.getHeadIcon()));
+                list1.add(model1);
+            });
+            vo.setManagersInfo(list1);
+        }
+        ListVO<ProjectGanttListVO> listVO = new ListVO<>();
+        listVO.setList(list);
+        return ActionResult.success(listVO);
+    }
+
+    /**
+     * 浠诲姟鍒楄〃
+     *
+     * @param page 鍒嗛〉妯″瀷
+     * @param projectId 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鑾峰彇椤圭洰浠诲姟鍒楄〃")
+    @GetMapping("/{projectId}/Task")
+    @Parameter(name = "projectId", description = "涓婚敭",required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<ListVO<ProjectGanttTaskTreeVO>> taskList(Page page, @PathVariable("projectId") String projectId) {
+        List<ProjectGanttEntity> data = projectGanttService.getTaskList(projectId);
+        List<ProjectGanttEntity> dataAll = data;
+        if (!StringUtils.isEmpty(page.getKeyword())) {
+            data = data.stream().filter(t -> String.valueOf(t.getFullName()).contains(page.getKeyword()) || String.valueOf(t.getEnCode()).contains(page.getKeyword())).collect(Collectors.toList());
+        }
+        List<ProjectGanttEntity> list = JsonUtil.getJsonToList(ListToTreeUtil.treeWhere(data, dataAll), ProjectGanttEntity.class);
+        List<ProjectGanttTreeModel> treeList = JsonUtil.getJsonToList(list, ProjectGanttTreeModel.class);
+        List<SumTree<ProjectGanttTreeModel>> trees = TreeDotUtils.convertListToTreeDot(treeList);
+        List<ProjectGanttTaskTreeVO> listVO = JsonUtil.getJsonToList(trees, ProjectGanttTaskTreeVO.class);
+        ListVO<ProjectGanttTaskTreeVO> vo = new ListVO<>();
+        vo.setList(listVO);
+        return ActionResult.success(vo);
+    }
+
+    /**
+     * 浠诲姟鏍戝舰
+     *
+     * @param projectId 涓婚敭
+     * @param id 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鑾峰彇椤圭洰璁″垝浠诲姟鏍戝舰锛堟柊寤轰换鍔★級")
+    @GetMapping("/{projectId}/Task/Selector/{id}")
+    @Parameter(name = "projectId", description = "涓婚敭", required = true)
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<ListVO<ProjectGanttTaskTreeVO>> taskTreeView(@PathVariable("projectId") String projectId, @PathVariable("id") String id) {
+        List<ProjectGanttTaskTreeModel> treeList = new ArrayList<>();
+        List<ProjectGanttEntity> data = projectGanttService.getTaskList(projectId);
+        if (!"0".equals(id)) {
+            //涓婄骇涓嶈兘閫夋嫨鑷繁
+            data.remove(projectGanttService.getInfo(id));
+        }
+        for (ProjectGanttEntity entity : data) {
+            ProjectGanttTaskTreeModel treeModel = new ProjectGanttTaskTreeModel();
+            treeModel.setId(entity.getId());
+            treeModel.setFullName(entity.getFullName());
+            treeModel.setParentId(entity.getParentId());
+            treeList.add(treeModel);
+        }
+        List<SumTree<ProjectGanttTaskTreeModel>> trees = TreeDotUtils.convertListToTreeDotFilter(treeList);
+        List<ProjectGanttTaskTreeVO> listVO = JsonUtil.getJsonToList(trees, ProjectGanttTaskTreeVO.class);
+        ListVO<ProjectGanttTaskTreeVO> vo = new ListVO<>();
+        vo.setList(listVO);
+        return ActionResult.success(vo);
+    }
+
+    /**
+     * 淇℃伅
+     *
+     * @param id 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鑾峰彇椤圭洰璁″垝淇℃伅")
+    @GetMapping("/{id}")
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<ProjectGanttInfoVO> info(@PathVariable("id") String id) throws DataException {
+        ProjectGanttEntity entity = projectGanttService.getInfo(id);
+        ProjectGanttInfoVO vo = JsonUtil.getJsonToBeanEx(entity, ProjectGanttInfoVO.class);
+        return ActionResult.success(vo);
+    }
+
+    /**
+     * 淇℃伅
+     *
+     * @param id 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鑾峰彇椤圭洰璁″垝淇℃伅")
+    @GetMapping("Task/{id}")
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<ProjectGanttTaskInfoVO> taskInfo(@PathVariable("id") String id) throws DataException {
+        ProjectGanttEntity entity = projectGanttService.getInfo(id);
+        ProjectGanttTaskInfoVO vo = JsonUtil.getJsonToBeanEx(entity, ProjectGanttTaskInfoVO.class);
+        return ActionResult.success(vo);
+    }
+
+
+    /**
+     * 鍒犻櫎
+     *
+     * @param id 涓婚敭
+     * @return
+     */
+    @Operation(summary = "鍒犻櫎椤圭洰璁″垝/浠诲姟")
+    @DeleteMapping("/{id}")
+    @Parameter(name = "id", description = "涓婚敭",required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<Object> delete(@PathVariable("id") String id) {
+        if (projectGanttService.allowDelete(id)) {
+            ProjectGanttEntity entity = projectGanttService.getInfo(id);
+            if (entity != null) {
+                projectGanttService.delete(entity);
+                return ActionResult.success(MsgCode.SU003.get());
+            }
+            return ActionResult.fail(MsgCode.FA003.get());
+        } else {
+            return ActionResult.fail(MsgCode.ETD112.get());
+        }
+    }
+
+    /**
+     * 鍒涘缓
+     *
+     * @param projectGanttCrForm 椤圭洰妯″瀷
+     * @return
+     */
+    @EncryptApi
+    @Operation(summary = "娣诲姞椤圭洰璁″垝")
+    @PostMapping
+    @Parameter(name = "projectGanttCrForm", description = "椤圭洰妯″瀷", required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<Object> create(@RequestBody @Valid ProjectGanttCrForm projectGanttCrForm) {
+        ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttCrForm, ProjectGanttEntity.class);
+        entity.setType(1);
+        entity.setParentId("0");
+        if (projectGanttService.isExistByFullName(projectGanttCrForm.getFullName(), entity.getId())) {
+            return ActionResult.fail(MsgCode.EXIST001.get());
+        }
+        if (projectGanttService.isExistByEnCode(projectGanttCrForm.getEnCode(), entity.getId())) {
+            return ActionResult.fail(MsgCode.EXIST002.get());
+        }
+        projectGanttService.create(entity);
+        return ActionResult.success(MsgCode.SU001.get());
+    }
+
+    /**
+     * 缂栬緫
+     *
+     * @param id                 涓婚敭
+     * @param projectGanttUpForm 椤圭洰妯″瀷
+     * @return
+     */
+    @Operation(summary = "淇敼椤圭洰璁″垝")
+    @PutMapping("/{id}")
+    @Parameter(name = "id", description = "涓婚敭", required = true)
+    @Parameter(name = "projectGanttUpForm", description = "椤圭洰妯″瀷", required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<Object> update(@PathVariable("id") String id, @RequestBody @Valid ProjectGanttUpForm projectGanttUpForm) {
+        ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttUpForm, ProjectGanttEntity.class);
+        if (projectGanttService.isExistByFullName(projectGanttUpForm.getFullName(), id)) {
+            return ActionResult.fail(MsgCode.EXIST001.get());
+        }
+        if (projectGanttService.isExistByEnCode(projectGanttUpForm.getEnCode(), id)) {
+            return ActionResult.fail(MsgCode.EXIST002.get());
+        }
+        boolean flag = projectGanttService.update(id, entity);
+        if (!flag) {
+            return ActionResult.fail(MsgCode.FA002.get());
+        }
+        return ActionResult.success(MsgCode.SU004.get());
+    }
+
+
+    /**
+     * 鍒涘缓
+     *
+     * @param projectGanttTsakCrForm 椤圭洰妯″瀷
+     * @return
+     */
+    @Operation(summary = "娣诲姞椤圭洰浠诲姟")
+    @PostMapping("/Task")
+    @Parameter(name = "projectGanttTsakCrForm", description = "椤圭洰妯″瀷",required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<Object> createTask(@RequestBody @Valid ProjectGanttTsakCrForm projectGanttTsakCrForm) {
+        ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttTsakCrForm, ProjectGanttEntity.class);
+        entity.setType(2);
+        if (projectGanttService.isExistByFullName(projectGanttTsakCrForm.getFullName(), entity.getId())) {
+            return ActionResult.fail(MsgCode.EXIST001.get());
+        }
+        projectGanttService.create(entity);
+        return ActionResult.success(MsgCode.SU001.get());
+    }
+
+    /**
+     * 缂栬緫
+     *
+     * @param id                     涓婚敭
+     * @param projectGanttTsakCrForm 椤圭洰妯″瀷
+     * @return
+     */
+    @Operation(summary = "淇敼椤圭洰浠诲姟")
+    @PutMapping("/Task/{id}")
+    @Parameter(name = "projectGanttTsakCrForm", description = "椤圭洰妯″瀷",required = true)
+    @Parameter(name = "id", description = "涓婚敭",required = true)
+    @SaCheckPermission("extend.projectGantt")
+    public ActionResult<Object> updateTask(@PathVariable("id") String id, @RequestBody @Valid ProjectGanttTsakUpForm projectGanttTsakCrForm) {
+        ProjectGanttEntity entity = JsonUtil.getJsonToBean(projectGanttTsakCrForm, ProjectGanttEntity.class);
+        if (projectGanttService.isExistByFullName(projectGanttTsakCrForm.getFullName(), id)) {
+            return ActionResult.fail(MsgCode.EXIST001.get());
+        }
+        boolean flag = projectGanttService.update(id, entity);
+        if (!flag) {
+            return ActionResult.fail(MsgCode.FA002.get());
+        }
+        return ActionResult.success(MsgCode.SU004.get());
+    }
+
+}

--
Gitblit v1.8.0