| | |
| | | if (file != null && file.size() > 0) { |
| | | for (int i = 0; i < file.size(); i++) { |
| | | MultipartFile multipartFile = file.get(i); |
| | | String fileName = multipartFile.getOriginalFilename(); |
| | | //String fileName = multipartFile.getOriginalFilename(); |
| | | //将fileName中可能存在的,去掉 |
| | | fileName = fileName.replace(",",""); |
| | | String filePath = fileDirPath + File.separator + timeFormat+"_"+fileName; |
| | | //fileName = fileName.replace(",",""); |
| | | String filePath = fileDirPath + File.separator + spare.getName()+"_"+spare.getModel()+"_"+spare.getVersion() + "_" + (i+1) + "_"+ timeFormat+".png"; |
| | | |
| | | multipartFile.transferTo(new File(filePath)); |
| | | String split = "pis_file"+File.separator+"deviceSpare"; |
| | |
| | | |
| | | } |
| | | |
| | | //第七列为图片-浮动式图片 TODO 待处理 处理已存在的物料 |
| | | //第七列为图片-浮动式图片 |
| | | //获取绘图对象中的所有图形 |
| | | XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch(); |
| | | if (drawing == null) { |
| | |
| | | if (!fileDir.exists()) { |
| | | fileDir.mkdirs(); |
| | | } |
| | | String filePath = fileDirPath + File.separator + timeFormat+"_"+spare.getName()+"_"+spare.getModel()+"_"+spare.getVersion()+".png"; |
| | | String filePath = fileDirPath + File.separator + spare.getName()+"_"+spare.getModel()+"_"+spare.getVersion() + "_"+ timeFormat+".png"; |
| | | |
| | | // 保存图片到本地 |
| | | try (FileOutputStream fos = new FileOutputStream(filePath)) { |
| | |
| | | //查询库中的所有设备器件 |
| | | List<DeviceSpare> deviceSpareListInDB = mapper.selectList((Wrapper<DeviceSpare>) CommonUtil.nullObject); |
| | | for (DeviceSpare spare : spareList){ |
| | | boolean isExist = false; |
| | | for (DeviceSpare spareInDB : deviceSpareListInDB){ |
| | | if (spare.getName().equals(spareInDB.getName()) |
| | | && spare.getModel().equals(spareInDB.getModel()) |
| | |
| | | && spare.getType().equals(spareInDB.getType()) |
| | | && spare.getSupplier().equals(spareInDB.getSupplier()) |
| | | ){ |
| | | isExist = true; |
| | | spare.setId(spareInDB.getId()); |
| | | spare.setQuantity(spareInDB.getQuantity()+spare.getQuantity()); |
| | | if (spare.getPictureUrl() != null && spareInDB.getPictureUrl()!=null){ |
| | | spare.setPictureUrl(spareInDB.getPictureUrl()+","+spare.getPictureUrl()); |
| | | } |
| | | spareListUpdate.add(spare); |
| | | |
| | | }else{ |
| | | } |
| | | } |
| | | if(!isExist){ |
| | | //不存在则新增 |
| | | spareListNew.add(spare); |
| | | } |
| | | } |
| | | //更新 |
| | | if(spareListUpdate.size()>0) { |
| | | updateQuantityAndPictureBatch(spareListUpdate); |
| | | } |
| | | //更新TODO |
| | | //新增 |
| | | if(spareListNew.size()>0) { |
| | | addBatch(spareListNew); |
| | | } |
| | | |
| | | //addBatch(spareList); |
| | | return new Response().setII(1,"导入完成"); |
| | | } |
| | | |
| | | return null; |
| | | private void updateQuantityAndPictureBatch(List<DeviceSpare> spareListUpdate) { |
| | | mapper.updateQuantityAndPictureBatch(spareListUpdate); |
| | | } |
| | | } |