From 8782a61b92d8dc1f8d3fd7d16a517fa934ac7e96 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 15 Nov 2021 20:59:33 +0800
Subject: [PATCH] 枪支,车辆批量导入,制证申请修改,审核通过状态修改为未制证

---
 src/main/java/org/springblade/modules/equipage/service/GunService.java                             |   12 +
 src/main/java/org/springblade/modules/equipage/service/impl/GunServiceImpl.java                    |   63 +++++
 src/main/java/org/springblade/modules/equipage/service/impl/CarServiceImpl.java                    |   60 +++++
 src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java                  |   47 +++
 src/main/java/org/springblade/modules/equipage/service/CarService.java                             |   11 
 src/main/java/org/springblade/modules/equipage/excel/GunImporter.java                              |   42 +++
 src/main/java/org/springblade/modules/equipage/excel/GunExcel.java                                 |   91 +++++++
 src/main/java/org/springblade/modules/equipage/entity/Car.java                                     |    4 
 src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java |   80 +++++-
 src/main/java/org/springblade/modules/equipage/controller/CarController.java                       |   46 +++
 src/main/java/org/springblade/modules/equipage/entity/Gun.java                                     |    2 
 src/main/java/org/springblade/modules/equipage/excel/CarExcel.java                                 |  111 +++++++++
 src/main/java/org/springblade/modules/equipage/excel/CarImporter.java                              |   40 +++
 src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java                               |    7 
 src/main/java/org/springblade/modules/equipage/controller/GunController.java                       |   56 ++++
 src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java                     |    3 
 16 files changed, 641 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java b/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
index 0d9f2ab..4900cc0 100644
--- a/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
+++ b/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
@@ -14,6 +14,7 @@
 import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.accreditation.excel.ExportSecurityBookPaperExcel;
 import org.springblade.modules.accreditation.excel.ExportSecurityPaperExcel;
+import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IUserService;
 import org.springblade.modules.accreditation.entity.AccreditationRecords;
 import org.springblade.modules.accreditation.service.AccreditationRecordsService;
@@ -82,15 +83,39 @@
 	@PostMapping("/audit")
 	public R audit(@RequestBody AccreditationRecords accreditationRecords){
 		accreditationRecords.setAuditTime(new Date());
+
 		boolean b = accreditationRecordsService.updateById(accreditationRecords);
-		//内网同步
-		String s =
-			"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
-				",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
-				",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
-				",audit_user = " + accreditationRecords.getAuditUser() + " " +
-				"where id = " + "'" + accreditationRecords.getId() + "'";
-		FtpUtil.sqlFileUpload(s);
+		//审核通过
+		if (accreditationRecords.getAuditStatus()==2){
+			//修改为未制证状态
+			AccreditationRecords records = accreditationRecordsService.getById(accreditationRecords);
+			User user = userService.getById(records.getUserId());
+			user.setUserType(7);
+			user.setUpdateTime(new Date());
+			//更新
+			userService.updateById(user);
+
+			//内网同步
+			String s =
+				"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+					",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+					",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+					",audit_user = " + accreditationRecords.getAuditUser() + " " +
+					"where id = " + "'" + accreditationRecords.getId() + "';" +
+				"update blade_user set user_type = " + user.getUserType() + "" +
+					",update_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "" +
+					"where id = " + "'" + user.getId() + "'";
+			FtpUtil.sqlFileUpload(s);
+		}else {
+			//内网同步
+			String s =
+				"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+					",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+					",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+					",audit_user = " + accreditationRecords.getAuditUser() + " " +
+					"where id = " + "'" + accreditationRecords.getId() + "'";
+			FtpUtil.sqlFileUpload(s);
+		}
 		//返回
 		return R.status(b);
 	}
@@ -110,14 +135,37 @@
 			accreditationRecords.setId(Long.parseLong(id));
 			accreditationRecords.setAuditTime(new Date());
 			accreditationRecordsService.updateById(accreditationRecords);
-			//内网同步
-			String s =
-				"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
-					",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
-					",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
-					",audit_user = " + accreditationRecords.getAuditUser() + " " +
-					"where id = " + "'" + accreditationRecords.getId() + "'";
-			FtpUtil.sqlFileUpload(s);
+			//审核通过
+			if (accreditationRecords.getAuditStatus()==2){
+				//修改为未制证状态
+				AccreditationRecords records = accreditationRecordsService.getById(id);
+				User user = userService.getById(records.getUserId());
+				user.setUserType(7);
+				user.setUpdateTime(new Date());
+				//更新
+				userService.updateById(user);
+
+				//内网同步
+				String s =
+					"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+						",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+						",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+						",audit_user = " + accreditationRecords.getAuditUser() + " " +
+						"where id = " + "'" + accreditationRecords.getId() + "';" +
+					"update blade_user set user_type = " + user.getUserType() + "" +
+						",update_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "" +
+						"where id = " + "'" + user.getId() + "'";
+				FtpUtil.sqlFileUpload(s);
+			}else {
+				//内网同步
+				String s =
+					"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+						",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+						",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+						",audit_user = " + accreditationRecords.getAuditUser() + " " +
+						"where id = " + "'" + accreditationRecords.getId() + "'";
+				FtpUtil.sqlFileUpload(s);
+			}
 		});
 		//返回
 		return R.status(true);
diff --git a/src/main/java/org/springblade/modules/equipage/controller/CarController.java b/src/main/java/org/springblade/modules/equipage/controller/CarController.java
index f0101cc..7735838 100644
--- a/src/main/java/org/springblade/modules/equipage/controller/CarController.java
+++ b/src/main/java/org/springblade/modules/equipage/controller/CarController.java
@@ -1,23 +1,31 @@
 package org.springblade.modules.equipage.controller;
 
+import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
+import org.apache.commons.codec.Charsets;
+import org.springblade.common.excel.RowWriteHandler;
 import org.springblade.common.utils.arg;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.equipage.entity.Car;
+import org.springblade.modules.equipage.excel.CarExcel;
+import org.springblade.modules.equipage.excel.CarImporter;
 import org.springblade.modules.equipage.service.CarService;
 import org.springblade.modules.equipage.vo.CarVo;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -141,4 +149,42 @@
 		return R.data(detail);
 	}
 
+	/**
+	 * 导入车辆信息, excel
+	 */
+	@PostMapping("import-car")
+	public R importCar(MultipartFile file, Integer isCovered,String deptId) {
+		CarImporter carImporter = new CarImporter(carService, false,deptId);
+		ExcelUtil.save(file, carImporter, CarExcel.class);
+		return R.success("操作成功");
+	}
+
+	/**
+	 * 车辆导出模板
+	 */
+	@GetMapping("export-template-car")
+	@ApiOperation(value = "导出模板")
+	public void exportSecurity(HttpServletResponse response) throws IOException {
+		List<CarExcel> list = new ArrayList<>();
+		CarExcel carExcel1 = new CarExcel();
+		carExcel1.setDeptId("xxx保安公司");
+		carExcel1.setBrand("****");
+		carExcel1.setCarNumber("赣A415225");
+		carExcel1.setMode("X54512545");
+		carExcel1.setPersonInCharge("张三");
+		carExcel1.setUmweltsatz("国IV");
+		list.add(carExcel1);
+		String fileName = null;
+		try {
+			response.setContentType("application/vnd.ms-excel");
+			response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
+			fileName = URLEncoder.encode("车辆导入数据模板"+ DateUtil.time(), Charsets.UTF_8.name());
+			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+			//修改单元格格式为文本格式
+			EasyExcel.write(response.getOutputStream(), CarExcel.class).sheet("车辆数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
+		} catch (Throwable var6) {
+			throw var6;
+		}
+	}
+
 }
diff --git a/src/main/java/org/springblade/modules/equipage/controller/GunController.java b/src/main/java/org/springblade/modules/equipage/controller/GunController.java
index 0393ab0..010138f 100644
--- a/src/main/java/org/springblade/modules/equipage/controller/GunController.java
+++ b/src/main/java/org/springblade/modules/equipage/controller/GunController.java
@@ -1,21 +1,33 @@
 package org.springblade.modules.equipage.controller;
 
+import com.alibaba.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
+import org.apache.commons.codec.Charsets;
+import org.springblade.common.excel.RowWriteHandler;
 import org.springblade.common.utils.arg;
+import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.equipage.entity.Gun;
+import org.springblade.modules.equipage.excel.GunExcel;
+import org.springblade.modules.equipage.excel.GunImporter;
 import org.springblade.modules.equipage.service.GunService;
 import org.springblade.modules.equipage.vo.GunVo;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -74,10 +86,9 @@
 
 			//数据同步
 			String s1 =
-				"insert into sys_gun(id,gun_card_number,issue_unit,card_number,gun_mode," +
+				"insert into sys_gun(id,issue_unit,card_number,gun_mode," +
 					"dept_id,person_in_charge,issue_time,valid_time,jurisdiction) " +
 					"values(" + "'" + gun.getId() + "'" + "," +
-					"'" + gun.getGunCardNumber() + "'" + "," +
 					"'" + gun.getIssueUnit() + "'" + "," +
 					"'" + gun.getCardNumber() + "'" + "," +
 					"'" + gun.getGunMode() + "'" + "," +
@@ -92,8 +103,7 @@
 			status = gunService.updateById(gun);
 			//内网同步
 			String s1 =
-				"update sys_gun set gun_card_number = " + "'" + gun.getGunCardNumber() + "'" +
-					",issue_unit = " + "'" + gun.getIssueUnit() + "'" +
+				"update sys_gun set issue_unit = " + "'" + gun.getIssueUnit() + "'" +
 					",card_number = " + "'" + gun.getCardNumber() + "'" +
 					",gun_mode = " + "'" + gun.getGunMode() + "'" +
 					",dept_id = " + "'" + gun.getDeptId() + "'" +
@@ -134,4 +144,42 @@
 		return R.data(detail);
 	}
 
+
+	/**
+	 * 导入枪支信息, excel
+	 */
+	@PostMapping("import-gun")
+	public R importGun(MultipartFile file, Integer isCovered, String deptId) {
+		GunImporter gunImporter = new GunImporter(gunService, false,deptId);
+		ExcelUtil.save(file, gunImporter, GunExcel.class);
+		return R.success("操作成功");
+	}
+
+	/**
+	 * 枪支导出模板
+	 */
+	@GetMapping("export-template-gun")
+	@ApiOperation(value = "导出模板")
+	public void exportGun(HttpServletResponse response) throws IOException {
+		List<GunExcel> list = new ArrayList<>();
+		GunExcel gunExcel1 = new GunExcel();
+		gunExcel1.setDeptId("xxx保安公司");
+		gunExcel1.setCardNumber("x****");
+		gunExcel1.setGunMode("x****");
+		gunExcel1.setIssueUnit("*****");
+		gunExcel1.setPersonInCharge("张三");
+		list.add(gunExcel1);
+		String fileName = null;
+		try {
+			response.setContentType("application/vnd.ms-excel");
+			response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
+			fileName = URLEncoder.encode("枪支导入数据模板"+ DateUtil.time(), Charsets.UTF_8.name());
+			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+			//修改单元格格式为文本格式
+			EasyExcel.write(response.getOutputStream(), GunExcel.class).sheet("枪支数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
+		} catch (Throwable var6) {
+			throw var6;
+		}
+	}
+
 }
diff --git a/src/main/java/org/springblade/modules/equipage/entity/Car.java b/src/main/java/org/springblade/modules/equipage/entity/Car.java
index 46a6e9e..d3c6b76 100644
--- a/src/main/java/org/springblade/modules/equipage/entity/Car.java
+++ b/src/main/java/org/springblade/modules/equipage/entity/Car.java
@@ -21,7 +21,7 @@
 	private static final long serialVersionUID = 1L;
 
 	/**
-	 * 招聘主键id
+	 * 主键id
 	 */
 	@TableId(value = "id",type = IdType.AUTO)
 	private Long id;
@@ -78,6 +78,8 @@
 	 * 车辆型号
 	 */
 	private String mode;
+
+
 	private String jurisdiction;
 
 }
diff --git a/src/main/java/org/springblade/modules/equipage/entity/Gun.java b/src/main/java/org/springblade/modules/equipage/entity/Gun.java
index dcc9331..e068ddd 100644
--- a/src/main/java/org/springblade/modules/equipage/entity/Gun.java
+++ b/src/main/java/org/springblade/modules/equipage/entity/Gun.java
@@ -22,7 +22,7 @@
 	private static final long serialVersionUID = 1L;
 
 	/**
-	 * 招聘主键id
+	 * 主键id
 	 */
 	@TableId(value = "id",type = IdType.AUTO)
 	private Long id;
diff --git a/src/main/java/org/springblade/modules/equipage/excel/CarExcel.java b/src/main/java/org/springblade/modules/equipage/excel/CarExcel.java
new file mode 100644
index 0000000..a61c8b0
--- /dev/null
+++ b/src/main/java/org/springblade/modules/equipage/excel/CarExcel.java
@@ -0,0 +1,111 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.equipage.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.format.DateTimeFormat;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * EquipageExcel 保安公司装备
+ * @author zhongrj
+ * @since 2021-08-12
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class CarExcel implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 保安公司名称
+	 */
+	@ColumnWidth(30)
+	@ExcelProperty("单位名称")
+	private String deptId;
+
+	/**
+	 * 车牌号码
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("车牌号码*")
+	private String carNumber;
+
+//	/**
+//	 * 号码种类
+//	 */
+//	@ColumnWidth(20)
+//	@ExcelProperty("号码种类")
+//	private String numberType;
+//
+//	/**
+//	 * 车辆类型
+//	 */
+//	@ColumnWidth(20)
+//	@ExcelProperty("车辆类型")
+//	private String carType;
+
+
+	/**
+	 * 车辆型号
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("车辆型号*")
+	private String mode;
+
+	/**
+	 * 责任人
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("责任人")
+	private String personInCharge;
+
+
+	/**
+	 * 厂商
+	 */
+	@ColumnWidth(10)
+	@ExcelProperty("厂商名称")
+	private String brand;
+
+//
+//	/**
+//	 * 出厂日期
+//	 */
+//	@ColumnWidth(20)
+//	@DateTimeFormat("yyyy-MM-dd")
+//	private Date dateForProduction;
+
+
+	/**
+	 * 环保标志 ,国IV
+	 */
+	@ColumnWidth(10)
+	@ExcelProperty("环保标志")
+	private String umweltsatz;
+
+
+}
diff --git a/src/main/java/org/springblade/modules/equipage/excel/CarImporter.java b/src/main/java/org/springblade/modules/equipage/excel/CarImporter.java
new file mode 100644
index 0000000..d5b1367
--- /dev/null
+++ b/src/main/java/org/springblade/modules/equipage/excel/CarImporter.java
@@ -0,0 +1,40 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.equipage.excel;
+
+import lombok.RequiredArgsConstructor;
+import org.springblade.core.excel.support.ExcelImporter;
+import org.springblade.modules.equipage.service.CarService;
+import java.util.List;
+
+/**
+ * 保安公司装备导入
+ * @author zhongrj
+ * @since 2021-08-12
+ */
+@RequiredArgsConstructor
+public class CarImporter implements ExcelImporter<CarExcel> {
+
+	private final CarService service;
+	private final Boolean isCovered;
+	private final String deptId;
+
+	@Override
+	public void save(List<CarExcel> data) {
+		service.importCar(data, isCovered, deptId);
+	}
+}
diff --git a/src/main/java/org/springblade/modules/equipage/excel/GunExcel.java b/src/main/java/org/springblade/modules/equipage/excel/GunExcel.java
new file mode 100644
index 0000000..a1dc802
--- /dev/null
+++ b/src/main/java/org/springblade/modules/equipage/excel/GunExcel.java
@@ -0,0 +1,91 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.equipage.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * EquipageExcel 保安公司装备
+ * @author zhongrj
+ * @since 2021-08-12
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class GunExcel implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 保安公司名称
+	 */
+	@ColumnWidth(30)
+	@ExcelProperty("单位名称")
+	private String deptId;
+
+	/**
+	 * 公务用枪编号
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("公务用枪编号*")
+	private String cardNumber;
+
+//	/**
+//	 * 号码种类
+//	 */
+//	@ColumnWidth(20)
+//	@ExcelProperty("号码种类")
+//	private String numberType;
+//
+//	/**
+//	 * 车辆类型
+//	 */
+//	@ColumnWidth(20)
+//	@ExcelProperty("车辆类型")
+//	private String carType;
+
+
+	/**
+	 * 发证单位名称
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("发证单位名称")
+	private String issueUnit;
+
+	/**
+	 * 责任人
+	 */
+	@ColumnWidth(20)
+	@ExcelProperty("责任人")
+	private String personInCharge;
+
+
+	/**
+	 * 枪型
+	 */
+	@ColumnWidth(10)
+	@ExcelProperty("枪型")
+	private String gunMode;
+
+
+}
diff --git a/src/main/java/org/springblade/modules/equipage/excel/GunImporter.java b/src/main/java/org/springblade/modules/equipage/excel/GunImporter.java
new file mode 100644
index 0000000..6249818
--- /dev/null
+++ b/src/main/java/org/springblade/modules/equipage/excel/GunImporter.java
@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.equipage.excel;
+
+import lombok.RequiredArgsConstructor;
+import org.springblade.core.excel.support.ExcelImporter;
+import org.springblade.modules.equipage.service.CarService;
+import org.springblade.modules.equipage.service.GunService;
+
+import java.util.List;
+
+/**
+ * 枪支导入
+ * @author zhongrj
+ * @since 2021-11-15
+ */
+@RequiredArgsConstructor
+public class GunImporter implements ExcelImporter<GunExcel> {
+
+	private final GunService service;
+	private final Boolean isCovered;
+	private final String deptId;
+
+	@Override
+	public void save(List<GunExcel> data) {
+		service.importGun(data, isCovered, deptId);
+	}
+}
diff --git a/src/main/java/org/springblade/modules/equipage/service/CarService.java b/src/main/java/org/springblade/modules/equipage/service/CarService.java
index 3a8bc34..3c8cb14 100644
--- a/src/main/java/org/springblade/modules/equipage/service/CarService.java
+++ b/src/main/java/org/springblade/modules/equipage/service/CarService.java
@@ -4,7 +4,11 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.springblade.modules.equipage.entity.Car;
+import org.springblade.modules.equipage.excel.CarExcel;
+import org.springblade.modules.equipage.excel.EquipageExcel;
 import org.springblade.modules.equipage.vo.CarVo;
+
+import java.util.List;
 
 public interface CarService extends IService<Car> {
 
@@ -22,4 +26,11 @@
 	 * @return
 	 */
 	IPage<CarVo> selectCarPage(IPage<CarVo> page, CarVo car);
+
+	/**
+	 * 车辆批量导入
+	 * @param data
+	 * @param isCovered
+	 */
+    void importCar(List<CarExcel> data, Boolean isCovered,String deptId);
 }
diff --git a/src/main/java/org/springblade/modules/equipage/service/GunService.java b/src/main/java/org/springblade/modules/equipage/service/GunService.java
index 6c987ed..819f257 100644
--- a/src/main/java/org/springblade/modules/equipage/service/GunService.java
+++ b/src/main/java/org/springblade/modules/equipage/service/GunService.java
@@ -2,7 +2,11 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.springblade.modules.equipage.entity.Gun;
+import org.springblade.modules.equipage.excel.GunExcel;
+import org.springblade.modules.equipage.excel.GunImporter;
 import org.springblade.modules.equipage.vo.GunVo;
+
+import java.util.List;
 
 public interface GunService extends IService<Gun> {
 
@@ -20,4 +24,12 @@
 	 * @return
      */
 	IPage<GunVo> selectGunPage(IPage<GunVo> page, GunVo gun);
+
+	/**
+	 * 枪支导入
+	 * @param data
+	 * @param isCovered
+	 * @param deptId
+	 */
+    void importGun(List<GunExcel> data, Boolean isCovered, String deptId);
 }
diff --git a/src/main/java/org/springblade/modules/equipage/service/impl/CarServiceImpl.java b/src/main/java/org/springblade/modules/equipage/service/impl/CarServiceImpl.java
index 9f9b908..e15ff26 100644
--- a/src/main/java/org/springblade/modules/equipage/service/impl/CarServiceImpl.java
+++ b/src/main/java/org/springblade/modules/equipage/service/impl/CarServiceImpl.java
@@ -2,11 +2,21 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.equipage.entity.Car;
+import org.springblade.modules.equipage.excel.CarExcel;
 import org.springblade.modules.equipage.mapper.CarMapper;
 import org.springblade.modules.equipage.service.CarService;
 import org.springblade.modules.equipage.vo.CarVo;
+import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IUserDeptService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 车辆服务实现类
@@ -14,6 +24,9 @@
  */
 @Service
 public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarService {
+
+	@Autowired
+	private IUserDeptService userDeptService;
 
 	/**
 	 * 车辆分页信息
@@ -34,4 +47,51 @@
 	public CarVo selectCarInfo(Car car) {
 		return baseMapper.selectCarInfo(car);
 	}
+
+
+	/**
+	 * 车辆批量导入
+	 * @param data
+	 * @param isCovered
+	 */
+	@Override
+	public void importCar(List<CarExcel> data, Boolean isCovered,String deptId) {
+		if (data.size()>0){
+			//遍历
+			data.forEach(carExcel -> {
+				Car car = Objects.requireNonNull(BeanUtil.copy(carExcel, Car.class));
+				//设置部门id
+				String deptIds = userDeptService.selectIn(carExcel.getDeptId());
+				if (null!=deptIds && !deptIds.equals("")) {
+					if (null != deptId && !deptId.equals("")) {
+						if (!deptId.equals(deptIds)) {
+							throw new ServiceException("导入失败!不能导入不是本公司的车辆信息数据!");
+						}
+					}
+					car.setDeptId(Long.parseLong(deptIds));
+				}else {
+					//如果deptIds 为空,则说明还没有改公司
+					throw new ServiceException("导入失败!公司名:["+carExcel.getDeptId()+"]不存在!");
+				}
+
+				//新增车辆数据
+				this.save(car);
+
+				//数据同步
+				String s = "insert into blade_user(" +
+					"id,dept_id,car_number,person_in_charge,brand,umweltsatz,mode) " +
+					"values(" + "'" + car.getId() + "'" +
+					"," + "'" + car.getDeptId() + "'" +
+					"," + "'" + car.getCarNumber() + "'" +
+					"," + "'" + car.getPersonInCharge() + "'" +
+					"," + "'" + car.getBrand() + "'" +
+					"," + "'" + car.getUmweltsatz() + "'" +
+					"," + "'" + car.getMode() + "'" + ")";
+				FtpUtil.sqlFileUpload(s);
+
+			});
+		}else {
+			throw new ServiceException("没有数据");
+		}
+	}
 }
diff --git a/src/main/java/org/springblade/modules/equipage/service/impl/GunServiceImpl.java b/src/main/java/org/springblade/modules/equipage/service/impl/GunServiceImpl.java
index 984a56f..30a5403 100644
--- a/src/main/java/org/springblade/modules/equipage/service/impl/GunServiceImpl.java
+++ b/src/main/java/org/springblade/modules/equipage/service/impl/GunServiceImpl.java
@@ -2,11 +2,23 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.FTP.FtpUtil;
+import org.springblade.modules.equipage.entity.Car;
 import org.springblade.modules.equipage.entity.Gun;
+import org.springblade.modules.equipage.excel.GunExcel;
+import org.springblade.modules.equipage.excel.GunImporter;
 import org.springblade.modules.equipage.mapper.GunMapper;
 import org.springblade.modules.equipage.service.GunService;
 import org.springblade.modules.equipage.vo.GunVo;
+import org.springblade.modules.system.service.IUserDeptService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * 枪支服务实现类
@@ -14,6 +26,9 @@
  */
 @Service
 public class GunServiceImpl extends ServiceImpl<GunMapper, Gun> implements GunService {
+
+	@Autowired
+	private IUserDeptService userDeptService;
 
 	/**
      * 枪支分页信息
@@ -34,4 +49,52 @@
 	public GunVo selectGunInfo(Gun gun) {
 		return baseMapper.selectGunInfo(gun);
 	}
+
+
+	/**
+	 * 枪支导入
+	 * @param data
+	 * @param isCovered
+	 * @param deptId
+	 */
+	@Override
+	public void importGun(List<GunExcel> data, Boolean isCovered, String deptId) {
+		if (data.size()>0){
+			//遍历
+			data.forEach(gunExcel -> {
+				Gun gun = Objects.requireNonNull(BeanUtil.copy(gunExcel, Gun.class));
+				//设置部门id
+				String deptIds = userDeptService.selectIn(gunExcel.getDeptId());
+				if (null!=deptIds && !deptIds.equals("")) {
+					if (null != deptId && !deptId.equals("")) {
+						if (!deptId.equals(deptIds)) {
+							throw new ServiceException("导入失败!不能导入不是本公司的枪支信息数据!");
+						}
+					}
+					gun.setDeptId(Long.parseLong(deptIds));
+				}else {
+					//如果deptIds 为空,则说明还没有改公司
+					throw new ServiceException("导入失败!公司名:["+gunExcel.getDeptId()+"]不存在!");
+				}
+
+				//新增车辆数据
+				this.save(gun);
+
+				//数据同步
+				String s1 =
+					"insert into sys_gun(id,issue_unit,card_number,gun_mode," +
+						"dept_id,person_in_charge) " +
+						"values(" + "'" + gun.getId() + "'" + "," +
+						"'" + gun.getIssueUnit() + "'" + "," +
+						"'" + gun.getCardNumber() + "'" + "," +
+						"'" + gun.getGunMode() + "'" + "," +
+						"'" + gun.getDeptId() + "'" + "," +
+						"'" +gun.getPersonInCharge() + "'" + ")";
+				FtpUtil.sqlFileUpload(s1);
+
+			});
+		}else {
+			throw new ServiceException("没有数据");
+		}
+	}
 }
diff --git a/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java b/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
index bcaf81c..1327f75 100644
--- a/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
+++ b/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -12,6 +12,7 @@
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.FTP.FtpUtil;
 import org.springblade.modules.exam.entity.ExamPaper;
@@ -326,7 +327,7 @@
 		try {
 			response.setContentType("application/vnd.ms-excel");
 			response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
-			fileName = URLEncoder.encode("实操成绩数据模板", Charsets.UTF_8.name());
+			fileName = URLEncoder.encode("实操成绩数据模板"+ DateUtil.time(), Charsets.UTF_8.name());
 			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
 			//修改单元格格式为文本格式
 			EasyExcel.write(response.getOutputStream(), ExamScoreExcel.class).sheet("实操成绩数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
diff --git a/src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java b/src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java
index 152343a..74b074b 100644
--- a/src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java
+++ b/src/main/java/org/springblade/modules/exam/excel/ExamScoreExcel.java
@@ -56,9 +56,16 @@
 	@ExcelProperty("准考证号*")
 	private String candidateNo;
 
+//	@ColumnWidth(15)
+//	@ExcelProperty("理论得分*")
+//	private Integer theoryGrade;
+
 	@ColumnWidth(15)
 	@ExcelProperty("实操得分*")
 	private Integer learnGrade;
 
 
+
+
+
 }
diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
index 77273b8..ec73a36 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -372,23 +372,48 @@
 //			AtomicBoolean status = new AtomicBoolean(true);
 //			//遍历
 //			examScoreExcelList.forEach(examScoreExcel -> {
+//				//根据身份证号查询培训信息
+//				User userInfoByIdCardNo = userService.getUserInfoByIdCardNo(examScoreExcel.getIdCardNo());
+//				TrainingRegistration registration = new TrainingRegistration();
+//				registration.setUserId(userInfoByIdCardNo.getId().toString());
+//				TrainingRegistration one1 = trainingRegistrationService.getOne(Condition.getQueryWrapper(registration));
 ////				测试生成考试成绩
 //				ExamScore examScore = new ExamScore();
-//				examScore.setCandidateNo(examScoreExcel.getCandidateNo());
-//				examScore.setQualified(2);
+//				examScore.setCandidateNo(one1.getCandidateNo());
+//				examScore.setQualified(0);
 //				//根据身份证号查询用户
-//				User user = userService.getUserInfoByIdCardNo(examScoreExcel.getIdCardNo());
-//				examScore.setUserId(user.getId().toString());
-//				examScore.setExamId("120");
-//				//根据准考证号查询报名id
-//				TrainingRegistration trainingRegistration = new TrainingRegistration();
-//				trainingRegistration.setCandidateNo(examScoreExcel.getCandidateNo());
-//				TrainingRegistration one = trainingRegistrationService.getOne(Condition.getQueryWrapper(trainingRegistration));
-//				examScore.setApplyId(one.getId());
+//				examScore.setUserId(userInfoByIdCardNo.getId().toString());
+//				examScore.setExamId(one1.getTrainExamId());
+//				examScore.setApplyId(one1.getId());
 //				examScore.setLearnGrade(examScoreExcel.getLearnGrade());
-//				examScore.setAllGrade(examScore.getLearnGrade()/2);
+//				examScore.setTheoryGrade(examScoreExcel.getTheoryGrade());
+//				examScore.setAllGrade((examScore.getLearnGrade()+examScore.getTheoryGrade())/2);
+//
 //				//新增
 //				this.save(examScore);
+//
+//				//生成准考证号
+//				if (null==userInfoByIdCardNo.getSecuritynumber() || userInfoByIdCardNo.getSecuritynumber().equals("") ) {
+//					//去生成保安证编号
+//					String pre = SecurityPaperUtil.getSecurityPaper();
+//					//查询当前年份已有的保安证编号
+//					int count = userService.getSecurityPaperCount(pre);
+//					String result = null;
+//					if (count == 0) {
+//						result = pre + "00001";
+//					} else {
+//						//格式化
+//						DecimalFormat decimalFormat = new DecimalFormat("00000");
+//						count++;
+//						result = pre + (decimalFormat.format(count));
+//					}
+//					userInfoByIdCardNo.setSecuritynumber(result);
+//					//修改为持证保安
+//					userInfoByIdCardNo.setHold("1");
+//					userInfoByIdCardNo.setRegistered(examScoreExcel.getExamName());
+//					//更新保安数据
+//					userService.updateById(userInfoByIdCardNo);
+//				}
 //			});
 //			//如果所有数据导入有一个异常
 //			if (!status.get()){

--
Gitblit v1.9.3