@Test public void testUpdateRecipes() throws Exception { }
public CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status){ int count = 0; Integer recipeId = recipeCollectionParam.getRecipeId(); Integer caseId = recipeCollectionParam.getCaseId(); Integer creatorRoleId = recipeCollectionParam.getCreatorRoleId(); List<RecipeParam> medicines = recipeCollectionParam.getMedicines(); recipeMapper.deleteById(recipeId); if(medicines.size() == 0){ Recipe recipe = new Recipe(); recipe.setId(recipeId); recipe.setMedicineId(0); recipe.setCaseId(caseId); recipe.setCreatorRoleId(creatorRoleId); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); return CommonResult.success(count); } for(RecipeParam recipeParam: medicines){ Recipe recipe = new Recipe(); Integer medicineId = recipeParam.getMedicineId(); String code = recipeParam.getMedicineCode(); if (medicineId == null) medicineId = medicineMapper.getIdByCode(code); recipeParam.setMedicineId(medicineId); recipe.setMedicineId(medicineId); recipe.setCaseId(caseId); recipe.setId(recipeId); recipe.setAmount(recipeParam.getAmount()); recipe.setRemainAmount(recipeParam.getAmount()); recipe.setMedicineSpecification(recipeParam.getMedicineSpecification()); recipe.setMedicineUnit(recipeParam.getMedicineUnit()); recipe.setMedicineFormulation(recipeParam.getMedicineFormulation()); recipe.setDosage(recipeParam.getDosage()); recipe.setFrequency(recipeParam.getFrequency()); recipe.setCreatorRoleId(creatorRoleId); recipe.setStatus(recipeParam.getStatus()); recipe.setMedicineType(recipeParam.getMedicineType()); recipe.setDepartmentId(medicineMapper.getDepartmentIdByMedicineId(medicineId)); HashMap hashMap; hashMap = medicineMapper.getMedicineTypeAndUPrice(medicineId); recipe.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); recipeParam.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); if (status == 2) { CommonResult commonResult = insertTransactionLog(recipeCollectionParam, recipeParam, creatorRoleId); if (commonResult.getCode() != 200) return CommonResult.fail(ResultCode.E_802); } } return CommonResult.success(count); }
RecipeManagementServiceImpl implements RecipeManagementService { public CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status){ int count = 0; Integer recipeId = recipeCollectionParam.getRecipeId(); Integer caseId = recipeCollectionParam.getCaseId(); Integer creatorRoleId = recipeCollectionParam.getCreatorRoleId(); List<RecipeParam> medicines = recipeCollectionParam.getMedicines(); recipeMapper.deleteById(recipeId); if(medicines.size() == 0){ Recipe recipe = new Recipe(); recipe.setId(recipeId); recipe.setMedicineId(0); recipe.setCaseId(caseId); recipe.setCreatorRoleId(creatorRoleId); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); return CommonResult.success(count); } for(RecipeParam recipeParam: medicines){ Recipe recipe = new Recipe(); Integer medicineId = recipeParam.getMedicineId(); String code = recipeParam.getMedicineCode(); if (medicineId == null) medicineId = medicineMapper.getIdByCode(code); recipeParam.setMedicineId(medicineId); recipe.setMedicineId(medicineId); recipe.setCaseId(caseId); recipe.setId(recipeId); recipe.setAmount(recipeParam.getAmount()); recipe.setRemainAmount(recipeParam.getAmount()); recipe.setMedicineSpecification(recipeParam.getMedicineSpecification()); recipe.setMedicineUnit(recipeParam.getMedicineUnit()); recipe.setMedicineFormulation(recipeParam.getMedicineFormulation()); recipe.setDosage(recipeParam.getDosage()); recipe.setFrequency(recipeParam.getFrequency()); recipe.setCreatorRoleId(creatorRoleId); recipe.setStatus(recipeParam.getStatus()); recipe.setMedicineType(recipeParam.getMedicineType()); recipe.setDepartmentId(medicineMapper.getDepartmentIdByMedicineId(medicineId)); HashMap hashMap; hashMap = medicineMapper.getMedicineTypeAndUPrice(medicineId); recipe.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); recipeParam.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); if (status == 2) { CommonResult commonResult = insertTransactionLog(recipeCollectionParam, recipeParam, creatorRoleId); if (commonResult.getCode() != 200) return CommonResult.fail(ResultCode.E_802); } } return CommonResult.success(count); } }
RecipeManagementServiceImpl implements RecipeManagementService { public CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status){ int count = 0; Integer recipeId = recipeCollectionParam.getRecipeId(); Integer caseId = recipeCollectionParam.getCaseId(); Integer creatorRoleId = recipeCollectionParam.getCreatorRoleId(); List<RecipeParam> medicines = recipeCollectionParam.getMedicines(); recipeMapper.deleteById(recipeId); if(medicines.size() == 0){ Recipe recipe = new Recipe(); recipe.setId(recipeId); recipe.setMedicineId(0); recipe.setCaseId(caseId); recipe.setCreatorRoleId(creatorRoleId); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); return CommonResult.success(count); } for(RecipeParam recipeParam: medicines){ Recipe recipe = new Recipe(); Integer medicineId = recipeParam.getMedicineId(); String code = recipeParam.getMedicineCode(); if (medicineId == null) medicineId = medicineMapper.getIdByCode(code); recipeParam.setMedicineId(medicineId); recipe.setMedicineId(medicineId); recipe.setCaseId(caseId); recipe.setId(recipeId); recipe.setAmount(recipeParam.getAmount()); recipe.setRemainAmount(recipeParam.getAmount()); recipe.setMedicineSpecification(recipeParam.getMedicineSpecification()); recipe.setMedicineUnit(recipeParam.getMedicineUnit()); recipe.setMedicineFormulation(recipeParam.getMedicineFormulation()); recipe.setDosage(recipeParam.getDosage()); recipe.setFrequency(recipeParam.getFrequency()); recipe.setCreatorRoleId(creatorRoleId); recipe.setStatus(recipeParam.getStatus()); recipe.setMedicineType(recipeParam.getMedicineType()); recipe.setDepartmentId(medicineMapper.getDepartmentIdByMedicineId(medicineId)); HashMap hashMap; hashMap = medicineMapper.getMedicineTypeAndUPrice(medicineId); recipe.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); recipeParam.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); if (status == 2) { CommonResult commonResult = insertTransactionLog(recipeCollectionParam, recipeParam, creatorRoleId); if (commonResult.getCode() != 200) return CommonResult.fail(ResultCode.E_802); } } return CommonResult.success(count); }  }
RecipeManagementServiceImpl implements RecipeManagementService { public CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status){ int count = 0; Integer recipeId = recipeCollectionParam.getRecipeId(); Integer caseId = recipeCollectionParam.getCaseId(); Integer creatorRoleId = recipeCollectionParam.getCreatorRoleId(); List<RecipeParam> medicines = recipeCollectionParam.getMedicines(); recipeMapper.deleteById(recipeId); if(medicines.size() == 0){ Recipe recipe = new Recipe(); recipe.setId(recipeId); recipe.setMedicineId(0); recipe.setCaseId(caseId); recipe.setCreatorRoleId(creatorRoleId); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); return CommonResult.success(count); } for(RecipeParam recipeParam: medicines){ Recipe recipe = new Recipe(); Integer medicineId = recipeParam.getMedicineId(); String code = recipeParam.getMedicineCode(); if (medicineId == null) medicineId = medicineMapper.getIdByCode(code); recipeParam.setMedicineId(medicineId); recipe.setMedicineId(medicineId); recipe.setCaseId(caseId); recipe.setId(recipeId); recipe.setAmount(recipeParam.getAmount()); recipe.setRemainAmount(recipeParam.getAmount()); recipe.setMedicineSpecification(recipeParam.getMedicineSpecification()); recipe.setMedicineUnit(recipeParam.getMedicineUnit()); recipe.setMedicineFormulation(recipeParam.getMedicineFormulation()); recipe.setDosage(recipeParam.getDosage()); recipe.setFrequency(recipeParam.getFrequency()); recipe.setCreatorRoleId(creatorRoleId); recipe.setStatus(recipeParam.getStatus()); recipe.setMedicineType(recipeParam.getMedicineType()); recipe.setDepartmentId(medicineMapper.getDepartmentIdByMedicineId(medicineId)); HashMap hashMap; hashMap = medicineMapper.getMedicineTypeAndUPrice(medicineId); recipe.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); recipeParam.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); if (status == 2) { CommonResult commonResult = insertTransactionLog(recipeCollectionParam, recipeParam, creatorRoleId); if (commonResult.getCode() != 200) return CommonResult.fail(ResultCode.E_802); } } return CommonResult.success(count); }  @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 { public CommonResult updateRecipes(RecipeCollectionParam recipeCollectionParam, Integer status){ int count = 0; Integer recipeId = recipeCollectionParam.getRecipeId(); Integer caseId = recipeCollectionParam.getCaseId(); Integer creatorRoleId = recipeCollectionParam.getCreatorRoleId(); List<RecipeParam> medicines = recipeCollectionParam.getMedicines(); recipeMapper.deleteById(recipeId); if(medicines.size() == 0){ Recipe recipe = new Recipe(); recipe.setId(recipeId); recipe.setMedicineId(0); recipe.setCaseId(caseId); recipe.setCreatorRoleId(creatorRoleId); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); return CommonResult.success(count); } for(RecipeParam recipeParam: medicines){ Recipe recipe = new Recipe(); Integer medicineId = recipeParam.getMedicineId(); String code = recipeParam.getMedicineCode(); if (medicineId == null) medicineId = medicineMapper.getIdByCode(code); recipeParam.setMedicineId(medicineId); recipe.setMedicineId(medicineId); recipe.setCaseId(caseId); recipe.setId(recipeId); recipe.setAmount(recipeParam.getAmount()); recipe.setRemainAmount(recipeParam.getAmount()); recipe.setMedicineSpecification(recipeParam.getMedicineSpecification()); recipe.setMedicineUnit(recipeParam.getMedicineUnit()); recipe.setMedicineFormulation(recipeParam.getMedicineFormulation()); recipe.setDosage(recipeParam.getDosage()); recipe.setFrequency(recipeParam.getFrequency()); recipe.setCreatorRoleId(creatorRoleId); recipe.setStatus(recipeParam.getStatus()); recipe.setMedicineType(recipeParam.getMedicineType()); recipe.setDepartmentId(medicineMapper.getDepartmentIdByMedicineId(medicineId)); HashMap hashMap; hashMap = medicineMapper.getMedicineTypeAndUPrice(medicineId); recipe.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); recipeParam.setMedicineUnitPrice((BigDecimal) hashMap.get("unitPrice")); count = recipeMapper.insertSelective(recipe); if(count <= 0) return CommonResult.fail(ResultCode.E_802); if (status == 2) { CommonResult commonResult = insertTransactionLog(recipeCollectionParam, recipeParam, creatorRoleId); if (commonResult.getCode() != 200) return CommonResult.fail(ResultCode.E_802); } } return CommonResult.success(count); }  @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);  }