Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
haungxing 3 months ago
parent
commit
284766a6a3
  1. 165
      hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java
  2. 7
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisResponseDTO.java
  3. 34
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/FrameRecordEntity.java
  4. 34
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/UserDeptConfigEntity.java
  5. 28
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java
  6. 28
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java
  7. 20
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java
  8. 25
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java
  9. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java
  10. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java
  11. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java
  12. 89
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java
  13. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java
  14. 49
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationFrameRecordController.java
  15. 47
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/UserDeptConfigController.java
  16. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.java
  17. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.xml
  18. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigConfigMapper.xml
  19. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigMapper.java
  20. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/FrameRecordService.java
  21. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/UserDeptConfigService.java
  22. 22
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/FrameRecordServiceImpl.java
  23. 64
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/UserDeptConfigServiceImpl.java
  24. 9
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  25. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java
  26. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml
  27. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java
  28. 108
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

165
hzims-biz-common/src/main/java/com/hnac/hzims/common/utils/FileUtil.java

@ -1,10 +1,13 @@
package com.hnac.hzims.common.utils; package com.hnac.hzims.common.utils;
import lombok.NonNull;
import lombok.Value;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.*;
import java.io.FileInputStream; import java.net.URL;
import java.io.IOException; import java.net.URLDecoder;
import java.util.Base64; import java.util.Base64;
/** /**
@ -13,7 +16,7 @@ import java.util.Base64;
*/ */
@Slf4j @Slf4j
public class FileUtil { public class FileUtil {
public static byte[] getFileBytes(String filePath) { public static byte[] getFileBytes(String filePath) throws IOException {
File file = new File(filePath); File file = new File(filePath);
FileInputStream fileInputStream = null; FileInputStream fileInputStream = null;
byte[] bytes = null; byte[] bytes = null;
@ -21,25 +24,165 @@ public class FileUtil {
fileInputStream = new FileInputStream(file); fileInputStream = new FileInputStream(file);
bytes = new byte[(int) file.length()]; bytes = new byte[(int) file.length()];
fileInputStream.read(bytes); fileInputStream.read(bytes);
return bytes;
} catch (Exception e) {
log.error("读取文件出错", e);
} finally { } finally {
if (null != fileInputStream) { if (null != fileInputStream) {
try {
fileInputStream.close(); fileInputStream.close();
} catch (IOException ignore) {
}
} }
} }
return bytes; 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) { public static String getBase64(byte[] bytes) {
return Base64.getEncoder().encodeToString(bytes); return Base64.getEncoder().encodeToString(bytes);
} }
public static String getBase64(String filePath) { public static String getBase64(String filePath) throws IOException {
return getBase64(getFileBytes(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();
}
}
}
}
} }

7
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 = "结果描述") @ApiModelProperty(value = "结果描述")
private String description; private String description;
@ApiModelProperty(value = "结果描述") @ApiModelProperty(value = "巡检识别子类型")
private String checkTypeSon; private String checkTypeSon;
@ApiModelProperty(value = "消息")
private String message;
} }
public Boolean getSuccess() { public Boolean getSuccess() {
return Optional.ofNullable(success).orElse(Boolean.FALSE); return Optional.ofNullable(success).orElse(data != null);
} }
} }

34
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;
}

34
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;
}

28
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<HygieneWeekVO> weekList;
@ApiModelProperty(value = "考核人员列表")
private List<HygieneEvaluationPeopleVO> evaluationList;
}

28
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<HygieneEvaluationScoreVO> scoreList;
}

20
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;
}

25
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;
}

3
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") @TableField("RESULT_JUDGE_MODEL")
private String resultJudgeModel; private String resultJudgeModel;
@ApiModelProperty(value = "消息")
@TableField("MESSAGE")
private String message;
} }

4
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; 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.Constants;
import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; import com.zhipu.oapi.service.v4.model.ChatCompletionRequest;
import com.zhipu.oapi.service.v4.model.ChatMessage; import com.zhipu.oapi.service.v4.model.ChatMessage;
@ -79,6 +79,8 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler {
} catch (Exception e) { } catch (Exception e) {
log.info("get data from response error", e); log.info("get data from response error", e);
} }
} else {
throw new HzServiceException(response.getMsg());
} }
return null; return null;
} }

13
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.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.io.IOException;
import java.util.*; import java.util.*;
/** /**
@ -46,7 +47,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n";
private final String multiQuestionConstrainsList = "'问题{}'代表第{}个问题,"; private final String multiQuestionConstrainsList = "'{}'代表第{}个问题,";
@Override @Override
public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) {
@ -100,7 +101,11 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
return request.getUrl(); return request.getUrl();
} }
if (StringUtil.isNotBlank(request.getFilePath())) { if (StringUtil.isNotBlank(request.getFilePath())) {
try {
return FileUtil.getBase64(request.getFilePath()); return FileUtil.getBase64(request.getFilePath());
} catch (IOException e) {
throw new HzServiceException("获取文件内容失败");
}
} }
return null; return null;
} }
@ -164,7 +169,11 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
if (ObjectUtil.isEmpty(strategyType)) { if (ObjectUtil.isEmpty(strategyType)) {
continue; 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.setData(results);
response.setCode(ResultCode.SUCCESS.getCode()); response.setCode(ResultCode.SUCCESS.getCode());

89
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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; 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.bigmodel.api.feign.IBigModelAnalysisClient;
import com.hnac.hzims.common.utils.FileUtil;
import com.hnac.hzinfo.datasearch.soe.ISoeClient; import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; 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.CameraInfoEntity;
import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity; import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity;
import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; 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 com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; 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.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil; 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.resource.feign.IOssClient;
import org.springblade.system.feign.ISysClient;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.hnac.hzinfo.inspect.task.schedule.XxlJobConstants.EXECUTE_VIDEO_TASK; 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 IOssClient ossClient;
private final ContentService contentService; private final ContentService contentService;
private final IBigModelAnalysisClient bigModelClient; 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()); String picUrl = hikApiService.manualCapture(camera.getPointCode());
record.setFileUrl(picUrl); record.setFileUrl(picUrl);
record.setCurrentValue(picUrl); record.setCurrentValue(picUrl);
pictureHandle(picUrl, content.getContentId(), record, task);
} }
} }
return record; return record;
@ -225,15 +242,83 @@ public class VideoTaskSchedule {
return null; 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<BladeFile> fileResponse = ossClient.putFile(multipartFile);
if (fileResponse.isSuccess()) {
record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl()));
}
ContentEntity content = contentService.getById(contentId); ContentEntity content = contentService.getById(contentId);
if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { if (StringUtil.isBlank(content.getMultiCheckTypeSon())) {
return; return;
} }
String[] typeArray = content.getMultiCheckTypeSon().split(","); String[] typeArray = content.getMultiCheckTypeSon().split(",");
List<String> checkTypeSonList = Arrays.asList(typeArray); List<String> 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<BigModelAnalysisResponseDTO.BigModelAnalysisResult> 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("推送成功~");
}
} }

7
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<HydroelectricPowerRainVo> stationPowerRains(List<HydroelectricDeviceVo> devices, List<Map<String, Object>> rains) { private List<HydroelectricPowerRainVo> stationPowerRains(List<HydroelectricDeviceVo> devices, List<Map<String, Object>> rains) {
List<HydroelectricDeviceGenerateVo> generates = new ArrayList<>(); List<HydroelectricDeviceGenerateVo> generates = new ArrayList<>();
devices.forEach(device->{ devices.forEach(device->{
if(CollectionUtil.isNotEmpty(device.getGenerates())){
generates.addAll(device.getGenerates()); generates.addAll(device.getGenerates());
}
}); });
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-1); 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.setDate(DateUtil.format(calendar.getTime(),"yyyy-MM-dd"));
// 发电量 // 发电量
if(CollectionUtil.isEmpty(generates)){
powerRain.setGenerate(0.0);
}else{
powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum()); powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum());
}
// 降雨量 // 降雨量
if(CollectionUtil.isNotEmpty(rains)){ if(CollectionUtil.isNotEmpty(rains)){
powerRain.setRain(rains.stream().mapToDouble(map->{ powerRain.setRain(rains.stream().mapToDouble(map->{

49
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.<FrameRecordEntity>lambdaQuery()
.eq(FrameRecordEntity::getStationId,stationId)
.eq(FrameRecordEntity::getCreateUser,userId)
));
}
}

47
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.<UserDeptConfigEntity>lambdaQuery()
.eq(UserDeptConfigEntity::getCreateUser,userId)
));
}
}

12
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<FrameRecordEntity> {
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/FrameRecordMapper.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.operational.station.mapper.FrameRecordMapper">
</mapper>

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/UserDeptConfigConfigMapper.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.operational.station.mapper.UserDeptConfigMapper">
</mapper>

12
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<UserDeptConfigEntity> {
}

10
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<FrameRecordEntity> {
}

11
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<UserDeptConfigEntity> {
boolean submit(UserDeptConfigEntity entity);
}

22
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<FrameRecordMapper, FrameRecordEntity> implements FrameRecordService {
}

64
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<UserDeptConfigMapper, UserDeptConfigEntity> 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> 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.<StationEntity>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);
}
}

9
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java

@ -245,4 +245,13 @@ public class HygieneController extends BladeController {
IPage<HygienePlanEntity> page = hygienePlanService.getDetailListByMonth(param, query); IPage<HygienePlanEntity> page = hygienePlanService.getDetailListByMonth(param, query);
return R.data(page); return R.data(page);
} }
@GetMapping("/evaluationPage")
@ApiOperation(value = "卫生考核表")
@ApiOperationSupport(order = 21)
@Operate(label = "卫生考核表", type = BusinessType.QUERY)
public R<HygieneEvaluationPageVO> evaluationPage(@RequestParam String month) {
HygieneEvaluationPageVO page = hygieneRecordService.getEvaluationPage(month);
return R.data(page);
}
} }

8
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.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; 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.HygieneRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -43,4 +44,11 @@ public interface HygieneRecordMapper extends UserDataScopeBaseMapper<HygieneReco
* @return 当月卫生自查数据表 * @return 当月卫生自查数据表
*/ */
List<HygieneRecordEntity> selectHygieneByMonth(@Param("month") String month); List<HygieneRecordEntity> selectHygieneByMonth(@Param("month") String month);
/**
* 根据id列表查询责任区对应负责人数据
* @param idList id列表
* @return 负责人名称列表
*/
List<HygieneZoneEntity> selectHygieneZoneByIds(@Param("idList") List<String> idList);
} }

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml

@ -46,4 +46,17 @@
ORDER BY ORDER BY
code DESC code DESC
</select> </select>
<select id="selectHygieneZoneByIds" resultType="com.hnac.hzims.safeproduct.entity.HygieneZoneEntity">
SELECT
id, principal
FROM
hzims_hygiene_zone
WHERE
is_deleted = 0
AND id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper> </mapper>

8
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.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO;
import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; 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.HygieneRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
@ -70,4 +71,11 @@ public interface IHygieneRecordService extends IService<HygieneRecordEntity> {
* @return 记录列表 * @return 记录列表
*/ */
List<HygieneRecordEntity> getReferenceRecord(Long planId); List<HygieneRecordEntity> getReferenceRecord(Long planId);
/**
* 查询卫生考核表
* @param month 当前月份
* @return 考核记录表VO类
*/
HygieneEvaluationPageVO getEvaluationPage(String month);
} }

108
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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.constants.SafeProductConstant;
import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO;
import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; 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.IHygieneRecordService;
import com.hnac.hzims.safeproduct.service.IHygieneZoneService; import com.hnac.hzims.safeproduct.service.IHygieneZoneService;
import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import com.hnac.hzims.safeproduct.vo.*;
import com.hnac.hzims.safeproduct.vo.HygieneZoneDetailVO; import com.hnac.hzinfo.exception.HzServiceException;
import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; 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.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -31,8 +33,10 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.DayOfWeek;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.time.temporal.WeekFields; import java.time.temporal.WeekFields;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -210,6 +214,104 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
} }
/** /**
* 查询卫生考核表
*/
@Override
public HygieneEvaluationPageVO getEvaluationPage(String month) {
HygieneEvaluationPageVO pageVO = new HygieneEvaluationPageVO();
// 获取月度周数据列表
List<HygieneWeekVO> 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<HygieneRecordEntity> recordList = baseMapper.selectHygieneByMonth(month);
if (CollectionUtil.isEmpty(recordList)) {
throw new HzServiceException(ResultCode.FAILURE, "本月度无卫生自查数据");
}
// 整理月度考核人员数据
// 查询所有责任区id和对应综合评分
List<String> zoneIdList = recordList.stream().map(HygieneRecordEntity::getHygieneZoneIds).collect(Collectors.toList());
List<String> comprehensiveScoreList = recordList.stream().map(HygieneRecordEntity::getComprehensiveScore).collect(Collectors.toList());
// 考核表数据
List<HygieneEvaluationPeopleVO> 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<HygieneZoneEntity> peopleNameList = baseMapper.selectHygieneZoneByIds(Arrays.asList(zoneIds));
// 遍历责任区数据
for (int j = 0; j < zoneIds.length; j++) {
List<HygieneEvaluationScoreVO> scoreList = new ArrayList<>();
HygieneEvaluationPeopleVO peopleVO = new HygieneEvaluationPeopleVO();
String zoneId = zoneIds[j];
Optional<HygieneZoneEntity> 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<HygieneEvaluationPeopleVO> 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<Long> 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 当月 * @param currentMonth 当月
* @return 存在则返回上一编号否则返回null * @return 存在则返回上一编号否则返回null

Loading…
Cancel
Save