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

📄 productionrunservices.java

📁 国外的一套开源CRM
💻 JAVA
字号:
/*
 * $Id: ProductionRunServices.java,v 1.2 2003/12/09 20:49:17 holivier Exp $
 *
 * Copyright (c) 2001, 2002, 2003 The Open For Business Project - www.ofbiz.org
 *
 * 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.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
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.condition.EntityExpr;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.util.EntityTypeUtil;
import org.ofbiz.entity.util.EntityUtil;
import org.ofbiz.security.Security;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ModelService;
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.GenericServiceException;

import org.ofbiz.manufacturing.techdata.TechDataServices;

/**
 * Services for Production Run maintenance
 *
 * @author     <a href="mailto:olivier.heintz@nereide.biz">Olivier Heintz</a>
 * @version    $Revision: 1.2 $
 * @since      3.0
 */
public class ProductionRunServices {

    public static final String module = ProductionRunServices.class.getName();
    public static final String resource = "ManufacturingUiLabels";

    /**
     * Deletes a ProductionRun.
     * @param ctx The DispatchContext that this service is operating in.
     * @param context Map containing the input parameters.
     * @return Map with the result of the service, the output parameters.
     */
    public static Map deleteProductionRun(DispatchContext ctx, Map context) {

        /*
         * pretty serious operation, status depending would delete:
         * - task
         * - goods
         * - inventoryItem
         * - ...
         *
         * The analyse is plan but I don't know when ;-) ...
         */
        return ServiceUtil.returnError("Cannot delete productionRun , operation not yet implemented");
    }

    /**
     * Creates a Production Run.
     *  - check if routing - product link exist
     *  - check if product have a Bill Of Material
     *  - check if routing have routingTask
     *  - create the workEffort for ProductionRun
     *  - for each valid routingTask of the routing create a workeffort-task
     *  - for the first routingTask, create for all the valid productIdTo with no associateRoutingTask  a WorkEffortGoodStandard
     *  - for each valid routingTask of the routing and valid productIdTo associate with this RoutingTask create a WorkEffortGoodStandard
     * @param ctx The DispatchContext that this service is operating in.
     * @param context Map containing the input parameters, productId, routingId, pRQuantity, startDate, workEffortName, description
     * @return Map with the result of the service, the output parameters.
     */
    public static Map createProductionRun(DispatchContext ctx, Map context) {
        Map result = new HashMap();
        GenericDelegator delegator = ctx.getDelegator();
		LocalDispatcher dispatcher = ctx.getDispatcher();        
       	Security security = ctx.getSecurity();
        Timestamp now = UtilDateTime.nowTimestamp();
	    List msgResult = new LinkedList();
        Locale locale = (Locale) context.get("locale");
       	GenericValue userLogin = (GenericValue) context.get("userLogin");
/* TODO: security management  and finishing cleaning (ex copy from PartyServices.java)
		if (!security.hasEntityPermission(secEntity, secOperation, userLogin)) {
			result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
			result.put(ModelService.ERROR_MESSAGE, "You do not have permission to perform this operation for this party");
			return partyId;
		}
*/
        String productId = (String) context.get("productId");
		String workEffortId = (String) context.get("routingId");
		java.sql.Timestamp  startDate =  (java.sql.Timestamp) context.get("startDate");
		String statusId = "PRUN_CREATED";
		GenericValue routing = null, product = null;
		List workEffortProducts = null, productBoms = null, routingTaskAssocs = null ;

		try {
			workEffortProducts = delegator.findByAnd("WorkEffortGoodStandard", UtilMisc.toMap("productId", productId,"workEffortId",workEffortId));
			routing = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId",workEffortId));
			product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
// TODO: sort by seq and filter by date, pour ne prendre que les composants valide 

⌨️ 快捷键说明

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