瀏覽代碼

bug提交

chenweida 8 年之前
父節點
當前提交
008805426b

+ 1 - 1
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java

@ -18,7 +18,7 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    List<QuartzJobConfig> findByAll(String s);
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' ")
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' order by a.id asc")
    List<QuartzJobConfig> findByIds();
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")

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

@ -45,7 +45,8 @@ public class ElastricSearchSave {
            }
            BulkResult br = jestClient.execute(bulk.build());
            //关闭链接
            jestClient.shutdownClient();
            logger.info("save data count:" + sms.size());
            logger.info("save flag:" + br.isSucceeded());
            return br.isSucceeded();
        } catch (Exception e) {
            logger.error(" save error :" + e.getMessage());

+ 13 - 18
patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java

@ -153,6 +153,11 @@ public class CurrentMysqlToEsQuotaJob implements Job {
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                Thread.sleep(20000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
    }
@ -177,32 +182,22 @@ public class CurrentMysqlToEsQuotaJob implements Job {
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<SaveModel> saveModels = result.getSourceAsObjectList(SaveModel.class);
            //如果之前有值批量更新
            if (saveModels != null && saveModels.size() > 0) {
            List<SaveModel> quarySaveModels = result.getSourceAsObjectList(SaveModel.class);
            //如果之前有值就用查询出来的然后修改数目即可
            if (quarySaveModels != null && quarySaveModels.size() > 0) {
                //list转map
                Map<String, SaveModel> smsMap = new HashMap<>();
                sms.stream().forEach(one -> {
                    smsMap.put(one.getId(), one);
                    smsMap.put(one.getTeam(), one);
                });
                //根据id批量更新
                Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
                for (SaveModel obj : saveModels) {
                    SaveModel newResult = smsMap.get(obj.getId());
                for (SaveModel obj : quarySaveModels) {
                    SaveModel newResult = smsMap.get(obj.getTeam());
                    obj.setResult1(newResult.getResult1());
                    obj.setResult2(newResult.getResult2());
                    Update index = new Update.Builder(obj.getId()).build();
                    bulk.addAction(index);
                }
                BulkResult br = jestClient.execute(bulk.build());
                logger.info("update data count:" + saveModels.size());
                logger.info("update flag:" + br.isSucceeded());
                return br.isSucceeded();
            } else {
                //批量插入
                return saveDate(sms);
                sms=quarySaveModels;
            }
            return saveDate(sms);
        } catch (Exception e) {
            e.printStackTrace();
        }

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

@ -2,6 +2,7 @@ package com.yihu.wlyy.statistics.vo;
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.util.Date;
@ -20,7 +21,7 @@ public class SaveModel {
    private Date quotaDate;//统计时间
    private String city;//城市代码 350200
    
    private String cityName;//
    private String town;//区代码 350206