Browse Source

新增DefectProcessServiceImpl,修改工作票,操作票

zhongwei
段飞宇 1 year ago
parent
commit
64f30a971e
  1. 6
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/constant/TicketProcessConstant.java
  2. 67
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DefectProcessServiceImpl.java
  3. 8
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java
  4. 8
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java
  5. 21
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  6. 1
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java
  7. 200
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

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

@ -29,4 +29,10 @@ public class TicketProcessConstant {
* 日常维护
*/
public static final String MAINTENANCE_KEY = "maintenance";
/**
* 消缺流程
*/
public static final String DEFECT_KEY = "defectDealty";
}

67
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DefectProcessServiceImpl.java

@ -0,0 +1,67 @@
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.operational.defect.feign.IOperDefectClient;
import lombok.RequiredArgsConstructor;
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 static com.hnac.hzims.middle.process.constant.TicketProcessConstant.DEFECT_KEY;
/**
* 消缺工作流实现类
*
* @Author dfy
* @Version v1.0
* @Serial 1.0
* @Date 2023/3/28 8:47
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class DefectProcessServiceImpl extends ProcessAbstractService {
private final IOperDefectClient defectClient;
private final ProcessDictService processDictService;
/**
* 设置执行那种实现类
*
* @param flowQueue
* @return
*/
@Override
public Boolean isWorkflowProcess(WorkflowQueue flowQueue) {
log.info("是否执行消缺工作流实流程环节操作~~~~,流程ticket: {}", flowQueue);
String dictValue = processDictService.selectDictValueByKey(DEFECT_KEY);
if (dictValue.equals(flowQueue.getProcessDefinitionKey())) {
log.info("已执行消缺工作流程环节操作~~~~");
return true;
}
log.error("未是否执行消缺工作流流程环节操作,请联系管理员~~~~");
return false;
}
/**
* 两票管理业务方法
*
* @param response
*/
@Override
public void calculate(ProcessWorkFlowResponse response) {
R defect = defectClient.saveDefect(response);
if (!defect.isSuccess()) {
throw new ServiceException("消缺工作流程出现异常呢");
}
}
}

8
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java

@ -4,7 +4,7 @@ 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.OperationTicketFeignClient;
import com.hnac.hzims.ticket.ticketprocess.feign.TicketProcessFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
@ -28,7 +28,7 @@ public class MachineryTicketProcessServiceImpl extends ProcessAbstractService {
private final OperationTicketFeignClient ticketProcessService;
private final TicketProcessFeignClient ticketProcessService;
@ -36,10 +36,6 @@ public class MachineryTicketProcessServiceImpl extends ProcessAbstractService {
/**
* 设置执行那种实现类
*

8
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java

@ -4,6 +4,7 @@ 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.OperationTicketFeignClient;
import com.hnac.hzims.ticket.ticketprocess.feign.TicketProcessFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -28,7 +29,7 @@ public class OperationTicketProcessServiceImpl extends ProcessAbstractService {
private final TicketProcessFeignClient operationTicketService;
private final OperationTicketFeignClient operationTicketFeignClient;
@ -44,7 +45,7 @@ public class OperationTicketProcessServiceImpl extends ProcessAbstractService {
*/
@Override
public Boolean isWorkflowProcess(WorkflowQueue flowQueue) {
log.info("是否执行操作票流程环节操作~~~~,流程flowQueue: {}", flowQueue);
log.info("是否执行操作票流程环节操作~~~~,流程flowQueue: {}", flowQueue);
String dictValue = processDictService.selectDictValueByKey(OPERATION_TICKET_KEY);
if (dictValue.equals(flowQueue.getProcessDefinitionKey())) {
log.info("已执行操作票流程环节操作~~~~");
@ -61,10 +62,9 @@ public class OperationTicketProcessServiceImpl extends ProcessAbstractService {
*/
@Override
public void calculate(ProcessWorkFlowResponse response) {
Boolean pending = operationTicketService.findPending(response);
Boolean pending = operationTicketFeignClient.findPending(response);
if (!pending) {
throw new ServiceException("操作票流程出现异常呢");
}
}
}

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

@ -77,7 +77,6 @@ public class OperationTicketServiceImpl implements OperationTicketService {
private final ProcessDictFeignService processDictFeignService;
private final IFlowClient flowClient;
@ -158,7 +157,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
log.info("获取下一个审批人是: {} ", response.getNextStepOperator());
log.info("获取下一个用户Id是: {} ", response.getUserId());
log.info("获取当前任务名称是: {} ", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
@ -168,9 +167,9 @@ public class OperationTicketServiceImpl implements OperationTicketService {
standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, StandardTicketInfoVo.class);
} catch (Exception e) {
log.error("获取表单出现异常了~~~~");
e.printStackTrace();
throw new IllegalArgumentException(e.getMessage());
}
//1.查询操作票信息
Long id = NumberUtils.toLong(response.getBusinessKey());
StandardTicketInfoEntity standardTicketInfoEntity = standardTicketInfoService.getById(id);
@ -197,8 +196,6 @@ public class OperationTicketServiceImpl implements OperationTicketService {
}).collect(Collectors.toList());
standardTicketMeasureService.updateBatchById(standardTicketMeasureEntities);
}
//推送消息
if (response.getTaskId() != null) {
MessagePushRecordDto message = new MessagePushRecordDto();
@ -238,6 +235,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
messageClient.sendMessage(message);
}
}
}
@ -379,8 +377,6 @@ public class OperationTicketServiceImpl implements OperationTicketService {
}
/**
* 新预览
*
@ -398,7 +394,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
StandardTicketInfoVo standardTicketInfoVo = standardTicketInfoService.selectDetailsById(ticketId);
//将查询的数据转换为map
Map<String, Object> workTicketInfoMap = this.convertMap(standardTicketInfoVo);
//导入下在word
//导入下在word
Map<String, Object> resultMap = OperationWordHelper.resultMap(workTicketInfoMap);
String workTicketStatus = OperationWordHelper.getWorkTicketStatus(status);
String os = TicketConstant.OS_NAME;
@ -421,6 +417,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
/**
* 将查询的数据转换为map
*
* @param standardTicketInfoVo
* @return
*/
@ -439,17 +436,17 @@ public class OperationTicketServiceImpl implements OperationTicketService {
map.put("index", index.get());
map.put("status", TicketConstants.MATTER_FINISH_STATUS.equals(measure.getStatus()) ? "√" : "");
map.put("operationTime", measure.getOperationTime());
map.put("hello","");
map.put("hello1","");
map.put("hello", "");
map.put("hello1", "");
index.getAndIncrement();
measureMapLists.add(map);
}
result.put("measureMapList", measureMapLists);
}else {
} else {
result.put("measureMapList", new ArrayList<>());
}
WordMapUtils.newMapWithList("measureMapList",result,false,17,null);
WordMapUtils.newMapWithList("measureMapList", result, false, 17, null);
return result;
}

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

@ -58,6 +58,7 @@ public class TicketProcessController {
ticketProcessService.findPending(response);
return true;
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("工作票待处理:" + e.getMessage());
}
}

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

@ -276,98 +276,78 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.error("获取工作票的数据为不存在");
return;
}
try {
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
workTicketInfo.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
} catch (Exception e) {
e.printStackTrace();
}
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
workTicketInfo.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
//更新安全措施
try {
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList);
for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) {
if (ObjectUtils.isNotEmpty(item.getId())) {
workTicketSafetyMeasureService.updateById(item);
} else {
item.setTicketId(workTicketInfo.getId());
workTicketSafetyMeasureService.save(item);
}
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList);
for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) {
if (ObjectUtils.isNotEmpty(item.getId())) {
workTicketSafetyMeasureService.updateById(item);
} else {
item.setTicketId(workTicketInfo.getId());
workTicketSafetyMeasureService.save(item);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// 第二种 工作票工作任务组
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
try {
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
log.info("获取工作票工作任务组:{}", workTicketContentDtoList);
workTicketContentDtoList.forEach(item -> {
if (ObjectUtils.isEmpty(item.getId())) {
contentService.save(item);
} else {
contentService.updateById(item);
}
});
}
} catch (Exception e) {
e.printStackTrace();
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
log.info("获取工作票工作任务组:{}", workTicketContentDtoList);
workTicketContentDtoList.forEach(item -> {
if (ObjectUtils.isEmpty(item.getId())) {
contentService.save(item);
} else {
contentService.updateById(item);
}
});
}
// 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
try {
if (ObjectUtils.isNotEmpty(workTicketDelay) && "延期".equals(workTicket.getInput())) {
WorkTicketDelayEntity workTicketDelayEntity = workTicketDelayService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作票延期:{}", workTicketDelay);
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else {
log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
}
if (ObjectUtils.isNotEmpty(workTicketDelay) && "延期".equals(workTicket.getInput())) {
WorkTicketDelayEntity workTicketDelayEntity = workTicketDelayService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作票延期:{}", workTicketDelay);
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else {
log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
}
} catch (Exception e) {
e.printStackTrace();
}
//工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
try {
log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue()));
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作结束:{}", workTicketFinish);
if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) {
log.info("获取工作结束保存成功");
workTicketFinish.setTicketId(workTicketInfo.getId());
workTicketFinishService.save(workTicketFinish);
} else {
log.info("获取工作结束更新成功");
workTicketDelay.setInitialTime(LocalDateTime.now());
workTicketFinishService.updateByTicketId(workTicketFinish);
}
log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue()));
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作结束:{}", workTicketFinish);
if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) {
log.info("获取工作结束保存成功");
workTicketFinish.setTicketId(workTicketInfo.getId());
workTicketFinishService.save(workTicketFinish);
} else {
log.info("获取工作结束更新成功");
workTicketDelay.setInitialTime(LocalDateTime.now());
workTicketFinishService.updateByTicketId(workTicketFinish);
}
} catch (Exception e) {
e.printStackTrace();
}
// 工作开始时间和结束时间
// List<WorkTicketOperateTimeEntity> workTicketOperateTimeEntities = workTicketVo.getWorkTicketOperateTimeEntities();
// if (CollectionUtils.isNotEmpty(workTicketOperateTimeEntities)) {
@ -376,58 +356,50 @@ public class TicketProcessServiceImpl implements TicketProcessService {
// }
//工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
try {
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange) && "转移".equals(workTicket.getInput())) {
log.info("工作票负责人变更: {}", workTicketPrincipalChange);
//原来的负责人
User user = UserCache.getUser(workTicketPrincipalChange.getInitialPrincipal());
//新的负责人
User newUser = UserCache.getUser(workTicketPrincipalChange.getChangePrincipal());
workTicketPrincipalChange.setCreateDept(workTicketInfo.getCreateDept());
workTicketPrincipalChange.setTicketId(workTicketInfo.getId());
workTicketPrincipalChange.setTenantId(workTicketInfo.getTenantId());
if (workTicketPrincipalChange.getFlowCode() == null) {
workTicketPrincipalChange.setFlowCode(IdWorker.getIdStr());
}
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange) && "转移".equals(workTicket.getInput())) {
log.info("工作票负责人变更: {}", workTicketPrincipalChange);
//原来的负责人
User user = UserCache.getUser(workTicketPrincipalChange.getInitialPrincipal());
//新的负责人
User newUser = UserCache.getUser(workTicketPrincipalChange.getChangePrincipal());
workTicketPrincipalChange.setCreateDept(workTicketInfo.getCreateDept());
workTicketPrincipalChange.setTicketId(workTicketInfo.getId());
workTicketPrincipalChange.setTenantId(workTicketInfo.getTenantId());
if (workTicketPrincipalChange.getFlowCode() == null) {
workTicketPrincipalChange.setFlowCode(IdWorker.getIdStr());
}
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId());
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId());
if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
log.info("工作票负责人保存变更");
workTicketPrincipalChangeService.save(workTicketPrincipalChange);
} else {
log.info("工作票负责人更新变更");
workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange);
}
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
workTicket.setPrincipal(workTicketPrincipalChange.getChangePrincipal());
workTicket.setPrincipalName(newUser.getName());
//更新工作票
workTicketInfoService.updateById(workTicket);
if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
log.info("工作票负责人保存变更");
workTicketPrincipalChangeService.save(workTicketPrincipalChange);
} else {
log.info("工作票负责人更新变更");
workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange);
}
} catch (Exception e) {
e.printStackTrace();
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
workTicket.setPrincipal(workTicketPrincipalChange.getChangePrincipal());
workTicket.setPrincipalName(newUser.getName());
//更新工作票
workTicketInfoService.updateById(workTicket);
}
//工作票危险点分析及控制措施票
try {
if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> {
item.setTicketId(workTicketInfo.getId());
return item;
}).collect(Collectors.toList());
if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> {
item.setTicketId(workTicketInfo.getId());
return item;
}).collect(Collectors.toList());
System.out.println("工作票危险点分析及控制措施票 : " + collect);
System.out.println("工作票危险点分析及控制措施票 : " + collect);
ticketInfoDangerService.saveBatch(collect);
}
ticketInfoDangerService.saveBatch(collect);
}
} catch (Exception e) {
e.printStackTrace();
}

Loading…
Cancel
Save