Commit 2d5a111c by jx-art

部分代码提交 测试请求外部接口

parent ffd70ceb
package com.netease.mail.yanxuan.change.biz.service;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeCommanderPO;
/**
* @author WangJiaXiang
* @date 2022/11/18/018$
* 内部服务接口
*/
public interface InteriorChangeConfigService {
String queryCommanderInfo(ChangeCommanderPO changeCommander);
}
...@@ -10,6 +10,7 @@ import com.netease.mail.yanxuan.change.biz.service.AdminChangeConfigService; ...@@ -10,6 +10,7 @@ import com.netease.mail.yanxuan.change.biz.service.AdminChangeConfigService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeTypeService; import com.netease.mail.yanxuan.change.biz.service.change.ChangeTypeService;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode; import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.bean.ResponseCodeEnum; import com.netease.mail.yanxuan.change.common.bean.ResponseCodeEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig; import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig; import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType; import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
...@@ -21,6 +22,7 @@ import com.netease.mail.yanxuan.change.dal.meta.model.vo.ChangeConfigVO; ...@@ -21,6 +22,7 @@ import com.netease.mail.yanxuan.change.dal.meta.model.vo.ChangeConfigVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -151,6 +153,11 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService { ...@@ -151,6 +153,11 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
if (changeConfigReq.getChangeSubject() == null){ if (changeConfigReq.getChangeSubject() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY); throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
} }
//验证变更主体
Boolean containsChangeSubject = ChangeSubjectEnum.getByType(changeConfigReq.getChangeSubject());
if (!containsChangeSubject){
throw ExceptionFactory.createBiz(ResponseCode.NO_DATA,"变更主体不存在");
}
changeConfig.setChangeSubject(changeConfigReq.getChangeSubject()); changeConfig.setChangeSubject(changeConfigReq.getChangeSubject());
if (changeConfigReq.getChangeLevel() == null){ if (changeConfigReq.getChangeLevel() == null){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY); throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_DEFICIENCY);
......
package com.netease.mail.yanxuan.change.biz.service.impl;
import com.netease.mail.yanxuan.change.biz.service.InteriorChangeConfigService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService;
import com.netease.mail.yanxuan.change.common.enums.ChangeCommanderEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeCommanderPO;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author WangJiaXiang
* @date 2022/11/18/018$
*/
public class InteriorChangeConfigServiceImpl implements InteriorChangeConfigService {
@Autowired
private ChangeConfigService changeConfigService;
@Override
public String queryCommanderInfo(ChangeCommanderPO changeCommander) {
//获取模板名称
ChangeConfig changeConfig = changeConfigService.queryChangeConfig(changeCommander.getId());
//查询出当前模板配置中选择的 角色
ChangeCommanderEnum changeCommanderEnum = ChangeCommanderEnum.getChangeCommanderEnum(changeConfig.getChangeCommanderType());
//直接排除 选项为固定人 或者发起人
if (changeCommanderEnum.getId() == 1 || changeCommanderEnum.getId() == 2){
return changeConfig.getChangeCommander();
}
ChangeSubjectEnum changeSubjectEnum = ChangeSubjectEnum.getChangeSubjectEnum(changeConfig.getChangeSubject());
if (changeSubjectEnum.getType() == 1){
//商品变更
return queryGoodsCommander(changeCommanderEnum,changeCommander.getGoodsInfos(),changeConfig.getChangeCommander());
}else if (changeSubjectEnum.getType() == 2){
//供应商 采购 计划 SQE
return queryChangeSupplier(changeCommanderEnum,changeCommander.getChangeSupplier(),changeConfig.getChangeCommander());
}
//其他变更 备注 其他变更之后固定人 和发起人在上面判断会被排除掉
return changeConfig.getChangeCommander();
}
/**
* 商品的最终角色查询
* @param commanderEnum 查询方向 枚举
* @param goodsInfos 商品的列表
* @param commander 商品的关联角色
* @return
*/
private String queryGoodsCommander(ChangeCommanderEnum commanderEnum,List<String> goodsInfos,String commander){
if (commanderEnum.getId() != 3 || goodsInfos == null || goodsInfos.size() == 0 || commander == null){
return "类型错误 或者未选择商品";
}
Map<String,Integer> map = new HashMap<String,Integer>();
//记录最大出现次数
int temp = 0;
//记录最大值
String name = "";
//记录出现的所有值
List<String> commanders = new ArrayList<String>();
if (commander.equals("商品BU")){
}else if (commander.equals("采购")){
}else if (commander.equals("计划")){
}else if (commander.equals("SQE")){
}
for (String goods : commanders){
if (!map.containsKey(goods)){
map.put(goods,1);
}else{
Integer integer = map.get(goods);
++integer;
if (temp < integer){
temp = integer;
name = goods;
}
map.put(goods,integer);
}
}
return name;
}
/**
* 供应商角色最终查询
* @param commanderEnum 查询方向 枚举
* @param changeSupplier 供应商信息
* @param commander 供应商关联角色
* @return
*/
private String queryChangeSupplier(ChangeCommanderEnum commanderEnum,String changeSupplier,String commander){
if (commanderEnum.getId() != 4 || changeSupplier == null || commander == null){
return "返回空值 或者指示值";
}
//changeSupplier 根据提供的信息去查询 最终返回
if (commander.equals("采购")){
}else if (commander.equals("计划")){
}else if (commander.equals("SQE")){
}
return null;
}
}
package com.netease.mail.yanxuan.change.common.enums;
/**
* @author WangJiaXiang
* @date 2022/11/18/018$
*/
public enum ChangeCommanderEnum {
COMMANDER_ORIGINATOR(1,"发起人"),
FIXED_PERSON(2,"固定人"),
GOODS_ASSOCIATED(3,"产品关联角色"),
SUPPLIERS_ASSOCIATED(4,"供应商关联角色");
ChangeCommanderEnum(Integer id, String name) {
this.id = id;
this.name = name;
}
private Integer id;
private String name;
public Integer getId() {
return id;
}
public String getName() {
return name;
}
public static ChangeCommanderEnum getChangeCommanderEnum(Integer id){
for (ChangeCommanderEnum day : ChangeCommanderEnum.values()) {
if (id == day.getId()){
return day;
}
}
return null;
}
}
...@@ -42,4 +42,15 @@ public enum ChangeSubjectEnum { ...@@ -42,4 +42,15 @@ public enum ChangeSubjectEnum {
} }
return false; return false;
} }
public static ChangeSubjectEnum getChangeSubjectEnum(Integer id){
for (ChangeSubjectEnum day : ChangeSubjectEnum.values()) {
if (id == day.getType()){
return day;
}
}
return null;
}
} }
\ No newline at end of file
package com.netease.mail.yanxuan.change.dal.meta.model.po;
import lombok.Data;
import java.util.List;
/**
* @author WangJiaXiang
* @date 2022/11/18/018$
* 用来查询最终负责人信息
*/
@Data
public class ChangeCommanderPO {
/**
* 变更模板主键ID
*/
private Long id;
/**
* 供应商信息
*/
private String changeSupplier;
/**
* 商品信息
*/
private List<String> goodsInfos;
}
package com.netease.mail.yanxuan.change.integration.flow;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse;
import com.netease.yanxuan.missa.client.annotation.MissaClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author WangJiaXiang
* @date 2022/11/18/018$
*/
@Service
@MissaClient(serviceCode = "yanxuan-qc-api")
public interface GoodsRpcService {
@GetMapping(value = "/xhr/item/basic/sqe.json")
AjaxResponse<String> getDetail(@RequestParam("itemId") Integer itemId);
}
...@@ -4,6 +4,7 @@ import com.netease.mail.yanxuan.change.common.bean.AjaxResult; ...@@ -4,6 +4,7 @@ import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
import com.netease.mail.yanxuan.change.biz.service.AdminChangeConfigService; import com.netease.mail.yanxuan.change.biz.service.AdminChangeConfigService;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigReq;
import com.netease.mail.yanxuan.change.integration.flow.GoodsRpcService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -98,4 +99,11 @@ public class ChangeConfigController { ...@@ -98,4 +99,11 @@ public class ChangeConfigController {
} }
@Autowired
private GoodsRpcService goodsRpcService;
@GetMapping("/test")
public AjaxResult test(){
return AjaxResult.of(1111,"调用成功",goodsRpcService.getDetail(32));
}
} }
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