Search in sources :

Example 11 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class EmailServerService method addEamilServer.

// 添加邮箱配置
public int addEamilServer(EmailServer emailServer) throws Exception {
    if (emailServer == null)
        throw new ServiceNullException("要添加的邮件配置为空");
    emailServer.setCreateTime(new Date());
    // 对密码进行加密
    if (StringUtils.isNotBlank(emailServer.getAccountPasswd()))
        emailServer.setAccountPasswd(AESencrp.encrypt(emailServer.getAccountPasswd(), dbEncKey));
    // 添加时更新时间等于添加时间
    emailServer.setLastModify(emailServer.getCreateTime());
    sqlSession.insert("com.itrus.portal.db.EmailServerMapper.insert", emailServer);
    return 0;
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) Date(java.util.Date)

Example 12 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class SysRegionService method getRegionsByCode.

/**
 * 根据行政区代码,获取行政区子级信息
 * @param code
 * @param type
 * @return
 * @throws ServiceNullException
 */
public List<Region4t> getRegionsByCode(String code, Integer type) throws ServiceNullException {
    List<Region4t> region4tList = new ArrayList<Region4t>();
    SysRegion sysRegion = getRegionByCode(code);
    // 指定代码不存在
    if (sysRegion == null) {
        throw new ServiceNullException("未知的行政区代码【" + code + "】");
    }
    // 查询指定代码的下层节点
    SysRegionExample sysRegionExample = new SysRegionExample();
    SysRegionExample.Criteria srCriteria = sysRegionExample.createCriteria();
    srCriteria.andParentIdEqualTo(sysRegion.getId());
    srCriteria.andTypeEqualTo(sysRegion.getType() + 1);
    sysRegionExample.setOrderByClause("code asc");
    Map<Long, SysRegion> childSR = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectByExample", sysRegionExample, "id");
    // 判断下级节点是否有子节点
    sysRegionExample.clear();
    sysRegionExample.setOrderByClause(null);
    srCriteria = sysRegionExample.createCriteria();
    srCriteria.andParentIdIn(new ArrayList<Long>(childSR.keySet()));
    Map<Long, Object> childNumMap = new HashMap<Long, Object>();
    if (!childSR.isEmpty())
        childNumMap = sqlSession.selectMap("com.itrus.portal.db.SysRegionMapper.selectChildNumByExample", sysRegionExample, "parentId");
    Iterator iter = childSR.entrySet().iterator();
    while (iter.hasNext()) {
        SysRegion sr = (SysRegion) ((Map.Entry) iter.next()).getValue();
        region4tList.add(new Region4t(sr.getNameCn(), sr.getCode(), sr.getType(), childNumMap.containsKey(sr.getId()) ? 1 : 0));
    }
    return region4tList;
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) SysRegion(com.itrus.portal.db.SysRegion) SysRegionExample(com.itrus.portal.db.SysRegionExample)

Example 13 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class RealNameAuthenticationSerivceImpl method updateRealName.

// 修改信息
public void updateRealName(RealNameAuthentication realname) throws ServiceNullException, Exception {
    if (realname == null || realname.getId() == null)
        throw new ServiceNullException("配置为空");
    RealNameAuthentication realname1 = getRealNameById(realname.getId());
    if (realname1 == null)
        throw new ServiceNullException("配置不存在");
    sqlSession.update("com.itrus.portal.db.RealNameAuthenticationMapper.updateByPrimaryKeySelective", realname);
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) RealNameAuthentication(com.itrus.portal.db.RealNameAuthentication)

Example 14 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class FilePathUtils method savepdf.

/**
 * 保存pdf
 * @param dir
 * @param bfile
 * @param bfile
 * @param fileType
 * @param itemType
 * @return
 * @throws IOException
 * @throws UserInfoServiceException
 * @throws ServiceNullException
 */
public File savepdf(File dir, byte[] bfile, String fileType, String itemType) throws IOException, UserInfoServiceException, ServiceNullException {
    BufferedOutputStream bos = null;
    FileOutputStream fos = null;
    String filename = itemType + fileType;
    // 创建磁盘文件
    File file = null;
    try {
        // dir = new File(fileURI.substring(0,fileURI.lastIndexOf("/")+1).replace("/", "\\"));
        if (!dir.exists() && dir.isDirectory()) {
            // 判断文件目录是否存在
            dir.mkdirs();
        }
        file = new File(dir, filename);
        fos = new FileOutputStream(file);
        bos = new BufferedOutputStream(fos);
        bos.write(bfile);
        if (file.length() > IMG_MAX_SIZE) {
            throw new UserInfoServiceException("PDF文件大小不能超过" + (IMG_MAX_SIZE / 1024) + "K");
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (bos != null) {
            try {
                bos.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
        if (fos != null) {
            try {
                fos.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    }
    return file;
}
Also used : FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream) MultipartFile(org.springframework.web.multipart.MultipartFile) File(java.io.File) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) ServiceNullException(com.itrus.portal.exception.ServiceNullException)

Example 15 with ServiceNullException

use of com.itrus.portal.exception.ServiceNullException in project portal by ixinportal.

the class ImageByBase64 method saveImage.

/**
 * 将图片写入磁盘
 *
 * @param fileBase64
 *            图片的base64字符串
 * @param saveFile
 *            将写入的磁盘文件
 * @throws ServiceNullException
 */
public void saveImage(String fileBase64, File saveFile) throws IOException, UserInfoServiceException, ServiceNullException {
    if (fileBase64.indexOf("/reviewWeb/img/") != -1) {
        String editbillImg = fileBase64.substring(fileBase64.indexOf("/reviewWeb/img/") + 15, fileBase64.length());
        String[] ss = editbillImg.split("/");
        Long type = Long.parseLong(ss[0]);
        Long id = Long.parseLong(ss[1]);
        Long num = Long.parseLong(ss[2]);
        File tempFile = getImg(type, id, num);
        if (null == tempFile) {
            logger.error("fileBase64:" + fileBase64);
        }
        CopyFile.copyFile(tempFile, saveFile);
        return;
    }
    // 检查传递的base64信息是否为图片地址:/img/{type}/{random}?t=uploadTime
    if (fileBase64.length() < 100 && fileBase64.indexOf("/img/") != -1) {
        try {
            String[] baseInfos = fileBase64.split("/");
            String[] uploadStr = baseInfos[3].split("=");
            String random = uploadStr[0].substring(0, uploadStr[0].indexOf("?"));
            String upload = uploadStr[1];
            // upload = upload.substring(upload.indexOf("=") + 1);
            // 上传时间
            Date uploadTime = new Date(Long.parseLong(upload));
            TempPic tempPic = tempPicService.getTempPicByRandomAndTime(random, uploadTime);
            if (null == tempPic) {
                logger.error("fileBase64:" + fileBase64);
                throw new ServiceNullException("未找到上传的临时图片记录");
            }
            String type = baseInfos[2];
            String fileName = null;
            // } else
            if ("1".equals(type)) {
                // 证件图片A
                fileName = tempPic.getImgFileA();
            } else if ("2".equals(type)) {
                // 证件图片B
                fileName = tempPic.getImgFileB();
            }
            if (null == fileName) {
                logger.error("fileBase64:" + fileBase64);
                throw new ServiceNullException("未找到上传的临时图片名称");
            }
            File tempFile = new File(tempPicService.getDir(random), fileName);
            // 将临时文件写入到需要保存的地方
            CopyFile.copyFile(tempFile, saveFile);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("fileBase64:" + fileBase64);
            throw new ServiceNullException("未找到上传的临时图片记录信息");
        }
    } else if (fileBase64.indexOf("/editbillImg/") != -1) {
        String editbillImg = fileBase64.substring(fileBase64.indexOf("/editbillImg/") + 13, fileBase64.length());
        String[] ss = editbillImg.split("/");
        String userSn = ss[2];
        Integer type = Integer.parseInt(ss[0]);
        Long editBillId = Long.parseLong(ss[1]);
        EditBill editBill = null;
        String fileName = "";
        if (null == type || StringUtils.isBlank(userSn) || null == editBillId) {
            logger.error("fileBase64:" + fileBase64);
            throw new ServiceNullException("填写中的订单的图片url不正确");
        }
        editBill = sqlsession.selectOne("com.itrus.portal.db.EditBillMapper.selectByPrimaryKey", editBillId);
        if (null == editBill) {
            logger.error("fileBase64:" + fileBase64);
            throw new ServiceNullException("找不到填写中的订单信息");
        }
        /*
			 * 0 营业执照图片, 1 组织机构代码图片, 2 税务登记图片, 3 法人正面图片
			 * 4 法人反面图片, 5 授权书图片, 6 代理人正面图片, 7 代理人反面图片
			 * */
        if (type.equals(0)) {
            fileName = editBill.getBlImgFile();
        } else if (type.equals(1)) {
            fileName = editBill.getOcImgFile();
        } else if (type.equals(2)) {
            fileName = editBill.getTrImgFile();
        } else if (type.equals(3)) {
            fileName = editBill.getIcfImgFile();
        } else if (type.equals(4)) {
            fileName = editBill.getIcbImgFile();
        } else if (type.equals(5)) {
            fileName = editBill.getPrImgFile();
        } else if (type.equals(6)) {
            fileName = editBill.getAtfImgFile();
        } else if (type.equals(7)) {
            fileName = editBill.getAtbImgFile();
        }
        File tempFile;
        try {
            tempFile = new File(filePathUtils.getDir(null, userSn), fileName);
            // 将临时文件写入到需要保存的地方
            CopyFile.copyFile(tempFile, saveFile);
        } catch (Exception e) {
            logger.error("fileBase64:" + fileBase64);
            e.printStackTrace();
            throw new ServiceNullException("填写中的订单的图片url不正确");
        }
    } else {
        // Base64解码
        byte[] b = Base64.decode(fileBase64);
        OutputStream out = new FileOutputStream(saveFile);
        out.write(b);
        out.flush();
        out.close();
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) ServiceNullException(com.itrus.portal.exception.ServiceNullException) File(java.io.File) Date(java.util.Date) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) EditBill(com.itrus.portal.db.EditBill) TempPic(com.itrus.portal.db.TempPic)

Aggregations

ServiceNullException (com.itrus.portal.exception.ServiceNullException)15 Date (java.util.Date)7 ActivityMsgTemp (com.itrus.portal.db.ActivityMsgTemp)3 File (java.io.File)3 IOException (java.io.IOException)3 SmsGate (com.itrus.portal.db.SmsGate)2 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)2 FileOutputStream (java.io.FileOutputStream)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 SigningServerException (com.itrus.cryptorole.SigningServerException)1 ActivityMsgTempExample (com.itrus.portal.db.ActivityMsgTempExample)1 EditBill (com.itrus.portal.db.EditBill)1 EmailServer (com.itrus.portal.db.EmailServer)1 EvidenceCert (com.itrus.portal.db.EvidenceCert)1 ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)1 RealNameAuthentication (com.itrus.portal.db.RealNameAuthentication)1 ReceiptConfig (com.itrus.portal.db.ReceiptConfig)1 SysRegion (com.itrus.portal.db.SysRegion)1 SysRegionExample (com.itrus.portal.db.SysRegionExample)1