| | |
| | | //处理存在关联关系的物料 |
| | | List<ProductBom> endList=new ArrayList<>(); |
| | | list.stream().forEach(bom -> { |
| | | bom.setConnFlag(0); |
| | | endList.add(bom); |
| | | if(bom.getMaterials()!=null&&bom.getMaterials().size()>0){ |
| | | for (Material m:bom.getMaterials()) { |
| | |
| | | withOutDwg+=File.separator+"standard"+File.separator+version; |
| | | } |
| | | //生成excel并将dwg文件放在同一报下压缩 |
| | | creatBomExcel(req,resp,product,endList,wb,"bom",withOutDwg); |
| | | creatBomExcel(req,resp,product,endList,wb,withOutDwg); |
| | | //记录日志 |
| | | DocUser docUser= ActionUtil.getUser(); |
| | | String operationDetail="具体产品信息为:"+product.toString(); |
| | |
| | | |
| | | |
| | | //根据产品信息创建excel表格并存放在指定目录 |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String type,String withOutDwg){ |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String withOutDwg){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=""; |
| | | String excelName=""; |
| | | String[] titleNames=new String[]{"序列","母物料编码","母物料名称","母物料型号","类别","子件编码","子件名称","子件型号" |
| | | ,"基本单位","子件数量","生产商","封装类型/材质","元件编号/料厚","表面处理/物料详情","备注","图片"}; |
| | | //字体格式-加粗 |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | HSSFFont font = wb.createFont(); |
| | |
| | | //图片元素 |
| | | 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()) { |
| | |
| | | File sourceFile=new File(fileDirName+ File.separator+dwgUrl); |
| | | copyFile(sourceFile,rootFace); |
| | | } |
| | | Row row=sheet.createRow(rownum+i+1); |
| | | row.setRowStyle(cellStyle); |
| | | sheet.getRow(rownum+i+1).createCell(1).setCellValue(i+1); |
| | | sheet.getRow(rownum+i+1).createCell(2).setCellValue(product.getParentCode()); |
| | | sheet.getRow(rownum+i+1).createCell(3).setCellValue(product.getParentName()); |
| | | sheet.getRow(rownum+i+1).createCell(4).setCellValue(product.getParentModel()); |
| | | sheet.getRow(rownum+i+1).createCell(5).setCellValue(bom.getCategory()); |
| | | sheet.getRow(rownum+i+1).createCell(6).setCellValue(bom.getSubCode()); |
| | | sheet.getRow(rownum+i+1).createCell(7).setCellValue(bom.getSubName()); |
| | | sheet.getRow(rownum+i+1).createCell(8).setCellValue(bom.getSubModel()); |
| | | sheet.getRow(rownum+i+1).createCell(9).setCellValue(bom.getUnit()==null?"":bom.getUnit()); |
| | | sheet.getRow(rownum+i+1).createCell(10).setCellValue(bom.getQuantity()==null?"": bom.getQuantity().toString()); |
| | | sheet.getRow(rownum+i+1).createCell(11).setCellValue(bom.getProducer()==null?"":bom.getProducer()); |
| | | sheet.getRow(rownum+i+1).createCell(12).setCellValue(bom.getMaterial()); |
| | | sheet.getRow(rownum+i+1).createCell(13).setCellValue(bom.getThickness()); |
| | | sheet.getRow(rownum+i+1).createCell(14).setCellValue(bom.getSurfaceDetail()); |
| | | sheet.getRow(rownum+i+1).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 { |
| | |
| | | bom.setDwgUrl(m.getDwgUrl()); |
| | | bom.setFileUrl(m.getFileUrl()); |
| | | bom.setCreateDate(m.getCreateDate()); |
| | | bom.setConnFlag(1); |
| | | return bom; |
| | | } |
| | | |
| | |
| | | update.eq("product_id",productId); |
| | | mapper.delete(update); |
| | | } |
| | | |
| | | public List<ProductBom> getListByCodeAndModelList2(List<ProductBom> bomList) { |
| | | return mapper.getListByCodeAndModelList2(bomList); |
| | | } |
| | | |
| | | public ProductBom getEnabledStandardBomListByParentCode(String parentCode) { |
| | | return mapper.getEnabledStandardBomListByParentCode(parentCode); |
| | | } |
| | | } |