From 6c9adc4164f0af8a6391bc5ff91ef124d773fc4a Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 17 Jun 2022 18:11:30 +0800
Subject: [PATCH] 用户修改方法新增
---
src/main/java/org/springblade/modules/system/controller/UserController.java | 127 ++++++++++++++++++++++++++++++-
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java | 68 ++++++++++------
2 files changed, 166 insertions(+), 29 deletions(-)
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 e8f912b..fcc58a9 100644
--- a/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
+++ b/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -496,7 +496,7 @@
if (examScoreList.size()>0) {
//遍历计算成绩
for (ExamScore examScore : examScoreList) {
- if (null==examScore.getTheoryGrade()){
+// if (null==examScore.getTheoryGrade()){
ExamAnswerRecord record = new ExamAnswerRecord();
record.setScoreId(examScore.getId());
List<ExamAnswerRecord> list = examAnswerRecordService.list(new QueryWrapper<>(record));
@@ -509,22 +509,22 @@
examScore.setTheoryGrade(num);
examScore.setAllGrade(Math.round(num/2));
//设置状态
- if (num >= 60) {
- examScore.setQualified(2);
+ if (num >= 60 && examScore.getLearnGrade()>=60) {
+ examScore.setQualified(0);
} else {
examScore.setQualified(1);
}
examScoreService.updateById(examScore);
- String s1 =
- "update exam_score set exam_id = " + examScore.getExamId() +
- ",theory_grade = " + "'" + examScore.getTheoryGrade() + "'" +
- ",all_grade = " + "'" + examScore.getAllGrade() + "'" +
- ",exam_end_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(examScore.getExamEndTime()) + "'" +
- ",qualified = " + "'" + examScore.getQualified() + "'" +
- " " + "where id = " + "'" + examScore.getId() + "'";
- myAsyncService.FTP(s1);
+// String s1 =
+// "update exam_score set exam_id = " + examScore.getExamId() +
+// ",theory_grade = " + "'" + examScore.getTheoryGrade() + "'" +
+// ",all_grade = " + "'" + examScore.getAllGrade() + "'" +
+// ",exam_end_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(examScore.getExamEndTime()) + "'" +
+// ",qualified = " + "'" + examScore.getQualified() + "'" +
+// " " + "where id = " + "'" + examScore.getId() + "'";
+// myAsyncService.FTP(s1);
}
- }
+// }
}
}
@@ -533,7 +533,7 @@
if (examScoreLists.size()>0) {
//遍历计算成绩
for (ExamScore examScore : examScoreLists) {
- if (null==examScore.getTheoryGrade()){
+// if (null==examScore.getTheoryGrade()){
if (examScore.getTheoryGrade()>=startScore && examScore.getTheoryGrade()<=endScore){
//生成随机数,在60-79 之间
int score = (int) ((Math.random() * 20));
@@ -543,16 +543,16 @@
examScore.setQualified(2);
examScore.setAllGrade(examScore.getTheoryGrade() / 2);
examScoreService.updateById(examScore);
- String s1 =
- "update exam_score set exam_id = " + examScore.getExamId() +
- ",theory_grade = " + "'" + examScore.getTheoryGrade() + "'" +
- ",all_grade = " + "'" + examScore.getAllGrade() + "'" +
- ",qualified = " + "'" + examScore.getQualified() + "'" +
- " " + "where id = " + "'" + examScore.getId() + "'";
- myAsyncService.FTP(s1);
+// String s1 =
+// "update exam_score set exam_id = " + examScore.getExamId() +
+// ",theory_grade = " + "'" + examScore.getTheoryGrade() + "'" +
+// ",all_grade = " + "'" + examScore.getAllGrade() + "'" +
+// ",qualified = " + "'" + examScore.getQualified() + "'" +
+// " " + "where id = " + "'" + examScore.getId() + "'";
+// myAsyncService.FTP(s1);
}
}
- }
+// }
}
}
@@ -562,12 +562,30 @@
@GetMapping("/clearPaper")
public void clearPaper() {
//修改符合条件的用户信息
- String s0 ="update blade_user set securitynumber = '',hold = '2' where securitynumber like concat('%','赣洪2022','%') and right(securitynumber,5) >2000";
- myAsyncService.FTP(s0);
+ //String s0 ="update blade_user set securitynumber = '',hold = '2' where securitynumber like concat('%','赣洪2022','%') and right(securitynumber,5) >2000";
+ //myAsyncService.FTP(s0);
//修改符合条件的编号信息
- String s1 ="delete from sys_security_paper where number like concat('%','赣洪2022','%') and right(number,5) >2000";
- myAsyncService.FTP(s1);
+ //String s1 ="delete from sys_security_paper where number like concat('%','赣洪2022','%') and right(number,5) >2000";
+ //myAsyncService.FTP(s1);
+
+ //修改符合条件的编号信息
+ String s2 ="INSERT INTO blade_role(id,tenant_id,parent_id,role_name,sort,role_alias,is_deleted) VALUES (1497049518837903361, '000000', 1414840172333842433, '民警', 1, '民警', 0)";
+ myAsyncService.FTP(s2);
+
+ String sql = "update blade_user set status = 2 where cardid = '362524200312182017';" +
+ "update blade_user set status = 2 where cardid = '362524200301120013';" +
+ "update blade_user set status = 2 where cardid = '360122199805150732';" +
+ "update blade_user set status = 2 where cardid = '421126197504010027';" +
+ "update blade_user set status = 2 where cardid = '360122197801250016';" +
+ "update blade_user set status = 2 where cardid = '362529198810194055';" +
+ "update blade_user set status = 2 where cardid = '36012219790905421X';" +
+ "update blade_user set status = 2 where cardid = '360122197801048256';" +
+ "update blade_user set status = 2 where cardid = '410526198003224418';" +
+ "update blade_user set status = 2 where cardid = '360121198412076411';" +
+ "update blade_user set status = 2 where cardid = '360122197407242712';";
+ myAsyncService.FTP(sql);
+
}
}
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 89c457f..c6283b2 100644
--- a/src/main/java/org/springblade/modules/system/controller/UserController.java
+++ b/src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -40,10 +40,7 @@
import org.springblade.common.excel.CustomCellWriteHeightConfig;
import org.springblade.common.excel.CustomCellWriteWeightConfig;
import org.springblade.common.excel.RowWriteHandler;
-import org.springblade.common.utils.HttpClientUtils;
-import org.springblade.common.utils.HttpReqUtil;
-import org.springblade.common.utils.ImageUtils;
-import org.springblade.common.utils.arg;
+import org.springblade.common.utils.*;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.launch.constant.AppConstant;
@@ -722,6 +719,128 @@
}
/**
+ * 修改保安员信息
+ */
+ @PostMapping("/updateSecurityInfo")
+ public R updateSecurityInfo(@RequestBody User user) throws Exception {
+ User user1 = userService.getById(user.getId());
+ user.setId(user1.getId());
+ user.setUpdateTime(new Date());
+ user.setPassword(user1.getPassword());
+ //创建更新的字符串
+ StringBuilder builder = new StringBuilder();
+ builder.append("update blade-user set update_time = "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()));
+
+ //姓名
+ if (null != user.getRealName() && !user.getRealName().equals("")) {
+ builder.append(",set real_name = "+user.getRealName());
+ }
+
+ int state = 1;
+ //身份证号码
+ if (null != user.getCardid() && !user.getCardid().equals("")) {
+ //身份证号校验
+ //去除所有空格
+ String cardid = user.getCardid().replaceAll(" ", "");
+ //校验
+ boolean b = IdCardNoUtil.checkIdCardNo(cardid);
+ if(b){
+ user.setCardid(cardid);
+ //账号,密码也修改
+ user.setAccount(user1.getRealName().substring(0,1)+cardid.substring(cardid.length()-4));
+ //获取默认密码配置
+ user.setPassword(user.getCardid().substring(user.getCardid().length() - 6));
+ //加密
+ if (Func.isNotEmpty(user.getPassword())) {
+ user.setPassword(DigestUtil.encrypt(user.getPassword()));
+ }
+ state = 2;
+ builder.append(",set account = "+user.getAccount()+",set cardid = "+user.getCardid()+",set password = "+user.getPassword());
+ }else {
+ throw new ServiceException("导入失败!身份证号码[ "+user.getCardid()+" ]不正确,请核对!");
+ }
+ }
+ //手机号
+ if (null != user.getPhone() && !user.getPhone().equals("")) {
+ builder.append(",set phone = "+user.getPhone());
+ }
+ //指纹url 处理
+ String url = "";
+ 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];
+ builder.append(",set fingerprint = "+url);
+ }
+ }
+ //头像
+ if (null != user.getAvatar() && !user.getAvatar().equals("")) {
+ String avatar = FtpConfig.ip +"/"+ user.getAvatar().substring(26);
+ System.out.println("头像上传 url = " + avatar);
+ builder.append(",set fingerprint = "+avatar);
+ }
+
+ //名族
+ if (null != user.getNation() && !user.getNation().equals("")) {
+ builder.append(",set nation = "+user.getNation());
+ }
+ //学历
+ if (null != user.getEducation() && !user.getEducation().equals("")) {
+ builder.append(",set education = "+user.getEducation());
+ }
+ //政治面貌
+ if (null != user.getPoliticaloutlook() && !user.getPoliticaloutlook().equals("")) {
+ builder.append(",set politicaloutlook = "+user.getPoliticaloutlook());
+ }
+ //健康状态
+ if (null != user.getHealstats() && !user.getHealstats().equals("")) {
+ builder.append(",set healstats = "+user.getHealstats());
+ }
+ //身高
+ if (null != user.getHeight() && !user.getHeight().equals("")) {
+ builder.append(",set height = "+user.getHeight());
+ }
+ //联系地址
+ if (null != user.getAddress() && !user.getAddress().equals("")) {
+ builder.append(",set address = "+user.getAddress());
+ }
+ //身份证地址
+ if (null != user.getRegistered() && !user.getRegistered().equals("")) {
+ builder.append(",set registered = "+user.getRegistered());
+ }
+
+ //修改
+ boolean status = userService.updateById(user);
+
+ if (status) {
+ if (state == 2) {
+ UserDTO userDTO = new UserDTO();
+ userDTO.setAccount(user.getAccount());
+ userDTO.setCardid(user.getCardid());
+ userDTO.setOldCardid(user1.getCardid());
+ userDTO.setPassword(user.getPassword());
+ userDTO.setRealName(user.getRealName());
+ userDTO.setPhone(user.getPhone());
+ userDTO.setSex(user.getSex());
+ userDTO.setAvatar(user.getAvatar());
+ //推送qfqk
+ myAsyncService.updateUserByAccount(userDTO);
+ } else {
+ myAsyncService.updateUserByQfqk(user);
+ }
+ }
+ //拼接最终的sql
+ String sql = builder.append(" where id = " + user.getId()).toString();
+ myAsyncService.FTP(sql);
+ //返回
+ return R.data(200,null,"修改成功!");
+ }
+
+ /**
* 账号修改
* @param user
* @return
--
Gitblit v1.9.3