Browse Source

修改登录模式

wangliang 1 year ago
parent
commit
2c52c53ff7

+ 16 - 6
sop-api/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -12,10 +12,7 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.core.cache.service.CacheService;
 import com.qmth.sop.business.bean.dto.*;
 import com.qmth.sop.business.bean.params.LoginParam;
-import com.qmth.sop.business.bean.result.AttachmentResult;
-import com.qmth.sop.business.bean.result.EditResult;
-import com.qmth.sop.business.bean.result.LoginResult;
-import com.qmth.sop.business.bean.result.MenuResult;
+import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.cache.CommonCacheService;
 import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.service.*;
@@ -93,6 +90,9 @@ public class SysController {
     @Resource
     FileStoreUtil fileStoreUtil;
 
+    @Resource
+    TBUserArchivesService tbUserArchivesService;
+
     @ApiOperation(value = "登录")
     @RequestMapping(value = "/login", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = LoginResult.class)})
@@ -105,9 +105,9 @@ public class SysController {
         List<SysUser> sysUserList = null;
         if (login.getType() == LoginTypeEnum.ACCOUNT) {//账号登录
             // 非空校验
-            Optional.ofNullable(login.getLoginName()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("用户名不能为空"));
+            Optional.ofNullable(login.getMobileNumber()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("手机号不能为空"));
             Optional.ofNullable(login.getPassword()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("密码不能为空"));
-            sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getLoginName, login.getLoginName()));
+            sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getMobileNumber, login.getMobileNumber()));
             if (CollectionUtils.isEmpty(sysUserList)) {
                 throw ExceptionResultEnum.ERROR.exception("用户不存在");
             }
@@ -147,6 +147,16 @@ public class SysController {
                 sysUserService.expiredVerifyCode(sysUser.getId(), sysUser.getMobileNumber());
             }
         }
+        if (Objects.nonNull(sysUser.getSource()) && sysUser.getSource() == UserSourceEnum.ARCHIVES) {//如果是档案用户,需校验是否在认证有效期内
+            UserArchivesResult userArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(null, sysUser.getId());
+            Optional.ofNullable(userArchivesResult).orElseThrow(() -> ExceptionResultEnum.USER_ARCHIVES_NO_DATA.exception());
+            if (Objects.isNull(userArchivesResult.getAuthenticationValidTime()) || System.currentTimeMillis() >= userArchivesResult.getAuthenticationValidTime().longValue()) {
+                throw ExceptionResultEnum.ERROR.exception("该档案用户认证状态已失效");
+            }
+            if (!userArchivesResult.getEnable()) {
+                throw ExceptionResultEnum.ERROR.exception("该档案用户已禁用");
+            }
+        }
         return ResultUtil.ok(sysUserService.login(login.getPassword(), sysUser, AppSourceEnum.SYSTEM));
     }
 

+ 40 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBDingApplyViewResult.java

@@ -1,5 +1,7 @@
 package com.qmth.sop.business.bean.result;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.business.entity.TBDingApply;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -21,6 +23,16 @@ public class TBDingApplyViewResult implements Serializable {
     @ApiModelProperty(value = "考勤异常申请信息")
     TBDingApply tbDingApply;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "流程任务id集合")
+    private List<Long> taskIdList;
+
+    @ApiModelProperty(value = "当前流程节点")
+    private FlowTaskResult currFlowTaskResult;
+
+    @ApiModelProperty(value = "历史流程节点信息")
+    List<FlowTaskResult> flowTaskHistoryList;
+
     @ApiModelProperty(value = "流程审批信息")
     List<TFFlowViewLogResult> flowApproveHistoryList;
 
@@ -33,12 +45,39 @@ public class TBDingApplyViewResult implements Serializable {
         this.tbDingApply = tbDingApply;
     }
 
-    public TBDingApplyViewResult(CrmProjectResult crmInfo, TBDingApply tbDingApply, List<TFFlowViewLogResult> flowApproveHistoryList) {
+    public TBDingApplyViewResult(CrmProjectResult crmInfo, TBDingApply tbDingApply, List<Long> taskIdList, List<FlowTaskResult> flowTaskHistoryList, FlowTaskResult currFlowTaskResult, List<TFFlowViewLogResult> flowApproveHistoryList) {
         this.crmInfo = crmInfo;
         this.tbDingApply = tbDingApply;
+        this.taskIdList = taskIdList;
+        this.flowTaskHistoryList = flowTaskHistoryList;
+        this.currFlowTaskResult = currFlowTaskResult;
         this.flowApproveHistoryList = flowApproveHistoryList;
     }
 
+    public List<Long> getTaskIdList() {
+        return taskIdList;
+    }
+
+    public void setTaskIdList(List<Long> taskIdList) {
+        this.taskIdList = taskIdList;
+    }
+
+    public FlowTaskResult getCurrFlowTaskResult() {
+        return currFlowTaskResult;
+    }
+
+    public void setCurrFlowTaskResult(FlowTaskResult currFlowTaskResult) {
+        this.currFlowTaskResult = currFlowTaskResult;
+    }
+
+    public List<FlowTaskResult> getFlowTaskHistoryList() {
+        return flowTaskHistoryList;
+    }
+
+    public void setFlowTaskHistoryList(List<FlowTaskResult> flowTaskHistoryList) {
+        this.flowTaskHistoryList = flowTaskHistoryList;
+    }
+
     public List<TFFlowViewLogResult> getFlowApproveHistoryList() {
         return flowApproveHistoryList;
     }

+ 40 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBProjectExchangeViewResult.java

@@ -1,5 +1,7 @@
 package com.qmth.sop.business.bean.result;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.business.entity.TBProjectExchange;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -21,6 +23,16 @@ public class TBProjectExchangeViewResult implements Serializable {
     @ApiModelProperty(value = "项目变更计划信息")
     TBProjectExchange tbProjectExchange;
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "流程任务id集合")
+    private List<Long> taskIdList;
+
+    @ApiModelProperty(value = "当前流程节点")
+    private FlowTaskResult currFlowTaskResult;
+
+    @ApiModelProperty(value = "历史流程节点信息")
+    List<FlowTaskResult> flowTaskHistoryList;
+
     @ApiModelProperty(value = "流程审批信息")
     List<TFFlowViewLogResult> flowApproveHistoryList;
 
@@ -33,12 +45,23 @@ public class TBProjectExchangeViewResult implements Serializable {
         this.tbProjectExchange = tbProjectExchange;
     }
 
-    public TBProjectExchangeViewResult(CrmProjectResult crmInfo, TBProjectExchange tbProjectExchange, List<TFFlowViewLogResult> flowApproveHistoryList) {
+    public TBProjectExchangeViewResult(CrmProjectResult crmInfo, TBProjectExchange tbProjectExchange, List<Long> taskIdList, List<FlowTaskResult> flowTaskHistoryList, FlowTaskResult currFlowTaskResult, List<TFFlowViewLogResult> flowApproveHistoryList) {
         this.crmInfo = crmInfo;
         this.tbProjectExchange = tbProjectExchange;
+        this.taskIdList = taskIdList;
+        this.flowTaskHistoryList = flowTaskHistoryList;
+        this.currFlowTaskResult = currFlowTaskResult;
         this.flowApproveHistoryList = flowApproveHistoryList;
     }
 
+    public List<Long> getTaskIdList() {
+        return taskIdList;
+    }
+
+    public void setTaskIdList(List<Long> taskIdList) {
+        this.taskIdList = taskIdList;
+    }
+
     public List<TFFlowViewLogResult> getFlowApproveHistoryList() {
         return flowApproveHistoryList;
     }
@@ -62,4 +85,20 @@ public class TBProjectExchangeViewResult implements Serializable {
     public void setTbProjectExchange(TBProjectExchange tbProjectExchange) {
         this.tbProjectExchange = tbProjectExchange;
     }
+
+    public List<FlowTaskResult> getFlowTaskHistoryList() {
+        return flowTaskHistoryList;
+    }
+
+    public void setFlowTaskHistoryList(List<FlowTaskResult> flowTaskHistoryList) {
+        this.flowTaskHistoryList = flowTaskHistoryList;
+    }
+
+    public FlowTaskResult getCurrFlowTaskResult() {
+        return currFlowTaskResult;
+    }
+
+    public void setCurrFlowTaskResult(FlowTaskResult currFlowTaskResult) {
+        this.currFlowTaskResult = currFlowTaskResult;
+    }
 }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/UserArchivesResult.java

@@ -93,6 +93,17 @@ public class UserArchivesResult {
     @ApiModelProperty(value = "人力资源状态")
     private UserArchivesStatusEnum status;
 
+    @ApiModelProperty(value = "是否启用(1启用,0作废)")
+    private Boolean enable;
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
     public Long getUserArchivesId() {
         return userArchivesId;
     }

+ 4 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java

@@ -346,11 +346,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 } else if (Objects.nonNull(dbUser.getOrgId()) && !dbUser.getOrgId().equals(sysUser.getOrgId())) {
                     sysUserService.removeUserInfo(sysUser.getId(), true);
                 }
-                //如果修改了机构或手机号,需更新用户缓存
+                //如果修改了机构或手机号,需更新用户缓存(也需要重新登录)
                 if (Objects.nonNull(dbUser.getOrgId()) && (dbUser.getOrgId().longValue() != sysUser.getOrgId().longValue()
                         || !Objects.equals(dbUser.getMobileNumber(), sysUser.getMobileNumber()))) {
-                    commonCacheService.updateUserCache(sysUser.getId());
-                    commonCacheService.updateUserAuthCache(sysUser.getId());
+//                    commonCacheService.updateUserCache(sysUser.getId());
+//                    commonCacheService.updateUserAuthCache(sysUser.getId());
+                    sysUserService.removeUserInfo(sysUser.getId(), true);
                 }
             }
         } catch (Exception e) {

+ 30 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -346,6 +347,12 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
+        FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+        LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+        FlowTaskResult currFlowTaskResult = null;
+        List<FlowTaskResult> flowTaskHistoryList = null;
+        List<Long> taskIdList = null;
+
         //获取流程审批历史
         List<TFFlowViewLogResult> flowApproveHistoryList = null;
         Map<Integer, Integer> approveSetupMap = new HashMap<>();
@@ -356,8 +363,30 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
             for (TFFlowViewLogResult t : flowApproveHistoryList) {
                 t.setMessageType(FlowMsgTypeEnum.STANDARD);
                 approveSetupMap.put(t.getApproveSetup(), t.getApproveSetup());
+                if (Objects.nonNull(t.getApproveRemark())) {
+                    String[] strs = t.getApproveRemark().split(";");
+                    if (strs.length > 0) {
+                        t.setApproveRemark(strs[0]);
+                    }
+                }
+            }
+        }
+        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+            FlowTaskResult flowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
+            if (flowTaskResult.getSetup() > 0) {
+                //正在审批的表单
+                if (Objects.nonNull(tfFlowApprove.getSetup()) && flowTaskResult.getSetup().intValue() == tfFlowApprove.getSetup().intValue()) {
+                    currFlowTaskResult = flowTaskResult;
+                    List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
+                    if (!CollectionUtils.isEmpty(taskList)) {
+                        taskIdList = taskList.stream().map(s -> Long.parseLong(s.getId())).collect(Collectors.toList());
+                    }
+                } else if (approveSetupMap.containsKey(flowTaskResult.getSetup())) {//已经审批过的表单
+                    flowTaskHistoryList = CollectionUtils.isEmpty(flowTaskHistoryList) ? new ArrayList<>(approveSetupMap.size()) : flowTaskHistoryList;
+                    flowTaskHistoryList.add(flowTaskResult);
+                }
             }
         }
-        return new TBDingApplyViewResult(crmProjectResult, tbDingApply, flowApproveHistoryList);
+        return new TBDingApplyViewResult(crmProjectResult, tbDingApply, taskIdList, flowTaskHistoryList, currFlowTaskResult, flowApproveHistoryList);
     }
 }

+ 30 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -204,6 +205,12 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
+        FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+        LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+        FlowTaskResult currFlowTaskResult = null;
+        List<FlowTaskResult> flowTaskHistoryList = null;
+        List<Long> taskIdList = null;
+
         //获取流程审批历史
         List<TFFlowViewLogResult> flowApproveHistoryList = null;
         Map<Integer, Integer> approveSetupMap = new HashMap<>();
@@ -214,8 +221,30 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
             for (TFFlowViewLogResult t : flowApproveHistoryList) {
                 t.setMessageType(FlowMsgTypeEnum.STANDARD);
                 approveSetupMap.put(t.getApproveSetup(), t.getApproveSetup());
+                if (Objects.nonNull(t.getApproveRemark())) {
+                    String[] strs = t.getApproveRemark().split(";");
+                    if (strs.length > 0) {
+                        t.setApproveRemark(strs[0]);
+                    }
+                }
+            }
+        }
+        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+            FlowTaskResult flowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
+            if (flowTaskResult.getSetup() > 0) {
+                //正在审批的表单
+                if (Objects.nonNull(tfFlowApprove.getSetup()) && flowTaskResult.getSetup().intValue() == tfFlowApprove.getSetup().intValue()) {
+                    currFlowTaskResult = flowTaskResult;
+                    List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
+                    if (!CollectionUtils.isEmpty(taskList)) {
+                        taskIdList = taskList.stream().map(s -> Long.parseLong(s.getId())).collect(Collectors.toList());
+                    }
+                } else if (approveSetupMap.containsKey(flowTaskResult.getSetup())) {//已经审批过的表单
+                    flowTaskHistoryList = CollectionUtils.isEmpty(flowTaskHistoryList) ? new ArrayList<>(approveSetupMap.size()) : flowTaskHistoryList;
+                    flowTaskHistoryList.add(flowTaskResult);
+                }
             }
         }
-        return new TBProjectExchangeViewResult(crmProjectResult, tbProjectExchange, flowApproveHistoryList);
+        return new TBProjectExchangeViewResult(crmProjectResult, tbProjectExchange, taskIdList, flowTaskHistoryList, currFlowTaskResult, flowApproveHistoryList);
     }
 }

+ 7 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -1965,4 +1965,10 @@ WHERE id=2;
 
 UPDATE sys_privilege
 SET name='用户查询', url='/api/admin/user/list', `type`='URL', parent_id=15, `sequence`=1, property='SYS', related=NULL, enable=1, default_auth=1, front_display=0
-WHERE id=252;
+WHERE id=252;
+
+--2023.10.20update
+UPDATE sys_user
+SET login_name='sysadmin', real_name='sysadmin', code=NULL, password='MTIzNDU2', mobile_number='0123456789*', org_id=NULL, gender=NULL, enable=1, pwd_count=1, pwd_update_time=1629353956868, remark=NULL, source='SYSTEM', create_id=NULL, create_time=NULL, update_id=1, update_time=1692077912643
+WHERE id=1;
+ALTER TABLE sys_user DROP KEY sys_user_UN_login_name;

+ 2 - 1
sop-business/src/main/resources/mapper/TBUserArchivesMapper.xml

@@ -176,7 +176,8 @@
             tbuas.authentication_valid_time AS authenticationValidTime,
             tbuas.remark,
             su.id AS userId,
-            tbua.status AS status
+            tbua.status AS status,
+            tbua.enable as enable
         FROM
             t_b_user_archives tbua
                 LEFT JOIN

+ 2 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java

@@ -111,6 +111,8 @@ public enum ExceptionResultEnum {
 
     FLOW_ROLE_ALLOCATION_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000042, "流程未配置审核角色数据"),
 
+    USER_ARCHIVES_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000043, "档案用户不存在"),
+
     /**
      * 401
      */

+ 0 - 2
sop-common/src/main/java/com/qmth/sop/common/enums/FieldUniqueEnum.java

@@ -13,8 +13,6 @@ public enum FieldUniqueEnum {
 
     sys_user_UN_moblie_number("手机号"),
 
-    sys_user_UN_login_name("登录名"),
-
     sys_org_UN_name("机构名称"),
 
     sys_role_UN_type("角色类型"),