Search in sources :

Example 6 with EvidenceEnclosureExample

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

the class BasicInformationController method show.

/**
 * 查看详情
 *
 * @param id
 * @param uiModel
 * @return
 */
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    Date time = new Date();
    // 得到方法开始的时间
    log.error("---------------------------" + time);
    basid = id;
    int coutn = 0;
    int size = 0;
    int cousize = 0;
    EvidenceBasicInformation basicinfor = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", id);
    List<EvidenceMainInformation> mlist = new ArrayList<EvidenceMainInformation>();
    Map<Long, EvidenceCompaniesSubmit> companiesSubmit = new HashMap<Long, EvidenceCompaniesSubmit>();
    Map<Long, List<RealNameRecord>> realnameRecor = new HashMap<Long, List<RealNameRecord>>();
    Map<Long, List<PersonalName>> personalName = new HashMap<Long, List<PersonalName>>();
    Map<Long, EvidenceIndividual> denceid = new HashMap<Long, EvidenceIndividual>();
    Map<Long, EvidenceRealName> realName = new HashMap<Long, EvidenceRealName>();
    // 事件对象认证
    Map<Long, EvidenceTrustedIdentity> trustedidentit = new HashMap<Long, EvidenceTrustedIdentity>();
    // 事件时间认证
    Map<Long, EvidenceEventTime> meventime = new HashMap<Long, EvidenceEventTime>();
    // 事件行为认证
    Map<Long, EvidenceEventBehavior> eventbehacior = new HashMap<Long, EvidenceEventBehavior>();
    // 无主体 事件对象认证
    Map<Integer, EvidenceTrustedIdentity> maintrustedidentit = new HashMap<Integer, EvidenceTrustedIdentity>();
    // 无主体事件时间认证
    Map<Integer, EvidenceEventTime> mainmeventime = new HashMap<Integer, EvidenceEventTime>();
    // 无主体事件行为认证
    Map<Integer, EvidenceEventBehavior> maineventbehacior = new HashMap<Integer, EvidenceEventBehavior>();
    // 事件意愿认证
    Map<Long, EvidenceEventDesire> meventdesire = new HashMap<Long, EvidenceEventDesire>();
    // 事件网络地址
    Map<Long, EvidenceEventNetworkAddress> networkaddress = new HashMap<Long, EvidenceEventNetworkAddress>();
    // 得到主体身份信息
    EvidenceSubjectIdentityExample subjectExample = new EvidenceSubjectIdentityExample();
    EvidenceSubjectIdentityExample.Criteria identity = subjectExample.createCriteria();
    // subjectExample.isDistinct();
    identity.andBasicInformationEqualTo(basicinfor.getEvidenceSn());
    List<EvidenceSubjectIdentity> subjectIdentity = sqlSession.selectList("com.itrus.portal.db.EvidenceSubjectIdentityMapper.selectByExample", subjectExample);
    for (int i = 0; i < subjectIdentity.size(); i++) {
        // 得到主体信息
        EvidenceMainInformationExample infomationE = new EvidenceMainInformationExample();
        EvidenceMainInformationExample.Criteria tionE = infomationE.createCriteria();
        tionE.andIdentificationEqualTo(subjectIdentity.get(i).getMainInformation());
        // infomationE.isDistinct();
        if (subjectIdentity.get(i).getMainName() != null) {
            tionE.andSubjectNameEqualTo(subjectIdentity.get(i).getMainName());
        }
        List<EvidenceMainInformation> mainInfo = sqlSession.selectList("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", infomationE);
        if (mainInfo.size() != 0) {
            mlist.add(mainInfo.get(0));
        }
    }
    for (int i = 0; i < mlist.size() - 1; i++) {
        for (int j = mlist.size() - 1; j > i; j--) {
            if (mlist.get(j).getIdentification().equals(mlist.get(i).getIdentification()) && mlist.get(j).getSubjectName().equals(mlist.get(i).getSubjectName())) {
                mlist.remove(j);
            }
        }
    }
    log.error("主题数量**********" + mlist.size());
    // 得到主题的时间
    Date time1 = new Date();
    Long Ltime = time1.getTime() - time.getTime();
    log.error("得到主题身份的毫秒数,Ltime" + Ltime);
    // 得到身份可信标识
    EvidenceTrustedIdentityExample trusten = new EvidenceTrustedIdentityExample();
    EvidenceTrustedIdentityExample.Criteria identityex = trusten.createCriteria();
    identityex.andBasicInformationEqualTo(basicinfor.getEvidenceSn());
    identityex.andEventContentIsNull();
    Map<Long, EvidenceTrustedIdentity> trustedidentity = sqlSession.selectMap("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trusten, "mainInformation");
    // 得到主题的时间
    Date time2 = new Date();
    Long Ltime1 = time2.getTime() - time.getTime();
    log.error("得到身份可信标识的毫秒数,Ltime1=" + Ltime1);
    // 身份意愿map
    Map<Long, EvidenceDesireIdentify> desire = new HashMap<Long, EvidenceDesireIdentify>();
    // 证据基本信息map
    Map<Long, EvidenceBasicInformation> basi = new HashMap<Long, EvidenceBasicInformation>();
    EvidenceRealName erealname = new EvidenceRealName();
    // 循环主题信息
    for (EvidenceMainInformation m : mlist) {
        // 判断可信身份标识是否为空
        if (/*trustedidentity!=null && trustedidentity.size()!=0&&*/
        trustedidentity.get(m.getId()) != null && trustedidentity.get(m.getId()).getEvidenceSn() != null) {
            // 得到可信身份标识关联的身份证据编号
            String evidenceSn = trustedidentity.get(m.getId()).getEvidenceSn().toString();
            if (StringUtils.isNotEmpty(evidenceSn)) {
                EvidenceBasicInformationExample basicinforE = new EvidenceBasicInformationExample();
                EvidenceBasicInformationExample.Criteria critbasic = basicinforE.createCriteria();
                critbasic.andEvidenceSnEqualTo(evidenceSn);
                EvidenceBasicInformation basicinfor1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByExample", basicinforE);
                // 得到身份意愿信息
                EvidenceDesireIdentifyExample desireIdentify = new EvidenceDesireIdentifyExample();
                EvidenceDesireIdentifyExample.Criteria desireExample = desireIdentify.createCriteria();
                desireExample.andEvidenceSnEqualTo(basicinfor1.getEvidenceSn());
                EvidenceDesireIdentify desire1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceDesireIdentifyMapper.selectByExample", desireIdentify);
                desire.put(m.getId(), desire1);
                // 将身份认证信息放入map
                basi.put(m.getId(), basicinfor1);
                // 得到实名认证信息
                EvidenceRealNameExample realnameE = new EvidenceRealNameExample();
                EvidenceRealNameExample.Criteria realnameEx = realnameE.createCriteria();
                realnameEx.andMainInformationEqualTo(m.getSubjectName() + ";" + m.getIdentification());
                // realnameEx.andBasicInformationEqualTo(basicinfor1.getId());
                realnameEx.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
                erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", realnameE);
                realName.put(m.getId(), erealname);
            }
            if (erealname != null) {
                if ("2".equals(erealname.getEventVerifierType()) || "3".equals(erealname.getEventVerifierType())) {
                    if ("1".equals(erealname.getType())) {
                        EvidenceCompaniesSubmitExample evidenceCompanies = new EvidenceCompaniesSubmitExample();
                        EvidenceCompaniesSubmitExample.Criteria submit = evidenceCompanies.createCriteria();
                        submit.andIdCodeEqualTo(erealname.getCompaniesSubmit());
                        EvidenceCompaniesSubmit companiesSubmit1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByExample", evidenceCompanies);
                        companiesSubmit.put(m.getId(), companiesSubmit1);
                    } else {
                        // 天威
                        EvidenceIndividualExample evidenceIndividual = new EvidenceIndividualExample();
                        EvidenceIndividualExample.Criteria individual = evidenceIndividual.createCriteria();
                        individual.andIdCodeEqualTo(erealname.getIndividual());
                        EvidenceIndividual dic = sqlSession.selectOne("com.itrus.portal.db.EvidenceIndividualMapper.selectByExample", evidenceIndividual);
                        denceid.put(m.getId(), dic);
                    }
                } else if ("1".equals(erealname.getEventVerifierType())) {
                    // 天威
                    if ("1".equals(erealname.getType())) {
                        // 获取流水号
                        String serialnamber = erealname.getSerialnumber();
                        // 将多个流水号以逗号分隔成一个数组
                        String[] namber = serialnamber.split(",");
                        // 声明一个list存储流水号
                        List<String> listString = new ArrayList<String>();
                        for (int i = 0; i < namber.length; i++) {
                            // 将数组中的流水号放入list中
                            listString.add(namber[i]);
                        }
                        // 查询实名认证信息
                        RealNameRecordExample realname = new RealNameRecordExample();
                        RealNameRecordExample.Criteria recor = realname.createCriteria();
                        recor.andSerialnumberIn(listString);
                        realname.setOrderByClause("returntime");
                        listReal = sqlSession.selectList("com.itrus.portal.db.RealNameRecordMapper.selectByExample", realname);
                        realnameRecor.put(m.getId(), listReal);
                    } else {
                        String serialnamber = erealname.getSerialnumber();
                        String[] namber = serialnamber.split(",");
                        List<String> listString = new ArrayList<String>();
                        for (int i = 0; i < namber.length; i++) {
                            listString.add(namber[i]);
                        // listReal.add(realnameRecor1);
                        }
                        PersonalNameExample personal = new PersonalNameExample();
                        PersonalNameExample.Criteria personalname = personal.createCriteria();
                        personalname.andSerialnumberIn(listString);
                        personal.setOrderByClause("returntime");
                        listPersonal = sqlSession.selectList("com.itrus.portal.db.PersonalNameMapper.selectByExample", personal);
                        personalName.put(m.getId(), listPersonal);
                    }
                }
            }
        }
    }
    // 得到身份的时间
    Date time3 = new Date();
    Long Ltime2 = time3.getTime() - time.getTime();
    log.error("得到身份信息的毫秒数,Ltime2=" + Ltime2);
    // 事件内容
    /*EvidenceEventContentExample evencontent = new EvidenceEventContentExample();
		EvidenceEventContentExample.Criteria countent = evencontent.createCriteria();
		//countent.andBasicInformationEqualTo(id);
		countent.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
		EvidenceEventContent mevencontent = sqlSession
				.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selectByExample", evencontent);*/
    EvidenceEventContent mevencontent = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selecttId", basicinfor.getEvidenceSn());
    // 得到事件内容的时间
    Date time4 = new Date();
    Long Ltime3 = time4.getTime() - time.getTime();
    log.error("得到事件内容的毫秒数,Ltime3=" + Ltime3);
    if (mevencontent != null && mevencontent.getIdCode() != null) {
        // 事件对象认证
        EvidenceTrustedIdentityExample trustenid = new EvidenceTrustedIdentityExample();
        EvidenceTrustedIdentityExample.Criteria identitye = trustenid.createCriteria();
        identitye.andEventContentEqualTo(mevencontent.getIdCode());
        trustedidentit = sqlSession.selectMap("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustenid, "mainInformation");
        // 事件时间认证
        EvidenceEventTimeExample eventime = new EvidenceEventTimeExample();
        EvidenceEventTimeExample.Criteria eventimeEx = eventime.createCriteria();
        eventimeEx.andEventContentEqualTo(mevencontent.getIdCode());
        meventime = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventTimeMapper.selectByExample", eventime, "mainInformation");
        // 事件行为认证
        EvidenceEventBehaviorExample eventbehaciorEx = new EvidenceEventBehaviorExample();
        EvidenceEventBehaviorExample.Criteria eventbe = eventbehaciorEx.createCriteria();
        eventbe.andEventContentEqualTo(mevencontent.getIdCode());
        eventbehacior = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventBehaviorMapper.selectByExample", eventbehaciorEx, "mainInformation");
        // 事件意愿认证
        EvidenceEventDesireExample desireEx = new EvidenceEventDesireExample();
        EvidenceEventDesireExample.Criteria eventdesire = desireEx.createCriteria();
        eventdesire.andEventContenteEqualTo(mevencontent.getIdCode());
        meventdesire = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventDesireMapper.selectByExample", desireEx, "mainInformation");
        // 事件网络地址
        EvidenceEventNetworkAddressExample network = new EvidenceEventNetworkAddressExample();
        EvidenceEventNetworkAddressExample.Criteria address = network.createCriteria();
        address.andEventContentEqualTo(mevencontent.getIdCode());
        networkaddress = sqlSession.selectMap("com.itrus.portal.db.EvidenceEventNetworkAddressMapper.selectByExample", network, "mainInformation");
        // 得到证据附件表,用于获取信息
        EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByPrimaryKey", mevencontent.getEvidenceEnclosure());
        uiModel.addAttribute("enclosure", envlosure);
    }
    // 得到事件的时间
    Date time5 = new Date();
    Long Ltime4 = time5.getTime() - time.getTime();
    log.error("得到事件详情的毫秒数,Ltime4=" + Ltime4);
    // 得到证据附件信息,用于查询服务委托人等信息
    EvidenceEnclosureExample enclou = new EvidenceEnclosureExample();
    EvidenceEnclosureExample.Criteria sure = enclou.createCriteria();
    sure.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
    ;
    sure.andPdfTypeEqualTo("1");
    List<EvidenceEnclosure> enclosure = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclou);
    // 得到事件的时间
    Date qtime = new Date();
    Long qLtime = qtime.getTime() - time5.getTime();
    log.error("***得到证据附件信息1的毫秒数,qLtime=" + qLtime);
    EvidenceEnclosureExample enclouE = new EvidenceEnclosureExample();
    EvidenceEnclosureExample.Criteria sureEX = enclouE.createCriteria();
    sureEX.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
    ;
    sureEX.andPdfTypeEqualTo("3");
    EvidenceEnclosure enclosurepdf = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclouE);
    // 得到事件的时间
    Date wtime = new Date();
    Long wLtime = wtime.getTime() - qtime.getTime();
    log.error("---得到证据附件信息2的毫秒数,wLtime=" + wLtime);
    // 得到无主题信息的数量
    int evencount = 0;
    if (trustedidentit.size() > 0) {
        evencount = trustedidentit.size();
    } else if (meventime.size() > 0) {
        evencount = meventime.size();
    } else if (maineventbehacior.size() > 0) {
        evencount = maineventbehacior.size();
    }
    Map<Integer, Integer> mapcoune = new HashMap<Integer, Integer>();
    // 用于得到无主题信息和数量
    for (int g = 0; g < evencount; g++) {
        int intsize = 0;
        // 得到无主题信息的key
        long z = g - evencount;
        String s = String.valueOf(z);
        // 将long类型转换为int类型,作为map的key进行重组
        int f = Integer.parseInt(s);
        if (trustedidentit.get(z) != null) {
            // System.out.println(trustedidentit.get(z).getMainInformation());
            // if(trustedidentit.get(z).getMainInformation()<0){
            maintrustedidentit.put(f, trustedidentit.get(z));
            cousize++;
            intsize++;
        // }
        }
        if (meventime.get(z) != null) {
            // if(meventime.get(z).getMainInformation()<0){
            mainmeventime.put(f, meventime.get(z));
            cousize++;
            intsize++;
        // }
        }
        if (eventbehacior.get(z) != null) {
            // if(eventbehacior.get(z).getMainInformation()<0){
            maineventbehacior.put(f, eventbehacior.get(z));
            cousize++;
            intsize++;
        // }
        }
        mapcoune.put(f, intsize);
    }
    uiModel.addAttribute("mapcoune", mapcoune);
    uiModel.addAttribute("enclosurepdf", enclosurepdf);
    uiModel.addAttribute("maintrustedidentit", maintrustedidentit);
    uiModel.addAttribute("mainmeventime", mainmeventime);
    uiModel.addAttribute("maineventbehacior", maineventbehacior);
    // 得到事件的时间
    Date time6 = new Date();
    Long Ltime5 = time6.getTime() - time.getTime();
    log.error("得到无主题信息的毫秒数,Ltime5=" + Ltime5);
    // 服务委托人签名信息
    Map<Long, EvidenceClientSignature> cilentsignat = new HashMap<Long, EvidenceClientSignature>();
    // 天威签名信息
    Map<Long, EvidenceClientSignature> cilentsignature = new HashMap<Long, EvidenceClientSignature>();
    // 服务委托人时间戳信息
    Map<Long, EvidenceClientTimeStamp> clientTimestamp = new HashMap<Long, EvidenceClientTimeStamp>();
    // 天威时间戳信息
    Map<Long, EvidenceClientTimeStamp> tclientTimestamp = new HashMap<Long, EvidenceClientTimeStamp>();
    // 服务委托人证书信息
    Map<Long, List<EvidenceCert>> listcert = new HashMap<Long, List<EvidenceCert>>();
    // 服务委托人核验信息
    Map<Long, EvidenceCheck> check = new HashMap<Long, EvidenceCheck>();
    // 天威核验信息
    Map<Long, EvidenceCheck> tcheck = new HashMap<Long, EvidenceCheck>();
    int ensize = 0;
    Map<Long, Integer> mint = new HashMap<Long, Integer>();
    // 循环附件信息取得服务委托人和天威签名时间戳信息
    for (EvidenceEnclosure en : enclosure) {
        Date time11 = new Date();
        int encount = 0;
        // 服务委托人签名信息
        /*EvidenceClientSignatureExample cilent = new EvidenceClientSignatureExample();
			EvidenceClientSignatureExample.Criteria signat = cilent.createCriteria();
			signat.andEvidenceSnEqualTo(en.getEvidenceSn());*/
        // signat.andNameEqualTo("0");
        List<EvidenceClientSignature> listclient = sqlSession.selectList("com.itrus.portal.db.EvidenceClientSignatureMapper.selectcertId", en.getEvidenceSn());
        EvidenceClientSignature clien1 = new EvidenceClientSignature();
        EvidenceClientSignature clien2 = new EvidenceClientSignature();
        for (int i = 0; i < listclient.size(); i++) {
            if ("0".equals(listclient.get(i).getName())) {
                clien1 = listclient.get(i);
            }
            if ("1".equals(listclient.get(i).getName())) {
                clien2 = listclient.get(i);
            }
        }
        cilentsignat.put(en.getId(), clien1);
        if (clien1.getId() != null) {
            ensize++;
            encount++;
            // 服务委托人证书信息
            /*EvidenceCertExample certEx = new EvidenceCertExample();
				EvidenceCertExample.Criteria evidenceCert = certEx.createCriteria();
				evidenceCert.andClientSignatureEqualTo(listclient.getId());*/
            List<EvidenceCert> listCert = sqlSession.selectList("com.itrus.portal.db.EvidenceCertMapper.selectByPrimaryKey", clien1.getCertId());
            listcert.put(en.getId(), listCert);
            // 服务委托人核验信息
            EvidenceCheckExample checkEx = new EvidenceCheckExample();
            EvidenceCheckExample.Criteria evidenceCheck = checkEx.createCriteria();
            evidenceCheck.andClientSignatureEqualTo(clien1.getId());
            EvidenceCheck listCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkEx);
            check.put(en.getId(), listCheck);
        }
        Date time12 = new Date();
        Long gettime = time12.getTime() - time11.getTime();
        log.error("-----------gettime0--------------" + gettime);
        // 天威签名信息
        /*EvidenceClientSignatureExample cilentsign = new EvidenceClientSignatureExample();
			EvidenceClientSignatureExample.Criteria signature = cilentsign.createCriteria();
			signature.andEvidenceSnEqualTo(en.getEvidenceSn());
			signature.andNameEqualTo("1");
			EvidenceClientSignature clientlist = sqlSession
					.selectOne("com.itrus.portal.db.EvidenceClientSignatureMapper.selectByExample", cilentsign);*/
        cilentsignature.put(en.getId(), clien2);
        if (clien2.getId() != null) {
            ensize++;
            encount++;
            // 服务委托人核验信息
            EvidenceCheckExample checkEx = new EvidenceCheckExample();
            EvidenceCheckExample.Criteria evidenceCheck = checkEx.createCriteria();
            evidenceCheck.andClientSignatureEqualTo(clien2.getId());
            EvidenceCheck listCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkEx);
            tcheck.put(en.getId(), listCheck);
        }
        Date time13 = new Date();
        Long gettime1 = time13.getTime() - time12.getTime();
        log.error("-----------gettime1--------------" + gettime1);
        // 服务委托人时间戳信息
        /*EvidenceClientTimeStampExample clientTime = new EvidenceClientTimeStampExample();
			EvidenceClientTimeStampExample.Criteria stamp = clientTime.createCriteria();
			stamp.andEvidenceSnEqualTo(en.getEvidenceSn());*/
        // stamp.andNameEqualTo("0");
        log.error("证据编号=======" + en.getEvidenceSn());
        List<EvidenceClientTimeStamp> listtime = sqlSession.selectList("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectTimeStamp", en.getEvidenceSn());
        EvidenceClientTimeStamp timestamp1 = new EvidenceClientTimeStamp();
        EvidenceClientTimeStamp timestamp2 = new EvidenceClientTimeStamp();
        log.error("时间戳listtime==--**" + listtime);
        for (int j = 0; j < listtime.size(); j++) {
            if ("0".equals(listtime.get(j).getName())) {
                timestamp1 = listtime.get(j);
                log.error("服务委托人时间-----------" + timestamp1);
            }
            /*else if("1".equals(listtime.get(j).getName())){
					timestamp2 = listtime.get(j);
				}*/
            log.error("服务委托人时间***********" + listtime.get(j).getName());
            if ("1".equals(listtime.get(j).getName())) {
                timestamp2 = listtime.get(j);
                log.error("服务委托人时间-----------" + timestamp2);
            }
        /*else if("0".equals(listtime.get(j).getName())){
					timestamp1 = listtime.get(j);
				}*/
        }
        clientTimestamp.put(en.getId(), timestamp1);
        if (timestamp1 != null) {
            ensize++;
            encount++;
        }
        Date time14 = new Date();
        Long gettime2 = time14.getTime() - time13.getTime();
        log.error("-----------gettime2--------------" + gettime2);
        // 天威时间戳信息
        /*EvidenceClientTimeStampExample tclientTime = new EvidenceClientTimeStampExample();
			EvidenceClientTimeStampExample.Criteria tstamp = tclientTime.createCriteria();
			tstamp.andEvidenceSnEqualTo(en.getEvidenceSn());
			tstamp.andNameEqualTo("1");
			EvidenceClientTimeStamp timelist = sqlSession
					.selectOne("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectByExample", tclientTime);*/
        tclientTimestamp.put(en.getId(), timestamp2);
        if (timestamp2 != null) {
            ensize++;
            encount++;
        }
        mint.put(en.getId(), encount);
        Date time15 = new Date();
        Long gettime3 = time15.getTime() - time14.getTime();
        log.error("-----------gettime3--------------" + gettime3);
    }
    // 得到事件的时间
    Date time7 = new Date();
    Long Ltime6 = time7.getTime() - time.getTime();
    log.error("得到证据申请信息和申请时间戳的毫秒数,Ltime6=" + Ltime6);
    Long Ltime10 = time7.getTime() - time6.getTime();
    log.error("+++++++++++*********---------,Ltime10++++++++++++++=" + Ltime10);
    uiModel.addAttribute("ensize", ensize);
    uiModel.addAttribute("mint", mint);
    List<EvidenceHisCertificate> hisCertificete = new ArrayList<EvidenceHisCertificate>();
    EvidenceHisRelationshipExample relation = new EvidenceHisRelationshipExample();
    EvidenceHisRelationshipExample.Criteria hisreation = relation.createCriteria();
    hisreation.andBasicInformationEqualTo(id);
    List<EvidenceHisRelationship> hisRelation = sqlSession.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", relation);
    for (int g = 0; g < hisRelation.size(); g++) {
        // 得到证据基本信息
        /*EvidenceBasicInformation basic = sqlSession.selectOne(
					"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey",
					hisRelation.get(g).getBasicInformation());*/
        EvidenceHisCertificate eh = sqlSession.selectOne("com.itrus.portal.db.EvidenceHisCertificateMapper.selectByPrimaryKey", hisRelation.get(g).getHisCertificate());
        hisCertificete.add(eh);
    }
    // 出证信息
    // List<Map<String, Object>> hisCertificete = hiscertificate.selectHisCertificateEnt();
    Map<Long, EvidenceOutTemplate> mout = new HashMap<Long, EvidenceOutTemplate>();
    Map<Long, EvidenceEnclosure> closure = new HashMap<Long, EvidenceEnclosure>();
    Map<Long, List<EvidenceBasicInformation>> mbasilist = new HashMap<Long, List<EvidenceBasicInformation>>();
    // ArrayList<EvidenceBasicInformation>();
    for (int j = 0; j < hisCertificete.size(); j++) {
        List<EvidenceBasicInformation> blist = new ArrayList<EvidenceBasicInformation>();
        Long hidId = hisCertificete.get(j).getId();
        String serialnumber = hisCertificete.get(j).getSerialnumber();
        if (hisCertificete.get(j).getHisAppService() != null && hisCertificete.get(j).getHisAppService() > 0) {
            Long appServiceId = hisCertificete.get(j).getHisAppService();
            // 得到服务编码
            AppService happservice = appService.selectById(appServiceId);
            // 得到出证服务配置
            EvidenceOutServiceConfigExample outsaveService = new EvidenceOutServiceConfigExample();
            EvidenceOutServiceConfigExample.Criteria saveServiceEx = outsaveService.createCriteria();
            saveServiceEx.andAppServiceEqualTo(happservice.getId());
            EvidenceOutServiceConfig outService = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutServiceConfigMapper.selectByExample", outsaveService);
            // 得到出证模板信息
            EvidenceOutTemplate outtemp = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByPrimaryKey", outService.getSaveRetTemplate());
            mout.put(hidId, outtemp);
            // 获取证据附件表
            EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
            EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
            envlosureEx.andSerialnumberEqualTo(serialnumber);
            envlosureEx.andPdfTypeEqualTo("4");
            EvidenceEnclosure envlosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
            closure.put(hidId, envlosure);
        }
        uiModel.addAttribute("closure", closure);
    /*long hid = Long.parseLong(hisCertificete.get(j).get("id").toString());
			EvidenceHisRelationshipExample relation = new EvidenceHisRelationshipExample();
			EvidenceHisRelationshipExample.Criteria hisreation = relation.createCriteria();
			hisreation.andHisCertificateEqualTo(hid);
			List<EvidenceHisRelationship> hisRelation = sqlSession
					.selectList("com.itrus.portal.db.EvidenceHisRelationshipMapper.selectByExample", relation);
			for (int g = 0; g < hisRelation.size(); g++) {
				// 得到证据基本信息
				EvidenceBasicInformation basic = sqlSession.selectOne(
						"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey",
						hisRelation.get(g).getBasicInformation());
				blist.add(basic);
			}
			mbasilist.put(hidId, blist);*/
    }
    uiModel.addAttribute("basi", basi);
    uiModel.addAttribute("check", check);
    uiModel.addAttribute("listcert", listcert);
    uiModel.addAttribute("realName", realName);
    uiModel.addAttribute("mbasilist", mbasilist);
    uiModel.addAttribute("mout", mout);
    uiModel.addAttribute("envlosure", enclosure);
    uiModel.addAttribute("hisCertificete", hisCertificete);
    uiModel.addAttribute("basicinfor", basicinfor);
    uiModel.addAttribute("tclientTimestamp", tclientTimestamp);
    uiModel.addAttribute("clientTimestamp", clientTimestamp);
    uiModel.addAttribute("cilentsignature", cilentsignature);
    uiModel.addAttribute("cilentsignat", cilentsignat);
    uiModel.addAttribute("networkaddress", networkaddress);
    uiModel.addAttribute("meventdesire", meventdesire);
    uiModel.addAttribute("eventbehacior", eventbehacior);
    uiModel.addAttribute("meventime", meventime);
    uiModel.addAttribute("trustedidentit", trustedidentit);
    uiModel.addAttribute("mevencontent", mevencontent);
    uiModel.addAttribute("trustedidentity", trustedidentity);
    uiModel.addAttribute("companiesSubmit", companiesSubmit);
    uiModel.addAttribute("realnameRecor", realnameRecor);
    uiModel.addAttribute("denceid", denceid);
    uiModel.addAttribute("personalName", personalName);
    uiModel.addAttribute("mainInfo", mlist);
    uiModel.addAttribute("milist", mlist);
    Map<Long, Integer> msize = new HashMap<Long, Integer>();
    // 得到认证数量
    for (EvidenceMainInformation m : mlist) {
        int showsize = 0;
        // 身份认证
        if (companiesSubmit.get(m.getId()) != null) {
            coutn++;
        }
        if (realnameRecor.get(m.getId()) != null) {
            coutn++;
        }
        if (personalName.get(m.getId()) != null) {
            coutn++;
        }
        if (desire.get(m.getId()) != null) {
            coutn++;
        }
        if (trustedidentity.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
            coutn++;
        }
        if (denceid.get(m.getId()) != null) {
            coutn++;
        }
        // 事件认证
        if (trustedidentit.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
            size++;
            showsize++;
        }
        if (meventime.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
            size++;
            showsize++;
        }
        if (eventbehacior.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
            size++;
            showsize++;
        }
        if (meventdesire.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
            size++;
            showsize++;
        }
        if (networkaddress.get(m.getSubjectName() + ";" + m.getIdentification()) != null) {
            size++;
            showsize++;
        }
        msize.put(m.getId(), showsize);
    }
    uiModel.addAttribute("cousize", cousize);
    uiModel.addAttribute("rowsize", size + 1 + cousize);
    uiModel.addAttribute("showsize", msize);
    uiModel.addAttribute("rowcoutn", coutn);
    uiModel.addAttribute("desire", desire);
    // 得到事件的时间
    Date time8 = new Date();
    // 方法结束时间
    log.error("******************time8=" + time8);
    Long Ltime7 = time8.getTime() - time.getTime();
    log.error("方法结束的毫秒数,Ltime7=" + Ltime7);
    return "basicinformation/show";
}
Also used : EvidenceSubjectIdentityExample(com.itrus.portal.db.EvidenceSubjectIdentityExample) PersonalNameExample(com.itrus.portal.db.PersonalNameExample) ArrayList(java.util.ArrayList) EvidenceRealName(com.itrus.portal.db.EvidenceRealName) EvidenceCompaniesSubmitExample(com.itrus.portal.db.EvidenceCompaniesSubmitExample) EvidenceEventNetworkAddressExample(com.itrus.portal.db.EvidenceEventNetworkAddressExample) EvidenceDesireIdentify(com.itrus.portal.db.EvidenceDesireIdentify) EvidenceEventBehaviorExample(com.itrus.portal.db.EvidenceEventBehaviorExample) EvidenceOutServiceConfigExample(com.itrus.portal.db.EvidenceOutServiceConfigExample) EvidenceSubjectIdentity(com.itrus.portal.db.EvidenceSubjectIdentity) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) RealNameRecord(com.itrus.portal.db.RealNameRecord) EvidenceEventNetworkAddress(com.itrus.portal.db.EvidenceEventNetworkAddress) EvidenceIndividualExample(com.itrus.portal.db.EvidenceIndividualExample) EvidenceRealNameExample(com.itrus.portal.db.EvidenceRealNameExample) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) EvidenceHisCertificate(com.itrus.portal.db.EvidenceHisCertificate) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) EvidenceOutServiceConfig(com.itrus.portal.db.EvidenceOutServiceConfig) PersonalName(com.itrus.portal.db.PersonalName) EvidenceOutTemplate(com.itrus.portal.db.EvidenceOutTemplate) EvidenceCompaniesSubmit(com.itrus.portal.db.EvidenceCompaniesSubmit) EvidenceClientSignature(com.itrus.portal.db.EvidenceClientSignature) EvidenceCheck(com.itrus.portal.db.EvidenceCheck) EvidenceEventBehavior(com.itrus.portal.db.EvidenceEventBehavior) EvidenceIndividual(com.itrus.portal.db.EvidenceIndividual) HashMap(java.util.HashMap) EvidenceClientTimeStamp(com.itrus.portal.db.EvidenceClientTimeStamp) ArrayList(java.util.ArrayList) List(java.util.List) EvidenceEventDesire(com.itrus.portal.db.EvidenceEventDesire) EvidenceHisRelationship(com.itrus.portal.db.EvidenceHisRelationship) EvidenceCheckExample(com.itrus.portal.db.EvidenceCheckExample) EvidenceCert(com.itrus.portal.db.EvidenceCert) EvidenceEventTime(com.itrus.portal.db.EvidenceEventTime) EvidenceMainInformation(com.itrus.portal.db.EvidenceMainInformation) EvidenceDesireIdentifyExample(com.itrus.portal.db.EvidenceDesireIdentifyExample) EvidenceEventDesireExample(com.itrus.portal.db.EvidenceEventDesireExample) EvidenceEventTimeExample(com.itrus.portal.db.EvidenceEventTimeExample) EvidenceEventContent(com.itrus.portal.db.EvidenceEventContent) AppService(com.itrus.portal.db.AppService) Date(java.util.Date) EvidenceHisRelationshipExample(com.itrus.portal.db.EvidenceHisRelationshipExample) EvidenceBasicInformationExample(com.itrus.portal.db.EvidenceBasicInformationExample) EvidenceTrustedIdentity(com.itrus.portal.db.EvidenceTrustedIdentity) EvidenceMainInformationExample(com.itrus.portal.db.EvidenceMainInformationExample) RealNameRecordExample(com.itrus.portal.db.RealNameRecordExample) EvidenceTrustedIdentityExample(com.itrus.portal.db.EvidenceTrustedIdentityExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with EvidenceEnclosureExample

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

the class BasicInformationController method logImg.

/**
 * 得到合同图片
 *
 * @param id
 * @param response
 * @return
 */
@RequestMapping(value = "/img/{id}/{count}")
public String logImg(@PathVariable("id") Long id, @PathVariable("count") int count, HttpServletResponse response) {
    String img = null;
    OutputStream os = null;
    FileInputStream fis = null;
    File file = null;
    // 得到证据内容信息
    EvidenceEventContent mevencontent = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selectByPrimaryKey", id);
    /*EvidenceBasicInformation basic = sqlSession.selectOne(
				"com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey",
				mevencontent.getBasicInformation());*/
    // 得到证据附件信息
    EvidenceEnclosureExample envlosureE = new EvidenceEnclosureExample();
    EvidenceEnclosureExample.Criteria envlosureEx = envlosureE.createCriteria();
    envlosureEx.andEvidenceSnEqualTo(mevencontent.getEvidenceSn());
    envlosureEx.andPdfTypeEqualTo("1");
    EvidenceEnclosure enclosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", envlosureE);
    try {
        // 生成图片
        if (enclosure != null) {
            if ("1".equals(enclosure.getPdfType())) {
                // 得到图片
                response.setHeader("Pragma", "no-cache");
                response.setHeader("Cache-Control", "no-cache");
                response.setDateHeader("Expires", 0);
                int size = count - 1;
                img = enclosure.getEvidenceSn() + ".pdf.1.0." + size + ".png";
                file = new File(systemConfigService.getpdfurl() + File.separator + enclosure.getBucketName());
                // filePathUtils
                // .getBillFile(systemConfigService.getpdfurl() + File.separator + enclosure.getBucketName());
                log.error("图片路径file===" + file);
                log.error("图片名称img===" + img + "********size=" + size);
            }
        }
        if (img == null) {
            return "status403";
        }
        if (!file.exists()) {
            file.mkdir();
        }
        File imgFile = new File(file, img);
        fis = new FileInputStream(imgFile);
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) EvidenceEventContent(com.itrus.portal.db.EvidenceEventContent) JSONException(org.json.JSONException) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with EvidenceEnclosureExample

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

the class EvidenceCallbackTask method init.

public void init() {
    try {
        EvidenceCallbackExample callbackExample = new EvidenceCallbackExample();
        EvidenceCallbackExample.Criteria criteria = callbackExample.createCriteria();
        criteria.andCounntLessThan(3);
        List<EvidenceCallback> callbacks = callbackService.selectAll(callbackExample);
        if (callbacks == null || callbacks.isEmpty()) {
            log.error("暂无需系统存证回调");
            return;
        }
        String url = null;
        String app_id = null;
        String secret_key = null;
        // 需要回执报告
        Map<Long, String> dataRet = new HashMap<Long, String>();
        Map<Long, List<String>> data = new HashMap<Long, List<String>>();
        Map<String, EvidenceCallback> cacheCallBackBySnMap = new HashMap<>();
        for (int i = 0; i < callbacks.size() && i < 1000; i++) {
            EvidenceCallback callback = callbacks.get(i);
            cacheCallBackBySnMap.put(callback.getEvidenceSn(), callback);
            if (callback.getAppServiceId() == null) {
                if (data.containsKey(callback.getAppId())) {
                    data.get(callback.getAppId()).add(callback.getEvidenceSn());
                } else {
                    List<String> sns = new ArrayList<String>();
                    sns.add(callback.getEvidenceSn());
                    data.put(callback.getAppId(), sns);
                }
            } else {
                dataRet.put(callback.getAppId(), callback.getEvidenceSn());
            }
        }
        // <----------------------------    处理data   start   ------------------------------>
        for (Map.Entry<Long, List<String>> entry : data.entrySet()) {
            ApplicationInfo applicationInfo = CacheCustomer.getAPP_INFO_MAP_BY_ID().get(entry.getKey());
            if (applicationInfo == null) {
                applicationInfo = infoService.selectById(entry.getKey());
            }
            if (applicationInfo.getAppId() != app_id || url == null || app_id == null || secret_key == null) {
                if (StringUtils.isEmpty(applicationInfo.getCallback()) || StringUtils.isEmpty(applicationInfo.getAppId()) || StringUtils.isEmpty(applicationInfo.getSecretKey())) {
                    log.error("回调失败:缺少配置。");
                    return;
                }
                if (url == null) {
                    url = applicationInfo.getCallback().trim();
                }
                if (app_id == null) {
                    app_id = applicationInfo.getAppId();
                }
                if (secret_key == null) {
                    secret_key = applicationInfo.getSecretKey();
                }
                log.error("EvidenceQueryQueue : URL=" + url + ",APP_ID=" + app_id + ",SECRET_KEY=" + secret_key);
                if (StringUtils.isEmpty(url) || StringUtils.isEmpty(app_id) || StringUtils.isEmpty(secret_key)) {
                    log.error("回调失败:缺少配置。");
                    return;
                }
            }
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("status", 1);
            param.put("message", "存证成功");
            param.put("appId", app_id);
            param.put("evidenceSns", JSONObject.toJSONString(entry.getValue()));
            String header = "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(app_id + entry.getValue(), secret_key), false);
            String retStr = OkHttpClientManagerCallback.post(url, header, param);
            JSONObject ret_data = JSONObject.parseObject(retStr);
            if (retStr == null || ret_data.getInteger("status") != 1) {
                log.error("EvidenceCallbackTask failure count [" + entry.getValue().size() + "]");
                for (String sn : entry.getValue()) {
                    EvidenceCallback callback = null;
                    if (cacheCallBackBySnMap.get(sn) == null) {
                        EvidenceCallbackExample callbackExample0 = new EvidenceCallbackExample();
                        EvidenceCallbackExample.Criteria criteria0 = callbackExample.createCriteria();
                        criteria0.andEvidenceSnEqualTo(sn);
                        callback = callbackService.selectAll(callbackExample0).get(0);
                    } else {
                        callback = cacheCallBackBySnMap.get(sn);
                    }
                    int counnt = callback.getCounnt() + 1;
                    if (counnt == 3) {
                        sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByPrimaryKey", callback.getId());
                    } else {
                        callback.setCounnt(counnt);
                        sqlSession.update("com.itrus.portal.db.EvidenceCallbackMapper.updateByPrimaryKeySelective", callback);
                    }
                }
            } else {
                log.error("EvidenceCallbackTask success count [" + entry.getValue().size() + "]");
                sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updates", entry.getValue().toArray());
                EvidenceCallbackExample callbackExample1 = new EvidenceCallbackExample();
                EvidenceCallbackExample.Criteria criteria1 = callbackExample.createCriteria();
                criteria1.andEvidenceSnIn(entry.getValue());
                sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByExample", callbackExample1);
            // for(String sn:entry.getValue()) {
            // EvidenceBasicInformation basicInformation = informationService
            // .getInformationBySn(sn, null);
            // basicInformation.setIsCallback(1);
            // sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKeySelective",
            // basicInformation);
            // 
            // EvidenceCallbackExample callbackExample1 = new EvidenceCallbackExample();
            // EvidenceCallbackExample.Criteria criteria1 = callbackExample.createCriteria();
            // criteria1.andEvidenceSnEqualTo(sn);
            // sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByExample",
            // callbackExample1);
            // 
            // }
            }
        }
        // <----------------------------    处理dataRet   start   ------------------------------>
        for (Entry<Long, String> entry : dataRet.entrySet()) {
            ApplicationInfo applicationInfo = CacheCustomer.getAPP_INFO_MAP_BY_ID().get(entry.getKey());
            if (applicationInfo == null) {
                applicationInfo = infoService.selectById(entry.getKey());
            }
            if (applicationInfo.getAppId() != app_id || url == null || app_id == null || secret_key == null) {
                if (StringUtils.isEmpty(applicationInfo.getCallback()) || StringUtils.isEmpty(applicationInfo.getAppId()) || StringUtils.isEmpty(applicationInfo.getSecretKey())) {
                    log.error("回调失败:缺少配置。");
                    return;
                }
                if (url == null) {
                    url = applicationInfo.getCallback().trim();
                }
                if (app_id == null) {
                    app_id = applicationInfo.getAppId();
                }
                if (secret_key == null) {
                    secret_key = applicationInfo.getSecretKey();
                }
                log.error("EvidenceQueryQueue : URL=" + url + ",APP_ID=" + app_id + ",SECRET_KEY=" + secret_key);
                if (StringUtils.isEmpty(url) || StringUtils.isEmpty(app_id) || StringUtils.isEmpty(secret_key)) {
                    log.error("回调失败:缺少配置。");
                    return;
                }
            }
            EvidenceBasicInformation basicInformation = informationService.getInformationBySn(entry.getValue(), null);
            // 得到证据回执base64
            String reportBase64 = null;
            // reportBase64 = EvidenceSaveServiceApi.cacheReportBySnMap.get(basicInformation.getEvidenceSn());
            if (StringUtils.isEmpty(reportBase64)) {
                // 获取原子服务地址  1.实名认证  2.密码服务  3.时间戳
                RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
                if (realNameAuthentication == null) {
                    try {
                        realNameAuthentication = realNameAuthenticationSerivce.getRealNameAuthenticationByTwo();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                // 获取回执报告附件表信息
                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 (enclosures != null && !enclosures.isEmpty()) {
                    EvidenceEnclosure enclosure = enclosures.get(0);
                    // 调解密下载接口从原子服务拿到回执报告base64
                    reportBase64 = EvidenceSaveServiceApi.decryptedAndDownload(sqlSession, enclosure.getBuid(), realNameAuthentication.getRealNameddress());
                } else {
                    // 调用生成回执报告方法
                    Map<String, Object> mapRet = null;
                    mapRet = reportTemplate.returnreceipt(basicInformation.getEvidenceSn(), applicationInfo, null);
                    if (mapRet.get("status") != null && (int) mapRet.get("status") == 0) {
                        // 修改证据基本信息回执状态为已出
                        reportBase64 = (String) mapRet.get("pdfBase64");
                        basicInformation.setReceiptStatus(1);
                        sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
                    }
                }
            } else {
            // EvidenceSaveServiceApi.cacheReportBySnMap.remove(basicInformation.getEvidenceSn());
            }
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("status", 1);
            param.put("appId", app_id);
            param.put("evidenceSn", basicInformation.getEvidenceSn());
            if (reportBase64 == null) {
                param.put("message", "存证成功,回执报告生成失败!");
            } else {
                param.put("message", "存证成功");
                param.put("reportBase64", reportBase64);
            }
            String header = "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(app_id + basicInformation.getEvidenceSn(), secret_key), false);
            String retStr = OkHttpClientManagerCallback.post(url, header, param);
            JSONObject ret_data = JSONObject.parseObject(retStr);
            String dataSn = basicInformation.getEvidenceSn();
            Long appId = entry.getKey();
            // 判断是否成功  true ——> 失败
            if (retStr == null || ret_data.getInteger("status") != 1) {
                EvidenceCallback callback = null;
                if (cacheCallBackBySnMap.get(dataSn) == null) {
                    EvidenceCallbackExample callbackExample0 = new EvidenceCallbackExample();
                    EvidenceCallbackExample.Criteria criteria0 = callbackExample.createCriteria();
                    criteria0.andEvidenceSnEqualTo(dataSn);
                    callback = callbackService.selectAll(callbackExample0).get(0);
                } else {
                    callback = cacheCallBackBySnMap.get(dataSn);
                }
                int counnt = callback.getCounnt() + 1;
                if (counnt == 3) {
                    sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByPrimaryKey", callback.getId());
                } else {
                    callback.setCounnt(counnt);
                    sqlSession.update("com.itrus.portal.db.EvidenceCallbackMapper.updateByPrimaryKeySelective", callback);
                }
            } else {
                List<String> sns = new ArrayList<>();
                sns.add(dataSn);
                sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updates", sns.toArray());
                EvidenceCallbackExample callbackExample1 = new EvidenceCallbackExample();
                EvidenceCallbackExample.Criteria criteria1 = callbackExample.createCriteria();
                criteria1.andEvidenceSnIn(sns);
                sqlSession.delete("com.itrus.portal.db.EvidenceCallbackMapper.deleteByExample", callbackExample1);
            }
        }
    // <----------------------------    处理dataRet   end   ------------------------------>
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        LogUtil.evidencelog(sqlSession, null, "存证回调接口", "失败原因:" + e.toString());
    }
}
Also used : HashMap(java.util.HashMap) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ArrayList(java.util.ArrayList) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) RealNameAuthentication(com.itrus.portal.db.RealNameAuthentication) ArrayList(java.util.ArrayList) List(java.util.List) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceCallback(com.itrus.portal.db.EvidenceCallback) EvidenceCallbackExample(com.itrus.portal.db.EvidenceCallbackExample) JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with EvidenceEnclosureExample

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

the class EvidenceOutTask method outBody.

/**
 * 自动出证
 * @param hisCertificate
 * @param orderNumber
 */
private void outBody(String orderNumber, EvidenceOutServiceConfig outServiceConfig, ApplicationInfo applicationInfo, AppService appService, String evidenceSns, String businessSn, Date date, String code, Integer count) {
    try {
        // 定义错误原因字段
        String hisCauseFailure = null;
        // 得到出证模板信息
        EvidenceOutTemplateExample outTemplateExample = new EvidenceOutTemplateExample();
        EvidenceOutTemplateExample.Criteria tec = outTemplateExample.createCriteria();
        tec.andIdEqualTo(outServiceConfig.getOutReportTemplate());
        EvidenceOutTemplate outTemplate = sqlSession.selectOne("com.itrus.portal.db.EvidenceOutTemplateMapper.selectByExample", outTemplateExample);
        // 整合证书需要的要素
        String[] factorArr = outTemplate.getFactor().split(",");
        // 整合出证信息表
        EvidenceHisCertificate hisCertificate = new EvidenceHisCertificate();
        hisCertificate.setServiceRequestPlatform(applicationInfo.getName());
        hisCertificate.setApplicationInfo(applicationInfo.getId());
        hisCertificate.setSisServiceName(appService.getAppServiceName());
        hisCertificate.setSerialnumber(orderNumber);
        hisCertificate.setHisAppService(appService.getId());
        hisCertificate.setApplicationTime(date);
        hisCertificate.setHisApplicant(code);
        hisCertificate.setHisState("1");
        hisCertificate.setOutState(0);
        hisCertificate.setOutTemplate(outServiceConfig.getOutReportTemplate());
        hisCertificate.setHisway(outServiceConfig.getOutWay().toString());
        sqlSession.insert("com.itrus.portal.db.EvidenceHisCertificateMapper.insert", hisCertificate);
        sqlSession.flushStatements();
        // int count = 0;
        if (StringUtils.isNotEmpty(evidenceSns)) {
            String[] evidenceSnArr = evidenceSns.split(",");
            for (String evidenceSn : evidenceSnArr) {
                // 获得对应证据编号的信息
                EvidenceBasicInformation basicInformation = basicInformationService.getInformationBySn(evidenceSn, 2);
                if (basicInformation == null) {
                    if (StringUtils.isEmpty(hisCauseFailure))
                        hisCauseFailure = "提交的" + evidenceSn + "证据编号为无效的证据编码";
                    else
                        hisCauseFailure = hisCauseFailure + "," + "提交的" + evidenceSn + "证据编号为无效的证据编码";
                    continue;
                }
                // count++;
                if (basicInformation.getEvidenceStatus() == 0 || StringUtils.isNotEmpty(basicInformation.getLackMainContent())) {
                    if (StringUtils.isEmpty(hisCauseFailure))
                        hisCauseFailure = "证据编号:" + evidenceSn + "核验未通过,不满足出证要求";
                    else
                        hisCauseFailure = hisCauseFailure + "," + "证据编号:" + evidenceSn + "核验未通过,不满足出证要求";
                }
                // 得到证据附件信息
                EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
                EvidenceEnclosureExample.Criteria eec = enclosureExample.createCriteria();
                eec.andEvidenceSnEqualTo(evidenceSn);
                eec.andPdfTypeEqualTo("1");
                List<EvidenceEnclosure> enclosures = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample);
                // 核验事件证据提交的要素
                String subFactor = null;
                String lackFactor = null;
                for (EvidenceEnclosure enclosure : enclosures) {
                    if (StringUtils.isEmpty(subFactor))
                        subFactor = enclosure.getSaveFactor();
                    else
                        subFactor = subFactor + "," + enclosure.getSaveFactor();
                }
                for (String factor : factorArr) {
                    if (!subFactor.contains(factor) && !(factor.contains("主体身份") || factor.contains("身份实名认证") || factor.contains("身份意愿鉴别"))) {
                        if (StringUtils.isEmpty(lackFactor))
                            lackFactor = factor;
                        else
                            lackFactor = lackFactor + "," + factor;
                    }
                }
                if (StringUtils.isNotEmpty(lackFactor)) {
                    if (StringUtils.isEmpty(hisCauseFailure))
                        hisCauseFailure = "证据编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactor;
                    else
                        hisCauseFailure = hisCauseFailure + "," + "证据编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactor;
                }
                // 核验身份提交的要素
                String idFactor = null;
                for (String factor : factorArr) {
                    if (factor.contains("主体身份") || factor.contains("身份实名认证") || factor.contains("身份意愿鉴别")) {
                        if (StringUtils.isEmpty(idFactor))
                            idFactor = factor;
                        else
                            idFactor = idFactor + "," + factor;
                    }
                }
                log.debug("idFactor__ : " + idFactor);
                if (StringUtils.isNotEmpty(idFactor)) {
                    EvidenceTrustedIdentityExample trustedIdentityExample = new EvidenceTrustedIdentityExample();
                    EvidenceTrustedIdentityExample.Criteria ttc = trustedIdentityExample.createCriteria();
                    ttc.andBasicInformationEqualTo(basicInformation.getId().toString());
                    ttc.andEventContentIsNull();
                    List<EvidenceTrustedIdentity> trustedIdentities = sqlSession.selectList("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trustedIdentityExample);
                    if (trustedIdentities == null || trustedIdentities.isEmpty()) {
                        if (StringUtils.isEmpty(hisCauseFailure))
                            hisCauseFailure = "证据编号:" + evidenceSn + ",缺少必要要素信息:可信身份标识";
                        else
                            hisCauseFailure = hisCauseFailure + "," + "证据编号:" + evidenceSn + ",缺少必要要素信息:可信身份标识";
                    } else {
                        for (EvidenceTrustedIdentity trustedIdentity : trustedIdentities) {
                            // 得到主体身份信息
                            EvidenceMainInformationExample informationExample = new EvidenceMainInformationExample();
                            EvidenceMainInformationExample.Criteria iec = informationExample.createCriteria();
                            // iec.andIdEqualTo(trustedIdentity.getMainInformation());
                            EvidenceMainInformation mainInformation = sqlSession.selectOne("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", informationExample);
                            // 整合没关联主体身份证据的信息
                            if (StringUtils.isEmpty(trustedIdentity.getEvidenceSn())) {
                                if (StringUtils.isEmpty(hisCauseFailure))
                                    hisCauseFailure = "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + idFactor;
                                else
                                    hisCauseFailure = hisCauseFailure + "," + "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + idFactor;
                            } else {
                                // 得到证据附件信息
                                EvidenceEnclosureExample enclosureExample1 = new EvidenceEnclosureExample();
                                EvidenceEnclosureExample.Criteria eec1 = enclosureExample1.createCriteria();
                                eec1.andEvidenceSnEqualTo(trustedIdentity.getEvidenceSn());
                                eec1.andPdfTypeEqualTo("1");
                                List<EvidenceEnclosure> enclosures1 = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample1);
                                String subFactorId = null;
                                String lackFactorId = null;
                                for (EvidenceEnclosure enclosure : enclosures1) {
                                    if (StringUtils.isEmpty(subFactorId))
                                        subFactorId = enclosure.getSaveFactor();
                                    else
                                        subFactorId = subFactorId + "," + enclosure.getSaveFactor();
                                }
                                log.debug("subFactorId__ : " + subFactorId);
                                String[] factorIdArr = idFactor.split(",");
                                for (String factor : factorIdArr) {
                                    if (!subFactorId.contains(factor)) {
                                        if (StringUtils.isEmpty(lackFactorId))
                                            lackFactorId = factor;
                                        else
                                            lackFactorId = lackFactorId + "," + factor;
                                    }
                                }
                                log.debug("lackFactorId__ : " + lackFactorId);
                                if (StringUtils.isNotEmpty(lackFactorId)) {
                                    if (StringUtils.isEmpty(hisCauseFailure))
                                        hisCauseFailure = "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactorId;
                                    else
                                        hisCauseFailure = hisCauseFailure + "," + "证据主体:" + mainInformation.getSubjectName() + ",编号:" + evidenceSn + ",缺少必要要素信息:" + lackFactorId;
                                }
                            }
                        }
                    }
                }
                // 存储出证与证据关系
                EvidenceHisRelationship hisRelationship = new EvidenceHisRelationship();
                hisRelationship.setBasicInformation(basicInformation.getId());
                hisRelationship.setHisCertificate(hisCertificate.getId());
                sqlSession.insert("com.itrus.portal.db.EvidenceHisRelationshipMapper.insert", hisRelationship);
            }
        } else {
            List<EvidenceBasicInformation> basicInformations = basicInformationService.getInformationByBusinessSn(businessSn, 2);
            if (basicInformations == null || basicInformations.isEmpty()) {
                if (StringUtils.isEmpty(hisCauseFailure))
                    hisCauseFailure = "提交的业务单号有误";
                else
                    hisCauseFailure = hisCauseFailure + "," + "提交的业务单号有误";
            }
            for (EvidenceBasicInformation basicInformation : basicInformations) {
                // 得到证据附件信息
                EvidenceEnclosureExample enclosureExample = new EvidenceEnclosureExample();
                EvidenceEnclosureExample.Criteria eec = enclosureExample.createCriteria();
                eec.andBasicInformationEqualTo(basicInformation.getId());
                eec.andPdfTypeEqualTo("1");
                List<EvidenceEnclosure> enclosures = sqlSession.selectList("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclosureExample);
                // 得到提交的要素
                String subFactor = null;
                String lackFactor = null;
                for (EvidenceEnclosure enclosure : enclosures) {
                    if (StringUtils.isEmpty(subFactor))
                        subFactor = enclosure.getSaveFactor();
                    else
                        subFactor = subFactor + "," + enclosure.getSaveFactor();
                }
                for (String factor : factorArr) {
                    if (!subFactor.contains(factor)) {
                        if (StringUtils.isEmpty(lackFactor))
                            lackFactor = factor;
                        else
                            lackFactor = lackFactor + "," + factor;
                    }
                }
                if (StringUtils.isNotEmpty(lackFactor)) {
                    if (StringUtils.isEmpty(hisCauseFailure))
                        hisCauseFailure = "证据编号:" + basicInformation.getEvidenceSn() + ",缺少必要要素信息:" + lackFactor;
                    else
                        hisCauseFailure = hisCauseFailure + "," + "证据编号:" + basicInformation.getEvidenceSn() + ",缺少必要要素信息:" + lackFactor;
                }
                // count++;
                if (basicInformation.getEvidenceStatus() == 0 || StringUtils.isNotEmpty(basicInformation.getLackMainContent())) {
                    if (StringUtils.isEmpty(hisCauseFailure))
                        hisCauseFailure = "证据编号:" + basicInformation.getEvidenceSn() + ",不满足出证要求";
                    else
                        hisCauseFailure = hisCauseFailure + "," + "证据编号:" + basicInformation.getEvidenceSn() + ",不满足出证要求";
                }
                // 存储出证与证据关系
                EvidenceHisRelationship hisRelationship = new EvidenceHisRelationship();
                hisRelationship.setBasicInformation(basicInformation.getId());
                hisRelationship.setHisCertificate(hisCertificate.getId());
                sqlSession.insert("com.itrus.portal.db.EvidenceHisRelationshipMapper.insert", hisRelationship);
            }
        }
        // 判断出证模式
        if (count == 1)
            hisCertificate.setHis("0");
        else
            hisCertificate.setHis("1");
        // 判断出证是否有错
        if (StringUtils.isNotEmpty(hisCauseFailure)) {
            // hisCertificate.setHisway("3");
            hisCertificate.setOutState(1);
            hisCertificate.setHisCauseFailure(hisCauseFailure);
        }
        sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKey", hisCertificate);
        sqlSession.flushStatements();
        // 判断是否为自动出证
        if ("1".equals(hisCertificate.getHisway()) && hisCertificate.getOutState() == 0) {
            String oper1 = "出证接口";
            String info1 = "出证申请成功,流水号:" + orderNumber;
            LogUtil.evidencelog(sqlSession, null, oper1, info1);
            Map<String, Object> mapRet = null;
            // 生成出证报告
            try {
                mapRet = reportTemplate.certificationReport(hisCertificate.getSerialnumber());
            } catch (Exception e) {
                StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 3];
                String infoErr = stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
                String oper = "出证接口";
                String info = "生成出证报告失败,流水号:" + orderNumber + ",失败原因:" + infoErr;
                LogUtil.evidencelog(sqlSession, null, oper, info);
                e.printStackTrace();
            }
            // 判断出证报告是否生成成功
            if (mapRet != null) {
                if ((int) mapRet.get("status") == 0) {
                    // hisCertificate.setOutState(0);
                    String oper = "出证接口";
                    String info = "生成出证报告成功,流水号:" + orderNumber;
                    LogUtil.evidencelog(sqlSession, null, oper, info);
                    hisCertificate.setHisState("0");
                } else {
                    // hisCertificate.setOutState(1);
                    String oper = "出证接口";
                    String info = null;
                    if (mapRet.get("message") != null) {
                        info = "生成出证报告失败,流水号:" + orderNumber + ",失败原因:" + mapRet.get("message").toString();
                    // hisCertificate.setHisCauseFailure(mapRet.get("message").toString());
                    } else {
                        info = "生成出证报告失败,流水号:" + orderNumber;
                    // hisCertificate.setHisCauseFailure("出证失败");
                    }
                    LogUtil.evidencelog(sqlSession, null, oper, info);
                }
            }
        } else {
            String oper = "出证接口";
            String info = "出证失败,流水号:" + orderNumber;
            // 判断为自动出证失败后  转人工出证
            if (hisCertificate.getHisway().equals("1")) {
                hisCertificate.setHisway("3");
                info = info + ",已自动转人工出证";
            }
            LogUtil.evidencelog(sqlSession, null, oper, info);
        }
        sqlSession.update("com.itrus.portal.db.EvidenceHisCertificateMapper.updateByPrimaryKeySelective", hisCertificate);
        // 出证计费加流水
        takeChargingService.takeCharing(appService.getServiceConfigName(), appService.getServiceConfigId(), applicationInfo, appService, hisCertificate.getId(), "EvidenceHisCertificate", count, applicationInfo.getName(), hisCertificate.getHisApplicant());
    } catch (Exception e) {
        e.printStackTrace();
        StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length - 3];
        String info = "出证失败,错误详情:" + stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
        String oper = "出证接口";
        LogUtil.evidencelog(sqlSession, null, oper, info);
    }
}
Also used : EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) EvidenceHisRelationship(com.itrus.portal.db.EvidenceHisRelationship) EvidenceHisCertificate(com.itrus.portal.db.EvidenceHisCertificate) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) EvidenceMainInformation(com.itrus.portal.db.EvidenceMainInformation) EvidenceOutTemplateExample(com.itrus.portal.db.EvidenceOutTemplateExample) EvidenceTrustedIdentity(com.itrus.portal.db.EvidenceTrustedIdentity) EvidenceOutTemplate(com.itrus.portal.db.EvidenceOutTemplate) EvidenceMainInformationExample(com.itrus.portal.db.EvidenceMainInformationExample) EvidenceTrustedIdentityExample(com.itrus.portal.db.EvidenceTrustedIdentityExample)

Example 10 with EvidenceEnclosureExample

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

Aggregations

EvidenceEnclosure (com.itrus.portal.db.EvidenceEnclosure)20 EvidenceEnclosureExample (com.itrus.portal.db.EvidenceEnclosureExample)20 EvidenceBasicInformation (com.itrus.portal.db.EvidenceBasicInformation)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)11 List (java.util.List)11 EvidenceHisCertificate (com.itrus.portal.db.EvidenceHisCertificate)8 EvidenceHisRelationship (com.itrus.portal.db.EvidenceHisRelationship)8 EvidenceHisRelationshipExample (com.itrus.portal.db.EvidenceHisRelationshipExample)7 EvidenceMainInformation (com.itrus.portal.db.EvidenceMainInformation)7 JSONObject (com.alibaba.fastjson.JSONObject)6 AppService (com.itrus.portal.db.AppService)6 EvidenceCompaniesSubmit (com.itrus.portal.db.EvidenceCompaniesSubmit)6 EvidenceIndividual (com.itrus.portal.db.EvidenceIndividual)6 EvidenceRealName (com.itrus.portal.db.EvidenceRealName)6 EvidenceRealNameExample (com.itrus.portal.db.EvidenceRealNameExample)6 EvidenceTrustedIdentity (com.itrus.portal.db.EvidenceTrustedIdentity)6 EvidenceTrustedIdentityExample (com.itrus.portal.db.EvidenceTrustedIdentityExample)6