Commit 04d0f544 authored by yangyang's avatar yangyang

feat(检验报告):1.接收接口; 2.驳回接口; 3.撤回接口;

parent 6ff62da9
package com.yeejoin.amos.boot.module.jyjc.api.service;
import java.util.Map;
/**
* <p>
* ProjectName: amos-boot-biz
* PackageName: com.yeejoin.amos.boot.module.jyjc.api.service
*
* @author yangyang
* @version v1.0
* @date 2023/12/15 15:55
*/
public interface IJyjcInspectionApplicationHandlerService {
String type();
boolean notifyInspectionUnit(Map<String, Object> params);
}
......@@ -23,7 +23,8 @@
workflow_prostance_id,
workflow_role,
unit_code_name,
status_name
status_name,
workflow_active_key
from tz_jyjc_opening_application
<where>
<if test="jyjcOpeningApplicationModel.applicationSeq != '' and jyjcOpeningApplicationModel.applicationSeq != null">
......
......@@ -25,7 +25,7 @@
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-workflow</artifactId>
<version>1.8.5</version>
<version>1.10.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
package com.yeejoin.amos.boot.module.jyjc.biz.config;
import com.yeejoin.amos.boot.module.ymt.api.enums.BaseExceptionEnum;
/**
......
package com.yeejoin.amos.boot.module.jyjc.biz.config;
import com.yeejoin.amos.boot.module.ymt.api.common.BaseException;
import com.yeejoin.amos.boot.module.ymt.api.enums.CommonErrorEnum;
/**
......
......@@ -5,7 +5,11 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcInspectionApplicationServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -113,4 +117,59 @@ public class JyjcInspectionApplicationController extends BaseController {
public ResponseModel<List<JyjcInspectionApplicationModel>> selectForList() {
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.queryForJyjcInspectionApplicationList());
}
/**
* 接收接口
*
*
* @param params params
* @return {@link ResponseModel< HashMap< String String>>}
* @author yangyang
* @throws
* @date 2023/12/15 11:25
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST",value = "接收", notes = "接收")
@PostMapping(value = "/flow/{type}/execute")
public ResponseModel<HashMap<String,String>> execueFlow(@PathVariable(value = "type") String type, @RequestBody Map<String, Object> params) {
params.put("type", type);
jyjcInspectionApplicationServiceImpl.doReceive(params);
HashMap<String,String> result =new HashMap<>();
result.put("result","success");
return ResponseHelper.buildResponse(result);
}
/**
* 退回接口(监督检验、定(首)检、检测)-通用
*
*
* @param params params
* @return {@link }
* @author yangyang
* @throws
* @date 2023/12/15 13:44
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "退回", notes = "退回")
@GetMapping(value = "/flow/reject")
public void rejectflow(@RequestBody Map<String,Object> params) {
jyjcInspectionApplicationServiceImpl.doReject(params);
}
/**
* 撤回接口(监督检验、定(首)检、检测)-通用
*
*
* @param instanceId instanceId
* @return {@link }
* @author yangyang
* @throws
* @date 2023/12/15 13:39
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "撤回", notes = "撤回")
@GetMapping(value = "/flow/rollback")
public void overflow( @RequestParam("instanceId") String instanceId) {
jyjcInspectionApplicationServiceImpl.doRollback(instanceId);
}
}
......@@ -4,9 +4,13 @@ import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationEqu
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionApplicationEquipMapper;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionApplicationEquipService;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationEquipModel;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Collections;
import java.util.List;
/**
......@@ -30,4 +34,13 @@ public class JyjcInspectionApplicationEquipServiceImpl extends BaseService<JyjcI
public List<JyjcInspectionApplicationEquipModel> queryForJyjcInspectionApplicationEquipList() {
return this.queryForList("" , false);
}
public List<JyjcInspectionApplicationEquipModel> listApplicationEquipByApplicationSeq(Long applicationSeq) {
// this.queryForList 尽量不要重载方法
List<JyjcInspectionApplicationEquip> entitys = this.lambdaQuery().eq(JyjcInspectionApplicationEquip::getApplicationSeq, applicationSeq).list();
if (ValidationUtil.isEmpty(entitys)) {
return Collections.EMPTY_LIST;
}
return Bean.toModels(entitys, JyjcInspectionApplicationEquipModel.class);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationPushLog;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionApplicationPushLogMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationEquipModel;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationModel;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionApplicationPushLogService;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationPushLogModel;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.Map;
/**
* 服务实现类
......@@ -30,4 +34,26 @@ public class JyjcInspectionApplicationPushLogServiceImpl extends BaseService<Jyj
public List<JyjcInspectionApplicationPushLogModel> queryForJyjcInspectionApplicationPushLogList() {
return this.queryForList("" , false);
}
/**
* 记录日志
*
*
* @param params params
* @return {@link boolean}
* @author yangyang
* @throws
* @date 2023/12/15 15:53
*/
public boolean saveInspectionApplicationPushLog(Map<String, Object> params) {
JyjcInspectionApplicationModel inspectionApplicationModel = (JyjcInspectionApplicationModel) params.get("inspectionApplication");
List<JyjcInspectionApplicationEquipModel> applicationEquipModels = (List<JyjcInspectionApplicationEquipModel>) params.get("applicationEquips");
JyjcInspectionApplicationPushLog logEntity = new JyjcInspectionApplicationPushLog();
logEntity.setApplicationSeq(inspectionApplicationModel.getSequenceNbr());
logEntity.setInspectionUnitCode(inspectionApplicationModel.getInspectionUnitCode());
logEntity.setPushData(JSON.toJSONString(applicationEquipModels));
logEntity.setPushStatus("0");
return this.save(logEntity);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import cn.hutool.core.map.MapBuilder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplication;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionApplicationMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationEquipModel;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionApplicationService;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationModel;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.handler.JyjcInspectionApplicationHandlerFactory;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.service.ICreateCodeService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 服务实现类
......@@ -16,7 +39,17 @@ import java.util.List;
* @date 2023-12-14
*/
@Service
@Slf4j
public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspectionApplicationModel,JyjcInspectionApplication,JyjcInspectionApplicationMapper> implements IJyjcInspectionApplicationService {
@Autowired
private JyjcInspectionResultServiceImpl inspectionResultService;
@Autowired
private JyjcInspectionApplicationEquipServiceImpl applicationEquipService;
@Autowired
private ICreateCodeService createCodeService;
@Autowired
private WorkflowHelper workflowHelper;
/**
* 分页查询
*/
......@@ -30,4 +63,136 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
public List<JyjcInspectionApplicationModel> queryForJyjcInspectionApplicationList() {
return this.queryForList("" , false);
}
/**
* 接收
*
*
* @param params params
* @return {@link }
* @author yangyang
* @throws
* @date 2023/12/15 15:14
*/
public void doReceive(Map<String, Object> params) {
execueFlow(params);
// 执行接收业务
Long sequenceNbr = (Long) params.get("sequenceNbr");
JyjcInspectionApplicationModel inspectionApplicationModel = this.queryBySeq(sequenceNbr);
List<JyjcInspectionApplicationEquipModel> applicationEquipModels = applicationEquipService.listApplicationEquipByApplicationSeq(sequenceNbr);
if (ValidationUtil.isEmpty(applicationEquipModels)) {
return;
}
List<JyjcInspectionResult> resultModels = new ArrayList(applicationEquipModels.size());
List<String> codes = createCodeService.createApplicationFormCode(ApplicationFormTypeEnum.JG.getCode(), applicationEquipModels.size());
for (int i = 0; i < applicationEquipModels.size(); i++) {
JyjcInspectionResult resultModel = new JyjcInspectionResult();
resultModel.setInspectionUnitCode(inspectionApplicationModel.getInspectionUnitCode());
resultModel.setApplicationNo(inspectionApplicationModel.getApplicationNo());
resultModel.setApplicationUnitCode(inspectionApplicationModel.getApplicationUnitCode());
resultModel.setResultStatus("未出");
// 解析设备
resultModel.setBizType(inspectionApplicationModel.getBizType());
resultModel.setResultNo(codes.get(i));
resultModel.setEquipUnicode(applicationEquipModels.get(i).getEquipUnicode());//设备唯一标识
}
inspectionResultService.saveOrUpdateBatch(resultModels);
// 通知对应的检验机构
Map<String, Object> thiryPartParams = MapBuilder.<String, Object>create().put("inspectionApplication", inspectionApplicationModel).put("applicationEquips", applicationEquipModels).build();
JyjcInspectionApplicationHandlerFactory.apply(inspectionApplicationModel.getBizType()).notifyInspectionUnit(thiryPartParams);
}
/**
* 退回
*
*
* @param params params
* @return {@link }
* @author yangyang
* @throws
* @date 2023/12/15 15:14
*/
public void doReject(Map<String, Object> params) {
execueFlow(params);
String instanceId = Optional.ofNullable(params.get("instanceId")).orElse("").toString();
params.put("status", FlowStatusEnum.REJECTED.getCode() + "");
updateModelByInstanceId(instanceId, params);
}
/**
* 接收/驳回通知检验单
*/
public void execueFlow(Map<String, Object> params) {
String op = params.get("op").toString();
String instanceId = params.get("instanceId").toString();
String comments= params.get("comments").toString();
try {
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
//组装信息
TaskResultDTO dto = new TaskResultDTO();
dto.setResultCode("approvalStatus");
dto.setTaskId(taskId);
HashMap<String,Object> varibalble = new HashMap<>();
varibalble.put("approvalStatus",op);
dto.setVariable(varibalble);
dto.setComment(comments);
// 执行流程
AjaxResult ajaxResult1 = Workflow.taskClient.completeByTask(taskId, dto);
if (ObjectUtils.isEmpty(ajaxResult1)) {
}
} catch (Exception e) {
e.printStackTrace();
log.error("执行工作流错误, => {}", params, e);
}
}
/**
* 撤回流程办理单
*/
public void doRollback(String instanceId) {
try {
// 撤回流程
FeignClientResult feignClientResult = Workflow.taskV2Client.rollBack(instanceId);
if (ObjectUtils.isEmpty(feignClientResult)) {
}
updateModelByInstanceId(instanceId, MapBuilder.<String, Object>create().put("status", FlowStatusEnum.REJECTED.getCode() + "").build());
} catch (Exception e) {
e.printStackTrace();
log.error("撤回工作流错误, => {}", instanceId, e);
}
}
public void updateModelByInstanceId(String instanceId, Map<String, Object> params) {
JyjcInspectionApplication entity = this.lambdaQuery().eq(JyjcInspectionApplication::getProcessInstanceId, instanceId).one();
if (entity == null) {
return;
}
String status = (String) params.get("status");
String inspectionChargePerson = (String) params.get("inspectionChargePerson");
String inspectionChargePhone = (String) params.get("inspectionChargePhone");
String processDescription = (String) params.get("comments");
if (StringUtils.isNotBlank(inspectionChargePerson)) {
entity.setInspectionChargePerson(inspectionChargePerson);
}
if (StringUtils.isNotBlank(inspectionChargePhone)) {
entity.setInspectionChargePhone(inspectionChargePhone);
}
if (StringUtils.isNotBlank(processDescription)) {
entity.setProcessDescription(processDescription);
}
JSONObject taskJson = workflowHelper.getTask(instanceId);
if (taskJson == null) {
log.warn("流程=>{}查询不到或已结束", instanceId);
return;
}
entity.setWorkflowRole(workflowHelper.getWorkflowRoleGroups(taskJson));
// entity.setWorkflowActiveKey(taskJson.getString("taskDefinitionKey"));
entity.setStatus(status);
// entity.setStatusName(FlowStatusEnum.getNameByType(Long.parseLong(status)));
this.updateById(entity);
}
}
\ No newline at end of file
......@@ -22,9 +22,11 @@ import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseUnitLicenceDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseUnitLicenceMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.service.ICreateCodeService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
......@@ -60,7 +62,8 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
@Autowired
CommonserviceImpl commonserviceImpl;
@Autowired
private ICreateCodeService createCodeService;
@Autowired
JyjcOpeningApplicationMapper jyjcOpeningApplicationMapper;
......@@ -91,7 +94,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
try {
if (enableStartFlow) {
// 开启工作流 startProcess
String instanceId = startFlow();
String instanceId = startFlow("1");
JSONObject dataObject = getTask(instanceId);
JSONArray executorArray = dataObject.getJSONObject("nodeInfo").getJSONArray("executor");
if(!ValidationUtil.isEmpty(executorArray)) {
......@@ -115,7 +118,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
model.setUnitCode(companyBo.getCompanyCode());
model.setUnitCode("91611103MAC4Q1EG7B");
model.setUnitCodeName(companyBo.getCompanyName());
model.setApplicationSeq(buildApplicationSeq());
model.setApplicationSeq(createCodeService.createDeviceRegistrationCode(ApplicationFormTypeEnum.JY.getCode()));
return this.createWithModel(model);
} else {
return this.updateWithModel(model);
......@@ -231,8 +234,8 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
// List<TzBaseUnitLicenceDto> baseUnitLicences = Bean.toModels(unitLicenceMapper.selectList(unitLicenceQueryWrapper), TzBaseUnitLicenceDto.class );
//
List<TzBaseUnitLicenceDto> baseUnitLicences = baseMapper.selectBaseUnitLicenceList(MapBuilder.<String, Object>create()
.put("unitCode", unitCode)
// .put("licenceType", LicenceTypeEnum.JYJC.getCode())
.put("unitCode", unitCode)
// .put("licenceType", LicenceTypeEnum.JYJC.getCode())
.build());
jyjcOpeningApplicationModel.setBaseUnitLicences(baseUnitLicences);
// 获取检验人员信息
......@@ -262,19 +265,21 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
return jyjcOpeningApplicationModel;
}
public String startFlow() throws Exception {
public String startFlow(String businessKey) throws Exception {
// 重新开启工作流
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(processDefinitionKey);
dto.setBusinessKey("1");
AjaxResult ajaxResult = Workflow.taskClient.startByVariable(dto);
dto.setBusinessKey(StringUtils.defaultString(businessKey, "1"));
// dto.setCompleteFirstTask(true);
FeignClientResult ajaxResult = Workflow.taskV2Client.startByVariable(dto);
// AjaxResult ajaxResult = Workflow.taskClient.startByVariable(dto);
if (log.isDebugEnabled()) {
log.debug("开启工作流结果:{}", ajaxResult);
}
if (ajaxResult == null || (ajaxResult.get(AjaxResult.CODE_TAG) != null && !"200".equals(ajaxResult.get(AjaxResult.CODE_TAG).toString()))) {
if (ajaxResult == null || 200 != ajaxResult.getStatus()) {
throw new BaseException("开启工作流错误");
}
return ((Map) ajaxResult.get("data")).get("id").toString();
return ((Map) ajaxResult.getResult()).get("id").toString();
}
/**
......@@ -353,34 +358,34 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
dataObject.put("nodeInfo", nodeInfo.getResult());
return dataObject;
}
/**
* JY+年(4位)+月(2位)+日(2位)+序列号(3位
*
* @param
* @return {@link java.lang.String}
* @throws
* @author yangyang
* @date 2023/12/13 22:30
*/
private String buildApplicationSeq() {
String sdf = new SimpleDateFormat("yyyyMMdd").format(new Date());
long increment = redisUtils.incr(CommonConstants.OPEN_APPLICATION_SEQ_KEY, 1);
if (increment == 0) {
redisUtils.expire(CommonConstants.OPEN_APPLICATION_SEQ_KEY, nextDay());
}
return CommonConstants.APPLICATION_SEQ_PREFIX + sdf + String.format("%03d", increment);
}
private long nextDay() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.add(Calendar.DAY_OF_MONTH, 1);
return (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
}
//
// /**
// * JY+年(4位)+月(2位)+日(2位)+序列号(3位
// *
// * @param
// * @return {@link java.lang.String}
// * @throws
// * @author yangyang
// * @date 2023/12/13 22:30
// */
// private String buildApplicationSeq() {
// String sdf = new SimpleDateFormat("yyyyMMdd").format(new Date());
// long increment = redisUtils.incr(CommonConstants.OPEN_APPLICATION_SEQ_KEY, 1);
// if (increment == 0) {
// redisUtils.expire(CommonConstants.OPEN_APPLICATION_SEQ_KEY, nextDay());
// }
// return CommonConstants.APPLICATION_SEQ_PREFIX + sdf + String.format("%03d", increment);
// }
//
// private long nextDay() {
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.HOUR_OF_DAY, 0);
// calendar.set(Calendar.MINUTE, 0);
// calendar.set(Calendar.SECOND, 0);
// calendar.set(Calendar.MILLISECOND, 0);
// calendar.add(Calendar.DAY_OF_MONTH, 1);
// return (calendar.getTimeInMillis() - System.currentTimeMillis()) / 1000;
// }
public List<Map<String, Object>> selectForFlowStatusList() {
return Arrays.stream(FlowStatusEnum.values()).map(this::mapPointTypeToMap).collect(Collectors.toList());
......
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jyjc.biz.feign.WorkflowFeignClient;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.LinkedHashMap;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* <p>
* ProjectName: amos-boot-biz
* PackageName: com.yeejoin.amos.boot.module.jyjc.biz.service.impl
*
* @author yangyang
* @version v1.0
* @date 2023/12/15 15:46
*/
@Component
@Slf4j
public class WorkflowHelper {
@Autowired
private WorkflowFeignClient workflowFeignClient;
/**
* 获取工作流
*
*
* @param instanceId instanceId
* @return {@link JSONObject}
* @author yangyang
* @throws
* @date 2023/12/15 16:17
*/
public JSONObject getTask(String instanceId) {
AjaxResult ajaxResult = Workflow.taskClient.getTask(instanceId);
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");// 工作流ID
FeignClientResult<JSONObject> nodeInfo = workflowFeignClient.getNodeInfotoken(RequestContext.getAppKey(), RequestContext.getProduct(), RequestContext.getToken(), taskId);
dataObject.put("nodeInfo", nodeInfo.getResult());
return dataObject;
}
public String getWorkflowStatus(JSONObject dataObject) {
return !ValidationUtil.isEmpty(dataObject) && !ValidationUtil.isEmpty(dataObject.get("status")) ? String.valueOf(dataObject.get("status")) : "";
}
public String getWorkflowRoleGroups(JSONObject dataObject) {
JSONArray executorArray = dataObject.getJSONObject("nodeInfo").getJSONArray("executor");
if(!ValidationUtil.isEmpty(executorArray)) {
return executorArray.stream().map(json -> Optional.ofNullable(((LinkedHashMap) json).get("groupId")).orElse("").toString()).collect(Collectors.joining(","));
}
return null;
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl.handler;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionApplicationHandlerService;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcInspectionApplicationPushLogServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* <p>
* ProjectName: amos-boot-biz
* PackageName: com.yeejoin.amos.boot.module.jyjc.biz.service.impl.handler
*
* @author yangyang
* @version v1.0
* @date 2023/12/15 16:12
*/
@Component
public class AbstractJyjcInspectionApplicationHandlerServiceImpl implements IJyjcInspectionApplicationHandlerService {
@Autowired
private JyjcInspectionApplicationPushLogServiceImpl applicationPushLogService;
@Override
public String type() {
return "default";
}
@Override
public boolean notifyInspectionUnit(Map<String, Object> params) {
// push日志
applicationPushLogService.saveInspectionApplicationPushLog(params);
return true;
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl.handler;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionApplicationHandlerService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @author yangyang
* @version v1.0
* @date 2023/11/8 15:10
*/
@Service
public class JyjcInspectionApplicationHandlerFactory implements ApplicationContextAware {
private static final Map<String, IJyjcInspectionApplicationHandlerService> SERVICE_POOL = new HashMap<>(12);
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
applicationContext.getBeansOfType(IJyjcInspectionApplicationHandlerService.class).forEach((beanName, bean) -> SERVICE_POOL.put(bean.type(), bean));
}
public static IJyjcInspectionApplicationHandlerService apply(String type) {
IJyjcInspectionApplicationHandlerService objectSceneService = SERVICE_POOL.get(type);
if (Objects.isNull(objectSceneService)) {
throw new IllegalArgumentException("SERVICE_POOL type: " + type + " is not found !");
}
return objectSceneService;
}
}
......@@ -16,6 +16,7 @@ public enum ApplicationFormTypeEnum {
*/
GZ("GZ"),
JY("JY"),
JG("JG"),// 检验结果
WB("WB"),
SY("SY");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment