From d9ee9d3b4c286f21d94b979465ed4db87b635a4d Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Tue, 16 Nov 2021 08:44:22 +0800
Subject: [PATCH] 1.押运公司保安添加持枪编码
---
src/main/java/org/springblade/modules/system/controller/DeptController.java | 25 ++++++
src/main/java/org/springblade/modules/system/excel/SecurityYyExcel.java | 79 +++++++++++++++++++
src/main/java/org/springblade/modules/system/controller/UserController.java | 75 ++++++++++++++++++
src/main/java/org/springblade/modules/system/entity/User.java | 5 +
src/main/java/org/springblade/modules/system/excel/SecurityYyImporter.java | 41 ++++++++++
src/main/java/org/springblade/modules/system/service/IUserService.java | 2
6 files changed, 225 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/controller/DeptController.java b/src/main/java/org/springblade/modules/system/controller/DeptController.java
index bafd574..b4d5bf0 100644
--- a/src/main/java/org/springblade/modules/system/controller/DeptController.java
+++ b/src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -33,6 +33,9 @@
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.FTP.FtpUtil;
+import org.springblade.modules.information.entity.Information;
+import org.springblade.modules.information.service.IInformationService;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.node.TreeNodes;
@@ -65,6 +68,7 @@
private final IDeptService deptService;
private final IUserService userService;
+ private final IInformationService informationService;
/**
* 详情
@@ -219,13 +223,34 @@
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入dept")
public R submit(@Valid @RequestBody Dept dept) {
+ // Information information = new Information();
+ //Integer isDeleted = 0;
if (deptService.submit(dept)) {
CacheUtil.clear(SYS_CACHE);
// 返回懒加载树更新节点所需字段
Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
.set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()));
+// String id = kv.get("id").toString();
+// information.setDepartmentid(id);
+// information.setEnterprisename(dept.getDeptName());
+// Integer deptCategory = dept.getDeptCategory();
+// information.setStats(String.valueOf(deptCategory));
return R.data(kv);
}
+// informationService.save(information);
+// String s = "insert into sys_information(id,enterpriseName,departmentid,stats) " +
+// "values(" + "'" + information.getId() + "'" +
+// "," + "'" + information.getEnterprisename() + "'" +
+// "," + "'" + information.getDepartmentid() + "'" +
+// "," + "'" + information.getStats() + "'"+ ")";
+// FtpUtil.sqlFileUpload(s);
+// String ss = "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category,is_deleted) values(" + "'" + dept.getId() + "'" + "," + "'" + dept.getParentId() + "'" + ","
+// + "'" + dept.getTenantId() + "'" +
+// "," + "'" + information.getEnterprisename() + "'" +
+// "," + "'" + dept.getAncestors() + "'" +
+// "," + "'" + dept.getDeptCategory() + "'" +
+// "," + "'" + isDeleted + "'" + ")";
+// FtpUtil.sqlFileUpload(ss);
return R.fail("操作失败");
}
diff --git a/src/main/java/org/springblade/modules/system/controller/UserController.java b/src/main/java/org/springblade/modules/system/controller/UserController.java
index 4c4f4b8..1ccc519 100644
--- a/src/main/java/org/springblade/modules/system/controller/UserController.java
+++ b/src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -259,6 +259,7 @@
+ ",role_id = " + "'" + user.getRoleId() + "'"
+ ",dept_id = " + "'" + user.getDeptId() + "'"
+ ",cardid = " + "'" + user.getCardid() + "'"
+ + ",guncode = " + "'" + user.getGuncode() + "'"
+ " " + "where id = " + "'" + user.getId() + "'";
FtpUtil.sqlFileUpload(s1);
}
@@ -323,6 +324,7 @@
+ ",hold = " + "'" + user.getHold() + "'"
+ ",jurisdiction = " + "'" + user.getJurisdiction() + "'"
+ ",reason_for_leav = " + "'" + user.getReasonForLeav() + "'"
+ + ",guncode = " + "'" + user.getGuncode() + "'"
+ " " + "where id = " + "'" + user.getId() + "'";
FtpUtil.sqlFileUpload(s1);
return R.success("修改成功");
@@ -526,6 +528,18 @@
return R.success("操作成功");
}
+ /**
+ * 导入持枪保安员
+ */
+ @PostMapping("import-securityYy")
+ @ApiOperationSupport(order = 12)
+ @ApiOperation(value = "导入用户", notes = "传入excel")
+ public R importSecurityYy(MultipartFile file, Integer isCovered,String deptId) {
+ SecurityYyImporter securityYyImporter = new SecurityYyImporter(userService, false,deptId);
+ ExcelUtil.save(file, securityYyImporter, SecurityYyExcel.class);
+ return R.success("操作成功");
+ }
+
// /**
// * 导出用户
// */
@@ -552,6 +566,17 @@
public void exportUser(HttpServletResponse response) {
List<UserExcel> list = new ArrayList<>();
ExcelUtil.export(response, "用户数据模板", "用户数据表", list, UserExcel.class);
+ }
+
+ /**
+ * 导出持枪保安模板
+ */
+ @GetMapping("export-templateYy")
+ @ApiOperationSupport(order = 14)
+ @ApiOperation(value = "导出模板")
+ public void exportUserYy(HttpServletResponse response) {
+ List<SecurityYyExcel> list = new ArrayList<>();
+ ExcelUtil.export(response, "持枪保安员数据模板", "持枪保安员数据表", list, SecurityYyExcel.class);
}
/**
@@ -593,6 +618,51 @@
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
//修改单元格格式为文本格式
EasyExcel.write(response.getOutputStream(), SecurityExcel.class).sheet("保安员数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
+ } catch (Throwable var6) {
+ throw var6;
+ }
+// ExcelUtil.export(response, "保安员导入数据模板", "保安员数据表", list, UserExcel.class);
+ }
+
+ /**
+ * 持枪保安员导出模板
+ */
+ @GetMapping("export-template-securityYy")
+ @ApiOperationSupport(order = 14)
+ @ApiOperation(value = "导出模板")
+ public void exportSecurityYy(HttpServletResponse response) throws IOException {
+ List<SecurityYyExcel> list = new ArrayList<>();
+ SecurityYyExcel securityExcel = new SecurityYyExcel();
+ securityExcel.setDeptId("xxx保安公司");
+ securityExcel.setRealName("张三");
+ securityExcel.setPhone("12345678901");
+ securityExcel.setSex("男");
+ securityExcel.setCardid("360XXX19XXXXXX****");
+ securityExcel.setNation("汉");
+ securityExcel.setRegistered("江西省南昌市******");
+ securityExcel.setHold("是");
+ securityExcel.setSecuritynumber("赣洪202100001");
+ list.add(securityExcel);
+
+ SecurityYyExcel securityExcel1 = new SecurityYyExcel();
+ securityExcel1.setDeptId("xxx保安公司");
+ securityExcel1.setRealName("李四");
+ securityExcel1.setPhone("12345678901");
+ securityExcel1.setSex("女");
+ securityExcel1.setCardid("360XXX19XXXXXX****");
+ securityExcel1.setNation("汉");
+ securityExcel1.setRegistered("江西省南昌市******");
+ securityExcel1.setHold("否");
+ securityExcel1.setSecuritynumber("");
+ list.add(securityExcel1);
+ 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(), SecurityYyExcel.class).sheet("保安员数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
} catch (Throwable var6) {
throw var6;
}
@@ -797,7 +867,7 @@
"id,tenant_id,account,password,name,real_name,avatar,email,phone,sex," +
"role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," +
"politicaloutlook,healstats,height,address,registered,rtime," +
- "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch) " +
+ "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch,guncode) " +
"values(" + "'" + user.getId() + "'" +
"," + "'" + user.getTenantId() + "'" +
"," + "'" + user.getAccount() + "'" +
@@ -827,7 +897,8 @@
"," + "'" + user.getExaminationType() + "'" +
"," + "'" + user.getStatus() + "'" +
"," + "'" + user.getIsDeleted() + "'" +
- "," + "'" + user.getDispatch() + "'" + ")";
+ "," + "'" + user.getIsDeleted() + "'" +
+ "," + "'" + user.getGuncode() + "'" + ")";
FtpUtil.sqlFileUpload(s);
//获取从业记录
diff --git a/src/main/java/org/springblade/modules/system/entity/User.java b/src/main/java/org/springblade/modules/system/entity/User.java
index b17e832..f1039f1 100644
--- a/src/main/java/org/springblade/modules/system/entity/User.java
+++ b/src/main/java/org/springblade/modules/system/entity/User.java
@@ -255,4 +255,9 @@
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("audit_time")
private Date auditTime;
+
+ /**
+ * 持枪编码
+ */
+ private String guncode;
}
diff --git a/src/main/java/org/springblade/modules/system/excel/SecurityYyExcel.java b/src/main/java/org/springblade/modules/system/excel/SecurityYyExcel.java
new file mode 100644
index 0000000..1abe558
--- /dev/null
+++ b/src/main/java/org/springblade/modules/system/excel/SecurityYyExcel.java
@@ -0,0 +1,79 @@
+/*
+ * 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.system.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;
+
+/**
+ * UserExcel
+ *
+ * @author Chill
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class SecurityYyExcel implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ExcelProperty("单位名称*")
+ @ColumnWidth(30)
+ private String deptId;
+
+ @ColumnWidth(10)
+ @ExcelProperty("姓名*")
+ private String realName;
+
+ @ColumnWidth(15)
+ @ExcelProperty("联系电话*")
+ private String phone;
+
+ @ExcelProperty("性别*")
+ @ColumnWidth(10)
+ private String sex;
+
+ @ExcelProperty("身份证号*")
+ @ColumnWidth(20)
+ private String cardid;
+
+ @ExcelProperty("民族")
+ @ColumnWidth(10)
+ private String nation;
+
+ @ExcelProperty("身份证住址*")
+ private String registered;
+
+ @ExcelProperty("是否持证*")
+ @ColumnWidth(15)
+ private String hold;
+
+ @ExcelProperty("保安员证编码")
+ @ColumnWidth(20)
+ private String securitynumber;
+
+ @ExcelProperty("持枪编码")
+ @ColumnWidth(20)
+ private String guncode;
+
+
+}
diff --git a/src/main/java/org/springblade/modules/system/excel/SecurityYyImporter.java b/src/main/java/org/springblade/modules/system/excel/SecurityYyImporter.java
new file mode 100644
index 0000000..7a44045
--- /dev/null
+++ b/src/main/java/org/springblade/modules/system/excel/SecurityYyImporter.java
@@ -0,0 +1,41 @@
+/*
+ * 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.system.excel;
+
+import lombok.RequiredArgsConstructor;
+import org.springblade.core.excel.support.ExcelImporter;
+import org.springblade.modules.system.service.IUserService;
+
+import java.util.List;
+
+/**
+ * 用户数据导入类
+ *
+ * @author Chill
+ */
+@RequiredArgsConstructor
+public class SecurityYyImporter implements ExcelImporter<SecurityYyExcel> {
+
+ private final IUserService service;
+ private final Boolean isCovered;
+ private final String deptId;
+
+ @Override
+ public void save(List<SecurityYyExcel> data) {
+ service.importSecurityYy(data, isCovered,deptId);
+ }
+}
diff --git a/src/main/java/org/springblade/modules/system/service/IUserService.java b/src/main/java/org/springblade/modules/system/service/IUserService.java
index 7d45fbd..2a7f4d7 100644
--- a/src/main/java/org/springblade/modules/system/service/IUserService.java
+++ b/src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -26,6 +26,7 @@
import org.springblade.modules.system.entity.UserOauth;
import org.springblade.modules.system.excel.QrCodeExcel;
import org.springblade.modules.system.excel.SecurityExcel;
+import org.springblade.modules.system.excel.SecurityYyExcel;
import org.springblade.modules.system.excel.UserExcel;
import org.springblade.modules.system.node.TreeNode;
import org.springblade.modules.system.vo.UserVO;
@@ -291,6 +292,7 @@
* @param isCovered
*/
void importSecurity(List<SecurityExcel> data, Boolean isCovered, String deptId);
+ void importSecurityYy(List<SecurityYyExcel> data, Boolean isCovered, String deptId);
/**
* 根据保安员编码查询保安信息
--
Gitblit v1.9.3