diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailImgVO.java new file mode 100644 index 0000000..c75df94 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailImgVO.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.safeproduct.vo; + +import cn.afterturn.easypoi.entity.ImageEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "车辆维保记录VO类-图片实体类") +public class CarMaintenanceDetailImgVO extends CarMaintenanceDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailStrVO.java new file mode 100644 index 0000000..c8f8e75 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailStrVO.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "车辆维保记录VO类-图片字符串类") +public class CarMaintenanceDetailStrVO extends CarMaintenanceDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailVO.java index 554bd7b..8d18ae4 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarMaintenanceDetailVO.java @@ -1,12 +1,10 @@ package com.hnac.hzims.safeproduct.vo; -import cn.afterturn.easypoi.entity.ImageEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; -import java.util.List; /** * @author liwen @@ -64,9 +62,6 @@ public class CarMaintenanceDetailVO { @ApiModelProperty("维保类型") private String maintenanceType; - @ApiModelProperty("图片列表") - private List images; - @ApiModelProperty("年份") private String year; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailImgVO.java new file mode 100644 index 0000000..6310c23 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailImgVO.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.safeproduct.vo; + +import cn.afterturn.easypoi.entity.ImageEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "车辆用车记录VO类-图片实体类") +public class CarUsedRecordDetailImgVO extends CarUsedRecordDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailStrVO.java new file mode 100644 index 0000000..2d5f620 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailStrVO.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "车辆用车记录VO类-图片字符串类") +public class CarUsedRecordDetailStrVO extends CarUsedRecordDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailVO.java index 50564f4..5f496bd 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarUsedRecordDetailVO.java @@ -1,13 +1,11 @@ package com.hnac.hzims.safeproduct.vo; -import cn.afterturn.easypoi.entity.ImageEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.Date; -import java.util.List; /** * @author liwen @@ -65,9 +63,6 @@ public class CarUsedRecordDetailVO { @ApiModelProperty("确认时间") private Date confirmationTime; - @ApiModelProperty("图片列表") - private List images; - @ApiModelProperty("年份") private String year; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailImgVO.java new file mode 100644 index 0000000..839ac6a --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailImgVO.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.safeproduct.vo; + +import cn.afterturn.easypoi.entity.ImageEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "会议记录VO类-图片实体类") +public class ConferenceRecordDetailImgVO extends ConferenceRecordDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailStrVO.java new file mode 100644 index 0000000..2650b11 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailStrVO.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "会议记录VO类-图片实体类") +public class ConferenceRecordDetailStrVO extends ConferenceRecordDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailVO.java index 6bfaadb..7abdf86 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/ConferenceRecordDetailVO.java @@ -1,13 +1,9 @@ package com.hnac.hzims.safeproduct.vo; -import cn.afterturn.easypoi.entity.ImageEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.Date; -import java.util.List; - /** * @author liwen * @date 2024-01-15 @@ -55,9 +51,6 @@ public class ConferenceRecordDetailVO { @ApiModelProperty("会议附件") private String filePath; - @ApiModelProperty("图片列表") - private List images; - @ApiModelProperty("年份") private String year; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java index abb312d..bbd34fa 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java @@ -4,12 +4,14 @@ import cn.afterturn.easypoi.entity.ImageEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @Data -@ApiModel(value = "演练记录表VO类") -public class RehearsalRecordDetailImgVO extends RehearsalRecordDetailVO{ +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "演练记录表VO类-图片实体类") +public class RehearsalRecordDetailImgVO extends RehearsalRecordDetailVO { @ApiModelProperty("图片列表") private List images; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java index 2a7c8bf..953a997 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java @@ -3,12 +3,14 @@ package com.hnac.hzims.safeproduct.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @Data -@ApiModel(value = "演练记录表VO类") -public class RehearsalRecordDetailStrVO extends RehearsalRecordDetailVO{ +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "演练记录表VO类-图片字符串类") +public class RehearsalRecordDetailStrVO extends RehearsalRecordDetailVO { @ApiModelProperty("图片列表") private List images; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailImgVO.java new file mode 100644 index 0000000..6d5724a --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailImgVO.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.safeproduct.vo; + +import cn.afterturn.easypoi.entity.ImageEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "培训记录表VO类-图片实体类") +public class TrainRecordDetailImgVO extends TrainRecordDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailStrVO.java new file mode 100644 index 0000000..a5a23f9 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailStrVO.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "培训记录表VO类-图片字符串类") +public class TrainRecordDetailStrVO extends TrainRecordDetailVO { + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailVO.java index e8850de..2eb2148 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainRecordDetailVO.java @@ -1,13 +1,9 @@ package com.hnac.hzims.safeproduct.vo; -import cn.afterturn.easypoi.entity.ImageEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.Date; -import java.util.List; - /** * @author liwen * @date 2024-01-15 @@ -55,9 +51,6 @@ public class TrainRecordDetailVO { @ApiModelProperty("培训附件") private String filePath; - @ApiModelProperty("图片列表") - private List images; - @ApiModelProperty("年份") private String year; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java new file mode 100644 index 0000000..c6f5d74 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ErrorCode.java @@ -0,0 +1,57 @@ +package com.hnac.hzims.bigmodel.zhipuai.constants; + +import com.hnac.hzinfo.exception.HzServiceException; +import lombok.Getter; +import org.springblade.core.tool.api.IResultCode; +import org.springblade.core.tool.api.ResultCode; + +/** + * @Author: ypj + * @Date: 2024/8/22 11:17 + */ +@Getter +public enum ErrorCode implements IResultCode { + + GET_DATA_FAILURE(1888000001, "获取数据失败"), + ANALYSIS_FAILURE(1888000002, "分析失败"), + STRATEGY_NOT_FOUND(1888000003, "策略未找到"), + GET_FILE_CONTENT_FAILURE(1888000004, "获取文件内容失败"), + REQUEST_TEXT_IS_EMPTY(1888000005, "交互文字内容不能为空"), + EMPTY_ANALYSIS_TYPE(1888000006, "识别类型为空"), + UNKNOWN_ANALYSIS_TYPE(1888000007, "未知的识别类型"), + NO_COMPARATOR(1888000008, "未获取到对比对象"), + NO_COMPARISON_TYPE(1888000009, "未获取到对比类型"), + GET_RESULT_FAIL(1888000010, "获取结果失败"),; + + private final int code; + private final String msg; + + ErrorCode(int code, String msg) { + this.code = code; + this.msg = msg; + } + + + @Override + public String getMessage() { + return this.msg; + } + + public HzServiceException throwException() { + return new HzServiceException(this); + } + + public static HzServiceException throwCommonException(String msg) { + return new HzServiceException(new IResultCode() { + @Override + public String getMessage() { + return msg; + } + + @Override + public int getCode() { + return ResultCode.FAILURE.getCode(); + } + }); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java index e2a85bd..477c3a8 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java @@ -2,9 +2,9 @@ package com.hnac.hzims.bigmodel.zhipuai.handler; import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; import com.hnac.hzims.bigmodel.zhipuai.constants.ComparisonType; +import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.hzinfo.exception.HzServiceException; import org.springframework.util.Assert; import java.util.Objects; @@ -23,18 +23,24 @@ public class ResultBooleanStrategy implements ResultStrategy { public Boolean getResult(ZhipuAnalysisInfoEntity info, Object resultData) { Object comparator = convertOriginalData(info.getResultCondition(), info.getResultType()); Assert.isTrue(Objects.nonNull(comparator), () -> { - throw new HzServiceException("没有获取到对比对象"); + throw ErrorCode.NO_COMPARATOR.throwException(); }); ComparisonType comparisonType = BaseEnum.getInstance(info.getResultJudgeModel(), ComparisonType.class); - switch (comparisonType) { + Assert.isTrue(Objects.nonNull(comparisonType), () -> { + throw ErrorCode.NO_COMPARISON_TYPE.throwException(); + }); + switch (Objects.requireNonNull(comparisonType)) { case EQUAL: return comparator.equals(resultData); case GREATER: - return ((Comparable) comparator).compareTo(resultData) < 0; + if (comparator instanceof Comparable && resultData instanceof Comparable) { + return ((Comparable) comparator).compareTo((Comparable)resultData) < 0; + } + break; case LESS: return ((Comparable) comparator).compareTo(resultData) > 0; } - return null; + throw ErrorCode.GET_RESULT_FAIL.throwException(); } } 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 0f0925a..6e98f7b 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,7 @@ package com.hnac.hzims.bigmodel.zhipuai.handler; import cn.hutool.core.lang.Assert; +import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.hzinfo.exception.HzServiceException; import com.zhipu.oapi.Constants; import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; @@ -58,14 +59,13 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { messages.add(chatMessage); String requestId = String.format(requestIdTemplate, System.currentTimeMillis()); - ChatCompletionRequest request = ChatCompletionRequest.builder() + return ChatCompletionRequest.builder() .model(getAnalysisModel()) .stream(Boolean.FALSE) .invokeMethod(Constants.invokeMethod) .messages(messages) .requestId(requestId) .build(); - return request; } @Override @@ -73,7 +73,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { ModelApiResponse response = sendRequest(text, url); log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(JsonUtil::toJson).orElse("null")); Assert.isTrue(Objects.nonNull(response) && response.isSuccess(), () -> { - throw new HzServiceException(response.getMsg()); + throw ErrorCode.throwCommonException(Optional.ofNullable(response).map(ModelApiResponse::getMsg).orElse("没有收到大模型平台响应")); }); try { String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); @@ -81,7 +81,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { return resultJson; } catch (Exception e) { log.info("get data from response error", e); - throw new HzServiceException("获取数据失败"); + throw ErrorCode.GET_DATA_FAILURE.throwException(); } } 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 d3b9a78..0afde6f 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 @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisRequestDTO; import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisResponseDTO; import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum; +import com.hnac.hzims.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.handler.ResultStrategy; @@ -41,29 +42,29 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { private final ZhipuAnalysisInfoService infoService; - private final String multiQuestionBrief = "从给出的图片回答以下{}个问题\n"; + private static final String MULTI_QUESTION_BRIEF = "从给出的图片回答以下{}个问题\n"; - private final String multiQuestionPrefix = "第{}个问题,"; + private static final String MULTI_QUESTION_PREFIX = "第{}个问题,"; - private final String multiQuestionConstrains = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; + private static final String MULTI_QUESTION_CONSTRAINS = "- 不要在输出中添加任何注释和思考过程和其他多余的内容,以JSON格式输出简单结果,{}结果只包含'是'或者'否'\n"; - private final String multiQuestionConstrainsList = "'{}'代表第{}个问题,"; + private static final String MULTI_QUESTION_CONSTRAINS_LIST = "'{}'代表第{}个问题,"; @Override public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) { Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()) || StringUtil.isNotBlank(request.getUrl()), () -> { - throw new HzServiceException("文件为空"); + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); }); ZhipuAnalysisFileResponse response = new ZhipuAnalysisFileResponse(); ZhipuAnalysisInfoEntity info = getAnalysisInfo(request); Assert.isTrue(Objects.nonNull(info), () -> { - throw new HzServiceException("没有找到对应的策略信息"); + throw ErrorCode.STRATEGY_NOT_FOUND.throwException(); }); ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel()); Assert.isTrue(StringUtil.isNotBlank(info.getRequestContent()), () -> { - throw new HzServiceException("智谱平台交互内容为空"); + throw ErrorCode.REQUEST_TEXT_IS_EMPTY.throwException(); }); //拼接文字内容 StringBuilder textBuilder = new StringBuilder(); @@ -78,13 +79,13 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { Object resultObject = analyser.getResultValue(analyser.getText(), info.getResultKey(), getSendUrl(request)); Assert.isTrue(Objects.nonNull(resultObject), () -> { - throw new HzServiceException("智谱平台分析失败"); + throw ErrorCode.ANALYSIS_FAILURE.throwException(); }); String resultStr = resultObject.toString(); ResultStrategyType strategyType = BaseEnum.getInstance(info.getResultStrategy(), ResultStrategyType.class); Assert.isTrue(Objects.nonNull(strategyType), () -> { - throw new HzServiceException("没有找到对应的结果数据解析策略"); + throw ErrorCode.STRATEGY_NOT_FOUND.throwException(); }); ResultStrategy strategy = strategyType.getStrategy(); @@ -100,14 +101,14 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { if (StringUtil.isNotBlank(request.getUrl())) { return request.getUrl(); } - if (StringUtil.isNotBlank(request.getFilePath())) { - try { - return FileUtil.getBase64(request.getFilePath()); - } catch (IOException e) { - throw new HzServiceException("获取文件内容失败"); - } + Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); + }); + try { + return FileUtil.getBase64(request.getFilePath()); + } catch (IOException e) { + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); } - return null; } @Override @@ -121,7 +122,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { .eq(StringUtil.isNotBlank(request.getCheckTypeSon()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSon()) .last("limit 1;")); } - log.info("the analysis information is {}", Optional.ofNullable(result).map(r -> JsonUtil.toJson(r)).orElse("null")); + log.debug("the analysis information is {}", Optional.ofNullable(result).map(r -> JsonUtil.toJson(r)).orElse("null")); return result; } @@ -131,15 +132,15 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { BigModelAnalysisResponseDTO response = new BigModelAnalysisResponseDTO(); try { Assert.isTrue(StringUtil.isNotBlank(request.getUrl()), () -> { - throw new HzServiceException("文件为空"); + throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); }); Assert.isTrue(CollectionUtil.isNotEmpty(request.getCodeList()) || CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), () -> { - throw new HzServiceException("识别类型为空"); + throw ErrorCode.EMPTY_ANALYSIS_TYPE.throwException(); }); List infoList = infoService.list(Wrappers.lambdaQuery().in(CollectionUtil.isNotEmpty(request.getCodeList()), ZhipuAnalysisInfoEntity::getCode, request.getCodeList()) .in(CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSonList())); Assert.isTrue(CollectionUtil.isNotEmpty(infoList), () -> { - throw new HzServiceException("未知的识别类型"); + throw ErrorCode.UNKNOWN_ANALYSIS_TYPE.throwException(); }); ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); @@ -148,7 +149,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { if (null == resultMap) { response.setCode(ResultCode.FAILURE.getCode()); - response.setMsg("智谱大模型分析失败"); + response.setMsg(ErrorCode.ANALYSIS_FAILURE.getMsg()); return response; } @@ -184,9 +185,9 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { response.setMsg(e.getMessage()); } else { response.setCode(ResultCode.FAILURE.getCode()); - response.setMsg("智谱大模型分析失败"); + response.setMsg(ErrorCode.ANALYSIS_FAILURE.getMsg()); } - log.error("智谱大模型分析失败", e); + log.error(ErrorCode.ANALYSIS_FAILURE.getMessage(), e); } return response; } @@ -196,18 +197,18 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { StringBuilder titleBuilder = new StringBuilder(); StringBuilder formatBuilder = new StringBuilder(); stringBuilder.append(ZhipuAnalyser.QUESTION_PROFILE) - .append(StringUtil.format(multiQuestionBrief, infoList.size())); + .append(StringUtil.format(MULTI_QUESTION_BRIEF, infoList.size())); formatBuilder.append("{"); for (int index = 1; index <= infoList.size(); index++) { ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1); - stringBuilder.append(StringUtil.format(multiQuestionPrefix, index)); - titleBuilder.append(StringUtil.format(multiQuestionConstrainsList, infoEntity.getResultKey(), index)); + stringBuilder.append(StringUtil.format(MULTI_QUESTION_PREFIX, index)); + titleBuilder.append(StringUtil.format(MULTI_QUESTION_CONSTRAINS_LIST, infoEntity.getResultKey(), index)); formatBuilder.append(infoEntity.getRequestOutputFormat()).append(","); } formatBuilder.deleteCharAt(formatBuilder.length() - 1); formatBuilder.append("}"); stringBuilder.append(ZhipuAnalyser.QUESTION_CONSTRAINS) - .append(StringUtil.format(multiQuestionConstrains, titleBuilder.toString())) + .append(StringUtil.format(MULTI_QUESTION_CONSTRAINS, titleBuilder.toString())) .append(ZhipuAnalyser.QUESTION_OUTPUT_FORMAT).append(formatBuilder); return stringBuilder.toString(); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java index d88ca90..33d77e2 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java @@ -19,7 +19,6 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; @@ -41,7 +40,7 @@ import java.util.Map; @AllArgsConstructor @Business(module = Constants.APP_NAME, value = "车辆管理", ignore = false) @Api(value = "车辆管理", tags = "车辆管理接口") -public class CarController extends BladeController { +public class CarController { private final ICarService carService; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java index 119188f..fcd7aac 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java @@ -17,7 +17,6 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; @@ -38,7 +37,7 @@ import java.util.Map; @RequestMapping("/conference") @Business(module = Constants.APP_NAME, value = "会议管理", ignore = false) @Api(value = "会议管理", tags = "会议管理接口") -public class ConferenceController extends BladeController { +public class ConferenceController { private final IConferencePlanService conferencePlanService; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java index 08d28ce..af81138 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java @@ -19,7 +19,6 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; @@ -40,7 +39,7 @@ import java.util.Map; @RequestMapping("/rehearsal") @Business(module = Constants.APP_NAME, value = "演练管理", ignore = false) @Api(value = "演练管理", tags = "演练管理接口") -public class RehearsalController extends BladeController { +public class RehearsalController { private final IRehearsalRecordService rehearsalRecordService; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java index ef252f9..3c39c65 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -23,7 +23,6 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*; @@ -45,7 +44,7 @@ import java.util.Map; @RequestMapping("/train") @Business(module = Constants.APP_NAME, value = "培训管理", ignore = false) @Api(value = "培训管理", tags = "培训管理接口") -public class TrainController extends BladeController { +public class TrainController { private final ITrainPlanService trainPlanService; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java index 7f6531a..1e48db1 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarMaintenanceService.java @@ -10,7 +10,6 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import javax.servlet.http.HttpServletResponse; -import java.util.List; import java.util.Map; /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java index dec42a9..8da1751 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarMaintenanceServiceImpl.java @@ -17,11 +17,14 @@ import com.hnac.hzims.safeproduct.mapper.CarMaintenanceMapper; import com.hnac.hzims.safeproduct.mapper.CarMapper; import com.hnac.hzims.safeproduct.service.ICarMaintenanceService; import com.hnac.hzims.safeproduct.utils.BaseUtil; +import com.hnac.hzims.safeproduct.vo.CarMaintenanceDetailImgVO; +import com.hnac.hzims.safeproduct.vo.CarMaintenanceDetailStrVO; import com.hnac.hzims.safeproduct.vo.CarMaintenanceDetailVO; import com.hnac.hzims.safeproduct.vo.CarMaintenancePageVO; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -123,20 +126,6 @@ public class CarMaintenanceServiceImpl extends ServiceImpl list = new ArrayList<>(); - if (StringUtils.isNotEmpty(carMaintenanceDetailVO.getImgPath())) { - String[] imgArr = carMaintenanceDetailVO.getImgPath().split(","); - for (String img : imgArr) { - ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + - BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); - list.add(imageEntity); - } - } else { - // 添加空的ImageEntity,防止数据填入时显示"{{" - list.add(new ImageEntity()); - } - carMaintenanceDetailVO.setImages(list); // 表头年月 String code = carMaintenanceDetailVO.getCode(); carMaintenanceDetailVO.setYear(code.substring(4, 8)); @@ -148,7 +137,28 @@ public class CarMaintenanceServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(carMaintenanceDetailVO); + // 图片 + Map params; + if (StringUtils.isNotEmpty(carMaintenanceDetailVO.getImgPath())) { + List list = new ArrayList<>(); + CarMaintenanceDetailImgVO imgVO = new CarMaintenanceDetailImgVO(); + BeanUtils.copyProperties(carMaintenanceDetailVO, imgVO); + String[] imgArr = carMaintenanceDetailVO.getImgPath().split(","); + for (String img : imgArr) { + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); + list.add(imageEntity); + } + imgVO.setImages(list); + params = BaseUtil.obj2Map(imgVO); + } else { + List list = new ArrayList<>(); + list.add(""); + CarMaintenanceDetailStrVO strVO = new CarMaintenanceDetailStrVO(); + BeanUtils.copyProperties(carMaintenanceDetailVO, strVO); + strVO.setImages(list); + params = BaseUtil.obj2Map(strVO); + } String templateFile = "template/车辆维保记录单" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/车辆维保记录单" + SafeProductConstant.DOCX_SUFFIX; String pdfPath = savePath + "/车辆维保记录单" + SafeProductConstant.PDF_SUFFIX; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java index 386e7c5..9c8de83 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarUsedRecordServiceImpl.java @@ -14,11 +14,14 @@ import com.hnac.hzims.safeproduct.enums.CarUsedRecordEnum; import com.hnac.hzims.safeproduct.mapper.CarUsedRecordMapper; import com.hnac.hzims.safeproduct.service.ICarUsedRecordService; import com.hnac.hzims.safeproduct.utils.BaseUtil; +import com.hnac.hzims.safeproduct.vo.CarUsedRecordDetailImgVO; +import com.hnac.hzims.safeproduct.vo.CarUsedRecordDetailStrVO; import com.hnac.hzims.safeproduct.vo.CarUsedRecordDetailVO; import com.hnac.hzims.safeproduct.vo.CarUsedRecordPageVO; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -117,25 +120,32 @@ public class CarUsedRecordServiceImpl extends ServiceImpl list = new ArrayList<>(); + Map params; if (StringUtils.isNotEmpty(carUsedRecordDetailVO.getImgPath())) { + List list = new ArrayList<>(); + CarUsedRecordDetailImgVO imgVO = new CarUsedRecordDetailImgVO(); + BeanUtils.copyProperties(carUsedRecordDetailVO, imgVO); String[] imgArr = carUsedRecordDetailVO.getImgPath().split(","); for (String img : imgArr) { ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); list.add(imageEntity); } + imgVO.setImages(list); + params = BaseUtil.obj2Map(imgVO); } else { - // 添加空的ImageEntity,防止数据填入时显示"{{" - list.add(new ImageEntity()); + List list = new ArrayList<>(); + list.add(""); + CarUsedRecordDetailStrVO strVO = new CarUsedRecordDetailStrVO(); + BeanUtils.copyProperties(carUsedRecordDetailVO, strVO); + strVO.setImages(list); + params = BaseUtil.obj2Map(strVO); } - carUsedRecordDetailVO.setImages(list); - // 表头年月 - String code = carUsedRecordDetailVO.getCode(); - carUsedRecordDetailVO.setYear(code.substring(4, 8)); - carUsedRecordDetailVO.setMonth(code.substring(8, 10)); - Map params = BaseUtil.obj2Map(carUsedRecordDetailVO); String templateFile = "template/用车记录单" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/用车记录单" + SafeProductConstant.DOCX_SUFFIX; String pdfPath = savePath + "/用车记录单" + SafeProductConstant.PDF_SUFFIX; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java index b8b4ed6..205a5f5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java @@ -17,9 +17,12 @@ import com.hnac.hzims.safeproduct.mapper.ConferenceRecordMapper; import com.hnac.hzims.safeproduct.service.IConferenceRecordService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.TimeUtils; +import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailImgVO; +import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailStrVO; import com.hnac.hzims.safeproduct.vo.ConferenceRecordDetailVO; import com.hnac.hzims.safeproduct.vo.ConferenceRecordVO; import org.springblade.core.mp.support.Query; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -120,28 +123,33 @@ public class ConferenceRecordServiceImpl extends ServiceImpl list = new ArrayList<>(); + Map params; if (StringUtils.isNotEmpty(conferenceRecordDetailVO.getImgPath())) { + List list = new ArrayList<>(); + ConferenceRecordDetailImgVO imgVO = new ConferenceRecordDetailImgVO(); + BeanUtils.copyProperties(conferenceRecordDetailVO, imgVO); String[] imgArr = conferenceRecordDetailVO.getImgPath().split(","); for (String img : imgArr) { ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); list.add(imageEntity); } + imgVO.setImages(list); + params = BaseUtil.obj2Map(imgVO); } else { - // 添加空的ImageEntity,防止数据填入时显示"{{" - list.add(new ImageEntity()); + List list = new ArrayList<>(); + list.add(""); + ConferenceRecordDetailStrVO strVO = new ConferenceRecordDetailStrVO(); + BeanUtils.copyProperties(conferenceRecordDetailVO, strVO); + strVO.setImages(list); + params = BaseUtil.obj2Map(strVO); } - conferenceRecordDetailVO.setImages(list); - Map params = BaseUtil.obj2Map(conferenceRecordDetailVO); String templateFile = "template/会议记录表" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/会议记录表" + SafeProductConstant.DOCX_SUFFIX; String pdfPath = savePath + "/会议记录表" + SafeProductConstant.PDF_SUFFIX; BaseUtil.exportDocument(templateFile, params, wordPath, pdfPath,"filePath", response); } - - /** * 查询会议记录表详情 */ diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java index 4d96ddd..5551eec 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java @@ -19,10 +19,13 @@ import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITrainRecordService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.TimeUtils; +import com.hnac.hzims.safeproduct.vo.TrainRecordDetailImgVO; +import com.hnac.hzims.safeproduct.vo.TrainRecordDetailStrVO; import com.hnac.hzims.safeproduct.vo.TrainRecordDetailVO; import com.hnac.hzims.safeproduct.vo.TrainRecordVO; import org.springblade.core.mp.support.Query; 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; import org.springframework.stereotype.Service; @@ -163,20 +166,32 @@ public class TrainRecordServiceImpl extends ServiceImpl - new ImageEntity(BaseUtil.imgToByte(savePath + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150) - ).collect(Collectors.toList())); - } else { - // 添加空的ImageEntity,防止数据填入时显示"{{" - trainRecordDetailVO.setImages(Collections.singletonList(new ImageEntity())); - } // 表头年月 String code = trainRecordDetailVO.getCode(); trainRecordDetailVO.setYear(code.substring(4, 8)); trainRecordDetailVO.setMonth(code.substring(8, 10)); - Map params = BaseUtil.obj2Map(trainRecordDetailVO); + // 图片 + Map params; + if (StringUtils.isNotEmpty(trainRecordDetailVO.getImgPath())) { + List list = new ArrayList<>(); + TrainRecordDetailImgVO imgVO = new TrainRecordDetailImgVO(); + BeanUtils.copyProperties(trainRecordDetailVO, imgVO); + String[] imgArr = trainRecordDetailVO.getImgPath().split(","); + for (String img : imgArr) { + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); + list.add(imageEntity); + } + imgVO.setImages(list); + params = BaseUtil.obj2Map(imgVO); + } else { + List list = new ArrayList<>(); + list.add(""); + TrainRecordDetailStrVO strVO = new TrainRecordDetailStrVO(); + BeanUtils.copyProperties(trainRecordDetailVO, strVO); + strVO.setImages(list); + params = BaseUtil.obj2Map(strVO); + } String templateFile = "template/培训记录表" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/培训记录表" + SafeProductConstant.DOCX_SUFFIX; String pdfPath = savePath + "/培训记录表" + SafeProductConstant.PDF_SUFFIX; diff --git a/hzims-service/safeproduct/src/main/resources/template/卫生考核表(五周).docx b/hzims-service/safeproduct/src/main/resources/template/卫生考核表(五周).docx index 8129688..e217f44 100644 Binary files a/hzims-service/safeproduct/src/main/resources/template/卫生考核表(五周).docx and b/hzims-service/safeproduct/src/main/resources/template/卫生考核表(五周).docx differ diff --git a/hzims-service/safeproduct/src/main/resources/template/卫生考核表(四周).docx b/hzims-service/safeproduct/src/main/resources/template/卫生考核表(四周).docx index a91c9f0..0043a37 100644 Binary files a/hzims-service/safeproduct/src/main/resources/template/卫生考核表(四周).docx and b/hzims-service/safeproduct/src/main/resources/template/卫生考核表(四周).docx differ