功能调整

sale
tianea 3 years ago
parent 5df5561216
commit 1d42ec0fd7

@ -57,4 +57,9 @@ public class ZhiYunApi {
String content = HttpUtil.get(baseUrl+"/api/question/findByCourseId?courseId="+courseId+"&pageSize="+pageSize+"&pageIndex="+pageIndex,headers); String content = HttpUtil.get(baseUrl+"/api/question/findByCourseId?courseId="+courseId+"&pageSize="+pageSize+"&pageIndex="+pageIndex,headers);
return content; return content;
} }
public String findAuthSchool(){
String content = HttpUtil.get(baseUrl+"/api/school/findByAuthorization",headers);
return content;
}
} }

@ -1,3 +1,3 @@
pic_path=/users/root/www/pic/ pic_path=/users/root/www/pic/
pic_recourse_url=/pic/ pic_recourse_url=/pic/
initPwd=123456 initPwd=123qwe

@ -4,6 +4,7 @@ import com.tz.platform.feign.vo.SchoolVo;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
@ -15,4 +16,7 @@ public interface IFeignSchool {
@RequestMapping(value = "/feign/system/school/list") @RequestMapping(value = "/feign/system/school/list")
List<SchoolVo> list(); List<SchoolVo> list();
@RequestMapping(value = "/feign/system/school/add")
void addSchool(@RequestBody String json);
} }

@ -1,10 +1,14 @@
package com.tz.platform.system.feign; package com.tz.platform.system.feign;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tz.platform.common.core.tools.BeanUtils; import com.tz.platform.common.core.tools.BeanUtils;
import com.tz.platform.entity.School; import com.tz.platform.entity.School;
import com.tz.platform.feign.IFeignSchool; import com.tz.platform.feign.IFeignSchool;
import com.tz.platform.feign.vo.SchoolVo; import com.tz.platform.feign.vo.SchoolVo;
import com.tz.platform.repository.SchoolDao; import com.tz.platform.repository.SchoolDao;
import com.tz.platform.system.pc.biz.SchoolBiz;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -16,6 +20,9 @@ public class FeignSchoolController implements IFeignSchool {
@Autowired @Autowired
private SchoolDao schoolDao ; private SchoolDao schoolDao ;
@Autowired
private SchoolBiz schoolBiz;
@Override @Override
public SchoolVo getByOuterId(Integer outerId) { public SchoolVo getByOuterId(Integer outerId) {
School school = schoolDao.getByOuterId(outerId); School school = schoolDao.getByOuterId(outerId);
@ -29,4 +36,23 @@ public class FeignSchoolController implements IFeignSchool {
List<SchoolVo> vo = BeanUtils.copyProperties(schoolList,SchoolVo.class); List<SchoolVo> vo = BeanUtils.copyProperties(schoolList,SchoolVo.class);
return vo; return vo;
} }
@Override
public void addSchool(String json) {
JSONObject content = JSONUtil.parseObj(json);
int code = content.getInt("code");
if(code == 200){
JSONArray jsonArray = content.getJSONArray("data");
jsonArray.forEach(object -> {
JSONObject schoolInfo = (JSONObject) object;
int id = schoolInfo.getInt("id");
String name = schoolInfo.getStr("name");
int level = schoolInfo.getInt("level");
if(name.isEmpty() ==false){
schoolBiz.save(id,name,level);
}
});
}
}
} }

@ -37,9 +37,11 @@ public class ZhiyunJob {
boolean lr = lock(jobName,ms); boolean lr = lock(jobName,ms);
if(lr){ if(lr){
try { try {
zhiyunAccountBiz.synSchool();
zhiyunAccountBiz.synGrade(); zhiyunAccountBiz.synGrade();
zhiyunAccountBiz.synAccountJob(); zhiyunAccountBiz.synAccountJob();
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace();
log.error("大赛状态更新任务失败: {}",ex.getMessage()); log.error("大赛状态更新任务失败: {}",ex.getMessage());
}finally { }finally {
unLock(jobName); unLock(jobName);
@ -47,6 +49,9 @@ public class ZhiyunJob {
} }
} }
/** /**
* redis * redis
* *

@ -38,6 +38,7 @@ public class ZhiyunAccountBiz {
public void synAccountJob(){ public void synAccountJob(){
List<SchoolVo> schoolVoList = feignSchool.list(); List<SchoolVo> schoolVoList = feignSchool.list();
schoolVoList.forEach(schoolVo -> { schoolVoList.forEach(schoolVo -> {
String studentContent = zhiYunApi.findAllStudent(schoolVo.getOuterId()); String studentContent = zhiYunApi.findAllStudent(schoolVo.getOuterId());
dealStudent(studentContent,schoolVo); dealStudent(studentContent,schoolVo);
String teacherCountent = zhiYunApi.findTeacherBySchoolId(schoolVo.getOuterId()); String teacherCountent = zhiYunApi.findTeacherBySchoolId(schoolVo.getOuterId());
@ -53,6 +54,14 @@ public class ZhiyunAccountBiz {
}); });
} }
public void synSchool(){
String content = zhiYunApi.findAuthSchool();
if(!content.isEmpty()){
feignSchool.addSchool(content);
}
}
public void synQuestion(){ public void synQuestion(){
List<SchoolVo> schoolVoList = feignSchool.list(); List<SchoolVo> schoolVoList = feignSchool.list();
schoolVoList.forEach(schoolVo -> { schoolVoList.forEach(schoolVo -> {
@ -96,6 +105,9 @@ public class ZhiyunAccountBiz {
JSONObject studentOb = (JSONObject)jo; JSONObject studentOb = (JSONObject)jo;
Integer classId = studentOb.getInt("classId"); Integer classId = studentOb.getInt("classId");
String studentNo = studentOb.getStr("studentNo"); String studentNo = studentOb.getStr("studentNo");
if(userList.stream().filter(user -> user.getStudentNo().equals(studentNo)).count()>0) {
return ;
}
String name = studentOb.getStr("name"); String name = studentOb.getStr("name");
User user = dealUser(studentNo,name,classId,school,UserTypeEnum.USER.getCode()); User user = dealUser(studentNo,name,classId,school,UserTypeEnum.USER.getCode());
userList.add(user); userList.add(user);
@ -106,7 +118,7 @@ public class ZhiyunAccountBiz {
} }
private User dealUser(String studentNo,String name,int classId,SchoolVo school,Integer userType){ private User dealUser(String studentNo,String name,int classId,SchoolVo school,Integer userType){
User user =userDao.getByUsername(studentNo); User user =userDao.getByStudentNo(studentNo);
if(user == null){ if(user == null){
user = new User(); user = new User();
user.setMobileSalt(StrUtil.get32UUID()); user.setMobileSalt(StrUtil.get32UUID());

Loading…
Cancel
Save