提交 024f55eb authored 作者: 邓砥奕's avatar 邓砥奕

修改bug

上级 3f901863
package com.tykj.dev.device.file.Controller;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.entity.FileRet;
......@@ -109,7 +106,7 @@ public class FileController {
File file = new File(url + "print/" + fileName);
// 第一步:创建一个document对象。
Document document = new Document();
Document document = new Document(PageSize.A4.rotate());
document.setMargins(0, 0, 0, 0);
// 第二步:
// 创建一个PdfWriter实例,
......@@ -121,10 +118,15 @@ public class FileController {
//转成
// Image.byte()
//多文件上传 图片专程byte 2进制
img.setAlignment(Image.ALIGN_CENTER);
// img.setAlignment(Image.ALIGN_CENTER);
// 根据图片大小设置页面,一定要先设置页面,再newPage(),否则无效
document.setPageSize(new Rectangle(img.getWidth(), img.getHeight()));
// document.setPageSize(new Rectangle(PageSize.A4.getWidth(), PageSize.A4.getHeight()));
document.newPage();
float height = img.getHeight();
float width = img.getWidth();
int percent = getPercent(height, width);
img.setAlignment(Image.MIDDLE);
img.scalePercent(percent);
document.add(img);
}
......@@ -190,4 +192,23 @@ public class FileController {
return new FileRet(originalFilename, url + newName, preview + newName);
}
/**
* 等比压缩,获取压缩百分比
*
* @param height 图片的高度
* @param weight 图片的宽度
* @return 压缩百分比
*/
private static int getPercent(float height, float weight) {
float percent = 0.0F;
if (height > weight) {
percent = PageSize.A4.rotate().getHeight() / height * 100;
} else {
percent = PageSize.A4.rotate().getWidth() / weight * 100;
}
return Math.round(percent);
}
}
......@@ -262,14 +262,15 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
public List<DeviceLibrary> getList(DeviceLibrarySelectVo deviceLibrarySelectVo) {
List<DeviceLibrary> deviceLibraryEntities = deviceLibraryDao.findAll(getSelectSpecification(deviceLibrarySelectVo));
//返回父子结构
Map<Integer, DeviceLibrary> nodeCollect =
deviceLibraryEntities.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
return GetTreeUtils.parseTreeFromDown(
deviceLibraryEntities,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
);
// Map<Integer, DeviceLibrary> nodeCollect =
// deviceLibraryEntities.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
// return GetTreeUtils.parseTreeFromDown(
// deviceLibraryEntities,
// DeviceLibrary::getId,
// deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
// DeviceLibrary::addChildNode
// );
return deviceLibraryEntities.stream().sorted(Comparator.comparing(DeviceLibrary::getLifeStatus)).collect(Collectors.toList());
}
public List<DeviceLibrary> getList2(DeviceLibrarySelectVo deviceLibrarySelectVo) {
......
......@@ -203,6 +203,9 @@ public class PackingLibrary {
@ApiModelProperty(value = "申请数量")
@Transient
private Integer applyNum;
@ApiModelProperty(value = "预分配的装备序列号")
@Transient
private String seq;
public void addChildNode(PackingLibrary packingLibraryEntity) {
childs.add(packingLibraryEntity);
......
......@@ -162,7 +162,7 @@ public class LogAspect {
this.newStatus = this.outPutTask.getBillStatus();
if (this.inputTask.getId() != null) {
for (LogType l : LogType.values()) {
if (l.oldStatus.equals(oldStatus) && l.newStatus.equals(newStatus)) {
if (l.oldStatus.equals(oldStatus) && l.newStatus.equals(newStatus) &&l.businessType.equals(outPutTask.getBusinessType())) {
this.opreation = l.getOperation();
break;
}
......@@ -170,7 +170,7 @@ public class LogAspect {
} else {
this.oldStatus = 0;
for (LogType l : LogType.values()) {
if (l.oldStatus == 0 && l.newStatus.equals(newStatus)) {
if (l.oldStatus == 0 && l.newStatus.equals(newStatus)&&l.businessType.equals(outPutTask.getBusinessType())) {
this.opreation = l.getOperation();
break;
}
......@@ -184,7 +184,7 @@ public class LogAspect {
opreation = this.replaceParam(opreation);
}
if (this.opreation == null) {
log.warn("[业务操作日志]存储失败:找不到旧状态为" + this.oldStatus + ",新状态为" + this.newStatus + "的日志模板");
log.warn("[业务操作日志]存储失败:找不到业务类型为+"+outPutTask.getBusinessType()+",旧状态为" + this.oldStatus + ",新状态为" + this.newStatus + "的日志模板");
} else {
TaskLogBto taskLogBto = new TaskLogBto(this.outPutTask.getId(), this.opreation, this.fileVos);
taskLogService.addLog(taskLogBto);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论