Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 1 year ago
parent
commit
14c181ef4c
  1. 48
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java
  2. 92
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  3. 98
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

48
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/OperationTicketController.java

@ -1,6 +1,9 @@
package com.hnac.hzims.ticket.standardTicket.controller; package com.hnac.hzims.ticket.standardTicket.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService; import com.hnac.hzims.ticket.standardTicket.service.OperationTicketService;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo;
@ -9,6 +12,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -30,6 +34,9 @@ public class OperationTicketController {
private final OperationTicketService operationTicketService; private final OperationTicketService operationTicketService;
private final IMessageClient messageClient;
/** /**
* 启动流程 * 启动流程
* *
@ -76,4 +83,45 @@ public class OperationTicketController {
} }
private final ISysClient sysClient;
@GetMapping("/test")
public void test(){
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(1671058860039106562L);
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent =
"您有一张工作票待审批,工作内容:".concat("11")
.concat(",审批环节:")
.concat("监护人确认");
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(2000000115L);
R<String> deptName = sysClient.getDeptName(2000000115L);
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
}
String userIds = "1522897714092781569";
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(1522897714092781569L);
System.out.println("businessMessageDTO = " + businessMessageDTO);
R<Boolean> booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
}else {
System.out.println("推送成功");
}
}
} }

92
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java

@ -5,11 +5,12 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
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.middle.process.feign.ProcessDictFeignService;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
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.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationClient;
@ -41,7 +42,6 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
@ -133,8 +133,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
//3. 保存操作对象 //3. 保存操作对象
this.saveStandardTicketInfo(standardTicketInfoVo); this.saveStandardTicketInfo(standardTicketInfoVo);
//5. 保存安全措施 //5. 保存安全措施
List<StandardTicketMeasureVo> standardTicketInfoVos = this.saveStandardTicketMeasure( List<StandardTicketMeasureVo> standardTicketInfoVos = this.saveStandardTicketMeasure(this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo));
this.saveStandardTicketMeasureWichTicket(standardTicketInfoVo));
standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos); standardTicketInfoVo.setStandardTicketMeasureVos(standardTicketInfoVos);
//6. 查询第操作票值 //6. 查询第操作票值
String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY); String dictValue = processDictFeignService.selectDictValueByKey(OPERATION_TICKET_KEY);
@ -183,6 +182,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
StandardTicketInfoEntity newStandardTicketInfoEntity = new StandardTicketInfoEntity(); StandardTicketInfoEntity newStandardTicketInfoEntity = new StandardTicketInfoEntity();
BeanUtils.copyProperties(standardTicketInfoVo, newStandardTicketInfoEntity); BeanUtils.copyProperties(standardTicketInfoVo, newStandardTicketInfoEntity);
newStandardTicketInfoEntity.setId(id); newStandardTicketInfoEntity.setId(id);
newStandardTicketInfoEntity.setCreateUser(standardTicketInfoEntity.getCreateUser());
//填充操作票信息 //填充操作票信息
saveStandardTicketInfoEntity(newStandardTicketInfoEntity, response); saveStandardTicketInfoEntity(newStandardTicketInfoEntity, response);
newStandardTicketInfoEntity.setProcessInstanceId(response.getProcessInstanceId()); newStandardTicketInfoEntity.setProcessInstanceId(response.getProcessInstanceId());
@ -202,45 +202,69 @@ public class OperationTicketServiceImpl implements OperationTicketService {
//推送消息 //推送消息
if (response.getTaskId() != null) { if (response.getTaskId() != null) {
MessagePushRecordDto message = new MessagePushRecordDto(); // MessagePushRecordDto message = new MessagePushRecordDto();
message.setBusinessClassify("business"); // message.setBusinessClassify("business");
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey()); // message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription()); // message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
message.setTaskId(standardTicketInfoEntity.getId()); // message.setTaskId(standardTicketInfoEntity.getId());
message.setTenantId("200000"); // message.setTenantId("200000");
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); // message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY); // message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent = "您有一张工作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle()).concat(",审批环节:").concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(standardTicketInfoEntity.getCreateDept());
// R<String> deptName = sysClient.getDeptName(standardTicketInfoEntity.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
//
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(standardTicketInfoEntity.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****; //您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = String countent =
"您有一张工作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle()) "您有一张工作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle())
.concat(",审批环节:") .concat(",审批环节:")
.concat(response.getTaskName()); .concat(response.getTaskName());
message.setContent(countent); businessMessageDTO.setContent(countent);
message.setDeptId(standardTicketInfoEntity.getCreateDept()); businessMessageDTO.setDeptId(standardTicketInfoEntity.getCreateDept());
R<String> deptName = sysClient.getDeptName(standardTicketInfoEntity.getCreateDept()); R<String> deptName = sysClient.getDeptName(standardTicketInfoEntity.getCreateDept());
if (deptName.isSuccess()) { if (deptName.isSuccess()) {
message.setDeptName(deptName.getData()); businessMessageDTO.setDeptName(deptName.getData());
} }
String userIds = response.getUserId(); String userIds = response.getUserId();
if (StringUtils.isBlank(userIds)) { businessMessageDTO.setUserIds(userIds);
log.error("推送的消息不能为空哦,{}", userIds); businessMessageDTO.setCreateUser(newStandardTicketInfoEntity.getCreateUser());
return;
}
String[] split = userIds.split(",");
for (String userId : split) {
message.setPusher(userId);
User user = UserCache.getUser(NumberUtils.toLong(userId));
if (ObjectUtils.isNotEmpty(user)) {
message.setPusherName(user.getName());
}
message.setAccount(userId);
message.setCreateUser(NumberUtils.toLong(userId)); System.out.println("================================================");
messageClient.sendMessage(message); System.out.println("businessMessageDTO = " + businessMessageDTO);
System.out.println("================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
} }
log.info("推送成功~");
} }
} }
@ -288,8 +312,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
params.put("taskId", standardTicketInfoVo.getId()); params.put("taskId", standardTicketInfoVo.getId());
params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString())); params.put("guardianUserIds", "taskUser_".concat(standardTicketInfoVo.getGuardian().toString()));
//已开启流程 //已开启流程
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(dictValue, String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params);
String.valueOf(standardTicketInfoVo.getId()), standardTicketInfoVo.getTitle(), params);
if (!processInstanceContainNameByKey.isSuccess()) { if (!processInstanceContainNameByKey.isSuccess()) {
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg()); log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限..."); throw new ServiceException("不好意思,您暂无权限...");
@ -311,8 +334,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
private List<StandardTicketMeasureEntity> saveStandardTicketMeasureWichTicket(StandardTicketInfoVo standardTicketInfoVo) { private List<StandardTicketMeasureEntity> saveStandardTicketMeasureWichTicket(StandardTicketInfoVo standardTicketInfoVo) {
List<StandardTicketMeasureVo> standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos(); List<StandardTicketMeasureVo> standardTicketMeasureVos = standardTicketInfoVo.getStandardTicketMeasureVos();
if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) { if (CollectionUtils.isNotEmpty(standardTicketMeasureVos)) {
List<StandardTicketMeasureEntity> measureEntityList = BeanUtil.copyProperties(standardTicketMeasureVos, List<StandardTicketMeasureEntity> measureEntityList = BeanUtil.copyProperties(standardTicketMeasureVos, StandardTicketMeasureEntity.class);
StandardTicketMeasureEntity.class);
List<StandardTicketMeasureEntity> collect = measureEntityList.stream().map(item -> { List<StandardTicketMeasureEntity> collect = measureEntityList.stream().map(item -> {
item.setTicketId(standardTicketInfoVo.getId()); item.setTicketId(standardTicketInfoVo.getId());
return item; return item;

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

@ -9,6 +9,7 @@ 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.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.dto.MessagePushRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService;
@ -279,7 +280,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//更新工作票 //更新工作票
workTicket.setId(workTicketInfo.getId()); workTicket.setId(workTicketInfo.getId());
//保存流程描述 //保存流程描述
workTicketInfo.setCreateDept(workTicketInfo.getCreateDept()); workTicket.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setCreateUser(workTicketInfo.getCreateUser());
workTicket.setTenantId(workTicketInfo.getTenantId()); workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response); saveWorkTicket(workTicket, response);
//工作流ID //工作流ID
@ -405,47 +407,77 @@ public class TicketProcessServiceImpl implements TicketProcessService {
if (response.getTaskId() != null || response.getUserId() != null) { if (response.getTaskId() != null || response.getUserId() != null) {
//推送消息 //推送消息
try { // try {
MessagePushRecordDto message = new MessagePushRecordDto(); // MessagePushRecordDto message = new MessagePushRecordDto();
message.setBusinessClassify("business"); // message.setBusinessClassify("business");
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); // message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); // message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
message.setTaskId(workTicketInfo.getId()); // message.setTaskId(workTicketInfo.getId());
message.setTenantId("200000"); // message.setTenantId("200000");
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); // message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY); // message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
// .concat(",审批环节: ")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(workTicketInfo.getCreateDept());
// message.setCreateDept(workTicketInfo.getCreateDept());
// R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// log.info("推送消息成功,用户名称{},消息{}", user.getName(), message);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(workTicketInfo.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****; //您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = String countent =
"您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent()) "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
.concat(",审批环节: ") .concat(",审批环节: ")
.concat(response.getTaskName()); .concat(response.getTaskName());
message.setContent(countent); businessMessageDTO.setContent(countent);
message.setDeptId(workTicketInfo.getCreateDept()); businessMessageDTO.setDeptId(workTicketInfo.getCreateDept());
message.setCreateDept(workTicketInfo.getCreateDept());
R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
if (deptName.isSuccess()) { if (deptName.isSuccess()) {
message.setDeptName(deptName.getData()); businessMessageDTO.setDeptName(deptName.getData());
} }
String userIds = response.getUserId(); String userIds = response.getUserId();
if (StringUtils.isBlank(userIds)) { businessMessageDTO.setUserIds(userIds);
log.error("推送的消息不能为空哦,{}", userIds); businessMessageDTO.setCreateUser(workTicketInfo.getCreateUser());
return; System.out.println("======================================================");
} System.out.println("businessMessageDTO = " + businessMessageDTO);
String[] split = userIds.split(","); System.out.println("======================================================");
for (String userId : split) { R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
message.setPusher(userId); if (!booleanR.isSuccess()) {
User user = UserCache.getUser(NumberUtils.toLong(userId)); throw new ServiceException("消息推送失败");
if (ObjectUtils.isNotEmpty(user)) { }
message.setPusherName(user.getName()); log.info("推送成功~");
}
message.setAccount(userId);
message.setCreateUser(NumberUtils.toLong(userId));
messageClient.sendMessage(message);
log.info("推送消息成功,用户名称{},消息{}", user.getName(), message);
}
} catch (Exception e) {
e.printStackTrace();
}
} }
} }

Loading…
Cancel
Save