mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-15 22:06:50 +08:00
合并stat 到third
This commit is contained in:
@@ -8,6 +8,9 @@ public interface CacheName {
|
||||
*/
|
||||
String NAME_AUTH= "auth";
|
||||
|
||||
|
||||
String NAME_USER_LOGIN_ERROR_NUM= "user:login:error:aid:";
|
||||
|
||||
/**
|
||||
* 验证码key前缀
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.xboe.data.api;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -9,15 +7,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.account.service.IAccountService;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.service.IDataUserSyncService;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -52,71 +47,7 @@ public class UserDataSyncApi extends ApiBaseController {
|
||||
//清除缓存需要loginName
|
||||
try {
|
||||
//先查询是否存在
|
||||
Account a=accountService.get(user.getId());
|
||||
User u=userService.get(user.getId());
|
||||
Organization org=null;
|
||||
if(a!=null) {
|
||||
//账户只是修改状态
|
||||
a.setDeleted(user.getDeleted());
|
||||
}else {
|
||||
//新账户
|
||||
a=new Account();
|
||||
a.setDeleted(user.getDeleted());
|
||||
a.setSysId(user.getKid());
|
||||
a.setLoginName(user.getCode());
|
||||
a.setAvatar(user.getAvatar());
|
||||
a.setId(user.getId());
|
||||
a.setRegTime(LocalDateTime.now());
|
||||
a.setSysId(user.getKid());
|
||||
a.setStatus(1);
|
||||
}
|
||||
if(u!=null) {
|
||||
//更新部分用户字段
|
||||
u.setDepartId(user.getDepartId());
|
||||
u.setDepartName(user.getDepartName());
|
||||
u.setName(user.getName());
|
||||
u.setUserType(user.getUserType());
|
||||
if(user.getLearningDuration()>0) { //不大于0才会更新
|
||||
u.setLearningDuration(user.getLearningDuration());
|
||||
}
|
||||
}else {
|
||||
//新建用户
|
||||
u=new User();
|
||||
u.setId(user.getId());
|
||||
u.setDepartId(user.getDepartId());
|
||||
u.setDepartName(user.getDepartName());
|
||||
u.setDynamic(0);
|
||||
u.setGender(u.getGender());
|
||||
u.setName(user.getName());
|
||||
u.setSign("");
|
||||
u.setUserNo(user.getCode());
|
||||
u.setUserType(user.getUserType());
|
||||
u.setSysId(user.getKid());
|
||||
u.setStudyTotal(0);
|
||||
u.setLearningDuration(user.getLearningDuration());
|
||||
if(user.getBandLevel()!=null && user.getBandLevel()>15) {
|
||||
u.setShowHome(false);//band16及以上
|
||||
}else {
|
||||
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
||||
}
|
||||
|
||||
}
|
||||
//对机构的判断,不为空时才会处理,为空时不处理
|
||||
if(StringUtils.isNotBlank(user.getDepartId())) {
|
||||
org=orgService.get(user.getDepartId());
|
||||
if(org==null) {
|
||||
org=new Organization();
|
||||
org.setCode("");
|
||||
org.setId(user.getDepartId());
|
||||
org.setName(user.getDepartName());
|
||||
org.setDeleted(false);
|
||||
org.setStatus(1);
|
||||
}
|
||||
org.setNamePath(user.getOrgNamePath());
|
||||
|
||||
}
|
||||
service.syncUserFull(a, u, org);
|
||||
|
||||
service.syncUserFull(user);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("同步处理用户错误", e);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xboe.data.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 受众人员
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class AudienceUser {
|
||||
|
||||
/**
|
||||
* 用户的统一id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户的姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 用户的代码
|
||||
*/
|
||||
private String code;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xboe.data.outside;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.dto.UserData;
|
||||
|
||||
public interface IOutSideDataService {
|
||||
|
||||
/**
|
||||
* 获取受众的所有用户
|
||||
* @param task
|
||||
*/
|
||||
List<AudienceUser> getUsersByAudienceId(String audienceId);
|
||||
|
||||
/**
|
||||
* 通过统一用户id获取用户的信息
|
||||
*/
|
||||
UserData getUserInfoByUserId(String userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.xboe.data.outside;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.api.TokenProxy;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.dto.UserData;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
|
||||
private String getNodeText(JsonNode jn) {
|
||||
if(jn!=null) {
|
||||
return jn.asText();
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AudienceUser> getUsersByAudienceId(String audienceId){
|
||||
|
||||
String token = TokenProxy.getToken(request);
|
||||
String type="application/json";
|
||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||
String url= getBaseUrl("/audience/memberList");
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("audienceId", audienceId);
|
||||
String json = null;
|
||||
List<AudienceUser> list=new ArrayList<AudienceUser>();
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
try {
|
||||
|
||||
json = mapper.writeValueAsString(params);
|
||||
String responseStr = okHttpUtil.doPostJson(url, json, headers);
|
||||
JsonNode rootNode= mapper.readTree(responseStr);
|
||||
|
||||
JsonNode result = rootNode.get("result")!=null ?( rootNode.get("result").get("data") !=null ? rootNode.get("result").get("data"):null):null;
|
||||
if(rootNode.get("result")!=null & rootNode.get("result").isArray()) {
|
||||
//这里应该是单独的线程去处理
|
||||
for(JsonNode JsonNode :result) {
|
||||
AudienceUser au=new AudienceUser();
|
||||
au.setId(JsonNode.get("id").asText());
|
||||
au.setName(getNodeText(JsonNode.get("userName")));
|
||||
au.setCode(getNodeText(JsonNode.get("userNo")));
|
||||
list.add(au);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取受众用户列表错误",e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserData getUserInfoByUserId(String userId) {
|
||||
|
||||
String token = TokenProxy.getToken(request);
|
||||
String type="application/json";
|
||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||
String url= getBaseUrl("/user/info");
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
try {
|
||||
String responseStr = okHttpUtil.doPostJson(url,"{}", headers);
|
||||
JsonNode rootNode= mapper.readTree(responseStr);
|
||||
int code = rootNode.get("code").asInt();
|
||||
if(code!=200) {
|
||||
log.error("获取当前用户信息返回结果错误:"+responseStr);
|
||||
return null;
|
||||
}
|
||||
UserData user=new UserData();
|
||||
JsonNode result = rootNode.get("result");
|
||||
if(rootNode.get("result")!=null & rootNode.get("result").isObject()) {
|
||||
//这里应该是单独的线程去处理
|
||||
user.setId(getNodeText(result.get("id")));
|
||||
String band=getNodeText(result.get("bandCode"));
|
||||
if(StringUtils.isNotBlank(band) && band.length()>4) {
|
||||
String bandNum=band.substring(4);
|
||||
user.setBandLevel(Integer.valueOf(bandNum));
|
||||
}else {
|
||||
user.setBandLevel(0);
|
||||
}
|
||||
user.setAvatar("");
|
||||
user.setCode(getNodeText(result.get("userNo")));
|
||||
user.setDeleted(result.get("deleted").asBoolean());
|
||||
user.setDepartId(getNodeText(result.get("departId")));
|
||||
user.setDepartName("");//无此字段
|
||||
user.setGender(1);//少此字段
|
||||
user.setKid(getNodeText(result.get("kid")));
|
||||
user.setLearningDuration(result.get("learningDuration").asInt());
|
||||
user.setName(result.get("realName").asText());
|
||||
user.setOrgNamePath(result.get("orgNamePath").asText());
|
||||
user.setUserType(1);//直接设置为学员
|
||||
if(StringUtils.isBlank(user.getCode())) {
|
||||
log.error("通过接口获取当前用户信息【"+user.getId()+"】"+user.getName()+",工号为空,不能使用");
|
||||
throw new RuntimeException("通过接口获取当前用户信息,工号为空,不能使用");
|
||||
}
|
||||
|
||||
}
|
||||
return user;
|
||||
} catch (Exception e) {
|
||||
log.error("获取当前用户信息错误",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getBaseUrl(String url) {
|
||||
String baseUrl=SysConstant.getConfigValue("xboe.server.userbasic.url");
|
||||
if(StringUtils.isBlank(baseUrl)) {
|
||||
log.error("调用用户接口错误,未配置用户服务的地址【xboe.server.userbasic.url】");
|
||||
throw new RuntimeException("获取用户信息错误,未配置用户服务的地址");
|
||||
}
|
||||
String reqUrl= baseUrl+"/user/info";
|
||||
return reqUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.xboe.data.service;
|
||||
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.system.organization.entity.Organization;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.data.dto.UserData;
|
||||
|
||||
/**
|
||||
* 用户数据的更橷
|
||||
@@ -17,5 +15,5 @@ public interface IDataUserSyncService {
|
||||
* @param org
|
||||
* @return
|
||||
*/
|
||||
void syncUserFull(Account a,User u,Organization org);
|
||||
void syncUserFull(UserData user);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.xboe.data.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.account.dao.AccountDao;
|
||||
import com.xboe.account.entity.Account;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.service.IDataUserSyncService;
|
||||
import com.xboe.module.teacher.dao.TeacherDao;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
@@ -29,10 +33,81 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
||||
|
||||
@Autowired
|
||||
TeacherDao teacherDao;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void syncUserFull(Account a, User u, Organization org) {
|
||||
public void syncUserFull(UserData user) {
|
||||
|
||||
//先查询是否存在
|
||||
Account a=accountDao.get(user.getId());
|
||||
User u=userDao.get(user.getId());
|
||||
Organization org=null;
|
||||
if(a!=null) {
|
||||
//账户只是修改状态
|
||||
if(user.getDeleted()!=null) {
|
||||
a.setDeleted(user.getDeleted());
|
||||
}
|
||||
|
||||
}else {
|
||||
//新账户
|
||||
a=new Account();
|
||||
a.setDeleted(user.getDeleted());
|
||||
a.setSysId(user.getKid());
|
||||
a.setLoginName(user.getCode());
|
||||
a.setAvatar(user.getAvatar());
|
||||
a.setId(user.getId());
|
||||
a.setRegTime(LocalDateTime.now());
|
||||
a.setSysId(user.getKid());
|
||||
a.setStatus(1);
|
||||
}
|
||||
if(u!=null) {
|
||||
//更新部分用户字段
|
||||
u.setDepartId(user.getDepartId());
|
||||
u.setDepartName(user.getDepartName());
|
||||
u.setName(user.getName());
|
||||
//2022-12-8 去掉用户类型的更新,因为返回的数据都是学员,
|
||||
//u.setUserType(user.getUserType());
|
||||
if(user.getLearningDuration()>0) { //不大于0才会更新
|
||||
u.setLearningDuration(user.getLearningDuration());
|
||||
}
|
||||
}else {
|
||||
//新建用户
|
||||
u=new User();
|
||||
u.setId(user.getId());
|
||||
u.setDepartId(user.getDepartId());
|
||||
u.setDepartName(user.getDepartName());
|
||||
u.setDynamic(0);
|
||||
u.setGender(user.getGender());
|
||||
u.setName(user.getName());
|
||||
u.setSign("");
|
||||
u.setUserNo(user.getCode());
|
||||
u.setUserType(user.getUserType());
|
||||
u.setSysId(user.getKid());
|
||||
u.setStudyTotal(0);
|
||||
u.setLearningDuration(user.getLearningDuration());
|
||||
if(user.getBandLevel()!=null && user.getBandLevel()>15) {
|
||||
u.setShowHome(false);//band16及以上
|
||||
}else {
|
||||
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
||||
}
|
||||
|
||||
}
|
||||
//对机构的判断,不为空时才会处理,为空时不处理
|
||||
if(StringUtils.isNotBlank(user.getDepartId())) {
|
||||
org=orgDao.get(user.getDepartId());
|
||||
if(org==null) {
|
||||
org=new Organization();
|
||||
org.setCode("");
|
||||
org.setId(user.getDepartId());
|
||||
org.setName(user.getDepartName());
|
||||
org.setDeleted(false);
|
||||
org.setStatus(1);
|
||||
}
|
||||
org.setNamePath(user.getOrgNamePath());
|
||||
|
||||
}
|
||||
|
||||
accountDao.saveOrUpdate(a);
|
||||
userDao.saveOrUpdate(u);
|
||||
if(org!=null) {
|
||||
|
||||
@@ -223,11 +223,7 @@ public class Cases extends BaseEntity {
|
||||
@Column(name = "case_value")
|
||||
private String caseValue;
|
||||
|
||||
/**
|
||||
* 是否属于优秀案例
|
||||
* */
|
||||
@Column(name = "excellent")
|
||||
private Boolean excellent;
|
||||
|
||||
|
||||
/**
|
||||
* 设置时间
|
||||
|
||||
@@ -472,12 +472,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//同时添加发布事件,这里的创建人需要修改为教师
|
||||
Course c=courseDao.get(id);
|
||||
//删除分两种情况,一个是管理员删除,一个是自己删除 ,所以这里的处理移到前端了
|
||||
// if(eventSender!=null) {
|
||||
// eventSender.send("删除课程","DeleteCourse", "删除课程【"+c.getName()+"】", c.getId(), "1", c.getName(), c.getSysCreateAid(), c.getSysCreateBy(),"");
|
||||
// }else {
|
||||
// log.error("未配置事件消息发送的实现");
|
||||
// }
|
||||
//删除
|
||||
if(c.getFullTextId()!=null) {
|
||||
try {
|
||||
fullTextSearch.remove(ICourseFullTextSearch.DEFAULT_INDEX_NAME,c.getFullTextId());
|
||||
@@ -485,6 +479,26 @@ public class CourseServiceImpl implements ICourseService {
|
||||
log.error("删除课程时删除全文索引错误",e);
|
||||
}
|
||||
}
|
||||
//只有速有全文检索返回标识的,才算是发布过再删除的,删除消息
|
||||
if(StringUtils.isNotBlank(c.getFullTextId())){
|
||||
if(eventSender!=null) {
|
||||
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", id));
|
||||
if(teachers.size()>0) {
|
||||
String authorIds="";
|
||||
for(CourseTeacher cteacher:teachers) {
|
||||
if(authorIds.equals("")) {
|
||||
authorIds+=cteacher.getTeacherId();
|
||||
}else {
|
||||
authorIds+="|"+cteacher.getTeacherId();
|
||||
}
|
||||
}
|
||||
String txt="管理删除课程";
|
||||
eventSender.send(txt,"CourseDelete", "管理删除课程", c.getId(), "1", c.getName(), aid, name,"authors:"+authorIds);
|
||||
}
|
||||
}else {
|
||||
log.error("未配置事件消息发送的实现");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//彻底删除,课件设置为无课程状态
|
||||
courseDao.setDeleted(id);
|
||||
@@ -834,12 +848,23 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//发布到全文检索中
|
||||
Course c=courseDao.get(courseId);
|
||||
if(fullTextSearch!=null) {
|
||||
|
||||
this.fullTextPublish(c);
|
||||
}
|
||||
//同时添加发布事件,这里的创建人需要修改为教师
|
||||
if(eventSender!=null) {
|
||||
eventSender.send("发布课程","PublishCourse", "发布课程【"+c.getName()+"】", c.getId(), "1", c.getName(), c.getSysCreateAid(), c.getSysCreateBy(),"");
|
||||
List<CourseTeacher> teachers = courseTeacherDao.findList(FieldFilters.eq("courseId", courseId));
|
||||
if(teachers.size()>0) {
|
||||
String authorIds="";
|
||||
for(CourseTeacher cteacher:teachers) {
|
||||
if(authorIds.equals("")) {
|
||||
authorIds+=cteacher.getTeacherId();
|
||||
}else {
|
||||
authorIds+="|"+cteacher.getTeacherId();
|
||||
}
|
||||
}
|
||||
eventSender.send("发布课程","PublishCourse", "发布课程【"+c.getName()+"】", c.getId(), "1", c.getName(), aid,name,"authors:"+authorIds);
|
||||
}
|
||||
|
||||
}else {
|
||||
log.error("未配置事件消息发送的实现");
|
||||
}
|
||||
@@ -943,7 +968,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Override
|
||||
public List<CourseTeacher> findTeachersByCourseId(String courseId) {
|
||||
|
||||
return courseTeacherDao.findList(OrderCondition.desc("teacherName"),FieldFilters.eq("courseId", courseId));
|
||||
return courseTeacherDao.findList(OrderCondition.desc("teacherId"),FieldFilters.eq("courseId", courseId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -961,7 +986,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Override
|
||||
public List<CourseTeacher> findTeachersByCourseIds(List<String> ids) {
|
||||
|
||||
return courseTeacherDao.findList(OrderCondition.desc("teacherName"),FieldFilters.in("courseId",ids));
|
||||
return courseTeacherDao.findList(OrderCondition.desc("teacherId"),FieldFilters.in("courseId",ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.module.course.dao.CourseTeacherDao;
|
||||
@@ -39,7 +40,7 @@ public class CourseTeacherServiceImpl implements ICourseTeacherService {
|
||||
public CourseTeacherDto getTeacherByCourseId(String courseId) {
|
||||
CourseTeacherDto dto = null;
|
||||
|
||||
List<CourseTeacher> list = dao.findList(FieldFilters.eq("courseId",courseId));
|
||||
List<CourseTeacher> list = dao.findList(OrderCondition.desc("teacherId"),FieldFilters.eq("courseId",courseId));
|
||||
if(list != null && !list.isEmpty()){
|
||||
dto=new CourseTeacherDto();
|
||||
dto.setCourseId(courseId);
|
||||
@@ -60,7 +61,7 @@ public class CourseTeacherServiceImpl implements ICourseTeacherService {
|
||||
public List<CourseTeacherDto> queryTeacher(Collection<String> ids) {
|
||||
List<CourseTeacherDto> teacherDtos = null;
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
List<CourseTeacher> list = dao.findList(FieldFilters.in("courseId",ids));
|
||||
List<CourseTeacher> list = dao.findList(OrderCondition.desc("teacherId"),FieldFilters.in("courseId",ids));
|
||||
if(list != null && !list.isEmpty()) {
|
||||
teacherDtos = new ArrayList<>();
|
||||
for (String s : ids) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ExamUserTask extends IdBaseEntity{
|
||||
/**
|
||||
* 群组,受众id
|
||||
*/
|
||||
@Column(name = "group_id",nullable=false,length=20)
|
||||
@Column(name = "group_id",nullable=false,length=36)
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,13 +10,14 @@ import javax.transaction.Transactional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.exam.dao.AloneExamAnswerDao;
|
||||
import com.xboe.module.exam.dao.AloneExamDao;
|
||||
import com.xboe.module.exam.dao.ExamUserTaskDao;
|
||||
import com.xboe.module.exam.dto.ExamTestDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.entity.ExamPaper;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.module.exam.entity.ExamUserTask;
|
||||
import com.xboe.module.exam.service.IExamUserTaskService;
|
||||
@@ -41,6 +42,9 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
|
||||
@Resource
|
||||
AloneExamDao aloneExamDao;
|
||||
|
||||
@Resource
|
||||
IOutSideDataService outSideService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -54,13 +58,13 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
examUserTask.setTaskTime(LocalDateTime.now());
|
||||
examUserTask.setStatus(ExamUserTask.STATUS_FINISH);
|
||||
dao.save(examUserTask);
|
||||
// 下面的代码应该调用rePushTask
|
||||
//执行推送,当前因为是固定人,所以这里直接添加处理,按受众添加到每个人中
|
||||
//查询受众的信息
|
||||
List<UserGroupItem> items = ugroupDao.findList("groupId", task.getGroupId());
|
||||
if(items.size()>0) {
|
||||
//防止加入两条的问题,应该是先查询,再添加
|
||||
Map<String,Object> amap= aloneExamDao.findMap("aid", "name",FieldFilters.eq("testId", task.getTestId()));
|
||||
|
||||
//这里应该是单独的线程去处理
|
||||
for(UserGroupItem item :items) {
|
||||
if(amap.containsKey(item.getAid())) {
|
||||
@@ -90,7 +94,7 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
@Transactional
|
||||
public void rePushTask(ExamTestDto task) {
|
||||
//执行推送,当前因为是固定人,所以这里直接添加处理,按受众添加到每个人中
|
||||
//查询受众的信息
|
||||
//查询受众的信息,2022、11、30 这个的返回需要从接口获取人员信息,然后推送
|
||||
List<UserGroupItem> items = ugroupDao.findList("groupId", task.getGroupId());
|
||||
if(items.size()>0) {
|
||||
//防止加入两条的问题,应该是先查询,再添加
|
||||
@@ -115,6 +119,33 @@ public class ExamUserTaskServiceImpl implements IExamUserTaskService{
|
||||
aloneExamDao.save(aloneExam);
|
||||
}
|
||||
}
|
||||
|
||||
//调用用户服务的接口,在启用下面的代码前,需要
|
||||
// List<AudienceUser> sudienceUsers=outSideService.getUsersByAudienceId(task.getGroupId());
|
||||
// if(sudienceUsers.size()>0) {
|
||||
// //防止加入两条的问题,应该是先查询,再添加
|
||||
// Map<String,Object> amap= aloneExamDao.findMap("aid", "name",FieldFilters.eq("testId", task.getTestId()));
|
||||
// //这里应该是单独的线程去处理
|
||||
// for(AudienceUser item :sudienceUsers) {
|
||||
// if(amap.containsKey(item.getId())) {
|
||||
// continue;
|
||||
// }
|
||||
// //检查是否存在
|
||||
// AloneExam aloneExam = new AloneExam();
|
||||
// aloneExam.setAid(item.getId());
|
||||
// aloneExam.setTestId(task.getTestId());
|
||||
// aloneExam.setTestName(task.getTestName());
|
||||
// aloneExam.setName(item.getName());
|
||||
// aloneExam.setUcode(item.getCode());
|
||||
// aloneExam.setTestDuration(task.getDuration());
|
||||
// aloneExam.setTaskTime(LocalDateTime.now());
|
||||
// aloneExam.setStartTime(task.getStartTime());
|
||||
// aloneExam.setStatus(AloneExamAnswer.STATUS_NONE);//未考试过
|
||||
// aloneExam.setScore(0f);
|
||||
// aloneExamDao.save(aloneExam);
|
||||
// }
|
||||
// }
|
||||
|
||||
//examUserTask.setStatus(ExamUserTask.STATUS_FINISH);
|
||||
//dao.update(examUserTask);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class UserGroupItem extends IdEntity {
|
||||
/**
|
||||
* 受众ID
|
||||
*/
|
||||
@Column(name = "group_Id", nullable = false, length = 20)
|
||||
@Column(name = "group_Id", nullable = false, length = 36)
|
||||
private String groupId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||
public void finishCheck(String studyId,String courseId,Integer total){
|
||||
int n=scItemDao.count(FieldFilters.eq("studyId",studyId));
|
||||
if(total==null) {
|
||||
total=courseContentDao.count(FieldFilters.eq("courseId", courseId));
|
||||
total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
||||
}
|
||||
|
||||
//以下注意,float类型,是否等于100对应
|
||||
|
||||
@@ -58,7 +58,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
||||
assess.setStudyItemId(sci.getId());
|
||||
dao.save(assess);
|
||||
//检查是否全部学习完成
|
||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", assess.getCourseId()));
|
||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", assess.getCourseId()),FieldFilters.eq("deleted",false));
|
||||
scDao.finishCheck(assess.getStudyId(),assess.getCourseId(),totalContent);
|
||||
}else {
|
||||
//转为评估只有一条,所以这里显示一条,不能再增加
|
||||
|
||||
@@ -70,7 +70,7 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
||||
//更新最终成绩
|
||||
//if(exam.get)
|
||||
//检查是否全部学习完成
|
||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", exam.getCourseId()));
|
||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", exam.getCourseId()),FieldFilters.eq("deleted",false));
|
||||
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent);
|
||||
}else {
|
||||
exam.setStudyItemId(obj.toString());//此项就是学习条目的id
|
||||
|
||||
@@ -60,7 +60,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
||||
homework.setStudyItemId(sci.getId());
|
||||
dao.save(homework);
|
||||
//检查是否全部学习完成
|
||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", homework.getCourseId()));
|
||||
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", homework.getCourseId()),FieldFilters.eq("deleted",false));
|
||||
scDao.finishCheck(homework.getStudyId(),homework.getCourseId(),totalContent);
|
||||
}else {
|
||||
//只是保留一条作业记录,不再保存多条记录了
|
||||
|
||||
@@ -35,7 +35,7 @@ public class EventDataSender implements IEventDataSender{
|
||||
|
||||
@Override
|
||||
public void send(String title, String eventKey, String content, String objId, String objType, String objInfo,
|
||||
String aid, String aname,String author) {
|
||||
String aid, String aname,String parameters) {
|
||||
String statBaseUrl=SysConstant.getConfigValue("xboe.stat.base.url");
|
||||
if(StringUtils.isBlank(statBaseUrl)) {
|
||||
log.error("发送事件失败:未配置【xboe.stat.base.url】的值");
|
||||
@@ -58,7 +58,7 @@ public class EventDataSender implements IEventDataSender{
|
||||
params.put("objInfo", objInfo);
|
||||
params.put("aid", aid);
|
||||
params.put("aname", aname);
|
||||
params.put("parameters","");
|
||||
params.put("parameters",parameters);
|
||||
String token = TokenProxy.getToken(request);
|
||||
//最后采用异常发送,不影响当前进程
|
||||
|
||||
|
||||
@@ -81,24 +81,6 @@ public class SysLoginApi extends ApiBaseController {
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@GetMapping("/login/send")
|
||||
public JsonResponse<Map<String, String>> sendMessage() {
|
||||
Map<String, String> rs=new HashMap<String, String>();
|
||||
|
||||
if(eventSender!=null) {
|
||||
try {
|
||||
eventSender.send("测试消息","keykey", "all测试消息","1231231", "1", "aaaa", "asdqadqw","wqwrqre","");
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return error("发送失败"+e.getMessage());
|
||||
}
|
||||
}else {
|
||||
//log.error();
|
||||
return error("未配置事件消息发送的实现");
|
||||
}
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名和密码登录
|
||||
*
|
||||
@@ -117,6 +99,9 @@ public class SysLoginApi extends ApiBaseController {
|
||||
if (!code.toLowerCase().equals(verCode)) {
|
||||
return error("验证码错误");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检查系统用户是否存在
|
||||
Account account = accountService.check(loginName,null);
|
||||
String passStr = "";
|
||||
@@ -124,8 +109,27 @@ public class SysLoginApi extends ApiBaseController {
|
||||
passStr = MD5Util.MD5Encode(password + account.getPassKey());
|
||||
}
|
||||
|
||||
// 从redis缓存中获取5分钟内登陆错误的次数
|
||||
String loginErrorNum = redisTemplate.opsForValue().get(CacheName.NAME_USER_LOGIN_ERROR_NUM+account);
|
||||
Integer loginErrorCount = 0;
|
||||
if(loginErrorNum != null){
|
||||
loginErrorCount = Integer.parseInt(loginErrorNum);
|
||||
}
|
||||
|
||||
if (account == null || StringUtil.isBlank(passStr) || !passStr.equals(account.getPassValue())) {
|
||||
return error("用户名或密码错误");
|
||||
if(loginErrorCount >=5){
|
||||
redisTemplate.opsForValue().set(CacheName.NAME_USER_LOGIN_ERROR_NUM+account, "5", 5, TimeUnit.MINUTES);
|
||||
return error("由于您登录失败次数过多,账号已被锁定!");
|
||||
}else{
|
||||
loginErrorCount = loginErrorCount + 1;
|
||||
redisTemplate.opsForValue().set(CacheName.NAME_USER_LOGIN_ERROR_NUM+account, loginErrorCount+"", 5, TimeUnit.MINUTES);
|
||||
int next = (6-loginErrorCount);
|
||||
if(next == 0){
|
||||
return error("账号已被锁定");
|
||||
}
|
||||
return error("用户名或密码错误,您还有"+(6-loginErrorCount)+"次登录机会");
|
||||
}
|
||||
// return error("用户名或密码错误");
|
||||
}
|
||||
|
||||
if (account.getStatus().equals(Constants.ACCOUNT_STATUS_DEACTIVATE)) {
|
||||
|
||||
@@ -43,6 +43,8 @@ xboe.externalinterface.url.system=http://localhost:9091
|
||||
## 新增加的教师的内部调用接口
|
||||
xboe.old.base.url=https://u-pre.boe.com
|
||||
|
||||
xboe.server.userbasic.url=https://u-pre.boe.com/userbasic
|
||||
|
||||
## 用户统计接口的api地址
|
||||
xboe.stat.base.url=http://127.0.0.1:9080
|
||||
|
||||
|
||||
Reference in New Issue
Block a user