Пример #1
0
  public void listOrderWSSub(BusinessRequest res) {

    OrderStateDto dto = super.getDto(OrderStateDto.class, res);
    if (StringUtils.isNullOrEmpty(dto.getUserName())) {
      dto.getOrdWebVo().getOperateResult().setResultCode("-1");
      dto.getOrdWebVo().getOperateResult().setResultContent("用户名不能为空");
      return;
    }
    if (StringUtils.isNullOrEmpty(dto.getPassWord())) {
      dto.getOrdWebVo().getOperateResult().setResultCode("-2");
      dto.getOrdWebVo().getOperateResult().setResultContent("密码不能为空");
      return;
    }
    NormalAccount normalAccount = normalAccountService.getNormalAccountByAccount(dto.getUserName());
    if (normalAccount == null) {
      dto.getOrdWebVo().getOperateResult().setResultCode("-3");
      dto.getOrdWebVo().getOperateResult().setResultContent("用户名不存在");
      return;
    }
    if (!normalAccount.getPassword().equals(dto.getPassWord())) {
      dto.getOrdWebVo().getOperateResult().setResultCode("-4");
      dto.getOrdWebVo().getOperateResult().setResultContent("密码不对");
      return;
    }
    if (!normalAccount.getNormalUser().getType().toString().equals("2")) {
      dto.getOrdWebVo().getOperateResult().setResultCode("-5");
      dto.getOrdWebVo().getOperateResult().setResultContent("用户名类型不对");
      return;
    }
    dto.setVendor(normalAccount.getNormalUser().getVendorId());
    dto.setSendFlag("0");
    // 调用对应的service方法
    ordertateService.listOrderWS(dto);
  }
Пример #2
0
  /*
  @BlhParameters(dtoCls=OrderStateDto.class,parameter={
  	@BlhParameter(parameterExpress="order.orderId",testvalues={("order.orderId=1000")},desc="订单ID")
  })
  @Descript("供应商确认收到订单")
  @OutPut(ognlExpress="dto.operateResult")
  */
  public void recievedMsg(BusinessRequest res) {
    OrderStateDto dto = super.getDto(OrderStateDto.class, res);

    this.recievedMsgSub(res);

    SysLog log = new SysLog();
    log.setOpArg(
        JsonUtils.toJson(StringUtils.convertList(dto.getOrderIdStr(), BaseConstants.COMMA))
            + "userNmae:"
            + dto.getUserName()
            + "password:"
            + dto.getPassWord());
    log.setOpName("webservice供应商确认收到订单");
    log.setOpDate(new Date());
    log.setOpResult(JsonUtils.toJson(dto.getOperateResult()));
    log.setOpType("webservice");
    log.setOpUser(dto.getUserName());
    commonService.saveOrUpdate(log);
  }
Пример #3
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);
    }
  }
Пример #4
0
  public void deliverSub(OrderStateDto dto) {

    if (dto.getDeliveritms() == null) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("入参为空");
      return;
    }
    if (dto.getDeliveritms().size() == 0) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("入参为空");
      return;
    }

    List<OrderDetailSub> detailSubs = new ArrayList<OrderDetailSub>();
    int num = 0;
    // 按订单拆分发货单
    for (VenDeliveritm tmpVenDeliveritm : dto.getDeliveritms()) {
      num++;
      if (StringUtils.isNullOrEmpty(tmpVenDeliveritm.getDeliveritmInvnoe())) {
        dto.getOperateResult().setResultCode("-2");
        dto.getOperateResult().setResultContent("第" + num + "行发票号不能为空");
        continue;
      }
      if (tmpVenDeliveritm.getDeliveritmQty() == null) {
        dto.getOperateResult().setResultCode("-3");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,发货数量不能为空");
        continue;
      }
      if (tmpVenDeliveritm.getDeliveritmRp() == null) {
        dto.getOperateResult().setResultCode("-4");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,进价不能为空");
        continue;
      }
      if (tmpVenDeliveritm.getDeliveritmOrderitmid() == null) {
        dto.getOperateResult().setResultCode("-5");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,没有订单明细ID");
        continue;
      }

      OrderDetail orderItm =
          commonService.get(OrderDetail.class, tmpVenDeliveritm.getDeliveritmOrderitmid());
      if (orderItm == null) {
        dto.getOperateResult().setResultCode("-6");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,订单明细ID错误");
        continue;
      }
      if (orderItm.getOrderState().longValue() != 2) {
        dto.getOperateResult().setResultCode("-7");
        dto.getOperateResult()
            .setResultContent(tmpVenDeliveritm.getDeliveritmInvnoe() + "发票号,订单状态错误");
        continue;
      }
      OrderDetailSub orderDetailSub = new OrderDetailSub();
      orderDetailSub.setOrderSubQty(tmpVenDeliveritm.getDeliveritmQty());
      orderDetailSub.setOrderSubRp(tmpVenDeliveritm.getDeliveritmRp());
      orderDetailSub.setOrderSubRpAmt(tmpVenDeliveritm.getDeliveritmRpamt());
      orderDetailSub.setOrdSubBatNo(tmpVenDeliveritm.getDeliveritmBatno());
      orderDetailSub.setOrdSubDate(new Date());
      orderDetailSub.setOrdSubDetailId(tmpVenDeliveritm.getDeliveritmOrderitmid());
      orderDetailSub.setOrdSubInvNo(tmpVenDeliveritm.getDeliveritmInvnoe());
      orderDetailSub.setOrdSubExpDate(tmpVenDeliveritm.getDeliveritmExpdate());
      detailSubs.add(orderDetailSub);
    }

    // 明细有错吴
    if (!dto.getOperateResult().getResultCode().equals("0")) {
      return;
    }
    for (OrderDetailSub orderDetailSub : detailSubs) {
      OrderDetail orderDetail =
          commonService.get(OrderDetail.class, orderDetailSub.getOrdSubDetailId());
      orderDetail.setOrderState(3l);
      commonService.saveOrUpdate(orderDetail);
      commonService.saveOrUpdate(orderDetailSub);
      ExeState exeState = new ExeState();
      exeState.setStateId(Long.valueOf(2));
      exeState.setOrdId(orderDetailSub.getOrdSubDetailId());
      exeState.setRemark("webservice 回传发票");
      exeState.setExedate(new java.sql.Timestamp(new Date().getTime()));
      commonService.saveOrUpdate(exeState);
    }
  }
Пример #5
0
  public void recievedMsgSub(BusinessRequest res) {
    OrderStateDto dto = super.getDto(OrderStateDto.class, res);
    OperateResult operateResult = new OperateResult();
    operateResult.setResultCode("-11");
    operateResult.setResultContent("falie");
    dto.setOperateResult(operateResult);

    if (StringUtils.isNullOrEmpty(dto.getUserName())) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("用户名不能为空");
      return;
    }
    if (StringUtils.isNullOrEmpty(dto.getPassWord())) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("密码不能为空");
      return;
    }
    NormalAccount normalAccount = normalAccountService.getNormalAccountByAccount(dto.getUserName());
    if (normalAccount == null) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("用户名或密码错误");
      return;
    }
    if (!normalAccount.getPassword().equals(dto.getPassWord())) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("用户名或密码错误");
      return;
    }
    if (!normalAccount.getNormalUser().getType().toString().equals("2")) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("用户名或密码错误");
      return;
    }

    if (StringUtils.isNullOrEmpty(dto.getOrderIdStr())) {
      dto.getOperateResult().setResultCode("-1");
      dto.getOperateResult().setResultContent("入参为空");
      return;
    }
    String[] strs = dto.getOrderIdStr().split(BaseConstants.COMMA);
    for (String id : strs) {
      OrderDetail order = commonService.get(OrderDetail.class, Long.valueOf(id));
      if (order == null) {
        dto.getOperateResult().setResultCode("-2");
        dto.getOperateResult().setResultContent("入参无效");
        continue;
      }
      if (order.getOrderVenId().longValue() != normalAccount.getNormalUser().getVendorId()) {
        dto.getOperateResult().setResultCode("-3");
        dto.getOperateResult().setResultContent("入参无效");
        continue;
      }
      if (order.getOrderState().longValue() != 1) {
        dto.getOperateResult().setResultCode("-4");
        dto.getOperateResult().setResultContent("订单状态不对");
        continue;
      }
      order.setOrderSendFlag("1");
      order.setOrderState(2l);
      commonService.saveOrUpdate(order);
      ExeState exeState = new ExeState();
      exeState.setStateId(Long.valueOf(2));
      exeState.setOrdId(order.getOrderId());
      exeState.setRemark("webservice 确认订单");
      exeState.setExedate(new java.sql.Timestamp(new Date().getTime()));
      commonService.saveOrUpdate(exeState);
    }
    if (!dto.getOperateResult().getResultCode().equals("-11")) {
      return;
    }
    dto.getOperateResult().setResultCode("0");
    dto.getOperateResult().setResultContent("success");
  }