You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
259 lines
8.6 KiB
259 lines
8.6 KiB
package com.connor.dfl.plm.util;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import com.connor.dfl.plm.dfl019.ClassPropBean;
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
import com.teamcenter.rac.kernel.TCClassificationService;
|
|
import com.teamcenter.rac.kernel.TCComponentICO;
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
|
|
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute;
|
|
import com.teamcenter.rac.kernel.ics.ICSProperty;
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
public class ClassValueUtil {
|
|
|
|
|
|
public static ClassValueBean getOutBuyPartValue(TCComponentItemRevision rev,List<String> errList) {
|
|
// TODO Auto-generated method stub
|
|
ClassValueBean valueBean = new ClassValueBean();
|
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
|
TCSession session = (TCSession) app.getSession();
|
|
List<String> vals = new ArrayList<String>();
|
|
StringBuilder sb = new StringBuilder();
|
|
List<ClassPropBean> classPropList = new ArrayList<ClassPropBean>();
|
|
TCClassificationService classificationService = session.getClassificationService();
|
|
try {
|
|
String className = rev.getClassificationClass();
|
|
if("".equals(className.trim())) {
|
|
errList.add(className);
|
|
MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发送至分类,请先发送分类!!",
|
|
"提示", MessageBox.WARNING);
|
|
return null;
|
|
}
|
|
TCComponentICO[] icos = rev.getClassificationObjects();
|
|
ICSAdminClass c = classificationService.newICSAdminClass();
|
|
c.load(className);
|
|
//String icoPUID = icos[0].getUid();
|
|
Map<Integer, String> claMap = new HashMap<Integer, String>();
|
|
if(icos != null && icos.length>0){
|
|
ICSProperty[] icss = icos[0].getICSProperties(true);
|
|
for (ICSProperty ics : icss) {
|
|
claMap.put(ics.getId(), ics.getValue());
|
|
}
|
|
}
|
|
for(Map.Entry<Integer, String> entry : claMap.entrySet()){
|
|
System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue());
|
|
}
|
|
ICSAdminClassAttribute[] icsAttrS = c.getAttributes();
|
|
|
|
if (icsAttrS != null) {
|
|
for (ICSAdminClassAttribute attr : icsAttrS) {
|
|
if (attr.isReferenceAttribute()) {
|
|
continue;
|
|
}
|
|
if (attr.isReference()) {
|
|
continue;
|
|
}
|
|
ClassPropBean bean = new ClassPropBean(attr);
|
|
classPropList.add(bean);
|
|
}
|
|
}
|
|
boolean have = true;
|
|
for (int i = 0; i < classPropList.size(); i++) {
|
|
ClassPropBean bean = classPropList.get(i);
|
|
String attrName = bean.propDisName;
|
|
System.out.println("attrName==========="+attrName);
|
|
String value = claMap.get(bean.propID);
|
|
if(bean.isLov) {
|
|
String lovValue = bean.lovMapping.get(value);
|
|
if("品牌".equals(attrName)) {
|
|
valueBean.setBrand(lovValue);
|
|
}else if("单位".equals(attrName)){
|
|
valueBean.setUnit(lovValue);
|
|
}
|
|
else if(attrName.contains("规格")){
|
|
String kaitou1 = attrName.substring(0,2);
|
|
//前两个字是否为规格
|
|
if("规格".equals(kaitou1)) {
|
|
valueBean.setSpec(lovValue);
|
|
}
|
|
}
|
|
else if(attrName.contains("订货码")){
|
|
valueBean.setCode(lovValue);
|
|
}else {
|
|
if("/".equals(lovValue) || "null".equals(lovValue)) {
|
|
System.out.println("不进行拼接");
|
|
continue;
|
|
}
|
|
sb.append(lovValue);
|
|
if(i < classPropList.size()-1) {
|
|
sb.append(";");
|
|
}
|
|
}
|
|
}else {
|
|
if("品牌".equals(attrName)) {
|
|
valueBean.setBrand(value);
|
|
}else if("单位".equals(attrName)){
|
|
valueBean.setUnit(value);
|
|
}else if(attrName.contains("规格")){
|
|
String kaitou2 = attrName.substring(0,2);
|
|
//前两个字是否为规格
|
|
if("规格".equals(kaitou2)) {
|
|
valueBean.setSpec(value);
|
|
}
|
|
}else if(attrName.contains("订货码")){
|
|
valueBean.setCode(value);
|
|
}else {
|
|
if("/".equals(value) || "null".equals(value)) {
|
|
System.out.println("不进行拼接");
|
|
continue;
|
|
}
|
|
sb.append(value);
|
|
if(i < classPropList.size()-1) {
|
|
sb.append(";");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (TCException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
StringBuilder specSB = new StringBuilder();
|
|
if(valueBean.getBrand() != null) {
|
|
if(!("".equals((valueBean.getBrand()).trim()))
|
|
&& !("/".equals((valueBean.getBrand()).trim()))
|
|
&& !("null".equals((valueBean.getBrand()).trim()))) {
|
|
specSB.append(valueBean.getBrand());
|
|
specSB.append(";");
|
|
}
|
|
}
|
|
if(valueBean.getSpec() != null) {
|
|
if(!("".equals((valueBean.getSpec()).trim()))
|
|
&& !("/".equals((valueBean.getSpec()).trim()))
|
|
&& !("null".equals((valueBean.getSpec()).trim()))) {
|
|
specSB.append(valueBean.getSpec());
|
|
specSB.append(";");
|
|
}
|
|
}
|
|
if(valueBean.getCode() != null) {
|
|
if(!("".equals((valueBean.getCode()).trim()))
|
|
&& !("/".equals((valueBean.getCode()).trim()))
|
|
&& !("null".equals((valueBean.getCode()).trim()))) {
|
|
specSB.append(valueBean.getCode());
|
|
specSB.append(";");
|
|
}
|
|
}
|
|
specSB.append(sb.toString());
|
|
valueBean.setSpecs(specSB.toString());
|
|
return valueBean;
|
|
}
|
|
|
|
public static ClassValueBean getOutSourcePartValue(TCComponentItemRevision rev,List<String> errList) {
|
|
// TODO Auto-generated method stub
|
|
ClassValueBean valueBean = new ClassValueBean();
|
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
|
TCSession session = (TCSession) app.getSession();
|
|
List<String> vals = new ArrayList<String>();
|
|
StringBuilder sb = new StringBuilder();
|
|
List<ClassPropBean> classPropList = new ArrayList<ClassPropBean>();
|
|
TCClassificationService classificationService = session.getClassificationService();
|
|
try {
|
|
String className = rev.getClassificationClass();
|
|
if("".equals(className.trim())) {
|
|
errList.add(className);
|
|
MessageBox.post(rev.getStringProperty("item_id")+"该物料没有发送至分类,请先发送分类!!",
|
|
"提示", MessageBox.WARNING);
|
|
return null;
|
|
}
|
|
TCComponentICO[] icos = rev.getClassificationObjects();
|
|
ICSAdminClass c = classificationService.newICSAdminClass();
|
|
c.load(className);
|
|
//String icoPUID = icos[0].getUid();
|
|
Map<Integer, String> claMap = new HashMap<Integer, String>();
|
|
if(icos != null && icos.length>0){
|
|
ICSProperty[] icss = icos[0].getICSProperties(true);
|
|
for (ICSProperty ics : icss) {
|
|
claMap.put(ics.getId(), ics.getValue());
|
|
}
|
|
}
|
|
for(Map.Entry<Integer, String> entry : claMap.entrySet()){
|
|
System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue());
|
|
}
|
|
ICSAdminClassAttribute[] icsAttrS = c.getAttributes();
|
|
|
|
if (icsAttrS != null) {
|
|
for (ICSAdminClassAttribute attr : icsAttrS) {
|
|
if (attr.isReferenceAttribute()) {
|
|
continue;
|
|
}
|
|
if (attr.isReference()) {
|
|
continue;
|
|
}
|
|
ClassPropBean bean = new ClassPropBean(attr);
|
|
classPropList.add(bean);
|
|
}
|
|
}
|
|
boolean have = true;
|
|
for (int i = 0; i < classPropList.size(); i++) {
|
|
ClassPropBean bean = classPropList.get(i);
|
|
String attrName = bean.propDisName;
|
|
System.out.println("attrName==========="+attrName);
|
|
String value = claMap.get(bean.propID);
|
|
if(bean.isLov) {
|
|
String lovValue = bean.lovMapping.get(value);
|
|
if("品牌".equals(attrName)) {
|
|
valueBean.setBrand(lovValue);
|
|
}else {
|
|
if("/".equals(lovValue) || "null".equals(lovValue)) {
|
|
System.out.println("不进行拼接");
|
|
continue;
|
|
}
|
|
sb.append(lovValue);
|
|
if(i < classPropList.size()-1) {
|
|
sb.append(";");
|
|
}
|
|
}
|
|
}else {
|
|
if("品牌".equals(attrName)) {
|
|
valueBean.setBrand(value);
|
|
}else {
|
|
if("/".equals(value) || "null".equals(value)) {
|
|
System.out.println("不进行拼接");
|
|
continue;
|
|
}
|
|
sb.append(value);
|
|
if(i < classPropList.size()-1) {
|
|
sb.append(";");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} catch (TCException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
StringBuilder specSB = new StringBuilder();
|
|
if(valueBean.getBrand() != null) {
|
|
if(!("".equals((valueBean.getBrand()).trim()))
|
|
&& !("/".equals((valueBean.getBrand()).trim()))
|
|
&& !("null".equals((valueBean.getBrand()).trim()))) {
|
|
specSB.append(valueBean.getBrand());
|
|
specSB.append(";");
|
|
}
|
|
}
|
|
specSB.append(sb.toString());
|
|
valueBean.setSpecs(specSB.toString());
|
|
return valueBean;
|
|
}
|
|
}
|