xinyb
4 天以前 67a32b3138862fa8faf2d774f4f841280f0e4000
src/com/yc/crm/mail/action/MailController.java
@@ -57,7 +57,7 @@
    /**
     * 左边结构层
     * 左边结构上层
     *
     * @return
     */
@@ -74,6 +74,33 @@
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            List<MailModuleEntity> list = emailIfc.getMailModuleList(userCode);
            msg.setSuccess("执行成功", list);
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
            SpObserver.setDBtoInstance();
        }
        return msg;
    }
    /**
     * 左边结构下层
     *
     * @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());
@@ -108,14 +135,16 @@
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            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) {
                Map<String,Object> map=new HashMap<>();
                map.put("page",page);
                map.put("limit",limit);
                map.put("total",emailIfc.getMailTotal(mail,mailType,isNoRead,userCode));
                map.put("list",t482101HEntityList);
                msg.setSuccess("执行完成", map);
                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 {
@@ -149,14 +178,16 @@
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            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) {
                Map<String,Object> map=new HashMap<>();
                map.put("page",page);
                map.put("limit",limit);
                map.put("total",emailIfc.getMailTotal(mail,3,false,userCode));
                map.put("list",t482101HEntityList);
                msg.setSuccess("执行完成", map);
                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 {
@@ -185,10 +216,18 @@
                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());
                            if (!t482101HEntity.getMailType().equals(1)) {//不是收件类型(1)
                                map.put("url", shoppingImageServer + "/uploads/attachment/" + dataSourceEntity.getDbId() + "/482101/" + a.getUnid() + "@p@" + a.getSeq() + "." + a.getFileType());
                            }
                            map.put("name", a.getOriginalFileName());
                            map.put("size", a.getFileSize());
                            map.put("fileType", a.getFileType());
                            list.add(map);
                        }
                        t482101HEntity.setAttachmentPath(list);
                    }
@@ -504,6 +543,98 @@
    }
    /**
     * 移动邮件分类
     *
     * @param request
     * @param response
     * @return
     */
    @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();
            String userCode = (String) session.getAttribute(SessionKey.USERCODE);//当前登录用户
            if (StringUtils.isBlank(userCode)) {//获取不到当前用户直接结束
                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;
    }
    /**
     * 加载不同目录里的邮件
     *
     * @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