Commit 5ddf32e1 by yangkuo

增加生成配置单接口

parent 9523aa56
......@@ -29,4 +29,4 @@ build/
### VS Code ###
.vscode/
.clas
\ No newline at end of file
*.class
\ No newline at end of file
package cn.com.uitech.config.controller;
package cn.com.uitech.authorization.controller;
import cn.com.uitech.config.dto.BomInitializeInputV2DTO;
import cn.com.uitech.config.dto.BomInitializeOutputV2DTO;
import cn.com.uitech.config.dto.*;
import cn.com.uitech.config.service.ConfiguratorService;
import cn.com.uitech.config.service.ConfiguratorV2Service;
import cn.com.uitech.config.utils.BusinessKeyHelper;
......@@ -16,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
/**
* @author leafinsight
*/
@Api(value = "/api/v2/configurator", tags = "选配器(V2)模块")
@Api(value = "/api/v2/configurator", tags = "选配器模块")
@RestController
@RequestMapping(value = "/v2")
public class ConfiguratorV2Controller {
......@@ -41,5 +40,40 @@ public class ConfiguratorV2Controller {
businessKeyHelper.getDataSourceFlag(bomInitializeInputV2DTO.getBusinessKey()));
}
@ApiOperation(value = "前置验证", notes = "前置验证")
@PostMapping(value = "/preValidate")
@ResponseStatus(HttpStatus.OK)
// @BizLog(action = "前置验证")
public PreValidationOutputV2DTO preValidate(@RequestBody PreValidationInputV2DTO preValidationInputV2DTO) {
return configuratorV2Service.preValidate(preValidationInputV2DTO,
businessKeyHelper.getTokenByBusinessKey(preValidationInputV2DTO.getBusinessKey()),
businessKeyHelper.getDataSourceFlag(preValidationInputV2DTO.getBusinessKey()));
}
/**
* @description 验证配置按钮
* @param postValidationInputV2DTO
* @return
*/
@ApiOperation(value = "后置验证", notes = "后置验证")
@PostMapping(value = "/postValidate")
@ResponseStatus(HttpStatus.OK)
// @BizLog(action = "后置验证")
public PostValidateOutputV2DTO postValidate(@RequestBody PostValidationInputV2DTO postValidationInputV2DTO) {
return configuratorV2Service.postValidate(postValidationInputV2DTO,
businessKeyHelper.getTokenByBusinessKey(postValidationInputV2DTO.getBusinessKey()),
businessKeyHelper.getDataSourceFlag(postValidationInputV2DTO.getBusinessKey()));
}
@ApiOperation(value = "生成配置", notes = "生成配置")
@PostMapping(value = "/generateConfiguration")
@ResponseStatus(HttpStatus.OK)
// @BizLog(action = "生成配置")
public GenerateConfigurationOutputV2DTO generateConfiguration(@RequestBody PostValidationInputV2DTO postValidationInputV2DTO) {
return configuratorV2Service.generateConfiguration(postValidationInputV2DTO,
businessKeyHelper.getTokenByBusinessKey(postValidationInputV2DTO.getBusinessKey()),
businessKeyHelper.getDataSourceFlag(postValidationInputV2DTO.getBusinessKey()));
}
}
......@@ -21,7 +21,6 @@ import springfox.documentation.annotations.ApiIgnore;
*/
@RestController
@RequestMapping("/standardModelManage")
@ApiIgnore
@Api(tags = {"StandardModelManageDto 基准机型管理"})
public class StandardModelManageController {
......@@ -33,6 +32,7 @@ public class StandardModelManageController {
* @param standardModelManageDto
* @return StandardModelManageDto
*/
@ApiIgnore
@PostMapping("/getStandardModel")
@ApiOperation(value = "基准机型管理 查询", notes = "基准机型管理 查询", httpMethod = "POST")
public CrmResponseEntity<StandardModelManageViewDto> getStandardModel(@RequestBody StandardModelManageDto standardModelManageDto){
......
package cn.com.uitech.authorization.pojo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.persistence.*;
import java.util.Collection;
import java.util.List;
......@@ -21,22 +20,26 @@ import java.util.List;
*/
@Data
@Entity(name = "sys_user")
@ApiModel(value = "用户信息实体类")
public class SysUser implements UserDetails {
/**
* 用户id
*/
@Id
@ApiModelProperty(hidden = true)
private String id;
/**
* 用户名
*/
@ApiModelProperty(name = "username", value = "用户名", dataType = "String")
@Column(nullable = false, unique = true)
private String username;
/**
* 密码
*/
@ApiModelProperty(name = "password", value = "密码", dataType = "String")
@Column(nullable = false)
private String password;
......@@ -45,35 +48,43 @@ public class SysUser implements UserDetails {
/**
* 状态
*/
@ApiModelProperty(hidden = true)
@Column(nullable = false)
private String status;
@Transient
@ApiModelProperty(hidden = true)
private String computername;
@Transient
@ApiModelProperty(hidden = true)
private String userprofile;
@Transient
@ApiModelProperty(hidden = true)
private String ipAddr;
/**
* 角色
*/
@Transient
@ApiModelProperty(hidden = true)
private List<GrantedAuthority> roles;
@Override
@ApiModelProperty(hidden = true)
public Collection<? extends GrantedAuthority> getAuthorities() {
return roles;
}
@Override
@ApiModelProperty(hidden = true)
public String getUsername() {
return username;
}
@JsonIgnore
@ApiModelProperty(hidden = true)
@Override
public boolean isAccountNonExpired() {
return true;
......@@ -81,17 +92,20 @@ public class SysUser implements UserDetails {
@JsonIgnore
@Override
@ApiModelProperty(hidden = true)
public boolean isAccountNonLocked() {
return true;
}
@JsonIgnore
@ApiModelProperty(hidden = true)
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@JsonIgnore
@ApiModelProperty(hidden = true)
@Override
public boolean isEnabled() {
return true;
......
package cn.com.uitech.config.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* @author leafinsight
*/
@Getter
@Setter
@NoArgsConstructor
@ToString
public class GenerateConfigurationOutputV2DTO {
private Boolean result;
private String message;
private Long configId;
// private Boolean npStatus;
// private Boolean syStatus;
// private Boolean thinkServiceStatus;
}
package cn.com.uitech.config.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* @author leafinsight
*/
@Getter
@Setter
@NoArgsConstructor
@ToString
public class PostValidateOutputV2DTO {
private Boolean result;
private String message;
}
package cn.com.uitech.config.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author leafinsight
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PostValidationInputV2DTO {
/**
* BomCode :
* Division :
* VtStr :
* CVS :
*/
private String bomCode;
private String division;
private String userCode;
private List<TotalCharacteristicListBean> totalCharacteristicList;
private List<PreValidationInputV2DTO.SelectedCharacteristicBean> selectedCharacteristicList;
private boolean selectedComplete = true;
private String businessKey;
private List<AttributesBeanDTO> attributes;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TotalCharacteristicListBean {
/**
* characteristicCode : 29961
* value : ["2"]
*/
private String characteristicCode;
private List<String> values;
}
}
package cn.com.uitech.config.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
public class BOMCVName {
/**
* bomCode : 10BWCTO1WW
* cList : [{"r3Code":"0000029961","r3EName":"Processor","name":"CPU","vList":[{"code":"00000299610010","r3EName":"CORE I7 4770S_8M CACHE","name":"Core i7-4770S 3.1GHz 8M Cache"}]},{"r3Code":"0000029961","r3EName":"Processor","name":"CPU","vList":[{"code":"00000299610010","r3EName":"CORE I7 4770S_8M CACHE","name":"Core i7-4770S 3.1GHz 8M Cache"}]}]
*/
private String bomCode;
private List<CListBean> cList;
@Getter
@Setter
@NoArgsConstructor
public static class CListBean {
/**
* r3Code : 0000029961
* r3EName : Processor
* name : CPU
* vList : [{"code":"00000299610010","r3EName":"CORE I7 4770S_8M CACHE","name":"Core i7-4770S 3.1GHz 8M Cache"}]
*/
private String r3Code;
private String r3EName;
private String name;
private List<VListBean> vList;
@Getter
@Setter
@NoArgsConstructor
public static class VListBean {
/**
* code : 00000299610010
* r3EName : CORE I7 4770S_8M CACHE
* name : Core i7-4770S 3.1GHz 8M Cache
*/
private String code;
private String r3EName;
private String name;
}
}
}
package cn.com.uitech.config.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class MessageJson {
/**
* Flag :
* Message :
*/
private boolean flag;
private String message;
}
package cn.com.uitech.config.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "ODRelation")
public class ODRelation {
@Id
@Column(name = "ODRelationID")
private Integer odRelationId;
@Column(name = "Name")
private String name;
@Column(name = "Type", columnDefinition = "tinyint")
private Integer type;
@Column(name = "Description")
private String description;
@Column(name = "BOMCode")
private String bomCode;
@Column(name = "BOMName")
private String bomName;
@Column(name = "ProductGroupCode", columnDefinition = "char")
private String productGroupCode;
@Column(name = "FirstCharacteristicCode")
private String firstCharacteristicCode;
@Column(name = "FirstR3Code")
private String firstR3Code;
@Column(name = "SecondCharacteristicCode")
private String secondCharacteristicCode;
@Column(name = "SecondR3Code")
private String secondR3Code;
@Column(name = "RelatedCharacteristicCode")
private String relatedCharacteristicCode;
@Column(name = "RelatedR3Code")
private String relatedR3Code;
@Column(name = "FirstCharacteristicCodeName")
private String firstCharacteristicCodeName;
@Column(name = "SecondCharacteristicCodeName")
private String secondCharacteristicCodeName;
@Column(name = "RelatedCharacteristicCodeName")
private String relatedCharacteristicCodeName;
@Column(name = "FirstCharacteristicValue")
private String firstCharacteristicValue;
@Column(name = "FirstR3VCode")
private String firstR3VCode;
@Column(name = "SecondCharacteristicValue")
private String secondCharacteristicValue;
@Column(name = "SecondR3VCode")
private String secondR3VCode;
@Column(name = "RelatedCharacteristicValue")
private String relatedCharacteristicValue;
@Column(name = "RelatedR3VCode")
private String relatedR3VCode;
@Column(name = "FirstCharacteristicValueName")
private String firstCharacteristicValueName;
@Column(name = "SecondCharacteristicValueName")
private String secondCharacteristicValueName;
@Column(name = "RelatedCharacteristicValueName")
private String relatedCharacteristicValueName;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CreateTime")
private Date createdTime;
}
package cn.com.uitech.config.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class ODRelationModel {
/**
* ODRelationID : 0
* Name :
* Type : 0
* Description :
* BOMCode :
* BOMName :
* ProductGroupCode :
* FirstCharacteristicCode :
* FirstR3Code :
* SecondCharacteristicCode :
* SecondR3Code :
* RelatedCharacteristicCode :
* RelatedR3Code :
* FirstCharacteristicCodeName :
* SecondCharacteristicCodeName :
* RelatedCharacteristicCodeName :
* FirstCharacteristicValue :
* FirstR3VCode :
* SecondCharacteristicValue :
* SecondR3VCode :
* RelatedCharacteristicValue :
* RelatedR3VCode :
* FirstCharacteristicValueName :
* SecondCharacteristicValueName :
* RelatedCharacteristicValueName :
* CreateTime :
*/
private int odRelationId;
private String name;
private int type;
private String description;
private String bomCode;
private String bomName;
private String productGroupCode;
private String firstCharacteristicCode;
private String firstR3Code;
private String secondCharacteristicCode;
private String secondR3Code;
private String relatedCharacteristicCode;
private String relatedR3Code;
private String firstCharacteristicCodeName;
private String secondCharacteristicCodeName;
private String relatedCharacteristicCodeName;
private String firstCharacteristicValue;
private String firstR3VCode;
private String secondCharacteristicValue;
private String secondR3VCode;
private String relatedCharacteristicValue;
private String relatedR3VCode;
private String firstCharacteristicValueName;
private String secondCharacteristicValueName;
private String relatedCharacteristicValueName;
private String createTime;
}
package cn.com.uitech.config.repository;
import cn.com.uitech.config.entity.ODRelation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ODRelationRepository extends JpaRepository<ODRelation, Integer> {
List<ODRelation> findByProductGroupCodeAndBomCode(String productGroupCode, String bomCode);
}
package cn.com.uitech.config.service;
import cn.com.uitech.config.entity.CTOQTYCMapping;
import cn.com.uitech.config.entity.CTOTotalQTYMapping;
import cn.com.uitech.config.entity.ODData;
import cn.com.uitech.config.entity.SpecialR3Code;
import cn.com.uitech.config.entity.*;
import cn.com.uitech.config.vo.BOMCVCacheVO;
import java.util.List;
......@@ -50,5 +47,7 @@ public interface ConfiguratorCacheService {
*/
List<String> getFollowR3Code(String token, String bomCode, String dataSourceFlag);
BOMCVName getBOMCVName(String token, String bomCode, String division, String dataSourceFlag);
}
package cn.com.uitech.config.service;
import cn.com.uitech.config.dto.BomInitializeInputV2DTO;
import cn.com.uitech.config.dto.BomInitializeOutputV2DTO;
import cn.com.uitech.config.dto.*;
public interface ConfiguratorV2Service {
BomInitializeOutputV2DTO getBasicDataWithName(BomInitializeInputV2DTO bomInitializeInputV2DTO, String token, String dataSourceFlag) throws Exception ;
PostValidateOutputV2DTO postValidate(PostValidationInputV2DTO postValidationInputV2DTO, String token, String dataSourceFlag);
GenerateConfigurationOutputV2DTO generateConfiguration(PostValidationInputV2DTO postValidationInputV2DTO, String token, String dataSourceFlag) ;
/**
* @param preValidationInputV2DTO 前置验证输入参数
* @param token 保留
* @return PreValidationOutputV2DTO
*/
PreValidationOutputV2DTO preValidate(PreValidationInputV2DTO preValidationInputV2DTO, String token, String dataSourceFlag) ;
}
package cn.com.uitech.config.service;
import cn.com.uitech.config.entity.CTOQTYCMapping;
import cn.com.uitech.config.entity.CTOTotalQTYMapping;
import cn.com.uitech.config.entity.SpecialR3Code;
import cn.com.uitech.config.entity.*;
import java.util.List;
......@@ -35,4 +33,14 @@ public interface ODDataService {
*/
List<String> getFollowR3Code(String bomCode, String dataSourceFlag);
/// <summary>
/// 获取BOM特征
/// </summary>
/// <param name="bomCode"></param>
/// <returns></returns>
List<BOMCVNameVM> getBOMCVNameVMByCode(String bomCode, String division, String dataSourceFlag);
List<ODRelationModel> getODRelationList(String productGroupCode, String bomCode, String dataSourceFlag);
}
package cn.com.uitech.config.service;
import cn.com.uitech.config.entity.MessageJson;
import cn.com.uitech.config.entity.ODData;
import cn.com.uitech.config.vo.BOMInitializeExResultVO;
import cn.com.uitech.config.vo.ConfigProcResultVO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -71,6 +73,10 @@ public interface OdService {
/// <returns></returns>
Boolean checkAllSelected(Map<String, Integer> arySelected, List<String> aryChar, List<String> aryHiddenC) ;
//检查常规特配配置结果的OD关系(公共方法)
MessageJson checkLMSODRelation(String bomcode, String productgroupcode, String vcodes, ArrayList vcodeList, String dataSourceFlag);
}
......@@ -388,6 +388,62 @@ public class ConfiguratorCacheServiceImpl implements ConfiguratorCacheService {
return aryList;
}
@Override
public BOMCVName getBOMCVName(String token, String bomCode, String division, String dataSourceFlag) {
BOMCVName bomcvName = new BOMCVName();
try {
ValueOperations<String, String> operations = redisTemplate.opsForValue();
String str = operations.get(BOM_CV_NAME + "_" + bomCode + "_" + division + "@" + token);
if (StringUtil.isNullOrEmpty(str)) {
bomcvName = setBOMCVName(token, bomCode, division, dataSourceFlag);
} else {
bomcvName = JSON.parseObject(str, new TypeReference<BOMCVName>() {
});
}
} catch (Exception e) {
e.printStackTrace();
}
return bomcvName;
}
public BOMCVName setBOMCVName(String token, String bomCode, String division, String dataSourceFlag) {
List<BOMCVNameVM> bomcvNameVMList = odDataService.getBOMCVNameVMByCode(bomCode, division, dataSourceFlag);
BOMCVName bomcvName = new BOMCVName();
if (bomcvNameVMList.size() > 0) {
try {
ValueOperations<String, String> operations = redisTemplate.opsForValue();
List<BOMCVNameVM> pList = bomcvNameVMList.stream().filter(d -> d.getR3Code().trim().length() == 10).collect(Collectors.toList());
bomcvName.setBomCode(bomCode);
List<BOMCVName.CListBean> cListBeanList = new ArrayList<>();
for (BOMCVNameVM item : pList) {
BOMCVName.CListBean cListBean = new BOMCVName.CListBean();
cListBean.setR3Code(item.getR3Code());
cListBean.setR3EName(item.getR3EName());
cListBean.setName(item.getName());
List<BOMCVName.CListBean.VListBean> vListBeanList = new ArrayList<>();
List<BOMCVNameVM> childList = bomcvNameVMList.stream().filter(d -> d.getCharacteristicCode().equals(item.getCharacteristicCode())).collect(Collectors.toList());
for (BOMCVNameVM cItem : childList) {
BOMCVName.CListBean.VListBean vListBean = new BOMCVName.CListBean.VListBean();
vListBean.setCode(cItem.getR3Code().trim());
vListBean.setR3EName(cItem.getR3EName().trim());
vListBean.setName(cItem.getName().trim());
vListBeanList.add(vListBean);
}
cListBean.setVList(vListBeanList);
cListBeanList.add(cListBean);
bomcvName.setCList(cListBeanList);
}
operations.set(BOM_CV_NAME + "_" + bomCode + "_" + division + "@" + token, JSON.toJSONString(bomcvName));
} catch (Exception e) {
e.printStackTrace();
}
}
return bomcvName;
}
}
......
package cn.com.uitech.config.service.impl;
import cn.com.uitech.config.entity.CTOQTYCMapping;
import cn.com.uitech.config.entity.CTOTotalQTYMapping;
import cn.com.uitech.config.entity.SpecialR3Code;
import cn.com.uitech.config.entity.*;
import cn.com.uitech.config.repository.CharacteristicRepository;
import cn.com.uitech.config.repository.ConfiguratorRepository;
import cn.com.uitech.config.repository.ODRelationRepository;
import cn.com.uitech.config.service.ODDataService;
import com.google.common.collect.Maps;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
public class ODDataServiceImpl implements ODDataService {
......@@ -23,6 +26,9 @@ public class ODDataServiceImpl implements ODDataService {
@Autowired
private CharacteristicRepository characteristicRepository;
@Autowired
private ODRelationRepository odRelationRepository;
@Override
public List<List<?>> getCharacteristicItemsByBomCodeV2ForPostGreSql(String bomCode, String division, int cdbID, String type, String dataType, int visibleType, String dataSourceFlag) {
Map<String, Object> map = Maps.newHashMap();
......@@ -93,4 +99,37 @@ public class ODDataServiceImpl implements ODDataService {
//return characteristicRepository.getFollowR3Code(bomCode);
return characteristicRepository.getFollowR3CodeForPostGreSql(bomCode);
}
/// <summary>
/// 获取BOM特征
/// </summary>
/// <param name="bomCode"></param>
/// <returns></returns>
@Override
public List<BOMCVNameVM> getBOMCVNameVMByCode(String bomCode, String division, String dataSourceFlag) {
Map<String, String> map = Maps.newHashMap();
map.put("p1", bomCode);
map.put("p2", division);
return configuratorRepository.getBOMCVNameVMByCode(map);
}
@Override
public List<ODRelationModel> getODRelationList(String productGroupCode, String bomCode, String dataSourceFlag) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return odRelationRepository.findByProductGroupCodeAndBomCode(productGroupCode, bomCode)
.stream()
.map(odRelation -> {
ODRelationModel odRelationModel = new ODRelationModel();
BeanUtils.copyProperties(odRelation, odRelationModel, "createdTime");
Optional.ofNullable(odRelation.getCreatedTime())
.ifPresent(createdTime -> odRelationModel.setCreateTime(sdf.format(createdTime)));
return odRelationModel;
}).collect(Collectors.toList());
}
}
package cn.com.uitech.config.service.impl;
import cn.com.uitech.config.entity.MessageJson;
import cn.com.uitech.config.entity.ODData;
import cn.com.uitech.config.entity.ODRelationModel;
import cn.com.uitech.config.service.ConfiguratorCacheService;
import cn.com.uitech.config.service.ODDataService;
import cn.com.uitech.config.service.OdService;
import cn.com.uitech.config.utils.CastUtil;
import cn.com.uitech.config.utils.StringUtil;
import cn.com.uitech.config.vo.BOMInitializeExResultVO;
import cn.com.uitech.config.vo.CheckODRelationOV;
import cn.com.uitech.config.vo.ConfigProcResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -18,6 +22,9 @@ public class OdServiceImpl implements OdService {
@Autowired
private ConfiguratorCacheService configuratorCacheService;
@Autowired
private ODDataService odDataService;
/// <summary>
/// BOM加载VT过滤
/// </summary>
......@@ -443,4 +450,100 @@ public class OdServiceImpl implements OdService {
return ret;
}
//检查常规特配配置结果的OD关系(公共方法)
@Override
public MessageJson checkLMSODRelation(String bomcode, String productgroupcode, String vcodes, ArrayList vcodeList, String dataSourceFlag) {
if (vcodeList == null) {
String[] vcodesArr = vcodes.split(";");
vcodeList = new ArrayList();
vcodeList.add(vcodesArr);
}
CheckODRelationOV checkODRelationOV = checkODRelation(bomcode, productgroupcode, vcodeList,dataSourceFlag);
MessageJson mj = new MessageJson();
mj.setFlag(checkODRelationOV.getResult());
mj.setMessage(checkODRelationOV.getMessage());
return mj;
}
//检查常规特配配置结果的OD关系
private CheckODRelationOV checkODRelation(String bomCode, String productGroupCode, ArrayList characteristicValueCodes,String dataSourceFlag) {
CheckODRelationOV checkODRelationOV = new CheckODRelationOV();
List<ODRelationModel> odRelationList = odDataService.getODRelationList(productGroupCode, bomCode,dataSourceFlag);
if (odRelationList == null) {
checkODRelationOV.setMessage("");
checkODRelationOV.setResult(true);
return checkODRelationOV;
}
for (ODRelationModel relation : odRelationList) {
//检查特征值列表是否满足OD关系
//依赖关系
if (relation.getType() == 1) {
//如果存在关联特征值
if (!StringUtil.isNullOrEmpty(relation.getSecondR3Code())) {
if (isValueInList(relation.getFirstR3VCode(), characteristicValueCodes)
&& isValueInList(relation.getSecondR3VCode(), characteristicValueCodes)
&& !isValueInList(relation.getRelatedR3VCode(), characteristicValueCodes)) {
checkODRelationOV.setMessage(relation.getDescription());
checkODRelationOV.setResult(false);
return checkODRelationOV;
}
} else {
//如果不存在关联特征值
if (isValueInList(relation.getFirstR3VCode(), characteristicValueCodes)
&& !isValueInList(relation.getRelatedR3VCode(), characteristicValueCodes)) {
checkODRelationOV.setMessage(relation.getDescription());
checkODRelationOV.setResult(false);
return checkODRelationOV;
}
}
} else {
//如果存在关联特征值
if (!StringUtil.isNullOrEmpty(relation.getSecondR3Code())) {
if (isValueInList(relation.getFirstR3VCode(), characteristicValueCodes)
&& isValueInList(relation.getSecondR3VCode(), characteristicValueCodes)
&& isValueInList(relation.getRelatedR3VCode(), characteristicValueCodes)) {
checkODRelationOV.setMessage(relation.getDescription());
checkODRelationOV.setResult(false);
return checkODRelationOV;
}
} else {
//如果不存在关联特征值
if (isValueInList(relation.getFirstR3VCode(), characteristicValueCodes)
&& isValueInList(relation.getRelatedR3VCode(), characteristicValueCodes)) {
checkODRelationOV.setMessage(relation.getDescription());
checkODRelationOV.setResult(false);
return checkODRelationOV;
}
}
}
}
checkODRelationOV.setMessage("");
checkODRelationOV.setResult(true);
return checkODRelationOV;
}
//检查一个特征值是否包含在列表中
private boolean isValueInList(String characteristicValueCode, ArrayList characteristicValueCodes) {
if (StringUtil.isNullOrEmpty(characteristicValueCode)) {
return false;
}
for (Object objectCharacteristicValueCode : characteristicValueCodes) {
if (characteristicValueCode.equals(objectCharacteristicValueCode)) {
return true;
}
}
return false;
}
}
package cn.com.uitech.config.vo;
import lombok.*;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class CheckODRelationOV {
private Boolean result;
private String message;
}
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