|
|
@ -3,13 +3,16 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; |
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.hnac.hzims.common.flow.StartProcessService; |
|
|
|
import com.hnac.hzims.common.flow.StartProcessService; |
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
|
|
|
|
import com.hnac.hzims.middle.process.feign.ICompensateProcessClient; |
|
|
|
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; |
|
|
|
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; |
|
|
|
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; |
|
|
|
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
|
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; |
|
|
|
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; |
|
|
|
import com.hnac.hzims.operational.feign.IAccessTaskClient; |
|
|
|
import com.hnac.hzims.operational.feign.IAccessTaskClient; |
|
|
@ -51,6 +54,7 @@ import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.flow.core.entity.BladeFlow; |
|
|
|
import org.springblade.flow.core.entity.BladeFlow; |
|
|
|
import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
|
|
|
|
import org.springblade.flow.core.utils.FlowUtil; |
|
|
|
import org.springblade.message.MessageConstants; |
|
|
|
import org.springblade.message.MessageConstants; |
|
|
|
import org.springblade.message.dto.BusinessMessageDTO; |
|
|
|
import org.springblade.message.dto.BusinessMessageDTO; |
|
|
|
import org.springblade.message.fegin.IMessageClient; |
|
|
|
import org.springblade.message.fegin.IMessageClient; |
|
|
@ -60,7 +64,9 @@ import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.PlatformTransactionManager; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import org.springframework.transaction.support.TransactionTemplate; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
@ -140,6 +146,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
@Value("${hzims.ticket.path.word.templatePath}") |
|
|
|
@Value("${hzims.ticket.path.word.templatePath}") |
|
|
|
private String templatePath; |
|
|
|
private String templatePath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ICompensateProcessClient compensateProcessClient; |
|
|
|
|
|
|
|
|
|
|
|
private final TicketInfoDangerService ticketInfoDangerService; |
|
|
|
private final TicketInfoDangerService ticketInfoDangerService; |
|
|
|
|
|
|
|
|
|
|
@ -162,7 +169,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
// @SneakyThrows
|
|
|
|
// @SneakyThrows
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
// @Transactional
|
|
|
|
public R startUp(WorkTicketVo workTicketVo) { |
|
|
|
public R startUp(WorkTicketVo workTicketVo) { |
|
|
|
log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); |
|
|
|
log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); |
|
|
|
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); |
|
|
|
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); |
|
|
@ -179,7 +186,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
R r = this.startProcess(saveEntity, dictValue,""); |
|
|
|
R r = this.startProcess(saveEntity, dictValue,""); |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private final PlatformTransactionManager transactionManager; |
|
|
|
|
|
|
|
private final TransactionTemplate transactionTemplate; |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String saveEntity(String entity) { |
|
|
|
public String saveEntity(String entity) { |
|
|
|
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); |
|
|
|
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); |
|
|
@ -208,7 +216,6 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); |
|
|
|
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); |
|
|
|
} |
|
|
|
} |
|
|
|
//signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2);
|
|
|
|
//signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2);
|
|
|
|
|
|
|
|
|
|
|
|
workTicketVo.getWorkTicket().setSignage(station.getSignage()); |
|
|
|
workTicketVo.getWorkTicket().setSignage(station.getSignage()); |
|
|
|
workTicketVo.getWorkTicket().setSignageCode(station.getCode()); |
|
|
|
workTicketVo.getWorkTicket().setSignageCode(station.getCode()); |
|
|
|
//2. 获取编码
|
|
|
|
//2. 获取编码
|
|
|
@ -217,6 +224,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
if (StringUtils.isBlank(code)) { |
|
|
|
if (StringUtils.isBlank(code)) { |
|
|
|
throw new ServiceException("服务器异常,请联系管理员"); |
|
|
|
throw new ServiceException("服务器异常,请联系管理员"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
transactionTemplate.setTransactionManager(transactionManager); |
|
|
|
|
|
|
|
String res = transactionTemplate.execute(status -> { |
|
|
|
workTicketVo.getWorkTicket().setCode(code); |
|
|
|
workTicketVo.getWorkTicket().setCode(code); |
|
|
|
//保存工作对象
|
|
|
|
//保存工作对象
|
|
|
|
log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket())); |
|
|
|
log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket())); |
|
|
@ -231,6 +240,8 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
//保存工作任务
|
|
|
|
//保存工作任务
|
|
|
|
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); |
|
|
|
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); |
|
|
|
return JSONObject.toJSONString(workTicketVo); |
|
|
|
return JSONObject.toJSONString(workTicketVo); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -245,7 +256,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { |
|
|
|
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { |
|
|
|
return R.success("线下流程,开票成功"); |
|
|
|
return R.success("线下流程,开票成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("workTicketVo", workTicketVo); |
|
|
|
params.put("workTicketVo", workTicketVo); |
|
|
|
//获取当前登录人
|
|
|
|
//获取当前登录人
|
|
|
|
Long userId = AuthUtil.getUserId(); |
|
|
|
Long userId = AuthUtil.getUserId(); |
|
|
@ -255,7 +266,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal()); |
|
|
|
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal()); |
|
|
|
} |
|
|
|
} |
|
|
|
//已开启流程
|
|
|
|
//已开启流程
|
|
|
|
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params); |
|
|
|
R processInstanceContainNameByKey = compensateProcessClient.startFlow( |
|
|
|
|
|
|
|
AuthUtil.getUserId().toString(),dictValue, |
|
|
|
|
|
|
|
FlowUtil.getBusinessKey("hzims_work_ticket_info",String.valueOf(workTicketVo.getWorkTicket().getId())), |
|
|
|
|
|
|
|
workTicketVo.getWorkTicket().getWorkContent(),params); |
|
|
|
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); |
|
|
|
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); |
|
|
|
if (!processInstanceContainNameByKey.isSuccess()) { |
|
|
|
if (!processInstanceContainNameByKey.isSuccess()) { |
|
|
|
//保存流程开始失败情况
|
|
|
|
//保存流程开始失败情况
|
|
|
@ -272,20 +286,24 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
r.setMsg("流程开启失败,请检查流程和用户权限后重试!"); |
|
|
|
r.setMsg("流程开启失败,请检查流程和用户权限后重试!"); |
|
|
|
r.setData(params); |
|
|
|
r.setData(params); |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
workTicket.setProcessInstanceId(processInstanceContainNameByKey.getData().toString()); |
|
|
|
|
|
|
|
workTicket.setIsNormal(true); |
|
|
|
|
|
|
|
firstWorkTicketService.updateById(workTicket); |
|
|
|
|
|
|
|
return R.success("启动流程成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); |
|
|
|
|
|
|
|
Duration between = Duration.between(start, Instant.now()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("================================================================"); |
|
|
|
|
|
|
|
log.info("耗时: " + (between.getSeconds()) + "秒"); |
|
|
|
|
|
|
|
log.info("耗时: " + (between.toMillis()) + "毫秒"); |
|
|
|
|
|
|
|
log.info("================================================================"); |
|
|
|
|
|
|
|
return R.success("启动流程成功"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R compensationProcess(String id) { |
|
|
|
public R compensationProcess(String id) { |
|
|
|
return null; |
|
|
|
WorkTicketInfoEntity entity = firstWorkTicketService.getById(id); |
|
|
|
|
|
|
|
if (ObjectUtils.isNotEmpty(entity)){ |
|
|
|
|
|
|
|
WorkTicketVo workTicketVo = new WorkTicketVo(); |
|
|
|
|
|
|
|
workTicketVo.setWorkTicket(entity); |
|
|
|
|
|
|
|
String dictValue = getDictValue(workTicketVo); |
|
|
|
|
|
|
|
return this.startProcess(JSON.toJSONString(entity), dictValue,entity.getRemark()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.fail("找不到对应流程数据,请稍后重试!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -321,7 +339,6 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void findPending(ProcessWorkFlowResponse response) { |
|
|
|
public void findPending(ProcessWorkFlowResponse response) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
log.info("获取待处理的数据 {}", response); |
|
|
|
log.info("获取待处理的数据 {}", response); |
|
|
|
log.info("获取businessKey: {}", response.getBusinessKey()); |
|
|
|
log.info("获取businessKey: {}", response.getBusinessKey()); |
|
|
@ -332,6 +349,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType()); |
|
|
|
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType()); |
|
|
|
//json转换表单
|
|
|
|
//json转换表单
|
|
|
|
String formData = JSON.toJSONString(response.getVariables()); |
|
|
|
String formData = JSON.toJSONString(response.getVariables()); |
|
|
|
|
|
|
|
if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ |
|
|
|
|
|
|
|
handException(response); |
|
|
|
|
|
|
|
return ; |
|
|
|
|
|
|
|
} |
|
|
|
log.info("获取表单的数据:{}", formData); |
|
|
|
log.info("获取表单的数据:{}", formData); |
|
|
|
FristWorkTicketVo fristWorkFlowResponse = null; |
|
|
|
FristWorkTicketVo fristWorkFlowResponse = null; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -343,6 +364,7 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
//获取表单数据
|
|
|
|
//获取表单数据
|
|
|
|
WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo(); |
|
|
|
WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
|
|
|
|
workTicket.setIsNormal(true); |
|
|
|
//2.流程处理
|
|
|
|
//2.流程处理
|
|
|
|
String businessKey = response.getBusinessKey(); |
|
|
|
String businessKey = response.getBusinessKey(); |
|
|
|
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey); |
|
|
|
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey); |
|
|
@ -503,10 +525,33 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
log.error("工作票流转失败,失败原因:{}",e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private R handException(ProcessWorkFlowResponse processWorkFlowResponse) { |
|
|
|
|
|
|
|
String[] split = processWorkFlowResponse.getBusinessKey().split(":"); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(split[1])){ |
|
|
|
|
|
|
|
log.error("异常消息转换失败,未找到BusinessKey:"+ processWorkFlowResponse); |
|
|
|
|
|
|
|
return R.fail("异常消息处理失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
WorkTicketInfoEntity workTicketInfoEntity = ticketInfoService.getOne(new LambdaQueryWrapper<WorkTicketInfoEntity>() {{ |
|
|
|
|
|
|
|
eq(WorkTicketInfoEntity::getId, split[1]); |
|
|
|
|
|
|
|
}}); |
|
|
|
|
|
|
|
workTicketInfoEntity.setIsNormal(false); |
|
|
|
|
|
|
|
workTicketInfoEntity.setRemark(JSONObject.toJSONString(processWorkFlowResponse.getVariables())); |
|
|
|
|
|
|
|
workTicketInfoEntity.setTaskName(processWorkFlowResponse.getTaskName()); |
|
|
|
|
|
|
|
workTicketInfoEntity.setProcessInstanceId(processWorkFlowResponse.getTaskId()); |
|
|
|
|
|
|
|
workTicketInfoEntity.setNextStepOperator(""); |
|
|
|
|
|
|
|
boolean flag = ticketInfoService.updateById(workTicketInfoEntity); |
|
|
|
|
|
|
|
if (!flag){ |
|
|
|
|
|
|
|
log.info("异常状态消息保存失败"+ processWorkFlowResponse); |
|
|
|
|
|
|
|
return R.success("消息保存失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.fail("消息保存成功"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Boolean offlineTicketFindPending(ProcessWorkFlowResponse response) { |
|
|
|
public Boolean offlineTicketFindPending(ProcessWorkFlowResponse response) { |
|
|
|
log.info("线下工作票接收到的工作票数据为:{}",JSON.toJSONString(response)); |
|
|
|
log.info("线下工作票接收到的工作票数据为:{}",JSON.toJSONString(response)); |
|
|
@ -515,6 +560,10 @@ public class TicketProcessServiceImpl implements TicketProcessService, StartProc |
|
|
|
log.error("接收到的数据为:{}",JSON.toJSONString(response.getVariables())); |
|
|
|
log.error("接收到的数据为:{}",JSON.toJSONString(response.getVariables())); |
|
|
|
throw new ServiceException("线下工作票处理流程环节接收数据失败,请联系管理员"); |
|
|
|
throw new ServiceException("线下工作票处理流程环节接收数据失败,请联系管理员"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if(ObjectUtils.isNotEmpty(response.getCode())&&700==response.getCode()){ |
|
|
|
|
|
|
|
handException(response); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
WorkTicketVo workTicketVo = ticketResponse.getWorkTicketVo(); |
|
|
|
WorkTicketVo workTicketVo = ticketResponse.getWorkTicketVo(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
WorkTicketInfoEntity info = firstWorkTicketService.getById(workTicket.getId()); |
|
|
|
WorkTicketInfoEntity info = firstWorkTicketService.getById(workTicket.getId()); |
|
|
|