Commit 417b0273 authored by tangwei's avatar tangwei

修改接口

parent 0bcdec2d
...@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.feign.WorkflowFeignClient; ...@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.feign.WorkflowFeignClient;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.beans.BeanMap; import net.sf.cglib.beans.BeanMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
...@@ -28,8 +29,10 @@ import org.springframework.stereotype.Service; ...@@ -28,8 +29,10 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import springfox.documentation.service.ApiListing; import springfox.documentation.service.ApiListing;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 服务实现类 * 服务实现类
...@@ -73,8 +76,24 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -73,8 +76,24 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
@Override @Override
@Transactional
public boolean savePowerStation(PowerStation powerStation) { public boolean savePowerStation(PowerStation powerStation) {
try{ //流程节点code
String flowTaskIdnext=this.getTaskNoAuth(powerStation.getProcessInstanceId());
WorkDto workDto=this.getNodeInfoCode(flowTaskIdnext);
powerStation.setNextProcessNode(workDto.getNextProcessNode());
powerStation.setNodeRole(workDto.getNodeRole());
powerStation.setNodeRouting(workDto.getNodeRouting());
return this.saveOrUpdate(powerStation); return this.saveOrUpdate(powerStation);
}catch (Exception e){
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
}
} }
@Override @Override
...@@ -146,7 +165,8 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -146,7 +165,8 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
powerStationService.savePowerStation(powerStation); powerStationService.savePowerStation(powerStation);
} }
}catch (Exception e){ }catch (Exception e){
log.error("工作流执行失败:{}", e.getMessage()); throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
} }
return code; return code;
} }
...@@ -154,37 +174,53 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -154,37 +174,53 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
public WorkDto getNodeInfoCode(String flowTaskId){ public WorkDto getNodeInfoCode(String flowTaskId){
WorkDto workDto=null; WorkDto workDto=null;
FeignClientResult<JSONObject> jSONObject= workflowFeignClient.getNodeInfo(flowTaskId); try{
FeignClientResult<JSONObject> jSONObject= workflowFeignClient.getNodeInfo(flowTaskId);
if(IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.getStatus()))){ if(IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.getStatus()))){
JSONObject js=jSONObject.getResult(); JSONObject js=jSONObject.getResult();
if(js==null){ if(js==null){
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
} }
JSONObject taskInfo= js.get("taskInfo")!=null?JSON.parseObject(js.get("taskInfo").toString()):null; LinkedHashMap taskInfo= js.get("taskInfo")!=null?(LinkedHashMap)js.get("taskInfo"):null;
String nextProcessNode=taskInfo!=null?taskInfo.get("taskDefinitionKey").toString():null; String nextProcessNode=taskInfo!=null?taskInfo.get("taskDefinitionKey").toString():null;
JSONObject executor= js.get("executor")!=null?JSON.parseObject(js.get("executor").toString()):null; List<LinkedHashMap> executor= js.get("executor")!=null?( List<LinkedHashMap>)js.get("executor"):null;
String nodeRole=executor!=null?executor.get("groupId").toString():null; String nodeRole=null;
if(!executor.isEmpty()){
List<String> idList = executor.stream().map(e->e.get("groupId").toString()).collect(Collectors.toList());
nodeRole=StringUtils.join(idList,",");
}
JSONObject extensionInfo= js.get("extensionInfo")!=null?JSON.parseObject(js.get("extensionInfo").toString()):null; LinkedHashMap extensionInfo= js.get("extensionInfo")!=null?(LinkedHashMap)js.get("extensionInfo"):null;
String nodeRouting=extensionInfo!=null?extensionInfo.get("nodeRole").toString():null; String nodeRouting=extensionInfo!=null?extensionInfo.get("nodeRole").toString():null;
workDto=new WorkDto(nodeRouting, nodeRole, nextProcessNode); workDto=new WorkDto(nodeRouting, nodeRole, nextProcessNode);
} }
return workDto; return workDto;
}catch (Exception e){
e.printStackTrace();
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
} }
}
public String getTaskNoAuth(String processInstanceId){ public String getTaskNoAuth(String processInstanceId){
String flowTaskId=null; String flowTaskId=null;
JSONObject jSONObject= workflowFeignClient.getTaskNoAuth(processInstanceId); try{
JSONObject jSONObject= workflowFeignClient.getTaskNoAuth(processInstanceId);
if(IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.get("code")))){ if(IDX_REQUEST_STATE.equals(String.valueOf(jSONObject.get("code")))){
JSONObject jsd= jSONObject.get("data")!=null?JSON.parseObject(jSONObject.get("data").toString()):null; LinkedHashMap jsd= jSONObject.get("data")!=null?(LinkedHashMap)jSONObject.get("data"):null;
flowTaskId=jsd!=null?jsd.get("id").toString():null; flowTaskId=jsd!=null?jsd.get("id").toString():null;
} }
if(flowTaskId==null){ if(flowTaskId==null){
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!"); throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
} }
return flowTaskId; return flowTaskId;
}catch (Exception e){
e.printStackTrace();
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
}
} }
// 设计信息填充 // 设计信息填充
......
...@@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -233,7 +234,7 @@ public class SurveyInformationServiceImpl extends BaseService<SurveyInformationD ...@@ -233,7 +234,7 @@ public class SurveyInformationServiceImpl extends BaseService<SurveyInformationD
powerStationService.savePowerStation(powerStation); powerStationService.savePowerStation(powerStation);
} }
} catch (Exception e){ } catch (Exception e){
e.getMessage(); throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
} }
} }
......
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