Index: forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java =================================================================== diff -u -r24141 -r24372 --- forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java (.../OrgUnitManagerImpl.java) (revision 24141) +++ forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java (.../OrgUnitManagerImpl.java) (revision 24372) @@ -1306,27 +1306,59 @@ @Override public List> searchApplyDepartmentByKeyWord( String keyWord, boolean onlyOneself) { - return searchOrgUnitByKeyWord(keyWord, true, onlyOneself); + return searchOrgUnitByKeyWord(keyWord, true, onlyOneself , 3 , 0 , 0); } - + @Override + public List> searchDepartmentByKeyWord( + String keyWord, boolean onlyOneself , int supplyRoomType, int limit, int offset) { + return searchOrgUnitByKeyWord(keyWord, true, onlyOneself , 3 , limit , offset); + } + + @Override + public int countDepartmentBySearchKeyWord(String keyWord, + boolean onlyOneself , int supplyRoomType) { + LoginUserData loginUser = AcegiHelper.getLoginUser(); + String searchSql = getOrgUnitSearchSql(keyWord); + + //1、是否只查申请科室 + String applyDepatmentSql = ""; + if (onlyOneself) { + applyDepatmentSql = " and po.orgUnitCoding in(select orgUnitCoding from SupplyRoomConfig where supplyRoomType="+ supplyRoomType +") "; + } + + //2、临床科室是否只能看到自己直属的科室 + String belongDepartmentSql = ""; + if (onlyOneself && objectDao.countBySql(String.format("select count(*) from SupplyRoomConfig where supplyRoomType in(1,2) and orgUnitCoding='%s'", loginUser.getCurrentOrgUnitCode())) <= 0) { + String orgUnitCodesWhereUserBelong = loginUser.getOrgUnitCodesWhereUserBelong(); + belongDepartmentSql = SqlUtils.get_InSql("po.orgUnitCoding", StringTools.split(orgUnitCodesWhereUserBelong, ",")); + } + +// String sql = String.format("select po.name,po.orgUnitCoding from OrgUnit po where po.id<>0 %s %s %s", searchSql, applyDepatmentSql, belongDepartmentSql); + String queryCondition = String.format("where po.id<>0 %s %s %s", searchSql, applyDepatmentSql, belongDepartmentSql); + int count = objectDao.countBySql("select count(0) from OrgUnit po " + queryCondition); + return count; + } + /** * 根据关键字搜索科室. * @param keyWord 关键字 * @param justSearchApplyDepatment 是否是搜索申请科室 * @param onlyOneself 临床科室是否只能看到自己直属的科室 + * @param limit 每页记录数,如果为0则查所有 + * @param offset 第多少条起 * @return */ private List> searchOrgUnitByKeyWord(String keyWord, - boolean justSearchApplyDepatment, boolean onlyOneself) { + boolean justSearchApplyDepatment, boolean onlyOneself , int supplyRoomType, int limit, int offset) { LoginUserData loginUser = AcegiHelper.getLoginUser(); String searchSql = getOrgUnitSearchSql(keyWord); //1、是否只查申请科室 String applyDepatmentSql = ""; if (justSearchApplyDepatment) { - applyDepatmentSql = " and po.orgUnitCoding in(select orgUnitCoding from SupplyRoomConfig where supplyRoomType=3) "; + applyDepatmentSql = " and po.orgUnitCoding in(select orgUnitCoding from SupplyRoomConfig where supplyRoomType="+ supplyRoomType +") "; } //2、临床科室是否只能看到自己直属的科室 @@ -1336,21 +1368,24 @@ belongDepartmentSql = SqlUtils.get_InSql("po.orgUnitCoding", StringTools.split(orgUnitCodesWhereUserBelong, ",")); } - String sql = String.format("select po.name,po.orgUnitCoding from OrgUnit po where po.id<>0 %s %s %s", searchSql, applyDepatmentSql, belongDepartmentSql); - - ResultSet result = objectDao.executeSql(sql); - List> list = new ArrayList>(); - try { - while(result.next()){ +// String sql = String.format("select po.name,po.orgUnitCoding from OrgUnit po where po.id<>0 %s %s %s", searchSql, applyDepatmentSql, belongDepartmentSql); + String queryCondition = String.format("where po.id<>0 %s %s %s", searchSql, applyDepatmentSql, belongDepartmentSql); + List orgUnitList = null; + if(limit > 0){ + orgUnitList = objectDao.findBySql(OrgUnit.class.getSimpleName(), queryCondition, offset, limit , null); + }else{ + orgUnitList = objectDao.findBySql(OrgUnit.class.getSimpleName() , queryCondition); + } + + List> list = null; + if(CollectionUtils.isNotEmpty(orgUnitList)){ + list = new ArrayList>(); + for (OrgUnit orgUnit : orgUnitList) { Map map = new HashMap(); - map.put("departmentName", StringTools.defaultString(result.getString("name"))); - map.put("departmentCode", StringTools.defaultString(result.getString("orgUnitCoding"))); + map.put("departmentName", StringTools.defaultString(orgUnit.getName())); + map.put("departmentCode", StringTools.defaultString(orgUnit.getOrgUnitCoding())); list.add(map); } - } catch (SQLException e) { - e.printStackTrace(); - }finally { - DatabaseUtil.closeResultSetAndStatement(result); } return list; } Index: forgon-core/src/main/java/com/forgon/security/controller/UserController.java =================================================================== diff -u -r24354 -r24372 --- forgon-core/src/main/java/com/forgon/security/controller/UserController.java (.../UserController.java) (revision 24354) +++ forgon-core/src/main/java/com/forgon/security/controller/UserController.java (.../UserController.java) (revision 24372) @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.portal.model.PortalItem; @@ -49,7 +50,9 @@ @Autowired private OperationManager operationManager; - @Autowired + /** + * 用Autowired未注入成功,换成用set方法注入了 + */ private HttpOptionManager httpOptionManager; @Autowired @@ -67,6 +70,7 @@ } @RequestMapping(value="/loadDesktopMenu") + @ResponseBody public void loadDesktopMenu() { List portalPages = portalPageManager.getCurrentUserCustomizePortalPage(); String userOperationIds = acegiHelper.getUserOperationIds(); Index: forgon-core/src/main/java/com/forgon/directory/controller/OrgUnitController.java =================================================================== diff -u --- forgon-core/src/main/java/com/forgon/directory/controller/OrgUnitController.java (revision 0) +++ forgon-core/src/main/java/com/forgon/directory/controller/OrgUnitController.java (revision 24372) @@ -0,0 +1,149 @@ +package com.forgon.directory.controller; + +import java.util.ArrayList; +import java.util.Collection; +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.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.forgon.directory.model.CssdServiceDepts; +import com.forgon.directory.model.OrgUnit; +import com.forgon.directory.service.OrgUnitManager; +import com.forgon.tools.json.JSONUtil; +import com.forgon.tools.string.StringTools; +import com.forgon.tools.util.SpringUtils; + +/** + * 组织机构controller类 + * @author shuyongfu + * @since date 2018-09-25 + */ +@Controller +@RequestMapping("/disinfectSystem/core/orgUnitController") +public class OrgUnitController { + + @Autowired + private OrgUnitManager orgUnitManager; + + /** + * 申请科室下拉搜索分页查询接口 + */ + @RequestMapping(value="/searchApplyDepartmentByKeyWord") + @ResponseBody + public void searchApplyDepartmentByKeyWord(){ + String spell = SpringUtils.getPraramValue("spell", null); + int limit = SpringUtils.getPraramValue("limit", 100); + int offset = SpringUtils.getPraramValue("offset", 0); + //指定的科室编码 + String departmentCode = SpringUtils.getPraramValue("departmentCode", null); + JSONObject result = JSONUtil.buildJsonObject(false); + //如果指定了要加载哪个科室,则直接返回即可 + if (StringTools.isNotBlank(departmentCode)) { + OrgUnit specifyDepartment = orgUnitManager.getByCode(departmentCode); + JSONArray jsonArray = new JSONArray(); + if (specifyDepartment != null) { + JSONObject obj = new JSONObject(); + obj.put("departmentName", specifyDepartment.getName()); + obj.put("departmentCode", specifyDepartment.getOrgUnitCoding()); + jsonArray.add(obj); + } + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_SUCCESS, true); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_TOTAL, jsonArray.size()); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_ROWS, jsonArray); + } else { + boolean onlyOneself = Boolean.valueOf(SpringUtils.getPraramValue("onlyOneself", "true")); + int count = orgUnitManager.countDepartmentBySearchKeyWord(spell, onlyOneself , 3); + List> list = new ArrayList>(); + if(count > 0){ + list = orgUnitManager.searchDepartmentByKeyWord(spell, onlyOneself , 3 , limit , offset); + } + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_SUCCESS, true); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_TOTAL, count); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_ROWS, JSONArray.fromObject(list)); + } + SpringUtils.output(result); + } + + /** + * 结算科室下拉搜索分页查询接口 + */ + @RequestMapping(value="/searchSettleDepartmentByKeyWord") + @ResponseBody + public void searchSettleDepartmentByKeyWord(){ + String spell = SpringUtils.getPraramValue("spell", null); + int limit = SpringUtils.getPraramValue("limit", 100); + int offset = SpringUtils.getPraramValue("offset", 0); + //指定的科室编码 + String departmentCode = SpringUtils.getPraramValue("departmentCode", null); + JSONObject result = JSONUtil.buildJsonObject(false); + //如果指定了要加载哪个科室,则直接返回即可 + if (StringTools.isNotBlank(departmentCode)) { + OrgUnit specifyDepartment = orgUnitManager.getByCode(departmentCode); + JSONArray jsonArray = new JSONArray(); + if (specifyDepartment != null) { + JSONObject obj = new JSONObject(); + obj.put("departmentName", specifyDepartment.getName()); + obj.put("departmentCode", specifyDepartment.getOrgUnitCoding()); + jsonArray.add(obj); + } + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_SUCCESS, true); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_TOTAL, jsonArray.size()); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_ROWS, jsonArray); + } else { + boolean onlyOneself = Boolean.valueOf(SpringUtils.getPraramValue("onlyOneself", "true")); + int count = orgUnitManager.countDepartmentBySearchKeyWord(spell, onlyOneself , 4); + List> list = new ArrayList>(); + if(count > 0){ + list = orgUnitManager.searchDepartmentByKeyWord(spell, onlyOneself , 4 , limit , offset); + } + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_SUCCESS, true); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_TOTAL, count); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_ROWS, JSONArray.fromObject(list)); + } + SpringUtils.output(result); + } + + /** + * 处理科室下拉搜索分页查询接口 + */ + @RequestMapping(value="/searchHandleDepartmentByKeyWord") + @ResponseBody + public void searchHandleDepartmentByKeyWord(){ + String spell = SpringUtils.getPraramValue("spell", null); + int limit = SpringUtils.getPraramValue("limit", 100); + int offset = SpringUtils.getPraramValue("offset", 0); + //申请科室 + String applyDepartCode = SpringUtils.getPraramValue("applyDepartCode", null); + //物品类型 + String tousseType = SpringUtils.getPraramValue("tousseType", null); + JSONObject result = JSONUtil.buildJsonObject(false); + + Collection list = orgUnitManager.getCssdsByApplyDepartAndType( + applyDepartCode, tousseType); + List> resultMapList = new ArrayList>(); + if(CollectionUtils.isNotEmpty(list)){ + Map resultMap = null; + for(CssdServiceDepts cssdServiceDepts : list){ + resultMap = new HashMap(); + resultMap.put("defaultHandleDepart", cssdServiceDepts.getDefaultHandleDepart()); + resultMap.put("departmentCode", cssdServiceDepts.getCssdOrgUnitCode()); + resultMap.put("departmentName", cssdServiceDepts.getCssdOrgUnitName()); + resultMapList.add(resultMap); + } + } + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_ROWS, JSONArray.fromObject(resultMapList)); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_SUCCESS, true); + JSONUtil.addLogProperty(result, JSONUtil.JSON_KEY_TOTAL, resultMapList.size()); + SpringUtils.output(result); + } + +} Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java =================================================================== diff -u -r24080 -r24372 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java (.../TousseDefinitionAction.java) (revision 24080) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/toussedefinition/action/TousseDefinitionAction.java (.../TousseDefinitionAction.java) (revision 24372) @@ -1814,6 +1814,10 @@ } json = JSONObject.fromObject(result); } + //增加success,rows和total的赋值,支持bootstrap框架 + JSONUtil.addProperty(json, JSONUtil.JSON_KEY_SUCCESS, true); + JSONUtil.addProperty(json, JSONUtil.JSON_KEY_TOTAL, json.opt("totalCount")); + JSONUtil.addProperty(json, JSONUtil.JSON_KEY_ROWS, json.opt("data")); StrutsResponseUtils.output(json); } catch (IOException e) { e.printStackTrace(); Index: forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManager.java =================================================================== diff -u -r22926 -r24372 --- forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManager.java (.../OrgUnitManager.java) (revision 22926) +++ forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManager.java (.../OrgUnitManager.java) (revision 24372) @@ -182,6 +182,26 @@ public List> searchApplyDepartmentByKeyWord(String keyWord, boolean onlyOneself); /** + * 根据关键字搜索科室的数据统计. + * @param keyWord 关键字 + * @param onlyOneself 临床科室是否只能看到自己直属的科室 + * @param supplyRoomType 科室供应室类型 + * @return + */ + public int countDepartmentBySearchKeyWord(String keyWord, boolean onlyOneself , int supplyRoomType); + + /** + * 根据关键字搜索科室. + * @param keyWord 关键字 + * @param onlyOneself 临床科室是否只能看到自己直属的科室 + * @param supplyRoomType 科室供应室类型 + * @param limit 每页记录数,如果为0则查所有 + * @param offset 第多少条起 + * @return + */ + public List> searchDepartmentByKeyWord(String keyWord, boolean onlyOneself , int supplyRoomType , int limit , int offset); + + /** * 根据科室名称查找"科室编码"和"科室名称",(可以支持 "名称的汉字","名称的拼音码","名称的五笔码"这三种格式的模糊查询) * @param orgUnitName:科室的名称 * @return