WarehouseManagementAction.java
package com.mycim.webapp.actions.warehouse;
import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.threadlocal.LocalContext;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.ObjectList;
import com.mycim.valueobject.inv.value.WarehouseNames;
import com.mycim.valueobject.prp.Operation;
import com.mycim.webapp.Constants;
import com.mycim.webapp.WebUtils;
import com.mycim.webapp.actions.AsmSetupAction;
import com.mycim.webapp.forms.WarehouseInfoForm;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 库房管理入口
*
* @author shijie.deng
* @date 2019/8/27
**/
public class WarehouseManagementAction extends AsmSetupAction {
@Override
public ActionForward init(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
WarehouseInfoForm theform = (WarehouseInfoForm) form;
Operation warehouse = getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
List<Map<String, String>> warehouseInventoryList = warehouseService
.getWarehouseInventoryList(warehouse.getInstanceRrn());
theform.setWarehouseInventoryList(warehouseInventoryList);
theform.setMaterialId("");
theform.setItemClass("");
theform.setMaterialType("");
theform.setTransformType("");
theform.setTransId(Constants.MODIFY_KEY);
request.setAttribute("instanceId", warehouse.getInstanceId());
return mapping.findForward(Constants.VIEW_KEY);
}
/**
* 查询
*/
public ActionForward queryByCondition(ActionMapping mapping, WarehouseInfoForm theform,
HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
long facilityRrn = LocalContext.getFacilityRrn();
Map<String, String> condition = new HashMap<>();
String materialRrn = null;
if (StringUtils.isNotEmpty(theform.getMaterialId())) {
materialRrn = StringUtils.toString(
getInstanceRrn(theform.getMaterialId().trim().toUpperCase(), facilityRrn, ObjectList.ITEM_KEY));
}
condition.put("materialRrn", materialRrn);
condition.put("materialClass", theform.getItemClass());
condition.put("materialType", theform.getMaterialType());
condition.put("transType", theform.getTransformType());
List<Map<String, String>> warehouseInventoryList = warehouseService
.getWarehouseInventoryList(warehouse.getInstanceRrn(), condition);
theform.setWarehouseInventoryList(warehouseInventoryList);
theform.setTransId(Constants.MODIFY_KEY);
return mapping.findForward(Constants.VIEW_KEY);
}
/**
* 接收物料
*/
public ActionForward receive(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(WarehouseNames.RECEIVE_TRANS);
}
/**
* 手动消耗物料
**/
public ActionForward manual(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
request.setAttribute("instanceId", warehouse.getInstanceId());
return mapping.findForward(WarehouseNames.MANUAL_TRANS);
}
/**
* 物料类型转换
**/
public ActionForward transtype(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(WarehouseNames.TRANSBADDEBRIS_TRANS);
}
/**
* 良品转不良品
**/
public ActionForward transBad(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(WarehouseNames.TRANSBAD_TRANS);
}
/**
* 退回物料
**/
public ActionForward transreturn(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(WarehouseNames.TRANSRETURN_TRANS);
}
/**
* 库房盘点
**/
public ActionForward stocktake(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(WarehouseNames.STOCKTAKE_TRANS);
}
/**
* 库房转移
**/
public ActionForward transferwarehouse(ActionMapping mapping, WarehouseInfoForm theform,
HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(WarehouseNames.TRANSFER_WAREHOUSE_TRANS);
}
/**
* 事务历史
**/
public ActionForward history(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward(Constants.HISTORY_KEY);
}
/**
* 物料详细查询
**/
public ActionForward members(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
String materialId = WebUtils.getParameterUpperCase("materialId", request);
theform.setMaterialId(materialId);
return mapping.findForward(Constants.MEMBERS_KEY);
}
/**
* 接收物料历史
**/
public ActionForward receiveHistory(ActionMapping mapping, WarehouseInfoForm theform, HttpServletRequest request) {
Operation warehouse = this.getRequestWarehouse(theform, request);
theform.setInstanceId(warehouse.getInstanceId());
theform.setNamedSpace(warehouse.getNamedSpace());
theform.setInstanceDesc(warehouse.getInstanceDesc());
return mapping.findForward("receiveHistory");
}
}