| | |
| | | Integer nextVersion = currentVersion + 1; |
| | | //产品物料关系迁移 |
| | | //查询生效版本的关联关系 |
| | | List<MaterialProductHistory> mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode, customCode, enabledProduct.getVersion()); |
| | | if(latestProduct.getVersion().intValue() == enabledProduct.getVersion()){ |
| | | //最新版本生效,关联关系版本连着的 |
| | | mphService.updateVersionBatch(mpList); |
| | | }else{ |
| | | //旧版本生效,关联关系版本不连着 |
| | | mpList.forEach(mp->{ |
| | | mp.setSVersion(nextVersion); |
| | | mp.setEVersion(nextVersion); |
| | | }); |
| | | mphService.insertBatch(mpList); |
| | | if(latestProduct!=null &&enabledProduct!=null) { |
| | | List<MaterialProductHistory> mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode, customCode, enabledProduct.getVersion()); |
| | | if (latestProduct.getVersion().intValue() == enabledProduct.getVersion()) { |
| | | //最新版本生效,关联关系版本连着的 |
| | | mphService.updateVersionBatch(mpList); |
| | | } else { |
| | | //旧版本生效,关联关系版本不连着 |
| | | mpList.forEach(mp -> { |
| | | mp.setSVersion(nextVersion); |
| | | mp.setEVersion(nextVersion); |
| | | }); |
| | | mphService.insertBatch(mpList); |
| | | } |
| | | } |
| | | |
| | | //将产品文件复制至正式路径 |
| | |
| | | |
| | | Material temp = new Material(); |
| | | temp.setSubModel(approving.getSubModel()); |
| | | temp.setNotes(CommonUtil.getProjectDir() + File.separator + "doc_file" + File.separator + "material" |
| | | temp.setNotes("doc_file" + File.separator + "material" |
| | | + File.separator + fileFullName); |
| | | materialDwgUrlNameList.add(temp); |
| | | break; |
| | |
| | | String filename = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1, picUrl.length() - 4); |
| | | String fileFullName = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1); |
| | | if(approving.getSubModel().toUpperCase().equals(filename.toUpperCase())){ |
| | | approving.setPictureUrl(CommonUtil.getProjectDir() + File.separator + "doc_file" + File.separator + "material" |
| | | approving.setPictureUrl("doc_file" + File.separator + "material" |
| | | + File.separator + fileFullName); |
| | | break; |
| | | } |
| | |
| | | String dwgName = materialUrl.substring(materialUrl.lastIndexOf(File.separator) + 1, materialUrl.length() - 4); |
| | | try { |
| | | FileCopyUtils.copy(new File(materialUrl),new File(materialDir+File.separator+dwgName+".dwg")); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | |
| | | picUrlList.forEach(picUrl->{ |
| | | String picFullName = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1); |
| | | try { |
| | | FileCopyUtils.copy(new File(picUrl),new File(materialDir+File.separator+picFullName)); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | bom.setThickness(approving.getThickness()); |
| | | bom.setType(approving.getType()); |
| | | bom.setUnit(approving.getUnit()); |
| | | bom.setUpUserId(approving.getUpUserId()); |
| | | //bom.setUpUserId(approving.getUpUserId()); |
| | | bom.setVersion(nextVersion); |
| | | |
| | | bomHistory.setProductId(productHistory.getId()); |
| | |
| | | bomHistory.setThickness(approving.getThickness()); |
| | | bomHistory.setType(approving.getType()); |
| | | bomHistory.setUnit(approving.getUnit()); |
| | | bomHistory.setUpUserId(approving.getUpUserId()); |
| | | //bomHistory.setUpUserId(approving.getUpUserId()); |
| | | bomHistory.setVersion(nextVersion); |
| | | |
| | | productBomHistoryList.add(bomHistory); |
| | |
| | | temp.setNotes(approving.getNotes()); |
| | | temp.setPictureUrl(approving.getPictureUrl()); |
| | | temp.setProducer(approving.getProducer()); |
| | | temp.setQuantity(approving.getQuantity()); |
| | | //TODO quantity |
| | | //temp.setQuantity(approving.getQuantity()); |
| | | temp.setStatus(1); |
| | | temp.setSubCode(approving.getSubCode()); |
| | | temp.setSubModel(approving.getSubModel()); |
| | |
| | | mService.insertBatch(materialList); |
| | | } |
| | | //将dwg图纸,全部更新到对应的记录url中 |
| | | mService.updateDwgUrl(materialDwgUrlNameList); |
| | | if(materialDwgUrlNameList.size()!=0) { |
| | | mService.updateDwgUrl(materialDwgUrlNameList); |
| | | } |
| | | /*List<ProductBomApproving> fileBomApprovingList = approvingList.stream() |
| | | .filter(productBomApproving -> |
| | | productBomApproving.getPictureUrl() != null || productBomApproving.getDwgUrl() != null |
| | |
| | | //区分是新增还是删除 |
| | | Integer materialId = approvingList.get(0).getMaterialId(); |
| | | if(materialId==null) { //新增 |
| | | String fileUrl = approvingList.get(0).getFileUrl(); |
| | | File file = new File(fileUrl); |
| | | |
| | | List<String> fileUrlList = new LinkedList<>(); |
| | | List<String> dwgUrlList = null; |
| | | List<String> materialUrlList = new LinkedList<>(); |
| | | List<Material> materialDwgUrlNameList = new LinkedList<>(); |
| | | |
| | | fileUrlList = FileUtil.getStaticFilePath(file,fileUrlList); |
| | | dwgUrlList = fileUrlList.stream().filter(url->url.contains(".dwg")).collect(Collectors.toList()); |
| | | //图纸与物料model对应,则图纸需要保留并转移到正式文件夹 |
| | | //同时,保留图纸对应的物料model和正式文件夹中的http url |
| | | dwgUrlList.forEach(dwgUrl-> { |
| | | approvingList.forEach(approving -> { |
| | | String filename = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1, dwgUrl.length() - 4); |
| | | String fileFullName = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1); |
| | | if (approving.getSubModel().toUpperCase().equals(filename.toUpperCase())) { |
| | | materialUrlList.add(dwgUrl); |
| | | |
| | | Material temp = new Material(); |
| | | temp.setSubModel(approving.getSubModel()); |
| | | temp.setNotes("doc_file" + File.separator + "material" |
| | | + File.separator + fileFullName); |
| | | materialDwgUrlNameList.add(temp); |
| | | } |
| | | }); |
| | | }); |
| | | String projectDir = CommonUtil.getProjectDir(); |
| | | String materialDir = projectDir + File.separator + "doc_file" + File.separator + "material"; |
| | | File materialFile = new File(materialDir); |
| | | if(!materialFile.exists()){ |
| | | materialFile.mkdirs(); |
| | | } |
| | | |
| | | materialUrlList.forEach(materialUrl->{ |
| | | String dwgName = materialUrl.substring(materialUrl.lastIndexOf(File.separator) + 1, materialUrl.length() - 4); |
| | | try { |
| | | FileCopyUtils.copy(new File(materialUrl),new File(materialDir+File.separator+dwgName+".dwg")); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | //将物料从审批表中转移到正式表 |
| | | approvingList.forEach(approve -> { |
| | | Material material = new Material(); |
| | |
| | | material.setSubName(approve.getSubName()); |
| | | material.setSubModel(approve.getSubModel()); |
| | | material.setUnit(approve.getUnit()); |
| | | material.setQuantity(approve.getQuantity()); |
| | | //TODO quantity |
| | | //material.setQuantity(approve.getQuantity()); |
| | | material.setProducer(approve.getProducer()); |
| | | material.setNotes(approve.getNotes()); |
| | | material.setCreateDate(new Date()); |
| | | material.setStatus(1); |
| | | materialDwgUrlNameList.forEach(materialDwgUrlName->{ |
| | | if(materialDwgUrlName.getSubModel().equals(approve.getSubModel())){ |
| | | material.setDwgUrl(materialDwgUrlName.getDwgUrl()); |
| | | } |
| | | }); |
| | | materialList.add(material); |
| | | }); |
| | | mService.insertBatch(materialList); |