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

📄 productionrun.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * $Id: ProductionRun.java 7238 2006-04-08 07:30:54Z jacopo $ * * * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org * Copyright (c) 2004 Nereide - www.nereide.biz * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */package org.ofbiz.manufacturing.jobshopmgt;import java.sql.Timestamp;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Map;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.manufacturing.techdata.TechDataServices;/** * ProductionRun Object used by the Jobshop management OFBiz comonents, * 	this object is used to find or updated an existing ProductionRun. * * @author     <a href="mailto:olivier.heintz@nereide.biz">Olivier Heintz</a> */public class ProductionRun {        public static final String module = ProductionRun.class.getName();    public static final String resource = "ManufacturingUiLabels";        protected GenericValue productionRun; // WorkEffort (PROD_ORDER_HEADER)    protected GenericValue productionRunProduct; // WorkEffortGoodStandard (type: PRUN_PROD_DELIV)    protected GenericValue productProduced; // Product (from WorkEffortGoodStandard of type: PRUN_PROD_DELIV)    protected Double quantity; // the estimatedQuantity        protected Timestamp estimatedStartDate;    protected Timestamp estimatedCompletionDate;    protected String productionRunName;    protected String description;    protected GenericValue currentStatus;    protected List productionRunComponents;    protected List productionRunRoutingTasks;    protected LocalDispatcher dispatcher;        /**     * indicate if quantity or estimatedStartDate has been modified and     *  estimatedCompletionDate not yet recalculated with recalculateEstimatedCompletionDate() methode.     */    private boolean updateCompletionDate = false;    /**     * indicate if quantity  has been modified, used for store() method to update appropriate entity.     */    private boolean quantityIsUpdated = false;        public ProductionRun(String productionRunId, GenericDelegator delegator, LocalDispatcher dispatcher) {        try {            if (! UtilValidate.isEmpty(productionRunId)) {                this.dispatcher = dispatcher;                GenericValue workEffort = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId));                if (workEffort != null) {                    // If this is a task, get the parent production run                    if (workEffort.getString("workEffortTypeId") != null && "PROD_ORDER_TASK".equals(workEffort.getString("workEffortTypeId"))) {                        workEffort = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", workEffort.getString("workEffortParentId")));                    }                }                this.productionRun = workEffort;                if (exist()) {                    this.estimatedStartDate = productionRun.getTimestamp("estimatedStartDate");                    this.estimatedCompletionDate = productionRun.getTimestamp("estimatedCompletionDate");                    this.productionRunName = productionRun.getString("workEffortName");                    this.description = productionRun.getString("description");                }            }        } catch (GenericEntityException e) {            Debug.logWarning(e.getMessage(), module);        }    }        /**     * test if the productionRun exist.     * @return true if it exist false otherwise.     **/    public boolean exist(){        return productionRun != null;    }        /**     * get the ProductionRun GenericValue .     * @return the ProductionRun GenericValue     **/    public GenericValue getGenericValue(){        return productionRun;    }    /**     * store  the modified ProductionRun object in the database.     *     <li>store the the productionRun header     *     <li> the productProduced related data     *     <li> the listRoutingTask related data     *     <li> the productComponent list related data     * @return true if success false otherwise     **/    public boolean store(){        if (exist()){            if (updateCompletionDate){                this.estimatedCompletionDate = recalculateEstimatedCompletionDate();            }            productionRun.set("estimatedStartDate",this.estimatedStartDate);            productionRun.set("estimatedCompletionDate",this.estimatedCompletionDate);            productionRun.set("workEffortName",this.productionRunName);            productionRun.set("description",this.description);            try {                productionRun.store();                if (quantityIsUpdated) {                    productionRunProduct.set("estimatedQuantity",this.quantity);                    productionRunProduct.store();                    quantityIsUpdated = false;                }                if (productionRunRoutingTasks != null) {                    for (Iterator iter = productionRunRoutingTasks.iterator(); iter.hasNext();){                        GenericValue routingTask = (GenericValue) iter.next();                        routingTask.store();                    }                }                if (productionRunComponents != null) {                    for (Iterator iter = productionRunComponents.iterator(); iter.hasNext();){                        GenericValue component = (GenericValue) iter.next();                        component.store();                    }                }            } catch (GenericEntityException e) {                Debug.logWarning(e.getMessage(), module);                return false;            }            return true;        }        return false;    }        /**     * get the Product GenericValue corresponding to the productProduced.     *     In the same time this method read the quantity property from SGBD     * @return the productProduced related object     **/    public GenericValue getProductProduced(){        if (exist()) {            if (productProduced == null) {                try {                    List productionRunProducts = productionRun.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV"),null);                    this.productionRunProduct = EntityUtil.getFirst(productionRunProducts);                    quantity = productionRunProduct.getDouble("estimatedQuantity");                    productProduced = productionRunProduct.getRelatedOneCache("Product");                } catch (GenericEntityException e) {                    Debug.logWarning(e.getMessage(), module);                }            }            return productProduced;        }        return null;    }        /**     * get the quantity property.     * @return the quantity property     **/    public Double getQuantity(){        if (exist()) {            if (quantity == null)  getProductProduced();            return quantity;        }        else return null;    }    /**     * set the quantity property and recalculated the productComponent quantity.     * @return     **/    public void setQuantity(Double newQuantity) {        if (quantity == null) getProductProduced();        double previousQuantity = quantity.doubleValue(), componentQuantity;        this.quantity = newQuantity;        this.quantityIsUpdated = true;        this.updateCompletionDate = true;        if (productionRunComponents == null) getProductionRunComponents();        for (Iterator iter = productionRunComponents.iterator(); iter.hasNext();){            GenericValue component = (GenericValue) iter.next();            componentQuantity = component.getDouble("estimatedQuantity").doubleValue();            component.set("estimatedQuantity", new Double(Math.floor((componentQuantity / previousQuantity * newQuantity.doubleValue() ) + 0.5)));        }        return;    }    /**     * get the estimatedStartDate property.     * @return the estimatedStartDate property     **/    public Timestamp getEstimatedStartDate(){        return (exist()? this.estimatedStartDate: null);    }    /**

⌨️ 快捷键说明

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