diff --git a/WebContent/Frame/page/js/ow/as_dw_info.js b/WebContent/Frame/page/js/ow/as_dw_info.js index 04081eb22..a4cea6e0b 100644 --- a/WebContent/Frame/page/js/ow/as_dw_info.js +++ b/WebContent/Frame/page/js/ow/as_dw_info.js @@ -413,7 +413,7 @@ function showItemRequired(dwname,sColName){ data: "DataObject=" + $("#SERIALIZED_ASD").val() + "&ColName="+ sColName + "&Required=1", success: function(msg){ if(msg.substring(0,5)=="fail:"){ - alert('校验更新失败:' +msg.substring(5)); + //alert('校验更新失败:' +msg.substring(5)); 2018/07/08 by zhulh 找不到校验文件没啥好大惊小怪的 return; } $("#SERIALIZED_ASD").val(msg); diff --git a/WebContent/Frame/page/ow/RequiredRuleUpdator.jsp b/WebContent/Frame/page/ow/RequiredRuleUpdator.jsp index f6c65f00e..19f55619f 100644 --- a/WebContent/Frame/page/ow/RequiredRuleUpdator.jsp +++ b/WebContent/Frame/page/ow/RequiredRuleUpdator.jsp @@ -25,7 +25,8 @@ try{ ObjectConverts.saveObject(new java.io.File(Component.getDWTmpPath(asObj.getSerializableName())), asObj); out.print(sDataObject); }catch(Exception e){ - e.printStackTrace(); + //e.printStackTrace();2018/07/08 by zhulh 找不到校验文件没啥好大惊小怪的 + ARE.getLog().error(e.getMessage()); out.print("fail:"+ e.toString()); } %> \ No newline at end of file diff --git a/src/com/amarsoft/app/util/ProductParamUtil.java b/src/com/amarsoft/app/util/ProductParamUtil.java index 00a974a95..8734deb96 100644 --- a/src/com/amarsoft/app/util/ProductParamUtil.java +++ b/src/com/amarsoft/app/util/ProductParamUtil.java @@ -22,7 +22,7 @@ import org.dom4j.io.XMLWriter; import jbo.prd.PRD_SPECIFIC_LIBRARY; import jbo.sys.LB_PRODUCT_INFO; -import com.alibaba.fastjson.JSON; +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; @@ -253,9 +253,10 @@ public class ProductParamUtil { 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); + /*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 = boLPI.getAttribute("PRODUCT_DATA").getString();*/ + String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if("".equals(pData)){ }else{ @@ -392,7 +393,7 @@ public class ProductParamUtil { * @throws Exception * @author zhulh */ - public static Map>> getProductComponentDecisionTable(String productId,String componentType,String paramName1,String paramName2) throws Exception{ + 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"); @@ -406,24 +407,19 @@ public class ProductParamUtil { List> parameValues = new ArrayList>(); for(BusinessObject boP:parameters){ Map parameValue = new HashMap(); - String paramValue1 = ""; - String paramValue2 = ""; - if(boP.containsAttribute("OPTIONALVALUE_"+(paramName1.toUpperCase()))){ - paramValue1 = boP.getString("OPTIONALVALUE_"+(paramName1.toUpperCase())); - }else if(boP.containsAttribute("VALUE_"+(paramName1.toUpperCase()))){ - paramValue1 = boP.getString("VALUE_"+(paramName1.toUpperCase())); - }else if(boP.containsAttribute("MANDATORYVALUE_"+(paramName1.toUpperCase()))){ - paramValue1 = boP.getString("MANDATORYVALUE_"+(paramName1.toUpperCase())); + 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); } - if(boP.containsAttribute("OPTIONALVALUE_"+(paramName2.toUpperCase()))){ - paramValue2 = boP.getString("OPTIONALVALUE_"+(paramName2.toUpperCase())); - }else if(boP.containsAttribute("VALUE_"+(paramName2.toUpperCase()))){ - paramValue2 = boP.getString("VALUE_"+(paramName2.toUpperCase())); - }else if(boP.containsAttribute("MANDATORYVALUE_"+(paramName2.toUpperCase()))){ - paramValue2 = boP.getString("MANDATORYVALUE_"+(paramName2.toUpperCase())); - } - parameValue.put(paramName1, paramValue1); - parameValue.put(paramName2, paramValue2); parameValues.add(parameValue); } productComponent.put(bo.getString("ID"), parameValues); @@ -464,9 +460,10 @@ public class ProductParamUtil { }*/ String parameterValue = ""; String realXmlPath = getProductValueXmlBySql(productId); - BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); + /*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 = boLPI.getAttribute("PRODUCT_DATA").getString();*/ + String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if("".equals(pData)){ }else{ @@ -508,30 +505,28 @@ public class ProductParamUtil { List exists = getBusinessObject(realXmlPath, "PRD0201"); String result=""; for(BusinessObject bo:exists){ - List list = com.alibaba.fastjson.JSONArray.parseArray(bo.getObject("DecisionTable").toString(), Map.class); + List parameters = bo.getBusinessObjects("DecisionTable"); if("ExpenseType".equals(bo.getString("ID"))){ continue; } - for (Map map : list) { - String key = map.get("jbo.sample.DecisionTable").toString(); - Map mapValue = (Map)JSON.parse(key); + for(BusinessObject boP:parameters){ String maxDays = ""; String minDays = ""; - if(mapValue.containsKey("MINIMUMVALUE_"+(paramName1.toUpperCase()))){ - minDays = mapValue.get("MINIMUMVALUE_"+(paramName1.toUpperCase())).toString(); - }else if(mapValue.containsKey("MINIMUMVALUE_"+(paramName2.toUpperCase()))){ - minDays = mapValue.get("MINIMUMVALUE_"+(paramName2.toUpperCase())).toString(); + 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(mapValue.containsKey("MAXIMUMVALUE_"+(paramName1.toUpperCase()))){ - maxDays = mapValue.get("MAXIMUMVALUE_"+(paramName1.toUpperCase())).toString(); - }else if(mapValue.containsKey("MAXIMUMVALUE_"+(paramName2.toUpperCase()))){ - maxDays = mapValue.get("MAXIMUMVALUE_"+(paramName2.toUpperCase())).toString(); + 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(mapValue.containsKey("VALUE_"+(paramName1.toUpperCase()))){ - result = mapValue.get("VALUE_"+(paramName1.toUpperCase())).toString(); - }else if(mapValue.containsKey("VALUE_"+(paramName2.toUpperCase()))){ - result = mapValue.get("VALUE_"+(paramName2.toUpperCase())).toString(); + 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; } @@ -547,20 +542,20 @@ public class ProductParamUtil { * @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); + /*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")){ + 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 realXmlPath; + }*/ + return productId; } public static String getProductValueXml(String productId) throws JBOException{ @@ -581,12 +576,11 @@ public class ProductParamUtil { 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); - if (boLPI == null) { - return exists; - } - String pData = boLPI.getAttribute("PRODUCT_DATA").getString(); + //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("".equals(pData)){ }else{ @@ -607,9 +601,6 @@ public class ProductParamUtil { Map valMap = new HashMap(); Set vSet = value.entrySet(); for(Entry v:vSet){ - if (v.getKey().toString().equals("DecisionTable")) { - System.out.println(v.getKey().toString()); - } valMap.put(v.getKey().toString(), v.getValue()); } bos[i] = BusinessObject.createBusinessObject("jbo.sample.Parameter",valMap); @@ -624,9 +615,10 @@ public class ProductParamUtil { public static List getBusinessObjectWithDecisionTable(String realXmlPath,String componentType) throws Exception{ List exists = new ArrayList(); - BizObjectManager bomLPI = JBOFactory.getBizObjectManager(LB_PRODUCT_INFO.CLASS_NAME); + /*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 = boLPI.getAttribute("PRODUCT_DATA").getString();*/ + String pData = ProductConfig.getProductData(realXmlPath); String type = componentType; if("".equals(pData)){ }else{ diff --git a/src_prd/com/amarsoft/app/als/prd/config/loader/ProductConfig.java b/src_prd/com/amarsoft/app/als/prd/config/loader/ProductConfig.java index 3c34ecb3c..2e0e49230 100644 --- a/src_prd/com/amarsoft/app/als/prd/config/loader/ProductConfig.java +++ b/src_prd/com/amarsoft/app/als/prd/config/loader/ProductConfig.java @@ -2,6 +2,8 @@ package com.amarsoft.app.als.prd.config.loader; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import jbo.prd.BUSINESS_TYPE; import jbo.prd.PRD_SPECIFIC_LIBRARY; @@ -13,23 +15,80 @@ import com.amarsoft.app.base.config.impl.BusinessComponentConfig; import com.amarsoft.app.base.exception.ALSException; import com.amarsoft.app.base.util.DateHelper; import com.amarsoft.app.base.util.XMLHelper; +import com.amarsoft.are.ARE; import com.amarsoft.are.lang.StringX; +import com.amarsoft.awe.util.ASResultSet; +import com.amarsoft.awe.util.SqlObject; import com.amarsoft.awe.util.Transaction; import com.amarsoft.dict.als.cache.AbstractCache; +//import com.tenwa.httpclient.resources.BigDataPropertiesUtil; +import com.tenwa.httpclient.resources.GPSConfigure; +import com.tenwa.httpclient.resources.QuartzPropertiesUtil; public class ProductConfig extends AbstractCache{ private static BusinessObjectCache productCache = null; + private static Map productInfos; + private static Map holidays; public void clear() throws Exception { productCache.clear(); + productInfos.clear(); + holidays.clear(); } public synchronized boolean load(Transaction transaction) throws Exception { + //缓存产品 + ARE.getLog().info("[CACHE] ProductInfo bulid Begin ................."); + cacheProduct(transaction); + ARE.getLog().info("[CACHE] ProductInfo bulid End ..................."); + ARE.getLog().info("[CACHE] Holiday bulid Begin ................."); + cacheHoliday(transaction); + ARE.getLog().info("[CACHE] Holiday bulid End ..................."); + /*ARE.getLog().info("[CACHE] BigDataParams bulid Begin ................."); + BigDataPropertiesUtil.destroy(); + BigDataPropertiesUtil.load(); + ARE.getLog().info("[CACHE] BigDataParams bulid End ...................");*/ + ARE.getLog().info("[CACHE] GPSParams bulid Begin ................."); + GPSConfigure.destroy(); + GPSConfigure.load(); + ARE.getLog().info("[CACHE] GPSParams bulid End ..................."); + ARE.getLog().info("[CACHE] GPSParams bulid Begin ................."); + QuartzPropertiesUtil.destroy(); + QuartzPropertiesUtil.load(); + ARE.getLog().info("[CACHE] GPSParams bulid End ..................."); productCache=new BusinessObjectCache(500); return true; } + private synchronized void cacheHoliday(Transaction transaction) throws Exception{ + holidays = new ConcurrentHashMap(); + ASResultSet rs = null; + rs = transaction.getASResultSet(new SqlObject("select c_date, otype from bt_holiday")); + while(rs.next()) { + holidays.put(rs.getString("c_date"), rs.getString("otype")); + } + rs.close(); + } + + private synchronized void cacheProduct(Transaction transaction) throws Exception{ + productInfos = new ConcurrentHashMap(); + ASResultSet rs = null; + rs = transaction.getASResultSet(new SqlObject("select lpi.product_id,lpi.product_data,bt.typename from lb_product_info lpi left join business_type bt on lpi.product_id = bt.typeno")); + while(rs.next()) { + productInfos.put(rs.getString("product_id"), rs.getString("product_data")); + } + rs.close(); + } + + public synchronized static String getProductData(String specificSerialNo) { + return productInfos.get(specificSerialNo); + } + + public synchronized static String getHoliday(String cdate) { + return holidays.get(cdate); + } + /** * 获取产品定义 * @param productID diff --git a/src_tenwa/com/tenwa/httpclient/resources/GPSConfigure.java b/src_tenwa/com/tenwa/httpclient/resources/GPSConfigure.java index f1e15ce1e..92d039556 100644 --- a/src_tenwa/com/tenwa/httpclient/resources/GPSConfigure.java +++ b/src_tenwa/com/tenwa/httpclient/resources/GPSConfigure.java @@ -7,13 +7,11 @@ import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import com.amarsoft.are.ARE; -import com.tenwa.httpclient.ResultMessage; - public class GPSConfigure { - private static final Map attributes; + private static Map attributes; - static{ + public static void load() { attributes = new ConcurrentHashMap(); Properties prop = new Properties(); try { @@ -31,7 +29,12 @@ public class GPSConfigure { ARE.getLog().info("init GPSConfigure info success"); } + public static void destroy() { + if(attributes != null) attributes.clear(); + } + public static String get(String propName) { + if(attributes == null) load(); return attributes.get(propName); } } diff --git a/src_tenwa/com/tenwa/httpclient/resources/QuartzPropertiesUtil.java b/src_tenwa/com/tenwa/httpclient/resources/QuartzPropertiesUtil.java index d42668de3..653ae28a6 100644 --- a/src_tenwa/com/tenwa/httpclient/resources/QuartzPropertiesUtil.java +++ b/src_tenwa/com/tenwa/httpclient/resources/QuartzPropertiesUtil.java @@ -9,9 +9,9 @@ import java.util.concurrent.ConcurrentHashMap; import com.amarsoft.are.ARE; public class QuartzPropertiesUtil { - private static final Map attributes; + private static Map attributes; - static{ + public static void load() { attributes = new ConcurrentHashMap(); Properties prop = new Properties(); try { @@ -29,7 +29,12 @@ public class QuartzPropertiesUtil { ARE.getLog().info("init QuartzPropertiesUtil info success"); } + public static void destroy() { + if(attributes != null) attributes.clear(); + } + public static String get(String propName) { + if(attributes == null) load(); return attributes.get(propName); } }