From acf90ad8e6bea592124541324467360cef565ff5 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 06 二月 2026 14:14:55 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbom_dianjiang

---
 server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 105 insertions(+), 10 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
index 0ce16ed..bc617e2 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -6,6 +6,7 @@
 import com.doumee.core.constants.Constants;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
+import com.doumee.core.iPass.IPass;
 import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
@@ -15,6 +16,7 @@
 import com.doumee.dao.business.model.Category;
 import com.doumee.dao.business.model.Multifile;
 import com.doumee.dao.system.model.SystemUser;
+import com.doumee.dao.vo.ZhanQuVO;
 import com.doumee.service.business.CategoryService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -23,6 +25,7 @@
 import com.github.yulichang.base.MPJBaseMapper;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.math3.analysis.function.Log;
 import org.apache.shiro.SecurityUtils;
 import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,10 +33,12 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * 鍒嗙被淇℃伅琛⊿ervice瀹炵幇
@@ -62,6 +67,17 @@
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        if(Constants.equalsInteger(category.getType(),Constants.ZERO)){
+            if(categoryMapper.selectCount(new QueryWrapper<Category>().lambda()
+                    .eq(Category::getType,Constants.ZERO)
+                    .eq(Category::getDetail,category.getDetail())
+                    .eq(Category::getDeleted,Constants.ZERO)
+            )>Constants.ZERO){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇ユ垬鍖虹紪鐮佸凡瀛樺湪");
+            }
+        }
+
+
         category.setDeleted(Constants.ZERO);
         category.setCreateTime(new Date());
         category.setCreateUser(loginUserInfo.getId());
@@ -127,12 +143,31 @@
         ){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
+        if(Constants.equalsInteger(category.getType(),Constants.ZERO)){
+            if(categoryMapper.selectCount(new QueryWrapper<Category>().lambda()
+                    .eq(Category::getType,Constants.ZERO)
+                    .eq(Category::getDetail,category.getDetail())
+                    .eq(Category::getDeleted,Constants.ZERO)
+                    .ne(Category::getId,category.getId())
+            )>Constants.ZERO){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"璇ユ垬鍖虹紪鐮佸凡瀛樺湪");
+            }
+        }
         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         category.setUpdateTime(new Date());
         category.setIsFixed(null);
         category.setUpdateUser(loginUserInfo.getId());
         categoryMapper.updateById(category);
+
+        if(Objects.isNull(category.getSortnum())){
+            categoryMapper.update(null,new UpdateWrapper<Category>().lambda()
+                    .set(Category::getSortnum,null)
+                    .eq(Category::getId,category.getId())
+            );
+        }
         dealBatchMultiFiles(category, category.getFileList(), loginUserInfo,true);
+
+
     }
     @Override
     public void updateStatus(Category category) {
@@ -180,6 +215,8 @@
     public List<Category> findList(Category category) {
         category.setDeleted(Constants.ZERO);
         QueryWrapper<Category> wrapper = new QueryWrapper<>(category);
+        wrapper.lambda().orderByAsc(Category::getSortnum);
+        wrapper.lambda().orderByAsc(Category::getId);
         return categoryMapper.selectList(wrapper);
     }
   
@@ -190,7 +227,7 @@
         Utils.MP.blankToNull(pageWrap.getModel());
         pageWrap.getModel().setDeleted(Constants.ZERO);
         queryWrapper.selectAll(Category.class)
-                .selectAs(SystemUser::getUsername, Category::getUpdateUserName)
+                .selectAs(SystemUser::getRealname, Category::getUpdateUserName)
                 .leftJoin(SystemUser.class,SystemUser::getId,Category::getUpdateUser);
         if (pageWrap.getModel().getId() != null) {
             queryWrapper.eq(Category::getId, pageWrap.getModel().getId());
@@ -234,6 +271,7 @@
             queryWrapper.eq(Category::getIsFixed, pageWrap.getModel().getIsFixed());
         }
         queryWrapper.orderByAsc(Category::getSortnum);
+        queryWrapper.orderByAsc(Category::getId);
         PageData<Category> result =PageData.from(categoryMapper.selectJoinPage(page, Category.class,queryWrapper));
         if(result!=null && result.getRecords()!=null){
             String path  = systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.RESOURCE_PATH).getCode()
@@ -277,20 +315,19 @@
     }
 
     @Override
-    public List<Category> getCategoryList(Integer type){
+    public List<Category> getCategoryList(Integer type,Integer rank){
         List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda().eq(Category::getDeleted,Constants.ZERO).eq(Category::getStatus,Constants.ZERO)
                 .eq(Objects.nonNull(type),Category::getType,type)
+                .apply(Objects.nonNull(rank)&&Constants.equalsInteger(rank,Constants.ONE)," id in ( " +
+                        " select m.obj_id from multifile m where m.ISDELETED = 0 and m.OBJ_TYPE = 0  " +
+                        " ) ")
                 .orderByAsc(Category::getSortnum)
+                .orderByAsc(Category::getId)
         );
         if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryList)){
-            String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode()
-                    +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.CATEGORY_FILES).getCode();
-            for (Category category:categoryList) {
-                if(StringUtils.isNotBlank(category.getIcon())){
-                    category.setIconFull(path + category.getIcon());
-                }
-                if(Constants.equalsInteger(category.getType(),Constants.ONE) ){
-                    initMultifileList(category);
+            for(Category cate : categoryList){
+                if(Constants.equalsInteger(cate.getType(),Constants.ONE) ){
+                    initMultifileList(cate);
                 }
             }
         }
@@ -298,4 +335,62 @@
     }
 
 
+    @Override
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+    public void syncZhanQu() throws IOException {
+        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        IPass iPass = new IPass();
+        List<ZhanQuVO> l =  iPass.getIPassZhanquList(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.IPASS_LOGIN_ACCOUNT).getCode(),
+                systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.IPASS_LOGIN_PSD).getCode(),
+                systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.IPASS_TOKEN_URL).getCode(),
+                systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.IPASS_ZHANQU_URL).getCode()
+        );
+        List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda()
+                .eq(Category::getType,Constants.ZERO)
+                .eq(Category::getDeleted,Constants.ZERO)
+        );
+        List<Category> updList = new ArrayList<>();
+        List<Category> addList = new ArrayList<>();
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(l)){
+            for (ZhanQuVO zhanQuVO:l) {
+                Category category = this.vaildData(zhanQuVO,categoryList,loginUserInfo);
+                if(Objects.isNull(category.getId())){
+                    addList.add(category);
+                }else{
+                    updList.add(category);
+                }
+            }
+        }
+        if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(addList)) {
+            categoryMapper.insertOrUpdate(addList);
+        }
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(updList)){
+            categoryMapper.insertOrUpdate(updList);
+        }
+    }
+
+
+    public Category vaildData(ZhanQuVO zhanQuVO , List<Category> categoryList, LoginUserInfo userInfo) {
+        Category returnData = new Category();
+        for (Category category:categoryList) {
+            returnData.setUpdateUser(userInfo.getId());
+            returnData.setUpdateTime(new Date());
+            if(category.getDetail().equals(zhanQuVO.getNodeCode())){
+                returnData = category   ;
+                returnData.setName(zhanQuVO.getNodeName());
+                return returnData;
+            }
+        }
+        returnData.setDetail(zhanQuVO.getNodeCode());
+        returnData.setCreateTime(new Date());
+        returnData.setDeleted(Constants.ZERO);
+        returnData.setStatus(zhanQuVO.getNodeStatus().equals("Y")?Constants.ZERO:Constants.ONE);
+        returnData.setName(zhanQuVO.getNodeName());
+        returnData.setCreateUser(userInfo.getId());
+        returnData.setType(Constants.ZERO);
+        returnData.setIsFixed(Constants.ZERO);
+        return returnData;
+    }
+
+
 }

--
Gitblit v1.9.3