| | |
| | | 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; |
| | |
| | | import com.whyc.util.ActionUtil; |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.ClientAnchor; |
| | | 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; |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private ProductMapper productMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private AttachLockMapper attachLockMapper; |
| | | |
| | | @Autowired |
| | | private DocLogService logService; |
| | |
| | | } |
| | | |
| | | } |
| | | //文件夹的拷贝移除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); |
| | | } |
| | |
| | | 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()) { |
| | |
| | | ,"基本单位","子件数量","生产商","封装类型/材质","元件编号/料厚","表面处理/物料详情","备注","图片"}; |
| | | //字体格式-加粗 |
| | | 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); |
| | | //font.setColor(HSSFFont.COLOR_RED); |
| | | cellStyle.setFont(font); |
| | | //创建单个sheet |
| | | HSSFSheet sheet = wb.createSheet("产品信息"); |
| | |
| | | } |
| | | //将没有管理BOM的dwg文件拷贝下载 |
| | | withOutDwg=fileDirName+File.separator+withOutDwg; |
| | | copyDir(withOutDwg,rootFace); |
| | | copyDirWithOutProductId(withOutDwg,rootFace,product.getId()); |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i=0;i<list.size();i++) { |
| | |
| | | BufferedImage bufferImg = ImageIO.read(new FileInputStream(new File(fileDirName+File.separator+bom.getPictureUrl()))); |
| | | ImageIO.write(bufferImg, "png", byteArrayOut); |
| | | //anchor主要用于设置图片的属性 |
| | | HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) 16, rownum+i+1, (short) 16, rownum+i+1); |
| | | HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) 16, rownum, (short) 16, rownum); |
| | | anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); |
| | | //插入图片 |
| | | patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); |
| | |
| | | //根据产品id查询子件及其关联的物料信息 |
| | | public Response getBomAndMaterial(int productId,int version) { |
| | | List<ProductBom> list=mapper.getBomAndMaterial(productId,version); |
| | | 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,"返回物料信息及关联物料"); |
| | | } |
| | | |
| | |
| | | public List<ProductBom> getEnabledBomListByParentCodeAndCustomCode(String parentCode, String customCode) { |
| | | return mapper.getEnabledBomListByParentCodeAndCustomCode(parentCode,customCode); |
| | | } |
| | | |
| | | } |