Index: forgon-core/src/main/java/com/forgon/security/action/RoleAction.java =================================================================== diff -u -r12331 -r15532 --- forgon-core/src/main/java/com/forgon/security/action/RoleAction.java (.../RoleAction.java) (revision 12331) +++ forgon-core/src/main/java/com/forgon/security/action/RoleAction.java (.../RoleAction.java) (revision 15532) @@ -14,6 +14,8 @@ import com.forgon.security.model.Role; import com.forgon.security.service.RoleManager; import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.json.JSONUtil; import com.forgon.tools.json.JsonPropertyFilter; import com.forgon.treenode.model.THTreeNode; import com.forgon.treenode.service.THTreeNodeManager; @@ -32,7 +34,6 @@ public String loadForm() { try { - StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); iniInfo(); JsonConfig config = new JsonConfig(); PropertyFilter propertyFilter = new JsonPropertyFilter( @@ -50,14 +51,12 @@ if(thTreeNode != null){ role.setCompanyName(thTreeNode.getName()); } - Map map = new HashMap(); + Map map = new HashMap(); map.put("success", true); map.put("data", role); JSONObject jsonObject = JSONObject.fromObject(map, config); - String jsonStr = jsonObject.toString(); - StrutsParamUtils.getResponse().getWriter().println(jsonStr); - - } catch (IOException e) { + StrutsResponseUtils.output(jsonObject); + } catch (Exception e) { e.printStackTrace(); } return null; @@ -72,11 +71,19 @@ } public String save() { - if (role != null) { - if ((role.getId() == null) || (role.getId() == 0)) { - role.setId(null); + try{ + if (role != null) { + if ((role.getId() == null) || (role.getId() == 0)) { + role.setId(null); + } + roleManager.save(role, role.getParentIds()); + StrutsResponseUtils.output(true, "保存成功"); } - roleManager.save(role, role.getParentIds()); + }catch(RuntimeException e){ + StrutsResponseUtils.output(false, e.getMessage()); + }catch(Exception e){ + e.printStackTrace(); + StrutsResponseUtils.output(false, "保存失败,请稍候重试"); } return null; } Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/InvoicePlanAction.java =================================================================== diff -u -r15437 -r15532 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/InvoicePlanAction.java (.../InvoicePlanAction.java) (revision 15437) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/action/InvoicePlanAction.java (.../InvoicePlanAction.java) (revision 15532) @@ -570,8 +570,20 @@ public void getScanResult(){ String barcode = StrutsParamUtils.getPraramValue("barcode", null); + String departCode = StrutsParamUtils.getPraramValue("departCode", ""); + String[] departCodes = StringUtils.split(departCode, ';'); + + String applyDate = StrutsParamUtils.getPraramValue("applyDate", ""); + + String tousseType = null; + try { + tousseType = URLDecoder.decode(StrutsParamUtils.getPraramValue("tousseType", ""),"utf-8"); + } catch (UnsupportedEncodingException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } try{ - JSONObject json = invoicePlanManager.invoicePlanListScanBarcode(barcode); + JSONObject json = invoicePlanManager.invoicePlanListScanBarcode(barcode,departCodes,applyDate,tousseType); StrutsResponseUtils.output(json); }catch(Exception ex){ StrutsResponseUtils.output(false, ex.getMessage()); Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java =================================================================== diff -u -r15487 -r15532 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 15487) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManagerImpl.java (.../InvoicePlanManagerImpl.java) (revision 15532) @@ -25,6 +25,7 @@ import org.apache.commons.collections4.PredicateUtils; import org.apache.commons.collections4.Transformer; import org.apache.commons.collections4.functors.NotNullPredicate; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -1787,23 +1788,34 @@ } @Override - public JSONObject invoicePlanListScanBarcode(String barcode) { + public JSONObject invoicePlanListScanBarcode(String barcode, + String[] departCodings, String applyDate, String tousseType) { if (StringUtils.isBlank(barcode)) { throw new RuntimeException("缺失参数barcode"); } OrgUnit orgUnit = orgUnitManager.getOrgUnitByBarcode(barcode); if (orgUnit != null) { - int invoicePlanAmount = getInvoicePlanByOrgUnitCodings( - Collections.singleton(orgUnit.getOrgUnitCoding()), - TimeQuantum.All).size(); - if (invoicePlanAmount <= 0) { - throw new RuntimeException("该科室没有申请物品"); + if(ArrayUtils.isNotEmpty(departCodings)){ + if(!ArrayUtils.contains(departCodings,orgUnit.getOrgUnitCoding())){ + throw new RuntimeException("请扫描当前科室分组中的科室条码"); + } + int invoicePlanAmount = getInvoicePlanByOrgUnitCodings( + Collections.singleton(orgUnit.getOrgUnitCoding()), + TimeQuantum.All).size(); + if (invoicePlanAmount <= 0) { + throw new RuntimeException("该科室没有申请物品"); + } } - return orgUnitw2json(orgUnit); } else { - InvoicePlan invoicePlan = (InvoicePlan) objectDao.getByProperty( - InvoicePlan.class.getSimpleName(), "serialNumber", barcode); + Collection list = CollectionUtils.emptyCollection(); + if(ArrayUtils.isNotEmpty(departCodings)){ + list = Arrays.asList(departCodings); + } + String sql = buildSqlForGetInvoicePlanByOrgUnitCodingsAndTousseType(list, applyDate, tousseType); + sql += " and serialNumber='" + barcode + "'"; + InvoicePlan invoicePlan = (InvoicePlan) objectDao.getBySql(InvoicePlan.class.getSimpleName(),sql); +// InvoicePlan invoicePlan = (InvoicePlan) objectDao.getByProperty(InvoicePlan.class.getSimpleName(), "serialNumber", barcode); if (invoicePlan == null) throw new RuntimeException("请扫描科室条码或申请单条码"); Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.js =================================================================== diff -u -r15510 -r15532 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.js (.../invoicePlanExtractedView.js) (revision 15510) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedView.js (.../invoicePlanExtractedView.js) (revision 15532) @@ -68,9 +68,13 @@ showResult("请扫描科室条码或申请单条码"); return; } + var store = grid.getStore(); + var departCode = store.baseParams['departCode']; + var applyDate = store.baseParams['applyDate']; + var tousseType = store.baseParams['tousseType']; Ext.Ajax.request({ url : WWWROOT + '/disinfectSystem/invoicePlanAction!getScanResult.do', - params : {barcode : barcode}, + params : {barcode : barcode,departCode:departCode,applyDate:applyDate,tousseType:tousseType}, success : function(response, options) { var result = Ext.decode(response.responseText); if(result){ Index: ssts-web/src/main/webapp/systemmanage/roleFormExt.js =================================================================== diff -u -r12331 -r15532 --- ssts-web/src/main/webapp/systemmanage/roleFormExt.js (.../roleFormExt.js) (revision 12331) +++ ssts-web/src/main/webapp/systemmanage/roleFormExt.js (.../roleFormExt.js) (revision 15532) @@ -128,16 +128,17 @@ Ext.getCmp('companyName').addClass('fieldReadOnlyNoRemove'); function save(b, e){ - this.disable(); + var thiz = this; + thiz.disable(); if(!formObj.form.isValid()){ Ext.MessageBox.show({title:'错误提示', msg:'请正确填写表单各值。',buttons:Ext.Msg.OK,icon:Ext.Msg.ERROR}); - this.enable(); + thiz.enable(); return false; } var companyId = Ext.getCmp('companyId').getValue(); if(companyId == null || companyId == ""){ alert("请选择一个公司后再增加角色!"); - this.enable(); + thiz.enable(); return false; } @@ -150,7 +151,7 @@ } */ if(validateRoleName()){ - this.enable(); + thiz.enable(); return false; } formObj.form.submit({ @@ -163,7 +164,12 @@ }, failure:function(form, action){ - alert('failure = '+action.failureType); + thiz.enable(); + if(action.result && action.result.message){ + showResult(action.result.message) + }else{ + showResult("提交超时,请重试"); + } } }); } Index: forgon-core/src/main/java/com/forgon/security/service/RoleManagerImpl.java =================================================================== diff -u -r12331 -r15532 --- forgon-core/src/main/java/com/forgon/security/service/RoleManagerImpl.java (.../RoleManagerImpl.java) (revision 12331) +++ forgon-core/src/main/java/com/forgon/security/service/RoleManagerImpl.java (.../RoleManagerImpl.java) (revision 15532) @@ -5,7 +5,10 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.Stack; +import java.util.stream.Collectors; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; @@ -180,6 +183,10 @@ addParents(role, parentIds); setRoleUser(role); objectDao.saveOrUpdate(role); + //验证是否形成继承环 + Stack path = new Stack(); + path.add(role); + validateInheritance(role,role.getParents(),path); } private void setRoleUser(Role role){ @@ -311,9 +318,42 @@ } } } - } - + /** + * 获取继承路径的字符串,用于提示用户在此继承路径上形成了继承环 + * @param path + * @return + */ + private String getRolePathStr(Stack path){ + if(CollectionUtils.isNotEmpty(path)){ + List names = path.stream().map(role->role.getSimpleName()).collect(Collectors.toList()); + return String.join("->", names); + } + return ""; + } + /** + * 验证是否形成了继承环 + * @param role 需要验证的角色,验证是从这个角色开始的 + * @param parents role的父角色的集合 + * @param path 从role到当前验证的父角色之间所有角色的继承路径 + */ + private void validateInheritance(Role role,Set parents,Stack path){ + if(CollectionUtils.isNotEmpty(parents)){ + for(Role parent : parents){ + if(parent != null){ + if(parent.getId().longValue() == role.getId().longValue()){ + path.push(parent); + throw new RuntimeException("角色继承错误:在继承路径(" + getRolePathStr(path) + ")上形成了继承环"); + }else if(CollectionUtils.isNotEmpty(parent.getParents())){ + path.push(parent); + validateInheritance(role,parent.getParents(),path); + //到此说明在这一条路径上没有异常,已经正常退出了,需要在路径上弹出parent + path.pop(); + } + } + } + } + } @SuppressWarnings("unchecked") public String[] getAllRoleNameArray() { String[] names = new String[] {}; Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java =================================================================== diff -u -r15517 -r15532 --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java (.../ServiceManagerImpl.java) (revision 15517) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java (.../ServiceManagerImpl.java) (revision 15532) @@ -2868,7 +2868,21 @@ public String getInfoByBarcode_InvoicePlanList(JSONObject params) { String barcode = params.optString("barcode"); - return invoicePlanManager.invoicePlanListScanBarcode(barcode).toString(); + JSONObject extraParam = params.optJSONObject("extraParam"); + String departCodings = null; + String applyDate = null; + String tousseType = null; + if(extraParam != null){ + departCodings = extraParam.optString("departCodings"); + applyDate = extraParam.optString("applyDate"); + tousseType = extraParam.optString("tousseType"); + } + String[] departCodingArr = null; + if(StringTools.isNotBlank(departCodings)){ + departCodingArr = departCodings.split(";"); + } + + return invoicePlanManager.invoicePlanListScanBarcode(barcode,departCodingArr,applyDate,tousseType).toString(); } public String getInfoByBarcode_InvoiceSignList(JSONObject params) { @@ -3373,7 +3387,18 @@ if(StringTools.isBlank(barcode)){ return JSONUtil.buildJsonObject(false, "缺失参数barcode").toString(); } + JSONObject extraParam =params.optJSONObject("extraParam"); + String departCode = null; + if(extraParam != null){ + departCode = extraParam.optString("departCode"); + } + String departPredicate = " 1= 1"; + if(StringTools.isNotBlank(departCode)){ + departPredicate = " po.departCoding='" + departCode + "' "; + } String hql = SqlUtils.getStringFieldPredicate("po.serialNumber", barcode); + hql += String.format(" and po.deliverStatus in('%s','%s') and %s", + InvoicePlan.DELIVERSTATUS_AWAITDELIVER,InvoicePlan.DELIVERSTATUS_PARTDELIVERED,departPredicate); OperationReservation or = operationReservationManager.getFirst(hql); if(or != null){ JSONObject json = JSONUtil.buildJsonObject(true); Index: ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java =================================================================== diff -u -r15437 -r15532 --- ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 15437) +++ ssts-recyclingapplication/src/main/java/com/forgon/disinfectsystem/recyclingapplication/service/InvoicePlanManager.java (.../InvoicePlanManager.java) (revision 15532) @@ -142,8 +142,12 @@ /** * 发货计划列表扫描科室条码或者单号条码,打开对应的发货单。先按条码找科室,找不到科室就按流水号找申请单 * @param barcode 科室条码或者单号条码 + * @param departCodings 科室分组中的科室编码 + * @param applyDate 申请时间过滤 + * @param tousseType 器械包类型,一次性物品或者非一次性物品 * @return */ - public JSONObject invoicePlanListScanBarcode(String barcode); + public JSONObject invoicePlanListScanBarcode(String barcode, + String[] departCodings, String applyDate, String tousseType); }