Commit 205baad6 authored by hanshuai's avatar hanshuai

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

parents fd2711d5 e27c569b
...@@ -94,3 +94,7 @@ ALTER TABLE `s_user` ...@@ -94,3 +94,7 @@ ALTER TABLE `s_user`
ALTER TABLE `b_schedule_dto` ALTER TABLE `b_schedule_dto`
ADD COLUMN `sunday` varchar(64) NULL AFTER `sub_agency_id`; ADD COLUMN `sunday` varchar(64) NULL AFTER `sub_agency_id`;
/*意见表新增sub_agency_id,与开课id进行区分*/
ALTER TABLE `b_opinion`
ADD COLUMN `sub_agency_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '子任务下教学单位id' AFTER `flag`;
...@@ -37,7 +37,6 @@ public class BArrangeController extends PaginationController<BArrange> { ...@@ -37,7 +37,6 @@ public class BArrangeController extends PaginationController<BArrange> {
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) //@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add") @PostMapping(value = "/add")
public Result add(String json) { public Result add(String json) {
System.out.println(json);
return Result.builder(bArrangeServiceImpl.save(json), return Result.builder(bArrangeServiceImpl.save(json),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -27,7 +27,7 @@ public interface BArrangeRepository extends BaseMapper<BArrange> { ...@@ -27,7 +27,7 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
+ "<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> "
+ "order by b_arrange.status,b_arrange.create_date desc" + "GROUP BY b_arrange.business_id order by b_arrange.status,b_arrange.create_date desc "
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMapByAgencyCode") @ResultMap(value = "BaseResultMapByAgencyCode")
List<BArrange> queryByAgencyCode(BArrange bArrange); List<BArrange> queryByAgencyCode(BArrange bArrange);
...@@ -40,10 +40,10 @@ public interface BArrangeRepository extends BaseMapper<BArrange> { ...@@ -40,10 +40,10 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
//维护人员查看全部的排课信息---------------------------------------------------------------------------------------- //维护人员查看全部的排课信息----------------------------------------------------------------------------------------
@Select("<script>select b_arrange.*,b_term.name from b_arrange left join b_term on b_term.code = b_arrange.term_code where 1=1 " @Select("<script>select b_arrange.*,b_term.name from b_arrange left join b_term on b_term.code = b_arrange.term_code where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> " + "<if test=\"delFlag !=null and delFlag != '' \">and b_arrange.del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> " + "<if test=\"flag !=null and flag != '' \">and b_arrange.flag = #{flag} </if> "
+ "<if test=\"termCode !=null and termCode != '' \">and term_code = #{termCode} </if> " + "<if test=\"termCode !=null and termCode != '' \">and term_code = #{termCode} </if> "
+ "<if test=\"status !=null and status != '' \">and status = #{status} </if> " + "<if test=\"status !=null and status != '' \">and b_arrange.status = #{status} </if> "
+ "order by b_arrange.status,b_arrange.create_date desc" + "order by b_arrange.status,b_arrange.create_date desc"
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap2") @ResultMap(value = "BaseResultMap2")
...@@ -77,13 +77,14 @@ public interface BArrangeRepository extends BaseMapper<BArrange> { ...@@ -77,13 +77,14 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
// @ResultMap(value = "scheduleDtoResultMap") // @ResultMap(value = "scheduleDtoResultMap")
// List<ScheduleDto> queryDtoByAgencySubtaskId(String bSubtaskId); // List<ScheduleDto> queryDtoByAgencySubtaskId(String bSubtaskId);
@Select("<script>select *,b_edu_class.class_name,b_lesson.lesson_name,b_rooms.classroom_name,s_user.`name` as teacher_name from b_schedule_dto " + @Select("<script>select b_schedule_dto.*,b_edu_class.class_name,b_lesson.lesson_name,b_rooms.classroom_name,s_user.`name` as teacher_name from b_schedule_dto " +
"LEFT JOIN b_edu_class on b_edu_class.`code` = b_schedule_dto.class_code " + "LEFT JOIN b_edu_class on b_edu_class.`code` = b_schedule_dto.class_code " +
"LEFT JOIN b_lesson on b_lesson.`code` = b_schedule_dto.lesson_code " + "LEFT JOIN b_lesson on b_lesson.`code` = b_schedule_dto.lesson_code " +
"LEFT JOIN b_rooms on b_rooms.`code` = b_schedule_dto.room_code " + "LEFT JOIN b_rooms on b_rooms.`code` = b_schedule_dto.room_code " +
"LEFT JOIN b_teacher on b_teacher.`code` = b_schedule_dto.teacher_code " + "LEFT JOIN b_teacher on b_teacher.`code` = b_schedule_dto.teacher_code " +
"LEFT JOIN s_user on s_user.login_name = b_teacher.`code` " + "LEFT JOIN s_user on s_user.login_name = b_teacher.`code` " +
"where sub_agency_id = #{subAgencyId} " + "where sub_agency_id = #{subAgencyId} " +
"GROUP BY lesson_code,teacher_code,class_code " +
"</script>") "</script>")
@ResultMap(value = "scheduleDtoResultMap") @ResultMap(value = "scheduleDtoResultMap")
List<ScheduleDto> queryDtoBySubAgencyId(String subAgencyId); List<ScheduleDto> queryDtoBySubAgencyId(String subAgencyId);
...@@ -148,5 +149,7 @@ public interface BArrangeRepository extends BaseMapper<BArrange> { ...@@ -148,5 +149,7 @@ public interface BArrangeRepository extends BaseMapper<BArrange> {
@Update("update b_arrange set del_flag = 1 where business_id = #{0}") @Update("update b_arrange set del_flag = 1 where business_id = #{0}")
int deleteArrange(String businessId); int deleteArrange(String businessId);
@Select("select count(*) from b_schedule_dto where room_code = ( select `code` from b_rooms where business_id = #{businessId})")
int countThisRoomNum(String businessId);
} }
...@@ -32,6 +32,7 @@ import org.rcisoft.business.bteacher.dao.BTeacherRepository; ...@@ -32,6 +32,7 @@ import org.rcisoft.business.bteacher.dao.BTeacherRepository;
import org.rcisoft.business.bteacher.entity.BTeacher; import org.rcisoft.business.bteacher.entity.BTeacher;
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.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
...@@ -214,6 +215,8 @@ public class BArrangeServiceImpl implements BArrangeService { ...@@ -214,6 +215,8 @@ public class BArrangeServiceImpl implements BArrangeService {
*/ */
@Override @Override
public List<BArrange> findAllByPagination(PageUtil paginationUtility, BArrange bArrange){ public List<BArrange> findAllByPagination(PageUtil paginationUtility, BArrange bArrange){
bArrange.setNotDeleted();
bArrange.setStart();
List<BArrange> list = bArrangeRepository.queryAll(bArrange); List<BArrange> list = bArrangeRepository.queryAll(bArrange);
return list; return list;
} }
...@@ -227,6 +230,8 @@ public class BArrangeServiceImpl implements BArrangeService { ...@@ -227,6 +230,8 @@ public class BArrangeServiceImpl implements BArrangeService {
else { else {
bArrange.setStatus("1,2,3,4"); bArrange.setStatus("1,2,3,4");
} }
bArrange.setStart();
bArrange.setNotDeleted();
return bArrangeRepository.queryByAgencyCode(bArrange); return bArrangeRepository.queryByAgencyCode(bArrange);
} }
...@@ -674,11 +679,18 @@ public class BArrangeServiceImpl implements BArrangeService { ...@@ -674,11 +679,18 @@ public class BArrangeServiceImpl implements BArrangeService {
public Map<String,Object> selectSubAgencyAndOption(String subAgencyId) { public Map<String,Object> selectSubAgencyAndOption(String subAgencyId) {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
BSubAgency bSubAgency = bArrangeRepository.selectSubAgencyAndOption(subAgencyId); BSubAgency bSubAgency = bArrangeRepository.selectSubAgencyAndOption(subAgencyId);
BTerm bTerm = bTermRepository.queryBtermByCode(bSubAgency.getTermCode()).get(0);
Map<String,Object> weeks = Week.buildWeek(bTerm.getStartDate(),bTerm.getEndDate());
List<BTeacher> bTeachers = bTeacherRepository.selectTeacherBySubAgencyId(subAgencyId); List<BTeacher> bTeachers = bTeacherRepository.selectTeacherBySubAgencyId(subAgencyId);
List<BEduClass> bEduClasses = bEduClassRepository.selectClassBySubAgencyId(subAgencyId); List<BEduClass> bEduClasses = bEduClassRepository.selectClassBySubAgencyId(subAgencyId);
map.put("bSubAgency",bSubAgency); map.put("bSubAgency",bSubAgency);
map.put("teacherList",bTeachers); map.put("teacherList",bTeachers);
map.put("classList",bEduClasses); map.put("classList",bEduClasses);
int currentlyWeek = (int) weeks.get("currentlyWeek");
if(currentlyWeek == 0){
currentlyWeek = -1;
}
map.put("currentlyWeek",currentlyWeek);
return map; return map;
} }
......
...@@ -143,7 +143,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -143,7 +143,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>();
String[] headers = {"班级编号","班级名称","所属年级"}; String[] headers = {"班级编号","学号","所属年级"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
//判断年级是否存在 //判断年级是否存在
List<String> valuesGrade = new ArrayList<>(); List<String> valuesGrade = new ArrayList<>();
......
...@@ -17,7 +17,7 @@ public interface BCompanyRepository extends BaseMapper<BCompany>{ ...@@ -17,7 +17,7 @@ public interface BCompanyRepository extends BaseMapper<BCompany>{
@Select("<script>SELECT bc.*,ba.name as agencyName,su.`name` as name," + @Select("<script>SELECT bc.*,ba.name as agencyName,su.`name` as name," +
"sr.role_name as roleName,sr.`code` as roleCode " + "sr.role_name as roleName,sr.`code` as roleCode,sr.business_id as roleId " +
"FROM b_company bc \n" + "FROM b_company bc \n" +
"LEFT JOIN s_user su on su.login_name = bc.`code`\n" + "LEFT JOIN s_user su on su.login_name = bc.`code`\n" +
"LEFT JOIN b_agency ba on ba.`code` = bc.agency_code \n" + "LEFT JOIN b_agency ba on ba.`code` = bc.agency_code \n" +
......
...@@ -38,6 +38,9 @@ public class BCompany extends IdEntity<BCompany>{ ...@@ -38,6 +38,9 @@ public class BCompany extends IdEntity<BCompany>{
@Transient @Transient
private String roleName; private String roleName;
@Transient
private String roleId;
public BCompany(String businessId, String delFlag, String flag) { public BCompany(String businessId, String delFlag, String flag) {
this.businessId = businessId; this.businessId = businessId;
this.delFlag = delFlag; this.delFlag = delFlag;
......
...@@ -4,6 +4,7 @@ import org.rcisoft.business.bcompany.dao.BCompanyRepository; ...@@ -4,6 +4,7 @@ import org.rcisoft.business.bcompany.dao.BCompanyRepository;
import org.rcisoft.business.bcompany.entity.BCompany; import org.rcisoft.business.bcompany.entity.BCompany;
import org.rcisoft.business.bcompany.service.BCompanyService; import org.rcisoft.business.bcompany.service.BCompanyService;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.common.util.TableUtil;
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.entity.DataEntity; import org.rcisoft.core.entity.DataEntity;
...@@ -11,6 +12,7 @@ import org.rcisoft.core.exception.ServiceException; ...@@ -11,6 +12,7 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
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.rcisoft.sys.role.dao.SysRoleRepository;
import org.rcisoft.sys.user.dao.SysUserMapper; import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser; import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.entity.UserRole; import org.rcisoft.sys.user.entity.UserRole;
...@@ -39,6 +41,10 @@ public class BCompanyServiceImpl implements BCompanyService{ ...@@ -39,6 +41,10 @@ public class BCompanyServiceImpl implements BCompanyService{
@Autowired @Autowired
private SysUserService userService; private SysUserService userService;
@Autowired
private SysRoleRepository sysRoleRepository;
@Override @Override
public PersistModel persist(BCompany model, SysUser user) { public PersistModel persist(BCompany model, SysUser user) {
int line = 0; int line = 0;
...@@ -85,16 +91,12 @@ public class BCompanyServiceImpl implements BCompanyService{ ...@@ -85,16 +91,12 @@ public class BCompanyServiceImpl implements BCompanyService{
@Override @Override
public PersistModel removeBCompany(String businessId) { public PersistModel removeBCompany(String businessId) {
BCompany company = bCompanyRepository.selectOne(new BCompany(businessId,"0","1")); /*删除关联角色*/
sysUserMapper.deleteByCode(company.getCode()); sysRoleRepository.deleteUserRoleByChildrenId(TableUtil.getTableByKey("1"),businessId);
/*删除sys_user*/
BCompany bCompany = new BCompany(); sysUserMapper.deleteByCompany(businessId);
bCompany.setDeleted(); /*删除b_company*/
bCompany.setBusinessId(businessId); int line = bCompanyRepository.deleteByPrimaryKey(businessId);
UserUtil.setCurrentMergeOperation(bCompany);
int line = bCompanyRepository.logicalDelete(bCompany);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
......
...@@ -44,5 +44,8 @@ public interface BEduClassRepository extends BaseMapper<BEduClass> { ...@@ -44,5 +44,8 @@ public interface BEduClassRepository extends BaseMapper<BEduClass> {
"left JOIN b_edu_class on b_schedule_dto.class_code = b_edu_class.code where sub_agency_id = #{subAgencyId} GROUP BY `code` ") "left JOIN b_edu_class on b_schedule_dto.class_code = b_edu_class.code where sub_agency_id = #{subAgencyId} GROUP BY `code` ")
@ResultMap(value = "SmallBaseResultMap" ) @ResultMap(value = "SmallBaseResultMap" )
List<BEduClass> selectClassBySubAgencyId(String subAgencyId); List<BEduClass> selectClassBySubAgencyId(String subAgencyId);
} }
...@@ -59,5 +59,7 @@ public class BEduClass extends IdEntity<BEduClass> { ...@@ -59,5 +59,7 @@ public class BEduClass extends IdEntity<BEduClass> {
@Transient @Transient
private String gradeName; private String gradeName;
@Transient
private int studentNum;
} }
...@@ -38,4 +38,10 @@ public interface BOpinionRepository extends BaseMapper<BOpinion> { ...@@ -38,4 +38,10 @@ public interface BOpinionRepository extends BaseMapper<BOpinion> {
@ResultMap("SubTaskResult") @ResultMap("SubTaskResult")
BSubtask querySubtaskInfo(String id); BSubtask querySubtaskInfo(String id);
@Select("select b_opinion.*,s_user.name as create_person from b_opinion left join s_user on b_opinion.create_by = s_user.business_id " +
"where b_opinion.sub_agency_id = #{subAgencyId} order by create_date DESC")
@ResultMap(value = "BaseResultMap")
List<BOpinion> queryOpinionBySubAgencyId(String subAgencyId);
} }
...@@ -23,6 +23,7 @@ import java.util.Date; ...@@ -23,6 +23,7 @@ import java.util.Date;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class BOpinion extends IdEntity<BOpinion> { public class BOpinion extends IdEntity<BOpinion> {
private static final long serialVersionUID = 1300895032499081565L;
// @Length(min = 1,max = 64,message = "长度最小为1,最大为50") // @Length(min = 1,max = 64,message = "长度最小为1,最大为50")
// @NotBlank // @NotBlank
...@@ -37,10 +38,15 @@ public class BOpinion extends IdEntity<BOpinion> { ...@@ -37,10 +38,15 @@ public class BOpinion extends IdEntity<BOpinion> {
@NotBlank @NotBlank
private String slId; private String slId;
private String subAgencyId;
@Transient
private String arrangeId; private String arrangeId;
@Transient
private String agencyCode; private String agencyCode;
@Transient
private String subtaskId; private String subtaskId;
@Transient @Transient
......
...@@ -87,7 +87,7 @@ public class BOpinionServiceImpl implements BOpinionService{ ...@@ -87,7 +87,7 @@ public class BOpinionServiceImpl implements BOpinionService{
public PersistModel save(String opinion,String id) { public PersistModel save(String opinion,String id) {
BOpinion bOpinion = new BOpinion(); BOpinion bOpinion = new BOpinion();
bOpinion.setOpinion(opinion); bOpinion.setOpinion(opinion);
bOpinion.setSlId(id); bOpinion.setSubAgencyId(id);
UserUtil.setCurrentPersistOperation(bOpinion); UserUtil.setCurrentPersistOperation(bOpinion);
//插入意见表b_opinion //插入意见表b_opinion
int line = bOpinionRepository.insertSelective(bOpinion); int line = bOpinionRepository.insertSelective(bOpinion);
......
...@@ -55,12 +55,25 @@ public class BRClassStudentController extends PaginationController<BRClassStuden ...@@ -55,12 +55,25 @@ public class BRClassStudentController extends PaginationController<BRClassStuden
stuCode); stuCode);
} }
@ApiOperation(value="excel导入", notes="excel导入") @ApiOperation(value="行政班excel导入", notes="行政班excel导入")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile") @ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1001')") @PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "excelImport") @PostMapping(value = "administrationExcelImport")
public Result excelImport(MultipartFile importFile) throws Exception { public Result administrationExcelImport(MultipartFile importFile) throws Exception {
PersistModel data = bRClassStudentService.importExcel(MultipartFile2HSSFWorkbookConverter.convert(importFile)); PersistModel data = bRClassStudentService.administrationExcelImport(MultipartFile2HSSFWorkbookConverter.convert(importFile));
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
data.getInfluenceReason());
}
@ApiOperation(value="企业班excel导入", notes="企业班excel导入")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "enterpriseExcelImport")
public Result enterpriseExcelImport(MultipartFile importFile) throws Exception {
PersistModel data = bRClassStudentService.enterpriseExcelImport(MultipartFile2HSSFWorkbookConverter.convert(importFile));
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -47,11 +47,13 @@ public interface BRClassStudentService{ ...@@ -47,11 +47,13 @@ public interface BRClassStudentService{
* @param hwb * @param hwb
* @return * @return
*/ */
PersistModel importExcel(HSSFWorkbook hwb) throws IOException; PersistModel administrationExcelImport(HSSFWorkbook hwb) throws IOException;
/** /**
* 物理删除 * 物理删除
* @return * @return
*/ */
PersistModel removeBRClassStudents(String stuCode, String classCode); PersistModel removeBRClassStudents(String stuCode, String classCode);
PersistModel enterpriseExcelImport(HSSFWorkbook convert);
} }
...@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bagency.dao.BAgencyRepository;
import org.rcisoft.business.bagency.entity.BAgency;
import org.rcisoft.business.bclass.dao.BClassRepository; import org.rcisoft.business.bclass.dao.BClassRepository;
import org.rcisoft.business.bclass.entity.BClass; import org.rcisoft.business.bclass.entity.BClass;
import org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository; import org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository;
...@@ -40,6 +42,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -40,6 +42,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
private BClassRepository bClassRepository; private BClassRepository bClassRepository;
@Autowired @Autowired
private BStudentRepository bStudentRepository; private BStudentRepository bStudentRepository;
@Autowired
private BAgencyRepository bAgencyRepository;
@Override @Override
public BRClassStudent selectOne(String businessId){ public BRClassStudent selectOne(String businessId){
...@@ -76,13 +80,14 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -76,13 +80,14 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel importExcel(HSSFWorkbook hwb) throws IOException { public PersistModel administrationExcelImport(HSSFWorkbook hwb) throws IOException {
ArrayList<BRClassStudent> brClassStudents = new ArrayList<BRClassStudent>(); ArrayList<BRClassStudent> brClassStudents = new ArrayList<BRClassStudent>();
ArrayList<String> studentCode = new ArrayList<String>(); ArrayList<String> studentCode = new ArrayList<String>();
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<>();
String[] headers = {"班级编号","学号"}; String[] headers = {"班级编号","学号","年级编号"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据 ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
if (values.size()<=0){ if (values.size()<=0){
...@@ -120,6 +125,14 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -120,6 +125,14 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
continue; continue;
} }
//判断:学年是否存在,存在才能录入
BClass b1 = new BClass();
b1.setGradeCode(value[2]);
if (bClassRepository.checkGrade(b1).size() == 0){
valuesGrade.add(value[2]);
continue;
}
//1.4 构造学生班级信息 //1.4 构造学生班级信息
brClassStudent= new BRClassStudent(value[0],value[1]); brClassStudent= new BRClassStudent(value[0],value[1]);
...@@ -156,6 +169,9 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -156,6 +169,9 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
nullResult.append("以下学生学号不存在:").append(JSON.toJSONString(studentCode)).append("。"); nullResult.append("以下学生学号不存在:").append(JSON.toJSONString(studentCode)).append("。");
// nullResult.append("部分学生不存在,请检查后重新上传"); // nullResult.append("部分学生不存在,请检查后重新上传");
} }
if(valuesGrade.size()>0){
result+="以下年级不存在:"+ JSON.toJSONString(valuesGrade)+"。";
}
result+=nullResult; result+=nullResult;
...@@ -190,5 +206,127 @@ public class BRClassStudentServiceImpl implements BRClassStudentService { ...@@ -190,5 +206,127 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
return new PersistModel(line); return new PersistModel(line);
} }
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel enterpriseExcelImport(HSSFWorkbook hwb){
ArrayList<BRClassStudent> brClassStudents = new ArrayList<BRClassStudent>();
ArrayList<String> studentCode = new ArrayList<String>();
ArrayList<String> classCode = new ArrayList<String>();
ArrayList<String> repeatCode = new ArrayList<String>();
List<String> valuesGrade = new ArrayList<>();
ArrayList<String> AgencyCode = new ArrayList<String>();
String[] headers = {"班级编号","学号","年级编号","教学单位编号"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
if (values.size()<=0){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
}
for(String[] value:values){ //将数据封装到entity
//1.0 检查信息是否为空
BRClassStudent brClassStudent = null;
if(value[0]==null||value[0].equals("")||value[1]==null||value[1].equals("")){
continue;
}
//1.1 检查班级是否存在
if((bClassRepository.selectOne(new BClass(value[0])))==null) {
if(!classCode.contains(value[0]))
classCode.add(value[0]);
continue;
}
//1.2 检查学生是否存在
if((bStudentRepository.selectOne(new BStudent(value[1])))==null) {
if(!studentCode.contains(value[1]))
studentCode.add(value[1]);
continue;
}
//1.3 检查班级学生是否存在
BRClassStudent classStudent = new BRClassStudent();
//classStudent.setClassCode(value[0]);
classStudent.setStudentCode(value[1]);
if((bRClassStudentRepository.selectOne(classStudent))!=null) {
repeatCode.add(value[1]);
continue;
}
//判断:学年是否存在,存在才能录入
BClass b1 = new BClass();
b1.setGradeCode(value[2]);
if (bClassRepository.checkGrade(b1).size() == 0){
valuesGrade.add(value[2]);
continue;
}
//判断教学单位是否存在
List<BAgency> bAgencies = bAgencyRepository.queryBAgencysByCode(value[3]);
if(bAgencies.size()<1){
AgencyCode.add(value[3]);
continue;
}
//1.4 构造学生班级信息
brClassStudent= new BRClassStudent(value[0],value[1]);
brClassStudent.setCommonBusinessId();
//UserUtils.setCurrentPersistOperation(brClassStudent);
if(!brClassStudents.contains(brClassStudent)){
brClassStudents.add(brClassStudent);
}
}
String result ="";
if (brClassStudents.size()>0){
int line = bRClassStudentRepository.insertList(brClassStudents);
if (line>0){
result = "成功导入"+brClassStudents.size()+"条数据。";
}else{
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR);
}
}
StringBuilder nullResult = new StringBuilder();
if(repeatCode.size()>0){
//nullResult.append("以下学生班级关系已存在:").append(JSON.toJSONString(repeatCode)).append("。");
nullResult.append("以下学生已存在于其他班级:").append(JSON.toJSONString(repeatCode)).append("。");
// nullResult.append("部分学生不存在,请检查后重新上传");
}
//2. 检查重复
if(classCode.size()>0){
nullResult.append("以下班级编号不存在:").append(JSON.toJSONString(classCode)).append("。");
// nullResult.append("部分班级不存在,请检查后重新上传");
}
if(studentCode.size()>0){
nullResult.append("以下学生学号不存在:").append(JSON.toJSONString(studentCode)).append("。");
// nullResult.append("部分学生不存在,请检查后重新上传");
}
if(valuesGrade.size()>0){
result+="以下年级不存在:"+ JSON.toJSONString(valuesGrade)+"。";
}
if(AgencyCode.size()>0){
result+="以下教学单位不存在:"+ JSON.toJSONString(AgencyCode)+"。";
}
result+=nullResult;
if(brClassStudents.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result);
}
//4.调用存储过程
Map<String,Object> map = new HashedMap();
map.put("result",null);
bClassRepository.updateStudentNum(map);
int l1 = MapUtils.getInteger(map,"result",-2);
if(l1<=0)
throw new ServiceException(ResultServiceEnums.UPDATE_STUDENT_NUM_ERROR);
return new PersistModel(1,result.toString());
}
} }
package org.rcisoft.business.brooms.dao; package org.rcisoft.business.brooms.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.ResultType; import org.apache.ibatis.annotations.ResultType;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.brooms.entity.BRooms; import org.rcisoft.business.brooms.entity.BRooms;
...@@ -34,6 +35,10 @@ public interface BRoomsRepository extends BaseMapper<BRooms> { ...@@ -34,6 +35,10 @@ public interface BRoomsRepository extends BaseMapper<BRooms> {
@Select("<script>select code from b_rooms where del_flag = 0</script>") @Select("<script>select code from b_rooms where del_flag = 0</script>")
List<String> queryAllCode(); List<String> queryAllCode();
@Select("<script>select count(*) from b_rooms where code = #{code} </script>")
int avoidRepeatCode(String code);
int addExcel(List<BRooms> list); int addExcel(List<BRooms> list);
} }
package org.rcisoft.business.brooms.service.impl; package org.rcisoft.business.brooms.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.brooms.utils.Upload2DataBase; import org.rcisoft.business.barrange.dao.BArrangeRepository;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.business.brooms.dao.BRoomsRepository;
import org.rcisoft.business.brooms.entity.BRooms;
import org.rcisoft.business.brooms.service.BRoomsService;
import org.rcisoft.business.bslschedule.dao.BSlScheduleRepository;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.Result; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.ExcelUtil; 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.model.PersistModel;
import org.rcisoft.business.brooms.dao.BRoomsRepository;
import org.rcisoft.business.brooms.entity.BRooms;
import org.rcisoft.business.brooms.service.BRoomsService;
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;
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 java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/** /**
* Created by on 2018-4-23 9:26:21. * Created by on 2018-4-23 9:26:21.
...@@ -39,6 +33,11 @@ public class BRoomsServiceImpl implements BRoomsService { ...@@ -39,6 +33,11 @@ public class BRoomsServiceImpl implements BRoomsService {
@Autowired @Autowired
private BRoomsRepository bRoomsRepository; private BRoomsRepository bRoomsRepository;
@Autowired
private BSlScheduleRepository bSlScheduleRepository;
@Autowired
private BArrangeRepository bArrangeRepository;
/** /**
* 保存 bRooms * 保存 bRooms
...@@ -48,13 +47,18 @@ public class BRoomsServiceImpl implements BRoomsService { ...@@ -48,13 +47,18 @@ public class BRoomsServiceImpl implements BRoomsService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(BRooms bRooms){ public PersistModel save(BRooms bRooms){
bRooms.setCommonBusinessId(); //判断是否存在重复编码
//增加操作 if(bRoomsRepository.avoidRepeatCode(bRooms.getCode()) != 0){
UserUtil.setCurrentPersistOperation(bRooms); throw new ServiceException(ResultServiceEnums.EXISE_ROOM_CODE);
int line = bRoomsRepository.insertSelective(bRooms); }else{
log.info(UserUtil.getUserInfoProp(bRooms.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+ bRooms.setCommonBusinessId();
bRooms.getBusinessId()+"的信息"); //增加操作
return new PersistModel(line); UserUtil.setCurrentPersistOperation(bRooms);
int line = bRoomsRepository.insertSelective(bRooms);
log.info(UserUtil.getUserInfoProp(bRooms.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
bRooms.getBusinessId()+"的信息");
return new PersistModel(line);
}
} }
/** /**
...@@ -65,12 +69,15 @@ public class BRoomsServiceImpl implements BRoomsService { ...@@ -65,12 +69,15 @@ public class BRoomsServiceImpl implements BRoomsService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel remove(BRooms bRooms){ public PersistModel remove(BRooms bRooms){
UserUtil.setCurrentMergeOperation(bRooms); if(bArrangeRepository.countThisRoomNum(bRooms.getBusinessId()) != 0
bRooms.setDeleted(); || bSlScheduleRepository.countThisRoomNum(bRooms.getBusinessId()) != 0){
int line = bRoomsRepository.logicalDelete(bRooms); throw new ServiceException(ResultServiceEnums.ROOM_HAS_USED);
log.info(UserUtil.getUserInfoProp(bRooms.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+ }else{
bRooms.getBusinessId()+"的信息"); int line = bRoomsRepository.deleteByPrimaryKey(bRooms.getBusinessId());
return new PersistModel(line); log.info(UserUtil.getUserInfoProp(bRooms.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
bRooms.getBusinessId()+"的信息");
return new PersistModel(line);
}
} }
/** /**
...@@ -130,6 +137,17 @@ public class BRoomsServiceImpl implements BRoomsService { ...@@ -130,6 +137,17 @@ public class BRoomsServiceImpl implements BRoomsService {
result += "编号 " + value[1] + " 在表中重复 "; result += "编号 " + value[1] + " 在表中重复 ";
continue; continue;
} }
//Int最大值为2147483648,所以不能超过9位数
if(value[5].length() >= 9){
result += "编号 " + value[1] + " 的数据座位数不合法 ";
continue;
}
try{
int seat = Integer.valueOf(value[5]);
}catch (Exception e){
result += "编号 " + value[1] + " 的数据座位数不合法 ";
continue;
}
BRooms bRooms = new BRooms(); BRooms bRooms = new BRooms();
String classroomName = ""; String classroomName = "";
if(value[0].equals("校本部")){ if(value[0].equals("校本部")){
...@@ -174,13 +192,18 @@ public class BRoomsServiceImpl implements BRoomsService { ...@@ -174,13 +192,18 @@ public class BRoomsServiceImpl implements BRoomsService {
currentlyCode.add(value[1]); currentlyCode.add(value[1]);
list.add(bRooms); list.add(bRooms);
} }
int flag = 1;
if(!result.equals("")){
flag = 0;
}
if(list.size() != 0){ if(list.size() != 0){
int i = bRoomsRepository.addExcel(list); int i = bRoomsRepository.addExcel(list);
result += "成功插入了 " + i + "条数据"; result += "成功插入了 " + i + "条数据";
}else { }else {
result += "没有输入被插入"; result += "没有输入被插入";
} }
return new PersistModel(1, result);
return new PersistModel(flag, result);
} }
} }
...@@ -24,11 +24,15 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> { ...@@ -24,11 +24,15 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> {
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BSlSchedule> queryBSlSchedules(BSlSchedule bSlSchedule); List<BSlSchedule> queryBSlSchedules(BSlSchedule bSlSchedule);
@Select("<script>select * from b_sl_schedule " @Select("<script>select *, "
+ "b_agency.name as agencyName,b_agency.code as agencyCode,b_agency.business_id as agencyId, \n"
+ "(select sum(student_num) from b_class where FIND_IN_SET(b_class.business_id,b_edu_class.classes_id)) AS studentNum from b_sl_schedule "
+ "left join b_edu_class on b_edu_class.code = b_sl_schedule.edu_class_code \n" + "left join b_edu_class on b_edu_class.code = b_sl_schedule.edu_class_code \n"
+ "left join b_lesson on b_lesson.code = b_sl_schedule.lesson_code \n" + "left join b_lesson on b_lesson.code = b_sl_schedule.lesson_code \n"
+ "left join b_rooms on b_rooms.code = b_sl_schedule.room_code \n" + "left join b_rooms on b_rooms.code = b_sl_schedule.room_code \n"
+ "left join s_user on s_user.login_name = b_sl_schedule.tea_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"
+ "where start_day between #{0} and #{1} and sub_agency_id = #{2} order by edu_class_code,start_day,seq" + "where start_day between #{0} and #{1} and sub_agency_id = #{2} order by edu_class_code,start_day,seq"
+ "</script>" + "</script>"
) )
...@@ -46,5 +50,9 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> { ...@@ -46,5 +50,9 @@ public interface BSlScheduleRepository extends BaseMapper<BSlSchedule> {
@Update("update b_sl_schedule set status = #{status} where sub_agency_id = #{subAgencyId} and del_flag = 0 and flag = 1") @Update("update b_sl_schedule set status = #{status} where sub_agency_id = #{subAgencyId} and del_flag = 0 and flag = 1")
int updateStatusBySubAgencyId(@Param("subAgencyId") String subAgencyId, @Param("status") String status); int updateStatusBySubAgencyId(@Param("subAgencyId") String subAgencyId, @Param("status") String status);
int countStudentNum(String classesId);
@Select("select count(*) from b_sl_schedule where room_code = ( select `code` from b_rooms where business_id = #{businessId})")
int countThisRoomNum(String businessId);
} }
...@@ -2,6 +2,7 @@ package org.rcisoft.business.bslschedule.entity; ...@@ -2,6 +2,7 @@ package org.rcisoft.business.bslschedule.entity;
import lombok.*; import lombok.*;
import org.rcisoft.business.bagency.entity.BAgency;
import org.rcisoft.business.beduclass.entity.BEduClass; import org.rcisoft.business.beduclass.entity.BEduClass;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.brooms.entity.BRooms; import org.rcisoft.business.brooms.entity.BRooms;
...@@ -73,5 +74,8 @@ public class BSlSchedule extends IdEntity<BSlSchedule> { ...@@ -73,5 +74,8 @@ public class BSlSchedule extends IdEntity<BSlSchedule> {
@Transient @Transient
private BEduClass bEduClass; private BEduClass bEduClass;
@Transient
private BAgency bAgency;
} }
...@@ -242,7 +242,7 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -242,7 +242,7 @@ public class BStudentServiceImpl implements BStudentService {
result+="以下邮箱已注册:"+ JSON.toJSONString(valuesEmailExist)+"。"; result+="以下邮箱已注册:"+ JSON.toJSONString(valuesEmailExist)+"。";
} }
if(valuesGrade.size()>0){ if(valuesGrade.size()>0){
result+="以下学生的学年信息不存在:"+ JSON.toJSONString(valuesGrade)+"。"; result+="以下学不存在:"+ JSON.toJSONString(valuesGrade)+"。";
} }
......
...@@ -91,9 +91,9 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -91,9 +91,9 @@ public class BTeacherServiceImpl implements BTeacherService {
List<String[]> valuesOK = new ArrayList<>(); List<String[]> valuesOK = new ArrayList<>();
List<String> valuesRepeat = new ArrayList<>(); List<String> valuesRepeat = new ArrayList<>();
List<String> valuesShort = new ArrayList<>(); List<String> valuesShort = new ArrayList<>();
List<String> valuesEmailExist = new ArrayList<>(); List<String> valuesIncomplete = new ArrayList<>();
List<String> valuesAgencyExist = new ArrayList<>(); List<String> valuesAgencyExist = new ArrayList<>();
int i = 1;
for (String[] value : values) { for (String[] value : values) {
String teaCode = value[0]; String teaCode = value[0];
...@@ -126,11 +126,16 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -126,11 +126,16 @@ public class BTeacherServiceImpl implements BTeacherService {
// } // }
//判断4:教师的所属教学单位是否存在,存在才能添加; //判断4:教师的所属教学单位是否存在,存在才能添加;
if (sysUserMapper.checkTeacherAgency(value[3]).size() == 0){ if(!value[3].equals("")&&value[3]!=null){
valuesAgencyExist.add(value[3]); if (sysUserMapper.checkTeacherAgency(value[3]).size() == 0){
valuesAgencyExist.add(value[3]);
continue;
}
}
if(value[0].equals("")||value[1].equals("")||value[2].equals("")){
valuesIncomplete.add(String.valueOf(i));
continue; continue;
} }
//合法:通过了三次判断,证明可建立该用户 //合法:通过了三次判断,证明可建立该用户
valuesOK.add(value); valuesOK.add(value);
...@@ -170,7 +175,7 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -170,7 +175,7 @@ public class BTeacherServiceImpl implements BTeacherService {
users.add(user); users.add(user);
userRoles.add(userRole); userRoles.add(userRole);
} }
i++;
} }
String result = ""; String result = "";
if (teachers.size()>0){ if (teachers.size()>0){
...@@ -190,9 +195,9 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -190,9 +195,9 @@ public class BTeacherServiceImpl implements BTeacherService {
if(valuesShort.size()>0){ if(valuesShort.size()>0){
result+="以下教师的工号位数不在8~15位之间:"+ JSON.toJSONString(valuesShort)+"。"; result+="以下教师的工号位数不在8~15位之间:"+ JSON.toJSONString(valuesShort)+"。";
} }
// if(valuesEmailExist.size()>0){ if(valuesIncomplete.size()>0){
// result+="以下教师邮箱已注册或格式不正确:"+ JSON.toJSONString(valuesEmailExist)+"。"; result+="第"+ JSON.toJSONString(valuesIncomplete)+"行数据不完整";
// } }
if (valuesAgencyExist.size()>0){ if (valuesAgencyExist.size()>0){
result+="以下教师的所属教学单位不存在:"+JSON.toJSONString(valuesAgencyExist)+"。"; result+="以下教师的所属教学单位不存在:"+JSON.toJSONString(valuesAgencyExist)+"。";
} }
...@@ -230,7 +235,7 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -230,7 +235,7 @@ public class BTeacherServiceImpl implements BTeacherService {
@Override @Override
@Transactional(readOnly = false,propagation = Propagation.REQUIRED,rollbackFor = Exception.class) @Transactional(readOnly = false,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public PersistModel persist(BTeacher model, SysUser user, String token) throws UnsupportedEncodingException { public PersistModel persist(BTeacher model, SysUser user, String token) {
int line = 0; int line = 0;
BeanUtils.copyProperties((DataEntity) model, (DataEntity) user); BeanUtils.copyProperties((DataEntity) model, (DataEntity) user);
if (model.getBusinessId() == null) { if (model.getBusinessId() == null) {
......
...@@ -154,4 +154,13 @@ public class BTermController extends PaginationController<BTerm> { ...@@ -154,4 +154,13 @@ public class BTermController extends PaginationController<BTerm> {
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
} }
@ApiOperation(value="获取校历", notes="获取校历")
@GetMapping(value = "/getSchoolWeek")
public Result getSchoolWeek(){
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bTermService.getSchoolWeek());
}
} }
...@@ -65,5 +65,9 @@ public interface BTermRepository extends BaseMapper<BTerm> { ...@@ -65,5 +65,9 @@ public interface BTermRepository extends BaseMapper<BTerm> {
"</foreach></script>") "</foreach></script>")
int insertList(List<BTeacher> bTeachers); int insertList(List<BTeacher> bTeachers);
*/ */
@Select("select * from b_term where current = 1")
@ResultMap(value = "BaseResultMap" )
BTerm queryCurrentTerm();
} }
...@@ -58,4 +58,6 @@ public interface BTermService{ ...@@ -58,4 +58,6 @@ public interface BTermService{
List<SelectModel> queryBTermList(); List<SelectModel> queryBTermList();
PersistModel changeCurrent(String id); PersistModel changeCurrent(String id);
List<String> getSchoolWeek();
} }
...@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service; ...@@ -18,6 +18,7 @@ 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 java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -139,4 +140,12 @@ public class BTermServiceImpl implements BTermService { ...@@ -139,4 +140,12 @@ public class BTermServiceImpl implements BTermService {
return new PersistModel(result); return new PersistModel(result);
} }
@Override
public List<String> getSchoolWeek(){
BTerm bTerm = bTermRepository.queryCurrentTerm();
List<String> list = new ArrayList<>();
list = Week.buildList(bTerm.getStartDate(),bTerm.getEndDate());
return list;
}
} }
package org.rcisoft.business.bterm.utils; package org.rcisoft.business.bterm.utils;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
public class Week { public class Week {
...@@ -129,4 +130,65 @@ public class Week { ...@@ -129,4 +130,65 @@ public class Week {
return map; return map;
} }
//通过开始时间与计算时间计算周数与具体信息
public static List<String> buildList(Date startDate1,Date endDate1){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> list = new ArrayList<>();
//转化起始时间
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(startDate1);
//转化结束时间
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(endDate1);
//遍历用时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate1);
int flag = 1;
String s = "";
while(!calendar.after(endCalendar)){
int weekOfDay = calendar.get(Calendar.DAY_OF_WEEK);
//第一周判断是否为完整的一周
if(flag == 1 && calendar.get(Calendar.DAY_OF_WEEK) != 2){
//如果不是时间往前推移,直到星期一,此间字符串添加','
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(startDate1);
while(calendar2.get(Calendar.DAY_OF_WEEK) != 2){
s += "0,";
calendar2.add(Calendar.DATE,-1);
}
flag = 0;
continue;
}
//平常周,判断是否为周日
if(weekOfDay != 1){
String formatTime = sdf.format(calendar.getTime());
s += formatTime+",";
calendar.add(Calendar.DATE,1);
}else{
String formatTime = sdf.format(calendar.getTime());
s += formatTime+",";
s = s.substring(0,s.length() - 1);
//因为是周日,所以List添加一条数据,开始下一周的遍历
list.add(s);
s = "";
calendar.add(Calendar.DATE,1);
}
}
int flag2 = 0;
//因为最后一周如果没有周日的话会跳出循环,字符串s依然有值,将最后的值插入List中
while(calendar.get(Calendar.DAY_OF_WEEK) != 1 || flag2 == 1){
if(calendar.get(Calendar.DAY_OF_WEEK) == 1){
s += "0,";
s = s.substring(0,s.length() - 1);
list.add(s);
break;
}else {
s += "0,";
calendar.add(Calendar.DATE,1);
flag2 = 1;
}
}
return list;
}
} }
package org.rcisoft.common.util;
import java.util.HashMap;
import java.util.Map;
/**
* Created by lcy on 18/5/15.
*/
public class TableUtil {
static Map<String,String> TableMap;
static {
TableMap = new HashMap<>();
TableMap.put("1","b_company");
TableMap.put("2","b_teacher");
TableMap.put("3","b_student");
}
/**
* 获取
* @param key
* @return
*/
public static String getTableByKey(String key){
return TableMap.get(key);
}
}
...@@ -178,7 +178,11 @@ public enum ResultServiceEnums { ...@@ -178,7 +178,11 @@ public enum ResultServiceEnums {
ROLE_HAS_USER(95,"仍然有绑定此角色的用户,不可删除此角色"), ROLE_HAS_USER(95,"仍然有绑定此角色的用户,不可删除此角色"),
CURRENT_TERM(96,"当前学期不可删除"), EXISE_ROOM_CODE(96,"此教室编号已存在,添加失败"),
CURRENT_TERM(97,"当前学期不可删除"),
ROOM_HAS_USED(98,"当前教室正在被使用,不可删除"),
; ;
private Integer code; private Integer code;
......
...@@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Select; ...@@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Select;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.sys.dept.entity.DeptRole; import org.rcisoft.sys.dept.entity.DeptRole;
import org.rcisoft.sys.role.entity.SysRole; import org.rcisoft.sys.role.entity.SysRole;
import org.rcisoft.sys.user.entity.SysUser;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
...@@ -203,4 +202,19 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -203,4 +202,19 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"LEFT JOIN s_role ON s_role_menu.ROLE_ID = s_role.business_id " + "LEFT JOIN s_role ON s_role_menu.ROLE_ID = s_role.business_id " +
"WHERE s_menu.MODEL_ID = #{modelId} AND ROLE_ID = #{roleId}") "WHERE s_menu.MODEL_ID = #{modelId} AND ROLE_ID = #{roleId}")
int queryRoleByRoleCode(@Param("modelId") String modelId, @Param("roleId") String roleId); int queryRoleByRoleCode(@Param("modelId") String modelId, @Param("roleId") String roleId);
/**
* 根据子表id 删除 s_r_user_role
* @param tableByKey
* @param businessId
* @return
*/
@Delete("DELETE sr " +
"FROM" +
"s_r_user_role sr " +
"LEFT JOIN s_user s on s.business_id = sr.user_id " +
"LEFT JOIN ${tb} c ON c. CODE = s.login_name " +
"WHERE" +
"c.business_id = #{cid}")
int deleteUserRoleByChildrenId(@Param("tb") String tableByKey,@Param("cid") String businessId);
} }
...@@ -3,7 +3,6 @@ package org.rcisoft.sys.role.service.impl; ...@@ -3,7 +3,6 @@ package org.rcisoft.sys.role.service.impl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.DelStatus;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
...@@ -67,19 +66,15 @@ public class SysRoleServiceImpl implements SysRoleService { ...@@ -67,19 +66,15 @@ public class SysRoleServiceImpl implements SysRoleService {
public int removeRole(String id,String token) { public int removeRole(String id,String token) {
//获得当前是此角色的人数 //获得当前是此角色的人数
int userCount = sysUserMapper.countUserByRole(id); int userCount = sysUserMapper.countUserByRole(id);
//如果仍然有用户是此角色,则该角色不可删除 //如果仍然有用户(如果用户被逻辑删除,则忽略此角色,但如果用于被停用,则依然被计算)是此角色,则该角色不可删除
if(userCount > 0){ if(userCount > 0){
throw new ServiceException(ResultServiceEnums.ROLE_HAS_USER); throw new ServiceException(ResultServiceEnums.ROLE_HAS_USER);
}else{ }else{
//删除该角色所有的关联信息 //删除该角色所有的关联信息
sysRoleRepository.deleteRoleMenuByRoleId(id); sysRoleRepository.deleteRoleMenuByRoleId(id);
sysRoleRepository.deleteUserRoleByRoleId(id); sysRoleRepository.deleteUserRoleByRoleId(id);
int line = sysRoleRepository.deleteByPrimaryKey(id);
SysRole sysRole = sysRoleRepository.selectByPrimaryKey(id); log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"删除了ID为"+ id+"的角色信息");
sysRole.setDelFlag(DelStatus.DELETED.getStatus());
UserUtil.setCurrentMergeOperation(sysRole);
int line = sysRoleRepository.updateByPrimaryKeySelective(sysRole);
log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"删除了ID为"+ sysRole.getBusinessId()+"的角色信息");
return line; return line;
} }
} }
......
...@@ -78,14 +78,13 @@ public class SysUserController extends PaginationController<SysUser> { ...@@ -78,14 +78,13 @@ public class SysUserController extends PaginationController<SysUser> {
@ApiOperation(value = "重置密码", notes = "根据用户学号或者工号重置密码") @ApiOperation(value = "重置密码", notes = "根据用户学号或者工号重置密码")
@PostMapping("/resetPassword") @PostMapping("/resetPassword")
@ApiImplicitParams({@ApiImplicitParam(name = "userCode", value = "学号或工号", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "loginName", value = "登录名", required = true, dataType = "varchar")})
@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) public Result resetPassword (String loginName){
public Result resetPassword (String userCode, String businessId){ PersistModel persistModel = new PersistModel(userServiceImpl.resetPassword(loginName));
PersistModel persistModel = new PersistModel(userServiceImpl.resetPassword(userCode,businessId));
return Result.builder(persistModel, return Result.builder(persistModel,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
userCode); loginName);
} }
......
...@@ -8,14 +8,10 @@ import org.rcisoft.business.bteacher.entity.BTeacher; ...@@ -8,14 +8,10 @@ import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.sys.user.entity.SysUser; import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.entity.UserRole; import org.rcisoft.sys.user.entity.UserRole;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static javafx.scene.input.KeyCode.V;
/** /**
* Created by lcy on 17/8/9. * Created by lcy on 17/8/9.
*/ */
...@@ -49,9 +45,23 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -49,9 +45,23 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("SELECT u.business_id from s_user u left join ${tab} s on u.login_name = s.code where s.business_id = #{id} and u.del_flag = 0 and u.flag = 1") @Select("SELECT u.business_id from s_user u left join ${tab} s on u.login_name = s.code where s.business_id = #{id} and u.del_flag = 0 and u.flag = 1")
String selectUserIdByStuOrTeaId(@Param("id") String id, @Param("tab") String table); String selectUserIdByStuOrTeaId(@Param("id") String id, @Param("tab") String table);
@Update("update s_user set del_flag = 1, flag = 0 where login_name = #{code}") @Update("update s_user set del_flag = 1 where login_name = #{code}")
int deleteByCode(String code); int deleteByCode(String code);
/**
* 用户删除 cy 5-15
* @param code
* @return
*/
@Delete("DELETE s " +
"FROM " +
" s_user s " +
"LEFT JOIN b_company c ON c. CODE = s.login_name " +
"WHERE " +
" c.business_id = #{code}")
int deleteByCompany(String code);
@Select("<script>select * from s_user where business_id = #{userId} and password = #{password} limit 1</script>") @Select("<script>select * from s_user where business_id = #{userId} and password = #{password} limit 1</script>")
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
SysUser checkPassword(@Param("userId") String userId, @Param("password") String password); SysUser checkPassword(@Param("userId") String userId, @Param("password") String password);
...@@ -63,10 +73,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -63,10 +73,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
String queryPasswordById(String userId); String queryPasswordById(String userId);
@Update("<script>update s_user set password = #{password} where 1=1 " + @Update("<script>update s_user set password = #{password} where 1=1 " +
"<if test=\"userCode !=null and userCode != '' \">and login_name = #{userCode} </if>" + "and login_name = #{loginName} " +
"<if test=\"businessId !=null and businessId != '' \">and business_id = #{businessId} </if> " +
"and del_flag = 0 and flag = 1</script>") "and del_flag = 0 and flag = 1</script>")
int resetPassword(@Param("userCode") String userCode, @Param("businessId") String businessId, @Param("password") String password); int resetPassword(@Param("loginName") String loginNam,@Param("password") String password);
@Select("<script>select business_id from s_user where login_name = #{studentCode} and del_flag = 0 and flag = 1</script>") @Select("<script>select business_id from s_user where login_name = #{studentCode} and del_flag = 0 and flag = 1</script>")
String queryUserIdByLoginName(String studentCode); String queryUserIdByLoginName(String studentCode);
...@@ -98,7 +107,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -98,7 +107,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("select business_id from s_user where login_name = #{0} and del_flag = 0") @Select("select business_id from s_user where login_name = #{0} and del_flag = 0")
String selectByLoginName(String loginName); String selectByLoginName(String loginName);
@Select("select count(*) from s_r_user_role where role_id = #{roleId} ") @Select("select count(*) from s_r_user_role " +
"left join s_user on s_user.business_id = s_r_user_role.user_id " +
"where role_id = #{roleId} and s_user.del_flag = 0 ")
int countUserByRole(String roleId); int countUserByRole(String roleId);
......
...@@ -19,7 +19,7 @@ public interface SysUserService { ...@@ -19,7 +19,7 @@ public interface SysUserService {
int changePassword(String userId, String newPassword); int changePassword(String userId, String newPassword);
int resetPassword(String userCode, String businessId); int resetPassword(String loginName);
int addOrUpdateUser(SysUser user); int addOrUpdateUser(SysUser user);
......
...@@ -105,11 +105,8 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -105,11 +105,8 @@ public class SysUserServiceImpl implements SysUserService {
} }
@Override @Override
public int resetPassword(String userCode, String businessId) { public int resetPassword(String loginName) {
if((userCode!=null&&!userCode.equals(""))&&(businessId!=null&&!businessId.equals(""))){ return sysUserMapper.resetPassword(loginName,passwordEncoder.encode(global.getDEFAULT_PASSWORD()));
throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR);
}
return sysUserMapper.resetPassword(userCode,businessId,passwordEncoder.encode(global.getDEFAULT_PASSWORD()));
} }
@Override @Override
......
...@@ -11,7 +11,9 @@ server: ...@@ -11,7 +11,9 @@ 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://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/new_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
......
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
<result column="subtask_id" jdbcType="VARCHAR" property="subtaskId" /> <result column="subtask_id" jdbcType="VARCHAR" property="subtaskId" />
<result column="subtask_name" jdbcType="VARCHAR" property="subtaskName" /> <result column="subtask_name" jdbcType="VARCHAR" property="subtaskName" />
<collection property="childList" javaType="ArrayList" column="business_id" ofType="org.rcisoft.business.bopinion.entity.BOpinion" <collection property="childList" javaType="ArrayList" column="business_id" ofType="org.rcisoft.business.bopinion.entity.BOpinion"
select="org.rcisoft.business.bopinion.dao.BOpinionRepository.queryOpinionBySlId" select="org.rcisoft.business.bopinion.dao.BOpinionRepository.queryOpinionBySubAgencyId"
/> />
</resultMap> </resultMap>
</mapper> </mapper>
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<result column="agency_code" jdbcType="VARCHAR" property="agencyCode"/> <result column="agency_code" jdbcType="VARCHAR" property="agencyCode"/>
<result column="subtask_id" jdbcType="VARCHAR" property="subtaskId"/> <result column="subtask_id" jdbcType="VARCHAR" property="subtaskId"/>
<result column="create_person" jdbcType="VARCHAR" property="createPerson"/> <result column="create_person" jdbcType="VARCHAR" property="createPerson"/>
<result column="sub_agency_id" jdbcType="VARCHAR" property="subAgencyId"/>
</resultMap> </resultMap>
......
...@@ -50,17 +50,21 @@ ...@@ -50,17 +50,21 @@
<result column="lesson_name" jdbcType="VARCHAR" property="bLesson.lessonName"/> <result column="lesson_name" jdbcType="VARCHAR" property="bLesson.lessonName"/>
<result column="class_hour" jdbcType="VARCHAR" property="bLesson.classHour"/> <result column="class_hour" jdbcType="VARCHAR" property="bLesson.classHour"/>
<result column="credits" jdbcType="VARCHAR" property="bLesson.credits"/> <result column="credits" jdbcType="VARCHAR" property="bLesson.credits"/>
<result column="campus" jdbcType="VARCHAR" property="bRooms.campus"/> <result column="campus" jdbcType="VARCHAR" property="bRooms.transitCampus"/>
<result column="building" jdbcType="VARCHAR" property="bRooms.building"/> <result column="building" jdbcType="VARCHAR" property="bRooms.building"/>
<result column="classroom_no" jdbcType="VARCHAR" property="bRooms.classroomNo"/> <result column="classroom_no" jdbcType="VARCHAR" property="bRooms.classroomNo"/>
<result column="classroom_name" jdbcType="VARCHAR" property="bRooms.classroomName"/> <result column="classroom_name" jdbcType="VARCHAR" property="bRooms.classroomName"/>
<result column="category" jdbcType="VARCHAR" property="bRooms.category"/> <result column="category" jdbcType="VARCHAR" property="bRooms.transitCategory"/>
<result column="class_seat" jdbcType="VARCHAR" property="bRooms.classSeat"/> <result column="class_seat" jdbcType="VARCHAR" property="bRooms.classSeat"/>
<result column="exam_seat" jdbcType="VARCHAR" property="bRooms.examSeat"/> <result column="exam_seat" jdbcType="VARCHAR" property="bRooms.examSeat"/>
<result column="name" jdbcType="VARCHAR" property="sysUser.name"/> <result column="name" jdbcType="VARCHAR" property="sysUser.name"/>
<result column="email" jdbcType="VARCHAR" property="sysUser.email"/> <result column="email" jdbcType="VARCHAR" property="sysUser.email"/>
<result column="phone" jdbcType="VARCHAR" property="sysUser.phone"/> <result column="phone" jdbcType="VARCHAR" property="sysUser.phone"/>
<result column="sex" jdbcType="VARCHAR" property="sysUser.sex"/> <result column="sex" jdbcType="VARCHAR" property="sysUser.sex"/>
<result column="agencyCode" jdbcType="VARCHAR" property="bAgency.code"/>
<result column="agencyName" jdbcType="VARCHAR" property="bAgency.name"/>
<result column="agencyId" jdbcType="VARCHAR" property="bAgency.businessId"/>
<result column="studentNum" jdbcType="VARCHAR" property="bEduClass.studentNum"/>
</resultMap> </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,
......
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
</resultMap> </resultMap>
<select id="countUserNum" parameterType="string" resultType="int"> <select id="countUserNum" parameterType="string" resultType="int">
select count(*) select count(*)
from s_r_user_role where role_id = #{id} from s_r_user_role
left join s_user on s_user.business_id = s_r_user_role.user_id
where role_id = #{id} and s_user.del_flag = 0
</select> </select>
<resultMap id="drResultMap" type="org.rcisoft.sys.dept.entity.DeptRole"> <resultMap id="drResultMap" type="org.rcisoft.sys.dept.entity.DeptRole">
......
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