Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseView.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseView.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseView.jsp (revision 12652) @@ -0,0 +1,75 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ page import="com.forgon.tools.SpringBeanManger" %> +<%@page import="com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig"%> +<%@page import="com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager"%> +<% +SupplyRoomConfigManager supplyRoomConfigManager = (SupplyRoomConfigManager)SpringBeanManger.getBean("supplyRoomConfigManager"); +SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager.getSystemParamsObj(); +SupplyRoomConfig firstSupplyRoom = supplyRoomConfigManager.getFirstSupplyRoomConfig(); +String departCode = firstSupplyRoom.getOrgUnitCoding(); +LoginUserData userData = AcegiHelper.getLoginUser(); +String currentOrgUnitCode = userData.getCurrentOrgUnitCode(); +String userName = userData.getUserFullName(); +request.setAttribute("userName", userName); +%> + + + +仓库管理 + + + +<%@ include file="/common/includeExtJsAndCss.jsp"%> + + + + + + + + + + + + + + + + + + + +
+
+
+ + \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/action/WareHouseAction.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/action/WareHouseAction.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/action/WareHouseAction.java (revision 12652) @@ -0,0 +1,211 @@ +package com.forgon.disinfectsystem.basedatamanager.warehouse.action; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import net.sf.json.JSONObject; +import net.sf.json.JsonConfig; +import net.sf.json.processors.DefaultValueProcessor; +import net.sf.json.util.CycleDetectionStrategy; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.basedatamanager.warehouse.service.WareHouseManager; +import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.basedatamanager.warehouse.WareHouse; +import com.forgon.tools.StrutsParamUtils; +import com.opensymphony.xwork2.ModelDriven; +import com.opensymphony.xwork2.Preparable; + +/** + * 仓库action类 + * @author shuyongfu + * @since 2016-03-21 + */ +@ParentPackage(value = "default") +@Namespace(value = "/disinfectSystem/baseData") +@Action(value = "wareHouseAction") +public class WareHouseAction implements ModelDriven, + Preparable { + + private Logger logger = Logger.getLogger(WareHouseAction.class); + + private WareHouse wareHouse; + + private WareHouseManager wareHouseManager; + + private SupplyRoomConfigManager supplyRoomConfigManager; + + public void setSupplyRoomConfigManager( + SupplyRoomConfigManager supplyRoomConfigManager) { + this.supplyRoomConfigManager = supplyRoomConfigManager; + } + + + public void setWareHouse(WareHouse wareHouse) { + this.wareHouse = wareHouse; + } + + + public void setWareHouseManager(WareHouseManager wareHouseManager) { + this.wareHouseManager = wareHouseManager; + } + + + /** + * 保存仓库数据 + */ + public void saveWareHouse() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("success", true); + if (wareHouse != null) { + try { + wareHouseManager.saveOrUpdateWareHouse(wareHouse); + } catch (Exception e) { + jsonObject.put("success", false); + jsonObject.put("message", "保存失败"); + logger.error("保存仓库失败:" + e); + } + } + try { + StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); + StrutsParamUtils.getResponse().getWriter().print(jsonObject); + } catch (IOException e) { + logger.error("保存仓库写入响应消息至前端失败:" + e); + } + } + + /** + * 删除仓库 + */ + public void deleteWareHouse() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("success", true); + String idStr = StrutsParamUtils.getPraramValue("ids", ""); + try { + if (StringUtils.isNotBlank(idStr)) { + String[] str = idStr.split(";"); + List idList = new ArrayList(); + for (String id : str) { + idList.add(Long.parseLong(id)); + } + wareHouseManager.removeWareHouse(idList); + } + } catch (Exception e) { + jsonObject.put("success", false); + jsonObject.put("message", "保存失败"); + logger.error("保存仓库写入响应消息至前端失败:" + e); + } + HttpServletResponse httpServletResponse = StrutsParamUtils + .getResponse(); + httpServletResponse.setCharacterEncoding("UTF-8"); + try { + httpServletResponse.getWriter().print(jsonObject); + } catch (IOException e) { + logger.error("删除仓库写入响应消息至前端失败:" + e); + } + } + + /** + * 加载仓库信息 + */ + public void loadWareHouse() { + try { + StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); + JsonConfig config = new JsonConfig(); + config.registerDefaultValueProcessor(Double.class, + new DefaultValueProcessor() { + @Override + public Object getDefaultValue( + @SuppressWarnings("rawtypes") Class arg0) { + return null; + } + }); + config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); + wareHouse = wareHouseManager.getWareHouseById(wareHouse.getId()); + Map map = new HashMap(); + map.put("success", true); + map.put("data", wareHouse); + JSONObject jsonObject = JSONObject.fromObject(map, config); + StrutsParamUtils.getResponse().getWriter() + .println(jsonObject.toString()); + } catch (Exception e) { + logger.error("加载仓库信息失败:" + e); + } + } + + /** + * 查询所有供应室 + * @return + */ + public void getCssds() { + SupplyRoomConfig firstSupplyRoom = supplyRoomConfigManager + .getFirstSupplyRoomConfig(); + List secondSupplyRooms = supplyRoomConfigManager + .getSecondSupplyRoomList(); + List> mapList = new ArrayList>(); + if (firstSupplyRoom != null) { + Map temp = new HashMap(); + temp.put("departCode", firstSupplyRoom.getOrgUnitCoding()); + temp.put("departName", firstSupplyRoom.getOrgUnitName()); + mapList.add(temp); + } + + if (secondSupplyRooms != null) { + for (SupplyRoomConfig config : secondSupplyRooms) { + Map temp = new HashMap(); + temp.put("departCode", config.getOrgUnitCoding()); + temp.put("departName", config.getOrgUnitName()); + mapList.add(temp); + } + } + Map map = new HashMap(); + map.put("totalCount", mapList.size()); + map.put("data", mapList); + JSONObject json = JSONObject.fromObject(map); + + HttpServletResponse response = StrutsParamUtils.getResponse(); + response.setCharacterEncoding("UTF-8"); + PrintWriter out; + try { + out = response.getWriter(); + out.print(json.toString()); + out.close(); + } catch (IOException e) { + logger.error("查询供应室信息失败:" + e); + } + + } + + + @Override + public void prepare() throws Exception { + String id = StrutsParamUtils.getPraramValue("id", ""); + if (StringUtils.isNotBlank(id) && !id.equals("0")) { + wareHouse = wareHouseManager + .getWareHouseById(Long.valueOf(id)); + } else { + wareHouse = new WareHouse(); + } + } + + + @Override + public WareHouse getModel() { + return wareHouse; + } + + +} Index: ssts-web/src/main/webapp/WEB-INF/dwr.xml =================================================================== diff -u -r12562 -r12652 --- ssts-web/src/main/webapp/WEB-INF/dwr.xml (.../dwr.xml) (revision 12562) +++ ssts-web/src/main/webapp/WEB-INF/dwr.xml (.../dwr.xml) (revision 12652) @@ -26,6 +26,11 @@ + + + + + Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseView.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseView.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseView.js (revision 12652) @@ -0,0 +1,160 @@ +var grid; + +// 删除仓库 +function deleteWareHouse() { + + var records = grid.getSelectionModel().getSelections(); + + if (records.length == 0) { + showResult("请选择要删除的仓库!"); + return false; + } + var ids = null; + for ( var i = 0, len = records.length; i < len; i++) { + if (ids == null) { + ids = records[i].data['id']; + } else { + ids = ids + ';' + records[i].data['id']; + } + } + top.Ext.MessageBox.confirm("请确认","是否确定要删除选中的仓库信息?", + function(button, text) { + if ("yes" == button) + Ext.Ajax.request( { + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!deleteWareHouse.do', + params : {ids : ids}, + success : function(response, options) { + var result = Ext.decode(response.responseText); + var success = result.success; + if (true != success) { + showResult(result.cause); + return; + } else { + showResult('删除成功'); + grid.dwrReload(); + } + }, + failure : function(response, options) { + var result = Ext.decode(response.responseText); + showResult(result.cause); + } + }); + }); + +} + +var refresh = function() { + grid.dwrReload(); + grid.store.reload(); +}; + +var loadFormData = function(grid) { + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择要修改的仓库!"); + return false; + } + if (records.length > 1) { + showResult("一次只能修改一个仓库!"); + return false; + } + id = records[0].data['id']; + addAndEditWareHouse(id); +}; + +/** + * 修改记录 + * modifyRecord函数 触发modify函数调用,并传入当前列的值以及record.data对象 + * 页面中需要定义 modify(v,data) 函数 + */ +function modify(v,data){ + loadFormData(grid); +} + +Ext.onReady(function() { + Ext.QuickTips.init(); + // 记录cookie(3步) + + var columns = [ + {header : "仓库id",width : 180,dataIndex : 'id', hidden:true,renderer : modifyRecord}, + {header : "仓库名称",width : 180,dataIndex : 'name'}, + {header : "所属供应室",width : 90,dataIndex : 'orgUnitName'}, + {header : "顺序",width : 65,dataIndex : 'sequence'}, + {header : "备注",width : 100,dataIndex : 'remark',id:'remark'} + ]; + + var readerDetail = [ + {name : 'id'}, + {name : 'name'}, + {name : 'orgUnitName'}, + {name : 'sequence'}, + {name : 'remark'} + ]; + + var filters = new Ext.grid.GridFilters({ + filters : [ + {type : 'string',dataIndex : 'name'}, + {type : 'string',dataIndex : 'orgUnitName'}, + {type : 'numeric',dataIndex : 'sequence'}, + {type : 'string',dataIndex : 'remark'} + ] + }); + + + var sign = true; + var tbar = [ { + text : '添加', + hidden : SSTS_Tousse_Create, + iconCls : 'btn_ext_application_add', + handler : function() { + addAndEditWareHouse(0,'否'); + } + }, '-',{ + text : '修改', + hidden : SSTS_Tousse_Update, + iconCls : 'btn_ext_application_edit', + id : 'editTbar', + handler : function() { + loadFormData(grid); + } + }, '-',{ + text : '删除', + hidden : SSTS_Tousse_Delete, + iconCls : 'btn_ext_application_del', + handler : function() { + deleteWareHouse(grid); + } + }]; + var dwrCallParams = null; + + Ext.ux.ForgonPageGrid.prototype.getGridParameterMap = function() { + + }; + + grid = new Ext.ux.ForgonPageGrid( { + title : '仓库列表', + tbar : tbar, + pageSize : 20, + defaultSortField : 'id', + defaultSortDirection : 'ASC', + isCheckboxSelectionModel : true, + rememberSelected : false, + isShowSearchField : true, + columns : columns, + plugins : filters, + autoExpandColumn : 'remark', + renderTo : 'gridDiv', + frame : false + }, readerDetail, WarehouseTableManager.findWareHouseTableList, dwrCallParams // 这个参数只是占位作用 + ); + + var viewport = new Ext.Viewport( { + layout : 'border', + items : [{ + region : 'center', + margins : '0 0 0 0', + layout : 'fit', + items : grid + } ] + }); + }); \ No newline at end of file Index: ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseForm.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseForm.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/basedatamanager/warehouse/wareHouseForm.js (revision 12652) @@ -0,0 +1,192 @@ +var id; +//仓库表单面板 +var formObj; +//仓库对话框对象 +var wareHouseWin; +//新增与修改仓库 +function addAndEditWareHouse(id) { + this.id = id; + formObj = new top.Ext.FormPanel({ + id : 'wareHouseForm', + frame : true, + labelSeparator : ':', + labelAlign:'right', + fileUpload : true, + bodyStyle : 'padding:5px 5px 0px 5px;', + width: 600, + labelWidth : 80, + autoScroll : true, + height : 200, + items : [{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'orgUnitId', + id : 'orgUnitId' + },{ + layout : 'column', + labelWidth : 80, + items : [{ + columnWidth : 1, + xtype : "fieldset", + title: '仓库信息', + bodyStyle:'padding:1px;', + layout : 'column', + autoHeight : true, + items : [{ + columnWidth : .4, + layout : 'form', + items:[{ + xtype : 'textfield', + fieldLabel : "仓库名称", + allowBlank : false, + blankText : '请输入名称!', + name : "name", + id : "name", + anchor : '100%', + listeners:{ + change:function(field,nV,oV){ + var value = nV.trim(); + field.setValue(value); + } + } + }] + },{ + columnWidth : .4, + layout : 'form', + items:[{ + xtype : 'combo', + fieldLabel : '所属供应室', + //width:180, + listWidth:200, + id : 'orgUnitName', + name : 'orgUnitName', + editable:false, + valueField : 'departCode', + displayField : 'departName', + store : new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!getCssds.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'departCode',mapping : 'departCode'}, + {name : 'departName',mapping : 'departName'} + ]) + }), + forceSelection : true, + allowBlank : false, + triggerAction : 'all', + anchor : '100%', + listeners:{ + select:function(combo, record, index){ + combo.setValue(record.data.departName); + top.Ext.getCmp("orgUnitId").setValue(record.data.id); + } + } + }] + }, { + columnWidth : .2, + layout : 'form', + items:[{ + xtype : 'numberfield', + fieldLabel : "顺序", + allowBlank : true, + maxLength : 1, + name : "sequence", + id : "sequence", + anchor : '100%' + }] + },{ + columnWidth : 1, + layout : 'form', + items:[{ + xtype : 'textarea', + fieldLabel : "备注", + allowBlank : true, + name : "remark", + id : "remark", + anchor : '100%' + }] + }] + }] + }], + buttons : [{ + id : 'saveBtn', + text : '保存', + handler : function(){ + saveWareHouse(this); + } + },{ + text : '取消', + id : 'saveAndNewBtn', + handler : function(){ + wareHouseWin.close(); + grid.dwrReload(); + } + }] + }); + + wareHouseWin = new top.Ext.Window({ + id : 'wareHouseWin', + layout : 'fit', + title : '仓库管理', + width : 600, + border : false, + modal : true, + height : 260, + plain : true, + items : [formObj] + }); + + wareHouseWin.show(); + + if(id != 0){ + formObj.form.load({ + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!loadWareHouse.do', + method : 'GET', + waitMsg : '正在加载数据,请稍候', + success : function(form, action) { + var wareHouse = action.result.data; + }, + failure : function(form, action) {}, + params : {id : id} + }); + } + +} + + +function saveWareHouse(thiz) { + if (!formObj.form.isValid()) { + showResult('请正确填写表单各值!'); + thiz.enable(); + return false; + } + top.Ext.MessageBox.confirm("请确认","是否确定要保存仓库?", + function(button, text) { + if ("yes" == button){ + formObj.form.submit( { + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!saveWareHouse.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + wareHouseWin.close(); + showResult('保存成功'); + grid.dwrReload(); + }, + failure : function(form, action) { + showResult('failure = ' + action.result.message,'error'); + top.Ext.getCmp('saveBtn').enable(); + } + }); + } + }); +} \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/service/WareHouseManager.java =================================================================== diff -u -r12638 -r12652 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/service/WareHouseManager.java (.../WareHouseManager.java) (revision 12638) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/service/WareHouseManager.java (.../WareHouseManager.java) (revision 12652) @@ -38,4 +38,11 @@ * @return */ public int removeWareHouse(List idList); + + /** + * 根据仓库id查询仓库信息 + * @param id + * @return + */ + public WareHouse getWareHouseById(Long id); } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/dwr/WarehouseTableManager.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/dwr/WarehouseTableManager.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/dwr/WarehouseTableManager.java (revision 12652) @@ -0,0 +1,31 @@ +package com.forgon.disinfectsystem.basedatamanager.warehouse.dwr; + +import java.util.List; +import java.util.Map; + +import com.forgon.component.grid.GridManager; +import com.forgon.disinfectsystem.basedatamanager.tousseGroup.service.TousseGroupManager; +import com.forgon.disinfectsystem.basedatamanager.warehouse.service.WareHouseManager; +import com.forgon.disinfectsystem.entity.basedatamanager.tousseGroup.TousseGroup; +import com.forgon.disinfectsystem.entity.basedatamanager.warehouse.WareHouse; + +/** + * 仓库dwr处理类 + * @author shuyongfu + * @since 2016-03-21 + * + */ +public class WarehouseTableManager { + + private GridManager gridManager; + + public void setGridManager(GridManager gridManager) { + this.gridManager = gridManager; + } + + public String findWareHouseTableList(Map> parameterMap) { + String renderGrid = gridManager.renderGrid(parameterMap, + WareHouse.class.getSimpleName(), "", new String[] {}); + return renderGrid; + } +} Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/service/WareHouseManagerImpl.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/service/WareHouseManagerImpl.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/warehouse/service/WareHouseManagerImpl.java (revision 12652) @@ -0,0 +1,88 @@ +package com.forgon.disinfectsystem.basedatamanager.warehouse.service; + +import java.util.List; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import com.forgon.directory.model.OrgUnit; +import com.forgon.disinfectsystem.entity.basedatamanager.warehouse.WareHouse; +import com.forgon.tools.hibernate.ObjectDao; + +/** + * 仓库manager实现类 + * @author shuyongfu + * @since 2016-03-21 + */ +public class WareHouseManagerImpl implements WareHouseManager { + + private ObjectDao objectDao; + + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + + /** + * 查询所有的仓库 + * @return + */ + @SuppressWarnings("unchecked") + public List getAll(){ + return objectDao.findAllObjects(WareHouse.class.getSimpleName()); + } + + /** + * 查询科室下的仓库,按sequence排序,返回集合的第1条就是默认仓库 + * @param orgUnit 默认按科室id,如果id为空,则按code查询 + * @return + */ + @SuppressWarnings("unchecked") + public List getWareHouseListByOrgUnit(OrgUnit orgUnit){ + String sql = " where 1=1 "; + if(orgUnit != null){ + if(orgUnit.getId() != null && orgUnit.getId() != 0){ + sql += " orgUnitId = " + orgUnit.getId(); + }else if(StringUtils.isNotBlank(orgUnit.getOrgUnitCoding())){ + sql += " orgUnitCode = " + orgUnit.getOrgUnitCoding(); + }else{ + return null; + } + sql += " order by sequence"; + }else{ + return null; + } + return objectDao.findBySql(WareHouse.class.getSimpleName(), sql); + } + + /** + * 新增或修改仓库 + * @param wareHouse + * @return + */ + public WareHouse saveOrUpdateWareHouse(WareHouse wareHouse){ + objectDao.saveOrUpdate(wareHouse); + return wareHouse; + } + + /** + * 删除科室(可多个删除) + * @param idList + * @return + */ + public int removeWareHouse(List idList){ + if(CollectionUtils.isNotEmpty(idList)){ + objectDao.delete(WareHouse.class.getSimpleName(), idList); + return idList.size(); + } + return 0; + } + + /** + * 根据仓库id查询仓库信息 + * @param id + * @return + */ + public WareHouse getWareHouseById(Long id){ + return (WareHouse)objectDao.getByProperty(WareHouse.class.getSimpleName(), "id", id); + } +} Index: ssts-web/src/main/resources/spring/applicationContext-disinfectsystem-service.xml =================================================================== diff -u -r12640 -r12652 --- ssts-web/src/main/resources/spring/applicationContext-disinfectsystem-service.xml (.../applicationContext-disinfectsystem-service.xml) (revision 12640) +++ ssts-web/src/main/resources/spring/applicationContext-disinfectsystem-service.xml (.../applicationContext-disinfectsystem-service.xml) (revision 12652) @@ -147,6 +147,22 @@ + + + + + + + + + + + + + +