Search in sources :

Example 66 with UserInfoServiceException

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

the class PersonCertificationServiceImpl method registerPersonInfo.

/**
 * 注册用户(第一步)
 *
 * @param mPhone
 * @param password
 * @return
 * @throws UserInfoServiceException
 */
public synchronized PersonInfo registerPersonInfo(String mPhone, String password) throws UserInfoServiceException {
    PersonInfo personInfo0 = getPersonInfoByMphone(mPhone);
    if (null != personInfo0)
        throw new UserInfoServiceException("该手机号已经注册过用户,请重新登录");
    PersonInfo personInfo = new PersonInfo();
    personInfo.setCreateTime(new Date());
    personInfo.setModifyTime(new Date());
    personInfo.setProject(sysconfigService.getPersonProject());
    ProductExample ex1 = new ProductExample();
    ProductExample.Criteria crt1 = ex1.or();
    crt1.andProjectEqualTo(personInfo.getProject());
    List<Product> products = sqlSession.selectList("com.itrus.portal.db.ProductMapper.selectByExample", ex1);
    String auth = "";
    for (int i = 0; i < products.size(); i++) {
        auth = auth + products.get(i).getAuthentication().toString() + ",";
    }
    auth = auth.substring(0, auth.length() - 1);
    personInfo.setAuthentication(auth);
    personInfo.setmPhone(mPhone);
    personInfo.setPassword(passwordEncoder.encodePassword(password, ComNames.SALT));
    // 设置用户唯一标识
    personInfo.setUniqueId(UniqueIDUtils.genPersonInfoUID(sqlSession));
    personInfo.setTrustMPhone(true);
    sqlSession.insert("com.itrus.portal.db.PersonInfoMapper.insert", personInfo);
    sqlSession.flushStatements();
    // 更新用户唯一标识
    personInfo.setUniqueId(UniqueIDUtils.genPersonInfoUID(personInfo));
    sqlSession.update("com.itrus.portal.db.PersonInfoMapper.updateByPrimaryKey", personInfo);
    return personInfo;
}
Also used : UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 67 with UserInfoServiceException

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

the class PersonCertificationServiceImpl method savePersonInfo.

/**
 * 新增用户
 *
 * @param personInfo
 * @return
 * @throws UserInfoServiceException
 */
public PersonInfo savePersonInfo(PersonInfo personInfo) throws UserInfoServiceException {
    PersonInfo personInfo0 = getPersonInfoByMphone(personInfo.getmPhone());
    if (null != personInfo0)
        throw new UserInfoServiceException("该手机号已经注册过用户,请重新登录");
    personInfo.setCreateTime(new Date());
    personInfo.setModifyTime(new Date());
    // 设置用户唯一标识
    personInfo.setUniqueId(UniqueIDUtils.genPersonInfoUID(sqlSession));
    personInfo.setTrustMPhone(true);
    sqlSession.insert("com.itrus.portal.db.PersonInfoMapper.insert", personInfo);
    sqlSession.flushStatements();
    return personInfo;
}
Also used : UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 68 with UserInfoServiceException

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

the class MakeCerServiceImpl method sendReNewInfo.

/**
 * 向用户发送待更新证书短信通知
 *
 * @param mPhone
 *            手机
 * @param project
 *            项目id
 * @param smsType
 *            短信模版类型(ZSGX:证书更新)
 *
 * @throws UserInfoServiceException
 */
public void sendReNewInfo(Bill bill, String mPhone, Long project, String smsType, String keySn, String enterpriseName, Date endTime, String productName) throws UserInfoServiceException {
    // 发送动态码,获取发送的短信内容
    MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(project, smsType);
    if (null == messageTemplate) {
        throw new UserInfoServiceException("未找到对应的短信模版,请联系管理员配置");
    }
    String content = messageTemplate.getMessageContent();
    String end = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endTime);
    // 进行替换
    content = content.replaceAll("enterpriseName", enterpriseName);
    content = content.replaceAll("keySn", keySn);
    content = content.replaceAll("endTime", end);
    content = content.replaceAll("productName", productName);
    // TODO 接口欠费,成功应该改回true,但是现在是欠费的,所以是false,为了通过,先改成这样,正确的应该是:!smsSendService.sendReNewInfoSms(mPhone, content, "更新证书", project)
    if (!smsSendService.sendReNewInfoSms(mPhone, content, "更新证书", project)) {
        // 发送失败
        throw new UserInfoServiceException("更新证书通知送失败,请联系管理员查看原因");
    } else {
        // 发送成功: 记录信息
        bill.setRenewSms(true);
        bill.setRenewSendTime(new Date());
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) SimpleDateFormat(java.text.SimpleDateFormat) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Date(java.util.Date)

Example 69 with UserInfoServiceException

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

the class GetRaInfoTask method getRaInfoByCertSerialNumber.

/**
 * 根据证书序列号,从本地数据库或者远程数据库获取证书对应的RA信息
 *
 * @param CertSerialNumber
 *            :证书序列号
 * @return
 * @throws UserInfoServiceException
 */
public String getRaInfoByCertSerialNumber(String CertSerialNumber) throws UserInfoServiceException {
    // 从本地数据库中查询是否存在该证书对应的ra哈希值
    RaInfoExample raInfoExample = new RaInfoExample();
    RaInfoExample.Criteria criteria = raInfoExample.or();
    criteria.andCertSerialnumberEqualTo(CertSerialNumber);
    RaInfo raInfo = sqlSession.selectOne("com.itrus.portal.db.RaInfoMapper.selectByExample", raInfoExample);
    Map<String, Object> retmMap = new HashMap<String, Object>();
    if (null != raInfo && !raInfo.getAccountHash().equals("")) {
        return raInfo.getAccountHash();
    } else {
        // 判断系统是否配置了RA信息同步地址
        SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoUrl");
        if (null == sysConfig) {
            throw new UserInfoServiceException("未配置RA信息同步地址");
        }
        // http://localhost:8080/raInfo/getRa.jsp
        String url = sysConfig.getConfig() + "/getRa.jsp";
        // 从远程数据库中获取证书对应的RA哈希值
        LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
        map.add("certSn", CertSerialNumber);
        try {
            String resStr = restTemplate.postForObject(url, map, String.class);
            Map<String, Object> remap = jsonTool.readValue(resStr, Map.class);
            Integer status = (Integer) remap.get("status");
            if (0 == status) {
                String type = "查询证书RA信息出错";
                String info = "查询出现错误的证书序列号:" + CertSerialNumber + ",错误信息:" + (String) remap.get("message");
                LogUtil.syslog(sqlSession, type, info);
                throw new UserInfoServiceException("查询RA信息出错,请联系管理员");
            } else {
                raInfo = insertOneRaInfoIntoDB(remap, raInfo);
                retmMap.put("accountHash", raInfo.getAccountHash());
                String type = "查询证书归属的RA信息成功";
                String info = "查询证书:" + CertSerialNumber + "的RA信息成功,归属RA:" + raInfo.getAccountHash();
                LogUtil.syslog(sqlSession, type, info);
                return raInfo.getAccountHash();
            }
        } catch (Exception e) {
            e.printStackTrace();
            String type = "查询证书RA信息出错";
            String info = "查询出现错误的证书序列号:" + CertSerialNumber + ",错误信息:" + e.getMessage();
            LogUtil.syslog(sqlSession, type, info);
            throw new UserInfoServiceException("查询证书RA信息出错,请联系管理员");
        }
    }
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) HashMap(java.util.HashMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UnknownHostException(java.net.UnknownHostException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RaInfo(com.itrus.portal.db.RaInfo) RaInfoExample(com.itrus.portal.db.RaInfoExample)

Example 70 with UserInfoServiceException

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

the class SendReNewInfoTask method sendReNewInfo.

/**
 * 心跳更新。启动时执行一次,之后每隔24小时执行一次
 */
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
public void sendReNewInfo() {
    // 筛选出所有是待更新的,而且未发送短信的订单
    BillExample billExample = new BillExample();
    BillExample.Criteria criteria = billExample.or();
    // 订单状态是12的时候,表示是待更新的订单
    criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_12);
    // 订单的短信发送时间是Null的时候,表示未发送过通知短信
    criteria.andRenewSendTimeIsNull();
    criteria.andIsDeleteEqualTo(false);
    // billExample.setLimit(100);
    List<Bill> bills = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
    if (null == bills || bills.size() < 1) {
        return;
    }
    String billSn = "";
    String mPhone = "";
    try {
        // 向每个订单发送短信通知
        for (int i = 0; i < bills.size(); i++) {
            billSn = bills.get(i).getBillId();
            UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bills.get(i).getUniqueId());
            mPhone = userInfo.getmPhone();
            UserCertExample userCertExample = new UserCertExample();
            UserCertExample.Criteria ucriteria = userCertExample.or();
            ucriteria.andIdEqualTo(bills.get(i).getOldUserCert());
            UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userCertExample);
            Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bills.get(i).getEnterprise());
            Long projectId = bills.get(i).getProject();
            String keySn = "";
            if (null == userCert.getKeySn()) {
                keySn = "该证书未绑定key";
            } else {
                keySn = userCert.getKeySn();
            }
            String enterpriseName = enterprise.getEnterpriseName();
            Date endTime = userCert.getCertEndTime();
            // 获取订单对应的产品信息
            Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bills.get(i).getProduct());
            String productName = product.getName();
            try {
                makeCerServiceImpl.sendReNewInfo(bills.get(i), mPhone, projectId, "ZSGX", keySn, enterpriseName, endTime, productName);
            } catch (UserInfoServiceException e) {
                String type = "发送证书更新通知失败";
                String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
                LogUtil.syslog(sqlSession, type, info);
                log.error("ERRORLOG证书更新通知 {}", info);
                return;
            } catch (Exception e) {
                String type = "发送证书更新通知失败";
                String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
                LogUtil.syslog(sqlSession, type, info);
                log.error("ERRORLOG证书更新通知 {}", info);
                return;
            }
        }
    } catch (Exception e) {
        String type = "发送证书更新通知失败";
        String info = "用户手机号:" + mPhone + ",订单号" + billSn + "错误信息:" + e.getMessage();
        LogUtil.syslog(sqlSession, type, info);
        log.error("ERRORLOG证书更新通知 {}", info);
        return;
    }
}
Also used : UserCertExample(com.itrus.portal.db.UserCertExample) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) BillExample(com.itrus.portal.db.BillExample) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) UserCert(com.itrus.portal.db.UserCert) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)73 Date (java.util.Date)39 HashMap (java.util.HashMap)31 File (java.io.File)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)22 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)21 Enterprise (com.itrus.portal.db.Enterprise)19 IOException (java.io.IOException)19 UserInfo (com.itrus.portal.db.UserInfo)17 TransactionStatus (org.springframework.transaction.TransactionStatus)14 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)14 SigningServerException (com.itrus.cryptorole.SigningServerException)11 IdentityCard (com.itrus.portal.db.IdentityCard)11 CertificateException (java.security.cert.CertificateException)11 BusinessLicense (com.itrus.portal.db.BusinessLicense)10 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)10 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)10 Agent (com.itrus.portal.db.Agent)9 OrgCode (com.itrus.portal.db.OrgCode)9 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)9