| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.pojo.DocUser; |
| | | import com.whyc.pojo.Software; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| | | import org.apache.poi.ss.usermodel.Cell; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | wrapper.orderByAsc("file_name"); |
| | | wrapper.orderByAsc("version"); |
| | | List list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list.size()>0,list,"软件信息返回"); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"软件信息返回"); |
| | | } |
| | | //根据subcode查询软件列表 |
| | | public Response getSoftBySubCode(String subCode) { |
| | |
| | | try { |
| | | // 转码防止乱码 |
| | | //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1")); |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( software.getFileName(), "utf-8")); |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( software.getFileName()+".zip", "utf-8")); |
| | | OutputStream out = resp.getOutputStream(); |
| | | FileInputStream in = new FileInputStream(fileDirName+File.separator+software.getFileUrl()); |
| | | int len=0; |
| | |
| | | logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail); |
| | | } |
| | | |
| | | public Response upload(MultipartFile file1, MultipartFile file2, List<Software> softwareList) throws IOException { |
| | | String file1Name = file1.getOriginalFilename(); |
| | | String file2Name = file2.getOriginalFilename(); |
| | | Software software = softwareList.get(0); |
| | | Date date = new Date(); |
| | | String dateUnion = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date); |
| | | //文件重命名 |
| | | file1Name = file1Name.substring(0,file1Name.lastIndexOf(".")) + "_" + dateUnion +file1Name.substring(file1Name.lastIndexOf(".")); |
| | | file2Name = file2Name.substring(0,file2Name.lastIndexOf(".")) + "_" + dateUnion +file2Name.substring(file2Name.lastIndexOf(".")); |
| | | //存储路径 |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | String softwareDir = rootFile + "software" + File.separator + software.getOwner() + File.separator + dateUnion; |
| | | String softwareHttpUrl = softwareDir.substring(softwareDir.lastIndexOf("doc_file"+ File.separator + "software")); |
| | | File softwareDirFile = new File(softwareDir); |
| | | if(!softwareDirFile.exists()){ |
| | | softwareDirFile.mkdirs(); |
| | | } |
| | | file1.transferTo(new File(softwareDir+File.separator+file1Name)); |
| | | file2.transferTo(new File(softwareDir+File.separator+file2Name)); |
| | | //设置路径 |
| | | for (Software software1:softwareList){ |
| | | software1.setFileUrl(softwareHttpUrl+File.separator+file1Name); |
| | | software1.setExcelUrl(softwareHttpUrl+File.separator+file2Name); |
| | | software1.setCreateTime(date); |
| | | } |
| | | //写入数据库 |
| | | insertBatch(softwareList); |
| | | return new Response().setII(1,"上传完成"); |
| | | } |
| | | |
| | | private void insertBatch(List<Software> softwareList){ |
| | | mapper.insertBatchSomeColumn(softwareList); |
| | | } |
| | | } |