feat(task): 添加任务日志地理位置功能并优化批量更新逻辑
- 新增 latitude 和 longitude 字段支持位置信息存储 - 移除重复步骤去重逻辑,直接批量更新所有日志 - 添加智能步骤合并方法,避免同一步骤多次更新数据丢失 - 在定位步骤中保存经纬度信息到任务日志 - 更新八工信息时包含位置数据 - 扩展 DTO 对象以支持位置信息传输master
parent
d9307f1e4f
commit
b1e94239d7
|
|
@ -40,6 +40,7 @@ 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;
|
||||
|
||||
|
||||
|
|
@ -146,12 +147,11 @@ public class TaskLogUpdateExe {
|
|||
handleSignStepsIfNeeded(currentLog, cmd, actionLogs, logs);
|
||||
}
|
||||
|
||||
// 批量更新 task_log(先去重,避免同一步骤被多次更新导致数据丢失)
|
||||
List<TaskLogDO> uniqueActionLogs = deduplicateActionLogs(actionLogs);
|
||||
taskLogRepository.updateBatchById(uniqueActionLogs);
|
||||
// 批量更新 task_log
|
||||
taskLogRepository.updateBatchById(actionLogs);
|
||||
|
||||
// 批量更新 eightworkInfo.info(只更新本次变化的步骤)
|
||||
updateEightworkInfo(cmd.getWorkId(), uniqueActionLogs);
|
||||
updateEightworkInfo(cmd.getWorkId(), actionLogs);
|
||||
|
||||
log.info("步骤流转完成: workId={}, currentStep={}", cmd.getWorkId(), currentLog.getStepName());
|
||||
}
|
||||
|
|
@ -182,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -271,7 +278,7 @@ public class TaskLogUpdateExe {
|
|||
|
||||
// 修改当前步骤状态为已完成
|
||||
currentLog.setStatus(TaskLogStatus.APPROVED.getCode());
|
||||
actionLogs.add(TaskLogConvertUtil.toDO(currentLog));
|
||||
addActionLog(actionLogs, currentLog);
|
||||
|
||||
// 延时转交步骤不自动流转下一步
|
||||
return false;
|
||||
|
|
@ -329,7 +336,7 @@ public class TaskLogUpdateExe {
|
|||
currentLog.setStatus(TaskLogStatus.IN_PROGRESS.getCode());
|
||||
|
||||
// 添加到待更新列表
|
||||
actionLogs.add(TaskLogConvertUtil.toDO(currentLog));
|
||||
addActionLog(actionLogs, currentLog);
|
||||
|
||||
log.info("气体检测记录已保存,当前填写次数: {}", currentTimes + 1);
|
||||
|
||||
|
|
@ -510,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());
|
||||
|
|
@ -562,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());
|
||||
}
|
||||
|
|
@ -594,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 {
|
||||
// 设置签字人
|
||||
|
|
@ -605,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());
|
||||
}
|
||||
}
|
||||
|
|
@ -655,6 +662,63 @@ public class TaskLogUpdateExe {
|
|||
).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能添加步骤到待更新列表
|
||||
* 如果该步骤已存在,则合并修改(保留所有非空字段)
|
||||
* 如果不存在,则添加新记录
|
||||
*
|
||||
* @param actionLogs 当前待更新列表
|
||||
* @param taskLogE 要添加的步骤实体
|
||||
*/
|
||||
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 字段
|
||||
* 只更新本次变化的步骤,减少数据库操作
|
||||
|
|
@ -699,6 +763,14 @@ public class TaskLogUpdateExe {
|
|||
stepInfo.put("signTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
stepInfo.put("status", logDO.getStatus());
|
||||
|
||||
// 定位步骤,添加经纬度信息
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue