Explorar o código

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida %!s(int64=7) %!d(string=hai) anos
pai
achega
5945246f26

+ 13 - 5
patient-co/patient-co-statistics-es/doc/es/统计新增索引.txt

@ -1,11 +1,11 @@
创建索引
POST  http://172.19.103.68:9200/wlyy_quota_test
POST  http://172.19.103.68:9200/wlyy_quota_cwd
查询索引
GET http://172.19.103.68:9200/wlyy_quota_test/
GET http://172.19.103.68:9200/wlyy_quota_cwd/
给索引加mapping
POST http://172.19.103.68:9200/wlyy_quota_test/wlyy_quota_test/_mapping
POST http://172.19.103.68:9200/wlyy_quota_cwd/wlyy_quota_cwd/_mapping
{
    "wlyy_quota_test": {
    "wlyy_quota_cwd": {
            "properties": {
                "quotaCode": {
                    "type": "string",
@ -97,4 +97,12 @@ POST http://172.19.103.68:9200/wlyy_quota_test/wlyy_quota_test/_mapping
                }
            }
        }
  }
  }
增加索引搜索大小
PUT  http://172.19.103.68:9200/wlyy_quota_cwd/_settings
{
  "index": {
    "max_result_window": 500000
  }
}

+ 5 - 0
patient-co/patient-co-statistics-es/pom.xml

@ -449,6 +449,11 @@
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.17</version>
        </dependency>
    </dependencies>
    <build>

+ 20 - 12
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/save/es/ElastricSearchSave.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.statistics.etl.save.es;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestResult;
@ -7,7 +8,6 @@ import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import io.searchbox.core.Update;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -54,9 +54,9 @@ public class ElastricSearchSave {
                }
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("update flag:" + br.isSucceeded());
            logger.info("update success:" + success);
            logger.info("update error:" + error);
            logger.info("save flag:" + br.isSucceeded());
            logger.info("save success:" + success);
            logger.info("save error:" + error);
            return br.isSucceeded();
        } catch (Exception e) {
            logger.error(" save error :" + e.getMessage());
@ -84,22 +84,30 @@ public class ElastricSearchSave {
//                    error++;
//                }
//            }
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (SaveModel obj : sms) {
                try {
                    JSONObject jo=new JSONObject();
                    obj.setCreateTime(new Date());
                    Update index = new Update.Builder(obj).index(esIndex).type(esType).id(obj.getId()).build();
                    JestResult result = jestClient.execute(index);
                    if (result.isSucceeded()) {
                        success++;
                    } else {
                        error++;
                        isSuccessed = false;
                    }
                    jo.put("doc",obj);
                    Update index = new Update.Builder(jo.toString()).index(esIndex).type(esType).id(obj.getId()).build();
                    bulk.addAction(index);
                  //  JestResult result = jestClient.execute(index);
//                    if (result.isSucceeded()) {
//                        success++;
//                    } else {
//                        error++;
//                        isSuccessed = false;
//                    }
                } catch (Exception e) {
                    error++;
                    isSuccessed = false;
                }
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("update flag:" + br.isSucceeded());
            logger.info("update success:" + success);
            logger.info("update error:" + error);
            return isSuccessed;

+ 10 - 5
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/vo/SaveModel.java

@ -1,10 +1,12 @@
package com.yihu.wlyy.statistics.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.searchbox.annotations.JestId;
import org.elasticsearch.index.analysis.AnalysisSettingsRequired;
import org.springframework.data.annotation.CreatedDate;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -18,9 +20,9 @@ public class SaveModel {
    private final static String townKey = "town";
    private final static String cityKey = "city";
    public final static String interval_day="1";
    public final static String interval_week="2";
    public final static String interval_month="3";
    public final static String interval_day = "1";
    public final static String interval_week = "2";
    public final static String interval_month = "3";
    public final static String teamLevel = "5";
    public final static String OrgLevel = "4";
@ -35,6 +37,9 @@ public class SaveModel {
    private String quotaCode;//指标code
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssXX")
    @CreatedDate
    @JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXX")
    private Date quotaDate;//统计时间
    private String city;//城市代码 350200
@ -74,13 +79,13 @@ public class SaveModel {
    private Integer result2 = 0;//统计结果  次数
    private String areaLevel;// 1 省 2 市 3 区县 4 机构 5团队
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssXX")
    @CreatedDate
    @JSONField(format = "yyyy-MM-dd'T'HH:mm:ssXX")
    private Date createTime;//创建时间
    private String timeLevel;// 1日 2年
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd ")
    public Date getQuotaDate() {
        return quotaDate;
    }