@Test public void testListCollectionTemplate() throws Exception { }
@Override public CommonResult listCollectionTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); JSONArray personalArray = new JSONArray(); JSONArray departmentArray = new JSONArray(); JSONArray hospitalArray = new JSONArray(); List<HashMap> collections = new ArrayList<>(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); System.out.println("***********department " + departmentId); if (type == 1) collections = inspectionTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 2) collections = examinationTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 3) collections = treatmentTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); for(HashMap collection : collections) { JSONObject collectionJson = new JSONObject(); String name = (String)collection.get("name"); Integer scope = (Integer)collection.get("scope"); Integer creator = (Integer)collection.get("roleId"); collectionJson.put("name", name); collectionJson.put("scope", scope); collectionJson.put("roleId", creator); collectionJson.put("newName", ""); collectionJson.put("departmentId", departmentId); collectionJson.put("type", type); JSONArray projectArray = new JSONArray(); List<HashMap> projects = new ArrayList<>(); if (type == 1) projects = inspectionTemplateMapper.listProject(creator, name); else if(type == 2) projects = examinationTemplateMapper.listProject(creator, name); else if(type == 3) projects = treatmentTemplateMapper.listProject(creator, name); for(HashMap project:projects){ JSONObject projectJson = new JSONObject(); String projectName = (String)project.get("projectName"); Integer projectId = (Integer)project.get("projectId"); projectJson.put("projectId", projectId); projectJson.put("projectName", projectName); projectJson.put("requirement", project.get("requirement")); projectJson.put("goal", project.get("goal")); projectJson.put("departmentId", project.get("departmentId")); projectJson.put("departmentName", project.get("departmentName")); projectJson.put("resultDescription", ""); projectJson.put("resultImage", ""); projectJson.put("status", 0); projectJson.put("advice", ""); JSONArray itemArray = new JSONArray(); List<HashMap> items = new ArrayList<>(); if (type == 1) items = inspectionTemplateMapper.listItems(roleId, name, projectId); else if (type == 2) items = examinationTemplateMapper.listItems(roleId, name, projectId); for (HashMap item : items) { JSONObject itemJson = new JSONObject(); itemJson.put("itemId", item.get("itemId")); itemJson.put("itemName", item.get("itemName")); itemJson.put("amount", 1); itemArray.add(itemJson); } projectJson.put("items", itemArray); projectArray.add(projectJson); } collectionJson.put("projects", projectArray); if (scope == 1) personalArray.add(collectionJson); else if(scope == 2) departmentArray.add(collectionJson); else if(scope == 3) hospitalArray.add(collectionJson); } returnJson.put("personalTemplates", personalArray); returnJson.put("departmentTemplates", departmentArray); returnJson.put("hospitalTemplates", hospitalArray); return CommonResult.success(returnJson); }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult listCollectionTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); JSONArray personalArray = new JSONArray(); JSONArray departmentArray = new JSONArray(); JSONArray hospitalArray = new JSONArray(); List<HashMap> collections = new ArrayList<>(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); System.out.println("***********department " + departmentId); if (type == 1) collections = inspectionTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 2) collections = examinationTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 3) collections = treatmentTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); for(HashMap collection : collections) { JSONObject collectionJson = new JSONObject(); String name = (String)collection.get("name"); Integer scope = (Integer)collection.get("scope"); Integer creator = (Integer)collection.get("roleId"); collectionJson.put("name", name); collectionJson.put("scope", scope); collectionJson.put("roleId", creator); collectionJson.put("newName", ""); collectionJson.put("departmentId", departmentId); collectionJson.put("type", type); JSONArray projectArray = new JSONArray(); List<HashMap> projects = new ArrayList<>(); if (type == 1) projects = inspectionTemplateMapper.listProject(creator, name); else if(type == 2) projects = examinationTemplateMapper.listProject(creator, name); else if(type == 3) projects = treatmentTemplateMapper.listProject(creator, name); for(HashMap project:projects){ JSONObject projectJson = new JSONObject(); String projectName = (String)project.get("projectName"); Integer projectId = (Integer)project.get("projectId"); projectJson.put("projectId", projectId); projectJson.put("projectName", projectName); projectJson.put("requirement", project.get("requirement")); projectJson.put("goal", project.get("goal")); projectJson.put("departmentId", project.get("departmentId")); projectJson.put("departmentName", project.get("departmentName")); projectJson.put("resultDescription", ""); projectJson.put("resultImage", ""); projectJson.put("status", 0); projectJson.put("advice", ""); JSONArray itemArray = new JSONArray(); List<HashMap> items = new ArrayList<>(); if (type == 1) items = inspectionTemplateMapper.listItems(roleId, name, projectId); else if (type == 2) items = examinationTemplateMapper.listItems(roleId, name, projectId); for (HashMap item : items) { JSONObject itemJson = new JSONObject(); itemJson.put("itemId", item.get("itemId")); itemJson.put("itemName", item.get("itemName")); itemJson.put("amount", 1); itemArray.add(itemJson); } projectJson.put("items", itemArray); projectArray.add(projectJson); } collectionJson.put("projects", projectArray); if (scope == 1) personalArray.add(collectionJson); else if(scope == 2) departmentArray.add(collectionJson); else if(scope == 3) hospitalArray.add(collectionJson); } returnJson.put("personalTemplates", personalArray); returnJson.put("departmentTemplates", departmentArray); returnJson.put("hospitalTemplates", hospitalArray); return CommonResult.success(returnJson); } }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult listCollectionTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); JSONArray personalArray = new JSONArray(); JSONArray departmentArray = new JSONArray(); JSONArray hospitalArray = new JSONArray(); List<HashMap> collections = new ArrayList<>(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); System.out.println("***********department " + departmentId); if (type == 1) collections = inspectionTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 2) collections = examinationTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 3) collections = treatmentTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); for(HashMap collection : collections) { JSONObject collectionJson = new JSONObject(); String name = (String)collection.get("name"); Integer scope = (Integer)collection.get("scope"); Integer creator = (Integer)collection.get("roleId"); collectionJson.put("name", name); collectionJson.put("scope", scope); collectionJson.put("roleId", creator); collectionJson.put("newName", ""); collectionJson.put("departmentId", departmentId); collectionJson.put("type", type); JSONArray projectArray = new JSONArray(); List<HashMap> projects = new ArrayList<>(); if (type == 1) projects = inspectionTemplateMapper.listProject(creator, name); else if(type == 2) projects = examinationTemplateMapper.listProject(creator, name); else if(type == 3) projects = treatmentTemplateMapper.listProject(creator, name); for(HashMap project:projects){ JSONObject projectJson = new JSONObject(); String projectName = (String)project.get("projectName"); Integer projectId = (Integer)project.get("projectId"); projectJson.put("projectId", projectId); projectJson.put("projectName", projectName); projectJson.put("requirement", project.get("requirement")); projectJson.put("goal", project.get("goal")); projectJson.put("departmentId", project.get("departmentId")); projectJson.put("departmentName", project.get("departmentName")); projectJson.put("resultDescription", ""); projectJson.put("resultImage", ""); projectJson.put("status", 0); projectJson.put("advice", ""); JSONArray itemArray = new JSONArray(); List<HashMap> items = new ArrayList<>(); if (type == 1) items = inspectionTemplateMapper.listItems(roleId, name, projectId); else if (type == 2) items = examinationTemplateMapper.listItems(roleId, name, projectId); for (HashMap item : items) { JSONObject itemJson = new JSONObject(); itemJson.put("itemId", item.get("itemId")); itemJson.put("itemName", item.get("itemName")); itemJson.put("amount", 1); itemArray.add(itemJson); } projectJson.put("items", itemArray); projectArray.add(projectJson); } collectionJson.put("projects", projectArray); if (scope == 1) personalArray.add(collectionJson); else if(scope == 2) departmentArray.add(collectionJson); else if(scope == 3) hospitalArray.add(collectionJson); } returnJson.put("personalTemplates", personalArray); returnJson.put("departmentTemplates", departmentArray); returnJson.put("hospitalTemplates", hospitalArray); return CommonResult.success(returnJson); }  }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult listCollectionTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); JSONArray personalArray = new JSONArray(); JSONArray departmentArray = new JSONArray(); JSONArray hospitalArray = new JSONArray(); List<HashMap> collections = new ArrayList<>(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); System.out.println("***********department " + departmentId); if (type == 1) collections = inspectionTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 2) collections = examinationTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 3) collections = treatmentTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); for(HashMap collection : collections) { JSONObject collectionJson = new JSONObject(); String name = (String)collection.get("name"); Integer scope = (Integer)collection.get("scope"); Integer creator = (Integer)collection.get("roleId"); collectionJson.put("name", name); collectionJson.put("scope", scope); collectionJson.put("roleId", creator); collectionJson.put("newName", ""); collectionJson.put("departmentId", departmentId); collectionJson.put("type", type); JSONArray projectArray = new JSONArray(); List<HashMap> projects = new ArrayList<>(); if (type == 1) projects = inspectionTemplateMapper.listProject(creator, name); else if(type == 2) projects = examinationTemplateMapper.listProject(creator, name); else if(type == 3) projects = treatmentTemplateMapper.listProject(creator, name); for(HashMap project:projects){ JSONObject projectJson = new JSONObject(); String projectName = (String)project.get("projectName"); Integer projectId = (Integer)project.get("projectId"); projectJson.put("projectId", projectId); projectJson.put("projectName", projectName); projectJson.put("requirement", project.get("requirement")); projectJson.put("goal", project.get("goal")); projectJson.put("departmentId", project.get("departmentId")); projectJson.put("departmentName", project.get("departmentName")); projectJson.put("resultDescription", ""); projectJson.put("resultImage", ""); projectJson.put("status", 0); projectJson.put("advice", ""); JSONArray itemArray = new JSONArray(); List<HashMap> items = new ArrayList<>(); if (type == 1) items = inspectionTemplateMapper.listItems(roleId, name, projectId); else if (type == 2) items = examinationTemplateMapper.listItems(roleId, name, projectId); for (HashMap item : items) { JSONObject itemJson = new JSONObject(); itemJson.put("itemId", item.get("itemId")); itemJson.put("itemName", item.get("itemName")); itemJson.put("amount", 1); itemArray.add(itemJson); } projectJson.put("items", itemArray); projectArray.add(projectJson); } collectionJson.put("projects", projectArray); if (scope == 1) personalArray.add(collectionJson); else if(scope == 2) departmentArray.add(collectionJson); else if(scope == 3) hospitalArray.add(collectionJson); } returnJson.put("personalTemplates", personalArray); returnJson.put("departmentTemplates", departmentArray); returnJson.put("hospitalTemplates", hospitalArray); return CommonResult.success(returnJson); }  @Override CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam); CommonResult saveItems(CollectionTemplateParam collectionTemplateParam,
                                  ProjectTemplateParam projectTemplateParam, String item); Boolean isAvailable(Integer roleId, String name, Integer type); @Override CommonResult listCollectionTemplate(Integer roleId, Integer type); CommonResult deleteCollectionTemplate(CollectionTemplateParam collectionTemplateParam); @Override CommonResult modifyCollectionTemplate(CollectionTemplateParam collectionTemplateParam); }
ProjectCollectionTemplateServiceImpl implements ProjectCollectionTemplateService { @Override public CommonResult listCollectionTemplate(Integer roleId, Integer type){ JSONObject returnJson = new JSONObject(); JSONArray personalArray = new JSONArray(); JSONArray departmentArray = new JSONArray(); JSONArray hospitalArray = new JSONArray(); List<HashMap> collections = new ArrayList<>(); Integer departmentId = roleMapper.getDepartmentIdByRoleId(roleId); System.out.println("***********department " + departmentId); if (type == 1) collections = inspectionTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 2) collections = examinationTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); else if(type == 3) collections = treatmentTemplateMapper.listTemplateNameAndCreator(roleId, departmentId); for(HashMap collection : collections) { JSONObject collectionJson = new JSONObject(); String name = (String)collection.get("name"); Integer scope = (Integer)collection.get("scope"); Integer creator = (Integer)collection.get("roleId"); collectionJson.put("name", name); collectionJson.put("scope", scope); collectionJson.put("roleId", creator); collectionJson.put("newName", ""); collectionJson.put("departmentId", departmentId); collectionJson.put("type", type); JSONArray projectArray = new JSONArray(); List<HashMap> projects = new ArrayList<>(); if (type == 1) projects = inspectionTemplateMapper.listProject(creator, name); else if(type == 2) projects = examinationTemplateMapper.listProject(creator, name); else if(type == 3) projects = treatmentTemplateMapper.listProject(creator, name); for(HashMap project:projects){ JSONObject projectJson = new JSONObject(); String projectName = (String)project.get("projectName"); Integer projectId = (Integer)project.get("projectId"); projectJson.put("projectId", projectId); projectJson.put("projectName", projectName); projectJson.put("requirement", project.get("requirement")); projectJson.put("goal", project.get("goal")); projectJson.put("departmentId", project.get("departmentId")); projectJson.put("departmentName", project.get("departmentName")); projectJson.put("resultDescription", ""); projectJson.put("resultImage", ""); projectJson.put("status", 0); projectJson.put("advice", ""); JSONArray itemArray = new JSONArray(); List<HashMap> items = new ArrayList<>(); if (type == 1) items = inspectionTemplateMapper.listItems(roleId, name, projectId); else if (type == 2) items = examinationTemplateMapper.listItems(roleId, name, projectId); for (HashMap item : items) { JSONObject itemJson = new JSONObject(); itemJson.put("itemId", item.get("itemId")); itemJson.put("itemName", item.get("itemName")); itemJson.put("amount", 1); itemArray.add(itemJson); } projectJson.put("items", itemArray); projectArray.add(projectJson); } collectionJson.put("projects", projectArray); if (scope == 1) personalArray.add(collectionJson); else if(scope == 2) departmentArray.add(collectionJson); else if(scope == 3) hospitalArray.add(collectionJson); } returnJson.put("personalTemplates", personalArray); returnJson.put("departmentTemplates", departmentArray); returnJson.put("hospitalTemplates", hospitalArray); return CommonResult.success(returnJson); }  @Override CommonResult insertCollectionTemplate(CollectionTemplateParam collectionTemplateParam); CommonResult saveItems(CollectionTemplateParam collectionTemplateParam,
                                  ProjectTemplateParam projectTemplateParam, String item); Boolean isAvailable(Integer roleId, String name, Integer type); @Override CommonResult listCollectionTemplate(Integer roleId, Integer type); CommonResult deleteCollectionTemplate(CollectionTemplateParam collectionTemplateParam); @Override CommonResult modifyCollectionTemplate(CollectionTemplateParam collectionTemplateParam);  }