@Test public void testListArrangementRules() throws Exception { }
@Override public CommonResult listArrangementRules(Integer departmentId){ JSONObject returnJson = new JSONObject(); List<HashMap> arrangementRuleList = arrangementRuleMapper.listArrangementRulesByDepartmentId(departmentId); HashMap<Integer, List<HashMap>> arrangementRules = new HashMap<>(); for(HashMap arrangementRule : arrangementRuleList){ Long idLong = (Long)arrangementRule.get("id"); Integer id = new Integer(String.valueOf(idLong)); List<HashMap> info; if(!arrangementRules.containsKey(id)) info = new ArrayList<>(); else info = arrangementRules.get(id); arrangementRule.remove("id"); arrangementRule.remove("departmentId"); Byte levelId = Byte.valueOf(String.valueOf(arrangementRule.get("registrationLevelId"))); arrangementRule.put("registrationLevel", ConstantMap.convert("挂号级别", levelId)); arrangementRule.remove("registrationLevelId"); Byte positionId = Byte.valueOf(String.valueOf(arrangementRule.get("titleId"))); arrangementRule.put("title", ConstantMap.convert("职称", positionId)); arrangementRule.remove("titleId"); arrangementRule.put("isValid", getStatusStr((Boolean)arrangementRule.get("isValid"))); info.add(arrangementRule); arrangementRules.put(id, info); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: arrangementRules.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("ruleId", entry.getKey()); jsonObject.put("ruleName", entry.getValue().get(0).get("ruleName")); Integer adminId = (Integer)entry.getValue().get(0).get("adminId"); jsonObject.put("adminName", roleMapper.getUserNameByRoleId(adminId)); jsonObject = formatJson(jsonObject, entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("arrangementRules", jsonArray); return CommonResult.success(returnJson); }
ArrangementManagementServiceImpl implements ArrangementManagementService { @Override public CommonResult listArrangementRules(Integer departmentId){ JSONObject returnJson = new JSONObject(); List<HashMap> arrangementRuleList = arrangementRuleMapper.listArrangementRulesByDepartmentId(departmentId); HashMap<Integer, List<HashMap>> arrangementRules = new HashMap<>(); for(HashMap arrangementRule : arrangementRuleList){ Long idLong = (Long)arrangementRule.get("id"); Integer id = new Integer(String.valueOf(idLong)); List<HashMap> info; if(!arrangementRules.containsKey(id)) info = new ArrayList<>(); else info = arrangementRules.get(id); arrangementRule.remove("id"); arrangementRule.remove("departmentId"); Byte levelId = Byte.valueOf(String.valueOf(arrangementRule.get("registrationLevelId"))); arrangementRule.put("registrationLevel", ConstantMap.convert("挂号级别", levelId)); arrangementRule.remove("registrationLevelId"); Byte positionId = Byte.valueOf(String.valueOf(arrangementRule.get("titleId"))); arrangementRule.put("title", ConstantMap.convert("职称", positionId)); arrangementRule.remove("titleId"); arrangementRule.put("isValid", getStatusStr((Boolean)arrangementRule.get("isValid"))); info.add(arrangementRule); arrangementRules.put(id, info); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: arrangementRules.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("ruleId", entry.getKey()); jsonObject.put("ruleName", entry.getValue().get(0).get("ruleName")); Integer adminId = (Integer)entry.getValue().get(0).get("adminId"); jsonObject.put("adminName", roleMapper.getUserNameByRoleId(adminId)); jsonObject = formatJson(jsonObject, entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("arrangementRules", jsonArray); return CommonResult.success(returnJson); } }
ArrangementManagementServiceImpl implements ArrangementManagementService { @Override public CommonResult listArrangementRules(Integer departmentId){ JSONObject returnJson = new JSONObject(); List<HashMap> arrangementRuleList = arrangementRuleMapper.listArrangementRulesByDepartmentId(departmentId); HashMap<Integer, List<HashMap>> arrangementRules = new HashMap<>(); for(HashMap arrangementRule : arrangementRuleList){ Long idLong = (Long)arrangementRule.get("id"); Integer id = new Integer(String.valueOf(idLong)); List<HashMap> info; if(!arrangementRules.containsKey(id)) info = new ArrayList<>(); else info = arrangementRules.get(id); arrangementRule.remove("id"); arrangementRule.remove("departmentId"); Byte levelId = Byte.valueOf(String.valueOf(arrangementRule.get("registrationLevelId"))); arrangementRule.put("registrationLevel", ConstantMap.convert("挂号级别", levelId)); arrangementRule.remove("registrationLevelId"); Byte positionId = Byte.valueOf(String.valueOf(arrangementRule.get("titleId"))); arrangementRule.put("title", ConstantMap.convert("职称", positionId)); arrangementRule.remove("titleId"); arrangementRule.put("isValid", getStatusStr((Boolean)arrangementRule.get("isValid"))); info.add(arrangementRule); arrangementRules.put(id, info); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: arrangementRules.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("ruleId", entry.getKey()); jsonObject.put("ruleName", entry.getValue().get(0).get("ruleName")); Integer adminId = (Integer)entry.getValue().get(0).get("adminId"); jsonObject.put("adminName", roleMapper.getUserNameByRoleId(adminId)); jsonObject = formatJson(jsonObject, entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("arrangementRules", jsonArray); return CommonResult.success(returnJson); }  }
ArrangementManagementServiceImpl implements ArrangementManagementService { @Override public CommonResult listArrangementRules(Integer departmentId){ JSONObject returnJson = new JSONObject(); List<HashMap> arrangementRuleList = arrangementRuleMapper.listArrangementRulesByDepartmentId(departmentId); HashMap<Integer, List<HashMap>> arrangementRules = new HashMap<>(); for(HashMap arrangementRule : arrangementRuleList){ Long idLong = (Long)arrangementRule.get("id"); Integer id = new Integer(String.valueOf(idLong)); List<HashMap> info; if(!arrangementRules.containsKey(id)) info = new ArrayList<>(); else info = arrangementRules.get(id); arrangementRule.remove("id"); arrangementRule.remove("departmentId"); Byte levelId = Byte.valueOf(String.valueOf(arrangementRule.get("registrationLevelId"))); arrangementRule.put("registrationLevel", ConstantMap.convert("挂号级别", levelId)); arrangementRule.remove("registrationLevelId"); Byte positionId = Byte.valueOf(String.valueOf(arrangementRule.get("titleId"))); arrangementRule.put("title", ConstantMap.convert("职称", positionId)); arrangementRule.remove("titleId"); arrangementRule.put("isValid", getStatusStr((Boolean)arrangementRule.get("isValid"))); info.add(arrangementRule); arrangementRules.put(id, info); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: arrangementRules.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("ruleId", entry.getKey()); jsonObject.put("ruleName", entry.getValue().get(0).get("ruleName")); Integer adminId = (Integer)entry.getValue().get(0).get("adminId"); jsonObject.put("adminName", roleMapper.getUserNameByRoleId(adminId)); jsonObject = formatJson(jsonObject, entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("arrangementRules", jsonArray); return CommonResult.success(returnJson); }  @Override CommonResult insertArrangementRule(ArrangementRuleParam arrangementRuleParam); @Override CommonResult listArrangementRules(Integer departmentId); @Override CommonResult insertArrangement(ArrangementParam arrangementParam); List<ArrangementConflictParam> saveArrangement(Date today, int week, Integer departmentId,
                                                          Integer arrangementRuleId, List<Arrangement> arrangements,
                                                          List<ArrangementConflictParam> conflict, Boolean toInsert,
                                                          List<Arrangement> toInsertArrangements); @Override CommonResult listArrangements(Date startDate, Date endDate, Integer departmentId); String getStatusStr(Boolean isValid); @Override CommonResult modifyArrangements(ArrangementParam arrangementParam); @Override CommonResult modifyArrangement(Integer arrangementId, Byte timeSlot); JSONObject formatJson(JSONObject jsonObject, List<HashMap> arrangementRule); }
ArrangementManagementServiceImpl implements ArrangementManagementService { @Override public CommonResult listArrangementRules(Integer departmentId){ JSONObject returnJson = new JSONObject(); List<HashMap> arrangementRuleList = arrangementRuleMapper.listArrangementRulesByDepartmentId(departmentId); HashMap<Integer, List<HashMap>> arrangementRules = new HashMap<>(); for(HashMap arrangementRule : arrangementRuleList){ Long idLong = (Long)arrangementRule.get("id"); Integer id = new Integer(String.valueOf(idLong)); List<HashMap> info; if(!arrangementRules.containsKey(id)) info = new ArrayList<>(); else info = arrangementRules.get(id); arrangementRule.remove("id"); arrangementRule.remove("departmentId"); Byte levelId = Byte.valueOf(String.valueOf(arrangementRule.get("registrationLevelId"))); arrangementRule.put("registrationLevel", ConstantMap.convert("挂号级别", levelId)); arrangementRule.remove("registrationLevelId"); Byte positionId = Byte.valueOf(String.valueOf(arrangementRule.get("titleId"))); arrangementRule.put("title", ConstantMap.convert("职称", positionId)); arrangementRule.remove("titleId"); arrangementRule.put("isValid", getStatusStr((Boolean)arrangementRule.get("isValid"))); info.add(arrangementRule); arrangementRules.put(id, info); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: arrangementRules.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("ruleId", entry.getKey()); jsonObject.put("ruleName", entry.getValue().get(0).get("ruleName")); Integer adminId = (Integer)entry.getValue().get(0).get("adminId"); jsonObject.put("adminName", roleMapper.getUserNameByRoleId(adminId)); jsonObject = formatJson(jsonObject, entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("arrangementRules", jsonArray); return CommonResult.success(returnJson); }  @Override CommonResult insertArrangementRule(ArrangementRuleParam arrangementRuleParam); @Override CommonResult listArrangementRules(Integer departmentId); @Override CommonResult insertArrangement(ArrangementParam arrangementParam); List<ArrangementConflictParam> saveArrangement(Date today, int week, Integer departmentId,
                                                          Integer arrangementRuleId, List<Arrangement> arrangements,
                                                          List<ArrangementConflictParam> conflict, Boolean toInsert,
                                                          List<Arrangement> toInsertArrangements); @Override CommonResult listArrangements(Date startDate, Date endDate, Integer departmentId); String getStatusStr(Boolean isValid); @Override CommonResult modifyArrangements(ArrangementParam arrangementParam); @Override CommonResult modifyArrangement(Integer arrangementId, Byte timeSlot); JSONObject formatJson(JSONObject jsonObject, List<HashMap> arrangementRule);  }