Commit 8fb5bd3c authored by hanshuai's avatar hanshuai

Merge branch 'V2.0.3' of ssh://103.249.252.28:10022/lcy/education

parents ec654a4e 1c525f8f
......@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2018-04-26 10:33:12
Date: 2018-05-02 15:28:30
*/
SET FOREIGN_KEY_CHECKS=0;
......@@ -33,10 +33,3 @@ CREATE TABLE `b_arrange` (
`status` varchar(1) DEFAULT NULL,
PRIMARY KEY (`business_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of b_arrange
-- ----------------------------
INSERT INTO `b_arrange` VALUES ('19aae22e47884deaad96f3470074271e', '333e421d32d9425ea99afce95b603902', '333e421d32d9425ea99afce95b603902', '2018-04-26 10:21:28', '2018-04-26 10:21:28', null, '0', '1', 't001', '哈哈哈', '0');
INSERT INTO `b_arrange` VALUES ('b', 'b', 'b', null, null, null, '0', '1', 'newTerm2', null, '0');
INSERT INTO `b_arrange` VALUES ('e15b02f7030e43ccab0277eacbe307ce', '333e421d32d9425ea99afce95b603902', '333e421d32d9425ea99afce95b603902', '2018-04-19 10:36:49', '2018-04-19 10:36:49', null, '0', '1', 'newTerm', null, '0');
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50627
Source Host : 127.0.0.1:3306
Source Database : edu_db
Target Server Type : MYSQL
Target Server Version : 50627
File Encoding : 65001
Date: 2018-05-02 17:14:01
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for b_company
-- ----------------------------
DROP TABLE IF EXISTS `b_company`;
CREATE TABLE `b_company` (
`business_id` varchar(255) COLLATE utf8_bin NOT NULL,
`code` varchar(15) CHARACTER SET utf8 DEFAULT NULL,
`create_by` varchar(64) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建者',
`update_by` varchar(64) CHARACTER SET utf8 DEFAULT NULL COMMENT '更新者',
`del_flag` varchar(1) CHARACTER SET utf8 DEFAULT NULL COMMENT '删除标记(0:未删除;1:删除)',
`flag` varchar(1) CHARACTER SET utf8 DEFAULT NULL COMMENT '启用标记(0:停用;1:启用)',
`remarks` varchar(64) CHARACTER SET utf8 DEFAULT NULL COMMENT '备注',
`update_date` datetime DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`agency_code` varchar(64) CHARACTER SET utf8 DEFAULT NULL COMMENT '所属教学单位',
PRIMARY KEY (`business_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of b_company
-- ----------------------------
/*
Navicat MySQL Data Transfer
Source Server : 127.0.0.1_3306
Source Server Version : 50717
Source Host : localhost:3306
Source Database : edu_db
Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2018-05-02 09:22:53
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for b_sub_agency
-- ----------------------------
DROP TABLE IF EXISTS `b_sub_agency`;
CREATE TABLE `b_sub_agency` (
`business_id` varchar(64) NOT NULL,
`create_by` varchar(64) DEFAULT NULL,
`update_by` varchar(64) DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`update_date` datetime DEFAULT NULL,
`remarks` varchar(64) DEFAULT NULL,
`del_flag` varchar(1) DEFAULT NULL,
`flag` varchar(1) DEFAULT NULL,
`agency_code` varchar(64) NOT NULL DEFAULT '',
`subtask_id` varchar(64) NOT NULL DEFAULT '',
`status` varchar(1) NOT NULL DEFAULT '',
PRIMARY KEY (`business_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of b_sub_agency
-- ----------------------------
INSERT INTO `b_sub_agency` VALUES ('1', null, null, null, null, null, '0', '1', 'xiaomi', '1', '0');
INSERT INTO `b_sub_agency` VALUES ('10', null, null, null, null, null, '0', '1', 'xiaomi', '4', '0');
INSERT INTO `b_sub_agency` VALUES ('11', null, null, null, null, null, '0', '1', 'huawei', '4', '0');
INSERT INTO `b_sub_agency` VALUES ('12', null, null, null, null, null, '0', '1', 'tengxun', '4', '0');
INSERT INTO `b_sub_agency` VALUES ('2', null, null, null, null, null, '0', '1', 'huawei', '1', '0');
INSERT INTO `b_sub_agency` VALUES ('3', null, null, null, null, null, '0', '1', 'tengxun', '1', '0');
INSERT INTO `b_sub_agency` VALUES ('4', null, null, null, null, null, '0', '1', 'xiaomi', '2', '0');
INSERT INTO `b_sub_agency` VALUES ('5', null, null, null, null, null, '0', '1', 'huawei', '2', '0');
INSERT INTO `b_sub_agency` VALUES ('6', null, null, null, null, null, '0', '1', 'tengxun', '2', '0');
INSERT INTO `b_sub_agency` VALUES ('7', null, null, null, null, null, '0', '1', 'xiaomi', '3', '0');
INSERT INTO `b_sub_agency` VALUES ('8', null, null, null, null, null, '0', '1', 'huawei', '3', '0');
INSERT INTO `b_sub_agency` VALUES ('9', null, null, null, null, null, '0', '1', 'tengxun', '3', '0');
......@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2018-04-26 10:33:46
Date: 2018-05-02 09:25:14
*/
SET FOREIGN_KEY_CHECKS=0;
......@@ -30,7 +30,6 @@ CREATE TABLE `b_subtask` (
`remarks` varchar(128) DEFAULT NULL,
`arrange_id` varchar(64) DEFAULT '',
`name` varchar(256) DEFAULT '',
`agency_code` varchar(64) DEFAULT NULL,
`status` varchar(1) DEFAULT NULL,
`grade_code` varchar(64) DEFAULT NULL,
PRIMARY KEY (`business_id`)
......@@ -39,11 +38,7 @@ CREATE TABLE `b_subtask` (
-- ----------------------------
-- Records of b_subtask
-- ----------------------------
INSERT INTO `b_subtask` VALUES ('1', '1', null, '1', null, '0', '1', null, 'e15b02f7030e43ccab0277eacbe307ce', 'aaa', '假的Code1', '0', null);
INSERT INTO `b_subtask` VALUES ('18228e13a9c14424a9586c76a405f40f', '333e421d32d9425ea99afce95b603902', '2018-04-26 10:21:28', '333e421d32d9425ea99afce95b603902', '2018-04-26 10:21:28', '0', '1', null, '19aae22e47884deaad96f3470074271e', 'aaa', 'xiaomi', '0', null);
INSERT INTO `b_subtask` VALUES ('2', '1', null, '1', null, '0', '1', null, 'e15b02f7030e43ccab0277eacbe307ce', 'bbb', '假的Code2', '0', null);
INSERT INTO `b_subtask` VALUES ('3', '1', null, '1', null, '0', '1', null, 'e15b02f7030e43ccab0277eacbe307ce', 'aaa', '假的Code3', '0', null);
INSERT INTO `b_subtask` VALUES ('4', '1', null, '1', null, '0', '1', null, 'b', 'aaaa', '假的Code4', '0', null);
INSERT INTO `b_subtask` VALUES ('4f3fdf16524949369331a64bed074603', '333e421d32d9425ea99afce95b603902', '2018-04-26 10:21:28', '333e421d32d9425ea99afce95b603902', '2018-04-26 10:21:28', '0', '1', null, '19aae22e47884deaad96f3470074271e', 'aaa', 'hauwei', '0', null);
INSERT INTO `b_subtask` VALUES ('5', '1', null, '1', null, '0', '1', null, 'b', 'bbbb', '假的Code5', '0', null);
INSERT INTO `b_subtask` VALUES ('6', '1', null, '1', null, '0', '1', null, 'b', 'bbbb', '假的Code6', '0', null);
INSERT INTO `b_subtask` VALUES ('1', '1', null, '1', null, '0', '1', null, 'e15b02f7030e43ccab0277eacbe307ce', 'aaa', '0', null);
INSERT INTO `b_subtask` VALUES ('2', '1', null, '1', null, '0', '1', null, 'e15b02f7030e43ccab0277eacbe307ce', 'bbb', '0', null);
INSERT INTO `b_subtask` VALUES ('3', '1', null, '1', null, '0', '1', null, 'b', 'aaa', '0', null);
INSERT INTO `b_subtask` VALUES ('4', '1', null, '1', null, '0', '1', null, 'b', 'bbb', '0', null);
......@@ -90,11 +90,14 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
@ResultMap(value = "scheduleDtoResultMap")
List<ScheduleDto> queryDtoByAgencyMany(String agencyCode,String name,String termCode,@Param("teacherCode") String teacherCode);
@Select("select status from b_sub_agency where subtask_id = #{subTaskId} and del_flag = 0 and flag = 1")
List<String> queryAgencyCode(String subTaskId);
int insertList(ArrayList<ScheduleDto> list);
int insertBSubtask(List<BSubtask> list);
int insertBSubAgency(List<BSubAgency> list);
}
......@@ -14,7 +14,10 @@ import org.rcisoft.business.barrange.entity.ScheduleDto;
import org.rcisoft.business.barrange.service.BArrangeService;
import org.rcisoft.business.bchapter.service.BChapterService;
import org.rcisoft.business.bclass.dao.BClassRepository;
import org.rcisoft.business.bdirection.dao.BDirectionRepository;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonDirection;
import org.rcisoft.business.brooms.dao.BRoomsRepository;
import org.rcisoft.business.bsl.dao.BSlRepository;
import org.rcisoft.business.bsl.entity.BSl;
......@@ -24,6 +27,7 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.ExcelUtil;
import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
......@@ -32,6 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
......@@ -59,7 +64,7 @@ public class BArrangeServiceImpl implements BArrangeService {
private BLessonRepository bLessonRepository;
@Autowired
private SysUserMapper sysUserMapper;
private BDirectionRepository bDirectionRepository;
@Autowired
private BClassRepository bClassRepository;
......@@ -103,7 +108,7 @@ public class BArrangeServiceImpl implements BArrangeService {
for(int j = 0; j < childList2.size() ; j++){
JSONObject agency = childList2.getJSONObject(j);
BSubAgency bSubAgency = new BSubAgency();
bSubAgency.setAgencyCode("agencyCode");
bSubAgency.setAgencyCode(agency.getString("agencyCode"));
bSubAgency.setStatus("0");
bSubAgency.setSubtaskId(bSubtask.getBusinessId());
UserUtil.setCurrentPersistOperation(bSubAgency);
......@@ -263,28 +268,48 @@ public class BArrangeServiceImpl implements BArrangeService {
//当前子任务下有教学单位未完成审核,不能进行开课
throw new ServiceException(ResultServiceEnums.AGENCY_NOT_PASS);
}
List<String> agencyCodes = new ArrayList<>();//bArrangeRepository.queryAgencyCode(subTaskId);
List<String> agencyCodes = bArrangeRepository.queryAgencyCode(subTaskId);
if(agencyCodes.size()<1){
//子任务下没有教学单位
throw new ServiceException(ResultServiceEnums.NO_AGENCY_SUBMISSION);
}
List<BSl> sls = new ArrayList<>();
if(agencyCodes.size()>0){
for(String agencyCode : agencyCodes){
List<ScheduleDto> schedules = bArrangeRepository.queryDtoByAgencyCode(agencyCode);
for(ScheduleDto schedule : schedules){
BSl sl = new BSl();
sl.setLessonCode(schedule.getLessonCode());
sl.setTeacherCode(schedule.getTeacherCode());
sl.setTermCode(termCode);
//学期编号+学期中存放的开课序号最大值+1作为新的开课序号
sl.setCode(termCode+String.valueOf(bTermRepository.queryMaxSlCodeByTermCode(termCode)+1));
sl.setAuditStatus("0");
UserUtil.setCurrentPersistOperation(sl);
sls.add(sl);
bTermRepository.MaxSlCodeByTermCode(termCode);//将该学期的开课序号最大值+1
//复制章节及文件目录
chapterService.addBslFormLesson(null,sl.getLessonCode(), sl.getBusinessId());
for(String agencyCode : agencyCodes){
List<ScheduleDto> schedules = bArrangeRepository.queryDtoByAgencyCode(agencyCode);
for(ScheduleDto schedule : schedules){
BSl sl = new BSl();
BLesson bLesson = bLessonRepository.queryBLessonByCode(schedule.getLessonCode());
//学期编号+学期中存放的开课序号最大值+1作为新的开课序号
int maxSlCode = bTermRepository.queryMaxSlCodeByTermCode(termCode);
//验证开课序号是否重复
String slCode = "";
for(int i=1;i<99999;i++){
slCode = termCode+String.valueOf(maxSlCode+i);
if(bSlRepository.selectOne(new BSl(slCode,"0","1"))==null)
break;
}
result =bSlRepository.insertList(sls);
sl.setCode(slCode);//课序号
sl.setLessonCode(schedule.getLessonCode());//课程编号
sl.setTeacherCode(schedule.getTeacherCode());//教师编号
sl.setTermCode(termCode);//学期编号
sl.setAuditStatus("0");//审核状态
sl.setClassHour(bLesson.getClassHour());//课时
sl.setCredits(bLesson.getCredits());//学分
UserUtil.setCurrentPersistOperation(sl);
sls.add(sl);
bTermRepository.MaxSlCodeByTermCode(termCode);//将该学期的开课序号最大值+1
//课程方向
BLessonDirection bLessonDirection = new BLessonDirection();
bLessonDirection.setBusinessId(IdGen.uuid());
bLessonDirection.setSlId(sl.getBusinessId());
bLessonDirection.setDirectionId(bLesson.getDirectionId());
bDirectionRepository.insertBLessonDirection(bLessonDirection);
//复制章节及文件目录
chapterService.addBslFormLesson(null,sl.getLessonCode(), sl.getBusinessId());
}
result =bSlRepository.insertList(sls);
}
return result;
}
......
......@@ -72,7 +72,7 @@ public class BClassController extends PaginationController<BClass> {
MessageConstant.MESSAGE_ALERT_ERROR,
id);
}
/**
@ApiOperation(value="excel导入", notes="上传excel到服务器")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1001')")
......@@ -84,6 +84,31 @@ public class BClassController extends PaginationController<BClass> {
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
*/
@ApiOperation(value="行政班excel导入", notes="上传excel到服务器")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "administrativeExcelImport")
public Result administrativeExcelImport(MultipartFile importFile, String token) throws Exception {
PersistModel data = bClassService.administrativeImportExcel(MultipartFile2HSSFWorkbookConverter.convert(importFile),token);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
@ApiOperation(value="企业班excel导入", notes="上传excel到服务器")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "businessExcelImport")
public Result businessExcelImport(MultipartFile importFile, String token) throws Exception {
PersistModel data = bClassService.businessImportExcel(MultipartFile2HSSFWorkbookConverter.convert(importFile),token);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
@ApiOperation(value="唯一查找", notes="根据ID查找一条记录")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
......
......@@ -37,17 +37,27 @@ public interface BClassRepository extends BaseMapper<BClass> {
@Insert("<script>INSERT INTO b_class" +
"(create_date,update_date,del_flag,flag,business_id,code,class_name)VALUES" +
"(create_date,update_date,del_flag,flag,business_id,code,class_name,grade_code)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.className})" +
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.className},#{item.gradeCode})" +
"</foreach></script>")
int insertList(List<BClass> bClasses);
@Insert("<script>INSERT INTO b_class" +
"(create_date,update_date,del_flag,flag,business_id,code,class_name,grade_code,type,agency_code)VALUES" +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.className},#{item.gradeCode},#{item.type},#{item.agencyCode})" +
"</foreach></script>")
int insertBusinessClassList(List<BClass> bClasses);
@Select("select * from b_class where del_flag != 1 and flag = 1")
@ResultMap(value = "BaseResultMap" )
List<BClass> queryBClassList();
@Select("select class_name from b_class where find_in_set(code,#{classesCode}) and del_flag != 1 and flag = 1")
List<String> queryClassNamesByIds(String classesCode);
@Select("select * from b_grade where code = #{gradeCode} and del_flag = 0 and flag = 1")
List<BClass> checkGrade(BClass bClass);
}
......@@ -51,11 +51,29 @@ public interface BClassService{
PersistModel removeBClass(String id);
/**
* 班级信息excel导入
* excel导入
* @param
* @return
*/
// PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException;
/**
* 行政班excel导入
* @param hwb
* @param token
* @return
* @throws IOException
*/
PersistModel administrativeImportExcel(HSSFWorkbook hwb, String token) throws IOException;
/**
* 企业版excel导入
* @param hwb
* @param token
* @return
* @throws IOException
*/
PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException;
PersistModel businessImportExcel(HSSFWorkbook hwb, String token) throws IOException;
List<SelectModel> queryBClassList();
}
......@@ -6,6 +6,7 @@ import org.rcisoft.business.bclass.dao.BClassRepository;
import org.rcisoft.business.bclass.entity.BClass;
import org.rcisoft.business.bclass.service.BClassService;
import org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository;
import org.rcisoft.business.bstudent.entity.BStudent;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException;
......@@ -78,14 +79,70 @@ public class BClassServiceImpl implements BClassService {
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
/**
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException {
ArrayList<BClass> bClasses = new ArrayList<BClass>();
ArrayList<String> repeatCode = new ArrayList<String>();
String[] headers = {"班级编号","班级名称"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false); //获取excel数据
if (values.size()<=0){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
}
for(String[] value:values){ //将数据封装到entity
BClass bClass = null;
BClass b = new BClass(value[0]);
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
continue;
}
if((bClass=bClassRepository.selectOne(b))!=null) {
repeatCode.add(value[0]);
continue;
}
bClass= new BClass(value[0],value[1]);
bClass.setCommonBusinessId();
UserUtil.setCurrentPersistOperation(bClass);
if(!bClasses.contains(bClass)){
bClasses.add(bClass);
}
}
if(bClasses.size()<1){
if(repeatCode.size()<1)
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
else
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),"Excel内所有数据之前都已经导入:"+ JSON.toJSONString(repeatCode));
}
String result = ExcelUtil.checkRepeat(repeatCode);
int line = bClassRepository.insertList(bClasses);
return new PersistModel(line,result);
}
*/
/**
* 行政班导入
* @param hwb
* @param token
* @return
* @throws IOException
*/
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException {
public PersistModel administrativeImportExcel(HSSFWorkbook hwb, String token) throws IOException {
ArrayList<BClass> bClasses = new ArrayList<BClass>();
ArrayList<String> repeatCode = new ArrayList<String>();
String[] headers = {"班级编号","班级名称"};
String[] headers = {"班级编号","班级名称","所属年级"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false); //获取excel数据
//判断年级是否存在
List<String> valuesGrade = new ArrayList<>();
if (values.size()<=0){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
......@@ -101,7 +158,16 @@ public class BClassServiceImpl implements BClassService {
repeatCode.add(value[0]);
continue;
}
//判断:学年是否存在,存在才能录入
BClass b1 = new BClass();
b1.setGradeCode(value[2]);
if (bClassRepository.checkGrade(b1).size() == 0){
valuesGrade.add(value[2]);
continue;
}
bClass= new BClass(value[0],value[1]);
bClass.setGradeCode(value[2]);
bClass.setCommonBusinessId();
UserUtil.setCurrentPersistOperation(bClass);
......@@ -120,6 +186,71 @@ public class BClassServiceImpl implements BClassService {
String result = ExcelUtil.checkRepeat(repeatCode);
int line = bClassRepository.insertList(bClasses);
if(valuesGrade.size()>0){
result+="以下班级的所属年级信息不存在:"+ JSON.toJSONString(valuesGrade)+"。";
}
return new PersistModel(line,result);
}
@Override
public PersistModel businessImportExcel(HSSFWorkbook hwb, String token) {
ArrayList<BClass> bClasses = new ArrayList<BClass>();
ArrayList<String> repeatCode = new ArrayList<String>();
String[] headers = {"班级编号","班级名称","所属年级","教学单位"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false); //获取excel数据
//判断年级是否存在
List<String> valuesGrade = new ArrayList<>();
if (values.size()<=0){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
}
for(String[] value:values){ //将数据封装到entity
BClass bClass = null;
BClass b = new BClass(value[0]);
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
continue;
}
if((bClass=bClassRepository.selectOne(b))!=null) {
repeatCode.add(value[0]);
continue;
}
//判断:学年是否存在,存在才能录入
BClass b1 = new BClass();
b1.setGradeCode(value[2]);
if (bClassRepository.checkGrade(b1).size() == 0){
valuesGrade.add(value[2]);
continue;
}
bClass= new BClass(value[0],value[1]);
bClass.setGradeCode(value[2]);
bClass.setAgencyCode(value[3]);
bClass.setType("1");
bClass.setCommonBusinessId();
UserUtil.setCurrentPersistOperation(bClass);
if(!bClasses.contains(bClass)){
bClasses.add(bClass);
}
}
if(bClasses.size()<1){
if(repeatCode.size()<1)
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
else
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),"Excel内所有数据之前都已经导入:"+ JSON.toJSONString(repeatCode));
}
String result = ExcelUtil.checkRepeat(repeatCode);
int line = bClassRepository.insertBusinessClassList(bClasses);
if(valuesGrade.size()>0){
result+="以下班级的所属年级信息不存在:"+ JSON.toJSONString(valuesGrade)+"。";
}
return new PersistModel(line,result);
}
......
package org.rcisoft.business.bcompany.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.business.bcompany.service.BCompanyService;
import org.rcisoft.business.bstudent.entity.BStudent;
import org.rcisoft.common.component.Global;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.converter.MultipartFile2HSSFWorkbookConverter;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* Created by Administrator on 2018/5/2.
*/
@RestController
@RequestMapping("/BCompany")
public class BCompanyController extends PaginationController<BCompany> {
@Autowired
private BCompanyService bCompanyService;
@Autowired
private Global global;
@ApiOperation(value="添加/编辑学生信息", notes="businessId为空时是添加方法,不为空时是修改方法")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "code", value = "工号", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "name", value = "姓名", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "agencyCode", value = "所属教学单位", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "roleId", value = "角色Id", required = true, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(BCompany bCompany, SysUser user) throws UnsupportedEncodingException {
user.setLoginName(bCompany.getCode());
PersistModel data = bCompanyService.persist(bCompany,user);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bCompany);
}
@ApiOperation(value="唯一查找", notes="根据ID查找一条记录")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
@GetMapping(value = "/one")
public Result queryOne(String businessId) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bCompanyService.selectOne(businessId));
}
@ApiOperation(value="根据条件分页查询", notes="根据条件分页查询学生信息")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "code", value = "学号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "isRecommend", value = "0:未推荐,1:推荐", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "recommendDate", value = "推荐时间,排序依据", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "recommendOrder", value = "推荐排序", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "recommendCourse", value = "推荐原因", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")})
@GetMapping(value = "/queryCompanysByPagination")
public GridModel queryCompanysByPagination(BCompany param) {
bCompanyService.queryCompanysByPagination(getPaginationUtility(),param);
GridModel gridModel = getGridModelResponse();
return gridModel;
}
@ApiOperation(value="逻辑删除", notes="根据ID删除一条记录")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
@PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "/remove")
public Result remove(String businessId) {
PersistModel data = bCompanyService.removeBCompany(businessId);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
@ApiOperation(value="根据条件查询", notes="根据条件查询学生信息")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "code", value = "学号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "isRecommend", value = "0:未推荐,1:推荐", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "recommendDate", value = "推荐时间,排序依据", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "recommendOrder", value = "推荐排序", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "recommendCourse", value = "推荐原因", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "remarks", value = "备注", required = false, dataType = "varchar")})
@GetMapping(value = "/queryBStudents")
public Result queryBStudents(BCompany param) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bCompanyService.queryBStudents(param));
}
}
package org.rcisoft.business.bcompany.dao;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.core.base.BaseMapper;
import java.util.List;
/**
* Created by Administrator on 2018/5/2.
*/
public interface BCompanyRepository extends BaseMapper<BCompany>{
@Select("<script>SELECT bc.*,ba.name as agencyName,su.`name` as name FROM b_company bc \n" +
"LEFT JOIN s_user su on su.login_name = bc.`code`\n" +
"LEFT JOIN b_agency ba on ba.`code` = bc.agency_code" +
"where bc.del_flag != 1 and bc.flag = 1 "+
"<if test=\"name!=null and name != ''\">and su.`name` like CONCAT('%',#{name},'%') </if>"+
"<if test=\"code!=null and code != ''\">and bc.`code` like CONCAT('%',#{code},'%') </if></script>")
@ResultMap(value = "BaseResultMap" )
List<BCompany> queryCompanys(BCompany param);
}
package org.rcisoft.business.bcompany.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* Created by Administrator on 2018/5/2.
*/
@Data
@Entity
@Table(name="b_company")
@NoArgsConstructor
@AllArgsConstructor
public class BCompany extends IdEntity<BCompany>{
private static final long serialVersionUID = 7782295246567640194L;
private String code;
private String agencyCode;
@Transient
private String name;
@Transient
private String agencyName;
public BCompany(String businessId, String delFlag, String flag) {
this.businessId = businessId;
this.delFlag = delFlag;
this.flag = flag;
}
}
package org.rcisoft.business.bcompany.service;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.sys.user.entity.SysUser;
import java.util.List;
/**
* Created by Administrator on 2018/5/2.
*/
public interface BCompanyService {
PersistModel persist(BCompany bCompany, SysUser user);
BCompany selectOne(String businessId);
List<BCompany> queryCompanysByPagination(PageUtil pageUtil, BCompany param);
PersistModel removeBCompany(String businessId);
List<BCompany> queryBStudents(BCompany param);
}
package org.rcisoft.business.bcompany.service.impl;
import org.rcisoft.business.bcompany.dao.BCompanyRepository;
import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.business.bcompany.service.BCompanyService;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.entity.DataEntity;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.entity.UserRole;
import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by Administrator on 2018/5/2.
*/
@Service
public class BCompanyServiceImpl implements BCompanyService{
@Autowired
private BCompanyRepository bCompanyRepository;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private Global global;
@Autowired
private SysUserService userService;
@Override
public PersistModel persist(BCompany model, SysUser user) {
int line = 0;
BeanUtils.copyProperties((DataEntity) model, (DataEntity) user);
if (model.getBusinessId() == null) { //添加
if (sysUserMapper.selectOne(new SysUser(model.getCode(),"0","1")) != null)
throw new ServiceException(ResultServiceEnums.COMPANY_EXISTS);
//1. 添加s_user
UserUtil.setCurrentPersistOperation(user);
user.setHeadPic(global.getDEFAULT_TEACHER_LOCATION());
userService.persistUser(user);
//2.添加b_company
UserUtil.setCurrentPersistOperation(model);
line = bCompanyRepository.insertSelective(model);
} else { //修改
String uid = sysUserMapper.selectUserIdByStuOrTeaId(model.getBusinessId(), "b_company");
if (uid == null)
throw new ServiceException(ResultServiceEnums.COMPANY_NOT_EXISTS);
UserUtil.setCurrentMergeOperation(model);
line = bCompanyRepository.updateByPrimaryKeySelective(model);
userService.updateUser(user,uid,line);
//删除原来角色
sysUserMapper.deleteUserRole(user.getBusinessId());
}
//添加新的角色
UserRole userRole = new UserRole(user.getBusinessId(),user.getRoleId());
userRole.setCommonBusinessId();
sysUserMapper.insertUserRole(userRole);
return new PersistModel(line);
}
@Override
public BCompany selectOne(String businessId) {
return bCompanyRepository.selectOne(new BCompany(businessId,"0","1"));
}
@Override
public List<BCompany> queryCompanysByPagination(PageUtil pageUtil, BCompany param) {
return bCompanyRepository.queryCompanys(param);
}
@Override
public PersistModel removeBCompany(String businessId) {
BCompany company = bCompanyRepository.selectOne(new BCompany(businessId,"0","1"));
sysUserMapper.deleteByCode(company.getCode());
BCompany bCompany = new BCompany();
bCompany.setDeleted();
UserUtil.setCurrentMergeOperation(bCompany);
int line = bCompanyRepository.logicalDelete(bCompany);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
@Override
public List<BCompany> queryBStudents(BCompany param) {
return bCompanyRepository.queryCompanys(param);
}
}
......@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bclass.entity.BClass;
import org.rcisoft.business.bstudent.entity.BStudent;
import org.rcisoft.business.bstudent.entity.BStudentDto;
import org.rcisoft.core.base.BaseMapper;
......@@ -166,7 +167,7 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
List<BStudent> queryStudentsByClassCode(String classCode);
@Select("select * from b_grade where code = #{gradeCode} and del_flag = 0 and flag = 1")
List<BStudent> checkStudentGrade(BStudent bStudent);
List<BClass> checkStudentGrade(BStudent bStudent);
}
......@@ -160,7 +160,13 @@ public enum ResultServiceEnums {
CODE_IS_EXISTS (86,"编号重复"),
AGENCY_NOT_PASS (87,"有教学单位未完成审核,不能进行开课")
AGENCY_NOT_PASS (87,"有教学单位未完成审核,不能进行开课"),
NO_AGENCY_SUBMISSION (88,"暂无教学单位提交审核"),
COMPANY_EXISTS(89,"该编号已经存在"),
COMPANY_NOT_EXISTS(90,"用户不存在"),
;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.bcompany.dao.BCompanyRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.bcompany.entity.BCompany">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="code" jdbcType="INTEGER" property="code"/>
<result column="agency_code" jdbcType="INTEGER" property="agencyCode"/>
</resultMap>
</mapper>
\ No newline at end of file
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