Commit 0f836c11 authored by zhangyingbin's avatar zhangyingbin

城燃管道流程大体框架

parent 87dd1100
package com.yeejoin.amos.boot.module.ugp.api.Enum;
public enum ProjectInitiationEnum {
启动流程("启动流程", "/workflow/task/startTask", ""),
流程详情("流程详情", "/workflow/task/{taskId}", "taskId"),
合并启动流程("合并启动流程", "/workflow/task/startProcess", ""),
所有已执行任务详情("所有已执行任务详情","/workflow/activitiHistory/task/detail/{taskId}","taskId"),
流程任务("流程任务", "/workflow/task?processInstanceId={processInstanceId}", "processInstanceId"),
我的代办("我的代办", "/workflow/task/all-list?processDefinitionKey={processDefinitionKey}", "processDefinitionKey"),
我的代办有ID("我的代办有ID", "/workflow/task/all-list?processDefinitionKey={processDefinitionKey}&userId={userId}", "processDefinitionKey,userId"),
已执行任务("已执行任务", "/workflow/activitiHistory/all-historytasks?processDefinitionKey={processDefinitionKey}", "processDefinitionKey"),
已执行任务有ID("已执行任务有ID", "/workflow/activitiHistory/all-historytasks?processDefinitionKey={processDefinitionKey}&userId={userId}", "processDefinitionKey,userId"),
启动免登录流程("启动免登录流程", "/processes/{appKey}", "appKey"),
当前节点("当前节点", "/wf/taskstodo?processInstanceId={processInstanceId}", "processInstanceId"),
执行流程("执行流程", "/workflow/task/pickupAndCompleteTask/{taskId}", "taskId"),
终止流程("终止流程", "/wf/processes/{processInstanceId}?deleteReason={deleteReason}", "processInstanceId,deleteReason"),
当前子节点("当前子节点", "/wf/processes/{processInstanceId}/tasks?taskDefinitionKey={taskDefinitionKey}", "processInstanceId,taskDefinitionKey"),
工作流流水("工作流流水","/wf/processes/{processInstanceId}/tasks", "processInstanceId"),
子节点信息("子节点信息","/workflow/task/list/all/{instanceId}", "instanceId");
private String desc;
private String uri;
private String params;
ProjectInitiationEnum(String desc, String uri, String params) {
this.desc = desc;
this.uri = uri;
this.params = params;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
}
package com.yeejoin.amos.boot.module.ugp.api.Util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
* <pre>
* 返回封装对象
* </pre>
*
* @author mincx
* @version CommonReponse.java v0.1
* @time 2017-9-19 15:43:32
*/
public class CommonResponse implements Serializable {
private static final long serialVersionUID = -8737351878134480646L;
/**
* 操作状态
*/
@ApiModelProperty(required=true,value="操作状态")
private String result;
/**
* 操作状态
*/
@ApiModelProperty(required=true,value="状态码")
private int status;
/**
* 数据
*/
@ApiModelProperty(required=false,value="数据")
private Object dataList;
/**
* 操作详细信息
*/
@ApiModelProperty(required=false,value="操作详细信息")
private String message;
public CommonResponse(){
}
public CommonResponse(String result) {
this.result = result;
}
public CommonResponse(Object dataList) {
this.dataList = dataList;
this.result = "";
}
public CommonResponse(String result, Object dataList) {
this.dataList = dataList;
this.result = result;
}
public CommonResponse(String result, String message) {
this.result = result;
this.message = message;
}
public CommonResponse(String result, Object dataList, String message) {
this.dataList = dataList;
this.result = result;
this.message = message;
}
public CommonResponse(String result, Object dataList, int status) {
this.dataList = dataList;
this.result = result;
this.status = status;
}
public CommonResponse(String result, String message, int status) {
this.result = result;
this.message = message;
this.status = status;
}
public CommonResponse(String result, Object dataList, String message, int status) {
this.dataList = dataList;
this.result = result;
this.message = message;
this.status = status;
}
public Boolean isSuccess(){
return "SUCCESS".equals(getResult());
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getDataList() {
return dataList;
}
public void setDataList(Object dataList) {
this.dataList = dataList;
}
public void setStatus(int status) {
this.status = status;
}
public int getStatus() {
return status;
}
public String toJsonStr() throws Exception {
return JSON.toJSONString(this,SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.SkipTransientField);
}
}
package com.yeejoin.amos.boot.module.ugp.api.Util;
import org.springframework.http.HttpStatus;
public class CommonResponseUtil
{
public static CommonResponse success()
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setStatus(HttpStatus.OK.value());
return response;
}
public static CommonResponse success(Object obj)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setStatus(HttpStatus.OK.value());
response.setDataList(obj);
return response;
}
public static CommonResponse success(Object obj, String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setStatus(HttpStatus.OK.value());
response.setDataList(obj);
response.setMessage(message);
return response;
}
public static CommonResponse failure()
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return response;
}
public static CommonResponse failure(String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setMessage(message);
return response;
}
public static CommonResponse failure(Object obj, String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
response.setDataList(obj);
response.setMessage(message);
return response;
}
}
package com.yeejoin.amos.boot.module.ugp.api.Util;
/**
* <pre>
* 系统常量
* </pre>
*
* @author mincx
* @version Constants.java v0.1
* @time 2017-9-19 15:43:32
*/
public class Constants {
public static final String ERROR_MESSAGE = "系统异常";
public static final String RESULT_SUCCESS = "SUCCESS";
public static final String RESULT_FAILURE = "FAILURE";
public static final String RULE_FACT_PREFIX = "rule_";
public static final String RULE_COMPILATION_ERROR = "规则编译异常";
public static final String NEW_LINE= "\r\n";
public static final String POSITION_LATITUDE = "latitude";
public static final String POSITION_LONGITUDE = "longitude";
public static final double PI = 3.1415;
public static final double EARTH_RADIUS = 6370.996;
public static final String RULE_CONDITION_AND = "&&";
public static final String RULE_CONDITION_OR = "||";
/**
* DES加密解密默认key
*/
public static final String XSS_KEY = "qaz";
/**
* 灾情状态
*/
public static final String FireHappenStateID = "90db70b7-49a4-4a72-b54b-0fabbed9bec7";//发生
public static final String FireDevelopStateID = "1f7fe7d7-b30c-4518-8c95-6e3bc506ca86";//猛烈
/**
* 车辆状态
*/
public static final String CarArrivedStateID = "ad55748a-1206-4507-8831-95b7f2ad804f";//到达
public static final String CarDispatchingStateID = "43a23576-3d0f-4c3d-a46b-555391a4d870";//待出动
public static final String CarOnDutyStateID = "21cc717f-60b4-46ae-942e-9efd63d13415";//执勤
public static final String CarOnSiteStateID = "d7eddc16-4c55-4de0-b726-3547c7b0b980";//在位
public static final String CarOnTheWayStateID = "5e1b6e98-d1dc-4c49-a7ad-b959d2278dba";//在途
public static final String CarRepairStateID = "e86d455b-e9fd-4938-9826-38ca46623287";//维修
/**
* 战斗力量编队状态
*/
public static final String RescuePowerArrivedStateID = "0951f770-7f75-43d8-bcec-47d7559be727";//到达
public static final String RescuePowerDispatchedStateID = "ec4afc56-6cec-41a3-95f5-20c735f052d4";//已调派
public static final String RescuePowerEnhanceStateID = "3d6cf113-b69d-47c3-a3a8-ded448cc4636";//增援
public static final String RescuePowerFightingStateID = "4bacd4b4-b07d-454e-b737-431e7c997cde";//战斗
public static final String RescuePowerStandByStateID = "4fc6e4d6-c6a8-453c-b554-ce7de0b828b2";//待命
/**
* sql注入关键字
*/
public static String badStr = "'|and|exec|execute|insert|select|delete|update|count|drop|%|chr|mid|master|truncate|" +
"char|declare|sitename|net user|xp_cmdshell|;|or|-|+|,|like'|and|exec|execute|insert|create|drop|" +
"table|from|grant|use|group_concat|column_name|" +
"information_schema.columns|table_schema|union|where|select|delete|update|order|by|count|" +
"chr|mid|master|truncate|char|declare|or|;|-|--|,|like|//|/|%|#";
}
package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.ProjectInitiationServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
@RestController
@Api(tags = "流程相关")
@RequestMapping(value = "/projectInitiation")
public class ProjectInitiationController {
@Autowired
ProjectInitiationServiceImpl projectInitiationServiceImpl;
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/start")
@ApiOperation(httpMethod = "GET", value = "流程启动", notes = "流程启动")
public void start() throws Exception {
projectInitiationServiceImpl.start();
}
}
package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.service.impl.WorkflowExcuteServiceImpl;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.ugp.api.Enum.ProjectInitiationEnum;
import com.yeejoin.amos.boot.module.ugp.api.Util.CommonResponse;
import com.yeejoin.amos.boot.module.ugp.api.Util.HttpUtil;
import com.yeejoin.amos.boot.module.ugp.api.constants.XJConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@Service
public class ProjectInitiationServiceImpl {
@Autowired
WorkflowExcuteServiceImpl workflowExcuteService;
@Autowired
WorkflowFeignService workflowFeignService;
private final Logger logger = LoggerFactory.getLogger(ProjectInitiationServiceImpl.class);
@Value("${params.work.flow.processDefinitionKey}")
private String processDefinitionKey;
public ResponseModel start() throws Exception {
String instanceId = workflowExcuteService.startAndComplete(processDefinitionKey,null);
JSONObject jsonObject = workflowFeignService.getTask(instanceId);
// workflowFeignService.completeByVariable(,)
return CommonResponseUtil.success();
}
// public JSONObject startNew(String processDefinitionKey) {
// String url = buildUrl(address, ProjectInitiationEnum.合并启动流程, null);
// Map<String, String> headerMap = Maps.newHashMap();
// headerMap.put(XJConstant.TOKEN_KEY, RequestContext.getToken());
// headerMap.put(XJConstant.PRODUCT, RequestContext.getProduct());
// headerMap.put(XJConstant.APPKEY, RequestContext.getAppKey());
// JSONObject body = new JSONObject();
// body.put("processDefinitionKey", processDefinitionKey);
// String resultStr = HttpUtil.sendHttpPostJsonWithHeader(url, body.toJSONString(), headerMap);
// logger.info("\r\n请求路径=======================>" + url + "\r\n请求参数=======================>" + body + "\r\n返回参数=======================>" + resultStr);
// return JSON.parseObject(resultStr);
// }
//
// private String buildUrl(String address, ProjectInitiationEnum projectInitiationEnum, Map<String, String> map) {
// String uri = projectInitiationEnum.getUri();
// String params = projectInitiationEnum.getParams();
// if (!StringUtils.isEmpty(params) && map != null) {
// String[] paramsArr = params.split(",");
// for (String param : paramsArr) {
// uri = uri.replace("{" + param + "}", map.get(param));
// }
// }
// return address + uri;
// }
}
......@@ -6,7 +6,7 @@ spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.10.210:10001/eureka/
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......
......@@ -50,3 +50,5 @@ emqx.user-name=super
emqx.password=123456
fire-rescue=123
params.work.flow.processDefinitionKey=ceshi
\ No newline at end of file
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