Browse Source

登录日志

lihong 1 year ago
parent
commit
9e1cc315bf

+ 5 - 6
src/main/java/cn/hnthyy/thmz/Utils/Tools.java

@@ -5,28 +5,24 @@ import cn.hnthyy.thmz.entity.thmz.Config;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
-import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.IdcardUtil;
-import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 
 import java.math.BigDecimal;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.sql.Struct;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 /**
  * 按照字节数截取字符串
@@ -724,8 +720,11 @@ public class Tools {
         return str;
     }
 
+    public static boolean containsChinese(String str){
+        return Pattern.compile("[\u4e00-\u9fa5]").matcher(str).find();
+    }
+
     public static void main(String[] args) {
-        System.out.println(IdcardUtil.getGenderByIdCard("432427197405123611"));
     }
 
 }

+ 27 - 8
src/main/java/cn/hnthyy/thmz/controller/LoginController.java

@@ -1,36 +1,42 @@
 package cn.hnthyy.thmz.controller;
 
-import cn.hnthyy.thmz.Utils.*;
+import cn.hnthyy.thmz.Utils.DateUtil;
+import cn.hnthyy.thmz.Utils.HttpUtil;
+import cn.hnthyy.thmz.Utils.JsonUtil;
+import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.his.mz.Employee;
+import cn.hnthyy.thmz.entity.his.mz.MzLoginLog;
 import cn.hnthyy.thmz.entity.thmz.EvaluateInfo;
-import cn.hnthyy.thmz.entity.thmz.LoginErr;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.entity.thmz.UserControls;
 import cn.hnthyy.thmz.entity.thmz.Windows;
 import cn.hnthyy.thmz.enums.WorkingStatusEnum;
 import cn.hnthyy.thmz.enums.YesNoEnum;
+import cn.hnthyy.thmz.mapper.his.mz.MzLoginLogMapper;
 import cn.hnthyy.thmz.service.his.mz.EmployeeService;
 import cn.hnthyy.thmz.service.his.zd.DictDataService;
 import cn.hnthyy.thmz.service.thmz.EvaluationService;
-import cn.hnthyy.thmz.service.thmz.LoginErrService;
 import cn.hnthyy.thmz.service.thmz.TokenService;
 import cn.hnthyy.thmz.service.thmz.TsmzService;
 import cn.hnthyy.thmz.service.thmz.UserService;
 import cn.hnthyy.thmz.service.thmz.WindowsService;
-import cn.hutool.core.codec.Base64;
 import cn.hutool.core.convert.Convert;
-import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.map.MapUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 @RestController
 @Slf4j
@@ -53,6 +59,8 @@ public class LoginController {
     private DictDataService dictDataService;
     @Resource
     private TsmzService tsmzService;
+    @Resource
+    private MzLoginLogMapper mzLoginLogMapper;
     /**登录错误次数 锁定账户临界值*/
     //private static final int LOGIN__ERR_COUNT =  10000;
     //private static final int LOGIN__ERR_COUNT_TIME =  1;
@@ -175,6 +183,7 @@ public class LoginController {
                 .clientIp(HttpUtil.getIPAddress(request)).build());
         Date deadTime = DateUtil.getDate(Constants.JWT_TTL);
         String token =TokenUtil.createJWT(JsonUtil.object2Json(user),deadTime);
+        saveLoginLog(user);
         resultMap.put("code", 0);
         resultMap.put("token", token);
         resultMap.put("userID", userParam.getUserCode());
@@ -185,7 +194,17 @@ public class LoginController {
         return resultMap;
     }
 
-
+    private void saveLoginLog(User user) {
+        try {
+            MzLoginLog loginLog = new MzLoginLog();
+            loginLog.setUserCode(user.getUserIdCode());
+            loginLog.setUserName(user.getUserName());
+            loginLog.setLoginTime(new Date());
+            mzLoginLogMapper.insert(loginLog);
+        }catch (Exception e){
+            log.error("保存登录日志记录错误:{}",e);
+        }
+    }
 
 
     /**

+ 7 - 1
src/main/java/cn/hnthyy/thmz/controller/zy/APatientMiController.java

@@ -4,6 +4,7 @@ import cn.hnthyy.thmz.Utils.AssertUtil;
 import cn.hnthyy.thmz.Utils.IDCardUtil;
 import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.StringUtil;
+import cn.hnthyy.thmz.Utils.Tools;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.mz.MzPatientMi;
 import cn.hnthyy.thmz.entity.his.zy.APatientMi;
@@ -255,7 +256,12 @@ public class APatientMiController {
         }
         if (StringUtils.isBlank(aPatientMi.getInpatientNo())) {
             resultMap.put("code", -1);
-            resultMap.put("message", "住院号不能为空");
+            resultMap.put("message", "住院号不能为空或不能包含中文");
+            return true;
+        }
+        if (Tools.containsChinese(aPatientMi.getInpatientNo())) {
+            resultMap.put("code", -1);
+            resultMap.put("message", "住院号不能包含中文");
             return true;
         }
         if (StringUtils.isBlank(aPatientMi.getAccountStreet())) {

+ 6 - 0
src/main/java/cn/hnthyy/thmz/controller/zy/ZyActpatientController.java

@@ -3,6 +3,7 @@ package cn.hnthyy.thmz.controller.zy;
 import cn.hnthyy.thmz.Utils.DateUtil;
 import cn.hnthyy.thmz.Utils.R;
 import cn.hnthyy.thmz.Utils.TokenUtil;
+import cn.hnthyy.thmz.Utils.Tools;
 import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.entity.his.zy.APatientMi;
 import cn.hnthyy.thmz.entity.his.zy.ZyActpatient;
@@ -154,6 +155,11 @@ public class ZyActpatientController {
             resultMap.put("message", "住院号不能为空");
             return true;
         }
+        if (Tools.containsChinese(zyActpatient.getInpatientNo())) {
+            resultMap.put("code", -1);
+            resultMap.put("message", "住院号不能包含中文");
+            return true;
+        }
 
         return false;
     }

+ 25 - 0
src/main/java/cn/hnthyy/thmz/entity/his/mz/MzLoginLog.java

@@ -0,0 +1,25 @@
+package cn.hnthyy.thmz.entity.his.mz;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.Value;
+
+import java.util.Date;
+
+/**
+ * @Description:门诊登录日志
+ * @Author:lihong
+ * @Date: 2024/8/27
+ */
+@Data
+@TableName("mz_login_log")
+public class MzLoginLog {
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    private String userCode;
+    private String userName;
+    private Date loginTime;
+
+}

+ 13 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzLoginLogMapper.java

@@ -0,0 +1,13 @@
+package cn.hnthyy.thmz.mapper.his.mz;
+
+import cn.hnthyy.thmz.entity.his.mz.MzLoginLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description:门诊登录日志
+ * @Author:lihong
+ * @Date: 2024/8/27
+ */
+
+public interface MzLoginLogMapper extends BaseMapper<MzLoginLog> {
+}