Commit 2a6af525 by zhaoxiaolei

H3C 约束完结

parent 91156b43
...@@ -89,4 +89,8 @@ public interface CharacteristicMapper extends IBaseMapper<Characteristic>, Inser ...@@ -89,4 +89,8 @@ public interface CharacteristicMapper extends IBaseMapper<Characteristic>, Inser
void updateSuperBomSku(SuperBomSkuInfo superBomSkuInfo); void updateSuperBomSku(SuperBomSkuInfo superBomSkuInfo);
Integer updateCharacteristicIsH3C(CharacteristicRequestParamDto dto); Integer updateCharacteristicIsH3C(CharacteristicRequestParamDto dto);
List<Characteristic> getCharacteristicH3CList(String superBomCode);
Integer getCharacteristicInfo(String characteristicCode, String superBomCode);
} }
...@@ -39,6 +39,7 @@ import org.springframework.web.client.RestTemplate; ...@@ -39,6 +39,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.util.stream.Stream;
@Service @Service
...@@ -793,6 +794,12 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -793,6 +794,12 @@ public class IntegrateServiceImpl implements IntegrateService {
if (!ObjectUtils.isEmpty(configurableBom)) { if (!ObjectUtils.isEmpty(configurableBom)) {
//有configid //有configid
if (!StringUtils.isEmpty(configurableBom.getConfigId())) { if (!StringUtils.isEmpty(configurableBom.getConfigId())) {
//查询出superBom下所有isH3C的数据
List<Characteristic> characteristicH3CList = characteristicMapper.getCharacteristicH3CList(configurableBom.getSuperBomCode());
List<String> h3cCodeList = new ArrayList<>();
for (Characteristic characteristic : characteristicH3CList) {
h3cCodeList.add(characteristic.getCharacteristicCode());
}
for (GetSKUByH3CConfigInfo.KeyValues keyValues : selectedCharacteristicList) { for (GetSKUByH3CConfigInfo.KeyValues keyValues : selectedCharacteristicList) {
CharacteristicValue characteristicValue = characteristicValueMapper.getCharacteristicValueInfoByCode(keyValues.getH3cVCode(), configurableBom.getSuperBomCode()); CharacteristicValue characteristicValue = characteristicValueMapper.getCharacteristicValueInfoByCode(keyValues.getH3cVCode(), configurableBom.getSuperBomCode());
//验证H3CVCODE 是否存在 //验证H3CVCODE 是否存在
...@@ -802,18 +809,41 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -802,18 +809,41 @@ public class IntegrateServiceImpl implements IntegrateService {
flag = false; flag = false;
break; break;
} else { } else {
//验证特征的是否存在 // 查询出superBom下所有isH3C的数据 characteristicH3CList 比较 是否都有传
//characteristicValue.get boolean contains = h3cCodeList.contains(characteristicValue.getCharacteristicCode());
//验证H3CVCODE是否下架 if(!contains){
if (characteristicValue.getIsState() == 0) { Integer isH3C = characteristicMapper.getCharacteristicInfo(characteristicValue.getCharacteristicCode(), configurableBom.getSuperBomCode());
cpnList.setMsg("CPQ数据验证失败,失败原因:" + characteristicValue.getCharacteristicValueCode() + "已下架!"); if(isH3C.equals(1)){
cpnList.setCode(ApiResult.INTERNAL_SERVER_ERROR.getCode()); //不存在数据库isH3C的数据返回报错
flag = false; cpnList.setMsg("CPQ数据验证失败,失败原因:" + characteristicValue.getCharacteristicCode() + "特征不能为空!");
break; cpnList.setCode(ApiResult.INTERNAL_SERVER_ERROR.getCode());
flag = false;
break;
}else{
//验证H3CVCODE是否下架
if (characteristicValue.getIsState() == 0) {
cpnList.setMsg("CPQ数据验证失败,失败原因:" + characteristicValue.getCharacteristicValueCode() + "已下架!");
cpnList.setCode(ApiResult.INTERNAL_SERVER_ERROR.getCode());
flag = false;
break;
} else {
//有superbom 有configid h3cvcode存在 没有下架 设置true进行撞配
flag = true;
}
}
}else{ }else{
//有superbom 有configid h3cvcode存在 没有下架 设置true进行撞配 //验证H3CVCODE是否下架
flag = true; if (characteristicValue.getIsState() == 0) {
cpnList.setMsg("CPQ数据验证失败,失败原因:" + characteristicValue.getCharacteristicValueCode() + "已下架!");
cpnList.setCode(ApiResult.INTERNAL_SERVER_ERROR.getCode());
flag = false;
break;
} else {
//有superbom 有configid h3cvcode存在 没有下架 设置true进行撞配
flag = true;
}
} }
} }
} }
}else{ }else{
...@@ -915,29 +945,53 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -915,29 +945,53 @@ public class IntegrateServiceImpl implements IntegrateService {
Map<String,Object> buildConfigurationMap = (Map<String, Object>) JSONObject.toJSON(buildConfiguration); Map<String,Object> buildConfigurationMap = (Map<String, Object>) JSONObject.toJSON(buildConfiguration);
String configId = (String) buildConfigurationMap.get("configId"); String configId = (String) buildConfigurationMap.get("configId");
superBomSkuInfo.setConfigId(configId); superBomSkuInfo.setConfigId(configId);
//撞配 找PLM申请SKU //撞配之前调用前置验证
Object ob = GetSKUByConfigInfo(superBomSkuInfo); //构建前置验证数据结构
boolean flag1 = ob instanceof GetProductOutDto; PostVerifyInputDTO postVerifyInputDTO = new PostVerifyInputDTO();
if (flag1) { postVerifyInputDTO.setProductClassCode(((SuperBomSkuInfo) superBomInfo).getProductClassCode());
Object o1 = JSONObject.toJSON(ob); postVerifyInputDTO.setSuperBomCode(((SuperBomSkuInfo) superBomInfo).getSuperBomCode());
Map<String, Object> map1 = (Map<String, Object>) o1; postVerifyInputDTO.setOperator("system");
Integer code = (Integer) map1.get("code"); postVerifyInputDTO.setSessionId(sessionId);
if (code.equals(200)) { List<PostVerifyInputDTO.SelectedCharacteristicListBean> selectedCharacteristicLists = new ArrayList<>();
JSONObject data = (JSONObject) map1.get("data"); superBomSkuInfo.getCharacteristicList().forEach(selectedCharacteristic->{
cpnList.setSkuCode((String) data.get("skuCode")); PostVerifyInputDTO.SelectedCharacteristicListBean selectedCharacteristicListBean = new PostVerifyInputDTO.SelectedCharacteristicListBean();
cpnList.setSkuName((String) data.get("skuName")); //根据 list里面的vcode 查询v信息和c信息 赋值到 生成配置的对象里
cpnList.setCode(code); selectedCharacteristicListBean.setCharacteristicName(selectedCharacteristic.getCharacteristicName());
} else { selectedCharacteristicListBean.setCharacteristicValueName(selectedCharacteristic.getCharacteristicValueName());
Object data = map1.get("data"); selectedCharacteristicListBean.setQuantity(1);
Object data2 = JSONObject.toJSON(data); selectedCharacteristicLists.add(selectedCharacteristicListBean);
Map<String, Object> map2 = (Map<String, Object>) data2; });
if(!ObjectUtils.isEmpty(map2)){ postVerifyInputDTO.setSelectedCharacteristicList(selectedCharacteristicLists);
cpnList.setSkuCode((String) map2.get("skuCode")); Object preVerify = integrateController.preVerify(postVerifyInputDTO, null);
cpnList.setSkuName((String) map2.get("skuName")); Map<String, Object> preVerifyMap = (Map<String, Object>) JSONObject.toJSON(preVerify);
cpnList.setPatern("CTO"); if(preVerifyMap.get("result").equals(true)){
cpnList.setCode(200); //撞配 找PLM申请SKU
Object ob = GetSKUByConfigInfo(superBomSkuInfo);
boolean flag1 = ob instanceof GetProductOutDto;
if (flag1) {
Object o1 = JSONObject.toJSON(ob);
Map<String, Object> map1 = (Map<String, Object>) o1;
Integer code = (Integer) map1.get("code");
if (code.equals(200)) {
JSONObject data = (JSONObject) map1.get("data");
cpnList.setSkuCode((String) data.get("skuCode"));
cpnList.setSkuName((String) data.get("skuName"));
cpnList.setCode(code);
} else {
Object data = map1.get("data");
Object data2 = JSONObject.toJSON(data);
Map<String, Object> map2 = (Map<String, Object>) data2;
if(!ObjectUtils.isEmpty(map2)){
cpnList.setSkuCode((String) map2.get("skuCode"));
cpnList.setSkuName((String) map2.get("skuName"));
cpnList.setPatern("CTO");
cpnList.setCode(200);
}
} }
} }
}else{
cpnList.setCode(500);
cpnList.setMsg("配置结果违反约束冲突"+(String) preVerifyMap.get("message"));
} }
} }
} }
......
...@@ -208,4 +208,12 @@ ...@@ -208,4 +208,12 @@
</if> </if>
</where> </where>
</update> </update>
<select id="getCharacteristicH3CList" resultType="cn.com.uitech.authorization.pojo.entity.Characteristic">
select * from super_characteristic_info where is_h3c = 1 and super_bom_code = #{superBomCode}
</select>
<select id="getCharacteristicInfo" resultType="java.lang.Integer">
select is_h3c isH3C from super_characteristic_info where characteristic_Code = #{characteristicCode} and super_bom_code = #{superBomCode}
</select>
</mapper> </mapper>
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