From dca2532f01dac86be25ad09fa9ee8035bccdca6a Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Sat, 27 Nov 2021 17:11:33 +0800
Subject: [PATCH] 1.部门tree修改 2.用户查询修改 3.培训报名年龄拦截
---
src/main/java/org/springblade/modules/system/controller/UserController.java | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 217 insertions(+), 5 deletions(-)
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..91c62c4 100644
--- a/src/main/java/org/springblade/modules/system/controller/UserController.java
+++ b/src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -55,6 +55,8 @@
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.*;
import org.springblade.modules.FTP.FtpUtil;
+import org.springblade.modules.dispatcher.entity.Dispatcher;
+import org.springblade.modules.dispatcher.service.IDispatcherService;
import org.springblade.modules.exam.excel.ExportExamScoreExcel;
import org.springblade.modules.experience.entity.Experience;
import org.springblade.modules.experience.service.IExperienceService;
@@ -111,6 +113,8 @@
private final IExperienceService experienceService;
private final JurisdictionService jurisdictionService;
+
+ private final IDispatcherService dispatcherService;
/**
* 查询单条
@@ -259,6 +263,7 @@
+ ",role_id = " + "'" + user.getRoleId() + "'"
+ ",dept_id = " + "'" + user.getDeptId() + "'"
+ ",cardid = " + "'" + user.getCardid() + "'"
+ + ",guncode = " + "'" + user.getGuncode() + "'"
+ " " + "where id = " + "'" + user.getId() + "'";
FtpUtil.sqlFileUpload(s1);
}
@@ -285,6 +290,39 @@
user.setFingerprint(split[0]);
//内网指纹图片url
url = split[1];
+ }
+ }
+
+ //如果是离职
+ if (null!=user.getStatus()){
+ if (user.getStatus()==2){
+ //修改派遣状态
+ user.setDispatch("1");
+ //同时将派遣记录中的派遣状态修改
+ //查询派遣记录(还在派遣中的)
+ Dispatcher dispatcher = new Dispatcher();
+ dispatcher.setUserIds(user.getId().toString());
+ dispatcher.setStatus(0);
+ List<Dispatcher> dispatcherList = dispatcherService.list(Condition.getQueryWrapper(dispatcher));
+ if (dispatcherList.size()>0){
+ dispatcherList.forEach(dispatcher1 -> {
+ dispatcher1.setStatus(1);
+ dispatcher1.setUpdateTime(new Date());
+ String s1 =
+ "update sys_dispatcher set status = " + "'" + dispatcher1.getStatus() + "'"
+ + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dispatcher1.getUpdateTime()) + "'"
+ + " " + "where id = " + "'" + dispatcher1.getId() + "'";
+ FtpUtil.sqlFileUpload(s1);
+ });
+ }
+ }
+ }
+
+ //如果是异常标记
+ if (null!=user.getExaminationType() && !user.getExaminationType().equals("")){
+ if (user.getExaminationType().equals("1")) {
+ //吊销保安证
+ user.setHold("3");
}
}
@@ -319,10 +357,52 @@
+ ",address = " + "'" + user.getAddress() + "'"
+ ",registered = " + "'" + user.getRegistered() + "'"
+ ",rtime = " + "'" + rtime + "'"
+ + ",dispatch = " + "'" + user.getDispatch() + "'"
+ ",securitynumber = " + "'" + user.getSecuritynumber() + "'"
+ ",hold = " + "'" + user.getHold() + "'"
+ ",jurisdiction = " + "'" + user.getJurisdiction() + "'"
+ ",reason_for_leav = " + "'" + user.getReasonForLeav() + "'"
+ + ",guncode = " + "'" + user.getGuncode() + "'"
+ + " " + "where id = " + "'" + user.getId() + "'";
+ FtpUtil.sqlFileUpload(s1);
+ return R.success("修改成功");
+ }
+
+
+ /**
+ * 修改
+ */
+ @PostMapping("/updateUserInfo")
+ public R updateUserInfo(@Valid @RequestBody User user) throws Exception {
+ String url = null;
+ if (null!=user.getFingerprint() && !user.getFingerprint().equals("")) {
+ if (user.getFingerprint().length()>100) {
+ //指纹图片上传并返回url
+ String s = uploadBase64String(user);
+ String[] split = s.split(",");
+ user.setFingerprint(split[0]);
+ //内网指纹图片url
+ url = split[1];
+ }
+ }
+
+ userService.updateById(user);
+
+ //内网同步
+ String s1 =
+ "update blade_user set account = " + "'" + user.getCardid() + "'"
+ + ",real_name = " + "'" + user.getRealName() + "'"
+ + ",avatar = " + "'" + user.getAvatar() + "'"
+ + ",sex = " + "'" + user.getSex() + "'"
+ + ",cardid = " + "'" + user.getCardid() + "'"
+ + ",nation = " + "'" + user.getNation() + "'"
+ + ",fingerprint = " + "'" + url + "'"
+ + ",my_picture = " + "'" + user.getMyPicture() + "'"
+ + ",address = " + "'" + user.getAddress() + "'"
+ + ",registered = " + "'" + user.getRegistered() + "'"
+ + ",securitynumber = " + "'" + user.getSecuritynumber() + "'"
+ + ",hold = " + "'" + user.getHold() + "'"
+ + ",cell = " + "'" + user.getCell() + "'"
+ " " + "where id = " + "'" + user.getId() + "'";
FtpUtil.sqlFileUpload(s1);
return R.success("修改成功");
@@ -526,6 +606,30 @@
return R.success("操作成功");
}
+ /**
+ * 导入保安员(test)
+ */
+ @PostMapping("import-security-test")
+ @ApiOperationSupport(order = 12)
+ @ApiOperation(value = "导入用户", notes = "传入excel")
+ public R importSecurityTest(MultipartFile file, Integer isCovered,String deptId) {
+ SecurityImporterTest securityImporter = new SecurityImporterTest(userService, false,deptId);
+ ExcelUtil.save(file, securityImporter, SecurityExcel.class);
+ 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 +656,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 +708,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;
}
@@ -742,9 +902,36 @@
user.setExaminationType("0");
user.setAccount(user.getCardid());
- Integer userCount = userService.selectCount(user.getAccount());
- if (userCount > 0 && Func.isEmpty(user.getId())) {
- throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+// Integer userCount = userService.selectCount(user.getAccount());
+ User user1 = new User();
+ user1.setIsDeleted(0);
+ user1.setStatus(1);
+ user1.setAccount(user.getCardid());
+ List<User> list = userService.list(Condition.getQueryWrapper(user1));
+
+ if (list.size() > 0 && Func.isEmpty(user.getId())) {
+ if (null!=user.getCell() && !user.getCell().equals("")) {
+ if (user.getCell().equals("2")){
+ list.forEach(user2 -> {
+ //判断是否在本单位,如果是本单位,则不能再次新增
+ if(!user2.getDeptId().equals(user.getDeptId())) {
+ user2.setStatus(2);
+ //先将原有人员离职 cell 1:手动录入 2:自动录入
+ userService.updateById(user2);
+ //内网同步
+ String s1 = "update blade_user set status = " + user2.getStatus() +
+ " where id = " + "'" + user2.getId() + "'";
+ FtpUtil.sqlFileUpload(s1);
+ }else {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
+ });
+ }else {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
+ }else {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
}
String url = null;
@@ -797,7 +984,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,cell) " +
"values(" + "'" + user.getId() + "'" +
"," + "'" + user.getTenantId() + "'" +
"," + "'" + user.getAccount() + "'" +
@@ -827,7 +1014,9 @@
"," + "'" + user.getExaminationType() + "'" +
"," + "'" + user.getStatus() + "'" +
"," + "'" + user.getIsDeleted() + "'" +
- "," + "'" + user.getDispatch() + "'" + ")";
+ "," + "'" + user.getDispatch() + "'" +
+ "," + "'" + user.getGuncode() + "'" +
+ "," + "'" + user.getCell() + "'" + ")";
FtpUtil.sqlFileUpload(s);
//获取从业记录
@@ -891,4 +1080,27 @@
return R.data(user1);
}
+
+ /**
+ * 保安员导出
+ * @param response
+ * @param user 查询条件
+ */
+ @GetMapping("export-security-info")
+ public void exportSecurityInfo(HttpServletResponse response,UserVO user) throws IOException {
+ List<SecurityExcel> list = userService.exportSecurityInfo(user);
+ 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(), SecurityExcel.class).sheet("保安员数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
+ } catch (Throwable var6) {
+ throw var6;
+ }
+// ExcelUtil.export(response, "保安员导入数据模板", "保安员数据表", list, UserExcel.class);
+ }
+
}
--
Gitblit v1.9.3