mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
495
496
package com.panzhihua.serviceapi.biz.impl;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
 
import javax.annotation.Resource;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.panzhihua.common.api.*;
import com.panzhihua.common.constants.TokenConstant;
import com.panzhihua.common.enums.LocalEventToLangChaoEventTypeEnum;
import com.panzhihua.common.model.dtos.api.EventFile;
import com.panzhihua.common.model.dtos.api.EventInfo;
import com.panzhihua.common.model.dtos.grid.LcEventVisitingTasksListDTO;
import com.panzhihua.common.model.vos.BcDictionaryItemVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComMngPopulationVO;
import com.panzhihua.common.model.vos.grid.EventDetailsVO;
import com.panzhihua.common.model.vos.grid.EventGridDataDetailsVO;
import com.panzhihua.common.model.vos.grid.EventResourceVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.service.grid.GridService;
import com.panzhihua.common.utlis.CopyUtil;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.serviceapi.biz.LcApiService;
import com.panzhihua.serviceapi.model.dto.*;
 
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
 
/**
 * program 攀枝花智慧社区项目 description 第三方浪潮市平台对接接口管理API
 *
 * @author manailin Date 2021-01-22 15:30
 **/
@Slf4j
@Service
public class LcApiServiceImpl implements LcApiService {
 
    @Value("${langchao.url}")
    private String host;
 
    @Resource
    private GridService gridService;
 
    @Autowired
    private StringRedisTemplate redisTemplate;
 
    @Resource
    private CommunityService communityService;
 
    /**
     * 工具方法 inputStream 转 File
     */
    private static File inputStreamToFile(InputStream ins, String name) throws Exception {
        File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name);
        log.info(System.getProperty("java.io.tmpdir") + File.separator + name);
        if (file.exists()) {
            return file;
        }
        OutputStream os = new FileOutputStream(file);
        int bytesRead;
        int len = 8192;
        byte[] buffer = new byte[len];
        while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
            os.write(buffer, 0, bytesRead);
        }
        os.close();
        ins.close();
        return file;
    }
 
    /**
     * 从redis获取token
     *
     * @return String 浪潮对接的token
     */
    private String getAuthToken() {
        ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
        if (valueOperations.get(LcApiConstants.LANG_CHAO_TOKEN) == null) {
            saveTokenFromRemoteRequest(LcApiConstants.LC_UPLOAD_NAME, LcApiConstants.LC_UPLOAD_PASSWORD);
        }
        return valueOperations.get(LcApiConstants.LANG_CHAO_TOKEN);
    }
 
    @Override
    public String saveTokenFromRemoteRequest(String name, String password) {
        Boolean authToken = redisTemplate.hasKey(LcApiConstants.LANG_CHAO_TOKEN);
        if (authToken != null) {
            // 如果redis存在token,直接返回redis存储的token
            ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
            return valueOperations.get(LcApiConstants.LANG_CHAO_TOKEN);
        } else {
            // 如果第一次请求浪潮的token请求,请求完成后,保存对于的token到数据库中。便于12小时内重复调用
            HttpRequest request = HttpUtil.createPost(
                host +
                LcApiConstants.GRID_GET_TOKEN_URL.replace("#username", name).replace("#password", password));
            HttpResponse result = request.execute();
            ValueOperations<String, String> valueOperations = redisTemplate.opsForValue();
            valueOperations.set(LcApiConstants.LANG_CHAO_TOKEN, result.body(), TokenConstant.EXPIRETIME,
                TimeUnit.MINUTES);
            return result.toString();
        }
    }
 
    @Override
    public String getAllEventTypeList() {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_EVENT_CATEGORY_URL);
        request.auth(getAuthToken());
        HttpResponse result = request.execute();
        return result.body();
    }
 
    @Override
    public String submitEventRegister(EventInfo eventInfo) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_REGIST_EVENT_URL);
        request.auth(getAuthToken());
        ObjectMapper mapper = new ObjectMapper();
        try {
            // 对象转map
            Map m = mapper.readValue(mapper.writeValueAsString(eventInfo), Map.class);
            request.form(m);
        } catch (JsonProcessingException e) {
            log.info("方法submitEventRegister发生错误:{}", e.getMessage());
        }
        HttpResponse result = request.execute();
        log.info("submitEventRegister上传浪潮事件信息:{}", result.body());
        return result.body();
    }
 
    @Override
    public R submitEventOrVisitRecordRelationFile(EventFile eventFile) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_EVENT_FILE_UPLOAD_URL);
        request.auth(getAuthToken());
        try {
            HttpURLConnection httpUrl = (HttpURLConnection)new URL(eventFile.getFiles()).openConnection();
            httpUrl.connect();
            File file = inputStreamToFile(httpUrl.getInputStream(), eventFile.getFileName());
            request.form("files", file);
            httpUrl.disconnect();
            request.form("dataId", eventFile.getDataId());
            request.form("type", eventFile.getType());
            request.form("module", eventFile.getModule());
            HttpResponse result = request.execute();
            file.delete();
            return R.ok(result.body());
        } catch (Exception e) {
            log.info("方法submitEventOrVisitRecordRelationFile发生错误:{}", e.getMessage());
        }
        return R.fail();
    }
 
    @Override
    public String getEventInfoById(String eventId) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_APP_EVENT_INFO_DETAIL_URL);
        request.auth(getAuthToken());
        request.form("eventId", eventId);
        HttpResponse result = request.execute();
        return result.body();
    }
 
    @Override
    public List<LcGridData> getGridTreeByAreaId(String areaId) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_GET_EVENT_INFO_AREA_ID_URL);
        request.auth(getAuthToken());
        request.form("areaId", areaId);
        request.form("level", 4);
        HttpResponse result = request.execute();
        return JSONArray.parseArray(result.body(), LcGridData.class);
    }
 
    @Override
    public List<LcGridData> getGridDataListByAreaId(String areaId) {
        log.info("浪潮请求url");
        log.info(host + LcApiConstants.GRID_GET_GRID_DATA_AREA_ID_URL);
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.GRID_GET_GRID_DATA_AREA_ID_URL);
        request.auth(getAuthToken());
        request.form("areaId", areaId);
        HttpResponse result = request.execute();
        return JSONArray.parseArray(result.body(), LcGridData.class);
    }
 
    @Override
    public List<GridMemberPageListDTO> getGridMemberListByAreaIdOrName(String areaId, String param, Long pageNum,
        Long pageSize) {
        HttpRequest request = HttpUtil.createGet(host + LcApiConstants.GRID_GET_GETALL_SEARCH_PAGE_URL);
        request.auth(getAuthToken());
        request.form("areaId", areaId);
        request.form("limit", pageSize);
        request.form("page", pageNum);
        if (StringUtils.isNotEmpty(param)) {
            request.form("param", param);
        }
        HttpResponse result = request.execute();
        LcReturnObject returenData = JSONObject.parseObject(result.body(), LcReturnObject.class);
        return JSONArray.parseArray(returenData.getData(), GridMemberPageListDTO.class);
    }
 
    @Override
    public void automationUploadEventAndFile() {
        List<EventDetailsVO> unUploadEventList = gridService.getUnUploadEvent();
        unUploadEventList.forEach(eventInfoVo -> {
            log.info("定时向浪潮服务器提交网格事件登记开始");
            EventInfo eventInfo = new EventInfo();
            String lcGrid = gridService.getLcGridIdByLocal(eventInfoVo.getGridId());
            String lcGridUserId = gridService.getLcUserIdByLocalUserId(eventInfoVo.getGridMemberId().toString());
            eventInfo.setGridId(lcGrid);
            R grid = gridService.eventGridDataDetails(eventInfoVo.getGridId());
            EventGridDataDetailsVO gridData = (EventGridDataDetailsVO)grid.getData();
            eventInfo.setGridName(gridData.getGridName());
            eventInfo.setCaseTypeCode(LocalEventToLangChaoEventTypeEnum.getCodeByName(eventInfoVo.getEventType()));
            String caseTypeName = LocalEventToLangChaoEventTypeEnum.getEventNameByCode(eventInfoVo.getEventType());
            eventInfo.setCaseTypeName(caseTypeName);
            if (eventInfoVo.getEventCategory() != 1L) {
                eventInfo.setHappenTime(String.valueOf(eventInfoVo.getPropagandaTime().getTime()));
            } else {
                eventInfo.setHappenTime(String.valueOf(eventInfoVo.getHappenTime().getTime()));
            }
            eventInfo.setHappenAddress(eventInfoVo.getHappenAddress());
            String[] data = eventInfoVo.getHappentLatLng().split(",");
            eventInfo.setLongitude(data[0]);
            eventInfo.setLatitude(data[1]);
            eventInfo.setCaseDescription(eventInfoVo.getEventDes());
            eventInfo.setCaseRecordTime(String.valueOf(eventInfoVo.getCreateAt().getTime()));
            eventInfo.setHandleType("REPORT");
            eventInfo.setHandleDescription(eventInfoVo.getProcessDesc());
            eventInfo.setDataId(eventInfoVo.getId().toString());
            // 获取系统网格员映射的浪潮网格员对于的用户ID
            eventInfo.setUserId(lcGridUserId);
            eventInfo.setHandleTime(DateUtils.getCurrentDateTimeStamp().toString());
            eventInfo.setCaseName(gridData.getGridName().concat(caseTypeName));
            log.info("事件请求数据:{}", JSONObject.toJSONString(eventInfo));
            String remoteData = submitEventRegister(eventInfo);
            LcReturnObject lcReturnObject = JSONObject.parseObject(remoteData, LcReturnObject.class);
            log.info("提交浪潮服务器,接口返回结果为:{}", remoteData);
            if (lcReturnObject.getSuccess()) {
                log.info("定时向浪潮服务器提交网格事件登记结束");
                log.info("开始上传附件信息");
                List<EventResourceVO> picsList = eventInfoVo.getPics();
                uploadLcApiEventFile(eventInfoVo, picsList, "png");
                List<EventResourceVO> audiosList = eventInfoVo.getAudios();
                uploadLcApiEventFile(eventInfoVo, audiosList, "mp3");
                List<EventResourceVO> videoList = eventInfoVo.getVideos();
                uploadLcApiEventFile(eventInfoVo, videoList, "mp4");
                log.info("结束上传附件信息");
                gridService.updateLcUploadFlag(eventInfoVo.getId());
            }
        });
    }
 
    @Override
    public String getFlowPersonVisitRecordDetailById(String recordId) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_FLOW_PERSON_DETAIL_URL);
        request.auth(getAuthToken());
        request.form("id", recordId);
        HttpResponse result = request.execute();
        return result.body();
    }
 
    @Override
    public String getFlowPersonVisitRecordPage(LcKeyPersonVisitRecordQueryDTO personVisitRecordQueryDTO,
        Long loginUserId) {
        HttpResponse result = getHttpResponse(personVisitRecordQueryDTO, loginUserId,
            host +
            LcApiConstants.VISIT_RECORD_FLOW_PERSON_PAGE_URL, "flowPeopleId");
        return result.body();
    }
 
    @Override
    public String uploadFlowPersonVisitRecord(LcFlowPersonVisitRecordDTO lcFlowPersonVisitRecordDTO) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_FLOW_PERSON_SAVE_URL);
        request.auth(getAuthToken());
        ObjectMapper mapper = new ObjectMapper();
        try {
            // 对象转map
            Map m = mapper.readValue(mapper.writeValueAsString(lcFlowPersonVisitRecordDTO), Map.class);
            request.form(m);
        } catch (JsonProcessingException e) {
            log.info("方法uploadFlowPersonVisitRecord发生错误:{}", e.getMessage());
        }
        HttpResponse result = request.execute();
        log.info("uploadFlowPersonVisitRecord上传浪潮事件信息:{}", result.body());
        return result.body();
    }
 
    @Override
    public String uploadKeyPersonVisitRecord(LcKeyPersonVisitRecordDTO lcKeyPersonVisitRecordDTO) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_KEY_PERSON_SAVE_REMOTE_URL);
        request.auth(getAuthToken());
        ObjectMapper mapper = new ObjectMapper();
        try {
            // 对象转map
            Map m = mapper.readValue(mapper.writeValueAsString(lcKeyPersonVisitRecordDTO), Map.class);
            request.form(m);
        } catch (JsonProcessingException e) {
            log.info("方法uploadKeyPersonVisitRecord发生错误:{}", e.getMessage());
        }
        HttpResponse result = request.execute();
        log.info("uploadKeyPersonVisitRecord上传浪潮事件信息:{}", result.body());
        return result.body();
    }
 
    @Override
    public String getKeyPersonVisitRecordDetailById(String recordId) {
        HttpRequest request = HttpUtil.createPost(host + LcApiConstants.VISIT_RECORD_KEY_PERSON_DETAIL_URL);
        request.auth(getAuthToken());
        request.form("id", recordId);
        HttpResponse result = request.execute();
        return result.body();
    }
 
    @Override
    public String getKeyPersonVisitRecordPage(LcKeyPersonVisitRecordQueryDTO personVisitRecordQueryDTO,
        Long loginUserId) {
        HttpResponse result = getHttpResponse(personVisitRecordQueryDTO, loginUserId,
            host +
            LcApiConstants.VISIT_RECORD_KEY_PERSON_PAGE_URL, "keyPersonId");
        return result.body();
    }
 
    @Override
    public void automationUploadVisitRecord() {
        List<LcEventVisitingTasksListDTO> unUploadTaskList = gridService.getUnUploadVisitingTask();
        unUploadTaskList.forEach(lcEventVisitingTasksListDTO -> {
            String lcGrid = gridService.getLcGridIdByLocal(lcEventVisitingTasksListDTO.getGridId());
            String lcGridUserId =
                gridService.getLcUserIdByLocalUserId(lcEventVisitingTasksListDTO.getGridMember().toString());
            R populationDetail = communityService.detailPopulation(lcEventVisitingTasksListDTO.getVisiterId(), null);
            ComMngPopulationVO comMngPopulationVO = (ComMngPopulationVO)populationDetail.getData();
            BcDictionaryItemVO diction = communityService.getByCode(DictionItemConstants.LC_CULTURE_LEVEL,
                comMngPopulationVO.getCultureLevel().toString());
            ComMngPopulationDTO comMngPopulationDTO =
                CopyUtil.copyProperties(comMngPopulationVO, ComMngPopulationDTO.class);
            if (diction != null) {
                comMngPopulationDTO.setCultureLevel(diction.getDictItemName());
            }
            R grid = gridService.eventGridDataDetails(lcEventVisitingTasksListDTO.getGridId());
            EventGridDataDetailsVO gridData = (EventGridDataDetailsVO)grid.getData();
            String[] data = lcEventVisitingTasksListDTO.getHappentLatLng().split(",");
            if (lcEventVisitingTasksListDTO.getVisiterType() != null) {
                log.info("上传数据导重点人口走访记录表");
                LcReturnObject lcReturnObject = requestLcKeyPersonVisitRecord(lcEventVisitingTasksListDTO, lcGrid,
                    lcGridUserId, comMngPopulationDTO, gridData.getGridName(), data);
                if (LcRequestEnum.SUCCESS.getCode().equals(lcReturnObject.getCode())) {
                    uploadVisitRecord(lcEventVisitingTasksListDTO);
                    gridService.updateLcUploadFlagVisitingTask(lcEventVisitingTasksListDTO.getId());
                }
            } else {
                log.info("上传数据导流动人口走访记录表");
                LcReturnObject lcReturnObject = requestLcFlowPersonVisitRecord(lcEventVisitingTasksListDTO, lcGrid,
                    lcGridUserId, comMngPopulationDTO, gridData.getGridName(), data);
                if (LcRequestEnum.SUCCESS.getCode().equals(lcReturnObject.getCode())) {
                    uploadVisitRecord(lcEventVisitingTasksListDTO);
                    gridService.updateLcUploadFlagVisitingTask(lcEventVisitingTasksListDTO.getId());
                }
            }
        });
    }
 
    private void uploadVisitRecord(LcEventVisitingTasksListDTO lcEventVisitingTasksListDTO) {
        log.info("开始上传走访任务附件文件");
        List<EventResourceVO> picsList = lcEventVisitingTasksListDTO.getPics();
        uploadVisitRecordFile(lcEventVisitingTasksListDTO, picsList, "IMAGE");
        List<EventResourceVO> audiosList = lcEventVisitingTasksListDTO.getAudios();
        uploadVisitRecordFile(lcEventVisitingTasksListDTO, audiosList, "AUDIO");
        List<EventResourceVO> videoList = lcEventVisitingTasksListDTO.getVideos();
        uploadVisitRecordFile(lcEventVisitingTasksListDTO, videoList, "VIDEO");
        log.info("结束上传走访任务附件文件");
    }
 
    private void uploadVisitRecordFile(LcEventVisitingTasksListDTO lcEventVisitingTasksListDTO,
        List<EventResourceVO> picsList, String type) {
        picsList.forEach(eventResourceVO -> {
            EventFile eventFile = new EventFile();
            eventFile.setDataId(lcEventVisitingTasksListDTO.getId().toString());
            eventFile.setFiles(eventResourceVO.getUrl());
            eventFile.setType(type);
            eventFile.setModule("key_person");
            eventFile.setFileName(eventResourceVO.getResourceName());
            submitEventOrVisitRecordRelationFile(eventFile);
        });
    }
 
    @Override
    public LcReturnObject requestLcFlowPersonVisitRecord(LcEventVisitingTasksListDTO lcEventVisitingTasksListDTO,
        String lcGrid, String lcGridUserId, Object populationDetail, String gridName, String[] data) {
        // 如果是流动人口走访
        LcFlowPersonVisitRecordDTO lcFlowPersonVisitRecordDTO = new LcFlowPersonVisitRecordDTO();
        lcFlowPersonVisitRecordDTO.setId(lcEventVisitingTasksListDTO.getId().toString());
        lcFlowPersonVisitRecordDTO.setUserId(lcGridUserId);
        lcFlowPersonVisitRecordDTO.setGridPersonName(lcEventVisitingTasksListDTO.getGridMemberName());
        lcFlowPersonVisitRecordDTO.setGridPersonPhone(lcEventVisitingTasksListDTO.getGridMenberTele());
        JSONObject population = (JSONObject)JSONObject.toJSON(populationDetail);
        lcFlowPersonVisitRecordDTO.setComMngPopulation(population.toJSONString());
        lcFlowPersonVisitRecordDTO.setGridId(lcGrid);
        lcFlowPersonVisitRecordDTO.setGridName(gridName);
        lcFlowPersonVisitRecordDTO.setWorkWithPoliceMan("0");
        lcFlowPersonVisitRecordDTO.setPoliceManName(null);
        lcFlowPersonVisitRecordDTO.setPoliceManPhone(null);
        lcFlowPersonVisitRecordDTO.setPoliceManWorkContent(null);
        lcFlowPersonVisitRecordDTO.setVisitTime(lcEventVisitingTasksListDTO.getHappenTime().getTime());
        lcFlowPersonVisitRecordDTO.setVisitAddress(lcEventVisitingTasksListDTO.getHappentAddress());
        lcFlowPersonVisitRecordDTO.setLongitude(Double.valueOf(data[0]));
        lcFlowPersonVisitRecordDTO.setLatitude(Double.valueOf(data[1]));
        lcFlowPersonVisitRecordDTO.setHouseType(null);
        lcFlowPersonVisitRecordDTO.setHouseAddress(lcEventVisitingTasksListDTO.getHappentAddress());
        lcFlowPersonVisitRecordDTO.setIsReportInfo(null);
        lcFlowPersonVisitRecordDTO.setHaveCertificate("0");
        lcFlowPersonVisitRecordDTO.setCertificateType("身份证");
        lcFlowPersonVisitRecordDTO.setCertificateNumber(population.getString("cardNo"));
        lcFlowPersonVisitRecordDTO.setCertificateDeadTime("0");
        lcFlowPersonVisitRecordDTO.setIsPropaganda("1");
        lcFlowPersonVisitRecordDTO.setIsCheckReview("1");
        lcFlowPersonVisitRecordDTO.setIsAbnormal(lcEventVisitingTasksListDTO.getException().toString());
        lcFlowPersonVisitRecordDTO.setAbnormalSituation(lcEventVisitingTasksListDTO.getTableContentJson());
        lcFlowPersonVisitRecordDTO.setRemark(lcEventVisitingTasksListDTO.getEventDes());
        log.info("requestLcFlowPersonVisitRecord事件请求数据:{}", JSONObject.toJSONString(lcFlowPersonVisitRecordDTO));
        String flowPersonData = uploadFlowPersonVisitRecord(lcFlowPersonVisitRecordDTO);
        LcReturnObject lcReturnObject = JSONObject.parseObject(flowPersonData, LcReturnObject.class);
        log.info("requestLcFlowPersonVisitRecord提交浪潮服务器,接口返回结果为:{}", lcReturnObject);
        return lcReturnObject;
    }
 
    @Override
    public LcReturnObject requestLcKeyPersonVisitRecord(LcEventVisitingTasksListDTO lcEventVisitingTasksListDTO,
        String lcGrid, String lcGridUserId, Object populationDetail, String gridName, String[] data) {
        LcKeyPersonVisitRecordDTO keyPersonVisitRecordDTO = new LcKeyPersonVisitRecordDTO();
        keyPersonVisitRecordDTO.setId(lcEventVisitingTasksListDTO.getId().toString());
        keyPersonVisitRecordDTO.setUserId(lcGridUserId);
        keyPersonVisitRecordDTO.setGridPersonName(lcEventVisitingTasksListDTO.getGridMemberName());
        keyPersonVisitRecordDTO.setGridPersonPhone(lcEventVisitingTasksListDTO.getGridMenberTele());
        keyPersonVisitRecordDTO.setComMngPopulation(JSONObject.toJSONString(populationDetail));
        keyPersonVisitRecordDTO.setGridId(lcGrid);
        keyPersonVisitRecordDTO.setGridName(gridName);
        keyPersonVisitRecordDTO.setVisitTime(lcEventVisitingTasksListDTO.getHappenTime().getTime());
        keyPersonVisitRecordDTO.setVisitAddress(lcEventVisitingTasksListDTO.getHappentAddress());
        keyPersonVisitRecordDTO.setLongitude(Double.valueOf(data[0]));
        keyPersonVisitRecordDTO.setLatitude(Double.valueOf(data[1]));
        keyPersonVisitRecordDTO.setFamilyMemberContact(lcEventVisitingTasksListDTO.getFamilyPhone());
        keyPersonVisitRecordDTO.setHowLive(lcEventVisitingTasksListDTO.getFamilySource());
        keyPersonVisitRecordDTO.setIsAbnormal(lcEventVisitingTasksListDTO.getException().toString());
        keyPersonVisitRecordDTO.setAbnormalSituation(null);
        keyPersonVisitRecordDTO.setAbnormalDes(lcEventVisitingTasksListDTO.getTableContentJson());
        keyPersonVisitRecordDTO.setRemark(lcEventVisitingTasksListDTO.getEventDes());
        keyPersonVisitRecordDTO
            .setType(LcVisitRecordKeyPersonLabelEnum.getCnDescByName(lcEventVisitingTasksListDTO.getVisiterType()));
        log.info("requestLcKeyPersonVisitRecord事件请求数据:{}", JSONObject.toJSONString(keyPersonVisitRecordDTO));
        String remoteData = uploadKeyPersonVisitRecord(keyPersonVisitRecordDTO);
        LcReturnObject lcReturnObject = JSONObject.parseObject(remoteData, LcReturnObject.class);
        log.info("requestLcKeyPersonVisitRecord提交浪潮服务器,接口返回结果为:{}", remoteData);
        return lcReturnObject;
    }
 
    private HttpResponse getHttpResponse(LcKeyPersonVisitRecordQueryDTO personVisitRecordQueryDTO, Long loginUserId,
        String requestUrl, String flowPeopleId) {
        HttpRequest request = HttpUtil.createPost(requestUrl);
        request.auth(getAuthToken());
        request.form("userId", loginUserId);
        request.form("gridId", personVisitRecordQueryDTO.getGridId());
        request.form("limit", personVisitRecordQueryDTO.getLimit());
        request.form("startNumber", personVisitRecordQueryDTO.getStartNumber());
        request.form(flowPeopleId, personVisitRecordQueryDTO.getPersonId());
        return request.execute();
    }
 
    private void uploadLcApiEventFile(EventDetailsVO eventInfoVo, List<EventResourceVO> picsList, String type) {
        picsList.forEach(eventResourceVO -> {
            EventFile eventFile = new EventFile();
            eventFile.setDataId(eventInfoVo.getId().toString());
            eventFile.setFiles(eventResourceVO.getUrl());
            eventFile.setType(type);
            eventFile.setModule("event");
            eventFile.setFileName(eventResourceVO.getResourceName());
            submitEventOrVisitRecordRelationFile(eventFile);
        });
    }
}