Index: ssts-web/src/main/webapp/homepage/menuconfigure.js =================================================================== diff -u -r15388 -r15410 --- ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 15388) +++ ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 15410) @@ -86,6 +86,7 @@ {hidden :SSTS_Invoice_Create,text:"科室发货计划设置",href:WWWROOT+'/disinfectsystem/invoice/invoiceDepartmentView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_Invoice_Select,text:"发货单管理",href:WWWROOT+'/disinfectsystem/invoice/invoiceView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_Invoice_Select,text:"材料发货管理",href:WWWROOT+'/disinfectsystem/invoice/materialInvoiceView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, + {hidden :SSTS_Invoice_Select,text:"手术预约管理",href:WWWROOT+'/disinfectsystem/invoice/operationReservationView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :true,text:"发货单批量打印",href:WWWROOT+'/disinfectsystem/invoice/invoicePrintView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_DeliverGoodsQuqery_Menu,text:"发货物品查询",href:WWWROOT+'/disinfectsystem/reportforms/invoiceQueryView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true} ] Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/dwr/table/OperationReservationTableManager.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/dwr/table/OperationReservationTableManager.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/dwr/table/OperationReservationTableManager.java (revision 15410) @@ -0,0 +1,44 @@ +package com.forgon.disinfectsystem.operationreservation.dwr.table; + +import java.util.List; +import java.util.Map; + +import com.forgon.component.grid.GridManager; +import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.disinfectsystem.entity.operationreservation.OperationReservation; +import com.forgon.disinfectsystem.operationreservation.service.OperationReservationManager; + +/** + * @author wangyi + * + * 2016-10-19 下午04:57:40 + */ +public class OperationReservationTableManager { + + private GridManager gridManager; + + private OperationReservationManager operationReservationManager; + + public void setOperationReservationManager( + OperationReservationManager operationReservationManager) { + this.operationReservationManager = operationReservationManager; + } + + public void setGridManager(GridManager gridManager) { + this.gridManager = gridManager; + } + + public String findOperationReservationTableList( + Map> parameterMap) { + + StringBuilder sqlBuilder = new StringBuilder(); + + String currentOrgUnitCode = AcegiHelper.getLoginUser().getCurrentOrgUnitCode(); + + return gridManager + .renderGrid(parameterMap, + OperationReservation.class.getSimpleName(), "", + new String[] { "invoice","applicationItems" }); + } + +} Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/action/OperationReservationAction.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/action/OperationReservationAction.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/action/OperationReservationAction.java (revision 15410) @@ -0,0 +1,172 @@ +package com.forgon.disinfectsystem.operationreservation.action; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletResponse; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.lang.StringUtils; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.Constants; +import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationName; +import com.forgon.disinfectsystem.entity.basedatamanager.operationNameManager.OperationUseTousseItem; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.disinfectsystem.entity.operationreservation.OperationReservation; +import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; +import com.forgon.disinfectsystem.operationreservation.service.OperationReservationManager; +import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.json.JSONUtil; +import com.opensymphony.xwork2.Preparable; + +/** + * @author wangyi + * 2016-10-19 下午18:25:19 + */ +@ParentPackage("default") +@Namespace("/disinfectsystem") +@Action("operationReservationAction") +public class OperationReservationAction implements Preparable{ + + private OperationReservationManager operationReservationManager; + + public void setOperationReservationManager( + OperationReservationManager operationReservationManager) { + this.operationReservationManager = operationReservationManager; + } + + private void responseMsg(String msg){ + HttpServletResponse response = StrutsParamUtils.getResponse(); + response.setCharacterEncoding("UTF-8"); + PrintWriter out; + try { + out = response.getWriter(); + out.println(msg); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 保存手术预约 + */ + public void saveOperationReservation() throws Exception{ + String data = StrutsParamUtils.getPraramValue("data", ""); + boolean success = true; + String msg = "保存成功!"; + try { + operationReservationManager.saveOrUpdate(data); + } catch (Exception e) { + success = false; + msg = e.getMessage(); + } + responseMsg(JSONUtil.buildJsonObject(success, msg).toString()); + } + + /** + * 删除手术预约 + * @return + */ + public void deleteOperationReservation(){ + String ids = StrutsParamUtils.getPraramValue("ids", ""); + String msg = "删除成功!"; + if(StringUtils.isNotBlank(ids)){ + String [] idArray = ids.split(";"); + for (int i = 0; i < idArray.length; i++) { + String tmpId = idArray[i]; + OperationReservation operationReservation = operationReservationManager.getById(tmpId); + if (operationReservation != null) { + if (StringUtils.equals( + InvoicePlan.DELIVERSTATUS_AWAITDELIVER, + operationReservation.getDeliverStatus())) { + operationReservationManager.delete(tmpId); + }else{ + msg = "部分单据已发货,不能删除!"; + } + } + } + } + responseMsg("{success:true,message:'" + msg + "'}"); + } + + public void loadOperationResevation(){ + String id = StrutsParamUtils.getPraramValue("id", ""); + OperationReservation operationReservation = operationReservationManager.getById(id); + JSONArray items = new JSONArray(); + JSONObject obj = new JSONObject(); + String operationName = ""; + if(operationReservation != null){ + operationName = operationReservation.getOperationName(); + if(operationReservation.getApplicationItems() != null){ + for (TousseItem item : operationReservation.getApplicationItems()) { + JSONObject itemJson = new JSONObject(); + itemJson.put("itemId", item.getId()); + itemJson.put("tousseDefinitionId", item.getTousseDefinitionId()); + itemJson.put("name", item.getTousseName()); + itemJson.put("amount", item.getAmount()); + items.add(itemJson); + } + } + } + obj.put("operationName", operationName); + obj.put("tousseItems", items); + obj.put("success", true); + responseMsg(obj.toString()); + } + + public void loadOperationReservation(){ + String id = StrutsParamUtils.getPraramValue("id", ""); + OperationReservation po = operationReservationManager.getById(id); + JSONObject obj = new JSONObject(); + boolean success = true; + if(po != null){ + JSONArray items = new JSONArray(); + if(po.getApplicationItems() != null){ + for (TousseItem item : po.getApplicationItems()) { + JSONObject itemJson = new JSONObject(); + itemJson.put("itemId", item.getId()); + itemJson.put("tousseDefinitionId", item.getTousseDefinitionId()); + itemJson.put("name", item.getTousseName()); + itemJson.put("amount", item.getAmount()); + items.add(itemJson); + } + } + obj.put("serialNumber", po.getSerialNumber()); + obj.put("applicant", po.getApplicant()); + obj.put("operationName", po.getOperationName()); + obj.put("operatingRoom", po.getOperatingRoom()); + obj.put("operatingRoomCode", po.getOperatingRoomCode()); + obj.put("doctors", po.getDoctors()); + String operationTime = ""; + if(po.getOperationTime() != null){ + operationTime = Constants.SIMPLEDATEFORMAT_YYYYMMDDHHMM.format(po.getOperationTime()); + } + obj.put("operationTime", operationTime); + obj.put("depart", po.getDepart()); + obj.put("departCoding", po.getDepartCoding()); + obj.put("handleDepart", po.getHandleDepart()); + obj.put("handleDepartCoding", po.getHandleDepartCoding()); + obj.put("remark", po.getRemark()); + + obj.put("items", items); + }else{ + success = false; + } + obj.put("success", success); + + responseMsg(obj.toString()); + } + + + @Override + public void prepare() throws Exception { + + } + +} Index: ssts-web/src/main/webapp/disinfectsystem/useRecord/useRecordForm.js =================================================================== diff -u -r15223 -r15410 --- ssts-web/src/main/webapp/disinfectsystem/useRecord/useRecordForm.js (.../useRecordForm.js) (revision 15223) +++ ssts-web/src/main/webapp/disinfectsystem/useRecord/useRecordForm.js (.../useRecordForm.js) (revision 15410) @@ -717,9 +717,18 @@ } var sexArray = [['男'],['女']]; - var operationNameStore = new Ext.data.SimpleStore({ - fields : [ 'operationName' ], - url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!findOrgUnitOperationName.do' + var operationNameStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!findOrgUnitOperationName.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'operationName',mapping : 'operationName'}] + ) }); var tousseCm = new Ext.grid.ColumnModel([sm, Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/toussedefinition/TousseDefinition.java =================================================================== diff -u -r15366 -r15410 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/toussedefinition/TousseDefinition.java (.../TousseDefinition.java) (revision 15366) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/toussedefinition/TousseDefinition.java (.../TousseDefinition.java) (revision 15410) @@ -108,6 +108,7 @@ public static final String PACKAGE_TYPE_INSIDE = "器械包"; public static final String PACKAGE_TYPE_INSIDE_AND_DISINFECTION = "器械包与消毒物品";//器械包(含敷料包和消毒物品) public static final String PACKAGE_TYPE_CAN_CUSTOM_PACKING = "允许自定义装配的器械包"; + public static final String PACKAGE_TYPE_INSIDE_AND_DRESSING = "器械包与敷料包";//器械包(含敷料包和消毒物品) public static final String PACKAGE_TYPE_FOREIGN = "外来器械包"; public static final String PACKAGE_TYPE_SPLIT = "外来器械拆分小包"; public static final String PACKAGE_TYPE_FOREIGNPROXY = "外部代理灭菌"; Index: ssts-web/src/main/resources/spring/applicationContext-disinfectsystem-service.xml =================================================================== diff -u -r15334 -r15410 --- ssts-web/src/main/resources/spring/applicationContext-disinfectsystem-service.xml (.../applicationContext-disinfectsystem-service.xml) (revision 15334) +++ ssts-web/src/main/resources/spring/applicationContext-disinfectsystem-service.xml (.../applicationContext-disinfectsystem-service.xml) (revision 15410) @@ -2030,4 +2030,24 @@ + + + + + + + + + + + PROPAGATION_REQUIRED + + + + + + + + + \ No newline at end of file Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java =================================================================== diff -u -r15381 -r15410 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java (.../TousseDefinitionAction.java) (revision 15381) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java (.../TousseDefinitionAction.java) (revision 15410) @@ -1599,6 +1599,29 @@ } /** + * 只查询普通器械包和敷料包 + */ + public void searchTousseAndDressing() { + if (spell == null) { + spell = ""; + } + try { + spell = java.net.URLDecoder.decode(spell, "UTF-8"); + Map result = tousseDefinitionManager.searchComboGoods(spell, TousseDefinition.PACKAGE_TYPE_INSIDE_AND_DRESSING,false,false,null); + JSONObject json = JSONObject.fromObject(result); + HttpServletResponse response = StrutsParamUtils.getResponse(); + response.setCharacterEncoding("UTF-8"); + PrintWriter out; + + out = response.getWriter(); + out.print(json); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** * 根据拼音码、五笔码获取内部器械包(器械包和敷料包)NAME和ID * * @return Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/operationreservation/OperationReservation.java =================================================================== diff -u -r15382 -r15410 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/operationreservation/OperationReservation.java (.../OperationReservation.java) (revision 15382) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/operationreservation/OperationReservation.java (.../OperationReservation.java) (revision 15410) @@ -4,12 +4,9 @@ package com.forgon.disinfectsystem.entity.operationreservation; import java.util.Date; - import javax.persistence.Entity; - import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; - import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; /** @@ -28,7 +25,12 @@ * 手术室 */ private String operatingRoom; + /** + * 手术室编码 + */ + private String operatingRoomCode; + /** * 医生 */ private String doctors; @@ -69,4 +71,12 @@ this.operationTime = operationTime; } + public String getOperatingRoomCode() { + return operatingRoomCode; + } + + public void setOperatingRoomCode(String operatingRoomCode) { + this.operatingRoomCode = operatingRoomCode; + } + } Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/service/OperationReservationManager.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/service/OperationReservationManager.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/service/OperationReservationManager.java (revision 15410) @@ -0,0 +1,19 @@ +package com.forgon.disinfectsystem.operationreservation.service; + +import com.forgon.disinfectsystem.entity.operationreservation.OperationReservation; +/** + * @author wangyi + * + * 2016-10-19 下午04:57:40 + */ +public interface OperationReservationManager { + + public void saveOrUpdate(String json); + + public void saveOrUpdate(OperationReservation operationReservation); + + public OperationReservation getById(String id); + + public void delete(String id); + +} Index: ssts-web/src/main/webapp/WEB-INF/dwr.xml =================================================================== diff -u -r15325 -r15410 --- ssts-web/src/main/webapp/WEB-INF/dwr.xml (.../dwr.xml) (revision 15325) +++ ssts-web/src/main/webapp/WEB-INF/dwr.xml (.../dwr.xml) (revision 15410) @@ -26,6 +26,10 @@ + + + + Index: ssts-web/src/main/webapp/systemmanage/operationNameView.js =================================================================== diff -u -r15387 -r15410 --- ssts-web/src/main/webapp/systemmanage/operationNameView.js (.../operationNameView.js) (revision 15387) +++ ssts-web/src/main/webapp/systemmanage/operationNameView.js (.../operationNameView.js) (revision 15410) @@ -62,11 +62,12 @@ } } -function deleteGoodsItem(rowIndex){ - if(rowIndex != null){ - var record = useTousseStore.getAt(rowIndex); - if(record){ +function deleteGoodsItem(tousseDefinitionId){ + for(var i = 0;i < useTousseStore.getCount();i++){ + var record = useTousseStore.getAt(i); + if(record.data.tousseDefinitionId == tousseDefinitionId){ useTousseStore.remove(record); + break; } } } @@ -112,15 +113,13 @@ menuDisabled: true, dataIndex:'button', renderer: function(v,p,record,rowIndex){ - return ""; + return ""; } }]); - var searchUrl = WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!searchComboTousseData.do'; - tousseAndDiposableGoodsStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ - url : searchUrl, + url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!searchTousseAndDressing.do', method : 'POST' }), reader : new Ext.data.JsonReader({ @@ -157,12 +156,12 @@ listeners : { select : function(combo, record, index) { top.Ext.getCmp('goodsSearch').setValue(record.data.name); - }, + }/*, specialkey : function(field, e) { if (e.getKey() == Ext.EventObject.ENTER) { top.Ext.getCmp('amount').focus(); } - } + }*/ } },{ text : '数量' Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java =================================================================== diff -u -r15350 -r15410 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 15350) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 15410) @@ -1398,6 +1398,11 @@ mapList = searchTousseBySimpleCodeAndAnyTousseTypeArr( searchString, new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, TousseDefinition.PACKAGE_TYPE_DRESSING,TousseDefinition.PACKAGE_TYPE_DISINFECTION },false); + //器械包和敷料包 + }else if(TousseDefinition.PACKAGE_TYPE_INSIDE_AND_DRESSING.equals(tousseType)){ + mapList = searchTousseBySimpleCodeAndAnyTousseTypeArr( + searchString, new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, + TousseDefinition.PACKAGE_TYPE_DRESSING},false); } // 只搜索器械包(包含敷料包,不含消毒物品) else if (TousseDefinition.PACKAGE_TYPE_INSIDE.equals(tousseType)){ @@ -1707,6 +1712,7 @@ List tousseDefinitions = (List) objectDao .findBySql(TousseDefinition.class.getSimpleName(), sql + " order by " + DatabaseUtil.getSqlLengthFunctionName(dbConnection) + "(po.name) asc"); + if (tousseDefinitions != null) { for (TousseDefinition tousseDefinition : tousseDefinitions) { //过滤停用的器械包 Index: ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.jsp (revision 15410) @@ -0,0 +1,75 @@ +<%@page import="com.forgon.disinfectsystem.entity.basedatamanager.supplier.Supplier"%> +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/includeExtJsAndCss.jsp"%> +<%@ page import="com.forgon.tools.SpringBeanManger" %> +<% + String userName = AcegiHelper.getLoginUser().getUserFullName(); + request.setAttribute("userName",userName); +%> + + + +手术预约信息 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/action/OperationNameAction.java =================================================================== diff -u -r15387 -r15410 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/action/OperationNameAction.java (.../OperationNameAction.java) (revision 15387) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/operationNameManager/action/OperationNameAction.java (.../OperationNameAction.java) (revision 15410) @@ -238,20 +238,39 @@ public void findOrgUnitOperationName() { String spell = StrutsParamUtils.getPraramValue("spell", ""); + String orgUnitCoding = StrutsParamUtils.getPraramValue("orgUnitCoding", ""); + if(StringUtils.isBlank(orgUnitCoding)){ + orgUnitCoding = AcegiHelper.getLoginUser().getCurrentOrgUnitCode(); + } spell = spell.toUpperCase(); - List operationList = operationNameManager.findAllOperationByParam(AcegiHelper.getLoginUser().getCurrentOrgUnitCode(), spell); - StringBuffer buff = new StringBuffer(); + List operationList = operationNameManager.findAllOperationByParam(orgUnitCoding, spell); + JSONArray array = new JSONArray(); if(operationList != null){ for(OperationName operationName : operationList){ - if(buff.length() > 0){ - buff.append(","); + JSONObject item = new JSONObject(); + item.put("id", operationName.getId()); + item.put("operationName", operationName.getOperationName()); + JSONArray useTousseArray = new JSONArray(); + if(operationName.getTousseItems() != null){ + for (OperationUseTousseItem tousseItem : operationName.getTousseItems()) { + JSONObject obj = new JSONObject(); + obj.put("id", tousseItem.getId()); + obj.put("name", tousseItem.getName()); + obj.put("amount", tousseItem.getAmount()); + obj.put("tousseDefinitionId", tousseItem.getTousseDefinitionId()); + useTousseArray.add(obj); + } } - buff.append("['").append(operationName.getOperationName()).append("']"); + item.put("items", useTousseArray); + array.add(item); } } - responseMsg("[" + buff.toString() + "]"); + JSONObject result = new JSONObject(); + result.put("totalCount", array.size()); + result.put("data", array); + responseMsg(result.toString()); } - + public void prepare() throws Exception { try { String orgCoding = StrutsParamUtils.getPraramValue("orgCoding", ""); Index: ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationView.js (revision 15410) @@ -0,0 +1,726 @@ +var entityName = "手术预约"; +var grid; +var operationReservationWindow; + +//明细grid删除按钮 +function renderDeleteButton(v,p,record,rowIndex){ + return ""; +} + +//删除grid明细 +function deleteItem(tousseDefinitionId){ + var gridStore = top.Ext.getCmp('operationReservationGrid').getStore(); + for(var i = 0;i < gridStore.getCount();i++){ + var record = gridStore.getAt(i); + if(record.data.tousseDefinitionId == tousseDefinitionId){ + gridStore.remove(record); + break; + } + } +} +//Ext.form.DateField在IE8下显示不全 +Ext.override(top.Ext.menu.Menu, { + autoWidth: function() { + this.width += "px"; + } +}); + +var goodsItemRecord = Ext.data.Record.create([ + {name : 'itemId'}, + {name : 'tousseDefinitionId'}, + {name : 'name'}, + {name : 'amount'} +]); + +function editOperationReservation(id) { + + var handleDepartStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/systemmanage/getCssdsByApplyDepartAndType.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + root : 'data' + },[ + {name : 'cssdOrgUnitCode',mapping : 'cssdOrgUnitCode'}, + {name : 'name',mapping : 'cssdOrgUnitName'} + ] + ), + listeners:{ + load:function(thiz, records, options){ + if (records.length == 1){ + top.Ext.getCmp("handleDepartCoding").setValue(records[0].data.cssdOrgUnitCode); + top.Ext.getCmp('handleDepart').setValue(records[0].data.name); + }else{ + top.Ext.getCmp("handleDepartCoding").setValue(); + top.Ext.getCmp('handleDepart').setValue(); + } + } + } + }); + + handleDepartStore.on('beforeload', function (store, options) { + if(top.Ext.getCmp("depart").getRawValue() == ""){ + showResult("请选择申请科室!"); + } + var orgUnitCoding = top.Ext.getCmp("departCoding").getValue(); + var new_params = {applyDepartCode : orgUnitCoding, tousseType : ""}; + Ext.apply(store.baseParams, new_params); + }); + + //科室数据 + var departJsonStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/supplyRoomConfigAction!getAllOrgUnitName.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + root : 'data' + },[ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'} + ] + ) + }); + + var tousseAndDiposableGoodsStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!searchTousseAndDressing.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'spelling',mapping : 'spelling'}, + {name : 'name',mapping : 'name'}, + {name : 'displayName',mapping : 'displayName'}, + {name : 'amount',mapping : 'amount'}] + ) + }); + + var operationNameStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectsystem/basedatamanager/operationOrgAction!findOrgUnitOperationName.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'operationName',mapping : 'operationName'}, + {name : 'items',mapping : 'items'}] + ) + }); + + operationNameStore.on('beforeload', function (store, options) { + if(top.Ext.getCmp("depart").getRawValue() == ""){ + showResult("请选择申请科室!"); + } + var orgUnitCoding = top.Ext.getCmp("departCoding").getValue(); + var new_params = {orgUnitCoding:orgUnitCoding}; + Ext.apply(store.baseParams, new_params); + }); + + //添加明细 + function addItems(itemId,tousseDefinitionId,name,amount){ + if(name == null || name == ''){ + showResult("请填写物品名称!"); + return false; + } + if(amount == null || amount == ''){ + showResult("请填写数量!"); + return false; + } + var store = top.Ext.getCmp('operationReservationGrid').getStore(); + var isExist = false; + var count = store.getCount(); + for(var i = 0 ; i < count ; i++){ + var record = store.getAt(i); + if(record.get("name") == name){ + isExist = true; + break; + } + } + if(!isExist){ + //添加操作 + var materialInvoiceItem = new goodsItemRecord({ + itemId : itemId, + tousseDefinitionId : tousseDefinitionId, + name : name, + amount : amount + }); + store.add(materialInvoiceItem); + top.Ext.getCmp('goodsName').setValue(''); + top.Ext.getCmp('amount').setValue(''); + top.Ext.getCmp('goodsName').focus(); + }else{ + showResult(name + ",已添加!"); + } + } + + var form = new top.Ext.FormPanel({ + id : 'materialInvoiceForm', + frame : true, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 660, + autoHeight : true, + autoScroll : true, + labelAlign : 'left', + items:[{ + layout : 'column', + items : [{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'handleDepartCoding', + id : 'handleDepartCoding' + },{ + xtype : 'hidden', + name : 'departCoding', + id : 'departCoding' + },{ + id:'serialNum', + columnWidth : .33, + layout : 'form', + labelWidth : 65, + hidden : (id == ""?true:false), + items : [{ + xtype : 'textfield', + fieldLabel : '单号', + maxLength : '41', + id : 'serialNumber', + name : 'serialNumber', + cls : 'fieldReadOnlyNoRemove', + allowBlank : true, + readOnly : true, + anchor : '95%' + }] + }, { + columnWidth : .33, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'textfield', + fieldLabel : '操作员', + maxLength : '60', + id : 'applicant', + name : 'applicant', + allowBlank : false, + readOnly : true, + cls : 'fieldReadOnlyNoRemove', + value : $Id('userName').value, + anchor : '95%' + }] + },{ + columnWidth : .33, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'textfield', + fieldLabel : '手术名称', + maxLength : '41', + id : 'operationName', + name : 'operationName', + cls : 'fieldReadOnlyNoRemove', + allowBlank : false, + readOnly : true, + anchor : '95%' + }] + },{ + columnWidth : .33, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'combo', + id : 'depart', + name : 'depart', + queryParam : 'spell', + fieldLabel : '申请科室', + minChars : 0, + valueField : 'id', + displayField : 'name', + store : departJsonStore, + forceSelection : true, + lazyInit : true, + triggerAction : 'all', + hideTrigger : false, + typeAhead : false, + allowBlank : false, + anchor : '95%', + listeners : { + select : function(combo , record , index){ + top.Ext.getCmp('departCoding').setValue(record.data.id); + top.Ext.getCmp('depart').setValue(record.data.name); + operationNameStore.load(); + + handleDepartStore.load(); + } + } + }] + }, { + columnWidth : .33, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'combo', + fieldLabel : '处理科室', + id : 'handleDepart', + name : 'handleDepart', + editable:false, + valueField : 'name', + displayField : 'name', + store : handleDepartStore, + forceSelection : true, + allowBlank : false, + triggerAction : 'all', + width:149 + }] + },{ + columnWidth : .33, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'datefieldWithMin', + fieldLabel : '手术时间', + id : 'operationTime', + name : 'operationTime', + format : 'Y-m-d H:i', + altFormats:'Y-m-d|Y-n-j|y-n-j|y-m-j|y-m-d|y-n-d|Y-n-d|Y-m-j|Ymd|Ynj|ynj|ymj|ymd|ynd|Ynd|Ymj|Y/m/d|Y/n/j|y/n/j|y/m/j|y/m/d|y/n/d|Y/n/d|Y/m/j', + editable: false, + allowBlank : true, + anchor : '100%' + }] + },{ + columnWidth : .33, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'textfield', + fieldLabel : '医生', + maxLength : '41', + id : 'doctors', + name : 'doctors', + allowBlank : true, + anchor : '95%' + }] + }, { + columnWidth : 1, + layout : 'form', + labelWidth : 65, + items : [{ + xtype : 'textarea', + fieldLabel : '备注', + height : 50, + id : 'remark', + name : 'remark', + maxLength : 665, + allowBlank : true, + anchor : '100%' + }] + }] + },new top.Ext.grid.EditorGridPanel({ + id : 'operationReservationGrid', + bodyStyle : 'border:1px solid #afd7af', + frame :false, + viewConfig: { + forceFit:true + }, + store : new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/materialInvoiceAction!getMaterialInvoiceItemsByMaterialInvoiceId.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'materialDefinitionId'}, + {name : 'materialName'}, + {name : 'userecordId'}, + {name : 'userecordName'}, + {name : 'userecordDepartCoding'}, + {name : 'amount'}, + {name : 'deleteButton'} + ] + }) + }), + cm : new Ext.grid.ColumnModel([new Ext.grid.RowNumberer({header:"序号",width:40}), + {header : "itemId",dataIndex : 'itemId',hidden : true}, + {header : "tousseDefinitionId",dataIndex : 'tousseDefinitionId',hidden : true}, + {header : "物品名称",dataIndex : 'name',width : 170,menuDisabled : true}, + {header : " 数量",dataIndex : 'amount',width : 80,menuDisabled : true, + editor : new Ext.form.TextField({ + regex: /^\d+$/, + regexText:'只能输入数字', + allowBlank : false + }) + }, + {header : "删除",width : 80,menuDisabled : true,dataIndex : 'deleteButton', id:'expandColumn', renderer:renderDeleteButton} + ]), + width :665, + height : 350, + autoExpandColumn : 'expandColumn', + clicksToEdit : 1,// 设置点击几次才可编辑 + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + tbar : [{ + text : '手术名称:' + },{ + xtype : 'combo', + queryParam : 'spell', + minChars : 0, + valueField : 'id', + displayField : 'operationName', + store : operationNameStore, + forceSelection : false, + lazyInit : true, + triggerAction : 'all', + hideTrigger : false, + typeAhead : false, + editable : true, + width:300, + name : "operation", + id : "operation", + anchor : '98%', + listeners : { + select : function(combo, record, index){ + + top.Ext.getCmp("operationName").setValue(combo.getRawValue()); + var store = top.Ext.getCmp('operationReservationGrid').getStore(); + store.removeAll(); + + var items = record.get("items"); + if(items != null){ + for(var i = 0 ; i < items.length ; i++){ + addItems("",items[i].tousseDefinitionId,items[i].name,items[i].amount); + } + } + } + } + } + ], + listeners: { + render : function() { + var tbar = new top.Ext.Toolbar ({ + items : [{ + text : '物品名称:' + },{ + xtype : 'combo', + id : 'goodsName', + name : 'goodsName', + queryParam : 'spell', + fieldLabel : '物品名称', + minChars : 0, + valueField : 'id', + displayField : 'displayName', + anchor : '100%', + width:300, + store : tousseAndDiposableGoodsStore, + lazyInit : true, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + forceSelection : true, + allowBlank : true + },{ + text : ' 数量:' + },{ + xtype : 'textfield', + maxLength : '16', + id : 'amount', + name : 'amount', + width : 70, + regex: /^\d+$/, + regexText:'只能输入数字', + anchor : '100%', + listeners : { + specialkey : function(field, e) { + if (e.getKey() == Ext.EventObject.ENTER) { + var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); + var name = top.Ext.getCmp('goodsName').getRawValue() + var amount = top.Ext.getCmp('amount').getValue(); + addItems("",tousseDefinitionId,name,amount); + } + } + } + },{ + text : '添加', + iconCls : 'btn_ext_add', + handler : function() { + var tousseDefinitionId = top.Ext.getCmp('goodsName').getValue(); + var name = top.Ext.getCmp('goodsName').getRawValue() + var amount = top.Ext.getCmp('amount').getValue(); + addItems("",tousseDefinitionId,name,amount); + } + } + ] + }); + tbar.render(top.Ext.getCmp('operationReservationGrid').tbar); + } + } + })], + buttons : [{ + id : 'btnSave', + text : '保存', + handler : function() { + + if (!form.getForm().isValid()) { + showResult('请正确填写表单各值'); + return false; + } + var store = top.Ext.getCmp('operationReservationGrid').getStore(); + if(store.getCount() <= 0){ + showResult('请添加物品项!'); + return false; + } + var jsonArray = new Array(); + for(var i = 0;i < store.getCount();i++){ + var record = store.getAt(i); + jsonArray.push({ + itemId : record.data.itemId, + tousseDefinitionId : record.data.tousseDefinitionId, + name : record.data.name, + amount : record.data.amount + }); + } + + var params = { + id : id, + operationName : top.Ext.getCmp("operationName").getValue(), + operatingRoom : top.Ext.getCmp("depart").getValue(), + operatingRoomCode : top.Ext.getCmp("departCoding").getValue(), + doctors : top.Ext.getCmp("doctors").getValue(), + operationTime : top.Ext.getCmp("operationTime").getRawValue(), + depart : top.Ext.getCmp("depart").getValue(), + departCoding : top.Ext.getCmp("departCoding").getValue(), + settleAccountsDepart : top.Ext.getCmp("depart").getValue(), + settleAccountsDepartCoding : top.Ext.getCmp("departCoding").getValue(), + handleDepart : top.Ext.getCmp("handleDepart").getRawValue(), + handleDepartCoding : top.Ext.getCmp("handleDepartCoding").getValue(), + remark : top.Ext.getCmp("remark").getValue(), + items : jsonArray + }; + + form.form.submit({ + url : WWWROOT + '/disinfectsystem/operationReservationAction!saveOperationReservation.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + params : {data : JSON.stringify(params)}, + success : function(form, action) { + showResult(action.result.message); + grid.dwrReload(); + operationReservationWindow.close(); + + }, + failure : function(form, action) { + showResult(action.result.message); + } + }); + } + },{ + text : '取消', + handler : function() { + operationReservationWindow.close(); + } + }] + }); + + operationReservationWindow = new top.Ext.Window( { + id : 'materialInvoiceWin', + layout : 'fit', + title : '手术预约单信息', + width : 700, + modal : true, + autoHeight : true, + border :false, + plain : true, + items : [ form ] + }); + operationReservationWindow.show(); + + if(id != ""){ + Ext.Ajax.request({ + url:WWWROOT + "/disinfectsystem/operationReservationAction!loadOperationReservation.do", + params:{id : id}, + success:function(result){ + if(result != null){ + var data = JSON.parse(result.responseText); + if(data.success){ + top.Ext.getCmp("serialNumber").setValue(data.serialNumber); + top.Ext.getCmp("applicant").setValue(data.applicant); + top.Ext.getCmp("operationName").setValue(data.operationName); + top.Ext.getCmp("depart").setValue(data.depart); + top.Ext.getCmp("departCoding").setValue(data.departCoding); + top.Ext.getCmp("doctors").setValue(data.doctors); + top.Ext.getCmp("operationTime").setValue(data.operationTime); + top.Ext.getCmp("handleDepart").setValue(data.handleDepart); + top.Ext.getCmp("handleDepartCoding").setValue(data.handleDepartCoding); + top.Ext.getCmp("remark").setValue(data.remark); + var tousseItems = data.items; + for(var i = 0 ; i < tousseItems.length ; i++){ + addItems(tousseItems[i].itemId,tousseItems[i].tousseDefinitionId,tousseItems[i].name,tousseItems[i].amount); + } + }else{ + showResult("该单已不存在!"); + } + } + }, + failure:function(){ + showResult("加载失败,请联系管理员!"); + } + }); + } +} + +// 删除 +function deleteOperationReservation(grid) { + 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/operationReservationAction!deleteOperationReservation.do', + params : {ids : ids}, + success : function(response, options) { + var result = Ext.decode(response.responseText); + showResult(result.message); + grid.dwrReload(); + }, + failure : function(response, options) { + showResult(response.responseText); + } + }); + } + } + ); + +} + +function editRecord(id){ + editOperationReservation(id); +} + +function modify(v,data){ + editRecord(data['id']); +} + +Ext.onReady(function() { + Ext.QuickTips.init(); + + function renderColor(v, p, record){ + var status = record.data['deliverStatus']; + var color = ""; + if("待发货" == status){//待发货 黄色 + color = "yellow"; + }else if("部分发货" == status){ //部分发货 粉红色 + color = "#F5A7FA"; + } + return "

" + v + "

"; + } + + var columns = [ + {header : "流水号",width : 100,dataIndex : 'serialNumber', renderer : modifyRecord}, + {header : "申请科室",width : 120,dataIndex : 'depart'}, + {header : "申请人",width : 60,dataIndex : 'applicant'}, + {header : "申请时间",width : 120,dataIndex : 'applicationTime', renderer : myDateFormatByMinute}, + {header : "医生",width : 120,dataIndex : 'doctors'}, + {header : "手术时间",width : 120,dataIndex : 'operationTime', renderer : myDateFormatByMinute}, + {header : "发货状态",width : 65,dataIndex : 'deliverStatus', renderer : renderColor}, + {id:'remark',header: "备注", dataIndex: 'remark'} + ]; + + var readerDetail = [ + {name : 'id'}, + {name : 'serialNumber'}, + {name : 'depart'}, + {name : 'operationTime'}, + {name : 'applicant'}, + {name : 'applicationTime'}, + {name : 'doctors'}, + {name : 'deliverStatus'}, + {name : 'remark'} + ]; + + var filters = new Ext.grid.GridFilters({ + filters:[ + {type: 'string', dataIndex: 'serialNumber'}, + {type: 'string', dataIndex: 'depart'}, + {type: 'string', dataIndex: 'applicant'}, + {type: 'string', dataIndex: 'doctors'}, + {type: 'string', dataIndex: 'deliverStatus'}, + {type: 'string', dataIndex: 'remark'} + ]} + ); + + var sign = true; + var tbar = [{ + text : '添加', + hidden : SSTS_Invoice_Update, + iconCls : 'btn_ext_application_add', + handler : function() { + editOperationReservation(""); + } + }, { + text : '删除', + hidden : SSTS_Invoice_Delete, + iconCls : 'btn_ext_application_del', + handler : function() { + deleteOperationReservation(grid); + } + }, { + text : '刷新列表', + iconCls : 'btn_ext_refresh1', + handler : function() { + grid.dwrReload(); + } + }]; + + grid = new Ext.ux.ForgonPageGrid( { + tbar : tbar, + pageSize : 20, + defaultSortField : 'id', + title : entityName + '列表', + defaultSortDirection : 'DESC', + isCheckboxSelectionModel : true, + rememberSelected : false, + isShowSearchField : true, + columns : columns, + plugins: filters, + autoExpandColumn : 'remark', + renderTo : 'gridDiv', + frame : false + }, readerDetail, + OperationReservationTableManager.findOperationReservationTableList, + null + ); + + 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-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/service/OperationReservationManagerImpl.java =================================================================== diff -u --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/service/OperationReservationManagerImpl.java (revision 0) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/operationreservation/service/OperationReservationManagerImpl.java (revision 15410) @@ -0,0 +1,236 @@ +package com.forgon.disinfectsystem.operationreservation.service; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.lang.StringUtils; + +import com.forgon.Constants; +import com.forgon.directory.acegi.tools.AcegiHelper; +import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan; +import com.forgon.disinfectsystem.entity.operationreservation.OperationReservation; +import com.forgon.disinfectsystem.entity.tousseitem.TousseItem; +import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseDefinitionManager; +import com.forgon.disinfectsystem.tousseitem.service.TousseItemManager; +import com.forgon.serialnumber.model.SerialNum; +import com.forgon.serialnumber.service.SerialNumManager; +import com.forgon.tools.GB2Alpha; +import com.forgon.tools.GB2WB; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.hibernate.ObjectDao; + +/** + * @author wangyi + * + * 2016-10-19 下午04:57:40 + */ + +public class OperationReservationManagerImpl implements + OperationReservationManager { + + private ObjectDao objectDao; + + private TousseItemManager tousseItemManager; + + private TousseDefinitionManager tousseDefinitionManager; + + private SerialNumManager serialNumManager; + + public void setSerialNumManager(SerialNumManager serialNumManager) { + this.serialNumManager = serialNumManager; + } + + public void setTousseDefinitionManager( + TousseDefinitionManager tousseDefinitionManager) { + this.tousseDefinitionManager = tousseDefinitionManager; + } + + public void setTousseItemManager(TousseItemManager tousseItemManager) { + this.tousseItemManager = tousseItemManager; + } + + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + + @Override + public void saveOrUpdate(String json) { + if(StringUtils.isNotBlank(json)){ + JSONObject data = JSONObject.fromObject(json); + + String id = data.optString("id"); + String operationName = data.optString("operationName"); + if(StringUtils.isBlank(operationName)){ + throw new RuntimeException("手术名称不能为空!"); + } + String operatingRoom = data.optString("operatingRoom"); + String operatingRoomCode = data.optString("operatingRoomCode"); + if(StringUtils.isBlank(operatingRoom) || StringUtils.isBlank(operatingRoomCode)){ + throw new RuntimeException("手术室不能为空!"); + } + String doctors = data.optString("doctors"); + String operationTimeString = data.optString("operationTime"); + String depart = data.optString("depart"); + String departCoding = data.optString("departCoding"); + if(StringUtils.isBlank(depart) || StringUtils.isBlank(departCoding)){ + throw new RuntimeException("申请科室不能为空!"); + } + String settleAccountsDepart = data.optString("settleAccountsDepart"); + String settleAccountsDepartCoding = data.optString("settleAccountsDepartCoding"); + if(StringUtils.isBlank(settleAccountsDepart) || StringUtils.isBlank(settleAccountsDepartCoding)){ + throw new RuntimeException("结算科室不能为空!"); + } + String handleDepart = data.optString("handleDepart"); + String handleDepartCoding = data.optString("handleDepartCoding"); + if(StringUtils.isBlank(handleDepart) || StringUtils.isBlank(handleDepartCoding)){ + throw new RuntimeException("处理科室不能为空!"); + } + + String remark = data.optString("remark"); + + OperationReservation operationReservation = null; + if(DatabaseUtil.isPoIdValid(id)){ + operationReservation = getById(id); + if(operationReservation == null){ + throw new RuntimeException("该单已不存在!"); + } + if (!InvoicePlan.DELIVERSTATUS_AWAITDELIVER + .equals(operationReservation.getDeliverStatus())) { + throw new RuntimeException("该单" + + operationReservation.getDeliverStatus() + + ",不能修改!"); + } + }else{ + operationReservation = new OperationReservation(); + } + operationReservation.setOperationName(operationName); + operationReservation.setOperatingRoom(operatingRoom); + operationReservation.setOperatingRoomCode(operatingRoomCode); + operationReservation.setDoctors(doctors); + if (StringUtils.isNotBlank(operationTimeString)) { + try { + Date operationTime = Constants.SIMPLEDATEFORMAT_YYYYMMDDHHMM.parse(operationTimeString); + operationReservation.setOperationTime(operationTime); + } catch (ParseException e) { + } + } + operationReservation.setDepart(depart); + operationReservation.setDepartCoding(departCoding); + operationReservation.setSettleAccountsDepart(settleAccountsDepart); + operationReservation.setSettleAccountsDepartCoding(settleAccountsDepartCoding); + if(operationReservation.getApplicationTime() == null){ + operationReservation.setApplicationTime(new Date()); + } + operationReservation.setApplicant(AcegiHelper.getLoginUserFullName()); + operationReservation.setSubmitTime(new Date()); + operationReservation.setCommittedStatus(true); + operationReservation.setHandleDepart(handleDepart); + operationReservation.setHandleDepartCoding(handleDepartCoding); + operationReservation.setRemark(remark); + operationReservation.setSpelling(GB2Alpha.string2Alpha(depart)); + operationReservation.setWbCode(GB2WB.getWBCode(depart)); + operationReservation.setRecyclingStatus(null); + operationReservation.setDeliverStatus(InvoicePlan.DELIVERSTATUS_AWAITDELIVER); + operationReservation.setType(InvoicePlan.TYPE_OPERATION_RESERVATION_APPLICATION); + operationReservation.setIncludeInvoiceItems(InvoicePlan.SIGNED_TRUE); + if(StringUtils.isBlank(operationReservation.getSerialNumber())){ + operationReservation.setSerialNumber(serialNumManager + .getSerialNumberStr(SerialNum.TYPE_RECYCLINGAPPLICATION)); + } + Map toDeleteMap = new HashMap(); + List oldItems = operationReservation.getApplicationItems(); + if(oldItems != null){ + for (TousseItem tousseItem : oldItems) { + toDeleteMap.put(tousseItem.getId(), tousseItem); + } + } + JSONArray jsonArray = data.optJSONArray("items"); + List tousseItems = new ArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonItem = jsonArray.optJSONObject(i); + Long itemId = jsonItem.optLong("itemId"); + Long tousseDefinitionId = jsonItem.optLong("tousseDefinitionId"); + if(!DatabaseUtil.isPoIdValid(tousseDefinitionId)){ + throw new RuntimeException("参数错误!"); + } + String name = jsonItem.optString("name"); + Integer amount = jsonItem.optInt("amount"); + if(amount <= 0){ + throw new RuntimeException(name + ",数量必须大于0!"); + } + TousseItem tousseItem = null; + if(DatabaseUtil.isPoIdValid(itemId)){ + tousseItem = tousseItemManager.getTousseItemById("" + itemId); + toDeleteMap.remove(itemId); + }else{ + tousseItem = new TousseItem(); + } + TousseDefinition td = tousseDefinitionManager.getTousseDefinitionById(tousseDefinitionId); + if (td == null) { + throw new RuntimeException(name + ",定义已不存在!"); + } + String tousseType = td.getTousseType(); + if (!TousseDefinition.PACKAGE_TYPE_INSIDE.equals(tousseType) + && !TousseDefinition.PACKAGE_TYPE_DRESSING.equals(tousseType)) { + throw new RuntimeException("暂不支持【" + tousseType + "】类型的器械包!"); + } + tousseItem.setAmount(amount); + tousseItem.setTousseName(name); + tousseItem.setTousseDefinitionId(tousseDefinitionId); + Double price = td.getPrice() == null ? 0d : td.getPrice(); + tousseItem.setPrice(price); + tousseItem.setRowPrice(price * amount); + tousseItem.setDiposable(Constants.STR_NO); + tousseItem.setTousseType(tousseType); + tousseItem.setInvoicePlan(operationReservation); + tousseItems.add(tousseItem); + } + operationReservation.setApplicationItems(tousseItems); + + saveOrUpdate(operationReservation); + + if(toDeleteMap.size() > 0){ + for (Long itemId : toDeleteMap.keySet()) { + TousseItem item = toDeleteMap.get(itemId); + objectDao.delete(item); + } + } + } + } + + @Override + public OperationReservation getById(String id) { + if (StringUtils.isNotBlank(id)) { + return (OperationReservation) objectDao.getByProperty( + OperationReservation.class.getSimpleName(), "id", + Long.valueOf(id)); + } + return null; + } + + @Override + public void delete(String id) { + if(StringUtils.isNotBlank(id)){ + OperationReservation operationReservation = getById(id); + if(operationReservation != null){ + objectDao.delete(operationReservation); + } + } + } + + @Override + public void saveOrUpdate(OperationReservation operationReservation) { + if(operationReservation != null){ + objectDao.saveOrUpdate(operationReservation); + } + } + +}