First commit of the "hhfacility" component a special purpose application for warehouse operations done using hand held devices.

The application is still in a very initial stage, a lot of cleanups still need to be done, but it is a nice start.
It has been contributed by Daniel Goodwin and Ray Barlow; see OFBIZ-226 for details.
Daniel, Ray many thanks to both of you.



git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@482801 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacopo Cappellato
2006-12-05 22:00:29 +00:00
parent efec6cd383
commit 53c1eff60c
8 changed files with 752 additions and 0 deletions
@@ -0,0 +1,88 @@
/*
* Copyright 2001-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.ofbiz.hhfacility;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.GeneralRuntimeException;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.webapp.control.RequestHandler;
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.DispatchContext;
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
public class FacilitySession {
public static final String module = FacilitySession.class.getName();
public static final String findProductsById(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
String idValueStr = request.getParameter("idValue");
String facilityIdStr = request.getParameter("facilityId");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
if (UtilValidate.isEmpty(idValueStr)) {
return "success";
}
Map productsMap = null;
try {
productsMap = dispatcher.runSync("findProductsById", UtilMisc.toMap("idValue", idValueStr, "facilityId", facilityIdStr));
} catch (GenericServiceException e) {
Debug.logError(e, "Problem in findProductsById", module);
return "error";
}
if (ServiceUtil.isError(productsMap)) {
return "error";
}
List productList = (List)productsMap.get("productList");
if (productList != null && productList.size() == 1) {
// Found only one product so go get it and redirect to the edit page
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
GenericValue product = EntityUtil.getFirst(productList);
String requestName = "/productstocktake?facilityId=" + facilityIdStr + "&productId=" + product.getString("productId");;
String target = rh.makeLink(request, response, requestName, false, false, false);
try {
response.sendRedirect(target);
return "none";
} catch (IOException e) {
Debug.logError(e, "Could not send redirect to: " + target, module);
}
}
request.setAttribute("productList", productList);
return "success";
}
}
@@ -0,0 +1,23 @@
/*
* Copyright 2001-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
import org.ofbiz.entity.*;
delegator = request.getAttribute("delegator");
facilities = delegator.findAll("Facility");
context.put("facilities", facilities);
@@ -0,0 +1,25 @@
/*
* Copyright 2001-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
import org.ofbiz.entity.*;
delegator = request.getAttribute("delegator");
productList = request.getAttribute("productList");
if ( productList != null ) {
context.put("productList", productList);
}
@@ -0,0 +1,111 @@
/*
* Copyright 2001-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
import org.ofbiz.entity.*;
import org.ofbiz.base.util.*;
import org.ofbiz.entity.util.EntityUtil;
import javolution.util.FastMap;
delegator = request.getAttribute("delegator");
productId = request.getParameter("productId");
if ( productId == null ) {
productId = session.getAttribute("productId");
}
if ( productId != null ) {
product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));
context.put("product", product);
facilityId = request.getParameter("facilityId");
contextInput = UtilMisc.toMap("productId",productId, "facilityId", facilityId);
resultOutput = dispatcher.runSync("getInventoryAvailableByFacility",contextInput);
quantitySummary = new HashMap();
quantitySummary.put("facilityId", facilityId);
quantitySummary.put("atp_qoh", ((Double)resultOutput.get("availableToPromiseTotal")).intValue() + " / " +
((Double)resultOutput.get("quantityOnHandTotal")).intValue());
context.put("quantitySummary", quantitySummary);
// For now this just generates a visual list of locations set against the product for this facility.
// todo: Will need to be able to edit and change these values at some point in the future.
productFacilityLocList = delegator.findByAnd("ProductFacilityLocation", UtilMisc.toMap("productId", productId, "facilityId", facilityId));
productFacilityLocListIter = productFacilityLocList.iterator();
facStr = null;
while (productFacilityLocListIter.hasNext()) {
facilityLoc = productFacilityLocListIter.next();
if ( UtilValidate.isEmpty(facStr) ) {
facStr = facilityLoc.get("locationSeqId");
} else {
facStr = facStr + ", " + facilityLoc.get("locationSeqId");
}
}
context.put("productFacilityLocations", facStr);
// Now we build a list of locations for inventory items against the facility.
// todo: change this to a select from inv_items where productId and facilityId matches distinct (locationSeqId).
invItemList = delegator.findByAnd("InventoryItem",
UtilMisc.toMap("productId", productId, "facilityId", facilityId));
Map locations = new HashMap();
boolean negativeQOH = false;
invItemListIter = invItemList.iterator();
while (invItemListIter.hasNext()) {
invItem = invItemListIter.next();
int qoh = ((Double)invItem.get("quantityOnHandTotal")).intValue();
if ( qoh < 0 )
negativeQOH = true;
locationFound = (String)invItem.get("locationSeqId");
if ( locationFound == null ) {
locationFound = "nullField";
}
if ( locations.get(locationFound) == null ) {
locations.put(locationFound, locationFound);
}
}
// Go through and build the list of atp/qoh against each location
productFacilityLocations = new ArrayList();
locationsIter = locations.keySet().iterator();
while (locationsIter.hasNext()) {
location = locationsIter.next();
contextInput = UtilMisc.toMap("productId",productId, "facilityId", facilityId, "locationSeqId", location);
resultOutput = dispatcher.runSync("getInventoryAvailableByLocation",contextInput);
quantitySummary = new HashMap();
quantitySummary.put("productId", productId);
quantitySummary.put("facilityId", facilityId);
if ( "nullField".equals( location ) == true ) {
quantitySummary.put("locationSeqId", "");
} else {
quantitySummary.put("locationSeqId", location);
}
quantitySummary.put("atp_qoh", ((Double)resultOutput.get("availableToPromiseTotal")).intValue() + " / " +
((Double)resultOutput.get("quantityOnHandTotal")).intValue());
productFacilityLocations.add(quantitySummary);
}
context.put("productQtyByLocations", productFacilityLocations);
if ( negativeQOH == true ) {
context.put("negativeQOH", "true");
}
}
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!--
Copyright 2001-2006 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<web-app>
<display-name>Facility Handheld Application</display-name>
<description>Facility Handheld Application</description>
<context-param>
<param-name>localDispatcherName</param-name>
<param-value>hhfacility</param-value>
<description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
</context-param>
<context-param>
<param-name>serviceReaderUrls</param-name>
<param-value>/WEB-INF/services.xml</param-value>
<description>Configuration File(s) For The Service Dispatcher</description>
</context-param>
<context-param>
<param-name>entityDelegatorName</param-name>
<param-value>default</param-value>
<description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
</context-param>
<filter>
<filter-name>ContextFilter</filter-name>
<display-name>ContextFilter</display-name>
<filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
<init-param>
<param-name>disableContextSecurity</param-name>
<param-value>N</param-value>
</init-param>
<init-param>
<param-name>allowedPaths</param-name>
<param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css</param-value>
</init-param>
<init-param>
<param-name>errorCode</param-name>
<param-value>403</param-value>
</init-param>
<init-param>
<param-name>redirectPath</param-name>
<param-value>/control/main</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener><listener-class>org.ofbiz.webapp.control.ControlEventListener</listener-class></listener>
<listener><listener-class>org.ofbiz.webapp.control.LoginEventListener</listener-class></listener>
<!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface -->
<!-- <listener><listener-class>org.ofbiz.webapp.control.ControlActivationEventListener</listener-class></listener> -->
<servlet>
<servlet-name>ControlServlet</servlet-name>
<display-name>ControlServlet</display-name>
<description>Main Control Servlet</description>
<servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ControlServlet</servlet-name>
<url-pattern>/control/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout> <!-- in minutes -->
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>
@@ -0,0 +1,32 @@
<#--
Copyright 2001-2006 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
</td>
</tr>
<tr class="boxtop">
<td width=100%>
</td>
</tr>
<tr height=24 class="boxbottom">
<td width=100%>
<span class="tabletext">
Hand Held Facility
</span>
</td>
</tr>
</table>
</body>
</html>
@@ -0,0 +1,93 @@
<#--
Copyright 2001-2006 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<#assign previousParams = sessionAttributes._PREVIOUS_PARAMS_?if_exists>
<#if previousParams?has_content>
<#assign previousParams = "?" + previousParams>
</#if>
<#assign username = requestParameters.USERNAME?default((sessionAttributes.autoUserLogin.userLoginId)?default(""))>
<#if username != "">
<#assign focusName = false>
<#else>
<#assign focusName = true>
</#if>
<table width='250' border='0' cellpadding='0' cellspacing='0' align='center'>
<tr>
<td width='100%' valign='top'>
<table border='0' width='100%' cellspacing='0' cellpadding='0' class='boxoutside'>
<tr>
<td width='100%'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' class='boxtop'>
<tr>
<td valign='middle' align='center'>
<div class="boxhead">Login</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width='100%'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' class='boxbottom'>
<tr>
<td align="center" valign="middle" width='100%'>
<form method="post" action="<@ofbizUrl>login${previousParams?if_exists}</@ofbizUrl>" name="loginform" style='margin: 0;'>
<table width='100%' border='0' cellpadding='0' cellspacing='2'>
<tr>
<td align="right">
<span class="tabletext">Username&nbsp;</span>
</td>
<td align="left">
<input type="text" class="inputBox" name="USERNAME" value="${username}" size="20">
</td>
</tr>
<tr>
<td align="right">
<span class="tabletext">Password&nbsp;</span>
</td>
<td align="left">
<input type="password" class="inputBox" name="PASSWORD" value="" size="20">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<!--<a href="javascript:document.loginform.submit()" class="buttontext">[Login]</a>-->
<input type="submit" value="Login" class="loginButton">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
<!--
<#if focusName>
document.loginform.USERNAME.focus();
<#else>
document.loginform.PASSWORD.focus();
</#if>
//-->
</script>
@@ -0,0 +1,289 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2001-2006 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-screen.xsd">
<screen name="GlobalDecorator">
<section>
<widgets>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/includes/header.ftl"/></html></platform-specific>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/includes/messages.ftl"/></html></platform-specific>
<decorator-section-include name="body"/>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/includes/footer.ftl"/></html></platform-specific>
</widgets>
</section>
</screen>
<screen name="CommonDecorator">
<section>
<widgets>
<include-screen name="GlobalDecorator"/>
</widgets>
</section>
</screen>
<screen name="FacilityDecorator">
<section>
<actions>
<set field="facilityId" from-field="parameters.facilityId"/>
<entity-one entity-name="Facility" value-name="parameters.facility"/>
</actions>
<widgets>
<decorator-screen name="CommonDecorator">
<decorator-section name="body">
<container>
<label style="head2">${parameters.facility.facilityName}</label>
</container>
<decorator-section-include name="body"/>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="login">
<section>
<widgets>
<decorator-screen name="CommonDecorator">
<decorator-section name="body">
<platform-specific>
<html><html-template location="component://hhfacility/webapp/hhfacility/login.ftl"/></html>
</platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="main">
<section>
<widgets>
<decorator-screen name="CommonDecorator">
<decorator-section name="body">
<section>
<condition><if-empty field-name="userLogin"/></condition>
<widgets>
<container><label style="tabletext" text="Please login"/></container>
</widgets>
</section>
<section>
<widgets>
<container><label style="head1">Facilities</label></container>
<include-form name="ListFacilities" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
</widgets>
</section>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="menu">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/menu.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="receipt">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Goods Receipt</label>
</container>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/receipt.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="poreceipt">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">PO Receipt</label>
</container>
<include-form name="POEnter" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="linereceipt">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">PO Line Receipt</label>
</container>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="productreceipt">
<section>
<actions>
<set field="focusField" value="productId"/>
</actions>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Product Receipt</label>
</container>
<include-form name="ProductEnter" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/setFocusOnField.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="qtyreceipt">
<section>
<actions>
<set field="productId" from-field="parameters.productId"/>
<entity-one entity-name="Product" value-name="product"/>
<set field="focusField" value="productLocation"/>
</actions>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<include-form name="ProductQtyEnter" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/setFocusOnField.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="movement">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Movement</label>
</container>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="picking">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Picking</label>
</container>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="packing">
<section>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Packing</label>
</container>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="stocktake">
<section>
<actions>
<set field="idValue" from-field="parameters.idValue"/>
<script location="component://hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh"/>
</actions>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Find Product Stocktake</label>
</container>
<include-form name="FindProductStock" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/stocktake.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="productstocktake">
<section>
<actions>
<script location="component://hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh"/>
<set field="locationSeqId" from-field="productFacilityLocations"/>
</actions>
<widgets>
<decorator-screen name="FacilityDecorator">
<decorator-section name="body">
<container>
<label style="head1">Stocktake</label>
</container>
<include-form name="ProductStocktake" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
<include-form name="UpdateProductStocktake" location="component://hhfacility/webapp/hhfacility/forms/FacilityForms.xml"/>
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/productstocktake.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
<screen name="facilities">
<section>
<actions>
<entity-condition entity-name="Facility" list-name="facilities">
<order-by field-name="facilityId"/>
</entity-condition>
</actions>
<widgets>
<decorator-screen name="CommonDecorator">
<decorator-section name="body">
<platform-specific><html><html-template location="component://hhfacility/webapp/hhfacility/facilities.ftl"/></html></platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
</screens>