Browse Source

# 线下工作票工作流程

zhongwei
haungxing 11 months ago
parent
commit
346a022986
  1. 5
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java
  2. 24
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/ticketprocess/feign/IOfflineTicketProcessClient.java
  3. 15
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/ticketprocess/feign/OfflineTicketProcessClientFallback.java
  4. 41
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineTicketProcessImpl.java
  5. 1
      hzims-service/hzims-middle/src/main/resources/db/1.0.2.sql
  6. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java
  7. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java
  8. 26
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/feign/OfflineTicketProcessClient.java
  9. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java
  10. 8
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java
  11. 98
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java
  12. 119
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  13. 129
      hzims-service/ticket/src/main/resources/file/线下工作票审批流程.bpmn20.xml

5
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java

@ -52,4 +52,9 @@ public class TicketProcessConstant {
* 值班计划
*/
public static final String DUTY_REC = "duty_rec";
/**
* 线下工作票
*/
public static final String OFFLINE_WORK_TICKET = "offlineWorkTicket";
}

24
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/ticketprocess/feign/IOfflineTicketProcessClient.java

@ -0,0 +1,24 @@
package com.hnac.hzims.ticket.ticketprocess.feign;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.constants.TicketConstants;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(value = TicketConstants.APP_NAME,fallback = OfflineTicketProcessClientFallback.class)
public interface IOfflineTicketProcessClient {
String API = "/offlineTicket";
String FIND_PENDING = API + "/findPending";
/**
* 线下工作票处理
* @param response 流程信息
* @return 处理结果
*/
@PostMapping(FIND_PENDING)
R findPending(@RequestBody ProcessWorkFlowResponse response);
}

15
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/ticketprocess/feign/OfflineTicketProcessClientFallback.java

@ -0,0 +1,15 @@
package com.hnac.hzims.ticket.ticketprocess.feign;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
@Component
public class OfflineTicketProcessClientFallback implements IOfflineTicketProcessClient {
@Override
public R findPending(ProcessWorkFlowResponse response) {
return R.fail("工作票处理流程失败!");
}
}

41
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineTicketProcessImpl.java

@ -0,0 +1,41 @@
package com.hnac.hzims.middle.processflow.strategy.serviceimpl;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.middle.processflow.service.ProcessDictService;
import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService;
import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue;
import com.hnac.hzims.ticket.ticketprocess.feign.IOfflineTicketProcessClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OFFLINE_WORK_TICKET;
@Slf4j
@Service
@AllArgsConstructor
public class OfflineTicketProcessImpl extends ProcessAbstractService {
private final ProcessDictService processDictService;
private final IOfflineTicketProcessClient offlineTicketProcessClient;
@Override
public Boolean isWorkflowProcess(WorkflowQueue flowQueue) {
String dictValue = processDictService.selectDictValueByKey(OFFLINE_WORK_TICKET);
return dictValue.equals(flowQueue.getProcessDefinitionKey());
}
@Override
public void calculate(ProcessWorkFlowResponse response) {
log.info("线下工作票调用fein接口消费开始---param",response);
R result = offlineTicketProcessClient.findPending(response);
Assert.isTrue(result.isSuccess(),() -> {
throw new ServiceException("线下工作票处理失败!");
});
log.info("线下工作票调用fein接口消费结束---");
}
}

1
hzims-service/hzims-middle/src/main/resources/db/1.0.2.sql

@ -0,0 +1 @@
INSERT INTO `process_dict` (`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (9, 9, 'offlineWorkTicket', 'offlineWorkTicket', '线下工作票', '线下工作票', 'Y', 0, NULL, '2023-12-28 16:35:10', '2023-12-28 16:35:14', '线下工作票流程');

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.operational.defect.constants.DefectConstant;
@ -15,6 +16,7 @@ import com.hnac.hzinfo.inspect.task.mapper.TaskEventMapper;
import com.hnac.hzinfo.inspect.task.service.*;
import com.hnac.hzinfo.inspect.task.vo.EventAddVO;
import com.hnac.hzinfo.inspect.task.vo.EventRecordAddVO;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.mp.base.BaseServiceImpl;
@ -43,6 +45,7 @@ import java.util.List;
* @author Chill
*/
@Service
@Slf4j
public class EventServiceImpl extends BaseServiceImpl<TaskEventMapper, EventEntity> implements IEventService {
@Autowired
@ -187,7 +190,9 @@ public class EventServiceImpl extends BaseServiceImpl<TaskEventMapper, EventEnti
if(!AuthUtil.isAdministrator()){
ITaskService taskService = SpringUtil.getBean(ITaskService.class);
TaskEntity taskEntity = taskService.getById(eventVO.getTaskId());
log.info("userId:"+ (user == null ? eventVO.getUserId() : user.getUserId()) + ";taskId:" + eventVO.getTaskId() );
TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).eq(TaskUserEntity::getUserId,user == null ? eventVO.getUserId() : user.getUserId()));
log.info("taskUserEntity:"+JSON.toJSONString(taskUserEntity));
if(taskUserEntity==null){
throw new ServiceException("该任务已被别人领取");
}

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java

@ -282,7 +282,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
taskUserService.update(Wrappers.<TaskUserEntity>lambdaUpdate().set(TaskUserEntity::getClaimStatus, ClaimStatusEnum.COLLECT.getStatus()).set(TaskUserEntity::getClaimTime, LocalDateTime.now()).eq(TaskUserEntity::getTaskId, task.getId()).eq(TaskUserEntity::getUserId, userId));
//如果是抢占任务,删除能够抢占此任务的其他人
if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) {
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getId, userId));
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, task.getId()).ne(TaskUserEntity::getUserId, userId));
}
task.setStatus(Integer.valueOf(TaskStatusEnum.UNDERWAY_STATUS.getStatus()));
task.setStartTime(LocalDateTime.now());

26
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/feign/OfflineTicketProcessClient.java

@ -0,0 +1,26 @@
package com.hnac.hzims.ticket.redisConsume.feign;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.ticketprocess.feign.IOfflineTicketProcessClient;
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
@Slf4j
public class OfflineTicketProcessClient implements IOfflineTicketProcessClient {
private final TicketProcessService processService;
@Override
@PostMapping(FIND_PENDING)
public R findPending(@RequestBody ProcessWorkFlowResponse response) {
return R.status(processService.offlineTicketFindPending(response));
}
}

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java

@ -45,6 +45,11 @@ public class TicketProcessController {
return R.data(ticketId);
}
@ApiOperation("开启工作票线下流程")
@PostMapping("/startUpOfflineTicket")
public R<Long> startUpOfflineTicket(@RequestBody WorkTicketVo workTicketVo) {
return R.data(ticketProcessService.startUpOfflineTicket(workTicketVo));
}
/**
* 工作票待处理

8
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java

@ -27,6 +27,12 @@ public interface TicketProcessService {
*/
void findPending(ProcessWorkFlowResponse response);
/**
* 线下工作票流程处理
* @param response 流程信息
* @return 处理结果
*/
Boolean offlineTicketFindPending(ProcessWorkFlowResponse response);
/**
@ -46,4 +52,6 @@ public interface TicketProcessService {
* @param value
*/
public void getDataConversion(Map<String, Object> dataConversion, String key, Object value);
Long startUpOfflineTicket(WorkTicketVo workTicketVo);
}

98
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.message.entity.config.PushConfigEntity;
import com.hnac.hzims.message.fegin.IMessageConfigClient;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
@ -21,13 +22,11 @@ import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService;
import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO;
import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.constants.WorkTicketConstants;
import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService;
import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService;
import com.hnac.hzims.ticket.utils.AsposeUtil;
import com.hnac.hzims.ticket.utils.ExcelUtil;
import com.hnac.hzims.ticket.utils.ObjectUtils;
import com.hnac.hzims.ticket.utils.PdfUtils;
import com.hnac.hzims.ticket.utils.*;
import com.hnac.hzims.ticket.workTicket.dto.*;
import com.hnac.hzims.ticket.workTicket.entity.*;
import com.hnac.hzims.ticket.workTicket.mapper.WorkDelayNoScopeMapper;
@ -39,7 +38,7 @@ import com.hnac.hzims.ticket.workTicket.wrapper.WorkTicketInfoWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.*;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
@ -54,14 +53,19 @@ import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.ResourceUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -69,6 +73,8 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.aspectj.weaver.tools.cache.SimpleCacheFactory.path;
/**
* @author hx
*/
@ -280,13 +286,23 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
@Override
public void preview(HttpServletResponse response,Long ticketId) {
WorkTicketInfoEntity workTicketInfoEntity = this.getById(ticketId);
Map params = this.getTicketParamById(ticketId,workTicketInfoEntity);
Map<String,Object> params = this.getTicketParamById(ticketId,workTicketInfoEntity);
String tempFileName = WorkTicketConstants.TicketSignageEnum.getTempFileNameByType(workTicketInfoEntity.getType());
Assert.isTrue(StringUtil.isNotBlank(tempFileName),() -> {
throw new ServiceException("未找到模板文件,预览失败!");
});
String wordPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".docx";
this.exportTicketWord("template/"+tempFileName, wordPath, params);
List<XWPFDocument> documents;
try {
documents = this.getDocuments(workTicketInfoEntity, params);
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
this.exportTicketWord(documents,wordPath);
} catch (IOException e) {
throw new RuntimeException(e);
}
String pdfPath = this.getFileSavePath() + params.get("code") + "_" + params.get("addressEquName") +".pdf";
AsposeUtil.wordToPdf(wordPath,pdfPath);
PdfUtils.readPdf(response,pdfPath);
@ -371,38 +387,60 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
}
return params;
}
/**
* word模板填充内容并将结果导出
* @param templatePath 模板路径
* @param savePath 结果导出路径
* @param params 填充对象
*/
private void exportTicketWord(String templatePath, String savePath, Map params) {
private List<XWPFDocument> getDocuments(WorkTicketInfoEntity workTicketInfo,Map<String,Object> params) {
List<XWPFDocument> result = Lists.newArrayList();
XWPFDocument document = this.fillDocument("template/" + WorkTicketConstants.TicketSignageEnum.getTempFileNameByType(workTicketInfo.getType()), params);
result.add(document);
//安全隔离措施附页 (true,展示附件,false,不展示附件)
if (workTicketInfo.getIsSafety()) {
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.SECURE_PAGE, params);
result.add(xwpfDocument);
}
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
if (workTicketInfo.getIsHazard()) {
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.SAFETY_PAGE, params);
result.add(xwpfDocument);
}
//动火工作票 (true,展示附件,false,不展示附件)
if (workTicketInfo.getIsRailway()) {
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.FLIGHT_PAGE, params);
result.add(xwpfDocument);
}
//有限空间监测记录单(true,展示附件,false,不展示附件)
if (workTicketInfo.getIsLimited()) {
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.SPACE_PAGE, params);
result.add(xwpfDocument);
}
//每日开工和收工时间附页
if (workTicketInfo.getIsStart()) {
XWPFDocument xwpfDocument = this.fillDocument("template/" + TicketConstant.START_PAGE, params);
result.add(xwpfDocument);
}
return result;
}
private XWPFDocument fillDocument(String templatePath, Map params) {
XWPFDocument xwpfDocument = null;
try {
xwpfDocument = WordExportUtil.exportWord07(templatePath, params);
} catch (Exception e) {
e.printStackTrace();
}
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(savePath);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
return xwpfDocument;
}
try {
xwpfDocument.write(outputStream);
}
catch(Exception e) {
e.printStackTrace();
}
finally {
try {
outputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
private void exportTicketWord(List<XWPFDocument> documents, String savePath) throws IOException {
FileOutputStream out = new FileOutputStream(savePath, true);
Path file = Paths.get(path);
if(Files.exists(file)) {
Files.delete(file);
}
new File(savePath).createNewFile();
for (XWPFDocument document : documents) {
document.write(out);
}
out.close();
}
@Override

119
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
@ -61,6 +62,7 @@ import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@ -488,6 +490,64 @@ public class TicketProcessServiceImpl implements TicketProcessService {
}
@Override
public Boolean offlineTicketFindPending(ProcessWorkFlowResponse response) {
log.info("线下工作票接收到的工作票数据为:{}",JSON.toJSONString(response));
FristWorkTicketVo ticketResponse = JSONObject.parseObject(JSON.toJSONString(response.getVariables()),FristWorkTicketVo.class);
Assert.isTrue(ObjectUtil.isNotEmpty(ticketResponse),() -> {
log.error("接收到的数据为:{}",JSON.toJSONString(response.getVariables()));
throw new ServiceException("线下工作票处理流程环节接收数据失败,请联系管理员");
});
WorkTicketVo workTicketVo = ticketResponse.getWorkTicketVo();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
WorkTicketInfoEntity info = firstWorkTicketService.getById(workTicket.getId());
if(ObjectUtil.isEmpty(info)) {
return true;
}
workTicket.setProcessInstanceId(response.getProcessInstanceId());
this.saveWorkTicket(workTicket,response);
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if(CollectionUtil.isNotEmpty(safetyMeasuresList)) {
workTicketSafetyMeasureService.saveOrUpdateBatch(safetyMeasuresList);
}
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
if(CollectionUtil.isNotEmpty(workTicketContentDtoList)) {
contentService.saveOrUpdateBatch(workTicketContentDtoList);
}
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
if(CollectionUtil.isNotEmpty(workTicketContentDtoList)) {
workTicketFinishService.saveOrUpdate(workTicketFinish);
}
// 推送消息
new Thread(() -> this.sendMessage(workTicket,response.getUserId())).start();
return true;
}
/**
* 推送消息
* @param ticketInfo 票据信息
*/
private void sendMessage(WorkTicketInfoEntity ticketInfo,String userIds) {
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(ticketInfo.getId());
businessMessageDTO.setTenantId(ticketInfo.getTenantId());
String content = "您有一张线下工作票待审批,工作内容: ".concat(ticketInfo.getWorkContent()).concat(",审批环节: ").concat(ticketInfo.getTaskName());
businessMessageDTO.setContent(content);
businessMessageDTO.setDeptId(ticketInfo.getCreateDept());
R<String> deptName = sysClient.getDeptName(ticketInfo.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
}
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(ticketInfo.getCreateUser());
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
}
}
/**
* 保存流程描述
@ -1298,6 +1358,65 @@ public class TicketProcessServiceImpl implements TicketProcessService {
}
}
@Override
@Transactional
public Long startUpOfflineTicket(WorkTicketVo workTicketVo) {
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
this.saveOfflineTicket(workTicket);
this.saveSafetyMeasures(workTicketVo.getSafetyMeasuresList(), workTicketVo.getWorkTicket());
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket());
// 开启工作流
String processInstanceId = this.startOfflineTicketProcess(workTicketVo);
return workTicket.getId();
}
/**
* 开启线下工作票流程
* @param workTicketVo 工作票
* @return 工作流实例ID
*/
private String startOfflineTicketProcess(WorkTicketVo workTicketVo) {
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
Map<String, Object> params = new HashMap<>();
workTicketVo.setWorkTicket(workTicket);
params.put("workTicketVo",workTicketVo);
R<BladeFlow> flowR =
flowClient.startProcessInstanceContainNameByKey("offlineWorkTicket",String.valueOf(workTicket.getId()),workTicket.getWorkContent(), params);
Assert.isTrue(flowR.isSuccess(),() -> {
throw new ServiceException("开启工作流失败,请联系管理员");
});
return flowR.getData().getProcessInstanceId();
}
/**
* 保存线下工作票
* @param workTicket 工作票信息
*/
private void saveOfflineTicket(WorkTicketInfoEntity workTicket) {
StationEntity stationEntity = new StationEntity();
stationEntity.setCode(workTicket.getSignageCode());
R<StationEntity> stationR = stationClient.getOne(stationEntity);
Assert.isTrue(stationR.isSuccess() && Func.isNotEmpty(stationR.getData().getSignage()),() -> {
throw new ServiceException("获取站点两票抬头失败");
});
workTicket.setSignage(stationR.getData().getSignage());
workTicket.setSignageCode(stationR.getData().getCode());
String code = processDictFeignService.getTicketByCode(workTicket.getSignage(), this.getTicketWichCode(workTicket.getType()));
workTicket.setCode(code);
Assert.isTrue(StringUtils.isNotBlank(code),() -> {
throw new ServiceException("生成两票编号失败,请联系管理员!");
});
workTicket.setStepOperator(AuthUtil.getUserName());
workTicket.setIsSafety(false);
workTicket.setIsHazard(false);
workTicket.setIsRailway(false);
workTicket.setIsLimited(false);
Assert.isTrue(firstWorkTicketService.save(workTicket),()-> {
throw new ServiceException("工作票保存失败");
});
}
/**
* 工作类型生成工作票类型
*/

129
hzims-service/ticket/src/main/resources/file/线下工作票审批流程.bpmn20.xml

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
<process id="offlineWorkTicket" name="线下工作票审批流程" isExecutable="true">
<startEvent id="startEvent1"></startEvent>
<userTask id="sid-194BD702-29AE-4DA6-A343-05464D12BB83" name="签发人签发" flowable:candidateGroups="signer">
<extensionElements>
<flowable:taskListener event="create" class="org.springblade.flow.engine.listener.DynamicTaskUserListener"></flowable:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="sid-EB9D9A51-ACB2-47FA-98CF-042CF7AF19FA" sourceRef="startEvent1" targetRef="sid-194BD702-29AE-4DA6-A343-05464D12BB83"></sequenceFlow>
<exclusiveGateway id="sid-C055B0CF-183B-4BFF-B9CA-D5C420311421"></exclusiveGateway>
<userTask id="sid-2CCB5862-1AB2-4327-9FBE-A11DC613B258" name="运行人员接收" flowable:candidateGroups="operatingCrew">
<extensionElements>
<flowable:taskListener event="create" class="org.springblade.flow.engine.listener.DynamicTaskUserListener"></flowable:taskListener>
</extensionElements>
</userTask>
<exclusiveGateway id="sid-24261C82-08E4-4F0A-B069-5F2BB1E1ECEF"></exclusiveGateway>
<sequenceFlow id="sid-2BD654BF-BFE4-481D-A710-185D10F7C413" sourceRef="sid-2CCB5862-1AB2-4327-9FBE-A11DC613B258" targetRef="sid-24261C82-08E4-4F0A-B069-5F2BB1E1ECEF"></sequenceFlow>
<userTask id="sid-33C2D3CB-1B69-4234-9AE9-3747F37BE8C5" name="许可人许可" flowable:candidateGroups="licensor">
<extensionElements>
<flowable:taskListener event="create" class="org.springblade.flow.engine.listener.DynamicTaskUserListener"></flowable:taskListener>
</extensionElements>
</userTask>
<userTask id="sid-1D70C4B2-A79B-4C02-AA30-9D755484C4B6" name="工作结束">
<extensionElements>
<flowable:taskListener event="create" class="org.springblade.flow.engine.listener.DynamicTaskUserListener"></flowable:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="sid-9FDA7FDD-A163-4496-B850-77C7A44C3F1F" sourceRef="sid-33C2D3CB-1B69-4234-9AE9-3747F37BE8C5" targetRef="sid-1D70C4B2-A79B-4C02-AA30-9D755484C4B6"></sequenceFlow>
<userTask id="sid-7A6326EA-6129-47EF-88D1-0FC14033B25A" name="工作票终结">
<extensionElements>
<flowable:taskListener event="create" class="org.springblade.flow.engine.listener.DynamicTaskUserListener"></flowable:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="sid-BE7A2AB4-4D34-43F6-BDDC-C2CB53F964B7" sourceRef="sid-1D70C4B2-A79B-4C02-AA30-9D755484C4B6" targetRef="sid-7A6326EA-6129-47EF-88D1-0FC14033B25A"></sequenceFlow>
<endEvent id="sid-6C4B76B7-BADC-4BE8-B1D2-2AF12FF547EC"></endEvent>
<sequenceFlow id="sid-EF45DC9B-AEAF-4609-8367-E8522F3CCA1C" sourceRef="sid-7A6326EA-6129-47EF-88D1-0FC14033B25A" targetRef="sid-6C4B76B7-BADC-4BE8-B1D2-2AF12FF547EC"></sequenceFlow>
<endEvent id="sid-766AC388-0E41-4887-A1D7-6146841CAACC"></endEvent>
<sequenceFlow id="sid-E08A5631-D8B8-4B09-85F0-4BF865E4C2A8" sourceRef="sid-194BD702-29AE-4DA6-A343-05464D12BB83" targetRef="sid-C055B0CF-183B-4BFF-B9CA-D5C420311421"></sequenceFlow>
<sequenceFlow id="sid-734786FF-1E1B-41E0-BACC-C2D3AF52082A" sourceRef="sid-24261C82-08E4-4F0A-B069-5F2BB1E1ECEF" targetRef="sid-33C2D3CB-1B69-4234-9AE9-3747F37BE8C5">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${recieveFlag==true}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-6B609D97-1BF7-44BC-9B53-898C6D2762EE" name="作废" sourceRef="sid-24261C82-08E4-4F0A-B069-5F2BB1E1ECEF" targetRef="sid-766AC388-0E41-4887-A1D7-6146841CAACC">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${recieveFlag==false}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-44C46EFD-79F0-499E-AF70-9346E510A717" name="作废" sourceRef="sid-C055B0CF-183B-4BFF-B9CA-D5C420311421" targetRef="sid-766AC388-0E41-4887-A1D7-6146841CAACC">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${signFlag==false}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-34DE7872-57AB-43B6-8166-09D1FA2D5ADF" sourceRef="sid-C055B0CF-183B-4BFF-B9CA-D5C420311421" targetRef="sid-2CCB5862-1AB2-4327-9FBE-A11DC613B258">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${signFlag==true}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_offlineWorkTicket">
<bpmndi:BPMNPlane bpmnElement="offlineWorkTicket" id="BPMNPlane_offlineWorkTicket">
<bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
<omgdc:Bounds height="30.0" width="30.0" x="74.99999888241292" y="359.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-194BD702-29AE-4DA6-A343-05464D12BB83" id="BPMNShape_sid-194BD702-29AE-4DA6-A343-05464D12BB83">
<omgdc:Bounds height="80.0" width="100.0" x="149.9999988824129" y="334.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-C055B0CF-183B-4BFF-B9CA-D5C420311421" id="BPMNShape_sid-C055B0CF-183B-4BFF-B9CA-D5C420311421">
<omgdc:Bounds height="40.0" width="40.0" x="294.9999988824129" y="354.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-2CCB5862-1AB2-4327-9FBE-A11DC613B258" id="BPMNShape_sid-2CCB5862-1AB2-4327-9FBE-A11DC613B258">
<omgdc:Bounds height="80.0" width="100.0" x="379.9999988824129" y="334.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-24261C82-08E4-4F0A-B069-5F2BB1E1ECEF" id="BPMNShape_sid-24261C82-08E4-4F0A-B069-5F2BB1E1ECEF">
<omgdc:Bounds height="40.0" width="40.0" x="524.9999988824129" y="354.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-33C2D3CB-1B69-4234-9AE9-3747F37BE8C5" id="BPMNShape_sid-33C2D3CB-1B69-4234-9AE9-3747F37BE8C5">
<omgdc:Bounds height="80.0" width="100.0" x="609.9999988824129" y="334.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-1D70C4B2-A79B-4C02-AA30-9D755484C4B6" id="BPMNShape_sid-1D70C4B2-A79B-4C02-AA30-9D755484C4B6">
<omgdc:Bounds height="80.0" width="100.0" x="754.9999988824129" y="334.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-7A6326EA-6129-47EF-88D1-0FC14033B25A" id="BPMNShape_sid-7A6326EA-6129-47EF-88D1-0FC14033B25A">
<omgdc:Bounds height="80.0" width="100.0" x="899.9999988824129" y="334.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-6C4B76B7-BADC-4BE8-B1D2-2AF12FF547EC" id="BPMNShape_sid-6C4B76B7-BADC-4BE8-B1D2-2AF12FF547EC">
<omgdc:Bounds height="28.0" width="28.0" x="1044.999998882413" y="360.999994635582"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-766AC388-0E41-4887-A1D7-6146841CAACC" id="BPMNShape_sid-766AC388-0E41-4887-A1D7-6146841CAACC">
<omgdc:Bounds height="28.0" width="28.0" x="415.99999268352997" y="284.9999957531691"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-E08A5631-D8B8-4B09-85F0-4BF865E4C2A8" id="BPMNEdge_sid-E08A5631-D8B8-4B09-85F0-4BF865E4C2A8">
<omgdi:waypoint x="249.9499988823975" y="375.2162284018157"></omgdi:waypoint>
<omgdi:waypoint x="295.4130423606618" y="375.41303811384284"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-44C46EFD-79F0-499E-AF70-9346E510A717" id="BPMNEdge_sid-44C46EFD-79F0-499E-AF70-9346E510A717">
<omgdi:waypoint x="315.4999988824129" y="355.499994635582"></omgdi:waypoint>
<omgdi:waypoint x="315.4999988824129" y="298.9999957531691"></omgdi:waypoint>
<omgdi:waypoint x="415.99999268352997" y="298.9999957531691"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-BE7A2AB4-4D34-43F6-BDDC-C2CB53F964B7" id="BPMNEdge_sid-BE7A2AB4-4D34-43F6-BDDC-C2CB53F964B7">
<omgdi:waypoint x="854.9499988824128" y="374.999994635582"></omgdi:waypoint>
<omgdi:waypoint x="899.9999988823936" y="374.999994635582"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-2BD654BF-BFE4-481D-A710-185D10F7C413" id="BPMNEdge_sid-2BD654BF-BFE4-481D-A710-185D10F7C413">
<omgdi:waypoint x="479.9499988824106" y="375.2162284018158"></omgdi:waypoint>
<omgdi:waypoint x="525.4130423606738" y="375.4130381138429"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-6B609D97-1BF7-44BC-9B53-898C6D2762EE" id="BPMNEdge_sid-6B609D97-1BF7-44BC-9B53-898C6D2762EE">
<omgdi:waypoint x="545.4999988824129" y="355.499994635582"></omgdi:waypoint>
<omgdi:waypoint x="545.4999988824129" y="298.9999957531691"></omgdi:waypoint>
<omgdi:waypoint x="443.9499235883342" y="298.9999957531691"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-9FDA7FDD-A163-4496-B850-77C7A44C3F1F" id="BPMNEdge_sid-9FDA7FDD-A163-4496-B850-77C7A44C3F1F">
<omgdi:waypoint x="709.9499988824128" y="374.999994635582"></omgdi:waypoint>
<omgdi:waypoint x="754.9999988823936" y="374.999994635582"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-EF45DC9B-AEAF-4609-8367-E8522F3CCA1C" id="BPMNEdge_sid-EF45DC9B-AEAF-4609-8367-E8522F3CCA1C">
<omgdi:waypoint x="999.9499988823469" y="374.999994635582"></omgdi:waypoint>
<omgdi:waypoint x="1044.999998882413" y="374.999994635582"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-EB9D9A51-ACB2-47FA-98CF-042CF7AF19FA" id="BPMNEdge_sid-EB9D9A51-ACB2-47FA-98CF-042CF7AF19FA">
<omgdi:waypoint x="104.94999737237052" y="374.999994635582"></omgdi:waypoint>
<omgdi:waypoint x="149.9999988824046" y="374.999994635582"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-34DE7872-57AB-43B6-8166-09D1FA2D5ADF" id="BPMNEdge_sid-34DE7872-57AB-43B6-8166-09D1FA2D5ADF">
<omgdi:waypoint x="334.52473595515613" y="375.4166613022487"></omgdi:waypoint>
<omgdi:waypoint x="379.999998882401" y="375.2181169063244"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-734786FF-1E1B-41E0-BACC-C2D3AF52082A" id="BPMNEdge_sid-734786FF-1E1B-41E0-BACC-C2D3AF52082A">
<omgdi:waypoint x="564.5247359551561" y="375.4166613022487"></omgdi:waypoint>
<omgdi:waypoint x="609.9999988824129" y="375.2181169063244"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Loading…
Cancel
Save