ludc
2023-11-09 6b0971b690de6e50d43b81799ba0378013455cdb
提交代码
已修改8个文件
190 ■■■■ 文件已修改
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/controller/LogErrorController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/controller/LogSystemController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/service/ILogSystemService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/service/impl/LogSystemServiceImpl.java 158 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeRuleController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/controller/LogErrorController.java
@@ -25,6 +25,7 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/controller/LogSystemController.java
@@ -1,9 +1,17 @@
package com.vci.ubcs.core.log.controller;
import com.vci.ubcs.core.log.service.ILogSystemService;
import com.vci.ubcs.log.entity.SystemLog;
import lombok.AllArgsConstructor;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * 本地系统日志
@@ -12,10 +20,18 @@
 */
@NonDS
@RestController
@AllArgsConstructor
//@AllArgsConstructor
@RequestMapping("/systemLog")
public class LogSystemController {
    @Autowired
    private ILogSystemService logSystemService;
    @GetMapping("/lazy-list")
    private R<List<SystemLog>> getSystemLogList(@RequestParam String serviceName){
         return R.data(logSystemService.getSystemLogList(serviceName));
    }
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/service/ILogSystemService.java
@@ -18,8 +18,10 @@
    /**
     * 查看,本地系统日志列表
     * @param logParentPath
     * @return
     */
    List<SystemLog> getSystemLogList();
    List<SystemLog> getSystemLogList(String logParentPath);
    /**
     * 下载,根据服务名所在文件名和文件名下载文件
Source/UBCS/ubcs-ops/ubcs-log/src/main/java/com/vci/ubcs/core/log/service/impl/LogSystemServiceImpl.java
@@ -2,16 +2,25 @@
import com.vci.ubcs.core.log.service.ILogSystemService;
import com.vci.ubcs.log.entity.SystemLog;
import com.vci.ubcs.omd.cache.EnumCache;
import com.vci.ubcs.omd.enums.EnumEnum;
import com.vci.ubcs.resource.bo.FileObjectBO;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.xml.crypto.Data;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.rmi.ServerException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 本地系统日志
@@ -25,55 +34,136 @@
     * 各个服务存放的的父路径
     */
    private final String parentPath = "/data1/ubcs/ubcs-server";
    /**
     * 各个服务的日志具体的目录路径
     */
    //@Value("#{'${ip-whitelist.ip}'.split(',')}")
    private List<String> serviceDirNames = new ArrayList<>(Arrays.asList("/ubcs_code/target/log","/ubcs_omd/target/log","/ubcs_system/target/log"));
    /**
     * 获取本地日志列表
     * @param logParentPath
     * @return
     */
    @Override
    public List<SystemLog> getSystemLogList() {
        serviceDirNames.stream().forEach(serviceDirName->{
            File file = new File(parentPath+serviceDirName);
            if(file.isDirectory()){
    public List<SystemLog> getSystemLogList(String logParentPath) {
        List<SystemLog> systemLogs = new ArrayList<>();
        // 不为空说明是加载当前这个服务路径下的日志文件
        if(Func.isNotEmpty(logParentPath)){
            File file = new File(logParentPath);
            if (file.isDirectory()) {
                File[] files = file.listFiles();
                for(File f : files){
                    if(f.isDirectory()){
                        //readAllFiles(f.getAbsolutePath());
                    }else{
                        System.out.println(f.getName());
                    }
                }
            }else{
                System.out.println(file.getName());
                Arrays.stream(files).forEach(item->{
                    // 组建日志文件对象
                    SystemLog systemLog = new SystemLog();
                    systemLog.setLogName(item.getName());
                    systemLog.setLogType(getLogType(item.getName()));
                    systemLog.setCreateTime(getLastModifiedOrCreatTime(false,logParentPath));
                    systemLog.setLastmodifier(getLastModifiedOrCreatTime(true,logParentPath));
                    systemLog.setLogPath(logParentPath);
                    String serviceId = getServiceId(logParentPath);
                    systemLog.setServiceId(serviceId);
                    systemLog.setServiceName(getServiceName(serviceId));
                    systemLogs.add(systemLog);
                });
            }
        });
        return null;
        }else {
            serviceDirNames.stream().forEach(serviceDirName->{
                File file = new File(parentPath+serviceDirName);
                SystemLog systemLog = new SystemLog();
                systemLog.setLastmodifier(getLastModifiedOrCreatTime(true,parentPath+serviceDirName));
                systemLog.setCreateTime(getLastModifiedOrCreatTime(false,parentPath+serviceDirName));
                systemLog.setLogPath(parentPath+serviceDirName);
                String serviceId = getServiceId(logParentPath);
                systemLog.setServiceId(serviceId);
                systemLog.setServiceName(getServiceName(serviceId));
                systemLogs.add(systemLog);
            });
        }
        return systemLogs;
    }
    /**
     * 获取文件最后修改或者创建时间
     * @param isModifier
     * @return
     */
    private String getLastModifiedOrCreatTime(boolean isModifier,String pathStr) {
        Path path = FileSystems.getDefault().getPath(pathStr);
        String date = "";
        try {
            BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            // 是获取最后修改时间
            if(isModifier){
                date = dateFormat.format(new Date(attr.lastModifiedTime().toMillis()));
            }else {
                date = dateFormat.format(new Date(attr.creationTime().toMillis()));
            }
        } catch (IOException e) {
            throw new ServiceException("Error reading file date attributes: " + e.getMessage());
        }
        return date;
    }
    /**
     * 获取日志类型
     * @param fileName
     * @return
     */
    private String getLogType(String fileName){
        //判断日志的的类型
        if (fileName.contains("error")) {
            return "Error";
        } else if (fileName.contains("info")) {
            return "Info";
        } else if (fileName.contains("warning")) {
            return "Warning";
        } else {
            return "Unknown";
        }
    }
    /**
     * 获取服务ID
     * @param servciePath
     * @return
     */
    private String getServiceId(String servciePath){
        String[] parts = servciePath.split("/");
        String extractedString = parts[parts.length - 2];
        return extractedString;
    }
    /**
     * 获取服务名称
     * @param serViceId
     * @return
     */
    private String getServiceName(String serViceId){
        return EnumCache.getValue(EnumEnum.SERCIVE_NAME_ROLE, serViceId);
    }
    /**
     * 下载日志文件
     * @param condition 查询条件map
     * @return
     * @throws ServerException
     */
    @Override
    public FileObjectBO downloadLogByServiceNameAndFileName(Map<String, String> condition) throws ServerException {
        return null;
    }
    /**
     * 删除日志文件
     * @param condition 主键集合
     * @throws ServerException
     */
    @Override
    public void deleteLogFile(Map<String, String> condition) throws ServerException {
    }
}
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodeRuleController.java
@@ -30,6 +30,7 @@
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springframework.util.CollectionUtils;
@@ -72,6 +73,7 @@
    @GetMapping(value = "/gridCodeRule")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入CodeRule")
    @ApiLog
    public R<IPage<CodeRuleVO>> gridCodeRule(BladeQueryObject bladeQueryObject) {
        IPage<CodeRuleVO> pages = codeRuleService.gridCodeRule(bladeQueryObject.getQuery().setDescs("CREATETIME"), bladeQueryObject.getConditionMap());
        return R.data(pages);
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/MdmEngineService.java
@@ -397,6 +397,7 @@
     * @return 处理成功数据条数
     */
    Integer insertBatchByType(String btmType, List<BaseModel> baseModels);
    /**
     * 传入业务类型以及ID查询业务表数据是否重复
     *
@@ -423,7 +424,8 @@
     * @param oids      需要查询的oid集合 逗号分开
     * @return 查询出的数据
     */
    List<BaseModel> selectByTypeAndOid(String btmType, String oids) ;
    List<BaseModel> selectByTypeAndOid(String btmType, String oids);
    /**
     * 传入业务类型以及相关数据进行批量更新操作
     *
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeRuleServiceImpl.java
@@ -134,6 +134,7 @@
     */
    @Override
    public IPage<CodeRuleVO> gridCodeRule(Query query, Map<String,Object> conidtionMap) throws VciBaseException {
        //int i = 1 / 0;
        //如果等于自己配置的管理组租户id和管理组超管账号,就不需要按照规则所有者来进行查询
        /*if(!(AuthUtil.getTenantId().equals(NacosConfigCache.getAdminUserInfo().getTenantId())
            && AuthUtil.getUserId().toString().equals(NacosConfigCache.getAdminUserInfo().getUserId().toString()))
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -3524,6 +3524,7 @@
     * @return 处理成功数据条数
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Integer insertBatchByType(String btmType, List<BaseModel> baseModels) {
        //使用传入的业务类型查询表
        R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(btmType));
@@ -3540,6 +3541,7 @@
        }).collect(Collectors.toSet());
        //将bean转为map,mybatis统一处理
        List<Map<String, String>> maps = new ArrayList<>();
        baseModels.stream().forEach(model -> {
            try {
                maps.add(VciBaseUtil.convertBean2Map(model,existFild));