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..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 @@ -1,10 +1,13 @@ 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.URL; +import java.net.URLDecoder; import java.util.Base64; /** @@ -13,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; @@ -21,25 +24,165 @@ 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) throws IOException { + 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(); + } finally { + if (null != inputStream) { + inputStream.close(); + } + if (null != outputStream) { + outputStream.close(); + } + } + return fileBytes; + } + + public static byte[] getUrlByte(String urlString) throws IOException { + return getUrlByte(new URL(urlString)); + } + + 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) throws UnsupportedEncodingException { + String result = removeUrlParam(url); + result = URLDecoder.decode(result, "utf-8"); + int index = result.lastIndexOf("http"); + if (index > 0) { + result = result.substring(index); + } + 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) throws IOException { + String pureUrl = getPureUrl(urlStr); + return getMultipartFileFromPureUrl(pureUrl); + } + + public static MultipartFile getMultipartFileFromPureUrl(String pureUrlStr) throws IOException { + MultipartFile result = null; + 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; + } + public static String getBase64(byte[] bytes) { return Base64.getEncoder().encodeToString(bytes); } - public static String getBase64(String filePath) { + public static String getBase64(String filePath) throws IOException { 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..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,11 +46,14 @@ 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() { - 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/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..14445e5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.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_station_frame_record") +public class FrameRecordEntity extends TenantEntity { + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("实时画面ID") + private String frameId; + + @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-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/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/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/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..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.*; /** @@ -46,7 +47,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) { @@ -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; } @@ -164,7 +169,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 1519e95..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 @@ -5,9 +5,13 @@ 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.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; @@ -33,19 +37,29 @@ 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; 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; +import java.util.Optional; import java.util.stream.Collectors; import static com.hnac.hzinfo.inspect.task.schedule.XxlJobConstants.EXECUTE_VIDEO_TASK; @@ -71,6 +85,8 @@ public class VideoTaskSchedule { private final IOssClient ossClient; private final ContentService contentService; private final IBigModelAnalysisClient bigModelClient; + private final IMessageClient messageClient; + private final ISysClient sysClient; /** * 视频巡检任务执行 @@ -173,6 +189,7 @@ public class VideoTaskSchedule { String picUrl = hikApiService.manualCapture(camera.getPointCode()); record.setFileUrl(picUrl); record.setCurrentValue(picUrl); + pictureHandle(picUrl, content.getContentId(), record, task); } } return record; @@ -225,15 +242,83 @@ public class VideoTaskSchedule { return null; } - private void pictureHandle(String url, Long contentId) { + private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) { + + 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())); + } ContentEntity content = contentService.getById(contentId); if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { return; } + String[] typeArray = content.getMultiCheckTypeSon().split(","); List checkTypeSonList = Arrays.asList(typeArray); - + String text = null; + try { + 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()); } + 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("推送成功~"); + } } 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->{ 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/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/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/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/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/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/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 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 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