微调
This commit is contained in:
@@ -210,4 +210,5 @@ public interface DevValidMessage {
|
|||||||
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
|
String PREINVESTMENT_PLAN_NOT_BLANK = "预投资计划不能为空";
|
||||||
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
|
String TIMECHECK_NOT_NULL = "是否做守时检测不能为空";
|
||||||
String CREATEID_NOT_BLANK = "设备序列号不能为空";
|
String CREATEID_NOT_BLANK = "设备序列号不能为空";
|
||||||
|
String ASSOCIATE_REPORT_NOT_NULL = "是否关联报告不能为空";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
FROM pq_report
|
FROM pq_report
|
||||||
WHERE name = #{name}
|
WHERE name = #{name}
|
||||||
AND version = #{version}
|
AND version = #{version}
|
||||||
and enable !=0
|
and state = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getPqReportById" resultType="com.njcn.gather.report.pojo.po.PqReport">
|
<select id="getPqReportById" resultType="com.njcn.gather.report.pojo.po.PqReport">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM pq_report
|
FROM pq_report
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
and enable !=0
|
and state = 1
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class AdPlanParam {
|
|||||||
private List<String> devIds;
|
private List<String> devIds;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否关联报告")
|
@ApiModelProperty(value = "是否关联报告")
|
||||||
|
@NotNull(message = DevValidMessage.ASSOCIATE_REPORT_NOT_NULL)
|
||||||
private Integer associateReport;
|
private Integer associateReport;
|
||||||
|
|
||||||
@ApiModelProperty(value = "报告模板名称")
|
@ApiModelProperty(value = "报告模板名称")
|
||||||
|
|||||||
@@ -193,6 +193,18 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
if (!plan1.getErrorSysId().equals(param.getErrorSysId())) {
|
if (!plan1.getErrorSysId().equals(param.getErrorSysId())) {
|
||||||
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
|
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_ERROR_SYS_WHEN_CHECKING);
|
||||||
}
|
}
|
||||||
|
if (param.getAssociateReport() != plan1.getAssociateReport()) {
|
||||||
|
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||||
|
}
|
||||||
|
if (param.getAssociateReport() != plan1.getAssociateReport()) {
|
||||||
|
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||||
|
}
|
||||||
|
if (param.getAssociateReport() == 1) {
|
||||||
|
String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportName(), param.getReportVersion());
|
||||||
|
if (!reportId.equals(plan1.getReportTemplateId())) {
|
||||||
|
throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanUtil.copyProperties(param, plan2);
|
BeanUtil.copyProperties(param, plan2);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,11 +3,17 @@ package com.njcn.gather.report.mapper;
|
|||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import com.njcn.gather.report.pojo.po.PqReport;
|
import com.njcn.gather.report.pojo.po.PqReport;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author makejava
|
* @author makejava
|
||||||
* @date 2025-03-19
|
* @date 2025-03-19
|
||||||
*/
|
*/
|
||||||
public interface PqReportMapper extends MPJBaseMapper<PqReport> {
|
public interface PqReportMapper extends MPJBaseMapper<PqReport> {
|
||||||
|
/**
|
||||||
|
* 获取所有已被计划绑定的报告模板id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getBoundReportIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,5 +3,8 @@
|
|||||||
<mapper namespace="com.njcn.gather.report.mapper.PqReportMapper">
|
<mapper namespace="com.njcn.gather.report.mapper.PqReportMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getBoundReportIds" resultType="java.lang.String">
|
||||||
|
select distinct Report_Template_Id from ad_plan where state = 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.gather.report.pojo.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2025-03-20
|
||||||
|
*/
|
||||||
|
public interface ReportValidMessage {
|
||||||
|
String NAME_NOT_BLANK = "报告模板名称不能为空";
|
||||||
|
String VERSION_NOT_BLANK = "报告模板版本号不能为空";
|
||||||
|
String ENABLE_NOT_NULL = "报告模板的启用状态不能为空";
|
||||||
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.njcn.gather.report.pojo.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author caozehui
|
|
||||||
* @data 2025-03-20
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
public enum ReportEnableEnum {
|
|
||||||
DELETE(0, "删除"),
|
|
||||||
ENABLE(1, "启用"),
|
|
||||||
DISABLE(2, "禁用");
|
|
||||||
|
|
||||||
private int code;
|
|
||||||
private String desc;
|
|
||||||
|
|
||||||
ReportEnableEnum(int code, String desc) {
|
|
||||||
this.code = code;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,10 @@ public enum ReportResponseEnum {
|
|||||||
|
|
||||||
FILE_UPLOAD_FAILED("A012001", "文件上传失败"),
|
FILE_UPLOAD_FAILED("A012001", "文件上传失败"),
|
||||||
FILE_SUFFIX_ERROR("A012002", "文件后缀错误,请上传.docx文件"),
|
FILE_SUFFIX_ERROR("A012002", "文件后缀错误,请上传.docx文件"),
|
||||||
REPORT_REPEATED("A012003", "已存在相同版本、相同名称的报告");
|
REPORT_REPEATED("A012003", "已存在相同版本、相同名称的报告"),
|
||||||
|
FILE_NOT_NULL("A012004", "上传的文件不能为空"),
|
||||||
|
DELETE_BOUND_REPORT_ERROR("A012005", "已被计划绑定模板的报告不能删除"),
|
||||||
|
FILE_NAME_SAME_ERROR("A012006", "文件名不能相同");
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String message;
|
private String message;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package com.njcn.gather.report.pojo.param;
|
package com.njcn.gather.report.pojo.param;
|
||||||
|
|
||||||
|
import com.njcn.gather.report.pojo.constant.ReportValidMessage;
|
||||||
import com.njcn.web.pojo.param.BaseParam;
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
* @data 2025-03-19
|
* @data 2025-03-19
|
||||||
@@ -14,9 +18,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
public class ReportParam {
|
public class ReportParam {
|
||||||
|
|
||||||
@ApiModelProperty(value = "报告模板名称", required = true)
|
@ApiModelProperty(value = "报告模板名称", required = true)
|
||||||
|
@NotBlank(message = ReportValidMessage.NAME_NOT_BLANK)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty(value = "版本号", required = true)
|
@ApiModelProperty(value = "版本号", required = true)
|
||||||
|
@NotBlank(message = ReportValidMessage.VERSION_NOT_BLANK)
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
@ApiModelProperty(value = "描述信息", required = true)
|
@ApiModelProperty(value = "描述信息", required = true)
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public class PqReport extends BaseEntity implements Serializable {
|
|||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0-删除 1-激活 2-未激活
|
* 状态:0-删除 1-正常
|
||||||
*/
|
*/
|
||||||
private Integer enable;
|
private Integer state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ public class PqReportVO {
|
|||||||
/**
|
/**
|
||||||
* 描述信息
|
* 描述信息
|
||||||
*/
|
*/
|
||||||
private String desc;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0-删除 1-激活 2-未激活
|
* 状态:0-删除 1-正常
|
||||||
*/
|
*/
|
||||||
private Integer enable;
|
//private Integer state;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class FileVO{
|
public static class FileVO{
|
||||||
|
|||||||
@@ -71,15 +71,6 @@ public interface IPqReportService extends IService<PqReport> {
|
|||||||
*/
|
*/
|
||||||
List<String> listAllVersion(String name);
|
List<String> listAllVersion(String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据报告名称和版本号查询报告
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param version
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
PqReport getReportByNameAndVersion(String name, String version);
|
|
||||||
|
|
||||||
void generateReport(DevReportParam devReportParam);
|
void generateReport(DevReportParam devReportParam);
|
||||||
|
|
||||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.text.StrPool;
|
import cn.hutool.core.text.StrPool;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@@ -23,7 +24,6 @@ import com.njcn.gather.plan.pojo.po.AdPlan;
|
|||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.report.mapper.PqReportMapper;
|
import com.njcn.gather.report.mapper.PqReportMapper;
|
||||||
import com.njcn.gather.report.pojo.DevReportParam;
|
import com.njcn.gather.report.pojo.DevReportParam;
|
||||||
import com.njcn.gather.report.pojo.enums.ReportEnableEnum;
|
|
||||||
import com.njcn.gather.report.pojo.enums.ReportResponseEnum;
|
import com.njcn.gather.report.pojo.enums.ReportResponseEnum;
|
||||||
import com.njcn.gather.report.pojo.param.ReportParam;
|
import com.njcn.gather.report.pojo.param.ReportParam;
|
||||||
import com.njcn.gather.report.pojo.po.PqReport;
|
import com.njcn.gather.report.pojo.po.PqReport;
|
||||||
@@ -102,7 +102,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
QueryWrapper<PqReport> wrapper = new QueryWrapper<>();
|
QueryWrapper<PqReport> wrapper = new QueryWrapper<>();
|
||||||
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
|
wrapper.like(StrUtil.isNotBlank(queryParam.getName()), "name", queryParam.getName())
|
||||||
.eq(StrUtil.isNotBlank(queryParam.getVersion()), "version", queryParam.getVersion())
|
.eq(StrUtil.isNotBlank(queryParam.getVersion()), "version", queryParam.getVersion())
|
||||||
.ne("enable", ReportEnableEnum.DELETE.getCode());
|
.eq("state", DataStateEnum.ENABLE.getCode());
|
||||||
Page<PqReport> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
|
Page<PqReport> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
|
||||||
|
|
||||||
List<PqReportVO> pqReportVOList = page1.getRecords().stream().map(pqReport -> {
|
List<PqReportVO> pqReportVOList = page1.getRecords().stream().map(pqReport -> {
|
||||||
@@ -155,7 +155,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
this.checkRepeat(reportParam, false);
|
this.checkRepeat(reportParam, false);
|
||||||
PqReport pqReport = new PqReport();
|
PqReport pqReport = new PqReport();
|
||||||
BeanUtils.copyProperties(reportParam, pqReport);
|
BeanUtils.copyProperties(reportParam, pqReport);
|
||||||
pqReport.setEnable(ReportEnableEnum.DISABLE.getCode());
|
pqReport.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
this.uploadFile(reportParam, pqReport);
|
this.uploadFile(reportParam, pqReport);
|
||||||
return this.save(pqReport);
|
return this.save(pqReport);
|
||||||
@@ -175,11 +176,15 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean delete(List<String> ids) {
|
public boolean delete(List<String> ids) {
|
||||||
|
List<String> boundReportIds = this.baseMapper.getBoundReportIds();
|
||||||
|
if (CollectionUtil.containsAny(boundReportIds, ids)) {
|
||||||
|
throw new BusinessException(ReportResponseEnum.DELETE_BOUND_REPORT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
// 删除对应的文件
|
// 删除对应的文件
|
||||||
this.deleteFile(ids);
|
this.deleteFile(ids);
|
||||||
boolean result = this.lambdaUpdate().in(CollectionUtil.isNotEmpty(ids), PqReport::getId, ids)
|
boolean result = this.lambdaUpdate().in(CollectionUtil.isNotEmpty(ids), PqReport::getId, ids)
|
||||||
.ne(PqReport::getEnable, ReportEnableEnum.DELETE.getCode())
|
.set(PqReport::getState, DataStateEnum.DELETED.getCode())
|
||||||
.set(PqReport::getEnable, ReportEnableEnum.DELETE.getCode())
|
|
||||||
.update();
|
.update();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -187,26 +192,18 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
@Override
|
@Override
|
||||||
public List<String> listAllName() {
|
public List<String> listAllName() {
|
||||||
List<String> result = this.lambdaQuery()
|
List<String> result = this.lambdaQuery()
|
||||||
.ne(PqReport::getEnable, ReportEnableEnum.DELETE.getCode()).list().stream().map(PqReport::getName).collect(Collectors.toList());
|
.eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).list().stream().map(PqReport::getName).collect(Collectors.toList());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> listAllVersion(String name) {
|
public List<String> listAllVersion(String name) {
|
||||||
List<String> result = this.lambdaQuery().eq(PqReport::getName, name)
|
List<String> result = this.lambdaQuery().eq(PqReport::getName, name)
|
||||||
.ne(PqReport::getEnable, ReportEnableEnum.DELETE.getCode())
|
.eq(PqReport::getState, DataStateEnum.ENABLE.getCode())
|
||||||
.list().stream().map(PqReport::getVersion).collect(Collectors.toList());
|
.list().stream().map(PqReport::getVersion).collect(Collectors.toList());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PqReport getReportByNameAndVersion(String name, String version) {
|
|
||||||
PqReport one = this.lambdaQuery().eq(PqReport::getName, name).eq(PqReport::getVersion, version)
|
|
||||||
.ne(PqReport::getEnable, ReportEnableEnum.DELETE.getCode())
|
|
||||||
.last("LIMIT 1").one();
|
|
||||||
return one;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件,并设置pqReport的basePath和detailPath属性
|
* 上传文件,并设置pqReport的basePath和detailPath属性
|
||||||
*
|
*
|
||||||
@@ -219,56 +216,64 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
//校验文件后缀
|
//校验文件后缀
|
||||||
MultipartFile baseFile = reportParam.getBaseFile();
|
MultipartFile baseFile = reportParam.getBaseFile();
|
||||||
MultipartFile detailFile = reportParam.getDetailFile();
|
MultipartFile detailFile = reportParam.getDetailFile();
|
||||||
String baseOriginalFilename = baseFile.getOriginalFilename();
|
if (ObjectUtil.isNotNull(baseFile) && ObjectUtil.isNotNull(detailFile) && !baseFile.isEmpty() && !detailFile.isEmpty()) {
|
||||||
String baseFileName = baseOriginalFilename.substring(0, baseOriginalFilename.lastIndexOf("."));
|
String baseOriginalFilename = baseFile.getOriginalFilename();
|
||||||
String baseSuffix = baseOriginalFilename.substring(baseOriginalFilename.lastIndexOf(".") + 1);
|
String baseFileName = baseOriginalFilename.substring(0, baseOriginalFilename.lastIndexOf("."));
|
||||||
String detailOriginalFilename = detailFile.getOriginalFilename();
|
String baseSuffix = baseOriginalFilename.substring(baseOriginalFilename.lastIndexOf(".") + 1);
|
||||||
String detailFileName = detailOriginalFilename.substring(0, detailOriginalFilename.lastIndexOf("."));
|
String detailOriginalFilename = detailFile.getOriginalFilename();
|
||||||
String detailSuffix = detailOriginalFilename.substring(detailOriginalFilename.lastIndexOf(".") + 1);
|
String detailFileName = detailOriginalFilename.substring(0, detailOriginalFilename.lastIndexOf("."));
|
||||||
|
String detailSuffix = detailOriginalFilename.substring(detailOriginalFilename.lastIndexOf(".") + 1);
|
||||||
|
|
||||||
if (!"docx".equals(baseSuffix) || !"docx".equals(detailSuffix)) {
|
if (!"docx".equals(baseSuffix) || !"docx".equals(detailSuffix)) {
|
||||||
throw new BusinessException(ReportResponseEnum.FILE_SUFFIX_ERROR);
|
throw new BusinessException(ReportResponseEnum.FILE_SUFFIX_ERROR);
|
||||||
}
|
}
|
||||||
|
if (baseFileName.equals(detailFileName)) {
|
||||||
pqReport.setBasePath(uploadDir + baseFileName + "_" + pqReport.getVersion() + ".docx");
|
throw new BusinessException(ReportResponseEnum.FILE_NAME_SAME_ERROR);
|
||||||
pqReport.setDetailPath(uploadDir + detailFileName + "_" + pqReport.getVersion() + ".docx");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 创建上传目录(如果不存在)
|
|
||||||
Path uploadPath = Paths.get(uploadDir);
|
|
||||||
if (!Files.exists(uploadPath)) {
|
|
||||||
Files.createDirectories(uploadPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//清空目录下的文件
|
pqReport.setBasePath(uploadDir + baseFileName + "_" + pqReport.getVersion() + ".docx");
|
||||||
File[] files = uploadPath.toFile().listFiles();
|
pqReport.setDetailPath(uploadDir + detailFileName + "_" + pqReport.getVersion() + ".docx");
|
||||||
if (ArrayUtil.isNotEmpty(files)) {
|
|
||||||
for (int i = 0; i < files.length; i++) {
|
try {
|
||||||
files[i].delete();
|
// 创建上传目录(如果不存在)
|
||||||
|
Path uploadPath = Paths.get(uploadDir);
|
||||||
|
if (!Files.exists(uploadPath)) {
|
||||||
|
Files.createDirectories(uploadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//清空目录下的文件
|
||||||
|
File[] files = uploadPath.toFile().listFiles();
|
||||||
|
if (ArrayUtil.isNotEmpty(files)) {
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
files[i].delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存文件
|
||||||
|
byte[] baseBytes = baseFile.getBytes();
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(pqReport.getBasePath()));
|
||||||
|
bufferedOutputStream.write(baseBytes);
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
|
||||||
|
byte[] detailBytes = detailFile.getBytes();
|
||||||
|
bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(pqReport.getDetailPath()));
|
||||||
|
bufferedOutputStream.write(detailBytes);
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// 保存文件
|
throw new BusinessException(ReportResponseEnum.FILE_NOT_NULL);
|
||||||
byte[] baseBytes = baseFile.getBytes();
|
|
||||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(pqReport.getBasePath()));
|
|
||||||
bufferedOutputStream.write(baseBytes);
|
|
||||||
bufferedOutputStream.flush();
|
|
||||||
bufferedOutputStream.close();
|
|
||||||
|
|
||||||
byte[] detailBytes = detailFile.getBytes();
|
|
||||||
bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(pqReport.getDetailPath()));
|
|
||||||
bufferedOutputStream.write(detailBytes);
|
|
||||||
bufferedOutputStream.flush();
|
|
||||||
|
|
||||||
bufferedOutputStream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据id删除已有的文件
|
* 根据id删除已有的文件
|
||||||
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
private void deleteFile(List<String> ids) {
|
private void deleteFile(List<String> ids) {
|
||||||
@@ -813,7 +818,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
QueryWrapper<PqReport> wrapper = new QueryWrapper();
|
QueryWrapper<PqReport> wrapper = new QueryWrapper();
|
||||||
wrapper.eq("name", reportParam.getName())
|
wrapper.eq("name", reportParam.getName())
|
||||||
.eq("version", reportParam.getVersion())
|
.eq("version", reportParam.getVersion())
|
||||||
.ne("enable", DataStateEnum.DELETED.getCode());
|
.eq("state", DataStateEnum.ENABLE.getCode());
|
||||||
if (isExcludeSelf) {
|
if (isExcludeSelf) {
|
||||||
if (reportParam instanceof ReportParam.UpdateParam) {
|
if (reportParam instanceof ReportParam.UpdateParam) {
|
||||||
wrapper.ne("id", ((ReportParam.UpdateParam) reportParam).getId());
|
wrapper.ne("id", ((ReportParam.UpdateParam) reportParam).getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user