| | |
| | | public ResultBody checkDepName(@RequestParam Map<String, Object> params) { |
| | | params.put("page", 1); |
| | | params.put("limit", 1); |
| | | if (sysDepartmentService.findList(params).getData().size()>0) { |
| | | if (sysDepartmentService.findList(params).getData().size() > 0) { |
| | | return ResultBody.failed().msg(String.format("该医院下已经存在科室 %s", params.get("departmentName"))); |
| | | } |
| | | return ResultBody.ok().msg(""); |
| | |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | //先检查该医院该科室是否已经存在 |
| | | Map<String, Object> checkDepartment=new HashMap<String,Object>(); |
| | | checkDepartment.put("page", 1); |
| | | checkDepartment.put("limit", 1); |
| | | checkDepartment.put("hospitalId",sysDepartment.getHospitalId()); |
| | | checkDepartment.put("departmentName",sysDepartment.getDepartmentName()); |
| | | if (sysDepartmentService.findList(checkDepartment).getData().size()>0) { |
| | | return ResultBody.failed().msg(String.format("该医院下已经存在科室 %s", sysDepartment.getDepartmentName())); |
| | | if (sysDepartment.getId() == null) { |
| | | Map<String, Object> checkDepartment = new HashMap<String, Object>(); |
| | | checkDepartment.put("page", 1); |
| | | checkDepartment.put("limit", 1); |
| | | checkDepartment.put("hospitalId", sysDepartment.getHospitalId()); |
| | | checkDepartment.put("departmentName", sysDepartment.getDepartmentName()); |
| | | if (sysDepartmentService.findList(checkDepartment).getData().size() > 0) { |
| | | return ResultBody.failed().msg(String.format("该医院下已经存在科室 %s", sysDepartment.getDepartmentName())); |
| | | } |
| | | } |
| | | //先检查是否存在组织信息 |
| | | SysOrganization sysOrganization=new SysOrganization(); |
| | | if(sysDepartment.getOrgId()!=null){ |
| | | sysOrganization.setId(sysDepartment.getOrgId());} |
| | | else{ |
| | | SysOrganization sysOrganization = new SysOrganization(); |
| | | if (sysDepartment.getOrgId() != null) { |
| | | sysOrganization.setId(sysDepartment.getOrgId()); |
| | | } else { |
| | | sysOrganization.setOrgName(sysDepartment.getDepartmentName()); |
| | | //临时暂用其它字段承载数据 |
| | | sysOrganization.setOrgParentId(sysDepartment.getUpdateUserId()); |
| | | } |
| | | sysOrganization=sysOrganizationService.findByObject(sysOrganization); |
| | | if(sysOrganization==null) |
| | | { |
| | | sysOrganization = sysOrganizationService.findByObject(sysOrganization); |
| | | if (sysOrganization == null) { |
| | | //创建一个组织 |
| | | sysOrganization=new SysOrganization(); |
| | | sysOrganization = new SysOrganization(); |
| | | sysOrganization.setOrgName(sysDepartment.getDepartmentName()); |
| | | sysOrganization.setOrgAttr(2); |
| | | sysOrganization.setOrgLevel(2); |
| | | //临时暂用其它字段承载数据 |
| | | sysOrganization.setOrgParentId(sysDepartment.getUpdateUserId()); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | sysOrganization.setOrgName(sysDepartment.getDepartmentName()); |
| | | } |
| | | boolean org=sysOrganizationService.saveOrUpdate(sysOrganization); |
| | | boolean org = sysOrganizationService.saveOrUpdate(sysOrganization); |
| | | sysDepartment.setOrgId(sysOrganization.getId()); |
| | | boolean v = sysDepartmentService.saveOrUpdate(sysDepartment); |
| | | if (v) { |