From d175d9c401fb97ebe6a580005a8c9ad5fedccb6b Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期一, 29 七月 2024 17:02:41 +0800
Subject: [PATCH] add other method
---
pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java
index 5f13142..84f5689 100644
--- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java
+++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java
@@ -1,5 +1,6 @@
package com.dy.pmsPlatform.product;
+import cn.hutool.core.codec.Base64;
import com.alibaba.excel.util.StringUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.daoOth.OthFileMapper;
@@ -12,6 +13,8 @@
import com.dy.pmsGlobal.pojoOth.OthFile;
import com.dy.pmsGlobal.pojoPlt.PltProduct;
import com.dy.pmsGlobal.pojoPlt.PltProductFile;
+import com.dy.pmsGlobal.util.QrCodeUtil;
+import com.google.zxing.WriterException;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@@ -22,6 +25,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
@@ -72,6 +76,10 @@
@Transactional
public int save(PltProduct p) {
+ //鍒ゆ柇浜у搧涓嶈兘閲嶅悕
+ if (dao.exists(p.name, p.id)) {
+ throw new RuntimeException("浜у搧鍚嶇О閲嶅");
+ }
int flag=0;
do {
p.code = getNextCode();
@@ -106,6 +114,9 @@
@Transactional
public int update(PltProduct p) {
+ if (dao.exists(p.name, p.id)) {
+ throw new RuntimeException("浜у搧鍚嶇О閲嶅");
+ }
int count = dao.updateByPrimaryKeySelective(p);
//鍒犻櫎鏃ф暟鎹�,閲嶆柊鎻掑叆
pfDao.deleteByProId(p.id);
@@ -166,8 +177,7 @@
return;
}
FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
-
- doc.webUrl = fileRestVo.fileWebUrl + file.filePath;
+ doc.webUrl = fileRestVo.fileSysRestUrl + fileRestVo.fileWebDownloadPath + doc.fileId;
doc.orgName = file.orgName;
doc.extName = file.extName;
});
@@ -195,8 +205,16 @@
//鏌ヨ绗﹀悎鏉′欢鐨勮褰�
rsVo.obj = dao.selectSome(params) ;
if(CollectionUtils.isNotEmpty(rsVo.obj)){
- rsVo.obj.forEach(pro->{
- pro = addWebUrl(pro);
+ rsVo.obj.parallelStream().forEach(item->{
+ try {
+ byte[] codes = QrCodeUtil.genQrCode(item.code);
+ item.qrCode = "data:image/jpeg;base64," + Base64.encode(codes);
+ item = addWebUrl(item);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (WriterException e) {
+ e.printStackTrace();
+ }
});
}
return rsVo ;
--
Gitblit v1.8.0