Commit 28d24b68 by 傅伟强-富德

Update test.txt

1 parent 6bd88b87
Showing with 104 additions and 6 deletions
......@@ -95,10 +95,108 @@
}
select
<include refid="Base_Column_List_SELF"/>
from BRANCH_INFO bi
where (bi.PARENT_BRANCH = #{branchCode,jdbcType=VARCHAR}
OR bi.BRANCH_CODE = #{branchCode,jdbcType=VARCHAR})
and bi.IS_VALID = 'Y'
@Override
public List<JSONObject> testSearch(List<JSONObject> jsonObject){
SearchSourceBuilder searchSourceBuilder=new SearchSourceBuilder();
BoolQueryBuilder boolQuery=new BoolQueryBuilder();
//AggregationBuilder aggregationBuilder = AggregationBuilders.cardinality("distinct").field("po_policy_no");
List<JSONObject> resultList=new ArrayList<JSONObject>();
for (JSONObject jsonObject2 : jsonObject)
{
String policyNos = jsonObject2.getString("policyNo");
//aggregationBuilder = AggregationBuilders.cardinality("distinct").field("_id");
boolQuery.filter(QueryBuilders.termsQuery("po_policy_no",policyNos));
//boolQuery.filter(QueryBuilders.termQuery("pp_prod_seq", "2"));
SumAggregationBuilder pp_modal_total_prem = AggregationBuilders.sum("pp_modal_total_prem").field("pp_modal_total_prem");
searchSourceBuilder.query(boolQuery).aggregation(pp_modal_total_prem);
try{
Search search=new Search.Builder(searchSourceBuilder.toString())
.addIndex("policyproinfo").addType(MyConstant.ES_TYPE)
.setParameter(Parameters.SIZE,8000).setParameter(Parameters.SCROLL,"5m")
.build();
//执行查询
logUtils.info("统计数据查询语句:"+searchSourceBuilder.toString());
JestResult result = client.execute(search);
// handleResult(resultList, result);
System.out.println(result);
List<JSONObject> selectList = result.getSourceAsObjectList(JSONObject.class);
//第一次查询的结果要先处理
for (JSONObject object : selectList) {
object.put("service_emp_no", jsonObject2.getString("servicerNo"));
object.put("rnpsi_assign_mode", jsonObject2.getString("assignRule"));
object.put("rnpsi_last_assign_user", jsonObject2.getString("lastAssignUser"));
//object.put("rnpsi_last_assign_date", DateUtil.getDateTimeFormat(jsonObject2.getString("lastAssignDate")));
bir=new Date();
System.out.println(bir);
//object.put("rnpsi_last_assign_date", bir);
object.put("rnpsi_orphan_mark", "0");
resultList.add(object);
}
}catch (Exception e){
logUtils.error(e);
}
}
System.out.println(insertBulk1(resultList));
return resultList;
}
private boolean insertBulk1(Object object)
{
//是否批量插入的判断
if (object.getClass().equals(List.class) || object.getClass().equals(ArrayList.class))
{
List<JSONObject> realObj = (List) object;
//构建批量插入的操作类 bulk 索引根据类名小写 type设定为doc
//最新的es里面可能会废除type的设定 一个index就装一种类型的对象
try
{
Bulk.Builder bulk = new Bulk.Builder();
//构造批量数据
for (JSONObject jsonObject :realObj){
System.out.println("参数:"+jsonObject);
String id=jsonObject.getString("po_policy_no")+"+"+String.valueOf(jsonObject.getInteger("pp_prod_seq"));
System.out.println("id:"+id);
Index index = new Index.Builder(jsonObject).index("policyproinfo").type(MyConstant.ES_TYPE).id(id).build();
bulk.addAction(index);
}
//执行结果
return client.execute(bulk.build()).isSucceeded();
}
catch (IOException e)
{
logUtils.error(e.getMessage());
return false;
}
}
return false;
}
JSONObject jsonObject=new JSONObject();
List<JSONObject> policyNolist=new ArrayList<JSONObject>();
for (Object object : paramArray)
{
jsonObject=(JSONObject)object;
for(String policyNo:policys){
if(policyNo.equals(jsonObject.get("policyNo"))){
policyNolist.add(jsonObject);
break;
}
}
}
//更新es
testSearch(policyNolist);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!