From 0d4e7fe74659b2900f2afae1c09142a63c396fa6 Mon Sep 17 00:00:00 2001 From: luyie Date: Tue, 20 Aug 2024 14:09:43 +0800 Subject: [PATCH 1/8] =?UTF-8?q?add:=E8=A7=86=E9=A2=91=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=EF=BC=8C=E6=88=AA=E5=9B=BE=E8=A7=86=E9=A2=91=E8=BD=AC=E5=AD=98?= =?UTF-8?q?minio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/common/utils/FileUtil.java | 175 ++++++++++++++++++++- .../api/dto/BigModelAnalysisResponseDTO.java | 2 +- .../hydroelectric/vo/HydroelectricDeviceVo.java | 4 +- .../hydroelectric/vo/HydroelectricPowerRainVo.java | 4 +- .../zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java | 4 +- .../inspect/task/schedule/VideoTaskSchedule.java | 34 +++- 6 files changed, 211 insertions(+), 12 deletions(-) diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java index c6167b5..ce65fb3 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java @@ -1,10 +1,14 @@ package com.hnac.hzims.common.utils; +import lombok.NonNull; +import lombok.Value; import lombok.extern.slf4j.Slf4j; +import org.springframework.web.multipart.MultipartFile; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLDecoder; import java.util.Base64; /** @@ -35,6 +39,131 @@ public class FileUtil { return bytes; } + public static byte[] getUrlByte(URL url) { + InputStream inputStream = null; + ByteArrayOutputStream outputStream = null; + byte[] fileBytes = null; + try { + inputStream = url.openStream(); + outputStream = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + fileBytes = outputStream.toByteArray(); + } catch (Exception e) { + log.error("获取url文件失败", e); + } finally { + try { + if (null != inputStream) { + inputStream.close(); + } + if (null != outputStream) { + outputStream.close(); + } + } catch (Exception ignore) { + + } + } + return fileBytes; + } + + public static byte[] getUrlByte(String urlString) { + try { + return getUrlByte(new URL(urlString)); + } catch (MalformedURLException e) { + log.error("获取url文件失败", e); + } + return null; + } + + public static String getContentTypeFromUrl(String url) { + String result = ""; + String fileType = url.toLowerCase(); + if (fileType.indexOf(".png") >= 0) { + result = "image/png"; + } else if (fileType.indexOf(".gif") >= 0) { + result = "image/gif"; + } else if (fileType.indexOf(".jpg") >= 0 || fileType.indexOf(".jpeg") >= 0) { + result = "image/jpeg"; + } else if (fileType.indexOf(".svg") >= 0) { + result = "image/svg+xml"; + } else if (fileType.indexOf(".doc") >= 0) { + result = "application/msword"; + } else if (fileType.indexOf(".xls") >= 0) { + result = "application/x-excel"; + } else if (fileType.indexOf(".zip") >= 0) { + result = "application/zip"; + } else if (fileType.indexOf(".pdf") >= 0) { + result = "application/pdf"; + } else if (fileType.indexOf(".mpeg") >= 0) { //MP3 + result = "audio/mpeg"; + } else if (fileType.indexOf(".mp4") >= 0) { + result = "video/mp4"; + } else if (fileType.indexOf(".plain") >= 0) { + result = "text/plain"; + } else if (fileType.indexOf(".html") >= 0) { + result = "text/html"; + } else if (fileType.indexOf(".json") >= 0) { + result = "application/json"; + } else { + result = "application/octet-stream"; + } + return result; + } + + public static String getPureUrl(String url) { + String result = removeUrlParam(url); + try { + result = URLDecoder.decode(result, "utf-8"); + int index = result.lastIndexOf("http"); + if (index > 0) { + result = result.substring(index); + } + } catch (UnsupportedEncodingException e) { + log.error("解码url失败"); + } + return result; + } + + public static String getOriginalFilename(String path) { + String result = path; + int index = path.lastIndexOf("/"); + if (index > 0) { + result = path.substring(index + 1); + } + return result; + } + + public static String removeUrlParam(String url) { + int index = url.indexOf("&"); + if (index > 0) { + return url.substring(0, index); + } + return url; + } + + public static MultipartFile getMultipartFileFromUrl(String urlStr) { + String pureUrl = getPureUrl(urlStr); + return getMultipartFileFromPureUrl(pureUrl); + } + + public static MultipartFile getMultipartFileFromPureUrl(String pureUrlStr) { + MultipartFile result = null; + try { + URL url = new URL(pureUrlStr); + byte[] bytes = getUrlByte(url); + String name = url.getPath(); + String originalName = getOriginalFilename(name); + String contentType = getContentTypeFromUrl(originalName); + result = new ByteArrayMultipartFile(name, originalName, contentType, bytes); + } catch (Exception e) { + log.error("获取url文件失败", e); + } + return result; + } + public static String getBase64(byte[] bytes) { return Base64.getEncoder().encodeToString(bytes); } @@ -42,4 +171,44 @@ public class FileUtil { public static String getBase64(String filePath) { return getBase64(getFileBytes(filePath)); } + + @Value + public static class ByteArrayMultipartFile implements MultipartFile { + String name; + + String originalFilename; + + String contentType; + + @NonNull + byte[] bytes; + + @Override + public boolean isEmpty() { + return bytes.length == 0; + } + + @Override + public long getSize() { + return bytes.length; + } + + @Override + public InputStream getInputStream() { + return new ByteArrayInputStream(bytes); + } + + @Override + public void transferTo(File destination) throws IOException { + OutputStream outputStream = null; + try { + outputStream = new FileOutputStream(destination); + outputStream.write(bytes); + } finally { + if (outputStream != null) { + outputStream.close(); + } + } + } + } } diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java index 9869fe1..af4a12f 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java @@ -51,6 +51,6 @@ public class BigModelAnalysisResponseDTO implements Serializable { } public Boolean getSuccess() { - return Optional.ofNullable(success).orElse(Boolean.FALSE); + return Optional.ofNullable(success).orElse(data != null); } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index 4eb7c5b..f3ce2b7 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.hydroelectric.vo; +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -19,7 +19,7 @@ public class HydroelectricDeviceVo { @ApiModelProperty(value = "设备名称") private String deivceName; - @ApiModelProperty(value = "开关机状态 : 0 - 关机 1 - 开机") + @ApiModelProperty(value = "开关机状态: 0 - 关机 1 - 开机") private Boolean state; @ApiModelProperty(value = "总装机容量") diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index 22df4ec..a2aae0e 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.hydroelectric.vo; +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -8,7 +8,7 @@ import lombok.Data; * @author ysj */ @Data -@ApiModel(value = "站点首页 - 最近30日发电量/降雨量") +@ApiModel(value = "站点首页-最近30日发电量/降雨量") public class HydroelectricPowerRainVo { @ApiModelProperty(value = "日期") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java index e56b0f3..7dae059 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java @@ -1,6 +1,6 @@ package com.hnac.hzims.bigmodel.zhipuai.handler; -import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; +import com.hnac.hzinfo.exception.HzServiceException; import com.zhipu.oapi.Constants; import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; import com.zhipu.oapi.service.v4.model.ChatMessage; @@ -79,6 +79,8 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { } catch (Exception e) { log.info("get data from response error", e); } + } else { + throw new HzServiceException(response.getMsg()); } return null; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index 1519e95..0de579a 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -5,7 +5,10 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; import com.hnac.hzims.bigmodel.api.feign.IBigModelAnalysisClient; +import com.hnac.hzims.common.utils.FileUtil; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; @@ -33,6 +36,8 @@ import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; @@ -42,10 +47,12 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Component; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import static com.hnac.hzinfo.inspect.task.schedule.XxlJobConstants.EXECUTE_VIDEO_TASK; @@ -173,6 +180,7 @@ public class VideoTaskSchedule { String picUrl = hikApiService.manualCapture(camera.getPointCode()); record.setFileUrl(picUrl); record.setCurrentValue(picUrl); + pictureHandle(picUrl, content.getContentId(), record); } } return record; @@ -225,15 +233,35 @@ public class VideoTaskSchedule { return null; } - private void pictureHandle(String url, Long contentId) { + private void pictureHandle(String url, Long contentId, EventRecordEntity record) { + MultipartFile multipartFile = FileUtil.getMultipartFileFromUrl(url); + R fileResponse = ossClient.putFile(multipartFile); + if (fileResponse.isSuccess()) { + record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl())); + } ContentEntity content = contentService.getById(contentId); if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { return; } - String[] typeArray = content.getMultiCheckTypeSon().split(","); - List checkTypeSonList = Arrays.asList(typeArray); + + try { + String[] typeArray = content.getMultiCheckTypeSon().split(","); + List checkTypeSonList = Arrays.asList(typeArray); + String text = FileUtil.getBase64(multipartFile.getBytes()); + BigModelAnalysisRequestDTO analysisRequest = new BigModelAnalysisRequestDTO(); + analysisRequest.setCheckTypeSonList(checkTypeSonList); + analysisRequest.setUrl(text); + BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); + if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { + return; + } + + } catch (Exception e) { + log.error("video task get big model analysis result fail", e); + } } + } From d7dfb9d957a6749b982c8bd00f9a1571953fde57 Mon Sep 17 00:00:00 2001 From: luyie Date: Tue, 20 Aug 2024 14:52:21 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix:=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index f3ce2b7..ec21858 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index a2aae0e..2fcb5e3 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; From 7292d8a4decb6bdc1a0ba916637f372d97fc9211 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 20 Aug 2024 14:55:55 +0800 Subject: [PATCH 3/8] =?UTF-8?q?add:=20=E5=8D=AB=E7=94=9F=E8=80=83=E6=A0=B8?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/vo/HygieneEvaluationPageVO.java | 28 ++++++ .../safeproduct/vo/HygieneEvaluationPeopleVO.java | 28 ++++++ .../safeproduct/vo/HygieneEvaluationScoreVO.java | 20 ++++ .../hnac/hzims/safeproduct/vo/HygieneWeekVO.java | 25 +++++ .../safeproduct/controller/HygieneController.java | 9 ++ .../safeproduct/mapper/HygieneRecordMapper.java | 8 ++ .../safeproduct/mapper/HygieneRecordMapper.xml | 13 +++ .../safeproduct/service/IHygieneRecordService.java | 8 ++ .../service/impl/HygieneRecordServiceImpl.java | 108 ++++++++++++++++++++- 9 files changed, 244 insertions(+), 3 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java new file mode 100644 index 0000000..6138a0f --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生考核表VO类") +public class HygieneEvaluationPageVO { + + @ApiModelProperty(value = "总分") + private Long totalScore; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "周数据列表") + private List weekList; + + @ApiModelProperty(value = "考核人员列表") + private List evaluationList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java new file mode 100644 index 0000000..def489e --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生考核分数VO类") +public class HygieneEvaluationPeopleVO { + + @ApiModelProperty(value = "单位") + private String unit; + + @ApiModelProperty(value = "负责人") + private String principal; + + @ApiModelProperty(value = "合计分") + private Long sumScore; + + @ApiModelProperty(value = "考核分列表") + private List scoreList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java new file mode 100644 index 0000000..f7729dc --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生考核分VO类") +public class HygieneEvaluationScoreVO { + + @ApiModelProperty(value = "周数") + private Integer weekNum; + + @ApiModelProperty(value = "考核分") + private Long score; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java new file mode 100644 index 0000000..49a56f3 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生周数据VO类") +public class HygieneWeekVO { + + @ApiModelProperty(value = "周数") + private Integer weekNum; + + @ApiModelProperty(value = "周开始日") + private Date startDate; + + @ApiModelProperty(value = "周结束日") + private Date endDate; +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index 1c4de51..1119951 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -245,4 +245,13 @@ public class HygieneController extends BladeController { IPage page = hygienePlanService.getDetailListByMonth(param, query); return R.data(page); } + + @GetMapping("/evaluationPage") + @ApiOperation(value = "卫生考核表") + @ApiOperationSupport(order = 21) + @Operate(label = "卫生考核表", type = BusinessType.QUERY) + public R evaluationPage(@RequestParam String month) { + HygieneEvaluationPageVO page = hygieneRecordService.getEvaluationPage(month); + return R.data(page); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java index b364016..34e0c05 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java @@ -2,6 +2,7 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import org.apache.ibatis.annotations.Mapper; @@ -43,4 +44,11 @@ public interface HygieneRecordMapper extends UserDataScopeBaseMapper selectHygieneByMonth(@Param("month") String month); + + /** + * 根据id列表查询责任区对应负责人数据 + * @param idList id列表 + * @return 负责人名称列表 + */ + List selectHygieneZoneByIds(@Param("idList") List idList); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml index d012ec4..6543db5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml @@ -46,4 +46,17 @@ ORDER BY code DESC + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java index 7d050d0..59152e5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; +import com.hnac.hzims.safeproduct.vo.HygieneEvaluationPageVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import org.springblade.core.mp.support.Query; @@ -70,4 +71,11 @@ public interface IHygieneRecordService extends IService { * @return 记录列表 */ List getReferenceRecord(Long planId); + + /** + * 查询卫生考核表 + * @param month 当前月份 + * @return 考核记录表VO类 + */ + HygieneEvaluationPageVO getEvaluationPage(String month); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 61b6449..755daf7 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; @@ -16,12 +17,13 @@ import com.hnac.hzims.safeproduct.mapper.HygieneRecordMapper; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; import com.hnac.hzims.safeproduct.service.IHygieneZoneService; import com.hnac.hzims.safeproduct.utils.BaseUtil; -import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; -import com.hnac.hzims.safeproduct.vo.HygieneZoneDetailVO; -import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import com.hnac.hzims.safeproduct.vo.*; +import com.hnac.hzinfo.exception.HzServiceException; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -31,8 +33,10 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.time.DayOfWeek; import java.time.LocalDate; import java.time.ZoneId; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.WeekFields; import java.util.*; import java.util.stream.Collectors; @@ -210,6 +214,104 @@ public class HygieneRecordServiceImpl extends ServiceImpl weekList = new ArrayList<>(); + // 获取周开始日 + LocalDate firstWeekDay = DateUtil.getFirstDayByYearMonth(month); + Date weekStart = DateUtil.toDate(firstWeekDay); + // 获取当月最后一天 + LocalDate lastDay = DateUtil.getLastDayByYearMonth(month); + Date lastDate = DateUtil.toDate(lastDay); + // 循环更新周数、周开始日、周结束日 + int weekNum = 1; + while (weekStart.before(lastDate)) { + // 周结束日 + LocalDate lastWeekDay = firstWeekDay.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)); + Date weekEnd = DateUtil.toDate(lastWeekDay); + // 存储周数据 + HygieneWeekVO weekVO = new HygieneWeekVO(); + weekVO.setWeekNum(weekNum++); + weekVO.setStartDate(weekStart); + weekVO.setEndDate(weekEnd); + weekList.add(weekVO); + // 更新周开始日 + firstWeekDay = firstWeekDay.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)); + weekStart = DateUtil.toDate(firstWeekDay); + } + pageVO.setWeekList(weekList); + + // 计算总分(总分 = 周数 * 100) + long totalScore = weekList.size() * 100L; + pageVO.setTotalScore(totalScore); + // 备注 + pageVO.setRemark("已按标准执行,本月总分" + totalScore + "分(每周100分)"); + + // 查询月度卫生自查数据 + List recordList = baseMapper.selectHygieneByMonth(month); + if (CollectionUtil.isEmpty(recordList)) { + throw new HzServiceException(ResultCode.FAILURE, "本月度无卫生自查数据"); + } + // 整理月度考核人员数据 + // 查询所有责任区id和对应综合评分 + List zoneIdList = recordList.stream().map(HygieneRecordEntity::getHygieneZoneIds).collect(Collectors.toList()); + List comprehensiveScoreList = recordList.stream().map(HygieneRecordEntity::getComprehensiveScore).collect(Collectors.toList()); + // 考核表数据 + List evaluationList = new ArrayList<>(); + for (int i = 0; i < recordList.size(); i++) { + HygieneRecordEntity hygieneRecordEntity = recordList.get(i); + String[] zoneIds = zoneIdList.get(i).split(","); + String[] scores = comprehensiveScoreList.get(i).split(","); + // 查询责任区对应的负责人名称 + List peopleNameList = baseMapper.selectHygieneZoneByIds(Arrays.asList(zoneIds)); + + // 遍历责任区数据 + for (int j = 0; j < zoneIds.length; j++) { + List scoreList = new ArrayList<>(); + HygieneEvaluationPeopleVO peopleVO = new HygieneEvaluationPeopleVO(); + String zoneId = zoneIds[j]; + Optional zoneOptional = peopleNameList.stream().filter(x -> x.getId().equals(Long.valueOf(zoneId))).findFirst(); + if (zoneOptional.isPresent()) { + Integer weekNo = hygieneRecordEntity.getWeekNum(); + // 考核人名称 + String principal = zoneOptional.get().getPrincipal(); + // 判断单位内该名称是否已存在 + Optional checkPeople = evaluationList.stream().filter(x -> x.getPrincipal().equals(principal) && + x.getUnit().equals(hygieneRecordEntity.getUnit())).findFirst(); + + if (checkPeople.isPresent()) { + peopleVO = checkPeople.get(); + scoreList = peopleVO.getScoreList(); + HygieneEvaluationScoreVO scoreVO = new HygieneEvaluationScoreVO(); + scoreVO.setWeekNum(weekNo); + scoreVO.setScore(Long.valueOf(scores[j])); + scoreList.add(scoreVO); + } else { + peopleVO.setUnit(hygieneRecordEntity.getUnit()); + peopleVO.setPrincipal(principal); + HygieneEvaluationScoreVO scoreVO = new HygieneEvaluationScoreVO(); + scoreVO.setWeekNum(weekNo); + scoreVO.setScore(Long.valueOf(scores[j])); + scoreList.add(scoreVO); + peopleVO.setScoreList(scoreList); + } + } + // 合计分 + List peopleScoreList = scoreList.stream().map(HygieneEvaluationScoreVO::getScore).collect(Collectors.toList()); + long sum = peopleScoreList.stream().mapToLong(Long::longValue).sum(); + peopleVO.setSumScore(sum); + evaluationList.add(peopleVO); + } + } + pageVO.setEvaluationList(evaluationList); + return pageVO; + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null From a5fa8b3b273c810dbf1a952fc4453dd55f42611b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 15:38:13 +0800 Subject: [PATCH 4/8] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- .../homePage/service/impl/HydroelectricServiceImpl.java | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index f3ce2b7..ec21858 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index a2aae0e..2fcb5e3 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index cbec557..b0a24f1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -721,7 +721,9 @@ public class HydroelectricServiceImpl implements HydroelectricService { private List stationPowerRains(List devices, List> rains) { List generates = new ArrayList<>(); devices.forEach(device->{ - generates.addAll(device.getGenerates()); + if(CollectionUtil.isNotEmpty(device.getGenerates())){ + generates.addAll(device.getGenerates()); + } }); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH,-1); @@ -737,7 +739,12 @@ public class HydroelectricServiceImpl implements HydroelectricService { // 日期 powerRain.setDate(DateUtil.format(calendar.getTime(),"yyyy-MM-dd")); // 发电量 - powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum()); + if(CollectionUtil.isEmpty(generates)){ + powerRain.setGenerate(0.0); + }else{ + powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum()); + + } // 降雨量 if(CollectionUtil.isNotEmpty(rains)){ powerRain.setRain(rains.stream().mapToDouble(map->{ From 7df985c3940f4f640c249e61c4c78dc7c91a3fe4 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 16:34:40 +0800 Subject: [PATCH 5/8] =?UTF-8?q?#=E5=AE=9E=E6=97=B6=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/entity/FrameRecordEntity.java | 31 ++++++++++++++ .../controller/StationFrameRecordController.java | 49 ++++++++++++++++++++++ .../station/mapper/FrameRecordMapper.java | 12 ++++++ .../station/mapper/FrameRecordMapper.xml | 6 +++ .../station/service/FrameRecordService.java | 10 +++++ .../service/impl/FrameRecordServiceImpl.java | 22 ++++++++++ 6 files changed, 130 insertions(+) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationFrameRecordController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/FrameRecordService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/FrameRecordServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java new file mode 100644 index 0000000..90dead1 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.station.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.springblade.core.tenant.mp.TenantEntity; + + +/** + * @author ysj + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("hzims_station_frame_record") +public class FrameRecordEntity extends TenantEntity { + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("实时画面保存配置ID,用逗号分割") + private String frameids; + + @ApiModelProperty("实时画面保存名称,用逗号分割") + private String frameNames; +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationFrameRecordController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationFrameRecordController.java new file mode 100644 index 0000000..91e8902 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationFrameRecordController.java @@ -0,0 +1,49 @@ +package com.hnac.hzims.operational.station.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.station.entity.FrameRecordEntity; +import com.hnac.hzims.operational.station.entity.VideoRecordEntity; +import com.hnac.hzims.operational.station.service.FrameRecordService; +import com.hnac.hzims.operational.station.service.VideoRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + + +/** + * @author ysj + */ +@RestController +@RequestMapping("/station/frameRecord") +@RequiredArgsConstructor +@Api(value = "站点实时画面保存记录", tags = "实时画面保存记录") +public class StationFrameRecordController extends BladeController { + + private final FrameRecordService frameRecordService; + + @PostMapping("/submit") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "新增或修改站点视频播放保存记录", notes = "传入VideoRecordEntity") + public R submit(@Valid @RequestBody FrameRecordEntity entity) { + return R.status(frameRecordService.saveOrUpdate(entity)); + } + + @GetMapping("/query") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "查询站点视频播放保存记录", notes = "传入VideoRecordEntity") + public R query(@RequestParam("stationId") String stationId, + @RequestParam("userId") String userId) { + return R.data(frameRecordService.getOne(Wrappers.lambdaQuery() + .eq(FrameRecordEntity::getStationId,stationId) + .eq(FrameRecordEntity::getCreateUser,userId) + )); + } + + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.java new file mode 100644 index 0000000..493ada6 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.operational.station.mapper; + +import com.hnac.hzims.operational.station.entity.FrameRecordEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + + +/** + * @author ysj + */ +public interface FrameRecordMapper extends UserDataScopeBaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.xml new file mode 100644 index 0000000..df7fae3 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/FrameRecordService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/FrameRecordService.java new file mode 100644 index 0000000..f22ba35 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/FrameRecordService.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.operational.station.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.operational.station.entity.FrameRecordEntity; + +/** + * @author ysj + */ +public interface FrameRecordService extends IService { +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/FrameRecordServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/FrameRecordServiceImpl.java new file mode 100644 index 0000000..99408ed --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/FrameRecordServiceImpl.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.station.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.operational.station.entity.FrameRecordEntity; +import com.hnac.hzims.operational.station.entity.VideoRecordEntity; +import com.hnac.hzims.operational.station.mapper.FrameRecordMapper; +import com.hnac.hzims.operational.station.mapper.VideoRecordMapper; +import com.hnac.hzims.operational.station.service.FrameRecordService; +import com.hnac.hzims.operational.station.service.VideoRecordService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author 86187 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class FrameRecordServiceImpl extends ServiceImpl implements FrameRecordService { + +} \ No newline at end of file From 5203b73053f7c3968f1a130ec55aec96c9bf7636 Mon Sep 17 00:00:00 2001 From: luyie Date: Tue, 20 Aug 2024 20:22:04 +0800 Subject: [PATCH 6/8] =?UTF-8?q?add:=E8=A7=86=E9=A2=91=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=EF=BC=8C=E5=A4=A7=E6=A8=A1=E5=9E=8B=E8=AF=86=E5=88=AB=EF=BC=8C?= =?UTF-8?q?=E5=AD=98=E8=AE=B0=E5=BD=95=EF=BC=8C=E6=8E=A8=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/BigModelAnalysisResponseDTO.java | 5 +- .../zhipuai/entity/ZhipuAnalysisInfoEntity.java | 3 ++ .../service/impl/ZhipuAnalysisServiceImpl.java | 8 +++- .../inspect/task/schedule/VideoTaskSchedule.java | 56 ++++++++++++++++++++-- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java index af4a12f..5c9cb9c 100644 --- a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java @@ -46,8 +46,11 @@ public class BigModelAnalysisResponseDTO implements Serializable { @ApiModelProperty(value = "结果描述") private String description; - @ApiModelProperty(value = "结果描述") + @ApiModelProperty(value = "巡检识别子类型") private String checkTypeSon; + + @ApiModelProperty(value = "消息") + private String message; } public Boolean getSuccess() { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java index ff583d4..40c420b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java @@ -69,4 +69,7 @@ public class ZhipuAnalysisInfoEntity extends TenantEntity { @TableField("RESULT_JUDGE_MODEL") private String resultJudgeModel; + @ApiModelProperty(value = "消息") + @TableField("MESSAGE") + private String message; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java index a639efa..f899713 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java @@ -46,7 +46,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; - private final String multiQuestionConstrainsList = "'问题{}'代表第{}个问题,"; + private final String multiQuestionConstrainsList = "'{}'代表第{}个问题,"; @Override public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { @@ -164,7 +164,11 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { if (ObjectUtil.isEmpty(strategyType)) { continue; } - result.setResult(strategyType.getStrategy().getResult(infoEntity, resultObj)); + Object conclusionObj = strategyType.getStrategy().getResult(infoEntity, resultObj); + result.setResult(conclusionObj); + if (conclusionObj instanceof Boolean && !(Boolean) conclusionObj) { + result.setMessage(infoEntity.getMessage()); + } } response.setData(results); response.setCode(ResultCode.SUCCESS.getCode()); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index 0de579a..f81601b 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -36,13 +36,18 @@ import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.oss.model.BladeFile; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.message.MessageConstants; +import org.springblade.message.dto.BusinessMessageDTO; +import org.springblade.message.fegin.IMessageClient; import org.springblade.resource.feign.IOssClient; +import org.springblade.system.feign.ISysClient; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Component; import org.springframework.transaction.TransactionDefinition; @@ -78,6 +83,8 @@ public class VideoTaskSchedule { private final IOssClient ossClient; private final ContentService contentService; private final IBigModelAnalysisClient bigModelClient; + private final IMessageClient messageClient; + private final ISysClient sysClient; /** * 视频巡检任务执行 @@ -180,7 +187,7 @@ public class VideoTaskSchedule { String picUrl = hikApiService.manualCapture(camera.getPointCode()); record.setFileUrl(picUrl); record.setCurrentValue(picUrl); - pictureHandle(picUrl, content.getContentId(), record); + pictureHandle(picUrl, content.getContentId(), record, task); } } return record; @@ -233,7 +240,7 @@ public class VideoTaskSchedule { return null; } - private void pictureHandle(String url, Long contentId, EventRecordEntity record) { + private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) { MultipartFile multipartFile = FileUtil.getMultipartFileFromUrl(url); R fileResponse = ossClient.putFile(multipartFile); if (fileResponse.isSuccess()) { @@ -256,12 +263,51 @@ public class VideoTaskSchedule { if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { return; } - + List results = analysisResponse.getData(); + StringBuilder stringBuilder = new StringBuilder(); + Boolean status = Boolean.TRUE; + for (BigModelAnalysisResponseDTO.BigModelAnalysisResult result : results) { + stringBuilder.append(result.getDescription()).append("\n"); + Boolean isGood = (Boolean) result.getResult(); + status = status && isGood; + if (!isGood) { + sendMessage(result.getMessage(), task, content); + } + } + record.setCurrentStatus(status ? "1" : "0"); + record.setCurrentValue(stringBuilder.toString()); } catch (Exception e) { log.error("video task get big model analysis result fail", e); } - } - + private void sendMessage(String messageText, TaskEntity task, ContentEntity content) { + BusinessMessageDTO messageDTO = new BusinessMessageDTO(); + messageDTO.setBusinessClassify("inspect"); + messageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.INSPECT.getKey()); + messageDTO.setSubject(MessageConstants.BusinessClassifyEnum.INSPECT.getDescription()); + messageDTO.setTaskId(task.getId()); + messageDTO.setTenantId(task.getTenantId()); + messageDTO.setDeptId(task.getCreateDept()); + messageDTO.setUserIds(String.valueOf(task.getUserId())); + messageDTO.setCreateUser(task.getCreateUser()); + StringBuilder textBuilder = new StringBuilder(); + textBuilder.append(task.getPlanName()); + if (StringUtil.isNotBlank(task.getBatchNumber())) { + textBuilder.append(",").append(task.getBatchNumber()); + } + if (StringUtil.isNotBlank(task.getRouteName())) { + textBuilder.append(",").append(task.getRouteName()); + } + if (StringUtil.isNotBlank(content.getName())) { + textBuilder.append(",").append(content.getName()); + } + textBuilder.append(",").append(messageText); + messageDTO.setContent(textBuilder.toString()); + R booleanR = messageClient.sendAppAndWsMsgByUsers(messageDTO); + if (!booleanR.isSuccess()) { + throw new ServiceException("消息推送失败"); + } + log.info("推送成功~"); + } } From 5379eb2945d4fbdeaa176ca87c62e6269d893d6c Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 21 Aug 2024 09:29:02 +0800 Subject: [PATCH 7/8] =?UTF-8?q?add:=E8=A7=86=E9=A2=91=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=EF=BC=8C=E5=A4=A7=E6=A8=A1=E5=9E=8B=E8=AF=86=E5=88=AB=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/common/utils/FileUtil.java | 74 +++++++--------------- .../service/impl/ZhipuAnalysisServiceImpl.java | 7 +- .../inspect/task/schedule/VideoTaskSchedule.java | 61 ++++++++++-------- 3 files changed, 66 insertions(+), 76 deletions(-) diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java index ce65fb3..180eb0e 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java @@ -6,7 +6,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.multipart.MultipartFile; import java.io.*; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLDecoder; import java.util.Base64; @@ -17,7 +16,7 @@ import java.util.Base64; */ @Slf4j public class FileUtil { - public static byte[] getFileBytes(String filePath) { + public static byte[] getFileBytes(String filePath) throws IOException { File file = new File(filePath); FileInputStream fileInputStream = null; byte[] bytes = null; @@ -25,21 +24,15 @@ public class FileUtil { fileInputStream = new FileInputStream(file); bytes = new byte[(int) file.length()]; fileInputStream.read(bytes); - return bytes; - } catch (Exception e) { - log.error("读取文件出错", e); } finally { if (null != fileInputStream) { - try { - fileInputStream.close(); - } catch (IOException ignore) { - } + fileInputStream.close(); } } return bytes; } - public static byte[] getUrlByte(URL url) { + public static byte[] getUrlByte(URL url) throws IOException { InputStream inputStream = null; ByteArrayOutputStream outputStream = null; byte[] fileBytes = null; @@ -52,30 +45,19 @@ public class FileUtil { outputStream.write(buffer, 0, bytesRead); } fileBytes = outputStream.toByteArray(); - } catch (Exception e) { - log.error("获取url文件失败", e); } finally { - try { - if (null != inputStream) { - inputStream.close(); - } - if (null != outputStream) { - outputStream.close(); - } - } catch (Exception ignore) { - + if (null != inputStream) { + inputStream.close(); + } + if (null != outputStream) { + outputStream.close(); } } return fileBytes; } - public static byte[] getUrlByte(String urlString) { - try { - return getUrlByte(new URL(urlString)); - } catch (MalformedURLException e) { - log.error("获取url文件失败", e); - } - return null; + public static byte[] getUrlByte(String urlString) throws IOException { + return getUrlByte(new URL(urlString)); } public static String getContentTypeFromUrl(String url) { @@ -113,16 +95,12 @@ public class FileUtil { return result; } - public static String getPureUrl(String url) { + public static String getPureUrl(String url) throws UnsupportedEncodingException { String result = removeUrlParam(url); - try { - result = URLDecoder.decode(result, "utf-8"); - int index = result.lastIndexOf("http"); - if (index > 0) { - result = result.substring(index); - } - } catch (UnsupportedEncodingException e) { - log.error("解码url失败"); + result = URLDecoder.decode(result, "utf-8"); + int index = result.lastIndexOf("http"); + if (index > 0) { + result = result.substring(index); } return result; } @@ -144,23 +122,19 @@ public class FileUtil { return url; } - public static MultipartFile getMultipartFileFromUrl(String urlStr) { + public static MultipartFile getMultipartFileFromUrl(String urlStr) throws IOException { String pureUrl = getPureUrl(urlStr); return getMultipartFileFromPureUrl(pureUrl); } - public static MultipartFile getMultipartFileFromPureUrl(String pureUrlStr) { + public static MultipartFile getMultipartFileFromPureUrl(String pureUrlStr) throws IOException { MultipartFile result = null; - try { - URL url = new URL(pureUrlStr); - byte[] bytes = getUrlByte(url); - String name = url.getPath(); - String originalName = getOriginalFilename(name); - String contentType = getContentTypeFromUrl(originalName); - result = new ByteArrayMultipartFile(name, originalName, contentType, bytes); - } catch (Exception e) { - log.error("获取url文件失败", e); - } + URL url = new URL(pureUrlStr); + byte[] bytes = getUrlByte(url); + String name = url.getPath(); + String originalName = getOriginalFilename(name); + String contentType = getContentTypeFromUrl(originalName); + result = new ByteArrayMultipartFile(name, originalName, contentType, bytes); return result; } @@ -168,7 +142,7 @@ public class FileUtil { return Base64.getEncoder().encodeToString(bytes); } - public static String getBase64(String filePath) { + public static String getBase64(String filePath) throws IOException { return getBase64(getFileBytes(filePath)); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java index f899713..d3b9a78 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java @@ -25,6 +25,7 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.io.IOException; import java.util.*; /** @@ -100,7 +101,11 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { return request.getUrl(); } if (StringUtil.isNotBlank(request.getFilePath())) { - return FileUtil.getBase64(request.getFilePath()); + try { + return FileUtil.getBase64(request.getFilePath()); + } catch (IOException e) { + throw new HzServiceException("获取文件内容失败"); + } } return null; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index f81601b..ddf145e 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -11,6 +11,7 @@ import com.hnac.hzims.bigmodel.api.feign.IBigModelAnalysisClient; import com.hnac.hzims.common.utils.FileUtil; import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; +import com.hnac.hzinfo.exception.HzServiceException; import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity; import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; @@ -54,6 +55,7 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; @@ -241,7 +243,14 @@ public class VideoTaskSchedule { } private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) { - MultipartFile multipartFile = FileUtil.getMultipartFileFromUrl(url); + + MultipartFile multipartFile = null; + try { + multipartFile = FileUtil.getMultipartFileFromUrl(url); + } catch (IOException e) { + log.error("获取截图文件失败", e); + throw new HzServiceException("获取截图文件失败"); + } R fileResponse = ossClient.putFile(multipartFile); if (fileResponse.isSuccess()) { record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl())); @@ -252,33 +261,35 @@ public class VideoTaskSchedule { return; } + String[] typeArray = content.getMultiCheckTypeSon().split(","); + List checkTypeSonList = Arrays.asList(typeArray); + String text = null; try { - String[] typeArray = content.getMultiCheckTypeSon().split(","); - List checkTypeSonList = Arrays.asList(typeArray); - String text = FileUtil.getBase64(multipartFile.getBytes()); - BigModelAnalysisRequestDTO analysisRequest = new BigModelAnalysisRequestDTO(); - analysisRequest.setCheckTypeSonList(checkTypeSonList); - analysisRequest.setUrl(text); - BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); - if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { - return; - } - List results = analysisResponse.getData(); - StringBuilder stringBuilder = new StringBuilder(); - Boolean status = Boolean.TRUE; - for (BigModelAnalysisResponseDTO.BigModelAnalysisResult result : results) { - stringBuilder.append(result.getDescription()).append("\n"); - Boolean isGood = (Boolean) result.getResult(); - status = status && isGood; - if (!isGood) { - sendMessage(result.getMessage(), task, content); - } + text = FileUtil.getBase64(multipartFile.getBytes()); + } catch (IOException e) { + log.error("转换截图文件内容失败", e); + throw new HzServiceException("转换截图文件内容失败"); + } + BigModelAnalysisRequestDTO analysisRequest = new BigModelAnalysisRequestDTO(); + analysisRequest.setCheckTypeSonList(checkTypeSonList); + analysisRequest.setUrl(text); + BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); + if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { + throw new HzServiceException("大模型识别失败"); + } + List results = analysisResponse.getData(); + StringBuilder stringBuilder = new StringBuilder(); + Boolean status = Boolean.TRUE; + for (BigModelAnalysisResponseDTO.BigModelAnalysisResult result : results) { + stringBuilder.append(result.getDescription()).append("\n"); + Boolean isGood = (Boolean) result.getResult(); + status = status && isGood; + if (!isGood) { + sendMessage(result.getMessage(), task, content); } - record.setCurrentStatus(status ? "1" : "0"); - record.setCurrentValue(stringBuilder.toString()); - } catch (Exception e) { - log.error("video task get big model analysis result fail", e); } + record.setCurrentStatus(status ? "1" : "0"); + record.setCurrentValue(stringBuilder.toString()); } private void sendMessage(String messageText, TaskEntity task, ContentEntity content) { From 47cdd07123bc445f520757e60ef751f1bb38b4ad Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 21 Aug 2024 11:36:04 +0800 Subject: [PATCH 8/8] # --- .../station/entity/FrameRecordEntity.java | 11 ++-- .../station/entity/UserDeptConfigEntity.java | 34 ++++++++++++ .../controller/UserDeptConfigController.java | 47 ++++++++++++++++ .../station/mapper/UserDeptConfigConfigMapper.xml | 4 ++ .../station/mapper/UserDeptConfigMapper.java | 12 ++++ .../station/service/UserDeptConfigService.java | 11 ++++ .../service/impl/UserDeptConfigServiceImpl.java | 64 ++++++++++++++++++++++ 7 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/UserDeptConfigEntity.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/UserDeptConfigController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigConfigMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigMapper.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/UserDeptConfigService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/UserDeptConfigServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java index 90dead1..14445e5 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java @@ -23,9 +23,12 @@ public class FrameRecordEntity extends TenantEntity { @ApiModelProperty("站点名称") private String stationName; - @ApiModelProperty("实时画面保存配置ID,用逗号分割") - private String frameids; + @ApiModelProperty("实时画面ID") + private String frameId; - @ApiModelProperty("实时画面保存名称,用逗号分割") - private String frameNames; + @ApiModelProperty("实时画面名称") + private String frameName; + + @ApiModelProperty("实时画面地址") + private String frameAddress; } \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/UserDeptConfigEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/UserDeptConfigEntity.java new file mode 100644 index 0000000..bc1b7fc --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/UserDeptConfigEntity.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.station.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.springblade.core.tenant.mp.TenantEntity; + + +/** + * @author ysj + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("hzims_user_dept_config") +public class UserDeptConfigEntity extends TenantEntity { + + @ApiModelProperty("机构Id") + private Long deptId; + + @ApiModelProperty("机构名称") + private String deptName; + + @ApiModelProperty("机构类别: 4-站点 3-区域 2,1-集团") + private Integer deptCategory; + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("站点名称") + private String stationName; +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/UserDeptConfigController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/UserDeptConfigController.java new file mode 100644 index 0000000..b4baff8 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/UserDeptConfigController.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.operational.station.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; +import com.hnac.hzims.operational.station.entity.VideoRecordEntity; +import com.hnac.hzims.operational.station.service.UserDeptConfigService; +import com.hnac.hzims.operational.station.service.VideoRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + + +/** + * @author ysj + */ +@RestController +@RequestMapping("/userDept/config") +@RequiredArgsConstructor +@Api(value = "用户机构配置保存记录", tags = "用户机构配置保存记录") +public class UserDeptConfigController extends BladeController { + + private final UserDeptConfigService userDeptConfigService; + + @PostMapping("/submit") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "新增或修改用户机构配置记录", notes = "传入UserDeptConfigEntity") + public R submit(@Valid @RequestBody UserDeptConfigEntity entity) { + return R.status(userDeptConfigService.submit(entity)); + } + + @GetMapping("/query") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "查询站点用户机构配置保存记录", notes = "传入userId") + public R query(@RequestParam("userId") String userId) { + return R.data(userDeptConfigService.getOne(Wrappers.lambdaQuery() + .eq(UserDeptConfigEntity::getCreateUser,userId) + )); + } + + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigConfigMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigConfigMapper.xml new file mode 100644 index 0000000..9c0737f --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigConfigMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigMapper.java new file mode 100644 index 0000000..a3774ab --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.operational.station.mapper; + +import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + + +/** + * @author ysj + */ +public interface UserDeptConfigMapper extends UserDataScopeBaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/UserDeptConfigService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/UserDeptConfigService.java new file mode 100644 index 0000000..7da046f --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/UserDeptConfigService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.operational.station.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; + +/** + * @author ysj + */ +public interface UserDeptConfigService extends IService { + boolean submit(UserDeptConfigEntity entity); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/UserDeptConfigServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/UserDeptConfigServiceImpl.java new file mode 100644 index 0000000..75849f0 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/UserDeptConfigServiceImpl.java @@ -0,0 +1,64 @@ +package com.hnac.hzims.operational.station.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; +import com.hnac.hzims.operational.station.mapper.UserDeptConfigMapper; +import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.operational.station.service.UserDeptConfigService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; +import org.springframework.stereotype.Service; + +/** + * @author 86187 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class UserDeptConfigServiceImpl extends ServiceImpl implements UserDeptConfigService { + + private final ISysClient sysClient; + + private final IStationService stationService; + + /** + * 保存用户机构配置 + * @param entity + * @return + */ + @Override + public boolean submit(UserDeptConfigEntity entity) { + if(ObjectUtil.isEmpty(entity.getDeptId())){ + return false; + } + R dept = sysClient.getDept(entity.getDeptId()); + if(!dept.isSuccess() || ObjectUtil.isEmpty(dept.getData())){ + return false; + } + entity.setDeptName(dept.getData().getDeptName()); + entity.setDeptCategory(dept.getData().getDeptCategory()); + if(dept.getData().getDeptCategory() == 4){ + StationEntity station = stationService.getOne(Wrappers.lambdaQuery() + .eq(StationEntity::getRefDept,dept.getData().getId()) + ); + if(ObjectUtil.isNotEmpty(station)){ + entity.setStationId(station.getCode()); + entity.setStationName(station.getName()); + }else{ + entity.setStationId(null); + entity.setStationName(null); + } + }else{ + entity.setStationId(null); + entity.setStationName(null); + } + + return super.saveOrUpdate(entity); + } +} \ No newline at end of file