Compare commits

..

4 Commits

  1. 9
      src/main/java/com/biutag/supervision/config/FastDFSConfig.java
  2. 5
      src/main/java/com/biutag/supervision/mapper/Report/ReportProjectMapper.java
  3. 3
      src/main/java/com/biutag/supervision/pojo/vo/entryWindow/EntryWindowVo.java
  4. 6
      src/main/java/com/biutag/supervision/pojo/vo/warning/WarningProblemExcelVo.java
  5. 30
      src/main/java/com/biutag/supervision/service/FileService.java
  6. 3
      src/main/java/com/biutag/supervision/service/Report/ReportProjectService.java
  7. 29
      src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java
  8. 12
      src/main/resources/mapper/ReportProjectMapper.xml

9
src/main/java/com/biutag/supervision/config/FastDFSConfig.java

@ -2,10 +2,12 @@ package com.biutag.supervision.config;
import com.github.tobato.fastdfs.domain.conn.TrackerConnectionManager;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Slf4j
@ComponentScan("com.github.tobato.fastdfs")
@Configuration
public class FastDFSConfig {
@ -15,6 +17,13 @@ public class FastDFSConfig {
@PostConstruct
public void init() {
try {
trackerConnectionManager.initTracker();
log.info("FastDFS Tracker初始化完成: trackerList={}", trackerConnectionManager.getTrackerList());
} catch (RuntimeException e) {
log.error("FastDFS Tracker初始化失败: trackerList={}, exceptionType={}, message={}",
trackerConnectionManager.getTrackerList(), e.getClass().getName(), e.getMessage(), e);
throw e;
}
}
}

5
src/main/java/com/biutag/supervision/mapper/Report/ReportProjectMapper.java

@ -22,7 +22,10 @@ public interface ReportProjectMapper extends BaseMapper<ReportProject> {
Page<EntryWindowVo> queryPage(@Param("page") Page<ReportProject> page, @Param(Constants.WRAPPER) QueryWrapper<ReportProject> queryWrapper);
Page<EntryWindowVo> queryPageWarning(@Param("page") Page<ReportProject> page, @Param(Constants.WRAPPER) QueryWrapper<ReportProject> queryWrapper,String warningState);
Page<EntryWindowVo> queryPageWarning(@Param("page") Page<ReportProject> page,
@Param(Constants.WRAPPER) QueryWrapper<ReportProject> queryWrapper,
@Param("warningState") String warningState,
@Param("userId") String userId);
Page<ConditionVo> queryPageCondition(@Param("page") Page<ReportProject> page,@Param(Constants.WRAPPER)QueryWrapper<ReportProject> queryWrapper);

3
src/main/java/com/biutag/supervision/pojo/vo/entryWindow/EntryWindowVo.java

@ -16,6 +16,9 @@ public class EntryWindowVo extends ReportProject {
private String warningId;
@Schema(description = "当前用户待审批的预警流程id")
private String flowId;
private String warningState;
//预警问题数
private Long warningContent;

6
src/main/java/com/biutag/supervision/pojo/vo/warning/WarningProblemExcelVo.java

@ -12,6 +12,12 @@ public class WarningProblemExcelVo {
@ExcelProperty(value = "项目名称")
private String reportName;
@ExcelProperty(value = "审计单位")
private String auditUnitStr;
@ExcelProperty(value = "项目单位")
private String projectUnitStr;
@ExcelProperty(value = "预警类型")
private String type;

30
src/main/java/com/biutag/supervision/service/FileService.java

@ -6,10 +6,13 @@ import cn.hutool.http.HttpUtil;
import com.biutag.supervision.mapper.FileBase64Mapper;
import com.biutag.supervision.pojo.entity.FileBase64;
import com.biutag.supervision.util.ImgUtils;
import com.github.tobato.fastdfs.domain.conn.TrackerConnectionManager;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -18,12 +21,19 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;
@Slf4j
@RequiredArgsConstructor
@Service
public class FileService {
private static final String STORAGE_GROUP = "group1";
private final FastFileStorageClient fastFileStorageClient;
private final TrackerConnectionManager trackerConnectionManager;
private final Environment environment;
private final FileBase64Mapper fileBase64Mapper;
@Value("${fdfs.preview-url}")
@ -34,8 +44,24 @@ public class FileService {
}
public String upload(InputStream is, long size, String fileExtName) {
StorePath storePath = fastFileStorageClient.uploadFile("group1", is, size, fileExtName);
return "/" + storePath.getFullPath();
long startTime = System.currentTimeMillis();
String activeProfiles = String.join(",", environment.getActiveProfiles());
log.info("FastDFS上传开始: activeProfiles={}, trackerList={}, group={}, fileSize={}, fileExtName={}",
activeProfiles, trackerConnectionManager.getTrackerList(), STORAGE_GROUP, size, fileExtName);
try {
StorePath storePath = fastFileStorageClient.uploadFile(STORAGE_GROUP, is, size, fileExtName);
String filePath = "/" + storePath.getFullPath();
log.info("FastDFS上传成功: activeProfiles={}, trackerList={}, group={}, filePath={}, elapsedMs={}",
activeProfiles, trackerConnectionManager.getTrackerList(), STORAGE_GROUP, filePath,
System.currentTimeMillis() - startTime);
return filePath;
} catch (RuntimeException e) {
log.error("FastDFS上传失败: activeProfiles={}, trackerList={}, group={}, fileSize={}, fileExtName={}, " +
"elapsedMs={}, exceptionType={}, message={}",
activeProfiles, trackerConnectionManager.getTrackerList(), STORAGE_GROUP, size, fileExtName,
System.currentTimeMillis() - startTime, e.getClass().getName(), e.getMessage(), e);
throw e;
}
}
public String uploadBase64(String base64, String originalFilename) {

3
src/main/java/com/biutag/supervision/service/Report/ReportProjectService.java

@ -98,7 +98,8 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
}
public Page<EntryWindowVo> getPageWarning(Page<ReportProject> page, QueryWrapper<ReportProject> lambdaQueryWrapper, String warningState) {
return baseMapper.queryPageWarning(page, lambdaQueryWrapper, warningState);
UserAuth user = UserContextHolder.getCurrentUser();
return baseMapper.queryPageWarning(page, lambdaQueryWrapper, warningState, user.getUserName());
}
/**

29
src/main/java/com/biutag/supervision/service/Warning/impl/WarningBusinessServiceImpl.java

@ -118,6 +118,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
@Transactional(rollbackFor = Exception.class)
public void save(WarningSaveRequest request) {
UserAuth user = UserContextHolder.getCurrentUser();
validateWarningHandler(request.getReportId(), user);
// 更新项目监督信息(由后端自动获取)
ReportProject project = new ReportProject();
@ -135,6 +136,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
@Transactional(rollbackFor = Exception.class)
public void submit(WarningSubmitRequest request) {
UserAuth user = UserContextHolder.getCurrentUser();
validateWarningHandler(request.getReportId(), user);
// 1. 更新项目监督信息(由后端自动获取)
ReportProject project = new ReportProject();
@ -185,6 +187,7 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
@Transactional(rollbackFor = Exception.class)
public void end(WarningEndRequest request) {
UserAuth user = UserContextHolder.getCurrentUser();
validateWarningHandler(request.getReportId(), user);
// 1. 更新项目状态(由后端自动获取预警监督人和时间)
ReportProject project = new ReportProject();
@ -462,6 +465,8 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
WarningProblemExcelVo vo = new WarningProblemExcelVo();
vo.setReportId(record.getId());
vo.setReportName(record.getReportName());
vo.setAuditUnitStr(record.getAuditUnitStr());
vo.setProjectUnitStr(record.getProjectUnitStr());
vo.setType(content.getType());
vo.setTitle(content.getTitle());
vo.setContent(content.getContent());
@ -594,6 +599,30 @@ public class WarningBusinessServiceImpl implements WarningBusinessService {
return flows.isEmpty() ? null : flows.get(0).getId();
}
/**
* 校验当前用户是否为预警待办处理人
* 首次预警没有待处理流程时允许操作存在待处理流程时仅允许对应处理人操作
*/
private void validateWarningHandler(String reportId, UserAuth user) {
List<ReportFlow> pendingFlows = flowMapper.selectList(
new LambdaQueryWrapper<ReportFlow>()
.eq(ReportFlow::getReportId, reportId)
.eq(ReportFlow::getType, "warning")
.eq(ReportFlow::getApproverState, FlowStateEnum.Start.getLabel())
.orderByDesc(ReportFlow::getAreportTime)
.last("LIMIT 1")
);
if (pendingFlows.isEmpty()) {
return;
}
ReportFlow pendingFlow = pendingFlows.get(0);
if (!StrUtil.equals(user.getUserName(), pendingFlow.getApproverId())) {
String handler = StrUtil.isBlank(pendingFlow.getApprover()) ? "其他人员" : pendingFlow.getApprover();
throw new RuntimeException("该项目当前由" + handler + "处理,请勿重复操作");
}
}
/**
* 保存预警内容
*/

12
src/main/resources/mapper/ReportProjectMapper.xml

@ -102,7 +102,17 @@
</select>
<select id="queryPageWarning" resultType="com.biutag.supervision.pojo.vo.entryWindow.EntryWindowVo">
SELECT p.*
SELECT p.*,
(
SELECT f.id
FROM report_flow f
WHERE f.report_id = p.id
AND f.type = 'warning'
AND f.approver_state = 'start'
AND f.approver_id = #{userId}
ORDER BY f.areport_time DESC
LIMIT 1
) AS flowId
FROM report_project p
${ew.getCustomSqlSegment}
GROUP BY p.id

Loading…
Cancel
Save