liusheng
2024-07-04 6a58a5a148c27c9ff66901bfbae6e52c1a56b5d2
代码提交
已添加1个文件
已修改3个文件
161 ■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HeLibraryController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/HtmlContentVO.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -21,6 +21,7 @@
import com.ruoyi.common.enums.PhotoEnum;
import com.ruoyi.common.enums.RadioEnum;
import com.ruoyi.common.enums.VadioEnum;
import com.smartor.domain.HtmlContentVO;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.converter.PicturesManager;
import org.apache.poi.hwpf.converter.WordToHtmlConverter;
@@ -32,10 +33,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
@@ -224,6 +222,26 @@
        }
    }
    /**
     * @param HtmlContentVO
     * @return
     */
    @GetMapping("/common/htmlContent")
    public AjaxResult htmlContent(@RequestBody HtmlContentVO htmlContentVO) {
        // èŽ·å–æ–‡ä»¶çš„åŽŸå§‹åç§°
        String fileName = htmlContentVO.getFileName();
        // å°†æ–‡ä»¶ä¿å­˜åˆ°æŒ‡å®šç›®å½•
        File outputFile = new File(RuoYiConfig.getUploadPath() + "/show/" + fileName.split("\\.", 2)[0] + fileName);
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile))) {
            writer.write(htmlContentVO.getContent());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return AjaxResult.success();
    }
    public static void convertDocToHtml(String docFilePath, String outputHtmlFilePath) throws TransformerException, IOException, ParserConfigurationException {
        InputStream inputStream = new FileInputStream(docFilePath);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/HeLibraryController.java
@@ -1,32 +1,24 @@
package com.ruoyi.web.controller.smartor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.HeLibrary;
import com.smartor.domain.HeLibraryVO;
import com.smartor.domain.IvrLibaTemplateVO;
import com.smartor.service.IHeLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * å®£æ•™èµ„料库Controller
smartor/src/main/java/com/smartor/domain/HtmlContentVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,31 @@
package com.smartor.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * å®£æ•™åˆ†ç±»å¯¹è±¡ he_category
 *
 * @author smartor
 * @date 2023-03-04
 */
@Data
@ApiModel(value = "HtmlContentVO", description = "富文本内容")
public class HtmlContentVO extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "内容")
    private String content;
    @ApiModelProperty(value = "文件名")
    private String fileName;
}
smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java
@@ -54,7 +54,7 @@
            return wjSend(sendTaskVO);
        } else if (sendTaskVO.getTaskType() == 3) {
            //宣教
            xjSend(sendTaskVO);
        }
        return null;
    }
@@ -202,6 +202,78 @@
        return 1;
    }
    public int xjSend(SendTaskVO sendTaskVO) {
        ServiceTask serviceTask1 = iServiceTaskService.selectServiceTaskByTaskid(sendTaskVO.getTaskId());
        if (sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 3 || sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 4) {
            //任务暂停或终止
            ServiceTask serviceTask = new ServiceTask();
            serviceTask.setTaskid(sendTaskVO.getTaskId());
            serviceTask.setStopState(serviceTask1.getStopState() + 1);
            serviceTask.setSendState(sendTaskVO.getSendState());
            iServiceTaskService.updateServiceTask(serviceTask);
            return 0;
        }
        //判断发送状态是否为空
        if (StringUtils.isEmpty(sendTaskVO.getSendType())) {
            sendTaskVO.setSendType(serviceTask1.getSendType().toString());
        }
        //判断任务是否是立即发送
        if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) {
            String content = sendMQContent(sendTaskVO, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), null);
            //立即发送
            redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS);
            //将任务状态修改成执行中
            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(serviceTask1.getSendTimeSlot())) {
                List<TaskSendTimeVO> taskSendTimeVOList = null;
                try {
                    taskSendTimeVOList = objectMapper.readValue(serviceTask1.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() {
                    });
                } catch (JsonProcessingException e) {
                    log.error("JsonProcessingException报错了:{}", e.getMessage());
                }
                for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) {
                    //去SendTimeslot中,获取所有的时间段
                    List<TaskSendTimeVO> list = new ArrayList<>();
                    list.add(taskSendTimeVO);
                    //获取开始发送时间
                    String begantime = taskSendTimeVO.getBegantime();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    //记录目前到发送时间的毫秒值 ï¼ˆå‘送时间的毫秒值 - å½“前时间的毫秒值)
                    Long milliseconds = 1000L;
                    try {
                        Date date = sdf.parse(begantime);
                        milliseconds = date.getTime() - System.currentTimeMillis();
                        System.out.println("日期毫秒数:" + milliseconds);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class);
                    sendTaskVO1.setSendType("1");
                    String content = sendMQContent(sendTaskVO1, serviceTask1.getTemplateid().toString(), serviceTask1.getPreachform(), serviceTask1.getStopState(), list);
                    redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS);
                }
                //将任务状态修改成执行中
                ServiceTask serviceTask = new ServiceTask();
                serviceTask.setTaskid(serviceTask1.getTaskid());
                serviceTask.setSendState(2);
                iServiceTaskService.updateServiceTask(serviceTask);
            }
        }
        return 1;
    }
    /**
     * MQ任务创建内容
     *