Search in sources :

Example 21 with EvidenceBasicInformation

use of com.itrus.portal.db.EvidenceBasicInformation in project portal by ixinportal.

the class EvidenceSaveServiceApi method searchStored.

/**
 * 查询存证
 * @param signature
 * 			签名值
 * @param appId
 * 			应用标识
 * @param evidenceSn
 * 			证据编号
 * @param request
 * @return
 */
@RequestMapping(value = "/searchStored")
@ResponseBody
public Map<String, Object> searchStored(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "evidenceSn", required = false) String evidenceSn, HttpServletRequest request) {
    // TODO : 查询存证接口
    Map<String, Object> result = new HashMap<String, Object>();
    // 验证参数是否完整
    if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(evidenceSn)) {
        result.put("status", 0);
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    // 得到应用信息 改成service
    Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
    ApplicationInfo applicationInfo = appInfoMap.get(appId);
    if (applicationInfo == null) {
        ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
        ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
        appInfoExampleCriteria.andAppIdEqualTo(appId);
        applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
    }
    if (applicationInfo == null) {
        result.put("status", -11);
        result.put("message", "应用标识不存在");
        return result;
    }
    if (applicationInfo.getIsAppStatus() == 0) {
        result.put("status", -12);
        result.put("message", "应用状态已关闭");
        return result;
    }
    // 核验ip限制
    if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
        result.put("status", -1);
        result.put("message", "没有此服务权限");
        log.debug("EvidenceSaveSeriveceTest_AccsessIp : " + request.getRemoteAddr());
        return result;
    }
    // 验证hmac有效性
    try {
        String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appId + evidenceSn, applicationInfo.getSecretKey()), false);
        if (!signature.equals("HMAC-SHA1 " + macVal)) {
            result.put("status", -2);
            result.put("message", "服务密钥错误");
            return result;
        }
    } catch (Exception e) {
        result.put("status", -3);
        result.put("message", "Hmac验证错误");
        e.printStackTrace();
        return result;
    }
    // 获得证据基础信息
    EvidenceBasicInformationExample basicInformationExample = new EvidenceBasicInformationExample();
    EvidenceBasicInformationExample.Criteria beCriteria = basicInformationExample.createCriteria();
    beCriteria.andEvidenceSnEqualTo(evidenceSn);
    List<EvidenceBasicInformation> basicInformationList = sqlSession.selectList("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByExample", basicInformationExample);
    if (basicInformationList == null || basicInformationList.isEmpty()) {
        result.put("status", 0);
        result.put("message", "未找到对应证据编号信息,请稍后重试。");
        return result;
    }
    EvidenceBasicInformation basicInformation = basicInformationList.get(0);
    // 判断该存储信息状态是否成功
    if (basicInformation.getEvidenceStatus() == 1) {
        // 判断业务类型为 身份认证 及 2,3 时  不需要返回回执报告        1:电子合同, 2:合同摘要数据, 3:图片摘要数据
        if (basicInformation.getType().equals("2") || basicInformation.getType().equals("3") || basicInformation.getType().equals("4") || (basicInformation.getType().equals("1") && basicInformation.getEvidenceType() == 1)) {
            result.put("status", 1);
            result.put("message", "存证成功");
            return result;
        }
        if (basicInformation.getReceiptStatus() == 1) {
            // 获取原子服务地址  1.实名认证  2.密码服务  3.时间戳
            RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
            if (realNameAuthentication == null) {
                try {
                    realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
                } catch (Exception e) {
                    e.printStackTrace();
                    result.put("status", -6);
                    result.put("message", "原子服务配置异常,请联系管理员");
                    return result;
                }
            }
            if (realNameAuthentication == null) {
                result.put("status", -6);
                result.put("message", "缺少密码服务配置,请联系管理员");
                return result;
            }
            // 获取回执报告附件表信息
            EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
            EvidenceEnclosureExample.Criteria ec = enclosureExample.createCriteria();
            ec.andEvidenceSnEqualTo(basicInformation.getEvidenceSn());
            ec.andPdfTypeEqualTo("3");
            List<EvidenceEnclosure> enclosures = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample);
            if (basicInformationList == null || basicInformationList.isEmpty()) {
                result.put("status", 0);
                result.put("message", "未找到对应回执报告信息");
                return result;
            }
            EvidenceEnclosure enclosure = enclosures.get(0);
            // 调解密下载接口从原子服务拿到回执报告base64
            String base64 = decryptedAndDownload(sqlSession, enclosure.getBuid(), realNameAuthentication.getRealNameddress());
            if (StringUtils.isNotEmpty(base64)) {
                result.put("base64", base64);
            } else {
                result.put("status", 0);
                result.put("message", "获取存证回执报告失败,请联系管理员");
                return result;
            }
        } else {
            // 调用生成回执报告方法
            Map<String, Object> mapRet = null;
            try {
                mapRet = reportTemplate.returnreceipt(evidenceSn, applicationInfo, null);
            } catch (Exception e) {
                result.put("status", 0);
                result.put("message", "生成存证回执报告失败,请重试或者联系管理员");
                return result;
            }
            if (mapRet.get("status") != null && (int) mapRet.get("status") == 0) {
                // 修改证据基本信息回执状态为已出
                result.put("reportBase64", mapRet.get("pdfBase64"));
                basicInformation.setReceiptStatus(1);
                sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
            } else {
                result.put("status", 0);
                result.put("message", "生成存证回执报告失败,请重试或者联系管理员");
                return result;
            }
        }
        result.put("status", 1);
        if (StringUtils.isEmpty(basicInformation.getLackMainContent()))
            result.put("message", "存证回执报告生成成功");
        else
            result.put("message", "存证回执报告生成成功," + basicInformation.getLackMainContent());
    } else {
        if (StringUtils.isEmpty(basicInformation.getLackMainContent()))
            result.put("message", basicInformation.getFailureReason());
        else
            result.put("message", basicInformation.getFailureReason() + "," + basicInformation.getLackMainContent());
        result.put("status", 0);
    }
    return result;
}
Also used : ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) RealNameAuthentication(com.itrus.portal.db.RealNameAuthentication) IOException(java.io.IOException) EvidenceBasicInformationExample(com.itrus.portal.db.EvidenceBasicInformationExample) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 22 with EvidenceBasicInformation

use of com.itrus.portal.db.EvidenceBasicInformation in project portal by ixinportal.

the class EvidenceSaveServiceApi method saveCallBack1.

@RequestMapping("/savecallback1")
@ResponseBody
public Map<String, Object> saveCallBack1(@RequestParam(value = "evidenceSn", required = false) String evidenceSn, HttpServletRequest request) throws Exception {
    EvidenceBasicInformation basicInformation = informationService.getInformationBySn(evidenceSn, null);
    // 调用生成回执报告方法
    ApplicationInfo applicationInfo = CacheCustomer.getAPP_INFO_MAP_BY_ID().get(basicInformation.getApplicationInfo());
    if (applicationInfo == null) {
        // TODO: 2018/3/15 从缓存取
        applicationInfo = infoService.selectById(basicInformation.getApplicationInfo());
    }
    Map<String, Object> mapRet = reportTemplate.returnreceipt(evidenceSn, applicationInfo, null);
    log.error("EvidenceQueryQueue mapRet is " + mapRet.get("status"));
    ;
    if (mapRet.get("status") != null && (int) mapRet.get("status") == 0) {
        // 修改证据基本信息回执状态为已出
        String reportBase64 = (String) mapRet.get("pdfBase64");
        basicInformation.setReceiptStatus(1);
        sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
    }
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("code", "1");
    retMap.put("message", "回调申请成功。");
    return retMap;
}
Also used : EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 23 with EvidenceBasicInformation

use of com.itrus.portal.db.EvidenceBasicInformation in project portal by ixinportal.

the class EvidenceSaveServiceApi method save.

// @Autowired
// private ProducerService producerService;
// 回执报告缓存Map key:证据编号  value:回执base64
// public static ConcurrentHashMap<String, String> cacheReportBySnMap = new ConcurrentHashMap<>();
/**
 * 存证接口
 * @param signature
 * 			签名值
 * @param appId
 * 			应用id
 * @param serviceCode
 * 			服务编号
 * @param evidenceSn
 * 			证据编号
 * @param signedBase64
 * 			签名值base64
 * @param evidencePackage
 * 			证据包
 * @param request
 * @return
 */
@RequestMapping("/save")
@ResponseBody
public Map<String, Object> save(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "serviceCode", required = false) String serviceCode, @RequestParam(value = "evidenceSn", required = false) String evidenceSn, @RequestParam(value = "hashAlg", required = false) String hashAlg, @RequestParam(value = "signedBase64", required = false) String signedBase64, @RequestParam(value = "evidencePackage", required = false) String evidencePackage, HttpServletRequest request) {
    // 返回值
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("status", 1);
    // 申请时间
    Date date = new Date();
    // 验证参数是否完整
    if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(serviceCode) || StringUtils.isEmpty(evidencePackage) || StringUtils.isEmpty(hashAlg) || StringUtils.isEmpty(signedBase64)) {
        result.put("status", 0);
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    // 获取对应应用信息
    ApplicationInfo applicationInfo = applicationInfoService.getApplicationInfo(appId);
    if (applicationInfo == null) {
        result.put("status", -11);
        result.put("message", "应用标识不存在");
        return result;
    }
    if (applicationInfo.getIsAppStatus() == 0) {
        result.put("status", -12);
        result.put("message", "应用状态已关闭");
        return result;
    }
    // 核验ip限制
    if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
        result.put("status", -1);
        result.put("message", "没有此服务权限");
        log.debug("EvidenceSaveSeriveceTest_AccsessIp : " + request.getRemoteAddr());
        return result;
    }
    // 验证hmac有效性
    try {
        String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, applicationInfo.getSecretKey()), false);
        if (!signature.equals("HMAC-SHA1 " + macVal)) {
            result.put("status", -2);
            result.put("message", "服务密钥错误");
            return result;
        }
    } catch (Exception e) {
        result.put("status", -3);
        result.put("message", "Hmac验证错误");
        e.printStackTrace();
        return result;
    }
    // 获取对应应用信息
    EvidenceSaveService evidenceSaveService = null;
    AppService appService = appServiceExt.getAppService(serviceCode);
    if (appService != null && "EvidenceSaveService".equals(appService.getServiceConfigName())) {
        evidenceSaveService = saveServiceImpl.selectById(appService.getServiceConfigId());
    } else {
        result.put("status", -21);
        result.put("message", "应用服务不存在");
        return result;
    }
    if (evidenceSaveService == null) {
        result.put("status", -21);
        result.put("message", "应用服务不存在");
        return result;
    }
    if (appService.getIsAppServiceStatus() == 0) {
        result.put("status", -22);
        result.put("message", "服务已关闭");
        return result;
    }
    // 获取存证回执模版
    if (evidenceSaveService.getAppServiceName() != null) {
        AppService appServiceOut = CacheCustomer.APP_SERVICE_MAP_BY_ID().get(evidenceSaveService.getAppServiceName());
        if (appServiceOut == null) {
            appServiceOut = appServiceExt.selectById(evidenceSaveService.getAppServiceName());
            if (appServiceOut == null) {
                result.put("status", -22);
                result.put("message", "回执模版不存在");
                return result;
            }
        }
    }
    if (StringUtils.isNotEmpty(evidenceSn)) {
        EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, 1);
        if (basicInformation != null) {
            result.put("status", 0);
            result.put("message", "该证据不可补交");
            return result;
        }
    }
    RealNameAuthentication realNameAuthentication = null;
    RealNameAuthentication realNameAuthenticationTime = null;
    RealNameAuthentication realNameAuthenticationOss = null;
    try {
        // 获取原子服务地址  1.实名认证  2.密码服务  3.时间戳  4.OSS
        realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
        if (realNameAuthentication == null) {
            realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
        }
        if (realNameAuthentication == null) {
            result.put("status", -6);
            result.put("message", "缺少密码服务配置,请联系管理员");
            return result;
        }
        // 获取原子服务地址  1.实名认证  2.密码服务  3.时间戳  4.OSS
        realNameAuthenticationTime = CacheCustomer.getAUTH_CONFIG_MAP().get(3);
        if (realNameAuthenticationTime == null) {
            realNameAuthenticationTime = realNameAuthenticationSerivce.getRealNameAuthenticationByThree();
        }
        if (realNameAuthenticationTime == null) {
            result.put("status", -6);
            result.put("message", "缺少时间戳服务配置,请联系管理员");
            return result;
        }
        // 获取原子服务地址  1.实名认证  2.密码服务  3.时间戳  4.OSS
        realNameAuthenticationOss = CacheCustomer.getAUTH_CONFIG_MAP().get(4);
        if (realNameAuthenticationOss == null) {
            realNameAuthenticationOss = realNameAuthenticationSerivce.getRealNameAuthenticationByOss();
        }
        if (realNameAuthenticationOss == null) {
            result.put("status", -6);
            result.put("message", "缺少OSS配置,请联系管理员");
            return result;
        }
        // 本次证据包大小
        int fileSize = evidencePackage.getBytes("utf-8").length;
        // 存证计费校验接口
        Map<String, Object> mapCharging = storeChargingService.checkStoreCharging(StringUtils.isBlank(evidenceSn), applicationInfo, appService, evidenceSaveService.getBaseSpace(), getSize(fileSize));
        // log.debug("存证计费校验   mapCharging__ : " + mapCharging);
        if ((int) mapCharging.get("retCode") == 0) {
            result.put("status", -4);
            if (mapCharging.get("retMsg") != null)
                result.put("message", mapCharging.get("retMsg"));
            else
                result.put("message", "服务计费失败");
            return result;
        }
        // 证据包申请
        String hashvalue = HMACSHA1.getDigest(hashAlg, evidencePackage);
        // 1.验签之后返回
        List<String> certs = verifySign(result, applicationInfo, evidenceSaveService, hashvalue, signedBase64, realNameAuthentication);
        Date dateVp = (Date) result.get("dateVp");
        Date dateVc = (Date) result.get("dateVc");
        result.remove("dateVp");
        result.remove("dateVc");
        if (null != certs) {
            String genSn = null;
            if (StringUtils.isEmpty(evidenceSn)) {
                genSn = UniqueIDUtils.genAppServiceUID(applicationInfo, appService.getAppServiceName(), sqlSession, 3);
            }
            result = saveTask.saveBody(result, applicationInfo, appService, evidenceSaveService, date, evidenceSn, genSn, signedBase64, evidencePackage, hashAlg, hashvalue, dateVp, dateVc, certs, realNameAuthentication, realNameAuthenticationTime, realNameAuthenticationOss, mapCharging);
            if ((int) result.get("status") == 1) {
                result.put("message", "申请存证成功,请稍后通过查询存证接口查看存证结果!");
                if (StringUtils.isNotEmpty(evidenceSn))
                    result.put("evidenceSn", evidenceSn);
                else
                    result.put("evidenceSn", genSn);
            }
        } else {
            result.put("status", -8);
            result.put("message", "验证证书失败");
        }
        return result;
    } catch (Exception e) {
        e.printStackTrace();
        if (e instanceof IllegalStateException) {
            result.put("status", -100);
            result.put("message", "当前系统忙,请稍后再尝试!");
            return result;
        }
        StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 2];
        String info = stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
        LogUtil.evidencelog(sqlSession, null, "存证接口", "申请存证失败,失败原因:" + info);
        result = new HashMap<String, Object>();
        result.put("status", -5);
        result.put("message", "系统服务错误,请联系管理员");
        return result;
    } finally {
        if (realNameAuthentication != null) {
            realNameAuthentication = null;
        }
        if (realNameAuthenticationOss != null) {
            realNameAuthenticationOss = null;
        }
        if (realNameAuthenticationTime != null) {
            realNameAuthenticationTime = null;
        }
    }
}
Also used : AppService(com.itrus.portal.db.AppService) HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) EvidenceSaveService(com.itrus.portal.db.EvidenceSaveService) RealNameAuthentication(com.itrus.portal.db.RealNameAuthentication) Date(java.util.Date) IOException(java.io.IOException) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 24 with EvidenceBasicInformation

use of com.itrus.portal.db.EvidenceBasicInformation in project portal by ixinportal.

the class EvidenceSaveServiceApi method searchGenerated.

/**
 * 查询出证
 * @param signature
 * 			签名值
 * @param appId
 * 			应用标识
 * @param orderNumber
 * 			服务流水号
 * @param request
 * @return
 */
@RequestMapping(value = "/searchGenerated")
@ResponseBody
public Map<String, Object> searchGenerated(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = true) String appId, @RequestParam(value = "orderNumber", required = true) String orderNumber, HttpServletRequest request) {
    // TODO : 查询出证接口
    Map<String, Object> result = new HashMap<String, Object>();
    // 验证参数是否完整
    if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(orderNumber)) {
        result.put("status", 0);
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    // 得到应用信息 改成service
    Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
    ApplicationInfo applicationInfo = appInfoMap.get(appId);
    if (applicationInfo == null) {
        ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
        ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
        appInfoExampleCriteria.andAppIdEqualTo(appId);
        applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
    }
    if (applicationInfo == null) {
        result.put("status", -11);
        result.put("message", "应用标识不存在");
        return result;
    }
    if (applicationInfo.getIsAppStatus() == 0) {
        result.put("status", -12);
        result.put("message", "应用状态已关闭");
        return result;
    }
    // 核验ip限制
    if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
        result.put("status", -1);
        result.put("message", "没有此服务权限");
        log.debug("EvidenceSaveSeriveceTest_AccsessIp : " + request.getRemoteAddr());
        return result;
    }
    // 验证hmac有效性
    try {
        String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appId + orderNumber, applicationInfo.getSecretKey()), false);
        if (!signature.equals("HMAC-SHA1 " + macVal)) {
            result.put("status", -2);
            result.put("message", "服务密钥错误");
            return result;
        }
    } catch (Exception e) {
        result.put("status", -3);
        result.put("message", "Hmac验证错误");
        e.printStackTrace();
        return result;
    }
    EvidenceHisCertificateExample hisCertificateExample = new EvidenceHisCertificateExample();
    EvidenceHisCertificateExample.Criteria hec = hisCertificateExample.createCriteria();
    hec.andSerialnumberEqualTo(orderNumber);
    List<EvidenceHisCertificate> hisCertificates = sqlSession.selectList("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByExample", hisCertificateExample);
    if (hisCertificates.size() == 0 || hisCertificates.isEmpty()) {
        result.put("status", 0);
        result.put("message", "流水号信息有误");
        return result;
    }
    EvidenceHisCertificate hisCertificate = hisCertificates.get(0);
    if (StringUtils.isNotEmpty(hisCertificate.getHisCauseFailure())) {
        result.put("status", 0);
        result.put("message", hisCertificate.getHisCauseFailure());
        return result;
    }
    EvidenceHisRelationshipExample hisRelationshipExample = new EvidenceHisRelationshipExample();
    EvidenceHisRelationshipExample.Criteria rec = hisRelationshipExample.createCriteria();
    rec.andHisCertificateEqualTo(hisCertificate.getId());
    List<EvidenceHisRelationship> hisRelationships = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", hisCertificates);
    for (EvidenceHisRelationship hisRelationship : hisRelationships) {
        EvidenceBasicInformation basicInformation = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", hisRelationship.getBasicInformation());
        Map<String, Object> map = evidenceSaveService.verifyFactor(basicInformation.getEvidenceSn());
        if ((int) map.get("status") != 1) {
            result.put("status", map.get("status"));
            result.put("message", map.get("message"));
            return result;
        }
    }
    // 通过流水号得到证据附件信息
    EvidenceEnclosureExample enclosurExample = new EvidenceEnclosureExample();
    EvidenceEnclosureExample.Criteria ec = enclosurExample.createCriteria();
    ec.andSerialnumberEqualTo(orderNumber);
    ec.andPdfTypeEqualTo("4");
    List<EvidenceEnclosure> enclosurs = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosurExample);
    // 判断证据是否已出
    if ("0".equals(hisCertificate.getHisState()) && enclosurs != null) {
        EvidenceEnclosure enclosure = enclosurs.get(0);
        try {
            // 获取密码服务
            RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
            if (realNameAuthentication == null) {
                realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
            }
            if (realNameAuthentication == null) {
                result.put("status", -6);
                result.put("message", "缺少服务配置,请联系管理员");
                return result;
            }
            // 下载出证报告base64
            String str = decryptedAndDownload(sqlSession, enclosure.getBuid(), realNameAuthentication.getRealNameddress());
        } catch (Exception e) {
            result.put("status", -5);
            result.put("message", "服务器出错,请联系管理员");
            String oper = "查询出证接口-异常";
            String info = "服务流水号: " + orderNumber + ",错误原因:" + e.toString();
            LogUtil.evidencelog(sqlSession, null, oper, info);
        }
    } else {
        // 生成出证报告
        Map<String, Object> mapRet = null;
        // 判断是否为自动出证
        if (hisCertificate.getHisway().equals("1")) {
            // 生成出证报告
            try {
                mapRet = reportTemplate.certificationReport(hisCertificate.getSerialnumber());
            } catch (Exception e) {
                result.put("status", 0);
                result.put("message", "出证失败");
                return result;
            }
        } else {
            result.put("status", 0);
            result.put("message", "无法自动出证");
            return result;
        }
        // 判断出证报告是否生成成功
        if (mapRet != null && (int) mapRet.get("status") == 0) {
            result.put("status", 1);
            result.put("message", "出证成功");
            result.put("orderNumber", hisCertificate.getSerialnumber());
            result.put("pdfBase64", mapRet.get("pdfBase64"));
            hisCertificate.setHisState("0");
        } else {
            result.put("status", 0);
            result.put("message", "出证失败");
            hisCertificate.setHisCauseFailure(mapRet.get("message").toString());
            // 判断为自动出证失败后  转人工出证
            if (hisCertificate.getHisway().equals("1")) {
                hisCertificate.setHisway("3");
                result.put("message", "出证失败,已自动转人工出证");
            }
        }
        sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey", hisCertificate);
    }
    return result;
}
Also used : ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) EvidenceHisRelationship(com.itrus.portal.db.EvidenceHisRelationship) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) EvidenceHisCertificate(com.itrus.portal.db.EvidenceHisCertificate) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) RealNameAuthentication(com.itrus.portal.db.RealNameAuthentication) IOException(java.io.IOException) EvidenceHisRelationshipExample(com.itrus.portal.db.EvidenceHisRelationshipExample) EvidenceHisCertificateExample(com.itrus.portal.db.EvidenceHisCertificateExample) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 25 with EvidenceBasicInformation

use of com.itrus.portal.db.EvidenceBasicInformation in project portal by ixinportal.

the class EvidenceSaveServiceApi method saveCallBack.

@RequestMapping("/savecallback")
@ResponseBody
public Map<String, Object> saveCallBack(@RequestParam(value = "evidenceSn", required = false) String evidenceSn, HttpServletRequest request) {
    long startTime = System.currentTimeMillis();
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("code", "0");
    try {
        EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, null);
        ApplicationInfo applicationInfo = CacheCustomer.getAPP_INFO_MAP_BY_ID().get(basicInformation.getApplicationInfo());
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("status", 1);
        param.put("appId", applicationInfo.getAppId());
        param.put("evidenceSns", evidenceSn);
        param.put("message", "存证成功");
        String header = "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(applicationInfo.getAppId() + evidenceSn, applicationInfo.getSecretKey()), false);
        long callbackTime = System.currentTimeMillis();
        // http://124.205.224.179:9018/km/evidencetest/tttt
        String retStr = OkHttpClientManagerCallback.post(applicationInfo.getCallback(), header, param);
        log.error("callbackTime is [" + (System.currentTimeMillis() - callbackTime) + "]");
        // JSONObject ret_data = JSONObject.parseObject(retStr);
        // if(retStr == null || ret_data.getInteger("status") != 1) {
        // retMap.put("code", "0");
        // retMap.put("message", "回调失败。");
        // return retMap;
        // }
        sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        return retMap;
    }
    retMap.put("status", "1");
    retMap.put("message", "回调申请成功。");
    log.error("saveCallBackTime is [" + (System.currentTimeMillis() - startTime) + "]");
    return retMap;
}
Also used : HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) JSONObject(com.alibaba.fastjson.JSONObject) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

EvidenceBasicInformation (com.itrus.portal.db.EvidenceBasicInformation)37 HashMap (java.util.HashMap)30 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 ArrayList (java.util.ArrayList)20 EvidenceEnclosure (com.itrus.portal.db.EvidenceEnclosure)19 Date (java.util.Date)18 JSONObject (com.alibaba.fastjson.JSONObject)16 EvidenceEnclosureExample (com.itrus.portal.db.EvidenceEnclosureExample)16 List (java.util.List)15 AppService (com.itrus.portal.db.AppService)13 IOException (java.io.IOException)13 EvidenceBasicInformationExample (com.itrus.portal.db.EvidenceBasicInformationExample)12 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)11 EvidenceHisCertificate (com.itrus.portal.db.EvidenceHisCertificate)11 EvidenceHisRelationship (com.itrus.portal.db.EvidenceHisRelationship)11 Map (java.util.Map)11 EvidenceEventContent (com.itrus.portal.db.EvidenceEventContent)10 EvidenceMainInformation (com.itrus.portal.db.EvidenceMainInformation)10 EvidenceHisRelationshipExample (com.itrus.portal.db.EvidenceHisRelationshipExample)8 EvidenceSubjectIdentity (com.itrus.portal.db.EvidenceSubjectIdentity)8