Search in sources :

Example 21 with ApplicationInfoExample

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

the class QueryPoryService method QueryBill.

/**
 * 根据提供的信息获取订单
 * @param signature
 * 			hmac签名值,采用HmacSHA1算法
 * @param appId
 * 			应用标识
 * @param phoneNumber
 * 			手机号
 * @param name
 * 			企业名称
 * @return
 */
@PostMapping(value = "/querybill")
@ResponseBody
public Map<String, Object> QueryBill(@RequestHeader("Content-Signature") String signature, @RequestParam("appId") String appId, @RequestParam("phoneNumber") String phoneNumber, @RequestParam("name") String name) {
    // 配置参数
    Map<String, Object> params = new HashMap<String, Object>();
    // 返回参数
    Map<String, Object> result = new HashMap<String, Object>();
    // 验证参数是否完整
    if (StringUtils.isEmpty(signature) || (StringUtils.isEmpty(phoneNumber) && StringUtils.isEmpty(name))) {
        result.put("status", -1);
        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 (null == applicationInfo) {
        result.put("retCode", -3);
        result.put("retMsg", "没有此应用");
        return result;
    }
    // 验证hmac有效性
    try {
        String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appId + phoneNumber + name, 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;
    }
    // 根据条件返回数据
    try {
        if (StringUtils.isNotEmpty(name)) {
            params.put("name", name);
        }
        if (StringUtils.isNotEmpty(phoneNumber)) {
            params.put("phoneNumber", phoneNumber);
        }
        List<Map<String, Object>> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectBillDataByAPI", params);
        result.put("billDate", billList);
        result.put("status", "1");
        result.put("message", "查询数据成功");
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        result.put("status", -5);
        result.put("message", "系统异常,请联系管理员");
    }
    return result;
}
Also used : ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) HashMap(java.util.HashMap) Map(java.util.Map) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 22 with ApplicationInfoExample

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

the class StatisticsdepositaryController method list.

@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "servicePlatformName", required = false) String servicePlatformName, @RequestParam(value = "Statistics", required = false) Integer Statistics, @RequestParam(value = "year1", required = false) Integer year1, @RequestParam(value = "year2", required = false) Integer year2, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "serviceName", required = false) String serviceName, @RequestParam(value = "type", required = false) String type, @RequestParam(value = "serviceClientName", required = false) String serviceClientName, Model uiModel) throws Exception {
    Map param = new HashMap();
    Integer year3 = null;
    if (year1 != null) {
        year3 = year1;
    }
    List<Map<Integer, Integer>> list = new ArrayList<Map<Integer, Integer>>();
    java.util.Date nowdate = new java.util.Date();
    String[] monthList = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
    String[] seasonList = { "S1", "S2", "S3", "S4" };
    String month = null;
    String season = null;
    String year = null;
    Calendar calendar = Calendar.getInstance();
    Calendar calendar2 = Calendar.getInstance();
    if (null != Statistics && Statistics == 12) {
        while (year1 <= year2) {
            for (int j = 0; j <= 11; j++) {
                calendar.set(Calendar.YEAR, year1);
                calendar.set(Calendar.MONTH, j);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                Date dt1 = calendar.getTime();
                calendar2.set(Calendar.YEAR, year1);
                calendar2.set(Calendar.MONTH, j + 1);
                calendar2.set(Calendar.DAY_OF_MONTH, 1);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                calendar2.set(Calendar.MILLISECOND, 0);
                Date dt2 = calendar2.getTime();
                if (StringUtils.isNotEmpty(servicePlatformName) && !"0".equals(servicePlatformName)) {
                    param.put("servicePlatformName", servicePlatformName);
                }
                if (StringUtils.isNotEmpty(serviceName)) {
                    param.put("serviceName", "%" + serviceName + "%");
                }
                if (type != null && !"0".equals(type)) {
                    param.put("type", type);
                }
                if (serviceClientName != null && !"0".equals(serviceClientName)) {
                    param.put("serviceClientName", serviceClientName);
                }
                month = year1 + "-" + monthList[j];
                param.put("queryDate1", dt1);
                param.put("queryDate2", dt2);
                Integer count = basicInformationimpl.selectcount(param);
                int sum = 0;
                // System.out.println("count="+count);
                if (count != 0) {
                    sum = basicInformationimpl.selectsize(param);
                }
                // System.out.println("sum="+sum);
                Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                map.put(1, year1);
                map.put(2, count);
                map.put(3, sum);
                list.add(map);
            }
            year1++;
        }
    }
    if (null != Statistics && Statistics == 4) {
        while (year1 <= year2) {
            for (int j = 0; j <= 9; j = j + 3) {
                calendar.set(Calendar.YEAR, year1);
                calendar.set(Calendar.MONTH, j);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                calendar.set(Calendar.HOUR_OF_DAY, 0);
                calendar.set(Calendar.MINUTE, 0);
                calendar.set(Calendar.SECOND, 0);
                calendar.set(Calendar.MILLISECOND, 0);
                Date dt1 = calendar.getTime();
                calendar2.set(Calendar.YEAR, year1);
                calendar2.set(Calendar.MONTH, j + 3);
                calendar2.set(Calendar.DAY_OF_MONTH, 1);
                calendar2.set(Calendar.HOUR_OF_DAY, 0);
                calendar2.set(Calendar.MINUTE, 0);
                calendar2.set(Calendar.SECOND, 0);
                calendar2.set(Calendar.MILLISECOND, 0);
                Date dt2 = calendar2.getTime();
                if (StringUtils.isNotEmpty(servicePlatformName) && !"0".equals(servicePlatformName)) {
                    param.put("serviceRequestPlatform", servicePlatformName);
                }
                if (serviceName != null && !"0".equals(serviceName)) {
                    param.put("serviceName", "%" + serviceName + "%");
                }
                if (type != null && !"0".equals(type)) {
                    param.put("type", type);
                }
                if (serviceClientName != null && !"0".equals(serviceClientName)) {
                    param.put("serviceClientName", serviceClientName);
                }
                param.put("queryDate1", dt1);
                param.put("queryDate2", dt2);
                Integer count = basicInformationimpl.selectcount(param);
                int sum = 0;
                System.out.println("count=" + count);
                if (count != 0) {
                    sum = basicInformationimpl.selectsize(param);
                }
                Map<Integer, Integer> map = new HashMap<Integer, Integer>();
                map.put(1, year1);
                map.put(2, count);
                map.put(3, sum);
                list.add(map);
            }
            year1++;
        }
    }
    if (null != Statistics && Statistics == 1) {
        while (year1 <= year2) {
            calendar.set(Calendar.YEAR, year1);
            calendar.set(Calendar.MONTH, 0);
            calendar.set(Calendar.DAY_OF_MONTH, 1);
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            Date dt1 = calendar.getTime();
            calendar2.set(Calendar.YEAR, year1 + 1);
            calendar2.set(Calendar.MONTH, 0);
            calendar2.set(Calendar.DAY_OF_MONTH, 1);
            calendar2.set(Calendar.HOUR_OF_DAY, 0);
            calendar2.set(Calendar.MINUTE, 0);
            calendar2.set(Calendar.SECOND, 0);
            calendar2.set(Calendar.MILLISECOND, 0);
            Date dt2 = calendar2.getTime();
            if (StringUtils.isNotEmpty(servicePlatformName) && !"0".equals(servicePlatformName)) {
                param.put("serviceRequestPlatform", servicePlatformName);
            }
            if (StringUtils.isNotEmpty(serviceName) && !"0".equals(serviceName)) {
                param.put("serviceName", "%" + serviceName + "%");
            }
            if (type != null && !"0".equals(type)) {
                param.put("type", type);
            }
            if (serviceClientName != null && !"0".equals(serviceClientName)) {
                param.put("serviceClientName", serviceClientName);
            }
            year = year + "Y";
            param.put("queryDate1", dt1);
            param.put("queryDate2", dt2);
            Integer count = basicInformationimpl.selectcount(param);
            int sum = 0;
            System.out.println("count=" + count);
            if (count != 0) {
                sum = basicInformationimpl.selectsize(param);
            }
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
            map.put(1, year1);
            map.put(2, count);
            map.put(3, sum);
            list.add(map);
            year1++;
        }
    }
    List appservice = applicationInfoService.selectByExample(new ApplicationInfoExample());
    uiModel.addAttribute("appservice", appservice);
    List<EvidenceBasicInformation> basicinfo = basicInformationimpl.selectList();
    uiModel.addAttribute("basicinfo", basicinfo);
    if (null == servicePlatformName || "0".equals(servicePlatformName)) {
        servicePlatformName = "所有应用";
    }
    uiModel.addAttribute("list", list);
    // System.out.println(list);
    uiModel.addAttribute("year1", year3);
    uiModel.addAttribute("servicePlatformName", servicePlatformName);
    uiModel.addAttribute("year2", year2);
    uiModel.addAttribute("Statistics", Statistics);
    uiModel.addAttribute("serviceName", serviceName);
    uiModel.addAttribute("type", type);
    uiModel.addAttribute("serviceClientName", serviceClientName);
    return "sratisticsdepositary/list";
}
Also used : ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) Date(java.util.Date) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Date(java.util.Date) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with ApplicationInfoExample

use of com.itrus.portal.db.ApplicationInfoExample 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 24 with ApplicationInfoExample

use of com.itrus.portal.db.ApplicationInfoExample 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 ApplicationInfoExample

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

the class EvidenceSaveServiceApi method generateTask.

/**
 * 出证
 * @param signature
 * 			签名值
 * @param appId
 * 			应用标识
 * @param serviceCode
 * 			服务编码
 * @param evidenceSns
 * 			要出证的证据编号(多个用逗号隔开)
 * @param businessSn
 * 			事件发生平台业务单号
 * @param request
 * @return
 */
@RequestMapping(value = "/generate")
@ResponseBody
public Map<String, Object> generateTask(@RequestHeader("Content-Signature") String signature, @RequestParam(value = "appId", required = true) String appId, @RequestParam(value = "serviceCode", required = true) String serviceCode, @RequestParam(value = "evidenceSns", required = false) String evidenceSns, @RequestParam(value = "businessSn", required = false) String businessSn, @RequestParam(value = "name", required = true) String name, @RequestParam(value = "code", required = true) String code, HttpServletRequest request) {
    log.equals("【提交出证申请日志】appId=" + appId + ",serviceCode=" + serviceCode + ",evidenceSns=" + evidenceSns + ",businessSn=" + businessSn + ",name=" + name + ",code=" + code);
    // 申请时间
    Date date = new Date();
    // TODO : 出证接口
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("status", 1);
    // 验证参数是否完整
    if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(serviceCode) || StringUtils.isEmpty(code) || StringUtils.isEmpty(name) || (evidenceSns == null && StringUtils.isEmpty(businessSn))) {
        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 + serviceCode + evidenceSns + businessSn + name + code, 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;
    }
    // 获取对应应用信息
    EvidenceOutServiceConfig outServiceConfig = null;
    AppService appService = appServiceExt.getAppService(serviceCode);
    if (appService != null && "EvidenceOutServiceConfig".equals(appService.getServiceConfigName())) {
        outServiceConfig = configService.selectById(appService.getServiceConfigId());
    } else {
        result.put("status", -21);
        result.put("message", "应用服务不存在");
        return result;
    }
    if (outServiceConfig == null) {
        result.put("status", -21);
        result.put("message", "应用服务不存在");
        return result;
    }
    if (appService.getIsAppServiceStatus() == 0) {
        result.put("status", -22);
        result.put("message", "服务已关闭");
        return result;
    }
    if (outServiceConfig.getOutWay() == null) {
        result.put("status", 0);
        result.put("message", "请联系管理员配置出证方式");
        return result;
    }
    // 得到出证份数
    int count = 0;
    if (StringUtils.isNotEmpty(evidenceSns)) {
        count = evidenceSns.split(",").length;
    } else {
        List<EvidenceBasicInformation> basicInformations = basicInformationService.getInformationByBusinessSn(businessSn, 2);
        count = basicInformations.size();
    }
    // 核验计费
    boolean blCharing = takeChargingService.checkTakeCharing(applicationInfo, appService, count);
    if (!blCharing) {
        result.put("status", -4);
        result.put("message", "服务计费失败");
        return result;
    }
    // 生成流水号
    String orderNumber = UniqueIDUtils.genAppServiceUID(applicationInfo, appService.getAppServiceName(), sqlSession, 3);
    // 修改需要出证的证据为待出征状态
    if (StringUtils.isNotEmpty(evidenceSns)) {
        String[] evidenceSnArr = evidenceSns.split(",");
        for (String evidenceSn : evidenceSnArr) {
            EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, 2);
            if (basicInformation != null) {
                basicInformation.setStatus(1);
                sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
                sqlSession.flushStatements();
            }
        }
    } else {
        List<EvidenceBasicInformation> basicInformations = basicInformationService.getInformationByBusinessSn(businessSn, 2);
        if (basicInformations != null) {
            for (EvidenceBasicInformation basicInformation : basicInformations) {
                basicInformation.setStatus(1);
                sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
                sqlSession.flushStatements();
            }
        }
    }
    // 判断是否为自动出证
    if ((int) result.get("status") == 1 && outServiceConfig.getOutWay() == 1) {
        // queueTask.putObjectQueue(new EvidenceLog(orderNumber, outServiceConfig, applicationInfo, appService, evidenceSns, businessSn, date, code, count, true));
        result.put("status", 1);
        result.put("message", "申请自动出证成功,请稍后通过查询出证接口查看出证结果!");
        result.put("orderNumber", orderNumber);
    } else {
        queueTask.putObjectQueue(new EvidenceOutTask(orderNumber, outServiceConfig, applicationInfo, appService, evidenceSns, businessSn, date, code, count, false));
        result.put("status", 0);
        result.put("message", "已转入人工出证");
    }
    return result;
}
Also used : ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) AppService(com.itrus.portal.db.AppService) HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) EvidenceOutServiceConfig(com.itrus.portal.db.EvidenceOutServiceConfig) 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)

Aggregations

ApplicationInfoExample (com.itrus.portal.db.ApplicationInfoExample)31 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)25 HashMap (java.util.HashMap)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 JSONObject (com.alibaba.fastjson.JSONObject)10 Map (java.util.Map)8 PostMapping (org.springframework.web.bind.annotation.PostMapping)8 Calendar (java.util.Calendar)7 Bill (com.itrus.portal.db.Bill)6 EvidenceBasicInformation (com.itrus.portal.db.EvidenceBasicInformation)6 Date (java.util.Date)6 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)5 ArrayList (java.util.ArrayList)5 JSONException (org.json.JSONException)5 Enterprise (com.itrus.portal.db.Enterprise)4 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)4 IOException (java.io.IOException)4 List (java.util.List)4 Agent (com.itrus.portal.db.Agent)3