| | |
| | | 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) { |
| | |
| | | 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,"返回数据"); |
| | | } |
| | | |
| | | /**获取产品的信息(不包含子料)*/ |
| | |
| | | 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 ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | public void updateUrl(List<ProductBomApproving> fileBomApprovingList) { |
| | | mapper.updateUrl(fileBomApprovingList); |
| | | } |
| | |
| | | } |
| | | 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) { |
| | | 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); |
| | |
| | | } |
| | | } |
| | | }); |
| | | //将没有管理BOM的dwg文件拷贝下载 |
| | | 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,endList,wb,"bom"); |
| | | creatBomExcel(req,resp,product,endList,wb,"bom",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){ |
| | | private void creatBomExcel(HttpServletRequest req, HttpServletResponse resp,Product product,List list, HSSFWorkbook wb,String type,String withOutDwg){ |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=""; |
| | | String excelName=""; |
| | | //字体格式-加粗 |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | 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); |
| | |
| | | if(!destfile.exists()) { |
| | | destfile.mkdir(); |
| | | } |
| | | //将没有管理BOM的dwg文件拷贝下载 |
| | | withOutDwg=fileDirName+File.separator+withOutDwg; |
| | | copyDir(withOutDwg,rootFace); |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i=0;i<list.size();i++) { |
| | |
| | | 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()); |
| | |
| | | } |
| | | } |
| | | //查询所有产品中没有与指定散装件关联的子件 |
| | | 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,"返回数据"); |
| | | } |
| | | //根据母料型号查询子件信息及有最新版本关联的散装件信息 |
| | | /*public Response getSubByMaterialProduct(String parentModel) { |
| | |
| | | } |
| | | ); |
| | | } |
| | | 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,"返回物料信息及关联物料"); |
| | | return new Response().setII(1,list.size()>0,list,"返回物料信息及关联物料"); |
| | | } |
| | | |
| | | //将物料存放为一个bom为下载做准备 |
| | |
| | | bom.setCreateDate(m.getCreateDate()); |
| | | 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); |
| | | } |
| | | } |