56d9f6a0b1ecfce70da391d406fcc92274cc1b03..73c8452a479ea83d4e9d28a7c66c019d9955d194
3 天以前 xinyb
CRM邮箱删除和待处理功能
73c845 对比 | 目录
3 天以前 xinyb
CRM邮箱附件路径的优化
67a32b 对比 | 目录
4个文件已修改
301 ■■■■ 已修改文件
src/com/yc/crm/mail/action/MailController.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/listener/EmailImageFilter.java 148 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailFileImpl.java 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/service/MailImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/com/yc/crm/mail/action/MailController.java
@@ -216,14 +216,17 @@
                if (StringUtils.isNotBlank(t482101HEntity.getAttachmentList())) {//附件的处理
                    //获取到附件内容
                    List<AttachmentEntity> attachmentEntities = mailFileIfc.getAttachmentEntityList(t482101HEntity.getAttachmentList());
                    List<Map<String,Object>> list = new ArrayList<>();
                    List<Map<String, Object>> list = new ArrayList<>();
                    if (attachmentEntities.size() > 0) {
                        for (AttachmentEntity a : attachmentEntities) {
                            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());
                            Map<String, Object> map = new HashMap<>();
                            map.put("url", "http://yingchen.onbus.cn:9010" + "/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);
@@ -652,24 +655,29 @@
                msg.setFail("邮件唯一标识docCode不能空");
                return msg;
            }
            if (param.get("handleTime") == null) {
                msg.setFail("待处理时间不能空");
                return msg;
            List<String> docCode = (List<String>) param.get("docCode");//待处理的单号
            String handleTime = "";//待处理时间
            if (param.get("handleTime") != null && !param.get("handleTime").equals("")) {
                handleTime = (String) param.get("handleTime");
            }
            List<String> docCode = (List<String>) param.get("docCode");
            String handleTime = (String) param.get("handleTime");
            // 正则表达式,用于匹配日期格式
            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("待处理日期格式为:yyyy-MM-dd HH:mm(如:1900-08-01 08:00)。请检查");
                return msg;
            if (StringUtils.isNotBlank(handleTime)) {
                // 正则表达式,用于匹配日期格式
                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("待处理日期格式为:yyyy-MM-dd HH:mm(如:1900-08-01 08:00)。请检查");
                    return msg;
                }
            }
            DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request);//获取数据源信息
            SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());//切换数据源
            emailIfc.updateMailHandle(handleTime, StringUtils.join(docCode, ","));
            msg.setOk("成功标记为待处理邮件");
            if(StringUtils.isBlank(handleTime)){//没值就是完成
                msg.setOk("待处理邮件已完成");
            }else{
                msg.setOk("标记为待处理邮件");
            }
        } catch (Exception e) {
            msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
        } finally {
src/com/yc/crm/mail/listener/EmailImageFilter.java
@@ -33,87 +33,89 @@
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        String reqUri = request.getRequestURI();
        synchronized (this) {
            HttpServletRequest request = (HttpServletRequest) servletRequest;
            HttpServletResponse response = (HttpServletResponse) servletResponse;
            String reqUri = request.getRequestURI();
        String hostUrl = SettingKey.getHostUrl(request);
        String queryString = request.getQueryString();
            String hostUrl = SettingKey.getHostUrl(request);
            String queryString = request.getQueryString();
        HttpSession session = request.getSession();
        String rootPath = session.getServletContext().getRealPath("/");
        ImageUrlParametersEntity imageUrlParametersEntity = getImageUrlParameters(reqUri);
        File file = new File(rootPath.substring(0, rootPath.length() - 1) + reqUri);
        try {
            if (file != null && file.exists()) {
                filterChain.doFilter(request, response);
                return;
            }
            MailFileIfc mailFileIfc= (MailFileIfc) FactoryBean.getBean("MailFileImpl");
            ImageEntity image = mailFileIfc.getImageFile(
                    imageUrlParametersEntity.getUnids(),
                    imageUrlParametersEntity.getWidth(),
                    imageUrlParametersEntity.getHeight(),
                    (imageUrlParametersEntity.getWidth() == null
                            && imageUrlParametersEntity.getHeight() == null ? true : false),
                    request, imageUrlParametersEntity.getAttachmentPath(), imageUrlParametersEntity.getFormidPath());
            if (image == null) {
                System.out.println("输出缩略图时出错,出错文件reqUri:" + hostUrl + reqUri + (queryString != null && !"".equals(queryString) ? "?" + queryString : ""));
                return;
            }
            if (image != null && image.getOriginalFileName() != null && (
                    image.getOriginalFileName().toLowerCase().endsWith(".pdf")
                            || image.getOriginalFileName().toLowerCase().endsWith(".doc")
                            || image.getOriginalFileName().toLowerCase().endsWith(".xls")
                            || image.getOriginalFileName().toLowerCase().endsWith(".ppt")
                            || image.getOriginalFileName().toLowerCase().endsWith(".docx")
                            || image.getOriginalFileName().toLowerCase().endsWith(".xlsx")
                            || image.getOriginalFileName().toLowerCase().endsWith(".pptx")
            )) {
                //不是图片格式,附件打开预览会自动下载,在这里处理直接跳过下面的生成输出流 by danaus 2023-07-10 09:49
                filterChain.doFilter(request, response);
                return;
            } else {
                //图片格式,直接显示
                response.setStatus(HttpServletResponse.SC_OK);
                InputStream is = null;
                try {
                    is = new FileInputStream(image.getFile());
                    //设置页面另存为时的文件名
                    response.setHeader("Content-Disposition", "inline; filename="
                            + (image != null && image.getOriginalFileName() != null ? new String(image.getOriginalFileName().getBytes("utf-8"), "ISO_8859_1") : ""));
                    String type = "image/";
                    //输出流
                    response.setContentType(type + image.getFileType());
                    OutputStream output = response.getOutputStream();
                    try {
                        FileCopyUtils.copy(is, output);
                    } catch (ClientAbortException | IllegalStateException e) {
                        System.out.println(getClass() + " reqUri:" + reqUri + ", Error:" + e.getMessage());
                    }
            HttpSession session = request.getSession();
            String rootPath = session.getServletContext().getRealPath("/");
            ImageUrlParametersEntity imageUrlParametersEntity = getImageUrlParameters(reqUri);
            File file = new File(rootPath.substring(0, rootPath.length() - 1) + reqUri);
            try {
                if (file != null && file.exists()) {
                    filterChain.doFilter(request, response);
                    return;
                    // 这里不能再执行   chain.doFilter(request, response) , 因为是新生成的文件,如果用  chain.doFilter 输出,则浏览器收到 404 文件不存的错误 ,
                    // 为了解决这个问题,使用  response 流 Stream 输出解决
                    //chain.doFilter(request, response);
                } catch (Exception e) {
                    System.out.println("输出缩略图时出错,出错文件reqUri:" + hostUrl + reqUri + (queryString != null && !"".equals(queryString) ? "?" + queryString : "") + ",错误原因:" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
                    e.printStackTrace();
                } finally {
                }
                MailFileIfc mailFileIfc = (MailFileIfc) FactoryBean.getBean("MailFileImpl");
                ImageEntity image = mailFileIfc.getImageFile(
                        imageUrlParametersEntity.getUnids(),
                        imageUrlParametersEntity.getWidth(),
                        imageUrlParametersEntity.getHeight(),
                        (imageUrlParametersEntity.getWidth() == null
                                && imageUrlParametersEntity.getHeight() == null ? true : false),
                        request, imageUrlParametersEntity.getAttachmentPath(), imageUrlParametersEntity.getFormidPath());
                if (image == null) {
                    System.out.println("输出缩略图时出错,出错文件reqUri:" + hostUrl + reqUri + (queryString != null && !"".equals(queryString) ? "?" + queryString : ""));
                    return;
                }
                if (image != null && image.getOriginalFileName() != null && (
                        image.getOriginalFileName().toLowerCase().endsWith(".pdf")
                                || image.getOriginalFileName().toLowerCase().endsWith(".doc")
                                || image.getOriginalFileName().toLowerCase().endsWith(".xls")
                                || image.getOriginalFileName().toLowerCase().endsWith(".ppt")
                                || image.getOriginalFileName().toLowerCase().endsWith(".docx")
                                || image.getOriginalFileName().toLowerCase().endsWith(".xlsx")
                                || image.getOriginalFileName().toLowerCase().endsWith(".pptx")
                )) {
                    //不是图片格式,附件打开预览会自动下载,在这里处理直接跳过下面的生成输出流 by danaus 2023-07-10 09:49
                    filterChain.doFilter(request, response);
                    return;
                } else {
                    //图片格式,直接显示
                    response.setStatus(HttpServletResponse.SC_OK);
                    InputStream is = null;
                    try {
                        if (is != null) is.close();
                    } catch (IOException e) {
                        is = new FileInputStream(image.getFile());
                        //设置页面另存为时的文件名
                        response.setHeader("Content-Disposition", "inline; filename="
                                + (image != null && image.getOriginalFileName() != null ? new String(image.getOriginalFileName().getBytes("utf-8"), "ISO_8859_1") : ""));
                        String type = "image/";
                        //输出流
                        response.setContentType(type + image.getFileType());
                        OutputStream output = response.getOutputStream();
                        try {
                            FileCopyUtils.copy(is, output);
                        } catch (ClientAbortException | IllegalStateException e) {
                            System.out.println(getClass() + " reqUri:" + reqUri + ", Error:" + e.getMessage());
                        }
                        return;
                        // 这里不能再执行   chain.doFilter(request, response) , 因为是新生成的文件,如果用  chain.doFilter 输出,则浏览器收到 404 文件不存的错误 ,
                        // 为了解决这个问题,使用  response 流 Stream 输出解决
                        //chain.doFilter(request, response);
                    } catch (Exception e) {
                        System.out.println("输出缩略图时出错,出错文件reqUri:" + hostUrl + reqUri + (queryString != null && !"".equals(queryString) ? "?" + queryString : "") + ",错误原因:" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
                        e.printStackTrace();
                    } finally {
                        try {
                            if (is != null) is.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            } catch (Exception e) {
                servletResponse.setContentType("text/html;charset=utf-8");
                PrintWriter out = servletResponse.getWriter();
                out.print(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            servletResponse.setContentType("text/html;charset=utf-8");
            PrintWriter out = servletResponse.getWriter();
            out.print(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
            out.flush();
            out.close();
        }
    }
src/com/yc/crm/mail/service/MailFileImpl.java
@@ -44,9 +44,10 @@
 */
@Service("MailFileImpl")
public class MailFileImpl extends BaseService implements MailFileIfc {
    private final ShoppingImageEntity shoppingImage =  new ShoppingImageEntity() ;
    private final ShoppingImageEntity shoppingImage = new ShoppingImageEntity();
    @Autowired
    private DefaultLobHandler defaultLobHandler;
    @Override
    public void saveAttachment(List<MailFileEntity> mailFile) {
        try {
@@ -90,6 +91,7 @@
            attachment.setUnid(unId);
            attachment.setFileType(list.get(i).get("FileType") == null ? null : (String) list.get(i).get("FileType"));
            attachment.setFileSize(list.get(i).get("FileSize") == null ? 0 : (Long) list.get(i).get("FileSize"));
            attachment.setSeq(list.get(i).get("seq") == null ? 0 : (Integer) list.get(i).get("seq"));
            attachment.setPhysicalFile(list.get(i).get("PhysicalFile") == null ? null : (String) list.get(i).get("PhysicalFile"));
            attachment.setOriginalFileName(list.get(i).get("OriginalFileName") == null ? null : (String) list.get(i).get("OriginalFileName"));
            attachment.setOriginalPicture(list.get(i).get("OriginalPicture") == null ? null : (byte[]) list.get(i).get("OriginalPicture"));  //附件处理
@@ -97,7 +99,6 @@
        }
        return attachmentList;
    }
    @Transactional(rollbackFor = Exception.class)
@@ -128,32 +129,32 @@
            width = null;
            height = null;
        }
        ShoppingImageEntity shoppingImageEntity = null ;
        ShoppingImageEntity shoppingImageEntity = null;
        DataSourceEntity dataSourceEntity = null;
        try {
            dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
            dataSourceEntity = MultiDataSource.getDataSourceMap(request);
            if (dataSourceEntity == null) {
                throw new Exception("没有找到数据源,获取图片文件失败!" ) ;
                throw new Exception("没有找到数据源,获取图片文件失败!");
            }
            String rootPath = session.getServletContext().getRealPath("/");
            //String uuid = UUID.randomUUID().toString().toUpperCase();
            shoppingImageEntity = getImage( unid,rootPath ,dataSourceEntity.getDbId(),attachmentPath,formidPath);
            shoppingImageEntity = getImage(unid, rootPath, dataSourceEntity.getDbId(), attachmentPath, formidPath);
            if (shoppingImageEntity == null || shoppingImageEntity.getImage() == null) {
                return null;
            }
            //取原图路径
            String shoppingImageFileName = SettingKey.getShoppingImageFileName(rootPath,unid, width,height, isShowOrgImage, dataSourceEntity.getDbId()+"", shoppingImageEntity.getFileType(),attachmentPath,formidPath);
            String shoppingImageFileName = SettingKey.getShoppingImageFileName(rootPath, unid, width, height, isShowOrgImage, dataSourceEntity.getDbId() + "", shoppingImageEntity.getFileType(), attachmentPath, formidPath);
            File file = shoppingImageEntity.getImage();
            if (file != null) {
                if (width != null && height != null && shoppingImageEntity.getFileType()!=null
                if (width != null && height != null && shoppingImageEntity.getFileType() != null
                        //图片文件才缩放,否则会报错
                        && StringUtils.containsAny(shoppingImageEntity.getFileType().toLowerCase(),"jpg","png","gif","jpeg","tiff","bmp","raw","tga","fpx","webp")) {
                        && StringUtils.containsAny(shoppingImageEntity.getFileType().toLowerCase(), "jpg", "png", "gif", "jpeg", "tiff", "bmp", "raw", "tga", "fpx", "webp")) {
                    // 缩放图片
                    ImageUtils.scale(file.getPath(), shoppingImageFileName, width, height);
                } else {
@@ -166,10 +167,10 @@
                return image;
            }
        } catch (IOException e) {
            System.out.println("输出缩略图时出错,出错文件名:" + (shoppingImageEntity!=null?shoppingImageEntity.getPhysicalFile():"") +  (dataSourceEntity!=null?"dbid:["+dataSourceEntity.getDbId() + "],系统名称:["+ dataSourceEntity.getSystemDescribe()+"]":"") );
            System.out.println("输出缩略图时出错,出错文件名:" + (shoppingImageEntity != null ? shoppingImageEntity.getPhysicalFile() : "") + (dataSourceEntity != null ? "dbid:[" + dataSourceEntity.getDbId() + "],系统名称:[" + dataSourceEntity.getSystemDescribe() + "]" : ""));
            throw e;
        }catch (Exception e) {
            throw e ;
        } catch (Exception e) {
            throw e;
        } finally {
            //if (width != null && height != null && file != null && file.exists())
            //    file.delete();
@@ -178,18 +179,18 @@
    }
    private ShoppingImageEntity getImage(String unids, String rootPath, int dbId, String attachmentPath, String formidPath) {
        if  (unids == null || "".equals(unids))  return null ;
        String unid = "" ,mailSeq = "" ;
        String unidStr[] = unids.split(SettingKey.NAVSPLIT) ;   //
        unid = unidStr[0] ;
        if (unidStr.length > 1 ) {
            String seqs[] = unidStr[1].split(";") ;
            mailSeq = seqs[seqs.length-1];   //只取最后一个 seq , 因为有时候传过来的值是:  7394;7382 ,如果不处理会导致语法错误
        if (unids == null || "".equals(unids)) return null;
        String unid = "", mailSeq = "";
        String unidStr[] = unids.split(SettingKey.NAVSPLIT);   //
        unid = unidStr[0];
        if (unidStr.length > 1) {
            String seqs[] = unidStr[1].split(";");
            mailSeq = seqs[seqs.length - 1];   //只取最后一个 seq , 因为有时候传过来的值是:  7394;7382 ,如果不处理会导致语法错误
        }
        String sql = " set nocount on ; \n"
                + " declare @myrowcount int,@myerror int \n"
                + " declare @unid varchar(50) = "+ GridUtils.prossSqlParm(unid)+" \n"
                + " declare @unid varchar(50) = " + GridUtils.prossSqlParm(unid) + " \n"
                + " declare @FormId int,@DocCode varchar(50),@FieldId varchar(50),@RowId varchar(50) \n"
                + " declare @OriginalFileName varchar(200),@PhysicalFile varchar(50),@FileType varchar(50),@FileSize bigint \n"
                + " declare @AuthorCode varchar(50),@AuthorName varchar(50),@OriginalPicture varbinary(max) \n"
@@ -198,9 +199,9 @@
                + "    @OriginalFileName = a.OriginalFileName ,@PhysicalFile = a.PhysicalFile,@FileType = a.FileType,\n"
                + "    @FileSize = isnull(a.FileSize,0),@AuthorCode = a.AuthorCode,@AuthorName = a.AuthorName,\n"
                + "    @OriginalPicture = a.OriginalPicture \n"
                + " from " + (formidPath!=null&&"9747".equals(formidPath)?"_sys_AttachmentLog":"_sys_Attachment9") + " a \n"
                + " from " + (formidPath != null && "9747".equals(formidPath) ? "_sys_AttachmentLog" : "_sys_Attachment9") + " a \n"
                + " where a.UNID = @unid  \n"
                + (mailSeq !=null && !"".equals(mailSeq)?" and a.fieldid = '" + mailSeq + "' \n":"")
                + (mailSeq != null && !"".equals(mailSeq) ? " and a.fieldid = '" + mailSeq + "' \n" : "")
                + " select @myrowcount  = @@rowcount,@myerror = @@error \n"
                + " if isnull(@myrowcount,0) = 0 \n"
@@ -209,16 +210,16 @@
                + "       @OriginalFileName = a.OriginalFileName ,@PhysicalFile = a.PhysicalFile,@FileType = a.FileType,\n"
                + "       @FileSize = isnull(a.FileSize,0),@AuthorCode = a.AuthorCode,@AuthorName = a.AuthorName,\n"
                + "       @OriginalPicture = a.OriginalPicture \n"
                + "    from "+ (formidPath!=null&&"9747".equals(formidPath)?"_sys_AttachmentLog":"_sys_Attachment") +" a \n"
                + "    from " + (formidPath != null && "9747".equals(formidPath) ? "_sys_AttachmentLog" : "_sys_Attachment") + " a \n"
                + "    where a.UNID = @unid  \n"
                + (mailSeq !=null && !"".equals(mailSeq)?"    and a.fieldid = '" + mailSeq + "' \n":"")
                + (mailSeq != null && !"".equals(mailSeq) ? "    and a.fieldid = '" + mailSeq + "' \n" : "")
                + " end \n "
                + " select @FormId as FormId,@DocCode as DocCode,@FieldId as FieldId,@RowId as RowId, \n" +
                "       @OriginalFileName as OriginalFileName ,@PhysicalFile as PhysicalFile,@FileType as FileType,\n" +
                "       isnull(@FileSize,0) as FileSize,@AuthorCode as AuthorCode,@AuthorName as AuthorName,\n" +
                "       @OriginalPicture as OriginalPicture \n";
        try {
            this.jdbcTemplate.query(sql,new AbstractLobStreamingResultSetExtractor(){
            this.jdbcTemplate.query(sql, new AbstractLobStreamingResultSetExtractor() {
                protected void handleNoRowFound() throws LobRetrievalFailureException {
                    System.out.println("在数据库id为:" + dbId + "中,导购管理  ShoppingImageImpl 未找到 unid=" + unids + " 的图片文件(或附件)!");
                    shoppingImage.setFormId(-1);
@@ -232,66 +233,67 @@
                    shoppingImage.setFileSize(0L);
                    shoppingImage.setAuthorCode("");
                    shoppingImage.setAuthorName("");
                    shoppingImage.setImage(null) ;
                    shoppingImage.setImage(null);
                }
                @Override
                protected void streamData(ResultSet rs) throws SQLException, IOException, DataAccessException {
                    shoppingImage.setFormId(rs.getString("FormId") == null?0:rs.getInt("FormId"));
                    shoppingImage.setDocCode(rs.getString("DocCode") == null?"":rs.getString("DocCode"));
                    shoppingImage.setFieldId(rs.getString("FieldId") == null?"":rs.getString("FieldId"));
                    shoppingImage.setRowId(rs.getString("RowId") == null?"":rs.getString("RowId"));
                    shoppingImage.setFormId(rs.getString("FormId") == null ? 0 : rs.getInt("FormId"));
                    shoppingImage.setDocCode(rs.getString("DocCode") == null ? "" : rs.getString("DocCode"));
                    shoppingImage.setFieldId(rs.getString("FieldId") == null ? "" : rs.getString("FieldId"));
                    shoppingImage.setRowId(rs.getString("RowId") == null ? "" : rs.getString("RowId"));
                    shoppingImage.setOriginalFileName(rs.getString("OriginalFileName") == null?null:rs.getString("OriginalFileName"));
                    shoppingImage.setPhysicalFile(rs.getString("PhysicalFile") == null?null:rs.getString("PhysicalFile"));
                    shoppingImage.setFileType(rs.getString("FileType") == null?null:rs.getString("FileType"));
                    shoppingImage.setOriginalFileName(rs.getString("OriginalFileName") == null ? null : rs.getString("OriginalFileName"));
                    shoppingImage.setPhysicalFile(rs.getString("PhysicalFile") == null ? null : rs.getString("PhysicalFile"));
                    shoppingImage.setFileType(rs.getString("FileType") == null ? null : rs.getString("FileType"));
                    shoppingImage.setFileSize(rs.getLong("FileSize"));
                    shoppingImage.setAuthorCode(rs.getString("AuthorCode") == null?null:rs.getString("AuthorName"));
                    shoppingImage.setAuthorName(rs.getString("AuthorName") == null?null:rs.getString("AuthorName"));
                    shoppingImage.setAuthorCode(rs.getString("AuthorCode") == null ? null : rs.getString("AuthorName"));
                    shoppingImage.setAuthorName(rs.getString("AuthorName") == null ? null : rs.getString("AuthorName"));
                    //取原图路径
                    String shoppingImageFileName = SettingKey.getShoppingImageFileName(rootPath,unids, null, null, true, dbId+"", shoppingImage.getFileType(),attachmentPath,formidPath);
                    InputStream is = null ;
                    byte[] bytes = null ;
                    String shoppingImageFileName = SettingKey.getShoppingImageFileName(rootPath, unids, null, null, true, dbId + "", shoppingImage.getFileType(), attachmentPath, formidPath);
                    InputStream is = null;
                    byte[] bytes = null;
                    try {
                        is = defaultLobHandler.getBlobAsBinaryStream(rs, "OriginalPicture");
                        if (is != null) {
                            bytes = ShoppingImageEntity.InputStreamToByte( is); //取二进制图片
                            bytes = ShoppingImageEntity.InputStreamToByte(is); //取二进制图片
                            File file = BlobToFile.writeBytesToFile(bytes,shoppingImageFileName);  //
                            File file = BlobToFile.writeBytesToFile(bytes, shoppingImageFileName);  //
                            if (file != null) {
                                shoppingImage.setImage(file);
                            }
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        throw e ;
                        throw e;
                    } finally {
                        bytes = null ;
                        bytes = null;
                        if (is != null) is.close();
                    }
                }   // end function
            });
            return shoppingImage ;
            return shoppingImage;
        }catch(DataAccessException e ) {
            if (e instanceof EmptyResultDataAccessException){
                return null ;
            }else {
                System.out.println("dbid:" + dbId + ",error:" + (e.getCause() != null ?e.getCause().getMessage():e.getMessage())) ;
        } catch (DataAccessException e) {
            if (e instanceof EmptyResultDataAccessException) {
                return null;
            } else {
                System.out.println("dbid:" + dbId + ",error:" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
                e.printStackTrace();
                throw e;
            }
        }catch(Exception e){
            System.out.println("dbid:" + dbId + ",error:" + (e.getCause() != null ?e.getCause().getMessage():e.getMessage())) ;
        } catch (Exception e) {
            System.out.println("dbid:" + dbId + ",error:" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
            e.printStackTrace();
            throw e;
        }
    }
    /**
     * 判断是否为数字
     *
src/com/yc/crm/mail/service/MailImpl.java
@@ -159,7 +159,7 @@
        String sql = "set nocount on\n";
        try {
            sql += "declare @docCode varchar(200) ='" + docCode + "' \n";
            sql += "update t482101H deleteFlag=1 where userCode =" + GridUtils.prossSqlParm(userCode) +
            sql += "update t482101H set delete_flag=1 where userCode =" + GridUtils.prossSqlParm(userCode) +
                    " and docCode in (select list from GetInStr(@docCode))\n";//标记删除
            sql += " select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
@@ -174,7 +174,7 @@
        String sql = "set nocount on\n";
        try {
            sql += "declare @docCode varchar(200) ='" + docCode + "' \n";
            sql += "update t482101H deleteFlag=1 where userCode =" + GridUtils.prossSqlParm(userCode) +
            sql += "update t482101H set delete_flag=1 where userCode =" + GridUtils.prossSqlParm(userCode) +
                    " and docCode in (select list from GetInStr(@docCode))\n";//标记删除
            sql += " select @@ROWCOUNT";
            return jdbcTemplate.queryForObject(sql, Integer.class);
@@ -221,6 +221,7 @@
                    "read_Flag,(case when (isnull(handle_time,'') <> '' and isnull(handle_time,'') < getdate()) then 1 else 0 end) as handle," +
                    "handle_time,sender_time,receiving_time from t482101H ";
            sql += " where userCode=" + GridUtils.prossSqlParm(userCode);
            sql += " and isnull(delete_Flag,0) = 0 ";//未删除的
            sql += " and mailType=" + mailType;//0:草稿箱 1:收件箱 2:发件箱
            if (StringUtils.isNotBlank(email)) {
                if (mailType == 1) {