From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 25 六月 2025 11:18:22 +0800
Subject: [PATCH] 验收报告修改

---
 src/main/java/com/whyc/service/ProductBomService.java |  354 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 288 insertions(+), 66 deletions(-)

diff --git a/src/main/java/com/whyc/service/ProductBomService.java b/src/main/java/com/whyc/service/ProductBomService.java
index 24072ee..d688662 100644
--- a/src/main/java/com/whyc/service/ProductBomService.java
+++ b/src/main/java/com/whyc/service/ProductBomService.java
@@ -9,6 +9,7 @@
 import com.whyc.dto.FileDirPath;
 import com.whyc.dto.Response;
 import com.whyc.dto.ZipUtils;
+import com.whyc.mapper.AttachLockMapper;
 import com.whyc.mapper.MaterialMapper;
 import com.whyc.mapper.ProductBomMapper;
 import com.whyc.mapper.ProductMapper;
@@ -16,16 +17,19 @@
 import com.whyc.util.ActionUtil;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.IndexedColors;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.*;
+import java.net.URLEncoder;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
@@ -43,6 +47,9 @@
     @Autowired(required = false)
     private ProductMapper productMapper;
 
+    @Autowired(required = false)
+    private AttachLockMapper attachLockMapper;
+
     @Autowired
     private DocLogService logService;
     //鍥剧焊鍒嗙被妫�绱�
@@ -50,7 +57,7 @@
         PageHelper.startPage(pageCurr,pageSize);
         List list=mapper.searchCadDrawer(productBom);
         PageInfo pageInfo=new PageInfo(list);
-        return  new Response().setII(1,list.size()>0?true:false,pageInfo,"鏁版嵁杩斿洖");
+        return  new Response().setII(1,list.size()>0,pageInfo,"鏁版嵁杩斿洖");
     }
    /* //鍥剧焊鏂囦欢涓嬭浇
     public void downloadCadDrawer(HttpServletRequest req, HttpServletResponse resp, List<ProductBom> boms) {
@@ -76,7 +83,7 @@
         wrapper.eq("sub_code",scode);
         wrapper.last("limit 1");
         ProductBom productBom=mapper.selectOne(wrapper);
-        return new Response().setII(1,productBom!=null?true:false,productBom,"杩斿洖鏁版嵁");
+        return new Response().setII(1,productBom!=null,productBom,"杩斿洖鏁版嵁");
     }
 
     /**鑾峰彇浜у搧鐨勪俊鎭�(涓嶅寘鍚瓙鏂�)*/
@@ -117,7 +124,7 @@
             newBom.setThickness(newBomHis.getThickness());
             newBom.setType(newBomHis.getType());
             newBom.setUnit(newBomHis.getUnit());
-            newBom.setUpUserId(newBomHis.getUpUserId());
+            //newBom.setUpUserId(newBomHis.getUpUserId());
             //newBom.setVersion(newBomHis.getEVersion());
 
             newBomList.add(newBom);
@@ -164,7 +171,57 @@
             e.printStackTrace();
         }
     }
+    //鏂囦欢澶圭殑鎷疯礉
+    public  void copyDir(String sourcePathDir, String newPathDir) {
+        File start = new File(sourcePathDir);
+        File end = new File(newPathDir);
+        if(!start.exists()) {
+            return;
+        }
+        String[] filePath = start.list();//鑾峰彇璇ユ枃浠跺す涓嬬殑鎵�鏈夋枃浠朵互鍙婄洰褰曠殑鍚嶅瓧
+        if(!end.exists()) {
+            end.mkdir();
+        }
+        if(filePath.length>=0){
+            for(String temp : filePath) {
+                //娣诲姞婊¤冻鎯呭喌鐨勬潯浠�
+                if(new File(sourcePathDir + File.separator + temp ).isFile()) {
+                    //涓烘枃浠跺垯杩涜鎷疯礉
+                    copyFile(new File(sourcePathDir + File.separator + temp ), newPathDir );
+                }
+            }
+        }
 
+    }
+    //鏂囦欢澶圭殑鎷疯礉绉婚櫎productId瀵瑰簲鐨勮閿佸畾鐨�
+    public  void copyDirWithOutProductId(String sourcePathDir, String newPathDir,int productId) {
+        File start = new File(sourcePathDir);
+        File end = new File(newPathDir);
+        if(!start.exists()) {
+            return;
+        }
+        String[] filePath = start.list();//鑾峰彇璇ユ枃浠跺す涓嬬殑鎵�鏈夋枃浠朵互鍙婄洰褰曠殑鍚嶅瓧
+        if(!end.exists()) {
+            end.mkdir();
+        }
+        if(filePath.length>=0){
+            for(String temp : filePath) {
+                //娣诲姞婊¤冻鎯呭喌鐨勬潯浠�
+                if(new File(sourcePathDir + File.separator + temp ).isFile()) {
+                    QueryWrapper wrapper=new QueryWrapper();
+                    wrapper.eq("product_id",productId);
+                    wrapper.eq("attach_name",temp);
+                    wrapper.eq("lock_flag",1);
+                    wrapper.last("limit 1");
+                    AttachLock attachLock=attachLockMapper.selectOne(wrapper);
+                    if(attachLock==null){
+                        //涓烘枃浠跺垯杩涜鎷疯礉
+                        copyFile(new File(sourcePathDir + File.separator + temp ), newPathDir );
+                    }
+                }
+            }
+        }
+    }
     public void updateUrl(List<ProductBomApproving> fileBomApprovingList) {
         mapper.updateUrl(fileBomApprovingList);
     }
@@ -185,38 +242,72 @@
         }
         List list=mapper.selectList(wrapper);
         PageInfo pageInfo=new PageInfo(list);
-        return new Response().setII(1,list!=null?true:false,pageInfo,"杩斿洖鏁版嵁");
+        return new Response().setII(1,list!=null,pageInfo,"杩斿洖鏁版嵁");
     }*/
     //浜у搧涓嬭浇(浜у搧id鍜岀増鏈�)
-    public  void downloadProduct(HttpServletRequest req, HttpServletResponse resp, int productId , int version) {
+    public  void downloadProduct(HttpServletRequest req, HttpServletResponse resp, int productId , int version
+       , @RequestParam String oprateReason, @RequestParam String oprateInfo) {
         HSSFWorkbook wb = new HSSFWorkbook();
-        //瀛椾綋鏍煎紡-鍔犵矖
-        HSSFCellStyle cellStyle = wb.createCellStyle();
-        HSSFFont font = wb.createFont();
-        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
-        cellStyle.setFont(font);
         //璇诲彇浜у搧淇℃伅
         QueryWrapper wrapper=new QueryWrapper();
         wrapper.eq("id",productId);
+        wrapper.eq("version",version);
         wrapper.last("limit 1");
         Product product=productMapper.selectOne(wrapper);
         //璇诲彇浜у搧鐨勫瓙浠跺拰鍏宠仈鐨勭墿鏂欎俊鎭�
         List<ProductBom> list=mapper.getBomAndMaterial(productId,version);
-        //澶勭悊
+        //澶勭悊瀛樺湪鍏宠仈鍏崇郴鐨勭墿鏂�
+        List<ProductBom> endList=new ArrayList<>();
+        list.stream().forEach(bom -> {
+            bom.setConnFlag(0);
+            if(bom.getDwgUrl()!=null){
+                QueryWrapper qwrapper=new QueryWrapper();
+                qwrapper.eq("material_id",bom.getMaterialId());
+                qwrapper.eq("attach_name",bom.getDwgUrl().substring(bom.getDwgUrl().lastIndexOf("\\")+1));
+                qwrapper.eq("lock_flag",1);
+                qwrapper.last("limit 1");
+                AttachLock attachLock=attachLockMapper.selectOne(qwrapper);
+                if(attachLock!=null){
+                    bom.setDwgUrl("");
+                }
+            }
+            endList.add(bom);
+            if(bom.getMaterials()!=null&&bom.getMaterials().size()>0){
+                for (Material m:bom.getMaterials()) {
+                    //灏嗙墿鏂欏瓨鏀句负涓�涓猙om涓轰笅杞藉仛鍑嗗
+                    ProductBom copyBom=copyMaterialToBom(m);
+                    endList.add(copyBom);
+                }
+            }
+        });
+        //灏嗘病鏈夌鐞咮OM鐨刣wg鏂囦欢鎷疯礉涓嬭浇
+        String withOutDwg="doc_file/product"+File.separator+product.getParentModel();
+        if(product.getCustomCode()!=null&&!product.getCustomCode().isEmpty()){
+            withOutDwg+=File.separator+product.getCustomCode()+File.separator+version;
+        }else{
+            withOutDwg+=File.separator+"standard"+File.separator+version;
+        }
         //鐢熸垚excel骞跺皢dwg鏂囦欢鏀惧湪鍚屼竴鎶ヤ笅鍘嬬缉
-        creatBomExcel(req,resp,product,list,wb,"bom");
-        //璁板綍鏃ュ織
-        DocUser docUser= ActionUtil.getUser();
-        String operationDetail="鍏蜂綋浜у搧淇℃伅涓�:"+product.toString();
-        String opreationMsg="鎵ц浜嗘渶鏂扮増浜у搧涓嬭浇鎿嶄綔";
-        String terminalIp=req.getRemoteAddr();
-        logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail);
+        creatBomExcel(req,resp,product,endList,wb,withOutDwg,ActionUtil.sdfwithALL.format(product.getVersionTime()),oprateReason,oprateInfo);
     }
+
+
     //鏍规嵁浜у搧淇℃伅鍒涘缓excel琛ㄦ牸骞跺瓨鏀惧湪鎸囧畾鐩綍
-    public void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String type){
+    private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String withOutDwg
+            , String oprateVersion, @RequestParam String oprateReason, @RequestParam String oprateInfo){
         String fileDirName = FileDirPath.getFileDirName();
         String rootFace="";
         String excelName="";
+        String[] titleNames=new String[]{"搴忓垪","姣嶇墿鏂欑紪鐮�","姣嶇墿鏂欏悕绉�","姣嶇墿鏂欏瀷鍙�","绫诲埆","瀛愪欢缂栫爜","瀛愪欢鍚嶇О","瀛愪欢鍨嬪彿"
+                                        ,"鍩烘湰鍗曚綅","瀛愪欢鏁伴噺","鐢熶骇鍟�","灏佽绫诲瀷/鏉愯川","鍏冧欢缂栧彿/鏂欏帤","琛ㄩ潰澶勭悊/鐗╂枡璇︽儏","澶囨敞","鍥剧墖"};
+        //瀛椾綋鏍煎紡-鍔犵矖
+        HSSFCellStyle cellStyle = wb.createCellStyle();
+        cellStyle.setFillForegroundColor(IndexedColors.GOLD.getIndex());//娣诲姞鍓嶆櫙鑹�,鍐呭鐪嬬殑娓呮
+        cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
+        HSSFFont font = wb.createFont();
+        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
+        //font.setColor(HSSFFont.COLOR_RED);
+        cellStyle.setFont(font);
         //鍒涘缓鍗曚釜sheet
         HSSFSheet sheet = wb.createSheet("浜у搧淇℃伅");
         sheet.setColumnWidth(1,5000);
@@ -231,34 +322,25 @@
         //鍥剧墖鍏冪礌
         HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
         int rownum = 1;
-        sheet.createRow(rownum);
-        sheet.getRow(rownum).createCell(1).setCellValue("搴忓垪");
-        sheet.getRow(rownum).createCell(2).setCellValue("姣嶇墿鏂欑紪鐮�");
-        sheet.getRow(rownum).createCell(3).setCellValue("姣嶇墿鏂欏悕绉�");
-        sheet.getRow(rownum).createCell(4).setCellValue("姣嶇墿鏂欏瀷鍙�");
-        sheet.getRow(rownum).createCell(5).setCellValue("绫诲埆");
-        sheet.getRow(rownum).createCell(6).setCellValue("瀛愪欢缂栫爜");
-        sheet.getRow(rownum).createCell(7).setCellValue("瀛愪欢鍚嶇О");
-        sheet.getRow(rownum).createCell(8).setCellValue("瀛愪欢鍨嬪彿");
-        sheet.getRow(rownum).createCell(9).setCellValue("鍩烘湰鍗曚綅");
-        sheet.getRow(rownum).createCell(10).setCellValue("瀛愪欢鏁伴噺");
-        sheet.getRow(rownum).createCell(11).setCellValue("鐢熶骇鍟�");
-        sheet.getRow(rownum).createCell(12).setCellValue("灏佽绫诲瀷/鏉愯川");
-        sheet.getRow(rownum).createCell(13).setCellValue("鍏冧欢缂栧彿/鏂欏帤");
-        sheet.getRow(rownum).createCell(14).setCellValue("琛ㄩ潰澶勭悊/鐗╂枡璇︽儏");
-        sheet.getRow(rownum).createCell(15).setCellValue("澶囨敞");
-        sheet.getRow(rownum).createCell(16).setCellValue("鍥剧墖");
+        HSSFRow row=sheet.createRow(rownum);
+        HSSFCell cell=row.createCell(0);
+        if(titleNames.length>0){
+            for (int i=0;i<titleNames.length;i++) {
+                cell=row.createCell(i+1);
+                cell.setCellValue(titleNames[i]);
+            }
+        }
         //鏋勫缓excel鍚嶇О鍜屽垱寤烘枃浠跺す
         excelName=product.getParentCode()+"_"+product.getParentModel();
         String timeStr= ActionUtil.sdfwithFTP.format(new Date());
-        if(type.equals("pic")){
-            excelName=timeStr;
-        }
         rootFace=fileDirName+File.separator+excelName;
         File destfile = new File(rootFace);
         if(!destfile.exists()) {
             destfile.mkdir();
         }
+        //灏嗘病鏈夌鐞咮OM鐨刣wg鏂囦欢鎷疯礉涓嬭浇
+        withOutDwg=fileDirName+File.separator+withOutDwg;
+        copyDirWithOutProductId(withOutDwg,rootFace,product.getId());
         //灏嗛�変腑鐨勬枃浠跺瓨鍏ユ寚瀹氱洰褰曚笅鎵撳寘涓嬭浇
         if(list!=null&&list.size()>0){
             for (int i=0;i<list.size();i++) {
@@ -268,23 +350,93 @@
                     File sourceFile=new File(fileDirName+ File.separator+dwgUrl);
                     copyFile(sourceFile,rootFace);
                 }
-                rownum=rownum+i+1;
-                Row row=sheet.createRow(rownum);
-                sheet.getRow(rownum).createCell(1).setCellValue(i+1);
-                sheet.getRow(rownum).createCell(2).setCellValue(product.getParentCode());
-                sheet.getRow(rownum).createCell(3).setCellValue(product.getParentName());
-                sheet.getRow(rownum).createCell(4).setCellValue(product.getParentModel());
-                sheet.getRow(rownum).createCell(5).setCellValue(bom.getCategory());
-                sheet.getRow(rownum).createCell(6).setCellValue(bom.getSubCode());
-                sheet.getRow(rownum).createCell(7).setCellValue(bom.getSubName());
-                sheet.getRow(rownum).createCell(8).setCellValue(bom.getSubModel());
-                sheet.getRow(rownum).createCell(9).setCellValue(bom.getUnit()==null?"":bom.getUnit());
-                sheet.getRow(rownum).createCell(10).setCellValue(bom.getQuantity());
-                sheet.getRow(rownum).createCell(11).setCellValue(bom.getProducer()==null?"":bom.getProducer());
-                sheet.getRow(rownum).createCell(12).setCellValue(bom.getMaterial());
-                sheet.getRow(rownum).createCell(13).setCellValue(bom.getThickness());
-                sheet.getRow(rownum).createCell(14).setCellValue(bom.getSurfaceDetail());
-                sheet.getRow(rownum).createCell(15).setCellValue(bom.getNotes());
+                rownum=rownum+1;
+                row=sheet.createRow(rownum);
+                if(bom.getConnFlag()==1){
+                    cell=row.createCell(0);
+                    cell.setCellValue("鏇挎崲浠�");
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(1);
+                    cell.setCellValue(i+1);
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(2);
+                    cell.setCellValue(product.getParentCode());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(3);
+                    cell.setCellValue(product.getParentName());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(4);
+                    cell.setCellValue(product.getParentModel());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(5);
+                    cell.setCellValue(bom.getCategory());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(6);
+                    cell.setCellValue(bom.getSubCode());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(7);
+                    cell.setCellValue(bom.getSubName());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(8);
+                    cell.setCellValue(bom.getSubModel());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(9);
+                    cell.setCellValue(bom.getUnit()==null?"":bom.getUnit());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(10);
+                    cell.setCellValue(bom.getQuantity()==null?"": bom.getQuantity().toString());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(11);
+                    cell.setCellValue(bom.getProducer()==null?"":bom.getProducer());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(12);
+                    cell.setCellValue(bom.getMaterial());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(12);
+                    cell.setCellValue(bom.getThickness());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(13);
+                    cell.setCellValue(bom.getThickness());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(14);
+                    cell.setCellValue(bom.getSurfaceDetail());
+                    cell.setCellStyle(cellStyle);
+
+                    cell=row.createCell(15);
+                    cell.setCellValue(bom.getNotes());
+                    cell.setCellStyle(cellStyle);
+                }else{
+                    row.createCell(1).setCellValue(i+1);
+                    row.createCell(2).setCellValue(product.getParentCode());
+                    row.createCell(3).setCellValue(product.getParentName());
+                    row.createCell(4).setCellValue(product.getParentModel());
+                    row.createCell(5).setCellValue(bom.getCategory());
+                    row.createCell(6).setCellValue(bom.getSubCode());
+                    row.createCell(7).setCellValue(bom.getSubName());
+                    row.createCell(8).setCellValue(bom.getSubModel());
+                    row.createCell(9).setCellValue(bom.getUnit()==null?"":bom.getUnit());
+                    row.createCell(10).setCellValue(bom.getQuantity()==null?"": bom.getQuantity().toString());
+                    row.createCell(11).setCellValue(bom.getProducer()==null?"":bom.getProducer());
+                    row.createCell(12).setCellValue(bom.getMaterial());
+                    row.createCell(13).setCellValue(bom.getThickness());
+                    row.createCell(14).setCellValue(bom.getSurfaceDetail());
+                    row.createCell(15).setCellValue(bom.getNotes());
+                }
                 if((bom.getPictureUrl()!=null)&&(!bom.getPictureUrl().isEmpty())){
                     ByteArrayOutputStream byteArrayOut = null;
                     try {
@@ -332,9 +484,10 @@
             ZipUtils.toZip(rootFace, forootFace,true);
 
             // 杞爜闃叉涔辩爜
-            resp.addHeader("Content-Disposition", "attachment;filename="
+            /*resp.addHeader("Content-Disposition", "attachment;filename="
                     + new String(excelName.getBytes("UTF-8"), "ISO8859-1")
-                    + ".zip");
+                    + ".zip");*/
+            resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode (excelName+".zip", "utf-8"));
             OutputStream out = resp.getOutputStream();
             FileInputStream in = new FileInputStream(rootFace+".zip");
             int len=0;
@@ -352,14 +505,17 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
+        //璁板綍鏃ュ織
+        logService.recordOperationLogDownLoad(ActionUtil.getUser().getId(),ActionUtil.getUser().getName(), UserOperation.TYPE_DOWNLOAD_PRODUCT.getType(),new Date(),req.getRemoteAddr()
+                ,excelName+".zip",rootFace+".zip",oprateReason,oprateInfo,oprateVersion);
     }
     //鏌ヨ鎵�鏈変骇鍝佷腑娌℃湁涓庢寚瀹氭暎瑁呬欢鍏宠仈鐨勫瓙浠�
-    public Response getAllSubWithOutMaterial(int MaterialId) {
-        List<ProductBom> list=mapper.getAllSubWithOutMaterial(MaterialId);
-        return new Response().setII(1,list.size()>0?true:false,list,"杩斿洖鏁版嵁");
+    public Response getAllSubWithOutMaterial(int materialId) {
+        List<ProductBom> list=mapper.getAllSubWithOutMaterial(materialId);
+        return new Response().setII(1,list.size()>0,list,"杩斿洖鏁版嵁");
     }
-    /*//鏍规嵁姣嶆枡鍨嬪彿鏌ヨ瀛愪欢淇℃伅鍙婃湁鏈�鏂扮増鏈叧鑱旂殑鏁h浠朵俊鎭�
-    public Response getSubByMaterialProduct(String parentModel) {
+   //鏍规嵁姣嶆枡鍨嬪彿鏌ヨ瀛愪欢淇℃伅鍙婃湁鏈�鏂扮増鏈叧鑱旂殑鏁h浠朵俊鎭�
+     /*public Response getSubByMaterialProduct(String parentModel) {
         List<ProductBom> list=mapper.getSubByMaterialProduct(parentModel);
         //鏌ヨ鍑哄瓨鍦ㄦ浛鎹㈠叧绯诲緱鏁h浠�
         List<ProductBom> replaceBoms=cponentMapper.getReplaceMaterial(parentModel);
@@ -379,11 +535,77 @@
                     }
             );
         }
-        return new Response().setII(1,list.size()>0?true:false,list,"杩斿洖鏁版嵁");
+        return new Response().setII(1,list.size()>0,list,"杩斿洖鏁版嵁");
     }*/
     //鏍规嵁浜у搧id鏌ヨ瀛愪欢鍙婂叾鍏宠仈鐨勭墿鏂欎俊鎭�
     public Response getBomAndMaterial(int productId,int version) {
         List<ProductBom> list=mapper.getBomAndMaterial(productId,version);
-        return new Response().setII(1,list.size()>0?true:false,list,"杩斿洖鐗╂枡淇℃伅鍙婂叧鑱旂墿鏂�");
+        if(list!=null&&list.size()>0){
+            list.stream().forEach(bom -> {
+                if(bom.getDwgUrl()!=null){
+                    QueryWrapper wrapper=new QueryWrapper();
+                    wrapper.eq("material_id",bom.getMaterialId());
+                    wrapper.eq("attach_name",bom.getDwgUrl().substring(bom.getDwgUrl().lastIndexOf("\\")+1));
+                    wrapper.last("limit 1");
+                    AttachLock attachLock=attachLockMapper.selectOne(wrapper);
+                    if(attachLock!=null){
+                        bom.setDwgUrl("");
+                    }
+                }
+            });
+        }
+        return new Response().setII(1,list.size()>0,list,"杩斿洖鐗╂枡淇℃伅鍙婂叧鑱旂墿鏂�");
+    }
+
+    //灏嗙墿鏂欏瓨鏀句负涓�涓猙om涓轰笅杞藉仛鍑嗗
+    private ProductBom copyMaterialToBom(Material m) {
+        ProductBom bom=new ProductBom();
+        bom.setType(m.getType());
+        //bom.setCategory(m.getCategory());
+        bom.setSubCode(m.getSubCode());
+        bom.setSubName(m.getSubName());
+        bom.setSubModel(m.getSubModel());
+        bom.setUnit(m.getUnit());
+        //bom.setQuantity(m.getQuantity());
+        //bom.setProducer(m.getProducer());
+        //bom.setMaterial(m.getMaterial());
+        //bom.setThickness(m.getThickness());
+        //bom.setSurfaceDetail(m.getSurfaceDetail());
+        //bom.setNotes(m.getNotes());
+        bom.setPictureUrl(m.getPictureUrl());
+        bom.setDwgUrl(m.getDwgUrl());
+        bom.setFileUrl(m.getFileUrl());
+        bom.setCreateDate(m.getCreateDate());
+        bom.setConnFlag(1);
+        return  bom;
+    }
+
+    public void insertBatch(List<ProductBom> productBomList) {
+        mapper.insertBatchSomeColumn(productBomList);
+    }
+
+    public List<ProductBom> getBomByProductId(Integer productId) {
+        QueryWrapper<ProductBom> query = Wrappers.query();
+        query.eq("product_id",productId);
+        return mapper.selectList(query);
+    }
+
+    public void deleteByProductId(Integer productId) {
+        UpdateWrapper<ProductBom> update = Wrappers.update();
+        update.eq("product_id",productId);
+        mapper.delete(update);
+    }
+
+    public List<ProductBom> getListByCodeAndModelList2(List<ProductBom> bomList) {
+        return mapper.getListByCodeAndModelList2(bomList);
+    }
+
+    public List<ProductBom> getEnabledBomListByParentCodeAndCustomCode(String parentCode, String customCode) {
+        return mapper.getEnabledBomListByParentCodeAndCustomCode(parentCode,customCode);
+    }
+
+    public void updateMaterialField2Bom() {
+        List<ProductBom> bomList = mapper.selectListWithMaterialField();
+        mapper.updateMaterialField2BomBatch(bomList);
     }
 }

--
Gitblit v1.9.1