| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.UserOperation; |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.ZipUtils; |
| | | import com.whyc.mapper.ProductBomMapper; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.ProductBom; |
| | | import com.whyc.pojo.ProductBomApproving; |
| | | import com.whyc.pojo.ProductBomHistory; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private ProductBomMapper mapper; |
| | | |
| | | @Autowired |
| | | private DocLogService logService; |
| | | //图纸分类检索 |
| | | public Response searchCadDrawer(ProductBom productBom,int pageCurr,int pageSize) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | |
| | | return new Response().setII(1,list.size()>0?true:false,pageInfo,"数据返回"); |
| | | } |
| | | //图纸文件下载 |
| | | public void downloadCadDrawer(HttpServletRequest req, HttpServletResponse resp) { |
| | | public void downloadCadDrawer(HttpServletRequest req, HttpServletResponse resp, ArrayList<String> pictureUrls) { |
| | | String fileDirName = FileDirPath.getFileDirName(); |
| | | String rootFace=fileDirName+ File.separator+"face"; |
| | | String rootFace=fileDirName+ File.separator+"downLoad"; |
| | | String pictureName=""; |
| | | //将选中的文件存入指定目录下打包下载 |
| | | if(pictureUrls!=null&&pictureUrls.size()>0){ |
| | | for (String picUrl:pictureUrls) { |
| | | pictureName+=picUrl.substring(picUrl.lastIndexOf("\\")+1)+","; |
| | | File sourceFile=new File(fileDirName+ File.separator+picUrl); |
| | | copyFile(sourceFile,rootFace); |
| | | } |
| | | } |
| | | String timeStr= ActionUtil.sdfwithFTP.format(new Date()); |
| | | try { |
| | | File file=new File(rootFace+".zip"); |
| | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //记录日志 |
| | | DocUser docUser= ActionUtil.getUser(); |
| | | String operationDetail="具体图纸为:"+pictureName.substring(0,pictureName.lastIndexOf(",")); |
| | | String opreationMsg="执行了文件打包下载操作"; |
| | | String terminalIp=req.getRemoteAddr(); |
| | | logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail); |
| | | |
| | | } |
| | | //根据子件code获取最终的信息 |
| | | public Response getBomBySubcode(String scode) { |
| | |
| | | newBom.setThickness(newBomHis.getThickness()); |
| | | newBom.setType(newBomHis.getType()); |
| | | newBom.setUnit(newBomHis.getUnit()); |
| | | newBom.setUpUser(newBomHis.getUpUser()); |
| | | newBom.setUpUserId(newBomHis.getUpUserId()); |
| | | newBom.setVersion(newBomHis.getEVersion()); |
| | | |
| | | newBomList.add(newBom); |
| | | }); |
| | | mapper.insertBatchSomeColumn(newBomList); |
| | | } |
| | | |
| | | //将选中的文件存入指定目录下 |
| | | public void copyFile(File source,String dest ){ |
| | | //创建目的地文件夹 |
| | | File destfile = new File(dest); |
| | | if(!destfile.exists()) { |
| | | destfile.mkdir(); |
| | | } |
| | | //source是文件,则用字节输入输出流复制文件 |
| | | try { |
| | | if(source.isFile()){ |
| | | FileInputStream fis = new FileInputStream(source); |
| | | //创建新的文件,保存复制内容,文件名称与源文件名称一致 |
| | | File dfile = new File(dest+File.separator+source.getName()); |
| | | if(!dfile.exists()){ |
| | | dfile.createNewFile(); |
| | | } |
| | | FileOutputStream fos = new FileOutputStream(dfile); |
| | | // 读写数据 |
| | | // 定义数组 |
| | | byte[] b = new byte[1024]; |
| | | // 定义长度 |
| | | int len; |
| | | // 循环读取 |
| | | while ((len = fis.read(b))!=-1) { |
| | | // 写出数据 |
| | | fos.write(b, 0 , len); |
| | | } |
| | | //关闭资源 |
| | | fos.close(); |
| | | fis.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void updateUrl(List<ProductBomApproving> fileBomApprovingList) { |
| | | mapper.updateUrl(fileBomApprovingList); |
| | | } |
| | | } |