|
|
|
@ -0,0 +1,447 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.EnumUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.util.TimeTool;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
|
import com.ibeetl.jlw.dao.StudentTeacherSystemUseLogAnalysisDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.StudentTeacherSystemUseLogAnalysisAddDTO;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.SystemUseLogsAnalysisDTO;
|
|
|
|
|
import com.ibeetl.jlw.entity.vo.SystemUseLogsAnalysisVO;
|
|
|
|
|
import com.ibeetl.jlw.web.query.StudentTeacherSystemUseLogAnalysisQuery;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.beetl.sql.annotation.entity.EnumValue;
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static cn.hutool.core.collection.IterUtil.getFirst;
|
|
|
|
|
import static cn.hutool.core.date.DateTime.now;
|
|
|
|
|
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
|
|
|
|
|
import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生教师行为分析 Service
|
|
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Transactional
|
|
|
|
|
@Validated
|
|
|
|
|
public class StudentTeacherSystemUseLogAnalysisService extends CoreBaseService<StudentTeacherSystemUseLogAnalysis>{
|
|
|
|
|
|
|
|
|
|
@Autowired private StudentTeacherSystemUseLogAnalysisDao studentTeacherSystemUseLogAnalysisDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentService studentService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherService teacherService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private UniversitiesCollegesService universitiesCollegesService;
|
|
|
|
|
|
|
|
|
|
public PageQuery<StudentTeacherSystemUseLogAnalysis>queryByCondition(PageQuery query){
|
|
|
|
|
PageQuery ret = studentTeacherSystemUseLogAnalysisDao.queryByCondition(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<StudentTeacherSystemUseLogAnalysis>queryByConditionQuery(PageQuery query){
|
|
|
|
|
PageQuery ret = studentTeacherSystemUseLogAnalysisDao.queryByConditionQuery(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteByList(List list){
|
|
|
|
|
String ids = "";
|
|
|
|
|
ToolUtils.deleteNullList(list);
|
|
|
|
|
for(int i=0;null != list && i<list.size();i++){
|
|
|
|
|
ids += list.get(i).toString()+(i==list.size()-1?"":",");
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
studentTeacherSystemUseLogAnalysisDao.deleteStudentTeacherSystemUseLogAnalysisByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteStudentTeacherSystemUseLogAnalysis(String ids){
|
|
|
|
|
try {
|
|
|
|
|
studentTeacherSystemUseLogAnalysisDao.deleteStudentTeacherSystemUseLogAnalysisByIds(ids);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new PlatformException("批量删除学生教师行为分析失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String addAll(StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
List<StudentTeacherSystemUseLogAnalysis> studentTeacherSystemUseLogAnalysisList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
studentTeacherSystemUseLogAnalysisList = JSON.parseArray(studentTeacherSystemUseLogAnalysisQuery.getStudentTeacherSystemUseLogAnalysisJsonStr(), StudentTeacherSystemUseLogAnalysis.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
try {
|
|
|
|
|
studentTeacherSystemUseLogAnalysisList.add(JSONObject.parseObject(studentTeacherSystemUseLogAnalysisQuery.getStudentTeacherSystemUseLogAnalysisJsonStr(), StudentTeacherSystemUseLogAnalysis.class));
|
|
|
|
|
} catch (Exception e1) {}
|
|
|
|
|
}
|
|
|
|
|
ToolUtils.deleteNullList(studentTeacherSystemUseLogAnalysisList);
|
|
|
|
|
if(null != studentTeacherSystemUseLogAnalysisList && studentTeacherSystemUseLogAnalysisList.size()>0){
|
|
|
|
|
for(int i=0;i<studentTeacherSystemUseLogAnalysisList.size();i++){
|
|
|
|
|
StudentTeacherSystemUseLogAnalysis studentTeacherSystemUseLogAnalysis = studentTeacherSystemUseLogAnalysisList.get(i);
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setUserId(studentTeacherSystemUseLogAnalysisQuery.getUserId());
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setOrgId(studentTeacherSystemUseLogAnalysisQuery.getOrgId());
|
|
|
|
|
}
|
|
|
|
|
insertBatch(studentTeacherSystemUseLogAnalysisList);
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult add(StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
StudentTeacherSystemUseLogAnalysis studentTeacherSystemUseLogAnalysis = studentTeacherSystemUseLogAnalysisQuery.pojo();
|
|
|
|
|
studentTeacherSystemUseLogAnalysisDao.insert(studentTeacherSystemUseLogAnalysis);
|
|
|
|
|
studentTeacherSystemUseLogAnalysisQuery.setId(studentTeacherSystemUseLogAnalysis.getId());
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
|
|
jsonResult.setData(studentTeacherSystemUseLogAnalysis.getId());//自增的ID丢进去
|
|
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
|
|
jsonResult.setMsg(msg);
|
|
|
|
|
return jsonResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String edit(StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
StudentTeacherSystemUseLogAnalysis studentTeacherSystemUseLogAnalysis = studentTeacherSystemUseLogAnalysisQuery.pojo();
|
|
|
|
|
studentTeacherSystemUseLogAnalysisDao.updateTemplateById(studentTeacherSystemUseLogAnalysis);
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String updateGivenByIds(StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
if(StringUtils.isNotBlank(studentTeacherSystemUseLogAnalysisQuery.get_given())){
|
|
|
|
|
boolean flag = studentTeacherSystemUseLogAnalysisDao.updateGivenByIds(studentTeacherSystemUseLogAnalysisQuery) > 0;
|
|
|
|
|
if(!flag){
|
|
|
|
|
msg = "更新指定参数失败";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
msg = "指定参数为空";
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<StudentTeacherSystemUseLogAnalysis> getValues (Object paras){
|
|
|
|
|
return sqlManager.select(SqlId.of("jlw.studentTeacherSystemUseLogAnalysis.getStudentTeacherSystemUseLogAnalysisValues"), StudentTeacherSystemUseLogAnalysis.class, paras);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<StudentTeacherSystemUseLogAnalysis> getValuesByQuery (StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
return studentTeacherSystemUseLogAnalysisDao.getValuesByQuery(studentTeacherSystemUseLogAnalysisQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<StudentTeacherSystemUseLogAnalysis> getValuesByQueryNotWithPermission (StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
return studentTeacherSystemUseLogAnalysisDao.getValuesByQueryNotWithPermission(studentTeacherSystemUseLogAnalysisQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StudentTeacherSystemUseLogAnalysis getInfo (String id){
|
|
|
|
|
StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery = new StudentTeacherSystemUseLogAnalysisQuery();
|
|
|
|
|
studentTeacherSystemUseLogAnalysisQuery.setId(id);
|
|
|
|
|
List<StudentTeacherSystemUseLogAnalysis> list = studentTeacherSystemUseLogAnalysisDao.getValuesByQuery(studentTeacherSystemUseLogAnalysisQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StudentTeacherSystemUseLogAnalysis getInfo (StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
List<StudentTeacherSystemUseLogAnalysis> list = studentTeacherSystemUseLogAnalysisDao.getValuesByQuery(studentTeacherSystemUseLogAnalysisQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JsonResult importTemplate(List<FileEntity> fileEntityList,List<Long>list,CoreUser coreUser){
|
|
|
|
|
List<String[]>errMsg = new ArrayList<>();
|
|
|
|
|
String msg ="";
|
|
|
|
|
int count = 0;
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
for(int item=0;null != fileEntityList && item<fileEntityList.size();item++){
|
|
|
|
|
FileEntity fileEntity = fileEntityList.get(item);
|
|
|
|
|
if(null != fileEntity){
|
|
|
|
|
File file = new File(fileEntity.getAbsoluteUrl());
|
|
|
|
|
if(file.exists() && file.isFile() && file.canRead() && ToolUtils.findInSet("xls,xlsx",fileEntity.getFormat())){
|
|
|
|
|
Workbook wb = null;
|
|
|
|
|
InputStream is = null;
|
|
|
|
|
try {
|
|
|
|
|
is = new FileInputStream(fileEntity.getAbsoluteUrl());
|
|
|
|
|
if("xls".equals(fileEntity.getFormat())){
|
|
|
|
|
wb = new HSSFWorkbook(is);
|
|
|
|
|
}else if("xlsx".equals(fileEntity.getFormat())){
|
|
|
|
|
wb = new XSSFWorkbook(is);
|
|
|
|
|
}
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
if(null != is){
|
|
|
|
|
is.close();
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if(wb != null){
|
|
|
|
|
//获取Sheet1
|
|
|
|
|
Sheet sheet = wb.getSheet("Sheet1");
|
|
|
|
|
//获取最大行数
|
|
|
|
|
int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
|
|
//获取第一行
|
|
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
|
|
//获取最大列数
|
|
|
|
|
int colNum = firstRow.getPhysicalNumberOfCells();
|
|
|
|
|
|
|
|
|
|
String columns[] = {
|
|
|
|
|
"一级名称",
|
|
|
|
|
"二级名称",
|
|
|
|
|
"院校名称",
|
|
|
|
|
"院校",
|
|
|
|
|
"用户类型 UserTypeEnum",
|
|
|
|
|
"所在省份",
|
|
|
|
|
"日期",
|
|
|
|
|
"使用时长",
|
|
|
|
|
"创建时间",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Map<String,Integer> map = new HashMap<>();//获取需要的表头的列
|
|
|
|
|
|
|
|
|
|
//从第一列找到需要的表头
|
|
|
|
|
for (int i=0; i<colNum; i++){
|
|
|
|
|
String cellData = getCellFormatValue(firstRow.getCell(i));
|
|
|
|
|
for(int j=0;j<columns.length;j++){
|
|
|
|
|
if(columns[j].equals(cellData)){
|
|
|
|
|
map.put(columns[j],i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//验证所需要的表头是否全
|
|
|
|
|
Integer flag = 0;
|
|
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
|
|
if(null != map.get(columns[i])){
|
|
|
|
|
flag ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(flag != columns.length){
|
|
|
|
|
String str = " ";
|
|
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
|
|
str += "\""+columns[i]+"\""+(i == columns.length-1?"":", ");
|
|
|
|
|
}
|
|
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含"+str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i<rowNum; i++) {
|
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
|
if(null == row){
|
|
|
|
|
errMsg.add(new String[]{"第"+(i+1)+"数据为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String firstName = getCellFormatValue(row.getCell(map.get(columns[0])));
|
|
|
|
|
String secondName = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
|
|
String universitiesCollegesName = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
|
|
String universitiesCollegesId = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
|
|
String userType = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
|
|
String province = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
|
|
String dayTime = getCellFormatValue(row.getCell(map.get(columns[6])));
|
|
|
|
|
String useDuration = getCellFormatValue(row.getCell(map.get(columns[7])));
|
|
|
|
|
String addTime = getCellFormatValue(row.getCell(map.get(columns[8])));
|
|
|
|
|
//TODO 判断(如重复等复杂判断要额外写)
|
|
|
|
|
if(StringUtils.isBlank(firstName)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[0])+1)+"列,第"+(i+1)+"行一级名称为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(secondName)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行二级名称为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(universitiesCollegesName)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[2])+1)+"列,第"+(i+1)+"行院校名称为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(universitiesCollegesId)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[3])+1)+"列,第"+(i+1)+"行院校为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(userType)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[4])+1)+"列,第"+(i+1)+"行用户类型 UserTypeEnum为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(province)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[5])+1)+"列,第"+(i+1)+"行所在省份为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(dayTime)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[6])+1)+"列,第"+(i+1)+"行日期为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(useDuration)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[7])+1)+"列,第"+(i+1)+"行使用时长为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
if(StringUtils.isBlank(addTime)){
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[8])+1)+"列,第"+(i+1)+"行创建时间为空"});
|
|
|
|
|
continue;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
//TODO 保存
|
|
|
|
|
StudentTeacherSystemUseLogAnalysis studentTeacherSystemUseLogAnalysis = new StudentTeacherSystemUseLogAnalysis();
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setFirstName(firstName);
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setSecondName(secondName);
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setUniversitiesCollegesName(universitiesCollegesName);
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setUniversitiesCollegesId(Long.parseLong(universitiesCollegesId));
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setUserType(EnumUtil.likeValueOf(UseTypeEnum.class, userType));
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setProvince(province);
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setDayTime(dayTime);
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setUseDuration(Long.parseLong(useDuration));
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setAddTime(TimeTool.getTime(addTime));
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setOrgId(coreUser.getOrgId());
|
|
|
|
|
studentTeacherSystemUseLogAnalysis.setUserId(coreUser.getId());
|
|
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
|
|
jsonResult.setCode(count>0?JsonReturnCode.SUCCESS.getCode():JsonReturnCode.FAIL.getCode());
|
|
|
|
|
jsonResult.setData(errMsg);
|
|
|
|
|
jsonResult.setMsg((count>0?"导入成功,共导入"+count+"条":"导入失败")+(StringUtils.isNotBlank(msg)?"<br>"+msg:""));
|
|
|
|
|
return jsonResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> getExcelValues (StudentTeacherSystemUseLogAnalysisQuery studentTeacherSystemUseLogAnalysisQuery){
|
|
|
|
|
return studentTeacherSystemUseLogAnalysisDao.getExcelValues(studentTeacherSystemUseLogAnalysisQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询使用记录,院校级别的统计。不关心哪个用户
|
|
|
|
|
* @param page
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public PageQuery<SystemUseLogsAnalysisVO> applicationUseLogsAnalysis(PageQuery<SystemUseLogsAnalysisDTO> page) {
|
|
|
|
|
return studentTeacherSystemUseLogAnalysisDao.applicationUseLogsAnalysis(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户类型
|
|
|
|
|
*/
|
|
|
|
|
@Getter
|
|
|
|
|
public enum UseTypeEnum {
|
|
|
|
|
|
|
|
|
|
STUDENT("学生"), TEACHER("教师");
|
|
|
|
|
|
|
|
|
|
@EnumValue
|
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
UseTypeEnum(String name) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addOrUpdateUseLog(StudentTeacherSystemUseLogAnalysisAddDTO dto, CoreUser coreUser) {
|
|
|
|
|
// 追加的使用时长
|
|
|
|
|
Long appendUseDuration = defaultIfNull(dto.getUseDuration(), 5L);
|
|
|
|
|
final String firstName = dto.getFirstName().trim();
|
|
|
|
|
final String secondName = dto.getSecondName().trim();
|
|
|
|
|
final Long userId = coreUser.getId();
|
|
|
|
|
final Long orgId = coreUser.getOrgId();
|
|
|
|
|
final String today = DateUtil.today();
|
|
|
|
|
// 院校名称
|
|
|
|
|
String universitiesCollegesName = "";
|
|
|
|
|
// 院校ID
|
|
|
|
|
Long universitiesCollegesId = null;
|
|
|
|
|
// 院校所在省
|
|
|
|
|
String province = null;
|
|
|
|
|
// 用户类型
|
|
|
|
|
UseTypeEnum useType = null;
|
|
|
|
|
|
|
|
|
|
// 查询唯一的条件,如果没查到那肯定是要新增一条数据咯
|
|
|
|
|
StudentTeacherSystemUseLogAnalysisQuery query = new StudentTeacherSystemUseLogAnalysisQuery();
|
|
|
|
|
query.setFirstName(firstName);
|
|
|
|
|
query.setSecondName(secondName);
|
|
|
|
|
query.setUserId(userId);
|
|
|
|
|
query.setOrgId(orgId);
|
|
|
|
|
query.setDayTime(today);
|
|
|
|
|
|
|
|
|
|
// 追加院校ID条件
|
|
|
|
|
if (coreUser.isStudent()) {
|
|
|
|
|
Student student = studentService.getByUserId(userId);
|
|
|
|
|
useType = UseTypeEnum.STUDENT;
|
|
|
|
|
if (student != null) {
|
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getUniversitiesCollegesByStudent(student);
|
|
|
|
|
province = universitiesColleges.getUniversitiesCollegesProvince();
|
|
|
|
|
universitiesCollegesId = universitiesColleges.getUniversitiesCollegesId();
|
|
|
|
|
universitiesCollegesName = universitiesColleges.getUniversitiesCollegesName();
|
|
|
|
|
query.setUniversitiesCollegesId(universitiesCollegesId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (coreUser.isTeacher()) {
|
|
|
|
|
Teacher teacher = teacherService.getByUserId(userId);
|
|
|
|
|
useType = UseTypeEnum.TEACHER;
|
|
|
|
|
if (teacher != null) {
|
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getUniversitiesCollegesByTeacher(teacher);
|
|
|
|
|
province = universitiesColleges.getUniversitiesCollegesProvince();
|
|
|
|
|
universitiesCollegesId = universitiesColleges.getUniversitiesCollegesId();
|
|
|
|
|
universitiesCollegesName = universitiesColleges.getUniversitiesCollegesName();
|
|
|
|
|
query.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<StudentTeacherSystemUseLogAnalysis> logAnalysisList = getValuesByQueryNotWithPermission(query);
|
|
|
|
|
|
|
|
|
|
// 如果查询到数据,则追加使用时长(分钟)
|
|
|
|
|
if (CollectionUtil.isNotEmpty(logAnalysisList)) {
|
|
|
|
|
StudentTeacherSystemUseLogAnalysis logAnalysis = getFirst(logAnalysisList);
|
|
|
|
|
logAnalysis.setUseDuration(defaultIfNull(logAnalysis.getUseDuration(), 0L) + appendUseDuration);
|
|
|
|
|
updateTemplate(logAnalysis);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 否则新增一条数据
|
|
|
|
|
else {
|
|
|
|
|
StudentTeacherSystemUseLogAnalysis useLogAnalysis = new StudentTeacherSystemUseLogAnalysis();
|
|
|
|
|
useLogAnalysis.setFirstName(firstName);
|
|
|
|
|
useLogAnalysis.setSecondName(secondName);
|
|
|
|
|
useLogAnalysis.setUniversitiesCollegesName(universitiesCollegesName);
|
|
|
|
|
useLogAnalysis.setUniversitiesCollegesId(universitiesCollegesId);
|
|
|
|
|
useLogAnalysis.setUserType(useType);
|
|
|
|
|
useLogAnalysis.setProvince(province);
|
|
|
|
|
useLogAnalysis.setDayTime(today);
|
|
|
|
|
useLogAnalysis.setUseDuration(appendUseDuration);
|
|
|
|
|
useLogAnalysis.setAddTime(now());
|
|
|
|
|
useLogAnalysis.setOrgId(orgId);
|
|
|
|
|
useLogAnalysis.setUserId(userId);
|
|
|
|
|
|
|
|
|
|
insert(useLogAnalysis);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|