Example #1
0
 /**
  * 功能:记录设备最新一次交易情况:例如报废,其他的视具体需要而定 需要同步到MIS的时候调用该方法。
  *
  * @param orderType String
  * @param isExist String
  * @throws DataHandleException
  */
 private void recordChkLog(String orderType, String isExist) throws DataHandleException {
   try {
     FreeFlowDTO dto = (FreeFlowDTO) dtoParameter;
     AmsAssetsTransLineDTO line = new AmsAssetsTransLineDTO();
     line.setTransId(dto.getTransId());
     AmsAssetsTransLineDAO lineDAO = new AmsAssetsTransLineDAO(userAccount, line, conn);
     lineDAO.setDTOClassName(AmsAssetsTransLineDTO.class.getName());
     DTOSet dtos = (DTOSet) lineDAO.getDataByForeignKey("transId");
     if (dtos != null && !dtos.isEmpty()) {
       int lineCount = dtos.getSize();
       String orderUrl = "";
       AmsAssetsChkLogDTO chkLogDTO = null;
       AmsAssetsChkLogDAO chkLogDAO = new AmsAssetsChkLogDAO(userAccount, null, conn);
       for (int i = 0; i < lineCount; i++) {
         line = (AmsAssetsTransLineDTO) dtos.getDTO(i);
         chkLogDTO = new AmsAssetsChkLogDTO();
         chkLogDTO.setBarcode(line.getBarcode());
         chkLogDTO.setLastChkNo(line.getTransNo());
         chkLogDTO.setHeaderId(line.getTransId());
         chkLogDTO.setResponsibilityUser(line.getResponsibilityUser());
         chkLogDTO.setResponsibilityDept(line.getDeptCode());
         chkLogDTO.setAddressId(line.getAddressId());
         chkLogDTO.setOrganizationId(userAccount.getOrganizationId());
         chkLogDTO.setCreatedBy(userAccount.getUserId());
         chkLogDTO.setOrderType(orderType);
         chkLogDTO.setIsExist(isExist);
         orderUrl = URLDefineList.FREE_FLOW_SERVLET;
         orderUrl += "?act=" + AssetsActionConstant.DETAIL_ACTION;
         orderUrl += "&transId=" + line.getTransId();
         chkLogDTO.setOrderDtlUrl(orderUrl);
         chkLogDAO.setDTOParameter(chkLogDTO);
         chkLogDAO.saveCheckLogData();
       }
     }
   } catch (QueryException ex) {
     ex.printLog();
     throw new DataHandleException(ex);
   }
 }
Example #2
0
  /**
   * 功能:审批单据,含调拨单,报废单,处置单,共享单
   *
   * @param flowDTO FlowDTO
   * @param orderLines 更改调拨单行的折旧费用账户(2008-12-01 17:37)
   * @return boolean
   */
  public boolean approveOrder(FlowDTO flowDTO, DTOSet orderLines) {
    boolean operateResult = false;
    boolean autoCommit = true;
    boolean needMsg = true;
    String flowCode = "";
    try {
      if (canApprove()) {
        autoCommit = conn.getAutoCommit();
        conn.setAutoCommit(false);
        FreeFlowDTO dto = (FreeFlowDTO) dtoParameter;
        flowCode = dto.getFlowCode();
        flowDTO.setProcName(dto.getProcdureName());
        flowDTO.setActivity(flowCode);
        flowDTO.setApplyId(dto.getTransId());
        flowDTO.setSessionUserId(userAccount.getUserId());
        flowDTO.setSessionUserName(userAccount.getUsername());
        flowDTO.setApplyNo(dto.getTransNo());
        FlowAction flowProcessor = new FlowAction(conn, flowDTO);
        boolean flow2End = flowProcessor.isFlowToEnd();
        dto.setFlow2End(flow2End);
        setDTOParameter(dto);
        if (flowCode.equals(FlowConstant.FLOW_CODE_NEXT)) {
          if (flow2End) {
            dto.setTransStatus(AssetsDictConstant.COMPLETED);
          } else {
            dto.setTransStatus(AssetsDictConstant.IN_PROCESS);
          }
          flowProcessor.flow();
        } else {
          dto.setTransStatus(AssetsDictConstant.REJECTED);
          flowProcessor.reject2Begin();
        }
        setDTOParameter(dto);
        OrderApproveModel modelProducer = (OrderApproveModel) sqlProducer;
        SQLModel sqlModel = modelProducer.getOrderApproveModel();
        DBOperator.updateRecord(sqlModel, conn);

        String provinceCode = servletConfig.getProvinceCode();
        if (provinceCode.equals(AssetsDictConstant.PROVINCE_CODE_JIN)
            && flowCode.equals(FlowConstant.FLOW_CODE_NEXT)) { // 仅山西需要该功能。
          if (dto.getTransferType().equals("BTW_COMP")) {
            AmsAssetsTransLineDAO lineDAO = new AmsAssetsTransLineDAO(userAccount, null, conn);
            lineDAO.uodateAccount(orderLines);
          }
        }
        if (flow2End && flowCode.equals(FlowConstant.FLOW_CODE_NEXT)) {
          sqlModel = modelProducer.getLineStatusUpdateModel(); // 更新资产单据行数据状态为已审批
          DBOperator.updateRecord(sqlModel, conn);
          if (dto.getTransType().equals(AssetsDictConstant.ASS_DIS)) { // 报废
            sqlModel = modelProducer.getAssetsDiscardModel();
            DBOperator.updateRecord(sqlModel, conn);
            deleteReserveAssets();
            if (provinceCode.equals(AssetsDictConstant.PROVINCE_CODE_SX)) { // 山西省报废要同步
              recordChkLog(AssetsDictConstant.ASS_DIS, AssetsDictConstant.STATUS_NO);
            }
          } else if (dto.getTransType().equals(AssetsDictConstant.ASS_CLR)) { // 处置
            sqlModel = modelProducer.getAssetsClearModel();
            DBOperator.updateRecord(sqlModel, conn);
            deleteReserveAssets();
          } else if (dto.getTransType().equals(AssetsDictConstant.ASS_FREE)) { // 闲置
            sqlModel = modelProducer.getAssetsFreeModel();
            DBOperator.updateRecord(sqlModel, conn);
            deleteReserveAssets();
          } else if (dto.getTransType().equals(AssetsDictConstant.ASS_SUB)) { // 减值
            sqlModel = modelProducer.getAssetsSubModel();
            DBOperator.updateRecord(sqlModel, conn);
            deleteReserveAssets();
          } else if (dto.getTransType().equals(AssetsDictConstant.ASS_SHARE)) { // 共享
            sqlModel = modelProducer.getAssetsShareModel();
            DBOperator.updateRecord(sqlModel, conn);
          }
        }
        operateResult = true;
      } else {
        prodMessage(AssetsMessageKeys.APPROVE_INVALID);
        message.setIsError(!operateResult);
        needMsg = false;
      }
    } catch (DataHandleException ex) {
      ex.printLog();
    } catch (SQLException ex) {
      Logger.logError(ex);
    } catch (ContainerException ex) {
      ex.printLog();
    } catch (QueryException ex) {
      ex.printLog();
    } finally {
      try {
        if (!operateResult) {
          conn.rollback();
        } else {
          conn.commit();
        }
        conn.setAutoCommit(autoCommit);
        if (needMsg) {
          processMessage(operateResult, flowCode);
        }
      } catch (SQLException ex1) {
        Logger.logError(ex1);
      }
    }
    return operateResult;
  }