zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
package cn.autoform.web.client.impl;
 
import cn.autoform.bean.*;
import cn.autoform.bean.page.PageResult;
import cn.autoform.bean.power.PowerButton;
import cn.autoform.bean.system.UserInfo;
import cn.autoform.db.entity.IpAndPortEntity;
import cn.autoform.db.exten.SelectForm;
import cn.autoform.db.exten.ServicesFormData;
import cn.autoform.db.exten.TableStructure;
import cn.autoform.fw.exception.FormClientException;
import cn.autoform.fw.exception.FormClientTimeout;
import cn.autoform.fw.exception.RestResult;
import cn.autoform.log.bean.OperationLog;
import cn.autoform.util.tool.GetFormClientResult;
import cn.autoform.util.tool.JSONTool;
import cn.autoform.util.tool.ObjectUtil;
import cn.autoform.util.tool.RequestContext;
import cn.autoform.web.client.FormClient;
import cn.autoform.web.client.util.HttpClientTool;
import cn.autoform.web.client.util.IpAndPortTool;
import com.alibaba.fastjson.TypeReference;
import com.iemsoft.framework.cloud.core.tools.http.Http;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
 
import java.util.*;
import java.util.concurrent.TimeoutException;
 
@Service
public class FormClientImpl implements FormClient {
 
    @Value("${autoForm.businessSystem}")
    private String autoFormClient;
 
    @Autowired
    IpAndPortTool ipAndPortTool;
 
    private static final Map<String, String> ipMap = new HashMap<>();
 
    public static final String CLIENT_CONTEXT_PATH = "/auto-form-client";
 
    static {
        ipMap.put("dataInsert", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/insert");
        ipMap.put("impDatas", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/impDatas");
        ipMap.put("dataUpdate", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/update");
        ipMap.put("dataDelete", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/delete");
        ipMap.put("dataSelectAll", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/selectAll");
        ipMap.put("dataSelectPage", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/selectPage");
        ipMap.put("dataSelectOne", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/selectOne");
        ipMap.put("createTable", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/create/table");
        ipMap.put("updateTable", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/update/table");
        ipMap.put("selectFormValue", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/select/formFieldMainValue");
        ipMap.put("getAssociateDataSourse", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/select/associateDataSourse");
        ipMap.put("getAssociateData", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/select/associateData");
        ipMap.put("getAssociateTitle", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/select/associateTitle");
        ipMap.put("operationLog", "%s/epc/epc-form" + "/form/operationLog");
 
        ipMap.put("workFlowOver", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/WorkFlow/over");
        ipMap.put("workFlowBefor", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/WorkFlow/befor");
        ipMap.put("workFlowAfter", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/WorkFlow/after");
        ipMap.put("workFlowRollback", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/WorkFlow/rollback");
        ipMap.put("workFlowCreate", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/WorkFlow/create");
 
        ipMap.put("budget", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/form/data/budget");
        ipMap.put("getUserInfo", "%s/epc/epc-tenant/tenant/getUserCode");
//        ipMap.put("getHigorg", "%s/epc/epc-tenant/tenant/data/budget");
        ipMap.put("getCode", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/select/higCode");
        ipMap.put("getUserName", "%s/epc/epc-form" + CLIENT_CONTEXT_PATH + "/data/getUserName");
        ipMap.put("updateState", "%s/epc/epc-form/form/data/updateState"); //费用云内部请求
        ipMap.put("selectState", "%s/epc/epc-form/form/data/selectState"); //费用云内部请求
        ipMap.put("getAllButton", "%s/epc/epc-form/form/button/getAllButton");//费用云 自定义按钮权限
        ipMap.put("formSolidiFication", "%s/epc/epc-form/data/formSolidiFication");//单据固化
        ipMap.put("addExcelLog", "%s/epc/epc-form/form/excel/addExcelLog");
        ipMap.put("updateExcelLog", "%s/epc/epc-form/form/excel/updateExcelLog");
        ipMap.put("selectLog", "%s/epc/epc-form/form/select/operationLog");//操作日志查询接口
//        ipMap.put("dataInsert", "%s/data/insert");
//        ipMap.put("dataUpdate", "%s/data/update");
//        ipMap.put("dataDelete", "%s/data/delete");
//        ipMap.put("dataSelectAll", "%s/data/selectAll");
//        ipMap.put("dataSelectPage", "%s/data/selectPage");
//        ipMap.put("dataSelectOne", "%s/data/selectOne");
//        ipMap.put("createTable", "%s/create/table");
//        ipMap.put("updateTable", "%s/update/table");
//        ipMap.put("selectFormValue", "%s/select/formFieldMainValue");
//        ipMap.put("getAssociateDataSourse", "%s/select/associateDataSourse");
//        ipMap.put("getAssociateData", "%s/select/associateData");
//        ipMap.put("getAssociateTitle", "%s/select/associateTitle");
    }
 
    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public Object addFormDataClient(ServicesFormData formData) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult> hc = new HttpClientTool(String.format(ipMap.get("dataInsert"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(formData);
        RestResult result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public PageResult<List<OperationLog>> selectOperationLog(Map<String,Object> map) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult> hc = new HttpClientTool(String.format(ipMap.get("selectLog"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(map);
        RestResult result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
    @Override
    public Object addOperationLog(Map<String,String> map) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult> hc = new HttpClientTool(String.format(ipMap.get("operationLog"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(map);
        RestResult result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public String mmp(String org) throws TimeoutException, FormClientException {
        Map<String, String> map = new HashMap<String, String>();
        map.put("code", org);
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult> hc = new HttpClientTool(String.format(ipMap.get("getCode"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(map);
        RestResult result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult>() {
                }));
        Map<String, Object> res = JSONTool.toObj(JSONTool.toJson(result.getData()), Map.class);
        Object a = res.get("data");
        if (a != null) {
            Map<String, String> orgs = JSONTool.toObj(JSONTool.toJson(a), Map.class);
            return orgs.get("parentCode");
        }
        return null;
    }
 
    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public void updateFormDataClient(ServicesFormData formData) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult> hc = new HttpClientTool(String.format(ipMap.get("dataUpdate"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(formData);
        System.out.println("回写状态:" + JSONTool.toJson(formData));
        RestResult result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult>() {
                }));
        GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public void deleteFormDataClient(ServicesFormData formData) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult> hc = new HttpClientTool(String.format(ipMap.get("dataDelete"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(formData);
        RestResult result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult>() {
                }));
        GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public List<Map<String, Object>> queryFormDataList(SelectForm selectForm) throws FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<List<Map<String, Object>>>> hc = new HttpClientTool(String.format(ipMap.get("dataSelectAll"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(selectForm);
        RestResult<List<Map<String, Object>>> result;
        try {
            result = hc.sendPost(
                    j -> JSONTool.toObj(j, new TypeReference<RestResult<List<Map<String, Object>>>>() {
                    }));
            return GetFormClientResult.getRightResult(result);
        } catch (TimeoutException e) {
            throw new FormClientTimeout();
        }
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public Map<String, Object> queryFormDataOne(SelectForm selectForm) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<Map<String, Object>>> hc = new HttpClientTool(String.format(ipMap.get("dataSelectOne"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(selectForm);
        RestResult<Map<String, Object>> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<Map<String, Object>>>() {
                }.getType()));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public PageResult<Map<String, Object>> queryFormDataPage(SelectForm selectForm) throws FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<PageResult<Map<String, Object>>>> hc = new HttpClientTool(String.format(ipMap.get("dataSelectPage"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(selectForm);
        try {
            return GetFormClientResult.getRightResult(hc.sendPost(
                    j -> JSONTool.toObj(j, new TypeReference<RestResult<PageResult<Map<String, Object>>>>() {
                    })));
        } catch (TimeoutException e) {
            e.printStackTrace();
            throw new FormClientTimeout();
        }
 
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public void createTable(TableStructure tableStructure) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
//        System.out.println(JSONTool.toJson(tableStructure));
//        System.out.println(String.format(ipMap.get("createTable"), ipAndPortEntity.getIp()));
        HttpClientTool<RestResult<Integer>> hc = new HttpClientTool(String.format(ipMap.get("createTable"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(tableStructure);
        GetFormClientResult.getRightResult(hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<Integer>>() {
                })));
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public void updateTable(TableStructure tableStructure) throws Exception {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<Integer>> hc = new HttpClientTool(String.format(ipMap.get("updateTable"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(tableStructure);
        hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<Integer>>() {
                }));
//         GetFormClientResult.getRightResult();
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public List<String> getFormFieldMainValue(String field, String tableName, String formID, String tenantID) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<List<String>>> hc = new HttpClientTool(String.format(ipMap.get("selectFormValue"), ipAndPortEntity.getIp()));
        Map<String, String> BodyInfos = new HashMap<>();
        BodyInfos.put("field", field);
        BodyInfos.put("tableName", tableName);
        hc.setBodyInfos(BodyInfos);
        RestResult<List<String>> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<List<String>>>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"rawtypes", "unchecked"})
    @Override
    public List<Map<String, Object>> getAssociateDataSourse() throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<List<Map<String, Object>>>> hc = new HttpClientTool(String.format(ipMap.get("getAssociateDataSourse"), ipAndPortEntity.getIp()));
        RestResult<List<Map<String, Object>>> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<List<Map<String, Object>>>>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public Map<String, Object> getAssociateData(BudgetData budgetData) throws TimeoutException, FormClientException {
        System.err.println(JSONTool.toJson(budgetData));
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<RestResult<Map<String, Object>>> hc = new HttpClientTool(String.format(ipMap.get("getAssociateData"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(budgetData);
        RestResult<Map<String, Object>> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<Map<String, Object>>>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings("rawtypes")
    @Override
    public List<BudgetTitle> getAssociateTitle(Map<String, Object> key) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        @SuppressWarnings("unchecked")
        HttpClientTool<RestResult<List<BudgetTitle>>> hc = new HttpClientTool(String.format(ipMap.get("getAssociateTitle"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(key);
        RestResult<List<BudgetTitle>> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<List<BudgetTitle>>>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings("rawtypes")
    @Override
    public Object getBudget(ProcessBudget processBudget) throws TimeoutException, FormClientException {
        System.err.println(JSONTool.toJson(processBudget));
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        @SuppressWarnings("unchecked")
        HttpClientTool<RestResult<Object>> hc = new HttpClientTool(String.format(ipMap.get("budget"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(processBudget);
        RestResult<Object> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<Object>>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    public void workFlowOver(WorkFlowStateEntity workFlowStateEntity) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        RestResult<Object> result = (RestResult<Object>)
                Http.post(String.format(ipMap.get("workFlowOver"), ipAndPortEntity.getIp()), RestResult.class)
                        .addBody(workFlowStateEntity)
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<RestResult<Object>>() {
                        }.getType())
                        .orElse(RestResult.newInstance());
        GetFormClientResult.getRightResult(result);
 
    }
 
    @Override
    public void workFlowAfter(WorkFlowStateEntity workFlowStateEntity) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        RestResult<Object> result = (RestResult<Object>)
                Http.post(String.format(ipMap.get("workFlowAfter"), ipAndPortEntity.getIp()), RestResult.class)
                        .addBody(workFlowStateEntity)
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<RestResult<Object>>() {
                        }.getType())
                        .orElse(RestResult.newInstance());
        GetFormClientResult.getRightResult(result);
    }
 
    @Override
    public void workFlowBefor(WorkFlowStateEntity workFlowStateEntity) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        RestResult<Object> result = (RestResult<Object>)
                Http.post(String.format(ipMap.get("workFlowBefor"), ipAndPortEntity.getIp()), RestResult.class)
                        .addBody(workFlowStateEntity)
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<RestResult<Object>>() {
                        }.getType())
                        .orElse(RestResult.newInstance());
        GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings("rawtypes")
    @Override
    public String getUserName(String formID, String tenantID, Integer dataRowNum) throws TimeoutException, FormClientException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        @SuppressWarnings("unchecked")
        HttpClientTool<RestResult<String>> hc = new HttpClientTool(String.format(ipMap.get("getUserName"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(new ModelMap("formID", formID)
                .addAttribute("tenantID", tenantID)
                .addAttribute("dataRowNum", dataRowNum)
                .addAttribute("formName", "formdata_" + tenantID + "_" + formID));
        RestResult<String> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<RestResult<String>>() {
                }));
        return GetFormClientResult.getRightResult(result);
    }
 
    @SuppressWarnings("rawtypes")
    @Override
    public int updateState(ProcessState process) throws FormClientException, TimeoutException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        Map<String, Object> result = (Map<String, Object>)
                Http.post(String.format(ipMap.get("updateState"), ipAndPortEntity.getIp()), Map.class)
                        .addBody(process)
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<Map<String, Object>>() {
                        }.getType())
                        .orElse(Collections.EMPTY_MAP);
        return Integer.parseInt(Objects.toString(JSONTool.toJson(result.get("data")), "-1"));
    }
 
    @Override
    public ProcessState selectState(ProcessState process) throws TimeoutException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<Map<String, Object>> hc = new HttpClientTool<Map<String, Object>>(String.format(ipMap.get("selectState"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(process);
        Map<String, Object> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<Map<String, Object>>() {
                }));
        System.out.println("查询返回结果:" + JSONTool.toJson(result));
        Object o = result.get("data");
        if (!ObjectUtil.empty(o)) {
            return JSONTool.toObj(JSONTool.toJson(o), ProcessState.class);
        } else {
            return null;
        }
    }
 
    @Override
    public PowerButton getAllButton(String formId, ProcessState state) throws TimeoutException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<Map<String, Object>> hc = new HttpClientTool<Map<String, Object>>(String.format(ipMap.get("getAllButton"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(new ModelMap("formId", formId).addAttribute("state", state));
        Map<String, Object> result = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<Map<String, Object>>() {
                }));
        Object obj = result.get("data");
        return JSONTool.toObj(JSONTool.toJson(obj), PowerButton.class);
    }
 
    @Override
    public int formSolidiFication(FormSolidiFication map) throws TimeoutException {
        @SuppressWarnings("unchecked")
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<Map<String, Object>> hc = new HttpClientTool<Map<String, Object>>(String.format(ipMap.get("formSolidiFication"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(map);
        Map<String, Object> ma = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<Map<String, Object>>() {
                }));
        return Integer.parseInt(Objects.toString(ma.get("data"), "-1"));
    }
 
    @Override
    public Integer impDatas(List<ServicesFormData> allFormDataList) throws TimeoutException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<Map<String, Object>> hc = new HttpClientTool<Map<String, Object>>(String.format(ipMap.get("impDatas"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(allFormDataList);
        Map<String, Object> ma = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<Map<String, Object>>() {
                }));
        return Integer.parseInt(Objects.toString(ma.get("data"), "-1"));
    }
 
    @Override
    public Integer addExcelLog(ExcelLog excelLog) throws TimeoutException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<Map<String, Object>> hc = new HttpClientTool<Map<String, Object>>(String.format(ipMap.get("addExcelLog"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(excelLog);
        Map<String, Object> ma = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<Map<String, Object>>() {
                }));
        return Integer.parseInt(Objects.toString(ma.get("data"), "-1"));
    }
 
    @Override
    public Integer updateExcelLog(ExcelLog excelLog) throws TimeoutException {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        HttpClientTool<Map<String, Object>> hc = new HttpClientTool<Map<String, Object>>(String.format(ipMap.get("updateExcelLog"), ipAndPortEntity.getIp()));
        hc.setBodyInfos(excelLog);
        Map<String, Object> ma = hc.sendPost(
                j -> JSONTool.toObj(j, new TypeReference<Map<String, Object>>() {
                }));
        return Integer.parseInt(Objects.toString(ma.get("data"), "-1"));
    }
 
    @Override
    public void workFlowRollback(WorkFlowStateEntity workFlowStateEntity) {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        RestResult<Object> result = (RestResult<Object>)
                Http.post(String.format(ipMap.get("workFlowRollback"), ipAndPortEntity.getIp()), RestResult.class)
                        .addBody(workFlowStateEntity)
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<RestResult<Object>>() {
                        }.getType())
                        .orElse(RestResult.newInstance());
        GetFormClientResult.getRightResult(result);
    }
 
    @Override
    public void workFlowCreate(WorkFlowStateEntity workFlowStateEntity) {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        RestResult<Object> result = (RestResult<Object>)
                Http.post(String.format(ipMap.get("workFlowCreate"), ipAndPortEntity.getIp()), RestResult.class)
                        .addBody(workFlowStateEntity)
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<RestResult<Object>>() {
                        }.getType())
                        .orElse(RestResult.newInstance());
        GetFormClientResult.getRightResult(result);
    }
 
    @Override
    public UserInfo getUserInfo() {
        IpAndPortEntity ipAndPortEntity = ipAndPortTool.queryIpAndPortByServiceName(autoFormClient);
        RestResult<UserInfo> result = (RestResult<UserInfo>)
                Http.post(String.format(ipMap.get("getUserInfo"), ipAndPortEntity.getIp()), RestResult.class)
                        .addBody(new UserInfo())
                        .addHeader(RequestContext.getHeader())
                        .execute(new TypeReference<RestResult<UserInfo>>() {
                        }.getType())
                        .orElse(RestResult.newInstance());
        GetFormClientResult.getRightResultGetUserCode(result);
        return  result.getData();
    }
 
 
}