test.txt
7.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
//保存登录动作
GrasSysOperationLog grasSysOperationLog=new GrasSysOperationLog();
grasSysOperationLog.setUserId(userId);
grasSysOperationLog.setOperation("/gras/login/singleLogin?user="+user+"&passWord="+password);
grasSysOperationLog.setCreatedUser(userId);
grasSysOperationLog.setUpdatedUser(userId);
grasSysOperationLog.setPkSerial(NumberUtil.random10());
grasSysOperationLog.setOperationDate(new Date());
grasSysOperationLogService.addGrasSysOperationLog(grasSysOperationLog);
String userId
operation
operationDate
pkSerial
updatedUser
updatedDate
createdDate
createdUser
/**
* 自动分单
*/
@Override
public void autoAllot() {
//"0005"——动态分单机构参数
GrasSysConfig grasSysConfig=oracleGrasSysConfigService.selectByConfigCode("0005");
if(grasSysConfig==null || grasSysConfig.getconfigOption()==null){
//根据3级机构级别查询机构
assignPolicyByLevel(MyConstant.BRANCH_LEVEL_03);
//根据2级机构级别查询机构
assignPolicyByLevel(MyConstant.BRANCH_LEVEL_02);
//根据1级机构级别查询机构
assignPolicyByLevel(MyConstant.BRANCH_LEVEL_01);
}else{
String[] branchList=grasSysConfig.getconfigOption().split(",");
for (String branchCode : branchList)
{
List<BranchInfo> branchCodeList= branchInfoService.queryBranchByParentBranch(branchCode);
executeAllotByLevel(branchCodeList);
logUtils.info("自动分单 ————试点机构分单:"+branchCode);
}
}
//自动同步
resultCheckService.autoResultBack();
}
private void assignPolicyByLevel(String level){
List<BranchInfo> branchList = branchInfoService.queryBranchByLevel(level);
executeAllotByLevel(branchList);
logUtils.info("自动分单-----分单机构级别:"+level);
}
@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);
rnspi_service_no
service_emp_name
pass:192.168.26.84
ES:http://192.168.26.80:9200
oracle:192.168.26.92:1521
P000000057225826维护给I000000000059079
P000000016509417,P000000046040981,P000000057117527,P000000057563951,P000000057691975 ,P000000016852982
--- 2019-03-21 22:46:06.482045000 Z