diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/LogParamVO.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/LogParamVO.java index 5382979e3..cae31676a 100644 --- a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/LogParamVO.java +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/LogParamVO.java @@ -17,12 +17,12 @@ public class LogParamVO { * 登录名 */ @ApiModelProperty("登录名") - private List loginName; + private List loginName; /** * 操作类型 */ @ApiModelProperty("操作类型") - private List operateType; + private List operateType; } diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/ValuePO.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/ValuePO.java new file mode 100644 index 000000000..a6cb96fef --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/vo/ValuePO.java @@ -0,0 +1,16 @@ +package com.njcn.system.pojo.vo; + +import lombok.Data; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/07/21 12:36 + */ +@Data +public class ValuePO { + + private String name; + private String value; + +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/config/SystemBaseConfig.java b/pqs-system/system-boot/src/main/java/com/njcn/system/config/SystemBaseConfig.java deleted file mode 100644 index cdc3d8984..000000000 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/config/SystemBaseConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.njcn.system.config; - -import lombok.Data; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * @version 1.0.0 - * @author: chenchao - * @date: 2022/07/15 14:31 - */ -@Data -@Component -public class SystemBaseConfig { - - @Value("${business.wavePath}") - private String wavePath; - - @Value("${business.tempPath}") - private String tempPath; - -} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AuditServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AuditServiceImpl.java index f5a1d269c..b0264bcdf 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AuditServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/AuditServiceImpl.java @@ -9,9 +9,9 @@ import com.alibaba.nacos.shaded.com.google.common.collect.Lists; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.common.config.GeneralInfo; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.poi.excel.ExcelUtil; -import com.njcn.system.config.SystemBaseConfig; import com.njcn.system.enums.AuditLogEnum; import com.njcn.system.mapper.AuditMapper; import com.njcn.system.mapper.UserLogMapper; @@ -21,6 +21,7 @@ import com.njcn.system.pojo.po.UserLog; import com.njcn.system.pojo.vo.AuditLogCusVO; import com.njcn.system.pojo.vo.AuditLogVO; import com.njcn.system.pojo.vo.LogParamVO; +import com.njcn.system.pojo.vo.ValuePO; import com.njcn.system.service.AuditService; import lombok.AllArgsConstructor; import org.apache.commons.compress.utils.IOUtils; @@ -41,6 +42,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @version 1.0.0 @@ -55,7 +57,7 @@ public class AuditServiceImpl extends ServiceImpl implem private final UserLogMapper userLogMapper; - private final SystemBaseConfig SystemBaseConfig; + private final GeneralInfo generalInfo; @Override public Page getAuditLog(AuditParam auditParam) { @@ -126,7 +128,7 @@ public class AuditServiceImpl extends ServiceImpl implem queryWrapper.ge("sys_user_log.update_time",date); List excelList = auditMapper.queryExportUser(queryWrapper); - File filePath = new File(SystemBaseConfig.getTempPath()); + File filePath = new File(generalInfo.getBusinessTempPath()); filePath.mkdirs(); File file = new File(filePath.getPath() + File.separator + nowDate +" sys_user_log.xlsx"); ExcelUtil.exportExcelWithTargetFile(file, UserLogExcel.class, excelList); @@ -165,7 +167,7 @@ public class AuditServiceImpl extends ServiceImpl implem @Override public boolean recoverLogFile() { LocalDate nowDate = LocalDate.now(); - File file = new File(SystemBaseConfig.getTempPath()+ File.separator + nowDate +" sys_user_log.xlsx"); + File file = new File(generalInfo.getBusinessTempPath() + File.separator + nowDate +" sys_user_log.xlsx"); if (!file.exists()) { throw new BusinessException(AuditLogEnum.NOT_FIND_FILE); } @@ -184,11 +186,32 @@ public class AuditServiceImpl extends ServiceImpl implem if (excelList.get(0).getId().isEmpty()) { throw new BusinessException(AuditLogEnum.LOG_EXCEPTION); } - for (UserLogExcel excel: excelList) { - UserLog userLog = new UserLog(); - BeanUtil.copyProperties(excel,userLog); - this.saveOrUpdate(userLog); + List oldIds = excelList.stream().map(UserLogExcel::getId).collect(Collectors.toList()); + //查找该备份文件是否已存在 + List logList = userLogMapper.selectBatchIds(oldIds); + if (CollectionUtils.isEmpty(logList)) { + List userLogs = new ArrayList<>(); + for (UserLogExcel excel: excelList) { + UserLog userLog = new UserLog(); + BeanUtil.copyProperties(excel,userLog); + userLogs.add(userLog); + } + this.saveBatch(userLogs); + } else { + List isIds = logList.stream().map(UserLog::getId).collect(Collectors.toList()); + List needSaveUserLogData = excelList.stream().filter(userLogExcelTemp -> !isIds.contains(userLogExcelTemp.getId())).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(needSaveUserLogData)) { + List userLogs = new ArrayList<>(); + for (UserLogExcel needSave: needSaveUserLogData) { + UserLog userLog = new UserLog(); + BeanUtil.copyProperties(needSave,userLog); + userLogs.add(userLog); + } + this.saveBatch(userLogs); + // this.saveOrUpdateBatch(userLogs); + } } + } catch (Exception e) { e.printStackTrace(); throw new ExcelImportException(e.getMessage(), e); @@ -238,10 +261,27 @@ public class AuditServiceImpl extends ServiceImpl implem @Override public LogParamVO saveLogParam() { LogParamVO logParamVO = new LogParamVO(); - logParamVO.setLoginName(auditMapper.selectLoginName()); - logParamVO.setOperateType(auditMapper.selectOperateType()); + List loginName = auditMapper.selectLoginName(); + List operateType = auditMapper.selectOperateType(); + List loginNameList = new ArrayList<>(); + List operateTypeList = new ArrayList<>(); + for (int i = 0; i