1、增加sql查询出的数组与查询字段的对应转成ClientBusinessObject类,以及部分基础类的替换成新平台的类。
已修改1个文件
69 ■■■■■ 文件已修改
Source/platformProject/vci-platform-web/src/main/java/com/vci/web/util/WebUtil.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/platformProject/vci-platform-web/src/main/java/com/vci/web/util/WebUtil.java
@@ -20,6 +20,9 @@
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;
@@ -1077,7 +1080,7 @@
     * @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);
        }
@@ -1089,7 +1092,7 @@
     * @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);
        }
@@ -1141,7 +1144,7 @@
     * @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);
    }
@@ -1151,14 +1154,14 @@
     * @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());
    
@@ -1175,7 +1178,7 @@
            }
            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);
@@ -1193,7 +1196,7 @@
            }
            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){
@@ -1217,7 +1220,7 @@
     * @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);
        }
@@ -1228,21 +1231,21 @@
     * @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);
                }
@@ -1255,7 +1258,7 @@
     * @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);
        }
@@ -1266,24 +1269,24 @@
     * @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);
                }
@@ -1350,7 +1353,7 @@
     * @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()){
@@ -1654,14 +1657,14 @@
     * @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<>();
@@ -1723,4 +1726,24 @@
        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;
    }
}