Browse Source

Merge branch 'master' of lyr/esb into master

esb 9 years ago
parent
commit
9784f57f59

+ 96 - 2
Hos-resource/src/main/java/com/yihu/ehr/datacollect/service/DatacollectService.java

@ -45,6 +45,8 @@ import javax.xml.namespace.QName;
import java.io.ByteArrayInputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -332,6 +334,98 @@ public class DatacollectService implements IDatacollectService {
        return "";
    }
    /**
     * 获取条件SQL
     * @param dbType
     * @param conditionString
     * @return
     * @throws ParseException
     */
    private String getConditionSql(DBType dbType,String conditionString) throws ParseException {
        String conditionSql = "";
        JSONArray conditions = new JSONArray(conditionString);
        Iterator iterator = conditions.iterator();
        while (iterator.hasNext())
        {
            JSONObject condition = (JSONObject)iterator.next();
            String logic = condition.getString("condition");
            String andOr = condition.getString("andOr");
            String field = condition.getString("field");
            String value = condition.getString("value");
            String fieldType = condition.getString("type");
            String keys = "";
            if(andOr.equals(" AND "))
            {
                conditionSql = conditionSql + " and ";
            }
            else
            {
                conditionSql = conditionSql + " or ";
            }
            if(logic.equals(" IN ") || logic.equals(" NOT IN "))
            {
                String[] keywords = value.split(",");
                for(String key : keywords)
                {
                    keys += "'" + key + "',";
                }
                keys = " (" + keys.substring(0,keys.length() - 1) + ") ";
            }
            else if(logic.equals(" LIKE "))
            {
                keys += " '%" + value + "%' ";
            }
            else
            {
                if(fieldType.equals("DATE"))
                {
                    keys  += getDateFormatSql(dbType,value);
                }
                else
                {
                    keys += " '" + value + "' ";
                }
            }
            conditionSql += field + logic + keys;
        }
        return conditionSql;
    }
    /**
     * 获取对应数据库时间格式
     * @param dbType
     * @param key
     * @return
     * @throws ParseException
     */
    private String getDateFormatSql(DBType dbType,String key) throws ParseException {
        String dateFormat = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
        Date d = formatDate.parse(key);
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        switch (dbType)
        {
            case Oracle:
                key = "to_date(\'" + format.format(d) + "\',\'YYYY-MM-DD HH24:MI:SS\')";
                break;
            case Sqlserver:
                break;
            default:
                key = "date_format(\'" + format.format(d) + "\',\'%y-%m-%d %T\')";
        }
        return key;
    }
    /**
     * 采集入库
     * @return
@ -430,7 +524,7 @@ public class DatacollectService implements IDatacollectService {
                //采集范围
                if(condition!=null && condition.length()>0)
                {
                    strWhere += getCondition(dbType,condition);
                    strWhere += getConditionSql(dbType,condition);
                }
                //增量采集
                String maxKey = "0";
@ -655,7 +749,7 @@ public class DatacollectService implements IDatacollectService {
                    String strWhere = " where 1=1";
                    //采集范围
                    if (condition != null && condition.length() > 0) {
                        strWhere += getCondition(dbType, condition);
                        strWhere += getConditionSql(dbType, condition);
                    }
                    //增量采集
                    String maxKey = "0";

+ 8 - 0
Hos-resource/src/main/webapp/develop/lib/ligerui/custom/ligerEx.js

@ -156,8 +156,11 @@
                    }
                    var field = $("#"+fieldControlId).ligerComboBox("getValue");
                    var condition = $("#"+conditionControlId).ligerComboBox("getValue");
                    debugger
                    var value = $("#"+valueControlId).val();
                    var type = $("#"+valueControlId+"_div").attr("controlType");
                    var selFieldData = $("#"+fieldControlId).ligerComboBox("getSelected");
                    var fieldType = "";
                    if(type == "combobox")
                    {
                        value = $("#"+valueControlId).ligerComboBox("getValue");
@ -166,10 +169,15 @@
                        value = $("#"+valueControlId).ligerMultbox("getValue");
                    }
                    if(selFieldData && selFieldData.type){
                        fieldType = selFieldData.type;
                    }
                    if(andOr.length>0 && field.length>0 && condition.length>0 && value.length>0)
                    {
                        o+='andOr:"'+andOr+'",';
                        o+='field:"'+field+'",';
                        o+='type:"' + fieldType + '",';
                        o+='condition:"'+condition+'",';
                        o+='value:"'+value+'"';
                        o+='}';