Commit deb845f7 authored by YangZhaoJun1's avatar YangZhaoJun1

Merge branch 'V2.0.3' of http://103.249.252.28:90/lcy/education into V2.0.3

parents 944c288c e746c5c6
...@@ -145,7 +145,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -145,7 +145,7 @@ public class BClassServiceImpl implements BClassService {
public PersistModel administrativeImportExcel(HSSFWorkbook hwb, String token) throws IOException { public PersistModel administrativeImportExcel(HSSFWorkbook hwb, String token) throws IOException {
ArrayList<BClass> bClasses = new ArrayList<BClass>(); ArrayList<BClass> bClasses = new ArrayList<BClass>();
ArrayList<String> repeatCode = new ArrayList<String>(); ArrayList<String> repeatCode = new ArrayList<String>();
String innerRepeatResult = "";
String[] headers = {"班级编号","学号","所属年级"}; String[] headers = {"班级编号","学号","所属年级"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
//判断年级是否存在 //判断年级是否存在
...@@ -155,7 +155,8 @@ public class BClassServiceImpl implements BClassService { ...@@ -155,7 +155,8 @@ public class BClassServiceImpl implements BClassService {
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
} }
for(String[] value:values){ //将数据封装到entity //外循环
outLoop : for(String[] value:values){ //将数据封装到entity
BClass bClass = null; BClass bClass = null;
BClass b = new BClass(value[0]); BClass b = new BClass(value[0]);
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){ if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
...@@ -172,6 +173,13 @@ public class BClassServiceImpl implements BClassService { ...@@ -172,6 +173,13 @@ public class BClassServiceImpl implements BClassService {
valuesGrade.add(value[2]); valuesGrade.add(value[2]);
continue; continue;
} }
//表中去重
for(BClass bClass1 : bClasses){
if(b1.getCode().equals(bClass1.getCode())){
innerRepeatResult += "编号 " + b1.getCode() + " 在Excel中重复出现,除第一条以外的数据插入失败 ";
continue outLoop;
}
}
bClass= new BClass(value[0],value[1]); bClass= new BClass(value[0],value[1]);
bClass.setGradeCode(value[2]); bClass.setGradeCode(value[2]);
...@@ -197,7 +205,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -197,7 +205,7 @@ public class BClassServiceImpl implements BClassService {
result+="以下班级的所属年级信息不存在:"+ JSON.toJSONString(valuesGrade)+"。"; result+="以下班级的所属年级信息不存在:"+ JSON.toJSONString(valuesGrade)+"。";
} }
return new PersistModel(line,result); return new PersistModel(line,result + innerRepeatResult);
} }
@Override @Override
...@@ -205,7 +213,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -205,7 +213,7 @@ public class BClassServiceImpl implements BClassService {
ArrayList<BClass> bClasses = new ArrayList<BClass>(); ArrayList<BClass> bClasses = new ArrayList<BClass>();
ArrayList<String> repeatCode = new ArrayList<String>(); ArrayList<String> repeatCode = new ArrayList<String>();
ArrayList<String> AgencyCode = new ArrayList<String>(); ArrayList<String> AgencyCode = new ArrayList<String>();
String innerRepeatResult = "";
String[] headers = {"班级编号","班级名称","所属年级","教学单位"}; String[] headers = {"班级编号","班级名称","所属年级","教学单位"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
//判断年级是否存在 //判断年级是否存在
...@@ -215,7 +223,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -215,7 +223,7 @@ public class BClassServiceImpl implements BClassService {
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
} }
for(String[] value:values){ //将数据封装到entity outLoop : for(String[] value:values){ //将数据封装到entity
BClass bClass = null; BClass bClass = null;
BClass b = new BClass(value[0]); BClass b = new BClass(value[0]);
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){ if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
...@@ -246,6 +254,13 @@ public class BClassServiceImpl implements BClassService { ...@@ -246,6 +254,13 @@ public class BClassServiceImpl implements BClassService {
bClass.setType("1"); bClass.setType("1");
bClass.setCommonBusinessId(); bClass.setCommonBusinessId();
UserUtil.setCurrentPersistOperation(bClass); UserUtil.setCurrentPersistOperation(bClass);
//表中去重
for(BClass bClass1 : bClasses){
if(b1.getBusinessId().equals(bClass1.getBusinessId())){
innerRepeatResult += "班级编号 " + b1.getBusinessId() + " 在Excel中重复出现,除第一条以外的数据插入失败 ";
continue outLoop;
}
}
if(!bClasses.contains(bClass)){ if(!bClasses.contains(bClass)){
bClasses.add(bClass); bClasses.add(bClass);
...@@ -269,7 +284,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -269,7 +284,7 @@ public class BClassServiceImpl implements BClassService {
result+="以下教学单位不存在:"+ JSON.toJSONString(AgencyCode)+"。"; result+="以下教学单位不存在:"+ JSON.toJSONString(AgencyCode)+"。";
} }
return new PersistModel(line,result); return new PersistModel(line,result + innerRepeatResult);
} }
@Override @Override
......
...@@ -115,7 +115,8 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -115,7 +115,8 @@ public class BLessonServiceImpl implements BLessonService {
ArrayList<String> direction = new ArrayList<String>(); ArrayList<String> direction = new ArrayList<String>();
List<String> isChinese = new ArrayList<>(); List<String> isChinese = new ArrayList<>();
List<String> isNegative = new ArrayList<>(); List<String> isNegative = new ArrayList<>();
List<String> currentlyCode = new ArrayList<>();
String innerRepeatResult = "";
String[] headers = {"课程编号","课程名称","课程方向编号","学时","学分"}; String[] headers = {"课程编号","课程名称","课程方向编号","学时","学分"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
...@@ -159,8 +160,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -159,8 +160,13 @@ public class BLessonServiceImpl implements BLessonService {
bLesson= new BLesson(value[0],value[1],value[3],value[4]); bLesson= new BLesson(value[0],value[1],value[3],value[4]);
bLesson.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION()); bLesson.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION());
UserUtil.setCurrentPersistOperation(bLesson); UserUtil.setCurrentPersistOperation(bLesson);
//表中去重
if(currentlyCode.contains(bLesson.getCode())){
innerRepeatResult += "编号 " + value[1] + " 在Excel中重复出现,除第一条以外的数据插入失败 \n";
continue;
}
if(!lessons.contains(bLesson)){ if(!lessons.contains(bLesson)){
currentlyCode.add(bLesson.getCode());
lessons.add(bLesson); lessons.add(bLesson);
BLessonDirection bDirection = new BLessonDirection(); BLessonDirection bDirection = new BLessonDirection();
...@@ -203,7 +209,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -203,7 +209,7 @@ public class BLessonServiceImpl implements BLessonService {
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result);
} }
return new PersistModel(1,result); return new PersistModel(1,result + innerRepeatResult);
} }
......
...@@ -86,7 +86,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -86,7 +86,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
ArrayList<String> classCode = new ArrayList<String>(); ArrayList<String> classCode = new ArrayList<String>();
ArrayList<String> repeatCode = new ArrayList<String>(); ArrayList<String> repeatCode = new ArrayList<String>();
List<String> valuesGrade = new ArrayList<>(); List<String> valuesGrade = new ArrayList<>();
List<String> currenty = new ArrayList<>();
String innerRepeatResult = "";
String[] headers = {"班级编号","学号"}; String[] headers = {"班级编号","学号"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
...@@ -127,10 +128,16 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -127,10 +128,16 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
//1.4 构造学生班级信息 //1.4 构造学生班级信息
brClassStudent= new BRClassStudent(value[0],value[1]); brClassStudent= new BRClassStudent(value[0],value[1]);
if(currenty.contains(brClassStudent.toString())){
innerRepeatResult += "班级编号,学号分别为 " + value[0] + " " + value[1] + " 的数据,在Excel中重复出现,除第一条以外的数据插入失败 \n";
continue;
}
currenty.add(brClassStudent.toString());
brClassStudent.setCommonBusinessId(); brClassStudent.setCommonBusinessId();
//UserUtils.setCurrentPersistOperation(brClassStudent); //UserUtils.setCurrentPersistOperation(brClassStudent);
if(!brClassStudents.contains(brClassStudent)){ if(!brClassStudents.contains(brClassStudent)){
brClassStudents.add(brClassStudent); brClassStudents.add(brClassStudent);
} }
} }
...@@ -174,7 +181,7 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -174,7 +181,7 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
int l1 = MapUtils.getInteger(map,"result",-2); int l1 = MapUtils.getInteger(map,"result",-2);
if(l1<=0) if(l1<=0)
throw new ServiceException(ResultServiceEnums.UPDATE_STUDENT_NUM_ERROR); throw new ServiceException(ResultServiceEnums.UPDATE_STUDENT_NUM_ERROR);
return new PersistModel(1,result.toString()); return new PersistModel(1,result.toString() + innerRepeatResult);
} }
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
......
...@@ -87,7 +87,8 @@ public class BRSlStudentServiceImpl implements BRSlStudentService { ...@@ -87,7 +87,8 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
ArrayList<String> studentCode = new ArrayList<String>(); ArrayList<String> studentCode = new ArrayList<String>();
/*ArrayList<String> gitlabP = new ArrayList<String>(); /*ArrayList<String> gitlabP = new ArrayList<String>();
ArrayList<String> gitlabUser = new ArrayList<String>();*/ ArrayList<String> gitlabUser = new ArrayList<String>();*/
String innerRepeatResult = "";
List<String> currently = new ArrayList<>();
String[] headers = {"课序号","学号"}; String[] headers = {"课序号","学号"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
...@@ -144,9 +145,14 @@ public class BRSlStudentServiceImpl implements BRSlStudentService { ...@@ -144,9 +145,14 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
//3.封装学生选课信息 //3.封装学生选课信息
brSlStudent= new BRSlStudent(value[1],value[0]); brSlStudent= new BRSlStudent(value[1],value[0]);
if(currently.contains(brSlStudent.toString())){
innerRepeatResult += "课序号,学号分别为 " + value[0] + " " + value[1] + " 的数据,在Excel中重复出现,除第一条以外的数据插入失败 \n";
continue;
}
currently.add(brSlStudent.toString());
brSlStudent.setBusinessId(IdGen.uuid()); brSlStudent.setBusinessId(IdGen.uuid());
if(!brSlStudents.contains(brSlStudent)){ if(!brSlStudents.contains(brSlStudent)){
brSlStudents.add(brSlStudent); brSlStudents.add(brSlStudent);
} }
} }
...@@ -180,12 +186,11 @@ public class BRSlStudentServiceImpl implements BRSlStudentService { ...@@ -180,12 +186,11 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
}*/ }*/
result+=nullResult; result+=nullResult;
if(brSlStudents.size()<1){ if(brSlStudents.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result);
} }
return new PersistModel(1,result+nullResult.toString()); return new PersistModel(1,result+nullResult.toString() + innerRepeatResult);
} }
static String sub(String str) { static String sub(String str) {
......
...@@ -156,6 +156,8 @@ public class BSlServiceImpl implements BSlService { ...@@ -156,6 +156,8 @@ public class BSlServiceImpl implements BSlService {
ArrayList<String> lessonCode = new ArrayList<String>(); ArrayList<String> lessonCode = new ArrayList<String>();
ArrayList<String> teacherCode = new ArrayList<String>(); ArrayList<String> teacherCode = new ArrayList<String>();
ArrayList<String> termCode = new ArrayList<String>(); ArrayList<String> termCode = new ArrayList<String>();
List<String> currentlyCode = new ArrayList<>();
String innerRepeatResult = "";
//ArrayList<String> direction = new ArrayList<String>(); //ArrayList<String> direction = new ArrayList<String>();
//List<BSl> repeatSl = new ArrayList<>(); //List<BSl> repeatSl = new ArrayList<>();
Map map = new HashMap(); Map map = new HashMap();
...@@ -218,11 +220,18 @@ public class BSlServiceImpl implements BSlService { ...@@ -218,11 +220,18 @@ public class BSlServiceImpl implements BSlService {
bSl.setSlCoverUrl(bLesson.getDefaultUrl()); bSl.setSlCoverUrl(bLesson.getDefaultUrl());
bSl.setCredits(bLesson.getCredits()); bSl.setCredits(bLesson.getCredits());
bSl.setClassHour(bLesson.getClassHour()); bSl.setClassHour(bLesson.getClassHour());
if(currentlyCode.contains(bSl.getCode())){
innerRepeatResult += "编号 " + bSl.getCode() + " 在Excel中重复出现,除第一条以外的数据插入失败 \n";
continue;
}
currentlyCode.add(bSl.getCode());
UserUtil.setCurrentPersistOperation(bSl); UserUtil.setCurrentPersistOperation(bSl);
BLessonDirection bDirection = new BLessonDirection(); BLessonDirection bDirection = new BLessonDirection();
if (!bSls.contains(bSl)) { if (!bSls.contains(bSl)) {
bSls.add(bSl); bSls.add(bSl);
bDirection.setDirectionId(bLesson.getDirectionId()); bDirection.setDirectionId(bLesson.getDirectionId());
bDirection.setBusinessId(IdGen.uuid()); bDirection.setBusinessId(IdGen.uuid());
...@@ -269,7 +278,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -269,7 +278,7 @@ public class BSlServiceImpl implements BSlService {
if(bSls.size()<1){ if(bSls.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result);
} }
return new PersistModel(1,result); return new PersistModel(1,result + innerRepeatResult);
} }
@Override @Override
......
...@@ -5,6 +5,7 @@ package org.rcisoft.business.bslschedule.controller; ...@@ -5,6 +5,7 @@ package org.rcisoft.business.bslschedule.controller;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.bslschedule.entity.ScheduleResult2;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -104,4 +105,27 @@ public class BSlScheduleController extends PaginationController<BSlSchedule> { ...@@ -104,4 +105,27 @@ public class BSlScheduleController extends PaginationController<BSlSchedule> {
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
bSlScheduleServiceImpl.queryMoreBSlSchedules(week,termCode,subAgencyId)); bSlScheduleServiceImpl.queryMoreBSlSchedules(week,termCode,subAgencyId));
} }
@ApiOperation(value="查周视图内部信息", notes="查周视图内部信息")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "每格的businessId", required = true, dataType = "varchar")})
@GetMapping(value = "/listDetail")
public Result listDetail(String businessId){
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bSlScheduleServiceImpl.queryDetail(businessId));
}
@ApiOperation(value="查周视图2", notes="查周视图2")
@ApiImplicitParams({@ApiImplicitParam(name = "week", value = "周次", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "termCode", value = "学期编号", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "subAgencyId", value = "subAgencyId", required = true, dataType = "varchar")})
@GetMapping(value = "/queryBSlScheduleMore2")
public Result queryBSlScheduleMore2(String week,String termCode,String subAgencyId) throws ParseException {
ScheduleResult2 scheduleResult2 = bSlScheduleServiceImpl.queryMoreBSlSchedules2(week,termCode,subAgencyId);
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
scheduleResult2);
}
} }
...@@ -2,6 +2,7 @@ package org.rcisoft.business.bslschedule.dao; ...@@ -2,6 +2,7 @@ package org.rcisoft.business.bslschedule.dao;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bslschedule.entity.BSlSchedule; import org.rcisoft.business.bslschedule.entity.BSlSchedule;
import org.rcisoft.business.bslschedule.entity.ScheduleDetail;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -69,5 +70,55 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> { ...@@ -69,5 +70,55 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> {
"left join b_teacher bt on bs.teacher_code = bt.code " + "left join b_teacher bt on bs.teacher_code = bt.code " +
"where bt.business_id = #{id}") "where bt.business_id = #{id}")
int querySlScheduleDtoByTeaCode(String id); int querySlScheduleDtoByTeaCode(String id);
@Select("SELECT\n" +
"\tb_sl_schedule.room_code as roomCode,\n" +
"\tb_sl_schedule.term_code as termCode,\n" +
"\tb_sl_schedule.tea_code as teaCode,\n" +
"\tb_sl_schedule.lesson_code as lessonCode,\n" +
"\tb_sl_schedule.edu_class_code as eduClassCode,\n" +
"\tb_sl_schedule.sub_agency_id as subAgencyId,\n" +
"\t(\n" +
"\t\tSELECT\n" +
"\t\t\tsum(student_num)\n" +
"\t\tFROM\n" +
"\t\t\tb_class\n" +
"\t\tWHERE\n" +
"\t\t\tFIND_IN_SET(\n" +
"\t\t\t\tb_class. CODE,\n" +
"\t\t\t\tb_edu_class.classes_id\n" +
"\t\t\t)\n" +
"\t) AS studentNum,\n" +
"\tb_lesson.lesson_name as lessonCode,\n" +
"\tb_sl.`code` AS bslCode,\n" +
"\tb_lesson.class_hour as classHour,\n" +
"\ts_user.`name` AS userName,\n" +
"\ts_user.email,\n" +
"\ts_user.phone,\n" +
"\tb_agency.`name` AS agencyName,\n" +
"\tb_agency.`code` AS agencyCode,\n" +
"\tb_rooms.campus,\n" +
"\tb_rooms.category,\n" +
"\tb_rooms.building,\n" +
"\tb_rooms.classroom_no as classroomNo,\n" +
"\tb_rooms.classroom_name as classroomName\n" +
"FROM\n" +
"\tb_sl_schedule\n" +
"LEFT JOIN b_rooms ON b_rooms.`code` = b_sl_schedule.room_code\n" +
"LEFT JOIN b_term ON b_term.`code` = b_sl_schedule.term_code\n" +
"LEFT JOIN b_lesson ON b_lesson.`code` = b_sl_schedule.lesson_code\n" +
"LEFT JOIN b_lesson_direction ON b_lesson_direction.lession_id = b_lesson.business_id\n" +
"LEFT JOIN b_direction ON b_direction.business_id = b_lesson_direction.direction_id\n" +
"LEFT JOIN b_edu_class ON b_edu_class. CODE = b_sl_schedule.edu_class_code\n" +
"LEFT JOIN s_user ON s_user.login_name = b_sl_schedule.tea_code\n" +
"LEFT JOIN b_teacher ON b_teacher. CODE = b_sl_schedule.tea_code\n" +
"LEFT JOIN b_agency ON b_agency. CODE = b_teacher.agency_code\n" +
"LEFT JOIN b_sl ON b_sl_schedule.tea_code = b_sl.teacher_code\n" +
"AND b_sl_schedule.term_code = b_sl.term_code\n" +
"AND b_sl_schedule.lesson_code = b_sl.lesson_code\n" +
"WHERE\n" +
"\tb_sl_schedule.business_id = #{businessId}")
@ResultMap(value = "DetailResultMap")
ScheduleDetail queryDetail(String businessId);
} }
package org.rcisoft.business.bslschedule.entity;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
@Data
@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
public class BSLData {
@Data
class InnerObject{
String index;
String tag;
InnerObject(String index,String tag){
this.index = index;
this.tag = tag;
}
}
@Data
class Detail{
List<InnerObject> innerObjectList = new ArrayList<>();
}
private Detail classes = new Detail();
private Detail section = new Detail();
private Detail mon = new Detail();
private Detail tue = new Detail();
private Detail wed = new Detail();
private Detail thu = new Detail();
private Detail fri = new Detail();
private Detail sat = new Detail();
private Detail sun = new Detail();
public void addDetail(String index,String tag,String flag){
switch (flag){
case "classes":
classes.innerObjectList.add(new InnerObject(index,tag));
break;
case "section":
section.innerObjectList.add(new InnerObject(index,tag));
break;
}
}
public void addDetail(String index,String tag,int flag){
switch (flag){
case Calendar.MONDAY:
mon.innerObjectList.add(new InnerObject(index,tag));
break;
case Calendar.TUESDAY:
tue.innerObjectList.add(new InnerObject(index,tag));
break;
case Calendar.WEDNESDAY:
wed.innerObjectList.add(new InnerObject(index,tag));
break;
case Calendar.THURSDAY:
thu.innerObjectList.add(new InnerObject(index,tag));
break;
case Calendar.FRIDAY:
fri.innerObjectList.add(new InnerObject(index,tag));
break;
case Calendar.SATURDAY:
sat.innerObjectList.add(new InnerObject(index,tag));
break;
case Calendar.SUNDAY:
sun.innerObjectList.add(new InnerObject(index,tag));
break;
}
}
}
package org.rcisoft.business.bslschedule.entity;
import lombok.Data;
import org.rcisoft.business.barrange.entity.ScheduleDto;
import java.util.ArrayList;
import java.util.List;
@Data
public class ScheduleDetail {
private String roomCode;
private String termCode;
private String teaCode;
private String lessonCode;
private String eduClassCode;
private String studentNum;
private String lessonName;
private String bslCode;
private String classHour;
private String userName;
private String email;
private String phone;
private String agencyName;
private String agencyCode;
private String campus;
private String category;
private String building;
private String classroomNo;
private String classroomName;
private String weekDetail;
private String subAgencyId;
List<ScheduleDto> list = new ArrayList<>();
public String getCampus(){
if(this.campus != null && !this.campus.equals("")){
switch (this.campus) {
case "0":
this.campus = "校本部";
break;
case "1":
this.campus = "新校区";
break;
}
}
return this.campus;
}
public String getBuilding(){
if(this.building != null && !this.building.equals("")){
switch (this.building) {
case "0":
this.building = "A区";
break;
case "1":
this.building = "B区";
break;
case "2":
this.building = "C区";
break;
case "3":
this.building = "D区";
break;
}
}
return this.building;
}
public String getCategory(){
if(this.category != null && !this.category.equals("")){
switch (this.category) {
case "0":
this.category = "普通教室";
break;
case "1":
this.category = "听力教室";
break;
case "2":
this.category = "多媒体教室";
break;
case "3":
this.category = "实训机房";
break;
case "4":
this.category = "报告厅";
break;
case "5":
this.category = "多功能报告厅";
break;
case "6":
this.category = "阶梯教室";
break;
}
}
return this.category;
}
}
package org.rcisoft.business.bslschedule.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.rcisoft.business.bcoursecode.entity.BCourseCode;
import javax.persistence.Entity;
import java.util.List;
import java.util.Map;
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ScheduleResult2 {
private String weekNum;
private Map<String,BSLData> bSlSchedules;
private List<BCourseCode> bCourseCodes;
}
...@@ -2,7 +2,9 @@ package org.rcisoft.business.bslschedule.service; ...@@ -2,7 +2,9 @@ package org.rcisoft.business.bslschedule.service;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bslschedule.entity.BSlSchedule; import org.rcisoft.business.bslschedule.entity.BSlSchedule;
import org.rcisoft.business.bslschedule.entity.ScheduleDetail;
import org.rcisoft.business.bslschedule.entity.ScheduleResult; import org.rcisoft.business.bslschedule.entity.ScheduleResult;
import org.rcisoft.business.bslschedule.entity.ScheduleResult2;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
...@@ -53,4 +55,8 @@ public interface BSlScheduleService { ...@@ -53,4 +55,8 @@ public interface BSlScheduleService {
ScheduleResult queryMoreBSlSchedules(String week,String termCode1, String subAgencyId); ScheduleResult queryMoreBSlSchedules(String week,String termCode1, String subAgencyId);
ScheduleDetail queryDetail(String businessId);
ScheduleResult2 queryMoreBSlSchedules2(String week, String termCode1, String subAgencyId);
} }
package org.rcisoft.business.bslschedule.service.impl; package org.rcisoft.business.bslschedule.service.impl;
import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.barrange.dao.BArrangeRepository; import org.rcisoft.business.barrange.dao.BArrangeRepository;
import org.rcisoft.business.barrange.entity.ScheduleDto; import org.rcisoft.business.barrange.entity.ScheduleDto;
import org.rcisoft.business.bcoursecode.dao.BCourseCodeRepository; import org.rcisoft.business.bcoursecode.dao.BCourseCodeRepository;
import org.rcisoft.business.bcoursecode.entity.BCourseCode; import org.rcisoft.business.bcoursecode.entity.BCourseCode;
import org.rcisoft.business.beduclass.dao.BEduClassRepository; import org.rcisoft.business.beduclass.dao.BEduClassRepository;
import org.rcisoft.business.beduclass.entity.BEduClass;
import org.rcisoft.business.blesson.dao.BLessonRepository; import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.brooms.dao.BRoomsRepository; import org.rcisoft.business.brooms.dao.BRoomsRepository;
import org.rcisoft.business.brooms.entity.BRooms; import org.rcisoft.business.bslschedule.entity.*;
import org.rcisoft.business.bsl.entity.BSl;
import org.rcisoft.business.bslschedule.entity.ScheduleResult;
import org.rcisoft.business.bslschedule.util.FindTime; import org.rcisoft.business.bslschedule.util.FindTime;
import org.rcisoft.business.bterm.dao.BTermRepository; import org.rcisoft.business.bterm.dao.BTermRepository;
import org.rcisoft.business.bterm.entity.BTerm; import org.rcisoft.business.bterm.entity.BTerm;
import org.rcisoft.business.bterm.utils.Week; import org.rcisoft.business.bterm.utils.Week;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.service.RcRedisService; import org.rcisoft.core.service.RcRedisService;
import org.rcisoft.core.service.SerializationUtils;
import org.rcisoft.core.util.ExcelUtil;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.bslschedule.dao.BSlScheduleRepository; import org.rcisoft.business.bslschedule.dao.BSlScheduleRepository;
import org.rcisoft.business.bslschedule.entity.BSlSchedule;
import org.rcisoft.business.bslschedule.service.BSlScheduleService; import org.rcisoft.business.bslschedule.service.BSlScheduleService;
import org.rcisoft.sys.user.dao.SysUserMapper; import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
...@@ -40,8 +28,6 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -40,8 +28,6 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -51,7 +37,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -51,7 +37,7 @@ import lombok.extern.slf4j.Slf4j;
* Created by on 2018-5-2 16:39:34. * Created by on 2018-5-2 16:39:34.
*/ */
@Service @Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED) @Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
@Slf4j @Slf4j
public class BSlScheduleServiceImpl implements BSlScheduleService { public class BSlScheduleServiceImpl implements BSlScheduleService {
...@@ -83,74 +69,79 @@ public class BSlScheduleServiceImpl implements BSlScheduleService { ...@@ -83,74 +69,79 @@ public class BSlScheduleServiceImpl implements BSlScheduleService {
private RcRedisService rcRedisServiceImpl; private RcRedisService rcRedisServiceImpl;
private static Map<String,Date> timeMap; private static Map<String, Date> timeMap;
private static String termCode; private static String termCode;
/** /**
* 保存 bSlSchedule * 保存 bSlSchedule
*
* @param bSlSchedule * @param bSlSchedule
* @return * @return
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(BSlSchedule bSlSchedule){ public PersistModel save(BSlSchedule bSlSchedule) {
bSlSchedule.setCommonBusinessId(); bSlSchedule.setCommonBusinessId();
//增加操作 //增加操作
UserUtil.setCurrentPersistOperation(bSlSchedule); UserUtil.setCurrentPersistOperation(bSlSchedule);
int line = bSlScheduleRepository.insertSelective(bSlSchedule); int line = bSlScheduleRepository.insertSelective(bSlSchedule);
log.info(UserUtil.getUserInfoProp(bSlSchedule.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+ log.info(UserUtil.getUserInfoProp(bSlSchedule.getToken(), UserUtil.USER_USERNAME) + "新增了ID为" +
bSlSchedule.getBusinessId()+"的信息"); bSlSchedule.getBusinessId() + "的信息");
return new PersistModel(line); return new PersistModel(line);
} }
/** /**
* 逻辑删除 * 逻辑删除
*
* @param bSlSchedule * @param bSlSchedule
* @return * @return
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel remove(BSlSchedule bSlSchedule){ public PersistModel remove(BSlSchedule bSlSchedule) {
UserUtil.setCurrentMergeOperation(bSlSchedule); UserUtil.setCurrentMergeOperation(bSlSchedule);
bSlSchedule.setDeleted(); bSlSchedule.setDeleted();
int line = bSlScheduleRepository.logicalDelete(bSlSchedule); int line = bSlScheduleRepository.logicalDelete(bSlSchedule);
log.info(UserUtil.getUserInfoProp(bSlSchedule.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+ log.info(UserUtil.getUserInfoProp(bSlSchedule.getToken(), UserUtil.USER_USERNAME) + "逻辑删除了ID为" +
bSlSchedule.getBusinessId()+"的信息"); bSlSchedule.getBusinessId() + "的信息");
return new PersistModel(line); return new PersistModel(line);
} }
/** /**
* 修改 bSlSchedule * 修改 bSlSchedule
*
* @param bSlSchedule * @param bSlSchedule
* @return * @return
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel merge(BSlSchedule bSlSchedule){ public PersistModel merge(BSlSchedule bSlSchedule) {
UserUtil.setCurrentMergeOperation(bSlSchedule); UserUtil.setCurrentMergeOperation(bSlSchedule);
int line = bSlScheduleRepository.updateByPrimaryKeySelective(bSlSchedule); int line = bSlScheduleRepository.updateByPrimaryKeySelective(bSlSchedule);
log.info(UserUtil.getUserInfoProp(bSlSchedule.getToken(),UserUtil.USER_USERNAME)+"修改了ID为"+ log.info(UserUtil.getUserInfoProp(bSlSchedule.getToken(), UserUtil.USER_USERNAME) + "修改了ID为" +
bSlSchedule.getBusinessId()+"的信息"); bSlSchedule.getBusinessId() + "的信息");
return new PersistModel(line); return new PersistModel(line);
} }
/** /**
* 根据id查询 bSlSchedule * 根据id查询 bSlSchedule
*
* @param id * @param id
* @return * @return
*/ */
public BSlSchedule findById(String id){ public BSlSchedule findById(String id) {
return bSlScheduleRepository.selectByPrimaryKey(id); return bSlScheduleRepository.selectByPrimaryKey(id);
} }
/** /**
* 分页查询 bSlSchedule * 分页查询 bSlSchedule
*
* @param bSlSchedule * @param bSlSchedule
* @return * @return
*/ */
public List<BSlSchedule> findAllByPagination(PageUtil<BSlSchedule> paginationUtility, public List<BSlSchedule> findAllByPagination(PageUtil<BSlSchedule> paginationUtility,
BSlSchedule bSlSchedule){ BSlSchedule bSlSchedule) {
bSlSchedule.setStart(); bSlSchedule.setStart();
bSlSchedule.setNotDeleted(); bSlSchedule.setNotDeleted();
return bSlScheduleRepository.queryBSlSchedules(bSlSchedule); return bSlScheduleRepository.queryBSlSchedules(bSlSchedule);
...@@ -158,42 +149,43 @@ public class BSlScheduleServiceImpl implements BSlScheduleService { ...@@ -158,42 +149,43 @@ public class BSlScheduleServiceImpl implements BSlScheduleService {
/** /**
* 按周与学期编号查询 bSlSchedule * 按周与学期编号查询 bSlSchedule
*
* @param week,termCode1,subAgencyId * @param week,termCode1,subAgencyId
* @return * @return
*/ */
@Override @Override
public ScheduleResult queryMoreBSlSchedules(String week,String termCode1 , String subAgencyId) { public ScheduleResult queryMoreBSlSchedules(String week, String termCode1, String subAgencyId) {
ScheduleResult scheduleResult = new ScheduleResult(); ScheduleResult scheduleResult = new ScheduleResult();
BTerm bTerm = bTermRepository.queryBtermByCode(termCode1).get(0); BTerm bTerm = bTermRepository.queryBtermByCode(termCode1).get(0);
if(bTerm.getWeek() == null || bTerm.getWeek().equals("")){ if (bTerm.getWeek() == null || bTerm.getWeek().equals("")) {
scheduleResult.setWeekNum(String.valueOf(Week.buildList(bTerm.getStartDate(),bTerm.getEndDate()).size() + 1)); scheduleResult.setWeekNum(String.valueOf(Week.buildList(bTerm.getStartDate(), bTerm.getEndDate()).size() + 1));
}else{ } else {
scheduleResult.setWeekNum(bTerm.getWeek()); scheduleResult.setWeekNum(bTerm.getWeek());
} }
Map<String,Date> map = FindTime.findTime(bTerm.getStartDate(),bTerm.getEndDate()); Map<String, Date> map = FindTime.findTime(bTerm.getStartDate(), bTerm.getEndDate());
Date min = new Date(); Date min = new Date();
//按周获取时间段 //按周获取时间段
if(map.get(week+",1") != null && !map.get(week+",1").toString().equals("")){ if (map.get(week + ",1") != null && !map.get(week + ",1").toString().equals("")) {
min = map.get(week+",1"); min = map.get(week + ",1");
}else if (map.get(week+",2") != null && !map.get(week+",2").toString().equals("")){ } else if (map.get(week + ",2") != null && !map.get(week + ",2").toString().equals("")) {
min = map.get(week+",2"); min = map.get(week + ",2");
}else if (map.get(week+",3") != null && !map.get(week+",3").toString().equals("")){ } else if (map.get(week + ",3") != null && !map.get(week + ",3").toString().equals("")) {
min = map.get(week+",3"); min = map.get(week + ",3");
}else if (map.get(week+",4") != null && !map.get(week+",4").toString().equals("")){ } else if (map.get(week + ",4") != null && !map.get(week + ",4").toString().equals("")) {
min = map.get(week+",4"); min = map.get(week + ",4");
}else if (map.get(week+",5") != null && !map.get(week+",5").toString().equals("")){ } else if (map.get(week + ",5") != null && !map.get(week + ",5").toString().equals("")) {
min = map.get(week+",5"); min = map.get(week + ",5");
}else if (map.get(week+",6") != null && !map.get(week+",6").toString().equals("")){ } else if (map.get(week + ",6") != null && !map.get(week + ",6").toString().equals("")) {
min = map.get(week+",6"); min = map.get(week + ",6");
}else if (map.get(week+",7") != null && !map.get(week+",7").toString().equals("")){ } else if (map.get(week + ",7") != null && !map.get(week + ",7").toString().equals("")) {
min = map.get(week+",7"); min = map.get(week + ",7");
} }
Calendar minCal = Calendar.getInstance(); Calendar minCal = Calendar.getInstance();
minCal.setTime(min); minCal.setTime(min);
Calendar maxCal = Calendar.getInstance(); Calendar maxCal = Calendar.getInstance();
maxCal.setTime(min); maxCal.setTime(min);
while(maxCal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY){ while (maxCal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
maxCal.add(Calendar.DATE,1); maxCal.add(Calendar.DATE, 1);
} }
SimpleDateFormat format0 = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format0 = new SimpleDateFormat("yyyy-MM-dd");
List<BSlSchedule> list = bSlScheduleRepository.queryMoreBSlSchedules( List<BSlSchedule> list = bSlScheduleRepository.queryMoreBSlSchedules(
...@@ -201,73 +193,7 @@ public class BSlScheduleServiceImpl implements BSlScheduleService { ...@@ -201,73 +193,7 @@ public class BSlScheduleServiceImpl implements BSlScheduleService {
format0.format(maxCal.getTime()), format0.format(maxCal.getTime()),
subAgencyId); subAgencyId);
// for(BSlSchedule bSlSchedule : list){
// int minWeek = 0;
// int maxWeek = 0;
// //共几周课
// int total = 0;
// String weekDetail = "";
// String key = bSlSchedule.getSubAgencyId() +
// bSlSchedule.getBEduClass() +
// bSlSchedule.getBLesson() + "";
// List<ScheduleDto> scheduleDtos = rcRedisServiceImpl.getList(key);
// //如果缓存内不存在数据
// if(scheduleDtos == null || scheduleDtos.size() == 0){
// List<ScheduleDto> list1 = bArrangeRepository.queryDtoThroughBsl(bSlSchedule.getSubAgencyId(),bSlSchedule.getEduClassCode(),bSlSchedule.getBLesson().getCode());
// for(int i = 0 ; i < list1.size() ; i++){
// String innerKey = key + i;
// rcRedisServiceImpl.setBytes(innerKey, SerializationUtils.serializer(list.get(i)));
// //获取周
// String detailWeek = list1.get(i).getWeek();
// //分割周
// String[] subWeek = detailWeek.split("-");
// //确定这段时间有几周
// if(subWeek.length > 1){
// if(i == 0)
// minWeek = Integer.valueOf(subWeek[0]);
// maxWeek = Integer.valueOf(subWeek[1]);
// total += (Integer.valueOf(subWeek[1]) - Integer.valueOf(subWeek[0]));
// weekDetail += "(" + detailWeek + "周)";
// }else{
// if(i == 0)
// minWeek = Integer.valueOf(detailWeek);
// maxWeek = Integer.valueOf(detailWeek);
// total += 1;
// weekDetail += "(" + detailWeek + "周)";
// }
// }
// bSlSchedule.setResult("共 " + total + "周," + weekDetail + FindTime.getStartOrEndTime(minWeek,"getStart") + FindTime.getStartOrEndTime(maxWeek,"getEnd"));
// bSlSchedule.setList(list1);
// }else{
// //如果存在
// List<ScheduleDto> list1 = new ArrayList<>();
// for(int i = 0 ; true ; i++){
// byte[] bytes = rcRedisServiceImpl.getBytes(key + i);
// if(bytes == null || bytes.length == 0){
// break;
// }
// ScheduleDto scheduleDto = SerializationUtils.deserializer(bytes,ScheduleDto.class);
// String detailWeek = scheduleDto.getWeek();
// String[] subWeek = detailWeek.split("-");
// list1.add(scheduleDto);
// if(subWeek.length > 1){
// if(i == 0)
// minWeek = Integer.valueOf(subWeek[0]);
// maxWeek = Integer.valueOf(subWeek[1]);
// total += (Integer.valueOf(subWeek[1]) - Integer.valueOf(subWeek[0]));
// weekDetail += "(" + detailWeek + "周)";
// }else{
// if(i == 0)
// minWeek = Integer.valueOf(detailWeek);
// maxWeek = Integer.valueOf(detailWeek);
// total += 1;
// weekDetail += "(" + detailWeek + "周)";
// }
// }
// bSlSchedule.setResult("共 " + total + "周," + weekDetail + FindTime.getStartOrEndTime(minWeek,"getStart") + FindTime.getStartOrEndTime(maxWeek,"getEnd"));
// bSlSchedule.setList(list1);
// }
// }
scheduleResult.setBSlSchedules(list); scheduleResult.setBSlSchedules(list);
BCourseCode bCourseCode = new BCourseCode(); BCourseCode bCourseCode = new BCourseCode();
bCourseCode.setFlag("1"); bCourseCode.setFlag("1");
...@@ -276,4 +202,124 @@ public class BSlScheduleServiceImpl implements BSlScheduleService { ...@@ -276,4 +202,124 @@ public class BSlScheduleServiceImpl implements BSlScheduleService {
return scheduleResult; return scheduleResult;
} }
@Override
public ScheduleDetail queryDetail(String businessId) {
int minWeek = 0;
int maxWeek = 0;
//共几周课
int total = 0;
String weekDetail = "";
ScheduleDetail scheduleDetail = bSlScheduleRepository.queryDetail(businessId);
List<ScheduleDto> scheduleDtoList = bArrangeRepository.queryDtoThroughBsl(scheduleDetail.getSubAgencyId()
,scheduleDetail.getEduClassCode()
,scheduleDetail.getLessonCode());
//获取周
for(int i = 0 ;i <scheduleDtoList.size() ; i++){
String detailWeek = scheduleDtoList.get(i).getWeek();
//分割周
String[] subWeek = detailWeek.split("-");
//确定这段时间有几周
if (subWeek.length > 1) {
if (i == 0)
minWeek = Integer.valueOf(subWeek[0]);
maxWeek = Integer.valueOf(subWeek[1]);
total += (Integer.valueOf(subWeek[1]) - Integer.valueOf(subWeek[0]));
weekDetail += "(" + detailWeek + "周)";
} else {
if (i == 0)
minWeek = Integer.valueOf(detailWeek);
maxWeek = Integer.valueOf(detailWeek);
total += 1;
weekDetail += "(" + detailWeek + "周)";
}
}
scheduleDetail.setList(scheduleDtoList);
scheduleDetail.setWeekDetail(weekDetail);
return scheduleDetail;
}
@Override
public ScheduleResult2 queryMoreBSlSchedules2(String week, String termCode1, String subAgencyId) {
Map<String,BSLData> resultMap = new HashMap<>();
ScheduleResult2 scheduleResult = new ScheduleResult2();
BTerm bTerm = bTermRepository.queryBtermByCode(termCode1).get(0);
//获取课程时间列表
BCourseCode bCourseCode = new BCourseCode();
bCourseCode.setFlag("1");
bCourseCode.setDelFlag("0");
List<BCourseCode> bCourseCodeList = bCourseCodeRepository.queryBCourseCodes(bCourseCode);
if (bTerm.getWeek() == null || bTerm.getWeek().equals("")) {
scheduleResult.setWeekNum(String.valueOf(Week.buildList(bTerm.getStartDate(), bTerm.getEndDate()).size() + 1));
} else {
scheduleResult.setWeekNum(bTerm.getWeek());
}
Map<String, Date> map = FindTime.findTime(bTerm.getStartDate(), bTerm.getEndDate());
Date min = new Date();
//按周获取时间段
if (map.get(week + ",1") != null && !map.get(week + ",1").toString().equals("")) {
min = map.get(week + ",1");
} else if (map.get(week + ",2") != null && !map.get(week + ",2").toString().equals("")) {
min = map.get(week + ",2");
} else if (map.get(week + ",3") != null && !map.get(week + ",3").toString().equals("")) {
min = map.get(week + ",3");
} else if (map.get(week + ",4") != null && !map.get(week + ",4").toString().equals("")) {
min = map.get(week + ",4");
} else if (map.get(week + ",5") != null && !map.get(week + ",5").toString().equals("")) {
min = map.get(week + ",5");
} else if (map.get(week + ",6") != null && !map.get(week + ",6").toString().equals("")) {
min = map.get(week + ",6");
} else if (map.get(week + ",7") != null && !map.get(week + ",7").toString().equals("")) {
min = map.get(week + ",7");
}
Calendar minCal = Calendar.getInstance();
minCal.setTime(min);
Calendar maxCal = Calendar.getInstance();
maxCal.setTime(min);
while (maxCal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
maxCal.add(Calendar.DATE, 1);
}
SimpleDateFormat format0 = new SimpleDateFormat("yyyy-MM-dd");
List<BSlSchedule> list = bSlScheduleRepository.queryMoreBSlSchedules(
format0.format(minCal.getTime()),
format0.format(maxCal.getTime()),
subAgencyId);
for(BSlSchedule bSlSchedule : list){
//判断这里是否有此班级,此时间的记录
BSLData bslData = resultMap.get(bSlSchedule.getEduClassCode() + "," + bSlSchedule.getSeq());
if(bslData == null){
bslData = new BSLData();
bslData.addDetail(bSlSchedule.getEduClassCode(),bSlSchedule.getBEduClass().getClassName(),"classes");
BCourseCode bCourseCode1 = bCourseCodeList.get(Integer.valueOf(bSlSchedule.getSeq()) - 1);
bslData.addDetail(bSlSchedule.getSeq(),bCourseCode1.getStartDate() + "-" + bCourseCode1.getEndDate(),"section");
//判断星期几
Calendar calendar = Calendar.getInstance();
Date date = bSlSchedule.getStartDay();
if(date == null)
continue;
calendar.setTime(date);
int DAY_OF_WEEK = calendar.get(Calendar.DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getBLesson().getCode(),bSlSchedule.getBLesson().getLessonName(),DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getTeaCode(),bSlSchedule.getTeacherName(),DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getRoomCode(),bSlSchedule.getBRooms().getClassroomName(),DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getBusinessId(),"businessId",DAY_OF_WEEK);
resultMap.put(bSlSchedule.getEduClassCode() + "," + bSlSchedule.getSeq(),bslData);
}else{
//判断星期几
Calendar calendar = Calendar.getInstance();
Date date = bSlSchedule.getStartDay();
if(date == null)
continue;
calendar.setTime(date);
int DAY_OF_WEEK = calendar.get(Calendar.DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getBLesson().getCode(),bSlSchedule.getBLesson().getLessonName(),DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getTeaCode(),bSlSchedule.getTeacherName(),DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getRoomCode(),bSlSchedule.getBRooms().getClassroomName(),DAY_OF_WEEK);
bslData.addDetail(bSlSchedule.getBusinessId(),"businessId",DAY_OF_WEEK);
}
}
scheduleResult.setBSlSchedules(resultMap);
scheduleResult.setBCourseCodes(bCourseCodeList);
return scheduleResult;
}
} }
...@@ -127,7 +127,8 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -127,7 +127,8 @@ public class BStudentServiceImpl implements BStudentService {
@Override @Override
public PersistModel importExcel(HSSFWorkbook hwb,String token) throws IOException { public PersistModel importExcel(HSSFWorkbook hwb,String token) throws IOException {
ArrayList<BStudent> students = new ArrayList<BStudent>(); ArrayList<BStudent> students = new ArrayList<BStudent>();
List<String> currentlyCode = new ArrayList<>();
String innerRepeatResult = "";
ArrayList<SysUser> users = new ArrayList<SysUser>(); ArrayList<SysUser> users = new ArrayList<SysUser>();
ArrayList<UserRole> userRoles = new ArrayList<UserRole>(); ArrayList<UserRole> userRoles = new ArrayList<UserRole>();
List<String> valuesIncomplete = new ArrayList<>(); List<String> valuesIncomplete = new ArrayList<>();
...@@ -239,7 +240,12 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -239,7 +240,12 @@ public class BStudentServiceImpl implements BStudentService {
bStudent.setGradeCode(value[3]); bStudent.setGradeCode(value[3]);
bStudent.setRemarks(value[4]); bStudent.setRemarks(value[4]);
UserUtil.setCurrentPersistOperation(bStudent); UserUtil.setCurrentPersistOperation(bStudent);
if(currentlyCode.contains(bStudent.getCode())){
innerRepeatResult += "编号 " + value[0] + " 在Excel中重复出现,除第一条以外的数据插入失败 \n";
continue;
}
if (!students.contains(bStudent)) { if (!students.contains(bStudent)) {
currentlyCode.add(bStudent.getCode());
students.add(bStudent); students.add(bStudent);
users.add(user); users.add(user);
userRoles.add(userRole); userRoles.add(userRole);
...@@ -285,7 +291,7 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -285,7 +291,7 @@ public class BStudentServiceImpl implements BStudentService {
if (valuesOK.size()<1){ if (valuesOK.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result); throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR.getCode(),result);
} }
return new PersistModel(1, result); return new PersistModel(1, result + innerRepeatResult);
......
...@@ -85,8 +85,8 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -85,8 +85,8 @@ public class BTeacherServiceImpl implements BTeacherService {
public PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException, InterruptedException { public PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException, InterruptedException {
ArrayList<BTeacher> teachers = new ArrayList<BTeacher>(); ArrayList<BTeacher> teachers = new ArrayList<BTeacher>();
ArrayList<SysUser> users = new ArrayList<SysUser>(); ArrayList<SysUser> users = new ArrayList<SysUser>();
String innerRepeatResult = "";
List<String> currentlyCode = new ArrayList<>();
ArrayList<UserRole> userRoles = new ArrayList<UserRole>(); ArrayList<UserRole> userRoles = new ArrayList<UserRole>();
String[] headers = {"教师工号", "教师姓名", "性别","教学单位编号","备注"}; String[] headers = {"教师工号", "教师姓名", "性别","教学单位编号","备注"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb, headers,true,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb, headers,true,1); //获取excel数据
...@@ -193,7 +193,12 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -193,7 +193,12 @@ public class BTeacherServiceImpl implements BTeacherService {
BTeacher bTeacher= new BTeacher(value[0],value[3]); BTeacher bTeacher= new BTeacher(value[0],value[3]);
bTeacher.setRemarks(value[4]); bTeacher.setRemarks(value[4]);
UserUtil.setCurrentPersistOperation(bTeacher); UserUtil.setCurrentPersistOperation(bTeacher);
if(currentlyCode.contains(bTeacher.getCode())){
innerRepeatResult += "编号 " + bTeacher.getCode() + " 在Excel中重复出现,除第一条以外的数据插入失败 ";
continue;
}
if (!teachers.contains(bTeacher)) { if (!teachers.contains(bTeacher)) {
currentlyCode.add(bTeacher.getCode());
teachers.add(bTeacher); teachers.add(bTeacher);
users.add(user); users.add(user);
userRoles.add(userRole); userRoles.add(userRole);
...@@ -235,7 +240,7 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -235,7 +240,7 @@ public class BTeacherServiceImpl implements BTeacherService {
} }
return new PersistModel(1, result); return new PersistModel(1, result + innerRepeatResult);
} }
......
...@@ -106,6 +106,15 @@ public class ExcelUtil { ...@@ -106,6 +106,15 @@ public class ExcelUtil {
return values; return values;
} }
// public static boolean isRepeat(List<String[]> totalValue,String[] value){
// for(int i = 0 ; i < totalValue.size() ; i++){
// for(int j = 0 ; j < value.length ; j++){
// if(((String)value[j]).equals((String)totalValue.get(i)[j])){
// return true;
// }
// }
// }
// }
/** /**
* 重复数据检查 * 重复数据检查
......
...@@ -11,8 +11,8 @@ server: ...@@ -11,8 +11,8 @@ server:
# org.springframework.web: DEBUG # org.springframework.web: DEBUG
druid: druid:
#url: jdbc:mysql://192.168.1.125:13318/new_edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false url: jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
url: jdbc:mysql://120.52.179.75:13318/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false #url: jdbc:mysql://120.52.179.75:13318/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
username: root username: root
password: 123456 password: 123456
initial-size: 1 initial-size: 1
......
...@@ -70,6 +70,11 @@ ...@@ -70,6 +70,11 @@
<result column="studentNum" jdbcType="VARCHAR" property="bEduClass.studentNum"/> <result column="studentNum" jdbcType="VARCHAR" property="bEduClass.studentNum"/>
<result column="bslCode" jdbcType="VARCHAR" property="bslCode" /> <result column="bslCode" jdbcType="VARCHAR" property="bslCode" />
</resultMap> </resultMap>
<resultMap id="DetailResultMap" type="org.rcisoft.business.bslschedule.entity.ScheduleDetail">
</resultMap>
<insert id="insertList"> <insert id="insertList">
insert into b_sl_schedule(business_id,flag,del_flag,update_by,create_by,create_date,update_date,remarks, insert into b_sl_schedule(business_id,flag,del_flag,update_by,create_by,create_date,update_date,remarks,
sl_id,room_code,term_code,tea_code,seq, sl_id,room_code,term_code,tea_code,seq,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment