Example #1
0
 public static void EncoderQrCode(String content) throws IOException {
   Qrcode qrcode = new Qrcode();
   qrcode.setQrcodeErrorCorrect('M');
   qrcode.setQrcodeEncodeMode('B');
   qrcode.setQrcodeVersion(7);
   //        if(content == null || !content.equals("")){
   //        	content = "DHCC";
   //        }
   String servicePassword = PropertiesBean.getInstance().getProperty("confg.serviceKey");
   content = AESCoder.aesCbcEncrypt(content, servicePassword);
   byte[] bstr = content.getBytes("UTF-8");
   BufferedImage bi = new BufferedImage(139, 139, BufferedImage.TYPE_INT_RGB);
   Graphics2D g = bi.createGraphics();
   g.setBackground(Color.WHITE); //
   g.clearRect(0, 0, 139, 139);
   g.setColor(Color.BLACK); //
   if (bstr.length > 0 && bstr.length < 123) {
     boolean[][] b = qrcode.calQrcode(bstr);
     for (int i = 0; i < b.length; i++) {
       for (int j = 0; j < b.length; j++) {
         if (b[j][i]) {
           g.fillRect(j * 3 + 2, i * 3 + 2, 3, 3);
         }
       }
     }
   }
   g.dispose();
   bi.flush();
   WebContextHolder.getContext().getResponse().setContentType("image/png");
   ImageIO.write(bi, "png", WebContextHolder.getContext().getResponse().getOutputStream());
 }
  /**
   * @param res
   * @throws IOException
   * @author penzi
   * @description:PDA调用,查询各订单的执行状态
   */
  public void OrderStateAndroid(BusinessRequest res) throws IOException {
    OrderStateDto dto = super.getDto(OrderStateDto.class, res);

    // 调用对应的service方法
    WebContextHolder.getContext().getResponse().setContentType("text/html;charset=UTF-8");
    WebContextHolder.getContext()
        .getResponse()
        .getWriter()
        .write(
            "{\"orderId\":"
                + dto.getExeState().getOrdId()
                + ",\"rows\":"
                + JsonUtils.toJson(ordertateService.listOrderExeState(dto))
                + "}");
    WebContextHolder.getContext().getResponse().getWriter().flush();
  }
Example #3
0
  public void getIncInfo(BusinessRequest res) throws Exception {

    HopIncDto dto = super.getDto(HopIncDto.class, res);

    List<HopIncVo> hopIncVos = new ArrayList<HopIncVo>();
    hopIncVos = hopIncService.getIncInfo(dto);
    WebContext webContext = WebContextHolder.getContext();
    webContext.getResponse().getWriter().write(JsonUtils.toJson(hopIncVos));
  }
Example #4
0
  /**
   * @Title: HopIncBlh.java @Description: TODO(导入药品)
   *
   * @param res
   * @return:void
   * @author zhouxin
   * @date 2014年6月10日 下午2:37:46
   * @version V1.0
   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public void upload(BusinessRequest res) throws IOException {

    HopIncDto dto = super.getDto(HopIncDto.class, res);
    dto.setOpFlg("1");
    // 生成随机文件名
    String newFileName = UUID.randomUUID().toString();
    // 获取文件存储路径
    String storageFileName = ServletActionContext.getServletContext().getRealPath("/uploadtmps");
    // 判断文件存储路径是否存在,若不存在则自动新建
    File document = new File(storageFileName);
    if (!document.exists()) {
      document.mkdir();
    }

    File dstFile = new File(storageFileName, newFileName);
    com.dhcc.framework.util.FileUtils.copyFile(dto.getUpload(), dstFile, BaseConstants.BUFFER_SIZE);

    //
    SysImpModelDto SysImpModelDto = new SysImpModelDto();
    SysImpModelDto.setImpModel(new ImpModel());
    SysImpModelDto.getImpModel().setType("INC");
    List<ImpModel> listImpModels = sysImpModelService.getModelList(SysImpModelDto);
    Map<Integer, String> modelMap = new HashMap<Integer, String>();
    for (int i = 0; i < listImpModels.size(); i++) {
      modelMap.put(
          Integer.valueOf(listImpModels.get(i).getSeq().toString()),
          listImpModels.get(i).getCode());
    }
    // 读取excel
    try {
      List<HopInc> hopIncs = new ArrayList<HopInc>();
      // 读取Excel文件
      Workbook workbook = null;
      Sheet sheet = null;
      Row row = null;
      Cell cell = null;

      String prefix =
          dto.getUploadFileName().substring(dto.getUploadFileName().lastIndexOf(".") + 1);
      if (prefix.equals("xls")) {
        workbook =
            new HSSFWorkbook(new FileInputStream(storageFileName + File.separator + newFileName));
      } else if (prefix.equals("xlsx")) {
        workbook =
            new XSSFWorkbook(new FileInputStream(storageFileName + File.separator + newFileName));
      } else {
        dto.setOpFlg("-1");
        dto.setMsg("<br>文件类型错误:");
        WebContextHolder.getContext().getResponse().getWriter().write(JsonUtils.toJson(dto));
        return;
      }
      sheet = workbook.getSheetAt(0);

      // 明细
      for (int numRows = 1; numRows <= sheet.getLastRowNum(); numRows++) {

        row = sheet.getRow(numRows);

        HopInc hopInc = new HopInc();
        for (int numCells = 0; numCells <= row.getLastCellNum(); numCells++) {
          cell = row.getCell(numCells);
          String colNameString = modelMap.get(numCells);
          if (StringUtils.isNullOrEmpty(colNameString)) {
            colNameString = " ";
          }
          ;
          switch (colNameString) {
            case "HOSPINC_CODE":
              if (cell != null) {
                hopInc.setIncCode(cell.toString());
              }
              break;
            case "HOSPINC_NAME":
              if (cell != null) {
                hopInc.setIncName(cell.toString());
              }
              break;
            case "HOSPINC_SPEC":
              if (cell != null) {
                hopInc.setIncSpec(cell.toString());
              }
              break;
            case "HOSPINC_PUOM":
              if (cell != null) {
                hopInc.setIncUomname(cell.toString());
              }
              break;
            case "HOSPINC_RP":
              if (cell != null) {
                cell.setCellType(Cell.CELL_TYPE_NUMERIC);
                hopInc.setIncRp((float) (cell.getNumericCellValue()));
              }
              break;
            case "HOSPINC_MANF":
              if (cell != null) {
                if (hopManfService.getIdByName(cell.toString()) == null) {
                  HopManf manf = new HopManf();
                  manf.setManfName(cell.toString());
                  manf.setManfHisid(
                      WebContextHolder.getContext().getVisit().getUserInfo().getHopId());
                  commonService.saveOrUpdate(manf);
                  hopInc.setIncManfid(manf.getHopManfId());
                } else {
                  hopInc.setIncManfid(hopManfService.getIdByName(cell.toString()));
                }
              }
              break;
            case "HOSPINC_CAT":
              if (cell != null) {
                hopInc.setIncCat(cell.toString());
              }
              break;
            case "HOSPINC_ALIAS":
              if (cell != null) {
                hopInc.setIncAliaS(cell.toString());
              }
              break;
            case "HOSPINC_PUOMCODE":
              if (cell != null) {
                hopInc.setIncUomcode(cell.toString());
              }
              break;
            case "HOSPINC_SP":
              if (cell != null) {
                cell.setCellType(Cell.CELL_TYPE_NUMERIC);
                hopInc.setIncSp((float) (cell.getNumericCellValue()));
              }
              break;
          }
        }
        // 验证数据的完整性
        if (org.apache.commons.lang.StringUtils.isBlank(hopInc.getIncCode())) {
          dto.setOpFlg("-1");
          dto.setMsg("<br>" + "第" + numRows + "行医院商品代码不能为空!");
          continue;
        } else {
          if (dto.getOpFlg().equals("1")) {
            DetachedCriteria criteria = DetachedCriteria.forClass(HopInc.class);
            criteria.add(Restrictions.eq("incCode", hopInc.getIncCode()));
            criteria.add(
                Restrictions.eq(
                    "hopHopId", Long.valueOf(super.getLoginInfo().get("HOSPID").toString())));
            List<HopInc> hopIncsIds = commonService.findByDetachedCriteria(criteria);
            if (hopIncsIds.size() > 0) {
              hopInc.setIncHospid(hopIncsIds.get(0).getIncHospid());
              hopInc.setIncId(hopIncsIds.get(0).getIncId());
            }
          }
        }
        hopIncs.add(hopInc);
      }
      if (dto.getOpFlg().equals("1")) {
        dto.setHopIncs(hopIncs);
        hopIncService.saveInc(dto);
      }
      workbook = null;
      FileUtils.forceDelete(dstFile);

    } catch (Exception e) {
      e.printStackTrace();
      dto.setOpFlg("-1");
      dto.setMsg("<br>" + dto.getMsg() + "<br>" + e.getMessage());
    } finally {
      super.writeJSON(dto);
      FileUtils.forceDelete(dstFile);
    }
  }
 /**
  * @Title: OrderStateBlh.java @Description: TODO(查询订单状态列表)
  *
  * @param res
  * @return:void
  * @author zhouxin
  * @date 2014年5月29日 下午2:43:23
  * @version V1.0
  * @throws IOException
  */
 public void getComboList(BusinessRequest res) throws IOException {
   WebContextHolder.getContext()
       .getResponse()
       .getWriter()
       .write(JsonUtils.toJson(ordertateService.getComboList()));
 }