@Test public void testListCurrentCaseRecipes() throws Exception { }
@Override public CommonResult listCurrentCaseRecipes(Integer caseId) { JSONObject returnJson = new JSONObject(); List<HashMap> recipeLogs = recipeMapper.listRecipeInfoByRegistrationId(caseId); if(recipeLogs.size() == 0) { returnJson.put("type", -1); returnJson.put("recipes", new JSONArray()); return CommonResult.success(returnJson); } if((Integer)recipeLogs.get(0).get("medicineType") == 0) returnJson.put("type", 0); else returnJson.put("type", 1); HashMap<Integer, List<HashMap>> recipes = new HashMap<>(); for(HashMap recipeLog : recipeLogs){ Long recipeIdLong = (Long)recipeLog.get("id"); Integer recipeId = new Integer(String.valueOf(recipeIdLong)); List<HashMap> medicines; if(!recipes.containsKey(recipeId)) medicines = new ArrayList<>(); else medicines = recipes.get(recipeId); medicines.add(medicineInfo(recipeLog)); recipes.put(recipeId, medicines); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: recipes.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("recipeId", entry.getKey()); jsonObject.put("medicines", entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("recipes", jsonArray); return CommonResult.success(returnJson); }
RecipeManagementServiceImpl implements RecipeManagementService { @Override public CommonResult listCurrentCaseRecipes(Integer caseId) { JSONObject returnJson = new JSONObject(); List<HashMap> recipeLogs = recipeMapper.listRecipeInfoByRegistrationId(caseId); if(recipeLogs.size() == 0) { returnJson.put("type", -1); returnJson.put("recipes", new JSONArray()); return CommonResult.success(returnJson); } if((Integer)recipeLogs.get(0).get("medicineType") == 0) returnJson.put("type", 0); else returnJson.put("type", 1); HashMap<Integer, List<HashMap>> recipes = new HashMap<>(); for(HashMap recipeLog : recipeLogs){ Long recipeIdLong = (Long)recipeLog.get("id"); Integer recipeId = new Integer(String.valueOf(recipeIdLong)); List<HashMap> medicines; if(!recipes.containsKey(recipeId)) medicines = new ArrayList<>(); else medicines = recipes.get(recipeId); medicines.add(medicineInfo(recipeLog)); recipes.put(recipeId, medicines); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: recipes.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("recipeId", entry.getKey()); jsonObject.put("medicines", entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("recipes", jsonArray); return CommonResult.success(returnJson); } }
RecipeManagementServiceImpl implements RecipeManagementService { @Override public CommonResult listCurrentCaseRecipes(Integer caseId) { JSONObject returnJson = new JSONObject(); List<HashMap> recipeLogs = recipeMapper.listRecipeInfoByRegistrationId(caseId); if(recipeLogs.size() == 0) { returnJson.put("type", -1); returnJson.put("recipes", new JSONArray()); return CommonResult.success(returnJson); } if((Integer)recipeLogs.get(0).get("medicineType") == 0) returnJson.put("type", 0); else returnJson.put("type", 1); HashMap<Integer, List<HashMap>> recipes = new HashMap<>(); for(HashMap recipeLog : recipeLogs){ Long recipeIdLong = (Long)recipeLog.get("id"); Integer recipeId = new Integer(String.valueOf(recipeIdLong)); List<HashMap> medicines; if(!recipes.containsKey(recipeId)) medicines = new ArrayList<>(); else medicines = recipes.get(recipeId); medicines.add(medicineInfo(recipeLog)); recipes.put(recipeId, medicines); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: recipes.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("recipeId", entry.getKey()); jsonObject.put("medicines", entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("recipes", jsonArray); return CommonResult.success(returnJson); }  }
RecipeManagementServiceImpl implements RecipeManagementService { @Override public CommonResult listCurrentCaseRecipes(Integer caseId) { JSONObject returnJson = new JSONObject(); List<HashMap> recipeLogs = recipeMapper.listRecipeInfoByRegistrationId(caseId); if(recipeLogs.size() == 0) { returnJson.put("type", -1); returnJson.put("recipes", new JSONArray()); return CommonResult.success(returnJson); } if((Integer)recipeLogs.get(0).get("medicineType") == 0) returnJson.put("type", 0); else returnJson.put("type", 1); HashMap<Integer, List<HashMap>> recipes = new HashMap<>(); for(HashMap recipeLog : recipeLogs){ Long recipeIdLong = (Long)recipeLog.get("id"); Integer recipeId = new Integer(String.valueOf(recipeIdLong)); List<HashMap> medicines; if(!recipes.containsKey(recipeId)) medicines = new ArrayList<>(); else medicines = recipes.get(recipeId); medicines.add(medicineInfo(recipeLog)); recipes.put(recipeId, medicines); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: recipes.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("recipeId", entry.getKey()); jsonObject.put("medicines", entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("recipes", jsonArray); return CommonResult.success(returnJson); }  @Override CommonResult listCurrentCaseRecipes(Integer caseId); HashMap medicineInfo(HashMap recipeLog); @Override CommonResult insertNewRecipe(); CommonResult preserveRecipes(RecipeCollectionParam recipeCollectionParam); CommonResult submitRecipes(RecipeCollectionParam recipeCollectionParam); CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status); CommonResult insertTransactionLog(RecipeCollectionParam collectionParam, RecipeParam recipeParam,
                                             Integer creatorRoleId); }
RecipeManagementServiceImpl implements RecipeManagementService { @Override public CommonResult listCurrentCaseRecipes(Integer caseId) { JSONObject returnJson = new JSONObject(); List<HashMap> recipeLogs = recipeMapper.listRecipeInfoByRegistrationId(caseId); if(recipeLogs.size() == 0) { returnJson.put("type", -1); returnJson.put("recipes", new JSONArray()); return CommonResult.success(returnJson); } if((Integer)recipeLogs.get(0).get("medicineType") == 0) returnJson.put("type", 0); else returnJson.put("type", 1); HashMap<Integer, List<HashMap>> recipes = new HashMap<>(); for(HashMap recipeLog : recipeLogs){ Long recipeIdLong = (Long)recipeLog.get("id"); Integer recipeId = new Integer(String.valueOf(recipeIdLong)); List<HashMap> medicines; if(!recipes.containsKey(recipeId)) medicines = new ArrayList<>(); else medicines = recipes.get(recipeId); medicines.add(medicineInfo(recipeLog)); recipes.put(recipeId, medicines); } JSONArray jsonArray = new JSONArray(); for(Map.Entry<Integer, List<HashMap>> entry: recipes.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put("recipeId", entry.getKey()); jsonObject.put("medicines", entry.getValue()); jsonArray.add(jsonObject); } returnJson.put("recipes", jsonArray); return CommonResult.success(returnJson); }  @Override CommonResult listCurrentCaseRecipes(Integer caseId); HashMap medicineInfo(HashMap recipeLog); @Override CommonResult insertNewRecipe(); CommonResult preserveRecipes(RecipeCollectionParam recipeCollectionParam); CommonResult submitRecipes(RecipeCollectionParam recipeCollectionParam); CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status); CommonResult insertTransactionLog(RecipeCollectionParam collectionParam, RecipeParam recipeParam,
                                             Integer creatorRoleId);  }