feat(task): 优化任务日志处理和受限空间删除功能
- 在 TaskLogController 中添加过滤逻辑,排除状态为 -1 的记录 - 为 ConfinedSpaceRemoveExe 添加事务回滚注解和详细文档说明 - 优化 TaskLogUpdateExe 中的 eightworkInfo.info 更新逻辑,改为批量更新变化的步骤 - 在 TaskLogUpdateExe 中添加签名路径和时间戳记录功能 - 修复 TaskLogServiceImpl 中 nextStep 方法的参数传递问题 - 为 TaskLogAddCmd 添加 others 参数支持 - 移除 MeasuresLogsDO 中冗余的 stepName 字段master
parent
bf10ad0b6f
commit
d9307f1e4f
|
|
@ -23,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web-adapter
|
* web-adapter
|
||||||
|
|
@ -62,7 +63,7 @@ public class TaskLogController {
|
||||||
@ApiOperation("所有数据")
|
@ApiOperation("所有数据")
|
||||||
@GetMapping("/listAll/{workId}")
|
@GetMapping("/listAll/{workId}")
|
||||||
public MultiResponse<TaskLogCO> listAll(@PathVariable("workId") String workId) {
|
public MultiResponse<TaskLogCO> listAll(@PathVariable("workId") String workId) {
|
||||||
return MultiResponse.of(taskLogService.listAll(workId));
|
return MultiResponse.of(taskLogService.listAll(workId).stream().filter(taskLogCO -> taskLogCO.getStatus() != -1).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("详情")
|
@ApiOperation("详情")
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,14 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
public class ConfinedSpaceRemoveExe {
|
public class ConfinedSpaceRemoveExe {
|
||||||
private final ConfinedSpaceGateway confinedSpaceGateway;
|
private final ConfinedSpaceGateway confinedSpaceGateway;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行删除受限空间的操作,并带有事务回滚功能
|
||||||
|
* 当发生异常时,事务会回滚,确保数据一致性
|
||||||
|
*
|
||||||
|
* @param id 要删除的受限空间的ID
|
||||||
|
* @return 删除操作是否成功,成功返回true
|
||||||
|
* @throws BizException 当删除操作失败时抛出业务异常
|
||||||
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean execute(Long id) {
|
public boolean execute(Long id) {
|
||||||
boolean res = confinedSpaceGateway.deletedConfinedSpaceById(id);
|
boolean res = confinedSpaceGateway.deletedConfinedSpaceById(id);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.zcloud.eightwork.command;
|
package com.zcloud.eightwork.command;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.cola.exception.BizException;
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
|
@ -11,7 +13,6 @@ import com.zcloud.eightwork.domain.gateway.TaskLogGateway;
|
||||||
import com.zcloud.eightwork.domain.gateway.EightworkSupplementaryInfoGateway;
|
import com.zcloud.eightwork.domain.gateway.EightworkSupplementaryInfoGateway;
|
||||||
import com.zcloud.eightwork.domain.model.MeasuresLogsE;
|
import com.zcloud.eightwork.domain.model.MeasuresLogsE;
|
||||||
import com.zcloud.eightwork.domain.model.EightworkSupplementaryInfoE;
|
import com.zcloud.eightwork.domain.model.EightworkSupplementaryInfoE;
|
||||||
import com.zcloud.eightwork.domain.model.EightworkInfoE;
|
|
||||||
import com.zcloud.eightwork.domain.model.TaskLogE;
|
import com.zcloud.eightwork.domain.model.TaskLogE;
|
||||||
import com.zcloud.eightwork.domain.model.enums.BranchFlag;
|
import com.zcloud.eightwork.domain.model.enums.BranchFlag;
|
||||||
import com.zcloud.eightwork.domain.model.enums.StepType;
|
import com.zcloud.eightwork.domain.model.enums.StepType;
|
||||||
|
|
@ -37,6 +38,7 @@ import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -144,11 +146,12 @@ public class TaskLogUpdateExe {
|
||||||
handleSignStepsIfNeeded(currentLog, cmd, actionLogs, logs);
|
handleSignStepsIfNeeded(currentLog, cmd, actionLogs, logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 批量更新
|
// 批量更新 task_log(先去重,避免同一步骤被多次更新导致数据丢失)
|
||||||
taskLogRepository.updateBatchById(actionLogs);
|
List<TaskLogDO> uniqueActionLogs = deduplicateActionLogs(actionLogs);
|
||||||
|
taskLogRepository.updateBatchById(uniqueActionLogs);
|
||||||
|
|
||||||
// 更新 eightworkInfo.info 字段
|
// 批量更新 eightworkInfo.info(只更新本次变化的步骤)
|
||||||
updateEightworkInfo(cmd.getWorkId(), logs);
|
updateEightworkInfo(cmd.getWorkId(), uniqueActionLogs);
|
||||||
|
|
||||||
log.info("步骤流转完成: workId={}, currentStep={}", cmd.getWorkId(), currentLog.getStepName());
|
log.info("步骤流转完成: workId={}, currentStep={}", cmd.getWorkId(), currentLog.getStepName());
|
||||||
}
|
}
|
||||||
|
|
@ -653,10 +656,14 @@ public class TaskLogUpdateExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新 eightworkInfo.info 字段
|
* 批量更新 eightworkInfo.info 字段
|
||||||
* 将所有步骤的信息以 step_${step_id} 为 key 存入 info
|
* 只更新本次变化的步骤,减少数据库操作
|
||||||
*/
|
*/
|
||||||
private void updateEightworkInfo(String workId, List<TaskLogE> logs) {
|
private void updateEightworkInfo(String workId, List<TaskLogDO> actionLogs) {
|
||||||
|
if (actionLogs == null || actionLogs.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EightworkInfoDO infoDO = eightworkInfoRepository.getOne(
|
EightworkInfoDO infoDO = eightworkInfoRepository.getOne(
|
||||||
new LambdaQueryWrapper<EightworkInfoDO>()
|
new LambdaQueryWrapper<EightworkInfoDO>()
|
||||||
.eq(EightworkInfoDO::getWorkId, workId)
|
.eq(EightworkInfoDO::getWorkId, workId)
|
||||||
|
|
@ -680,23 +687,25 @@ public class TaskLogUpdateExe {
|
||||||
infoJson = new JSONObject();
|
infoJson = new JSONObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 遍历所有步骤,更新 info
|
// 循环更新本次变化的步骤
|
||||||
for (TaskLogE log : logs) {
|
for (TaskLogDO logDO : actionLogs) {
|
||||||
JSONObject stepInfo = new JSONObject();
|
JSONObject stepInfo = new JSONObject();
|
||||||
stepInfo.put("stepName", log.getStepName());
|
stepInfo.put("stepName", logDO.getStepName());
|
||||||
stepInfo.put("actUserDepartment", log.getActUserDepartment());
|
stepInfo.put("actUserDepartment", logDO.getActUserDepartment());
|
||||||
stepInfo.put("actUserDepartmentName", log.getActUserDepartmentName());
|
stepInfo.put("actUserDepartmentName", logDO.getActUserDepartmentName());
|
||||||
stepInfo.put("actUser", log.getActUser());
|
stepInfo.put("actUser", logDO.getActUser());
|
||||||
stepInfo.put("actUserName", log.getActUserName());
|
stepInfo.put("actUserName", logDO.getActUserName());
|
||||||
stepInfo.put("status", log.getStatus());
|
stepInfo.put("signPath", logDO.getSignPath());
|
||||||
|
stepInfo.put("signTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
|
||||||
|
stepInfo.put("status", logDO.getStatus());
|
||||||
|
|
||||||
infoJson.put("step_" + log.getStepId(), stepInfo);
|
infoJson.put("step_" + logDO.getStepId(), stepInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新到数据库
|
// 更新到数据库
|
||||||
infoDO.setInfo(infoJson.toJSONString());
|
infoDO.setInfo(infoJson.toJSONString());
|
||||||
eightworkInfoRepository.updateById(infoDO);
|
eightworkInfoRepository.updateById(infoDO);
|
||||||
|
|
||||||
log.info("已更新作业 info: workId={}", workId);
|
log.info("已批量更新步骤 info: workId={}, count={}", workId, actionLogs.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class TaskLogServiceImpl implements TaskLogServiceI {
|
||||||
TaskLogNextCmd taskLogNextCmd = new TaskLogNextCmd(commitTaskLogDO.getId(),
|
TaskLogNextCmd taskLogNextCmd = new TaskLogNextCmd(commitTaskLogDO.getId(),
|
||||||
commitTaskLogDO.getWorkId(),
|
commitTaskLogDO.getWorkId(),
|
||||||
commitTaskLogDO.getStepId(),
|
commitTaskLogDO.getStepId(),
|
||||||
TaskLogStatus.APPROVED.getCode(),null,null,null,null);
|
TaskLogStatus.APPROVED.getCode(),null,null,null,cmd.getOthers());
|
||||||
|
|
||||||
taskLogUpdateExe.nextStep(taskLogNextCmd);
|
taskLogUpdateExe.nextStep(taskLogNextCmd);
|
||||||
return SingleResponse.buildSuccess();
|
return SingleResponse.buildSuccess();
|
||||||
|
|
|
||||||
|
|
@ -51,5 +51,7 @@ public class TaskLogAddCmd extends Command {
|
||||||
|
|
||||||
@ApiModelProperty(value = "部门id", name = "departmentId")
|
@ApiModelProperty(value = "部门id", name = "departmentId")
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
|
@ApiModelProperty(value = "其他参数", name = "others")
|
||||||
|
private JSONObject others;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,6 @@ public class MeasuresLogsDO extends BaseDO {
|
||||||
//作业类型
|
//作业类型
|
||||||
@ApiModelProperty(value = "作业类型")
|
@ApiModelProperty(value = "作业类型")
|
||||||
private String workType;
|
private String workType;
|
||||||
//填写步骤名
|
|
||||||
@ApiModelProperty(value = "填写步骤名")
|
|
||||||
private String stepName;
|
|
||||||
//防护措施
|
//防护措施
|
||||||
@ApiModelProperty(value = "防护措施")
|
@ApiModelProperty(value = "防护措施")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue