Search in sources :

Example 6 with EvidenceRealNameExample

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

the class BasicInformationController method loadImg.

/**
 * 得到图片
 *
 * @param type1
 *            企业 个人
 * @param type2
 *            代理人 法定代表人
 * @param id
 * @param response
 * @return
 */
@RequestMapping(value = "/img/{type1}/{type2}/{id}")
public String loadImg(@PathVariable("type1") int type1, @PathVariable("type2") int type2, @PathVariable("id") Long id, HttpServletResponse response) {
    String img = null;
    String img1 = null;
    OutputStream os = null;
    FileInputStream fis = null;
    File file = null;
    try {
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        if (type1 == 1) {
            EvidenceCompaniesSubmit companiesSubmit = sqlSession.selectOne("com.itrus.portal.db.EvidenceCompaniesSubmitMapper.selectByPrimaryKey", id);
            String cid = companiesSubmit.getIdCode();
            EvidenceRealNameExample real = new EvidenceRealNameExample();
            EvidenceRealNameExample.Criteria nameEx = real.createCriteria();
            nameEx.andCompaniesSubmitEqualTo(cid);
            EvidenceRealName erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", real);
            // erealname.getEvidenceEnclosure());
            if (type2 == 1) {
                img = companiesSubmit.getPhotoCodeImg();
            }
            if (type2 == 2) {
                img = companiesSubmit.getInformationImg();
            }
            if (type2 == 3) {
                EvidenceRepresentative repseentative = sqlSession.selectOne("com.itrus.portal.db.EvidenceRepresentativeMapper.selectByPrimaryKey", companiesSubmit.getRepresentative());
                img = repseentative.getInformationImg();
            }
            if (type2 == 4) {
                EvidenceRepresentative repseentative = sqlSession.selectOne("com.itrus.portal.db.EvidenceRepresentativeMapper.selectByPrimaryKey", companiesSubmit.getRepresentative());
                img = repseentative.getPhotoCodeImg();
            }
            if (type2 == 5) {
                EvidenceTheAgent theagent = sqlSession.selectOne("com.itrus.portal.db.EvidenceTheAgentMapper.selectByPrimaryKey", companiesSubmit.getTheAgent());
                img = theagent.getInformationImg();
            }
            if (type2 == 6) {
                EvidenceTheAgent theagent = sqlSession.selectOne("com.itrus.portal.db.EvidenceTheAgentMapper.selectByPrimaryKey", companiesSubmit.getTheAgent());
                img = theagent.getPhotoCodeImg();
            }
            file = filePathUtils.getBillFile(erealname.getEvidenceSn());
        }
        if (type1 == 2) {
            EvidenceIndividual indiv = sqlSession.selectOne("com.itrus.portal.db.EvidenceIndividualMapper.selectByPrimaryKey", id);
            String cid = indiv.getIdCode();
            EvidenceRealNameExample real = new EvidenceRealNameExample();
            EvidenceRealNameExample.Criteria nameEx = real.createCriteria();
            nameEx.andIndividualEqualTo(cid);
            EvidenceRealName erealname = sqlSession.selectOne("com.itrus.portal.db.EvidenceRealNameMapper.selectByExample", real);
            /*EvidenceEnclosure enclosure = sqlSession.selectOne(
						"com.itrus.portal.db.EvidenceEnclosureMapper.selectByPrimaryKey",
						erealname.getEvidenceEnclosure());*/
            EvidenceEnclosureExample enclou = new EvidenceEnclosureExample();
            EvidenceEnclosureExample.Criteria sure = enclou.createCriteria();
            // sure.andBasicInformationEqualTo(id);
            sure.andEvidenceSnEqualTo(erealname.getEvidenceSn());
            // sure.andPdfTypeEqualTo("1");
            EvidenceEnclosure enclosure = sqlSession.selectOne("com.itrus.portal.db.EvidenceEnclosureMapper.selectByExample", enclou);
            if (type2 == 1) {
                img = indiv.getPhotoCodeImg();
            }
            if (type2 == 2) {
                img = indiv.getInformationImg();
            }
            file = filePathUtils.getBillFile(enclosure.getEvidenceSn());
        }
        if (img == null) {
            return "status403";
        }
        if (!file.exists()) {
            file.mkdir();
        }
        File imgFile = new File(file, img);
        fis = new FileInputStream(imgFile);
        byte[] bb = IOUtils.toByteArray(fis);
        os = response.getOutputStream();
        os.write(bb);
        os.flush();
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        // 关闭流!
        try {
            if (null != fis) {
                fis.close();
            }
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
    return null;
}
Also used : EvidenceIndividual(com.itrus.portal.db.EvidenceIndividual) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) EvidenceEnclosureExample(com.itrus.portal.db.EvidenceEnclosureExample) EvidenceEnclosure(com.itrus.portal.db.EvidenceEnclosure) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) EvidenceRealName(com.itrus.portal.db.EvidenceRealName) JSONException(org.json.JSONException) IOException(java.io.IOException) EvidenceTheAgent(com.itrus.portal.db.EvidenceTheAgent) EvidenceRepresentative(com.itrus.portal.db.EvidenceRepresentative) File(java.io.File) EvidenceCompaniesSubmit(com.itrus.portal.db.EvidenceCompaniesSubmit) EvidenceRealNameExample(com.itrus.portal.db.EvidenceRealNameExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EvidenceCompaniesSubmit (com.itrus.portal.db.EvidenceCompaniesSubmit)6 EvidenceEnclosure (com.itrus.portal.db.EvidenceEnclosure)6 EvidenceEnclosureExample (com.itrus.portal.db.EvidenceEnclosureExample)6 EvidenceIndividual (com.itrus.portal.db.EvidenceIndividual)6 EvidenceRealName (com.itrus.portal.db.EvidenceRealName)6 EvidenceRealNameExample (com.itrus.portal.db.EvidenceRealNameExample)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 EvidenceBasicInformation (com.itrus.portal.db.EvidenceBasicInformation)5 EvidenceDesireIdentify (com.itrus.portal.db.EvidenceDesireIdentify)5 EvidenceDesireIdentifyExample (com.itrus.portal.db.EvidenceDesireIdentifyExample)5 PersonalNameExample (com.itrus.portal.db.PersonalNameExample)5 RealNameRecord (com.itrus.portal.db.RealNameRecord)5 RealNameRecordExample (com.itrus.portal.db.RealNameRecordExample)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 EvidenceEventBehavior (com.itrus.portal.db.EvidenceEventBehavior)4 EvidenceEventBehaviorExample (com.itrus.portal.db.EvidenceEventBehaviorExample)4 EvidenceEventContent (com.itrus.portal.db.EvidenceEventContent)4 EvidenceEventDesire (com.itrus.portal.db.EvidenceEventDesire)4