Compare commits

...

2 Commits

Author SHA1 Message Date
fangjiakai b1e94239d7 feat(task): 添加任务日志地理位置功能并优化批量更新逻辑
- 新增 latitude 和 longitude 字段支持位置信息存储
- 移除重复步骤去重逻辑,直接批量更新所有日志
- 添加智能步骤合并方法,避免同一步骤多次更新数据丢失
- 在定位步骤中保存经纬度信息到任务日志
- 更新八工信息时包含位置数据
- 扩展 DTO 对象以支持位置信息传输
2026-03-20 10:13:35 +08:00
fangjiakai d9307f1e4f feat(task): 优化任务日志处理和受限空间删除功能
- 在 TaskLogController 中添加过滤逻辑,排除状态为 -1 的记录
- 为 ConfinedSpaceRemoveExe 添加事务回滚注解和详细文档说明
- 优化 TaskLogUpdateExe 中的 eightworkInfo.info 更新逻辑,改为批量更新变化的步骤
- 在 TaskLogUpdateExe 中添加签名路径和时间戳记录功能
- 修复 TaskLogServiceImpl 中 nextStep 方法的参数传递问题
- 为 TaskLogAddCmd 添加 others 参数支持
- 移除 MeasuresLogsDO 中冗余的 stepName 字段
2026-03-20 09:13:48 +08:00
10 changed files with 142 additions and 29 deletions

View File

@ -23,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.stream.Collectors;
/**
* web-adapter
@ -62,7 +63,7 @@ public class TaskLogController {
@ApiOperation("所有数据")
@GetMapping("/listAll/{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("详情")

View File

@ -18,6 +18,14 @@ import org.springframework.transaction.annotation.Transactional;
public class ConfinedSpaceRemoveExe {
private final ConfinedSpaceGateway confinedSpaceGateway;
/**
*
*
*
* @param id ID
* @return true
* @throws BizException
*/
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long id) {
boolean res = confinedSpaceGateway.deletedConfinedSpaceById(id);

View File

@ -1,6 +1,8 @@
package com.zcloud.eightwork.command;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.cola.exception.BizException;
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.model.MeasuresLogsE;
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.enums.BranchFlag;
import com.zcloud.eightwork.domain.model.enums.StepType;
@ -37,7 +38,9 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -144,11 +147,11 @@ public class TaskLogUpdateExe {
handleSignStepsIfNeeded(currentLog, cmd, actionLogs, logs);
}
// 批量更新
// 批量更新 task_log
taskLogRepository.updateBatchById(actionLogs);
// 更新 eightworkInfo.info 字段
updateEightworkInfo(cmd.getWorkId(), logs);
// 批量更新 eightworkInfo.info只更新本次变化的步骤
updateEightworkInfo(cmd.getWorkId(), actionLogs);
log.info("步骤流转完成: workId={}, currentStep={}", cmd.getWorkId(), currentLog.getStepName());
}
@ -179,10 +182,17 @@ public class TaskLogUpdateExe {
currentLog.setSignPath(cmd.getSignPath());
}
// 定位步骤,保存经纬度
if (PC_FLAG.equals(currentLog.getLocateStepFlag())) {
currentLog.setLatitude(cmd.getLatitude());
currentLog.setLongitude(cmd.getLongitude());
log.info("定位步骤已保存经纬度: latitude={}, longitude={}", cmd.getLatitude(), cmd.getLongitude());
}
// 发送待办完成事件
sendTodoCompleteEvent(currentLog.getId());
actionLogs.add(TaskLogConvertUtil.toDO(currentLog));
addActionLog(actionLogs, currentLog);
}
/**
@ -268,7 +278,7 @@ public class TaskLogUpdateExe {
// 修改当前步骤状态为已完成
currentLog.setStatus(TaskLogStatus.APPROVED.getCode());
actionLogs.add(TaskLogConvertUtil.toDO(currentLog));
addActionLog(actionLogs, currentLog);
// 延时转交步骤不自动流转下一步
return false;
@ -326,7 +336,7 @@ public class TaskLogUpdateExe {
currentLog.setStatus(TaskLogStatus.IN_PROGRESS.getCode());
// 添加到待更新列表
actionLogs.add(TaskLogConvertUtil.toDO(currentLog));
addActionLog(actionLogs, currentLog);
log.info("气体检测记录已保存,当前填写次数: {}", currentTimes + 1);
@ -507,7 +517,7 @@ public class TaskLogUpdateExe {
for (TaskLogE next : nextSteps) {
next.setStatus(TaskLogStatus.IN_PROGRESS.getCode());
actionLogs.add(TaskLogConvertUtil.toDO(next));
addActionLog(actionLogs, next);
// 发送待办通知
sendTodoAddEvent(workId, next, currentLog.getWorkType());
@ -559,7 +569,7 @@ public class TaskLogUpdateExe {
}
branchStep.setStatus(TaskLogStatus.IN_PROGRESS.getCode());
actionLogs.add(TaskLogConvertUtil.toDO(branchStep));
addActionLog(actionLogs, branchStep);
sendTodoAddEvent(getWorkId(currentLog.getWorkId()), branchStep, currentLog.getWorkType());
log.info("已激活分支步骤: stepName={}, mergeTo={}", branchStep.getStepName(), branchStep.getBranchMergeStep());
}
@ -591,7 +601,7 @@ public class TaskLogUpdateExe {
if (CAN_SKIP_FLAG.equals(currentLog.getCanSkip()) && signInfo.getActUser() == null) {
// 设置为跳过状态
signStepLog.setStatus(TaskLogStatus.SKIPPED.getCode());
actionLogs.add(TaskLogConvertUtil.toDO(signStepLog));
addActionLog(actionLogs, signStepLog);
log.info("步骤设置为跳过: {}", signStepLog.getStepName());
} else {
// 设置签字人
@ -602,7 +612,7 @@ public class TaskLogUpdateExe {
signInfo.getActUser(),
signInfo.getActUserName()
);
actionLogs.add(TaskLogConvertUtil.toDO(signStepLog));
addActionLog(actionLogs, signStepLog);
log.info("已设置签字人: step={}, user={}", signStepLog.getStepName(), signInfo.getActUserName());
}
}
@ -653,10 +663,71 @@ public class TaskLogUpdateExe {
}
/**
* eightworkInfo.info
* step_${step_id} key info
*
*
*
*
* @param actionLogs
* @param taskLogE
*/
private void updateEightworkInfo(String workId, List<TaskLogE> logs) {
private void addActionLog(List<TaskLogDO> actionLogs, TaskLogE taskLogE) {
TaskLogDO newDO = TaskLogConvertUtil.toDO(taskLogE);
// 查找是否已存在该步骤的记录
for (int i = 0; i < actionLogs.size(); i++) {
TaskLogDO existing = actionLogs.get(i);
if (existing.getId().equals(newDO.getId())) {
// 存在则合并:保留所有非空字段
mergeTaskLogDO(existing, newDO);
log.debug("合并步骤修改: stepId={}, stepName={}", taskLogE.getStepId(), taskLogE.getStepName());
return;
}
}
// 不存在则添加
actionLogs.add(newDO);
}
/**
* TaskLogDO
* source target
*
* @param target DO
* @param source DO
*/
private void mergeTaskLogDO(TaskLogDO target, TaskLogDO source) {
if (source.getStatus() != null) {
target.setStatus(source.getStatus());
}
if (source.getActUser() != null) {
target.setActUser(source.getActUser());
}
if (source.getActUserName() != null) {
target.setActUserName(source.getActUserName());
}
if (source.getActUserDepartment() != null) {
target.setActUserDepartment(source.getActUserDepartment());
}
if (source.getActUserDepartmentName() != null) {
target.setActUserDepartmentName(source.getActUserDepartmentName());
}
if (source.getSignPath() != null) {
target.setSignPath(source.getSignPath());
}
if (source.getCurrentFillTimes() != null) {
target.setCurrentFillTimes(source.getCurrentFillTimes());
}
}
/**
* eightworkInfo.info
*
*/
private void updateEightworkInfo(String workId, List<TaskLogDO> actionLogs) {
if (actionLogs == null || actionLogs.isEmpty()) {
return;
}
EightworkInfoDO infoDO = eightworkInfoRepository.getOne(
new LambdaQueryWrapper<EightworkInfoDO>()
.eq(EightworkInfoDO::getWorkId, workId)
@ -680,23 +751,33 @@ public class TaskLogUpdateExe {
infoJson = new JSONObject();
}
// 遍历所有步骤,更新 info
for (TaskLogE log : logs) {
// 循环更新本次变化的步骤
for (TaskLogDO logDO : actionLogs) {
JSONObject stepInfo = new JSONObject();
stepInfo.put("stepName", log.getStepName());
stepInfo.put("actUserDepartment", log.getActUserDepartment());
stepInfo.put("actUserDepartmentName", log.getActUserDepartmentName());
stepInfo.put("actUser", log.getActUser());
stepInfo.put("actUserName", log.getActUserName());
stepInfo.put("status", log.getStatus());
stepInfo.put("stepName", logDO.getStepName());
stepInfo.put("actUserDepartment", logDO.getActUserDepartment());
stepInfo.put("actUserDepartmentName", logDO.getActUserDepartmentName());
stepInfo.put("actUser", logDO.getActUser());
stepInfo.put("actUserName", logDO.getActUserName());
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);
// 定位步骤,添加经纬度信息
if (logDO.getLatitude() != null || logDO.getLongitude() != null) {
JSONObject location = new JSONObject();
location.put("latitude", logDO.getLatitude());
location.put("longitude", logDO.getLongitude());
stepInfo.put("location", location);
}
infoJson.put("step_" + logDO.getStepId(), stepInfo);
}
// 更新到数据库
infoDO.setInfo(infoJson.toJSONString());
eightworkInfoRepository.updateById(infoDO);
log.info("已更新作业 info: workId={}", workId);
log.info("已批量更新步骤 info: workId={}, count={}", workId, actionLogs.size());
}
}

View File

@ -55,7 +55,7 @@ public class TaskLogServiceImpl implements TaskLogServiceI {
TaskLogNextCmd taskLogNextCmd = new TaskLogNextCmd(commitTaskLogDO.getId(),
commitTaskLogDO.getWorkId(),
commitTaskLogDO.getStepId(),
TaskLogStatus.APPROVED.getCode(),null,null,null,null);
TaskLogStatus.APPROVED.getCode(),null,null,null,cmd.getOthers());
taskLogUpdateExe.nextStep(taskLogNextCmd);
return SingleResponse.buildSuccess();

View File

@ -51,5 +51,7 @@ public class TaskLogAddCmd extends Command {
@ApiModelProperty(value = "部门id", name = "departmentId")
private Long departmentId;
@ApiModelProperty(value = "其他参数", name = "others")
private JSONObject others;
}

View File

@ -44,5 +44,11 @@ public class TaskLogNextCmd extends Command {
private List<TaskSignStepInfoCmd> signLogs;
@ApiModelProperty(value = "其他参数", name = "others")
private JSONObject others;
//纬度
@ApiModelProperty(value = "纬度")
private String latitude;
//经度
@ApiModelProperty(value = "经度")
private String longitude;
}

View File

@ -130,6 +130,12 @@ public class TaskLogCO extends ClientObject {
//持续步骤当前填写次数
@ApiModelProperty(value = "持续步骤当前填写次数")
private Integer currentFillTimes;
//纬度
@ApiModelProperty(value = "纬度")
private String latitude;
//经度
@ApiModelProperty(value = "经度")
private String longitude;
@ApiModelProperty(value = "当前步骤需设置的签字人")
List<TaskLogCO> settingSignSteps;

View File

@ -89,6 +89,10 @@ public class TaskLogE extends BaseE {
private Long blockingStepId;
//持续步骤当前填写次数
private Integer currentFillTimes;
//纬度
private String latitude;
//经度
private String longitude;
public TaskLogE(TaskLogE log) {
this.taskLogId = log.getTaskLogId();
@ -122,6 +126,8 @@ public class TaskLogE extends BaseE {
this.minFillTimes = log.getMinFillTimes();
this.blockingStepId = log.getBlockingStepId();
this.currentFillTimes = log.getCurrentFillTimes();
this.latitude = log.getLatitude();
this.longitude = log.getLongitude();
}

View File

@ -22,9 +22,6 @@ public class MeasuresLogsDO extends BaseDO {
//作业类型
@ApiModelProperty(value = "作业类型")
private String workType;
//填写步骤名
@ApiModelProperty(value = "填写步骤名")
private String stepName;
//防护措施
@ApiModelProperty(value = "防护措施")
private String content;

View File

@ -128,6 +128,12 @@ public class TaskLogDO extends BaseDO {
//持续步骤当前填写次数
@ApiModelProperty(value = "持续步骤当前填写次数")
private Integer currentFillTimes;
//纬度
@ApiModelProperty(value = "纬度")
private String latitude;
//经度
@ApiModelProperty(value = "经度")
private String longitude;
public TaskLogDO(String taskLogId) {
this.taskLogId = taskLogId;