Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java =================================================================== diff -u -r26060 -r26144 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 26060) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManager.java (.../TousseDefinitionManager.java) (revision 26144) @@ -174,6 +174,19 @@ String settleAccountsDepartCoding,String deptCode); /** + * 搜索器械包(含消毒物品)和一次性物品,返回JSONObject对象. + * @param searchString 搜索的字符串 + * @param tousseType 搜索的物品类型(多样化) + * @param showReferencePrice 是否显示参考价格 + * @param showExternalCodeOfDisposableGoods 是否显示一次性物品的外部编码 + * @param settleAccountsDepartCoding 结算科室编码 + * @param deptCode 处理科室编码 + * @param useAssetsBelong 使用资产归属过滤 + * @return + */ + public Map searchComboGoods(String searchString, String tousseType,boolean showReferencePrice,boolean showExternalCodeOfDisposableGoods, + String settleAccountsDepartCoding,String deptCode, boolean useAssetsBelong); + /** * 获取某个包定义的所有器械材料实例. * @param tousseDefinitionId 器械包ID * @return @@ -391,6 +404,33 @@ * 根据关键字进行检索,获取器械包或一次性物品..
* 如果searchString为中文,则按照器械包的(拼音码、五笔码、外部编码、名称)这四个字段进行检索
* 如果searchString为英文,则根据用户属性表的searchMode字段来决定
+ * @param simpleSpell 检索的关键字 + * @param isSeachTousse 为true时只查询器械包,为false时只查询一次性物品 + * @param includeCoustomTousse 为true时不过滤自定义器械包,为false时过滤自定义器械包 + * @param searchTousseBelonged 是否只搜索登录用户当前科室能处理的器械包 + * @param onlySearchRecyclingTousse 是否只搜索要回收的器械包 + * @param displayPrice + * @param pageIndex 页码 + * @param countOfLI 显示数目,当countOfLI为0时查询所有的记录,不分页 + * @param showDisableGoods 是否显示禁用物品 + * @param showExternalCodeOfDisposableGoods 是否显示一次性物品的外部编码 + * @param settleAccountsDepartCoding 结算科室的科室编码(用于取一次性物品的浮动系数) + * @param handleDepartCode + * @param specifyDisposableTypes 是否包含指定的一次性物品类型,格式:{include:是否包含,disposableTypes:'一次性物品类型集合'} + * @param useAssetsBelong 使用资产归属过滤 + * @return + */ + public List> searchTousseOrDiposableGoodsBySpellAndWbCode( + String simpleSpell, boolean isSeachTousse, + boolean includeCoustomTousse, boolean searchTousseBelonged, + boolean onlySearchRecyclingTousse, boolean displayPrice, + String pageIndex, String countOfLI, boolean showDisableGoods, + boolean showExternalCodeOfDisposableGoods,String settleAccountsDepartCoding,String handleDepartCode,String specifyDisposableTypes,boolean useAssetsBelong); + + /** + * 根据关键字进行检索,获取器械包或一次性物品..
+ * 如果searchString为中文,则按照器械包的(拼音码、五笔码、外部编码、名称)这四个字段进行检索
+ * 如果searchString为英文,则根据用户属性表的searchMode字段来决定
* * @param simpleSpell 检索的关键字 * @param isSeachTousse 为true时只查询器械包,为false时只查询一次性物品 @@ -417,6 +457,35 @@ String pageIndex, String countOfLI, boolean showDisableGoods, boolean showExternalCodeOfDisposableGoods,String settleAccountsDepartCoding,String handleDepartCode,String specifyDisposableTypes); /** + * 根据关键字进行检索,获取器械包或一次性物品..
+ * 如果searchString为中文,则按照器械包的(拼音码、五笔码、外部编码、名称)这四个字段进行检索
+ * 如果searchString为英文,则根据用户属性表的searchMode字段来决定
+ * + * @param simpleSpell 检索的关键字 + * @param isSeachTousse 为true时只查询器械包,为false时只查询一次性物品 + * @param includeCoustomTousse 为true时不过滤自定义器械包,为false时过滤自定义器械包 + * @param includeForeignTousse 为true时包含外来器械包,为false时过滤外来器械包 + * @param searchTousseBelonged 是否只搜索登录用户当前科室能处理的器械包 + * @param onlySearchRecyclingTousse 是否只搜索要回收的器械包 + * @param showReferencePrice + * @param pageIndex 页码 + * @param countOfLI 显示数目,当countOfLI为0时查询所有的记录,不分页 + * @param showDisableGoods 是否显示禁用物品 + * @param showExternalCodeOfDisposableGoods 是否显示一次性物品的外部编码 + * @param settleAccountsDepartCoding + * @param handleDepartCode + * @param specifyDisposableTypes 是否包含指定的一次性物品类型,格式:{include:是否包含,disposableTypes:'一次性物品类型集合'} + * @param useAssetsBelong 使用资产归属过滤 + * @return + */ + public List> searchTousseOrDiposableGoodsBySpellAndWbCode( + String simpleSpell, boolean isSeachTousse, + boolean includeCoustomTousse, boolean searchTousseBelonged, + boolean onlySearchRecyclingTousse, boolean displayPrice, + boolean includeForeignTousse, + String pageIndex, String countOfLI, boolean showDisableGoods, + boolean showExternalCodeOfDisposableGoods,String settleAccountsDepartCoding,String handleDepartCode,String specifyDisposableTypes,boolean useAssetsBelong); + /** * 根据包定义查找包定义,因为可能会存在多个,这里取id最大的. * @param tousseDefinition * @return @@ -492,6 +561,33 @@ String[] tousseTypeArr ,boolean showDisableGoods, boolean sortBySpelling); /** + * 在指定的器械包类型的基础上,根据关键字模糊查询,获取器械包的部分信息.. + * @param keyword 搜索的关键字:为空时则不需要模糊查询(即:全部符合条件),否则按照用户的检索习惯进行模糊查询 + * @param tousseTypeArr 指定的器械包类型的数组,如果不指定则为:所有器械包类型 + * @param showDisableGoods 是否要显示已经停用的器械包 + * @param sortBySpelling 是否按拼音码进行排序 + * @param useAssetsBelong 使用资产归属过滤 + * @return 返回值格式如下,取每个器械包对象的12个属性:
+ * [{
+ * id:器械包id,
+ * name:器械包名称,
+ * displayName:如果外部编码不为空则为“外部编码+ +器械包名称”,否则为“器械包名称”,
+ * spelling:器械包名称拼音码,
+ * wbCode:器械包名称五笔码,
+ * price:器械包价格,
+ * borrowPrice:器械包出借价格,
+ * type:器械包类型,
+ * isCleanedEntirely:是否整包清洗,
+ * isApplyEntireTousse:是否整包申请(只针对消毒物品才有意义),
+ * expressInvoice:是否快速发货,
+ * unit:器械包的单位,
+ * materialsArry:材料的详细信息(包类型为消毒物品才有此属性)
+ * },{}......] + */ + public List> searchTousseByKeywordAndTousseTypeArr(String keyword, + String[] tousseTypeArr ,boolean showDisableGoods, boolean sortBySpelling, boolean useAssetsBelong); + + /** * overload * (器械包工作量报表使用,只需要名字,不需要查询过多的数据,加快报表设置统计类型的效率)在指定的器械包类型的基础上,根据关键字模糊查询,获取器械包的名字 * @param filterForDisplay 是否过滤掉ForDisplay=0的器械包 @@ -518,6 +614,18 @@ public List getCssdHandleTousseDefinitionList(OrgUnit cssdOrgUnit,String spell,int start,int limit,Set predicates,JSONObject retObj); /** + * 查询科室处理器械包. + * @param cssdOrgUnit 处理科室的科室编码 + * @param spell 搜索关键字 + * @param start 开始的行数 + * @param limit 每一页显示的大小 + * @param predicates 需要过滤的条件集合 + * @param retObj 额外的参数是一个JSONObject对象(里面有两个属性:1、needToBw:为true则需要根据物品黑白名单过滤 2、appCode:申请科室的科室编码) + * @param useAssetsBelong 使用资产归属过滤 + * @return + */ + public List getCssdHandleTousseDefinitionList(OrgUnit cssdOrgUnit,String spell,int start,int limit,Set predicates,JSONObject retObj,boolean useAssetsBelong); + /** * 新建或修改科室处理器械包配置. * @param orgUnit * @param tousseDefinitionList @@ -613,6 +721,12 @@ String handlerDepartCodes,String supplierName,boolean showDisableGoods,boolean showForeignTousseAncestorDefinition); /** + * 重载上面的方法,新增是否使用资产归属过滤 + * @param useAssetsBelong 使用资产归属过滤 + */ + public List searchTousseDefinitions(String searchString,String tousseType, + String handlerDepartCodes,String supplierName,boolean showDisableGoods,boolean showForeignTousseAncestorDefinition,boolean useAssetsBelong); + /** * 获取祖先id,如果祖先id为空,则返回包定义自己的id. * @param tousseDefinition * @return Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java =================================================================== diff -u -r26142 -r26144 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 26142) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/service/TousseDefinitionManagerImpl.java (.../TousseDefinitionManagerImpl.java) (revision 26144) @@ -968,7 +968,104 @@ TousseDefinition.class.getSimpleName(), sql); return tousseDefinitions; } + @Override + public List searchTousseDefinitions(String searchString, + String tousseType, String handlerDepartCodes, String supplierName, + boolean showDisableGoods, + boolean showForeignTousseAncestorDefinition, boolean useAssetsBelong) { + searchString = SqlUtils.filterIllegalCharachers(searchString); + + String sql = createQuerySQL(searchString); + + if (TousseDefinition.PACKAGE_TYPE_INSIDE.equals(tousseType)) {// 内部器械包 + // 申请单会进入这个ELSE + sql += " and po.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_INSIDE + "'"; + } else if (TousseDefinition.PACKAGE_TYPE_FOREIGN.equals(tousseType)) {// 外来器械包 + // 外来器械包 + sql += " and po.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_FOREIGN + "'"; + // 如果当前登录用户为外来器械供应商的申请人员时,只查询该申请人员关联的供应商下的外来器械包或未配置申请人员的供应商的外来器械包 + List supplierNameList = supplierManager.getSupplierNameListByTypeAndUserCode(Supplier.SUPPLIER_TYPE_RENTTOUSSE, AcegiHelper.getLoginUser().getUserName()); + if(CollectionUtils.isNotEmpty(supplierNameList)){ + sql += " and " + SqlUtils.getStringFieldInLargeCollectionsPredicate("supplierName", supplierNameList); + } + } else if (TousseDefinition.PACKAGE_TYPE_DISINFECTION + .equals(tousseType)) { + // 消毒物品 + sql += " and po.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_DISINFECTION + + "'"; + } else if (TousseDefinition.PACKAGE_TYPE_FOREIGNPROXY.equals(tousseType)) {// 外部代理灭菌器械包 + // 外部代理灭菌器械包 + sql += " and po.tousseType = '" + + TousseDefinition.PACKAGE_TYPE_FOREIGNPROXY + "'"; + } + // 允许自定义装配的器械包 + else if (TousseDefinition.PACKAGE_TYPE_CAN_CUSTOM_PACKING.equals(tousseType)) { + sql = addInternalTousseTypesQuery(sql); + + sql += " and po.isCustomPacking = '" + + TousseDefinition.STR_YES + "'"; + } else if ("all".equals(tousseType)) { + sql += " and po.tousseType != '" + + TousseDefinition.PACKAGE_TYPE_SPLIT + "'"; + } else { + // 其他 (内部器械包) + sql = addInternalTousseTypesQuery(sql); + } + if (StringUtils.isNotBlank(handlerDepartCodes)) { + String handlerDepartCodeSql = null; + for (String handlerDepartCode : handlerDepartCodes.split(";")) { + if (handlerDepartCodeSql == null) { + handlerDepartCodeSql = " and (po.handlerDepartCode = '" + + handlerDepartCode + "'"; + } else { + handlerDepartCodeSql += " or po.handlerDepartCode = '" + + handlerDepartCode + "'"; + } + } + sql += handlerDepartCodeSql + ")"; + } + if(StringUtils.isNotBlank(supplierName)){ + sql += String.format(" and po.supplierName='%s'", supplierName); + } + // 包类型不是【外来器械包】时,才增加forDisplay!=0的过滤 + if (!TousseDefinition.PACKAGE_TYPE_FOREIGN.equals(tousseType)) { + sql += " and po.forDisplay != 0 "; + }else{ + if(showForeignTousseAncestorDefinition){ + sql += " and po.forDisplay != 0 "; + // 查询外来器械申请单创建的包定义 + } else { + if(!showDisableGoods){ + //用祖先id的话,有些旧数据祖先id是自己,就没办法停用了。 + sql += String.format(" and po.name not in(select distinct t.name from TousseDefinition t where t.tousseType = '%s' and t.forDisplay = 1 and t.isDisable = '%s') ", + TousseDefinition.PACKAGE_TYPE_FOREIGN,Constants.STR_YES); + } + } + } + + //不显示停用的器械包 + if(!showDisableGoods){ + sql += " and (po.isDisable = '" + Constants.STR_NO + "' or po.isDisable is null) "; + } + //根据资产归属进行过滤 + String orgUnitCoding = AcegiHelper.getCurrentOrgUnitCode(); + //判断当前科室是否是供应室 不过滤供应室 + boolean isFirstOrSecondSupplyRoomOrgUnit = supplyRoomConfigManager.isFirstOrSecondSupplyRoomOrgUnit(orgUnitCoding); + if(useAssetsBelong && !isFirstOrSecondSupplyRoomOrgUnit){ + //只查询归属本科室的包 + sql += " and ( (po.assetsBelong like '%\"departCode\":\""+orgUnitCoding+"\"%') or po.assetsBelong is null or po.assetsBelong = '')"; + } + sql += " order by " + DatabaseUtil.getSqlLengthFunctionName(dbConnection) + "(po.name) asc,id desc"; + + @SuppressWarnings("unchecked") + List tousseDefinitions = objectDao.findBySql( + TousseDefinition.class.getSimpleName(), sql); + return tousseDefinitions; + } private String addInternalTousseTypesQuery(String sql) { sql += " and po.tousseType != '" + TousseDefinition.PACKAGE_TYPE_FOREIGN @@ -1039,7 +1136,7 @@ map.put("data", mapList); return JSONObject.fromObject(map); } - + @Override @SuppressWarnings("unchecked") public List> searchTousseOrDiposableGoodsBySpellAndWbCode( @@ -1054,6 +1151,19 @@ } @Override + public List> searchTousseOrDiposableGoodsBySpellAndWbCode( + String simpleSpell, boolean isSeachTousse, + boolean includeCoustomTousse, boolean searchTousseBelonged, + boolean onlySearchRecyclingTousse, boolean displayPrice, + String pageIndex, String countOfLI, boolean showDisableGoods, + boolean showExternalCodeOfDisposableGoods, + String settleAccountsDepartCoding, String handleDepartCode, + String specifyDisposableTypes, boolean useAssetsBelong) { + return searchTousseOrDiposableGoodsBySpellAndWbCode(simpleSpell,isSeachTousse,includeCoustomTousse, + searchTousseBelonged,onlySearchRecyclingTousse,displayPrice,false,pageIndex, + countOfLI,showDisableGoods,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,handleDepartCode,specifyDisposableTypes,true); + } + @Override @SuppressWarnings("unchecked") public List> searchTousseOrDiposableGoodsBySpellAndWbCode( String simpleSpell, boolean isSeachTousse, @@ -1159,7 +1269,6 @@ String[] split = specifyDisposableTypeObj.optString("disposableTypes").split(";"); if (split.length > 0) { List list = Arrays.asList(split); - String typeSql = ""; if (specifyDisposableTypeObj.optBoolean("include")) { typeSql = String.format(" and %s ", SqlUtils.getStringFieldInLargeCollectionsPredicate("po.type", list)); @@ -1179,6 +1288,139 @@ } return mapList; } + @Override + public List> searchTousseOrDiposableGoodsBySpellAndWbCode( + String simpleSpell, boolean isSeachTousse, + boolean includeCoustomTousse, boolean searchTousseBelonged, + boolean onlySearchRecyclingTousse, boolean displayPrice, + boolean includeForeignTousse, String pageIndex, String countOfLI, + boolean showDisableGoods, + boolean showExternalCodeOfDisposableGoods, + String settleAccountsDepartCoding, String handleDepartCode, + String specifyDisposableTypes, boolean useAssetsBelong) { + // 有些输入法会输入"'",要过滤掉,不过滤执行sql会报异常 + if(StringUtils.isNotBlank(simpleSpell)){ + simpleSpell = simpleSpell.replace("'", ""); + } + String sql = createQuerySQL(simpleSpell); + + if (onlySearchRecyclingTousse){ + sql += " and po.isRecycling = '"+TousseDefinition.STR_YES+"' and po.tousseType in ('"+ TousseDefinition.PACKAGE_TYPE_INSIDE +"','"+ TousseDefinition.PACKAGE_TYPE_DISINFECTION +"') "; + } + + //按处理科室查询器械包,改为从CssdHandleTousses表查询,不再按器械包定义里面的查询 + /*if (searchTousseBelonged){ + String handlerDepartCode = AcegiHelper.getLoginUser().getOrgUnitCodingFromSupplyRoomConfig(); + if(StringUtils.isNotBlank(handlerDepartCode)){ + sql += " and po.handlerDepartCode = '" + handlerDepartCode + "' "; + } + }*/ + List> mapList = new ArrayList>(); + if (isSeachTousse) { + // 排除外部代理灭菌和外来器械拆分小包 + sql += (" and po.tousseType != '" + + TousseDefinition.PACKAGE_TYPE_SPLIT + + "' and po.tousseType != '" + + TousseDefinition.PACKAGE_TYPE_FOREIGNPROXY + "'"); + + if(includeCoustomTousse == false){ + sql += (" and po.tousseType != '" + + TousseDefinition.PACKAGE_TYPE_CUSTOM + "'"); + } + if(includeForeignTousse == false){ + sql += (" and po.tousseType != '" + + TousseDefinition.PACKAGE_TYPE_FOREIGN + "'"); + } + sql += " and po.forDisplay = 1 ";//自己生成的包定义不显示 + if(searchTousseBelonged){ + sql += " and po.ancestorID in (select tousseDefinitionId from " + CssdHandleTousses.class.getSimpleName() + + " where orgUnitCode='"+ AcegiHelper.getLoginUser().getCurrentOrgUnitCode()+"')"; + } + //是否显示禁用物品 + if(!showDisableGoods){ + sql += " and po.isDisable != '" + TousseDefinition.STR_YES + "' "; + } + //根据资产归属进行过滤 + String orgUnitCoding = AcegiHelper.getCurrentOrgUnitCode(); + //判断当前科室是否是供应室 不过滤供应室 + boolean isFirstOrSecondSupplyRoomOrgUnit = supplyRoomConfigManager.isFirstOrSecondSupplyRoomOrgUnit(orgUnitCoding); + if(useAssetsBelong && !isFirstOrSecondSupplyRoomOrgUnit){ + //只查询归属本科室的包 + sql += " and ( (po.assetsBelong like '%\"departCode\":\""+orgUnitCoding+"\"%') or po.assetsBelong is null or po.assetsBelong = '')"; + } + int amount = Integer.parseInt(countOfLI); + int index = (Integer.parseInt(pageIndex) - 1) * amount; + + if (amount > 0){ + // 如果要分页显示,则不能按名字长度排序。因为同样长度的包太多,会导致分页不准确 + sql += " order by po.name asc"; + }else{ + // 不分页显示,按名称的长度排序显示 + sql += " order by " + DatabaseUtil.getSqlLengthFunctionName(dbConnection) + "(po.name) asc"; + } + List tousseDefinitions = objectDao + .findBySql(TousseDefinition.class.getSimpleName(), sql, + index, amount, null); + if (tousseDefinitions != null) { +// String handlerDepartCode = AcegiHelper.getLoginUser().getOrgUnitCodingFromSupplyRoomConfig(); + for (TousseDefinition tousseDefinition : tousseDefinitions) { + //不可以在这里这样判断,因为有分页,有可能因为分页导致查询结果中没有目标处理科室的内容,但是实际上是有对应的内容的,只是当前页没有获取到 +// if (searchTousseBelonged){ +// if(!getTousseTaskGroupByOrgUnitCode(tousseDefinition , handlerDepartCode)){ +// continue; +// } +// } + Map temp = new HashMap(); + temp.put("id", tousseDefinition.getId()); + temp.put("name", tousseDefinition.getName()); + temp.put("showName", tousseDefinition.getName()); + temp.put("displayName", tousseDefinition.getName()); + temp.put("spelling", tousseDefinition.getSpelling()); + temp.put("price", tousseDefinition.getPrice()); + temp.put("type", tousseDefinition.getTousseType()); + temp.put("isCleanedEntirely", tousseDefinition.getIsCleanedEntirely()); + temp.put("isApplyEntireTousse", tousseDefinition.getIsApplyEntireTousse()); + Double borrowPrice = tousseDefinition.getBorrowPrice(); + temp.put("borrowPrice", borrowPrice == null ? 0 : borrowPrice); + String isDisableIDCard = tousseDefinition.getIsDisableIDCard(); + String isThereIdentificationCard = "否"; + if("否".equals(isDisableIDCard)){ + isThereIdentificationCard = "是"; + } + temp.put("isThereIdentificationCard", isThereIdentificationCard); + mapList.add(temp); + } + } + } else { + if(!showDisableGoods){ + sql += " and po.isDisable = '" + Constants.STR_NO + "' and po.isApplicationMaterial = '" + DisposableGoodsStock.CONSTANT_YES + "' "; + } + //按一次性物品类型过滤 + if (StringTools.isNotBlank(specifyDisposableTypes)) { + JSONObject specifyDisposableTypeObj = JSONObject.fromObject(specifyDisposableTypes); + String[] split = specifyDisposableTypeObj.optString("disposableTypes").split(";"); + if (split.length > 0) { + List list = Arrays.asList(split); + + String typeSql = ""; + if (specifyDisposableTypeObj.optBoolean("include")) { + typeSql = String.format(" and %s ", SqlUtils.getStringFieldInLargeCollectionsPredicate("po.type", list)); + } else { + typeSql = String.format(" and (%s or po.type='' or po.type is null) ", SqlUtils.getStringFieldNotInCollectionsPredicate("po.type", list)); + } + sql += typeSql; + } + } + sql += " order by " + + DatabaseUtil.getSqlLengthFunctionName(dbConnection) + + "(po.name) asc"; + List> diposableGoodsList = diposableGoodsManager + .getDisposableGoodsList(sql,displayPrice,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,handleDepartCode); + + mapList = diposableGoodsList; + } + return mapList; + } private List> searchTousseOrDiposableGoodsBySpellAndWbCodeWithStock( String simpleSpell) { @@ -1549,6 +1791,60 @@ mapList.addAll(searchTousseOrDiposableGoodsBySpellAndWbCode( searchString, false, false, false,false,showReferencePrice,"1","0",false,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,deptCode,null)); } + + Map map = new HashMap(); + map.put("totalCount", mapList.size()); + map.put("data", mapList); + return map; + } + @Override + public Map searchComboGoods(String searchString, + String tousseType, boolean showReferencePrice, + boolean showExternalCodeOfDisposableGoods, + String settleAccountsDepartCoding, String deptCode, + boolean useAssetsBelong) { + List> mapList = new ArrayList>(); + // 只搜索器械包(包含敷料包和消毒物品),如果启用了聚合包功能则包括聚合包 + if (TousseDefinition.PACKAGE_TYPE_INSIDE_AND_DISINFECTION.equals(tousseType)){ + String[] searchTousseTypeArray = new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, + TousseDefinition.PACKAGE_TYPE_DRESSING,TousseDefinition.PACKAGE_TYPE_DISINFECTION }; + if(CssdUtils.getSystemSetConfigByNameBool("enableComboTousse")){ + searchTousseTypeArray = new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, + TousseDefinition.PACKAGE_TYPE_DRESSING,TousseDefinition.PACKAGE_TYPE_DISINFECTION,TousseDefinition.PACKAGE_TYPE_COMBO }; + } + mapList = searchTousseByKeywordAndTousseTypeArr( + searchString, searchTousseTypeArray,false ,false); + //器械包和敷料包 + }else if(TousseDefinition.PACKAGE_TYPE_INSIDE_AND_DRESSING.equals(tousseType)){ + mapList = searchTousseByKeywordAndTousseTypeArr( + searchString, new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, + TousseDefinition.PACKAGE_TYPE_DRESSING},false ,false); + } + // 只搜索器械包(包含敷料包,不含消毒物品) + else if (TousseDefinition.PACKAGE_TYPE_INSIDE.equals(tousseType)){ + mapList = searchTousseByKeywordAndTousseTypeArr( + searchString, new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, + TousseDefinition.PACKAGE_TYPE_DRESSING },false ,false,true); + } + // 只搜索一次性物品 + else if (TousseItem.TYPE_DIPOSABLE_GOODS.equals(tousseType)){ + mapList.addAll(searchTousseOrDiposableGoodsBySpellAndWbCode( + searchString, false, false, false,false,true,"1","0",false,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,deptCode,null)); + } + //只搜索消毒物品 + else if (TousseDefinition.PACKAGE_TYPE_DISINFECTION.equals(tousseType)){ + mapList = searchTousseByKeywordAndTousseTypeArr(searchString, new String[]{TousseDefinition.PACKAGE_TYPE_DISINFECTION},false ,false,true); + } + // 搜索多种器械包(含消毒物品)和一次性物品,用于组合申请单 + else{ + mapList = searchTousseByKeywordAndTousseTypeArr( + searchString, new String[]{TousseDefinition.PACKAGE_TYPE_INSIDE, + TousseDefinition.PACKAGE_TYPE_DRESSING, + TousseDefinition.PACKAGE_TYPE_DISINFECTION },false ,true); + + mapList.addAll(searchTousseOrDiposableGoodsBySpellAndWbCode( + searchString, false, false, false,false,showReferencePrice,"1","0",false,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,deptCode,null)); + } Map map = new HashMap(); map.put("totalCount", mapList.size()); @@ -1647,7 +1943,7 @@ public String searchInsideTousse(String simpleSpell, String pages, String countOfLI) { List> mapList = searchTousseOrDiposableGoodsBySpellAndWbCode( - simpleSpell, true, false, true, true,false, pages, countOfLI,false,false,null,null,null); + simpleSpell, true, false, true, true,false, pages, countOfLI,false,false,null,null,null,true); JSONArray array = new JSONArray(); int countOfLIInt = Integer.valueOf(countOfLI); if (mapList != null) { @@ -1880,6 +2176,55 @@ } @Override + public List> searchTousseByKeywordAndTousseTypeArr( + String keyword, String[] tousseTypeArr, boolean showDisableGoods, + boolean sortBySpelling, boolean useAssetsBelong) { + String sql = createQuerySQL(keyword); + + //只在指定器械包类型做查询 + if (tousseTypeArr != null && tousseTypeArr.length > 0) { + String tempTousseTypeSql = ""; + for (String tousseType : tousseTypeArr) { + if (tousseType != null) { + if (StringUtils.isNotBlank(tempTousseTypeSql)) { + tempTousseTypeSql += " or "; + } + tempTousseTypeSql += " po.tousseType = '" + + tousseType.trim() + "'"; + } + } + + if (StringUtils.isNotBlank(tempTousseTypeSql)) { + sql += " and (" + tempTousseTypeSql + ") "; + } + } + sql += " and po.forDisplay != 0 "; //forDisplay=0的过滤掉 + + if (!showDisableGoods) { //过滤已停用的器械包(注意:如果isDisable属性为空,当成非停用的器械包,不过滤) + sql += String.format(" and(po.isDisable is null or po.isDisable<>'%s') ", + TousseDefinition.STR_YES); + } + //根据资产归属进行过滤 + String orgUnitCoding = AcegiHelper.getCurrentOrgUnitCode(); + //判断当前科室是否是供应室 不过滤供应室 + boolean isFirstOrSecondSupplyRoomOrgUnit = supplyRoomConfigManager.isFirstOrSecondSupplyRoomOrgUnit(orgUnitCoding); + if(useAssetsBelong && !isFirstOrSecondSupplyRoomOrgUnit){ + //只查询归属本科室的包 + sql += " and ( (po.assetsBelong like '%\"departCode\":\""+orgUnitCoding+"\"%') or po.assetsBelong is null or po.assetsBelong = '')"; + } + String orderBySql = String.format(" order by %s ", (sortBySpelling ? "spelling" : DatabaseUtil.getSqlLengthFunctionName(dbConnection) + "(name)")); + + List> mapList = new ArrayList>(); + List tousseDefinitions = objectDao.findBySql(TousseDefinition.class.getSimpleName(), sql + orderBySql); + + if (tousseDefinitions != null) { + for (TousseDefinition tousseDefinition : tousseDefinitions) { + mapList.add(buildTousseDefinitionInfo(tousseDefinition)); + } + } + return mapList; + } + @Override public List> searchTousseByKeywordAndTousseTypeArr(boolean filterForDisplay, String keyword, String[] tousseTypeArr, boolean showDisableGoods) { String sql = createQuerySQL(keyword); @@ -2308,7 +2653,7 @@ whereSql = goodFilterConfigManagerImpl.buildBWListSql(whereSql, appCode); } } - + String findSql = String.format(" from %s %s order by spelling ", TousseDefinition.class.getSimpleName(),whereSql); logger.debug("findSql:" + findSql); if(limit > 0){ @@ -2323,7 +2668,53 @@ retObj.put("totalCount", totalCount); return list; } + @Override + public List getCssdHandleTousseDefinitionList( + OrgUnit cssdOrgUnit, String spell, int start, int limit, + Set predicates, JSONObject retObj, boolean useAssetsBelong) { + List list = null; + int totalCount = 0; + String whereSql = " where fordisplay = 1 and id in (select tousseDefinitionId from " + + CssdHandleTousses.class.getSimpleName() + " where orgUnitCode = '" + cssdOrgUnit.getOrgUnitCoding() + "')"; + whereSql += " and (spelling like '%" + spell + "%' or wbCode like '%" + + spell + "%' or externalCode like '" + spell + + "%' or name like '%" + spell + "%') and (isDisable is null or isDisable = '"+TousseDefinition.STR_NO+"')"; + if(!predicates.isEmpty()){ + for (String predicate : predicates) { + whereSql += " and " + predicate; + } + } + if (JSONUtil.optBoolean(retObj, "needToBw", false)){ + //黑白名单过滤 + String appCode = retObj.getString("appCode"); + if(StringUtils.isNotBlank(appCode)){ + //只有申请科室编号不为空才开启过滤 + whereSql = goodFilterConfigManagerImpl.buildBWListSql(whereSql, appCode); + } + } + //根据资产归属进行过滤 + String orgUnitCoding = AcegiHelper.getCurrentOrgUnitCode(); + //判断当前科室是否是供应室 不过滤供应室 + boolean isFirstOrSecondSupplyRoomOrgUnit = supplyRoomConfigManager.isFirstOrSecondSupplyRoomOrgUnit(orgUnitCoding); + if(true && !isFirstOrSecondSupplyRoomOrgUnit){ + //只查询归属本科室的包 + whereSql += " and ( (po.assetsBelong like '%\"departCode\":\""+orgUnitCoding+"\"%') or po.assetsBelong is null or po.assetsBelong = '')"; + } + String findSql = String.format(" from %s %s order by spelling ", TousseDefinition.class.getSimpleName(),whereSql); + logger.debug("findSql:" + findSql); + if(limit > 0){ + list = objectDao.findByHql(findSql,start,limit); + totalCount = objectDao.countObjectBySql(TousseDefinition.class.getSimpleName(),whereSql); + }else{ + list = objectDao.findByHql(findSql); + if(list != null){ + totalCount = list.size(); + } + } + retObj.put("totalCount", totalCount); + return list; + } @Override public List saveOrUpdateCssdHandleTousseDefinitions( OrgUnit orgUnit, List tousseDefinitionList) { Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java =================================================================== diff -u -r26060 -r26144 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java (.../TousseDefinitionAction.java) (revision 26060) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java (.../TousseDefinitionAction.java) (revision 26144) @@ -1460,7 +1460,7 @@ spell = java.net.URLDecoder.decode(spell, "UTF-8"); List tousseDefinitions = tousseDefinitionManager.searchTousseDefinitions( - spell, TousseDefinition.PACKAGE_TYPE_FOREIGNPROXY, null,null,false,false); + spell, TousseDefinition.PACKAGE_TYPE_FOREIGNPROXY, null,null,false,false,true); JSONArray data = new JSONArray(); for (TousseDefinition tousseDefinition : tousseDefinitions) { @@ -1763,7 +1763,7 @@ retObj.put("needToBw", true); retObj.put("appCode", appCode); } - List tousseDefinitiionList = tousseDefinitionManager.getCssdHandleTousseDefinitionList(cssd,spell,start,limit,predicates,retObj); + List tousseDefinitiionList = tousseDefinitionManager.getCssdHandleTousseDefinitionList(cssd,spell,start,limit,predicates,retObj,true); if(CollectionUtils.isNotEmpty(tousseDefinitiionList)){ for(TousseDefinition tousseDefinition : tousseDefinitiionList){ @@ -1827,7 +1827,7 @@ result.put("data", mapDataList); json = JSONObject.fromObject(result); }else{ //申请时处理科室为空的是不合理的 - Map result = tousseDefinitionManager.searchComboGoods(spell, tousseType,showReferencePrice,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,null); + Map result = tousseDefinitionManager.searchComboGoods(spell, tousseType,showReferencePrice,showExternalCodeOfDisposableGoods,settleAccountsDepartCoding,null,true); List> mapList = (List>)result.get("data"); List> mapDataList = mapList; if(limit > 0){