/** * 功能:构造单据审批消息提示 * * @param operateResult boolean * @param flowCode String */ private void processMessage(boolean operateResult, String flowCode) { FreeFlowDTO dto = (FreeFlowDTO) dtoParameter; if (flowCode.equals(FlowConstant.FLOW_CODE_NEXT)) { if (operateResult) { prodMessage(AssetsMessageKeys.PASS_ORDER_SUCCESS); } else { prodMessage(AssetsMessageKeys.PASS_ORDER_FAILURE); } } else { if (operateResult) { prodMessage(AssetsMessageKeys.REJECT_ORDER_SUCCESS); } else { prodMessage(AssetsMessageKeys.REJECT_ORDER_FAILURE); } } String orderType = dto.getTransTypeValue(); if (orderType.indexOf("单") > -1) { orderType = orderType.substring(0, orderType.length() - 1); } message.addParameterValue(orderType); message.addParameterValue(dto.getTransNo()); message.setIsError(!operateResult); }
/** * 功能:审批单据,含调拨单,报废单,处置单,共享单 * * @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; }