From 6c4b31ce20ea2ff466d4d6fca81982d338e82146 Mon Sep 17 00:00:00 2001 From: tangcy <406968399@qq.com> Date: Sat, 11 Apr 2026 13:06:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E7=90=86=E7=A1=AE=E8=AE=A4=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=B0=83=E7=94=A8=E7=AC=AC=E4=B8=89=E6=96=B9=E6=89=A3?= =?UTF-8?q?=E5=88=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/ConstructionIssueFeedback.java | 3 + .../domain/VideoStreamDetection.java | 3 + .../domain/dto/VideoDetectionItemDTO.java | 3 + .../ConstructionIssueFeedbackServiceImpl.java | 58 ++++++--- ...tructionIssueRectificationServiceImpl.java | 67 +++++++--- .../ThirdPartyDeductionReportService.java | 80 ++++++++++++ .../impl/VideoStreamDetectionServiceImpl.java | 90 ++++++++++---- .../utils/ThirdPartyHttpClient.java | 95 ++++++++++++++ .../RiskControlCardTemplateController.java | 66 +++++----- .../logistics/domain/RiskControlCardItem.java | 23 ++-- .../AccessPermitIssuanceController.java | 52 ++++---- .../service/IAccessPermitIssuanceService.java | 8 ++ .../impl/AccessPermitIssuanceServiceImpl.java | 16 +++ .../service/impl/OwnerIssuerServiceImpl.java | 4 + .../ConstructionIssueFeedbackMapper.xml | 6 +- .../ConstructionIssueRectificationMapper.xml | 5 +- .../resources/mapper/PcAlarmTypeMapper.xml | 2 +- .../mapper/RiskControlCardItemMapper.xml | 10 +- .../mapper/VideoStreamDetectionMapper.xml | 9 +- .../service/impl/ThirdPartyServiceImpl.java | 117 ++++++------------ 20 files changed, 505 insertions(+), 212 deletions(-) create mode 100644 aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ThirdPartyDeductionReportService.java create mode 100644 aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/utils/ThirdPartyHttpClient.java diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/ConstructionIssueFeedback.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/ConstructionIssueFeedback.java index 8cd8ee82..2b789873 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/ConstructionIssueFeedback.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/ConstructionIssueFeedback.java @@ -28,6 +28,9 @@ public class ConstructionIssueFeedback extends BaseEntity { @Schema(description = "视频检测记录ID,来源为1时关联cons_video_detection.id") private Long videoDetectionId; + @Schema(description = "检查项ID(风险管控卡模板检查项ID)") + private Long checkItemId; + @Schema(description = "检测名称") private String detectionName; diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/VideoStreamDetection.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/VideoStreamDetection.java index ff96c949..de490802 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/VideoStreamDetection.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/VideoStreamDetection.java @@ -43,6 +43,9 @@ public class VideoStreamDetection { @Schema(description = "检测类型:-1物体检测 0动火作业 1高空作业 2用电作业 3起重吊装 4有限空间 5补充规则") private Integer detectType; + @Schema(description = "规则ID") + private String ruleId; + @Schema(description = "报警级别") private String alarmLevel; diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/dto/VideoDetectionItemDTO.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/dto/VideoDetectionItemDTO.java index 5a824e54..caeb4de5 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/dto/VideoDetectionItemDTO.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/domain/dto/VideoDetectionItemDTO.java @@ -33,4 +33,7 @@ public class VideoDetectionItemDTO { @Schema(description = "检测类型:-1物体检测 0动火作业 1高空作业 2用电作业 3起重吊装 4有限空间 5补充规则") private Integer detectType; + + @Schema(description = "规则ID") + private String ruleId; } diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueFeedbackServiceImpl.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueFeedbackServiceImpl.java index fabb4a8c..2ed1a6dc 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueFeedbackServiceImpl.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueFeedbackServiceImpl.java @@ -14,54 +14,78 @@ import java.util.Date; import java.util.List; /** - * 施工问题反馈Service业务层 - * - * @author ruoyi + * 施工问题反馈 Service */ @Service -public class ConstructionIssueFeedbackServiceImpl implements IConstructionIssueFeedbackService { - +public class ConstructionIssueFeedbackServiceImpl implements IConstructionIssueFeedbackService +{ @Autowired private ConstructionIssueFeedbackMapper constructionIssueFeedbackMapper; @Autowired private ConstructionIssueRectificationMapper constructionIssueRectificationMapper; + @Autowired + private ThirdPartyDeductionReportService thirdPartyDeductionReportService; + @Override - public ConstructionIssueFeedback selectConstructionIssueFeedbackById(Long id) { + public ConstructionIssueFeedback selectConstructionIssueFeedbackById(Long id) + { return constructionIssueFeedbackMapper.selectConstructionIssueFeedbackById(id); } - @Override - public List selectConstructionIssueFeedbackList(ConstructionIssueFeedback query) { + public List selectConstructionIssueFeedbackList(ConstructionIssueFeedback query) + { return constructionIssueFeedbackMapper.selectConstructionIssueFeedbackList(query); } @Override - public int manualSubmit(ConstructionIssueFeedback feedback) { + public int manualSubmit(ConstructionIssueFeedback feedback) + { if (feedback.getProjectId() == null) { throw new ServiceException("项目ID不能为空"); } if (StringUtils.isEmpty(feedback.getDetectionName())) { throw new ServiceException("检测名称不能为空"); } - feedback.setSourceType("2"); // 人工提交 - feedback.setStatus("0"); // 待处理 - feedback.setSubmitBy(SecurityUtils.getUsername()); - feedback.setSubmitTime(new Date()); - feedback.setCreateBy(SecurityUtils.getUsername()); - return constructionIssueFeedbackMapper.insertConstructionIssueFeedback(feedback); + if (feedback.getCheckItemId() == null) { + throw new ServiceException("检查项ID不能为空"); + } + String username = SecurityUtils.getUsername(); + Date now = new Date(); + feedback.setSourceType("2"); + feedback.setStatus("0"); + feedback.setSubmitBy(username); + feedback.setSubmitTime(now); + feedback.setCreateBy(username); + + int rows = constructionIssueFeedbackMapper.insertConstructionIssueFeedback(feedback); + if (rows > 0) { + thirdPartyDeductionReportService.report( + feedback.getCheckItemId(), + feedback.getProjectId(), + feedback.getDescription(), + feedback.getDescription(), + feedback.getProblemPhotoUrl(), + null, + feedback.getSubmitTime(), + now + ); + } + return rows; } @Override - public int updateConstructionIssueFeedback(ConstructionIssueFeedback feedback) { + public int updateConstructionIssueFeedback(ConstructionIssueFeedback feedback) + { feedback.setUpdateBy(SecurityUtils.getUsername()); return constructionIssueFeedbackMapper.updateConstructionIssueFeedback(feedback); } @Override - public int countPendingByProjectId(Long projectId) { + public int countPendingByProjectId(Long projectId) + { return constructionIssueFeedbackMapper.countPendingByProjectId(projectId); } } diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueRectificationServiceImpl.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueRectificationServiceImpl.java index ea2be71e..a3eb8a87 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueRectificationServiceImpl.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ConstructionIssueRectificationServiceImpl.java @@ -5,7 +5,6 @@ import com.admin.contractor.domain.ConstructionIssueRectification; import com.admin.contractor.domain.dto.RectificationReviewDTO; import com.admin.contractor.domain.dto.RectificationSubmitDTO; import com.admin.contractor.domain.vo.RectificationDetailVO; -import com.admin.contractor.domain.vo.RectificationPendingVO; import com.admin.contractor.mapper.ConstructionIssueFeedbackMapper; import com.admin.contractor.mapper.ConstructionIssueRectificationMapper; import com.admin.contractor.service.IConstructionIssueRectificationService; @@ -15,26 +14,29 @@ import com.ruoyi.common.security.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; import java.util.List; /** - * 施工问题整改Service业务层 - * - * @author ruoyi + * 施工问题整改 Service */ @Service -public class ConstructionIssueRectificationServiceImpl implements IConstructionIssueRectificationService { - +public class ConstructionIssueRectificationServiceImpl implements IConstructionIssueRectificationService +{ @Autowired private ConstructionIssueRectificationMapper rectificationMapper; @Autowired private ConstructionIssueFeedbackMapper feedbackMapper; + @Autowired + private ThirdPartyDeductionReportService thirdPartyDeductionReportService; @Override @Transactional(rollbackFor = Exception.class) - public int submitRectification(RectificationSubmitDTO dto) { + public int submitRectification(RectificationSubmitDTO dto) + { if (dto.getFeedbackId() == null) { throw new ServiceException("问题反馈ID不能为空"); } @@ -47,6 +49,7 @@ public class ConstructionIssueRectificationServiceImpl implements IConstructionI if (dto.getRectificationTime() == null) { throw new ServiceException("整改完成时间不能为空"); } + ConstructionIssueFeedback feedback = feedbackMapper.selectConstructionIssueFeedbackById(dto.getFeedbackId()); if (feedback == null) { throw new ServiceException("问题反馈不存在"); @@ -54,13 +57,14 @@ public class ConstructionIssueRectificationServiceImpl implements IConstructionI if (!"0".equals(feedback.getStatus()) && !"3".equals(feedback.getStatus())) { throw new ServiceException("仅待处理或复核不通过的问题可提交整改"); } + String username = SecurityUtils.getUsername(); ConstructionIssueRectification draft = rectificationMapper.selectDraftByFeedbackId(dto.getFeedbackId()); if (draft != null) { draft.setRectificationDesc(dto.getRectificationDesc()); draft.setRectificationPhotoUrls(dto.getRectificationPhotoUrls()); draft.setRectificationTime(dto.getRectificationTime()); - draft.setStatus("1"); // 已提交 + draft.setStatus("1"); draft.setUpdateBy(username); rectificationMapper.updateConstructionIssueRectification(draft); } else { @@ -69,43 +73,47 @@ public class ConstructionIssueRectificationServiceImpl implements IConstructionI record.setRectificationDesc(dto.getRectificationDesc()); record.setRectificationPhotoUrls(dto.getRectificationPhotoUrls()); record.setRectificationTime(dto.getRectificationTime()); - record.setStatus("1"); // 已提交 + record.setStatus("1"); record.setCreateBy(username); rectificationMapper.insertConstructionIssueRectification(record); } - // 问题反馈状态改为待复核 + ConstructionIssueFeedback update = new ConstructionIssueFeedback(); update.setId(dto.getFeedbackId()); - update.setStatus("1"); // 待复核 + update.setStatus("1"); update.setUpdateBy(username); feedbackMapper.updateConstructionIssueFeedback(update); return 1; } @Override - public List listByFeedbackId(Long feedbackId) { + public List listByFeedbackId(Long feedbackId) + { return rectificationMapper.selectByFeedbackId(feedbackId); } @Override - public RectificationDetailVO getDetailByFeedbackId(Long feedbackId) { + public RectificationDetailVO getDetailByFeedbackId(Long feedbackId) + { return rectificationMapper.selectDetailByFeedbackId(feedbackId); } @Override - public List listByProjectId(Long projectId) { + public List listByProjectId(Long projectId) + { return rectificationMapper.selectByProjectId(projectId); } @Override - public List listDetailByProjectId(Long projectId) { + public List listDetailByProjectId(Long projectId) + { return rectificationMapper.selectDetailByProjectId(projectId); } - @Override @Transactional(rollbackFor = Exception.class) - public int submitReview(RectificationReviewDTO dto) { + public int submitReview(RectificationReviewDTO dto) + { if (dto.getRectificationId() == null) { throw new ServiceException("整改记录ID不能为空"); } @@ -115,6 +123,7 @@ public class ConstructionIssueRectificationServiceImpl implements IConstructionI if (StringUtils.isEmpty(dto.getReviewComment())) { throw new ServiceException("复核意见不能为空"); } + ConstructionIssueRectification rect = rectificationMapper.selectConstructionIssueRectificationById(dto.getRectificationId()); if (rect == null) { throw new ServiceException("整改记录不存在"); @@ -122,15 +131,35 @@ public class ConstructionIssueRectificationServiceImpl implements IConstructionI if (!"0".equals(rect.getReviewResult())) { throw new ServiceException("该整改已复核"); } + String username = SecurityUtils.getUsername(); rectificationMapper.updateReview(dto.getRectificationId(), dto.getReviewResult(), dto.getReviewComment(), dto.getReviewPhotoUrls(), username); - // 问题反馈状态:1到位→2复核通过,2未到位→3复核不通过(需重新整改) + + ConstructionIssueFeedback feedback = feedbackMapper.selectConstructionIssueFeedbackById(rect.getFeedbackId()); + if (feedback == null) { + throw new ServiceException("关联问题反馈不存在"); + } + ConstructionIssueFeedback update = new ConstructionIssueFeedback(); update.setId(rect.getFeedbackId()); - update.setStatus("1".equals(dto.getReviewResult()) ? "2" : "3"); // 2复核通过 3复核不通过 + update.setStatus("1".equals(dto.getReviewResult()) ? "2" : "3"); update.setUpdateBy(username); feedbackMapper.updateConstructionIssueFeedback(update); + + if ("2".equals(dto.getReviewResult())) { + thirdPartyDeductionReportService.report( + feedback.getCheckItemId(), + feedback.getProjectId(), + feedback.getDescription(), + dto.getReviewComment(), + feedback.getProblemPhotoUrl(), + null, + feedback.getSubmitTime(), + new Date() + ); + } + return 1; } } diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ThirdPartyDeductionReportService.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ThirdPartyDeductionReportService.java new file mode 100644 index 00000000..7e40fc4e --- /dev/null +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/ThirdPartyDeductionReportService.java @@ -0,0 +1,80 @@ +package com.admin.contractor.service.impl; + +import com.admin.contractor.utils.ThirdPartyHttpClient; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ruoyi.common.core.exception.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 第三方扣分上报封装 + */ +@Service +public class ThirdPartyDeductionReportService +{ + private static final Logger log = LoggerFactory.getLogger(ThirdPartyDeductionReportService.class); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + private static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; + + private final ThirdPartyHttpClient thirdPartyHttpClient; + + public ThirdPartyDeductionReportService(ThirdPartyHttpClient thirdPartyHttpClient) + { + this.thirdPartyHttpClient = thirdPartyHttpClient; + } + + public void report(Long backConfigId, Long projectId, String description, String reason, + String pictureUrl, String videoUrl, Date warnTime, Date handTime) + { + if (backConfigId == null || projectId == null) { + throw new ServiceException("第三方扣分上报失败:缺少必要字段 backConfigId 或 projectId"); + } + try { + String token = thirdPartyHttpClient.getToken("admin", "admin123456"); + if (token == null) { + throw new ServiceException("第三方扣分上报失败:获取第三方Token失败"); + } + Map payload = new LinkedHashMap<>(); + payload.put("backConfigId", backConfigId); + payload.put("description", description); + payload.put("projectId", projectId); + payload.put("reason", reason); + payload.put("status", 0); + payload.put("wainTime", format(warnTime)); + payload.put("handTime", format(handTime != null ? handTime : new Date())); + payload.put("pictureUrl", pictureUrl); + payload.put("videoUrl", videoUrl); + + String response = thirdPartyHttpClient.submitDeduction(token, OBJECT_MAPPER.writeValueAsString(payload)); + if (response == null) { + throw new ServiceException("第三方扣分上报失败:调用第三方接口无响应"); + } + JsonNode jsonNode = OBJECT_MAPPER.readTree(response); + if (jsonNode.has("code") && jsonNode.get("code").asInt() != 200) { + String message = jsonNode.has("message") ? jsonNode.get("message").asText() : "业务处理失败"; + throw new ServiceException("第三方扣分上报失败:" + message); + } + } catch (Exception e) { + if (e instanceof ServiceException) { + throw (ServiceException) e; + } + log.error("第三方扣分上报异常", e); + throw new ServiceException("第三方扣分上报失败:" + e.getMessage()); + } + } + + private String format(Date date) + { + if (date == null) { + return null; + } + return new SimpleDateFormat(TIME_PATTERN).format(date); + } +} diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/VideoStreamDetectionServiceImpl.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/VideoStreamDetectionServiceImpl.java index 30c8a69a..fce28926 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/VideoStreamDetectionServiceImpl.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/service/impl/VideoStreamDetectionServiceImpl.java @@ -9,11 +9,11 @@ import com.admin.contractor.mapper.ConstructionIssueFeedbackMapper; import com.admin.contractor.mapper.VideoStreamDetectionMapper; import com.admin.contractor.service.IVideoStreamDetectionService; import com.admin.property.mapper.PcCameraAllocMapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.utils.SecurityUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,13 +23,11 @@ import java.util.Date; import java.util.List; /** - * 视频流检测推送Service(第三方推送落库) - * - * @author ruoyi + * 视频流检测推送 Service */ @Service -public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionService { - +public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionService +{ @Autowired private VideoStreamDetectionMapper videoStreamDetectionMapper; @@ -39,22 +37,27 @@ public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionSer @Autowired(required = false) private PcCameraAllocMapper pcCameraAllocMapper; - private static final ObjectMapper objectMapper = new ObjectMapper(); + @Autowired + private ThirdPartyDeductionReportService thirdPartyDeductionReportService; + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Override @Transactional(rollbackFor = Exception.class) - public int push(VideoStreamPushDTO dto) { + public int push(VideoStreamPushDTO dto) + { if (dto.getDescription() == null || dto.getDescription().isEmpty()) { return 0; } + String projectId = null; if (pcCameraAllocMapper != null && dto.getStreamId() != null) { - // streamId 约定为球机编号 cameraNo Long projectIdValue = pcCameraAllocMapper.selectProjectIdByCameraNo(dto.getStreamId()); if (projectIdValue != null) { projectId = String.valueOf(projectIdValue); } } + List list = new ArrayList<>(); for (VideoDetectionItemDTO item : dto.getDescription()) { VideoStreamDetection entity = new VideoStreamDetection(); @@ -68,11 +71,13 @@ public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionSer entity.setConfidence(item.getConfidence()); entity.setTag(item.getTag()); entity.setDetectType(item.getDetectType()); + entity.setRuleId(item.getRuleId()); entity.setImgUrl(dto.getImgUrl()); entity.setVideoUrl(dto.getVideoUrl()); entity.setIsFirst(Boolean.TRUE.equals(dto.getIsFirst()) ? "1" : "0"); list.add(entity); } + if (list.isEmpty()) { return 0; } @@ -81,28 +86,33 @@ public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionSer } @Override - public List listPendingReview(VideoStreamDetection query) { + public List listPendingReview(VideoStreamDetection query) + { return videoStreamDetectionMapper.selectPendingReviewList(query); } @Override - public List listAllPushRecords(VideoStreamDetection query) { + public List listAllPushRecords(VideoStreamDetection query) + { return videoStreamDetectionMapper.selectAllPushRecords(query); } @Override - public List listReviewedRecords(VideoStreamDetection query) { + public List listReviewedRecords(VideoStreamDetection query) + { return videoStreamDetectionMapper.selectReviewedRecords(query); } @Override - public VideoStreamDetection selectVideoStreamDetectionById(Long id) { + public VideoStreamDetection selectVideoStreamDetectionById(Long id) + { return videoStreamDetectionMapper.selectVideoStreamDetectionById(id); } @Override @Transactional(rollbackFor = Exception.class) - public int submitReview(VideoDetectionReviewItemDTO dto) { + public int submitReview(VideoDetectionReviewItemDTO dto) + { if (dto == null) { throw new ServiceException("复核项不能为空"); } @@ -112,26 +122,27 @@ public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionSer if (StringUtils.isEmpty(dto.getReviewResult())) { throw new ServiceException("复核结果不能为空"); } - String username = SecurityUtils.getUsername(); - Date now = new Date(); - // 单条复核:根据检测ID定位记录 + VideoStreamDetection detection = videoStreamDetectionMapper.selectVideoStreamDetectionById(dto.getVideoDetectionId()); if (detection == null) { return 0; } - String result = StringUtils.isNotEmpty(dto.getReviewResult()) ? dto.getReviewResult() : ""; - videoStreamDetectionMapper.updateReview(dto.getVideoDetectionId(), result, username); - if ("2".equals(result)) { - // 单条复核不再要求前端传 projectId;直接从检测记录回填 + String username = SecurityUtils.getUsername(); + Date now = new Date(); + videoStreamDetectionMapper.updateReview(dto.getVideoDetectionId(), dto.getReviewResult(), username); + + if ("2".equals(dto.getReviewResult())) { Long issueProjectId = parseProjectId(detection.getProjectId()); if (issueProjectId == null) { - throw new ServiceException("存在不合格项时,项目ID不能为空"); + throw new ServiceException("不合格项缺少项目ID"); } + ConstructionIssueFeedback feedback = new ConstructionIssueFeedback(); feedback.setProjectId(issueProjectId); feedback.setSourceType("1"); feedback.setVideoDetectionId(detection.getId()); + feedback.setCheckItemId(parseCheckItemId(detection.getRuleId())); feedback.setDetectionName(detection.getName()); feedback.setDescription(detection.getLabel()); feedback.setProblemPhotoUrl(detection.getImgUrl()); @@ -141,30 +152,55 @@ public class VideoStreamDetectionServiceImpl implements IVideoStreamDetectionSer feedback.setSubmitTime(now); feedback.setCreateBy(username); constructionIssueFeedbackMapper.insertConstructionIssueFeedback(feedback); + + thirdPartyDeductionReportService.report( + feedback.getCheckItemId(), + issueProjectId, + detection.getLabel(), + detection.getTag(), + detection.getImgUrl(), + detection.getVideoUrl(), + detection.getCreateTime(), + now + ); } return 1; } - private String toBoxJson(List box) { + private String toBoxJson(List box) + { if (box == null || box.isEmpty()) { return null; } try { - return objectMapper.writeValueAsString(box); + return OBJECT_MAPPER.writeValueAsString(box); } catch (JsonProcessingException e) { return null; } } - private Long parseProjectId(String projectId) { + private Long parseProjectId(String projectId) + { if (StringUtils.isEmpty(projectId)) { return null; } try { return Long.valueOf(projectId); } catch (NumberFormatException e) { - throw new ServiceException("projectId 格式错误,必须为数字字符串"); + throw new ServiceException("projectId 格式错误,必须是数字字符串"); + } + } + + private Long parseCheckItemId(String ruleId) + { + if (StringUtils.isEmpty(ruleId)) { + return null; + } + try { + return Long.valueOf(ruleId); + } catch (NumberFormatException e) { + return null; } } } diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/utils/ThirdPartyHttpClient.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/utils/ThirdPartyHttpClient.java new file mode 100644 index 00000000..bb0e11cf --- /dev/null +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/contractor/utils/ThirdPartyHttpClient.java @@ -0,0 +1,95 @@ +package com.admin.contractor.utils; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import javax.annotation.PostConstruct; +import java.util.Collections; + +@Component +public class ThirdPartyHttpClient +{ + private static final Logger log = LoggerFactory.getLogger(ThirdPartyHttpClient.class); + private static final String BASE_URL = "http://1.13.245.108/trainCore"; + private static final int CONNECT_TIMEOUT_MS = 1500; + private static final int READ_TIMEOUT_MS = 2500; + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + private RestTemplate restTemplate; + + @PostConstruct + public void init() + { + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setConnectTimeout(CONNECT_TIMEOUT_MS); + factory.setReadTimeout(READ_TIMEOUT_MS); + restTemplate = new RestTemplate(factory); + } + + public String getToken(String username, String password) + { + try { + String url = BASE_URL + "/login/getToken"; + String body = String.format("{\"username\":\"%s\",\"password\":\"%s\"}", username, password); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + HttpEntity entity = new HttpEntity<>(body, headers); + ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); + if (response.getStatusCode() != HttpStatus.OK) { + return null; + } + return parseToken(response.getBody()); + } catch (Exception e) { + log.error("获取第三方 token 异常", e); + return null; + } + } + + public String submitDeduction(String token, String requestBody) + { + try { + String url = BASE_URL + "/thirdParty/deduction"; + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.set("Authorization", token); + HttpEntity entity = new HttpEntity<>(requestBody, headers); + ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); + return response.getStatusCode() == HttpStatus.OK ? response.getBody() : null; + } catch (Exception e) { + log.error("第三方扣分上报异常", e); + return null; + } + } + + private String parseToken(String responseBody) + { + try { + JsonNode jsonNode = OBJECT_MAPPER.readTree(responseBody); + if (jsonNode.has("data") && !jsonNode.get("data").isNull()) { + JsonNode dataNode = jsonNode.get("data"); + if (dataNode.has("token")) { + return dataNode.get("token").asText(); + } + if (dataNode.isValueNode()) { + return dataNode.asText(); + } + } + return null; + } catch (Exception e) { + return null; + } + } +} diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/controller/RiskControlCardTemplateController.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/controller/RiskControlCardTemplateController.java index 464408f1..6c7d67de 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/controller/RiskControlCardTemplateController.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/controller/RiskControlCardTemplateController.java @@ -22,21 +22,19 @@ import javax.servlet.http.HttpServletResponse; import java.util.List; /** - * 风险管控卡模板Controller - * - * @author ruoyi + * 风险管控卡模板 Controller */ @Tag(name = "风险管控卡模板配置") @RestController @RequestMapping("/logistics/riskCard/template") public class RiskControlCardTemplateController extends BaseController { - + @Autowired private IRiskControlCardTemplateService templateService; - + @Autowired private IRiskControlCardItemService itemService; - + /** * 查询风险管控卡模板列表 */ @@ -48,7 +46,7 @@ public class RiskControlCardTemplateController extends BaseController { List list = templateService.selectRiskControlCardTemplateList(template); return getDataTable(list); } - + /** * 导出风险管控卡模板列表 */ @@ -58,20 +56,20 @@ public class RiskControlCardTemplateController extends BaseController { @PostMapping("/export") public void export(HttpServletResponse response, RiskControlCardTemplate template) { List list = templateService.selectRiskControlCardTemplateList(template); - ExcelUtil util = new ExcelUtil(RiskControlCardTemplate.class); + ExcelUtil util = new ExcelUtil<>(RiskControlCardTemplate.class); util.exportExcel(response, list, "风险管控卡模板数据"); } - + /** - * 获取风险管控卡模板详细信息 + * 获取风险管控卡模板详情 */ - @Operation(summary = "获取风险管控卡模板详细信息") + @Operation(summary = "获取风险管控卡模板详情") @PreAuthorize("@ss.hasPermi('logistics:riskCard:query')") @GetMapping(value = "/{templateId}") public AjaxResult getInfo(@Parameter(description = "模板ID") @PathVariable("templateId") Long templateId) { return success(templateService.selectRiskControlCardTemplateById(templateId)); } - + /** * 新增风险管控卡模板 */ @@ -82,7 +80,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult add(@Validated @RequestBody RiskControlCardTemplate template) { return toAjax(templateService.insertRiskControlCardTemplate(template)); } - + /** * 修改风险管控卡模板 */ @@ -93,7 +91,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult edit(@Validated @RequestBody RiskControlCardTemplate template) { return toAjax(templateService.updateRiskControlCardTemplate(template)); } - + /** * 删除风险管控卡模板 */ @@ -104,7 +102,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult remove(@Parameter(description = "模板ID数组") @PathVariable Long[] templateIds) { return toAjax(templateService.deleteRiskControlCardTemplateByIds(templateIds)); } - + /** * 发布模板 */ @@ -115,7 +113,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult publish(@Parameter(description = "模板ID") @PathVariable("templateId") Long templateId) { return toAjax(templateService.publishTemplate(templateId)); } - + /** * 作废模板 */ @@ -126,7 +124,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult obsolete(@Parameter(description = "模板ID") @PathVariable("templateId") Long templateId) { return toAjax(templateService.obsoleteTemplate(templateId)); } - + /** * 保存并发布模板 */ @@ -137,9 +135,9 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult saveAndPublish(@Validated @RequestBody RiskControlCardTemplate template) { return toAjax(templateService.saveAndPublishTemplate(template)); } - + /** - * 保存模板(未发布,状态设置为0) + * 保存模板(未发布) */ @Operation(summary = "保存模板未发布") @PreAuthorize("@ss.hasPermi('logistics:riskCard:edit')") @@ -148,7 +146,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult save(@Validated @RequestBody RiskControlCardTemplate template) { return toAjax(templateService.saveTemplate(template)); } - + /** * 批量导入检查项 */ @@ -157,10 +155,10 @@ public class RiskControlCardTemplateController extends BaseController { @Log(title = "风险管控卡检查项", businessType = BusinessType.IMPORT) @PostMapping("/importItems/{templateId}") public AjaxResult importItems(@Parameter(description = "模板ID") @PathVariable("templateId") Long templateId, - @Parameter(description = "检查项列表") @RequestBody List items) { + @Parameter(description = "检查项列表") @RequestBody List items) { return toAjax(templateService.batchImportItems(templateId, items)); } - + /** * 导出模板(包含检查项) */ @@ -170,9 +168,9 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult exportTemplate(@Parameter(description = "模板ID") @PathVariable("templateId") Long templateId) { return success(templateService.exportTemplate(templateId)); } - + /** - * 查询检查项列表 + * 查询检查项列表(按模板ID) */ @Operation(summary = "查询检查项列表") @PreAuthorize("@ss.hasPermi('logistics:riskCard:query')") @@ -181,7 +179,19 @@ public class RiskControlCardTemplateController extends BaseController { List items = itemService.selectItemsByTemplateId(templateId); return success(items); } - + + /** + * 查询检查项列表(分页+筛选) + */ + @Operation(summary = "查询检查项分页列表") + @PreAuthorize("@ss.hasPermi('logistics:riskCard:query')") + @GetMapping("/item/list") + public TableDataInfo listItems(RiskControlCardItem item) { + startPage(); + List list = itemService.selectRiskControlCardItemList(item); + return getDataTable(list); + } + /** * 新增检查项 */ @@ -192,7 +202,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult addItem(@Validated @RequestBody RiskControlCardItem item) { return toAjax(itemService.insertRiskControlCardItem(item)); } - + /** * 修改检查项 */ @@ -203,7 +213,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult editItem(@Validated @RequestBody RiskControlCardItem item) { return toAjax(itemService.updateRiskControlCardItem(item)); } - + /** * 删除检查项 */ @@ -214,7 +224,7 @@ public class RiskControlCardTemplateController extends BaseController { public AjaxResult removeItem(@Parameter(description = "检查项ID") @PathVariable("itemId") Long itemId) { return toAjax(itemService.deleteRiskControlCardItemById(itemId)); } - + /** * 更新检查项排序 */ diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/domain/RiskControlCardItem.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/domain/RiskControlCardItem.java index 6a445e88..112ff594 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/domain/RiskControlCardItem.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/logistics/domain/RiskControlCardItem.java @@ -5,37 +5,40 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; +import java.math.BigDecimal; + /** * 风险管控卡检查项 - * - * @author ruoyi */ @Data @EqualsAndHashCode(callSuper = true) @Schema(description = "风险管控卡检查项") public class RiskControlCardItem extends BaseEntity { - + @Schema(description = "检查项ID") private Long itemId; - + @Schema(description = "模板ID") private Long templateId; - + @Schema(description = "检查项描述") private String itemDescription; - + @Schema(description = "检查方式:0人工检查,1自动检查") private String checkMethod; - + @Schema(description = "是否必选:0可选,1必选") private String isRequired; @Schema(description = "风险等级:1高 2中 3低") private String riskLevel; - + + @Schema(description = "分值") + private BigDecimal score; + @Schema(description = "排序号") private Integer sortOrder; - - @Schema(description = "删除标志(0代表存在 2代表删除)") + + @Schema(description = "删除标志:0存在 2删除") private String delFlag; } diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/controller/AccessPermitIssuanceController.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/controller/AccessPermitIssuanceController.java index 2c4061ab..c8eb1c6a 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/controller/AccessPermitIssuanceController.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/controller/AccessPermitIssuanceController.java @@ -20,20 +20,18 @@ import org.springframework.web.bind.annotation.*; import java.util.List; /** - * 出入证签发Controller - * - * @author ruoyi + * Access permit issuance controller. */ @Tag(name = "出入证签发管理") @RestController @RequestMapping("/owner/accessPermitIssuance") public class AccessPermitIssuanceController extends BaseController { - + @Autowired private IAccessPermitIssuanceService accessPermitIssuanceService; - + /** - * 查询待签发出入证列表 + * Query access permit issuance list. */ @Operation(summary = "查询待签发出入证列表", description = "查询待签发、已签发、已作废等状态的出入证列表") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:list')") @@ -43,29 +41,39 @@ public class AccessPermitIssuanceController extends BaseController { List list = accessPermitIssuanceService.selectAccessPermitIssuanceList(accessPermit); return getDataTable(list); } - + /** - * 获取出入证签发详细信息 + * Get access permit details by permit id. */ - @Operation(summary = "获取出入证签发详细信息") + @Operation(summary = "获取出入证签发详情信息") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:query')") @GetMapping(value = "/{permitId}") public AjaxResult getInfo(@Parameter(description = "出入证ID") @PathVariable("permitId") Long permitId) { return success(accessPermitIssuanceService.selectAccessPermitById(permitId)); } - + /** - * 根据工作票ID获取签发信息(用于预填充表单) + * Get access permit details by project id. */ - @Operation(summary = "根据工作票ID获取签发信息", description = "根据工作票ID获取项目信息、作业地点、负责人等信息,用于签发出入证时预填充") + @Operation(summary = "根据项目ID获取出入证详情") + @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:query')") + @GetMapping("/project/{projectId}") + public AjaxResult getByProjectId(@Parameter(description = "项目ID") @PathVariable("projectId") Long projectId) { + return success(accessPermitIssuanceService.selectAccessPermitByProjectId(projectId)); + } + + /** + * Get issuance prefill info by ticket id. + */ + @Operation(summary = "根据工作票ID获取签发信息", description = "根据工作票ID获取项目信息、作业地点、负责人等信息,用于签发出入证时预填充表单") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:query')") @GetMapping("/ticket/{ticketId}") public AjaxResult getInfoByTicketId(@Parameter(description = "工作票ID") @PathVariable("ticketId") Long ticketId) { return success(accessPermitIssuanceService.getIssuanceInfoByTicketId(ticketId)); } - + /** - * 签发出入证 + * Issue access permit. */ @Operation(summary = "签发出入证", description = "确认签发出入证,更新状态为已签发") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:issue')") @@ -74,9 +82,9 @@ public class AccessPermitIssuanceController extends BaseController { public AjaxResult issue(@Validated @RequestBody AccessPermit accessPermit) { return toAjax(accessPermitIssuanceService.issueAccessPermit(accessPermit)); } - + /** - * 查看关联票证 + * View related work ticket. */ @Operation(summary = "查看关联票证", description = "根据出入证ID查看关联的工作票信息") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:query')") @@ -85,9 +93,9 @@ public class AccessPermitIssuanceController extends BaseController { WorkTicket workTicket = accessPermitIssuanceService.getRelatedWorkTicket(permitId); return success(workTicket); } - + /** - * 作废出入证 + * Cancel access permit. */ @Operation(summary = "作废出入证", description = "将出入证状态更新为已作废") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:edit')") @@ -96,9 +104,9 @@ public class AccessPermitIssuanceController extends BaseController { public AjaxResult cancel(@Parameter(description = "出入证ID") @PathVariable("permitId") Long permitId) { return toAjax(accessPermitIssuanceService.cancelAccessPermit(permitId)); } - + /** - * 查询项目已添加的车辆列表 + * Query vehicles added under project. */ @Operation(summary = "查询项目已添加的车辆列表", description = "查询某个项目下所有出入证已添加的车辆列表(去重)") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:query')") @@ -107,9 +115,9 @@ public class AccessPermitIssuanceController extends BaseController { List vehicles = accessPermitIssuanceService.getProjectVehicles(projectId); return success(vehicles); } - + /** - * 查询出入证已添加的车辆列表 + * Query vehicles added in access permit. */ @Operation(summary = "查询出入证已添加的车辆列表", description = "查询指定出入证已添加的车辆列表") @PreAuthorize("@ss.hasPermi('owner:accessPermitIssuance:query')") diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/IAccessPermitIssuanceService.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/IAccessPermitIssuanceService.java index 5e2931f7..86a67de2 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/IAccessPermitIssuanceService.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/IAccessPermitIssuanceService.java @@ -28,6 +28,14 @@ public interface IAccessPermitIssuanceService { * @return 出入证信息 */ AccessPermit selectAccessPermitById(Long permitId); + + /** + * 根据项目ID查询出入证详情 + * + * @param projectId 项目ID + * @return 出入证信息 + */ + AccessPermit selectAccessPermitByProjectId(Long projectId); /** * 根据工作票ID获取签发信息(用于预填充表单) diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/AccessPermitIssuanceServiceImpl.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/AccessPermitIssuanceServiceImpl.java index fae99ac7..0114d743 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/AccessPermitIssuanceServiceImpl.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/AccessPermitIssuanceServiceImpl.java @@ -95,6 +95,22 @@ public class AccessPermitIssuanceServiceImpl implements IAccessPermitIssuanceSer } return permit; } + + /** + * 根据项目ID查询出入证详情 + * + * @param projectId 项目ID + * @return 出入证信息 + */ + @Override + public AccessPermit selectAccessPermitByProjectId(Long projectId) { + AccessPermit permit = accessPermitMapper.selectAccessPermitByProjectId(projectId); + if (permit != null) { + parseJsonFields(permit); + loadSysUsers(permit); + } + return permit; + } /** * 根据工作票ID获取签发信息(用于预填充表单) diff --git a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/OwnerIssuerServiceImpl.java b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/OwnerIssuerServiceImpl.java index cd727ebf..d7f8ef98 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/OwnerIssuerServiceImpl.java +++ b/aidmt-modules/aidmt-manage-ms/src/main/java/com/admin/owner/service/impl/OwnerIssuerServiceImpl.java @@ -143,6 +143,10 @@ public class OwnerIssuerServiceImpl implements IOwnerIssuerService { if (issuer == null) { return false; } + // 签发人被禁用时,视为无权限 + if (!"0".equals(issuer.getStatus())) { + return false; + } if (issuer.getValidUntil() != null && issuer.getValidUntil().before(todayStart())) { return false; } diff --git a/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueFeedbackMapper.xml b/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueFeedbackMapper.xml index b6f2147e..c02a2380 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueFeedbackMapper.xml +++ b/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueFeedbackMapper.xml @@ -9,6 +9,7 @@ + @@ -46,11 +47,11 @@ insert into cons_issue_fb( - project_id, source_type, video_detection_id, detection_name, description, + project_id, source_type, video_detection_id, check_item_id, detection_name, description, problem_photo_url, attachment_urls, status, submit_by, submit_time, remark, del_flag, create_by, create_time ) values ( - #{projectId}, #{sourceType}, #{videoDetectionId}, #{detectionName}, #{description}, + #{projectId}, #{sourceType}, #{videoDetectionId}, #{checkItemId}, #{detectionName}, #{description}, #{problemPhotoUrl}, #{attachmentUrls}, #{status}, #{submitBy}, #{submitTime}, #{remark}, '0', #{createBy}, now() ) @@ -60,6 +61,7 @@ update cons_issue_fb status = #{status}, + check_item_id = #{checkItemId}, attachment_urls = #{attachmentUrls}, remark = #{remark}, update_by = #{updateBy}, diff --git a/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueRectificationMapper.xml b/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueRectificationMapper.xml index 1b58d4a6..33a6bbea 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueRectificationMapper.xml +++ b/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/ConstructionIssueRectificationMapper.xml @@ -58,6 +58,7 @@ + @@ -84,7 +85,7 @@ + @@ -20,7 +21,7 @@ - select item_id, template_id, item_description, check_method, is_required, risk_level, sort_order, del_flag, create_by, create_time, update_by, update_time + select item_id, template_id, item_description, check_method, is_required, risk_level, score, sort_order, del_flag, create_by, create_time, update_by, update_time from risk_control_card_item_template @@ -57,6 +58,7 @@ check_method, is_required, risk_level, + score, sort_order, create_by, create_time @@ -66,6 +68,7 @@ #{checkMethod}, #{isRequired}, #{riskLevel}, + #{score}, #{sortOrder}, #{createBy}, now() @@ -73,10 +76,10 @@ - insert into risk_control_card_item_template(template_id, item_description, check_method, is_required, risk_level, sort_order, create_by, create_time) + insert into risk_control_card_item_template(template_id, item_description, check_method, is_required, risk_level, score, sort_order, create_by, create_time) values - (#{item.templateId}, #{item.itemDescription}, #{item.checkMethod}, #{item.isRequired}, #{item.riskLevel}, #{item.sortOrder}, #{item.createBy}, now()) + (#{item.templateId}, #{item.itemDescription}, #{item.checkMethod}, #{item.isRequired}, #{item.riskLevel}, #{item.score}, #{item.sortOrder}, #{item.createBy}, now()) @@ -87,6 +90,7 @@ check_method = #{checkMethod}, is_required = #{isRequired}, risk_level = #{riskLevel}, + score = #{score}, sort_order = #{sortOrder}, update_by = #{updateBy}, update_time = now() diff --git a/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/VideoStreamDetectionMapper.xml b/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/VideoStreamDetectionMapper.xml index 20ce7baf..f57c2c93 100644 --- a/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/VideoStreamDetectionMapper.xml +++ b/aidmt-modules/aidmt-manage-ms/src/main/resources/mapper/VideoStreamDetectionMapper.xml @@ -16,6 +16,7 @@ + @@ -28,10 +29,10 @@ insert into cons_video_detection( - stream_id, project_id, frame_timestamp, name, label, need_alert, box_json, confidence, tag, detect_type, img_url, video_url, is_first, create_time + stream_id, project_id, frame_timestamp, name, label, need_alert, box_json, confidence, tag, detect_type, rule_id, img_url, video_url, is_first, create_time ) values - (#{item.streamId}, #{item.projectId}, #{item.frameTimestamp}, #{item.name}, #{item.label}, #{item.needAlert}, #{item.boxJson}, #{item.confidence}, #{item.tag}, #{item.detectType}, #{item.imgUrl}, #{item.videoUrl}, #{item.isFirst}, now()) + (#{item.streamId}, #{item.projectId}, #{item.frameTimestamp}, #{item.name}, #{item.label}, #{item.needAlert}, #{item.boxJson}, #{item.confidence}, #{item.tag}, #{item.detectType}, #{item.ruleId}, #{item.imgUrl}, #{item.videoUrl}, #{item.isFirst}, now()) @@ -54,7 +55,7 @@ select v.id, v.stream_id, v.project_id, v.frame_timestamp, v.name, v.label, v.need_alert, - v.box_json, v.confidence, v.tag, v.detect_type, v.img_url, v.video_url, v.is_first, + v.box_json, v.confidence, v.tag, v.detect_type, v.rule_id, v.img_url, v.video_url, v.is_first, v.review_status, v.review_by, v.review_time, v.create_time from cons_video_detection v where 1 = 1 diff --git a/aidmt-modules/aidmt-system-ms/src/main/java/com/ruoyi/system/service/impl/ThirdPartyServiceImpl.java b/aidmt-modules/aidmt-system-ms/src/main/java/com/ruoyi/system/service/impl/ThirdPartyServiceImpl.java index 75dcc29d..0bb0bdc3 100644 --- a/aidmt-modules/aidmt-system-ms/src/main/java/com/ruoyi/system/service/impl/ThirdPartyServiceImpl.java +++ b/aidmt-modules/aidmt-system-ms/src/main/java/com/ruoyi/system/service/impl/ThirdPartyServiceImpl.java @@ -1,112 +1,75 @@ package com.ruoyi.system.service.impl; -import com.ruoyi.system.domain.dto.ThirdPartyDeductionDTO; -import com.ruoyi.system.utils.ThirdPartyHttpClient; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.system.domain.dto.ThirdPartyDeductionDTO; import com.ruoyi.system.service.IThirdPartyService; -import lombok.extern.slf4j.Slf4j; +import com.ruoyi.system.utils.ThirdPartyHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** - * 第三方接口Service实现 - * - * @author ruoyi + * 第三方接口 Service 实现 */ -@Slf4j @Service -public class ThirdPartyServiceImpl implements IThirdPartyService { +public class ThirdPartyServiceImpl implements IThirdPartyService +{ + private static final Logger log = LoggerFactory.getLogger(ThirdPartyServiceImpl.class); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Autowired private ThirdPartyHttpClient thirdPartyHttpClient; - private static final ObjectMapper objectMapper = new ObjectMapper(); - - /** - * 获取第三方系统Token - * - * @param username 用户名 - * @param password 密码 - * @return Token - */ @Override - public String getThirdPartyToken(String username, String password) { - log.info("获取第三方Token: username={}", username); + public String getThirdPartyToken(String username, String password) + { return thirdPartyHttpClient.getToken(username, password); } - /** - * 调用第三方扣分上报接口 - * - * @param dto 扣分上报数据 - * @return 调用结果 - */ @Override - public AjaxResult callThirdPartyDeduction(ThirdPartyDeductionDTO dto) { + public AjaxResult callThirdPartyDeduction(ThirdPartyDeductionDTO dto) + { try { - log.info("调用第三方扣分上报接口:thirdId={}, projectId={}", dto.getThirdId(), dto.getProjectId()); - - // 获取 Token - String token = getThirdPartyToken("admin", "admin123456"); - if (token == null) { - return AjaxResult.error("获取第三方 Token 失败"); - } - - // 转换 DTO 为 JSON 字符串 - String requestBody = objectMapper.writeValueAsString(dto); - - // 调用第三方接口 - String response = thirdPartyHttpClient.submitDeduction(token, requestBody); - if (response == null) { - return AjaxResult.error("调用第三方扣分上报接口失败"); - } - - // 检查业务返回码 - JsonNode jsonNode = objectMapper.readTree(response); - if (jsonNode.has("code") && jsonNode.get("code").asInt() != 200) { - String message = jsonNode.has("message") ? jsonNode.get("message").asText() : "业务处理失败"; - log.warn("第三方扣分上报业务失败:{}", message); - return AjaxResult.error("扣分上报失败:" + message); - } - - log.info("第三方扣分上报成功"); - return AjaxResult.success("扣分上报成功", response); - } catch (Exception e) { - log.error("调用第三方扣分上报接口异常", e); - return AjaxResult.error("调用第三方扣分上报接口异常:" + e.getMessage()); - } - } - - /** - * 调用第三方获取企业评分接口 - * - * @param companyId 企业ID - * @return 企业评分信息 - */ - @Override - public AjaxResult callThirdPartyGetCompanyScore(Long companyId) { - try { - log.info("调用第三方获取企业评分接口: companyId={}", companyId); - - // 获取Token String token = getThirdPartyToken("admin", "admin123456"); if (token == null) { return AjaxResult.error("获取第三方Token失败"); } + String requestBody = OBJECT_MAPPER.writeValueAsString(dto); + String response = thirdPartyHttpClient.submitDeduction(token, requestBody); + if (response == null) { + return AjaxResult.error("调用第三方扣分上报失败"); + } + JsonNode jsonNode = OBJECT_MAPPER.readTree(response); + if (jsonNode.has("code") && jsonNode.get("code").asInt() != 200) { + String message = jsonNode.has("message") ? jsonNode.get("message").asText() : "业务处理失败"; + return AjaxResult.error("扣分上报失败:" + message); + } + return AjaxResult.success("扣分上报成功", response); + } catch (Exception e) { + log.error("调用第三方扣分上报异常", e); + return AjaxResult.error("调用第三方扣分上报异常:" + e.getMessage()); + } + } - // 调用第三方接口 + @Override + public AjaxResult callThirdPartyGetCompanyScore(Long companyId) + { + try { + String token = getThirdPartyToken("admin", "admin123456"); + if (token == null) { + return AjaxResult.error("获取第三方Token失败"); + } String response = thirdPartyHttpClient.getCompanyScore(token, companyId); if (response == null) { - return AjaxResult.error("调用第三方获取企业评分接口失败"); + return AjaxResult.error("调用第三方获取企业评分失败"); } - - log.info("获取企业评分成功: {}", response); return AjaxResult.success("获取企业评分成功", response); } catch (Exception e) { - log.error("调用第三方获取企业评分接口异常", e); - return AjaxResult.error("调用第三方获取企业评分接口异常: " + e.getMessage()); + log.error("调用第三方获取企业评分异常", e); + return AjaxResult.error("调用第三方获取企业评分异常:" + e.getMessage()); } } }