Browse Source

学校导入校验Excel格式

lazhaoqian 3 years ago
parent
commit
28b4edd764
29 changed files with 441 additions and 28 deletions
  1. 288 0
      blade-service/blade-school/src/main/java/org/springblade/school/controller/SalaryItemController.java
  2. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/AttendanceExcel.java
  3. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/AwardExcel.java
  4. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/EmployExcel.java
  5. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/EomNumberExcel.java
  6. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/InsuranceExcel.java
  7. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/LeadExcel.java
  8. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/LearningPower.java
  9. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/OvertimeExcel.java
  10. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PayTaxes.java
  11. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PerformanceExcel.java
  12. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PersonalInsurance.java
  13. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PhoneFineExcel.java
  14. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PositionExcel.java
  15. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PostAllowance.java
  16. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PostTrainExcel.java
  17. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/PrepareLessonsExcel.java
  18. 1 3
      blade-service/blade-school/src/main/java/org/springblade/school/excel/ReservedFunds.java
  19. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/SalaryItemExcel.java
  20. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/SanitationFee.java
  21. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/TeacherSubsidy.java
  22. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/TeachingExcel.java
  23. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/TeamLeaderExcel.java
  24. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/VacationExcel.java
  25. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/WeChatExcel.java
  26. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/WorkloadExcel.java
  27. 0 1
      blade-service/blade-school/src/main/java/org/springblade/school/excel/ZhaPingExcel.java
  28. 1 0
      blade-service/blade-school/src/main/java/org/springblade/school/service/impl/SalaryItemServiceImpl.java
  29. 151 0
      blade-service/blade-school/src/main/java/org/springblade/school/util/ExcelCheck.java

+ 288 - 0
blade-service/blade-school/src/main/java/org/springblade/school/controller/SalaryItemController.java

@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -37,6 +38,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.school.entity.Salary;
 import org.springblade.school.excel.*;
+import org.springblade.school.util.ExcelCheck;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.school.entity.SalaryItem;
@@ -161,6 +163,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-工资表导入", notes = "传入excel")
 	public R importSupplierDesc(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new SalaryItemExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<SalaryItemExcel> excelList = ExcelUtil.read(file, SalaryItemExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -204,6 +217,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-聘用导入", notes = "传入excel")
 	public R importEmploy(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new EmployExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<EmployExcel> excelList = ExcelUtil.read(file, EmployExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -230,6 +254,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-职级导入", notes = "传入excel")
 	public R importPosition(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PositionExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PositionExcel> excelList = ExcelUtil.read(file, PositionExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -256,6 +291,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-学习强国扣费导入", notes = "传入excel")
 	public R importPower(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new LearningPower());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<LearningPower> excelList = ExcelUtil.read(file, LearningPower.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -282,6 +328,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-微信金额导入", notes = "传入excel")
 	public R importWeChat(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new WeChatExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<WeChatExcel> excelList = ExcelUtil.read(file, WeChatExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -308,6 +365,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-班主任补贴导入", notes = "传入excel")
 	public R importTeacherSubsidy(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new TeacherSubsidy());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<TeacherSubsidy> excelList = ExcelUtil.read(file, TeacherSubsidy.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -334,6 +402,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-周末加班导入", notes = "传入excel")
 	public R importOvertime(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new OvertimeExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<OvertimeExcel> excelList = ExcelUtil.read(file, OvertimeExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -360,6 +439,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-电话费、罚款导入", notes = "传入excel")
 	public R importPhoneFine(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PhoneFineExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PhoneFineExcel> excelList = ExcelUtil.read(file, PhoneFineExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -386,6 +476,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-卫生费导入", notes = "传入excel")
 	public R importSanitationFee(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new SanitationFee());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<SanitationFee> excelList = ExcelUtil.read(file, SanitationFee.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -412,6 +513,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-出勤导入", notes = "传入excel")
 	public R importAttendanceExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new AttendanceExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<AttendanceExcel> excelList = ExcelUtil.read(file, AttendanceExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -438,6 +550,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-保险个人导入", notes = "传入excel")
 	public R importPersonalInsurance(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PersonalInsurance());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PersonalInsurance> excelList = ExcelUtil.read(file, PersonalInsurance.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -464,6 +587,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-公积金导入", notes = "传入excel")
 	public R importReservedFunds(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new ReservedFunds());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<ReservedFunds> excelList = ExcelUtil.read(file, ReservedFunds.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -490,6 +624,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-个税导入", notes = "传入excel")
 	public R importPayTaxes(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PayTaxes());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PayTaxes> excelList = ExcelUtil.read(file, PayTaxes.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -516,6 +661,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-新岗岗前培训导入", notes = "传入excel")
 	public R importPostTrainExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PostTrainExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PostTrainExcel> excelList = ExcelUtil.read(file, PostTrainExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -542,6 +698,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-奖励导入", notes = "传入excel")
 	public R importAwardExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new AwardExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<AwardExcel> excelList = ExcelUtil.read(file, AwardExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -568,6 +735,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-假期加班导入", notes = "传入excel")
 	public R importVacationExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new VacationExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<VacationExcel> excelList = ExcelUtil.read(file, VacationExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -594,6 +772,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-岗位补贴导入", notes = "传入excel")
 	public R importPostAllowance(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PostAllowance());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PostAllowance> excelList = ExcelUtil.read(file, PostAllowance.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -620,6 +809,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-绩效、教学成绩奖导入", notes = "传入excel")
 	public R importPerformanceExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PerformanceExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PerformanceExcel> excelList = ExcelUtil.read(file, PerformanceExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -646,6 +846,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-工作量导入", notes = "传入excel")
 	public R importWorkloadExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new WorkloadExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<WorkloadExcel> excelList = ExcelUtil.read(file, WorkloadExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -672,6 +883,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-查评导入", notes = "传入excel")
 	public R importZhaPingExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new ZhaPingExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<ZhaPingExcel> excelList = ExcelUtil.read(file, ZhaPingExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -698,6 +920,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-保险导入", notes = "传入excel")
 	public R importInsuranceExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new InsuranceExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<InsuranceExcel> excelList = ExcelUtil.read(file, InsuranceExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -724,6 +957,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-月底人数导入", notes = "传入excel")
 	public R importEomNumberExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new EomNumberExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<EomNumberExcel> excelList = ExcelUtil.read(file, EomNumberExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -750,6 +994,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-教研组长导入", notes = "传入excel")
 	public R importTeamLeaderExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new TeamLeaderExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<TeamLeaderExcel> excelList = ExcelUtil.read(file, TeamLeaderExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -776,6 +1031,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-备课组长导入", notes = "传入excel")
 	public R importPrepareLessonsExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new PrepareLessonsExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<PrepareLessonsExcel> excelList = ExcelUtil.read(file, PrepareLessonsExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -802,6 +1068,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-领导干部导入", notes = "传入excel")
 	public R importLeadExcel(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new LeadExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<LeadExcel> excelList = ExcelUtil.read(file, LeadExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{
@@ -828,6 +1105,17 @@ public class SalaryItemController extends BladeController {
 	@ApiOperation(value = "导入-工资管理-小学部-下学期绩效导入", notes = "传入excel")
 	public R importTeachingExcell(@RequestParam("file") MultipartFile file,@RequestParam("id") Long id)
 	{
+		//校验模板
+		String excelPattern = null;
+		try {
+			excelPattern = ExcelCheck.checkExcelPattern(file, new TeachingExcel());
+		} catch (Exception e) {
+			throw new SecurityException("校验Excel失败");
+		}
+		if (StringUtils.isNotBlank(excelPattern)){
+			throw new SecurityException(excelPattern);
+		}
+		//导入数据
 		List<TeachingExcel> excelList = ExcelUtil.read(file, TeachingExcel.class);
 		if(CollectionUtils.isEmpty(excelList))
 		{

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/AttendanceExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class AttendanceExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/AwardExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class AwardExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 学科
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/EmployExcel.java

@@ -16,7 +16,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class EmployExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/EomNumberExcel.java

@@ -18,7 +18,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class EomNumberExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/InsuranceExcel.java

@@ -18,7 +18,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class InsuranceExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 单位名称
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/LeadExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class LeadExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/LearningPower.java

@@ -18,7 +18,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class LearningPower implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/OvertimeExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class OvertimeExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PayTaxes.java

@@ -18,7 +18,6 @@ import java.util.Date;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PayTaxes implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 工号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PerformanceExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PerformanceExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PersonalInsurance.java

@@ -18,7 +18,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PersonalInsurance implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 部门
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PhoneFineExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PhoneFineExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PositionExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PositionExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PostAllowance.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PostAllowance implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PostTrainExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PostTrainExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/PrepareLessonsExcel.java

@@ -18,7 +18,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class PrepareLessonsExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 1 - 3
blade-service/blade-school/src/main/java/org/springblade/school/excel/ReservedFunds.java

@@ -19,7 +19,6 @@ import java.util.Date;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class ReservedFunds implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 个人账户
 	 */
@@ -45,8 +44,7 @@ public class ReservedFunds implements Serializable {
 	 * 所属年月
 	 */
 	@ExcelProperty(value = "所属年月")
-	@JsonFormat(pattern = "yyyy-MM")
-	private Date subordinateYears;
+	private String subordinateYears;
 
 	/**
 	 * 单位金额

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/SalaryItemExcel.java

@@ -18,7 +18,6 @@ import java.util.Date;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class SalaryItemExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/SanitationFee.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class SanitationFee implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/TeacherSubsidy.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class TeacherSubsidy implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 班级
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/TeachingExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class TeachingExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/TeamLeaderExcel.java

@@ -18,7 +18,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class TeamLeaderExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/VacationExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class VacationExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/WeChatExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class WeChatExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/WorkloadExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class WorkloadExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 姓名
 	 */

+ 0 - 1
blade-service/blade-school/src/main/java/org/springblade/school/excel/ZhaPingExcel.java

@@ -17,7 +17,6 @@ import java.math.BigDecimal;
 @HeadRowHeight(20)
 @ContentRowHeight(18)
 public class ZhaPingExcel implements Serializable {
-	private static final long serialVersionUID = 1L;
 	/**
 	 * 序号
 	 */

+ 1 - 0
blade-service/blade-school/src/main/java/org/springblade/school/service/impl/SalaryItemServiceImpl.java

@@ -1495,4 +1495,5 @@ public class SalaryItemServiceImpl extends ServiceImpl<SalaryItemMapper, SalaryI
 		salaryAccessoryService.save(salaryAccessory);
 	}
 
+
 }

+ 151 - 0
blade-service/blade-school/src/main/java/org/springblade/school/util/ExcelCheck.java

@@ -0,0 +1,151 @@
+package org.springblade.school.util;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.nacos.api.utils.StringUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.BufferedInputStream;
+import java.lang.reflect.Field;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author: xxx
+ * @createTime: 2021/12/07 17:07
+ * @company: https://www.xxx.cn
+ * @description:
+ */
+public class ExcelCheck {
+
+	/**
+	 * 检验导入Excel的格式
+	 * @param excel
+	 * @return
+	 * @throws Exception
+	 */
+	public static String checkExcelPattern(MultipartFile excel,Object object) throws Exception {
+		if(excel == null || excel.isEmpty()){
+			throw new Exception("导入文件不能为空!");
+		}
+		//用于拼接校验结果
+		StringBuilder builder = new StringBuilder();
+		//大小校验
+        /*if((excel.getSize()/1048576)>2){
+            builder.append("上传文件仅支持2M以内的Excel文件;");
+        }*/
+		//校验文件格式,必须为excel文件
+        String fileName = excel.getOriginalFilename();
+        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
+        if (!"xlsx".equals(suffix)) {
+            builder.append("导入文件只支持xlsx类型后缀;");
+        }
+		//校验文件表头
+		BufferedInputStream fin = new BufferedInputStream(excel.getInputStream());
+		Workbook wb = null;
+		try{
+			wb = WorkbookFactory.create(fin);;
+		}catch(Exception e){
+			wb = WorkbookFactory.create(fin);;
+		}
+		//XSSFWorkbook wb = new XSSFWorkbook(fin);导致出现异常
+		//columnName = {"姓名", "性别", "年级", "班级","身份证号","学籍号","学工号","性格","家庭情况","操行等等","特长","标签"};
+		//获取注解当中的值
+		Map<String, List<String>> annotationValue = getAnnotationValue(object);
+		List<String> annotationName = annotationValue.get("annotationName");
+		//获取到的实体注解名称顺序要与excel表头顺序保持一样
+		String[] columnName = annotationName.toArray(new String[]{});
+		Sheet sheet = wb.getSheetAt(0);
+		Row row = sheet.getRow(0);
+		if (row != null && row.getLastCellNum() >= columnName.length) {
+			int lastCellNum = row.getLastCellNum();
+			for (int idx = 0; idx < lastCellNum; idx++) {
+				String value = getCellValue(row.getCell(idx)).trim();
+				if (idx <  columnName.length) {
+					if (StringUtils.isBlank(value) || !columnName[idx].equals(value)) {
+						builder.append("第" + (idx + 1) + "列表头应为" + columnName[idx]+"!");
+					}
+				} else {
+					if (idx ==  columnName.length) {
+						builder.append("导入文件只应该有:"+ columnName.length+"!");
+					}
+				}
+			}
+		} else {
+			builder.append("上传文件首行不能为空,且应与模板文件表头保持一致;");
+		}
+		if(builder.length()>0){
+			builder.append("请下载模板按照模板表头顺序进行上传!");
+			//builder.setCharAt(builder.length()-1, '!');
+		}
+		return builder.toString();
+	}
+
+
+	/**
+	 * 获取cell值
+	 *
+	 * @param cell
+	 * @return
+	 */
+	private static String getCellValue(Cell cell) {
+		String cellValue = "";
+		// 以下是判断数据的类型
+		switch (cell.getCellType()) {
+			case Cell.CELL_TYPE_NUMERIC: // 数字
+				if (DateUtil.isCellDateFormatted(cell)) {
+					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+					cellValue = sdf.format(DateUtil.getJavaDate(cell.getNumericCellValue())).toString();
+				} else {
+					DataFormatter dataFormatter = new DataFormatter();
+					cellValue = dataFormatter.formatCellValue(cell);
+				}
+				break;
+			case Cell.CELL_TYPE_STRING: // 字符串
+				cellValue = cell.getStringCellValue();
+				break;
+			case Cell.CELL_TYPE_BOOLEAN: // Boolean
+				cellValue = cell.getBooleanCellValue() + "";
+				break;
+			case Cell.CELL_TYPE_FORMULA: // 公式
+				cellValue = cell.getCellFormula() + "";
+				break;
+			case Cell.CELL_TYPE_BLANK: // 空值
+				cellValue = "";
+				break;
+			case Cell.CELL_TYPE_ERROR: // 故障
+				cellValue = "非法字符";
+				break;
+			default:
+				cellValue = "未知类型";
+				break;
+		}
+		return cellValue;
+	}
+	/**
+	 * 获取该注解对象的属性值(字段名称和注解的value值)
+	 * @param object
+	 * @return
+	 */
+	public static Map<String,List<String>> getAnnotationValue(Object object) {
+		Map<String,List<String>>map=new HashMap<>();
+		List<String> fieldList=new ArrayList<>();
+		List<String> annotationList=new ArrayList<>();
+		//StudentVO studentVO = new StudentVO();
+		Field[] fields = object.getClass().getDeclaredFields();
+		for(int i = 0 ; i < fields.length ; i++) {
+			//设置是否允许访问,不是修改原来的访问权限修饰词。
+			fields[i].setAccessible(true);
+			ExcelProperty annotation = fields[i].getAnnotation(ExcelProperty.class);
+			String[] value = annotation.value();
+			for (String s : value) {
+				annotationList.add(s);
+			}
+			fieldList.add(fields[i].getName());
+		}
+		map.put("fieldName",fieldList);
+		map.put("annotationName",annotationList);
+		return map;
+	}
+
+}