db/lxzn_qlj_nc.sql
ÎļþÌ«´ó pom.xml
@@ -73,6 +73,7 @@ <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.33</version> <scope>runtime</scope> </dependency> src/main/java/com/lxzn/base/controller/ServiceOuterController.java
@@ -43,10 +43,10 @@ @Autowired private IDncPassLogService dncPassLogService; @RequestMapping("/nc") public void fileClientTxtOrNc() { dncPassLogService.fileClientTxtOrNc(); } // @RequestMapping("/nc") // public void fileClientTxtOrNc() { // dncPassLogService.fileClientTxtOrNc(); // } @Value("${serviceIntranet.appIdCheck}") private String appIdCheck; src/main/java/com/lxzn/base/service/IDncPassLogService.java
@@ -17,15 +17,15 @@ * @return */ DncPassLog findDayTime(String dateDay); /** * åéæä»¶ */ void fileClientTxtOrNc(); /** * å é¤åºå®è·¯å¾ä¸è¶ æ¶æä»¶ * @return */ void deleteNcSendFile(); // // /** // * åéæä»¶ // */ // void fileClientTxtOrNc(); // // /** // * å é¤åºå®è·¯å¾ä¸è¶ æ¶æä»¶ // * @return // */ // void deleteNcSendFile(); } src/main/java/com/lxzn/base/service/IReceiveFileService.java
@@ -6,8 +6,8 @@ */ public interface IReceiveFileService { /** * è§£ææ°æ® */ void analysisAndCopyFileRec(); // /** // * è§£ææ°æ® // */ // void analysisAndCopyFileRec(); } src/main/java/com/lxzn/base/service/impl/DncPassLogServiceImpl.java
@@ -79,209 +79,209 @@ return super.baseMapper.findDateTimeDay(dateDay); } @Override @Scheduled(cron = "${fileCron}") public void fileClientTxtOrNc() { SysLogMessageDto message = new SysLogMessageDto(); String host = "127.0.0.1"; if (StringUtils.isNotBlank(serverIp)) { host = serverIp; } String port = "8299"; if (StringUtils.isNotBlank(serverPort)) { port = serverPort; } String username = "admin"; if (StringUtils.isNotBlank(usernameService)) { username = usernameService; } String pwd = "123"; if (StringUtils.isNotBlank(pwdService)) { pwd = pwdService; } //æä»¶æ¬å°å°åï¼æ ¹æ®å°åæ¾å°æä»¶ï¼å°æä»¶è§£æææä»¶æµ String localFilePath = "E:\\test\\a\\"; if (StringUtils.isNotBlank(localFilePathC)) { localFilePath = localFilePathC; } //æä»¶ä¸ä¼ ç®çå°åï¼å°æä»¶ä¸ä¼ å°è¯¥å°å String servicePath = "E:\\test\\b\\"; if (StringUtils.isNotBlank(servicePathS)) { servicePath = servicePathS; } boolean btelnetPort = TelnetUtil.telnetPort(serverIp,Integer.valueOf(serverPort),10); if (!btelnetPort) { System.out.println("æå¡å¨è¿æ¥ï¼ " + serverIp + ":" + serverPort + " å¼å¸¸ï¼" ); return; } //ç¬¬ä¸æ¥ï¼è·åtoken String token = null; try { token = FileClient.getToken(host,port,username,pwd,addressToken); } catch (Throwable throwable) { throwable.printStackTrace(); } //è¥è·åtokenæåï¼åè¿è¡ä¸ä¼ æä»¶æ¥å£è°ç¨ if (token !=null && !token.equals("")){ try { File f3 = new File(localFilePath); File[] files = f3.listFiles(); for (File fi : files){ if (fi.isFile()){ SysLogTypeObjectDto objectName = new SysLogTypeObjectDto(); objectName.setDateTime(DateUtil.format(DateUtil.getNow(),DateUtil.STR_DATE_TIME_SMALL)); objectName.setFileName(fi.getName()); objectName.setFileSize(FileUtil.changeFileFormatKb(String.valueOf(new File(localFilePath).length()))); objectName.setSourceAddress(localFilePath); objectName.setDestination(serverIp);//æå¡ç«¯IP //顺åºå· DncPassLog passLog = getById("num0001"); if (passLog == null) { passLog = new DncPassLog(); passLog.setId("num0001"); passLog.setSequenceNumber(1); objectName.setFileNum(Integer.toString(1)); save(passLog); } else { Integer number = passLog.getSequenceNumber()+1; removeById("num0001"); objectName.setFileNum(Integer.toString(number)); passLog = new DncPassLog(); passLog.setId("num0001"); passLog.setSequenceNumber(number); save(passLog); } InetAddress address = null; try { address = InetAddress.getLocalHost(); String ip = address.getHostAddress(); objectName.setSourceAddress("20.10.17.11");//客æ·ç«¯IP objectName.setAddress(ip); } catch (UnknownHostException e) { objectName.setSourceAddress("127.0.0.1"); objectName.setAddress("127.0.0.1"); } objectName.setDestination(host); objectName.setResult("失败"); //è·åæä¸ªæä»¶ä¸çæææä»¶ String loFilePath = localFilePath + fi.getName(); String servicePathName =servicePath+"//" + fi.getName(); File file = new File(loFilePath); if (file == null || !file.exists()){ objectName.setAbstract1("sm3"); } else { String sm3 = SmUtil.sm3(file); objectName.setAbstract1(sm3); } String b = FileClient.uploadFile(host,port,token,fi.getName(),servicePathName,loFilePath,addressUploadFile); //æä»¶å¤ä»½å é¤ if (b == null) { try { objectName.setResult("失败"); objectName.setTypes("error"); SyslogClient.sendClient(logIp,Integer.valueOf(logPort),objectName.toString()); }catch (Exception e) { return; } } else if ( b.equals("æå")) { //å¤ä»½æ°æ® boolean fCopy = FileUtil.copyNcFile(loFilePath,newFilePathC + "/" + DateUtil.format(DateUtil.getNow(), DateUtil.STR_YEARMONTHDAY) + "/" +fi.getName()); if (fCopy) { FileUtil.deleteNcFile(loFilePath); } else { FileUtil.copyNcFile(loFilePath,newFilePathC + "/" + DateUtil.format(DateUtil.getNow(), DateUtil.STR_YEARMONTHDAY) + "/" +fi.getName()); FileUtil.deleteNcFile(loFilePath); } try { objectName.setTypes("Info"); objectName.setResult("æå"); SyslogClient.sendClient(logIp,Integer.valueOf(logPort),objectName.toString()); }catch (Exception e) { return; } } else { try { objectName.setResult("失败"); objectName.setTypes("error"); SyslogClient.sendClient(logIp,Integer.valueOf(logPort),objectName.toString()); }catch (Exception e) { return; } } } } } catch (Throwable throwable) { throwable.printStackTrace(); } } } /** * 宿¶ä»»å¡æ§è¡å¨åæ° æ¯å¤©åæ¨1.30æ§è¡ */ @Override @Scheduled(cron = "0 30 1 * * ?") public void deleteNcSendFile() { Integer day; //ååå ¸æ¶é´ List<SingleDictionary> singleDictionaries=iSingleDictionaryService.findListFromTypeCode("DEL_TIME_SEND"); if (singleDictionaries.size()!=1){ return; }else { day= singleDictionaries.get(0).getDicValue(); } Path ncDirectory = Paths.get("D:\\NC"); //å¤©è½¬ç§ long dayToSecond = day * 24 * 60 * 60; if (Files.exists(ncDirectory) && Files.isDirectory(ncDirectory)) { // é彿¥æ¾NCç®å½ä¸ææå为sendçæä»¶å¤¹ try (Stream<Path> sendFolders = Files.walk(ncDirectory) .filter(Files::isDirectory) .filter(path -> path.getFileName().toString().equalsIgnoreCase("send"))) { sendFolders.forEach(sendFolder -> { try { // è·åå½åæ¶é´ Instant now = Instant.now(); // éåSENDæä»¶å¤¹å çæææä»¶ Files.walk(sendFolder) .filter(Files::isRegularFile) .forEach(file -> { try { // è·åæä»¶çæåä¿®æ¹æ¶é´ Instant lastModified = Files.getLastModifiedTime(file).toInstant(); // è®¡ç®æ¶é´å·® Duration duration = Duration.between(lastModified, now); // 夿æ¯å¦è¶ æ¶ï¼æ¶é´åå¨åå ¸ä¸ï¼base_single_dictionaryï¼ if (duration.getSeconds() > dayToSecond) { try { Files.delete(file); System.out.println("å·²å 餿件: " + file); } catch (IOException e) { System.err.println("å 餿件 " + file + " æ¶åºç°é误: " + e.getMessage()); } } } catch (IOException e) { System.err.println("è·åæä»¶ " + file + " çæåä¿®æ¹æ¶é´æ¶åºç°é误: " + e.getMessage()); } }); } catch (IOException e) { System.err.println("éå " + sendFolder + " æä»¶å¤¹æ¶åºç°é误: " + e.getMessage()); } }); } catch (IOException e) { System.err.println("æ¥æ¾sendæä»¶å¤¹æ¶åºç°é误: " + e.getMessage()); } } else { System.err.println("DççNCç®å½ä¸å卿䏿¯ææçç®å½"); } } // @Override // @Scheduled(cron = "${fileCron}") // public void fileClientTxtOrNc() { // SysLogMessageDto message = new SysLogMessageDto(); // String host = "127.0.0.1"; // if (StringUtils.isNotBlank(serverIp)) { // host = serverIp; // } // String port = "8299"; // if (StringUtils.isNotBlank(serverPort)) { // port = serverPort; // } // String username = "admin"; // if (StringUtils.isNotBlank(usernameService)) { // username = usernameService; // } // String pwd = "123"; // if (StringUtils.isNotBlank(pwdService)) { // pwd = pwdService; // } // //æä»¶æ¬å°å°åï¼æ ¹æ®å°åæ¾å°æä»¶ï¼å°æä»¶è§£æææä»¶æµ // String localFilePath = "E:\\test\\a\\"; // if (StringUtils.isNotBlank(localFilePathC)) { // localFilePath = localFilePathC; // } // //æä»¶ä¸ä¼ ç®çå°åï¼å°æä»¶ä¸ä¼ å°è¯¥å°å // String servicePath = "E:\\test\\b\\"; // if (StringUtils.isNotBlank(servicePathS)) { // servicePath = servicePathS; // } // boolean btelnetPort = TelnetUtil.telnetPort(serverIp,Integer.valueOf(serverPort),10); // if (!btelnetPort) { // System.out.println("æå¡å¨è¿æ¥ï¼ " + serverIp + ":" + serverPort + " å¼å¸¸ï¼" ); // return; // } // //ç¬¬ä¸æ¥ï¼è·åtoken // String token = null; // try { // token = FileClient.getToken(host,port,username,pwd,addressToken); // } catch (Throwable throwable) { // throwable.printStackTrace(); // } // // //è¥è·åtokenæåï¼åè¿è¡ä¸ä¼ æä»¶æ¥å£è°ç¨ // if (token !=null && !token.equals("")){ // try { // File f3 = new File(localFilePath); // File[] files = f3.listFiles(); // for (File fi : files){ // if (fi.isFile()){ // SysLogTypeObjectDto objectName = new SysLogTypeObjectDto(); // objectName.setDateTime(DateUtil.format(DateUtil.getNow(),DateUtil.STR_DATE_TIME_SMALL)); // objectName.setFileName(fi.getName()); // objectName.setFileSize(FileUtil.changeFileFormatKb(String.valueOf(new File(localFilePath).length()))); // objectName.setSourceAddress(localFilePath); // objectName.setDestination(serverIp);//æå¡ç«¯IP // //顺åºå· // DncPassLog passLog = getById("num0001"); // if (passLog == null) { // passLog = new DncPassLog(); // passLog.setId("num0001"); // passLog.setSequenceNumber(1); // objectName.setFileNum(Integer.toString(1)); // save(passLog); // } else { // Integer number = passLog.getSequenceNumber()+1; // removeById("num0001"); // objectName.setFileNum(Integer.toString(number)); // // passLog = new DncPassLog(); // passLog.setId("num0001"); // passLog.setSequenceNumber(number); // save(passLog); // } // // InetAddress address = null; // try { // address = InetAddress.getLocalHost(); // String ip = address.getHostAddress(); // objectName.setSourceAddress("20.10.17.11");//客æ·ç«¯IP // objectName.setAddress(ip); // } catch (UnknownHostException e) { // objectName.setSourceAddress("127.0.0.1"); // objectName.setAddress("127.0.0.1"); // } // objectName.setDestination(host); // objectName.setResult("失败"); // //è·åæä¸ªæä»¶ä¸çæææä»¶ // String loFilePath = localFilePath + fi.getName(); // String servicePathName =servicePath+"//" + fi.getName(); // File file = new File(loFilePath); // if (file == null || !file.exists()){ // objectName.setAbstract1("sm3"); // } else { // String sm3 = SmUtil.sm3(file); // objectName.setAbstract1(sm3); // } // // String b = FileClient.uploadFile(host,port,token,fi.getName(),servicePathName,loFilePath,addressUploadFile); // //æä»¶å¤ä»½å é¤ // if (b == null) { // try { // objectName.setResult("失败"); // objectName.setTypes("error"); // SyslogClient.sendClient(logIp,Integer.valueOf(logPort),objectName.toString()); // }catch (Exception e) { // return; // } // } // else if ( b.equals("æå")) { // //å¤ä»½æ°æ® // boolean fCopy = FileUtil.copyNcFile(loFilePath,newFilePathC + "/" + DateUtil.format(DateUtil.getNow(), // DateUtil.STR_YEARMONTHDAY) + "/" +fi.getName()); // if (fCopy) { // FileUtil.deleteNcFile(loFilePath); // } else { // FileUtil.copyNcFile(loFilePath,newFilePathC + "/" + DateUtil.format(DateUtil.getNow(), // DateUtil.STR_YEARMONTHDAY) + "/" +fi.getName()); // FileUtil.deleteNcFile(loFilePath); // } // try { // objectName.setTypes("Info"); // objectName.setResult("æå"); // SyslogClient.sendClient(logIp,Integer.valueOf(logPort),objectName.toString()); // }catch (Exception e) { // return; // } // } else { // try { // objectName.setResult("失败"); // objectName.setTypes("error"); // SyslogClient.sendClient(logIp,Integer.valueOf(logPort),objectName.toString()); // }catch (Exception e) { // return; // } // } // } // } // // } catch (Throwable throwable) { // throwable.printStackTrace(); // } // } // } // // /** // * 宿¶ä»»å¡æ§è¡å¨åæ° æ¯å¤©åæ¨1.30æ§è¡ // */ // @Override // @Scheduled(cron = "0 30 1 * * ?") // public void deleteNcSendFile() { // Integer day; // //ååå ¸æ¶é´ // List<SingleDictionary> singleDictionaries=iSingleDictionaryService.findListFromTypeCode("DEL_TIME_SEND"); // if (singleDictionaries.size()!=1){ // return; // }else { // day= singleDictionaries.get(0).getDicValue(); // } // Path ncDirectory = Paths.get("D:\\NC"); // //å¤©è½¬ç§ // long dayToSecond = day * 24 * 60 * 60; // if (Files.exists(ncDirectory) && Files.isDirectory(ncDirectory)) { // // é彿¥æ¾NCç®å½ä¸ææå为sendçæä»¶å¤¹ // try (Stream<Path> sendFolders = Files.walk(ncDirectory) // .filter(Files::isDirectory) // .filter(path -> path.getFileName().toString().equalsIgnoreCase("send"))) { // sendFolders.forEach(sendFolder -> { // try { // // è·åå½åæ¶é´ // Instant now = Instant.now(); // // éåSENDæä»¶å¤¹å çæææä»¶ // Files.walk(sendFolder) // .filter(Files::isRegularFile) // .forEach(file -> { // try { // // è·åæä»¶çæåä¿®æ¹æ¶é´ // Instant lastModified = Files.getLastModifiedTime(file).toInstant(); // // è®¡ç®æ¶é´å·® // Duration duration = Duration.between(lastModified, now); // // 夿æ¯å¦è¶ æ¶ï¼æ¶é´åå¨åå ¸ä¸ï¼base_single_dictionaryï¼ // if (duration.getSeconds() > dayToSecond) { // try { // Files.delete(file); // System.out.println("å·²å 餿件: " + file); // } catch (IOException e) { // System.err.println("å 餿件 " + file + " æ¶åºç°é误: " + e.getMessage()); // } // } // } catch (IOException e) { // System.err.println("è·åæä»¶ " + file + " çæåä¿®æ¹æ¶é´æ¶åºç°é误: " + e.getMessage()); // } // }); // } catch (IOException e) { // System.err.println("éå " + sendFolder + " æä»¶å¤¹æ¶åºç°é误: " + e.getMessage()); // } // }); // } catch (IOException e) { // System.err.println("æ¥æ¾sendæä»¶å¤¹æ¶åºç°é误: " + e.getMessage()); // } // } else { // System.err.println("DççNCç®å½ä¸å卿䏿¯ææçç®å½"); // } // } } src/main/java/com/lxzn/base/service/impl/ReceiveFileServiceImpl.java
@@ -37,157 +37,157 @@ @Value("${fileNCPath}") private String fileNCPath; @Override @Scheduled(cron = "${ncFileRec}") public void analysisAndCopyFileRec() { if (StringUtils.isBlank(filePath)) { return; } File f3 = new File(filePath); File[] files = f3.listFiles(); for (File fi : files){ InputStreamReader input =null; BufferedReader bufferedReader =null; String loFilePath = filePath + fi.getName(); System.out.println(loFilePath); try { if (FileUtil.getFileSuffix(fi.getName()).equals("nc")) { String line; int count = 0; NcTxtFilePathInfo result = new NcTxtFilePathInfo(); FileInputStream fis = null; try { fis = new FileInputStream(loFilePath); } catch (Exception e1) { e1.printStackTrace(); } Scanner sc = new Scanner(fis, "UTF-8"); while (count < 8 && sc.hasNext()) { line = sc.nextLine(); if (count ==0) { result.setFileTxtName(line.trim()); } else if (count ==1) { result.setFileNcName(line.trim()); }else if (count ==2) { result.setOrigFileName(line.trim()); }else if (count ==3) { result.setOrigFileSuffix(line.trim()); }else if (count ==4) { result.setFilePath(line.trim()); }else if (count ==5) { result.setEquipmentId(line.trim()); }else if (count ==6) { result.setFileAddOrDelete(Integer.valueOf(line.trim())); }else if (count == 7) { result.setFileSize(line.trim()); } count++; } if (sc != null) { sc.close(); } if (bufferedReader != null) { bufferedReader.close(); } if (input != null) { input.close(); } if (result == null) { continue; } if (result.getFileAddOrDelete() != null ) { if ( result.getFileAddOrDelete()==1) { String path = ""; SingleDictionary singleDictionary=dictionaryService.findListFromTypeCode("virtual_equipment_id").get(0); String docEquipmentId = null; if (singleDictionary != null) { docEquipmentId= String.valueOf(singleDictionary.getDicValue()); } if (result.getEquipmentId().equals(docEquipmentId)) { //èæè®¾å¤å¤ç path = filePath + result.getOrigFileName(); if (StringUtils.isNotBlank(result.getOrigFileName()) && result.getOrigFileName().equals("null")) { //æä»¶å¾ å¤ç //å¤ä»½æ°æ® FileUtil.deleteFileNewRec(loFilePath); continue; } }else { path = filePath + result.getFileNcName()+ ".NC"; if (StringUtils.isNotBlank(result.getFileNcName()) && result.getFileNcName().equals("null")) { //æä»¶å¾ å¤ç //å¤ä»½æ°æ® FileUtil.deleteFileNewRec(loFilePath); continue; } } File ncFile = new File(path); if (ncFile == null) { continue; } else { //å·²ç»å卿件éè¦å¤ä»½ String size = String.valueOf(ncFile.length()); if (!size.equals(result.getFileSize())) { continue; } boolean bool = docInfoService.addDocInfoRecService(result.getEquipmentId(), ncFile,result.getOrigFileSuffix(), FileUtil.getFilenameNonSuffix(result.getOrigFileName()) ,result.getFilePath()); if (bool) { FileUtil.deleteFileNewRec(path); FileUtil.deleteFileNewRec(loFilePath); } } } else { String path; /*if(StringUtils.isBlank(result.getOrigFileSuffix())) { path = fileNCPath + "/" + result.getFilePath() + "/send/" +result.getOrigFileName(); } else { path = fileNCPath + "/" + result.getFilePath() + "/send/" +result.getOrigFileName()+ "." + result.getOrigFileSuffix(); }*/ /*File ncFile = new File(path);*/ /*if (ncFile == null) { return; } else { //å¾ ä¼å boolean deleteFile = FileUtil.copyFileNcToBak(result.getFilePath(), result.getOrigFileName(), result.getOrigFileSuffix()); FileUtil.deleteFile(path); FileUtil.deleteFile(loFilePath); }*/ } } } } catch (Exception e1) { try { if (bufferedReader != null) { bufferedReader.close(); } if (input != null) { input.close(); } } catch (IOException e) { e.printStackTrace(); } e1.printStackTrace(); } finally { try { if (bufferedReader != null) { bufferedReader.close(); } if (input != null) { input.close(); } } catch (IOException e) { e.printStackTrace(); } } } } // @Override // @Scheduled(cron = "${ncFileRec}") // public void analysisAndCopyFileRec() { // if (StringUtils.isBlank(filePath)) { // return; // } // File f3 = new File(filePath); // File[] files = f3.listFiles(); // for (File fi : files){ // InputStreamReader input =null; // BufferedReader bufferedReader =null; // String loFilePath = filePath + fi.getName(); // System.out.println(loFilePath); // try { // if (FileUtil.getFileSuffix(fi.getName()).equals("nc")) { // String line; // int count = 0; // NcTxtFilePathInfo result = new NcTxtFilePathInfo(); // FileInputStream fis = null; // try { // fis = new FileInputStream(loFilePath); // } catch (Exception e1) { // e1.printStackTrace(); // } // Scanner sc = new Scanner(fis, "UTF-8"); // while (count < 8 && sc.hasNext()) { // line = sc.nextLine(); // if (count ==0) { // result.setFileTxtName(line.trim()); // } else if (count ==1) { // result.setFileNcName(line.trim()); // }else if (count ==2) { // result.setOrigFileName(line.trim()); // }else if (count ==3) { // result.setOrigFileSuffix(line.trim()); // }else if (count ==4) { // result.setFilePath(line.trim()); // }else if (count ==5) { // result.setEquipmentId(line.trim()); // }else if (count ==6) { // result.setFileAddOrDelete(Integer.valueOf(line.trim())); // }else if (count == 7) { // result.setFileSize(line.trim()); // } // count++; // } // if (sc != null) { // sc.close(); // } // if (bufferedReader != null) { // bufferedReader.close(); // } // if (input != null) { // input.close(); // } // if (result == null) { // continue; // } // if (result.getFileAddOrDelete() != null ) { // if ( result.getFileAddOrDelete()==1) { // String path = ""; // SingleDictionary singleDictionary=dictionaryService.findListFromTypeCode("virtual_equipment_id").get(0); // String docEquipmentId = null; // if (singleDictionary != null) { // docEquipmentId= String.valueOf(singleDictionary.getDicValue()); // } // if (result.getEquipmentId().equals(docEquipmentId)) { // //èæè®¾å¤å¤ç // path = filePath + result.getOrigFileName(); // if (StringUtils.isNotBlank(result.getOrigFileName()) && // result.getOrigFileName().equals("null")) { // //æä»¶å¾ å¤ç // //å¤ä»½æ°æ® // FileUtil.deleteFileNewRec(loFilePath); // continue; // } // }else { // path = filePath + result.getFileNcName()+ ".NC"; // if (StringUtils.isNotBlank(result.getFileNcName()) && // result.getFileNcName().equals("null")) { // //æä»¶å¾ å¤ç // //å¤ä»½æ°æ® // FileUtil.deleteFileNewRec(loFilePath); // continue; // } // } // File ncFile = new File(path); // if (ncFile == null) { // continue; // } else { // //å·²ç»å卿件éè¦å¤ä»½ // String size = String.valueOf(ncFile.length()); // if (!size.equals(result.getFileSize())) { // continue; // } // // boolean bool = docInfoService.addDocInfoRecService(result.getEquipmentId(), // ncFile,result.getOrigFileSuffix(), // FileUtil.getFilenameNonSuffix(result.getOrigFileName()) // ,result.getFilePath()); // if (bool) { // FileUtil.deleteFileNewRec(path); // FileUtil.deleteFileNewRec(loFilePath); // } // } // } else { // String path; // /*if(StringUtils.isBlank(result.getOrigFileSuffix())) { // path = fileNCPath + "/" + result.getFilePath() + "/send/" +result.getOrigFileName(); // } else { // path = fileNCPath + "/" + result.getFilePath() + "/send/" +result.getOrigFileName()+ "." + result.getOrigFileSuffix(); // }*/ // // /*File ncFile = new File(path);*/ // /*if (ncFile == null) { // return; // } else { // //å¾ ä¼å // boolean deleteFile = FileUtil.copyFileNcToBak(result.getFilePath(), // result.getOrigFileName(), result.getOrigFileSuffix()); // FileUtil.deleteFile(path); // FileUtil.deleteFile(loFilePath); // }*/ // } // // } // } // } catch (Exception e1) { // try { // if (bufferedReader != null) { // bufferedReader.close(); // } // if (input != null) { // input.close(); // } // } catch (IOException e) { // e.printStackTrace(); // } // e1.printStackTrace(); // } finally { // try { // if (bufferedReader != null) { // bufferedReader.close(); // } // if (input != null) { // input.close(); // } // } catch (IOException e) { // e.printStackTrace(); // } // } // } // } } src/main/java/com/lxzn/config/WebServiceConfig.java
@@ -1,62 +1,62 @@ package com.lxzn.config; import com.lxzn.webservice.DncWebService; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBus; import org.apache.cxf.jaxws.EndpointImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.xml.ws.Endpoint; /** * @Description: * @Author: zhangherong * @Date: Created in 2020/12/24 17:09 * @Version: 1.0 * @Modified By: */ @Configuration public class WebServiceConfig { @Autowired private DncWebService dncWebService; /** * Apache CXF æ ¸å¿æ¶ææ¯ä»¥BUSä¸ºæ ¸å¿ï¼æ´åå ¶ä»ç»ä»¶ã * Busæ¯CXFç主干, ä¸ºå ±äº«èµæºæä¾ä¸ä¸ªå¯é ç½®çåºæï¼ä½ç¨ç±»ä¼¼äºSpringçApplicationContextï¼è¿äºå ±äº«èµæºå æ¬ * WSDl管çå¨ãç»å®å·¥åçãéè¿å¯¹BUSè¿è¡æ©å±ï¼å¯ä»¥æ¹ä¾¿å°å®¹çº³èªå·±çèµæºï¼æè æ¿æ¢ç°æçèµæºãé»è®¤Buså®ç°åºäºSpringæ¶æï¼ * éè¿ä¾èµæ³¨å ¥ï¼å¨è¿è¡æ¶å°ç»ä»¶ä¸²èèµ·æ¥ãBusFactoryè´è´£Busçå建ãé»è®¤çBusFactoryæ¯SpringBusFactoryï¼å¯¹åºäºé»è®¤ * çBuså®ç°ã卿é è¿ç¨ä¸ï¼SpringBusFactoryä¼æç´¢META-INF/cxfï¼å å«å¨ CXF çjarä¸ï¼ä¸çææbeané ç½®æä»¶ã * æ ¹æ®è¿äºé ç½®æä»¶æå»ºä¸ä¸ªApplicationContextãå¼åè ä¹å¯ä»¥æä¾èªå·±çé ç½®æä»¶æ¥å®å¶Busã */ @Bean(name = Bus.DEFAULT_BUS_ID) public SpringBus springBus() { return new SpringBus(); } /** * æ¤æ¹æ³ä½ç¨æ¯æ¹å项ç®ä¸æå¡åçåç¼åï¼æ¤å¤127.0.0.1æè localhostä¸è½è®¿é®æ¶ï¼è¯·ä½¿ç¨ipconfigæ¥çæ¬æºipæ¥è®¿é® * æ¤æ¹æ³è¢«æ³¨éå, å³ä¸æ¹ååç¼å(é»è®¤æ¯services), wsdl访é®å°å为 http://127.0.0.1:8080/services/ws/api?wsdl * å»ææ³¨éåwsdl访é®å°å为ï¼http://127.0.0.1:8080/soap/ws/api?wsdl * http://127.0.0.1:8080/soap/ååºæå¡å表 æ http://127.0.0.1:8080/soap/ws/api?wsdl æ¥çå®é çæå¡ * æ°å»ºServletè®°å¾éè¦å¨å¯å¨ç±»æ·»å 注解ï¼@ServletComponentScan * * 妿å¯å¨æ¶åºç°é误ï¼not loaded because DispatcherServlet Registration found non dispatcher servlet dispatcherServlet * å¯è½æ¯springbootä¸cfxçæ¬ä¸å ¼å®¹ã * åæ¶å¨spring boot2.0.6ä¹åççæ¬ä¸xcféæï¼ä¸éè¦å¨å®ä¹ä»¥ä¸æ¹æ³ï¼ç´æ¥å¨application.propertiesé ç½®æä»¶ä¸æ·»å ï¼ * cxf.path=/serviceï¼é»è®¤æ¯servicesï¼ */ //@Bean //public ServletRegistrationBean dispatcherServlet() { // return new ServletRegistrationBean(new CXFServlet(), "/soap/*"); //} @Bean public Endpoint endpoint() { EndpointImpl endpoint = new EndpointImpl(springBus(), dncWebService); endpoint.publish("/ws/dnc"); return endpoint; } } //package com.lxzn.config; // //import com.lxzn.webservice.DncWebService; //import org.apache.cxf.Bus; //import org.apache.cxf.bus.spring.SpringBus; //import org.apache.cxf.jaxws.EndpointImpl; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Configuration; // //import javax.xml.ws.Endpoint; // ///** // * @Description: // * @Author: zhangherong // * @Date: Created in 2020/12/24 17:09 // * @Version: 1.0 // * @Modified By: // */ //@Configuration //public class WebServiceConfig { // // @Autowired // private DncWebService dncWebService; // // /** // * Apache CXF æ ¸å¿æ¶ææ¯ä»¥BUSä¸ºæ ¸å¿ï¼æ´åå ¶ä»ç»ä»¶ã // * Busæ¯CXFç主干, ä¸ºå ±äº«èµæºæä¾ä¸ä¸ªå¯é ç½®çåºæï¼ä½ç¨ç±»ä¼¼äºSpringçApplicationContextï¼è¿äºå ±äº«èµæºå æ¬ // * WSDl管çå¨ãç»å®å·¥åçãéè¿å¯¹BUSè¿è¡æ©å±ï¼å¯ä»¥æ¹ä¾¿å°å®¹çº³èªå·±çèµæºï¼æè æ¿æ¢ç°æçèµæºãé»è®¤Buså®ç°åºäºSpringæ¶æï¼ // * éè¿ä¾èµæ³¨å ¥ï¼å¨è¿è¡æ¶å°ç»ä»¶ä¸²èèµ·æ¥ãBusFactoryè´è´£Busçå建ãé»è®¤çBusFactoryæ¯SpringBusFactoryï¼å¯¹åºäºé»è®¤ // * çBuså®ç°ã卿é è¿ç¨ä¸ï¼SpringBusFactoryä¼æç´¢META-INF/cxfï¼å å«å¨ CXF çjarä¸ï¼ä¸çææbeané ç½®æä»¶ã // * æ ¹æ®è¿äºé ç½®æä»¶æå»ºä¸ä¸ªApplicationContextãå¼åè ä¹å¯ä»¥æä¾èªå·±çé ç½®æä»¶æ¥å®å¶Busã // */ // @Bean(name = Bus.DEFAULT_BUS_ID) // public SpringBus springBus() { // return new SpringBus(); // } // // /** // * æ¤æ¹æ³ä½ç¨æ¯æ¹å项ç®ä¸æå¡åçåç¼åï¼æ¤å¤127.0.0.1æè localhostä¸è½è®¿é®æ¶ï¼è¯·ä½¿ç¨ipconfigæ¥çæ¬æºipæ¥è®¿é® // * æ¤æ¹æ³è¢«æ³¨éå, å³ä¸æ¹ååç¼å(é»è®¤æ¯services), wsdl访é®å°å为 http://127.0.0.1:8080/services/ws/api?wsdl // * å»ææ³¨éåwsdl访é®å°å为ï¼http://127.0.0.1:8080/soap/ws/api?wsdl // * http://127.0.0.1:8080/soap/ååºæå¡å表 æ http://127.0.0.1:8080/soap/ws/api?wsdl æ¥çå®é çæå¡ // * æ°å»ºServletè®°å¾éè¦å¨å¯å¨ç±»æ·»å 注解ï¼@ServletComponentScan // * // * 妿å¯å¨æ¶åºç°é误ï¼not loaded because DispatcherServlet Registration found non dispatcher servlet dispatcherServlet // * å¯è½æ¯springbootä¸cfxçæ¬ä¸å ¼å®¹ã // * åæ¶å¨spring boot2.0.6ä¹åççæ¬ä¸xcféæï¼ä¸éè¦å¨å®ä¹ä»¥ä¸æ¹æ³ï¼ç´æ¥å¨application.propertiesé ç½®æä»¶ä¸æ·»å ï¼ // * cxf.path=/serviceï¼é»è®¤æ¯servicesï¼ // */ // //@Bean // //public ServletRegistrationBean dispatcherServlet() { // // return new ServletRegistrationBean(new CXFServlet(), "/soap/*"); // //} // // @Bean // public Endpoint endpoint() { // EndpointImpl endpoint = new EndpointImpl(springBus(), dncWebService); // endpoint.publish("/ws/dnc"); // return endpoint; // } //} src/main/java/com/lxzn/framework/domain/webservice/PlmProgramSourceInfo.java
@@ -14,7 +14,7 @@ */ @Data @NoArgsConstructor @TableName(value = "PLM_PROGRAM_SOURCE") @TableName(value = "plm_program_source") public class PlmProgramSourceInfo implements Serializable { @TableId(value = "id") private String id; src/main/java/com/lxzn/framework/domain/webservice/request/ThirdDeProgramSource.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,89 @@ package com.lxzn.framework.domain.webservice.request; import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import org.apache.commons.io.FilenameUtils; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * éæ3DE * @author clown * * @date 2022/9/19 */ @Data public class ThirdDeProgramSource implements Serializable { @TableId(value = "id") private String id; /*é¶ä»¶åç§°*/ @TableField(value = "part_name") private String partName; /*é¶ä»¶å¾å·*/ @TableField(value = "part_no") private String partNo; /*çæ¬å·(å·¥èºè§ç¨çæ¬å·)*/ @TableField(value = "revision_no") private String revisionNo; /*车é´åç§°*/ @TableField(value = "nc_plant_name") private String ncPlantName; /*车é´ç¼å·*/ @TableField(value = "nc_plant_no") private String ncPlantNo; /*å·¥åºç¼å·*/ @TableField(value = "skgx_id") private String skgxId; /*å·¥åºåç§°*/ @TableField(value = "skgx_name") private String skgxName; /*æºåºåå· nc_jcid*/ @TableField(value = "nc_jcid") private String ncJcid; /*æºåºæä½ç³»ç»*/ @TableField(value = "nc_os") private String ncOs; /*设å¤ç¼å·*/ @TableField(value = "equipment_id") private String equipmentId; /*ç¨åºæä»¶åï¼å¯è½å¤ä¸ªï¼*/ @TableField(value = "nc_file_name") private String ncFileName; private transient Map<String, byte[]> ncFiles; // ä¿®å¤æä»¶åæ®µå®ä¹ private List<FileInfo> files; // æ·»å æä»¶ä¿¡æ¯ç±» @Data public static class FileInfo { private String file_name; // æ·»å å ¶ä»å¯è½å段 private String file_type; private Long file_size; } // æ·»å æä»¶è·¯å¾ååç§°åæ®µ private String filePath; private String fileName; // æ·»å 设置NCæä»¶çæ¹æ³ public void setNcFiles(Map<String, byte[]> ncFiles) { this.ncFiles = ncFiles; this.files = new ArrayList<>(); for (Map.Entry<String, byte[]> entry : ncFiles.entrySet()) { FileInfo fileInfo = new FileInfo(); fileInfo.setFile_name(entry.getKey()); fileInfo.setFile_size((long) entry.getValue().length); fileInfo.setFile_type(FilenameUtils.getExtension(entry.getKey())); this.files.add(fileInfo); } } } src/main/java/com/lxzn/nc/service/IDocRelativeService.java
@@ -47,4 +47,14 @@ * @return */ List<DeviceInfo> findDeviceByDocId(String docId); /** * æ¥è¯¢å ³èå ³ç³» * @param docId * @param classificationId * @param attributionType * @param attributionId * @return */ DocRelative findDocRelative(String docId, String classificationId, Integer attributionType, String attributionId); } src/main/java/com/lxzn/nc/service/impl/DocRelativeServiceImpl.java
@@ -157,4 +157,22 @@ ExceptionCast.cast(CommonCode.INVALID_PARAM); return super.getBaseMapper().findDeviceByDocId(docId); } /** * æ¥è¯¢å ³èå ³ç³» * @param docId * @param classificationId * @param attributionType * @param attributionId * @return */ @Override public DocRelative findDocRelative(String docId, String classificationId, Integer attributionType, String attributionId){ LambdaQueryWrapper<DocRelative> lambdaQueryWrapper = Wrappers.lambdaQuery(); lambdaQueryWrapper.eq(DocRelative::getDocId, docId); lambdaQueryWrapper.eq(DocRelative::getAttributionType, attributionType); lambdaQueryWrapper.eq(DocRelative::getAttributionId, attributionId); lambdaQueryWrapper.eq(DocRelative::getClassificationId, classificationId); return super.getOne(lambdaQueryWrapper); } } src/main/java/com/lxzn/webservice/DncWebService.java
@@ -3,6 +3,7 @@ import com.lxzn.framework.domain.webservice.PlmProgramSourceInfo; import com.lxzn.framework.domain.webservice.ProcedureFinish; import com.lxzn.framework.domain.webservice.request.PlmProgramSource; import com.lxzn.framework.domain.webservice.request.ThirdDeProgramSource; import com.lxzn.webservice.ext.MesResultModel; import javax.jws.WebMethod; @@ -14,7 +15,7 @@ * @CreateTime: 2025-02-27 * @Description: */ @WebService(name = "DncWebService", targetNamespace = "http://lxzn.webservice.com") //@WebService(name = "DncWebService", targetNamespace = "http://lxzn.webservice.com") public interface DncWebService { /** @@ -26,32 +27,20 @@ @WebMethod MesResultModel syncPlmNcLogProgram(@WebParam(name = "msg") String msg); public MesResultModel setTree(PlmProgramSource plmProgramSource); /** * NCç¨åºé½å¥æ¥å£ï¼MESï¼-DNCç³»ç»æ¥æ¶å°PLMä¼ çNCç¨åºï¼å°ç¨åºå 对åºçé¶ä»¶å·ãå·¥åºå·ã设å¤ç¼å·ä¼ ç»MESç³»ç» * 宿¶æ«æPlmProgramSourceInfo表ä¸çæ°æ®ï¼è¿è¡æ°æ®åæ¥ï¼æ¯åé忥䏿¬¡ * éæPLMææ * @param plmProgramSource * @return */ void syncWorkmanship(); public MesResultModel setPlmTree(PlmProgramSource plmProgramSource); /** * 派工任å¡ä¸åæ¥å£(MES) * * @param msg * éæ3DEææ * @param thirdDeProgramSource * @return */ @WebMethod String issuedDispatchTask(@WebParam(name = "msg") String msg); public MesResultModel processThirdDEProgram(ThirdDeProgramSource thirdDeProgramSource); /** * å®å·¥æ¥å£(MES) * * @param msg * @return */ @WebMethod String issuedProcedureFinish(@WebParam(name = "msg") String msg); String readFileName(String itemCode); String readFileName(String itemCode); } src/main/java/com/lxzn/webservice/controller/DncWebController.java
@@ -1,11 +1,14 @@ package com.lxzn.webservice.controller; import com.lxzn.framework.domain.webservice.request.ThirdDeProgramSource; import com.lxzn.framework.domain.webservice.request.PlmProgramSource; import com.lxzn.webservice.DncWebService; import com.lxzn.webservice.ext.MesResultModel; import lombok.extern.slf4j.Slf4j; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipFile; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.transaction.annotation.Transactional; @@ -17,7 +20,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.util.*; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -29,16 +31,22 @@ @Autowired private DncWebService dncWebService; @Value("${ncPdm.file_path}") @Value("${fileHomePath}") private String filePath; // å®ä¹å ³é®æä»¶ç±»å private static final String INNER_ZIP_PREFIX = "ãå ¬å¼ãNCç¨åºæä»¶ "; private static final String JSON_EXT = ".json"; private static final String TXT_EXT = ".txt"; /** * éæplmæ°æ®ï¼å缩å ï¼é颿¯NCå缩å ä¸JSONæä»¶ï¼ * @param file * @return */ @PostMapping(value = "/syncPlmNcLogProgram", consumes = "multipart/form-data") @Transactional public String processNcPackage(MultipartFile file) { Path workDir = null; try { if (file == null || file.isEmpty()) { log.error("æ¥æ¶å°çå缩æä»¶ä¸ºç©º"); @@ -47,7 +55,7 @@ // å建临æ¶ç®å½ String timestamp = String.valueOf(System.currentTimeMillis()); Path workDir = Paths.get(filePath, timestamp); workDir = Paths.get(filePath, "plm_" + timestamp); Files.createDirectories(workDir); // ä¿ååå§æä»¶ @@ -92,7 +100,6 @@ for (Map.Entry<String, byte[]> entry : ncFiles.entrySet()) { String fileName = entry.getKey(); if (allNcFiles.containsKey(fileName)) { // ä¿®æ¹ç¹5ï¼è®°å½éå¤è¦åï¼å®é ä¸å¡ä¸å¯è½éè¦æ´ä¸¥æ ¼å¤çï¼ log.warn("æ£æµå°éå¤NCæä»¶å: {}", fileName); } allNcFiles.put(fileName, entry.getValue()); @@ -108,19 +115,183 @@ // ä¸å¡å¤ç return JSONObject.toJSONString( dncWebService.setTree(plmPrograms) dncWebService.setPlmTree(plmPrograms) ); } catch (Exception e) { log.error("å¤çNCæä»¶å 失败", e); return MesResultModel.error("æä»¶å¤ç失败: " + e.getMessage()); } finally { // æ¸ çä¸´æ¶æä»¶ if (workDir != null) { deleteDirectory(workDir.toFile()); } } } /** * éæ3DEæ°æ®,å缩å ï¼å个å缩å å å«å¤ä¸ªNCæä»¶ãä¸ä¸ªå·¥èºæ°æ®.TXTï¼ * @param file ä¸ä¼ çåç¼©å æä»¶ * @return å¤çç»æ */ @PostMapping(value = "/integration3DEData", consumes = "multipart/form-data") @Transactional public String integration3DEData(MultipartFile file) { Path workDir = null; try { if (file == null || file.isEmpty()) { log.error("æ¥æ¶å°ç3DEå缩æä»¶ä¸ºç©º"); return MesResultModel.error("æ¥æ¶å°ç3DEå缩æä»¶ä¸ºç©º"); } // å建临æ¶å·¥ä½ç®å½ String timestamp = String.valueOf(System.currentTimeMillis()); workDir = Paths.get(filePath, "3de_" + timestamp); Files.createDirectories(workDir); // ä¿ååå§æä»¶ Path originalPath = workDir.resolve( Objects.requireNonNull(file.getOriginalFilename()) ); Files.copy(file.getInputStream(), originalPath, StandardCopyOption.REPLACE_EXISTING); log.info("3DEåå§æä»¶å·²ä¿å: {} (大å°: {} åè)", originalPath, Files.size(originalPath)); // è§£åZIPå è·åæææä»¶ Map<String, byte[]> packageContents = extractOuterZipContents(originalPath); log.info("3DEå缩å è§£ææåï¼å å« {} 个æä»¶", packageContents.size()); // æ¥æ¾å·¥èºæ°æ®TXTæä»¶ byte[] processData = findFileByExtension(packageContents, TXT_EXT); if (processData == null) { return MesResultModel.error("æªæ¾å°å·¥èºæ°æ®TXTæä»¶"); } // è§£æå·¥èºæ°æ®TXTæä»¶ ThirdDeProgramSource thirdDeProgramSource = parseProcessTxtFile(processData); if (thirdDeProgramSource == null) { return MesResultModel.error("è§£æå·¥èºæ°æ®TXTæä»¶å¤±è´¥"); } // æåææNCæä»¶ Map<String, byte[]> ncFiles = extractNcFiles(packageContents); if (ncFiles.isEmpty()) { return MesResultModel.error("æªæ¾å°NCç¨åºæä»¶"); } log.info("æ¾å° {} 个NCç¨åºæä»¶", ncFiles.size()); // 设置NCæä»¶éååæä»¶è·¯å¾ä¿¡æ¯ thirdDeProgramSource.setNcFiles(ncFiles); thirdDeProgramSource.setFilePath(workDir.toString()); thirdDeProgramSource.setFileName(originalPath.getFileName().toString()); // è°ç¨æå¡å¤ç3DEæ°æ® return JSONObject.toJSONString( dncWebService.processThirdDEProgram(thirdDeProgramSource) ); } catch (Exception e) { log.error("å¤ç3DEæ°æ®å 失败", e); return MesResultModel.error("3DEæä»¶å¤ç失败: " + e.getMessage()); } finally { // æ¸ çä¸´æ¶æä»¶ if (workDir != null) { deleteDirectory(workDir.toFile()); } } } /** * è§£æå·¥èºæ°æ®TXTæä»¶ * @param txtData TXTæä»¶å 容 * @return ThirdDeProgramSource对象 */ private ThirdDeProgramSource parseProcessTxtFile(byte[] txtData) { try { String content = new String(txtData, StandardCharsets.UTF_8); log.info("å·¥èºæ°æ®TXTå 容:\n{}", content); // 使ç¨FastJSONè§£æJSONæ ¼å¼çTXT JSONObject json = JSONObject.parseObject(content); if (json == null) { log.error("è§£æå·¥èºæ°æ®å¤±è´¥: 䏿¯ææçJSONæ ¼å¼"); return null; } // åå»ºå¯¹è±¡å¹¶è®¾ç½®å±æ§ ThirdDeProgramSource programSource = new ThirdDeProgramSource(); programSource.setPartName(json.getString("part_name")); programSource.setPartNo(json.getString("part_no")); programSource.setRevisionNo(json.getString("revision_no")); programSource.setSkgxId(json.getString("skgx_id")); programSource.setSkgxName(json.getString("skgx_name")); programSource.setNcJcid(json.getString("nc_jcid")); programSource.setNcOs(json.getString("nc_os")); programSource.setEquipmentId(json.getString("equipment_id")); programSource.setNcFileName(json.getString("nc_file_name")); programSource.setNcPlantNo(json.getString("nc_plant_no")); programSource.setNcPlantName(json.getString("nc_plant_name")); log.debug("è§£æçå·¥èºæ°æ®: partName={}, partNo={}, revisionNo={}, skgxId={}, skgxName={}, " + "ncJcid={}, ncOs={}, equipmentId={}, ncFileName={}, ncPlantNo={}, ncPlantName={}", programSource.getPartName(), programSource.getPartNo(), programSource.getRevisionNo(), programSource.getSkgxId(), programSource.getSkgxName(), programSource.getNcJcid(), programSource.getNcOs(), programSource.getEquipmentId(), programSource.getNcFileName(), programSource.getNcPlantNo(), programSource.getNcPlantName()); return programSource; } catch (Exception e) { log.error("è§£æå·¥èºæ°æ®TXTæä»¶å¤±è´¥", e); return null; } } /** * è§£æé®å¼å¯¹æ ¼å¼çTXTæä»¶ * @param content TXTæä»¶å 容 * @return é®å¼å¯¹æ å° */ private Map<String, String> parseKeyValueTxt(String content) { Map<String, String> result = new HashMap<>(); String[] lines = content.split("\\r?\\n"); for (String line : lines) { line = line.trim(); if (line.isEmpty() || line.startsWith("#") || line.startsWith("//")) { continue; // è·³è¿ç©ºè¡å注é } int separatorIndex = line.indexOf('='); if (separatorIndex > 0) { String key = line.substring(0, separatorIndex).trim(); String value = line.substring(separatorIndex + 1).trim(); result.put(key, value); } } return result; } /** * 仿件å 容䏿åNCæä»¶ * @param packageContents å å 容æ å° * @return NCæä»¶æ å° */ private Map<String, byte[]> extractNcFiles(Map<String, byte[]> packageContents) { Map<String, byte[]> ncFiles = new HashMap<>(); for (Map.Entry<String, byte[]> entry : packageContents.entrySet()) { String fileName = entry.getKey(); String fileExt = FilenameUtils.getExtension(fileName).toLowerCase(); if (fileExt.equals("nc")) { ncFiles.put(fileName, entry.getValue()); log.debug("æ¾å°NCæä»¶: {}", fileName); } } return ncFiles; } // ä¼ååçè§£åæ¹æ³ï¼ä½¿ç¨commons-compressï¼ private Map<String, byte[]> extractOuterZipContents(Path filePath) throws IOException { Map<String, byte[]> contents = new HashMap<>(); log.info("å¼å§è§£æZIPæä»¶: {}", filePath); try { try (ZipFile zipFile = new ZipFile(filePath.toFile())) { log.info("ZIPæä»¶æ ¼å¼æ£æµ: {}", zipFile.getEncoding()); @@ -131,17 +302,9 @@ if (entry.isDirectory()) continue; try (InputStream is = zipFile.getInputStream(entry)) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[8192]; int len; while ((len = is.read(buffer)) > 0) { baos.write(buffer, 0, len); } // ä¿çåå§æä»¶å String name = entry.getName(); contents.put(name, baos.toByteArray()); log.debug("æåæä»¶: {} ({} åè)", name, baos.size()); byte[] data = IOUtils.toByteArray(is); contents.put(entry.getName(), data); log.debug("æåæä»¶: {} ({} åè)", entry.getName(), data.length); } } } @@ -175,14 +338,15 @@ private List<byte[]> findAllFilesByExtension(Map<String, byte[]> contents, String extension) { String extLower = extension.toLowerCase(); return contents.entrySet().stream() .filter(e -> { String fileName = e.getKey(); // 使ç¨å°åæ¯è¾é¿å 大å°åææé®é¢ return fileName.toLowerCase().endsWith(extLower); }) .map(Map.Entry::getValue) .collect(Collectors.toList()); List<byte[]> result = new ArrayList<>(); for (Map.Entry<String, byte[]> entry : contents.entrySet()) { String fileName = entry.getKey().toLowerCase(); if (fileName.endsWith(extLower)) { result.add(entry.getValue()); } } return result; } // å é¨ZIPè§£ææ¹æ³ @@ -213,57 +377,25 @@ * æ ¹æ®æ©å±åæ¥æ¾æä»¶ */ private byte[] findFileByExtension(Map<String, byte[]> contents, String extension) { return contents.entrySet().stream() .filter(e -> e.getKey().toLowerCase().endsWith(extension)) .map(Map.Entry::getValue) .findFirst() .orElse(null); String extLower = extension.toLowerCase(); for (Map.Entry<String, byte[]> entry : contents.entrySet()) { if (entry.getKey().toLowerCase().endsWith(extLower)) { return entry.getValue(); } } return null; } /** * è·åæä»¶åï¼æ ¹æ®æ©å±åï¼ */ private String getFileNameByExtension(Map<String, byte[]> contents) { return contents.keySet().stream() .filter(k -> k.toLowerCase().endsWith(DncWebController.JSON_EXT)) .findFirst() .orElse("Unknown"); } /** * æ¥æ¾ä¸æå®åç¼å¹é çæä»¶å 容 * @param contents æä»¶å 容æ å°ï¼æä»¶å -> æä»¶å å®¹ï¼ * @param prefix è¦å¹é çæä»¶ååç¼ * @return å¹é ç第ä¸ä¸ªæä»¶å å®¹ï¼æªæ¾å°è¿å null */ private byte[] findFileByPrefix(Map<String, byte[]> contents, String prefix) { if (prefix == null || prefix.isEmpty()) { log.warn("æä»¶åç¼ä¸è½ä¸ºç©º"); return null; for (String key : contents.keySet()) { if (key.toLowerCase().endsWith(JSON_EXT)) { return key; } } return contents.entrySet().stream() .filter(entry -> { String fileName = entry.getKey(); // è·¯å¾è§èåå¤ç String normalizedKey = fileName.replace('\\', '/'); // è·å纯æä»¶å int lastSlash = normalizedKey.lastIndexOf('/'); String pureFileName = (lastSlash >= 0) ? normalizedKey.substring(lastSlash + 1) : normalizedKey; // è°è¯æ¥å¿ log.debug("æ£æ¥æä»¶: [åå§: {}], [纯æä»¶å: {}], åç¼: {}", fileName, pureFileName, prefix); return pureFileName.contains("NC"); }) .map(Map.Entry::getValue) .findFirst() .orElse(null); return "Unknown"; } /** @@ -274,4 +406,26 @@ return JSONObject.parseObject(json, PlmProgramSource.class); } /** * éå½å é¤ç®å½ */ private void deleteDirectory(File directory) { if (!directory.exists()) return; File[] files = directory.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { deleteDirectory(file); } else { if (!file.delete()) { log.warn("æ æ³å 餿件: {}", file.getAbsolutePath()); } } } } if (!directory.delete()) { log.warn("æ æ³å é¤ç®å½: {}", directory.getAbsolutePath()); } } } src/main/java/com/lxzn/webservice/impl/DncWebServiceImpl.java
@@ -8,14 +8,14 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.lxzn.activiti.service.IAssignFileStreamService; import com.lxzn.framework.domain.activiti.response.ActivitiCode; import com.lxzn.framework.domain.filesystem.response.FileUploadResult; import com.lxzn.framework.domain.nc.*; import com.lxzn.framework.domain.nc.response.DocumentCode; import com.lxzn.framework.domain.webservice.DispatchInfo; import com.lxzn.framework.domain.webservice.PlmProgramSourceInfo; import com.lxzn.framework.domain.webservice.ProcedureFinish; import com.lxzn.framework.domain.webservice.request.NcProgramInfo; import com.lxzn.framework.domain.webservice.request.PlmProgramSource; import com.lxzn.framework.domain.webservice.request.*; import com.lxzn.framework.exception.ExceptionCast; import com.lxzn.framework.model.response.CommonCode; import com.lxzn.framework.utils.CxfClientUtil; @@ -24,9 +24,8 @@ import com.lxzn.framework.utils.ZipUtil; import com.lxzn.framework.utils.file.FileUtil; import com.lxzn.nc.service.*; import com.lxzn.nc.service.impl.DeviceInfoServiceImpl; import com.lxzn.webservice.DncWebService; import com.lxzn.framework.domain.webservice.request.WsDispatch; import com.lxzn.framework.domain.webservice.request.WsProcedureFinish; import com.lxzn.webservice.ext.MesResultModel; import com.lxzn.webservice.service.IDispatchInfoService; import com.lxzn.webservice.service.IPlmProgramSourceInfoService; @@ -62,40 +61,12 @@ * @Description: */ @Service @WebService(name = "DncWebService", targetNamespace = "http://lxzn.webservice.com", endpointInterface = "com.lxzn.webservice.DncWebService" ) //@WebService(name = "DncWebService", // targetNamespace = "http://lxzn.webservice.com", // endpointInterface = "com.lxzn.webservice.DncWebService" //) @Slf4j public class DncWebServiceImpl implements DncWebService { @Value("${ncPdm.file_path}") private String filePath; /** * url */ @Value("${webservice.url}") private String url; /** * namespace */ @Value("${webservice.namespace}") private String namespace; /** * method */ @Value("${webservice.method}") private String method; @Resource private IDispatchInfoService dispatchInfoService; @Resource private IProcedureFinishService procedureFinishService; @Resource private IDeviceInfoService deviceInfoService; @Resource private IAssignFileStreamService assignFileStreamService; @Resource private IPlmProgramSourceInfoService iPlmProgramSourceInfoService; @Autowired @@ -126,112 +97,10 @@ private IDocClassificationService docClassificationService; @Autowired private IDeviceManagementService deviceManagementService; /** * 派工任å¡ä¸åæ¥å£ * @param msg * @return */ @Override public String issuedDispatchTask(@WebParam(name = "msg") String msg){ log.info("MES派工任å¡ä¸ååå§æ°æ® === {}", msg); List<WsDispatch> wsDispatchList = JSONObject.parseArray(msg, WsDispatch.class); for (WsDispatch wsDispatch : wsDispatchList) { DispatchInfo dispatchInfo = new DispatchInfo(); BeanUtils.copyProperties(wsDispatch, dispatchInfo); dispatchInfoService.save(dispatchInfo); Map<Boolean,String> ncResult = disPatchTaskNc(dispatchInfo); if (ncResult.containsKey(false)) { // è¿åå ·ä½çéè¯¯ä¿¡æ¯ return MesResultModel.error("NCä»»å¡ä¸å失败: " + ncResult.get(false)); } } return MesResultModel.success("æå"); } /** * ä¸åç¨åº */ public Map<Boolean,String> disPatchTaskNc(DispatchInfo dispatchInfo) { String processCode = dispatchInfo.getOperationSeqNo() + "_" + dispatchInfo.getEquipmentId(); return assignFileStreamService.disPatchTaskNc(dispatchInfo.getEquipmentId(), dispatchInfo.getWorkshop(),dispatchInfo.getMdsItemCode(),processCode,dispatchInfo.getRevisionNo(),dispatchInfo.getId()); } /** * å®å·¥ * * @param msg * @return */ @Override public String issuedProcedureFinish(String msg) { log.info("MESå®å·¥åå§æ°æ® === {}", msg); List<WsProcedureFinish> wsProcedureFinishList = JSONObject.parseArray(msg, WsProcedureFinish.class); if (CollectionUtils.isEmpty(wsProcedureFinishList)) { return MesResultModel.error("MesResultModel"); } List<ProcedureFinish> procedureFinishList = wsProcedureFinishList.stream() .map(source -> { ProcedureFinish target = new ProcedureFinish(); BeanUtils.copyProperties(source, target); return target; }) .collect(Collectors.toList()); procedureFinishService.saveBatch(procedureFinishList); //DNCç³»ç»ä¾æ®å·¥åå·å é¤è®¾å¤ç»ææ ä¸å¯¹åºçNCç¨åºåå·¥æ§ç½NCç¨åº for (ProcedureFinish procedureFinish : procedureFinishList) { //DNCç³»ç»ä¾æ®å·¥åå·å é¤è®¾å¤ç»ææ ä¸å¯¹åºçNCç¨åºåå·¥æ§ç½NCç¨åº if (procedureFinish.getEndineStatus().equals("3")){ //å é¤è®¾å¤ç»ææ ä¸å¯¹åºçNCç¨åºåå·¥æ§ç½NCç¨åº ProductInfo productInfo = productInfoService.getByProductNo("PLM"); if (productInfo == null) { log.error("======= 产åå±çº§å¼å¸¸,请èç³»å¼å人å======="); return MesResultModel.error("产åå±çº§å¼å¸¸,请èç³»å¼å人å"); } List<ComponentInfo> componentInfoList = componentInfoService.getByProductId(productInfo.getProductId()); List<String > comlist = new ArrayList<>(); if (componentInfoList != null && !componentInfoList.isEmpty()) { for (ComponentInfo cc : componentInfoList) { comlist.add(cc.getComponentId()); } } else { return MesResultModel.error("æ é¨ä»¶ä¿¡æ¯,请èç³»å¼å人å"); } String processCode=procedureFinish.getMdsItemCode(); PartsInfo part = partsInfoService.getByCodeAndComIdList(procedureFinish.getMdsItemCode(),comlist); if (part == null) { return MesResultModel.error("æ æ¤é¶ä»¶ä¿¡æ¯"+"__" + processCode+",请èç³»å¼å人å"); } processCode = processCode.split("_")[0]; //å·¥åº ProcessStream stream = processStreamService.findByProcessEquipment(procedureFinish.getEquipmentId(), processCode,procedureFinish.getRevisionNo(),productInfo.getProductId(),part.getPartsId()); if (stream == null) { return MesResultModel.error("æ æ¤å·¥åºä¿¡æ¯"+"__" + processCode+",请èç³»å¼å人å"); } //æ¥è¯¢å¯¹åºNCç¨åº List<ProcessStream> processStreamList = new ArrayList<>(); processStreamList.add(stream); List<DocInfo> docFileList = docInfoService.getByProcessIds(processStreamList); if (docFileList == null || docFileList.isEmpty()) { return MesResultModel.error("æ æ¤NCç¨åº" + "__" + processCode + ",请èç³»å¼å人å"); } docFileList.forEach(docFile -> { docInfoService.deleteDocInfo(docFile.getDocId()); }); } } log.info("æ¥æ¶MESå®å·¥åå§æ°æ®æåï¼"); return MesResultModel.success("æå"); } @Autowired private DeviceInfoServiceImpl deviceInfoService; @Autowired private IDeviceGroupService deviceGroupService; /** * è·åNCæä»¶å屿§ä¿¡æ¯(éæPLM) * @@ -246,7 +115,7 @@ List<PlmProgramSource> plmProgramSourceList = JSONObject.parseArray(msg, PlmProgramSource.class); AtomicReference<MesResultModel> mesResultModel= new AtomicReference<>(new MesResultModel()); plmProgramSourceList.forEach(item -> { mesResultModel.set(setTree(item)); mesResultModel.set(setPlmTree(item)); }); return mesResultModel.get(); } @@ -262,7 +131,7 @@ * @param plmProgramSource * @return */ public MesResultModel setTree(PlmProgramSource plmProgramSource) { public MesResultModel setPlmTree(PlmProgramSource plmProgramSource) { MesResultModel model = new MesResultModel(); model.setSuccFlag("æå"); PlmProgramSourceInfo plmProgramSourceInfo = new PlmProgramSourceInfo(); @@ -485,76 +354,407 @@ return model; } /** * å°è£ æ ç»æ * 1. 产å éææ°æ® * 2ãé¨ä»¶ æç §é¨é¨ï¼è½¦é´ nc_plant_name ï¼ç»´åº¦å»ºç« * 3ãé¶ä»¶ å¾å·ï¼é¶ä»¶å·ãé¶ä»¶åç§°ï¼ part_no * 4ãå·¥åº å·¥èºIDï¼å·¥èºè§ç¨ç¼å·/临è§ç¼å·ï¼ * 5. ncæä»¶ ï¼å·¥åºä¸ï¼ * 6.æºåºåå·ä¸æºåºæä½ç³»ç»ç»æè®¾å¤ç±»ä¸å·¥åºè¿è¡ç»å® * éæ3DEææ * @param thirdDeProgramSource * @return */ @Override @Transactional public MesResultModel processThirdDEProgram(ThirdDeProgramSource thirdDeProgramSource) { MesResultModel model = new MesResultModel(); model.setSuccFlag("æå"); try { log.info("3DE NCæä»¶å屿§ä¿¡æ¯åå§æ°æ® === {}", JSONObject.toJSONString(thirdDeProgramSource)); // 产å - 使ç¨é»è®¤ç3DE产å ProductInfo productInfo = productInfoService.getByProductNo("3DE"); if (productInfo == null) { return createErrorModel(model, "3DE产åå±çº§å¼å¸¸,请èç³»å¼å人å"); } // é¨ä»¶ - æç §è½¦é´ç»´åº¦å»ºç« ComponentInfo componentInfo = componentInfoService.getByCode(thirdDeProgramSource.getNcPlantNo()); if (componentInfo == null) { componentInfo = new ComponentInfo(); componentInfo.setComponentId(IdWorker.getIdStr()); componentInfo.setComponentCode(thirdDeProgramSource.getNcPlantNo()); componentInfo.setComponentName(thirdDeProgramSource.getNcPlantName()); componentInfo.setComponentStatus(1); componentInfo.setRankLevel(1); componentInfo.setParentId(productInfo.getProductId()); componentInfo.setProductId(productInfo.getProductId()); if (!componentInfoService.save(componentInfo)) { return createErrorModel(model, "æ·»å 3DEé¨ä»¶å±çº§å¤±è´¥,请èç³»å¼å人å"); } if (!savePermissionList(componentInfo, productInfo.getProductId())) { return createErrorModel(model, "æ·»å 3DEé¨ä»¶æé失败,请èç³»å¼å人å"); } } // é¶ä»¶ - å¾å·ï¼é¶ä»¶å·ãé¶ä»¶åç§°ï¼ PartsInfo partsInfo = partsInfoService.getByCode(thirdDeProgramSource.getPartNo()); if (partsInfo == null) { partsInfo = new PartsInfo(); partsInfo.setPartsId(IdWorker.getIdStr()); partsInfo.setComponentId(componentInfo.getComponentId()); partsInfo.setProductId(productInfo.getProductId()); partsInfo.setPartsStatus(1); partsInfo.setPartsCode(thirdDeProgramSource.getPartNo()); partsInfo.setPartsName(thirdDeProgramSource.getPartName()); partsInfo.setPartsModel(thirdDeProgramSource.getPartNo()); if (!partsInfoService.save(partsInfo)) { return createErrorModel(model, "æ·»å 3DEé¶ä»¶å±çº§å¤±è´¥,请èç³»å¼å人å"); } // æ·»å é¶ä»¶æé if (!savePartsPermission(partsInfo, productInfo.getProductId())) { return createErrorModel(model, "æ·»å 3DEé¶ä»¶æé失败,请èç³»å¼å人å"); } } // å·¥åº - å·¥èºIDï¼å·¥èºè§ç¨ç¼å·/临è§ç¼å·ï¼ ProcessStream processStream = processStreamService.findByProcessNoAndPartsId( thirdDeProgramSource.getSkgxId(), partsInfo.getPartsId()); List<ProcessStream> addProcessList = new ArrayList<>(); List<ProcessStream> updateProcessList = new ArrayList<>(); if (processStream == null) { processStream = new ProcessStream(); processStream.setProcessId(IdWorker.getIdStr()); processStream.setProductId(productInfo.getProductId()); processStream.setComponentId(componentInfo.getComponentId()); processStream.setPartsId(partsInfo.getPartsId()); processStream.setProcessCode(thirdDeProgramSource.getSkgxId()); processStream.setProcessName(thirdDeProgramSource.getSkgxName()); processStream.setCraftVersion(thirdDeProgramSource.getRevisionNo()); // 设置工èºçæ¬ // 设å¤ä¿¡æ¯å¤ç DeviceManagement deviceManagement = deviceManagementService.findEquipmentIdsFromEqId( thirdDeProgramSource.getNcPlantName(), thirdDeProgramSource.getEquipmentId()); if (deviceManagement != null && StringUtils.isNotEmpty(deviceManagement.getEquipmentIds())) { processStream.setProcessingEquipmentCode(deviceManagement.getEquipmentIds()); } else { processStream.setProcessingEquipmentCode(thirdDeProgramSource.getEquipmentId()); } processStream.setProcessingEquipmentOs(thirdDeProgramSource.getNcOs()); processStream.setProcessingEquipmentModel(thirdDeProgramSource.getNcJcid()); addProcessList.add(processStream); } else { // æ´æ°æ¶æ£æ¥çæ¬æ¯å¦åæ´ if (!Objects.equals(processStream.getCraftVersion(), thirdDeProgramSource.getRevisionNo())) { processStream.setCraftVersion(thirdDeProgramSource.getRevisionNo()); } processStream.setProcessName(thirdDeProgramSource.getSkgxName()); updateProcessList.add(processStream); } if (!addProcessList.isEmpty() && !processStreamService.saveBatch(addProcessList)) { return createErrorModel(model, "æ·»å 3DEå·¥åºå¤±è´¥,请èç³»å¼å人å"); } if (!updateProcessList.isEmpty() && !processStreamService.updateBatchById(updateProcessList)) { return createErrorModel(model, "æ´æ°3DEå·¥åºå¤±è´¥,请èç³»å¼å人å"); } // ææ¡£åç±» DocClassification ncDocClass = docClassificationService.getByCode("NC"); if (ncDocClass == null) { return createErrorModel(model, "NCææ¡£åç±»ä¸åå¨,请èç³»å¼å人å"); } // sendææ¡£åç±» DocClassification sendDocClass = docClassificationService.getByCode("SEND"); if (sendDocClass == null) { return createErrorModel(model, "SENDææ¡£åç±»ä¸åå¨,请èç³»å¼å人å"); } // å¤çNCæä»¶ if (thirdDeProgramSource.getNcFiles() != null && !thirdDeProgramSource.getNcFiles().isEmpty()) { for (Map.Entry<String, byte[]> entry : thirdDeProgramSource.getNcFiles().entrySet()) { String fileName = entry.getKey(); byte[] fileContent = entry.getValue(); String suffix = FileUtil.getFileSuffix(fileName); String baseName = FileUtil.getFilenameNonSuffix(fileName); // æ¥æ¾ç°æææ¡£ DocInfo docInfo = docInfoService.findByAttrAndDocName(baseName, 5, processStream.getProcessId(), suffix); FileUploadResult fileUploadResult = FileUtil.uploadFileByFileNameAndFis( fileName, new ByteArrayInputStream(fileContent)); if (fileUploadResult == null) { return createErrorModel(model, "ä¸ä¼ 3DE NCæä»¶å¤±è´¥"); } boolean success; if (docInfo == null) { // æ°å¢ææ¡£ docInfo = new DocInfo(); String docId = IdWorker.getIdStr(); docInfo.setDocId(docId); docInfo.setDocName(fileUploadResult.getFileName()); docInfo.setDocSuffix(fileUploadResult.getFileSuffix()); docInfo.setDocStatus(5); // åå»ºææ¡£å ³è DocRelative docRelative = new DocRelative(); docRelative.setAttributionId(processStream.getProcessId()); docRelative.setDocId(docInfo.getDocId()); docRelative.setAttributionType(5); docRelative.setClassificationId(ncDocClass.getClassificationId()); if (!docRelativeService.save(docRelative)) { return createErrorModel(model, "å建3DEææ¡£å ³è失败"); } // ä¿åææ¡£æä»¶ if (getFile(docInfo, fileUploadResult, docFileService)) { return createErrorModel(model, "ä¿å3DEææ¡£æä»¶å¤±è´¥"); } success = docInfoService.save(docInfo); // è·åææ°ææ¡£æä»¶ DocFile docFile = docFileService.getDocFileNearest(docId); // æ·»å å°è®¾å¤ if (!linkToDevice(thirdDeProgramSource.getEquipmentId(), docInfo.getDocId(), docFile, sendDocClass)) { return createErrorModel(model, "æ·»å è®¾å¤ææ¡£å ³è失败"); } } else { // æ´æ°ææ¡£ - å¤ççæ¬æ§å¶ if (StringUtils.isNotEmpty(processStream.getCraftVersion()) && StringUtils.isNotEmpty(thirdDeProgramSource.getRevisionNo())) { // çæ¬åæ´ï¼ä¿åæ§çæ¬æä»¶ if (!Objects.equals(processStream.getCraftVersion(), thirdDeProgramSource.getRevisionNo())) { this.createFileOldNcPathAndCopyFor3DE(docInfo, thirdDeProgramSource); } } DocFile docFile = getDocFile(docInfo, fileUploadResult); success = docFileService.addDocFile(docFile); if (success) { docInfo.setPublishVersion(docFile.getDocVersion()); docInfo.setPublishFileId(docFile.getFileId()); success = docInfoService.updateById(docInfo); // æ´æ°è®¾å¤å ³è if (!updateDeviceLink(thirdDeProgramSource.getEquipmentId(), docInfo.getDocId(), sendDocClass)) { return createErrorModel(model, "æ´æ°è®¾å¤ææ¡£å ³è失败"); } } } if (!success) { return createErrorModel(model, "å¤ç3DE NCæä»¶å¤±è´¥"); } } } return model; } catch (Exception e) { log.error("å¤ç3DEç¨åºæ°æ®å¼å¸¸: {}", e.getMessage(), e); return createErrorModel(model, "å¤ç3DEç¨åºæ°æ®å¼å¸¸: " + e.getMessage()); } } /** * æ·»å å°è®¾å¤ */ private boolean linkToDevice(String equipmentId, String docId, DocFile docFile, DocClassification sendDocClass) { try { DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(equipmentId); if (deviceInfo == null) { log.error("DNCä¸è®¾å¤ä¸åå¨: {}", equipmentId); return false; } DocRelative deviceDocRelative = new DocRelative(); deviceDocRelative.setAttributionId(deviceInfo.getDeviceId()); deviceDocRelative.setDocId(docId); deviceDocRelative.setAttributionType(4); deviceDocRelative.setClassificationId(sendDocClass.getClassificationId()); boolean saved = docRelativeService.save(deviceDocRelative); if (!saved) { log.error("ä¿åè®¾å¤ææ¡£å ³è失败: device={}, doc={}", equipmentId, docId); return false; } // å¤å¶æä»¶å°è®¾å¤è·¯å¾ List<String> groupPaths = deviceGroupService.findListParentTreeAll(deviceInfo.getGroupId()); if (groupPaths != null && !groupPaths.isEmpty()) { String devicePath = String.join("/", groupPaths) + "/" + deviceInfo.getDeviceNo(); // å¤å¶æä»¶ boolean copySuccess = FileUtil.copyFileNc( docFile.getFilePath(), devicePath, docFile.getFileEncodeName(), docFile.getFileName(), docFile.getFileSuffix()); if (!copySuccess) { log.error("æä»¶å¤å¶å¤±è´¥: {} -> {}", docFile.getFilePath(), devicePath); return false; } // å 餿§çæ¬æä»¶ FileUtil.deleteZipFromToSend( devicePath, docFile.getFileName(), docFile.getFileSuffix()); } return true; } catch (Exception e) { log.error("æ·»å è®¾å¤ææ¡£å ³èå¼å¸¸: {}", e.getMessage(), e); return false; } } /** * æ´æ°è®¾å¤å ³è */ private boolean updateDeviceLink(String equipmentId, String docId, DocClassification sendDocClass) { try { DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(equipmentId); if (deviceInfo == null) { log.error("DNCä¸è®¾å¤ä¸åå¨: {}", equipmentId); return false; } // æ£æ¥å ³èæ¯å¦å·²åå¨ DocRelative existingRel = docRelativeService.findDocRelative(docId,sendDocClass.getClassificationId(), 4,deviceInfo.getDeviceId()); if (existingRel == null) { // å建æ°å ³è DocRelative deviceDocRelative = new DocRelative(); deviceDocRelative.setAttributionId(deviceInfo.getDeviceId()); deviceDocRelative.setDocId(docId); deviceDocRelative.setAttributionType(4); deviceDocRelative.setClassificationId(sendDocClass.getClassificationId()); return docRelativeService.save(deviceDocRelative); } return true; } catch (Exception e) { log.error("æ´æ°è®¾å¤å ³èå¼å¸¸: {}", e.getMessage(), e); return false; } } /** * 为3DEæ°æ®å建æ§çæ¬NCæä»¶å¤ä»½ */ private boolean createFileOldNcPathAndCopyFor3DE(DocInfo docInfo, ThirdDeProgramSource thirdDeProgramSource) { DocFile docFile = docFileService.getDocFileNearest(docInfo.getDocId()); if (docFile == null) { log.error("æªæ¾å°æè¿çæ¬ç3DEææ¡£æä»¶ï¼docId: {}", docInfo.getDocId()); return false; } String directoryPath = String.join(File.separator, "3de_bak", thirdDeProgramSource.getNcPlantName(), thirdDeProgramSource.getPartNo(), thirdDeProgramSource.getSkgxId(), ""); File directory = new File(directoryPath); if (!directory.exists() && !directory.mkdirs()) { log.error("å建3DEç®å½å¤±è´¥: {}", directoryPath); return false; } // æå»ºç®æ æä»¶è·¯å¾ String targetFileName = buildTargetFileName(docFile); String targetFilePath = directoryPath + targetFileName; try { Path sourcePath = Paths.get(docFile.getFilePath()); Path targetPath = Paths.get(targetFilePath); Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); log.info("3DEæä»¶å¤å¶æå: {} -> {}", docFile.getFilePath(), targetFilePath); return true; } catch (IOException e) { log.error("3DEæä»¶å¤å¶å¤±è´¥: {}", e.getMessage(), e); if (directory.exists() && isDirectoryEmpty(directory)) { directory.delete(); } return false; } } /** * ä¿åé¶ä»¶æé */ private boolean savePartsPermission(PartsInfo partsInfo, String productId) { List<PermissionStream> oldPermissionList = permissionStreamService.getAllByProductId(productId); if (CollectionUtils.isEmpty(oldPermissionList)) { return true; } List<PartsDepartment> partsDepartPermList = new ArrayList<>(); List<PermissionStream> partsPermList = new ArrayList<>(); List<PartsPermission> partsUserPermList = new ArrayList<>(); for (PermissionStream p : oldPermissionList) { if (ValidateUtil.validateString(p.getUserId())) { // ç¨æ·æé PartsPermission permission = new PartsPermission(); permission.setPartsId(partsInfo.getPartsId()); permission.setUserId(p.getUserId()); partsUserPermList.add(permission); PermissionStream stream = new PermissionStream(); stream.setUserId(p.getUserId()); stream.setProductId(partsInfo.getProductId()); stream.setComponentId(partsInfo.getComponentId()); stream.setPartsId(partsInfo.getPartsId()); partsPermList.add(stream); } if (ValidateUtil.validateString(p.getDepartId())) { // é¨é¨æé PartsDepartment department = new PartsDepartment(); department.setPartsId(partsInfo.getPartsId()); department.setDepartId(p.getDepartId()); partsDepartPermList.add(department); PermissionStream stream = new PermissionStream(); stream.setProductId(partsInfo.getProductId()); stream.setComponentId(partsInfo.getComponentId()); stream.setPartsId(partsInfo.getPartsId()); stream.setDepartId(p.getDepartId()); partsPermList.add(stream); } } boolean success = true; if (!partsUserPermList.isEmpty()) { success = success && partsPermissionService.saveBatch(partsUserPermList); } if (!partsDepartPermList.isEmpty()) { success = success && partsDepartmentService.saveBatch(partsDepartPermList); } if (!partsPermList.isEmpty()) { success = success && permissionStreamService.saveBatch(partsPermList); } return success; } private MesResultModel createErrorModel(MesResultModel model, String errorMsg) { model.setSuccFlag("失败"); model.setError(errorMsg); return model; } /** * * NCç¨åºé½å¥æ¥å£ï¼MESï¼-DNCç³»ç»æ¥æ¶å°PLMä¼ çNCç¨åºï¼å°ç¨åºå 对åºçé¶ä»¶å·ãå·¥åºå·ã设å¤ç¼å·ä¼ ç»MESç³»ç» * 宿¶æ«æPlmProgramSourceInfo表ä¸çæ°æ®ï¼è¿è¡æ°æ®åæ¥ï¼æ¯åé忥䏿¬¡ */ @Scheduled(cron = "0 0/1 * * * ?") @Transactional(rollbackFor = Exception.class) public void syncWorkmanship() { // è·åææéè¦åæ¥çæ°æ® List<PlmProgramSourceInfo> plmProgramSourceInfos = iPlmProgramSourceInfoService.list( new LambdaQueryWrapper<PlmProgramSourceInfo>() .eq(PlmProgramSourceInfo::getMesStatus, "0") .orderByAsc(PlmProgramSourceInfo::getId) ); if (plmProgramSourceInfos.isEmpty()) { log.info("æ å¾ åæ¥æ°æ®ï¼è·³è¿å¤ç"); return; } List<NcProgramInfo> ncProgramInfos = plmProgramSourceInfos.stream().map(item -> { NcProgramInfo ncProgramInfo = new NcProgramInfo(); ncProgramInfo.setMdsItemCode(item.getCzkAe8nPartNo()); ncProgramInfo.setRevisionNo(item.getRevisionNo()); ncProgramInfo.setNcProgramName(item.getFileName()); ncProgramInfo.setOpreationSeqNo(item.getCzkAe8nOpNo()); ncProgramInfo.setEquipmentId(item.getCzkAe8nEquipNo()); ncProgramInfo.setWorkshop(item.getCzkAe8nDivision()); // ncProgramInfo.setMesId(item.getId()); // ç¡®ä¿çæç¬¦åè¦æ±çmesId // ncProgramInfo.setOperFlag(); return ncProgramInfo; }).collect(Collectors.toList()); log.info("WebService-NCç¨åºé½å¥æ¥å£ï¼MESï¼åæ¥å¼å§ï¼æ¶é´: {}", new Date()); try { String jsonPayload = JSONObject.toJSONString(ncProgramInfos); log.debug("䏿¥æ°æ®: {}", jsonPayload); // è°ç¨WebServiceå¹¶è·å详ç»ååº String result = CxfClientUtil.invokeService(url, jsonPayload, namespace, method); log.info("æ¥å£ååº: {}", result); // è§£æååºç»æï¼åªä¼ææåå失败 if (result.contains("æå")) { List<PlmProgramSourceInfo> toUpdate = new ArrayList<>(); plmProgramSourceInfos.forEach(item -> { item.setMesStatus("1"); toUpdate.add(item); }); // æ¹éæ´æ°ç¶æ if (!toUpdate.isEmpty()) { iPlmProgramSourceInfoService.updateBatchById(toUpdate); log.info("æåæ´æ°{}æ¡æ°æ®ç¶æ", toUpdate.size()); } }else { log.error("忥MESç³»ç»å¤±è´¥: {}", result); } } catch (Exception e) { log.error("忥MESç³»ç»å¤±è´¥: {}", e.getMessage(), e); // ä» æ è®°å¤ç失败çè®°å½ plmProgramSourceInfos.forEach(item -> item.setMesStatus("0")); iPlmProgramSourceInfoService.updateBatchById(plmProgramSourceInfos); throw new RuntimeException("åæ¥å¤±è´¥ï¼å·²åæ»ç¶æ", e); // 触åäºå¡åæ» } } /** @@ -644,17 +844,6 @@ } String[] files = directory.list(); return files == null || files.length == 0; } private static String buildRequestBody(NcProgramInfo ncProgramInfo) { StringBuilder body = new StringBuilder(); body.append("mesId=").append(ncProgramInfo.getMesId()) .append("&mdsItemCode=").append(ncProgramInfo.getMdsItemCode()) .append("&revisionNo=").append(ncProgramInfo.getRevisionNo()) .append("&opreationSeqNo=").append(ncProgramInfo.getOpreationSeqNo()) .append("&equipmentId=").append(ncProgramInfo.getEquipmentId()) .append("&workshop=").append(ncProgramInfo.getWorkshop()); return body.toString(); } src/main/resources/application.yml
@@ -10,7 +10,7 @@ application: name: lxzn-dev-admin datasource: url: jdbc:mysql://127.0.0.1:3316/lxzn_qlj_nc?useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true url: jdbc:mysql://127.0.0.1:3316/lxzn_qlj_nc?serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&tinyInt1isBit=false&nullCatalogMeansCurrent=true&characterEncoding=utf8 username: root password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver @@ -42,11 +42,13 @@ maxIdle: 3 minIdle: 1 maxWait: -1 #è¿æ¥æ± æå¤§çè¡æ¶é´ -1没æéå¶ database: 5 activiti: check-process-definitions: true database-schema-update: true db-history-used: true history-level: full async-executor-activate: false servlet: multipart: #é»è®¤æ¯ææä»¶ä¸ä¼ . @@ -116,9 +118,6 @@ dnc: server: url: http://localhost:8199 ncPdm: file_path: d://lxzn_storage/plm fileOldNcPath: dnc//plm_bak #æ§æä»¶è®°å½å°å webservice: url: http://20.10.193.21:9308/webservice/mes/eqiupment/v1/mdc2mes.asmx?wsdl src/main/resources/com.lxzn.base.dao/MdcPassLogMapper.xml
@@ -1,9 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.base.dao.DncPassLogMapper"> <select id="findDateTimeDay" resultType="DncPassLog" parameterType="String"> select top 1 * from dnc_pass_log u where day_time = #{dayTime} order by create_time desc <select id="findDateTimeDay" resultType="com.lxzn.framework.domain.base.DncPassLog" parameterType="String"> SELECT * FROM dnc_pass_log u WHERE day_time = #{dayTime} ORDER BY create_time DESC LIMIT 1; </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/ComponentDepartmentMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.ComponentDepartmentMapper"> <select id="getDepartPermsByComponentId" resultType="Department" parameterType="String"> <select id="getDepartPermsByComponentId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -14,7 +14,7 @@ on u.depart_id=p.depart_id </select> <select id="getDepartNonPermsByComponentId" resultType="Department" parameterType="String"> <select id="getDepartNonPermsByComponentId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -24,4 +24,4 @@ from sys_department u where u.depart_id not in (select depart_id from nc_component_department where component_id=#{componentId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/ComponentPermissionMapper.xml
@@ -14,7 +14,7 @@ on u.user_id=p.user_id </select> <select id="getUserNonPermsByComponentId" resultType="User" parameterType="String"> <select id="getUserNonPermsByComponentId" resultType="com.lxzn.framework.domain.ucenter.User" parameterType="String"> select u.user_id , u.username , u.nickname @@ -24,4 +24,4 @@ from sys_user u where u.user_id not in (select user_id from nc_component_permission where component_id=#{componentId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/DeviceGroupDepartMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.DeviceGroupDepartMapper"> <select id="getDepartPermsByGroupId" resultType="Department" parameterType="String"> <select id="getDepartPermsByGroupId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -14,7 +14,7 @@ on u.depart_id=p.depart_id </select> <select id="getDepartNonPermsByGroupId" resultType="Department" parameterType="String"> <select id="getDepartNonPermsByGroupId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -24,4 +24,4 @@ from sys_department u where u.depart_id not in (select depart_id from nc_device_group_department where group_id=#{groupId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/DeviceGroupMapper.xml
@@ -39,17 +39,17 @@ where parent_id=#{parentId} and delete_flag=0 </select> <resultMap id="deviceGroupExtPermsMap" type="DeviceGroupExt"> <resultMap id="deviceGroupExtPermsMap" type="com.lxzn.framework.domain.nc.ext.DeviceGroupExt"> <id column="group_id" property="groupId" /> <result column="user_id" property="userId" /> <collection column="{parentId=group_id, userId=user_id}" property="children" javaType="ArrayList" ofType="DeviceGroupExt" select="getByParentIdAndUserPerms"> javaType="ArrayList" ofType="com.lxzn.framework.domain.nc.ext.DeviceGroupExt" select="getByParentIdAndUserPerms"> <id column="group_id" property="groupId" /> <result column="user_id" property="userId" /> </collection> </resultMap> <resultMap id="deviceGroupExtPermsMapAs" type="DeviceGroupExt"> <resultMap id="deviceGroupExtPermsMapAs" type="com.lxzn.framework.domain.nc.ext.DeviceGroupExt"> <id column="group_id" property="groupId" /> <association property="parent" column="{id=parent_id}" select="findById"> </association> src/main/resources/com.lxzn.nc.dao/DeviceGroupPermissionMapper.xml
@@ -14,7 +14,7 @@ on u.user_id=p.user_id </select> <select id="getUserNonPermsByGroupId" resultType="User" parameterType="String"> <select id="getUserNonPermsByGroupId" resultType="com.lxzn.framework.domain.ucenter.User" parameterType="String"> select u.user_id , u.username , u.nickname @@ -24,4 +24,4 @@ from sys_user u where u.user_id not in (select user_id from nc_device_group_permission where group_id=#{groupId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/DeviceInfoMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.DeviceInfoMapper"> <select id="getDeviceByUserPermed" resultType="DeviceInfo" parameterType="String"> <select id="getDeviceByUserPermed" resultType="com.lxzn.framework.domain.nc.DeviceInfo" parameterType="String"> select d.device_id , d.group_id , d.device_no src/main/resources/com.lxzn.nc.dao/DevicePermissionMapper.xml
@@ -14,7 +14,7 @@ on u.user_id=p.user_id </select> <select id="getUserNonPermsByDeviceId" resultType="User" parameterType="String"> <select id="getUserNonPermsByDeviceId" resultType="com.lxzn.framework.domain.ucenter.User" parameterType="String"> select u.user_id , u.username , u.nickname @@ -24,4 +24,4 @@ from sys_user u where u.user_id not in (select user_id from nc_device_permission where device_id=#{deviceId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/DocInfoMapper.xml
@@ -4,7 +4,7 @@ <delete id="deleteByDocId"> delete from nc_doc_info where doc_id = #{docId} </delete> <select id="findDocExtList" parameterType="String" resultType="DocInfo"> <select id="findDocExtList" parameterType="String" resultType="com.lxzn.framework.domain.nc.DocInfo"> select u.doc_id ,r.classification_id @@ -36,7 +36,7 @@ </select> <select id="findDeviceDocExtList" parameterType="String" resultType="DocInfo"> <select id="findDeviceDocExtList" parameterType="String" resultType="com.lxzn.framework.domain.nc.DocInfo"> select u.doc_id ,r.classification_id @@ -70,7 +70,7 @@ ${ew.customSqlSegment} </select> <select id="findByAttrAndDocName" parameterType="Map" resultType="DocInfo"> <select id="findByAttrAndDocName" parameterType="Map" resultType="com.lxzn.framework.domain.nc.DocInfo"> select r.doc_id ,r.attribution_id ,r.attribution_type @@ -89,7 +89,7 @@ where d.delete_flag=0 and d.doc_name=#{docName} and d.doc_suffix=#{docSuffix} </select> <select id="getByDocAttrAndDocId" parameterType="Map" resultType="DocInfo"> <select id="getByDocAttrAndDocId" parameterType="Map" resultType="com.lxzn.framework.domain.nc.DocInfo"> select r.doc_id ,r.attribution_id ,r.attribution_type @@ -109,7 +109,7 @@ where d.delete_flag=0 </select> <select id="getByDocId" parameterType="String" resultType="DocInfo"> <select id="getByDocId" parameterType="String" resultType="com.lxzn.framework.domain.nc.DocInfo"> select r.doc_id ,r.attribution_id ,r.attribution_type src/main/resources/com.lxzn.nc.dao/DocRelativeMapper.xml
@@ -4,7 +4,7 @@ <delete id="deleteById"> delete from nc_doc_relative where doc_id = #{docId} </delete> <select id="findDeviceByDocId" resultType="DeviceInfo" parameterType="String"> <select id="findDeviceByDocId" resultType="com.lxzn.framework.domain.nc.DeviceInfo" parameterType="String"> select d.device_id , d.group_id , d.device_no src/main/resources/com.lxzn.nc.dao/PartsDepartmentMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.PartsDepartmentMapper"> <select id="getDepartPermsByPartsId" resultType="Department" parameterType="String"> <select id="getDepartPermsByPartsId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -14,7 +14,7 @@ on u.depart_id=p.depart_id </select> <select id="getDepartNonPermsByProductId" resultType="Department" parameterType="String"> <select id="getDepartNonPermsByProductId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -24,4 +24,4 @@ from sys_department u where u.depart_id not in (select depart_id from nc_parts_department where parts_id=#{partsId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/PartsInfoMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.PartsInfoMapper"> <select id="getByUserPerms" resultType="PartsInfo" parameterType="String"> <select id="getByUserPerms" resultType="com.lxzn.framework.domain.nc.PartsInfo" parameterType="String"> select p.parts_id , p.parts_name , p.product_id src/main/resources/com.lxzn.nc.dao/PartsPermissionMapper.xml
@@ -14,7 +14,7 @@ on u.user_id=p.user_id </select> <select id="getUserNonPermsByProductId" resultType="User" parameterType="String"> <select id="getUserNonPermsByProductId" resultType="com.lxzn.framework.domain.ucenter.User" parameterType="String"> select u.user_id , u.username , u.nickname @@ -24,4 +24,4 @@ from sys_user u where u.user_id not in (select user_id from nc_parts_permission where parts_id=#{partsId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/ProductDepartmentMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.ProductDepartmentMapper"> <select id="getDepartPermsByProductId" resultType="Department" parameterType="String"> <select id="getDepartPermsByProductId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -14,7 +14,7 @@ on u.depart_id=p.depart_id </select> <select id="getDepartNonPermsByProductId" resultType="Department" parameterType="String"> <select id="getDepartNonPermsByProductId" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select u.depart_id , u.depart_name , u.depart_code @@ -24,4 +24,4 @@ from sys_department u where u.depart_id not in (select depart_id from nc_product_department where product_id=#{productId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.nc.dao/ProductInfoMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.nc.dao.ProductInfoMapper"> <select id="getByUserPerms" resultType="ProductInfo" parameterType="String"> <select id="getByUserPerms" resultType="com.lxzn.framework.domain.nc.ProductInfo" parameterType="String"> select p.product_id , p.product_no , p.product_model src/main/resources/com.lxzn.nc.dao/ProductPermissionMapper.xml
@@ -14,7 +14,7 @@ on u.user_id=p.user_id </select> <select id="getUserNonPermsByProductId" resultType="User" parameterType="String"> <select id="getUserNonPermsByProductId" resultType="com.lxzn.framework.domain.ucenter.User" parameterType="String"> select u.user_id , u.username , u.nickname @@ -24,4 +24,4 @@ from sys_user u where u.user_id not in (select user_id from nc_product_permission where product_id=#{productId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.ucenter.dao/ButtonMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.ucenter.dao.ButtonMapper"> <select id="getButtonPerms" parameterType="String" resultType="Button"> <select id="getButtonPerms" parameterType="String" resultType="com.lxzn.framework.domain.ucenter.Button"> select distinct b.button_id , b.button_perm , b.button_name @@ -15,7 +15,7 @@ </select> <select id="getMenuButtonPerms" parameterType="java.util.Map" resultType="Button"> <select id="getMenuButtonPerms" parameterType="java.util.Map" resultType="com.lxzn.framework.domain.ucenter.Button"> select distinct b.button_id , b.button_perm , b.button_name @@ -33,7 +33,7 @@ where u.user_id=#{userId} </select> <select id="getObjectButtonPerms" parameterType="java.util.Map" resultType="Button"> <select id="getObjectButtonPerms" parameterType="java.util.Map" resultType="com.lxzn.framework.domain.ucenter.Button"> select distinct b.button_id , b.button_perm , b.button_name @@ -50,4 +50,4 @@ on u.role_id=r.role_id where u.user_id=#{userId} </select> </mapper> </mapper> src/main/resources/com.lxzn.ucenter.dao/DepartmentMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.ucenter.dao.DepartmentMapper"> <select id="getUserPermDepart" resultType="Department" parameterType="String"> <select id="getUserPermDepart" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select r.depart_id, r.depart_name, r.depart_code, r.description from (select depart_id, depart_name, depart_code, description from sys_department where delete_flag=0) r @@ -10,7 +10,7 @@ on r.depart_id=ur.depart_id </select> <select id="getUserNonPermDepart" resultType="Department" parameterType="String"> <select id="getUserNonPermDepart" resultType="com.lxzn.framework.domain.ucenter.Department" parameterType="String"> select r.depart_id, r.depart_name, r.depart_code, r.description from (select depart_id, depart_name, depart_code, description from sys_department where delete_flag=0) r where r.depart_id not in @@ -51,7 +51,7 @@ where delete_flag = 0 and parent_id=#{parentId} </select> <select id="getUserApproveDepart" parameterType="String" resultType="User"> <select id="getUserApproveDepart" parameterType="String" resultType="com.lxzn.framework.domain.ucenter.User"> select u.user_id , u.username , u.nickname @@ -68,7 +68,7 @@ on u.user_id=d.user_id </select> <select id="getUserNonApproveDepart" parameterType="String" resultType="User"> <select id="getUserNonApproveDepart" parameterType="String" resultType="com.lxzn.framework.domain.ucenter.User"> select u.user_id , u.username , u.nickname @@ -83,4 +83,4 @@ from sys_user u where u.user_id not in (select user_id from sys_depart_approve_user where depart_id=#{departId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.ucenter.dao/MenuMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.ucenter.dao.MenuMapper"> <select id="findByUserId" parameterType="String" resultType="Menu"> <select id="findByUserId" parameterType="String" resultType="com.lxzn.framework.domain.ucenter.Menu"> select m.menu_id , m.perm_code , m.menu_name @@ -23,13 +23,13 @@ 3ãå¤çº§å ³èè¯å¥æ¯å弿¥è¯¢ç æ°æ®éå¤§çæ åµä¸æ§è½ä½ä¸ 4ãå¦æç¡®å®çº§æ å¯ä»¥ä½¿ç¨çº§èæ¥è¯¢ä¸æ¬¡æ¥è¯¢ ä¾åï¼ --> <resultMap id="menuExtBaseResult" type="MenuExt"> <resultMap id="menuExtBaseResult" type="com.lxzn.framework.domain.ucenter.ext.MenuExt"> <id column="menu_id" property="menuId" /> <collection column="menu_id" property="childList" select="findByParentId"> </collection> </resultMap> <resultMap id="menuExtSingleSelectResult" type="MenuExt"> <resultMap id="menuExtSingleSelectResult" type="com.lxzn.framework.domain.ucenter.ext.MenuExt"> <id column="menu_id_one" property="menuId" /> <result column="perm_code_one" property="permCode" /> <result column="menu_name_one" property="menuName" /> @@ -38,7 +38,7 @@ <result column="icon_cls_one" property="iconCls" /> <result column="priority_one" property="priority" /> <result column="rank_level_one" property="rankLevel" /> <collection property="childList" ofType="MenuExt"> <collection property="childList" ofType="com.lxzn.framework.domain.ucenter.ext.MenuExt"> <id column="menu_id_two" property="menuId" /> <result column="perm_code_two" property="permCode" /> <result column="menu_name_two" property="menuName" /> @@ -47,7 +47,7 @@ <result column="icon_cls_two" property="iconCls" /> <result column="priority_two" property="priority" /> <result column="rank_level_two" property="rankLevel" /> <collection property="childList" ofType="MenuExt"> <collection property="childList" ofType="com.lxzn.framework.domain.ucenter.ext.MenuExt"> <id column="menu_id_three" property="menuId" /> <result column="perm_code_three" property="permCode" /> <result column="menu_name_three" property="menuName" /> @@ -120,4 +120,4 @@ on cm.parent_id = bm.menu_id where am.rank_level=1 and am.delete_flag=0 </select> </mapper> </mapper> src/main/resources/com.lxzn.ucenter.dao/RoleMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.ucenter.dao.RoleMapper"> <select id="getUserPermRole" resultType="Role" parameterType="String"> <select id="getUserPermRole" resultType="com.lxzn.framework.domain.ucenter.Role" parameterType="String"> select r.role_id, r.role_code, r.role_name, r.description from (select role_id, role_code, role_name, description from sys_role where delete_flag=0) r @@ -10,10 +10,10 @@ on r.role_id=ur.role_id </select> <select id="getUserNonPermRole" resultType="Role" parameterType="String"> <select id="getUserNonPermRole" resultType="com.lxzn.framework.domain.ucenter.Role" parameterType="String"> select r.role_id, r.role_code, r.role_name, r.description from (select role_id, role_code, role_name, description from sys_role where delete_flag=0) r where r.role_id not in (select role_id from sys_user_role where user_id=#{userId}) </select> </mapper> </mapper> src/main/resources/com.lxzn.ucenter.dao/UserMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.lxzn.ucenter.dao.UserMapper"> <select id="findUserExtByUsername" parameterType="String" resultType="UserExt"> <select id="findUserExtByUsername" parameterType="String" resultType="com.lxzn.framework.domain.ucenter.ext.UserExt"> select u.user_id ,u.username @@ -18,7 +18,7 @@ ${ew.customSqlSegment} </select> <resultMap id="userDepartExt" type="UserDepartExt"> <resultMap id="userDepartExt" type="com.lxzn.framework.domain.ucenter.ext.UserDepartExt"> <id column="user_id" property="userId" /> <collection column="user_id" property="departs" select="com.lxzn.ucenter.dao.DepartmentMapper.getUserPermDepart"> </collection> @@ -55,4 +55,4 @@ from sys_user u where u.delete_flag=0 </select> </mapper> </mapper> src/main/resources/processes/assign_nc_to_device.bpmn
@@ -1,61 +1,61 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1589077876043" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema"> <process id="assign_nc_to_device" isClosed="false" isExecutable="true" name="ææ´¾NCææ¡£å°è®¾å¤" processType="None"> <startEvent id="_2" name="StartEvent"/> <userTask activiti:assignee="${apply_user}" activiti:exclusive="true" id="_3" name="æäº¤ç³è¯·"/> <userTask activiti:candidateUsers="${approve_users}" activiti:exclusive="true" id="_4" name="审æ¹"/> <endEvent id="_5" name="EndEvent"/> <sequenceFlow id="_6" sourceRef="_2" targetRef="_3"/> <sequenceFlow id="_7" sourceRef="_3" targetRef="_4"/> <sequenceFlow id="_8" sourceRef="_4" targetRef="_5"/> </process> <bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram"> <bpmndi:BPMNPlane bpmnElement="assign_nc_to_device"> <bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2"> <omgdc:Bounds height="32.0" width="32.0" x="40.0" y="135.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3"> <omgdc:Bounds height="55.0" width="85.0" x="145.0" y="125.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4"> <omgdc:Bounds height="55.0" width="85.0" x="335.0" y="125.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5"> <omgdc:Bounds height="32.0" width="32.0" x="545.0" y="135.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_2" targetElement="_3"> <omgdi:waypoint x="72.0" y="151.0"/> <omgdi:waypoint x="145.0" y="152.5"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_3" targetElement="_4"> <omgdi:waypoint x="230.0" y="152.5"/> <omgdi:waypoint x="335.0" y="152.5"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_4" targetElement="_5"> <omgdi:waypoint x="420.0" y="152.5"/> <omgdi:waypoint x="545.0" y="151.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> <process id="assign_nc_to_device" isClosed="false" isExecutable="true" name="ææ´¾NCææ¡£å°è®¾å¤" processType="None"> <startEvent id="_2" name="StartEvent"/> <userTask activiti:assignee="${apply_user}" activiti:exclusive="true" id="_3" name="æäº¤ç³è¯·"/> <userTask activiti:candidateUsers="${approve_users}" activiti:exclusive="true" id="_4" name="审æ¹"/> <endEvent id="_5" name="EndEvent"/> <sequenceFlow id="_6" sourceRef="_2" targetRef="_3"/> <sequenceFlow id="_7" sourceRef="_3" targetRef="_4"/> <sequenceFlow id="_8" sourceRef="_4" targetRef="_5"/> </process> <bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram"> <bpmndi:BPMNPlane bpmnElement="assign_nc_to_device"> <bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2"> <omgdc:Bounds height="32.0" width="32.0" x="40.0" y="135.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3"> <omgdc:Bounds height="55.0" width="85.0" x="145.0" y="125.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4"> <omgdc:Bounds height="55.0" width="85.0" x="335.0" y="125.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5"> <omgdc:Bounds height="32.0" width="32.0" x="545.0" y="135.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="_2" targetElement="_3"> <omgdi:waypoint x="72.0" y="151.0"/> <omgdi:waypoint x="145.0" y="152.5"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_3" targetElement="_4"> <omgdi:waypoint x="230.0" y="152.5"/> <omgdi:waypoint x="335.0" y="152.5"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_4" targetElement="_5"> <omgdi:waypoint x="420.0" y="152.5"/> <omgdi:waypoint x="545.0" y="151.0"/> <bpmndi:BPMNLabel> <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>