test.txt
13.1 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
and po.duty_status='1'
select
rpsi.POLICY_NO policyNo,rpsi.service_no servicerNo,po.BRANCH_CODE branchCode,si.EMP_NAME empName,
po.CHANNEL_TYPE AS channelType,bi.BRANCH_NAME branchName,ppi.PREM_DUE_DATE premDate,ctl.DESCRIPTION AS description
from policy po
inner join rn_policy_service_info rpsi on rpsi.policy_no=po.policy_no
inner join branch_code_relation bcr on bcr.branch_code=po.branch_code
inner join policy_product pp on pp.policy_no=po.policy_no and pp.prod_seq='1'
inner join policy_prem_info ppi on ppi.policy_no =po.policy_no
inner join staff_info si on si.emp_no = rpsi.service_no
inner join CHANNEL_TYPE_TBL CTL on CTL.CHANNEL_TYPE = PO.CHANNEL_TYPE
inner join branch_info bi on bi.branch_code = po.branch_code
left join gras_assign_failed_record gfr on gfr.policy_no=rpsi.policy_no and gfr.is_valid='Y'
where
bcr.relative_grade>-1
and gfr.policy_no is null
and ppi.prem_status='1'
and ppi.prem_source='1'
and po.duty_status='1'
and(rpsi.assign_rule IN ('01', '02') OR rpsi.assign_rule IS NULL)
and pp.product_code not in('CBAN_TN1','CBAN_UN1','CBAN_VN1')
and bcr.relative_branch_code = #{branchCode,jdbcType=VARCHAR}
AND ppi.PREM_DUE_DATE >= "TO_DATE"(#{nowMonth},'yyyy-MM-dd hh24:mi:ss')
AND ppi.PREM_DUE_DATE < "TO_DATE"(#{nextMonth},'yyyy-MM-dd hh24:mi:ss')
private boolean checkAssessmentPeriod(int premDueYear, int premDueMonth)
{
//例如:当前5月份操作离职交接时,只对应缴月在3月、4月、5月的保单进行规则校验
Date nowDate=DateUtil.getNowDate();
int nowYear=DateUtil.getYear(nowDate);
int nowMonth=DateUtil.getMonth(nowDate);
//最小月
Date earliestDate=DateUtil.getDateMonthFormat(DateUtil.getDateMonthFormat(DateUtil.getFirstMonth(3)));
int earliestYear=DateUtil.getYear(earliestDate);
int earliestMonth=DateUtil.getMonth(earliestDate);
//同年 当前:2019-4 最小月:2019-1 应缴月:2019-3
if(earliestYear==nowYear){
//同年 : 小于等于当前月 && 大于最小月 --3月小于5月,大于2月
if(nowYear==premDueYear && premDueMonth<=nowMonth && premDueMonth>earliestMonth){
return true;
}
}
//不同年
if(earliestYear<nowYear){
//当前:2019-3 最小月:2018-12 应缴月:2019-3
//应缴月与当前时间同年 && 应缴月小于等于当前月
if(nowYear==premDueYear && premDueMonth<=nowMonth){
return true;
}
//应缴月与最小月同年 && 应缴月大于最小月
if(nowYear==earliestYear && premDueMonth>earliestMonth){
return true;
}
}
return false;
}
policySuccessList=quitAssign(policyNoList,policyList,policyFailedList,failedList);
private List<Map<String, String>> quitAssign(List<String> policyNoList, List<JSONObject> policyList, List<Map<String,String>> policyFailedList,Set<String> failedList)
//错误信息
Map<String,String> policyFailedMap = null;
failedList.add(policyNo);
policyNoList.remove(policyNo);
policyFailedMap = new HashMap<>();
policyFailedMap.put("policyNo", policyNo);
policyFailedMap.put("servicerNo", servicerNo);
policyFailedMap.put("cause", "离职人员下同一应缴月下的保单只能分配给一个人");
policyFailedList.add(policyFailedMap);
break;
//情况二:若保单交出服务人员和该保单现服务人员相同,则说明之前有发生过保单离职交接,那根据一个月中只能分给同一个服务人员原则,那只能分配给接收服务人员
//处理脏数据
//如果离职后调整的服务人员也处于离职状态的话,则允许此次操作
StaffInfo staffInfo1 = staffInfoService.selectByPrimaryKey(record.getNextAgent());
//若是离职,则不可调整 break
if(staffInfo1 != null && staffInfo1.getLeaveDate() == null){
failedList.add(policyNo);
policyNoList.remove(policyNo);
policyFailedMap = new HashMap<>();
policyFailedMap.put("policyNo", policyNo);
policyFailedMap.put("servicerNo", servicerNo);
policyFailedMap.put("cause", "离职人员下同一应缴月下的保单只能分配给一个人");
policyFailedList.add(policyFailedMap);
break;
}
PosLapsePolicyMapper
<select id="selectByPolicyNoAndProSeq" resultMap="BaseResultMap">
select * from (
SELECT <include refid="Base_Column_List" />
FROM POS_LAPSE_POLICY
WHERE policy_no = #{policyNo,jdbcType=VARCHAR} and PROD_SEQ = #{prodSeq,jdbcType=DECIMAL}
and IS_REINSTATEMENT='N'
order by LAPSE_DATE DESC
)
where rownum=1
addDate(date, days) {
if (days == undefined || days == '') {
days = 1;
}
var date = new Date(date);
date.setDate(date.getDate() + days);
var month = date.getMonth() + 1;
return date.getFullYear()+'-'+month+'-'+date.getDate();
}
nextDate=this.addDate(nextDate.substring(0, 10),1);
var date = new Date(dueDate.substring(0,10));
date.setDate(date.getDate() + 1);
var month = date.getMonth() + 1;
dueDate = date.getFullYear()+ '-' + month + '-' + date.getDate();
to_char(ppi.prem_due_date,'yyyy-mm-dd') || 'T' || to_char(ppi.prem_due_date,'hh24:mi:ss') || '+0800' AS pp_prem_due_date,
/**
* 自动分单
*/
@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