Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-19 09:04:47 +08:00
commit 409b0b3b9b
3 changed files with 76 additions and 17 deletions

View File

@ -25,6 +25,7 @@ import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.*;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -93,7 +94,7 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
final String eventName = delegateExecution.getEventName();
switch (eventName) {
case EVENTNAME_END:
endTake(delegateExecution.getVariables());
endTake(delegateExecution);
break;
}
}
@ -120,7 +121,8 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
*
* @param kv
*/
private void endTake(Map<String, Object> kv) { // 进入最后结束节点
private void endTake(DelegateExecution delegateExecution) { // 进入最后结束节点
Map<String, Object> kv = delegateExecution.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
@ -141,6 +143,11 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
.collect(Collectors.toList()).toArray(new String[dtoList.size()]);
}
jdbcTemplate.batchUpdate(sqls);
if (auditingBaseDTO.getReject() == null || auditingBaseDTO.getReject() != Boolean.TRUE) { // 都是同意
batchApplyCode(delegateExecution, dtoList);
}
}
}
@ -218,19 +225,19 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
Map<String, Object> kv = delegateTask.getVariables();
//如果有code说明已经注册过了,以及只有通过的流程申请
if (kv.get("gatewayCode") != null ||
!ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) return;
try {
List<TAbilityApplicationDTO> dtoList = new ArrayList<>();
if (kv.containsKey("tAbilityApplicationDTOList")) {
dtoList = (List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList");
}
dtoList.stream().forEach(index -> {
applyCode(delegateTask, index); // 列表内都执行
});
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
// if (kv.get("gatewayCode") != null ||
// !ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) return;
// try {
// List<TAbilityApplicationDTO> dtoList = new ArrayList<>();
// if (kv.containsKey("tAbilityApplicationDTOList")) {
// dtoList = (List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList");
// }
// dtoList.stream().forEach(index -> {
// applyCode(delegateTask, index); // 列表内都执行
// });
// } catch (Exception e) {
// logger.error(e.getLocalizedMessage(), e);
// }
}
@ -261,5 +268,49 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), msg);
}
private void batchApplyCode(DelegateExecution delegateExecution, List<TAbilityApplicationDTO> dtoList) {
logger.info("-------能力申请code-------");
StringBuilder allMsg = new StringBuilder();
allMsg.append("您的能力申请已通过,访问令牌如下:");
allMsg.append('\n');
for (TAbilityApplicationDTO abilityApplicationDTO : dtoList) {
ResourceEntity resourceEntity = resourceService.selectById(abilityApplicationDTO.getResourceId());
//没有groupid当做没有接口直接跳过
if (resourceEntity.getGroupId() == null)
continue;
String code = UUID.randomUUID().toString();
apiGatewayService.subscribeCode(String.valueOf(abilityApplicationDTO.getId()), code);
String apiPrefix = "/juapi/" + abilityApplicationDTO.getResourceId();
String msg = String.format("能力名称:%s接口认证code为%s, 接口公共前缀为:%s", resourceEntity.getName(), code, apiPrefix);
allMsg.append(msg);
allMsg.append('\n');
}
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
//先用不正经方法找
List<Task> tasks = taskService.createTaskQuery().
processInstanceId(delegateExecution.getProcessInstanceId()).
list();
Task bigDataTask = null;
for (Task task : tasks) {
if ("大数据部门负责人审批".equals(task.getName())) {
bigDataTask = task;
break;
}
}
if (bigDataTask != null){
taskService.addComment(bigDataTask.getId(), delegateExecution.getProcessInstanceId(), allMsg.toString());
}
}
}

View File

@ -35,7 +35,7 @@ spring:
config:
multi-statement-allow: true
flyway:
enabled: true
enabled: false
validate-on-migrate: false
#上传的静态资源配置
resource:
@ -65,4 +65,7 @@ qdyjj:
ipAndPort: 15.2.21.238:9015
mybatis-plus:
configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
sso:
mode: cas # 取值 yawei,cas,不填时为禁用sso

View File

@ -45,6 +45,11 @@ public class ApiGatewayServiceTest {
}
@Test
public void registerAPI(){
apiGatewayService.registerApi2Gateway("1522550194544123907");
}
@Test
public void registerCode2Group() {
String code = UUID.randomUUID().toString();