| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.UserOperation; |
| | |
| | | if(!software.getFileName().equals(file1Name.substring(0,file1Name.lastIndexOf(".")))){ |
| | | return new Response().set(1,false,"附件的文件名与软件发布记录excel内的文件名称不一致"); |
| | | } |
| | | Software softExists = getByFilename(software.getFileName()); |
| | | if(softExists != null){ //文件名:规格型号_软件版本,已存在,不能重复上传;这种情况属于追加机型,别处更新 |
| | | return new Response().set(1,false,"文件名称("+softExists.getFileName()+")已存在,不能重复上传"); |
| | | } |
| | | 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(".")); |
| | | //文件重命名(暂不需要,严格遵守名称规则的情况下不会重名) |
| | | //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(); |
| | | String softwareDir = rootFile + "software" + File.separator + software.getOwner()+ File.separator + software.getFileName(); |
| | | String softwareHttpUrl = softwareDir.substring(softwareDir.lastIndexOf("doc_file"+ File.separator + "software")); |
| | | File softwareDirFile = new File(softwareDir); |
| | | if(!softwareDirFile.exists()){ |
| | |
| | | return new Response().set(1,true,"上传完成"); |
| | | } |
| | | |
| | | private Software getByFilename(String fileName) { |
| | | QueryWrapper<Software> query = Wrappers.query(); |
| | | query.eq("file_name",fileName).last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | |
| | | private void insertBatch(List<Software> softwareList){ |
| | | mapper.insertBatchSomeColumn(softwareList); |
| | | } |