From 5c1f794731bed6d20e8d66e79564a059a538d2a7 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 9 Jan 2024 15:53:44 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=B7=A5=E4=BD=9C=E4=BB=BB=E5=8A=A1=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/ticket/repair/entity/WorkTaskEntity.java | 68 +++++++++++++++++++++- .../repair/controller/WorkTaskController.java | 2 +- .../ticket/repair/service/IWorkTaskService.java | 2 +- .../repair/service/impl/WorkTaskServiceImpl.java | 47 ++++++++++++++- 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java index 5039c17..2965c3a 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java @@ -3,10 +3,13 @@ package com.hnac.hzims.ticket.repair.entity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import java.util.Date; + /** * @author ysj */ @@ -18,6 +21,69 @@ public class WorkTaskEntity extends TenantEntity { private static final long serialVersionUID = -3122149146340663132L; - + @ApiModelProperty(value = "工作任务单编号") + private String code; + + @ApiModelProperty(value = "工作负责人") + private Long head; + + @ApiModelProperty(value = "工作负责人名称") + private String headName; + + @ApiModelProperty(value = "工作负责人名称") + private Date headHandlTime; + + @ApiModelProperty(value = "班组ID") + private Long groupId; + + @ApiModelProperty(value = "班组成员ID : 按 “,”分割") + private String member; + + @ApiModelProperty(value = "班组成员名称 : 按 “,”分割") + private String memberName; + + @ApiModelProperty(value = "签名班组人员ID : 按 “,”分割") + private String signatureMember; + + @ApiModelProperty(value = "签名班组成员名称 : 按 “,”分割") + private String signatureMemberName; + + @ApiModelProperty(value = "工作计划开始时间") + private Date planStartTime; + + @ApiModelProperty(value = "工作计划结束时间") + private Date endStartTime; + + @ApiModelProperty(value = "工作任务") + private String workTask; + + @ApiModelProperty(value = "现场安全措施") + private String securityMeasures; + + @ApiModelProperty(value = "安全风险及预控措施") + private String riskPreControl; + + @ApiModelProperty(value = "许可人") + private Long licensor; + + @ApiModelProperty(value = "许可人名称") + private String licensorName; + + @ApiModelProperty(value = "许可时间") + private Date licensorTime; + + @ApiModelProperty(value = "工作结束时间") + private Date workEndTime; + + @ApiModelProperty(value = "备注") + private String memo; + + @ApiModelProperty(value = "工作流实例") + private String processInstanceId; + + @ApiModelProperty(value = "流程环节名称") + private String taskName; + @ApiModelProperty(value = "流程环节处理人") + private String nextStepOperator; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/controller/WorkTaskController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/controller/WorkTaskController.java index b5b573d..4ca1e79 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/controller/WorkTaskController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/controller/WorkTaskController.java @@ -48,6 +48,6 @@ public class WorkTaskController extends BladeController { @ApiOperationSupport(order = 1) @ApiOperation(value = "工作任务单") public R startV4(@RequestBody WorkTaskVO workTask) { - return R.status(workTaskService.startProcess(workTask)); + return R.status(workTaskService.start(workTask)); } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/IWorkTaskService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/IWorkTaskService.java index eb5d32c..aab73e2 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/IWorkTaskService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/IWorkTaskService.java @@ -10,7 +10,7 @@ import org.springblade.core.mp.base.BaseService; */ public interface IWorkTaskService extends BaseService { - boolean startProcess(WorkTaskVO workTask); + boolean start(WorkTaskVO workTask); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java index 904ed8e..392ff00 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java @@ -1,32 +1,65 @@ package com.hnac.hzims.ticket.repair.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity; import com.hnac.hzims.ticket.repair.mapper.WorkTaskMapper; import com.hnac.hzims.ticket.repair.service.IWorkTaskService; import com.hnac.hzims.ticket.repair.vo.WorkTaskVO; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.flow.core.entity.BladeFlow; +import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.flow.core.utils.FlowUtil; +import org.springblade.flow.core.utils.TaskUtil; import org.springframework.stereotype.Service; +import java.util.Map; + /** * @author ysj */ +@Slf4j @Service @RequiredArgsConstructor public class WorkTaskServiceImpl extends BaseServiceImpl implements IWorkTaskService { + private final IFlowClient flowClient; + /** * 工作任务单-开启流程 * @param workTask * @return */ @Override - public boolean startProcess(WorkTaskVO workTask) { + public boolean start(WorkTaskVO workTask) { // 步骤1.保存工作任务单 this.saveWorkTask(workTask); - return false; + // 步骤2.开启检修计划流程 + this.startProcess(workTask); + return true; + } + + private void startProcess(WorkTaskVO workTask) { + Map variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); + variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); + R result = flowClient.startProcessInstanceContainNameByKey("work_task", FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())), workTask.getCode(), variables); + log.error("work_task_start_process_result :{}",result); + // 更新任务流程Id + if (result.isSuccess()) { + BladeFlow flow = result.getData(); + workTask.setProcessInstanceId(flow.getProcessInstanceId()); + this.updateById(workTask); + } else { + throw new ServiceException("开启检修计划流程失败,code=" + result.getCode()); + } } /** @@ -34,6 +67,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl variables = (Map) processWorkFlowResponse.getVariables(); + WorkTaskVO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); + // 当前流程名称 + entity.setTaskName(processWorkFlowResponse.getTaskName()); + // 流程阶段执行人员名称 + entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); + + // 更新工作任务单信息 + this.updateById(entity); return false; } } \ No newline at end of file