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;
}
Aggregations