zhanghua
2022-09-28 5a6af9762dfb9e3ed75422303a795b2bb8c21885
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
package com.ycl.service.caseHandler.impl;
 
import com.ycl.entity.caseHandler.BaseCase;
import com.ycl.entity.caseHandler.Violations;
import com.ycl.entity.video.VideoAlarmReport;
import com.ycl.mapper.caseHandler.BaseCaseMapper;
import com.ycl.remote.dto.*;
import com.ycl.remote.service.CityPlatformService;
import com.ycl.service.caseHandler.IBaseCaseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.service.caseHandler.IViolationsService;
import com.ycl.service.video.IVideoAlarmReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
/**
 * <p>
 * 案件基本信息 服务实现类
 * </p>
 *
 * @author wl
 * @since 2022-09-24
 */
@Service
public class BaseCaseServiceImpl extends ServiceImpl<BaseCaseMapper, BaseCase> implements IBaseCaseService {
 
    private CityPlatformService cityPlatformService;
    private IViolationsService violationsService;
    private IVideoAlarmReportService videoAlarmReportService;
 
    @Value("${fdfs.fileUrl}")
    private String fileUrl;
 
    @Autowired
    public void setCityPlatformService(CityPlatformService cityPlatformService) {
        this.cityPlatformService = cityPlatformService;
    }
 
    @Autowired
    public void setViolationsService(IViolationsService violationsService) {
        this.violationsService = violationsService;
    }
 
    @Autowired
    public void setVideoAlarmReportService(IVideoAlarmReportService videoAlarmReportService) {
        this.videoAlarmReportService = videoAlarmReportService;
    }
 
    @Override
    public String uploadEvent(Integer caseId) {
        BaseCase baseCase = this.getById(caseId);
        Violations violations = violationsService.getById(caseId);
        String medias = "";
        String eventDesc = "";
        if (violations != null) {
            eventDesc = violations.getDescription();
            VideoAlarmReport videoAlarmReport = videoAlarmReportService.getById(violations.getVideoAlarmReportId());
            if (videoAlarmReport != null) {
                StringBuilder stringBuilder = new StringBuilder().append("[{'mediaURL':'").append(fileUrl).append(videoAlarmReport.getPicData()).append("'}]");
                medias = stringBuilder.toString();
            }
        }
        EventAddParamDto dto = EventAddParamDto.builder().y84(baseCase.getLatitude().toString()).x84(baseCase.getLongitude().toString())
                .source(11).address(baseCase.getSite()).eventDesc(eventDesc).eventSign(baseCase.getCode()).medias(medias).build();
        ResultResponseDto<EventAddResponseDto> result = cityPlatformService.addEvent(dto);
        if (result.getCode() == 0) {
            EventAddResponseDto responseDto = result.getResult();
            baseCase.setTaskCode(responseDto.getTaskcode());
            this.updateById(baseCase);
            return null;
        } else {
            return result.getMsg();
        }
    }
 
    @Override
    public String processEvent(Integer caseId) {
        BaseCase baseCase = this.getById(caseId);
        EventProcessParamDto paramDto = EventProcessParamDto.builder().eventSign(baseCase.getCode()).taskcode(baseCase.getTaskCode()).build();
        ResultResponseDto<EventProcessResponseDto> responseDto = cityPlatformService.getEventProcess(paramDto);
        if (responseDto.getCode() == 0) {
            EventProcessResponseDto eventProcessResponseDto = responseDto.getResult();
            /*********** 未处理市平台返回数据 ***************/
            return null;
        } else {
            return responseDto.getMsg();
        }
    }
}