|
@@ -4,8 +4,8 @@ import cn.hutool.core.io.IoUtil;
|
|
import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.shopsettlement.vo.ShopSettlementRespVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.shopsettlement.vo.ShopSettlementRespVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.shopsettlement.vo.ShopSettlementSaveReqVO;
|
|
import cn.newfeifan.mall.module.distri.controller.admin.shopsettlement.vo.ShopSettlementSaveReqVO;
|
|
|
|
+import cn.newfeifan.mall.module.distri.dal.dataobject.shopsettlement.ShopSettlementDO;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.shopsettlement.data.ShopSettlementErrorData;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.shopsettlement.data.ShopSettlementErrorData;
|
|
-import cn.newfeifan.mall.module.distri.dal.dataobject.shopsettlement.data.ShopSettlementPDFData;
|
|
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.shopsettlement.file.BufferedImageMultipartFile;
|
|
import cn.newfeifan.mall.module.distri.dal.dataobject.shopsettlement.file.BufferedImageMultipartFile;
|
|
import cn.newfeifan.mall.module.distri.enums.PtSettlemntStatusEnum;
|
|
import cn.newfeifan.mall.module.distri.enums.PtSettlemntStatusEnum;
|
|
import cn.newfeifan.mall.module.distri.service.shopsettlement.ShopSettlementService;
|
|
import cn.newfeifan.mall.module.distri.service.shopsettlement.ShopSettlementService;
|
|
@@ -122,7 +122,7 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
}
|
|
}
|
|
|
|
|
|
// 获取选择日期,店铺的结算信息
|
|
// 获取选择日期,店铺的结算信息
|
|
- List<ShopSettlementPDFData> shopSettList = shopSettlementService.selectListByPtId(id);
|
|
|
|
|
|
+ List<ShopSettlementDO> shopSettList = shopSettlementService.selectListByPtId(id);
|
|
|
|
|
|
if (shopSettList.isEmpty()) {
|
|
if (shopSettList.isEmpty()) {
|
|
ErrorCode ERROR = new ErrorCode(1_002_030_027, "选择的行中没有结算单记录");
|
|
ErrorCode ERROR = new ErrorCode(1_002_030_027, "选择的行中没有结算单记录");
|
|
@@ -140,6 +140,11 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
// 加载指定路径的PDF文档
|
|
// 加载指定路径的PDF文档
|
|
PDDocument document = PDDocument.load(tempFile.toFile());
|
|
PDDocument document = PDDocument.load(tempFile.toFile());
|
|
|
|
|
|
|
|
+ if(document.getNumberOfPages() == 0){
|
|
|
|
+ ErrorCode ERROR = new ErrorCode(1_002_030_028, "选择的文件是空的");
|
|
|
|
+ throw exception(ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
// 创建PDF渲染器,用于将PDF页面渲染为图像
|
|
// 创建PDF渲染器,用于将PDF页面渲染为图像
|
|
PDFRenderer pdfRenderer = new PDFRenderer(document);
|
|
PDFRenderer pdfRenderer = new PDFRenderer(document);
|
|
|
|
|
|
@@ -182,13 +187,13 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
// 判断备注的账单日期是否与结算单为同一天
|
|
// 判断备注的账单日期是否与结算单为同一天
|
|
String time = getOrderTime(pageText);
|
|
String time = getOrderTime(pageText);
|
|
if (time != null && !time.isEmpty()) {
|
|
if (time != null && !time.isEmpty()) {
|
|
- for (ShopSettlementPDFData shopSettlementPDFData : shopSettList) {
|
|
|
|
|
|
+ for (ShopSettlementDO shopSettlement : shopSettList) {
|
|
// 判断日期是否同样
|
|
// 判断日期是否同样
|
|
- isSameDate(shopSettlementPDFData, formatter, time);
|
|
|
|
|
|
+ isSameDate(shopSettlement, formatter, time);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for (ShopSettlementPDFData shopSettlementPDFData : shopSettList) {
|
|
|
|
|
|
+ for (ShopSettlementDO shopSettlement : shopSettList) {
|
|
// 账号
|
|
// 账号
|
|
String accountNumber = getErrorAccountNumber(pageText, false);
|
|
String accountNumber = getErrorAccountNumber(pageText, false);
|
|
// 户名
|
|
// 户名
|
|
@@ -196,9 +201,9 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
// 金额
|
|
// 金额
|
|
String money = getMoney(pageText);
|
|
String money = getMoney(pageText);
|
|
|
|
|
|
- if (shopSettlementPDFData.getShop().getAccountNumber().equals(accountNumber) &&
|
|
|
|
- shopSettlementPDFData.getShop().getAccountName().equals(accountName) &&
|
|
|
|
- shopSettlementPDFData.getShopTotalHighAmount().divide(new BigDecimal("100"), 2, RoundingMode.FLOOR).toString().equals(money)) {
|
|
|
|
|
|
+ if (shopSettlement.getAccountNumber().equals(accountNumber) &&
|
|
|
|
+ shopSettlement.getAccountName().equals(accountName) &&
|
|
|
|
+ shopSettlement.getShopTotalHighAmount().divide(new BigDecimal("100"), 2, RoundingMode.FLOOR).toString().equals(money)) {
|
|
|
|
|
|
BufferedImage image = pdfRenderer.renderImageWithDPI(pageIndex, 300);
|
|
BufferedImage image = pdfRenderer.renderImageWithDPI(pageIndex, 300);
|
|
int desiredHeight = 1200; // 设定你想要的高度
|
|
int desiredHeight = 1200; // 设定你想要的高度
|
|
@@ -231,7 +236,7 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
// 上传文件
|
|
// 上传文件
|
|
String fileUrl = fileService.createFile(file.getOriginalFilename(), null, IoUtil.readBytes(file.getInputStream()));
|
|
String fileUrl = fileService.createFile(file.getOriginalFilename(), null, IoUtil.readBytes(file.getInputStream()));
|
|
|
|
|
|
- ShopSettlementSaveReqVO bean = BeanUtils.toBean(shopSettlementPDFData, ShopSettlementSaveReqVO.class);
|
|
|
|
|
|
+ ShopSettlementSaveReqVO bean = BeanUtils.toBean(shopSettlement, ShopSettlementSaveReqVO.class);
|
|
bean.setAttachment(fileUrl);
|
|
bean.setAttachment(fileUrl);
|
|
|
|
|
|
// 保存修改结算单
|
|
// 保存修改结算单
|
|
@@ -245,13 +250,13 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
|
|
|
|
for (ShopSettlementErrorData shopSettlementErrorData : errorList) {
|
|
for (ShopSettlementErrorData shopSettlementErrorData : errorList) {
|
|
|
|
|
|
- for (ShopSettlementPDFData shopSettlementPDFData : shopSettList) {
|
|
|
|
|
|
+ for (ShopSettlementDO shopSettlement : shopSettList) {
|
|
|
|
|
|
- if (shopSettlementPDFData.getShop().getAccountNumber().equals(shopSettlementErrorData.getAccountNumber()) &&
|
|
|
|
- shopSettlementPDFData.getShop().getAccountName().equals(shopSettlementErrorData.getAccountName()) &&
|
|
|
|
- shopSettlementPDFData.getShopTotalHighAmount().divide(new BigDecimal("100"), 2, RoundingMode.FLOOR).toString().equals(shopSettlementErrorData.getMoney())
|
|
|
|
|
|
+ if (shopSettlement.getAccountNumber().equals(shopSettlementErrorData.getAccountNumber()) &&
|
|
|
|
+ shopSettlement.getAccountName().equals(shopSettlementErrorData.getAccountName()) &&
|
|
|
|
+ shopSettlement.getShopTotalHighAmount().divide(new BigDecimal("100"), 2, RoundingMode.FLOOR).toString().equals(shopSettlementErrorData.getMoney())
|
|
) {
|
|
) {
|
|
- ShopSettlementSaveReqVO bean = BeanUtils.toBean(shopSettlementPDFData, ShopSettlementSaveReqVO.class);
|
|
|
|
|
|
+ ShopSettlementSaveReqVO bean = BeanUtils.toBean(shopSettlement, ShopSettlementSaveReqVO.class);
|
|
bean.setAttachment(null);
|
|
bean.setAttachment(null);
|
|
|
|
|
|
shopSettlementErrorData.setShopSettlement(BeanUtils.toBean(bean, ShopSettlementRespVO.class));
|
|
shopSettlementErrorData.setShopSettlement(BeanUtils.toBean(bean, ShopSettlementRespVO.class));
|
|
@@ -263,8 +268,8 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
}
|
|
}
|
|
|
|
|
|
boolean status = true;
|
|
boolean status = true;
|
|
- for (ShopSettlementPDFData shopSettlementPDFData : shopSettList) {
|
|
|
|
- if (shopSettlementPDFData.getAttachment() == null) {
|
|
|
|
|
|
+ for (ShopSettlementDO shopSettlement : shopSettList) {
|
|
|
|
+ if (shopSettlement.getAttachment() == null) {
|
|
status = false;
|
|
status = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -287,7 +292,12 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
// 关闭PDF文档
|
|
// 关闭PDF文档
|
|
document.close();
|
|
document.close();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- ErrorCode ERROR = new ErrorCode(1_002_030_027, "处理PDF文件异常: " + e.getMessage());
|
|
|
|
|
|
+ String message = e.getMessage();
|
|
|
|
+ if(e.getMessage().equals("String index out of range: -1")){
|
|
|
|
+ message = "上传的PDF文件内容不正确!";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ErrorCode ERROR = new ErrorCode(1_002_030_027, "处理PDF文件异常: " + message);
|
|
throw exception(ERROR);
|
|
throw exception(ERROR);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -297,13 +307,13 @@ public class PtSettlementServiceImpl implements PtSettlementService {
|
|
/**
|
|
/**
|
|
* 判断备注的账单日期是否与结算单为同一天
|
|
* 判断备注的账单日期是否与结算单为同一天
|
|
*
|
|
*
|
|
- * @param shopSettlementPDFData 结算单
|
|
|
|
|
|
+ * @param shopSettlement 结算单
|
|
* @param formatter 日期格式
|
|
* @param formatter 日期格式
|
|
* @param time 日期
|
|
* @param time 日期
|
|
*/
|
|
*/
|
|
- private void isSameDate(ShopSettlementPDFData shopSettlementPDFData, DateTimeFormatter formatter, String time) {
|
|
|
|
|
|
+ private void isSameDate(ShopSettlementDO shopSettlement, DateTimeFormatter formatter, String time) {
|
|
// 使用定义的格式器格式化LocalDateTime对象
|
|
// 使用定义的格式器格式化LocalDateTime对象
|
|
- String formattedDate = shopSettlementPDFData.getCreateTime().minusDays(1).format(formatter);
|
|
|
|
|
|
+ String formattedDate = shopSettlement.getCreateTime().minusDays(1).format(formatter);
|
|
|
|
|
|
if (!time.equals(formattedDate)) {
|
|
if (!time.equals(formattedDate)) {
|
|
ErrorCode ERROR = new ErrorCode(1_002_030_028, "上传的PDF文件中有回执单日期与结算单日期不同!");
|
|
ErrorCode ERROR = new ErrorCode(1_002_030_028, "上传的PDF文件中有回执单日期与结算单日期不同!");
|