| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.ProductBomApproving; |
| | | import com.whyc.pojo.WorksheetMain; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.xml.crypto.Data; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | |
| | | int k = i-2; |
| | | if(k<allPictures.size()){ |
| | | PictureData pictureData = allPictures.get(k); |
| | | //图片存储 |
| | | CommonUtil.getRootFile(); |
| | | bomApproving.setPictureUrl(bomApproving.getSubModel()+"."+pictureData.suggestFileExtension()); |
| | | //图片存储 product_approving/username/2022-07/ |
| | | DocUser user = ActionUtil.getUser(); |
| | | String dateFormat = new SimpleDateFormat("YYYY-MM").format(new Date()); |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | String approvingPath = rootFile + File.separator + "product_approving" + File.separator + user.getName() + File.separator + dateFormat; |
| | | File provingFile = new File(approvingPath); |
| | | if(!provingFile.exists()){ |
| | | provingFile.mkdirs(); |
| | | } |
| | | String suffix = pictureData.suggestFileExtension(); |
| | | String picturePath = approvingPath + File.separator + bomApproving.getSubModel() + File.separator + suffix; |
| | | byte[] data = pictureData.getData(); |
| | | FileOutputStream fileOutputStream = null; |
| | | try { |
| | | File pictureFile = new File(picturePath); |
| | | fileOutputStream = new FileOutputStream(pictureFile); |
| | | fileOutputStream.write(data); |
| | | }finally { |
| | | fileOutputStream.close(); |
| | | } |
| | | bomApproving.setPictureUrl(picturePath); |
| | | } |
| | | }break; |
| | | } |