Browse Source

对接三方平台修改

master
wxz 5 years ago
parent
commit
440472f1ec
  1. 19
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ThirdPlatformFormDTO.java
  2. 18
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdplatformCustomerRegisterResultDTO.java
  3. 15
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java
  4. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java
  5. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java
  6. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ProjectController.java
  7. 43
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ThirdPlatformController.java
  8. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java
  9. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ProjectService.java
  10. 11
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java
  11. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  12. 21
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java
  13. 22
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml

19
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ThirdPlatformFormDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class ThirdPlatformFormDTO {
// 列出注册关系分组
public static interface ListRegRelsGroups {}
@NotBlank(message = "客户ID不能为空", groups = { ListRegRelsGroups.class })
private String customerId;
@NotBlank(message = "客户ID不能为空", groups = { ListRegRelsGroups.class })
private String actionKey;
}

18
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdplatformCustomerRegisterResultDTO.java

@ -0,0 +1,18 @@
package com.epmet.dto.result;
import lombok.Data;
@Data
public class ThirdplatformCustomerRegisterResultDTO {
/**
*
*/
private String customerId;
/**
*
*/
private String platformId;
private String platformName;
}

15
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java

@ -2,6 +2,7 @@ package com.epmet.apiservice.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.apiservice.ApiService;
import com.epmet.apiservice.result.LZGridPlatformProjectAssistResult;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.constant.ThirdPlatformActions;
import com.epmet.dto.form.ProjectApplyAssistFormDTO;
@ -17,13 +18,21 @@ public class LuzhouGridPlatformApiService extends ApiService {
@Override
public ProjectAssistResult projectAssist(ProjectApplyAssistFormDTO formDTO) {
String platformId = formDTO.getPlatformId();
String result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, "{}", null);
ProjectAssistResult projectAssistResult = null;
// 正式调用第三方平台
//String result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, "{}", null);
// 开发阶段临时写死
String result = "{\"eventId\":\"test-task-id\"}";
ProjectAssistResult projectAssistResult = new ProjectAssistResult();
if (!StringUtils.isBlank(result)) {
// 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是
// 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体,
// 所有apiService都要想办法转化成这个类型。
//projectAssistResult = JSON.parseObject(result, ProjectAssistResult.class);
LZGridPlatformProjectAssistResult lzResult = JSON.parseObject(result, LZGridPlatformProjectAssistResult.class);
// 此处设置为第三方系统返回的唯一id
projectAssistResult.setTaskId(lzResult.getEventId());
}
System.out.println("泸州网格化平台项目协助发送成功");
return projectAssistResult;

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java

@ -1,4 +1,13 @@
package com.epmet.apiservice.result;
import lombok.Data;
@Data
public class LZGridPlatformProjectAssistResult {
/**
* 事件id
*/
private String eventId;
}

5
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java

@ -5,4 +5,9 @@ import lombok.Data;
@Data
public class ProjectAssistResult {
/**
* 任务id
*/
private String taskId;
}

5
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ProjectController.java

@ -1,5 +1,6 @@
package com.epmet.controller;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ProjectApplyAssistFormDTO;
@ -45,8 +46,8 @@ public class ProjectController {
@PostMapping("apply-assist")
public Result applyAssist(@RequestBody ProjectApplyAssistFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
projectService.applyAssist(formDTO);
return new Result();
ProjectAssistResult projectAssistResult = projectService.applyAssist(formDTO);
return new Result().ok(projectAssistResult);
}
}

43
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/ThirdPlatformController.java

@ -0,0 +1,43 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ThirdPlatformFormDTO;
import com.epmet.dto.result.ThirdplatformCustomerRegisterResultDTO;
import com.epmet.service.ThirdPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 第三方平台维护相关api
*/
@RestController
@RequestMapping("thirdplatform")
public class ThirdPlatformController {
@Autowired
private ThirdPlatformService thirdPlatformService;
/**
* 列出第三方平台注册关系
* @param input
* @return
*/
@PostMapping("list-reg-rels")
public Result<List<ThirdplatformCustomerRegisterResultDTO>> listRegsteredPlatforms(@RequestBody ThirdPlatformFormDTO input) {
ValidatorUtils.validateEntity(input);
List<ThirdplatformCustomerRegisterResultDTO> platformRegs = thirdPlatformService.listByCustomerId(input.getCustomerId(), input.getActionKey());
return new Result<List<ThirdplatformCustomerRegisterResultDTO>>().ok(platformRegs);
}
//@PostMapping("register")
}

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java

@ -19,10 +19,13 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.constant.ThirdPlatformConstant;
import com.epmet.dto.result.ThirdplatformCustomerRegisterResultDTO;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
@ -32,5 +35,12 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface ThirdplatformCustomerRegisterDao extends BaseDao<ThirdplatformCustomerRegisterEntity> {
/**
* 动态sql查询
* @param customerId
* @return
*/
List<ThirdplatformCustomerRegisterResultDTO> listDTOS(@Param("customerId") String customerId, @Param("actionKey") String actionKey);
ThirdplatformCustomerRegisterEntity getByCustomerIdAndPlatformId(@Param("customerId") String customerId, @Param("platformId") String platformId);
}

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ProjectService.java

@ -1,5 +1,6 @@
package com.epmet.service;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.dto.form.ProjectApplyAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
@ -14,5 +15,5 @@ public interface ProjectService {
*
* @param formDTO
*/
void applyAssist(ProjectApplyAssistFormDTO formDTO);
ProjectAssistResult applyAssist(ProjectApplyAssistFormDTO formDTO);
}

11
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java

@ -0,0 +1,11 @@
package com.epmet.service;
import com.epmet.dto.result.ThirdplatformCustomerRegisterResultDTO;
import java.util.List;
public interface ThirdPlatformService {
List<ThirdplatformCustomerRegisterResultDTO> listByCustomerId(String customerId, String actionKey);
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -24,7 +24,7 @@ public class ProjectServiceImpl implements ProjectService, ApiServiceSelector {
}
@Override
public void applyAssist(ProjectApplyAssistFormDTO formDTO) {
public ProjectAssistResult applyAssist(ProjectApplyAssistFormDTO formDTO) {
String customerId = formDTO.getCustomerId();
String platformId = formDTO.getPlatformId();
@ -33,6 +33,6 @@ public class ProjectServiceImpl implements ProjectService, ApiServiceSelector {
// 判断该客户是否注册了该平台,如果没有的话,抛出异常
apiService.judgeRegistered(customerId, platformId);
ProjectAssistResult projectAssistResult = apiService.projectAssist(formDTO);
return apiService.projectAssist(formDTO);
}
}

21
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java

@ -0,0 +1,21 @@
package com.epmet.service.impl;
import com.epmet.dao.ThirdplatformCustomerRegisterDao;
import com.epmet.dto.result.ThirdplatformCustomerRegisterResultDTO;
import com.epmet.service.ThirdPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ThirdPlatformServiceImpl implements ThirdPlatformService {
@Autowired
private ThirdplatformCustomerRegisterDao thirdplatformCustomerRegisterDao;
@Override
public List<ThirdplatformCustomerRegisterResultDTO> listByCustomerId(String customerId, String actionKey) {
return thirdplatformCustomerRegisterDao.listDTOS(customerId, actionKey);
}
}

22
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml

@ -32,5 +32,27 @@
and DEL_FLAG = 0
</select>
<select id="listDTOS" resultType="com.epmet.dto.result.ThirdplatformCustomerRegisterResultDTO">
select tcr.id,
tcr.customer_id,
tcr.platform_id,
tpf.PLATFORM_NAME,
tcr.del_flag,
tcr.revision,
tcr.created_by,
tcr.created_time,
tcr.updated_by,
tcr.updated_time
from thirdplatform_customer_register tcr
inner join thirdplatform tpf on (tcr.PLATFORM_ID = tpf.ID)
inner join thirdplatform_action ta on (tpf.ID = ta.PLATFORM_ID)
<where>
tcr.CUSTOMER_ID = #{customerId}
and ta.ACTION_KEY = #{actionKey}
and tcr.DEL_FLAG = 0
and tpf.DEL_FLAG = 0
</where>
</select>
</mapper>
Loading…
Cancel
Save