浏览代码

新闻公告微信推送

phoenix 1 年之前
父节点
当前提交
96f07a9135

+ 0 - 5
src/main/java/com/xjrsoft/module/oa/controller/ProclamationController.java

@@ -77,11 +77,6 @@ public class ProclamationController {
     @ApiOperation(value = "新增公告")
     @ApiOperation(value = "新增公告")
     public RT<Boolean> add(@RequestBody AddProclamationDto addProclamationDto) {
     public RT<Boolean> add(@RequestBody AddProclamationDto addProclamationDto) {
         Long newsId = newsService.addProclamation(addProclamationDto);
         Long newsId = newsService.addProclamation(addProclamationDto);
-        if(newsId != null){
-            CompletableFuture.runAsync(() -> {
-                newsService.SendMessage(newsId);
-            });
-        }
         return RT.ok(true);
         return RT.ok(true);
     }
     }
 
 

+ 6 - 2
src/main/java/com/xjrsoft/module/oa/service/impl/NewsServiceImpl.java

@@ -307,7 +307,12 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
             xjrNews.setModifyUserId(StpUtil.getLoginIdAsLong());
             xjrNews.setModifyUserId(StpUtil.getLoginIdAsLong());
             xjrNews.setModifyDate(LocalDateTime.now());
             xjrNews.setModifyDate(LocalDateTime.now());
 
 
-            addRelation(xjrNews, null, 1);
+            Boolean isSuccess = addRelation(xjrNews, null, 1);
+            if(isSuccess){
+                CompletableFuture.runAsync(() -> {
+                    this.SendMessage(xjrNews.getId());
+                });
+            }
         }
         }
 
 
         if (xjrNews.getStatus() == 3) {
         if (xjrNews.getStatus() == 3) {
@@ -858,7 +863,6 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
                         weChatSendMessageDto.setContent(data);
                         weChatSendMessageDto.setContent(data);
                         weChatService.sendTemplateMessage(weChatSendMessageDto);
                         weChatService.sendTemplateMessage(weChatSendMessageDto);
                     }
                     }
-//
                 }
                 }
             } else {
             } else {
                 List<NewsRelationVo> newsRelationVoList = newsRelationMapper.selectJoinList(NewsRelationVo.class,
                 List<NewsRelationVo> newsRelationVoList = newsRelationMapper.selectJoinList(NewsRelationVo.class,

+ 10 - 0
src/main/java/com/xjrsoft/module/textbook/controller/TextbookIssueRecordController.java

@@ -20,9 +20,11 @@ import com.xjrsoft.module.textbook.vo.TextbookIssueRecordVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import javax.servlet.ServletContext;
 import javax.validation.Valid;
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
@@ -44,6 +46,9 @@ public class TextbookIssueRecordController {
 
 
     private final ITextbookIssueRecordService textbookIssueRecordService;
     private final ITextbookIssueRecordService textbookIssueRecordService;
 
 
+    @Autowired
+    private ServletContext servletContext;
+
     @GetMapping(value = "/page")
     @GetMapping(value = "/page")
     @ApiOperation(value="教材出库记录列表(分页)")
     @ApiOperation(value="教材出库记录列表(分页)")
     @SaCheckPermission("textbookissuerecord:detail")
     @SaCheckPermission("textbookissuerecord:detail")
@@ -126,6 +131,11 @@ public class TextbookIssueRecordController {
             dataList.add(BeanUtil.toBean(textbookIssueRecordPageVo, TextbookIssueRecordExcelVo.class));
             dataList.add(BeanUtil.toBean(textbookIssueRecordPageVo, TextbookIssueRecordExcelVo.class));
         }
         }
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
+
+//        String projectRoot = servletContext.getRealPath("/");
+//        String fileName = projectRoot + "test" + System.currentTimeMillis() + ".xlsx";
+//        EasyExcel.write(fileName, TextbookIssueRecordExcelVo.class).sheet("用户表").doWrite(dataList);
+
         EasyExcel.write(bot, TextbookIssueRecordExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
         EasyExcel.write(bot, TextbookIssueRecordExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
 
 
         return RT.fileStream(bot.toByteArray(), "TextbookIssueRecord" + ExcelTypeEnum.XLSX.getValue());
         return RT.fileStream(bot.toByteArray(), "TextbookIssueRecord" + ExcelTypeEnum.XLSX.getValue());

+ 5 - 0
src/test/java/com/xjrsoft/module/oa/service/impl/NewsServiceImplTest.java

@@ -25,4 +25,9 @@ class NewsServiceImplTest {
             setStatus(2);
             setStatus(2);
         }});
         }});
     }
     }
+
+    @Test
+    void dataHandle() {
+        newsService.dataHandle(1747971884062928896L);
+    }
 }
 }