package com.amarsoft.app.util; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import net.sf.json.JSONArray; import net.sf.json.JSONNull; import net.sf.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import jbo.prd.PRD_SPECIFIC_LIBRARY; import jbo.sys.LB_PRODUCT_INFO; import com.amarsoft.app.als.prd.config.loader.ProductConfig; import com.amarsoft.app.base.businessobject.BusinessObject; import com.amarsoft.app.base.businessobject.BusinessObjectHelper; import com.amarsoft.app.base.util.XMLHelper; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; public class ProductParamUtil { /** * 传入产品编号、组件类型编号和参数编号,返回参数对应的值 * @param productId 产品编号 * @param componentType 组件类型编号 * @param parameterId 传入产品编号 * @return 参数对应的值 * @throws Exception * @author zhulh */ public static String getProductParameterValue(String productId,String componentType,String parameterId) throws Exception{ String parameterValue = ""; String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); //List exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObject(realXmlPath, componentType); if(exists.size()==0){ return parameterValue; } List parameters = exists.get(0).getBusinessObjects("Parameter"); for(BusinessObject boP:parameters){ if(parameterId.equals(boP.getString("PARAMETERID"))){ if(boP.containsAttribute("OPTIONALVALUE")){ parameterValue = boP.getString("OPTIONALVALUE"); }else if(boP.containsAttribute("MANDATORYVALUE")){ parameterValue = boP.getString("MANDATORYVALUE"); }else if(boP.containsAttribute("VALUE")){ parameterValue = boP.getString("VALUE"); } } } return parameterValue; } /** * 传入产品编号、组件类型编号和参数编号,返回参数对应的最大值 * @param productId 参数编号 * @param componentType 组件类型编号 * @param parameterId 传入产品编号 * @return 参数对应的最大值 * @throws Exception * @author zhulh */ public static String getProductParameterMaxValue(String productId,String componentType,String parameterId) throws Exception{ String parameterValue = ""; String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); //List exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObject(realXmlPath, componentType); if(exists.size()==0){ return parameterValue; } List parameters = exists.get(0).getBusinessObjects("Parameter"); for(BusinessObject boP:parameters){ if(parameterId.equals(boP.getString("PARAMETERID"))){ if(boP.containsAttribute("MAXIMUMVALUE")){ parameterValue = boP.getString("MAXIMUMVALUE"); } } } return parameterValue; } /** * 传入产品编号、组件类型编号和参数编号,返回参数对应的最小值 * @param productId 参数编号 * @param componentType 组件类型编号 * @param parameterId 传入产品编号 * @return 参数对应的最小值 * @throws Exception * @author zhulh */ public static String getProductParameterMinValue(String productId,String componentType,String parameterId) throws Exception{ String parameterValue = ""; String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); //List exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObject(realXmlPath, componentType); if(exists.size()==0){ return parameterValue; } List parameters = exists.get(0).getBusinessObjects("Parameter"); for(BusinessObject boP:parameters){ if(parameterId.equals(boP.getString("PARAMETERID"))){ if(boP.containsAttribute("MINIMUMVALUE")){ parameterValue = boP.getString("MINIMUMVALUE"); } } } return parameterValue; } /** * 传入产品编号和组件类别编号,将组件参数封装进map返回 * @param productId 产品编号 * @param componentType 组件类别编号 * @return 组件对应数据的MAP * @throws Exception * @author zhulh */ public static Map> getProductComponentType(String productId,String componentType) throws Exception{ Map> productComponent = new HashMap>(); String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); /*List exists = new ArrayList(); BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true); String pData = boLPI.getAttribute("PRODUCT_DATA").getString(); String type = componentType; if("".equals(pData)){ }else{ JSONArray jsonArray = JSONArray.fromObject(pData); Iterator it = jsonArray.iterator(); while(it.hasNext()){ JSONObject jo = (JSONObject)it.next().get("jbo.sample.Component"); if(type.equals(jo.get("TYPE"))){ JSONArray ja = JSONArray.fromObject(jo.get("Parameter")); BusinessObject b = BusinessObject.createBusinessObject("Component"); b.setAttributes(jo); BusinessObject[] bos = new BusinessObject[ja.size()]; for(int i=0;i exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObject(realXmlPath, componentType); if(exists.size()==0){ return productComponent; } for(BusinessObject bo:exists){ List parameters = bo.getBusinessObjects("Parameter"); if("ExpenseType".equals(bo.getString("ID"))){ continue; } Map parameValue = new HashMap(); for(BusinessObject boP:parameters){ String parameterValue = ""; String parameterValueMax = ""; String parameterValueMin = ""; if(boP.containsAttribute("OPTIONALVALUE")){ parameterValue = boP.getString("OPTIONALVALUE"); }else if(boP.containsAttribute("MANDATORYVALUE")){ parameterValue = boP.getString("MANDATORYVALUE"); }else if(boP.containsAttribute("VALUE")){ parameterValue = boP.getString("VALUE"); } if(boP.containsAttribute("MAXIMUMVALUE")){ parameterValueMax = boP.getString("MAXIMUMVALUE"); } if(boP.containsAttribute("MINIMUMVALUE")){ parameterValueMin = boP.getString("MINIMUMVALUE"); } parameValue.put(boP.getString("PARAMETERID"), parameterValue); if(!"".equals(parameterValueMax)){ parameValue.put(boP.getString("PARAMETERID")+"-MAX", parameterValueMax); } if(!"".equals(parameterValueMin)){ parameValue.put(boP.getString("PARAMETERID")+"-MIN", parameterValueMin); } } productComponent.put(bo.getString("ID"), parameValue); } return productComponent; } /** * 传入产品编号、组件类别编号和参数编号,将组件参数封装进map返回 * @param productId 产品编号 * @param componentType 组件类别编号 * @return 组件对应单个参数的MAP * @throws Exception * @author zhulh */ public static Map> getProductComponentTypeOneParam(String productId,String componentType,String parameterId) throws Exception{ Map> productComponent = new HashMap>(); String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); //List exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObject(realXmlPath, componentType); if(exists.size()==0){ return productComponent; } for(BusinessObject bo:exists){ List parameters = bo.getBusinessObjects("Parameter"); if("ExpenseType".equals(bo.getString("ID"))){ continue; } Map parameValue = new HashMap(); for(BusinessObject boP:parameters){ String parameterValue = ""; String parameterValueMax = ""; String parameterValueMin = ""; if(parameterId.equals(boP.getString("PARAMETERID"))){ if(boP.containsAttribute("OPTIONALVALUE")){ parameterValue = boP.getString("OPTIONALVALUE"); }else if(boP.containsAttribute("MANDATORYVALUE")){ parameterValue = boP.getString("MANDATORYVALUE"); }else if(boP.containsAttribute("VALUE")){ parameterValue = boP.getString("VALUE"); } if(boP.containsAttribute("MAXIMUMVALUE")){ parameterValueMax = boP.getString("MAXIMUMVALUE"); } if(boP.containsAttribute("MINIMUMVALUE")){ parameterValueMin = boP.getString("MINIMUMVALUE"); } parameValue.put(boP.getString("PARAMETERID"), parameterValue); if(!"".equals(parameterValueMax)){ parameValue.put(boP.getString("PARAMETERID")+"-MAX", parameterValueMax); } if(!"".equals(parameterValueMin)){ parameValue.put(boP.getString("PARAMETERID")+"-MIN", parameterValueMin); } } } productComponent.put(bo.getString("ID"), parameValue); } return productComponent; } /** * 获取资料清单数据 * @param productId 产品编号 * @param componentType 组件编号 * @throws Exception */ public static List getProductDocInfo(String productId,String componentType) throws Exception{ List docInfo = new ArrayList(); String realXmlPath = getProductValueXmlBySql(productId); /*BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true); String pData = boLPI.getAttribute("PRODUCT_DATA").getString();*/ String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if(StringUtils.isEmpty(pData)){ }else{ JSONArray jsonArray = JSONArray.fromObject(pData); Iterator it = jsonArray.iterator(); JSONArray docList = null; JSONArray docGroupConfig = null; while(it.hasNext()){ JSONObject jo = it.next().getJSONObject("jbo.sample.Component"); if(type.equals(jo.get("TYPE"))){ docList = JSONArray.fromObject(jo.get("DecisionTable")); } if("PRD0413".equals(jo.get("TYPE"))){ docGroupConfig = JSONArray.fromObject(jo.get("DecisionTable")); } } if(docList.size() != 0){ for(int i=0;i singleRow = new HashMap(); singleRow.put("FLOW_INFO", decisionTable.optString("VALUE_FLOW_INFO")); singleRow.put("DOCLIST", decisionTable.optString("OPTIONALVALUE_DOCLIST")); singleRow.put("TYPE", decisionTable.optString("VALUE_TYPE")); docInfo.add(singleRow); }else if("Combination".equals(docType)){ Map combination = new HashMap(); List> d = new ArrayList>(); combination.put("FLOW_INFO", decisionTable.optString("VALUE_FLOW_INFO")); combination.put("TYPE", decisionTable.optString("VALUE_TYPE")); if(docGroupConfig != null){ for(int j=0;j docconfig = new HashMap(); JSONObject dgcObj = docGroupConfig.getJSONObject(j); JSONObject dgcValue = dgcObj.getJSONObject("jbo.sample.DecisionTable"); String dgcId = dgcValue.optString("ID"); if(dgcId.startsWith(id)){ docconfig.put("DOCNO", dgcValue.optString("OPTIONALVALUE_DOCLIST")); docconfig.put("MAINTYPE", dgcValue.optString("VALUE_MAINTYPE")); docconfig.put("POSITION", dgcValue.optString("VALUE_POSITION")); }else{ continue; } d.add(docconfig); } } combination.put("DOCCONFIG", d); docInfo.add(combination); } } } } /*SAXReader reader = new SAXReader(); Document doc = reader.read(realXmlPath); List component = doc.selectNodes("//Component[@TYPE='"+componentType+"']"); for(Element e:component){ Element el = e.element("DecisionTables"); List ets = el.elements("DecisionTable"); for(Element et:ets){ String docType = et.attributeValue("VALUE_TYPE"); if("SingleRow".equals(docType)){ Map singleRow = new HashMap(); singleRow.put("FLOW_INFO", et.attributeValue("VALUE_FLOW_INFO")); singleRow.put("DOCLIST", et.attributeValue("OPTIONALVALUE_DOCLIST")); singleRow.put("TYPE", et.attributeValue("VALUE_TYPE")); docInfo.add(singleRow); }else if("Combination".equals(docType)){ Map combination = new HashMap(); List> d = new ArrayList>(); combination.put("FLOW_INFO", et.attributeValue("VALUE_FLOW_INFO")); combination.put("TYPE", et.attributeValue("VALUE_TYPE")); List subComponent = doc.selectNodes("//Component[@TYPE='PRD0413']"); for(Element sc:subComponent){ Element sel = sc.element("DecisionTables"); List sets = sel.elements("DecisionTable"); int n = 1; for(Element set:sets){ Map docconfig = new HashMap(); if(set.attributeValue("ID").startsWith(et.attributeValue("ID"))){ docconfig.put("DOCNO", set.attributeValue("OPTIONALVALUE_DOCLIST")); docconfig.put("MAINTYPE", set.attributeValue("VALUE_MAINTYPE")); docconfig.put("POSITION", set.attributeValue("VALUE_POSITION")); }else{ continue; } d.add(docconfig); n++; } } combination.put("DOCCONFIG", d); docInfo.add(combination); } } }*/ return docInfo; } /** * 删除决策组的数据 * @param productId * @param componentType * @param id * @throws Exception */ public static void removeProductParame(String productId,String componentType,String id) throws Exception{ String realXmlPath = getProductValueXml(productId); SAXReader reader = new SAXReader(); Document doc = reader.read(realXmlPath); List component = doc.selectNodes("//Component[@TYPE='"+componentType+"']"); for(Element e:component){ Element el = e.element("DecisionTables"); List ets = el.elements("DecisionTable"); for(Element et:ets){ if(et.attributeValue("ID").startsWith(id)){ el.remove(et); } } } OutputFormat xmlFormat = OutputFormat.createPrettyPrint(); xmlFormat.setEncoding("GBK"); XMLWriter writer = new XMLWriter(new FileOutputStream(realXmlPath),xmlFormat); writer.write(doc); writer.close(); } /** * 传入产品编号和组件类别编号,将参数组封装进map返回 * @param productId 产品编号 * @param componentType 组件类别编号 * @return 组件对应数据的MAP * @throws Exception * @author zhulh */ public static Map>> getProductComponentDecisionTable(String productId,String componentType,String... paramNames) throws Exception{ Map>> productComponent = new HashMap>>(); String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); //List exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObjectWithDecisionTable(realXmlPath,componentType); if(exists.size()==0){ return productComponent; } for(BusinessObject bo:exists){ List parameters = bo.getBusinessObjects("DecisionTable"); if("ExpenseType".equals(bo.getString("ID"))){ continue; } List> parameValues = new ArrayList>(); for(BusinessObject boP:parameters){ Map parameValue = new HashMap(); String paramValue = ""; for(String paramName : paramNames) { if(boP.containsAttribute("OPTIONALVALUE_"+(paramName.toUpperCase()))){ paramValue = boP.getString("OPTIONALVALUE_"+(paramName.toUpperCase())); }else if(boP.containsAttribute("VALUE_"+(paramName.toUpperCase()))){ paramValue = boP.getString("VALUE_"+(paramName.toUpperCase())); }else if(boP.containsAttribute("MANDATORYVALUE_"+(paramName.toUpperCase()))){ paramValue = boP.getString("MANDATORYVALUE_"+(paramName.toUpperCase())); } else { paramValue = boP.getString(paramName.toUpperCase()); } parameValue.put(paramName, paramValue); } parameValues.add(parameValue); } productComponent.put(bo.getString("ID"), parameValues); } return productComponent; } /** * 传入产品编号、组件类型编号和组件ID,寻找唯一参数的值 * @param productId 产品编号 * @param componentType 组件类型编号 * @param id 对应组件的ID * @param parameterId 传入参数ID * @return 参数对应的值 * @throws Exception * @author zhulh */ public static String getProductParameterValue(String productId,String componentType,String id,String parameterId) throws Exception{ /*String realXmlPath = getProductValueXml(productId); String parameterValue = ""; SAXReader reader = new SAXReader(); Document doc = reader.read(realXmlPath); List component = doc.selectNodes("//Component[@TYPE='"+componentType+"' and @ID='"+id+"']"); for(Element e:component){ Element el = e.element("Parameters"); List ets = el.elements("Parameter"); for(Element et:ets){ if(parameterId.equals(et.attributeValue("PARAMETERID"))){ if(et.attribute("OPTIONALVALUE") != null){ parameterValue = et.attributeValue("OPTIONALVALUE"); }else if(et.attribute("MANDATORYVALUE") != null){ parameterValue = et.attributeValue("MANDATORYVALUE"); }else if(et.attribute("VALUE") != null){ parameterValue = et.attributeValue("VALUE"); } } } }*/ String parameterValue = ""; String realXmlPath = getProductValueXmlBySql(productId); /*BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true); String pData = boLPI.getAttribute("PRODUCT_DATA").getString();*/ String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if(StringUtils.isEmpty(pData)){ }else{ JSONArray jsonArray = JSONArray.fromObject(pData); Iterator it = jsonArray.iterator(); JSONArray param = null; while(it.hasNext()){ JSONObject jo = it.next().getJSONObject("jbo.sample.Component"); if(type.equals(jo.get("TYPE")) && id.equals(jo.get("ID"))){ param = JSONArray.fromObject(jo.get("Parameter")); } } if(param != null){ for(int i=0;i getProductComponentAllParameters(String productId,String componentType,String id) throws Exception{ Map parameValue = new HashMap(); String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); /*List exists = new ArrayList(); BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true); String pData = boLPI.getAttribute("PRODUCT_DATA").getString(); String type = componentType; if("".equals(pData)){ }else{ JSONArray jsonArray = JSONArray.fromObject(pData); Iterator it = jsonArray.iterator(); while(it.hasNext()){ JSONObject jo = (JSONObject)it.next().get("jbo.sample.Component"); if(type.equals(jo.get("TYPE"))){ JSONArray ja = JSONArray.fromObject(jo.get("Parameter")); BusinessObject b = BusinessObject.createBusinessObject("Component"); b.setAttributes(jo); BusinessObject[] bos = new BusinessObject[ja.size()]; for(int i=0;i exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type",componentType); List exists = getBusinessObject(realXmlPath, componentType); if(exists.size()==0){ return parameValue; } for(BusinessObject bo:exists){ List parameters = bo.getBusinessObjects("Parameter"); if(!id.equals(bo.getString("ID"))){ continue; } for(BusinessObject boP:parameters){ String parameterValue = ""; String parameterValueMax = ""; String parameterValueMin = ""; if(boP.containsAttribute("OPTIONALVALUE")){ parameterValue = boP.getString("OPTIONALVALUE"); }else if(boP.containsAttribute("MANDATORYVALUE")){ parameterValue = boP.getString("MANDATORYVALUE"); }else if(boP.containsAttribute("VALUE")){ parameterValue = boP.getString("VALUE"); } if(boP.containsAttribute("MAXIMUMVALUE")){ parameterValueMax = boP.getString("MAXIMUMVALUE"); } if(boP.containsAttribute("MINIMUMVALUE")){ parameterValueMin = boP.getString("MINIMUMVALUE"); } parameValue.put(boP.getString("PARAMETERID"), parameterValue); if(!"".equals(parameterValueMax)){ parameValue.put(boP.getString("PARAMETERID")+"-MAX", parameterValueMax); } if(!"".equals(parameterValueMin)){ parameValue.put(boP.getString("PARAMETERID")+"-MIN", parameterValueMin); } } if(!parameValue.isEmpty()) { break; } } return parameValue; } /** * 获取五级分类结果 * @param productId * @param overDays * @param paramName1 * @param paramName2 * @return * @throws Exception */ public static String getFiveGradeClassification (String productId, String overDays, String paramName1,String paramName2) throws Exception{ String realXmlPath = getProductValueXmlBySql(productId); //List componentList = XMLHelper.getBusinessObjectList(realXmlPath,"Component||Status='1'","ID"); //List exists = BusinessObjectHelper.getBusinessObjectsBySql(componentList, "Type like :Type", "Type","PRD0201"); List exists = getBusinessObject(realXmlPath, "PRD0201"); String result=""; if(exists.size()==0){ return result; } for(BusinessObject bo:exists){ List parameters = bo.getBusinessObjects("DecisionTable"); if("ExpenseType".equals(bo.getString("ID"))){ continue; } for(BusinessObject boP:parameters){ String maxDays = ""; String minDays = ""; if(boP.containsAttribute("MINIMUMVALUE_"+(paramName1.toUpperCase()))){ minDays = boP.getString("MINIMUMVALUE_"+(paramName1.toUpperCase())); }else if(boP.containsAttribute("MINIMUMVALUE_"+(paramName2.toUpperCase()))){ minDays = boP.getString("MINIMUMVALUE_"+(paramName2.toUpperCase())); } if(boP.containsAttribute("MAXIMUMVALUE_"+(paramName1.toUpperCase()))){ maxDays = boP.getString("MAXIMUMVALUE_"+(paramName1.toUpperCase())); }else if(boP.containsAttribute("MAXIMUMVALUE_"+(paramName2.toUpperCase()))){ maxDays = boP.getString("MAXIMUMVALUE_"+(paramName2.toUpperCase())); } if(Integer.parseInt(minDays)<=Integer.parseInt(overDays)&& Integer.parseInt(maxDays)>=Integer.parseInt(overDays)){ if(boP.containsAttribute("VALUE_"+(paramName1.toUpperCase()))){ result = boP.getString("VALUE_"+(paramName1.toUpperCase())); }else if(boP.containsAttribute("VALUE_"+(paramName2.toUpperCase()))){ result = boP.getString("VALUE_"+(paramName2.toUpperCase())); } return result; } } } return result; } /** * 传入产品编号,获取产品对应XML路径 * @param productId 产品编号 * @return 产品对应XML路径 * @throws JBOException * @author zhulh */ public static String getProductValueXmlBySql(String productId) throws JBOException{ /*BizObject bo = JBOFactory.getBizObjectManager(PRD_SPECIFIC_LIBRARY.CLASS_NAME).createQuery("productid=:ProductId").setParameter("ProductId", productId).getSingleResult(false); String realXmlPath = ""; if(bo != null){ //String path = ProductParamUtil.class.getResource("/").toString(); String configfile = bo.getAttribute("configfile").toString(); if(path.startsWith("file:/home")){ path = path.substring(5, path.length()-9); }else{ path = path.substring(6, path.length()-9); } //realXmlPath = path+configfile.substring(configfile.indexOf("/")); realXmlPath = configfile; }*/ return productId; } public static String getProductValueXml(String productId) throws JBOException{ BizObject bo = JBOFactory.getBizObjectManager(PRD_SPECIFIC_LIBRARY.CLASS_NAME).createQuery("productid=:ProductId").setParameter("ProductId", productId).getSingleResult(false); String realXmlPath = ""; if(bo != null){ String path = ProductParamUtil.class.getResource("/").toString(); String configfile = bo.getAttribute("configfile").toString(); if(path.startsWith("file:/home")){ path = path.substring(5, path.length()-9); }else{ path = path.substring(6, path.length()-9); } realXmlPath = path+configfile.substring(configfile.indexOf("/")); } return realXmlPath; } public static List getBusinessObject(String realXmlPath,String componentType) throws Exception{ List exists = new ArrayList(); //BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); //BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true); //String pData = boLPI.getAttribute("PRODUCT_DATA").getString(); //切换读取缓存 String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if(StringUtils.isEmpty(pData)){ }else{ JSONArray jsonArray = JSONArray.fromObject(pData); Iterator it = jsonArray.iterator(); while(it.hasNext()){ JSONObject jo = it.next().getJSONObject("jbo.sample.Component"); if(type.equals(jo.get("TYPE"))){ JSONArray ja = JSONArray.fromObject(jo.get("Parameter")); BusinessObject b = BusinessObject.createBusinessObject("Component"); b.setAttributes(jo); BusinessObject[] bos = new BusinessObject[ja.size()]; for(int i=0;i valMap = new HashMap(); Set vSet = value.entrySet(); for(Entry v:vSet){ valMap.put(v.getKey().toString(), v.getValue()); } bos[i] = BusinessObject.createBusinessObject("jbo.sample.Parameter",valMap); } b.setAttributeValue("Parameter", bos); exists.add(b); } } } return exists; } public static List getBusinessObjectWithDecisionTable(String realXmlPath,String componentType) throws Exception{ List exists = new ArrayList(); /*BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); BizObject boLPI = bomLPI.createQuery("ID=:ID").setParameter("ID", realXmlPath).getSingleResult(true); String pData = boLPI.getAttribute("PRODUCT_DATA").getString();*/ String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if(StringUtils.isEmpty(pData)){ }else{ JSONArray jsonArray = JSONArray.fromObject(pData); Iterator it = jsonArray.iterator(); while(it.hasNext()){ JSONObject jo = it.next().getJSONObject("jbo.sample.Component"); if(type.equals(jo.get("TYPE"))){ JSONArray ja = JSONArray.fromObject(jo.get("DecisionTable")); BusinessObject b = BusinessObject.createBusinessObject("Component"); b.setAttributes(jo); BusinessObject[] bos = new BusinessObject[ja.size()]; for(int i=0;i valMap = new HashMap(); Set vSet = value.entrySet(); for(Entry v:vSet){ valMap.put(v.getKey().toString(), v.getValue()); } bos[i] = BusinessObject.createBusinessObject("jbo.sample.DecisionTable",valMap); } b.setAttributeValue("DecisionTable", bos); exists.add(b); } } } return exists; } }