package jnpf.limsController;
|
|
import cn.dev33.satoken.annotation.SaCheckLogin;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jnpf.exception.DataException;
|
import jnpf.flowable.WorkFlowApi;
|
import jnpf.flowable.entity.TaskEntity;
|
import jnpf.limsEntity.LimsSxtFlowEventParam;
|
import jnpf.limsService.LimsWendingxingKaocaJihuaZhouqiService;
|
import jnpf.limsService.LimsWendingxingXiaohuiShenqingService;
|
import jnpf.util.R;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Map;
|
|
@Slf4j
|
@Tag(name = "lims稳定性考察计划接口", description = "稳定性考察计划周期变更")
|
@RestController
|
@SaCheckLogin
|
@RequestMapping("/lims/biz/wendingxing/kaoca/jihua")
|
public class LimsWendingxingKaocaJihuaController {
|
|
@Autowired
|
private LimsWendingxingKaocaJihuaZhouqiService zhouqiService;
|
@Autowired
|
private LimsWendingxingXiaohuiShenqingService xiaohuiService;
|
@Autowired
|
private WorkFlowApi workFlowApi;
|
|
@Operation(summary = "同步稳定性考察计划变更周期")
|
@PostMapping("/biangeng/zhouqi/tongbu")
|
public R<Integer> syncBiangengZhouqi(@RequestBody Map<String, String> params) {
|
String flowId = params == null ? null : params.get("flow_id");
|
String flowTaskId = params == null ? null : params.get("flow_task_id");
|
if (!StringUtils.hasText(flowId)) {
|
return R.error("流程ID(flow_id)不能为空");
|
}
|
if (!StringUtils.hasText(flowTaskId)) {
|
return R.error("流程任务ID(flow_task_id)不能为空");
|
}
|
int count = zhouqiService.syncByFlow(flowId.trim(), flowTaskId.trim());
|
return R.success("同步成功", count);
|
}
|
|
@Operation(summary = "同步稳定性销毁申请流程发起状态")
|
@PostMapping("/xiaohui/shenqing/flow-status/start")
|
public R<Object> syncXiaohuiFlowStarted(@RequestBody LimsSxtFlowEventParam param) {
|
String validationMessage = validateFlowEventParam(param);
|
if (validationMessage != null) {
|
return R.error(validationMessage);
|
}
|
try {
|
xiaohuiService.syncFlowStarted(param.getFlowId(), param.getTaskId());
|
return R.success();
|
} catch (DataException e) {
|
log.warn("稳定性销毁申请流程发起状态同步失败,flowId={}, taskId={}",
|
param.getFlowId(), param.getTaskId(), e);
|
return R.error(e.getMessage());
|
}
|
}
|
|
@Operation(summary = "同步稳定性销毁申请流程结束状态")
|
@PostMapping("/xiaohui/shenqing/flow-status/end")
|
public R<Object> syncXiaohuiFlowEnded(@RequestBody LimsSxtFlowEventParam param) {
|
String validationMessage = validateFlowEventParam(param);
|
if (validationMessage != null) {
|
return R.error(validationMessage);
|
}
|
TaskEntity task = workFlowApi.getInfoSubmit(param.getTaskId());
|
if (task == null) {
|
return R.error("未找到流程任务:" + param.getTaskId());
|
}
|
if (!param.getTaskId().equals(task.getId())) {
|
return R.error("流程任务与传入任务ID不匹配");
|
}
|
try {
|
xiaohuiService.syncFlowEnded(param.getFlowId(), param.getTaskId(), task.getStatus());
|
return R.success();
|
} catch (DataException e) {
|
log.warn("稳定性销毁申请流程结束状态同步失败,flowId={}, taskId={}, status={}",
|
param.getFlowId(), param.getTaskId(), task.getStatus(), e);
|
return R.error(e.getMessage());
|
}
|
}
|
|
private String validateFlowEventParam(LimsSxtFlowEventParam param) {
|
if (param == null) {
|
return "请求参数不能为空";
|
}
|
if (!StringUtils.hasText(param.getFlowId())) {
|
return "流程id(flow_id)不能为空";
|
}
|
if (!StringUtils.hasText(param.getTaskId())) {
|
return "流程任务id(task_id)不能为空";
|
}
|
return null;
|
}
|
}
|