Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/dev' into dev

24282 1 rok pred
rodič
commit
6b61d15810

+ 19 - 0
hx-file/src/main/java/com/fjhx/file/service/FileInfoService.java

@@ -36,6 +36,15 @@ public interface FileInfoService extends BaseService<FileInfo> {
     void saveFile(List<ObsFile> obsFileList, Long businessId, Integer businessType);
 
     /**
+     * 保存文件
+     *
+     * @param obsFileList  文件列表
+     * @param businessId   业务id
+     * @param businessType 业务文件类型
+     */
+    void saveAllFile(List<ObsFile> obsFileList, Long businessId, Integer businessType);
+
+    /**
      * 更新文件
      *
      * @param obsFileList  文件列表
@@ -59,4 +68,14 @@ public interface FileInfoService extends BaseService<FileInfo> {
      */
     void removeFile(Long businessId);
 
+    void copyFileAndSave(List<ObsFile> fileList, Long businessId, Integer businessType);
+
+
+    /**
+     * 交换业务ID
+     * @param  newBusinessId 新业务id
+     * @param  oldBusinessId 旧业务id
+     */
+    void exchangeBusinessId(Long oldBusinessId,Long newBusinessId);
+
 }

+ 82 - 1
hx-file/src/main/java/com/fjhx/file/service/impl/FileInfoServiceImpl.java

@@ -7,6 +7,11 @@ import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.file.entity.*;
 import com.fjhx.file.mapper.FileInfoMapper;
@@ -20,7 +25,9 @@ import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.io.File;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -139,7 +146,6 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
     }
 
     /**
-     *
      * @param obsFileList  文件列表
      * @param businessId   业务id
      * @param businessType 业务文件类型
@@ -162,6 +168,27 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
     }
 
     /**
+     * 保存文件--直接插入
+     * @param obsFileList  文件列表
+     * @param businessId   业务id
+     * @param businessType 业务文件类型
+     */
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    public void saveAllFile(List<ObsFile> obsFileList, Long businessId, Integer businessType) {
+        if (obsFileList == null || obsFileList.size() == 0) {
+            return;
+        }
+        List<FileInfo> fileInfoList = BeanUtil.copyToList(obsFileList, FileInfo.class);
+        for (FileInfo fileInfo : fileInfoList) {
+            fileInfo.setId(IdWorker.getId());
+            fileInfo.setBusinessId(businessId);
+            fileInfo.setBusinessType(businessType);
+        }
+        this.saveBatch(fileInfoList);
+    }
+
+    /**
      *
      * @param obsFileList  文件列表
      * @param businessId   业务id
@@ -210,10 +237,64 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
     }
 
     /**
+     * 交换业务ID
+     * @param  oldBusinessId 旧业务id
+     * @param  newBusinessId 新业务id
+     */
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void exchangeBusinessId(Long oldBusinessId, Long newBusinessId) {
+        List<FileInfo> oldFile = this.list(Wrappers.<FileInfo>query().lambda().select(FileInfo::getId).eq(FileInfo::getBusinessId,oldBusinessId));
+        List<FileInfo> newFile = this.list(Wrappers.<FileInfo>query().lambda().select(FileInfo::getId).eq(FileInfo::getBusinessId,newBusinessId));
+        if(CollectionUtils.isNotEmpty(oldFile)){
+            List<Long> ids = oldFile.stream().map(FileInfo::getId).collect(Collectors.toList());
+            this.update(Wrappers.<FileInfo>update().lambda().set(FileInfo::getBusinessId,newBusinessId).in(FileInfo::getId,ids));
+        }
+        if(CollectionUtils.isNotEmpty(newFile)){
+            List<Long> ids = newFile.stream().map(FileInfo::getId).collect(Collectors.toList());
+            this.update(Wrappers.<FileInfo>update().lambda().set(FileInfo::getBusinessId,oldBusinessId).in(FileInfo::getId,ids));
+        }
+    }
+
+    /**
      * 获取oss链接客户端
      */
     private ObsClient getObsClient() {
         return new ObsClient(ak, sk, endPoint);
     }
 
+    /**
+     * 判断文件是否已经绑定业务 是将文件复制一份并保存
+     *
+     * @param fileList     文件列表
+     * @param businessId   业务id
+     * @param businessType 业务文件类型
+     */
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    public void copyFileAndSave(List<ObsFile> fileList, Long businessId, Integer businessType) {
+        if (ObjectUtils.isEmpty(fileList)) {
+            return;
+        }
+        List<Long> fids = fileList.stream().map(ObsFile::getId).collect(Collectors.toList());
+        Map<Long, FileInfo> fileInfoMap = this.mapKEntity(FileInfo::getId, q -> q.in(FileInfo::getId, fids));
+        List<FileInfo> newFileInfo = new ArrayList<>();
+        for (ObsFile obsFile : fileList) {
+            FileInfo fileInfo = fileInfoMap.get(obsFile.getId());
+            if (ObjectUtils.isEmpty(fileInfo)) {
+                continue;
+            }
+            //如果文件已经有业务id了 且业务id不是当前业务id 就将文件复制一份
+            if (ObjectUtils.isNotEmpty(fileInfo.getBusinessId()) && !businessId.equals(fileInfo.getBusinessId())) {
+                long id = IdWorker.getId();
+                fileInfo.setId(id);
+                obsFile.setId(id);
+                newFileInfo.add(fileInfo);
+            }
+        }
+        this.saveBatch(newFileInfo);
+        saveFile(fileList, businessId, businessType);
+    }
+
 }

+ 39 - 0
hx-file/src/main/java/com/fjhx/file/utils/ObsFileUtil.java

@@ -67,6 +67,24 @@ public class ObsFileUtil {
     }
 
     /**
+     * 交换ID
+     * @param oldBusinessId   旧业务id
+     * @param newBusinessId 新业务id
+     */
+    public static void exchangeBusinessId(Long oldBusinessId,Long newBusinessId) {
+        fileInfoService.exchangeBusinessId(oldBusinessId, newBusinessId);
+    }
+
+    /**
+     * 保存所有文件
+     * @param obsFileList
+     * @param businessId
+     */
+    public static void saveAllFile(List<ObsFile> obsFileList, Long businessId,Integer type) {
+        fileInfoService.saveAllFile(obsFileList, businessId,type);
+    }
+
+    /**
      * 删除文件
      *
      * @param businessId 业务id
@@ -88,4 +106,25 @@ public class ObsFileUtil {
         return fileInfoService.getList(dto);
     }
 
+    /**
+     * 判断文件是否已经绑定业务 是将文件复制一份并保存
+     *
+     * @param fileList   文件列表
+     * @param businessId 业务id
+     */
+    public static void copyFileAndSave(List<ObsFile> fileList, Long businessId) {
+        copyFileAndSave(fileList, businessId, defaultFileType);
+    }
+
+    /**
+     * 判断文件是否已经绑定业务 是将文件复制一份并保存
+     *
+     * @param fileList     文件列表
+     * @param businessId   业务id
+     * @param businessType 业务文件类型
+     */
+    public static void copyFileAndSave(List<ObsFile> fileList, Long businessId, Integer businessType) {
+        fileInfoService.copyFileAndSave(fileList, businessId, businessType);
+    }
+
 }

+ 7 - 2
hx-kd100/src/main/java/com/fjhx/kd100/util/KD100Util.java

@@ -91,8 +91,13 @@ public class KD100Util {
         if (Objects.equals(message, "ok")) {
             Integer state = result.getState();
             if (!Objects.equals(state, KD100Status.STATUS_3)) {
-                // 如果不是已签收状态,则开启订阅(物流状态跟踪并推送)
-                KD100Util.subscribe(com, num);
+                //判断是否已经订阅过 防止重复订阅
+                LogisticsInfoService logisticsInfoService = SpringUtil.getBean(LogisticsInfoService.class);
+                long count = logisticsInfoService.count(q -> q.eq(LogisticsInfo::getNumber, num).eq(LogisticsInfo::getCompany, com));
+                if (count == 0) {
+                    // 如果不是已签收状态,则开启订阅(物流状态跟踪并推送)
+                    KD100Util.subscribe(com, num);
+                }
             }
             return saveInfo(com, num, state, businessId, businessType, cls);
         } else {

+ 20 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ruoyi.system.service.impl;
 
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.constant.UserConstants;
@@ -17,6 +19,7 @@ import com.ruoyi.system.mapper.SysRoleMapper;
 import com.ruoyi.system.mapper.SysRoleMenuMapper;
 import com.ruoyi.system.mapper.SysUserRoleMapper;
 import com.ruoyi.system.service.ISysRoleService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -29,6 +32,7 @@ import java.util.*;
  * @author ruoyi
  */
 @Service
+@Slf4j
 public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
 
     @Autowired
@@ -221,6 +225,12 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
     @Override
     @Transactional
     public int updateRole(SysRole role) {
+
+        Long userId = SecurityUtils.getUserId();
+        String tenantId = SecurityUtils.getTenantId();
+        log.error("调用方法:updateRole,tenantId:{},userId:{},date:{},data;{}",
+                tenantId, userId, DateUtil.formatDateTime(new Date()), JSONObject.toJSONString(role));
+
         // 修改角色信息
         roleMapper.updateRole(role);
         // 删除角色与菜单关联
@@ -311,6 +321,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
     @Override
     @Transactional
     public int deleteRoleById(Long roleId) {
+        Long userId = SecurityUtils.getUserId();
+        String tenantId = SecurityUtils.getTenantId();
+        log.error("调用方法:deleteRoleById,tenantId:{},userId:{},date:{},data;{}",
+                tenantId, userId, DateUtil.formatDateTime(new Date()), JSONObject.toJSONString(roleId));
+
         // 删除角色与菜单关联
         roleMenuMapper.deleteRoleMenuByRoleId(roleId);
         // 删除角色与部门关联
@@ -387,6 +402,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
 
     @Override
     public void editRoleMenu(SysRole role) {
+        Long userId = SecurityUtils.getUserId();
+        String tenantId = SecurityUtils.getTenantId();
+        log.error("调用方法:editRoleMenu,tenantId:{},userId:{},date:{},data;{}",
+                tenantId, userId, DateUtil.formatDateTime(new Date()), JSONObject.toJSONString(role));
+
         // 删除角色与菜单关联
         roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
         int num = insertRoleMenu(role);