From 56d9f6a0b1ecfce70da391d406fcc92274cc1b03 Mon Sep 17 00:00:00 2001
From: xinyb <574600396@qq.com>
Date: 星期六, 28 九月 2024 17:31:26 +0800
Subject: [PATCH] CRM邮箱收件和发件调整

---
 src/com/yc/crm/mail/action/MailController.java |  180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 166 insertions(+), 14 deletions(-)

diff --git a/src/com/yc/crm/mail/action/MailController.java b/src/com/yc/crm/mail/action/MailController.java
index e182c91..5c912cc 100644
--- a/src/com/yc/crm/mail/action/MailController.java
+++ b/src/com/yc/crm/mail/action/MailController.java
@@ -26,6 +26,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**
@@ -56,7 +57,7 @@
 
 
     /**
-     * 宸﹁竟缁撴瀯灞�
+     * 宸﹁竟缁撴瀯涓婂眰
      *
      * @return
      */
@@ -83,13 +84,40 @@
     }
 
     /**
+     * 宸﹁竟缁撴瀯涓嬪眰
+     *
+     * @return
+     */
+    @GetMapping("/getEmailModuleBelow.do")
+    public AllBackMsg getEmailModuleBelow(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AllBackMsg msg = new AllBackMsg();
+        try {
+            HttpSession session = request.getSession();
+            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//褰撳墠鐧诲綍鐢ㄦ埛
+            if (StringUtils.isBlank(userCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫
+                msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
+                return msg;
+            }
+            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
+            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
+            List<MailModuleBelowEntity> list = emailIfc.getMailModuleBelowList(userCode);
+            msg.setSuccess("鎵ц鎴愬姛", list);
+        } catch (Exception e) {
+            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
+        } finally {
+            SpObserver.setDBtoInstance();
+        }
+        return msg;
+    }
+
+    /**
      * 鑾峰彇閭欢鍒楄〃锛堝寘鎷崏绋跨锛屾敹浠剁锛�
      *
      * @return
      */
     @GetMapping("/getMailList.do")
     public AllBackMsg getMailList(String mail, @RequestParam(defaultValue = "1") Integer mailType,
-                                  @RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "20") Integer limit, boolean isNoRead, HttpServletRequest request, HttpServletResponse response) throws Exception {
+                                  @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit, boolean isNoRead, HttpServletRequest request, HttpServletResponse response) throws Exception {
         AllBackMsg msg = new AllBackMsg();
         try {
             if (StringUtils.isNotBlank(mail)) {
@@ -106,10 +134,17 @@
             }
             DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
             SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
-            List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode,page,limit);
+            List<t482101HList> t482101HEntityList = emailIfc.getReceivingMailList(mail, mailType, isNoRead, userCode, page, limit);
+            Map<String, Object> map = new HashMap<>();
+            map.put("page", page);
+            map.put("limit", limit);
             if (t482101HEntityList.size() > 0) {
-                msg.setSuccess("鎵ц瀹屾垚", t482101HEntityList);
+                map.put("total", emailIfc.getMailTotal(mail, mailType, isNoRead, null, userCode));
+                map.put("list", t482101HEntityList);
+            } else {
+                map.put("list", new ArrayList<>());
             }
+            msg.setSuccess("鎵ц瀹屾垚", map);
         } catch (Exception e) {
             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
         } finally {
@@ -124,7 +159,7 @@
      * @return
      */
     @GetMapping("/getHandleMailList.do")
-    public AllBackMsg getHandleMailList(String mail,@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "20") Integer limit,
+    public AllBackMsg getHandleMailList(String mail, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit,
                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
         AllBackMsg msg = new AllBackMsg();
         try {
@@ -142,10 +177,17 @@
             }
             DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
             SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
-            List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode,page,limit);
+            List<t482101HList> t482101HEntityList = emailIfc.getHandleMailList(mail, userCode, page, limit);
+            Map<String, Object> map = new HashMap<>();
+            map.put("page", page);
+            map.put("limit", limit);
             if (t482101HEntityList.size() > 0) {
-                msg.setSuccess("鎵ц瀹屾垚", t482101HEntityList);
+                map.put("total", emailIfc.getMailTotal(mail, 3, false, null, userCode));
+                map.put("list", t482101HEntityList);
+            } else {
+                map.put("list", new ArrayList<>());
             }
+            msg.setSuccess("鎵ц瀹屾垚", map);
         } catch (Exception e) {
             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
         } finally {
@@ -174,10 +216,15 @@
                 if (StringUtils.isNotBlank(t482101HEntity.getAttachmentList())) {//闄勪欢鐨勫鐞�
                     //鑾峰彇鍒伴檮浠跺唴瀹�
                     List<AttachmentEntity> attachmentEntities = mailFileIfc.getAttachmentEntityList(t482101HEntity.getAttachmentList());
-                    List<String> list = new ArrayList<>();
+                    List<Map<String,Object>> list = new ArrayList<>();
                     if (attachmentEntities.size() > 0) {
                         for (AttachmentEntity a : attachmentEntities) {
-                            list.add(shoppingImageServer + "/uploads/email/" + dataSourceEntity.getDbId() + "/482101/" + a.getUnid() + "@p@" + a.getPhysicalFile());
+                            Map<String,Object> map=new HashMap<>();
+                            map.put("url",shoppingImageServer + "/uploads/email/" + dataSourceEntity.getDbId() + "/482101/" + a.getUnid() + "@p@" + a.getPhysicalFile());
+                            map.put("name",a.getOriginalFileName());
+                            map.put("size",a.getFileSize());
+                            map.put("fileType",a.getFileType());
+                            list.add(map);
                         }
                         t482101HEntity.setAttachmentPath(list);
                     }
@@ -493,14 +540,14 @@
     }
 
     /**
-     * 寰呭鐞嗛偖浠�
+     * 绉诲姩閭欢鍒嗙被
      *
      * @param request
      * @param response
      * @return
      */
-    @GetMapping("/updateHandle.do")
-    public AllBackMsg updateHandle(String handleTime, String docCode, HttpServletRequest request, HttpServletResponse response) throws Exception {
+    @PostMapping("/updateMailType.do")
+    public AllBackMsg updateMailType(@RequestBody Map<String, Object> map, HttpServletRequest request, HttpServletResponse response) throws Exception {
         AllBackMsg msg = new AllBackMsg();
         try {
             HttpSession session = request.getSession();
@@ -509,14 +556,119 @@
                 msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
                 return msg;
             }
+            if (map.get("docCode") == null) {
+                msg.setFail("鑾峰彇涓嶅埌绉诲姩閭欢缂栧彿docCode");
+                return msg;
+            }
+            String docCode = (String) map.get("docCode");
+            Integer folderId = map.get("folderId") == null ? 0 : (Integer) map.get("folderId");
+            List<String> tagArray = (List<String>) map.get("tagId");
+            if (folderId.equals(0) && (tagArray == null || tagArray.size() == 0)) {
+                msg.setFail("绉诲姩閭欢鍒嗙被涓嶈兘涓虹┖");
+                return msg;
+            }
+            String tagId = "";
+            if (tagArray != null && tagArray.size() > 0) {
+                tagId = StringUtils.join(tagArray, ",");
+            }
+            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
+            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
+            emailIfc.updateMailType(docCode, folderId, tagId);
+            msg.setOk("绉诲姩鎴愬姛");
+        } catch (Exception e) {
+            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
+        } finally {
+            SpObserver.setDBtoInstance();
+        }
+        return msg;
+    }
 
-            if (StringUtils.isBlank(docCode)) {
+    /**
+     * 鍔犺浇涓嶅悓鐩綍閲岀殑閭欢
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @GetMapping("/classificationMail.do")
+    public AllBackMsg classificationMail(@RequestParam(defaultValue = "-1") Integer id, String type, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "20") Integer limit,
+                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AllBackMsg msg = new AllBackMsg();
+        try {
+            HttpSession session = request.getSession();
+            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//褰撳墠鐧诲綍鐢ㄦ埛
+            if (StringUtils.isBlank(userCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫
+                msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
+                return msg;
+            }
+            if (id == null || id.equals(-1)) {
+                msg.setFail("鑾峰彇涓嶅埌鏂囦欢Id");
+                return msg;
+            }
+            if (StringUtils.isBlank(type)) {
+                msg.setFail("鑾峰彇涓嶅埌鏂囦欢绫诲瀷");
+                return msg;
+            }
+            type = type + "_" + id;//缁勮涓�
+            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
+            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
+            List<t482101HList> t482101 = emailIfc.getFolderMailList(type, userCode, page, limit);
+            Map<String, Object> map = new HashMap<>();
+            map.put("page", page);
+            map.put("limit", limit);
+            if (t482101.size() > 0) {
+                map.put("total", emailIfc.getMailTotal(null, 6, false, type, userCode));
+                map.put("list", t482101);
+            } else {
+                map.put("list", new ArrayList<>());
+            }
+            msg.setSuccess("鎵ц瀹屾垚", map);
+        } catch (Exception e) {
+            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
+        } finally {
+            SpObserver.setDBtoInstance();
+        }
+        return msg;
+    }
+
+    /**
+     * 寰呭鐞嗛偖浠�
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @PostMapping("/updateHandle.do")
+    public AllBackMsg updateHandle(@RequestBody Map<String, Object> param, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        AllBackMsg msg = new AllBackMsg();
+        try {
+            HttpSession session = request.getSession();
+            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//褰撳墠鐧诲綍鐢ㄦ埛
+            if (StringUtils.isBlank(userCode)) {//鑾峰彇涓嶅埌褰撳墠鐢ㄦ埛鐩存帴缁撴潫
+                msg.setFail("鑾峰彇涓嶅埌鐢ㄦ埛淇℃伅");
+                return msg;
+            }
+            if (param.get("docCode") == null) {
                 msg.setFail("閭欢鍞竴鏍囪瘑docCode涓嶈兘绌�");
+                return msg;
+            }
+            if (param.get("handleTime") == null) {
+                msg.setFail("寰呭鐞嗘椂闂翠笉鑳界┖");
+                return msg;
+            }
+            List<String> docCode = (List<String>) param.get("docCode");
+            String handleTime = (String) param.get("handleTime");
+            // 姝e垯琛ㄨ揪寮忥紝鐢ㄤ簬鍖归厤鏃ユ湡鏍煎紡
+            String regex = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}";
+            Pattern pattern = Pattern.compile(regex);
+            Matcher matcher = pattern.matcher(handleTime);
+            if (!matcher.matches()) {
+                msg.setFail("寰呭鐞嗘棩鏈熸牸寮忎负锛歽yyy-MM-dd HH:mm锛堝锛�1900-08-01 08:00锛夈�傝妫�鏌�");
                 return msg;
             }
             DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//鑾峰彇鏁版嵁婧愪俊鎭�
             SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//鍒囨崲鏁版嵁婧�
-            emailIfc.updateMailHandle(handleTime, docCode);
+            emailIfc.updateMailHandle(handleTime, StringUtils.join(docCode, ","));
             msg.setOk("鎴愬姛鏍囪涓哄緟澶勭悊閭欢");
         } catch (Exception e) {
             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());

--
Gitblit v1.8.0