| | |
| | | import com.vci.web.pageModel.*; |
| | | import com.vci.web.properties.WebProperties; |
| | | import com.vci.web.service.impl.WebLoServiceImpl; |
| | | import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
| | | import net.sf.jsqlparser.statement.select.PlainSelect; |
| | | import net.sf.jsqlparser.statement.select.SelectItem; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | * @param cbo 业务数据 |
| | | * @param obj 对象 |
| | | */ |
| | | public static void copyValueToObjectFromCbos(ClientBusinessObject cbo,Object obj){ |
| | | public static void copyValueToObjectFromCbos(com.vci.client.bof.ClientBusinessObject cbo,Object obj){ |
| | | if(cbo!=null){ |
| | | copyValueToObjectFromBos(cbo.getBusinessObject(),obj); |
| | | } |
| | |
| | | * @param obj 对象 |
| | | * @param fieldAttrMap 属性映射 |
| | | */ |
| | | public static void copyValueToObjectFromCbos(ClientBusinessObject cbo,Object obj,Map<String,String> fieldAttrMap){ |
| | | public static void copyValueToObjectFromCbos(com.vci.client.bof.ClientBusinessObject cbo,Object obj,Map<String,String> fieldAttrMap){ |
| | | if(cbo!=null){ |
| | | copyValueToObjectFromBos(cbo.getBusinessObject(),obj,fieldAttrMap); |
| | | } |
| | |
| | | * @param bo 业务数据 |
| | | * @param obj 对象 |
| | | */ |
| | | public static void copyValueToObjectFromBos(BusinessObject bo ,Object obj){ |
| | | public static void copyValueToObjectFromBos(com.vci.corba.omd.data.BusinessObject bo ,Object obj){ |
| | | copyValueToObjectFromBos(bo,obj,null); |
| | | } |
| | | |
| | |
| | | * @param obj 对象 |
| | | * @param fieldAttrMap 属性映射 |
| | | */ |
| | | public static void copyValueToObjectFromBos(BusinessObject bo ,Object obj,Map<String,String> fieldAttrMap){ |
| | | public static void copyValueToObjectFromBos(com.vci.corba.omd.data.BusinessObject bo , Object obj, Map<String,String> fieldAttrMap){ |
| | | if(bo!=null && obj != null){ |
| | | //先把所有的字段映射找到 |
| | | if(fieldAttrMap == null){ |
| | | fieldAttrMap = getFieldNameMap(obj.getClass()); |
| | | } |
| | | AttributeValue[] newAList = bo.newAttrValList; |
| | | AttributeValue[] hisAList = bo.hisAttrValList; |
| | | com.vci.corba.omd.data.AttributeValue[] newAList = bo.newAttrValList; |
| | | com.vci.corba.omd.data.AttributeValue[] hisAList = bo.hisAttrValList; |
| | | //要先把BO对象上的值拷贝过去 |
| | | List<Field> boFields = getAllFieldForObj(bo.getClass()); |
| | | |
| | |
| | | } |
| | | if(newAList!=null&&newAList.length>0){ |
| | | for(int i = 0 ; i < newAList.length;i++){ |
| | | AttributeValue av = newAList[i]; |
| | | com.vci.corba.omd.data.AttributeValue av = newAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | if(fieldAttrMap.containsKey(attrName)) { |
| | | String fieldName = fieldAttrMap.get(attrName); |
| | |
| | | } |
| | | if(hisAList!=null&&hisAList.length>0){ |
| | | for(int i = 0 ; i < hisAList.length;i++){ |
| | | AttributeValue av = hisAList[i]; |
| | | com.vci.corba.omd.data.AttributeValue av = hisAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | String fieldName = fieldAttrMap.get(attrName); |
| | | if(fieldName!=null){ |
| | |
| | | * @param cbo 业务数据 |
| | | * @param map map |
| | | */ |
| | | public static void copyValueToMapFromCbos(ClientBusinessObject cbo,Map<String,String> map){ |
| | | public static void copyValueToMapFromCbos(com.vci.client.bof.ClientBusinessObject cbo,Map<String,String> map){ |
| | | if(cbo!=null){ |
| | | copyValueToMapFromBos(cbo.getBusinessObject(),map); |
| | | } |
| | |
| | | * @param bo 业务数据 |
| | | * @param map map |
| | | */ |
| | | public static void copyValueToMapFromBos(BusinessObject bo,Map<String,String> map){ |
| | | public static void copyValueToMapFromBos(com.vci.corba.omd.data.BusinessObject bo, Map<String,String> map){ |
| | | if(bo!=null ){ |
| | | //先把所有的字段映射找到 |
| | | AttributeValue[] newAList = bo.newAttrValList; |
| | | AttributeValue[] hisAList = bo.hisAttrValList; |
| | | com.vci.corba.omd.data.AttributeValue[] newAList = bo.newAttrValList; |
| | | com.vci.corba.omd.data.AttributeValue[] hisAList = bo.hisAttrValList; |
| | | if(hisAList!=null&&hisAList.length>0){// |
| | | for(int i = 0 ; i < hisAList.length;i++){ |
| | | AttributeValue av = hisAList[i]; |
| | | com.vci.corba.omd.data.AttributeValue av = hisAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | map.put(attrName, av.attrVal); |
| | | } |
| | | } |
| | | if(newAList!=null&&newAList.length>0){//NEW的优先级高些 |
| | | for(int i = 0 ; i < newAList.length;i++){ |
| | | AttributeValue av = newAList[i]; |
| | | com.vci.corba.omd.data.AttributeValue av = newAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | map.put(attrName, av.attrVal); |
| | | } |
| | |
| | | * @param clo 链接类型 |
| | | * @param map map |
| | | */ |
| | | public static void copyValueToMapFromClos(ClientLinkObject clo,Map<String,String> map){ |
| | | public static void copyValueToMapFromClos(com.vci.client.bof.ClientLinkObject clo,Map<String,String> map){ |
| | | if(clo!=null){ |
| | | copyValueToMapFromLos(clo.getLinkObject(),map); |
| | | } |
| | |
| | | * @param lo 链接类型 |
| | | * @param map map |
| | | */ |
| | | public static void copyValueToMapFromLos(LinkObject lo,Map<String,String> map){ |
| | | public static void copyValueToMapFromLos(com.vci.corba.omd.data.LinkObject lo,Map<String,String> map){ |
| | | if(lo!=null){ |
| | | WebLoServiceImpl.LO_BASE_FIELD_MAP.forEach((field,attr)->{ |
| | | map.put(attr.toLowerCase(),getValueFromFieldForCbo(getFieldForObject(field,lo),lo)); |
| | | }); |
| | | //先把所有的字段映射找到 |
| | | AttributeValue[] newAList = lo.newAttrValList; |
| | | AttributeValue[] hisAList = lo.hisAttrValList; |
| | | com.vci.corba.omd.data.AttributeValue[] newAList = lo.newAttrValList; |
| | | com.vci.corba.omd.data.AttributeValue[] hisAList = lo.hisAttrValList; |
| | | if(hisAList!=null&&hisAList.length>0){ |
| | | for(int i = 0 ; i < hisAList.length;i++){ |
| | | AttributeValue av = hisAList[i]; |
| | | com.vci.corba.omd.data.AttributeValue av = hisAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | map.put(attrName, av.attrVal); |
| | | } |
| | | } |
| | | if(newAList!=null&&newAList.length>0){ |
| | | for(int i = 0 ; i < newAList.length;i++){ |
| | | AttributeValue av = newAList[i]; |
| | | com.vci.corba.omd.data.AttributeValue av = newAList[i]; |
| | | String attrName = av.attrName.toLowerCase(); |
| | | map.put(attrName, av.attrVal); |
| | | } |
| | |
| | | * @param cbo 链接类型 |
| | | * @param map 对象 |
| | | */ |
| | | public static void copyValueToCboFromMap(ClientBusinessObject cbo,Map<String,String> map) throws VciBaseException{ |
| | | public static void copyValueToCboFromMap(com.vci.client.bof.ClientBusinessObject cbo,Map<String,String> map) throws VciBaseException{ |
| | | if(map!=null){ |
| | | Iterator<String> it = map.keySet().iterator(); |
| | | while(it.hasNext()){ |
| | |
| | | * @param wrapperOptions 封装的信息 |
| | | * @return 树列表 |
| | | */ |
| | | public static <T,R> List<Tree> cboList2Trees(List<? extends ClientBusinessObject> doList, TreeWrapperOptions wrapperOptions, Function<T,R> f){ |
| | | public static <T,R> List<Tree> cboList2Trees(List<? extends com.vci.client.bof.ClientBusinessObject> doList, TreeWrapperOptions wrapperOptions, Function<T,R> f){ |
| | | if(CollectionUtils.isEmpty(doList)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Tree> allTree = new ArrayList<Tree>(); |
| | | List<Tree> children = new ArrayList<Tree>(); |
| | | for (int i = 0 ; i < doList.size();i++) { |
| | | ClientBusinessObject cbo = doList.get(i); |
| | | com.vci.client.bof.ClientBusinessObject cbo = doList.get(i); |
| | | Tree tree =new Tree(); |
| | | List<String> oidFieldNames = VciBaseUtil.str2List(wrapperOptions.getOidFieldName()); |
| | | List<String> oidValues = new LinkedList<>(); |
| | |
| | | new Tree().findChild(allTree,children); |
| | | return allTree; |
| | | } |
| | | |
| | | public static com.vci.client.bof.ClientBusinessObject arryAndSqlToClientBusinessObject(String sqlStr,String[] valueArry) { |
| | | com.vci.client.bof.ClientBusinessObject clientBusinessObject = new com.vci.client.bof.ClientBusinessObject(); |
| | | try { |
| | | PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(sqlStr); |
| | | com.vci.corba.omd.data.AttributeValue[] attributeValues = new com.vci.corba.omd.data.AttributeValue[valueArry.length]; |
| | | for (int i = 0; i < select.getSelectItems().size(); i++) { |
| | | SelectItem selectItem = select.getSelectItem(i); |
| | | com.vci.corba.omd.data.AttributeValue attributeValue = new com.vci.corba.omd.data.AttributeValue(); |
| | | attributeValue.attrName = selectItem.getAlias().getName(); |
| | | attributeValue.attrVal = valueArry[i]; |
| | | attributeValues[i] = attributeValue; |
| | | } |
| | | clientBusinessObject.getBusinessObject().newAttrValList= attributeValues; |
| | | }catch (Exception e){ |
| | | logger.error("数据解析错误",e); |
| | | return null; |
| | | } |
| | | return clientBusinessObject; |
| | | } |
| | | } |