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
package com.b3.rbl.compensation.rest;
import com.b3.rbl.compensation.model.jbpm.*;
import com.b3.rbl.compensation.service.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.log4j.Log4j2;
import nonapi.io.github.classgraph.json.JSONDeserializer;
import org.apache.tomcat.util.json.JSONParser;
import org.json.simple.JSONObject;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jackson.JsonObjectDeserializer;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.sql.Date;
@Log4j2
@RestController
@RequestMapping("jbpm/")
public class JbpmRestApi {
@Autowired
JbpmService jbpmService;
@Autowired
PaymentService paymentService;
@Autowired
MonthlyBonusService monthlyBonusService;
@Autowired
MonthlyOverridingService monthlyOverridingService;
@Autowired
QuarterlyBonusService quarterlyBonusService;
@Autowired
HealthInsuranceService healthInsuranceService;
ModelMapper modelMapper;
@GetMapping("get-container")
public ResponseEntity<String> getContainerId() {
jbpmService.initialize();
jbpmService.disposeAndCreateContainer();
return ResponseEntity.ok(jbpmService.listContainers());
}
@PostMapping("add-data")
public void insertData(@RequestBody Object result) {
// log.info("result {}", result);
AgentDetailData data = new AgentDetailData();
// data.setAgents((List<AgentResult>) result);
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonResult = objectMapper.writeValueAsString(result);
log.info("json {}", jsonResult);
// Parse the JSON string to List<AgentResult>
List<AgentResult> agents;
agents = objectMapper.readValue(jsonResult, new TypeReference<List<AgentResult>>() {
});
data.setAgents(agents);
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jbpmService.setupData(data);
}
@PostMapping("addmonthly-data")
public void insertMonthlyData(@RequestBody Object result) {
// log.info("result {}", result);
AgentDetailData data = new AgentDetailData();
// data.setAgents((List<AgentResult>) result);
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonResult = objectMapper.writeValueAsString(result);
log.info("json {}", jsonResult);
// Parse the JSON string to List<AgentResult>
List<AgentResult> agents;
agents = objectMapper.readValue(jsonResult, new TypeReference<List<AgentResult>>() {
});
data.setAgents(agents);
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (data.getAgents().size() > 0) {
monthlyBonusService.setupMonthlyData(data);
}
}
@PostMapping("addhealthinsurance-data")
public void insertHealthInsuranceData(@RequestBody Object result) {
// log.info("result {}", result);
AgentDetailData data = new AgentDetailData();
// data.setAgents((List<AgentResult>) result);
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonResult = objectMapper.writeValueAsString(result);
log.info("json {}", jsonResult);
// Parse the JSON string to List<AgentResult>
List<AgentResult> agents;
agents = objectMapper.readValue(jsonResult, new TypeReference<List<AgentResult>>() {
});
data.setAgents(agents);
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
healthInsuranceService.setupHealthInsuranceData(data);
}
@PostMapping("quarterlyBonus-addata")
public void insertQuarterlyData(@RequestBody Object result) {
// log.info("result {}", result);
AgentDetailData data = new AgentDetailData();
// data.setAgents((List<AgentResult>) result);
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonResult = objectMapper.writeValueAsString(result);
// log.info("json {}", jsonResult);
// Parse the JSON string to List<AgentResult>
List<AgentResult> agents;
agents = objectMapper.readValue(jsonResult, new TypeReference<List<AgentResult>>() {
});
data.setAgents(agents);
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(data.getAgents().size() > 0 ){
quarterlyBonusService.setupQuarterlyData(data);
}
}
// @PostMapping("execute-rule")
// public ResponseEntity<IncomeDetails> executeRule(@RequestBody IncomeDetails
// incomeDetails){
// jbpmService.initialize();
// jbpmService.disposeAndCreateContainer();
// return ResponseEntity.ok(jbpmService.executeCommands(incomeDetails));
// }
@PostMapping("execute-business-process")
public ResponseEntity<String> executeBusinessProcess(@RequestParam(name = "scheduleDate") String scheduleDate)
throws JsonProcessingException {
jbpmService.initialize();
log.info("schedule {}", scheduleDate);
paymentService.getDataTax(scheduleDate);
// jbpmService.getDataTax(scheduleDate);
// jbpmService.disposeAndCreateContainer();
// jbpmService.calculationFyc(agents);
// jbpmService.executeBusinessProcess(agents);
return ResponseEntity.ok().body("Processing Success");
}
@PostMapping("execute-business-process/monthly")
public ResponseEntity<String> executeBusinessProcess(@RequestParam(name = "startdate") Date startdate,
@RequestParam(name = "enddate") Date enddate) throws JsonProcessingException {
monthlyBonusService.initialize();
log.info("startdate {}", startdate);
log.info("enddate {}", enddate);
monthlyBonusService.getDataMonthlyBonus(startdate, enddate);
return ResponseEntity.ok().body("Success");
}
@PostMapping("execute-business-process/monthly-overriding")
public ResponseEntity<String> executeMonthlyOverridingProcess(@RequestParam(name = "startDate") Date startDate,
@RequestParam(name = "endDate") Date endDate) throws JsonProcessingException {
monthlyOverridingService.initialize();
monthlyOverridingService.getFycRycAmount(startDate, endDate);
return ResponseEntity.ok().body("Success");
}
@PostMapping("insert-monthly-overriding")
public void insertMonthlyOverriding(@RequestBody Object result) {
// log.info("result {}", result);
AgentDetailData data = new AgentDetailData();
ObjectMapper objectMapper = new ObjectMapper();
try {
String jsonResult = objectMapper.writeValueAsString(result);
// log.info("json {}", jsonResult);
// Parse the JSON string to List<AgentResult>
List<AgentResult> agents;
agents = objectMapper.readValue(jsonResult, new TypeReference<List<AgentResult>>() {
});
data.setAgents(agents);
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
monthlyOverridingService.setupData(data);
}
@PostMapping("execute-business-process/quarterly-bonus")
public ResponseEntity<String> executeQuarterlyBonusProcess(@RequestParam(name = "startdate") Date startdate, @RequestParam(name = "enddate") Date enddate)
throws JsonProcessingException {
quarterlyBonusService.initialize();
log.info("startdate {}", startdate);
log.info("enddate {}", enddate);
if (startdate != null && enddate != null) {
Calendar startdateCal = Calendar.getInstance();
startdateCal.setTime(startdate);
Calendar enddateCal = Calendar.getInstance();
enddateCal.setTime(enddate);
int monthDiff = (enddateCal.get(Calendar.MONTH) - startdateCal.get(Calendar.MONTH)) + 1;
if ( monthDiff == 3) {
//quarterlyBonusService.getDataQuarterlyBonus(startdate, enddate);
quarterlyBonusService.getDataQuarterlyTeamBonus(startdate, enddate);
//quarterlyBonusService.getDataQuarterlyTeamSDBonus(startdate, enddate);
return ResponseEntity.ok().body("Success");
} else {
return ResponseEntity.badRequest().body("Invalid date range 3 month");
}
}else {
return ResponseEntity.badRequest().body("Invalid date input");
}
}
@PostMapping("execute-business-process/healthInsuranceIndividual")
public ResponseEntity<String> executeBusinessProcessHealthInsuranceIndividual(@RequestParam(name = "startDate") Date startDate, @RequestParam(name = "endDate") Date endDate)
throws JsonProcessingException {
healthInsuranceService.initialize();
log.info("startDate {}", startDate);
log.info("endDate {}", endDate);
healthInsuranceService.getDataHealthInsuranceIndividual(startDate, endDate);
return ResponseEntity.ok().body("Processing Success");
}
@PostMapping("execute-business-process/healthInsuranceTeam")
public ResponseEntity<String> executeBusinessProcessHealthInsuranceTeam(@RequestParam(name = "startDate") Date startDate, @RequestParam(name = "endDate") Date endDate)
throws JsonProcessingException {
healthInsuranceService.initialize();
log.info("startDate {}", startDate);
log.info("endDate {}", endDate);
healthInsuranceService.getDataHealthInsuranceTeam(startDate, endDate);
return ResponseEntity.ok().body("Processing Success");
}
@PostMapping("excecute-debt-process")
public ResponseEntity<String> executeDebtProcess(@RequestParam(name = "scheduleDate") String scheduleDate) {
paymentService.getDataDebt(scheduleDate);
return ResponseEntity.ok().body("Processing Success");
}
@GetMapping("get-Hello-World")
public ResponseEntity<String> getHelloWorld() {
return ResponseEntity.ok(jbpmService.getHelloWorld());
}
}