From 509bb223e3662d3cb6bd3fecb1e73f954ca73b40 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Wed, 10 Jan 2024 18:52:17 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=8E=A8=E9=80=81=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/wx/send/WeiXinSendMessageService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/wx/send/WeiXinSendMessageService.java b/tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/wx/send/WeiXinSendMessageService.java index 3d81929..ba51166 100644 --- a/tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/wx/send/WeiXinSendMessageService.java +++ b/tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/wx/send/WeiXinSendMessageService.java @@ -62,9 +62,9 @@ public class WeiXinSendMessageService { //本次结束,进入下次循环 continue; } - if (user.getAuthorize() == AuthorizeStatusEnum.AUTHORIZE_ON.getCode() && user.getSubscribeTimes() == SubscribeTimesEnum.SUBSCRIBE_TIMES_NO_ONE.getCode()) { - continue; - } +// if (user.getAuthorize() == AuthorizeStatusEnum.AUTHORIZE_ON.getCode() && user.getSubscribeTimes() == SubscribeTimesEnum.SUBSCRIBE_TIMES_NO_ONE.getCode()) { +// continue; +// } //获取当前登录openId UserAuthorize userAuthorize = userAuthorizeMapper.selectOne(Wrappers.lambdaQuery() .eq(UserAuthorize::getUserId, userId) -- 2.27.0 From 57410ae4cec871a198c206dc2c615b432e35fd72 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Fri, 19 Jan 2024 11:29:01 +0800 Subject: [PATCH 02/22] =?UTF-8?q?1=E3=80=81=E4=BA=8B=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E6=8A=A5=E7=B1=BB=E5=9E=8B=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=EF=BC=9B2=E3=80=81dsp=E6=8E=A8=E9=80=81=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E4=BA=8B=E4=BB=B6=E7=B1=BB=E5=9E=8B=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=8A=A8=E4=B8=8A=E6=8A=A5=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tuoheng-admin/sql/sql_change_v1.3.7.sql | 9 +++++++ .../com/tuoheng/admin/entity/Accident.java | 5 ++++ .../accident/AccidentReportTypeEnum.java | 27 +++++++++++++++++++ .../ignore/AccidentIgnoreService.java | 2 +- .../third/dsp/DspCallbackServiceImpl.java | 2 ++ .../main/resources/mapper/AccidentMapper.xml | 5 ++-- .../admin/service/DspCallbackServiceTest.java | 14 +++++----- 7 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentReportTypeEnum.java diff --git a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql new file mode 100644 index 0000000..478b18d --- /dev/null +++ b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql @@ -0,0 +1,9 @@ +-- 2024-01-19 11:20 +-- v1.3.7 + +use tuoheng_freeway; + + +-- 事件表 +alter table tuoheng_freeway.th_accident add report_type tinyint(1) default 1 not null comment '上报类型:1:自动上报(默认);2:手动上报' after dept_id; + diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java index 8df7e08..0fa9c58 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java @@ -32,6 +32,11 @@ public class Accident extends BaseEntity { */ private String deptId; + /** + * 上报类型:1:自动上报(默认);2:手动上报 + */ + private Integer reportType; + /** * 巡检任务id */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentReportTypeEnum.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentReportTypeEnum.java new file mode 100644 index 0000000..b589c64 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentReportTypeEnum.java @@ -0,0 +1,27 @@ +package com.tuoheng.admin.enums.accident; + +import lombok.Getter; + +/** + * 事件上报类型 + * + * @author wanjing + * @team tuoheng + * @date 2024-01-19 + */ +public enum AccidentReportTypeEnum { + + AUTO(1,"自动上报"), + MANUAL(2,"手动上报"),; + + AccidentReportTypeEnum(int code, String description){ + this.code = code; + this.description = description; + } + + @Getter + private int code; + + @Getter + private String description; +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java index 206ee60..b7ed2ea 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java @@ -32,7 +32,7 @@ public class AccidentIgnoreService { private AccidentMapper accidentMapper; public JsonResult ignore(String id) { -// log.info("进入忽略事故业务"); +// log.info("进入忽略事故业务, id={}", id); User user = CurrentUserUtil.getUserInfo(); String userId = user.getId(); String tenantId = user.getTenantId(); diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java index cec67c1..5dfaa77 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.entity.*; import com.tuoheng.admin.enums.*; +import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.request.third.DspCallbackRequest; import com.tuoheng.admin.request.third.QuestionFile; @@ -335,6 +336,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService { } Accident accident = new Accident(); //问题类型为应急类型时添加数据 + accident.setReportType(AccidentReportTypeEnum.AUTO.getCode()); accident.setTenantId(inspectionFile.getTenantId()); accident.setInspectionId(inspectionFile.getInspectionId()); accident.setInspectionFileId(inspectionFile.getId()); diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index 31eee07..ea63c00 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -6,6 +6,7 @@ + @@ -42,13 +43,13 @@ - id, tenant_id, dept_id, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, + id, tenant_id, dept_id, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark - select id, tenant_id, dept_id, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, + select id, tenant_id, dept_id, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark from th_accident diff --git a/tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/DspCallbackServiceTest.java b/tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/DspCallbackServiceTest.java index 1c8d80c..cd55a49 100755 --- a/tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/DspCallbackServiceTest.java +++ b/tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/DspCallbackServiceTest.java @@ -38,18 +38,18 @@ public class DspCallbackServiceTest { @Test public void testGetOneById() { - String requestId = "369567d311de473886c40a5c85305493"; + String requestId = "c4da0ec5d77b46d6992f9f9462fb1bc3"; DspCallbackRequest dspCallbackRequest = new DspCallbackRequest(); - dspCallbackRequest.setAnalyseStatus(2); + dspCallbackRequest.setAnalyseStatus(10); dspCallbackRequest.setType(1); List questionFiles = new ArrayList<>(); QuestionFile questionFile = new QuestionFile(); - questionFile.setFileCode("PVR2024010815484594512"); - questionFile.setFileName("2024-01-08-15-48-45_frame-52-332_type_20240108154845591880-1-003-1_AI.jpg"); - questionFile.setFileOriginalUrl("https://image.t-aaron.com/369567d311de473886c40a5c85305493/2024-01-08-15-48-45_frame-52-332_type_20240108154845581518-1-0-0_OR.jpg"); - questionFile.setFileMarkerUrl("https://image.t-aaron.com/369567d311de473886c40a5c85305493/2024-01-08-15-48-45_frame-52-332_type_20240108154845591880-1-003-1_AI.jpg"); - questionFile.setAnalyseTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, "2024-01-08 15:48:45")); + questionFile.setFileCode("PBS2024011110351459454"); + questionFile.setFileName("2024-01-11-10-35-14_frame-2926-3206_type_20240111103514148029-1-003-1_AI.jpg"); + questionFile.setFileOriginalUrl("https://image.t-aaron.com/c4da0ec5d77b46d6992f9f9462fb1bc3/2024-01-11-10-35-14_frame-2926-3206_type_20240111103514141070-1-0-0_OR.jpg"); + questionFile.setFileMarkerUrl("https://image.t-aaron.com/c4da0ec5d77b46d6992f9f9462fb1bc3/2024-01-11-10-35-14_frame-2926-3206_type_20240111103514148029-1-003-1_AI.jpg"); + questionFile.setAnalyseTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, "2024-01-11 10:35:14")); questionFile.setQuestionName("车辆"); questionFile.setQuestionCode("003008"); questionFiles.add(questionFile); -- 2.27.0 From f748a45733dac7b0efc2d78795e352a3b471b370 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Tue, 23 Jan 2024 10:53:53 +0800 Subject: [PATCH 03/22] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E4=B8=8A=E6=8A=A5=E5=BA=94=E6=80=A5=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E6=96=B0=E5=A2=9E=E6=8C=89=E6=9C=88?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=BA=94=E6=80=A5=E4=BA=8B=E4=BB=B6;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tuoheng-admin/sql/sql_change_v1.3.7.sql | 1 + .../admin/controller/AccidentController.java | 17 ++ .../admin/conver/AccidentConverMapper.java | 3 + .../request/accident/AddAccidentRequest.java | 48 +++++ .../accident/QuestionTypeStatisticsVo.java | 35 +++ .../service/accident/AccidentServiceImpl.java | 29 +++ .../service/accident/IAccidentService.java | 16 ++ .../accident/add/AddAccidentService.java | 93 ++++++++ .../statistics/StatisticsByMonthService.java | 204 ++++++++++++++++++ .../vo/accident/AccidentStatisticsVo.java | 33 +++ 10 files changed, 479 insertions(+) create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QuestionTypeStatisticsVo.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java diff --git a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql index 478b18d..dbbcb0b 100644 --- a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql +++ b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql @@ -5,5 +5,6 @@ use tuoheng_freeway; -- 事件表 +alter table tuoheng_freeway.th_accident add name varchar(20) default '' not null comment '事件名称' after dept_id; alter table tuoheng_freeway.th_accident add report_type tinyint(1) default 1 not null comment '上报类型:1:自动上报(默认);2:手动上报' after dept_id; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index 148cec0..bb67791 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -2,6 +2,7 @@ package com.tuoheng.admin.controller; import com.tuoheng.admin.query.AccidentQuery; import com.tuoheng.admin.request.accident.*; +import com.tuoheng.admin.request.dept.AddDeptRequest; import com.tuoheng.admin.service.accident.IAccidentService; import com.tuoheng.common.core.utils.JsonResult; import org.springframework.beans.factory.annotation.Autowired; @@ -139,4 +140,20 @@ public class AccidentController { public JsonResult ignore(@PathVariable("id") String id){ return accidentService.ignore(id); } + + /** + * 新增应急事件 + */ + @PostMapping("/add") + public JsonResult add(@RequestBody AddAccidentRequest request) { + return accidentService.insert(request); + } + + /** + * 统计月份数据 + */ + @GetMapping("/statistics/month") + public JsonResult statisticsByMonth() { + return accidentService.statisticsByMonth(); + } } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/AccidentConverMapper.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/AccidentConverMapper.java index 325ba65..bfff28e 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/AccidentConverMapper.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/AccidentConverMapper.java @@ -2,6 +2,7 @@ package com.tuoheng.admin.conver; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.Dept; +import com.tuoheng.admin.request.accident.AddAccidentRequest; import com.tuoheng.admin.vo.accident.AccidentVo; import com.tuoheng.admin.vo.dept.DeptInfoVo; import com.tuoheng.admin.vo.dept.DeptTreeVo; @@ -23,4 +24,6 @@ public interface AccidentConverMapper { */ List accidentListToAccidentVoList(List accidentList); + Accident addAccidentRequestToAccident(AddAccidentRequest request); + } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java new file mode 100644 index 0000000..c637514 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java @@ -0,0 +1,48 @@ +package com.tuoheng.admin.request.accident; + +import lombok.Data; + +/** + * + * @author wanjing + * @team tuoheng + * @date 2024-01-19 + */ +@Data +public class AddAccidentRequest { + + /** + * 经度 + */ + private String name; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + + /** + * 公路id + */ + private String roadId; + + /** + * 公路编码 + */ + private String roadCode; + + /** + * 路段ID + */ + private String sectionId; + + /** + * 图片 + */ + private String image; +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QuestionTypeStatisticsVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QuestionTypeStatisticsVo.java new file mode 100644 index 0000000..5bec1f4 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QuestionTypeStatisticsVo.java @@ -0,0 +1,35 @@ +package com.tuoheng.admin.request.accident; + +import lombok.Data; + +/** + * 事件月份统计 返回实体类 + * + * @author wanjing + * @team tuoheng + * @date 2024-01-19 + */ +@Data +public class QuestionTypeStatisticsVo { + + /** + * 问题Id + */ + private String questionId; + + /** + * 问题编码 + */ + private String questionCode; + + /** + * 问题名称 + */ + private String questionName; + + /** + * 问题数量 + */ + private Integer count; + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index e99331f..c205aac 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -4,10 +4,12 @@ import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.query.AccidentQuery; import com.tuoheng.admin.request.accident.*; +import com.tuoheng.admin.service.accident.add.AddAccidentService; import com.tuoheng.admin.service.accident.ignore.AccidentIgnoreService; import com.tuoheng.admin.service.accident.query.*; import com.tuoheng.admin.service.accident.reoprt.ReportAccidentService; import com.tuoheng.admin.service.accident.reoprt.ReportNoAccidentService; +import com.tuoheng.admin.service.accident.statistics.StatisticsByMonthService; import com.tuoheng.admin.service.accident.verify.AccidentVerifyCompletedService; import com.tuoheng.admin.service.accident.verify.AccidentVerifyService; import com.tuoheng.common.core.common.BaseServiceImpl; @@ -24,6 +26,9 @@ import org.springframework.stereotype.Service; @Slf4j public class AccidentServiceImpl extends BaseServiceImpl implements IAccidentService { + @Autowired + private AddAccidentService addAccidentService; + @Autowired private QueryAccidentCardPageListService queryAccidentCardPageListService; @@ -63,6 +68,20 @@ public class AccidentServiceImpl extends BaseServiceImpl { + /** + * 新增应急事件 + * + * @param request 应急事件对象 + * @return 结果 + */ + JsonResult insert(AddAccidentRequest request); + /** * 查询事故列表(分页) * @@ -115,4 +124,11 @@ public interface IAccidentService extends IBaseService { */ JsonResult ignore(String id); + /** + * 统计月份数据 + * + * @return 结果 + */ + JsonResult statisticsByMonth(); + } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java new file mode 100644 index 0000000..c574f2c --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java @@ -0,0 +1,93 @@ +package com.tuoheng.admin.service.accident.add; + +import com.tuoheng.admin.conver.AccidentConverMapper; +import com.tuoheng.admin.entity.Accident; +import com.tuoheng.admin.entity.User; +import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; +import com.tuoheng.admin.mapper.AccidentMapper; +import com.tuoheng.admin.request.accident.AddAccidentRequest; +import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.common.core.exception.ServiceException; +import com.tuoheng.common.core.utils.DateUtils; +import com.tuoheng.common.core.utils.JsonResult; +import com.tuoheng.common.core.utils.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 添加应急事故业务层处理 + * + * @author wanjing + * @team tuoheng + * @date 2024-01-19 + */ +@Slf4j +@Service +public class AddAccidentService { + + @Autowired + private AccidentMapper accidentMapper; + + public JsonResult add(AddAccidentRequest request) { +// log.info("进入添加应急事件业务, id={}", id); + User user = CurrentUserUtil.getUserInfo(); + String userId = user.getId(); + JsonResult result = this.check(request); + if (0 != result.getCode()) { + log.info("添加应急事件:校验失败:{}", result.getMsg()); + return result; + } + Accident accident = this.buildAccident(userId, request); + accident.setTenantId(user.getTenantId()); + accident.setDeptId(user.getDeptId()); + Integer count = accidentMapper.insert(accident); + if (count <= 0) { + log.info("事故忽略,修改预警信息失败"); + } + + return JsonResult.success(); + } + + /** + * 检查参数 + * + * @param request + * @return + */ + private JsonResult check(AddAccidentRequest request) { + if (StringUtils.isEmpty(request.getName())) { + throw new ServiceException("应急事件名称为空"); + } + if (StringUtils.isEmpty(request.getLatitude()) || StringUtils.isNull(request.getLongitude())) { + throw new ServiceException("应急事件位置为空"); + } + if (StringUtils.isEmpty(request.getRoadId())) { + throw new ServiceException("应急事件公路为空"); + } + if (StringUtils.isEmpty(request.getSectionId())) { + throw new ServiceException("应急事件路段为空"); + } + if (StringUtils.isEmpty(request.getImage())) { + throw new ServiceException("应急事件图片为空"); + } + return JsonResult.success(); + } + + /** + * 修改预警记录信息 + * + * @param userId + * @param userId + */ + private Accident buildAccident(String userId, AddAccidentRequest request) { + Accident accident = AccidentConverMapper.INSTANCE.addAccidentRequestToAccident(request); + accident.setReportType(AccidentReportTypeEnum.MANUAL.getCode()); + accident.setStatus(AccidentStatusEnum.UNTREATED.getCode()); + accident.setCreateUser(userId); + accident.setCreateTime(DateUtils.now()); + accident.setIgnoreTime(DateUtils.now()); + return accident; + } +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java new file mode 100644 index 0000000..8842026 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java @@ -0,0 +1,204 @@ +package com.tuoheng.admin.service.accident.statistics; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tuoheng.admin.entity.Accident; +import com.tuoheng.admin.entity.Dept; +import com.tuoheng.admin.entity.QuestionType; +import com.tuoheng.admin.entity.User; +import com.tuoheng.admin.enums.DataPermissionEnum; +import com.tuoheng.admin.enums.FlagEnum; +import com.tuoheng.admin.enums.MarkEnum; +import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; +import com.tuoheng.admin.mapper.AccidentMapper; +import com.tuoheng.admin.mapper.DeptMapper; +import com.tuoheng.admin.mapper.QuestionTypeMapper; +import com.tuoheng.admin.mapper.UserMapper; +import com.tuoheng.admin.request.accident.QuestionTypeStatisticsVo; +import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.admin.vo.accident.AccidentPromptlyLookVo; +import com.tuoheng.admin.vo.accident.AccidentStatisticsVo; +import com.tuoheng.admin.vo.accident.QueryAccidentPageVO; +import com.tuoheng.common.core.utils.DateUtils; +import com.tuoheng.common.core.utils.JsonResult; +import com.tuoheng.common.core.utils.StringUtils; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 查询事故卡片分页列表业务层处理 + * + * @author wanjing + * @team tuoheng + * @date 2024-01-20 + */ +@Slf4j +@Service +public class StatisticsByMonthService { + + @Autowired + private DeptMapper deptMapper; + + @Autowired + private QuestionTypeMapper questionTypeMapper; + + @Autowired + private AccidentMapper accidentMapper; + + public JsonResult statistics() { + User user = CurrentUserUtil.getUserInfo(); + String tenantId = user.getTenantId(); + List deptIdList = this.getDeptIdList(user, user.getDeptId()); + List questionTypeList = questionTypeMapper.selectList(new LambdaQueryWrapper() + .eq(QuestionType::getMark, MarkEnum.VALID.getCode())); + List searchTimeList = this.getSearchTimeList(); + List accidentStatisticsVoList = new ArrayList<>(); + AccidentStatisticsVo accidentStatisticsVo; + List questionTypeStatisticsVoList = new ArrayList<>(); + QuestionTypeStatisticsVo questionTypeStatisticsVo; + for (SearchTime searchTime : searchTimeList) { + List accidentList = accidentMapper.selectList(Wrappers.lambdaQuery() + .eq(Accident::getTenantId, tenantId) + .eq(Accident::getReportType, AccidentReportTypeEnum.AUTO.getCode()) + .in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) + .between(Accident::getCreateTime, searchTime.getBeginTime(), searchTime.getEndTime()) + .eq(Accident::getMark, MarkEnum.VALID.getCode()) + .orderByDesc(Accident::getCreateTime)); + Integer questionCount = 0; + for (QuestionType questionType : questionTypeList) { + questionTypeStatisticsVo = new QuestionTypeStatisticsVo(); + questionTypeStatisticsVo.setQuestionId(questionType.getId()); + questionTypeStatisticsVo.setQuestionCode(questionType.getCode()); + questionTypeStatisticsVo.setQuestionName(questionType.getContent()); + for (Accident accident : accidentList) { + if (questionType.getCode().equals(accident.getQuestionCode())) { + questionCount++; + } + } + questionTypeStatisticsVo.setCount(questionCount); + questionTypeStatisticsVoList.add(questionTypeStatisticsVo); + } + accidentStatisticsVo = new AccidentStatisticsVo(); + accidentStatisticsVo.setYear(searchTime.getYear()); + accidentStatisticsVo.setMonth(searchTime.getMonth()); + accidentStatisticsVo.setQuestionTypeStatisticsList(questionTypeStatisticsVoList); + accidentStatisticsVoList.add(accidentStatisticsVo); + } + return JsonResult.success(accidentStatisticsVoList); + } + + /** + * 根据用户自己的数据权限,查询对应部门的数据 + * + * @param user + * @return + */ + private List getDeptIdList(User user, String deptId) { + List deptIdList = new ArrayList<>(); + if (StringUtils.isNotEmpty(deptId)) { + deptIdList.add(deptId); + return deptIdList; + } + if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { + return null; + } else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { + deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); + } else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { + deptIdList.add(user.getDeptId()); + } + return deptIdList; + } + + private List getSearchTimeList() { + List searchTimeList = new ArrayList<>(); + Integer currentYear = DateUtils.getYear(); + Integer currentMonth = DateUtils.getMonth(); + SearchTime searchTime1 = new SearchTime(); + SearchTime searchTime2 = new SearchTime(); + SearchTime searchTime3 = new SearchTime(); + Integer year1; + Integer year2; + Integer year3; + Integer month1; + Integer month2; + Integer month3; + Integer day = 1; + if (1 == currentMonth) { + year1 = currentYear - 1; + year2 = currentYear - 1; + year3 = currentYear; + month1 = 11; + month2 = 12; + month3 = currentMonth; + } else if (2 == currentMonth) { + year1 = currentYear - 1; + year2 = currentYear; + year3 = currentYear; + month1 = 12; + month2 = currentMonth - 1; + month3 = currentMonth; + } else { + year1 = currentYear; + year2 = currentYear; + year3 = currentYear; + month1 = currentMonth - 2; + month2 = currentMonth - 1; + month3 = currentMonth; + } + + LocalDate localDate1 = LocalDate.of(year1, month1, day); + LocalDate firstDayOfMonth1 = localDate1.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth1 = localDate1.with(TemporalAdjusters.lastDayOfMonth()); + searchTime1.setYear(year1); + searchTime1.setMonth(month1); + searchTime1.setBeginTime(firstDayOfMonth1 + " 00:00:00"); + searchTime1.setEndTime(lastDayOfMonth1 + " 23:59:59"); + + LocalDate localDate2 = LocalDate.of(year2, month2, day); + LocalDate firstDayOfMonth2 = localDate2.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth2 = localDate2.with(TemporalAdjusters.lastDayOfMonth()); + searchTime2.setYear(year2); + searchTime2.setMonth(month2); + searchTime2.setBeginTime(firstDayOfMonth2 + " 00:00:00"); + searchTime2.setEndTime(lastDayOfMonth2 + " 23:59:59"); + + LocalDate localDate3 = LocalDate.of(year3, month3, day); + LocalDate firstDayOfMonth3 = localDate3.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth3 = localDate3.with(TemporalAdjusters.lastDayOfMonth()); + searchTime3.setYear(year3); + searchTime3.setMonth(month3); + searchTime3.setBeginTime(firstDayOfMonth3 + " 00:00:00"); + searchTime3.setEndTime(lastDayOfMonth3 + " 23:59:59"); + + searchTimeList.add(searchTime1); + searchTimeList.add(searchTime2); + searchTimeList.add(searchTime3); + return searchTimeList; + } +} + +@Data +class SearchTime { + + private Integer year; + + private Integer month; + + private String beginTime; + + private String endTime; + +} \ No newline at end of file diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java new file mode 100644 index 0000000..c26a896 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java @@ -0,0 +1,33 @@ +package com.tuoheng.admin.vo.accident; + +import com.tuoheng.admin.request.accident.QuestionTypeStatisticsVo; +import lombok.Data; + +import java.util.List; + +/** + * 事件月份统计 返回实体类 + * + * @author wanjing + * @team tuoheng + * @date 2024-01-19 + */ +@Data +public class AccidentStatisticsVo { + + /** + * 年 + */ + private Integer year; + + /** + * 月份 + */ + private Integer month; + + /** + * 问题类型统计 + */ + private List questionTypeStatisticsList; + +} -- 2.27.0 From c264fa5049299a9e4ab2e865f6f13d9486bc0f25 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Tue, 23 Jan 2024 11:05:52 +0800 Subject: [PATCH 04/22] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tuoheng/common/core/utils/DateUtils.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java b/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java index ad66e23..fc507a7 100644 --- a/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java +++ b/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java @@ -435,4 +435,34 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils { return DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, closest); } + public static Integer getYear() { + LocalDate localDate = LocalDate.now(); + return localDate.getYear(); + } + + public static Integer getMonth() { + LocalDate localDate = LocalDate.now(); + return localDate.getMonthValue(); + } + + /** + * 获得多少个月以前(正数)或以后(负数)的时间,格式化成yyyy-MM-dd HH:mm:ss:SS + */ + public static String getMonthBefore(int month) { + Calendar calendar = Calendar.getInstance();//日历对象 + calendar.setTime(date); //设置当前日期 + calendar.add(Calendar.MONTH, month);//为负月份减,为正月份加 + return sdf.format(calendar.getTime()); + } + + /** + * 获得多少年以前(正数)或以后(负数)的时间,格式化成yyyy-MM-dd HH:mm:ss:SS + */ + public static String getYearBefore(int year) { + Calendar calendar = Calendar.getInstance();//日历对象 + calendar.setTime(date); //设置当前日期 + calendar.add(Calendar.YEAR, year); //为负年减,为年份加 + return sdf.format(calendar.getTime()); + } + } -- 2.27.0 From 54584000580e649561b9d3abcddc32871bb0d361 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Tue, 23 Jan 2024 11:15:03 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tuoheng/common/core/utils/DateUtils.java | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java b/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java index fc507a7..694d18c 100644 --- a/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java +++ b/tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java @@ -445,24 +445,4 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils { return localDate.getMonthValue(); } - /** - * 获得多少个月以前(正数)或以后(负数)的时间,格式化成yyyy-MM-dd HH:mm:ss:SS - */ - public static String getMonthBefore(int month) { - Calendar calendar = Calendar.getInstance();//日历对象 - calendar.setTime(date); //设置当前日期 - calendar.add(Calendar.MONTH, month);//为负月份减,为正月份加 - return sdf.format(calendar.getTime()); - } - - /** - * 获得多少年以前(正数)或以后(负数)的时间,格式化成yyyy-MM-dd HH:mm:ss:SS - */ - public static String getYearBefore(int year) { - Calendar calendar = Calendar.getInstance();//日历对象 - calendar.setTime(date); //设置当前日期 - calendar.add(Calendar.YEAR, year); //为负年减,为年份加 - return sdf.format(calendar.getTime()); - } - } -- 2.27.0 From 2107a9709b62e34fe0ed11711cddfff566f4ec5d Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Thu, 25 Jan 2024 15:53:39 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=AB=98=E9=80=9F?= =?UTF-8?q?=E5=BA=94=E6=80=A5=E4=BA=8B=E4=BB=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/constant/DroneControlConstant.java | 32 +++ .../admin/controller/AccidentController.java | 70 ++++--- .../com/tuoheng/admin/entity/Accident.java | 2 +- .../enums/{ => accident}/AccidentEnum.java | 2 +- .../{ => accident}/AccidentStatusEnum.java | 2 +- .../{ => accident}/AccidentTaskEnum.java | 2 +- .../tuoheng/admin/mapper/AccidentMapper.java | 15 +- .../request/accident/AddAccidentRequest.java | 5 - ...QueryAccidentRealtimeInfoListRequest.java} | 2 +- .../accident/QueryHistoryPageListRequest.java | 33 +++ .../accident/AccidentNoticeService.java | 4 +- .../service/accident/AccidentServiceImpl.java | 28 ++- .../service/accident/AccidentTipsService.java | 6 +- .../service/accident/IAccidentService.java | 31 ++- .../service/accident/TimeAxisService.java | 3 +- .../accident/add/AddAccidentService.java | 39 +++- .../ignore/AccidentIgnoreService.java | 38 ++-- .../QueryAccidentCardPageListService.java | 7 - .../query/QueryAccidentDetailsService.java | 2 +- .../QueryAccidentHistoryListService.java | 193 ++++++++++++++++++ ...QueryAccidentRealtimeInfoListService.java} | 34 +-- .../reoprt/ReportAccidentService.java | 2 +- .../reoprt/ReportNoAccidentService.java | 4 +- .../AccidentVerifyCompletedService.java | 2 +- .../verify/AccidentVerifyService.java | 2 +- .../accidentread/AccidentReadServiceImpl.java | 7 +- .../service/third/airport/AirportService.java | 1 + .../third/airport/AirportServiceImpl.java | 6 + .../third/airport/PointFlightService.java | 2 +- .../control/AirportDroneControlService.java | 58 ++++++ .../airport/control/DroneContinueService.java | 48 +++++ .../airport/control/DroneExecuteService.java | 45 ++++ .../airport/control/DronePauseService.java | 41 ++++ .../control/DroneReturnHomeService.java | 39 ++++ .../airport/control/DroneUndoService.java | 45 ++++ .../third/dsp/DspCallbackServiceImpl.java | 2 +- .../tuoheng/admin/vo/accident/AccidentVo.java | 17 +- .../main/resources/mapper/AccidentMapper.xml | 24 ++- 38 files changed, 736 insertions(+), 159 deletions(-) create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/DroneControlConstant.java rename tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/{ => accident}/AccidentEnum.java (95%) rename tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/{ => accident}/AccidentStatusEnum.java (91%) rename tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/{ => accident}/AccidentTaskEnum.java (90%) rename tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/{QueryAccidentCardListRequest.java => QueryAccidentRealtimeInfoListRequest.java} (88%) create mode 100755 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryHistoryPageListRequest.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentHistoryListService.java rename tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/{QueryAccidentCardListService.java => QueryAccidentRealtimeInfoListService.java} (81%) create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/DroneControlConstant.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/DroneControlConstant.java new file mode 100644 index 0000000..3cd4d81 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/DroneControlConstant.java @@ -0,0 +1,32 @@ +package com.tuoheng.admin.constant; + +/** + * 无人机操控指令 + * + * @author wanjing + * @team tuoheng + * @date 2023-06-25 + */ +public interface DroneControlConstant { + + /** + * 悬停 + */ + String PAUSE = "01"; + + /** + * 终止降落 + */ + String TERMINATE_LANDING = "02"; + + /** + * 返航 + */ + String RETURN_HOME = "03"; + + /** + * 继续飞行 + */ + String RECOVERY = "04"; + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index bb67791..0a3fb80 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -2,12 +2,13 @@ package com.tuoheng.admin.controller; import com.tuoheng.admin.query.AccidentQuery; import com.tuoheng.admin.request.accident.*; -import com.tuoheng.admin.request.dept.AddDeptRequest; import com.tuoheng.admin.service.accident.IAccidentService; import com.tuoheng.common.core.utils.JsonResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * 事故前端控制器 * @@ -22,21 +23,50 @@ public class AccidentController { private IAccidentService accidentService; /** - * 查询事故卡片分页列表 + * 查询事件实时信息列表 */ - @GetMapping("/card/page/list") - public JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request) { -// log.info("进入查询事故分页列表接口"); - return accidentService.getAccidentCardPageList(request); + @GetMapping("/realtime/info/list") + public JsonResult getRealtimeInfoList(QueryAccidentRealtimeInfoListRequest request) { +// log.info("进入查询事件实时信息接口"); + return accidentService.getRealtimeInfoList(request); + } + + /** + * 查询历史事件列表 + */ + @GetMapping("/history/page/list") + public JsonResult getHistoryPageList(QueryHistoryPageListRequest request) { +// log.info("进入查询历史事件列表接口"); + return accidentService.getHistoryPageList(request); + } + + /** + * 忽略 + * + * @return + */ + @PostMapping("/ignore/{idList}") + public JsonResult ignore(@PathVariable("idList") List idList){ + return accidentService.ignore(idList); + } + + /** + * 事件核实完成 + * @param request + * @return + */ + @PostMapping("/verify/completed") + public JsonResult verifyCompleted(AccidentVerifyCompletedRequest request) { + return accidentService.verifyCompleted(request); } /** - * 查询事故卡片列表 + * 查询事故卡片分页列表 */ - @GetMapping("/card/list") - public JsonResult getAccidentCardList(QueryAccidentCardListRequest request) { + @GetMapping("/card/page/list") + public JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request) { // log.info("进入查询事故分页列表接口"); - return accidentService.getAccidentCardList(request); + return accidentService.getAccidentCardPageList(request); } /** @@ -105,15 +135,7 @@ public class AccidentController { return accidentService.verify(request); } - /** - * 事故核实完成 - * @param request - * @return - */ - @PostMapping("/verify/completed") - public JsonResult verifyCompleted(AccidentVerifyCompletedRequest request) { - return accidentService.verifyCompleted(request); - } + /** * 事故上报 @@ -131,15 +153,7 @@ public class AccidentController { return accidentService.noAccident(request); } - /** - * 预警忽略 - * - * @return - */ - @PostMapping("/ignore/{id}") - public JsonResult ignore(@PathVariable("id") String id){ - return accidentService.ignore(id); - } + /** * 新增应急事件 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java index 0fa9c58..c048fd7 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java @@ -128,7 +128,7 @@ public class Accident extends BaseEntity { private Integer uavReturn; /** - * 事故状态:1未处理 2处理中 3已忽略 4已处理 + * 事故状态:1未处理 2处理中 3已忽略 4已处理 5已完成 */ private Integer status; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentEnum.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentEnum.java similarity index 95% rename from tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentEnum.java rename to tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentEnum.java index efdefa4..49e1254 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentEnum.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentEnum.java @@ -1,4 +1,4 @@ -package com.tuoheng.admin.enums; +package com.tuoheng.admin.enums.accident; /** * @Author ChengWang diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentStatusEnum.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentStatusEnum.java similarity index 91% rename from tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentStatusEnum.java rename to tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentStatusEnum.java index 5c4182f..146543f 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentStatusEnum.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentStatusEnum.java @@ -1,4 +1,4 @@ -package com.tuoheng.admin.enums; +package com.tuoheng.admin.enums.accident; import lombok.Getter; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentTaskEnum.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentTaskEnum.java similarity index 90% rename from tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentTaskEnum.java rename to tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentTaskEnum.java index 4a5385d..fc23cca 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AccidentTaskEnum.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/accident/AccidentTaskEnum.java @@ -1,4 +1,4 @@ -package com.tuoheng.admin.enums; +package com.tuoheng.admin.enums.accident; import lombok.Getter; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java index 49b226b..ab8f5c6 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java @@ -4,8 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.tuoheng.admin.entity.Accident; -import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; +import com.tuoheng.admin.request.accident.QueryAccidentRealtimeInfoListRequest; import com.tuoheng.admin.request.accident.QueryAccidentCardPageListRequest; +import com.tuoheng.admin.request.accident.QueryHistoryPageListRequest; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -25,11 +26,19 @@ public interface AccidentMapper extends BaseMapper { Page selectPageList(@Param("page") IPage page, @Param("request") QueryAccidentCardPageListRequest request); /** - * 查询事故分页列表 + * 查询实时事件信息列表 + * + * @param request 事故查询实体 + * @return 事故集合 + */ + List getRealtimeInfoList(@Param("request") QueryAccidentRealtimeInfoListRequest request); + + /** + * 查询历史事件分页列表 * * @param request 事故查询实体 * @return 事故集合 */ - List selectAccidentCardList(@Param("request") QueryAccidentCardListRequest request); + Page getHistoryPageList(@Param("page") IPage page, @Param("request") QueryHistoryPageListRequest request); } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java index c637514..162b970 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java @@ -31,11 +31,6 @@ public class AddAccidentRequest { */ private String roadId; - /** - * 公路编码 - */ - private String roadCode; - /** * 路段ID */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentRealtimeInfoListRequest.java similarity index 88% rename from tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java rename to tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentRealtimeInfoListRequest.java index 3f45418..4c8ab54 100755 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentRealtimeInfoListRequest.java @@ -12,7 +12,7 @@ import java.util.List; * @date 2023-03-20 */ @Data -public class QueryAccidentCardListRequest { +public class QueryAccidentRealtimeInfoListRequest { /** * 任务状态 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryHistoryPageListRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryHistoryPageListRequest.java new file mode 100755 index 0000000..6c4e9af --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryHistoryPageListRequest.java @@ -0,0 +1,33 @@ +package com.tuoheng.admin.request.accident; + +import com.tuoheng.common.core.common.BaseQuery; +import lombok.Data; + +import java.util.List; + +/** + * 查询事故卡片请求实体 + * + * @author wanjing + * @team tuoheng + * @date 2023-03-20 + */ +@Data +public class QueryHistoryPageListRequest extends BaseQuery { + + /** + * 任务状态 + */ + private List statusList; + + /** + * 租户Id + */ + private String tenantId; + + /** + * 部门Id list + */ + private List deptIdList; + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java index 70e26f3..dfd5f4b 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentNoticeService.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.AccidentRead; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.enums.DataPermissionEnum; import com.tuoheng.admin.enums.FlagEnum; import com.tuoheng.admin.enums.MarkEnum; @@ -14,9 +14,7 @@ import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.AccidentReadMapper; import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.utils.CurrentUserUtil; -import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.JsonResult; -import com.tuoheng.common.core.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index c205aac..a676946 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -18,6 +18,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * @Author ChengWang * @Date 2023/3/2 @@ -33,7 +35,10 @@ public class AccidentServiceImpl extends BaseServiceImpl idList) { + return accidentIgnoreService.ignore(idList); } /** diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java index 24636fd..e90d629 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentTipsService.java @@ -1,14 +1,10 @@ package com.tuoheng.admin.service.accident; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.Dept; import com.tuoheng.admin.entity.Section; -import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentEnum; -import com.tuoheng.admin.enums.MarkEnum; -import com.tuoheng.admin.enums.DataPermissionEnum; +import com.tuoheng.admin.enums.accident.AccidentEnum; import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.SectionMapper; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java index 2f1c5f9..6519a90 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/IAccidentService.java @@ -3,16 +3,33 @@ package com.tuoheng.admin.service.accident; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.query.AccidentQuery; import com.tuoheng.admin.request.accident.*; -import com.tuoheng.admin.request.dept.AddDeptRequest; import com.tuoheng.common.core.common.IBaseService; import com.tuoheng.common.core.utils.JsonResult; +import java.util.List; + /** * @Author ChengWang * @Date 2022/11/17 */ public interface IAccidentService extends IBaseService { + /** + * 查询实时事件信息列表 + * + * @param request 事件列表查询实体 + * @return 事件集合 + */ + JsonResult getRealtimeInfoList(QueryAccidentRealtimeInfoListRequest request); + + /** + * 查询历史事件分页列表 + * + * @param request 事件列表查询实体 + * @return 事件集合 + */ + JsonResult getHistoryPageList(QueryHistoryPageListRequest request); + /** * 新增应急事件 * @@ -29,14 +46,6 @@ public interface IAccidentService extends IBaseService { */ JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request); - /** - * 查询事故列表 - * - * @param request 事故列表查询实体 - * @return 巡检任务集合 - */ - JsonResult getAccidentCardList(QueryAccidentCardListRequest request); - /** * 查询事故信息 * @@ -119,10 +128,10 @@ public interface IAccidentService extends IBaseService { /** * 忽略 * - * @param id + * @param idList * @return */ - JsonResult ignore(String id); + JsonResult ignore(List idList); /** * 统计月份数据 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java index f964ee4..cf456cc 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java @@ -1,12 +1,11 @@ package com.tuoheng.admin.service.accident; -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.AccidentRead; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentEnum; +import com.tuoheng.admin.enums.accident.AccidentEnum; import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.AccidentReadMapper; import com.tuoheng.admin.mapper.UserMapper; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java index c574f2c..b0d3e6f 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java @@ -1,11 +1,18 @@ package com.tuoheng.admin.service.accident.add; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.conver.AccidentConverMapper; import com.tuoheng.admin.entity.Accident; +import com.tuoheng.admin.entity.RoadInformation; +import com.tuoheng.admin.entity.Section; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; +import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; import com.tuoheng.admin.mapper.AccidentMapper; +import com.tuoheng.admin.mapper.RoadInformationMapper; +import com.tuoheng.admin.mapper.SectionMapper; import com.tuoheng.admin.request.accident.AddAccidentRequest; import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.common.core.exception.ServiceException; @@ -30,6 +37,12 @@ public class AddAccidentService { @Autowired private AccidentMapper accidentMapper; + @Autowired + private RoadInformationMapper roadInformationMapper; + + @Autowired + private SectionMapper sectionMapper; + public JsonResult add(AddAccidentRequest request) { // log.info("进入添加应急事件业务, id={}", id); User user = CurrentUserUtil.getUserInfo(); @@ -39,7 +52,7 @@ public class AddAccidentService { log.info("添加应急事件:校验失败:{}", result.getMsg()); return result; } - Accident accident = this.buildAccident(userId, request); + Accident accident = this.buildAccident(user, request); accident.setTenantId(user.getTenantId()); accident.setDeptId(user.getDeptId()); Integer count = accidentMapper.insert(accident); @@ -78,16 +91,30 @@ public class AddAccidentService { /** * 修改预警记录信息 * - * @param userId - * @param userId + * @param user + * @param request */ - private Accident buildAccident(String userId, AddAccidentRequest request) { + private Accident buildAccident(User user, AddAccidentRequest request) { Accident accident = AccidentConverMapper.INSTANCE.addAccidentRequestToAccident(request); accident.setReportType(AccidentReportTypeEnum.MANUAL.getCode()); accident.setStatus(AccidentStatusEnum.UNTREATED.getCode()); - accident.setCreateUser(userId); + accident.setCreateUser(user.getId()); accident.setCreateTime(DateUtils.now()); accident.setIgnoreTime(DateUtils.now()); + RoadInformation roadInformation = roadInformationMapper.selectOne(Wrappers.lambdaQuery() + .eq(RoadInformation::getTenantId, user.getTenantId()) + .eq(RoadInformation::getId, request.getRoadId()) + .eq(RoadInformation::getMark, MarkEnum.VALID.getCode())); + if (ObjectUtil.isNotEmpty(roadInformation)) { + accident.setRoadCode(roadInformation.getCode()); + } + Section section = sectionMapper.selectOne(Wrappers.
lambdaQuery() + .eq(Section::getTenantId, user.getTenantId()) + .eq(Section::getId, request.getSectionId()) + .eq(Section::getMark, MarkEnum.VALID.getCode())); + if (ObjectUtil.isNotEmpty(section)) { + accident.setSectionName(section.getCode()); + } return accident; } } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java index b7ed2ea..71a3d69 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java @@ -1,22 +1,22 @@ package com.tuoheng.admin.service.accident.ignore; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.mapper.AccidentMapper; -import com.tuoheng.admin.request.accident.ReportAccidentRequest; import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.DateUtils; import com.tuoheng.common.core.utils.JsonResult; -import com.tuoheng.common.core.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * 忽略事故业务层处理 * @@ -31,12 +31,12 @@ public class AccidentIgnoreService { @Autowired private AccidentMapper accidentMapper; - public JsonResult ignore(String id) { + public JsonResult ignore(List idList) { // log.info("进入忽略事故业务, id={}", id); User user = CurrentUserUtil.getUserInfo(); String userId = user.getId(); String tenantId = user.getTenantId(); - JsonResult result = this.check(tenantId, id); + JsonResult result = this.check(tenantId, idList); if (0 != result.getCode()) { log.info("忽略事故业务:校验失败:{}", result.getMsg()); return result; @@ -52,24 +52,28 @@ public class AccidentIgnoreService { * 检查参数 * * @param tenantId - * @param id + * @param idList * @return */ - private JsonResult check(String tenantId, String id) { - if (StringUtils.isEmpty(id)) { - throw new ServiceException("事故ID为空"); + private JsonResult check(String tenantId, List idList) { + if (CollectionUtil.isEmpty(idList)) { + throw new ServiceException("应急事件idList为空"); } - Accident accident = accidentMapper.selectOne(new LambdaQueryWrapper() + List accidentList = accidentMapper.selectList(new LambdaQueryWrapper() .eq(Accident::getTenantId, tenantId) - .eq(Accident::getId, id) + .in(Accident::getId, idList) .eq(Accident::getMark, MarkEnum.VALID.getCode())); - if (ObjectUtil.isNull(accident)) { - throw new ServiceException("事故不存在"); + if (CollectionUtil.isEmpty(accidentList)) { + throw new ServiceException("应急事件不存在"); } - if (AccidentStatusEnum.UNTREATED.getCode() != accident.getStatus()) { - throw new ServiceException("未处理的事故才能忽略"); + + for (Accident accident : accidentList) { + if (AccidentStatusEnum.UNTREATED.getCode() != accident.getStatus()) { + log.info("未处理的应急事件才能忽略, accidentId={}", accident.getId()); + throw new ServiceException("未处理的应急事件才能忽略"); + } } - return JsonResult.success(accident); + return JsonResult.success(accidentList); } /** diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java index 99b83fb..b98363f 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java @@ -107,13 +107,6 @@ public class QueryAccidentCardPageListService { deptName = deptNameMap.get(accidentVo.getDeptId()); accidentVo.setDeptName(deptName); } - if (ObjectUtil.isNotNull(userMap)) { - user = userMap.get(accidentVo.getDeptId()); - if (ObjectUtil.isNotNull(user)) { - accidentVo.setDepartmentHead(user.getRealname()); - accidentVo.setDepartmentHeadTelephone(user.getMobile()); - } - } } return accidentVoList; } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentDetailsService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentDetailsService.java index dd86120..1212ab6 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentDetailsService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentDetailsService.java @@ -3,7 +3,7 @@ package com.tuoheng.admin.service.accident.query; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.tuoheng.admin.entity.*; -import com.tuoheng.admin.enums.AccidentEnum; +import com.tuoheng.admin.enums.accident.AccidentEnum; import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.vo.accident.AccidentDetailsVo; import com.tuoheng.common.core.config.common.CommonConfig; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentHistoryListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentHistoryListService.java new file mode 100644 index 0000000..ed3ccd3 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentHistoryListService.java @@ -0,0 +1,193 @@ +package com.tuoheng.admin.service.accident.query; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tuoheng.admin.conver.AccidentConverMapper; +import com.tuoheng.admin.entity.*; +import com.tuoheng.admin.enums.DataPermissionEnum; +import com.tuoheng.admin.enums.MarkEnum; +import com.tuoheng.admin.mapper.*; +import com.tuoheng.admin.request.accident.QueryHistoryPageListRequest; +import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.admin.vo.accident.AccidentVo; +import com.tuoheng.admin.vo.inspection.InspectionVo; +import com.tuoheng.common.core.config.common.CommonConfig; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 查询历史事件列表业务层处理 + * + * @author wanjing + * @team tuoheng + * @date 2023-03-03 + */ +@Slf4j +@Service +public class QueryAccidentHistoryListService { + + @Autowired + private DeptMapper deptMapper; + + @Autowired + private UserMapper userMapper; + + @Autowired + private InspectionFileMapper inspectionFileMapper; + + @Autowired + private AccidentMapper accidentMapper; + + @Autowired + private InspectionMapper inspectionMapper; + + public JsonResult getPageList(QueryHistoryPageListRequest request) { +// log.info("进入查询历史事件分页列表业务"); + User user = CurrentUserUtil.getUserInfo(); + String tenantId = user.getTenantId(); + + JsonResult result = this.check(tenantId, request); + if (0 != result.getCode()) { + log.info("进入查询历史事件分页列表业务:校验失败:{}", result.getMsg()); + return result; + } + + List deptIdList = this.getDeptIdList(user); + request.setDeptIdList(deptIdList); + request.setTenantId(tenantId); + + IPage page = new Page<>(request.getPage(), request.getLimit()); + IPage pageData = accidentMapper.getHistoryPageList(page, request); + if (null == pageData || pageData.getTotal() == 0) { + log.info("查询历史事件分页列表为空"); + return JsonResult.success(pageData); + } + List accidentVoList = this.buildAccidentVoList(pageData.getRecords()); + IPage voPageData = new Page<>(); + voPageData.setPages(pageData.getPages()); + voPageData.setCurrent(pageData.getCurrent()); + voPageData.setSize(pageData.getSize()); + voPageData.setTotal(pageData.getTotal()); + voPageData.setRecords(accidentVoList); + return JsonResult.success(voPageData); + } + + /** + * 检查参数 + * + * @param tenantId + * @param request + * @return + */ + private JsonResult check(String tenantId, QueryHistoryPageListRequest request) { + return JsonResult.success(); + } + + /** + * 根据用户自己的数据权限,查询对应部门的数据 + * + * @param user + * @return + */ + private List getDeptIdList(User user) { + List deptIdList = new ArrayList<>(); + if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { + return null; + } else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { + deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); + } else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { + deptIdList.add(user.getDeptId()); + } + return deptIdList; + } + + /** + * @param accidentList + * @return + */ + private List buildAccidentVoList(List accidentList) { + Map deptNameMap = this.getDeptMap(accidentList); + Map inspectionFileMap = this.getInspectionFileMap(accidentList); + Map inspectionMap = this.getInspectionMap(accidentList); + List accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); + String deptName; + User user; + InspectionFile inspectionFile; + Inspection inspection; + for (AccidentVo accidentVo : accidentVoList) { + if (ObjectUtil.isNotNull(deptNameMap)) { + deptName = deptNameMap.get(accidentVo.getDeptId()); + accidentVo.setDeptName(deptName); + } + if (ObjectUtil.isNotNull(inspectionFileMap)) { + inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); + if (ObjectUtil.isNotNull(inspectionFile)) { + accidentVo.setFileName(inspectionFile.getFileName()); + accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage()); + accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal()); + accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); + } + } + if(ObjectUtil.isNotNull(inspectionMap)){ + inspection = inspectionMap.get(accidentVo.getInspectionId()); + if(ObjectUtil.isNotNull(inspection)){ + accidentVo.setInspectionStatus(inspection.getStatus()); + } + } + } + return accidentVoList; + } + + private Map getInspectionMap(List accidentList) { + if (CollectionUtil.isEmpty(accidentList)) { + return null; + } + List inspectionIdList = accidentList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList()); + List inspectionList = inspectionMapper.selectList(Wrappers.lambdaQuery() + .eq(Inspection::getMark, MarkEnum.VALID.getCode()) + .in(Inspection::getId, inspectionIdList)); + Map inspectionMap = inspectionList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v), HashMap::putAll); + + return inspectionMap; + } + + /** + * 设置列表中每一个的部门名称 + * 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 + * + * @param accidentList + * @return + */ + private Map getDeptMap(List accidentList) { + if (CollectionUtil.isEmpty(accidentList)) { + return null; + } + List deptIdList = accidentList.stream().map(o -> o.getDeptId()).collect(Collectors.toList()); + List deptList = deptMapper.selectListByIdList(deptIdList); + Map deptNameMap = deptList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll); + return deptNameMap; + } + + private Map getInspectionFileMap(List accidentList) { + if (CollectionUtil.isEmpty(accidentList)) { + return null; + } + List inspectionFileIdList = accidentList.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); + List inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper() + .in(InspectionFile::getId, inspectionFileIdList)); + Map inspectionFileMap = inspectionFileList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v), HashMap::putAll); + return inspectionFileMap; + } +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java similarity index 81% rename from tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java rename to tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java index 3070124..8d7fece 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java @@ -9,7 +9,7 @@ import com.tuoheng.admin.entity.*; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.DataPermissionEnum; import com.tuoheng.admin.mapper.*; -import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; +import com.tuoheng.admin.request.accident.QueryAccidentRealtimeInfoListRequest; import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.vo.accident.AccidentVo; import com.tuoheng.common.core.config.common.CommonConfig; @@ -25,7 +25,7 @@ import java.util.Map; import java.util.stream.Collectors; /** - * 查询事故卡片列表业务层处理 + * 查询事件实时信息列表业务层处理 * * @author wanjing * @team tuoheng @@ -33,7 +33,7 @@ import java.util.stream.Collectors; */ @Slf4j @Service -public class QueryAccidentCardListService { +public class QueryAccidentRealtimeInfoListService { @Autowired private DeptMapper deptMapper; @@ -50,8 +50,8 @@ public class QueryAccidentCardListService { @Autowired private InspectionMapper inspectionMapper; - public JsonResult getList(QueryAccidentCardListRequest request) { -// log.info("进入查询事件列表业务"); + public JsonResult getList(QueryAccidentRealtimeInfoListRequest request) { +// log.info("进入事件实时信息列表业务"); User user = CurrentUserUtil.getUserInfo(); String tenantId = user.getTenantId(); @@ -64,7 +64,7 @@ public class QueryAccidentCardListService { List deptIdList = this.getDeptIdList(user); request.setDeptIdList(deptIdList); request.setTenantId(tenantId); - List accidentList = accidentMapper.selectAccidentCardList(request); + List accidentList = accidentMapper.getRealtimeInfoList(request); // 构造返回结果对象 List accidentVoList = this.buildAccidentVoList(accidentList); @@ -79,7 +79,7 @@ public class QueryAccidentCardListService { * @param request * @return */ - private JsonResult check(String tenantId, QueryAccidentCardListRequest request) { + private JsonResult check(String tenantId, QueryAccidentRealtimeInfoListRequest request) { return JsonResult.success(); } @@ -107,7 +107,6 @@ public class QueryAccidentCardListService { */ private List buildAccidentVoList(List accidentList) { Map deptNameMap = this.getDeptMap(accidentList); - Map userMap = this.getUserMap(deptNameMap); Map inspectionFileMap = this.getInspectionFileMap(accidentList); Map inspectionMap = this.getInspectionMap(accidentList); List accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); @@ -120,13 +119,6 @@ public class QueryAccidentCardListService { deptName = deptNameMap.get(accidentVo.getDeptId()); accidentVo.setDeptName(deptName); } - if (ObjectUtil.isNotNull(userMap)) { - user = userMap.get(accidentVo.getDeptId()); - if (ObjectUtil.isNotNull(user)) { - accidentVo.setDepartmentHead(user.getRealname()); - accidentVo.setDepartmentHeadTelephone(user.getMobile()); - } - } if (ObjectUtil.isNotNull(inspectionFileMap)) { inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); if (ObjectUtil.isNotNull(inspectionFile)) { @@ -176,18 +168,6 @@ public class QueryAccidentCardListService { return deptNameMap; } - private Map getUserMap(Map deptMap) { - if (ObjectUtil.isNull(deptMap)) { - return null; - } - List deptIdList = deptMap.keySet().stream().collect(Collectors.toList()); - List userList = userMapper.selectList(new LambdaQueryWrapper() - .in(User::getDeptId, deptIdList) - .eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())); - Map userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll); - return userMap; - } - private Map getInspectionFileMap(List accidentList) { if (CollectionUtil.isEmpty(accidentList)) { return null; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java index 2c995b0..24c8094 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportAccidentService.java @@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.request.accident.ReportAccidentRequest; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java index dda6b71..6c6b106 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/reoprt/ReportNoAccidentService.java @@ -5,14 +5,12 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.Inspection; -import com.tuoheng.admin.entity.InspectionFile; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.InspectionFileMapper; import com.tuoheng.admin.mapper.InspectionMapper; -import com.tuoheng.admin.request.accident.ReportAccidentRequest; import com.tuoheng.admin.request.accident.ReportNoAccidentRequest; import com.tuoheng.admin.service.third.airport.DroneControlService; import com.tuoheng.admin.utils.CurrentUserUtil; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyCompletedService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyCompletedService.java index 59744fa..17f42ac 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyCompletedService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyCompletedService.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.enums.InspectionStatusEnum; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.mapper.AccidentMapper; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java index 70423e9..102612c 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/verify/AccidentVerifyService.java @@ -10,7 +10,7 @@ import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.InspectionFile; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentStatusEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.enums.InspectionStatusEnum; import com.tuoheng.admin.enums.InspectionTypeEnum; import com.tuoheng.admin.enums.MarkEnum; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java index 76b1378..e153f0c 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accidentread/AccidentReadServiceImpl.java @@ -3,12 +3,9 @@ package com.tuoheng.admin.service.accidentread; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.tuoheng.admin.entity.AccidentRead; -import com.tuoheng.admin.enums.AccidentEnum; +import com.tuoheng.admin.enums.accident.AccidentEnum; import com.tuoheng.admin.mapper.AccidentReadMapper; -import com.tuoheng.admin.service.accident.IAccidentService; import com.tuoheng.admin.utils.CurrentUserUtil; -import com.tuoheng.common.core.common.BaseServiceImpl; -import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.DateUtils; import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.StringUtils; @@ -16,8 +13,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; - /** * @Author ChengWang * @Date 2023/3/2 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java index 0f27a1a..9f5b9e1 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java @@ -33,4 +33,5 @@ public interface AirportService { JsonResult reversalFlight(ReversalFlightRequest request); + JsonResult controlDrone(Integer inspectionId); } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java index e2e6e6b..883ba70 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java @@ -89,4 +89,10 @@ public class AirportServiceImpl implements AirportService { return reversalFlightService.reversalFlight(request); } + @Override + public JsonResult controlDrone(Integer inspectionId) { + return null; + } + + } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java index 80a8394..892f85b 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/PointFlightService.java @@ -7,7 +7,7 @@ import com.tuoheng.admin.constant.SystemConstant; import com.tuoheng.admin.entity.Inspection; import com.tuoheng.admin.entity.Tenant; import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.AccidentEnum; +import com.tuoheng.admin.enums.accident.AccidentEnum; import com.tuoheng.admin.enums.TaskStatusEnum; import com.tuoheng.admin.mapper.InspectionMapper; import com.tuoheng.admin.mapper.TenantMapper; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java new file mode 100644 index 0000000..869e751 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java @@ -0,0 +1,58 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.common.core.config.common.CommonConfig; +import com.tuoheng.common.core.exception.ServiceException; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +/** + * 机场平台回调业务平台 + * + * @author wanjing + * @team tuoheng + * @date 2023-06-25 + */ +@Slf4j +@Service +public class AirportDroneControlService { + + @Autowired + @Qualifier("restTemplate") + private RestTemplate restTemplate; + + + /** + * @return + */ + public JsonResult exec(JSONObject jsonObject) { + String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL; + log.info("调用机场平台,操作无人机,url:{}", url); + log.info("调用机场平台,操作无人机,jsonObject:{}", jsonObject); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity httpEntity = new HttpEntity(jsonObject, headers); + ResponseEntity response; + try { + response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); + } catch (Exception e) { + log.error("调用机场平台,接口异常, url:{}", url); + log.error("调用机场平台,接口异常, httpEntity:{}", httpEntity); + throw new ServiceException("调用机场平台,接口异常"); + } + JsonResult jsonResult = response.getBody(); + if (0 != jsonResult.getCode()) { + log.info("调用机场平台,操作无人机,机场返回失败,jsonResult:{}", jsonResult.getMsg()); + return JsonResult.error(-1, "调用机场平台,操作无人机,机场返回失败"); + } + log.info("调用机场平台,操作无人机结束"); + return JsonResult.success(); + } + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java new file mode 100644 index 0000000..5528814 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java @@ -0,0 +1,48 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.common.core.config.common.CommonConfig; +import com.tuoheng.common.core.exception.ServiceException; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Slf4j +@Service +public class DroneContinueService { + + @Autowired + private AirportDroneControlService airportDroneControlService; + + /** + * 调用机场平台,原无人机继续巡检 + * + * @param airportId 机场Id + * @param taskId 巡检任务Id + */ + public JsonResult continuee(Integer airportId, Integer taskId) { + log.info("继续任务, taskId={}", taskId); + JSONObject jsonObject = this.getJSONObject(airportId, taskId); + JsonResult result = airportDroneControlService.exec(jsonObject); + return result; + } + + /** + * @param airportId + * @param taskId + * @return + */ + private JSONObject getJSONObject(Integer airportId, Integer taskId) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("zhilin", "04"); + jsonObject.put("airportId", airportId); + jsonObject.put("taskId", taskId); + jsonObject.put("msg", "继续巡检"); + return jsonObject; + } +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java new file mode 100644 index 0000000..d7826f7 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java @@ -0,0 +1,45 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class DroneExecuteService { + + @Autowired + private AirportDroneControlService airportDroneControlService; + + /** + * 执行任务 + * + * @param taskId + * @return + */ + public JsonResult callBack(Integer taskId, String url, Integer airportId, String tenantCode) { + log.info("执行任务, taskId={}", taskId); + JSONObject jsonObject = this.getJSONObject(taskId, url, airportId, tenantCode); + JsonResult result = airportDroneControlService.exec(jsonObject); + return result; + } + + /** + * @param taskId + * @param url + * @return + */ + private JSONObject getJSONObject(Integer taskId, String url, Integer airportId, String tenantCode) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("requestId", taskId); + jsonObject.put("airportId", airportId); + jsonObject.put("code", SystemConstant.PLATFORM_CODE); + jsonObject.put("tenantCode", tenantCode); + jsonObject.put("wayUrl", url); + return jsonObject; + } + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java new file mode 100644 index 0000000..80ac743 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java @@ -0,0 +1,41 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.DroneControlConstant; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class DronePauseService { + + @Autowired + private AirportDroneControlService airportDroneControlService; + + /** + * 航线暂停 + * + * @param airportId + * @return + */ + public JsonResult pause(Integer airportId) { + log.info("航线暂停, airportId={}", airportId); + JSONObject jsonObject = this.getJSONObject(airportId); + JsonResult result = airportDroneControlService.exec(jsonObject); + return result; + } + + /** + * @param airportId + * @return + */ + private JSONObject getJSONObject(Integer airportId) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("zhilin", DroneControlConstant.PAUSE); + jsonObject.put("airportId", Integer.valueOf(airportId)); + jsonObject.put("msg", "航线暂停"); + return jsonObject; + } +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java new file mode 100644 index 0000000..632a6c2 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java @@ -0,0 +1,39 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.DroneControlConstant; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +@Slf4j +public class DroneReturnHomeService { + + @Autowired + private AirportDroneControlService airportDroneControlService; + + /** + * 一键返航 + * + * @param airportId + * @return + */ + public JsonResult returnHome(Integer airportId) { + log.info("南京海事局, 一键返航, airportId={}", airportId); + JSONObject jsonObject = this.getJSONObject(airportId); + JsonResult result = airportDroneControlService.exec(jsonObject); + return result; + } + + /** + * @param airportId + * @return + */ + private JSONObject getJSONObject(Integer airportId) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("zhilin", DroneControlConstant.RETURN_HOME); + jsonObject.put("airportId", airportId); + jsonObject.put("msg", "一键返航"); + return jsonObject; + } +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java new file mode 100644 index 0000000..7a187ac --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java @@ -0,0 +1,45 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class DroneUndoService { + + @Autowired + private AirportDroneControlService airportDroneControlService; + + /** + * 取消任务 + * + * @param taskId + * @param airportCode + * @return + */ + public JsonResult callBack(Integer taskId, String airportCode) { + log.info("取消任务, taskId={}", taskId); + JSONObject jsonObject = this.getJSONObject(taskId, airportCode); + JsonResult result = airportDroneControlService.exec(jsonObject); + return result; + } + + /** + * @param taskId + * @param airportCode + * @return + */ + private JSONObject getJSONObject(Integer taskId, String airportCode) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code", SystemConstant.PLATFORM_CODE); +// jsonObject.put("tenantCode", NJHSJConstant.TENANT_CODE); + jsonObject.put("airportCode", airportCode); + jsonObject.put("taskId", taskId); + return jsonObject; + } + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java index 5dfaa77..a316453 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.entity.*; import com.tuoheng.admin.enums.*; import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; +import com.tuoheng.admin.enums.accident.AccidentStatusEnum; import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.request.third.DspCallbackRequest; import com.tuoheng.admin.request.third.QuestionFile; @@ -20,7 +21,6 @@ import com.tuoheng.common.core.config.common.CommonConfig; import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.*; import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java index 0985bb6..c577882 100755 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java @@ -1,18 +1,13 @@ package com.tuoheng.admin.vo.accident; -import com.fasterxml.jackson.annotation.JsonFormat; import com.tuoheng.common.core.common.BaseEntity; import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.math.BigDecimal; -import java.util.Date; /** * 事件对象 * - * @team tuoheng * @author wanjing + * @team tuoheng * @date 2023-03-03 */ @Data @@ -30,16 +25,6 @@ public class AccidentVo extends BaseEntity { */ private String deptName; - /** - * 部门负责人 - */ - private String departmentHead; - - /** - * 部门负责人联系方式 - */ - private String departmentHeadTelephone; - /** * 巡检任务id */ diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index ea63c00..7b07c20 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -84,7 +84,7 @@ order by create_time desc - select from th_accident @@ -107,4 +107,26 @@ order by create_time desc + \ No newline at end of file -- 2.27.0 From a2d46041aa6cdb21cbcf8a90343fbac2eaae0378 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Thu, 25 Jan 2024 16:21:47 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E5=BA=94=E6=80=A5=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/AccidentController.java | 8 +- .../tuoheng/admin/mapper/AccidentMapper.java | 4 +- ...java => QueryAccidentPageListRequest.java} | 2 +- .../service/accident/AccidentServiceImpl.java | 9 +- .../service/accident/IAccidentService.java | 2 +- .../QueryAccidentCardPageListService.java | 218 ------------------ .../query/QueryAccidentPageListService.java | 96 +++++++- .../main/resources/mapper/AccidentMapper.xml | 2 +- 8 files changed, 100 insertions(+), 241 deletions(-) rename tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/{QueryAccidentCardPageListRequest.java => QueryAccidentPageListRequest.java} (94%) delete mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index 0a3fb80..f66aa81 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -61,12 +61,12 @@ public class AccidentController { } /** - * 查询事故卡片分页列表 + * 查询事件分页列表 */ - @GetMapping("/card/page/list") - public JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request) { + @GetMapping("/page/list") + public JsonResult getAccidentPageList(QueryAccidentPageListRequest request) { // log.info("进入查询事故分页列表接口"); - return accidentService.getAccidentCardPageList(request); + return accidentService.getAccidentPageList(request); } /** diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java index ab8f5c6..d232782 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.request.accident.QueryAccidentRealtimeInfoListRequest; -import com.tuoheng.admin.request.accident.QueryAccidentCardPageListRequest; +import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; import com.tuoheng.admin.request.accident.QueryHistoryPageListRequest; import org.apache.ibatis.annotations.Param; @@ -23,7 +23,7 @@ public interface AccidentMapper extends BaseMapper { * @param request 事故查询实体 * @return 事故集合 */ - Page selectPageList(@Param("page") IPage page, @Param("request") QueryAccidentCardPageListRequest request); + Page selectPageList(@Param("page") IPage page, @Param("request") QueryAccidentPageListRequest request); /** * 查询实时事件信息列表 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardPageListRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentPageListRequest.java similarity index 94% rename from tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardPageListRequest.java rename to tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentPageListRequest.java index 8b05541..3518898 100755 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardPageListRequest.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentPageListRequest.java @@ -16,7 +16,7 @@ import java.util.List; * @date 2022-11-17 */ @Data -public class QueryAccidentCardPageListRequest extends BaseQuery { +public class QueryAccidentPageListRequest extends BaseQuery { /** * 公路名称 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index a676946..5758cb0 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -31,9 +31,6 @@ public class AccidentServiceImpl extends BaseServiceImpl { * @param request 事故分页列表查询实体 * @return 巡检任务集合 */ - JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request); + JsonResult getAccidentPageList(QueryAccidentPageListRequest request); /** * 查询事故信息 diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java deleted file mode 100644 index b98363f..0000000 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardPageListService.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.tuoheng.admin.service.accident.query; - -import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.tuoheng.admin.conver.AccidentConverMapper; -import com.tuoheng.admin.entity.Accident; -import com.tuoheng.admin.entity.Dept; -import com.tuoheng.admin.entity.User; -import com.tuoheng.admin.enums.DataPermissionEnum; -import com.tuoheng.admin.enums.FlagEnum; -import com.tuoheng.admin.enums.MarkEnum; -import com.tuoheng.admin.mapper.AccidentMapper; -import com.tuoheng.admin.mapper.DeptMapper; -import com.tuoheng.admin.mapper.UserMapper; -import com.tuoheng.admin.query.AccidentQuery; -import com.tuoheng.admin.request.accident.QueryAccidentCardPageListRequest; -import com.tuoheng.admin.utils.CurrentUserUtil; -import com.tuoheng.admin.vo.accident.AccidentVo; -import com.tuoheng.admin.vo.accident.QueryAccidentPageVO; -import com.tuoheng.common.core.enums.ServiceExceptionEnum; -import com.tuoheng.common.core.exception.ServiceException; -import com.tuoheng.common.core.utils.DateUtils; -import com.tuoheng.common.core.utils.JsonResult; -import com.tuoheng.common.core.utils.StringUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * 查询事故卡片分页列表业务层处理 - * - * @author wanjing - * @team tuoheng - * @date 2023-03-03 - */ -@Slf4j -@Service -public class QueryAccidentCardPageListService { - - @Autowired - private DeptMapper deptMapper; - - @Autowired - private UserMapper userMapper; - - @Autowired - private AccidentMapper accidentMapper; - - public JsonResult getPageList(QueryAccidentCardPageListRequest request) { -// log.info("进入查询事件分页列表业务"); - String tenantId = CurrentUserUtil.getTenantId(); - request.setTenantId(tenantId); - JsonResult result = this.check(tenantId, request); - if (0 != result.getCode()) { - log.info("进入查询事故卡片分页列表业务:校验失败:{}", result.getMsg()); - return result; - } - - // 设置分页参数 - IPage page = new Page<>(request.getPage(), request.getLimit()); - IPage pageData = accidentMapper.selectPageList(page, request); - - // 构造返回结果对象 - List accidentVoList = this.buildAccidentVoList(pageData.getRecords()); - - // 重写返回结果对象 - IPage accidentVoPageData = new Page<>(); - accidentVoPageData.setPages(pageData.getPages()); - accidentVoPageData.setCurrent(pageData.getCurrent()); - accidentVoPageData.setSize(pageData.getSize()); - accidentVoPageData.setTotal(pageData.getTotal()); - accidentVoPageData.setRecords(accidentVoList); - return JsonResult.success(accidentVoPageData); - } - - /** - * 检查参数 - * - * @param tenantId - * @param request - * @return - */ - private JsonResult check(String tenantId, QueryAccidentCardPageListRequest request) { - return JsonResult.success(); - } - - /** - * @param accidentList - * @return - */ - private List buildAccidentVoList(List accidentList) { - Map deptNameMap = this.getDeptMap(accidentList); - Map userMap = this.getUserMap(deptNameMap); - List accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); - String deptName; - User user; - for (AccidentVo accidentVo : accidentVoList) { - if (ObjectUtil.isNotNull(deptNameMap)) { - deptName = deptNameMap.get(accidentVo.getDeptId()); - accidentVo.setDeptName(deptName); - } - } - return accidentVoList; - } - - /** - * 设置列表中每一个的部门名称 - * 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 - * - * @param accidentList - * @return - */ - private Map getDeptMap(List accidentList) { - List deptIdList = accidentList.stream().map(o -> o.getDeptId()).collect(Collectors.toList()); - List deptList = deptMapper.selectListByIdList(deptIdList); - Map deptNameMap = deptList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll); - return deptNameMap; - } - - private Map getUserMap(Map deptMap) { - if (ObjectUtil.isNull(deptMap)) { - return null; - } - List deptIdList = deptMap.keySet().stream().collect(Collectors.toList()); - List userList = userMapper.selectList(new LambdaQueryWrapper() - .in(User::getDeptId, deptIdList) - .eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())); - Map userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll); - return userMap; - } - - public JsonResult index(AccidentQuery query) { - //校验 - if (query.getLimit() == null && query.getPage() == null) { - throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); - } - - //当前租户下 - User user = CurrentUserUtil.getUserInfo(); - String tenantId = user.getTenantId(); - List deptIdList = this.getDeptIdList(user, query.getDeptId()); - query.setDeptIdList(deptIdList); - query.setTenantId(tenantId); - IPage page = new Page<>(query.getPage(), query.getLimit()); - IPage pageData = new Page<>(query.getPage(), query.getLimit()); - //搜索时间 - Date startTime = null; - Date endTime = null; - if (StringUtils.isNotEmpty(query.getStartTime()) && StringUtils.isNotEmpty(query.getEndTime())) { - startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getStartTime() + " 00:00:00"); - endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getEndTime() + " 23:59:59"); - } - query.setAccidentStartTime(startTime); - query.setAccidentEndTime(endTime); - //获取分页数据 - IPage accidentPageData = accidentMapper.selectPage(page, Wrappers.lambdaQuery() - .eq(null != query.getCode(), Accident::getRoadCode, query.getCode()) - .in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) - .between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), - Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) - .eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) - .eq(Accident::getMark, MarkEnum.VALID.getCode()) - .orderByDesc(Accident::getCreateTime)); - //属性复制 - List result = accidentPageData.getRecords().stream().map(x -> { - QueryAccidentPageVO vo = new QueryAccidentPageVO(); - BeanUtils.copyProperties(x, vo); - //公路代号 - if (StringUtils.isNotEmpty(x.getRoadCode())) { - vo.setCode(x.getRoadCode()); - } - //监管部门 - if (StringUtils.isNotEmpty(x.getDeptId())) { - //根据当前部门id查询对应的部门名称 - Dept dept = deptMapper.selectById(x.getDeptId()); - vo.setName(dept.getName() != null ? dept.getName() : ""); - } - - return vo; - }).collect(Collectors.toList()); - pageData.setPages(accidentPageData.getPages()); - pageData.setRecords(result); - pageData.setTotal(accidentPageData.getTotal()); - pageData.setCurrent(accidentPageData.getCurrent()); - - return JsonResult.success(pageData); - } - - /** - * 根据用户自己的数据权限,查询对应部门的数据 - * - * @param user - * @return - */ - private List getDeptIdList(User user, String deptId) { - List deptIdList = new ArrayList<>(); - if (StringUtils.isNotEmpty(deptId)) { - deptIdList.add(deptId); - return deptIdList; - } - if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { - return null; - } else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { - deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); - } else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { - deptIdList.add(user.getDeptId()); - } - return deptIdList; - } -} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java index a4abbcf..1f87ca6 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentPageListService.java @@ -1,9 +1,12 @@ package com.tuoheng.admin.service.accident.query; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tuoheng.admin.conver.AccidentConverMapper; import com.tuoheng.admin.entity.Accident; import com.tuoheng.admin.entity.Dept; import com.tuoheng.admin.entity.User; @@ -14,7 +17,9 @@ import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.UserMapper; import com.tuoheng.admin.query.AccidentQuery; +import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.admin.vo.accident.AccidentVo; import com.tuoheng.admin.vo.accident.QueryAccidentPageVO; import com.tuoheng.common.core.enums.ServiceExceptionEnum; import com.tuoheng.common.core.exception.ServiceException; @@ -26,9 +31,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -51,19 +54,99 @@ public class QueryAccidentPageListService { @Autowired private AccidentMapper accidentMapper; + public JsonResult getPageList(QueryAccidentPageListRequest request) { +// log.info("进入查询事件分页列表业务"); + String tenantId = CurrentUserUtil.getTenantId(); + request.setTenantId(tenantId); + JsonResult result = this.check(tenantId, request); + if (0 != result.getCode()) { + log.info("进入查询事件分页列表业务:校验失败:{}", result.getMsg()); + return result; + } + + // 设置分页参数 + IPage page = new Page<>(request.getPage(), request.getLimit()); + IPage pageData = accidentMapper.selectPageList(page, request); + + // 构造返回结果对象 + List accidentVoList = this.buildAccidentVoList(pageData.getRecords()); + + // 重写返回结果对象 + IPage accidentVoPageData = new Page<>(); + accidentVoPageData.setPages(pageData.getPages()); + accidentVoPageData.setCurrent(pageData.getCurrent()); + accidentVoPageData.setSize(pageData.getSize()); + accidentVoPageData.setTotal(pageData.getTotal()); + accidentVoPageData.setRecords(accidentVoList); + return JsonResult.success(accidentVoPageData); + } + + /** + * 检查参数 + * + * @param tenantId + * @param request + * @return + */ + private JsonResult check(String tenantId, QueryAccidentPageListRequest request) { + return JsonResult.success(); + } + + /** + * @param accidentList + * @return + */ + private List buildAccidentVoList(List accidentList) { + Map deptNameMap = this.getDeptMap(accidentList); + List accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); + String deptName; + for (AccidentVo accidentVo : accidentVoList) { + if (ObjectUtil.isNotNull(deptNameMap)) { + deptName = deptNameMap.get(accidentVo.getDeptId()); + accidentVo.setDeptName(deptName); + } + } + return accidentVoList; + } + + /** + * 设置列表中每一个的部门名称 + * 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 + * + * @param accidentList + * @return + */ + private Map getDeptMap(List accidentList) { + List deptIdList = accidentList.stream().map(o -> o.getDeptId()).collect(Collectors.toList()); + List deptList = deptMapper.selectListByIdList(deptIdList); + Map deptNameMap = deptList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll); + return deptNameMap; + } + + private Map getUserMap(Map deptMap) { + if (ObjectUtil.isNull(deptMap)) { + return null; + } + List deptIdList = deptMap.keySet().stream().collect(Collectors.toList()); + List userList = userMapper.selectList(new LambdaQueryWrapper() + .in(User::getDeptId, deptIdList) + .eq(User::getRoleId, DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode())); + Map userMap = userList.stream().collect(HashMap::new, (m, v) -> m.put(v.getDeptId(), v), HashMap::putAll); + return userMap; + } + public JsonResult index(AccidentQuery query) { //校验 if (query.getLimit() == null && query.getPage() == null) { throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); } + //当前租户下 User user = CurrentUserUtil.getUserInfo(); String tenantId = user.getTenantId(); - List deptIdList = this.getDeptIdList(user, query.getDeptId()); query.setDeptIdList(deptIdList); query.setTenantId(tenantId); - IPage page = new Page<>(query.getPage(), query.getLimit()); IPage pageData = new Page<>(query.getPage(), query.getLimit()); //搜索时间 @@ -77,9 +160,8 @@ public class QueryAccidentPageListService { query.setAccidentEndTime(endTime); //获取分页数据 IPage accidentPageData = accidentMapper.selectPage(page, Wrappers.lambdaQuery() - .eq(Accident::getTenantId, tenantId) - .in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) .eq(null != query.getCode(), Accident::getRoadCode, query.getCode()) + .in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) .between(null != query.getAccidentStartTime() && null != query.getAccidentEndTime(), Accident::getCreateTime, query.getAccidentStartTime(), query.getAccidentEndTime()) .eq(Accident::getFlag, FlagEnum.INSPECTION_ACCIDENT.getCode()) diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index 7b07c20..36b1782 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -55,7 +55,7 @@ from th_accident - select from th_accident -- 2.27.0 From 61346fbe06f0bed6bcbff88976fedd8188a04ac5 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Sat, 27 Jan 2024 14:04:16 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BA=8B=E4=BB=B6=E5=90=8D=E7=A7=B0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/tuoheng/admin/entity/Accident.java | 5 +++++ .../admin/service/third/dsp/DspCallbackServiceImpl.java | 1 + .../src/main/resources/mapper/AccidentMapper.xml | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java index c048fd7..dba03cf 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java @@ -22,6 +22,11 @@ public class Accident extends BaseEntity { private static final long serialVersionUID = 1L; + /** + * 事件名称 + */ + private String name; + /** * 租户id */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java index a316453..596813a 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java @@ -371,6 +371,7 @@ public class DspCallbackServiceImpl implements IDspCallbackService { if (ObjectUtils.isNotEmpty(roadInformation)) { accident.setRoadCode(roadInformation.getCode()); } + accident.setName(inspectionFile.getQuestionName()); accident.setQuestionId(inspectionFile.getQuestionId()); accident.setQuestionCode(inspectionFile.getQuestionCode()); accident.setQuestionName(inspectionFile.getQuestionName()); diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index 36b1782..bde1ce2 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -6,6 +6,7 @@ + @@ -43,13 +44,13 @@ - id, tenant_id, dept_id, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, + id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark - select id, tenant_id, dept_id, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, + select id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark from th_accident -- 2.27.0 From b21c468410ce892220772e0727c9e0ee5615a89c Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Sat, 27 Jan 2024 14:46:26 +0800 Subject: [PATCH 09/22] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8D=A1=E7=89=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/AccidentController.java | 9 + .../tuoheng/admin/mapper/AccidentMapper.java | 10 + .../QueryAccidentCardListRequest.java | 32 ++++ .../service/accident/AccidentServiceImpl.java | 9 + .../service/accident/IAccidentService.java | 8 + .../query/QueryAccidentCardListService.java | 180 ++++++++++++++++++ .../main/resources/mapper/AccidentMapper.xml | 23 +++ 7 files changed, 271 insertions(+) create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index f66aa81..5ef855e 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -69,6 +69,15 @@ public class AccidentController { return accidentService.getAccidentPageList(request); } + /** + * 查询事故卡片列表 + */ + @GetMapping("/card/list") + public JsonResult getAccidentCardList(QueryAccidentCardListRequest request) { +// log.info("进入查询事故分页列表接口"); + return accidentService.getAccidentCardList(request); + } + /** * 获取巡检任务信息信息 */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java index d232782..432afa3 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.tuoheng.admin.entity.Accident; +import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; import com.tuoheng.admin.request.accident.QueryAccidentRealtimeInfoListRequest; import com.tuoheng.admin.request.accident.QueryAccidentPageListRequest; import com.tuoheng.admin.request.accident.QueryHistoryPageListRequest; @@ -41,4 +42,13 @@ public interface AccidentMapper extends BaseMapper { */ Page getHistoryPageList(@Param("page") IPage page, @Param("request") QueryHistoryPageListRequest request); + + /** + * 查询事故分页列表 + * + * @param request 事故查询实体 + * @return 事故集合 + */ + List selectAccidentCardList(@Param("request") QueryAccidentCardListRequest request); + } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java new file mode 100644 index 0000000..3f45418 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/QueryAccidentCardListRequest.java @@ -0,0 +1,32 @@ +package com.tuoheng.admin.request.accident; + +import lombok.Data; + +import java.util.List; + +/** + * 查询事故卡片请求实体 + * + * @author wanjing + * @team tuoheng + * @date 2023-03-20 + */ +@Data +public class QueryAccidentCardListRequest { + + /** + * 任务状态 + */ + private List statusList; + + /** + * 租户Id + */ + private String tenantId; + + /** + * 部门Id list + */ + private List deptIdList; + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index 5758cb0..79cc464 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -37,6 +37,9 @@ public class AccidentServiceImpl extends BaseServiceImpl { */ JsonResult getHistoryPageList(QueryHistoryPageListRequest request); + /** + * 查询事故列表 + * + * @param request 事故列表查询实体 + * @return 巡检任务集合 + */ + JsonResult getAccidentCardList(QueryAccidentCardListRequest request); + /** * 新增应急事件 * diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java new file mode 100644 index 0000000..01de7eb --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java @@ -0,0 +1,180 @@ +package com.tuoheng.admin.service.accident.query; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.tuoheng.admin.conver.AccidentConverMapper; +import com.tuoheng.admin.entity.*; +import com.tuoheng.admin.enums.MarkEnum; +import com.tuoheng.admin.enums.DataPermissionEnum; +import com.tuoheng.admin.mapper.*; +import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; +import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.admin.vo.accident.AccidentVo; +import com.tuoheng.common.core.config.common.CommonConfig; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 查询事故卡片列表业务层处理 + * + * @author wanjing + * @team tuoheng + * @date 2023-03-03 + */ +@Slf4j +@Service +public class QueryAccidentCardListService { + + @Autowired + private DeptMapper deptMapper; + + @Autowired + private UserMapper userMapper; + + @Autowired + private InspectionFileMapper inspectionFileMapper; + + @Autowired + private AccidentMapper accidentMapper; + + @Autowired + private InspectionMapper inspectionMapper; + + public JsonResult getList(QueryAccidentCardListRequest request) { +// log.info("进入查询事件列表业务"); + User user = CurrentUserUtil.getUserInfo(); + String tenantId = user.getTenantId(); + + JsonResult result = this.check(tenantId, request); + if (0 != result.getCode()) { + log.info("进入查询事故卡片列表业务:校验失败:{}", result.getMsg()); + return result; + } + + List deptIdList = this.getDeptIdList(user); + request.setDeptIdList(deptIdList); + request.setTenantId(tenantId); + List accidentList = accidentMapper.selectAccidentCardList(request); + + // 构造返回结果对象 + List accidentVoList = this.buildAccidentVoList(accidentList); + + return JsonResult.success(accidentVoList); + } + + /** + * 检查参数 + * + * @param tenantId + * @param request + * @return + */ + private JsonResult check(String tenantId, QueryAccidentCardListRequest request) { + return JsonResult.success(); + } + + /** + * 根据用户自己的数据权限,查询对应部门的数据 + * + * @param user + * @return + */ + private List getDeptIdList(User user) { + List deptIdList = new ArrayList<>(); + if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { + return null; + } else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { + deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); + } else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { + deptIdList.add(user.getDeptId()); + } + return deptIdList; + } + + /** + * @param accidentList + * @return + */ + private List buildAccidentVoList(List accidentList) { + Map deptNameMap = this.getDeptMap(accidentList); + Map inspectionFileMap = this.getInspectionFileMap(accidentList); + Map inspectionMap = this.getInspectionMap(accidentList); + List accidentVoList = AccidentConverMapper.INSTANCE.accidentListToAccidentVoList(accidentList); + String deptName; + InspectionFile inspectionFile; + Inspection inspection; + for (AccidentVo accidentVo : accidentVoList) { + if (ObjectUtil.isNotNull(deptNameMap)) { + deptName = deptNameMap.get(accidentVo.getDeptId()); + accidentVo.setDeptName(deptName); + } + if (ObjectUtil.isNotNull(inspectionFileMap)) { + inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); + if (ObjectUtil.isNotNull(inspectionFile)) { + accidentVo.setFileName(inspectionFile.getFileName()); + accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage()); + accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal()); + accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); + } + } + if(ObjectUtil.isNotNull(inspectionMap)){ + inspection = inspectionMap.get(accidentVo.getInspectionId()); + if(ObjectUtil.isNotNull(inspection)){ + accidentVo.setInspectionStatus(inspection.getStatus()); + } + } + } + return accidentVoList; + } + + private Map getInspectionMap(List accidentList) { + if (CollectionUtil.isEmpty(accidentList)) { + return null; + } + List inspectionIdList = accidentList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList()); + List inspectionList = inspectionMapper.selectList(Wrappers.lambdaQuery() + .eq(Inspection::getMark, MarkEnum.VALID.getCode()) + .in(Inspection::getId, inspectionIdList)); + Map inspectionMap = inspectionList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v), HashMap::putAll); + + return inspectionMap; + } + + /** + * 设置列表中每一个的部门名称 + * 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 + * + * @param accidentList + * @return + */ + private Map getDeptMap(List accidentList) { + if (CollectionUtil.isEmpty(accidentList)) { + return null; + } + List deptIdList = accidentList.stream().map(o -> o.getDeptId()).collect(Collectors.toList()); + List deptList = deptMapper.selectListByIdList(deptIdList); + Map deptNameMap = deptList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll); + return deptNameMap; + } + + private Map getInspectionFileMap(List accidentList) { + if (CollectionUtil.isEmpty(accidentList)) { + return null; + } + List inspectionFileIdList = accidentList.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); + List inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper() + .in(InspectionFile::getId, inspectionFileIdList)); + Map inspectionFileMap = inspectionFileList.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v), HashMap::putAll); + return inspectionFileMap; + } +} \ No newline at end of file diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index bde1ce2..74125fb 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -130,4 +130,27 @@ order by create_time desc + + \ No newline at end of file -- 2.27.0 From d0d02bfa0c43c42157cd185700527d3ca2829941 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Sat, 27 Jan 2024 16:10:25 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E5=BA=94=E6=80=A5=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E7=89=87=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql | 2 +- .../com/tuoheng/admin/controller/AccidentController.java | 2 -- .../src/main/java/com/tuoheng/admin/entity/Accident.java | 5 +++++ .../admin/service/accident/add/AddAccidentService.java | 2 ++ .../src/main/resources/mapper/AccidentMapper.xml | 5 +++-- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql index dbbcb0b..2e9da0a 100644 --- a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql +++ b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql @@ -7,4 +7,4 @@ use tuoheng_freeway; -- 事件表 alter table tuoheng_freeway.th_accident add name varchar(20) default '' not null comment '事件名称' after dept_id; alter table tuoheng_freeway.th_accident add report_type tinyint(1) default 1 not null comment '上报类型:1:自动上报(默认);2:手动上报' after dept_id; - +alter table tuoheng_freeway.th_accident add image varchar(255) default '' not null comment '图片' after question_name; \ No newline at end of file diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index 5ef855e..fb69e6f 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -144,8 +144,6 @@ public class AccidentController { return accidentService.verify(request); } - - /** * 事故上报 */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java index dba03cf..cedbc68 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Accident.java @@ -92,6 +92,11 @@ public class Accident extends BaseEntity { */ private String questionName; + /** + * 图片 + */ + private String image; + /** * 是否有事故:0:无;1:有 */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java index b0d3e6f..3bbe530 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java @@ -1,6 +1,7 @@ package com.tuoheng.admin.service.accident.add; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.conver.AccidentConverMapper; import com.tuoheng.admin.entity.Accident; @@ -15,6 +16,7 @@ import com.tuoheng.admin.mapper.RoadInformationMapper; import com.tuoheng.admin.mapper.SectionMapper; import com.tuoheng.admin.request.accident.AddAccidentRequest; import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.admin.utils.GaodeUtil; import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.DateUtils; import com.tuoheng.common.core.utils.JsonResult; diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index 74125fb..f9ecbd5 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -18,6 +18,7 @@ + @@ -44,13 +45,13 @@ - id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, + id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, image, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark - select id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, + select id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, image, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, check_user, check_time, check_result, verification_time, report_time, no_accident_time, ignore_time, end_time, flag, mark from th_accident -- 2.27.0 From d59a801e2d21dffaef2e8056be0220ea5c5fc254 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 09:10:10 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=BA=94=E6=80=A5?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=BF=BD=E7=95=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ignore/AccidentIgnoreService.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java index 71a3d69..27e76b6 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/ignore/AccidentIgnoreService.java @@ -32,7 +32,7 @@ public class AccidentIgnoreService { private AccidentMapper accidentMapper; public JsonResult ignore(List idList) { -// log.info("进入忽略事故业务, id={}", id); +// log.info("进入忽略事故业务, idList={}", idList); User user = CurrentUserUtil.getUserInfo(); String userId = user.getId(); String tenantId = user.getTenantId(); @@ -41,9 +41,9 @@ public class AccidentIgnoreService { log.info("忽略事故业务:校验失败:{}", result.getMsg()); return result; } - Accident accident = (Accident) result.getData(); + List accidentList = (List) result.getData(); - this.updateAccident(userId, accident); + this.updateAccident(userId, accidentList); return JsonResult.success(); } @@ -66,7 +66,6 @@ public class AccidentIgnoreService { if (CollectionUtil.isEmpty(accidentList)) { throw new ServiceException("应急事件不存在"); } - for (Accident accident : accidentList) { if (AccidentStatusEnum.UNTREATED.getCode() != accident.getStatus()) { log.info("未处理的应急事件才能忽略, accidentId={}", accident.getId()); @@ -82,16 +81,16 @@ public class AccidentIgnoreService { * @param userId * @param userId */ - private void updateAccident(String userId, Accident accident) { - Accident accidentUpdate = new Accident(); - accidentUpdate.setId(accident.getId()); - accidentUpdate.setStatus(AccidentStatusEnum.IGNORED.getCode()); - accidentUpdate.setUpdateUser(userId); - accidentUpdate.setUpdateTime(DateUtils.now()); - accidentUpdate.setIgnoreTime(DateUtils.now()); - Integer count = accidentMapper.updateById(accidentUpdate); - if (count <= 0) { - log.info("事故忽略,修改预警信息失败"); + private void updateAccident(String userId, List accidentList) { + for (Accident accident : accidentList) { + accident.setStatus(AccidentStatusEnum.IGNORED.getCode()); + accident.setUpdateUser(userId); + accident.setUpdateTime(DateUtils.now()); + accident.setIgnoreTime(DateUtils.now()); + Integer count = accidentMapper.updateById(accident); + if (count <= 0) { + log.info("事故忽略,修改预警信息失败, accidentId={}", accident.getId()); + } } } } -- 2.27.0 From 3f217ed922b07ed6f1ac51cf349aa278459a10a1 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 09:36:32 +0800 Subject: [PATCH 12/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=AE=9E=E6=97=B6=E4=BF=A1=E6=81=AF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tuoheng/admin/controller/AccidentController.java | 2 -- .../query/QueryAccidentRealtimeInfoListService.java | 7 +++++++ .../java/com/tuoheng/admin/vo/accident/AccidentVo.java | 10 ++++++++++ .../src/main/resources/mapper/AccidentMapper.xml | 1 - 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index fb69e6f..f90b4ed 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -160,8 +160,6 @@ public class AccidentController { return accidentService.noAccident(request); } - - /** * 新增应急事件 */ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java index 8d7fece..16bef12 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java @@ -8,12 +8,14 @@ import com.tuoheng.admin.conver.AccidentConverMapper; import com.tuoheng.admin.entity.*; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.DataPermissionEnum; +import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.request.accident.QueryAccidentRealtimeInfoListRequest; import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.vo.accident.AccidentVo; import com.tuoheng.common.core.config.common.CommonConfig; import com.tuoheng.common.core.utils.JsonResult; +import com.tuoheng.common.core.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -119,6 +121,11 @@ public class QueryAccidentRealtimeInfoListService { deptName = deptNameMap.get(accidentVo.getDeptId()); accidentVo.setDeptName(deptName); } + if (AccidentReportTypeEnum.MANUAL.getCode() == accidentVo.getReportType()) { + if (StringUtils.isNotEmpty(accidentVo.getImage())) { + accidentVo.setImage(CommonConfig.imageURL + accidentVo.getImage()); + } + } if (ObjectUtil.isNotNull(inspectionFileMap)) { inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); if (ObjectUtil.isNotNull(inspectionFile)) { diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java index c577882..97f86aa 100755 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java @@ -25,6 +25,11 @@ public class AccidentVo extends BaseEntity { */ private String deptName; + /** + * 上报类型:1:自动上报(默认);2:手动上报 + */ + private Integer reportType; + /** * 巡检任务id */ @@ -75,6 +80,11 @@ public class AccidentVo extends BaseEntity { */ private String questionName; + /** + * 图片 + */ + private String image; + /** * 经度 */ diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml index f9ecbd5..21e9d49 100644 --- a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentMapper.xml @@ -43,7 +43,6 @@ - id, tenant_id, dept_id, name, report_type, inspection_id, inspection_file_id, accident_inspection_id, road_id, road_code, section_id, section_name, question_id, question_code, question_name, image, is_casualties, is_driving_safety, is_fire, record, longitude, latitude, uav_return, status, create_user, create_time, update_user, update_time, -- 2.27.0 From 4a9775fbc39edccb2c98aae6b61701340d72188e Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 09:43:10 +0800 Subject: [PATCH 13/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=AE=9E=E6=97=B6=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=9B=BE=E7=89=87=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/query/QueryAccidentRealtimeInfoListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java index 16bef12..b6c817a 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java @@ -123,7 +123,7 @@ public class QueryAccidentRealtimeInfoListService { } if (AccidentReportTypeEnum.MANUAL.getCode() == accidentVo.getReportType()) { if (StringUtils.isNotEmpty(accidentVo.getImage())) { - accidentVo.setImage(CommonConfig.imageURL + accidentVo.getImage()); + accidentVo.setFileImage(CommonConfig.imageURL + accidentVo.getImage()); } } if (ObjectUtil.isNotNull(inspectionFileMap)) { -- 2.27.0 From 50cc419a24cd8d648192f5861610a7953760256b Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 09:48:35 +0800 Subject: [PATCH 14/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=AE=9E=E6=97=B6=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=9B=BE=E7=89=87=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryAccidentRealtimeInfoListService.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java index b6c817a..671557d 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java @@ -123,18 +123,21 @@ public class QueryAccidentRealtimeInfoListService { } if (AccidentReportTypeEnum.MANUAL.getCode() == accidentVo.getReportType()) { if (StringUtils.isNotEmpty(accidentVo.getImage())) { - accidentVo.setFileImage(CommonConfig.imageURL + accidentVo.getImage()); + accidentVo.setImage(CommonConfig.imageURL + accidentVo.getImage()); } - } - if (ObjectUtil.isNotNull(inspectionFileMap)) { - inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); - if (ObjectUtil.isNotNull(inspectionFile)) { - accidentVo.setFileName(inspectionFile.getFileName()); - accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage()); - accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal()); - accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); + } else if (AccidentReportTypeEnum.AUTO.getCode() == accidentVo.getReportType()) { + if (ObjectUtil.isNotNull(inspectionFileMap)) { + inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); + if (ObjectUtil.isNotNull(inspectionFile)) { + accidentVo.setFileName(inspectionFile.getFileName()); + accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage()); + accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal()); + accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); + accidentVo.setImage(CommonConfig.imageURL + accidentVo.getFileImage()); + } } } + if(ObjectUtil.isNotNull(inspectionMap)){ inspection = inspectionMap.get(accidentVo.getInspectionId()); if(ObjectUtil.isNotNull(inspection)){ -- 2.27.0 From 40e64d2ed04558da1676373397bda50c17b0d059 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 09:55:23 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BA=94=E6=80=A5=E4=BA=8B=E4=BB=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/accident/add/AddAccidentService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java index 3bbe530..b6c9934 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java @@ -107,16 +107,19 @@ public class AddAccidentService { .eq(RoadInformation::getTenantId, user.getTenantId()) .eq(RoadInformation::getId, request.getRoadId()) .eq(RoadInformation::getMark, MarkEnum.VALID.getCode())); - if (ObjectUtil.isNotEmpty(roadInformation)) { - accident.setRoadCode(roadInformation.getCode()); + if (ObjectUtil.isEmpty(roadInformation)) { + throw new ServiceException("公路信息不存在"); + } + accident.setRoadCode(roadInformation.getCode()); Section section = sectionMapper.selectOne(Wrappers.
lambdaQuery() .eq(Section::getTenantId, user.getTenantId()) .eq(Section::getId, request.getSectionId()) .eq(Section::getMark, MarkEnum.VALID.getCode())); - if (ObjectUtil.isNotEmpty(section)) { - accident.setSectionName(section.getCode()); + if (ObjectUtil.isEmpty(section)) { + throw new ServiceException("路段信息不存在"); } + accident.setSectionName(section.getSectionRange()); return accident; } } -- 2.27.0 From a83416326ae37f03d4c32c34318c9410239f276c Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 10:00:01 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E4=BF=A1=E6=81=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/accident/AccidentStatisticsVo.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java index c26a896..01764a1 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentStatisticsVo.java @@ -1,9 +1,10 @@ package com.tuoheng.admin.vo.accident; -import com.tuoheng.admin.request.accident.QuestionTypeStatisticsVo; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; -import java.util.List; +import java.util.Date; /** * 事件月份统计 返回实体类 @@ -26,8 +27,18 @@ public class AccidentStatisticsVo { private Integer month; /** - * 问题类型统计 + * 事件数 */ - private List questionTypeStatisticsList; + private Integer count; + + /** + * 开始时间 + */ + private String beginTime; + + /** + * 结束时间 + */ + private String endTime; } -- 2.27.0 From 17a83fe9f43e06fdfc1b5d78cce6a4dea2674c15 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 10:03:54 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E4=BF=AE=E7=BB=9F=E8=AE=A1=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/StatisticsByMonthService.java | 169 +++++------------- .../tuoheng/admin/vo/accident/AccidentVo.java | 5 + 2 files changed, 52 insertions(+), 122 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java index 8842026..eb8aac9 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/statistics/StatisticsByMonthService.java @@ -1,42 +1,29 @@ package com.tuoheng.admin.service.accident.statistics; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.tuoheng.admin.entity.Accident; -import com.tuoheng.admin.entity.Dept; -import com.tuoheng.admin.entity.QuestionType; import com.tuoheng.admin.entity.User; import com.tuoheng.admin.enums.DataPermissionEnum; -import com.tuoheng.admin.enums.FlagEnum; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; import com.tuoheng.admin.mapper.AccidentMapper; import com.tuoheng.admin.mapper.DeptMapper; import com.tuoheng.admin.mapper.QuestionTypeMapper; -import com.tuoheng.admin.mapper.UserMapper; -import com.tuoheng.admin.request.accident.QuestionTypeStatisticsVo; import com.tuoheng.admin.utils.CurrentUserUtil; -import com.tuoheng.admin.vo.accident.AccidentPromptlyLookVo; import com.tuoheng.admin.vo.accident.AccidentStatisticsVo; -import com.tuoheng.admin.vo.accident.QueryAccidentPageVO; import com.tuoheng.common.core.utils.DateUtils; import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.StringUtils; import lombok.Data; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.stream.Collectors; /** * 查询事故卡片分页列表业务层处理 @@ -52,9 +39,6 @@ public class StatisticsByMonthService { @Autowired private DeptMapper deptMapper; - @Autowired - private QuestionTypeMapper questionTypeMapper; - @Autowired private AccidentMapper accidentMapper; @@ -62,40 +46,15 @@ public class StatisticsByMonthService { User user = CurrentUserUtil.getUserInfo(); String tenantId = user.getTenantId(); List deptIdList = this.getDeptIdList(user, user.getDeptId()); - List questionTypeList = questionTypeMapper.selectList(new LambdaQueryWrapper() - .eq(QuestionType::getMark, MarkEnum.VALID.getCode())); - List searchTimeList = this.getSearchTimeList(); - List accidentStatisticsVoList = new ArrayList<>(); - AccidentStatisticsVo accidentStatisticsVo; - List questionTypeStatisticsVoList = new ArrayList<>(); - QuestionTypeStatisticsVo questionTypeStatisticsVo; - for (SearchTime searchTime : searchTimeList) { - List accidentList = accidentMapper.selectList(Wrappers.lambdaQuery() + List accidentStatisticsVoList = this.getSixMonth(DateUtils.getYear(), DateUtils.getMonth()); + for (AccidentStatisticsVo accidentStatisticsVo : accidentStatisticsVoList) { + Integer count = accidentMapper.selectCount(Wrappers.lambdaQuery() .eq(Accident::getTenantId, tenantId) - .eq(Accident::getReportType, AccidentReportTypeEnum.AUTO.getCode()) .in(CollectionUtils.isNotEmpty(deptIdList), Accident::getDeptId, deptIdList) - .between(Accident::getCreateTime, searchTime.getBeginTime(), searchTime.getEndTime()) + .between(Accident::getCreateTime, accidentStatisticsVo.getBeginTime(), accidentStatisticsVo.getEndTime()) .eq(Accident::getMark, MarkEnum.VALID.getCode()) .orderByDesc(Accident::getCreateTime)); - Integer questionCount = 0; - for (QuestionType questionType : questionTypeList) { - questionTypeStatisticsVo = new QuestionTypeStatisticsVo(); - questionTypeStatisticsVo.setQuestionId(questionType.getId()); - questionTypeStatisticsVo.setQuestionCode(questionType.getCode()); - questionTypeStatisticsVo.setQuestionName(questionType.getContent()); - for (Accident accident : accidentList) { - if (questionType.getCode().equals(accident.getQuestionCode())) { - questionCount++; - } - } - questionTypeStatisticsVo.setCount(questionCount); - questionTypeStatisticsVoList.add(questionTypeStatisticsVo); - } - accidentStatisticsVo = new AccidentStatisticsVo(); - accidentStatisticsVo.setYear(searchTime.getYear()); - accidentStatisticsVo.setMonth(searchTime.getMonth()); - accidentStatisticsVo.setQuestionTypeStatisticsList(questionTypeStatisticsVoList); - accidentStatisticsVoList.add(accidentStatisticsVo); + accidentStatisticsVo.setCount(count); } return JsonResult.success(accidentStatisticsVoList); } @@ -122,83 +81,49 @@ public class StatisticsByMonthService { return deptIdList; } - private List getSearchTimeList() { - List searchTimeList = new ArrayList<>(); - Integer currentYear = DateUtils.getYear(); - Integer currentMonth = DateUtils.getMonth(); - SearchTime searchTime1 = new SearchTime(); - SearchTime searchTime2 = new SearchTime(); - SearchTime searchTime3 = new SearchTime(); - Integer year1; - Integer year2; - Integer year3; - Integer month1; - Integer month2; - Integer month3; - Integer day = 1; - if (1 == currentMonth) { - year1 = currentYear - 1; - year2 = currentYear - 1; - year3 = currentYear; - month1 = 11; - month2 = 12; - month3 = currentMonth; - } else if (2 == currentMonth) { - year1 = currentYear - 1; - year2 = currentYear; - year3 = currentYear; - month1 = 12; - month2 = currentMonth - 1; - month3 = currentMonth; - } else { - year1 = currentYear; - year2 = currentYear; - year3 = currentYear; - month1 = currentMonth - 2; - month2 = currentMonth - 1; - month3 = currentMonth; + /** + * 获取某一月份的前六个月 + */ + public List getSixMonth(Integer year, Integer month) { + //返回值 + List accidentStatisticsVoList = new ArrayList<>(); + AccidentStatisticsVo accidentStatisticsVo; + Integer yearTmp; + Integer monthTmp; + for (int i = 4; i >= 0; i--) { + yearTmp = year; + monthTmp = month - 1; + accidentStatisticsVo = new AccidentStatisticsVo(); + if (monthTmp > 6) { + monthTmp = monthTmp - i; + } else { + if (monthTmp - i <= 0) { + yearTmp = yearTmp - 1; + monthTmp = monthTmp - i + 12; + } else { + yearTmp = yearTmp - 1; + monthTmp = monthTmp - i; + } + } + LocalDate localDate = LocalDate.of(yearTmp, monthTmp, 1); + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); + accidentStatisticsVo.setYear(yearTmp); + accidentStatisticsVo.setMonth(monthTmp); + accidentStatisticsVo.setBeginTime(firstDayOfMonth + " 00:00:00"); + accidentStatisticsVo.setEndTime(lastDayOfMonth + " 23:59:59"); + accidentStatisticsVoList.add(accidentStatisticsVo); } - LocalDate localDate1 = LocalDate.of(year1, month1, day); - LocalDate firstDayOfMonth1 = localDate1.with(TemporalAdjusters.firstDayOfMonth()); - LocalDate lastDayOfMonth1 = localDate1.with(TemporalAdjusters.lastDayOfMonth()); - searchTime1.setYear(year1); - searchTime1.setMonth(month1); - searchTime1.setBeginTime(firstDayOfMonth1 + " 00:00:00"); - searchTime1.setEndTime(lastDayOfMonth1 + " 23:59:59"); - - LocalDate localDate2 = LocalDate.of(year2, month2, day); - LocalDate firstDayOfMonth2 = localDate2.with(TemporalAdjusters.firstDayOfMonth()); - LocalDate lastDayOfMonth2 = localDate2.with(TemporalAdjusters.lastDayOfMonth()); - searchTime2.setYear(year2); - searchTime2.setMonth(month2); - searchTime2.setBeginTime(firstDayOfMonth2 + " 00:00:00"); - searchTime2.setEndTime(lastDayOfMonth2 + " 23:59:59"); - - LocalDate localDate3 = LocalDate.of(year3, month3, day); - LocalDate firstDayOfMonth3 = localDate3.with(TemporalAdjusters.firstDayOfMonth()); - LocalDate lastDayOfMonth3 = localDate3.with(TemporalAdjusters.lastDayOfMonth()); - searchTime3.setYear(year3); - searchTime3.setMonth(month3); - searchTime3.setBeginTime(firstDayOfMonth3 + " 00:00:00"); - searchTime3.setEndTime(lastDayOfMonth3 + " 23:59:59"); - - searchTimeList.add(searchTime1); - searchTimeList.add(searchTime2); - searchTimeList.add(searchTime3); - return searchTimeList; + LocalDate localDate2 = LocalDate.of(year, month, 1); + LocalDate firstDayOfMonth = localDate2.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = localDate2.with(TemporalAdjusters.lastDayOfMonth()); + AccidentStatisticsVo currentMonthAccidentStatisticsVo = new AccidentStatisticsVo(); + currentMonthAccidentStatisticsVo.setYear(year); + currentMonthAccidentStatisticsVo.setMonth(month + 1); + currentMonthAccidentStatisticsVo.setBeginTime(firstDayOfMonth + " 00:00:00"); + currentMonthAccidentStatisticsVo.setEndTime(lastDayOfMonth + " 23:59:59"); + accidentStatisticsVoList.add(currentMonthAccidentStatisticsVo); + return accidentStatisticsVoList; } -} - -@Data -class SearchTime { - - private Integer year; - - private Integer month; - - private String beginTime; - - private String endTime; - } \ No newline at end of file diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java index 97f86aa..6da6b1b 100755 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentVo.java @@ -15,6 +15,11 @@ public class AccidentVo extends BaseEntity { private static final long serialVersionUID = 1L; + /** + * 事件名称 + */ + private String name; + /** * 部门id */ -- 2.27.0 From 6e5a7be97a4f68ed22c9412a5fc329b8f9be5e7b Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 11:22:44 +0800 Subject: [PATCH 18/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8D=A1=E7=89=87=E5=88=97=E8=A1=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../query/QueryAccidentCardListService.java | 23 +++++++++++++------ .../QueryAccidentRealtimeInfoListService.java | 1 - 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java index 01de7eb..91bcc11 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentCardListService.java @@ -8,12 +8,14 @@ import com.tuoheng.admin.conver.AccidentConverMapper; import com.tuoheng.admin.entity.*; import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.DataPermissionEnum; +import com.tuoheng.admin.enums.accident.AccidentReportTypeEnum; import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.request.accident.QueryAccidentCardListRequest; import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.vo.accident.AccidentVo; import com.tuoheng.common.core.config.common.CommonConfig; import com.tuoheng.common.core.utils.JsonResult; +import com.tuoheng.common.core.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -118,13 +120,20 @@ public class QueryAccidentCardListService { deptName = deptNameMap.get(accidentVo.getDeptId()); accidentVo.setDeptName(deptName); } - if (ObjectUtil.isNotNull(inspectionFileMap)) { - inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); - if (ObjectUtil.isNotNull(inspectionFile)) { - accidentVo.setFileName(inspectionFile.getFileName()); - accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage()); - accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal()); - accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); + if (AccidentReportTypeEnum.MANUAL.getCode() == accidentVo.getReportType()) { + if (StringUtils.isNotEmpty(accidentVo.getImage())) { + accidentVo.setImage(CommonConfig.imageURL + accidentVo.getImage()); + } + } else if (AccidentReportTypeEnum.AUTO.getCode() == accidentVo.getReportType()) { + if (ObjectUtil.isNotNull(inspectionFileMap)) { + inspectionFile = inspectionFileMap.get(accidentVo.getInspectionFileId()); + if (ObjectUtil.isNotNull(inspectionFile)) { + accidentVo.setFileName(inspectionFile.getFileName()); + accidentVo.setFileImage(CommonConfig.imageURL + inspectionFile.getFileImage()); + accidentVo.setFileOriginal(CommonConfig.imageURL + inspectionFile.getFileOriginal()); + accidentVo.setFileThumbnail(CommonConfig.imageURL + inspectionFile.getFileThumbnail()); + accidentVo.setImage(CommonConfig.imageURL + accidentVo.getFileImage()); + } } } if(ObjectUtil.isNotNull(inspectionMap)){ diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java index 671557d..59f97a8 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentRealtimeInfoListService.java @@ -137,7 +137,6 @@ public class QueryAccidentRealtimeInfoListService { } } } - if(ObjectUtil.isNotNull(inspectionMap)){ inspection = inspectionMap.get(accidentVo.getInspectionId()); if(ObjectUtil.isNotNull(inspection)){ -- 2.27.0 From 401c31c30f38cc37b3066ead177079e0c3f9d8e7 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 16:16:00 +0800 Subject: [PATCH 19/22] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=BA=E5=9C=BA=E8=B0=83=E5=BA=A6=E5=88=97=E8=A1=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tuoheng-admin/sql/sql_change_v1.3.7.sql | 21 +++- .../admin/controller/AccidentController.java | 9 ++ .../admin/entity/AccidentInspection.java | 51 ++++++++ .../mapper/AccidentInspectionMapper.java | 13 ++ .../service/accident/AccidentServiceImpl.java | 14 +++ .../service/accident/IAccidentService.java | 8 ++ ...eryAccidentAirportDispatchListService.java | 111 ++++++++++++++++++ .../control/DroneReturnHomeService.java | 2 +- .../vo/accident/AccidentInspectionVo.java | 44 +++++++ .../mapper/AccidentInspectionMapper.xml | 6 + 10 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/AccidentInspection.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentInspectionMapper.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentInspectionVo.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentInspectionMapper.xml diff --git a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql index 2e9da0a..a891490 100644 --- a/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql +++ b/tuoheng-service/tuoheng-admin/sql/sql_change_v1.3.7.sql @@ -7,4 +7,23 @@ use tuoheng_freeway; -- 事件表 alter table tuoheng_freeway.th_accident add name varchar(20) default '' not null comment '事件名称' after dept_id; alter table tuoheng_freeway.th_accident add report_type tinyint(1) default 1 not null comment '上报类型:1:自动上报(默认);2:手动上报' after dept_id; -alter table tuoheng_freeway.th_accident add image varchar(255) default '' not null comment '图片' after question_name; \ No newline at end of file +alter table tuoheng_freeway.th_accident add image varchar(255) default '' not null comment '图片' after question_name; + +-- 应急事件与应急任务关联表 +create table th_accident_inspection +( + id varchar(36) not null comment 'ID' + primary key, + tenant_id varchar(36) default '' not null comment '租户ID', + accident_id varchar(36) default '' not null comment '事故ID', + inspection_id varchar(36) default '' not null comment '巡检任务ID', + name varchar(255) default '' null comment '记录名称', + drone_forward_type tinyint(1) default 1 not null comment '无人机前往类型:1:原无人机直接前往;2:新无人机前往;3:手动添加的应急事故,无人机前往;', + remark varchar(255) null comment '备注', + create_user varchar(36) default '' null comment '添加人', + create_time timestamp default CURRENT_TIMESTAMP null comment '创建时间', + update_user varchar(36) default '' null comment '更新人', + update_time timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间', + mark tinyint unsigned default '1' not null comment '有效标识' +) + comment '应急事件与应急任务关联表'; \ No newline at end of file diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index f90b4ed..8d955dd 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -40,6 +40,15 @@ public class AccidentController { return accidentService.getHistoryPageList(request); } + /** + * 事件机场调度列表 + */ + @GetMapping("/airport/dispatch/{id}") + public JsonResult getAirportDispatchList(@PathVariable("id") String id) { +// log.info("进入查询事件事件调度列表接口"); + return accidentService.getAirportDispatchList(id); + } + /** * 忽略 * diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/AccidentInspection.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/AccidentInspection.java new file mode 100644 index 0000000..6873fcf --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/AccidentInspection.java @@ -0,0 +1,51 @@ +package com.tuoheng.admin.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.tuoheng.common.core.common.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author ChengWang + * @Date 2023/3/2 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@TableName("th_accident_inspection") +public class AccidentInspection extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 租户id + */ + private String tenantId; + + /** + * 事故ID + */ + private String accidentId; + + /** + * 巡检任务ID + */ + private String inspectionId; + + /** + * 无人机前往类型:1:原无人机直接前往;2:新无人机前往;3:手动添加的应急事故,无人机前往; + */ + private Integer droneForwardType; + + /** + * 记录名称 + */ + private String name; + + /** + * 备注 + */ + private String remark; + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentInspectionMapper.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentInspectionMapper.java new file mode 100644 index 0000000..14c92f5 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/AccidentInspectionMapper.java @@ -0,0 +1,13 @@ +package com.tuoheng.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.tuoheng.admin.entity.AccidentInspection; + +/** + * @Author ChengWang + * @Date 2023/3/2 + */ +public interface AccidentInspectionMapper extends BaseMapper { + + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index 79cc464..7523c3b 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -37,6 +37,9 @@ public class AccidentServiceImpl extends BaseServiceImpl { */ JsonResult getHistoryPageList(QueryHistoryPageListRequest request); + /** + * 查询机场调度列表 + * + * @param id 事件Id + * @return 事件集合 + */ + JsonResult getAirportDispatchList(String id); + /** * 查询事故列表 * diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java new file mode 100644 index 0000000..10e809b --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java @@ -0,0 +1,111 @@ +package com.tuoheng.admin.service.accident.query; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.tuoheng.admin.entity.AccidentInspection; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.entity.User; +import com.tuoheng.admin.enums.MarkEnum; +import com.tuoheng.admin.mapper.AccidentInspectionMapper; +import com.tuoheng.admin.mapper.AccidentMapper; +import com.tuoheng.admin.mapper.InspectionMapper; +import com.tuoheng.admin.utils.CurrentUserUtil; +import com.tuoheng.admin.vo.accident.AccidentInspectionVo; +import com.tuoheng.common.core.exception.ServiceException; +import com.tuoheng.common.core.utils.JsonResult; +import com.tuoheng.common.core.utils.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 查询事件实时信息列表业务层处理 + * + * @author wanjing + * @team tuoheng + * @date 2023-03-03 + */ +@Slf4j +@Service +public class QueryAccidentAirportDispatchListService { + + @Autowired + private AccidentInspectionMapper accidentInspectionMapper; + + @Autowired + private AccidentMapper accidentMapper; + + @Autowired + private InspectionMapper inspectionMapper; + + public JsonResult getList(String id) { +// log.info("进入查询事件机场调度列表业务"); + User user = CurrentUserUtil.getUserInfo(); + String tenantId = user.getTenantId(); + + JsonResult result = this.check(tenantId, id); + if (0 != result.getCode()) { + log.info("进入查询事件机场调度列表业务:校验失败:{}", result.getMsg()); + return result; + } + + List accidentInspectionList = accidentInspectionMapper.selectList(new LambdaQueryWrapper() + .eq(AccidentInspection::getAccidentId, id) + .eq(AccidentInspection::getMark, MarkEnum.VALID.getCode())); + if (ObjectUtil.isEmpty(accidentInspectionList)) { + log.info("该应急事件没有对应的应急任务,accidentId={}", id); + return JsonResult.success(); + } + + // 构造返回结果对象 + List accidentInspectionVoList = this.buildAccidentInspectionVoList(accidentInspectionList); + + return JsonResult.success(accidentInspectionVoList); + } + + /** + * 检查参数 + * + * @param tenantId + * @param id + * @return + */ + private JsonResult check(String tenantId, String id) { + if (StringUtils.isEmpty(id)) { + throw new ServiceException("应急事件ID为空"); + } + return JsonResult.success(); + } + + /** + * @param accidentInspectionList + * @return + */ + private List buildAccidentInspectionVoList(List accidentInspectionList) { + if (CollectionUtil.isEmpty(accidentInspectionList)) { + return null; + } + List inspectionIdList = accidentInspectionList.stream().map(o -> o.getInspectionId()).collect(Collectors.toList()); + List inspectionList = inspectionMapper.selectList(Wrappers.lambdaQuery() + .eq(Inspection::getMark, MarkEnum.VALID.getCode()) + .in(Inspection::getId, inspectionIdList)); + List accidentInspectionVoList = new ArrayList<>(); + AccidentInspectionVo accidentInspectionVo; + for (Inspection inspection : inspectionList) { + accidentInspectionVo = new AccidentInspectionVo(); + accidentInspectionVo.setInspectionId(inspection.getId()); + accidentInspectionVo.setInspectionCode(inspection.getCode()); + accidentInspectionVo.setInspectionName(inspection.getName()); + accidentInspectionVo.setStatus(inspection.getStatus()); + accidentInspectionVoList.add(accidentInspectionVo); + } + return accidentInspectionVoList; + } + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java index 632a6c2..2d92de1 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java @@ -19,7 +19,7 @@ public class DroneReturnHomeService { * @return */ public JsonResult returnHome(Integer airportId) { - log.info("南京海事局, 一键返航, airportId={}", airportId); + log.info("一键返航, airportId={}", airportId); JSONObject jsonObject = this.getJSONObject(airportId); JsonResult result = airportDroneControlService.exec(jsonObject); return result; diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentInspectionVo.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentInspectionVo.java new file mode 100644 index 0000000..db1cf5a --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/accident/AccidentInspectionVo.java @@ -0,0 +1,44 @@ +package com.tuoheng.admin.vo.accident; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + +/** + * @Author xiaoying + * @Date 2023/4/13 17:10 + */ +@Data +public class AccidentInspectionVo { + + /** + * 任务ID + */ + private String inspectionId; + + /** + * 任务ID + */ + private String inspectionCode; + + /** + * 任务名称 + */ + private String inspectionName; + + /** + * 任务状态 + */ + private Integer status; + + /** + * 时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentInspectionMapper.xml b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentInspectionMapper.xml new file mode 100644 index 0000000..c489e2b --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/resources/mapper/AccidentInspectionMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file -- 2.27.0 From e5c0448812ecd19fb1f79ff4bb2f61dfab03873f Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Mon, 29 Jan 2024 16:16:55 +0800 Subject: [PATCH 20/22] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=BA=E5=9C=BA=E8=B0=83=E5=BA=A6=E5=88=97=E8=A1=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accident/query/QueryAccidentAirportDispatchListService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java index 10e809b..4a2ef49 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryAccidentAirportDispatchListService.java @@ -103,6 +103,7 @@ public class QueryAccidentAirportDispatchListService { accidentInspectionVo.setInspectionCode(inspection.getCode()); accidentInspectionVo.setInspectionName(inspection.getName()); accidentInspectionVo.setStatus(inspection.getStatus()); + accidentInspectionVo.setCreateTime(inspection.getCreateTime()); accidentInspectionVoList.add(accidentInspectionVo); } return accidentInspectionVoList; -- 2.27.0 From 25309490490b608b5de384111c74627bcb6ecce3 Mon Sep 17 00:00:00 2001 From: wanjing <“wanjing5234@163.com”> Date: Tue, 30 Jan 2024 13:45:02 +0800 Subject: [PATCH 21/22] =?UTF-8?q?=E6=9C=BA=E5=9C=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=88=B1=E5=86=85=E6=B9=BF=E5=BA=A6=EF=BC=8C?= =?UTF-8?q?=E8=88=B1=E5=86=85=E6=B8=A9=E5=BA=A6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tuoheng/admin/dto/AirportDetailDto.java | 9 +++++++++ .../admin/service/accident/AccidentServiceImpl.java | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/dto/AirportDetailDto.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/dto/AirportDetailDto.java index 49ef599..3b1f863 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/dto/AirportDetailDto.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/dto/AirportDetailDto.java @@ -66,5 +66,14 @@ public class AirportDetailDto { */ private String battery; + /** + * 舱内湿度 + */ + private String tahHum; + + /** + * 舱内温度 + */ + private String tahTmp; } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index 7523c3b..d9912f8 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -105,7 +105,6 @@ public class AccidentServiceImpl extends BaseServiceImpl Date: Wed, 31 Jan 2024 09:08:35 +0800 Subject: [PATCH 22/22] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=93=8D=E6=8E=A7?= =?UTF-8?q?=E6=97=A0=E4=BA=BA=E6=9C=BA=E6=8E=A5=E5=8F=A3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/AccidentController.java | 7 ++ .../request/accident/DroneControlRequest.java | 56 +++++++++++++ .../service/accident/AccidentServiceImpl.java | 14 ++++ .../service/accident/IAccidentService.java | 9 +++ .../service/third/airport/AirportService.java | 1 - .../third/airport/AirportServiceImpl.java | 6 -- .../control/AirportDroneControlService.java | 79 ++++++++++++++++++- .../airport/control/DroneContinueService.java | 28 ++----- .../airport/control/DroneExecuteService.java | 32 +++----- .../control/DroneGuideFlightService.java | 32 ++++++++ .../airport/control/DronePauseService.java | 23 ++---- .../control/DroneReturnHomeService.java | 25 ++---- .../airport/control/DroneUndoService.java | 43 +++++----- 13 files changed, 252 insertions(+), 103 deletions(-) create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/DroneControlRequest.java create mode 100644 tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneGuideFlightService.java diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java index 8d955dd..480a8fa 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AccidentController.java @@ -184,4 +184,11 @@ public class AccidentController { public JsonResult statisticsByMonth() { return accidentService.statisticsByMonth(); } + + @PostMapping(value = "/droneControl") + public JsonResult droneControl(@RequestBody DroneControlRequest request) { +// log.info("进入操作无人机接口, request={}", request); + return accidentService.droneControl(request); + } + } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/DroneControlRequest.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/DroneControlRequest.java new file mode 100644 index 0000000..c3692dd --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/DroneControlRequest.java @@ -0,0 +1,56 @@ +package com.tuoheng.admin.request.accident; + +import lombok.Data; + +/** + * 事故上报请求实体 + * + * @author wanjing + * @team tuoheng + * @date 2023-03-15 + */ +@Data +public class DroneControlRequest { + + /** + * 任务id + */ + private String inspectionId; + + /** + * 操作类型:1:悬停;2:指点飞行;3:继续任务;4:立即返航;5:取消任务 + */ + private Integer type; + + /** + * 机场任务ID + */ + private Integer airportTaskId; + + /** + * 巡检机场id + */ + private Integer airportId; + + /** + * 高度 + */ + private Integer zalt; + + /** + * 纬度 + */ + private String latitude; + + /** + * 经度 + */ + private String longitude; + + /** + * 租户code + */ + private String tenantCode; + + +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java index d9912f8..f4fdd0f 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/AccidentServiceImpl.java @@ -12,6 +12,7 @@ import com.tuoheng.admin.service.accident.reoprt.ReportNoAccidentService; import com.tuoheng.admin.service.accident.statistics.StatisticsByMonthService; import com.tuoheng.admin.service.accident.verify.AccidentVerifyCompletedService; import com.tuoheng.admin.service.accident.verify.AccidentVerifyService; +import com.tuoheng.admin.service.third.airport.control.AirportDroneControlService; import com.tuoheng.common.core.common.BaseServiceImpl; import com.tuoheng.common.core.utils.JsonResult; import lombok.extern.slf4j.Slf4j; @@ -79,6 +80,9 @@ public class AccidentServiceImpl extends BaseServiceImpl { */ JsonResult statisticsByMonth(); + + /** + * 操作无人机 + * + * @return 结果 + */ + JsonResult droneControl(DroneControlRequest request); + + } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java index 9f5b9e1..0f27a1a 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java @@ -33,5 +33,4 @@ public interface AirportService { JsonResult reversalFlight(ReversalFlightRequest request); - JsonResult controlDrone(Integer inspectionId); } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java index 883ba70..e2e6e6b 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java @@ -89,10 +89,4 @@ public class AirportServiceImpl implements AirportService { return reversalFlightService.reversalFlight(request); } - @Override - public JsonResult controlDrone(Integer inspectionId) { - return null; - } - - } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java index 869e751..bddac3c 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/AirportDroneControlService.java @@ -1,7 +1,16 @@ package com.tuoheng.admin.service.third.airport.control; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.entity.Tenant; +import com.tuoheng.admin.enums.MarkEnum; +import com.tuoheng.admin.mapper.InspectionMapper; +import com.tuoheng.admin.mapper.TenantMapper; +import com.tuoheng.admin.request.accident.DroneControlRequest; +import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.common.core.config.common.CommonConfig; import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.JsonResult; @@ -23,15 +32,79 @@ import org.springframework.web.client.RestTemplate; @Service public class AirportDroneControlService { + @Autowired + private TenantMapper tenantMapper; + + @Autowired + private InspectionMapper inspectionMapper; + + @Autowired + private DroneContinueService droneContinueService; + + @Autowired + private DroneGuideFlightService droneGuideFlightService; + + @Autowired + private DronePauseService dronePauseService; + + @Autowired + private DroneReturnHomeService droneReturnHomeService; + + @Autowired + private DroneUndoService droneUndoService; + @Autowired @Qualifier("restTemplate") private RestTemplate restTemplate; + /** + * @return + */ + public JsonResult exec(DroneControlRequest request) { + //查询当前对应的任务 + Inspection inspection = inspectionMapper.selectOne(Wrappers.lambdaQuery() + .eq(Inspection::getId, request.getInspectionId()) + .eq(Inspection::getMark, MarkEnum.VALID.getCode())); + if (ObjectUtil.isEmpty(inspection)) { + throw new ServiceException("操控无人机,该任务不存在"); + } + + Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId()); + if (ObjectUtil.isEmpty(tenant)) { + throw new ServiceException("操控无人机,该租户不存在"); + } + request.setAirportId(inspection.getAirportId()); + request.setAirportTaskId(request.getAirportTaskId()); + request.setTenantCode(tenant.getCode()); + + // 1:悬停;2:指点飞行;3:继续任务;4:立即返航;5:取消任务 + JSONObject jsonObject = null; + if (1 == request.getType()) { + // 悬停 + jsonObject = dronePauseService.getJSONObject(request); + } else if (2 == request.getType()) { + // 指点飞行 + jsonObject = droneGuideFlightService.getJSONObject(request); + } else if (3 == request.getType()) { + // 继续任务 + jsonObject = droneContinueService.getJSONObject(request); + } else if (4 == request.getType()) { + // 立即返航 + jsonObject = droneReturnHomeService.getJSONObject(request); + } else if (5 == request.getType()) { + // 取消任务 + jsonObject = droneUndoService.getJSONObject(request); + } else { + throw new ServiceException("操控无人机,错误的操作指令"); + } + JsonResult jsonResult = this.call(jsonObject); + return jsonResult; + } /** * @return */ - public JsonResult exec(JSONObject jsonObject) { + private JsonResult call(JSONObject jsonObject) { String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL; log.info("调用机场平台,操作无人机,url:{}", url); log.info("调用机场平台,操作无人机,jsonObject:{}", jsonObject); @@ -42,8 +115,8 @@ public class AirportDroneControlService { try { response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); } catch (Exception e) { - log.error("调用机场平台,接口异常, url:{}", url); - log.error("调用机场平台,接口异常, httpEntity:{}", httpEntity); + log.error("调用机场平台,操作无人机,接口异常, url:{}", url); + log.error("调用机场平台,操作无人机,接口异常, httpEntity:{}", httpEntity); throw new ServiceException("调用机场平台,接口异常"); } JsonResult jsonResult = response.getBody(); diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java index 5528814..aa704b7 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneContinueService.java @@ -2,6 +2,8 @@ package com.tuoheng.admin.service.third.airport.control; import com.alibaba.fastjson.JSONObject; import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.request.accident.DroneControlRequest; import com.tuoheng.common.core.config.common.CommonConfig; import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.JsonResult; @@ -16,32 +18,18 @@ import org.springframework.web.client.RestTemplate; @Service public class DroneContinueService { - @Autowired - private AirportDroneControlService airportDroneControlService; - /** - * 调用机场平台,原无人机继续巡检 + * 用机场平台,原无人机继续巡检 * - * @param airportId 机场Id - * @param taskId 巡检任务Id - */ - public JsonResult continuee(Integer airportId, Integer taskId) { - log.info("继续任务, taskId={}", taskId); - JSONObject jsonObject = this.getJSONObject(airportId, taskId); - JsonResult result = airportDroneControlService.exec(jsonObject); - return result; - } - - /** - * @param airportId - * @param taskId + * @param request * @return */ - private JSONObject getJSONObject(Integer airportId, Integer taskId) { + public JSONObject getJSONObject(DroneControlRequest request) { + log.info("继续巡检, inspectionId={}", request.getInspectionId()); JSONObject jsonObject = new JSONObject(); jsonObject.put("zhilin", "04"); - jsonObject.put("airportId", airportId); - jsonObject.put("taskId", taskId); + jsonObject.put("airportId", request.getAirportId()); + jsonObject.put("taskId", request.getAirportTaskId()); jsonObject.put("msg", "继续巡检"); return jsonObject; } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java index d7826f7..4dd75cc 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneExecuteService.java @@ -1,7 +1,13 @@ package com.tuoheng.admin.service.third.airport.control; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.entity.Tenant; +import com.tuoheng.admin.enums.MarkEnum; +import com.tuoheng.admin.mapper.TenantMapper; +import com.tuoheng.admin.request.accident.DroneControlRequest; import com.tuoheng.common.core.utils.JsonResult; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -11,33 +17,19 @@ import org.springframework.stereotype.Service; @Service public class DroneExecuteService { - @Autowired - private AirportDroneControlService airportDroneControlService; - /** * 执行任务 * - * @param taskId - * @return - */ - public JsonResult callBack(Integer taskId, String url, Integer airportId, String tenantCode) { - log.info("执行任务, taskId={}", taskId); - JSONObject jsonObject = this.getJSONObject(taskId, url, airportId, tenantCode); - JsonResult result = airportDroneControlService.exec(jsonObject); - return result; - } - - /** - * @param taskId - * @param url + * @param request * @return */ - private JSONObject getJSONObject(Integer taskId, String url, Integer airportId, String tenantCode) { + public JSONObject getJSONObject(DroneControlRequest request) { + String url = ""; JSONObject jsonObject = new JSONObject(); - jsonObject.put("requestId", taskId); - jsonObject.put("airportId", airportId); + jsonObject.put("requestId", request.getAirportTaskId()); + jsonObject.put("airportId", request.getAirportId()); jsonObject.put("code", SystemConstant.PLATFORM_CODE); - jsonObject.put("tenantCode", tenantCode); + jsonObject.put("tenantCode", request.getTenantCode()); jsonObject.put("wayUrl", url); return jsonObject; } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneGuideFlightService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneGuideFlightService.java new file mode 100644 index 0000000..d6fcc85 --- /dev/null +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneGuideFlightService.java @@ -0,0 +1,32 @@ +package com.tuoheng.admin.service.third.airport.control; + +import com.alibaba.fastjson.JSONObject; +import com.tuoheng.admin.constant.DroneControlConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.request.accident.DroneControlRequest; +import com.tuoheng.common.core.utils.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class DroneGuideFlightService { + + /** + * 指点飞行 + * + * @param request + * @return + */ + public JSONObject getJSONObject(DroneControlRequest request) { + log.info("指点飞行, inspectionId={}", request.getInspectionId()); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("taskId", request.getAirportTaskId()); + jsonObject.put("airportId", request.getAirportId()); + jsonObject.put("zalt", request.getZalt()); + jsonObject.put("zlon", request.getLongitude()); + jsonObject.put("zlat", request.getLatitude()); + return jsonObject; + } +} diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java index 80ac743..57e7a4b 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DronePauseService.java @@ -2,6 +2,8 @@ package com.tuoheng.admin.service.third.airport.control; import com.alibaba.fastjson.JSONObject; import com.tuoheng.admin.constant.DroneControlConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.request.accident.DroneControlRequest; import com.tuoheng.common.core.utils.JsonResult; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -11,30 +13,17 @@ import org.springframework.stereotype.Service; @Service public class DronePauseService { - @Autowired - private AirportDroneControlService airportDroneControlService; - /** * 航线暂停 * - * @param airportId - * @return - */ - public JsonResult pause(Integer airportId) { - log.info("航线暂停, airportId={}", airportId); - JSONObject jsonObject = this.getJSONObject(airportId); - JsonResult result = airportDroneControlService.exec(jsonObject); - return result; - } - - /** - * @param airportId + * @param request * @return */ - private JSONObject getJSONObject(Integer airportId) { + public JSONObject getJSONObject(DroneControlRequest request) { + log.info("航线暂停, inspectionId={}", request.getInspectionId()); JSONObject jsonObject = new JSONObject(); jsonObject.put("zhilin", DroneControlConstant.PAUSE); - jsonObject.put("airportId", Integer.valueOf(airportId)); + jsonObject.put("airportId", request.getAirportTaskId()); jsonObject.put("msg", "航线暂停"); return jsonObject; } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java index 2d92de1..f594788 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneReturnHomeService.java @@ -2,37 +2,28 @@ package com.tuoheng.admin.service.third.airport.control; import com.alibaba.fastjson.JSONObject; import com.tuoheng.admin.constant.DroneControlConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.request.accident.DroneControlRequest; import com.tuoheng.common.core.utils.JsonResult; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; @Slf4j +@Service public class DroneReturnHomeService { - @Autowired - private AirportDroneControlService airportDroneControlService; - /** * 一键返航 * - * @param airportId - * @return - */ - public JsonResult returnHome(Integer airportId) { - log.info("一键返航, airportId={}", airportId); - JSONObject jsonObject = this.getJSONObject(airportId); - JsonResult result = airportDroneControlService.exec(jsonObject); - return result; - } - - /** - * @param airportId + * @param request * @return */ - private JSONObject getJSONObject(Integer airportId) { + public JSONObject getJSONObject(DroneControlRequest request) { + log.info("一键返航, inspectionId={}", request.getInspectionId()); JSONObject jsonObject = new JSONObject(); jsonObject.put("zhilin", DroneControlConstant.RETURN_HOME); - jsonObject.put("airportId", airportId); + jsonObject.put("airportId", request.getAirportId()); jsonObject.put("msg", "一键返航"); return jsonObject; } diff --git a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java index 7a187ac..908b8f1 100644 --- a/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java +++ b/tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/control/DroneUndoService.java @@ -1,44 +1,49 @@ package com.tuoheng.admin.service.third.airport.control; +import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSONObject; import com.tuoheng.admin.constant.SystemConstant; +import com.tuoheng.admin.entity.Inspection; +import com.tuoheng.admin.request.accident.DroneControlRequest; +import com.tuoheng.admin.service.third.airport.AirportService; +import com.tuoheng.admin.service.third.airport.GetAirLineListService; +import com.tuoheng.admin.service.third.airport.GetAirportListByAirportIds; +import com.tuoheng.admin.vo.AirportInfoVo; +import com.tuoheng.admin.vo.AirportLineVo; +import com.tuoheng.common.core.exception.ServiceException; import com.tuoheng.common.core.utils.JsonResult; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Slf4j @Service public class DroneUndoService { @Autowired - private AirportDroneControlService airportDroneControlService; + private GetAirportListByAirportIds getAirportListByAirportIds; /** * 取消任务 * - * @param taskId - * @param airportCode - * @return - */ - public JsonResult callBack(Integer taskId, String airportCode) { - log.info("取消任务, taskId={}", taskId); - JSONObject jsonObject = this.getJSONObject(taskId, airportCode); - JsonResult result = airportDroneControlService.exec(jsonObject); - return result; - } - - /** - * @param taskId - * @param airportCode + * @param request * @return */ - private JSONObject getJSONObject(Integer taskId, String airportCode) { + public JSONObject getJSONObject(DroneControlRequest request) { + log.info("取消任务, inspectionId={}", request.getInspectionId()); + List airportInfoVoList = getAirportListByAirportIds.getAirportInfo(String.valueOf(request.getAirportId())); + if (CollectionUtil.isEmpty(airportInfoVoList)) { + log.error("操控无人机,该机场不存在, "); + throw new ServiceException("操控无人机,该机场不存在"); + } + AirportInfoVo airportInfoVo = airportInfoVoList.get(9); JSONObject jsonObject = new JSONObject(); jsonObject.put("code", SystemConstant.PLATFORM_CODE); -// jsonObject.put("tenantCode", NJHSJConstant.TENANT_CODE); - jsonObject.put("airportCode", airportCode); - jsonObject.put("taskId", taskId); + jsonObject.put("tenantCode", request.getTenantCode()); + jsonObject.put("airportCode", airportInfoVo.getCode()); + jsonObject.put("taskId", request.getAirportTaskId()); return jsonObject; } -- 2.27.0