Пример #1
0
 /**
  * 功能:构造获取当前用户某一盘点工单下的所有待盘点资产SQL
  *
  * @return SQLModel
  */
 public SQLModel getOrderAssetsModel() {
   SQLModel sqlModel = new SQLModel();
   EamDhCheckHeaderDTO dto = (EamDhCheckHeaderDTO) dtoParameter;
   List sqlArgs = new ArrayList();
   String sqlStr =
       "SELECT"
           + " EDCL.HEADER_ID,"
           + " EDCL.BARCODE,"
           + " EDCL.ITEM_CODE,"
           + " EDCL.ITEM_CATEGORY,"
           + " EDCL.ITEM_NAME,"
           + " EDCL.ITEM_SPEC,"
           + " EDCL.ITEM_CATEGORY2,"
           + " EDCL.VENDOR_BARCODE,"
           + " EDCL.PRICE,"
           + " EDCL.START_DATE,"
           + " EDCL.RESPONSIBILITY_USER,"
           + " EDCL.DEPT_CODE RESPONSIBILITY_DEPT,"
           + " EDCL.MAINTAIN_USER,"
           + " EDCL.VENDOR_ID,"
           + " EDCL.VENDOR_NAME"
           + " FROM"
           + " EAM_DH_CHECK_LINE EDCL"
           + " WHERE"
           + " EDCL.BARCODE = EDCL.BARCODE"
           + " AND EDCL.HEADER_ID = ?";
   sqlArgs.add(dto.getHeaderId());
   sqlModel.setSqlStr(sqlStr);
   sqlModel.setArgs(sqlArgs);
   return sqlModel;
 }
Пример #2
0
 /**
  * 功能:构造更新当前用户下载的工单的SQL
  *
  * @return SQLModel
  */
 public SQLModel getOrderDownloadModel() {
   SQLModel sqlModel = new SQLModel();
   List sqlArgs = new ArrayList();
   EamDhCheckHeaderDTO dto = (EamDhCheckHeaderDTO) dtoParameter;
   String sqlStr =
       "UPDATE"
           + " EAM_DH_CHECK_HEADER EDCH"
           + " SET"
           + " EDCH.ORDER_STATUS = ?,"
           + " EDCH.DOWNLOAD_DATE = GETDATE(),"
           + " EDCH.DOWNLOAD_BY = ?"
           + " WHERE"
           + " EDCH.HEADER_ID = ?";
   sqlArgs.add(dto.getOrderStatus());
   sqlArgs.add(userAccount.getUserId());
   sqlArgs.add(dto.getHeaderId());
   sqlModel.setSqlStr(sqlStr);
   sqlModel.setArgs(sqlArgs);
   return sqlModel;
 }
Пример #3
0
  /**
   * 功能:保存工单
   *
   * @param orders DTOSet
   * @return boolean
   */
  public boolean saveOrders(DTOSet orders) {
    boolean operateResult = false;
    boolean autoCommit = true;
    EamDhCheckBatchDTO dto = (EamDhCheckBatchDTO) dtoParameter;
    boolean isNewBatch = dto.getBatchId().equals("");
    String act = dto.getAct();
    try {
      autoCommit = conn.getAutoCommit();
      conn.setAutoCommit(false);
      if (isNewBatch) {
        SeqProducer seqPrd = new SeqProducer(conn);
        // TODO
        dto.setBatchId(seqPrd.getStrNextSeq("EAM_DH_CHECK_BATCH") + "");
        String companyCode = userAccount.getCompanyCode();
        String orderType = LvecDicts.CHECK_BATCH;
        OrderNumGenerator numPrd = new OrderNumGenerator(conn, companyCode, orderType);
        numPrd.setOrderLength(3);
        dto.setBatchNo(numPrd.getOrderNum());
        setDTOParameter(dto);
        createData();
      } else {
        updateData();
      }
      EamDhCheckLineDAO lineDAO = new EamDhCheckLineDAO(userAccount, null, conn);
      EamDhCheckLineDTO orderLine = new EamDhCheckLineDTO();
      if (!dto.getOrderType().equals(LvecDicts.ORD_TYPE1_DHBS)) {
        orderLine.setBatchId(dto.getBatchId());
        lineDAO.setDTOParameter(orderLine);
        lineDAO.DeleteByForeignKey("batchId");
      }
      EamDhCheckHeaderDTO orderHeader = new EamDhCheckHeaderDTO();
      orderHeader.setBatchId(dto.getBatchId());
      EamDhCheckHeaderDAO headerDAO = new EamDhCheckHeaderDAO(userAccount, orderHeader, conn);
      headerDAO.DeleteByForeignKey("batchId");

      int orderCount = orders.getSize();
      for (int i = 0; i < orderCount; i++) {
        orderHeader = (EamDhCheckHeaderDTO) orders.getDTO(i);

        if (orderHeader.getCheckLocation() == 0) {

          continue;
        }
        orderHeader.setBatchId(dto.getBatchId());
        orderHeader.setCheckTaskId(dto.getCheckTaskId());
        orderHeader.setAct(act);
        headerDAO.setDTOParameter(orderHeader);
        headerDAO.saveOrder();

        if (!orderHeader.getOrderType().equals(LvecDicts.ORD_TYPE1_DHBS)) { // 非补扫工单才需要创建行信息
          orderHeader = (EamDhCheckHeaderDTO) headerDAO.getDTOParameter();
          orderLine.setHeaderId(orderHeader.getHeaderId());
          orderLine.setOrderType(orderHeader.getOrderType());
          orderLine.setBatchId(dto.getBatchId());
          lineDAO.setDTOParameter(orderLine);
          lineDAO.createData();
        }
      }
      operateResult = true;
    } catch (Exception ex) {
      Logger.logError(ex);
    } finally {
      try {
        if (operateResult) {
          conn.commit();
          if (act.equals(DzyhActionConstant.SAVE_ACTION)) { // 暂存工单
            prodMessage(LvecMessageKeys.ORDER_SAVE_SUCCESS);
          } else if (act.equals(DzyhActionConstant.DISTRI_ORDER)) { // 下发工单
            prodMessage(LvecMessageKeys.ORDER_DISTRI_SUCCESS);
          }
        } else {
          conn.rollback();
          if (isNewBatch) {
            dto.setBatchId("");
            dto.setBatchNo(LvecWebAttributes.ORDER_NO_AUTO_PRODUCE);
          }
          if (act.equals(DzyhActionConstant.SAVE_ACTION)) { // 暂存工单
            prodMessage(LvecMessageKeys.ORDER_SAVE_FAILURE);
          } else if (act.equals(DzyhActionConstant.DISTRI_ORDER)) { // 下发工单
            prodMessage(LvecMessageKeys.ORDER_DISTRI_FAILURE);
          }
          message.setIsError(true);
        }
        conn.setAutoCommit(autoCommit);
        setDTOParameter(dto);
      } catch (SQLException ex) {
        Logger.logError(ex);
      }
    }
    return operateResult;
  }