liusheng
2024-07-03 3fc51e7cbdabb7dcd1615c6efac52323f6ca8adb
代码提交
已添加3个文件
已修改6个文件
777 ■■■■ 文件已修改
ruoyi-admin/pom.xml 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java 218 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/enums/PhotoEnum.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/enums/RadioEnum.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/enums/VadioEnum.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java 142 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java 38 ●●●● 补丁 | 查看 | 原始文档 | 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&param2=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 + "&param2=" + 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 + "&param2=" + patid + "&param3=" + ivrTask1.getTaskName());
                        log.info("链接完整路径:{}", req_path + "/outsideChain?param1=" + taskId + "&param2=" + patid + "&param3=" + 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;