|
@@ -51,27 +51,25 @@ public class SpecialtyService {
|
|
|
specialty.setEnable(true);
|
|
|
ExcelError error = importCheck(specialty);
|
|
|
if (error == null) {
|
|
|
- addSpecialty(list,specialty);
|
|
|
+ addSpecialty(specialty);
|
|
|
}
|
|
|
return error;
|
|
|
}
|
|
|
});
|
|
|
- specialtyRepo.save(list);
|
|
|
- for (Specialty specialty : list) {
|
|
|
- dataSendService.sendSpecialty(specialty);
|
|
|
- }
|
|
|
return excelErrors;
|
|
|
}
|
|
|
|
|
|
- private void addSpecialty(List<Specialty> specialties,Specialty specialty){
|
|
|
- for(Specialty tempSpecialty:specialties){
|
|
|
- if(tempSpecialty.getCode().equals(specialty.getCode())){
|
|
|
- tempSpecialty.setName(specialty.getName());
|
|
|
- tempSpecialty.setUpdateTime(new Date());
|
|
|
- return;
|
|
|
- }
|
|
|
+ private void addSpecialty(Specialty specialty){
|
|
|
+ Specialty old = specialtyRepo.findByOrgIdAndCode(specialty.getOrgId(),specialty.getCode());
|
|
|
+ if(old == null){
|
|
|
+ Specialty tempSpecialty = specialtyRepo.save(specialty);
|
|
|
+ dataSendService.sendSpecialty(tempSpecialty);
|
|
|
+ }else{
|
|
|
+ old.setName(specialty.getName());
|
|
|
+ old.setUpdateTime(new Date());
|
|
|
+ Specialty tempSpecialty = specialtyRepo.save(old);
|
|
|
+ dataSendService.sendSpecialty(tempSpecialty);
|
|
|
}
|
|
|
- specialties.add(specialty);
|
|
|
}
|
|
|
|
|
|
private ExcelError importCheck(Specialty specialty) {
|
|
@@ -81,10 +79,6 @@ public class SpecialtyService {
|
|
|
if(StringUtils.isEmpty(specialty.getName())){
|
|
|
return new ExcelError("名称不能为空");
|
|
|
}
|
|
|
- Specialty domain = specialtyRepo.findByOrgIdAndCode(specialty.getOrgId(),specialty.getCode());
|
|
|
- if(domain != null){
|
|
|
- return new ExcelError("代码已存在");
|
|
|
- }
|
|
|
return null;
|
|
|
}
|
|
|
|