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

📄 editworkeffortgoodstandard.bsh

📁 国外的一套开源CRM
💻 BSH
字号:
/*
 *  Copyright (c) 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.
 *
 *@author     Olivier.Heintz@nereide.biz
 *@version    $Revision: 1.3 $
 *@since      3.0
 */


import java.sql.Timestamp;
import java.util.*;
import org.ofbiz.base.util.*;
import org.ofbiz.entity.*;
import org.ofbiz.entity.model.DynamicViewEntity;
import org.ofbiz.entity.model.ModelKeyMap;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.condition.EntityExpr;
import org.ofbiz.entity.util.EntityListIterator;
import org.ofbiz.content.widget.html.*;

security = request.getAttribute("security");
delegator = request.getAttribute("delegator");

if(security.hasEntityPermission("MANUFACTURING", "_VIEW", session)) {
    context.put("hasPermission", Boolean.TRUE);
} else {
    context.put("hasPermission", Boolean.FALSE);
}
String byProduct = request.getParameter("byProduct");
String routingTemplate = request.getParameter("routingTemplate");
String productId = request.getParameter("productId");
String workEffortId  = request.getParameter("workEffortId");
String workEffortName = null;
String statusId = null;
List allRoutingProductLinks = null;
if ("Y".equals(routingTemplate)) statusId = "ROU_PROD_TEMPLATE";

DynamicViewEntity dynamicViewEntity = new DynamicViewEntity();
dynamicViewEntity.addMemberEntity("WEGS", "WorkEffortGoodStandard");
dynamicViewEntity.addAliasAll("WEGS",null);
dynamicViewEntity.addMemberEntity("WE", "WorkEffort");
dynamicViewEntity.addViewLink("WEGS", "WE", Boolean.FALSE, ModelKeyMap.makeKeyMapList("workEffortId"));
dynamicViewEntity.addAlias("WE", "workEffortName", "workEffortName", null, null, null, null);
dynamicViewEntity.addMemberEntity("PRD", "Product");
dynamicViewEntity.addViewLink("WEGS", "PRD", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));
dynamicViewEntity.addAlias("PRD", "internalName", "internalName", null, null, null, null);

if ("Y".equals(byProduct)) {
		 EntityListIterator eli = delegator.findListIteratorByCondition(dynamicViewEntity, EntityExpr("productId", EntityOperator.EQUALS, productId), null, null, null, null);
		 allRoutingProductLinks = eli.getCompleteList();
}
else { 
		 EntityListIterator eli = delegator.findListIteratorByCondition(dynamicViewEntity,new EntityExpr("workEffortId", EntityOperator.EQUALS, workEffortId), null, null, null, null);
		 allRoutingProductLinks = eli.getCompleteList();
		 workEffortName=delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", workEffortId)).getString("workEffortName");
}
		

HtmlFormWrapper listRoutingProductLinkWrapper = new HtmlFormWrapper("/routing/RoutingTaskForms.xml", "ListRoutingProductLink", request, response);
listRoutingProductLinkWrapper.putInContext("allRoutingProductLinks", allRoutingProductLinks);
listRoutingProductLinkWrapper.putInContext("uiLabelMap", request.getAttribute("uiLabelMap"));
listRoutingProductLinkWrapper.putInContext("byProduct", byProduct);
listRoutingProductLinkWrapper.putInContext("routingTemplate", routingTemplate);
context.put("listRoutingProductLinkWrapper",listRoutingProductLinkWrapper);
context.put("allRoutingProductLinks",allRoutingProductLinks);

GenericValue routingProductLink = null;
String fromDateString = request.getParameter("fromDate");
if (productId != null && workEffortId != null && fromDateString != null) {  
	Timestamp fromDate = null;
	try {fromDate = Timestamp.valueOf(fromDateString);}
	catch (IllegalArgumentException e){ fromDate=null; }
	routingProductLink = delegator.findByPrimaryKey("WorkEffortGoodStandard", UtilMisc.toMap("productId", productId,"workEffortId", workEffortId,"fromDate",fromDate));
	if (routingProductLink != null) { 
		HtmlFormWrapper updateRoutingProductLinkWrapper = new HtmlFormWrapper("/routing/RoutingTaskForms.xml", "UpdateRoutingProductLink", request, response);
		updateRoutingProductLinkWrapper.putInContext("routingProductLink", routingProductLink);
		updateRoutingProductLinkWrapper.putInContext("uiLabelMap", request.getAttribute("uiLabelMap"));
		updateRoutingProductLinkWrapper.putInContext("byProduct", byProduct);
		updateRoutingProductLinkWrapper.putInContext("routingTemplate", routingTemplate);
		if ("N".equals(byProduct)) {
				updateRoutingProductLinkWrapper.putInContext("workEffortName", workEffortName);
				updateRoutingProductLinkWrapper.putInContext("internalName", routingProductLink.getRelatedOne("Product").getString("internalName"));
		}
		context.put("routingProductLink", routingProductLink);
		context.put("updateRoutingProductLinkWrapper", updateRoutingProductLinkWrapper);
	}
}

HtmlFormWrapper addRoutingProductLinkWrapper = new HtmlFormWrapper("/routing/RoutingTaskForms.xml", "AddRoutingProductLink", request, response);
addRoutingProductLinkWrapper.putInContext("uiLabelMap", request.getAttribute("uiLabelMap"));
addRoutingProductLinkWrapper.putInContext("byProduct", byProduct);
addRoutingProductLinkWrapper.putInContext("routingTemplate", routingTemplate);
addRoutingProductLinkWrapper.putInContext("statusId", statusId);
if ("Y".equals(byProduct)) { 
			addRoutingProductLinkWrapper.putInContext("productId", productId);
			addRoutingProductLinkWrapper.putInContext("workEffortId", null);
			}
else    {addRoutingProductLinkWrapper.putInContext("workEffortId", workEffortId);
			addRoutingProductLinkWrapper.putInContext("workEffortName", workEffortName);
			addRoutingProductLinkWrapper.putInContext("productId", null);
			}
context.put("addRoutingProductLinkWrapper", addRoutingProductLinkWrapper);



⌨️ 快捷键说明

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