ruoyi-admin/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/enums/PhotoEnum.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/enums/RadioEnum.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/enums/VadioEnum.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ruoyi-admin/pom.xml
@@ -130,8 +130,42 @@ <artifactId>nls-sdk-common</artifactId> <version>2.1.6</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>5.2.3</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <version>5.2.3</version> </dependency> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.12.0</version> </dependency> <dependency> <groupId>xml-apis</groupId> <artifactId>xml-apis</artifactId> <version>1.4.01</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>5.2.3</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>3.1.0</version> </dependency> </dependencies> <build> <plugins> <plugin> @@ -162,4 +196,18 @@ <finalName>${project.artifactId}</finalName> </build> <repositories> <repository> <id>central</id> <url>https://repo.maven.apache.org/maven2</url> </repository> <repository> <id>aliyun</id> <url>https://maven.aliyun.com/repository/public</url> </repository> <repository> <id>jcenter</id> <url>https://jcenter.bintray.com/</url> </repository> </repositories> </project> ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -263,6 +263,118 @@ } /** * 宣æä»»å¡å¤ç * * @param commonTaskcallMQ */ private void xjHandle(CommonTaskcallMQ commonTaskcallMQ) { //夿ä¸ä¸commonTaskcallMQä¸çstopstateæ¯å¦ä¸ivr_taskä¸çä¸è´ï¼ä¸ä¸è´ï¼åè¯´ææ¯æåäº ServiceTask ivrTask1 = ivrTaskMapper.selectServiceTaskByTaskid(commonTaskcallMQ.getTaskid()); if (ivrTask1.getStopState() != commonTaskcallMQ.getStopState()) { //å°æ¶æ¯ä»éåä¸åé¤ return; } if (StringUtils.isNotEmpty(commonTaskcallMQ.getPreachform())) { //å¦ä½ä»»å¡åéæ¹å¼ä¸ä¸ºç©º String[] split = commonTaskcallMQ.getPreachform().split(","); System.out.println("splitçå¼ä¸ºï¼" + split); for (String serviceFrom : split) { String descByCode = ServiceFromEnum.getDescByCode(Integer.valueOf(serviceFrom)); //è¿éå¯ä»¥èèç¨çç¥æ¨¡å¼ä¼åä¸ä¸ï¼ä¸ç¶å¤ªé¾çäº //éè¿æ¨¡æ¿IDè·å模æ¿é®é¢ IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO(); ivrTaskTemplateVO.setID(Long.valueOf(commonTaskcallMQ.getTemplateid())); IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO); //éè¿ä»»å¡IDæ¿å°æ£è ä¿¡æ¯ ServiceSubtask ivrTaskcall = new ServiceSubtask(); ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); List<ServiceSubtask> ivrTaskcalls = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); if (descByCode.equals("çµè¯")) { for (ServiceSubtask ivrTaskcall1 : ivrTaskcalls) { ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(ivrTaskcall1.getTaskid()); if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) { //å¦ä½ä»»å¡è¢«âæåâæâç»æ¢â break; } //ä»»å¡åéè®°å½ï¼è¿ä¸ªä»£ç åºè¯¥åå¨phoneTaskä¸ï¼å åå¨è¿ï¼åé¢åæ¹ï¼ ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); serviceSubtaskRecord.setTaskid(ivrTaskcall1.getTaskid().toString()); serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); serviceSubtaskRecord.setTasktype(ivrTaskcall1.getType()); serviceSubtaskRecord.setPreachform("3"); serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); //éè¿å¤çº¿ç¨çæ¹å¼å»æçµè¯ executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); } } else if (descByCode.equals("å¤åªä½")) { //å¤åªä½ } else if (descByCode.equals("纸质")) { //纸质 } else if (descByCode.equals("çä¿¡")) { //çä¿¡ // http://localhost:8099/followvisit/particty?param1=3¶m2=348 //对urlä¸ä¸¤ä¸ªåæ°å å¯ RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); SendMagParam sendMagParam = new SendMagParam(); sendMagParam.setType("4"); sendMagParam.setUrl(req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); Boolean aBoolean = sendService.sendMsg(sendMagParam); //ä»»å¡åéè®°å½ ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); serviceSubtaskRecord.setPreachform("4"); serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); serviceSubtaskRecord.setResult(aBoolean == true ? "æå" : "失败"); serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); } } else if (descByCode.equals("å ¬ä¼å·")) { //å ¬ä¼å· RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); SendMagParam sendMagParam = new SendMagParam(); sendMagParam.setType("5"); sendMagParam.setUrl(req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); log.info("龿¥å®æ´è·¯å¾ï¼{}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); //è¿ä¸ªæ¨¡æ¿IDå åæ»ï¼åé¢åæå¯é sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); Map map = new HashMap(); map.put("first", ivrTask1.getTaskName()); sendMagParam.setContent(JSON.toJSONString(map)); Boolean aBoolean = sendService.sendMsg(sendMagParam); //ä»»å¡åéè®°å½ ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); serviceSubtaskRecord.setPreachform("4"); serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); serviceSubtaskRecord.setResult(aBoolean == true ? "æå" : "失败"); serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); } } //éç¥ MQ æ¶æ¯å·²è¢«æ¥æ¶,å¯ä»¥ACK(ä»éåä¸å é¤)äº ï¼è¿ä¸ªéè¦æ ¹æ®ä¸å¡åå»å¤çACKï¼ } } } /** * é®å·ä»»å¡å¤ç * * @param commonTaskcallMQ ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -1,9 +1,26 @@ package com.ruoyi.web.controller.common; import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.lang.model.util.Elements; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import com.ruoyi.common.enums.PhotoEnum; import com.ruoyi.common.enums.RadioEnum; import com.ruoyi.common.enums.VadioEnum; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.converter.PicturesManager; import org.apache.poi.hwpf.converter.WordToHtmlConverter; import org.apache.poi.hwpf.usermodel.Picture; import org.apache.poi.hwpf.usermodel.PictureType; import org.jsoup.Jsoup; import org.jsoup.nodes.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +37,8 @@ import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.framework.config.ServerConfig; import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.w3c.dom.Document; /** * éç¨è¯·æ±å¤ç @@ -28,8 +47,7 @@ */ @RestController @RequestMapping("/common") public class CommonController { public class CommonController { private static final Logger log = LoggerFactory.getLogger(CommonController.class); @Autowired @@ -44,12 +62,9 @@ * @param delete æ¯å¦å é¤ */ @GetMapping("/download") public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { try { if (!FileUtils.checkAllowDownload(fileName)) { public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { try { if (!FileUtils.checkAllowDownload(fileName)) { throw new Exception(StringUtils.format("æä»¶åç§°({})éæ³ï¼ä¸å 许ä¸è½½ã ", fileName)); } String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); @@ -58,14 +73,71 @@ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); FileUtils.setAttachmentResponseHeader(response, realFileName); FileUtils.writeBytes(filePath, response.getOutputStream()); if (delete) { if (delete) { FileUtils.deleteFile(filePath); } } catch (Exception e) { } catch (Exception e) { log.error("ä¸è½½æä»¶å¤±è´¥", e); } } /** * åç±»ä¸ä¼ è¯·æ± */ @PostMapping("/uploadSort") public AjaxResult uploadFileSort(MultipartFile file) { try { // ä¸ä¼ æä»¶è·¯å¾ String filePath = RuoYiConfig.getUploadPath(); String originalFilename = file.getOriginalFilename().split("\\.", 2)[1]; if (VadioEnum.getDescByCode(originalFilename)) { filePath = filePath + "/vadio"; } else if (RadioEnum.getDescByCode(originalFilename)) { filePath = filePath + "/radio"; } else if (PhotoEnum.getDescByCode(originalFilename)) { filePath = filePath + "/photo"; } else { filePath = filePath + "/file"; } // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° String fileName = FileUploadUtils.uploadSort(filePath, file); String url = serverConfig.getUrl() + fileName; AjaxResult ajax = AjaxResult.success(); ajax.put("url", url); ajax.put("fileName", fileName); ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("originalFilename", file.getOriginalFilename()); return ajax; } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } /** * ä¸ä¼ 并转æhtmlè¯·æ± */ @PostMapping("/uploadShow") public AjaxResult uploadFileShow(MultipartFile file) { try { // ä¸ä¼ æä»¶è·¯å¾ String filePath = RuoYiConfig.getUploadPath(); String originalFilename = file.getOriginalFilename().split("\\.", 2)[1]; filePath = filePath + "/show/" + file.getOriginalFilename().split("\\.", 2)[0]; // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° String fileName = FileUploadUtils.uploadSort(filePath, file); //å°word转æhtml convertDocToHtml(filePath + "\\" + file.getOriginalFilename(), filePath + "\\" + file.getOriginalFilename().split("\\.", 2)[0] + ".html", filePath); updatePicture(filePath + "\\" + file.getOriginalFilename().split("\\.", 2)[0] + ".html"); String url = serverConfig.getUrl() + fileName.replaceAll("\\.[^.]*$", ".html"); AjaxResult ajax = AjaxResult.success(); ajax.put("url", url); ajax.put("fileName", fileName); ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("originalFilename", file.getOriginalFilename()); return ajax; } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } @@ -73,10 +145,8 @@ * éç¨ä¸ä¼ 请æ±ï¼åä¸ªï¼ */ @PostMapping("/upload") public AjaxResult uploadFile(MultipartFile file) throws Exception { try { public AjaxResult uploadFile(MultipartFile file) { try { // ä¸ä¼ æä»¶è·¯å¾ String filePath = RuoYiConfig.getUploadPath(); // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° @@ -88,9 +158,7 @@ ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("originalFilename", file.getOriginalFilename()); return ajax; } catch (Exception e) { } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } @@ -99,18 +167,15 @@ * éç¨ä¸ä¼ 请æ±ï¼å¤ä¸ªï¼ */ @PostMapping("/uploads") public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception { try { public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception { try { // ä¸ä¼ æä»¶è·¯å¾ String filePath = RuoYiConfig.getUploadPath(); List<String> urls = new ArrayList<String>(); List<String> fileNames = new ArrayList<String>(); List<String> newFileNames = new ArrayList<String>(); List<String> originalFilenames = new ArrayList<String>(); for (MultipartFile file : files) { for (MultipartFile file : files) { // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° String fileName = FileUploadUtils.upload(filePath, file); String url = serverConfig.getUrl() + fileName; @@ -125,9 +190,7 @@ ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); return ajax; } catch (Exception e) { } catch (Exception e) { return AjaxResult.error(e.getMessage()); } } @@ -136,13 +199,9 @@ * æ¬å°èµæºéç¨ä¸è½½ */ @GetMapping("/download/resource") public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) throws Exception { try { if (!FileUtils.checkAllowDownload(resource)) { public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) throws Exception { try { if (!FileUtils.checkAllowDownload(resource)) { throw new Exception(StringUtils.format("èµæºæä»¶({})éæ³ï¼ä¸å 许ä¸è½½ã ", resource)); } // æ¬å°èµæºè·¯å¾ @@ -154,10 +213,91 @@ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); FileUtils.setAttachmentResponseHeader(response, downloadName); FileUtils.writeBytes(downloadPath, response.getOutputStream()); } catch (Exception e) { } catch (Exception e) { log.error("ä¸è½½æä»¶å¤±è´¥", e); } } private void convertDocToHtml(String docFilePath, String outputHtmlFilePath, String imageDirPath) throws IOException, ParserConfigurationException { // Load DOC into HWPFDocument InputStream inputStream = new FileInputStream(docFilePath); HWPFDocument document = new HWPFDocument(inputStream); // Prepare HTML output WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()); // Set PicturesManager to handle image saving wordToHtmlConverter.setPicturesManager(new PicturesManager() { @Override public String savePicture(byte[] content, PictureType pictureType, String suggestedName, float widthInches, float heightInches) { File imageFile = new File(imageDirPath + "/" + suggestedName); try (FileOutputStream fos = new FileOutputStream(imageFile)) { fos.write(content); } catch (IOException e) { e.printStackTrace(); } return suggestedName; } }); // Convert document to HTML wordToHtmlConverter.processDocument(document); // Save images List<Picture> pics = document.getPicturesTable().getAllPictures(); if (pics != null) { for (Picture pic : pics) { try (FileOutputStream fos = new FileOutputStream(imageDirPath + "/" + pic.suggestFullFileName())) { fos.write(pic.getContent()); } } } // Convert to HTML Document htmlDocument = wordToHtmlConverter.getDocument(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); org.apache.xml.serialize.OutputFormat format = new org.apache.xml.serialize.OutputFormat(htmlDocument); org.apache.xml.serialize.XMLSerializer serializer = new org.apache.xml.serialize.XMLSerializer(outStream, format); serializer.serialize(htmlDocument); // Write HTML file try (OutputStream outputStream = new FileOutputStream(outputHtmlFilePath)) { outputStream.write(outStream.toByteArray()); } } private void updatePicture(String htmlFilePath) { try { // Load HTML file File inputFile = new File(htmlFilePath); org.jsoup.nodes.Document doc = Jsoup.parse(inputFile, "UTF-8"); // Select all elements with style attribute and modify their width and height to 90% org.jsoup.select.Elements elementsWithStyle = doc.select("[style]"); for (Element element : elementsWithStyle) { String style = element.attr("style"); String modifiedStyle = modifyStyle(style); element.attr("style", modifiedStyle); } // Save the modified HTML to output file try (FileWriter writer = new FileWriter(htmlFilePath)) { writer.write(doc.outerHtml()); } System.out.println("Modification completed successfully."); } catch (IOException e) { e.printStackTrace(); } } private String modifyStyle(String style) { // Define patterns for width and height Pattern widthPattern = Pattern.compile("width\\s*:\\s*[^;]+"); Pattern heightPattern = Pattern.compile("height\\s*:\\s*[^;]+"); // Replace width and height with 90% Matcher widthMatcher = widthPattern.matcher(style); style = widthMatcher.replaceAll("width: 90%"); Matcher heightMatcher = heightPattern.matcher(style); style = heightMatcher.replaceAll("height: 90%"); return style; } } ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
@@ -1,94 +1,16 @@ package com.ruoyi.web.test; import com.ruoyi.web.task.PhoneTask; import org.junit.Test; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import java.security.*; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; //@SpringBootTest //@RunWith(SpringRunner.class) public class MQTest { @Autowired private RabbitTemplate rabbitTemplate; @Test public void testSend() { try { // çæRSAå¯é¥å¯¹ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(2048); KeyPair keyPair = keyPairGenerator.generateKeyPair(); // è·åå ¬é¥åç§é¥ PublicKey publicKey = keyPair.getPublic(); PrivateKey privateKey = keyPair.getPrivate(); String publicKeyString = Base64.getEncoder().encodeToString(privateKey.getEncoded()); System.out.println(publicKeyString); // ææ String plainText = "Hello, World!"; // å å¯ Cipher encryptCipher = Cipher.getInstance("RSA"); encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encryptedBytes = encryptCipher.doFinal(plainText.getBytes()); // å°å å¯åçæ°æ®è½¬æ¢ä¸ºBase64ç¼ç çå符串 String encryptedText = Base64.getEncoder().encodeToString(encryptedBytes); System.out.println("å å¯åçæ°æ®ï¼" + encryptedText); // è§£å¯ Cipher decryptCipher = Cipher.getInstance("RSA"); decryptCipher.init(Cipher.DECRYPT_MODE, privateKey); byte[] decryptedBytes = decryptCipher.doFinal(Base64.getDecoder().decode(encryptedBytes)); // ææ String decryptedText = new String(decryptedBytes); System.out.println("è§£å¯åçæ°æ®ï¼" + decryptedText); } catch (Exception e) { } // String str = "absdf"; // String c = Character.toUpperCase(str.charAt(0)) + str.substring(1); // System.out.println(c); "æ¨å¥½ï¼ææ¯æµäºå»é¢å¼ å»çï¼æ¨æ¯${name}åï¼è¿æ¯å®¶å±?".replaceAll("$$*variable", "AA"); // Pattern pattern = Pattern.compile("^(?!.*(好|太好)).*$"); // Matcher matcher = pattern.matcher("ç¡ç ä¸å¥½"); // System.out.println(matcher.matches()); // å建åºå®å¤§å°ççº¿ç¨æ± // ExecutorService executorService = Executors.newFixedThreadPool(10); // // executorService.submit(new PhoneTask()); } @Test public void testSend22() { try { byte[] privateKeyBytes = Base64.getDecoder().decode(""); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); PrivateKey privateKey = keyFactory.generatePrivate(keySpec); // 使ç¨ç§é¥è§£å¯æ°æ® Cipher decryptCipher = Cipher.getInstance("RSA"); decryptCipher.init(Cipher.DECRYPT_MODE, privateKey); byte[] decryptedBytes = decryptCipher.doFinal(Base64.getDecoder().decode("")); } // è§£å¯åçæ°æ® String decryptedData = new String(decryptedBytes); System.out.println("è§£å¯åçæ°æ®ï¼" + decryptedData); } catch (Exception e) { } } } ruoyi-common/src/main/java/com/ruoyi/common/enums/PhotoEnum.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,45 @@ package com.ruoyi.common.enums; /** * åéç±»åæä¸¾ */ public enum PhotoEnum { jpg("jpg ", "jpg "), jpeg("jpeg", "jpeg"), png("png", "png"), gif("gif", "gif"), bmp("bmp", "bmp"), tiff("tiff ", "tiff "), tif("tif", "tif"), svg("svg", "svg"); private String code; private String desc; PhotoEnum(String code, String desc) { this.code = code; this.desc = desc; } public static Boolean getDescByCode(String code) { PhotoEnum[] organEnums = values(); for (int i = 0; i < organEnums.length; i++) { PhotoEnum organEnum = organEnums[i]; if (organEnum.getCode().equals(code)) { return true; } } return false; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } } ruoyi-common/src/main/java/com/ruoyi/common/enums/RadioEnum.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,45 @@ package com.ruoyi.common.enums; /** * åéç±»åæä¸¾ */ public enum RadioEnum { mp3("mp3", "mp3"), wav("wav", "wav"), flac("flac", "flac"), aac("aac", "aac"), ogg("ogg", "ogg"), wma("wma", "wma"); private String code; private String desc; RadioEnum(String code, String desc) { this.code = code; this.desc = desc; } public static Boolean getDescByCode(String code) { RadioEnum[] organEnums = values(); for (int i = 0; i < organEnums.length; i++) { RadioEnum organEnum = organEnums[i]; if (organEnum.getCode().equals(code)) { return true; } } return false; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } } ruoyi-common/src/main/java/com/ruoyi/common/enums/VadioEnum.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,45 @@ package com.ruoyi.common.enums; /** * åéç±»åæä¸¾ */ public enum VadioEnum { avi("avi", "avi"), mpeg("mpeg", "mpeg"), mp4("mp4", "mp4"), wmv("wmv", "wmv"), flv("flv", "flv"), mov("mov", "mov"), rmvb("rmvb", "rmvb"), mkv("mkv", "mkv"); private String code; private String desc; VadioEnum(String code, String desc) { this.code = code; this.desc = desc; } public static Boolean getDescByCode(String code) { VadioEnum[] organEnums = values(); for (int i = 0; i < organEnums.length; i++) { VadioEnum organEnum = organEnums[i]; if (organEnum.getCode().equals(code)) { return true; } } return false; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } } ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
@@ -4,6 +4,7 @@ import java.io.IOException; import java.nio.file.Paths; import java.util.Objects; import org.apache.commons.io.FilenameUtils; import org.springframework.web.multipart.MultipartFile; import com.ruoyi.common.config.RuoYiConfig; @@ -20,8 +21,7 @@ * * @author ruoyi */ public class FileUploadUtils { public class FileUploadUtils { /** * é»è®¤å¤§å° 50M */ @@ -37,13 +37,11 @@ */ private static String defaultBaseDir = RuoYiConfig.getProfile(); public static void setDefaultBaseDir(String defaultBaseDir) { public static void setDefaultBaseDir(String defaultBaseDir) { FileUploadUtils.defaultBaseDir = defaultBaseDir; } public static String getDefaultBaseDir() { public static String getDefaultBaseDir() { return defaultBaseDir; } @@ -54,14 +52,10 @@ * @return æä»¶åç§° * @throws Exception */ public static final String upload(MultipartFile file) throws IOException { try { public static final String upload(MultipartFile file) throws IOException { try { return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); } catch (Exception e) { } catch (Exception e) { throw new IOException(e.getMessage(), e); } } @@ -74,14 +68,10 @@ * @return æä»¶åç§° * @throws IOException */ public static final String upload(String baseDir, MultipartFile file) throws IOException { try { public static final String upload(String baseDir, MultipartFile file) throws IOException { try { return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); } catch (Exception e) { } catch (Exception e) { throw new IOException(e.getMessage(), e); } } @@ -98,13 +88,9 @@ * @throws IOException æ¯å¦è¯»åæä»¶åºéæ¶ * @throws InvalidExtensionException æä»¶æ ¡éªå¼å¸¸ */ public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, InvalidExtensionException { public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, InvalidExtensionException { int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); } @@ -118,30 +104,52 @@ } /** * ç¼ç æä»¶å * æä»¶ä¸ä¼ * * @param baseDir ç¸å¯¹åºç¨çåºç®å½ * @param file ä¸ä¼ çæä»¶ * @param allowedExtension ä¸ä¼ æä»¶ç±»å * @return è¿åä¸ä¼ æåçæä»¶å * @throws FileSizeLimitExceededException å¦æè¶ åºæå¤§å¤§å° * @throws FileNameLengthLimitExceededException æä»¶åå¤ªé¿ * @throws IOException æ¯å¦è¯»åæä»¶åºéæ¶ * @throws InvalidExtensionException æä»¶æ ¡éªå¼å¸¸ */ public static final String extractFilename(MultipartFile file) { return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file)); public static final String uploadSort(String baseDir, MultipartFile file) throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, InvalidExtensionException { int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); } public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); String fileName = file.getOriginalFilename(); String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); file.transferTo(Paths.get(absPath)); return getPathFileName(baseDir, fileName); } /** * ç¼ç æä»¶å */ public static final String extractFilename(MultipartFile file) { return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file)); } public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { File desc = new File(uploadDir + File.separator + fileName); if (!desc.exists()) { if (!desc.getParentFile().exists()) { if (!desc.exists()) { if (!desc.getParentFile().exists()) { desc.getParentFile().mkdirs(); } } return desc; } public static final String getPathFileName(String uploadDir, String fileName) throws IOException { public static final String getPathFileName(String uploadDir, String fileName) throws IOException { int dirLastIndex = RuoYiConfig.getProfile().length() + 1; String currentDir = StringUtils.substring(uploadDir, dirLastIndex); return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; @@ -155,41 +163,24 @@ * @throws FileSizeLimitExceededException å¦æè¶ åºæå¤§å¤§å° * @throws InvalidExtensionException */ public static final void assertAllowed(MultipartFile file, String[] allowedExtension) throws FileSizeLimitExceededException, InvalidExtensionException { public static final void assertAllowed(MultipartFile file, String[] allowedExtension) throws FileSizeLimitExceededException, InvalidExtensionException { long size = file.getSize(); if (size > DEFAULT_MAX_SIZE) { if (size > DEFAULT_MAX_SIZE) { throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); } String fileName = file.getOriginalFilename(); String extension = getExtension(file); if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, fileName); } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, fileName); } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, fileName); } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) { throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, fileName); } else { if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, fileName); } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, fileName); } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, fileName); } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) { throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, fileName); } else { throw new InvalidExtensionException(allowedExtension, extension, fileName); } } @@ -202,12 +193,9 @@ * @param allowedExtension * @return */ public static final boolean isAllowedExtension(String extension, String[] allowedExtension) { for (String str : allowedExtension) { if (str.equalsIgnoreCase(extension)) { public static final boolean isAllowedExtension(String extension, String[] allowedExtension) { for (String str : allowedExtension) { if (str.equalsIgnoreCase(extension)) { return true; } } @@ -220,11 +208,9 @@ * @param file 表åæä»¶ * @return åç¼å */ public static final String getExtension(MultipartFile file) { public static final String getExtension(MultipartFile file) { String extension = FilenameUtils.getExtension(file.getOriginalFilename()); if (StringUtils.isEmpty(extension)) { if (StringUtils.isEmpty(extension)) { extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType())); } return extension; smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java
@@ -36,7 +36,7 @@ private IServiceTaskService ivrTaskService; @Autowired private ISvyTaskService iSvyTaskService; private IServiceTaskService iServiceTaskService; @Autowired private RedisCache redisCache; @@ -131,40 +131,40 @@ } public int wjSend(SendTaskVO sendTaskVO) { SvyTask svyTask = iSvyTaskService.selectSvyTaskByTaskid(sendTaskVO.getTaskId()); ServiceTask serviceTask1 = iServiceTaskService.selectServiceTaskByTaskid(sendTaskVO.getTaskId()); if (sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 3 || sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 4) { //任塿åæç»æ¢ SvyTask serviceTask = new SvyTask(); ServiceTask serviceTask = new ServiceTask(); serviceTask.setTaskid(sendTaskVO.getTaskId()); serviceTask.setStopState(svyTask.getStopState() + 1); serviceTask.setSendState(sendTaskVO.getSendState().toString()); iSvyTaskService.updateSvyTask(serviceTask); serviceTask.setStopState(serviceTask1.getStopState() + 1); serviceTask.setSendState(sendTaskVO.getSendState()); iServiceTaskService.updateServiceTask(serviceTask); return 0; } //夿åéç¶ææ¯å¦ä¸ºç©º if (StringUtils.isEmpty(sendTaskVO.getSendType())) { sendTaskVO.setSendType(svyTask.getSendType().toString()); sendTaskVO.setSendType(serviceTask1.getSendType().toString()); } //夿任塿¯å¦æ¯ç«å³åé if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) { String content = sendMQContent(sendTaskVO, svyTask.getTemplateid(), svyTask.getPreachform(), svyTask.getStopState(), null); String content = sendMQContent(sendTaskVO, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), null); //ç«å³åé redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS); //å°ä»»å¡ç¶æä¿®æ¹ææ§è¡ä¸ SvyTask serviceTask = new SvyTask(); serviceTask.setTaskid(svyTask.getTaskid()); serviceTask.setSendState("2"); iSvyTaskService.updateSvyTask(serviceTask); ServiceTask serviceTask = new ServiceTask(); serviceTask.setTaskid(serviceTask1.getTaskid()); serviceTask.setSendState(2); iServiceTaskService.updateServiceTask(serviceTask); } else if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1") || StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("3")) { //æ¶é´æ®µåé ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isNotEmpty(svyTask.getSendTimeSlot())) { if (StringUtils.isNotEmpty(serviceTask1.getSendTimeSlot())) { List<TaskSendTimeVO> taskSendTimeVOList = null; try { taskSendTimeVOList = objectMapper.readValue(svyTask.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() { taskSendTimeVOList = objectMapper.readValue(serviceTask1.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() { }); } catch (JsonProcessingException e) { log.error("JsonProcessingExceptionæ¥éäºï¼{}", e.getMessage()); @@ -189,14 +189,14 @@ SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class); sendTaskVO1.setSendType("1"); String content = sendMQContent(sendTaskVO1, svyTask.getTemplateid(), svyTask.getPreachform(), svyTask.getStopState(), list); String content = sendMQContent(sendTaskVO1, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), list); redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS); } //å°ä»»å¡ç¶æä¿®æ¹ææ§è¡ä¸ SvyTask serviceTask = new SvyTask(); serviceTask.setTaskid(svyTask.getTaskid()); serviceTask.setSendState("2"); iSvyTaskService.updateSvyTask(serviceTask); ServiceTask serviceTask = new ServiceTask(); serviceTask.setTaskid(serviceTask1.getTaskid()); serviceTask.setSendState(2); iServiceTaskService.updateServiceTask(serviceTask); } } return 1;