Commit d939b7fc authored by zhangyingbin's avatar zhangyingbin

完善基本流程

parent d27ab565
package com.yeejoin.amos.boot.module.ugp.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@ApiModel(value="ProjectInitiationDto", description="项目立项流程日志表")
public class ProjectInitiationDto extends BaseDto {
@TableField("instance_id")
private String instanceId;
@TableField("task_id")
private String taskId;
@TableField("task_name")
private String taskName;
@TableField("executor")
private String executor;
@TableField("context")
private String context;
}
package com.yeejoin.amos.boot.module.ugp.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tz_ugp_project_initiation_log")
public class ProjectInitiation extends BaseEntity {
@TableField("instance_id")
private String instanceId;
@TableField("task_id")
private String taskId;
@TableField("task_name")
private String taskName;
@TableField("executor")
private String executor;
@TableField("context")
private String context;
}
package com.yeejoin.amos.boot.module.ugp.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectInitiation;
public interface ProjectInitiationMapper extends BaseMapper<ProjectInitiation> {
}
package com.yeejoin.amos.boot.module.ugp.api.service;
import com.alibaba.fastjson.JSONObject;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
public interface IProjectInitiationService {
/**
* 流程启动
* @return 返回instanceId ,加入项目信息表中
* @throws Exception
*/
String start();
/**
* 执行流程节点,并记录日志
*/
void execute(String instanceId, Object object, String option);
}
package com.yeejoin.amos.boot.module.ugp.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.ugp.biz.service.impl.ProjectInitiationServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ResponseHeader;
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.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@RestController
@Api(tags = "流程相关")
......@@ -22,7 +23,15 @@ public class ProjectInitiationController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/start")
@ApiOperation(httpMethod = "GET", value = "流程启动", notes = "流程启动")
public void start() throws Exception {
projectInitiationServiceImpl.start();
public ResponseModel<String> start() throws Exception {
return ResponseHelper.buildResponse(projectInitiationServiceImpl.start());
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/execute/{instanceId}")
@ApiOperation(httpMethod = "GET", value = "流程启动", notes = "流程启动")
public ResponseModel<String> execute(@PathVariable("instanceId")String instanceId, Object object, String option) throws Exception {
projectInitiationServiceImpl.execute(instanceId,object,option);
return ResponseHelper.buildResponse("ok");
}
}
......@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.ugp.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
......@@ -10,65 +12,177 @@ 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 com.yeejoin.amos.boot.module.ugp.api.dto.ProjectInitiationDto;
import com.yeejoin.amos.boot.module.ugp.api.entity.InstallNoticeMsg;
import com.yeejoin.amos.boot.module.ugp.api.entity.ProjectInitiation;
import com.yeejoin.amos.boot.module.ugp.api.entity.SuperviseRule;
import com.yeejoin.amos.boot.module.ugp.api.mapper.ProjectInitiationMapper;
import com.yeejoin.amos.boot.module.ugp.api.service.IProjectInitiationService;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.client.AgencyUserClient;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.rule.model.IdxProjectModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.SmsRecordModel;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.client.TaskClient;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
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.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.StringUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
import java.util.*;
@Service
public class ProjectInitiationServiceImpl {
public class ProjectInitiationServiceImpl extends BaseService<ProjectInitiationDto, ProjectInitiation, ProjectInitiationMapper> implements IProjectInitiationService {
@Autowired
WorkflowExcuteServiceImpl workflowExcuteService;
@Autowired
WorkflowFeignService workflowFeignService;
@Autowired
InstallNoticeMsgServiceImpl installNoticeMsgService;
@Autowired
ProjectServiceImpl projectServiceImpl;
@Autowired
SuperviseRuleServiceImpl superviseRuleServiceImpl;
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();
private static String SMSCODE = "SMS_UGP_0001";
@Override
@Transactional(rollbackFor = Exception.class)
public String start() {
String instanceId = null;
try {
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(processDefinitionKey);
dto.setBusinessKey("1");
AjaxResult ajaxResult = Workflow.taskClient.startByVariable(dto);
instanceId = ((Map)ajaxResult.get("data")).get("id").toString();
ProjectInitiation projectInitiation = new ProjectInitiation();
projectInitiation.setInstanceId(instanceId);
projectInitiation.setTaskName("流程启动!");
this.save(projectInitiation);
} catch (Exception e) {
e.printStackTrace();
System.out.println("流程启动失败:"+e.getMessage());
}
//审核条件
String option = "0";
if (true) {
option = "1";
}
//执行审核流程
execute(instanceId, new JSONObject(),option);
return instanceId;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void execute(String instanceId,Object objectd, String option){
JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectd));
JSONObject jsonObject = workflowFeignService.getTask(instanceId);
ProjectInitiation projectInitiation = new ProjectInitiation();
projectInitiation.setInstanceId(instanceId);
projectInitiation.setContext(JSON.toJSONString(objectd));
JSONObject dataObject = jsonObject.getJSONObject("data");
projectInitiation.setTaskId(dataObject.getString("id"));
projectInitiation.setTaskName(dataObject.getString("name"));
TaskResultDTO dto = new TaskResultDTO();
dto.setResult(option);
dto.setResultCode("condition");
dto.setTaskId(projectInitiation.getTaskId());
HashMap<String, Object> var = new HashMap<>();
var.put("condition", option);
dto.setVariable(var);
if ("平台审核".equals(dataObject.getString("name"))) {
System.out.println();
}
if("监检员审核".equals(dataObject.getString("name"))){
if("1".equals(option)){
projectInitiation.setTaskName(dataObject.getString("name")+"(流程结束!)");
}
}
if("接受审查意见".equals(dataObject.getString("name"))){
projectInitiation.setTaskName(dataObject.getString("name")+"(流程结束!)");
}
if ("告知申请".equals(dataObject.getString("name"))) {
if(!ValidationUtil.isEmpty(objectd)) {
//设置短信发送的基本参数
HashMap<String, String> smsParams = new HashMap();
smsParams.put("smsCode", SMSCODE);
smsParams.put("companyName", object.getString("installationUnit"));
smsParams.put("projectName", object.getString("name"));
//条件构造器 通过项目id查出来的项目详情信息中的区域代码,在监管区域规则表中拿到详细信息中的监察部门id,在使用监察部门id查找到该部门下的用户List。
QueryWrapper<SuperviseRule> wrapper = new QueryWrapper<>();
wrapper.eq("admin_region_code", projectServiceImpl.getById(object.getLong("projectId")).getInstallRegionCode());
List<AgencyUserModel> agencyUserModelList = Privilege.agencyUserClient.queryByDepartmentId(superviseRuleServiceImpl.getOne(wrapper).getSuperviseDeptId(), null, null, null).getResult();
//遍历用户List,拿到用户手机号、userId,来发短信、存短信日志。
for (AgencyUserModel agencyUserModel : agencyUserModelList) {
SmsRecordModel smsRecordModel = sendSmsMassage(SMSCODE, agencyUserModel.getMobile(), smsParams);
InstallNoticeMsg installNoticeMsg = new InstallNoticeMsg();
if (ValidationUtil.isEmpty(smsRecordModel)) {
continue;
}
installNoticeMsg.setContent(smsRecordModel.getSmsContent());
installNoticeMsg.setInstallNoticeId(smsRecordModel.getSequenceNbr());
installNoticeMsg.setTargetUnitId(Long.valueOf(smsRecordModel.getAgencyCode()));
installNoticeMsg.setTargetPersonId(Long.valueOf(agencyUserModel.getUserId()));
installNoticeMsg.setSendTime(smsRecordModel.getSendTime());
installNoticeMsgService.save(installNoticeMsg);
}
}
}
if ("监检科室分配".equals(dataObject.getString("name"))) {
}
if ("监检员分配".equals(dataObject.getString("name"))) {
}
if ("监检员审核".equals(dataObject.getString("name"))) {
// 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;
// }
}
try {
Workflow.taskClient.completeByTask(projectInitiation.getTaskId(),dto);
this.save(projectInitiation);
} catch (Exception e) {
e.printStackTrace();
System.out.println("任务完成失败:"+e.getMessage());
}
}
@Transactional(rollbackFor = Exception.class)
public SmsRecordModel sendSmsMassage(String smsCode, String mobile, HashMap<String, String> smsParams){
SmsRecordModel smsRecordModel = new SmsRecordModel();
if(!ValidationUtil.isEmpty(mobile)){
smsParams.put("smsCode",smsCode);
smsParams.put("mobile",mobile);
smsRecordModel = Systemctl.smsClient.sendCommonSms(smsParams).getResult();
}
return smsRecordModel;
}
}
......@@ -29,4 +29,4 @@ emqx.password=123456
fire-rescue=123
params.work.flow.processDefinitionKey=ceshi
\ No newline at end of file
params.work.flow.processDefinitionKey=xiangmulixiangliucheng
\ No newline at end of file
......@@ -19,6 +19,11 @@
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-workflow</artifactId>
<version>1.7.9-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
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