Commit 40d74606 authored by 李博今's avatar 李博今

修改导入排课,返回学期名

parent 7a9daab3
...@@ -89,3 +89,8 @@ ALTER TABLE `b_term` ...@@ -89,3 +89,8 @@ ALTER TABLE `b_term`
ALTER TABLE `s_user` ALTER TABLE `s_user`
DROP COLUMN `agency_code`, DROP COLUMN `agency_code`,
DROP COLUMN `is_created`; DROP COLUMN `is_created`;
/*新增周日*/
ALTER TABLE `b_schedule_dto`
ADD COLUMN `sunday` varchar(64) NULL AFTER `sub_agency_id`;
...@@ -19,14 +19,14 @@ public interface BArrangeRepository extends BaseMapper<BArrange> { ...@@ -19,14 +19,14 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
//企业人员查看自身公司的排课信息------------------------------------------------------------------------------------- //企业人员查看自身公司的排课信息-------------------------------------------------------------------------------------
@Select("<script>select b_arrange.business_id,term_code,description,agency_code,b_arrange.status from b_arrange " @Select("<script>select b_arrange.business_id,term_code,b_term.name as term_name,description,agency_code,b_arrange.status from b_arrange "
+ "LEFT JOIN b_subtask ON b_arrange.business_id = b_subtask.arrange_id " + "LEFT JOIN b_subtask ON b_arrange.business_id = b_subtask.arrange_id "
+ "LEFT JOIN b_sub_agency ON b_subtask.business_id = b_sub_agency.subtask_id " + "LEFT JOIN b_sub_agency ON b_subtask.business_id = b_sub_agency.subtask_id "
+ "LEFT JOIN b_term ON b_term.code = b_arrange.term_code "
+ "where 1=1 and agency_code = #{agencyCode} " + "where 1=1 and agency_code = #{agencyCode} "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> " + "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> " + "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "<if test=\"status !=null and status != '' \">and FIND_IN_SET(b_arrange.`status`,#{status}) </if> " + "<if test=\"status !=null and status != '' \">and FIND_IN_SET(b_arrange.`status`,#{status}) </if> "
+ "GROUP BY b_arrange.business_id "
+ "order by b_arrange.status,b_arrange.create_date desc" + "order by b_arrange.status,b_arrange.create_date desc"
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMapByAgencyCode") @ResultMap(value = "BaseResultMapByAgencyCode")
......
...@@ -77,6 +77,10 @@ public class ScheduleDto extends IdEntity<ScheduleDto>{ ...@@ -77,6 +77,10 @@ public class ScheduleDto extends IdEntity<ScheduleDto>{
@NotBlank @NotBlank
private String saturday; private String saturday;
@Length(min = 1,max = 64,message = "长度最小为1,最大为64")
@NotBlank
private String sunday;
/*教室编号*/ /*教室编号*/
@Length(min = 1,max = 64,message = "长度最小为1,最大为64") @Length(min = 1,max = 64,message = "长度最小为1,最大为64")
@NotBlank @NotBlank
......
package org.rcisoft.business.bterm.service.impl; package org.rcisoft.business.bterm.service.impl;
import org.rcisoft.business.bclass.entity.BClass;
import org.rcisoft.business.bsl.dao.BSlRepository; import org.rcisoft.business.bsl.dao.BSlRepository;
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.enums.BTermEnum; import org.rcisoft.business.bterm.enums.BTermEnum;
import org.rcisoft.business.bterm.service.BTermService; import org.rcisoft.business.bterm.service.BTermService;
import org.rcisoft.business.bterm.utils.Week;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
...@@ -13,12 +13,11 @@ import org.rcisoft.core.model.PersistModel; ...@@ -13,12 +13,11 @@ import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.model.SelectModel; import org.rcisoft.core.model.SelectModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -63,6 +62,8 @@ public class BTermServiceImpl implements BTermService { ...@@ -63,6 +62,8 @@ public class BTermServiceImpl implements BTermService {
}else { }else {
if(bTermRepository.selectOne(new BTerm(model.getCode()))!=null) if(bTermRepository.selectOne(new BTerm(model.getCode()))!=null)
throw new ServiceException(ResultServiceEnums.TERM_EXISTS); throw new ServiceException(ResultServiceEnums.TERM_EXISTS);
Map<String,Object> map = Week.buildWeek(model.getStartDate(),model.getEndDate());
model.setWeek(String.valueOf(((List<Week>) map.get("weeks")).size()));
UserUtil.setCurrentPersistOperation(model); UserUtil.setCurrentPersistOperation(model);
line = bTermRepository.insertSelective(model); line = bTermRepository.insertSelective(model);
} }
......
package org.rcisoft.business.bterm.utils;
import java.util.*;
public class Week {
private int weekNumber;
private Date startDate;
private Date endDate;
public Week() {
}
public Week(int weekNumber, Date startDate, Date endDate) {
this.weekNumber = weekNumber;
this.startDate = startDate;
this.endDate = endDate;
}
public int getWeekNumber() {
return weekNumber;
}
public void setWeekNumber(int weekNumber) {
this.weekNumber = weekNumber;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
//通过开始时间与计算时间计算周数与具体信息
public static Map<String,Object> buildWeek(Date startDate1,Date endDate1){
Map<String,Object> map = new HashMap<>();
int currentlyWeek = 0;
//声明数组
List<Week> weeks = new ArrayList<>();
Integer weekNumber = 1;
//保存学期结束时间,方便以后进行比较
Calendar termEndDate = Calendar.getInstance();
termEndDate.setTime(endDate1);
//结束时间 +1 方便计算
//termEndDate.add(Calendar.DATE,1);
//周开始时间
Calendar startDate = Calendar.getInstance();
startDate.setTime(startDate1);
//判断第一天为星期几, 1为星期日,2为星期一,………………
int dayOfWeek = startDate.get(Calendar.DAY_OF_WEEK);
//周结束时间
Calendar endDate = Calendar.getInstance();
endDate.setTime(startDate1);
//周结束时间为周开始时间直到周日
endDate.add(Calendar.DATE,8-dayOfWeek);
//当前时间
Calendar currenlyTime = Calendar.getInstance();
//如果第一周并不是完整的一周,则预先存入数组
if(dayOfWeek != 2){
Week week = new Week();
week.setWeekNumber(weekNumber);
week.setStartDate(startDate.getTime());
week.setEndDate(endDate.getTime());
//判断是否为当前周
if((startDate.getTime().before(currenlyTime.getTime()) || startDate.getTime().equals(currenlyTime.getTime()))
&&
(endDate.getTime().after(currenlyTime.getTime()) || endDate.getTime().equals(currenlyTime.getTime()))){
currentlyWeek = week.getWeekNumber();
}
weeks.add(week);
//为下次循环做准备,周数加一,开始时间与结束时间 +7
weekNumber += 1;
//将时间调整为正常数据
startDate.setTime(endDate.getTime());
startDate.add(Calendar.DATE,1);
endDate.add(Calendar.DATE,7);
}
//判断是否超出时间范围
while(startDate.before(termEndDate) || startDate.equals(termEndDate)){
//创建周实例
Week week = new Week();
//将该周的周数,开始时间,结束时间填入
//if-else 判断最后一周是否为完整的一周
if(endDate.equals(termEndDate) || endDate.before(termEndDate)){
week.setWeekNumber(weekNumber);
week.setStartDate(startDate.getTime());
week.setEndDate(endDate.getTime());
//判断是否为当前周
if((startDate.getTime().before(currenlyTime.getTime()) || startDate.getTime().equals(currenlyTime.getTime()))
&&
(endDate.getTime().after(currenlyTime.getTime()) || endDate.getTime().equals(currenlyTime.getTime()))){
currentlyWeek = week.getWeekNumber();
}
weeks.add(week);
}else{
week.setWeekNumber(weekNumber);
week.setStartDate(startDate.getTime());
week.setEndDate(termEndDate.getTime());
//判断是否为当前周
if((startDate.getTime().before(currenlyTime.getTime()) || startDate.getTime().equals(currenlyTime.getTime()))
&&
(endDate.getTime().after(currenlyTime.getTime()) || endDate.getTime().equals(currenlyTime.getTime()))){
currentlyWeek = week.getWeekNumber();
}
weeks.add(week);
}
//为下次循环做准备,周数加一,开始时间与结束时间 +7
weekNumber += 1;
startDate.add(Calendar.DATE,7);
endDate.add(Calendar.DATE,7);
}
map.put("weeks",weeks);
map.put("currentlyWeek",currentlyWeek);
return map;
}
}
...@@ -8,6 +8,8 @@ public enum ResultServiceEnums { ...@@ -8,6 +8,8 @@ public enum ResultServiceEnums {
EXCEL_IMPORT_DATA_NOT_EXIST(11,"Excel中没有找到任何完整有效的数据"), EXCEL_IMPORT_DATA_NOT_EXIST(11,"Excel中没有找到任何完整有效的数据"),
EXCEL_IMPORT_DATA_HAS_NULL(92,"第一行存在空数据"),
EXCEL_IMPORT_HEADER_ERROR(12,"excel表头信息错误,导入失败"), EXCEL_IMPORT_HEADER_ERROR(12,"excel表头信息错误,导入失败"),
EXCEL_IMPORT_DB_INSERT_ERROR(13,"数据库插入失败"), EXCEL_IMPORT_DB_INSERT_ERROR(13,"数据库插入失败"),
......
...@@ -41,13 +41,17 @@ public class ExcelUtil { ...@@ -41,13 +41,17 @@ public class ExcelUtil {
if(hr==null||hr.getLastCellNum()<0){ if(hr==null||hr.getLastCellNum()<0){
continue; continue;
} }
int firstcolumnnum = hr.getFirstCellNum(); int firstcolumnnum = hr.getFirstCellNum();
int lastcolumnnum = hr.getLastCellNum(); int lastcolumnnum = hr.getLastCellNum();
String[] value = new String[lastcolumnnum]; String[] value = new String[lastcolumnnum];
boolean hasEmpty = true; boolean hasEmpty = true;
for (int k = firstcolumnnum; k < lastcolumnnum; k++) { //修改过!!!!!!!!!!!!
for (int k = 0; k < lastcolumnnum; k++) {
HSSFCell hc = hr.getCell(k); HSSFCell hc = hr.getCell(k);
if(hc == null){
value[k] = "";
continue;
}
if (j==firstrownum + headNum) { if (j==firstrownum + headNum) {
//判断表头那一列为空数据并记录。 //判断表头那一列为空数据并记录。
if(parseDB(hc).trim().equals("")) { if(parseDB(hc).trim().equals("")) {
...@@ -58,14 +62,16 @@ public class ExcelUtil { ...@@ -58,14 +62,16 @@ public class ExcelUtil {
} }
else { else {
if(allowEmpty){//允许单元格为空,但不允许整行为空时 if(allowEmpty){//允许单元格为空,但不允许整行为空时
if (!parseDB(hc).trim().equals("")&&emptyColList.get(k)!=-1&&hasEmpty) { //hc != null &&
if (hc != null && !parseDB(hc).trim().equals("")&&emptyColList.get(k)!=-1&&hasEmpty) {
//只要一行中有一个值不为空,即为正确数据 //只要一行中有一个值不为空,即为正确数据
hasEmpty = false; hasEmpty = false;
} }
}else{//不允许单元格为空,只要一行中有一个值为空,即为错误数据 }else{//不允许单元格为空,只要一行中有一个值为空,即为错误数据
hasEmpty = false; hasEmpty = false;
if (parseDB(hc).trim().equals("")&&emptyColList.get(k)!=-1) { //hc != null &&
if (hc != null && parseDB(hc) != null && parseDB(hc).trim().equals("")&&emptyColList.get(k)!=-1) {
//在第j行第k列有空数据,且该列表头不是空的,则舍弃本行数据。 //在第j行第k列有空数据,且该列表头不是空的,则舍弃本行数据。
hasEmpty = true; hasEmpty = true;
...@@ -73,9 +79,14 @@ public class ExcelUtil { ...@@ -73,9 +79,14 @@ public class ExcelUtil {
} }
} }
}
//如果此单元格为空则插入""
if(hc == null){
value[k] = "";
}else {
value[k] = parseDB(hc);
} }
value[k] = parseDB(hc);
//parseDB(hc.getCellType(), hc); //parseDB(hc.getCellType(), hc);
} }
if(j==firstrownum + headNum){ if(j==firstrownum + headNum){
...@@ -140,4 +151,10 @@ public class ExcelUtil { ...@@ -140,4 +151,10 @@ public class ExcelUtil {
return cellValue; return cellValue;
} }
public static Boolean containSunday(HSSFWorkbook hwb){
HSSFRow hssfRow = hwb.getSheetAt(0).getRow(2);
int i = hssfRow.getLastCellNum() - hssfRow.getFirstCellNum();
return i == 29;
}
} }
server:
port: 8081
context-path: /edu #ContextPath must start with '/' and not end with '/'
tomcat:
max-threads: 300
#uri-encoding: UTF-8
#logging:
# path:/working/resource/eduServer/SpringBootLog
# level:
# root: INFO
# org.springframework.web: info
druid:
url: jdbc:mysql://edu2_mysql:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
username: root
password: 123456
initial-size: 1
min-idle: 1
max-active: 20
test-on-borrow: true
mybatis:
mapper-locations: classpath:mapper/**/**/*.xml
mapper:
mappers:
- org.rcisoft.core.base.BaseMapper
not-empty: false
identity: MYSQL
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
spring:
jackson:
default-property-inclusion: non_null
http:
# encoding:
# force: true
# charset: UTF-8
# enabled: true
multipart:
enabled: true
max-file-size: 500Mb
max-request-size: 1000Mb
mvc:
throw-exception-if-no-handler-found: true
resources:
add-mappings: false
redis:
host: edu2_redis
port: 6379
pool:
max-idle: 50
max-active: 1000
min-idle: 5
max-wait: -1
database: 0
password: ''
timeout: 3600
freemarker:
charset: UTF-8
suffix: .ftl
template-loader-path: classpath:/templates/
lxc:
lxc_prefix: lessonLxc
lxc_ports: lxcPorts
lxc_dockerfilePath: /eduLxc
lxc_initPort: 20001
lxc_maxPort: 30000
lxc_minu: 30
lxc_isRemote: 1
lxc_endlineTime: 10
lxc_delayTime: 30
springfox:
documentation:
swagger:
v2:
path: /api-docs
jwt:
header: Authorization
secret: mySecret
expiration: 604800
tokenHead: "Bearer "
login_secert_key: "base64EncodedSecretKey"
route:
authentication:
path: "/login"
refresh: "/refresh"
register: "/register"
global:
default_location:
course: /default/course.jpg
student: /default/student.png
teacher: /default/teacher.png
carousel: /default/carousel.jpg
lk:
publicalias: publiccert
storePwd: rcrtcyedu2
subject: edu2
licPath: /lk/license.lic
pubPath: /lk/publicCerts.store
password:
default: 123456
min_password: 6
max_password: 16
path:
base_upload_server_location: /working/resource/eduServer/
physical_upload_server_location: /working/dockervolume/edu2_data_ubuntu/eduServer
course_location: course
lesson_location: lesson
sl_location: sl
freemarker_location: /freemarker
image_location: /upload
video_location: video
temp_location: temp
file_location: file
ppt_location: ppt
pdf_location: pdf
cut_pdf_location: cutPdf
excel_template_location: excel-template/
cource_logo_location: /course/logo
images_location: /images
lanch_logo_location: /lanch/logo
md_file_location: mdFiles
che_def_template_location: /WEB-INF/classes/che-def-jsonfile/java-mysql.json
che_project_init_location: /working/dockervolume/chedir/project
cource_code_location: code
cource_project_location: project
student_code_location: studentCode
xml_location: /xmlTemp
other:
server_url: http://192.168.1.125:10180/eduServer
is_server_linux: 1
max_code_length: 15
open_office_home: D:/oppenOffice/openOffice
cut_pdf_num: 30
code:
admin: ROLE_1001
teacher: ROLE_1002
student: ROLE_1003
java: '001'
html: '002'
java_simple: '0001'
java_project: '0002'
html_simple: '1001'
html_project: '1002'
serverLxc:
ip: 192.168.1.125
username: root
password: 123456
libreoffice:
ip: 192.168.1.125
port: 10188
#ip:edu2_libre
#port:8997
\ No newline at end of file
...@@ -74,5 +74,4 @@ ...@@ -74,5 +74,4 @@
</root> </root>
</springProfile> </springProfile>
</configuration> </configuration>
\ No newline at end of file
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<result column="description" jdbcType="VARCHAR" property="description"/> <result column="description" jdbcType="VARCHAR" property="description"/>
<result column="status" jdbcType="VARCHAR" property="status"/> <result column="status" jdbcType="VARCHAR" property="status"/>
<result column="agency_code" jdbcType="VARCHAR" property="agencyCode" /> <result column="agency_code" jdbcType="VARCHAR" property="agencyCode" />
<result column="term_name" jdbcType="VARCHAR" property="termName" />
<collection property="childList" javaType="ArrayList" column="{agencyCode=agency_code,arrangeId=business_id}" ofType="org.rcisoft.business.barrange.entity.BSubtask" <collection property="childList" javaType="ArrayList" column="{agencyCode=agency_code,arrangeId=business_id}" ofType="org.rcisoft.business.barrange.entity.BSubtask"
select="org.rcisoft.business.barrange.dao.BArrangeRepository.queryByAgencyCode2" select="org.rcisoft.business.barrange.dao.BArrangeRepository.queryByAgencyCode2"
/> />
...@@ -79,6 +80,7 @@ ...@@ -79,6 +80,7 @@
<result column="thursday" jdbcType="VARCHAR" property="thursday"/> <result column="thursday" jdbcType="VARCHAR" property="thursday"/>
<result column="friday" jdbcType="VARCHAR" property="friday"/> <result column="friday" jdbcType="VARCHAR" property="friday"/>
<result column="saturday" jdbcType="VARCHAR" property="saturday"/> <result column="saturday" jdbcType="VARCHAR" property="saturday"/>
<result column="sunday" jdbcType="VARCHAR" property="saturday"/>
<result column="room_code" jdbcType="VARCHAR" property="roomCode"/> <result column="room_code" jdbcType="VARCHAR" property="roomCode"/>
<result column="classroom_name" jdbcType="VARCHAR" property="roomName"/> <result column="classroom_name" jdbcType="VARCHAR" property="roomName"/>
<result column="sub_agency_id" jdbcType="VARCHAR" property="subAgencyId"/> <result column="sub_agency_id" jdbcType="VARCHAR" property="subAgencyId"/>
...@@ -100,14 +102,15 @@ ...@@ -100,14 +102,15 @@
<insert id="insertList"> <insert id="insertList">
insert into b_schedule_dto(business_id,flag,del_flag,update_by,create_by,create_date,update_date,remarks, insert into b_schedule_dto(business_id,flag,del_flag,update_by,create_by,create_date,update_date,remarks,
lesson_code,teacher_code,class_code,week,class_hour, lesson_code,teacher_code,class_code,week,class_hour,
monday,tuesday,wednesday,thursday,friday,saturday,room_code,sub_agency_id) monday,tuesday,wednesday,thursday,friday,saturday,sunday,room_code,sub_agency_id)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.businessId},#{item.flag},#{item.delFlag},#{item.updateBy},#{item.createBy}, (#{item.businessId},#{item.flag},#{item.delFlag},#{item.updateBy},#{item.createBy},
#{item.createDate},#{item.updateDate},#{item.remarks}, #{item.createDate},#{item.updateDate},#{item.remarks},
#{item.lessonCode},#{item.teacherCode},#{item.classCode}, #{item.lessonCode},#{item.teacherCode},#{item.classCode},
#{item.week},#{item.classHour}, #{item.week},#{item.classHour},
#{item.monday},#{item.tuesday},#{item.wednesday},#{item.thursday},#{item.friday},#{item.saturday},#{item.roomCode},#{item.subAgencyId}) #{item.monday},#{item.tuesday},#{item.wednesday},#{item.thursday},#{item.friday},#{item.saturday},
#{item.sunday},#{item.roomCode},#{item.subAgencyId})
</foreach> </foreach>
</insert> </insert>
......
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