From f9feae49eee21286708bcef1cea91be34d9e9241 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期二, 25 十一月 2025 09:04:59 +0800
Subject: [PATCH] 修改新增
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/CatalogueServiceImpl.java | 74 +++++++++++++++++++++++++++++++++++--
1 files changed, 70 insertions(+), 4 deletions(-)
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CatalogueServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CatalogueServiceImpl.java
index f41451a..40c4f0f 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CatalogueServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CatalogueServiceImpl.java
@@ -1,8 +1,10 @@
package com.gkhy.exam.system.service.impl;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
+import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.*;
import com.gkhy.exam.system.domain.req.CatalogueDataReq;
@@ -11,14 +13,17 @@
import com.gkhy.exam.system.domain.vo.CatalogueVo;
import com.gkhy.exam.system.mapper.CatalogueMapper;
import com.gkhy.exam.system.mapper.CompanyIndustryTemplateMapper;
+import com.gkhy.exam.system.mapper.ProductItemMapper;
import com.gkhy.exam.system.mapper.SysCompanyMapper;
import com.gkhy.exam.system.service.CatalogueService;
+import com.gkhy.exam.system.service.ProjectDocumentService;
import com.gkhy.exam.system.service.SysCompanyService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
+import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -32,6 +37,10 @@
private SysCompanyMapper sysCompanyMapper;
@Autowired
private CompanyIndustryTemplateMapper companyIndustryTemplateMapper;
+ @Autowired
+ private ProductItemMapper productItemMapper;
+ @Autowired
+ private ProjectDocumentService projectDocumentService;
/**
* 目录管理
@@ -52,7 +61,7 @@
private List<CatalogueVo> getchildren(CatalogueVo catalogueVo, List<CatalogueVo> catalogueVos) {
List<CatalogueVo> catalogueCharlden = new ArrayList<>();
for (CatalogueVo catalogue : catalogueVos) {
- if (catalogueVo.getId() == catalogue.getParentId()){
+ if (catalogueVo.getId().equals(catalogue.getParentId())){
catalogueCharlden.add(catalogue);
}
}
@@ -65,8 +74,13 @@
@Override
public CommonResult insertCatalogue(Catalogue catalogue) {
+ if (catalogue.getType()==2||catalogue.getType()==3){
+ if (catalogue.getCompanyId()==null){
+ throw new ApiException("企业id不能为空");
+ }
+ }
catalogue.setCreateBy(SecurityUtils.getUsername());
- catalogue.setCreateTime(LocalDate.now());
+ catalogue.setCreateTime(LocalDateTime.now());
int insert = catalogueMapper.insert(catalogue);
if (insert>0){
return CommonResult.success();
@@ -77,7 +91,7 @@
@Override
public CommonResult updateCatalogue(Catalogue catalogue) {
catalogue.setUpdateBy(SecurityUtils.getUsername());
- catalogue.setUpdateTime(LocalDate.now());
+ catalogue.setUpdateTime(LocalDateTime.now());
int i = catalogueMapper.updateById(catalogue);
if (i>0){
return CommonResult.success();
@@ -97,7 +111,7 @@
Catalogue catalogue = new Catalogue();
catalogue.setId(catalogueId);
catalogue.setDelFlag(2);
- catalogue.setUpdateTime(LocalDate.now());
+ catalogue.setUpdateTime(LocalDateTime.now());
catalogue.setUpdateBy(SecurityUtils.getUsername());
int i = catalogueMapper.updateById(catalogue);
if (i>0){
@@ -232,4 +246,56 @@
public CommonResult selectCatalogueDataFileList(CatalogueReq catalogueReq) {
return CommonResult.success(catalogueMapper.selectCatalogueDataFile(catalogueReq.getCompanyId(),catalogueReq.getCatalogueId()));
}
+
+ @Override
+ public CommonResult copyCatalogue(List<CatalogueVo> catalogue) {
+ Integer companyId = catalogue.get(0).getCompanyId();
+ Integer type = catalogue.get(0).getType();
+ catalogueMapper.delete(Wrappers.<Catalogue>lambdaQuery().eq(Catalogue::getCompanyId,companyId).eq(Catalogue::getType,catalogue.get(0).getType()));
+ for (CatalogueVo catalogueVo : catalogue) {
+ Catalogue catalogue1 = new Catalogue();
+ BeanUtils.copyProperties(catalogueVo,catalogue1);
+ catalogueMapper.insertCatalogue(catalogue1);
+ List<CatalogueVo> children = catalogueVo.getChildren();
+ if (children.size()>0){
+ saveCatalogue(children,catalogue1);
+ }
+ }
+ productItemMapper.deletedByCompanyId(companyId,type.equals(2)?1:2);
+ return CommonResult.success();
+ }
+
+ @Override
+ public CommonResult selectCatalogueDocumentList(CatalogueReq catalogueReq) {
+ List<CatalogueVo> catalogueVos = catalogueMapper.selectCatalogueList(catalogueReq);
+ for (CatalogueVo catalogueVo : catalogueVos) {
+ List<ProjectDocument> projectDocuments = projectDocumentService.selectList(catalogueVo.getCompanyId(), catalogueReq.getItemId(), catalogueVo.getId());
+ catalogueVo.setProjectDocuments(projectDocuments);
+ }
+
+ List<CatalogueVo> collect = catalogueVos.stream().filter(catalogueVo -> catalogueVo.getParentId() == 0).collect(Collectors.toList());
+ for (CatalogueVo catalogueVo : collect) {
+ List<CatalogueVo> getchildren = getchildren(catalogueVo, catalogueVos);
+ catalogueVo.setChildren(getchildren);
+ }
+ return CommonResult.success(collect);
+ }
+
+ private void saveCatalogue(List<CatalogueVo> children,Catalogue catalogue) {
+ for (CatalogueVo child : children) {
+ Catalogue catalogue1 = new Catalogue();
+ BeanUtils.copyProperties(child,catalogue1);
+ catalogue1.setParentId(catalogue.getId());
+ catalogue1.setCompanyId(catalogue.getCompanyId());
+ catalogueMapper.insertCatalogue(catalogue1);
+ List<CatalogueVo> children1 = child.getChildren();
+ if (children1.size()>0){
+ saveCatalogue(children1,catalogue1);
+ }else {
+ continue;
+ }
+ }
+ }
+
+
}
--
Gitblit v1.9.2