| | |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.SoftwareMapper; |
| | | import com.whyc.pojo.AttachLock; |
| | | import com.whyc.pojo.DocUser; |
| | | import com.whyc.pojo.Software; |
| | | import com.whyc.util.ActionUtil; |
| | |
| | | //取第一个sheet表 |
| | | Sheet sheet = workbook.getSheetAt(0); |
| | | int lastRowNum = sheet.getLastRowNum(); |
| | | //校准lastRowNum |
| | | for (int i = 8; i <= lastRowNum; i++) { |
| | | if(sheet.getRow(i).getCell(1).getStringCellValue().equals("发布说明")){ |
| | | lastRowNum = i; |
| | | break; |
| | | } |
| | | } |
| | | //固定5列 |
| | | short cellNum = 5; |
| | | //取固定部分值 |
| | |
| | | common.setBasedVersion(sheet.getRow(5).getCell(4).getStringCellValue()); |
| | | |
| | | common.setOwner(sheet.getRow(6).getCell(2).getStringCellValue()); |
| | | common.setFilingDate(sheet.getRow(6).getCell(4).getStringCellValue()); |
| | | Cell cellFilingDate = sheet.getRow(6).getCell(4); |
| | | if(cellFilingDate.getCellType() == Cell.CELL_TYPE_NUMERIC){ |
| | | Date dateCellValue = cellFilingDate.getDateCellValue(); |
| | | common.setFilingDate(DateUtil.YYYY_MM_DD.format(dateCellValue)); |
| | | System.out.println(dateCellValue); |
| | | }else { |
| | | cellFilingDate.setCellType(Cell.CELL_TYPE_STRING); |
| | | common.setFilingDate(cellFilingDate.getStringCellValue()); |
| | | } |
| | | //最后一行,取发布说明 |
| | | common.setReleaseNotes(sheet.getRow(lastRowNum).getCell(2).getStringCellValue()); |
| | | |
| | |
| | | //取第3列,第5列 |
| | | Cell cell = sheet.getRow(8 + i).getCell(2); |
| | | cell.setCellType(Cell.CELL_TYPE_STRING); |
| | | software.setApplyMaterialCode(cell.getStringCellValue()); |
| | | String stringCellValue = cell.getStringCellValue(); |
| | | if(!stringCellValue.equals("")) { |
| | | int length = stringCellValue.length(); |
| | | if (length == 9) { |
| | | stringCellValue = "0" + stringCellValue; |
| | | } else if (length < 9) { |
| | | int centerZeroNum = 10 - length - 1; |
| | | StringBuilder centerZeroStr = new StringBuilder(); |
| | | for (int j = 0; j < centerZeroNum; j++) { |
| | | centerZeroStr.append("0"); |
| | | } |
| | | String strFront = stringCellValue.substring(0, 3); |
| | | String strBehind = stringCellValue.substring(3); |
| | | stringCellValue = "0" + strFront + centerZeroStr + strBehind; |
| | | } |
| | | } |
| | | software.setApplyMaterialCode(stringCellValue); |
| | | software.setApplyModel(sheet.getRow(8+i).getCell(4).getStringCellValue()); |
| | | |
| | | softwareList.add(software); |
| | |
| | | |
| | | } |
| | | //查询软件列表的信息 |
| | | public Response getAllSoftware(String fileName,String applyMaterialCode,String applyModel,String owner, int pageCurr, int pageSize) { |
| | | public Response getAllSoftware(Integer lockFlag, String fileName, String applyMaterialCode, String applyModel, String owner, String boardNumber, int pageCurr, int pageSize) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | | List list=mapper.getFileUrl(fileName,applyMaterialCode,applyModel,owner); |
| | | List list=mapper.getFileUrl(lockFlag,fileName,applyMaterialCode,applyModel,owner,boardNumber); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"软件信息返回"); |
| | | } |
| | |
| | | wrapper.eq("id",id); |
| | | wrapper.last("limit 1"); |
| | | Software software=mapper.selectOne(wrapper); |
| | | |
| | | String filename=software.getFileUrl().substring(software.getFileUrl().lastIndexOf("\\")+1); |
| | | 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()+".zip", "utf-8")); |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode (filename, "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 { |
| | | @Transactional |
| | | public Response upload(MultipartFile file1, MultipartFile file2, String fontUpdateTime, List<Software> softwareList) throws IOException { |
| | | String file1Name = file1.getOriginalFilename(); |
| | | String file2Name = file2.getOriginalFilename(); |
| | | Software software = softwareList.get(0); |
| | |
| | | file2.transferTo(new File(softwareDir+File.separator+file2Name)); |
| | | //设置路径 |
| | | for (Software software1:softwareList){ |
| | | software1.setFontUpdateTime(fontUpdateTime); |
| | | software1.setFileUrl(softwareHttpUrl+File.separator+file1Name); |
| | | software1.setExcelUrl(softwareHttpUrl+File.separator+file2Name); |
| | | software1.setCreateTime(date); |
| | | //锁定-专供测试人员才能解锁 |
| | | software1.setLockFlag(-1); |
| | | } |
| | | /* 取消自动锁定原来版本,因为新版本需要进行测试才能使用 |
| | | //锁定原来的所有版本:根据版号和软件类型 |
| | | List<String> materialCodeList = softwareList.stream().map(Software::getApplyMaterialCode).collect(Collectors.toList()); |
| | | lockByBoardNumberAndTypeAndMaterialCode(software.getBoardNumber(),software.getType(),materialCodeList);*/ |
| | | //写入数据库 |
| | | insertBatch(softwareList); |
| | | return new Response().set(1,true,"上传完成"); |
| | | } |
| | | |
| | | private void lockByBoardNumberAndTypeAndMaterialCode(String boardNumber, String type, List<String> materialCodeList) { |
| | | UpdateWrapper<Software> update = Wrappers.update(); |
| | | update.set("lock_flag",1) |
| | | .set("local_reason","软件版本升级") |
| | | .eq("board_number",boardNumber) |
| | | .eq("type",type) |
| | | .in("apply_material_code",materialCodeList); |
| | | mapper.update(null,update); |
| | | } |
| | | |
| | | private Software getByFilename(String fileName) { |
| | |
| | | return new Response().set(1,true,"更新完成"); |
| | | } |
| | | } |
| | | //根据软件id修改软件锁定状态 |
| | | |
| | | /** |
| | | * 根据软件唯一值字段修改软件锁定状态,这里选取fileUrl |
| | | * |
| | | * @param fileUrl |
| | | * @param lockFlag |
| | | * @param localReason |
| | | * @return |
| | | */ |
| | | public Response updateSoftwareLock(String fileUrl,int lockFlag,String localReason) { |
| | | String userName = ActionUtil.getUser().getName(); |
| | | if(lockFlag ==0){ |
| | | //只有李桂华才能解锁 待测试锁定的软件 |
| | | QueryWrapper<Software> query = Wrappers.query(); |
| | | query.eq("file_url",fileUrl).last(" limit 1"); |
| | | Software softwareInDB = mapper.selectOne(query); |
| | | if(softwareInDB.getLockFlag() == -1){ |
| | | if(!userName.equals("李桂华")){ |
| | | return new Response().set(1,false,"无权限解锁 待测试的软件"); |
| | | } |
| | | } |
| | | } |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("lock_flag",lockFlag); |
| | | uwrapper.set("local_reason",localReason); |
| | |
| | | int flag=mapper.update(null,uwrapper); |
| | | return new Response().set(1,flag>0,"锁定/解锁成功"); |
| | | } |
| | | |
| | | } |