Commit debe3b98 by 穆龙飞

Merge branch 'feature-changeFlow-221110' of…

Merge branch 'feature-changeFlow-221110' of https://yxwbgit.mail.netease.com/yx-qc-change-flow/yanxuan-qc-change-system into feature-changeFlow-221110
parents 5d0d79e1 a9165047
...@@ -42,3 +42,5 @@ spring.redis.pool.max-wait=10000 ...@@ -42,3 +42,5 @@ spring.redis.pool.max-wait=10000
spring.redis.host=yx-cust23-online.ncr.cn-east-p1.internal. spring.redis.host=yx-cust23-online.ncr.cn-east-p1.internal.
spring.redis.port=32427 spring.redis.port=32427
# supplier
supplier.url=http://127.0.0.1:8550/proxy/test-v1.yanxuan-supplier-ms.service.mailsaas
\ No newline at end of file
...@@ -39,3 +39,6 @@ spring.redis.pool.max-idle=20 ...@@ -39,3 +39,6 @@ spring.redis.pool.max-idle=20
spring.redis.pool.max-wait=10000 spring.redis.pool.max-wait=10000
spring.redis.host=yx-cust23-test.ncr.cn-east-p1.internal spring.redis.host=yx-cust23-test.ncr.cn-east-p1.internal
spring.redis.port=31461 spring.redis.port=31461
# supplier
supplier.url=http://127.0.0.1:8550/proxy/test-v1.yanxuan-supplier-ms.service.mailsaas
\ No newline at end of file
...@@ -200,7 +200,7 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ ...@@ -200,7 +200,7 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ
*/ */
private GoodsResponseRpc queryChangeSupplier(ChangeCommanderEnum commanderEnum,String changeSupplierId,String commander){ private GoodsResponseRpc queryChangeSupplier(ChangeCommanderEnum commanderEnum,String changeSupplierId,String commander){
GoodsResponseRpc rpc = new GoodsResponseRpc(); GoodsResponseRpc rpc = new GoodsResponseRpc();
if (commanderEnum.getId() != ChangeCommanderEnum.SUPPLIERS_ASSOCIATED.getId() || changeSupplierId == null || commander == null){ if (!commanderEnum.getId().equals(ChangeCommanderEnum.SUPPLIERS_ASSOCIATED.getId()) || changeSupplierId == null || commander == null){
return null; return null;
} }
SupplierRelatedUserReq req = new SupplierRelatedUserReq(); SupplierRelatedUserReq req = new SupplierRelatedUserReq();
...@@ -217,7 +217,7 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ ...@@ -217,7 +217,7 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ
req.setSupplierIdList(supplierIdList); req.setSupplierIdList(supplierIdList);
//进行参数解析 //进行参数解析
List<SupplierUserRsp> listAjaxResponse = supplierInfoService.querySupplierRelatedUser(req); List<SupplierUserRsp> listAjaxResponse = supplierInfoService.querySupplierRelatedUser(req);
if (listAjaxResponse != null || listAjaxResponse.size() == 0){ if (CollectionUtils.isEmpty(listAjaxResponse)){
return null; return null;
} }
SupplierUserRsp supplierUserRsp = listAjaxResponse.get(0); SupplierUserRsp supplierUserRsp = listAjaxResponse.get(0);
...@@ -315,7 +315,7 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ ...@@ -315,7 +315,7 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ
log.error("[queryGoodsCommander] error,e{}", e); log.error("[queryGoodsCommander] error,e{}", e);
commanderResponse.setEmail(appConfig.getDefaultEmail()); commanderResponse.setEmail(appConfig.getDefaultEmail());
} }
break; return commanderResponse;
case SUPPLIERS_ASSOCIATED: case SUPPLIERS_ASSOCIATED:
String changeSupplier = req.getChangeSupplier(); String changeSupplier = req.getChangeSupplier();
Assert.isTrue(StringUtils.isNotBlank(changeSupplier), "变更负责人为供应商时,商品列表不可为空"); Assert.isTrue(StringUtils.isNotBlank(changeSupplier), "变更负责人为供应商时,商品列表不可为空");
...@@ -329,11 +329,10 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ ...@@ -329,11 +329,10 @@ public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigServ
log.error("[queryChangeSupplier] error,e{}", e); log.error("[queryChangeSupplier] error,e{}", e);
commanderResponse.setEmail(appConfig.getDefaultEmail()); commanderResponse.setEmail(appConfig.getDefaultEmail());
} }
break; return commanderResponse;
default: default:
throw ExceptionFactory.createBiz(ResponseCode.COMMANDER_TYPE_NOT_EXIST, "变更负责人类型错误"); throw ExceptionFactory.createBiz(ResponseCode.COMMANDER_TYPE_NOT_EXIST, "变更负责人类型错误");
} }
return null;
} }
/** /**
......
package com.netease.mail.yanxuan.change.integration.flow.supplier.impl; package com.netease.mail.yanxuan.change.integration.flow.supplier.impl;
import java.util.List;
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 com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.integration.flow.supplier.FlowRpcSupplierInfoService; import com.netease.mail.yanxuan.change.integration.flow.supplier.FlowRpcSupplierInfoService;
import com.netease.mail.yanxuan.change.integration.flow.supplier.req.SupplierRelatedUserReq; import com.netease.mail.yanxuan.change.integration.flow.supplier.req.SupplierRelatedUserReq;
import com.netease.mail.yanxuan.change.integration.flow.supplier.rsp.SupplierUserRsp; import com.netease.mail.yanxuan.change.integration.flow.supplier.rsp.SupplierUserRsp;
import com.netease.mail.yanxuan.change.integration.rpc.RpcObjectHandler; import com.netease.mail.yanxuan.change.integration.rpc.RpcListData;
import com.netease.mail.yanxuan.change.integration.rpc.RpcTemplate; import com.netease.mail.yanxuan.change.integration.rpc.RpcTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @author WangJiaXiang * @author WangJiaXiang
...@@ -21,18 +22,27 @@ import java.util.List; ...@@ -21,18 +22,27 @@ import java.util.List;
@Service @Service
public class FlowRpcSupplierInfoServiceImpl implements FlowRpcSupplierInfoService { public class FlowRpcSupplierInfoServiceImpl implements FlowRpcSupplierInfoService {
private final String path = "/api/supplier/batchGetSupplierRelatedUser.json";
@Autowired @Autowired
private RpcTemplate rpcTemplate; private RpcTemplate rpcTemplate;
@Value("${supplier.url}")
private String supplierUrl;
Logger logger = LoggerFactory.getLogger(FlowRpcSupplierInfoServiceImpl.class); Logger logger = LoggerFactory.getLogger(FlowRpcSupplierInfoServiceImpl.class);
@Override @Override
public List<SupplierUserRsp> querySupplierRelatedUser(SupplierRelatedUserReq req) { public List<SupplierUserRsp> querySupplierRelatedUser(SupplierRelatedUserReq req) {
String url = "http://127.0.0.1:8550/proxy/test-v1.yanxuan-supplier-ms.service.mailsaas/api/supplier/batchGetSupplierRelatedUser.json"; List<SupplierUserRsp> objects = null;
JSONObject supplierUserRsp = rpcTemplate.postJson(url, JSON.toJSONString(req),500,new RpcObjectHandler<>(JSONObject.class)); try {
Object data = supplierUserRsp.get("data"); String url = supplierUrl + path;
List<SupplierUserRsp> objects = JSONArray.parseArray(data.toString(), SupplierUserRsp.class); objects = rpcTemplate.postJson(url, JSON.toJSONString(req), 500,
logger.error("请求返回结果"+objects); new RpcListData<>(SupplierUserRsp.class));
} catch (Exception e) {
e.printStackTrace();
logger.error("请求返回结果,e:{}", e);
}
return objects; return objects;
} }
} }
package com.netease.mail.yanxuan.change.integration.rpc;
/**
* @author jmt
* @Date 2021/6/7
*/
public enum RpcCode {
/**
* 成功响应
*/
OK(200),
/**
* 业务失败
*/
FAIL(400),
/**
* 系统异常
*/
SERVER_ERROR(500);
private int value;
RpcCode(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
package com.netease.mail.yanxuan.change.integration.rpc;
/**
* @author jmt
* @Date 2021/6/7
*/
public interface RpcConst {
String CODE = "code";
String RESULT = "result";
String DATA = "data";
String ERRCODE = "errorCode";
}
package com.netease.mail.yanxuan.change.integration.rpc;
import java.io.IOException;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* @author jmt
* @Date 2021/6/7
*/
public class RpcListData<T> implements RpcTemplate.CallHandler<List<T>> {
private final Class<T> tClass;
public RpcListData(Class<T> tClass) {
this.tClass = tClass;
}
@Override
public List<T> handle(String resp) throws IOException {
JSONObject rpcResult = JSON.parseObject(resp);
int code = rpcResult.getIntValue(RpcConst.CODE);
if (code == RpcCode.OK.getValue()) {
return JSON.parseArray(rpcResult.getString(RpcConst.DATA), tClass);
}
throw new RpcResultException("response error, code = " + code);
}
}
package com.netease.mail.yanxuan.change.integration.rpc;
/**
* @author: bndong
* @date: 2021/5/29
*/
public class RpcResultException extends RpcException {
public RpcResultException(String message) {
super(message);
}
public RpcResultException(Throwable t) {
super(t);
}
public RpcResultException(String message, Throwable t) {
super(message, t);
}
}
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