⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vinventorymovegen.java

📁 大家共享愉快, 共享愉快, 共享愉快, 共享愉快,共享愉快
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 * The contents of this file are subject to the   Compiere License  Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * You may obtain a copy of the License at http://www.compiere.org/license.html
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
 * Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
 * are Copyright (C) 1999-2005 Jorg Janke.
 * All parts are Copyright (C) 1999-2005 ComPiere, Inc.  All Rights Reserved.
 * Contributor(s): ______________________________________.
 *****************************************************************************/
package org.compiere.apps.form;

import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import javax.swing.event.*;
import org.compiere.apps.*;
import org.compiere.grid.ed.*;
import org.compiere.minigrid.*;
import org.compiere.model.*;
import org.compiere.plaf.*;
import org.compiere.print.*;
import org.compiere.process.*;
import org.compiere.swing.*;
import org.compiere.util.*;
import javax.swing.border.TitledBorder;

/**
 *	Manual Inventory Move Selection
 *
 *  @author Jorg Janke
 *  @version $Id: VInventoryMoveGen.java,v 1.28 2005/03/11 20:28:34 jjanke Exp $
 */
public class VInventoryMoveGen extends CPanel implements FormPanel,
        ActionListener, VetoableChangeListener, ChangeListener,
        TableModelListener, ASyncProcess {
    /**
     *	Initialize Panel
     *  @param WindowNo window
     *  @param frame frame
     */
    public void init(int WindowNo, FormFrame frame) {
        log.info("");
        m_WindowNo = WindowNo;
        m_frame = frame;
        Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y");
        try {
            fillPicks();
            jbInit();
            dynInit();
            frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
            frame.getContentPane().add(statusBar, BorderLayout.SOUTH);
        } catch (Exception ex) {
            log.log(Level.SEVERE, "init", ex);
        }
    } //	init

    /**	Window No			*/
    private int m_WindowNo = 0;
    /**	FormFrame			*/
    private FormFrame m_frame;
    private boolean m_selectionActive = true;
    private String m_whereClause;
    private Object m_M_Production_ID = null;
    /**	Logger			*/
    private static CLogger log = CLogger.getCLogger(VInventoryMoveGen.class);
    //
    private CTabbedPane tabbedPane = new CTabbedPane();
    private CPanel selPanel = new CPanel();
    private CPanel selNorthPanel = new CPanel();
    private BorderLayout selPanelLayout = new BorderLayout();
    private CLabel lProduction = new CLabel();
    private VLookup fProduction;
    private FlowLayout northPanelLayout = new FlowLayout();
    private ConfirmPanel confirmPanelSel = new ConfirmPanel(true);
    private ConfirmPanel confirmPanelGen = new ConfirmPanel(false, true, false, false, false, false, true);
    private StatusBar statusBar = new StatusBar();
    private CPanel genPanel = new CPanel();
    private BorderLayout genLayout = new BorderLayout();
    private CTextPane info = new CTextPane();
    private JScrollPane scrollPane = new JScrollPane();
    private MiniTable miniTable = new MiniTable();
    private CPanel selectionPanel = new CPanel(new ALayout());
    private VLocator locatorField;

    private static int COLUMN_M_PRODUCTION_ID = 3596;

    /**
     *	Static Init.
     *  <pre>
     *  selPanel (tabbed)
     *      fProduction
     *      scrollPane & miniTable
     *  genPanel
     *      info
     *  </pre>
     *  @throws Exception
     */
    void jbInit() throws Exception {
        CompiereColor.setBackground(this);
        //
        selPanel.setLayout(selPanelLayout);
        lProduction.setLabelFor(fProduction);
        lProduction.setText(Msg.translate(Env.getCtx(), "M_Production_ID"));

        //selectionPanel.setBorder(new TitledBorder("Locator"));
        int row = 0;
        CLabel label = new CLabel(Msg.translate(Env.getCtx(), "M_Locator_ID"));
        MLocatorLookup locatorLookup = new MLocatorLookup(Env.getCtx(),
                m_WindowNo);
        locatorField = new VLocator("M_Locator_ID", true, false, true,
                                    locatorLookup, m_WindowNo);
        selectionPanel.add(label, new ALayoutConstraint(row++, 0));
        selectionPanel.add(locatorField, null);

        selNorthPanel.setLayout(northPanelLayout);
        northPanelLayout.setAlignment(FlowLayout.LEFT);
        tabbedPane.add(selPanel, Msg.getMsg(Env.getCtx(), "Select"));
        selPanel.add(selNorthPanel, BorderLayout.NORTH);
        selNorthPanel.add(lProduction, null);
        selNorthPanel.add(fProduction, null);
        selNorthPanel.add(selectionPanel, null);
        selPanel.setName("selPanel");

        selPanel.add(confirmPanelSel, BorderLayout.SOUTH);
        selPanel.add(scrollPane, BorderLayout.CENTER);
        scrollPane.getViewport().add(miniTable, null);
        confirmPanelSel.addActionListener(this);
        //
        tabbedPane.add(genPanel, Msg.getMsg(Env.getCtx(), "Generate"));
        genPanel.setLayout(genLayout);
        genPanel.add(info, BorderLayout.CENTER);
        genPanel.setEnabled(false);
        info.setBackground(CompierePLAF.getFieldBackground_Inactive());
        info.setEditable(false);
        genPanel.add(confirmPanelGen, BorderLayout.SOUTH);
        confirmPanelGen.addActionListener(this);
    } //	jbInit

    /**
     *	Fill Picks
     *		Column_ID from C_Order
     *  @throws Exception if Lookups cannot be initialized
     */
    private void fillPicks() throws Exception {
        MLookup orgL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0,
                                          COLUMN_M_PRODUCTION_ID,
                                          DisplayType.TableDir);
        fProduction = new VLookup("M_Production_ID", false, false, true, orgL);
        lProduction.setText(Msg.translate(Env.getCtx(), "M_Production_ID"));
        fProduction.addVetoableChangeListener(this);
    } //	fillPicks

    /**
     *	Dynamic Init.
     *	- Create GridController & Panel
     *	- AD_Column_ID from C_Order
     */
    private void dynInit() {
        //  create Columns
        miniTable.addColumn("M_ProductionLine_ID");
        miniTable.addColumn("Production");
        miniTable.addColumn("FinishedProduct");
        miniTable.addColumn("BOMProduct");
        miniTable.addColumn("MovementQty");
        miniTable.addColumn("Locator");
        miniTable.addColumn("QtyOnHand");
        miniTable.addColumn("AttributeSetInstance");
        miniTable.addColumn("Description");
        //
        miniTable.setMultiSelection(true);
        miniTable.setRowSelectionAllowed(true);
        //  set details
        miniTable.setColumnClass(0, IDColumn.class, false, " ");
        miniTable.setColumnClass(1, String.class, true,
                                 Msg.translate(Env.getCtx(), "M_Production_ID"));
        miniTable.setColumnClass(2, String.class, true,
                                 Msg.translate(Env.getCtx(), "M_Product_ID"));
        miniTable.setColumnClass(3, String.class, true,
                                 Msg.translate(Env.getCtx(), "M_ProductBOM_ID"));
        miniTable.setColumnClass(4, BigDecimal.class, true,
                                 Msg.translate(Env.getCtx(), "MovementQty"));
        miniTable.setColumnClass(5, String.class, true,
                                 Msg.translate(Env.getCtx(), "M_Locator_ID"));
        miniTable.setColumnClass(6, BigDecimal.class, true,
                                 Msg.translate(Env.getCtx(), "QtyOnHand"));
        miniTable.setColumnClass(7, String.class, true,
                                 Msg.translate(Env.getCtx(),
                                               "M_AttributeSetInstance_ID"));
        miniTable.setColumnClass(8, String.class, true,
                                 Msg.translate(Env.getCtx(), "Description"));
        //
        miniTable.autoSize();
        miniTable.getModel().addTableModelListener(this);
        //	Info
        statusBar.setStatusLine(Msg.getMsg(Env.getCtx(),
                                           "InventoryMoveGenerateSel")); //@@
        statusBar.setStatusDB(" ");
        //	Tabbed Pane Listener
        tabbedPane.addChangeListener(this);
    } //	dynInit

    /**
     *  Query Info
     */
    private void executeQuery() {
        log.info("");
        //  Create SQL
        StringBuffer sql = new StringBuffer(
                "select pl.m_productionline_id,pt.name as production,p.name as FinishedProduct,p2.name as BOMProduct, "
                + "-pl.movementqty as movementQty,l.value as Locator, "
                + "(select s.qtyonhand from m_storage s where s.m_product_id = pl.m_product_id and s.m_locator_id = pl.m_locator_id) as qtyonhand, "
                + "asi.description as AttributeSetInstance,pl.description from m_productionline pl "
                + "inner join m_productionplan pp on (pp.m_productionplan_id = pl.m_productionplan_id) "
                +
                "inner join m_production pt on (pt.m_production_id = pp.m_production_id) "
                +
                "inner join m_product p on (p.m_product_id = pp.m_product_id) "
                +
                "inner join m_product p2 on (p2.m_product_id = pl.m_product_id) "
                + "left join m_attributesetinstance asi on (asi.m_attributesetinstance_id = pl.m_attributesetinstance_id) "
                +
                "inner join m_locator l on (l.m_locator_id = pl.m_locator_id) "
                + "where pl.movementqty < 0 and pl.isSelected ='N'");

        if (m_M_Production_ID != null)
            sql.append(" AND pt.M_Production_ID=").append(m_M_Production_ID);
        //
        sql.append(" ORDER BY pt.M_Production_ID, p.name");

        //  reset table
        int row = 0;
        miniTable.setRowCount(row);
        //  Execute
        try {
            PreparedStatement pstmt = DB.prepareStatement(sql.toString());
            ResultSet rs = pstmt.executeQuery();
            //
            while (rs.next()) {
                //  extend table
                miniTable.setRowCount(row + 1);
                //  set values
                miniTable.setValueAt(new IDColumn(rs.getInt(1)), row, 0); //  M_ProductionLine_ID
                miniTable.setValueAt(rs.getString(2), row, 1); //  Production
                miniTable.setValueAt(rs.getString(3), row, 2); //  FinishedProduct
                miniTable.setValueAt(rs.getString(4), row, 3); //  BOMProduct
                miniTable.setValueAt(rs.getBigDecimal(5), row, 4); //  MovementQty
                miniTable.setValueAt(rs.getString(6), row, 5); //  Locator
                miniTable.setValueAt(rs.getBigDecimal(7), row, 6); //  QtyOnHand
                miniTable.setValueAt(rs.getString(8), row, 7); //  AttributeSetInstance
                miniTable.setValueAt(rs.getString(9), row, 8); //  Description
                //  prepare next
                row++;
            }
            rs.close();
            pstmt.close();
        } catch (SQLException e) {
            log.log(Level.SEVERE, sql.toString(), e);
        }
        //
        miniTable.autoSize();
        //statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
    } //  executeQuery

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -