|
|
|
@ -6,6 +6,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.hnac.hzims.common.flow.StartProcessService; |
|
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
|
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; |
|
|
|
|
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; |
|
|
|
@ -27,6 +28,7 @@ import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
|
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; |
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.utils.WordHelper; |
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.utils.WordMapUtils; |
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; |
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo; |
|
|
|
|
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo; |
|
|
|
|
import com.hnac.hzims.ticket.utils.MergeDocUtils; |
|
|
|
@ -87,7 +89,7 @@ import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.MACHI
|
|
|
|
|
@Slf4j |
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
@Service |
|
|
|
|
public class TicketProcessServiceImpl implements TicketProcessService { |
|
|
|
|
public class TicketProcessServiceImpl implements TicketProcessService, StartProcessService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IFlowClient flowClient; |
|
|
|
@ -159,12 +161,31 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
* |
|
|
|
|
* @param workTicketVo |
|
|
|
|
*/ |
|
|
|
|
@SneakyThrows |
|
|
|
|
// @SneakyThrows
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public Long startUp(WorkTicketVo workTicketVo) { |
|
|
|
|
log.info("ticket:start:request",JSON.toJSONString(workTicketVo)); |
|
|
|
|
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法"); |
|
|
|
|
//保存操作票
|
|
|
|
|
String saveEntity = saveEntity(JSONObject.toJSONString(workTicketVo)); |
|
|
|
|
workTicketVo= JSONObject.parseObject(saveEntity, WorkTicketVo.class); |
|
|
|
|
//查询第工作票值
|
|
|
|
|
String dictValue = getDictValue(workTicketVo); |
|
|
|
|
log.info("查询第工作票值: {}", dictValue); |
|
|
|
|
if (StringUtils.isBlank(dictValue)) { |
|
|
|
|
throw new ServiceException("服务器异常,请联系管理员"); |
|
|
|
|
} |
|
|
|
|
//开启动作流
|
|
|
|
|
this.startProcess(saveEntity,dictValue); |
|
|
|
|
// //处理任务--老版本业务要求,2024/07/05弃用
|
|
|
|
|
// this.returnTicket(workTicketVo);
|
|
|
|
|
return workTicketVo.getWorkTicket().getId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String saveEntity(String entity) { |
|
|
|
|
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); |
|
|
|
|
if (workTicketVo.getWorkTicket().getSignage() == null) { |
|
|
|
|
throw new ServiceException("票据抬头未配置,请您到站点管理配置"); |
|
|
|
|
} |
|
|
|
@ -200,27 +221,63 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
throw new ServiceException("服务器异常,请联系管理员"); |
|
|
|
|
} |
|
|
|
|
workTicketVo.getWorkTicket().setCode(code); |
|
|
|
|
//3 .保存工作对象
|
|
|
|
|
//保存工作对象
|
|
|
|
|
log.info("ticket:start:vo",JSON.toJSONString(workTicketVo.getWorkTicket())); |
|
|
|
|
this.saveWorkTicketInfo(workTicketVo.getWorkTicket()); |
|
|
|
|
//4. 保存安全措施
|
|
|
|
|
WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket()); |
|
|
|
|
boolean isSave = firstWorkTicketService.save(workTicket); |
|
|
|
|
log.info("ticket:start:save",JSON.toJSONString(workTicket)); |
|
|
|
|
if (!isSave) { |
|
|
|
|
throw new IllegalArgumentException("保存工作对象错误"); |
|
|
|
|
} |
|
|
|
|
//保存安全措施
|
|
|
|
|
this.saveSafetyMeasures(workTicketVo.getSafetyMeasuresList(), workTicketVo.getWorkTicket()); |
|
|
|
|
//5. 保存工作任务
|
|
|
|
|
//保存工作任务
|
|
|
|
|
this.saveWorkTicketContentDto(workTicketVo.getWorkTicketContentDtoList(), workTicketVo.getWorkTicket()); |
|
|
|
|
//6. 查询第工作票值
|
|
|
|
|
String dictValue = getDictValue(workTicketVo); |
|
|
|
|
log.info("查询第工作票值: {}", dictValue); |
|
|
|
|
if (StringUtils.isBlank(dictValue)) { |
|
|
|
|
throw new ServiceException("服务器异常,请联系管理员"); |
|
|
|
|
return JSONObject.toJSONString(workTicketVo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void startProcess(String entity, String dictValue) { |
|
|
|
|
WorkTicketVo workTicketVo= JSONObject.parseObject(entity, WorkTicketVo.class); |
|
|
|
|
WorkTicketInfoEntity workTicket = getWorkTicketInfo(workTicketVo.getWorkTicket()); |
|
|
|
|
workTicketVo.setWorkTicket(workTicket); |
|
|
|
|
Instant start = Instant.now(); |
|
|
|
|
//若为线下工作票 则无需开启工作流
|
|
|
|
|
Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus(); |
|
|
|
|
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
|
params.put("workTicketVo", workTicketVo); |
|
|
|
|
//获取当前登录人
|
|
|
|
|
Long userId = AuthUtil.getUserId(); |
|
|
|
|
//负责人
|
|
|
|
|
Long principal = workTicketVo.getWorkTicket().getPrincipal(); |
|
|
|
|
if ("8".equals(workTicketVo.getWorkTicket().getType()) && principal.longValue() != userId.longValue()) { |
|
|
|
|
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal()); |
|
|
|
|
} |
|
|
|
|
//7. 开启动作流
|
|
|
|
|
this.dealProcess(dictValue, workTicketVo); |
|
|
|
|
//8. 处理任务
|
|
|
|
|
this.returnTicket(workTicketVo); |
|
|
|
|
//已开启流程
|
|
|
|
|
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params); |
|
|
|
|
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); |
|
|
|
|
if (!processInstanceContainNameByKey.isSuccess()) { |
|
|
|
|
//保存流程开始失败情况
|
|
|
|
|
workTicket.setIsNormal(false); |
|
|
|
|
boolean isSave = firstWorkTicketService.save(workTicket); |
|
|
|
|
log.info("ticket:start:save",JSON.toJSONString(workTicket)); |
|
|
|
|
if (!isSave) { |
|
|
|
|
throw new IllegalArgumentException("保存工作对象错误"); |
|
|
|
|
} |
|
|
|
|
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); |
|
|
|
|
throw new ServiceException("流程开启失败,请检查流程和用户权限后重试!"); |
|
|
|
|
} |
|
|
|
|
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); |
|
|
|
|
Duration between = Duration.between(start, Instant.now()); |
|
|
|
|
|
|
|
|
|
return workTicketVo.getWorkTicket().getId(); |
|
|
|
|
log.info("================================================================"); |
|
|
|
|
log.info("耗时: " + (between.getSeconds()) + "秒"); |
|
|
|
|
log.info("耗时: " + (between.toMillis()) + "毫秒"); |
|
|
|
|
log.info("================================================================"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 验证是走那种工作票流程,默认走第一种工作票 |
|
|
|
|
* |
|
|
|
@ -707,54 +764,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 开启流程 |
|
|
|
|
* |
|
|
|
|
* @param newFirstWorkTicketFlowKey |
|
|
|
|
* @param workTicketVo |
|
|
|
|
*/ |
|
|
|
|
public void dealProcess(String newFirstWorkTicketFlowKey, WorkTicketVo workTicketVo) { |
|
|
|
|
Instant start = Instant.now(); |
|
|
|
|
//若为线下工作票 则无需开启工作流
|
|
|
|
|
Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus(); |
|
|
|
|
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//log.info("租户Id:{}", AuthUtil.getTenantId());
|
|
|
|
|
//log.info("用户部门Id: {}", AuthUtil.getUser().getDeptId());
|
|
|
|
|
//log.info("用户Id: {}", AuthUtil.getUserId());
|
|
|
|
|
//获取签发人角色下的人员
|
|
|
|
|
// R<List<User>> listR = userClient.relationUserListByRoleAlias(AuthUtil.getTenantId(), Long.parseLong(AuthUtil.getUser().getDeptId()), TicketConstants.SIGNER_ROLE);
|
|
|
|
|
// if (!listR.isSuccess() || CollectionUtil.isEmpty(listR.getData())) {
|
|
|
|
|
// throw new ServiceException("工作票签发人角色下未查询到相关人员");
|
|
|
|
|
// }
|
|
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
|
params.put("workTicketVo", workTicketVo); |
|
|
|
|
//获取当前登录人
|
|
|
|
|
Long userId = AuthUtil.getUserId(); |
|
|
|
|
//负责人
|
|
|
|
|
Long principal = workTicketVo.getWorkTicket().getPrincipal(); |
|
|
|
|
if ("8".equals(workTicketVo.getWorkTicket().getType()) && principal.longValue() != userId.longValue()) { |
|
|
|
|
params.put("principal", "taskUser_" + workTicketVo.getWorkTicket().getPrincipal()); |
|
|
|
|
} |
|
|
|
|
//已开启流程
|
|
|
|
|
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(newFirstWorkTicketFlowKey, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params); |
|
|
|
|
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess()); |
|
|
|
|
if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getCode() == 500) { |
|
|
|
|
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); |
|
|
|
|
throw new ServiceException("不好意思,您暂无权限..."); |
|
|
|
|
} |
|
|
|
|
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey); |
|
|
|
|
Duration between = Duration.between(start, Instant.now()); |
|
|
|
|
|
|
|
|
|
log.info("================================================================"); |
|
|
|
|
log.info("耗时: " + (between.getSeconds()) + "秒"); |
|
|
|
|
log.info("耗时: " + (between.toMillis()) + "毫秒"); |
|
|
|
|
log.info("================================================================"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 保存工作任务 |
|
|
|
|
* |
|
|
|
@ -810,7 +819,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
* @param workTicket |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public WorkTicketInfoEntity saveWorkTicketInfo(WorkTicketInfoEntity workTicket) { |
|
|
|
|
public WorkTicketInfoEntity getWorkTicketInfo(WorkTicketInfoEntity workTicket) { |
|
|
|
|
workTicket.setStatus(Func.isEmpty(workTicket.getPrincipal()) || Func.isEmpty(workTicket.getClassGroupMembers()) ? WorkTicketConstants.FirstWorkTicketStatusEnum.OFFLINE_OPERATE.getStatus() : WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus()); |
|
|
|
|
//班组成员名称
|
|
|
|
|
String byclassGroupMembers = getByClassGroupMembers(workTicket); |
|
|
|
@ -826,11 +835,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
workTicket.setIsHazard(false); |
|
|
|
|
workTicket.setIsRailway(false); |
|
|
|
|
workTicket.setIsLimited(false); |
|
|
|
|
boolean isSave = firstWorkTicketService.save(workTicket); |
|
|
|
|
log.info("ticket:start:save",JSON.toJSONString(workTicket)); |
|
|
|
|
if (!isSave) { |
|
|
|
|
throw new IllegalArgumentException("保存工作对象错误"); |
|
|
|
|
} |
|
|
|
|
return workTicket; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1392,7 +1396,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
* @param workTicketVo 工作票 |
|
|
|
|
* @return 工作流实例ID |
|
|
|
|
*/ |
|
|
|
|
private String startOfflineTicketProcess(WorkTicketVo workTicketVo) { |
|
|
|
|
public String startOfflineTicketProcess(WorkTicketVo workTicketVo) { |
|
|
|
|
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket(); |
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
workTicketVo.setWorkTicket(workTicket); |
|
|
|
@ -1400,6 +1404,13 @@ public class TicketProcessServiceImpl implements TicketProcessService {
|
|
|
|
|
R<BladeFlow> flowR = |
|
|
|
|
flowClient.startProcessInstanceContainNameByKey("offlineWorkTicket",String.valueOf(workTicket.getId()),workTicket.getWorkContent(), params); |
|
|
|
|
Assert.isTrue(flowR.isSuccess(),() -> { |
|
|
|
|
//保存流程开始失败情况
|
|
|
|
|
workTicket.setIsNormal(false); |
|
|
|
|
boolean isSave = firstWorkTicketService.save(workTicket); |
|
|
|
|
log.info("ticket:start:save",JSON.toJSONString(workTicket)); |
|
|
|
|
if (!isSave) { |
|
|
|
|
throw new IllegalArgumentException("保存工作对象错误"); |
|
|
|
|
} |
|
|
|
|
throw new ServiceException("开启工作流失败,请联系管理员"); |
|
|
|
|
}); |
|
|
|
|
return flowR.getData().getProcessInstanceId(); |
|
|
|
|