Index: ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialAppropriationView.js =================================================================== diff -u -r18549 -r18614 --- ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialAppropriationView.js (.../materialAppropriationView.js) (revision 18549) +++ ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialAppropriationView.js (.../materialAppropriationView.js) (revision 18614) @@ -721,7 +721,7 @@ filters:[ {type: 'string', dataIndex: 'serialNumber'}, {type: 'string', dataIndex: 'operator'}, - {type: 'string', dataIndex: 'warehouseName'}, + {type: 'string', dataIndex: 'wareHouseName'}, {type: 'string', dataIndex: 'targetWareHouseName'}, {type: 'date', dataIndex: 'time'}, {type: 'string', dataIndex: 'remark'} @@ -796,7 +796,7 @@ } var startDayofMonth = dt.getFullYear() + "/" + v + "/01"; var tBarForm = new TBarForm(); - tBarForm.setKeyWordStore(WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionData.do'); + tBarForm.setKeyWordStore(WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionDatas.do?selectType=material',100);//100每页显示多少条记录 var queryForm = tBarForm.initForm(); var tableContent; Index: ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialOutView.js =================================================================== diff -u -r18549 -r18614 --- ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialOutView.js (.../materialOutView.js) (revision 18549) +++ ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialOutView.js (.../materialOutView.js) (revision 18614) @@ -2,7 +2,7 @@ var grid; var materialDefinitionStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ - url : WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionData.do?selectType=material', + url : WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionDatas.do?selectType=material', method : 'POST' }), reader : new Ext.data.JsonReader({ @@ -862,7 +862,7 @@ }); var tBarForm = new TBarForm(); - tBarForm.setKeyWordStore(WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionData.do'); + tBarForm.setKeyWordStore(WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionDatas.do?selectType=material', 100);//100为每页最多显示多少条记录 var queryForm = tBarForm.initForm(); var viewport = new Ext.Viewport( { layout : 'border', Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/service/MaterialDefinitionManagerImpl.java =================================================================== diff -u -r18218 -r18614 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/service/MaterialDefinitionManagerImpl.java (.../MaterialDefinitionManagerImpl.java) (revision 18218) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/service/MaterialDefinitionManagerImpl.java (.../MaterialDefinitionManagerImpl.java) (revision 18614) @@ -207,6 +207,39 @@ * 获取器械包NAME和ID */ @Override + public JSONObject searchMaterialDefinitionAndDiposableGoodsData( + String simpleSpell, String selectType , String canInventory ,int start, int limit) { + JSONObject json = null; + int count = 0; + List> mapList = new ArrayList>(); + if ("material".equals(selectType)) { + mapList.addAll(searchMaterialDefinitionOrDiposableGoodsBySpellData( + simpleSpell, true , null , false, false, canInventory , start , limit));// 再生材料 + count = searchMaterialDefinitionOrDiposableGoodsBySpellPage(simpleSpell, true , null , false, false, canInventory);//材料页数 + } + + if ("diposable".equals(selectType)) { + mapList.addAll(searchMaterialDefinitionOrDiposableGoodsBySpellData( + simpleSpell, false , null, false, false, canInventory , start , limit));// 一次性材料 + count = searchMaterialDefinitionOrDiposableGoodsBySpellPage(simpleSpell, false , null , false, false, canInventory);//一次性物品页数 + } + + if ("all".equals(selectType)){ + mapList.addAll(searchMaterialDefinitionAndDiposableGoodsBySpell( + simpleSpell, null, false, false, canInventory ,start , limit)) ;//材料和一次性物品 + count = searchMaterialDefinitionAndDiposableGoodsBySpellPage(simpleSpell, null, false , false, canInventory);//材料和一次性物品总页数 + } + Map map = new HashMap(); + map.put("totalCount", count); + map.put("data", mapList); + json = JSONObject.fromObject(map); + return json; + } + + /** + * 获取器械包NAME和ID + */ + @Override public JSONObject searchMaterialDefinitionAndDiposableGoods( String simpleSpell, String selectType , String canInventory) { JSONObject json = null; @@ -332,20 +365,394 @@ @SuppressWarnings("unchecked") public List> searchMaterialDefinitionOrDiposableGoodsBySpell( String simpleSpell, boolean isSeachMaterialDefinition , Collection warehouseIds){ - return searchMaterialDefinitionOrDiposableGoodsBySpell(simpleSpell,isSeachMaterialDefinition,warehouseIds,false ,false, null); + return searchMaterialDefinitionOrDiposableGoodsBySpell(simpleSpell,isSeachMaterialDefinition,warehouseIds,false ,false, null); } /** + * 获取材料或一次性定义记录数 + * * @param simpleSpell 搜索的简码 + * @param isSeachMaterialDefinition 是否搜索材料定义 + * @param warehouseIds 仓库id集合 + * @param isIncludeForeignMaterial 是否包含外来器械材料 + * @param isIncludeDisable 是否包含停用器械材料 + * @param canInventory 是否盘点 yes表示只搜索能被当前科室盘点的数据,no表示只搜索不能被当前科室盘点的数据,其它值则表示不按此条件过滤 + * @return + */ + private int searchMaterialDefinitionOrDiposableGoodsBySpellPage(String simpleSpell, boolean isSeachMaterialDefinition , Collection warehouseIds,boolean isIncludeForeignMaterial ,boolean isIncludeDisable, String canInventory){ + String sql = "where 1=1"; + Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); + Matcher m = pat.matcher(simpleSpell); + //当前登录用户 + LoginUserData currentLoginUser = AcegiHelper.getLoginUser(); + //所属科室 + String orgUnitCoding = currentLoginUser.getCurrentOrgUnitCode(); + //检索模式 + String searchMode = currentLoginUser.getSearchMode(); + if (simpleSpell.trim().length() > 0) { + simpleSpell = simpleSpell.toUpperCase(); + if (m.find()) { //如果关键字是中文就按照"名称"检索即可 + sql += " and po.name like '" + simpleSpell + "%'"; + } else { + sql += getSelfSearchSQL(searchMode, simpleSpell); + } + } else { + sql += " and (po.spelling like '%" + simpleSpell + + "%' or po.wbCode like '%" + simpleSpell + + "%' or po.externalCode like '%" + simpleSpell + "%') "; + } + int count = 0 ; + if (isSeachMaterialDefinition) {// 查询再生材料 + String inventoryCondition = ""; + if(StringUtils.isNotBlank(orgUnitCoding)){ + //如果是否盘点为yes时 + if(StringUtils.equalsIgnoreCase("yes", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + inventoryCondition += " and (',' + inventoryDepartCoding like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + inventoryCondition += " and (',' || inventoryDepartCoding like '%," + orgUnitCoding + ",%') "; + } + } + //否则如果是否盘点为no时 + else if(StringUtils.equalsIgnoreCase("no", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + inventoryCondition += " and (',' + inventoryDepartCoding not like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + inventoryCondition += " and (',' || inventoryDepartCoding not like '%," + orgUnitCoding + ",%') "; + } + } + }else{ + //如果所属科室为空,不管是否盘点为yes或no时都返回空 + if(StringUtils.equalsIgnoreCase("yes", canInventory) || StringUtils.equalsIgnoreCase("no", canInventory)){ + return 0; + } + } + if(StringUtils.isNotBlank(inventoryCondition)){ + sql += inventoryCondition; + } + if(isIncludeForeignMaterial == false){ + // 不包含外来器械材料,排除外来器械材料 + sql += " and (po.isForeignMaterial is null or po.isForeignMaterial = '" + Constants.STR_NO + "') "; + } + if (isIncludeDisable == false) { + // 排除停用的器械材料 + sql += " and (po.disable is null or po.disable = '" + + Constants.STR_NO + "') "; + + } + String materialSql = " select count(*) from materialDefinition po " + sql; + count = objectDao.countBySql(materialSql); + + } else {// 一次性材料 + if(StringUtils.isNotBlank(orgUnitCoding)){ + //如果是否盘点为yes时 + if(StringUtils.equalsIgnoreCase("yes", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' + notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' || notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + } + } + //否则如果是否盘点为no时 + else if(StringUtils.equalsIgnoreCase("no", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (',' + notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (',' || notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + } + } + }else{ + //如果所属科室为空,不管是否盘点为yes或no时都返回空 + if(StringUtils.equalsIgnoreCase("yes", canInventory) || StringUtils.equalsIgnoreCase("no", canInventory)){ + return 0; + } + } + String disposableGoodsSql = " select count(*) from disposableGoods po" + " " + sql + " and po.isPartOfTousseMaterial = '能' "; + count = objectDao.countBySql(disposableGoodsSql ); + + } + return count; + + } + /** + * 获取材料和一次性物品的总记录数 + * @param simpleSpell 搜索的简码 + * @param isIncludeForeignMaterial 是否包含外来器械材料 + * @param isIncludeDisable 是否包含停用器械材料 + * @param canInventory 是否盘点 yes表示只搜索能被当前科室盘点的数据,no表示只搜索不能被当前科室盘点的数据,其它值则表示不按此条件过滤 + * @return + */ + private int searchMaterialDefinitionAndDiposableGoodsBySpellPage(String simpleSpell,Collection warehouseIds,boolean isIncludeForeignMaterial ,boolean isIncludeDisable, String canInventory){ + + String sql = "where 1=1 "; + Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); + Matcher m = pat.matcher(simpleSpell); + //当前登录用户 + LoginUserData currentLoginUser = AcegiHelper.getLoginUser(); + //所属科室 + String orgUnitCoding = currentLoginUser.getCurrentOrgUnitCode(); + //检索模式 + String searchMode = currentLoginUser.getSearchMode(); + if (simpleSpell.trim().length() > 0) { + simpleSpell = simpleSpell.toUpperCase(); + if (m.find()) { //如果关键字是中文就按照"名称"检索即可 + sql += " and po.name like '" + simpleSpell + "%'"; + } else { + sql += getSelfSearchSQL(searchMode, simpleSpell); + } + } else { + sql += " and (po.spelling like '%" + simpleSpell + + "%' or po.wbCode like '%" + simpleSpell + + "%' or po.externalCode like '%" + simpleSpell + "%') "; + } + String materialSql = "select md.spelling,md.wbCode, md.name,md.specification,md.disable,md.isForeignMaterial,md.externalCode from materialDefinition md"; + materialSql += " where 1=1 "; + + if(isIncludeForeignMaterial == false){ + // 不包含外来器械材料,排除外来器械材料 + materialSql += " and (md.isForeignMaterial is null or md.isForeignMaterial = '" + Constants.STR_NO + "') "; + } + if (isIncludeDisable == false) { + // 排除停用的器械材料 + materialSql += " and (md.disable is null or md.disable = '" + + Constants.STR_NO + "') "; + } + + String disposableGoodsSql = "select dg.spelling,dg.wbCode, dg.name,dg.specification,'','',dg.externalCode from disposableGoods dg"; + //如果是否盘点为yes时 + if(StringUtils.equalsIgnoreCase("yes", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' + notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' || notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + } + } + //否则如果是否盘点为no时 + else if(StringUtils.equalsIgnoreCase("no", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (',' + notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (',' || notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + } + } + else{ + //如果所属科室为空,不管是否盘点为yes或no时都返回空 + if(StringUtils.equalsIgnoreCase("yes", canInventory) || StringUtils.equalsIgnoreCase("no", canInventory)){ + return 0; + } + } + String mdSql = "select count(*) from (" + materialSql + "union all" +" "+ disposableGoodsSql + " )" + "po"+" " + sql; + int count = objectDao.countBySql(mdSql); + return count; + } + + + + /** * 根据条件搜索材料或一次性物品定义 * @param simpleSpell 搜索的简码 * @param isSeachMaterialDefinition 是否搜索材料定义 * @param warehouseIds 仓库id集合 * @param isIncludeForeignMaterial 是否包含外来器械材料 * @param isIncludeDisable 是否包含停用器械材料 * @param canInventory 是否盘点 yes表示只搜索能被当前科室盘点的数据,no表示只搜索不能被当前科室盘点的数据,其它值则表示不按此条件过滤 + * @param start 起始记录数 + * @param limit 最大记录数 * @return */ @SuppressWarnings("unchecked") + private List> searchMaterialDefinitionOrDiposableGoodsBySpellData( + String simpleSpell, boolean isSeachMaterialDefinition , Collection warehouseIds,boolean isIncludeForeignMaterial ,boolean isIncludeDisable, String canInventory , int start , int limit) { + String sql = "where 1=1 "; + Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); + Matcher m = pat.matcher(simpleSpell); + //当前登录用户 + LoginUserData currentLoginUser = AcegiHelper.getLoginUser(); + //所属科室 + String orgUnitCoding = currentLoginUser.getCurrentOrgUnitCode(); + //检索模式 + String searchMode = currentLoginUser.getSearchMode(); + if (simpleSpell.trim().length() > 0) { + simpleSpell = simpleSpell.toUpperCase(); + if (m.find()) { //如果关键字是中文就按照"名称"检索即可 + sql += " and po.name like '" + simpleSpell + "%'"; + } else { + sql += getSelfSearchSQL(searchMode, simpleSpell); + } + } else { + sql += " and (po.spelling like '%" + simpleSpell + + "%' or po.wbCode like '%" + simpleSpell + + "%' or po.externalCode like '%" + simpleSpell + "%') "; + } + + List> mapList = new ArrayList>(); + if (isSeachMaterialDefinition) {// 查询再生材料 + String inventoryCondition = ""; + if(StringUtils.isNotBlank(orgUnitCoding)){ + //如果是否盘点为yes时 + if(StringUtils.equalsIgnoreCase("yes", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + inventoryCondition += " and (',' + inventoryDepartCoding like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + inventoryCondition += " and (',' || inventoryDepartCoding like '%," + orgUnitCoding + ",%') "; + } + } + //否则如果是否盘点为no时 + else if(StringUtils.equalsIgnoreCase("no", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + inventoryCondition += " and (',' + inventoryDepartCoding not like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + inventoryCondition += " and (',' || inventoryDepartCoding not like '%," + orgUnitCoding + ",%') "; + } + } + }else{ + //如果所属科室为空,不管是否盘点为yes或no时都返回空 + if(StringUtils.equalsIgnoreCase("yes", canInventory) || StringUtils.equalsIgnoreCase("no", canInventory)){ + return new ArrayList>(); + } + } + if(CollectionUtils.isNotEmpty(warehouseIds)){ + String wareHousePredicate = SqlUtils.getNonStringFieldInCollectionsPredicate("gs.wareHouseId", warehouseIds); + String materialSql = "select md.id,md.name,md.specification,md.disable,md.isForeignMaterial,md.externalCode,md.cost,gs.amount as storage " + + "from MaterialDefinition md left join (select materialDefinitionId , wareHouseId ,sum(amount) as amount from goodsstock where materialDefinitionId is not null and materialDefinitionId<>0 group by wareHouseId,materialDefinitionId ) gs on md.id=gs.materialDefinitionId and " + wareHousePredicate; + materialSql += " where 1=1 "; + if(StringUtils.isNotBlank(simpleSpell)){ + materialSql += " and (md.spelling like '%" + simpleSpell + + "%' or md.wbCode like '%" + simpleSpell + + "%' or md.name like '%" + simpleSpell + + "%' or md.specification like '%" + simpleSpell + + "%' or md.externalCode like '%" + simpleSpell + "%') "; + } + if(isIncludeForeignMaterial == false){ + // 不包含外来器械材料,排除外来器械材料 + materialSql += " and (md.isForeignMaterial is null or md.isForeignMaterial = '" + Constants.STR_NO + "') "; + } + if (isIncludeDisable == false) { + // 排除停用的器械材料 + materialSql += " and (md.disable is null or md.disable = '" + + Constants.STR_NO + "') "; + } + if(StringUtils.isNotBlank(inventoryCondition)){ + materialSql += inventoryCondition; + } + materialSql += " order by externalCode"; + ResultSet rs = objectDao.executeSql(materialSql); + + try { + while(rs.next()){ + Map temp = new HashMap(); + temp.put("id", rs.getObject("id")); + String materialName = rs.getString("name"); + String specification = rs.getString("specification"); + if(StringUtils.isNotBlank(specification)){ + materialName += "[" + specification + "]"; + } + temp.put("name", materialName); + String displayName = materialName; + String externalCode = rs.getString("externalCode"); + Object storage = rs.getObject("storage"); + if(StringUtils.isNotBlank(externalCode)){ + displayName = "" + externalCode + ":" + displayName; + } + displayName += "(库存:" + (storage == null ? 0 : storage) + ")"; + temp.put("displayName", displayName); + + temp.put("cost", rs.getObject("cost")); + temp.put("storage", rs.getObject("storage")); + mapList.add(temp); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + }else{ + if(StringUtils.isNotBlank(inventoryCondition)){ + sql += inventoryCondition; + } + if(isIncludeForeignMaterial == false){ + // 不包含外来器械材料,排除外来器械材料 + sql += " and (po.isForeignMaterial is null or po.isForeignMaterial = '" + Constants.STR_NO + "') "; + } + if (isIncludeDisable == false) { + // 排除停用的器械材料 + sql += " and (po.disable is null or po.disable = '" + + Constants.STR_NO + "') "; + } + + + List materialDefinition = objectDao.findBySql( + MaterialDefinition.class.getSimpleName(), sql,start,limit,null); //分页查找 + + for (MaterialDefinition md : materialDefinition) { + Map temp = new HashMap(); + temp.put("id", md.getId()); + String materialName = CssdUtils.getMaterialName(md); + temp.put("name", materialName); + temp.put("displayName", materialName); + temp.put("type", "器械"); + temp.put("spelling", md.getSpelling()); + temp.put("cost", md.getCost()); + temp.put("price", md.getDisinfectionPrice()); + temp.put("storage", md.getStorage()); + temp.put("externalCode", md.getExternalCode()); + temp.put("unit", md.getUnit()); + temp.put("goodsType", md.getGoodsType()); + temp.put("isImplant", StringUtils.isBlank(md.getIsImplant()) ? Constants.STR_NO : md.getIsImplant()); + mapList.add(temp); + } + } + } else {// 一次性材料 + if(StringUtils.isNotBlank(orgUnitCoding)){ + //如果是否盘点为yes时 + if(StringUtils.equalsIgnoreCase("yes", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' + notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' || notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + } + } + //否则如果是否盘点为no时 + else if(StringUtils.equalsIgnoreCase("no", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (',' + notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (',' || notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + } + } + }else{ + //如果所属科室为空,不管是否盘点为yes或no时都返回空 + if(StringUtils.equalsIgnoreCase("yes", canInventory) || StringUtils.equalsIgnoreCase("no", canInventory)){ + return new ArrayList>(); + } + } + + List disposableGoodsList = objectDao.findBySql( + DisposableGoods.class.getSimpleName(), sql + + " and po.isPartOfTousseMaterial = '能'",start,limit,null); //分页查找 + for (DisposableGoods diposableGood : disposableGoodsList) { + Map temp = new HashMap(); + temp.put("id", diposableGood.getId()); + String diposableGoodName = diposableGood.getName(); + if (StringUtils.isNotBlank(diposableGood.getSpecification())) { + diposableGoodName += "[" + diposableGood.getSpecification() + "]"; + } + temp.put("name", diposableGoodName); + temp.put("displayName", diposableGoodName); + temp.put("type", "一次性物品"); + temp.put("spelling", diposableGood.getSpelling()); + temp.put("cost", diposableGood.getReferencePrice()); + temp.put("price", diposableGood.getReferencePrice()); + temp.put("storage", diposableGood.getAmount()); + temp.put("externalCode", diposableGood.getExternalCode()); + temp.put("goodsType", diposableGood.getGoodsType()); + temp.put("unit", diposableGood.getUnit()); + mapList.add(temp); + } + + } + return mapList; + } + @SuppressWarnings("unchecked") private List> searchMaterialDefinitionOrDiposableGoodsBySpell( String simpleSpell, boolean isSeachMaterialDefinition , Collection warehouseIds,boolean isIncludeForeignMaterial ,boolean isIncludeDisable, String canInventory) { String sql = "where 1=1 "; @@ -535,6 +942,102 @@ } return mapList; + } + + /** + * 搜索材料和一次性物品定义 + * @param simpleSpell 搜索的简码 + * @param isIncludeForeignMaterial 是否包含外来器械材料 + * @param isIncludeDisable 是否包含停用器械材料 + * @param canInventory 是否盘点 yes表示只搜索能被当前科室盘点的数据,no表示只搜索不能被当前科室盘点的数据,其它值则表示不按此条件过滤 + * @param start 起始记录数 + * @param limit 最大记录数 + * @return + */ + @SuppressWarnings("unchecked") + private List> searchMaterialDefinitionAndDiposableGoodsBySpell( + String simpleSpell,Collection warehouseIds,boolean isIncludeForeignMaterial ,boolean isIncludeDisable, String canInventory , int start , int limit) { + String sql = "where 1=1 "; + Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); + Matcher m = pat.matcher(simpleSpell); + //当前登录用户 + LoginUserData currentLoginUser = AcegiHelper.getLoginUser(); + //所属科室 + String orgUnitCoding = currentLoginUser.getCurrentOrgUnitCode(); + //检索模式 + String searchMode = currentLoginUser.getSearchMode(); + if (simpleSpell.trim().length() > 0) { + simpleSpell = simpleSpell.toUpperCase(); + if (m.find()) { //如果关键字是中文就按照"名称"检索即可 + sql += " and po.name like '" + simpleSpell + "%'"; + } else { + sql += getSelfSearchSQL(searchMode, simpleSpell); + } + } else { + sql += " and (po.spelling like '%" + simpleSpell + + "%' or po.wbCode like '%" + simpleSpell + + "%' or po.externalCode like '%" + simpleSpell + "%') "; + } + //如果是否盘点为yes时 + if(StringUtils.equalsIgnoreCase("yes", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' + notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (notInventoryDeptCode is null or ',' || notInventoryDeptCode not like '%," + orgUnitCoding + ",%') "; + } + } + //否则如果是否盘点为no时 + else if(StringUtils.equalsIgnoreCase("no", canInventory)){ + if(DatabaseUtil.isSqlServer(dbConnection.getDatabase())){ + sql += " and (',' + notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + }else if(DatabaseUtil.isOracle(dbConnection.getDatabase())){ + sql += " and (',' || notInventoryDeptCode like '%," + orgUnitCoding + ",%') "; + } + } + else{ + //如果所属科室为空,不管是否盘点为yes或no时都返回空 + if(StringUtils.equalsIgnoreCase("yes", canInventory) || StringUtils.equalsIgnoreCase("no", canInventory)){ + return new ArrayList>(); + } + } + List> mapList = new ArrayList>(); + String materialSql = "select md.id, md.spelling,md.wbCode, md.name,md.specification,md.disable,md.isForeignMaterial,md.externalCode from materialDefinition md"; + materialSql += " where 1=1 "; + + if(isIncludeForeignMaterial == false){ + // 不包含外来器械材料,排除外来器械材料 + materialSql += " and (md.isForeignMaterial is null or md.isForeignMaterial = '" + Constants.STR_NO + "') "; + } + if (isIncludeDisable == false) { + // 排除停用的器械材料 + materialSql += " and (md.disable is null or md.disable = '" + + Constants.STR_NO + "') "; + } + + String disposableGoodsSql = "select dg.id, dg.spelling,dg.wbCode, dg.name,dg.specification,'','',dg.externalCode from disposableGoods dg"; + String mdSql = "select * from (" + materialSql + "union all" +" "+ disposableGoodsSql + " )" + "po"+" " + sql; + + Object[] condition = new Object[]{}; + List> map = objectDao.findSqlByParam(mdSql, condition, start, limit); //分页查找 + + for (Map md : map) { + System.out.println(md); + String materialName = (String) md.get("name"); + String specification = (String) md.get("specification"); + if(StringUtils.isNotBlank(specification)){ + materialName += "[" + specification + "]"; + } + String displayName = materialName; + String externalCode = (String) md.get("externalCode"); + if(StringUtils.isNotBlank(externalCode)){ + displayName = "" + externalCode + ":" + displayName; + } + md.put("name", materialName); + md.put("displayName", displayName); + mapList.add(md); + } + + return mapList; } /** Index: ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialEntryView.js =================================================================== diff -u -r18549 -r18614 --- ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialEntryView.js (.../materialEntryView.js) (revision 18549) +++ ssts-web/src/main/webapp/disinfectsystem/materialmanager/materialEntryView.js (.../materialEntryView.js) (revision 18614) @@ -7,7 +7,7 @@ var materialDefinitionStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ - url : WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionData.do?selectType=material', + url : WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialDefinitionDatas.do?selectType=material', method : 'POST' }), reader : new Ext.data.JsonReader({ @@ -925,7 +925,7 @@ } }); - var queryForm = new TBarForm(materialDefinitionStore).initForm(); + var queryForm = new TBarForm(materialDefinitionStore,100).initForm(); //100为每页最多显示多少条记录 var viewport = new Ext.Viewport( { layout : 'border', items : [queryForm,{ Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/action/MaterialDefinitionAction.java =================================================================== diff -u -r18137 -r18614 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/action/MaterialDefinitionAction.java (.../MaterialDefinitionAction.java) (revision 18137) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/action/MaterialDefinitionAction.java (.../MaterialDefinitionAction.java) (revision 18614) @@ -52,6 +52,7 @@ import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JSONUtil; +import com.forgon.tools.util.PageUtil; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; @@ -512,6 +513,47 @@ } StrutsResponseUtils.output(jsonStr); } + /** + * 根据拼音简拼,获取材料NAME和ID 如果 tousseDefinitionId 不为空,则只查询该器械包中的材料以及数量 + * 目前请求的页面有(材料入库,退库,调拨,和材料发货) + */ + public void getMaterialDefinitionDatas() { + if (spell == null) { + return; + } + String tousseDefinitionId = StrutsParamUtils.getPraramValue( + "tousseDefinitionId", ""); + //类型:all(所有)、material(材料)或diposable(一次性物品) + String selectType = StrutsParamUtils + .getPraramValue("selectType", "all"); + //能否被盘点:all(所有)、yes(是)、no(否) + String canInventory = StrutsParamUtils + .getPraramValue("canInventory", "all"); + //起始记录数 + int start = StrutsParamUtils.getPraramValue("start", 0); + //最大记录数 + int limit = StrutsParamUtils.getPraramValue("limit", 0); + String jsonStr = ""; + try { + spell = java.net.URLDecoder.decode(spell, "UTF-8"); + } catch (UnsupportedEncodingException e1) { + e1.printStackTrace(); + } + if (StringUtils.isBlank(tousseDefinitionId)) { + jsonStr = materialDefinitionManager + .searchMaterialDefinitionAndDiposableGoodsData(spell, + selectType,canInventory,start,limit).toString(); + } else { + try { + jsonStr = materialInstanceManager + .searchMaterialInstanceByTousseDefinitionIdAndSpell( + tousseDefinitionId, spell, selectType,canInventory); + } catch (SQLException e) { + e.printStackTrace(); + } + } + StrutsResponseUtils.output(jsonStr); + } /** * 根据拼音简拼,获取材料NAME和ID,包括获取外来器械材料 如果 tousseDefinitionId 不为空,则只查询该器械包中的材料以及数量 * Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/service/MaterialDefinitionManager.java =================================================================== diff -u -r18137 -r18614 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/service/MaterialDefinitionManager.java (.../MaterialDefinitionManager.java) (revision 18137) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/service/MaterialDefinitionManager.java (.../MaterialDefinitionManager.java) (revision 18614) @@ -142,4 +142,14 @@ */ public MaterialDefinition getMaterialDefinitionByNameAndspecification(String name, String specification); + /** + * 获取器械包NAME和ID + * @param simpleSpell 搜索内容:按名称、规格、拼音码、五笔码等字段进行过滤 + * @param selectType 搜索物品类型:material或diposable或 all + * @param canInventory all,yes或no + * @param start 起始记录数 + * @param limit 最大记录数 + * @return + */ + public JSONObject searchMaterialDefinitionAndDiposableGoodsData(String simpleSpell, String selectType , String canInventory , int start, int limit); }