Compare commits
2 Commits
bf10ad0b6f
...
b1e94239d7
| Author | SHA1 | Date |
|---|---|---|
|
|
b1e94239d7 | |
|
|
d9307f1e4f |
|
|
@ -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("详情")
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -51,5 +51,7 @@ public class TaskLogAddCmd extends Command {
|
|||
|
||||
@ApiModelProperty(value = "部门id", name = "departmentId")
|
||||
private Long departmentId;
|
||||
@ApiModelProperty(value = "其他参数", name = "others")
|
||||
private JSONObject others;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@ public class MeasuresLogsDO extends BaseDO {
|
|||
//作业类型
|
||||
@ApiModelProperty(value = "作业类型")
|
||||
private String workType;
|
||||
//填写步骤名
|
||||
@ApiModelProperty(value = "填写步骤名")
|
||||
private String stepName;
|
||||
//防护措施
|
||||
@ApiModelProperty(value = "防护措施")
|
||||
private String content;
|
||||
|
|
|
|||
|
|
@ -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