/**
  * @Title: queryPtryzpSingle @Description: TODO(根据来源表名与来源ID查询照片)
  *
  * @param @param entity
  * @param @return 设定文件
  * @return HttpEntity<byte[]> 返回类型
  * @throws
  */
 @RestfulAnnotation(serverId = "33", valiField = "lybm,lyid,ryid")
 @RequestMapping(value = "/single", method = RequestMethod.GET)
 public @ResponseBody String queryPtryzpSingle(ZpfjPtryzpglb entity) {
   //		HttpHeaders headers = new HttpHeaders();
   //		headers.setContentType(MediaType.IMAGE_JPEG);
   ZpfjPtryzpxxb zpfjPtryzpxxb = zpfjPtryzpService.queryPtryzpSingle(entity);
   if (zpfjPtryzpxxb != null
       && zpfjPtryzpxxb.getZp() != null
       && zpfjPtryzpxxb.getZp().length > 0) {
     //			headers.setContentLength(zpfjPtryzpxxb.getZp().length);
     return base64Edcoder(zpfjPtryzpxxb.getZp());
   } else {
     //			if ("111".equals(entity.getCyzjdm()) //调用公安请求服务,暂时不用 2015-3-27
     //					|| "112".equals(entity.getCyzjdm())
     //					|| "335".equals(entity.getCyzjdm())) {
     //				SessionBean sessionBean = getSessionBean();
     //				CzrkRequestService czrkRequestService = new CzrkRequestService();
     //				CzrkResult result = czrkRequestService.selectCzrk(entity.getZjhm(), true);
     //				if (result != null && !StringUtils.isBlank(result.getXP())) {
     //					byte[] pictureByte = null;
     //					try {
     //						pictureByte = new BASE64Decoder().decodeBuffer(result
     //								.getXP());
     //					} catch (Exception ex) {
     //						byte[] empty_ryzp = SystemConfig.getByteArray("empty_ryzp");
     //						headers.setContentLength(empty_ryzp.length);
     //						return new HttpEntity(empty_ryzp, headers);
     //					}
     //					if (pictureByte != null) {
     //						ZpfjPtryzpxxb zpfjPtryzpxxb1 = new ZpfjPtryzpxxb();
     //						zpfjPtryzpxxb1.setZp(pictureByte);
     //						try {
     //							zpfjPtryzpxxb1.setZpslt(ImageUtils
     //									.convertImageSize(pictureByte, 179, 220,
     //											false));
     //						} catch (Exception e) {
     //							e.printStackTrace();
     //						}
     //						ZpfjPtryzpglb zpfjPtryzpglb = new ZpfjPtryzpglb();
     //						zpfjPtryzpglb.setRyid(entity.getRyid());
     //						zpfjPtryzpglb.setLybm("人员基本信息表");
     //						zpfjPtryzpglb.setLyid(entity.getRyid());
     //						zpfjPtryzpglb.setLyms("RK_RYJBXXB");
     //						zpfjPtryzpService.savePtryzpxxb(zpfjPtryzpglb,
     //								zpfjPtryzpxxb1, sessionBean);
     //						headers.setContentLength(pictureByte.length);
     //						return new HttpEntity(pictureByte, headers);
     //					}
     //				}
     //			}
     byte[] empty_ryzp = SystemConfig.getByteArray("empty_ryzp");
     //			headers.setContentLength(empty_ryzp.length);
     return base64Edcoder(empty_ryzp);
   }
 }
 /**
  * @Title: queryPtryzpsltSingle @Description: TODO(根据来源表名与来源ID查询照片缩略图)
  *
  * @param @param entity
  * @param @return 设定文件
  * @return HttpEntity<byte[]> 返回类型
  * @throws
  */
 @RequestMapping(value = "/single/small", method = RequestMethod.GET)
 public @ResponseBody String queryPtryzpsltSingle(ZpfjPtryzpglb entity) {
   //		HttpHeaders headers = new HttpHeaders();
   //		headers.setContentType(MediaType.IMAGE_JPEG);
   ZpfjPtryzpxxb zpfjPtryzpxxb = zpfjPtryzpService.queryPtryzpsltSingle(entity);
   if (zpfjPtryzpxxb != null
       && zpfjPtryzpxxb.getZpslt() != null
       && zpfjPtryzpxxb.getZpslt().length > 0) {
     //			headers.setContentLength(zpfjPtryzpxxb.getZpslt().length);
     return base64Edcoder(zpfjPtryzpxxb.getZpslt());
   } else {
     byte[] empty_ryzp = SystemConfig.getByteArray("empty_ryzp");
     //			headers.setContentLength(empty_ryzp.length);
     return base64Edcoder(empty_ryzp);
   }
 }
 /**
  * @Title: save @Description: TODO(照片上传) JSON格式用ZpfjPtryzpglb里面的uploadFile接收BASE64位数据,FORM表单用
  * CommonsMultipartFile uploadFile接收照片
  *
  * @param @param uploadFile
  * @param @param zpfjPtryzpglb
  * @param @param sessionBean
  * @param @return 设定文件
  * @return ModelAndView 返回类型
  * @throws
  */
 @RestfulAnnotation(serverId = "11", valiField = "ryid,lybm,lyid,lyms")
 @RequestMapping(value = "/upload", method = RequestMethod.POST)
 public @ResponseBody ModelAndView save(
     @RequestParam(required = false) CommonsMultipartFile uploadFile,
     ZpfjPtryzpglb zpfjPtryzpglb,
     SessionBean sessionBean) {
   ModelAndView mv = new ModelAndView(getViewName(sessionBean));
   Map<String, Object> model = new HashMap<String, Object>();
   try {
     boolean isEmpty = false;
     byte[] imageByte = null;
     if (uploadFile != null && !uploadFile.isEmpty()) {
       imageByte = uploadFile.getBytes();
     } else if (uploadFile != null || StringUtils.isEmpty(zpfjPtryzpglb.getUploadFile())) {
       isEmpty = true;
     } else {
       imageByte = base64Decoder(zpfjPtryzpglb.getUploadFile());
     }
     if (isEmpty) {
       model.put(AppConst.STATUS, AppConst.FAIL);
       model.put(AppConst.MESSAGES, "保存失败!由于上传文件为空!");
     } else {
       ZpfjPtryzpxxb zpfjPtryzpxxb = new ZpfjPtryzpxxb();
       zpfjPtryzpxxb.setZp(imageByte);
       zpfjPtryzpxxb.setZpslt(ImageUtils.convertImageSize(imageByte, 179, 220, false));
       zpfjPtryzpService.savePtryzpxxb(zpfjPtryzpglb, zpfjPtryzpxxb, getSessionBean(sessionBean));
       model.put(AppConst.STATUS, AppConst.SUCCESS);
       model.put(AppConst.MESSAGES, getAddSuccess());
     }
   } catch (Exception e) {
     logger.error(e.getLocalizedMessage(), e);
     model.put(AppConst.STATUS, AppConst.FAIL);
     model.put(AppConst.MESSAGES, getAddFail());
   }
   mv.addObject(AppConst.MESSAGES, new Gson().toJson(model));
   return mv;
 }