|
@@ -5,7 +5,9 @@ import java.io.IOException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -71,6 +73,19 @@ public class YunkaiService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private PropertyRepo propertyRepo;
|
|
private PropertyRepo propertyRepo;
|
|
|
|
+
|
|
|
|
+ private Map<String,String> allProperty(String coursePropertyId){
|
|
|
|
+ List<Property> list=propertyRepo.findByCoursePropertyIdOrderByNumber(coursePropertyId);
|
|
|
|
+ Map<String,String> map=new HashMap<>();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ for(Property p:list) {
|
|
|
|
+ if(StringUtils.isNotBlank(p.getFromId())) {
|
|
|
|
+ map.put(p.getFromId(), p.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
|
|
private void savePropOneCourse(User user, File zfile, Long rootOrgId, String courseCode, String batch) {
|
|
private void savePropOneCourse(User user, File zfile, Long rootOrgId, String courseCode, String batch) {
|
|
GetCourseReq req = new GetCourseReq();
|
|
GetCourseReq req = new GetCourseReq();
|
|
@@ -78,15 +93,22 @@ public class YunkaiService {
|
|
req.setCode(courseCode);
|
|
req.setCode(courseCode);
|
|
GetCourseResp res = courseCloudService.getCourse(req);
|
|
GetCourseResp res = courseCloudService.getCourse(req);
|
|
|
|
|
|
- CourseProperty cp = new CourseProperty();
|
|
|
|
- cp.setCourseCode(courseCode);
|
|
|
|
- cp.setCourseId(res.getCourseBean().getId());
|
|
|
|
- cp.setCourseName(res.getCourseBean().getName());
|
|
|
|
- cp.setEnable(true);
|
|
|
|
- cp.setOrgId(rootOrgId);
|
|
|
|
- cp.setName(res.getCourseBean().getName() + "课程属性" + batch);
|
|
|
|
- cp.setBatch(batch);
|
|
|
|
- coursePropertyRepo.save(cp);
|
|
|
|
|
|
+ CourseProperty cp =coursePropertyRepo.findByOrgIdAndCourseIdAndBatch(rootOrgId, res.getCourseBean().getId(),batch);
|
|
|
|
+ Map<String,String> allProperty=new HashMap<>();
|
|
|
|
+ if(cp==null) {
|
|
|
|
+ cp= new CourseProperty();
|
|
|
|
+ cp.setCourseCode(courseCode);
|
|
|
|
+ cp.setCourseId(res.getCourseBean().getId());
|
|
|
|
+ cp.setCourseName(res.getCourseBean().getName());
|
|
|
|
+ cp.setEnable(true);
|
|
|
|
+ cp.setOrgId(rootOrgId);
|
|
|
|
+ cp.setName(res.getCourseBean().getName() + "课程属性" + batch);
|
|
|
|
+ cp.setBatch(batch);
|
|
|
|
+ coursePropertyRepo.save(cp);
|
|
|
|
+ }else {
|
|
|
|
+ allProperty=allProperty(cp.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
String json;
|
|
String json;
|
|
try {
|
|
try {
|
|
json = FileUtils.readFileToString(zfile, "utf-8");
|
|
json = FileUtils.readFileToString(zfile, "utf-8");
|
|
@@ -98,34 +120,44 @@ public class YunkaiService {
|
|
for (PropertyDto pd : pds) {
|
|
for (PropertyDto pd : pds) {
|
|
num++;
|
|
num++;
|
|
Property p = new Property();
|
|
Property p = new Property();
|
|
- p.setCode(pd.getName());
|
|
|
|
- p.setCoursePropertyId(cp.getId());
|
|
|
|
- p.setName(pd.getName());
|
|
|
|
- p.setNumber(num);
|
|
|
|
- p.setOrgId(rootOrgId);
|
|
|
|
- p.setParentId("0");
|
|
|
|
- p.setFromId(pd.getId().toString());
|
|
|
|
- propertyRepo.save(p);
|
|
|
|
|
|
+ if(!allProperty.keySet().contains(pd.getId().toString())) {
|
|
|
|
+ p.setCode(pd.getName());
|
|
|
|
+ p.setCoursePropertyId(cp.getId());
|
|
|
|
+ p.setName(pd.getName());
|
|
|
|
+ p.setNumber(num);
|
|
|
|
+ p.setOrgId(rootOrgId);
|
|
|
|
+ p.setParentId("0");
|
|
|
|
+ p.setFromId(pd.getId().toString());
|
|
|
|
+ p.setBatch(batch);
|
|
|
|
+ propertyRepo.save(p);
|
|
|
|
+ }else {
|
|
|
|
+ p.setId(allProperty.get(pd.getId().toString()));
|
|
|
|
+ }
|
|
if (CollectionUtils.isNotEmpty(pd.getSubPropertyDto())) {
|
|
if (CollectionUtils.isNotEmpty(pd.getSubPropertyDto())) {
|
|
int subnum = 0;
|
|
int subnum = 0;
|
|
List<Property> ps = new ArrayList<>();
|
|
List<Property> ps = new ArrayList<>();
|
|
for (PropertyDto subpd : pd.getSubPropertyDto()) {
|
|
for (PropertyDto subpd : pd.getSubPropertyDto()) {
|
|
subnum++;
|
|
subnum++;
|
|
- Property subp = new Property();
|
|
|
|
- subp.setCode(subpd.getName());
|
|
|
|
- subp.setCoursePropertyId(cp.getId());
|
|
|
|
- subp.setName(subpd.getName());
|
|
|
|
- subp.setNumber(subnum);
|
|
|
|
- subp.setOrgId(rootOrgId);
|
|
|
|
- subp.setParentId(p.getId());
|
|
|
|
- subp.setFromId(subpd.getId().toString());
|
|
|
|
- ps.add(subp);
|
|
|
|
|
|
+ if(!allProperty.keySet().contains(subpd.getId().toString())) {
|
|
|
|
+ Property subp = new Property();
|
|
|
|
+ subp.setCode(subpd.getName());
|
|
|
|
+ subp.setCoursePropertyId(cp.getId());
|
|
|
|
+ subp.setName(subpd.getName());
|
|
|
|
+ subp.setNumber(subnum);
|
|
|
|
+ subp.setOrgId(rootOrgId);
|
|
|
|
+ subp.setParentId(p.getId());
|
|
|
|
+ subp.setFromId(subpd.getId().toString());
|
|
|
|
+ subp.setBatch(batch);
|
|
|
|
+ ps.add(subp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(ps.size()>0) {
|
|
|
|
+ propertyRepo.saveAll(ps);
|
|
}
|
|
}
|
|
- propertyRepo.saveAll(ps);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Transactional
|
|
@Transactional
|
|
public void saveProp(User user, MultipartFile dataFile, Long rootOrgId, List<String> courseCodes, String batch) {
|
|
public void saveProp(User user, MultipartFile dataFile, Long rootOrgId, List<String> courseCodes, String batch) {
|
|
String tempDir = systemProperties.getTempDataDir();
|
|
String tempDir = systemProperties.getTempDataDir();
|