From f5156a92b4f64b496336e6465ff9e76ba6d9c756 Mon Sep 17 00:00:00 2001
From: liuxm <liuxm_a@163.com>
Date: 星期一, 03 六月 2024 08:38:51 +0800
Subject: [PATCH] 组装生产任务计划

---
 pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java |   48 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 13 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 0ee58f1..13089bc 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,7 +13,11 @@
 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;
 import org.apache.dubbo.common.utils.PojoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -20,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;
@@ -118,19 +124,17 @@
             if(param.id !=null){
                 paramDao.updateByPrimaryKeySelective(param);
             }else{
+                param.deleted=false;
                 paramDao.insert(param);
             }
         });
-        saveRel(p, p.processDocuments, "01");
-        saveRel(p, p.userManual, "02");
-        saveRel(p, p.materials, "03");
+        saveRel(p, p.proFiles);
     }
 
-    private void saveRel(PltProduct p, List<PltProductFile> docs, String fileType) {
+    private void saveRel(PltProduct p, List<PltProductFile> docs) {
         docs.forEach(doc -> {
             doc.proId = p.id;
-            doc.fileType = fileType;
-            pfDao.insert(doc);
+            pfDao.insertSelective(doc);
         });
     }
 
@@ -160,13 +164,15 @@
                 pro.imageWebPathZip = fileOperate.getImgFileZipPath(filePathWithWebUrl);
             }
 
-            Stream.concat(
-                     pro.userManual.stream(),
-                     Stream.concat(pro.processDocuments.stream(), pro.materials.stream())
-             )
-             .forEach(doc -> {
-                 String webUrl = getFilePathWithWebUrl(doc.fileId);
-                 doc.webUrl = webUrl;
+            pro.proFiles.stream().forEach(doc -> {
+                 OthFile file = othFileMapper.selectByPrimaryKey(doc.fileId);
+                 if (file == null) {
+                     return;
+                 }
+                 FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
+                 doc.webUrl = fileRestVo.fileSysRestUrl + fileRestVo.fileWebDownloadPath + doc.fileId;
+                 doc.orgName = file.orgName;
+                 doc.extName = file.extName;
              });
         }
         return pro;
@@ -191,6 +197,19 @@
         rsVo.calculateAndSet(itemTotal, params);
         //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
         rsVo.obj = dao.selectSome(params) ;
+        if(CollectionUtils.isNotEmpty(rsVo.obj)){
+            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 ;
     }
 
@@ -224,4 +243,7 @@
     }
 
 
+    public void downloadDoc(HttpServletResponse response) {
+        PltProduct pro=dao.selectByPrimaryKey(Long.valueOf(1));
+    }
 }

--
Gitblit v1.8.0