Selaa lähdekoodia

应用和项目 推送

master
PoffyZhang 1 vuosi sitten
vanhempi
commit
9c166726b6
5 muutettua tiedostoa jossa 65 lisäystä ja 0 poistoa
  1. +51
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  2. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/PushProjectAppToIrsDTO.java
  3. +5
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectApplicationDTO.java
  4. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java
  5. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java

+ 51
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java Näytä tiedosto

@@ -2,7 +2,10 @@ package com.ningdatech.pmapi.irs.manage;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.common.enumeration.CommonEnum;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.CryptUtils;
import com.ningdatech.pmapi.common.util.RefreshKeyUtil;
import com.ningdatech.pmapi.irs.model.dto.ApiApplyDTO;
@@ -11,16 +14,22 @@ import com.ningdatech.pmapi.irs.model.dto.ApiSearchResult;
import com.ningdatech.pmapi.irs.model.dto.PushProjectAppToIrsDTO;
import com.ningdatech.pmapi.irs.model.res.ApiResponse;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication;
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @Classname AppIrsManage
@@ -35,6 +44,10 @@ public class AppIrsManage {

private final IProjectService projectService;

private final IProjectApplicationService applicationService;

private final StateMachineUtils stateMachineUtils;

@Value("${irs.push-app.appKey}")
private String pushAppKey;

@@ -61,7 +74,11 @@ public class AppIrsManage {
*/
public Boolean pushProjectApp(PushProjectAppToIrsDTO dto) throws NoSuchAlgorithmException {
String appCode = dto.getAppCode();
Long appId = dto.getAppId();
String projectCode = dto.getProjectCode();
ProjectApplication app = applicationService.getById(appId);
VUtils.isTrue(Objects.isNull(app)).throwMessage("应用不存在!");
VUtils.isTrue(CommonEnum.NO.getCode().equals(app.getIsFirst())).throwMessage("应用不是初次新建!");
Project project = projectService.getProjectByCode(projectCode);
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!");

@@ -90,6 +107,40 @@ public class AppIrsManage {

ApiResponse body = forEntity.getBody();

if(Objects.isNull(body)){
return Boolean.FALSE;
}

if(Objects.nonNull(body.getSuccess())
&& body.getSuccess()){
//保存关系
app.setAppCode(appCode);
if(applicationService.updateById(app)){
/**
* 判断下 如果成功的话 那么判断下 这个项目的初次创建的app 是否都已经被注册
* 如果都已经注册 要调用状态机 进入下一个状态
*/
List<ProjectApplication> apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectId, project.getId()));
//筛选出 初次新建的app 但是没有appCode的
apps = apps.stream().filter(a -> {
if(CommonEnum.YES.getCode().equals(a.getIsFirst()) &&
StringUtils.isBlank(app.getAppCode())){
return Boolean.TRUE;
}
return Boolean.FALSE;
})
.collect(Collectors.toList());

//如果筛选出来的 为空的话 就调用状态机
if(CollUtil.isEmpty(apps)){
stateMachineUtils.pass(project);
project.setUpdateOn(LocalDateTime.now());
projectService.updateById(project);
}
}
}

return body.getSuccess();
}



+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/irs/model/dto/PushProjectAppToIrsDTO.java Näytä tiedosto

@@ -20,6 +20,10 @@ import javax.validation.constraints.NotBlank;
@NoArgsConstructor
public class PushProjectAppToIrsDTO {

@ApiModelProperty("我们系统的appId")
@NotBlank(message = "appId 不能为空")
private Long appId;

@ApiModelProperty("app code")
@NotBlank(message = "appCode 不能为空")
private String appCode;


+ 5
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectApplicationDTO.java Näytä tiedosto

@@ -162,4 +162,9 @@ public class ProjectApplicationDTO implements Serializable {
@ApiModelProperty("申报单位编码")
private String buildOrgCode;

@ApiModelProperty("项目编码")
private String projectCode;

@ApiModelProperty("应用编码")
private String appCode;
}

+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectApplication.java Näytä tiedosto

@@ -179,4 +179,6 @@ public class ProjectApplication implements Serializable {

private Long updateBy;

@ApiModelProperty("项目编码")
private String projectCode;
}

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectApplicationVO.java Näytä tiedosto

@@ -171,6 +171,9 @@ public class ProjectApplicationVO implements Serializable {
@ApiModelProperty("申报单位编码")
private String buildOrgCode;

@ApiModelProperty("项目编码")
private String projectCode;

private Long createBy;

private Long updateBy;


Loading…
Peruuta
Tallenna