Search in sources :

Example 1 with EvidenceClientSignature

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

the class BasicInformationController method show2.

/**
 * 查看详情
 *
 * @param id
 * @param uiModel
 * @return
 */
@RequestMapping(value = "show/{identification}", produces = "text/html")
public String show2(@PathVariable("identification") String id, Model uiModel) {
    List<EvidenceMainInformation> mlist = new ArrayList<EvidenceMainInformation>();
    List<EvidenceMainInformation> milist = 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, EvidenceTrustedIdentity> trustedidentit = new HashMap<Long, EvidenceTrustedIdentity>();
    // 事件时间认证
    Map<Long, EvidenceEventTime> meventime = new HashMap<Long, EvidenceEventTime>();
    // 事件行为认证
    Map<Long, EvidenceEventBehavior> eventbehacior = new HashMap<Long, EvidenceEventBehavior>();
    // 事件意愿认证
    Map<Long, EvidenceEventDesire> meventdesire = new HashMap<Long, EvidenceEventDesire>();
    // 事件网络地址
    Map<Long, EvidenceEventNetworkAddress> networkaddress = new HashMap<Long, EvidenceEventNetworkAddress>();
    // 身份意愿信息
    Map<Long, EvidenceDesireIdentify> desire = new HashMap<Long, EvidenceDesireIdentify>();
    // 得到基本信息
    EvidenceBasicInformation basicinfor = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByPrimaryKey", basid);
    // 得到主体身份信息
    EvidenceMainInformationExample mainExample = new EvidenceMainInformationExample();
    EvidenceMainInformationExample.Criteria info = mainExample.createCriteria();
    info.andIdentificationEqualTo(id);
    // 得到主体信息
    List<EvidenceMainInformation> mainInfor = sqlSession.selectList("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", mainExample);
    EvidenceMainInformation mainInfo = new EvidenceMainInformation();
    if (mainInfor.size() != 0) {
        mlist.add(mainInfor.get(0));
        mainInfo = mainInfor.get(0);
    }
    EvidenceSubjectIdentityExample subjectExample = new EvidenceSubjectIdentityExample();
    EvidenceSubjectIdentityExample.Criteria identity = subjectExample.createCriteria();
    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());
        if (subjectIdentity.get(i).getMainName() != null) {
            tionE.andSubjectNameEqualTo(subjectIdentity.get(i).getMainName());
        }
        List<EvidenceMainInformation> ainInfo = sqlSession.selectList("com.itrus.portal.db.EvidenceMainInformationMapper.selectByExample", infomationE);
        if (ainInfo.size() != 0) {
            milist.add(ainInfo.get(0));
        }
    /*EvidenceMainInformation ainInfo = sqlSession.selectOne(
					"com.itrus.portal.db.EvidenceMainInformationMapper.selectByPrimaryKey",
					subjectIdentity.get(i).getMainInformation());
			milist.add(ainInfo);*/
    }
    // 身份信息证据的map
    Map<Long, EvidenceBasicInformation> basi = new HashMap<Long, EvidenceBasicInformation>();
    // 得到身份可信标识
    EvidenceTrustedIdentityExample trusten = new EvidenceTrustedIdentityExample();
    EvidenceTrustedIdentityExample.Criteria identityex = trusten.createCriteria();
    // identityex.andMainInformationEqualTo(mainInfo.getId());
    identityex.andBasicInformationEqualTo(basicinfor.getEvidenceSn());
    identityex.andEventContentIsNull();
    Map<Long, EvidenceTrustedIdentity> trustedidentity = sqlSession.selectMap("com.itrus.portal.db.EvidenceTrustedIdentityMapper.selectByExample", trusten, "mainInformation");
    // String evidenceSn = null;
    if (trustedidentity != null && trustedidentity.get(mainInfo.getId()) != null) {
        if (trustedidentity.get(mainInfo.getId()).getEvidenceSn() != null) {
            String evidenceSn = trustedidentity.get(mainInfo.getId()).getEvidenceSn().toString();
            // 得到可信身份标识关联的证据身份信息
            EvidenceBasicInformationExample basicinforE = new EvidenceBasicInformationExample();
            EvidenceBasicInformationExample.Criteria critbasic = basicinforE.createCriteria();
            critbasic.andEvidenceSnEqualTo(evidenceSn);
            EvidenceBasicInformation basicinfor1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceBasicInformationMapper.selectByExample", basicinforE);
            basi.put(mainInfo.getId(), basicinfor1);
            // 得到身份意愿信息
            EvidenceDesireIdentifyExample desireIdentify = new EvidenceDesireIdentifyExample();
            EvidenceDesireIdentifyExample.Criteria desireExample = desireIdentify.createCriteria();
            desireExample.andMainInformationEqualTo(mainInfo.getIdentification());
            desire = sqlSession.selectMap("com.itrus.portal.db.EvidenceDesireIdentifyMapper.selectByExample", desireIdentify, "mainInformation");
            // 得到实名认证信息
            EvidenceRealNameExample realnameE = new EvidenceRealNameExample();
            EvidenceRealNameExample.Criteria realnameEx = realnameE.createCriteria();
            realnameEx.andMainInformationEqualTo(mainInfo.getSubjectName() + ";" + mainInfo.getIdentification());
            // realnameEx.andBasicInformationEqualTo(basicinfor1.getId());
            realnameEx.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
            EvidenceRealName erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", realnameE);
            if (erealname != null) {
                if ("2".equals(erealname.getEventVerifierType()) || "3".equals(erealname.getEventVerifierType())) {
                    // 判断企业还是个人
                    if ("1".equals(erealname.getType())) {
                        EvidenceCompaniesSubmitExample evidenceCompanies = new EvidenceCompaniesSubmitExample();
                        EvidenceCompaniesSubmitExample.Criteria submitEx = evidenceCompanies.createCriteria();
                        submitEx.andIdCodeEqualTo(erealname.getCompaniesSubmit());
                        EvidenceCompaniesSubmit companiesSubmit1 = sqlSession.selectOne("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByExample", evidenceCompanies);
                        companiesSubmit.put(mainInfo.getId(), companiesSubmit1);
                    } else {
                        EvidenceIndividualExample evidenceIndiv = new EvidenceIndividualExample();
                        EvidenceIndividualExample.Criteria idualEx = evidenceIndiv.createCriteria();
                        idualEx.andIdCodeEqualTo(erealname.getIndividual());
                        EvidenceIndividual dic = sqlSession.selectOne("com.itrus.portal.db.EvidenceIndividualMapper.selectByPrimaryKey", evidenceIndiv);
                        denceid.put(mainInfo.getId(), dic);
                    }
                } else if ("1".equals(erealname.getEventVerifierType())) {
                    if ("1".equals(erealname.getType())) {
                        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]);
                        }
                        RealNameRecordExample realname = new RealNameRecordExample();
                        RealNameRecordExample.Criteria recor = realname.createCriteria();
                        // recor.andSerialnumberEqualTo(a[i]);
                        recor.andSerialnumberIn(listString);
                        realname.setOrderByClause("returntime");
                        listReal = sqlSession.selectList("com.itrus.portal.db.RealNameRecordMapper.selectByExample", realname);
                        realnameRecor.put(mainInfo.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]);
                        }
                        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(mainInfo.getId(), listPersonal);
                    }
                }
            }
            uiModel.addAttribute("erealname", erealname);
        }
    }
    // 事件内容
    EvidenceEventContentExample evencontent = new EvidenceEventContentExample();
    EvidenceEventContentExample.Criteria countent = evencontent.createCriteria();
    // countent.andBasicInformationEqualTo(basicinfor.getId());
    countent.andEvidenceSnEqualTo(basicinfor.getEvidenceSn());
    EvidenceEventContent mevencontent = sqlSession.selectOne("com.itrus.portal.db.EvidenceEventContentMapper.selectByExample", evencontent);
    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);
    }
    // 得到证据附件信息
    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);
    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);
    uiModel.addAttribute("enclosurepdf", enclosurepdf);
    // 服务委托人签名信息
    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>();
    int ensize = 0;
    for (EvidenceEnclosure en : enclosure) {
        // 服务委托人签名信息
        EvidenceClientSignatureExample cilent = new EvidenceClientSignatureExample();
        EvidenceClientSignatureExample.Criteria signat = cilent.createCriteria();
        signat.andEvidenceSnEqualTo(en.getEvidenceSn());
        signat.andNameEqualTo("0");
        EvidenceClientSignature listclient = sqlSession.selectOne("com.itrus.portal.db.EvidenceClientSignatureMapper.selectByExample", cilent);
        if (listclient != null) {
            cilentsignat.put(en.getId(), listclient);
            ensize++;
            // 服务委托人证书信息
            /*	EvidenceCertExample certEx = new EvidenceCertExample();
				EvidenceCertExample.Criteria evidenceCert = certEx.createCriteria();
				evidenceCert.andClientSignatureEqualTo(listclient.getId());
				List<EvidenceCert> listCert = sqlSession
						.selectList("com.itrus.portal.db.EvidenceCertMapper.selectByExample", certEx);*/
            List<EvidenceCert> listCert = sqlSession.selectList("com.itrus.portal.db.EvidenceCertMapper.selectByPrimaryKey", listclient.getCertId());
            listcert.put(en.getId(), listCert);
            // 服务委托人核验信息
            EvidenceCheckExample checkEx = new EvidenceCheckExample();
            EvidenceCheckExample.Criteria evidenceCheck = checkEx.createCriteria();
            evidenceCheck.andClientSignatureEqualTo(listclient.getId());
            EvidenceCheck listCheck = sqlSession.selectOne("com.itrus.portal.db.EvidenceCheckMapper.selectByExample", checkEx);
            check.put(en.getId(), listCheck);
        }
        // 天威签名信息
        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);
        if (clientlist != null) {
            cilentsignature.put(en.getId(), clientlist);
            ensize++;
        }
        // 服务委托人时间戳信息
        EvidenceClientTimeStampExample clientTime = new EvidenceClientTimeStampExample();
        EvidenceClientTimeStampExample.Criteria stamp = clientTime.createCriteria();
        stamp.andEvidenceSnEqualTo(en.getEvidenceSn());
        stamp.andNameEqualTo("0");
        EvidenceClientTimeStamp listtime = sqlSession.selectOne("com.itrus.portal.db.EvidenceClientTimeStampMapper.selectByExample", clientTime);
        if (listtime != null) {
            clientTimestamp.put(en.getId(), listtime);
            ensize++;
        }
        // 天威时间戳信息
        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);
        if (timelist != null) {
            tclientTimestamp.put(en.getId(), timelist);
            ensize++;
        }
    }
    uiModel.addAttribute("basi", basi);
    uiModel.addAttribute("ensize", ensize);
    uiModel.addAttribute("check", check);
    uiModel.addAttribute("listcert", listcert);
    uiModel.addAttribute("envlosure", enclosure);
    // uiModel.addAttribute("erealname", erealname);
    uiModel.addAttribute("milist", milist);
    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("desire", desire);
    int coutn = 0;
    int size = 0;
    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("showsize", msize);
    uiModel.addAttribute("rowsize", size + 1);
    uiModel.addAttribute("rowcoutn", coutn);
    return "basicinformation/show";
}
Also used : EvidenceIndividual(com.itrus.portal.db.EvidenceIndividual) EvidenceSubjectIdentityExample(com.itrus.portal.db.EvidenceSubjectIdentityExample) HashMap(java.util.HashMap) PersonalNameExample(com.itrus.portal.db.PersonalNameExample) EvidenceClientTimeStamp(com.itrus.portal.db.EvidenceClientTimeStamp) ArrayList(java.util.ArrayList) EvidenceRealName(com.itrus.portal.db.EvidenceRealName) EvidenceClientTimeStampExample(com.itrus.portal.db.EvidenceClientTimeStampExample) ArrayList(java.util.ArrayList) List(java.util.List) EvidenceEventDesire(com.itrus.portal.db.EvidenceEventDesire) EvidenceCompaniesSubmitExample(com.itrus.portal.db.EvidenceCompaniesSubmitExample) EvidenceEventNetworkAddressExample(com.itrus.portal.db.EvidenceEventNetworkAddressExample) EvidenceDesireIdentify(com.itrus.portal.db.EvidenceDesireIdentify) EvidenceEventBehaviorExample(com.itrus.portal.db.EvidenceEventBehaviorExample) EvidenceSubjectIdentity(com.itrus.portal.db.EvidenceSubjectIdentity) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) RealNameRecord(com.itrus.portal.db.RealNameRecord) EvidenceCheckExample(com.itrus.portal.db.EvidenceCheckExample) EvidenceEventContentExample(com.itrus.portal.db.EvidenceEventContentExample) EvidenceCert(com.itrus.portal.db.EvidenceCert) EvidenceEventTime(com.itrus.portal.db.EvidenceEventTime) EvidenceEventNetworkAddress(com.itrus.portal.db.EvidenceEventNetworkAddress) EvidenceIndividualExample(com.itrus.portal.db.EvidenceIndividualExample) EvidenceRealNameExample(com.itrus.portal.db.EvidenceRealNameExample) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) EvidenceMainInformation(com.itrus.portal.db.EvidenceMainInformation) EvidenceDesireIdentifyExample(com.itrus.portal.db.EvidenceDesireIdentifyExample) PersonalName(com.itrus.portal.db.PersonalName) EvidenceEventDesireExample(com.itrus.portal.db.EvidenceEventDesireExample) EvidenceEventTimeExample(com.itrus.portal.db.EvidenceEventTimeExample) EvidenceCompaniesSubmit(com.itrus.portal.db.EvidenceCompaniesSubmit) EvidenceEventContent(com.itrus.portal.db.EvidenceEventContent) EvidenceClientSignature(com.itrus.portal.db.EvidenceClientSignature) EvidenceCheck(com.itrus.portal.db.EvidenceCheck) EvidenceClientSignatureExample(com.itrus.portal.db.EvidenceClientSignatureExample) EvidenceBasicInformationExample(com.itrus.portal.db.EvidenceBasicInformationExample) EvidenceEventBehavior(com.itrus.portal.db.EvidenceEventBehavior) 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 2 with EvidenceClientSignature

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

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

the class EvidenceSaveContractService method saveBody.

// 存证核验处理方法(pdf电子合同)
public Map<String, Object> saveBody(Map<String, Object> result1, ApplicationInfo applicationInfo1, AppService appService1, EvidenceSaveService evidenceSaveService, Date applyDate, String evidenceSn, String genSn, String signedBase64, String evidencePackage, String hashAlg, String hashvalue, Date dateVp, Date dateVc, List<String> certs, RealNameAuthentication realNameAuthentication, RealNameAuthentication realNameAuthenticationTime, RealNameAuthentication realNameAuthenticationOss, Map<String, Object> mapCharging) {
    Map<String, Object> result = result1;
    ApplicationInfo applicationInfo = applicationInfo1;
    AppService appService = appService1;
    List<Object> objs = new ArrayList<Object>();
    String info = null;
    // 证据服务记录
    EvidenceBasicInformation basicInformation = null;
    // 本次证据包大小
    int fileSize = evidencePackage.getBytes().length;
    // 定义一个证据的提交次数
    int count = 0;
    String failureReason = null;
    String sn = genSn;
    if (StringUtils.isNotBlank(evidenceSn)) {
        sn = evidenceSn;
    }
    try {
        // 得到证据包json
        JSONObject jsonEvidenceContent = JSONObject.parseObject(evidencePackage);
        // 获取证书固定服务配置
        EvidenceServiceConfiguration serviceConfiguration = null;
        serviceConfiguration = CacheCustomer.getEVIDENCE_SERVICE_CONFIG();
        if (serviceConfiguration == null) {
            List<EvidenceServiceConfiguration> serviceconfig = sqlSession.selectList("com.itrus.portal.db.EvidenceServiceConfigurationMapper.selectByExample");
            if (!serviceconfig.isEmpty()) {
                serviceConfiguration = serviceconfig.get(0);
                CacheCustomer.setEVIDENCE_SERVICE_CONFIG(serviceConfiguration);
            } else {
                result.put("status", -22);
                result.put("message", "缺少服务配置");
                return result;
            }
        }
        // 验签信息入库
        EvidenceClientSignature clientSignature = new EvidenceClientSignature();
        clientSignature.setHashAlgorithm(hashAlg);
        clientSignature.setHashvalue(hashvalue);
        clientSignature.setName("0");
        // ---- 关联证书
        clientSignature.setCertId(Long.parseLong(applicationInfo.getCertBase64()));
        clientSignature.setSignatureType("2");
        clientSignature.setIdentiType("1");
        clientSignature.setSignaturevalue(signedBase64);
        clientSignature.setCreateTime(dateVp);
        clientSignature.setEvidenceSn(sn);
        objs.add(clientSignature);
        clientSignature = null;
        // 密钥别名定义
        String alias = null;
        // 判断是否需要签名或时间戳
        if (evidenceSaveService.getFixationWay() != null && evidenceSaveService.getFixationWay() != 1) {
            // 判断是否需要签名
            if (evidenceSaveService.getFixationWay() == 2 || evidenceSaveService.getFixationWay() == 4) {
                // 定义签名参数
                Map<String, Object> param = new HashMap<String, Object>();
                String url = null;
                // 判断签名类型配置是否为空
                if (StringUtils.isNotBlank(serviceConfiguration.getSignatureType())) {
                    // 得到配置证书
                    EvidenceCertificate evidenceCertificate = null;
                    evidenceCertificate = CacheCustomer.getEVIDENCE_CERTIFICATE_MAP().get((long) serviceConfiguration.getSignatureCertificate());
                    if (evidenceCertificate == null) {
                        evidenceCertificate = certificateService.selectById((long) serviceConfiguration.getSignatureCertificate());
                    }
                    // 得到服务配置的签名证书的密钥别名
                    alias = CacheCustomer.getMAP_COMFIG().get((long) serviceConfiguration.getSignatureCertificate());
                    if (StringUtils.isEmpty(alias)) {
                        alias = secretKeyService.getAliasByCertId((long) serviceConfiguration.getSignatureCertificate());
                    }
                    // 配置签名url 和 参数   1.裸签名  2.p7分离式签名  3.p7非分离式签名  (本期只做2)
                    switch(Integer.parseInt(serviceConfiguration.getSignatureType())) {
                        case 1:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + SIGNATURE_SIGN;
                            break;
                        case 2:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("detached", true);
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + P7_SIGN;
                            break;
                        case 3:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("detached", false);
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + P7_SIGN;
                            break;
                    }
                    // 异步处理p7签名
                    // HttpAsyncClientUtil.getInstance().execute(
                    // url,
                    // AuthService.getHeader(),
                    // param,
                    // new EvidenceSignTask(
                    // url,
                    // param,
                    // sn,
                    // Long.parseLong(evidenceCertificate.getCert())));
                    // 异步处理p7签名
                    // OkHttpClientManagerSign.postAsyn(
                    // url,
                    // AuthService.getHeader().get("Authorization").toString(),
                    // param,
                    // new EvidenceSignTask(
                    // url,
                    // param,
                    // sn,
                    // Long.parseLong(evidenceCertificate.getCert())));
                    String strP7 = null;
                    try {
                        long p7Sign = System.currentTimeMillis();
                        strP7 = OkHttpClientManagerSign.post(url, AuthService.getHeader().get("Authorization").toString(), param);
                        log.error("p7Sign time is [" + (System.currentTimeMillis() - p7Sign) + "]");
                    } catch (Exception e) {
                        e.printStackTrace();
                        LogUtil.evidencelog(sqlSession, sn, "存证接口_天威签名", "天威签名失败,证据编号:" + sn + ", 请求参数:" + param.toString() + ", 请求地址:" + url + ", 返回结果:" + strP7 + ", 失败原因:" + e.toString());
                        result.put("status", 0);
                        result.put("message", "天威签名失败");
                        return result;
                    }
                    JSONObject jsonRepP7Sign = JSONObject.parseObject(strP7);
                    if (jsonRepP7Sign.getIntValue("code") != 0) {
                        // 天威签名失败
                        LogUtil.evidencelog(sqlSession, sn, "存证接口_天威签名", "天威签名失败,证据编号:" + sn + ", 请求参数:" + param.toString() + ", 请求地址:" + url + ", 返回结果:" + strP7 + ", 失败原因:" + jsonRepP7Sign);
                        result.put("status", 0);
                        result.put("message", "天威签名失败");
                        return result;
                    } else {
                        // 天威签名服务记录入库
                        EvidenceClientSignature signature = new EvidenceClientSignature();
                        signature.setHashAlgorithm(param.get("hashAlg").toString());
                        signature.setName("1");
                        signature.setEvidenceSn(sn);
                        signature.setSignatureType("2");
                        signature.setCertId(Long.parseLong(evidenceCertificate.getCert()));
                        signature.setHashvalue(param.get("content").toString());
                        signature.setSignaturevalue(jsonRepP7Sign.getString("signedData"));
                        signature.setCreateTime(new Date());
                        objs.add(signature);
                    }
                    evidenceCertificate = null;
                }
            }
            // 判断是否需要签名时间戳
            if (evidenceSaveService.getFixationWay() == 3 || evidenceSaveService.getFixationWay() == 4) {
                // 对证据包HASH
                String plainHash = HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage);
                // 异步处理时间戳   ---  本期是实现新版本接口
                long timeSign = System.currentTimeMillis();
                Map<String, Object> retTime = EvidenceSaveServiceApi.genTimeStamp(realNameAuthenticationTime, plainHash, serviceConfiguration.getArithmetic(), sn, null);
                log.error("timeSign time is [" + (System.currentTimeMillis() - timeSign) + "]");
                if (!(boolean) retTime.get("retStatus") || retTime.get("obj") == null) {
                    result.put("status", 0);
                    result.put("message", "天威时间戳签名失败");
                    return result;
                }
                objs.add(retTime.get("obj"));
            }
        }
        alias = null;
        Map<String, Object> retSaveMap = new HashMap<String, Object>();
        // 判断证据编号是否为空   true -> 证据编码为空 代表第一次存证   ,false ->证据编码不为空 代表不是第一次存证
        if (StringUtils.isEmpty(evidenceSn)) {
            basicInformation = new EvidenceBasicInformation();
            basicInformation.setReceiptStatus(0);
            basicInformation.setStatus(0);
            basicInformation.setIsCallback(0);
            basicInformation.setCreateTime(new Date());
            basicInformation.setEndTime(EvidenceSaveServiceApi.convertDate(evidenceSaveService.getSaveTime()));
            basicInformation.setEvidenceSize(fileSize);
            basicInformation.setEvidenceSn(genSn);
            basicInformation.setAppService(appService.getId());
            basicInformation.setEvidenceStatus(1);
            basicInformation.setApplicationInfo(applicationInfo.getId());
            basicInformation.setOutAppService(evidenceSaveService.getAppServiceName());
            basicInformation.setSaveServiceNmae(appService.getAppServiceName());
            basicInformation.setServicePlatformName(applicationInfo.getName());
            basicInformation.setServiceClientName(applicationInfo.getServiceClientName());
            basicInformation.setServiceClientId(applicationInfo.getServiceClientId());
            if (StringUtils.isNotEmpty(failureReason)) {
                basicInformation.setFailureReason(failureReason);
                basicInformation.setEvidenceStatus(0);
                result.put("status", 0);
            }
            // 对要素 (接收 核验 必填) 操作进行处理
            long saveFactorTime = System.currentTimeMillis();
            retSaveMap = saveFactor(retSaveMap, evidenceSaveService, genSn, jsonEvidenceContent, basicInformation, realNameAuthentication, realNameAuthenticationOss, serviceConfiguration, true, applyDate.getTime());
            log.error("saveFactorTime time is [" + (System.currentTimeMillis() - saveFactorTime) + "]");
        } else {
            result.put("status", 0);
            result.put("message", "提交证据失败,系统暂不支持补交功能。");
            return result;
        }
        if (retSaveMap.get("status") != null) {
            result.put("status", retSaveMap.get("status"));
            result.put("message", retSaveMap.get("message"));
            return result;
        } else {
            List<Object> lists = (List<Object>) retSaveMap.get("objs");
            for (Object obj : lists) {
                objs.add(obj);
            }
        }
        basicInformation = (EvidenceBasicInformation) retSaveMap.get("basicInformation");
        if (basicInformation.getEvidenceStatus() != null && basicInformation.getEvidenceStatus() == 0) {
            result.put("status", 0);
            result.put("message", basicInformation.getEvidenceStatus());
            return result;
        }
        // 得到加密证书别名
        alias = CacheCustomer.getMAP_COMFIG().get((long) serviceConfiguration.getEncryptionCertificate());
        if (StringUtils.isEmpty(alias)) {
            alias = secretKeyService.getAliasByCertId((long) serviceConfiguration.getEncryptionCertificate());
        }
        // 内部加密存储证据包
        String urlSave = realNameAuthentication.getRealNameddress() + "/storage/save";
        Map<String, Object> mapSave = new HashMap<String, Object>();
        mapSave.put("type", "ST_E");
        mapSave.put("bucketName", realNameAuthenticationOss.getKeyCode());
        mapSave.put("objectName", applicationInfo.getServiceClientId() + "/" + sn + (count + 1));
        mapSave.put("contentType", "CT_BASE64_DATA");
        mapSave.put("content", Base64.encode(evidencePackage.getBytes("utf-8")));
        mapSave.put("alias", alias);
        mapSave.put("digestZValue", false);
        mapSave.put("encAlg", serviceConfiguration.getEncryptionAlgorithm());
        String saveFactor = null;
        if (retSaveMap.get("saveFactor") != null) {
            saveFactor = retSaveMap.get("saveFactor").toString();
        }
        // 异步处理存储
        // long saveTime = System.currentTimeMillis();
        // HttpAsyncClientUtil.getInstance().execute(
        // urlSave,
        // AuthService.getHeader(),
        // mapSave,
        // new EvidenceSavePackageTask(
        // urlSave,
        // mapSave,
        // null,
        // (StringUtils.isEmpty(evidenceSn) ? genSn : evidenceSn),
        // fileSize,
        // null,
        // applyDate,
        // Integer.toString(evidenceSaveService.getSaveTime()),
        // saveFactor));
        // log.error("saveTime time is [" + (System.currentTimeMillis() - saveTime) + "]");
        log.error("save is " + (!(evidenceSaveService.getEncryptionWay() == null || evidenceSaveService.getEncryptionWay() == 0)));
        if (!(evidenceSaveService.getEncryptionWay() == null || evidenceSaveService.getEncryptionWay() == 0)) {
            // String retSave = null;
            // try {
            // long saveTime = System.currentTimeMillis();
            // retSave = OkHttpClientManagerSave.post(urlSave, AuthService.getHeader().get("Authorization").toString(), mapSave);
            // log.error("saveTime time is [" + (System.currentTimeMillis() - saveTime) + "]");
            // } catch (Exception e) {
            // e.printStackTrace();
            // LogUtil.evidencelog(sqlSession, sn, "存证接口_存储数据包", "存储数据包失败,证据编号:"
            // + sn +  ", 请求地址:"
            // + urlSave + ",返回结果" + retSave + ", 失败原因:" +e.toString());
            // 
            // result.put("status", 0);
            // result.put("message", "证据存储失败");
            // return result;
            // }
            // JSONObject jsonSave = JSONObject.parseObject(retSave);
            // if(jsonSave.getIntValue("code") != 0) {//天威签名失败
            // LogUtil.evidencelog(sqlSession, sn, "存证接口_存储数据包", "存储数据包失败,证据编号:"
            // + sn + ", 请求地址:" + urlSave
            // + ",返回结果" + retSave + ", 失败原因:" + jsonSave.getString("message"));
            // 
            // result.put("status", 0);
            // result.put("message", "证据存储失败");
            // return result;
            // 
            // } else {
            // EvidenceEnclosure enclosure = new EvidenceEnclosure();
            // enclosure.setBuid(jsonSave.getString("buid"));
            // enclosure.setEvidenceSn(sn);
            // enclosure.setFilesize(Integer.toString(fileSize));
            // enclosure.setPdfType("1");
            // enclosure.setApplicationTime(applyDate);
            // enclosure.setCreateTime(new Date());
            // enclosure.setSaveTime(Integer.toString(evidenceSaveService.getSaveTime()));
            // if(mapSave.get("type") != null)
            // enclosure.setType(mapSave.get("type").toString());
            // if(mapSave.get("contentType") != null)
            // enclosure.setContentType(mapSave.get("contentType").toString());
            // if(mapSave.get("bucketName") != null)
            // enclosure.setBucketName(mapSave.get("bucketName").toString());
            // if(mapSave.get("objectName") != null)
            // enclosure.setObjectName(mapSave.get("objectName").toString());
            // if(mapSave.get("alias") != null)
            // enclosure.setAlias(mapSave.get("alias").toString());
            // enclosure.setFixationTime(new Date());
            // if(saveFactor != null){
            // enclosure.setSaveFactor(saveFactor);
            // }
            // objs.add(enclosure);
            // }
            long saveTime = System.currentTimeMillis();
            OkHttpClientManagerSave.postAsyn(urlSave, AuthService.getHeader().get("Authorization").toString(), mapSave, new EvidenceSavePackageTask(urlSave, mapSave, null, sn, fileSize, null, applyDate, Integer.toString(evidenceSaveService.getSaveTime()), saveFactor));
            log.error("saveTime time is [" + (System.currentTimeMillis() - saveTime) + "]");
        }
        if ((int) result.get("status") == 1) {
        } else {
            basicInformation.setEvidenceStatus(0);
            if (StringUtils.isEmpty(basicInformation.getFailureReason())) {
                if (result.get("message") != null) {
                    basicInformation.setFailureReason(result.get("message").toString());
                }
            } else {
                if (result.get("message") != null) {
                    basicInformation.setFailureReason(basicInformation.getFailureReason() + "," + result.get("message").toString());
                }
            }
        }
        objs.add(basicInformation);
        // 记录计费流水
        if ((int) mapCharging.get("retCode") == 1) {
            Map<String, Object> mapStoreCg = storeChargingService.storeCharging(appService.getServiceConfigName(), appService.getServiceConfigId(), applicationInfo, appService, null, "EvidenceBasicInformation", evidenceSaveService.getBaseSpace(), EvidenceSaveServiceApi.getSize(fileSize), StringUtils.isBlank(evidenceSn), sn);
            // + ",totalSize__ : " + EvidenceSaveServiceApi.getSize(fileSize));
            if ((int) mapStoreCg.get("retCode") != 1) {
                result.put("status", -4);
                result.put("message", "服务计费失败");
                return result;
            }
        }
        boolean l = false;
        for (Object o : objs) {
            if (o == null)
                l = true;
        }
        log.error("objs count is [" + objs.size() + "]" + ", objsIncNull is" + l);
        queueThread.putListQueue(objs);
    } catch (Exception e) {
        e.printStackTrace();
        if (null == info) {
            info = "系统处理异常!";
        }
        LogUtil.evidencelog(sqlSession, sn, "存证接口", "存证失败,证据编号:" + sn + ", 失败原因:" + e.toString());
        result.put("status", -5);
        result.put("message", "系统服务错误,请联系管理员");
        return result;
    } finally {
        result.remove("saveFactor");
        result.remove("basicInformation");
    }
    return result;
}
Also used : AppService(com.itrus.portal.db.AppService) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) EvidenceSavePackageTask(com.itrus.portal.evidence.controller.threeAppAPIService.EvidenceSavePackageTask) Date(java.util.Date) EvidenceServiceConfiguration(com.itrus.portal.db.EvidenceServiceConfiguration) JSONObject(com.alibaba.fastjson.JSONObject) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) ArrayList(java.util.ArrayList) EvidenceClientSignature(com.itrus.portal.db.EvidenceClientSignature)

Example 4 with EvidenceClientSignature

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

the class EvidenceSaveTask method saveBody.

// private AtomicInteger counter = new AtomicInteger(0);
// private static final String CERT_VERIFY = "/cert/verify";
// 验证pdf文档签章
// private static final String PDF_VERIFY = "/pdf/verify";
// private Map<String, Object> result;
// private ApplicationInfo applicationInfo;
// private AppService appService;
// private EvidenceSaveService evidenceSaveService;
// private Date applyDate;
// private String evidenceSn;
// private String genSn;
// private String signedBase64;
// private String evidencePackage;
// private String hashAlg;
// private String hashvalue;
// private Date dateVp;
// private Date dateVc;
// private List<String> certs;
// private RealNameAuthentication realNameAuthentication;
// private RealNameAuthentication realNameAuthenticationTime;
// private RealNameAuthentication realNameAuthenticationOss;
// private Map<String, Object> mapCharging;
// private static EvidenceSaveTask evidenceSaveTask;
// public static EvidenceSaveTask getInstance() {
// if(evidenceSaveTask == null) {
// synchronized (EvidenceSaveTask.class) {
// evidenceSaveTask = new EvidenceSaveTask();
// }
// }
// return evidenceSaveTask;
// }
// public EvidenceSaveTask () {
// super();
// }
// private ScheduledTask scheduledTask = SpringContextHolder.getBean(ScheduledTask.class);
// public EvidenceSaveTask(Map<String, Object> result, ApplicationInfo applicationInfo, AppService appService,
// EvidenceSaveService evidenceSaveService,  Date applyDate, String evidenceSn, String genSn,
// String signedBase64, String evidencePackage, String hashAlg, String hashvalue, Date dateVp,
// Date dateVc, List<String> certs, RealNameAuthentication realNameAuthentication,
// RealNameAuthentication realNameAuthenticationTime, RealNameAuthentication realNameAuthenticationOss,
// Map<String, Object> mapCharging) {
// this.result = result;
// this.applicationInfo = applicationInfo;
// this.appService = appService;
// this.evidenceSaveService = evidenceSaveService;
// this.applyDate = applyDate;
// this.evidenceSn = evidenceSn;
// this.genSn = genSn;
// this.signedBase64 = signedBase64;
// this.evidencePackage = evidencePackage;
// this.hashAlg = hashAlg;
// this.hashvalue = hashvalue;
// this.dateVp = dateVp;
// this.dateVc = dateVc;
// this.certs = certs;
// this.realNameAuthentication = realNameAuthentication;
// this.realNameAuthenticationTime = realNameAuthenticationTime;
// this.realNameAuthenticationOss = realNameAuthenticationOss;
// this.mapCharging = mapCharging;
// }
/**
 * 删除证件包
 * @param fileName
 * @return
 * @throws Exception
 */
// public boolean deleteEvidence(String fileName) throws Exception{
// try {
// File file = new File(systemConfigService.getpdfurl(), fileName);
// if(file.exists()) {
// return file.delete();
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// return false;
// }
/**
 * 核验处理方法
 * @param result
 * 			返回值
 * @param applicationInfo
 * 			应用
 * @param evidenceSaveService
 * 			服务配置
 * @param evidenceSn
 * 			证据编号
 * @param signedBase64
 * 			签名值
 * @param evidencePackage
 * 			证据包
 * @return
 * @throws Exception
 */
public Map<String, Object> saveBody(Map<String, Object> result, ApplicationInfo applicationInfo, AppService appService, EvidenceSaveService evidenceSaveService, Date applyDate, String evidenceSn, String genSn, String signedBase64, String evidencePackage, String hashAlg, String hashvalue, Date dateVp, Date dateVc, List<String> certs, RealNameAuthentication realNameAuthentication, RealNameAuthentication realNameAuthenticationTime, RealNameAuthentication realNameAuthenticationOss, Map<String, Object> mapCharging) throws Exception {
    List<Object> objs = new ArrayList<Object>();
    String info = null;
    // 证据服务记录
    EvidenceBasicInformation basicInformation = null;
    // 本次证据包大小
    int fileSize = evidencePackage.getBytes().length;
    // 定义一个证据的提交次数
    int count = 0;
    try {
        // 定义时间戳固定时间
        // Date genTime = null;
        String failureReason = null;
        JSONObject jsonEvidenceContent = JSONObject.parseObject(evidencePackage);
        // 定义证书固定服务配置
        EvidenceServiceConfiguration serviceConfiguration = null;
        // 定义证书固定服务配置
        serviceConfiguration = CacheCustomer.getEVIDENCE_SERVICE_CONFIG();
        if (serviceConfiguration == null) {
            // 得到证书固定服务配置
            List<EvidenceServiceConfiguration> serviceconfig = sqlSession.selectList("com.itrus.portal.db.EvidenceServiceConfigurationMapper.selectByExample");
            if (!serviceconfig.isEmpty()) {
                serviceConfiguration = serviceconfig.get(0);
                CacheCustomer.setEVIDENCE_SERVICE_CONFIG(serviceConfiguration);
            } else {
                result.put("status", -22);
                result.put("message", "缺少服务配置");
                return result;
            }
        }
        // 验签信息入库
        EvidenceClientSignature clientSignature = new EvidenceClientSignature();
        clientSignature.setHashAlgorithm(hashAlg);
        clientSignature.setHashvalue(hashvalue);
        clientSignature.setName("0");
        // ---- 关联证书
        clientSignature.setCertId(Long.parseLong(applicationInfo.getCertBase64()));
        clientSignature.setSignatureType("2");
        clientSignature.setIdentiType("1");
        clientSignature.setSignaturevalue(signedBase64);
        clientSignature.setCreateTime(dateVp);
        // clientSignature.setCreateTimeMs(applyDate.getTime());
        if (StringUtils.isNotEmpty(evidenceSn))
            clientSignature.setEvidenceSn(evidenceSn);
        else
            clientSignature.setEvidenceSn(genSn);
        // queueThread.putObjectQueue(clientSignature);
        objs.add(clientSignature);
        clientSignature = null;
        // 密钥别名定义
        String alias = null;
        // 判断是否需要签名或时间戳
        if (evidenceSaveService.getFixationWay() != null && evidenceSaveService.getFixationWay() != 1) {
            // 判断是否需要签名
            if (evidenceSaveService.getFixationWay() == 2 || evidenceSaveService.getFixationWay() == 4) {
                // 定义签名参数
                Map<String, Object> param = new HashMap<String, Object>();
                String url = null;
                // 判断签名类型配置是否为空
                if (StringUtils.isNotBlank(serviceConfiguration.getSignatureType())) {
                    // 得到配置证书
                    EvidenceCertificate evidenceCertificate = null;
                    evidenceCertificate = CacheCustomer.getEVIDENCE_CERTIFICATE_MAP().get((long) serviceConfiguration.getSignatureCertificate());
                    if (evidenceCertificate == null) {
                        evidenceCertificate = certificateService.selectById((long) serviceConfiguration.getSignatureCertificate());
                    }
                    // 得到服务配置的签名证书的密钥别名
                    alias = CacheCustomer.getMAP_COMFIG().get((long) serviceConfiguration.getSignatureCertificate());
                    if (StringUtils.isEmpty(alias)) {
                        alias = secretKeyService.getAliasByCertId((long) serviceConfiguration.getSignatureCertificate());
                    }
                    // 配置签名url 和 参数   1.裸签名  2.p7分离式签名  3.p7非分离式签名  (本期只做2)
                    switch(Integer.parseInt(serviceConfiguration.getSignatureType())) {
                        case 1:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("contentType", "CT_HASH");
                            url = realNameAuthentication.getRealNameddress() + SIGNATURE_SIGN;
                            break;
                        case 2:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("detached", true);
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + P7_SIGN;
                            break;
                        case 3:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("detached", false);
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + P7_SIGN;
                            break;
                    }
                    // 异步处理p7签名
                    // HttpAsyncClientUtil.getInstance().execute(
                    // url,
                    // AuthService.getHeader(),
                    // param,
                    // new EvidenceSignTask(
                    // url,
                    // param,
                    // evidenceSn!=null?evidenceSn:genSn,
                    // Long.parseLong(evidenceCertificate.getCert())));
                    String strP7 = null;
                    try {
                        // strP7 = clientService.postForm(url, AuthService.getHeader(), param);
                        strP7 = OkHttpClientManagerSign.post(url, AuthService.getHeader().get("Authorization").toString(), param);
                    } catch (Exception e) {
                        e.printStackTrace();
                        LogUtil.evidencelog(sqlSession, (evidenceSn != null ? evidenceSn : genSn).toString(), "存证接口_天威签名", "天威签名失败,证据编号:" + (evidenceSn != null ? evidenceSn : genSn).toString() + ", 请求参数:" + param.toString() + ", 请求地址:" + url + ", 返回结果:" + strP7 + ", 失败原因:" + e.toString());
                        // TODO: handle exception
                        result.put("status", 0);
                        result.put("message", "天威签名失败");
                        return result;
                    }
                    // log.error("strP7 : " + strP7);
                    JSONObject jsonRepP7Sign = JSONObject.parseObject(strP7);
                    if (jsonRepP7Sign.getIntValue("code") != 0) {
                        // 天威签名失败
                        LogUtil.evidencelog(sqlSession, (evidenceSn != null ? evidenceSn : genSn).toString(), "存证接口_天威签名", "天威签名失败,证据编号:" + (evidenceSn != null ? evidenceSn : genSn).toString() + ", 请求参数:" + param.toString() + ", 请求地址:" + url + ", 返回结果:" + strP7 + ", 失败原因:" + jsonRepP7Sign.getString("message"));
                        result.put("status", 0);
                        result.put("message", "天威签名失败");
                        return result;
                    } else {
                        // 天威签名服务记录入库
                        EvidenceClientSignature signature = new EvidenceClientSignature();
                        signature.setHashAlgorithm(param.get("hashAlg").toString());
                        signature.setName("1");
                        signature.setEvidenceSn(evidenceSn != null ? evidenceSn : genSn);
                        signature.setSignatureType("2");
                        signature.setCertId(Long.parseLong(evidenceCertificate.getCert()));
                        signature.setHashvalue(param.get("content").toString());
                        signature.setSignaturevalue(jsonRepP7Sign.getString("signedData"));
                        signature.setCreateTime(new Date());
                        // signature.setCreateTimeMs(applyDate.getTime());
                        objs.add(signature);
                    }
                    evidenceCertificate = null;
                }
            }
            // 判断是否需要签名时间戳
            if (evidenceSaveService.getFixationWay() == 3 || evidenceSaveService.getFixationWay() == 4) {
                // 对证据包HASH
                String plainHash = HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage);
                // 异步处理时间戳   ---  本期是实现新版本接口
                Map<String, Object> retTime = EvidenceSaveServiceApi.genTimeStamp(realNameAuthenticationTime, plainHash, serviceConfiguration.getArithmetic(), evidenceSn != null ? evidenceSn : genSn, null);
                if (!(boolean) retTime.get("retStatus") && retTime.get("obj") != null) {
                    result.put("status", 0);
                    result.put("message", "天威时间戳签名失败");
                    return result;
                }
                objs.add(retTime.get("obj"));
            }
        }
        alias = null;
        Map<String, Object> retSaveMap = new HashMap<String, Object>();
        // 判断证据编号是否为空   true -> 证据编码为空 代表第一次存证   ,false ->证据编码不为空 代表不是第一次存证
        if (StringUtils.isEmpty(evidenceSn)) {
            basicInformation = new EvidenceBasicInformation();
            basicInformation.setReceiptStatus(0);
            basicInformation.setStatus(0);
            basicInformation.setIsCallback(0);
            basicInformation.setCreateTime(new Date());
            // basicInformation.setCreateTimeMs(applyDate.getTime());
            basicInformation.setEndTime(EvidenceSaveServiceApi.convertDate(evidenceSaveService.getSaveTime()));
            basicInformation.setEvidenceSize(fileSize);
            basicInformation.setEvidenceSn(genSn);
            basicInformation.setAppService(appService.getId());
            basicInformation.setEvidenceStatus(1);
            basicInformation.setApplicationInfo(applicationInfo.getId());
            basicInformation.setOutAppService(evidenceSaveService.getAppServiceName());
            basicInformation.setSaveServiceNmae(appService.getAppServiceName());
            basicInformation.setServicePlatformName(applicationInfo.getName());
            basicInformation.setServiceClientName(applicationInfo.getServiceClientName());
            basicInformation.setServiceClientId(applicationInfo.getServiceClientId());
            if (StringUtils.isNotEmpty(failureReason)) {
                basicInformation.setFailureReason(failureReason);
                basicInformation.setEvidenceStatus(0);
                result.put("status", 0);
            }
            // 对要素 (接收 核验 必填) 操作进行处理
            retSaveMap = saveFactor(retSaveMap, evidenceSaveService, genSn, jsonEvidenceContent, basicInformation, realNameAuthentication, realNameAuthenticationOss, serviceConfiguration, true);
        } else {
            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.size() == 0 || basicInformationList.isEmpty()) {
                result.put("status", 0);
                result.put("message", "未找到对应证据编号信息");
                return result;
            }
            basicInformation = basicInformationList.get(0);
            if (basicInformation.getEvidenceStatus() != null && basicInformation.getEvidenceStatus() == 0) {
                result.put("status", 0);
                result.put("message", "本次证据补交失败。对应证据编号已存在核验失败信息,原因:" + basicInformation.getFailureReason());
                return result;
            }
            // 得到提交次数
            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);
            if (!enclosures.isEmpty()) {
                count = enclosures.size();
            }
            basicInformation.setEvidenceSize(basicInformation.getEvidenceSize() + fileSize);
            basicInformation.setAppService(appService.getId());
            // 对要素 (接收 核验) 操作进行处理
            retSaveMap = saveFactor(retSaveMap, evidenceSaveService, evidenceSn, jsonEvidenceContent, basicInformation, realNameAuthentication, realNameAuthenticationOss, serviceConfiguration, false);
        }
        String saveFactor = null;
        if (retSaveMap.get("status") != null) {
            result.put("status", retSaveMap.get("status"));
            result.put("message", retSaveMap.get("message"));
            return result;
        } else {
            List<Object> lists = (List<Object>) retSaveMap.get("objs");
            for (Object obj : lists) {
                objs.add(obj);
            }
        }
        basicInformation = (EvidenceBasicInformation) retSaveMap.get("basicInformation");
        if (basicInformation.getEvidenceStatus() != null && basicInformation.getEvidenceStatus() == 0) {
            result.put("status", 0);
            result.put("message", basicInformation.getEvidenceStatus());
            return result;
        }
        // 得到加密证书别名
        alias = CacheCustomer.getMAP_COMFIG().get((long) serviceConfiguration.getEncryptionCertificate());
        if (StringUtils.isEmpty(alias)) {
            alias = secretKeyService.getAliasByCertId((long) serviceConfiguration.getEncryptionCertificate());
        }
        // 内部加密存储证据包
        String urlSave = realNameAuthentication.getRealNameddress() + "/storage/save";
        Map<String, Object> mapSave = new HashMap<String, Object>();
        mapSave.put("type", "ST_E");
        mapSave.put("bucketName", realNameAuthenticationOss.getKeyCode());
        mapSave.put("objectName", applicationInfo.getServiceClientId() + "/" + (StringUtils.isEmpty(evidenceSn) ? genSn : evidenceSn) + (count + 1));
        mapSave.put("contentType", "CT_BASE64_DATA");
        mapSave.put("content", Base64.encode(evidencePackage.getBytes("utf-8")));
        mapSave.put("alias", alias);
        mapSave.put("digestZValue", false);
        mapSave.put("encAlg", serviceConfiguration.getEncryptionAlgorithm());
        if (result.get("saveFactor") != null) {
            saveFactor = retSaveMap.get("saveFactor").toString();
        }
        // 异步处理存储
        // HttpAsyncClientUtil.getInstance().execute(
        // urlSave,
        // AuthService.getHeader(),
        // mapSave,
        // new EvidenceSavePackageTask(
        // urlSave,
        // mapSave,
        // null,
        // evidenceSn!=null?evidenceSn:genSn,
        // Integer.toString(fileSize),
        // genTime,
        // applyDate,
        // Integer.toString(evidenceSaveService.getSaveTime()),
        // saveFactor));
        // String retSave = clientService.postForm(urlSave, AuthService.getHeader(), mapSave);
        String retSave = null;
        try {
            retSave = OkHttpClientManagerSave.post(urlSave, AuthService.getHeader().get("Authorization").toString(), mapSave);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            LogUtil.evidencelog(sqlSession, (evidenceSn != null ? evidenceSn : genSn).toString(), "存证接口_存储数据包", "存储数据包失败,证据编号:" + (evidenceSn != null ? evidenceSn : genSn).toString() + ", 请求参数:" + mapSave.toString() + ", 请求地址:" + urlSave + ",返回结果" + retSave + ", 失败原因:" + e.toString());
            result.put("status", 0);
            result.put("message", "证据存储失败");
            return result;
        }
        JSONObject jsonSave = JSONObject.parseObject(retSave);
        if (jsonSave.getIntValue("code") != 0) {
            // 天威签名失败
            LogUtil.evidencelog(sqlSession, (evidenceSn != null ? evidenceSn : genSn).toString(), "存证接口_存储数据包", "存储数据包失败,证据编号:" + (evidenceSn != null ? evidenceSn : genSn).toString() + ", 请求参数:" + mapSave.toString() + ", 请求地址:" + urlSave + ",返回结果" + retSave + ", 失败原因:" + jsonSave);
            result.put("status", 0);
            result.put("message", "证据存储失败");
            return result;
        } else {
            EvidenceEnclosure enclosure = new EvidenceEnclosure();
            enclosure.setBuid(jsonSave.getString("buid"));
            enclosure.setEvidenceSn((evidenceSn != null ? evidenceSn : genSn).toString());
            enclosure.setFilesize(Integer.toString(fileSize));
            enclosure.setPdfType("1");
            enclosure.setApplicationTime(applyDate);
            enclosure.setCreateTime(new Date());
            // enclosure.setCreateTimeMs(applyDate.getTime());
            enclosure.setSaveTime(Integer.toString(evidenceSaveService.getSaveTime()));
            if (mapSave.get("type") != null)
                enclosure.setType(mapSave.get("type").toString());
            if (mapSave.get("contentType") != null)
                enclosure.setContentType(mapSave.get("contentType").toString());
            if (mapSave.get("bucketName") != null)
                enclosure.setBucketName(mapSave.get("bucketName").toString());
            if (mapSave.get("objectName") != null)
                enclosure.setObjectName(mapSave.get("objectName").toString());
            if (mapSave.get("alias") != null)
                enclosure.setAlias(mapSave.get("alias").toString());
            enclosure.setFixationTime(new Date());
            if (saveFactor != null) {
                enclosure.setSaveFactor(saveFactor);
            }
            // queueThread.putObjectQueue(enclosure);
            objs.add(enclosure);
        }
        // 判断是否为补交
        if (count > 0) {
            // 判断是否出过证据, true : 修改出证状态为部分出  ; 出证状态:0未出1待出2已出 3部分出 4出证失败
            if (basicInformation.getStatus() == 2) {
                basicInformation.setStatus(3);
            }
        }
        // }
        if ((int) result.get("status") == 1) {
        // 判断是否需要生成存在回执
        // if(evidenceSaveService.getAppServiceName() != null) {
        // // 生成存证回执报告 查询存证时
        // Map<String, Object> mapRet = reportTemplate.returnreceipt(basicInformation.getEvidenceSn(), applicationInfo);
        // if(mapRet.get("status") != null && (int)mapRet.get("status") == 0) {
        // basicInformation.setReceiptStatus(1);//存证回执状态1已出0未出
        // } else {
        // //    throw new Exception("生成存证回执报告失败," + mapRet.get("message"));
        // }
        // }
        // EvidenceSubmitDateExample dateExample = new EvidenceSubmitDateExample();
        // EvidenceSubmitDateExample.Criteria criteria = dateExample.createCriteria();
        // if(StringUtils.isNotBlank(evidenceSn))
        // criteria.andEvidenceSnEqualTo(evidenceSn);
        // else
        // criteria.andEvidenceSnEqualTo(genSn);
        // sqlSession.delete("com.itrus.portal.db.EvidenceClientTimeStampMapper.deleteByExample", dateExample);
        } else {
            basicInformation.setEvidenceStatus(0);
            if (StringUtils.isEmpty(basicInformation.getFailureReason())) {
                if (result.get("message") != null) {
                    basicInformation.setFailureReason(result.get("message").toString());
                }
            } else {
                if (result.get("message") != null) {
                    basicInformation.setFailureReason(basicInformation.getFailureReason() + "," + result.get("message").toString());
                }
            }
        }
        // queueThread.putObjectQueue(basicInformation);
        objs.add(basicInformation);
        queueThread.putListQueue(objs);
        // 记录计费流水
        if ((int) mapCharging.get("retCode") == 1) {
            // log.error("计费次数:" + counter.getAndIncrement());
            // log.error("【计费】");
            Map<String, Object> mapStoreCg = storeChargingService.storeCharging(appService.getServiceConfigName(), appService.getServiceConfigId(), applicationInfo, appService, null, "EvidenceBasicInformation", evidenceSaveService.getBaseSpace(), EvidenceSaveServiceApi.getSize(fileSize), StringUtils.isBlank(evidenceSn), (evidenceSn != null ? evidenceSn : genSn).toString());
            // + ",totalSize__ : " + EvidenceSaveServiceApi.getSize(fileSize));
            if ((int) mapStoreCg.get("retCode") != 1) {
                result.put("status", -4);
                result.put("message", "服务计费失败");
                return result;
            }
        }
    // sqlSession.update("com.itrus.portal.db.EvidenceBasicInformationMapper.updateByPrimaryKey", basicInformation);
    // sqlSession.flushStatements();
    // if((int)result.get("status") == 1) {
    // LogUtil.evidencelog(sqlSession, "存证接口", "存证基础信息保存成功,证据编号:" + basicInformation.getEvidenceSn());
    // } else {
    // LogUtil.evidencelog(sqlSession, "存证接口", "存证失败,详情:"+ basicInformation.getEvidenceSn()
    // + basicInformation.getFailureReason());
    // }
    } catch (Exception e) {
        e.printStackTrace();
        if (null == info) {
            info = "系统处理异常!";
        }
        // StackTraceElement stackTraceElement = e.getStackTrace()[e.getStackTrace().length-2];
        // info = stackTraceElement.getClassName() + stackTraceElement.getLineNumber() + e.toString();
        LogUtil.evidencelog(sqlSession, (evidenceSn != null ? evidenceSn : genSn).toString(), "存证接口", "存证失败,证据编号:" + (evidenceSn != null ? evidenceSn : genSn).toString() + ", 失败原因:" + e.toString());
        result.put("status", -5);
        result.put("message", "系统服务错误,请联系管理员");
        return result;
    } finally {
        result.remove("saveFactor");
        result.remove("basicInformation");
    }
    return result;
}
Also used : EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) Date(java.util.Date) EvidenceBasicInformationExample(com.itrus.portal.db.EvidenceBasicInformationExample) EvidenceServiceConfiguration(com.itrus.portal.db.EvidenceServiceConfiguration) JSONObject(com.alibaba.fastjson.JSONObject) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) JSONObject(com.alibaba.fastjson.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) EvidenceClientSignature(com.itrus.portal.db.EvidenceClientSignature)

Example 5 with EvidenceClientSignature

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

the class EvidenceSignTask method saveSign.

// 入库方法
private void saveSign(String data) {
    try {
        JSONObject jsonRepP7Sign = JSONObject.parseObject(data);
        if (jsonRepP7Sign.getIntValue("code") != 0) {
            // 天威签名失败
            LogUtil.evidencelog(sqlSession, sn.toString(), "存证接口_存储签名值", "存储签名值失败,证据编号:" + sn.toString() + ", 失败原因:" + jsonRepP7Sign.getString("message"));
        } else {
            // 存储天威签名服务记录
            EvidenceClientSignature signature = new EvidenceClientSignature();
            signature.setHashAlgorithm(param.get("hashAlg").toString());
            signature.setName("1");
            signature.setEvidenceSn(sn);
            signature.setSignatureType("2");
            signature.setCertId(certId);
            signature.setHashvalue(param.get("content").toString());
            signature.setSignaturevalue(jsonRepP7Sign.getString("signedData"));
            signature.setCreateTime(new Date());
            queueThread.putObjectQueue(signature);
        }
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Date(java.util.Date) IOException(java.io.IOException) EvidenceClientSignature(com.itrus.portal.db.EvidenceClientSignature)

Aggregations

EvidenceClientSignature (com.itrus.portal.db.EvidenceClientSignature)8 EvidenceBasicInformation (com.itrus.portal.db.EvidenceBasicInformation)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 EvidenceEnclosure (com.itrus.portal.db.EvidenceEnclosure)6 List (java.util.List)6 EvidenceClientTimeStamp (com.itrus.portal.db.EvidenceClientTimeStamp)5 EvidenceEnclosureExample (com.itrus.portal.db.EvidenceEnclosureExample)5 EvidenceMainInformation (com.itrus.portal.db.EvidenceMainInformation)5 JSONObject (com.alibaba.fastjson.JSONObject)4 AppService (com.itrus.portal.db.AppService)4 EvidenceBasicInformationExample (com.itrus.portal.db.EvidenceBasicInformationExample)4 EvidenceCert (com.itrus.portal.db.EvidenceCert)4 EvidenceCheck (com.itrus.portal.db.EvidenceCheck)4 EvidenceCheckExample (com.itrus.portal.db.EvidenceCheckExample)4 EvidenceCompaniesSubmit (com.itrus.portal.db.EvidenceCompaniesSubmit)4 EvidenceDesireIdentify (com.itrus.portal.db.EvidenceDesireIdentify)4 EvidenceEventBehavior (com.itrus.portal.db.EvidenceEventBehavior)4 EvidenceEventContent (com.itrus.portal.db.EvidenceEventContent)4 EvidenceEventDesire (com.itrus.portal.db.EvidenceEventDesire)4