保险附件上传,下载,附件列表已完成,保险模块完成
This commit is contained in:
parent
b28515f8d7
commit
a01f765e8d
|
@ -13,13 +13,14 @@ public class Message implements Serializable {
|
|||
private static final long serialVersionUID = 4010434089386946123L;
|
||||
|
||||
public static final String IMAGE_IS_EMPTY = "图像信息为空";
|
||||
public static final String ATTACH_INFO_IS_NOT_EXIST = "附件信息id不存在";
|
||||
public static final String ATTACH_FILE_IS_NOT_EXIST = "不存在{}的附件文件";
|
||||
public static final String IMAGE_PATH_IS_NOT_EXIST = "图像地址不存在";
|
||||
public static final String IMAGE_ID_IS_NOT_EXIST = "图像id不存在";
|
||||
public static final String DEFECT_ID_IS_NOT_EXIST = "缺陷id不存在";
|
||||
public static final String PROJECT_ID_IS_NOT_EXIST = "项目id不存在";
|
||||
public static final String TURBINE_ID_IS_NOT_EXIST = "机组id不存在";
|
||||
public static final String PART_ID_IS_NOT_EXIST = "部件id不存在";
|
||||
public static final String IMAGE_SOURCE_ID_NOT_EXIST_OR_ILLEGAL = "部件id不存在或者不合法";
|
||||
public static final String USER_ID_NOT_EXIST = "用户id不存在";
|
||||
public static final String USER_ID_NOT_EXIST_OR_ILLEGAL = "用户id不存在或者不合法";
|
||||
public static final String ACCOUNT_EXIST = "用户账号已经存在,请重新输入";
|
||||
|
@ -44,6 +45,7 @@ public class Message implements Serializable {
|
|||
public static final String INSURANCE_COMPANY_NAME_IS_EXIST = "保险公司名称已存在";
|
||||
public static final String INSURANCE_COMPANY_ID_IS_NOT_EXIST = "保险公司id不存在";
|
||||
public static final String INSURANCE_INFO_ID_IS_NOT_EXIST = "保险信息id不存在";
|
||||
public static final String INSURANCE_FILE_IS_NOT_EXIST = "保险文不存在";
|
||||
public static final String TASK_ID_GROUP_ID_ALL_EMPTY = "任务id和任务组id不可同时为空";
|
||||
public static final String TASK_STATUS_NOT_PENDING = "任务状态不是未开始";
|
||||
public static final String TASK_STATUS_NOT_IN_PROGRESS = "任务状态不是进行中";
|
||||
|
|
|
@ -84,9 +84,12 @@ public interface Converts {
|
|||
InsuranceCompanyEntity toInsuranceCompanyEntity(InsuranceCompanyReq req);
|
||||
|
||||
List<InsuranceInfoResp> toInsuranceInfoResp(List<InsuranceInfoEntity> list);
|
||||
List<InsuranceAttachResp> toInsuranceAttachResp(List<InsuranceInfoEntity> list);
|
||||
|
||||
InsuranceInfoResp toInsuranceInfoResp(InsuranceInfoEntity entity);
|
||||
|
||||
InsuranceInfoEntity toInsuranceInfoEntity(InsuranceInfoReq req);
|
||||
|
||||
AttachInfoResp toAttacheInfoResp(AttachInfoEntity entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,5 +50,9 @@ public class AttachInfoEntity extends AuditableEntity implements Serializable {
|
|||
@ApiModelProperty("备注")
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 1代表删除)")
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ public class InsuranceInfoEntity extends AuditableEntity implements Serializable
|
|||
@TableField("insurance_bill_code")
|
||||
private String insuranceBillCode;
|
||||
|
||||
@ApiModelProperty("附件id")
|
||||
@TableField("attach_info_id")
|
||||
private String attachInfoId;
|
||||
|
||||
@ApiModelProperty("生效日期")
|
||||
@TableField("effective_date")
|
||||
private LocalDate effectiveDate;
|
||||
|
|
|
@ -21,6 +21,9 @@ public class AttachInfoReq implements Serializable {
|
|||
@Serial
|
||||
private static final long serialVersionUID = -59837569061686176L;
|
||||
|
||||
@ApiModelProperty("自定义路径")
|
||||
private String userDefinedPath;
|
||||
|
||||
@ApiModelProperty("文件类型")
|
||||
private String fileType;
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
* @date 2025/06/25 21:59
|
||||
* @Description: 附件信息表请求类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="AttachInfo响应对象", description="附件信息表")
|
||||
public class AttachInfoResp implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -59837569061686176L;
|
||||
|
||||
@ApiModelProperty("附件id")
|
||||
private String attachId;
|
||||
|
||||
@ApiModelProperty("业务id")
|
||||
private String businessId;
|
||||
|
||||
@ApiModelProperty("附件路径")
|
||||
private String attachPath;
|
||||
|
||||
@ApiModelProperty("文件类型")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author: gaoxiong
|
||||
* @Date: 2025/6/24 23:46
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("保险附件响应实体")
|
||||
public class InsuranceAttachResp implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -4902944535128070359L;
|
||||
|
||||
@ApiModelProperty("保险信息id")
|
||||
private String insuranceInfoId;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("用户姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("用户编码")
|
||||
private String userCode;
|
||||
|
||||
@ApiModelProperty("附件id")
|
||||
private String attachInfoId;
|
||||
|
||||
@ApiModelProperty("附件路径")
|
||||
private String attachPath;
|
||||
|
||||
@ApiModelProperty("文件类型")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
}
|
|
@ -42,6 +42,10 @@ public class InsuranceInfoReq implements Serializable {
|
|||
@ApiModelProperty("保单号")
|
||||
private String insuranceBillCode;
|
||||
|
||||
@NotBlank(message = "保单号不能为空")
|
||||
@ApiModelProperty("附件id,调用/attach-info{businessType}方法获取,businessType传值insurance_file,userDefinedPath传值规则:userid + '/' + insuranceBillCode")
|
||||
private String attachInfoId;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@NotNull(message = "生效日期不能为空")
|
||||
@ApiModelProperty("生效日期")
|
||||
|
|
|
@ -6,9 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -53,6 +50,12 @@ public class InsuranceInfoResp implements Serializable {
|
|||
@ApiModelProperty("保单号")
|
||||
private String insuranceBillCode;
|
||||
|
||||
@ApiModelProperty("附件id")
|
||||
private String attachInfoId;
|
||||
|
||||
@ApiModelProperty("附件信息")
|
||||
private AttachInfoResp attachInfoResp;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty("生效日期")
|
||||
private LocalDate effectiveDate;
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.List;
|
|||
@Getter
|
||||
public enum AttachBusinessTypeEnum {
|
||||
PROJECT_TASK("PROJECT_TASK", "项目任务"),
|
||||
INSURANCE_FILE("insurance", "保险文件"),
|
||||
;
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
|
|
@ -15,7 +15,7 @@ public enum FilePathEnum {
|
|||
VIDEO("/static/video/", "video"),
|
||||
AUDIO("/static/audio/", "audio"),
|
||||
ATTACH("/static/attach/", "attach"),
|
||||
;
|
||||
INSURANCE("/static/insurance/", "insurance");
|
||||
|
||||
@Getter
|
||||
private final String urlPath;
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.dite.znpt.domain.vo.AttachInfoReq;
|
|||
import com.dite.znpt.enums.AttachBusinessTypeEnum;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -33,6 +35,8 @@ public interface AttachInfoService extends IService<AttachInfoEntity> {
|
|||
**/
|
||||
List<String> saveData(String businessType, AttachInfoReq infoReq, MultipartFile[] files);
|
||||
|
||||
|
||||
void download(String attachId, HttpServletResponse response) throws Exception;
|
||||
/**
|
||||
* 功能描述:删除附件信息
|
||||
*
|
||||
|
@ -41,6 +45,8 @@ public interface AttachInfoService extends IService<AttachInfoEntity> {
|
|||
**/
|
||||
void deleteByBusinessId(String businessId, AttachBusinessTypeEnum typeEnum);
|
||||
|
||||
void deleteByAttachInfoId(String attachIdInfoId);
|
||||
|
||||
/**
|
||||
* 功能描述:删除附件信息
|
||||
*
|
||||
|
|
|
@ -2,9 +2,11 @@ package com.dite.znpt.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dite.znpt.domain.entity.InsuranceInfoEntity;
|
||||
import com.dite.znpt.domain.vo.InsuranceAttachResp;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoListReq;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoReq;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoResp;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -16,6 +18,8 @@ import java.util.List;
|
|||
public interface InsuranceInfoService extends IService<InsuranceInfoEntity> {
|
||||
List<InsuranceInfoResp> page(InsuranceInfoListReq req);
|
||||
List<InsuranceInfoResp> list(InsuranceInfoListReq req);
|
||||
List<InsuranceAttachResp> pageAttach(InsuranceInfoListReq req);
|
||||
List<InsuranceAttachResp> listAttach(InsuranceInfoListReq req);
|
||||
InsuranceInfoResp detail(String insuranceInfoId);
|
||||
void save(InsuranceInfoReq req);
|
||||
void update(String insuranceInfoId, InsuranceInfoReq req);
|
||||
|
|
|
@ -7,18 +7,29 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.constant.Constants;
|
||||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.domain.entity.AttachInfoEntity;
|
||||
import com.dite.znpt.domain.entity.InsuranceInfoEntity;
|
||||
import com.dite.znpt.domain.vo.AttachInfoReq;
|
||||
import com.dite.znpt.enums.AttachBusinessTypeEnum;
|
||||
import com.dite.znpt.enums.FilePathEnum;
|
||||
import com.dite.znpt.service.AttachInfoService;
|
||||
import com.dite.znpt.mapper.FileInfoMapper;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.dite.znpt.util.PageUtil;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -58,7 +69,11 @@ public class AttachInfoServiceImpl extends ServiceImpl<FileInfoMapper, AttachInf
|
|||
**/
|
||||
@Override
|
||||
public List<String> saveData(String businessType, AttachInfoReq infoReq, MultipartFile[] files) {
|
||||
String temPathPrefix = FilePathEnum.ATTACH.getFileAbsolutePath().concat(businessType).concat(FileUtil.FILE_SEPARATOR).concat(DateUtil.today()).concat(FileUtil.FILE_SEPARATOR);
|
||||
String temPathPrefix = FilePathEnum.ATTACH.getFileAbsolutePath().concat(businessType).concat(FileUtil.FILE_SEPARATOR);
|
||||
if(StrUtil.isNotBlank(infoReq.getUserDefinedPath())){
|
||||
temPathPrefix = temPathPrefix.concat(infoReq.getUserDefinedPath()).concat(FileUtil.FILE_SEPARATOR);
|
||||
}
|
||||
temPathPrefix = temPathPrefix.concat(DateUtil.today()).concat(FileUtil.FILE_SEPARATOR);
|
||||
if (!FileUtil.exist(temPathPrefix)) {
|
||||
FileUtil.mkdir(temPathPrefix);
|
||||
}
|
||||
|
@ -84,6 +99,38 @@ public class AttachInfoServiceImpl extends ServiceImpl<FileInfoMapper, AttachInf
|
|||
return list.stream().map(AttachInfoEntity::getAttachId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(String attachId, HttpServletResponse response) throws Exception {
|
||||
AttachInfoEntity attachInfo = this.getById(attachId);
|
||||
if(null == attachInfo || !Constants.DEL_FLAG_0.equals(attachInfo.getDelFlag())){
|
||||
throw new ServerException(Message.ATTACH_INFO_IS_NOT_EXIST);
|
||||
}
|
||||
String filePath = FilePathEnum.ATTACH.getFileAbsolutePath().concat(StrUtil.removePrefix(attachInfo.getAttachPath(), FilePathEnum.ATTACH.getUrlPath()));
|
||||
File file = new File(filePath);
|
||||
// 检查文件是否存在
|
||||
if (!file.exists()) {
|
||||
throw new ServerException(StrUtil.format(Message.ATTACH_FILE_IS_NOT_EXIST, attachInfo.getAttachPath()));
|
||||
}
|
||||
// 设置响应头
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode(file.getName()));
|
||||
response.setContentLengthLong(file.length());
|
||||
// 打开文件输入流并写入响应输出流
|
||||
try (FileInputStream fileInputStream = new FileInputStream(file);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
byte[] buffer = new byte[1024]; // 缓冲区大小
|
||||
int bytesRead;
|
||||
// 读取文件并写入输出流
|
||||
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
outputStream.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
response.sendError(500, "文件下载失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能描述:删除附件信息
|
||||
*
|
||||
|
@ -97,9 +144,16 @@ public class AttachInfoServiceImpl extends ServiceImpl<FileInfoMapper, AttachInf
|
|||
deleteByBusinessIds(ListUtil.toList(businessId), typeEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByAttachInfoId(String attachIdInfoId) {
|
||||
this.update(Wrappers.lambdaUpdate(AttachInfoEntity.class).eq(AttachInfoEntity::getAttachId, attachIdInfoId).set(AttachInfoEntity::getDelFlag, Constants.DEL_FLAG_1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByBusinessIds(List<String> businessIds, AttachBusinessTypeEnum typeEnum) {
|
||||
lambdaUpdate().in(AttachInfoEntity::getBusinessId, businessIds)
|
||||
.eq(AttachInfoEntity::getBusinessType, typeEnum.getCode()).remove();
|
||||
.eq(AttachInfoEntity::getBusinessType, typeEnum.getCode())
|
||||
.set(AttachInfoEntity::getDelFlag, Constants.DEL_FLAG_1).update();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.constant.Constants;
|
||||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.converts.Converts;
|
||||
import com.dite.znpt.domain.entity.ImageCollectEntity;
|
||||
|
@ -17,7 +16,6 @@ import com.dite.znpt.mapper.ImageCollectMapper;
|
|||
import com.dite.znpt.service.ImageCollectService;
|
||||
import com.dite.znpt.service.ImageService;
|
||||
import com.dite.znpt.service.PartService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
|
@ -1,34 +1,38 @@
|
|||
package com.dite.znpt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dite.znpt.constant.Constants;
|
||||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.converts.Converts;
|
||||
import com.dite.znpt.domain.entity.InsuranceCompanyEntity;
|
||||
import com.dite.znpt.domain.entity.InsuranceInfoEntity;
|
||||
import com.dite.znpt.domain.entity.InsuranceTypeEntity;
|
||||
import com.dite.znpt.domain.entity.UserEntity;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoListReq;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoReq;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoResp;
|
||||
import com.dite.znpt.domain.entity.*;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.enums.AttachBusinessTypeEnum;
|
||||
import com.dite.znpt.enums.FilePathEnum;
|
||||
import com.dite.znpt.enums.InsuranceStatusEnum;
|
||||
import com.dite.znpt.enums.UserStatusEnum;
|
||||
import com.dite.znpt.exception.ServiceException;
|
||||
import com.dite.znpt.mapper.InsuranceInfoMapper;
|
||||
import com.dite.znpt.service.InsuranceCompanyService;
|
||||
import com.dite.znpt.service.InsuranceInfoService;
|
||||
import com.dite.znpt.service.InsuranceTypeService;
|
||||
import com.dite.znpt.service.UserService;
|
||||
import com.dite.znpt.service.*;
|
||||
import com.dite.znpt.util.PageUtil;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
|
@ -47,6 +51,9 @@ public class InsuranceInfoServiceImpl extends ServiceImpl<InsuranceInfoMapper, I
|
|||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private AttachInfoService attacheInfoService;
|
||||
|
||||
@Override
|
||||
public List<InsuranceInfoResp> page(InsuranceInfoListReq req) {
|
||||
PageUtil.startPage();
|
||||
|
@ -55,7 +62,7 @@ public class InsuranceInfoServiceImpl extends ServiceImpl<InsuranceInfoMapper, I
|
|||
|
||||
@Override
|
||||
public List<InsuranceInfoResp> list(InsuranceInfoListReq req) {
|
||||
return Converts.INSTANCE.toInsuranceInfoResp(
|
||||
List<InsuranceInfoResp> result = Converts.INSTANCE.toInsuranceInfoResp(
|
||||
this.list(Wrappers.lambdaQuery(InsuranceInfoEntity.class)
|
||||
.like(StrUtil.isNotBlank(req.getName()), InsuranceInfoEntity::getName, req.getName())
|
||||
.like(StrUtil.isNotBlank(req.getUserCode()), InsuranceInfoEntity::getUserCode, req.getUserCode())
|
||||
|
@ -63,6 +70,42 @@ public class InsuranceInfoServiceImpl extends ServiceImpl<InsuranceInfoMapper, I
|
|||
.eq(StrUtil.isNotBlank(req.getInsuranceCompanyId()), InsuranceInfoEntity::getInsuranceCompanyId, req.getInsuranceCompanyId())
|
||||
.eq(StrUtil.isNotBlank(req.getInsuranceStatus()), InsuranceInfoEntity::getInsuranceStatus, req.getInsuranceStatus())
|
||||
));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InsuranceAttachResp> pageAttach(InsuranceInfoListReq req) {
|
||||
PageUtil.startPage();
|
||||
return this.listAttach(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InsuranceAttachResp> listAttach(InsuranceInfoListReq req) {
|
||||
List<InsuranceAttachResp> result = Converts.INSTANCE.toInsuranceAttachResp(
|
||||
this.list(Wrappers.lambdaQuery(InsuranceInfoEntity.class)
|
||||
.like(StrUtil.isNotBlank(req.getName()), InsuranceInfoEntity::getName, req.getName())
|
||||
.like(StrUtil.isNotBlank(req.getUserCode()), InsuranceInfoEntity::getUserCode, req.getUserCode())
|
||||
.eq(StrUtil.isNotBlank(req.getInsuranceTypeId()), InsuranceInfoEntity::getInsuranceTypeId, req.getInsuranceCompanyId())
|
||||
.eq(StrUtil.isNotBlank(req.getInsuranceCompanyId()), InsuranceInfoEntity::getInsuranceCompanyId, req.getInsuranceCompanyId())
|
||||
.eq(StrUtil.isNotBlank(req.getInsuranceStatus()), InsuranceInfoEntity::getInsuranceStatus, req.getInsuranceStatus())
|
||||
)
|
||||
);
|
||||
|
||||
List<String> attachInfoIds = result.stream().map(InsuranceAttachResp::getAttachInfoId).filter(StrUtil::isNotBlank).toList();
|
||||
if(CollUtil.isNotEmpty(attachInfoIds)){
|
||||
Map<String, AttachInfoEntity> attachIdMap = attacheInfoService.list(
|
||||
Wrappers.lambdaQuery(AttachInfoEntity.class).in(AttachInfoEntity::getAttachId, attachInfoIds).eq(AttachInfoEntity::getDelFlag, Constants.DEL_FLAG_0)
|
||||
).stream().collect(Collectors.toMap(AttachInfoEntity::getAttachId, Function.identity()));
|
||||
result.forEach(resp -> {
|
||||
if(StrUtil.isNotBlank(resp.getAttachInfoId()) && attachIdMap.containsKey(resp.getAttachInfoId())){
|
||||
resp.setAttachPath(attachIdMap.get(resp.getAttachInfoId()).getAttachPath());
|
||||
resp.setCreateTime(attachIdMap.get(resp.getAttachInfoId()).getCreateTime());
|
||||
resp.setFileType(attachIdMap.get(resp.getAttachInfoId()).getFileType());
|
||||
resp.setRemark(attachIdMap.get(resp.getAttachInfoId()).getRemark());
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,13 +114,23 @@ public class InsuranceInfoServiceImpl extends ServiceImpl<InsuranceInfoMapper, I
|
|||
if(null == insuranceInfoEntity || !Constants.DEL_FLAG_0.equals(insuranceInfoEntity.getDelFlag())){
|
||||
throw new ServiceException(Message.INSURANCE_INFO_ID_IS_NOT_EXIST);
|
||||
}
|
||||
return Converts.INSTANCE.toInsuranceInfoResp(insuranceInfoEntity);
|
||||
InsuranceInfoResp result = Converts.INSTANCE.toInsuranceInfoResp(insuranceInfoEntity);
|
||||
if(StrUtil.isNotBlank(insuranceInfoEntity.getAttachInfoId())){
|
||||
AttachInfoEntity attachInfoEntity = attacheInfoService.getById(insuranceInfoEntity.getAttachInfoId());
|
||||
result.setAttachInfoResp(Converts.INSTANCE.toAttacheInfoResp(attachInfoEntity));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void save(InsuranceInfoReq req) {
|
||||
this.save(validation(Converts.INSTANCE.toInsuranceInfoEntity(req)));
|
||||
InsuranceInfoEntity entity = validation(Converts.INSTANCE.toInsuranceInfoEntity(req));
|
||||
this.save(entity);
|
||||
if(StrUtil.isNotBlank(entity.getAttachInfoId())){
|
||||
attacheInfoService.updateBusinessIdByAttachIds(entity.getInsuranceInfoId(), Arrays.asList(entity.getAttachInfoId()), AttachBusinessTypeEnum.INSURANCE_FILE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -90,6 +143,9 @@ public class InsuranceInfoServiceImpl extends ServiceImpl<InsuranceInfoMapper, I
|
|||
InsuranceInfoEntity entity = Converts.INSTANCE.toInsuranceInfoEntity(req);
|
||||
entity.setInsuranceInfoId(insuranceInfoId);
|
||||
this.updateById(validation(entity));
|
||||
if(StrUtil.isNotBlank(entity.getAttachInfoId())){
|
||||
attacheInfoService.updateBusinessIdByAttachIds(entity.getInsuranceInfoId(), Arrays.asList(entity.getAttachInfoId()), AttachBusinessTypeEnum.INSURANCE_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,12 +175,13 @@ public class InsuranceInfoServiceImpl extends ServiceImpl<InsuranceInfoMapper, I
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void deleteById(String insuranceInfoId) {
|
||||
InsuranceInfoEntity insuranceInfoEntity = this.getById(insuranceInfoId);
|
||||
if(null == insuranceInfoEntity || !Constants.DEL_FLAG_0.equals(insuranceInfoEntity.getDelFlag())){
|
||||
InsuranceInfoEntity entity = this.getById(insuranceInfoId);
|
||||
if(null == entity || !Constants.DEL_FLAG_0.equals(entity.getDelFlag())){
|
||||
throw new ServiceException(Message.INSURANCE_INFO_ID_IS_NOT_EXIST);
|
||||
}
|
||||
insuranceInfoEntity.setDelFlag(Constants.DEL_FLAG_1);
|
||||
this.updateById(insuranceInfoEntity);
|
||||
entity.setDelFlag(Constants.DEL_FLAG_1);
|
||||
attacheInfoService.deleteByAttachInfoId(entity.getAttachInfoId());
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
|
@ -1,25 +1,17 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.entity.AudioFileInfoEntity;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.enums.ImageSourceEnum;
|
||||
import com.dite.znpt.service.AudioFileInfoService;
|
||||
import com.dite.znpt.service.ImageCollectService;
|
||||
import com.dite.znpt.service.ImageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,15 +1,25 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.dite.znpt.constant.Message;
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.domain.entity.InsuranceInfoEntity;
|
||||
import com.dite.znpt.domain.vo.InsuranceAttachResp;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoListReq;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoReq;
|
||||
import com.dite.znpt.domain.vo.InsuranceInfoResp;
|
||||
import com.dite.znpt.service.AttachInfoService;
|
||||
import com.dite.znpt.service.InsuranceInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.rmi.ServerException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -25,6 +35,9 @@ public class InsuranceInfoController {
|
|||
@Resource
|
||||
private InsuranceInfoService insuranceInfoService;
|
||||
|
||||
@Resource
|
||||
private AttachInfoService attachInfoService;
|
||||
|
||||
@ApiOperation(value = "分页查询保险信息列表", httpMethod = "GET")
|
||||
@GetMapping("/page")
|
||||
public PageResult<InsuranceInfoResp> page(InsuranceInfoListReq req) {
|
||||
|
@ -37,6 +50,18 @@ public class InsuranceInfoController {
|
|||
return Result.ok(insuranceInfoService.list(req));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询保险附件列表", httpMethod = "GET")
|
||||
@GetMapping("/page-attach")
|
||||
public PageResult<InsuranceAttachResp> pageAttach(InsuranceInfoListReq req) {
|
||||
return PageResult.ok(insuranceInfoService.pageAttach(req));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询保险附件列表", httpMethod = "GET")
|
||||
@GetMapping("/list-attach")
|
||||
public Result<List<InsuranceAttachResp>> listAttach(InsuranceInfoListReq req) {
|
||||
return Result.ok(insuranceInfoService.listAttach(req));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询保险信息详情", httpMethod = "GET")
|
||||
@GetMapping("/detail/{insuranceInfoId}")
|
||||
public Result<InsuranceInfoResp> detail(@PathVariable String insuranceInfoId) {
|
||||
|
@ -63,4 +88,20 @@ public class InsuranceInfoController {
|
|||
insuranceInfoService.deleteById(insuranceInfoId);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param response
|
||||
* @功能描述 下载文件:将输入流中的数据循环写入到响应输出流中,而不是一次性读取到内存
|
||||
*/
|
||||
@GetMapping("/download-file/{insuranceInfoId}")
|
||||
public void downloadFile(@PathVariable String insuranceInfoId, HttpServletResponse response) throws Exception {
|
||||
InsuranceInfoEntity insuranceInfo = insuranceInfoService.getById(insuranceInfoId);
|
||||
if(null == insuranceInfo){
|
||||
throw new ServerException(Message.INSURANCE_INFO_ID_IS_NOT_EXIST);
|
||||
}
|
||||
if(StrUtil.isBlank(insuranceInfo.getAttachInfoId())){
|
||||
throw new ServerException(Message.INSURANCE_FILE_IS_NOT_EXIST);
|
||||
}
|
||||
attachInfoService.download(insuranceInfo.getAttachInfoId(), response);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue