Bladeren bron

924 定时备份

LT32820A 2 maanden geleden
bovenliggende
commit
a34878fdc5

+ 2 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/client/AppManage/WorkFlowClient.java

@@ -14,5 +14,7 @@ public interface WorkFlowClient {
     @PostMapping("/WF/API/startFlow")
     void startFlow(@RequestParam("flowNo") String flowNo,
                    @RequestParam("username") String username,
+                   @RequestParam("toEmps") String toEmps,
+                   @RequestParam("execUserNo") String execUserNo,
                    @RequestBody Hashtable<String, String> hashtable);
 }

+ 6 - 3
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/AppmanageController.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.system.controller;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.PermissionData;
@@ -11,7 +12,9 @@ import org.jeecg.modules.system.service.AppmanageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 功能描述
@@ -129,7 +132,6 @@ public class AppmanageController {
     // 反审核
     @GetMapping("/getLock")
     public Result<Boolean> checkLock(String key){
-        System.out.println("访问到了:"+key);
         return Result.ok(appInfoService.checkLock(key));
     }
 
@@ -183,7 +185,8 @@ public class AppmanageController {
 
     // 应用注册审核通过后续处理(微服务调用)
     @GetMapping("/afterAppCheckPass")
-    public void afterAppCheckPass(@RequestParam("appid")String appid){
-        appInfoService.afterAppCheckPass(appid);
+    public <T> void afterAppCheckPass(@RequestParam("appid")String appid, @RequestParam("formData") T formData){
+        System.out.println("应用注册审核通过后续处理:"+formData);
+        appInfoService.afterAppCheckPass(appid, formData);
     }
 }

+ 34 - 4
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/AppBaseInfoMapper.java

@@ -19,16 +19,46 @@ import java.util.List;
 public interface AppBaseInfoMapper extends BaseMapper<AppBaseInfo> {
 
     List<AppBaseInfo> queryAppInfoList(@Param("key") String key,
-                                          @Param("type") String type,
-                                          @Param("status") String status);
+                                       @Param("type") String type,
+                                       @Param("status") String status);
 
     @Update("update app_base_info set del_flag = 0, info_status = 1 where id = #{appid}")
     void recoverAppInfo(@Param("appid") String appid);
 
+    // 根据id找到应用基础信息(忽略del_flag版本)
+    @Select("select * from app_base_info where id = #{appid}")
+    AppBaseInfo queryAppBaseInfoById(@Param("appid") String appid);
+
+    //应用列表(数据隔离)
+    List<AppBaseInfo> appList(@Param("permissionSql") String permissionSql);
+
     // 从用户表找到用户账号
     @Select("SELECT username from sys_user where id = #{id}")
     String queryUsernameById(@Param("id") String id);
 
-    //应用列表(数据隔离)
-    List<AppBaseInfo> appList(@Param("permissionSql") String permissionSql);
+    @Update("<script>" +
+            "UPDATE app_base_info " +
+            "<set>" +
+            "name = #{baseInfo.name}, " +
+            "type = #{baseInfo.type}, " +
+            "status = #{baseInfo.status}, " +
+            "admin = #{baseInfo.admin}, " +
+            "business_user = #{baseInfo.businessUser}, " +
+            "requirement_user = #{baseInfo.requirementUser}, " +
+            "develop_user = #{baseInfo.developUser}, " +
+            "operation_user = #{baseInfo.operationUser}, " +
+            "menu_info = #{baseInfo.menuInfo}, " +
+            "descr = #{baseInfo.descr}, " +
+            "check_user = #{baseInfo.checkUser}, " +
+            "check_time = #{baseInfo.checkTime}, " +
+            "check_tag = #{baseInfo.checkTag}, " +
+            "create_by = #{baseInfo.createBy}, " +
+            "create_time = #{baseInfo.createTime}, " +
+            "add_type = #{baseInfo.addType}, " +
+            "info_status = #{baseInfo.info_status}, " +
+            "del_flag = #{baseInfo.delFlag} " +
+            "</set>" +
+            "WHERE id = #{baseInfo.id}" +
+            "</script>")
+    void undateBaseInfo(@Param("baseInfo") AppBaseInfo baseInfo);
 }

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/AppmanageService.java

@@ -66,6 +66,6 @@ public interface AppmanageService  {
     // 是否为应用管理员或开发负责人、运维负责人
     boolean isAppAdminOrDevOrOpe(String appid);
 
-    void afterAppCheckPass(String appid);
+    <T> void afterAppCheckPass(String appid, T formData);
 }
 

+ 25 - 43
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/AppmanageServiceImpl.java

@@ -97,8 +97,7 @@ public class AppmanageServiceImpl implements AppmanageService {
     @Autowired
     private AppManageUtil appManageUtil;
 
-    @Autowired
-    private WorkFlowClient workFlowClient;
+
 
     private final ReentrantLock lock = new ReentrantLock();
     private final String UNCHECK_TAG_BASE_PATH = "AppInfouncheckTag:";
@@ -116,17 +115,19 @@ public class AppmanageServiceImpl implements AppmanageService {
         QueryWrapper<AppBaseInfo> appBaseInfoQueryWrapper = new QueryWrapper<>();
         appBaseInfoQueryWrapper.eq("name", appBaseInfo.getName());
         if (baseInfoMapper.selectOne(appBaseInfoQueryWrapper) != null) return "应用名称已存在";
+
         // 创建人
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         appBaseInfo.setCreateBy(loginUser.getId());
         appBaseInfo.setAddType(appInfo.getAddType());
         appBaseInfo.setDelFlag(1);
         baseInfoMapper.insert(appBaseInfo);
-        // 提交至工作流的表单信息(需要将用户id换成真名,字典值换成字典文本)
+
+        // 提交至工作流的表单信息(临时将用户id换成真名,字典值换成字典文本)
         AppBaseInfo sendCheck_appBaseInfo = appBaseInfo;
         sendCheck_appBaseInfo.setAdmin(customMapper.queryRealnameByUserId(appBaseInfo.getAdmin()));
-        if (appBaseInfo.getDevelopUser()!=null)
-            sendCheck_appBaseInfo.setDevelopUser(customMapper.queryRealnameByUserId(appBaseInfo.getDevelopUser()));
+//        if (appBaseInfo.getDevelopUser()!=null)
+//            sendCheck_appBaseInfo.setDevelopUser(customMapper.queryRealnameByUserId(appBaseInfo.getDevelopUser()));
         if (appBaseInfo.getOperationUser()!=null)
             sendCheck_appBaseInfo.setOperationUser(customMapper.queryRealnameByUserId(appBaseInfo.getOperationUser()));
         if (appBaseInfo.getRequirementUser()!=null)
@@ -140,7 +141,7 @@ public class AppmanageServiceImpl implements AppmanageService {
         if (appInfo.getAppEnvInfoDTO()!=null) hasEnvInfo = appInfo.getAppEnvInfoDTO().size()>0;
         // 简易注册模式下添加基础信息即可
         if (appBaseInfo.getAddType().equals("easy")){
-            sendCheckWordFlow(sendCheck_appBaseInfo, "021",loginUser.getUsername());
+            appManageUtil.sendCheckWordFlow(sendCheck_appBaseInfo, "021",loginUser.getUsername(),"admin");
             return "提交成功";
         }else {
             APP_Register_workFlow_FormEntity appRegisterWorkFlowFormEntity = new APP_Register_workFlow_FormEntity();
@@ -151,7 +152,7 @@ public class AppmanageServiceImpl implements AppmanageService {
                 AppManageUtil appManageUtil = new AppManageUtil();
                 appRegisterWorkFlowFormEntity = appManageUtil.TransitionEnvInfoToAppRegisterWorkFlowForm(appRegisterWorkFlowFormEntity, appInfo.getAppEnvInfoDTO());
             }
-            sendCheckWordFlow(appRegisterWorkFlowFormEntity, "022",loginUser.getUsername());
+            appManageUtil.sendCheckWordFlow(appRegisterWorkFlowFormEntity, "022",loginUser.getUsername(),"admin");
         }
         String appid = appBaseInfo.getId();
 
@@ -238,6 +239,7 @@ public class AppmanageServiceImpl implements AppmanageService {
      */
     @Override
     public Boolean editBaseInfo(AppBaseInfo baseInfo) throws Exception {
+
         int i = baseInfoMapper.updateById(baseInfo);
         // 保存成功解除反审核状态
         if (i>0) uncheckLock("AppbaseInfo"+baseInfo.getId());
@@ -539,6 +541,7 @@ public class AppmanageServiceImpl implements AppmanageService {
         lock.lock();
         try {
             String uncheckinfo = (String) redisUtil.get(UNCHECK_TAG_BASE_PATH+key);
+            String test = (String) redisUtil.get("bucunzaide");
             // 该条信息处于反审核状态,反审核方为当前用户,直接返回false
             if (uncheckinfo!=null && uncheckinfo.equals(loginUser.getId())) {
                 return false;
@@ -549,7 +552,9 @@ public class AppmanageServiceImpl implements AppmanageService {
                 redisUtil.set(UNCHECK_TAG_BASE_PATH+key, loginUser.getId(), 600);
                 return false;
             }
-        } finally {
+        }catch (Exception e) {
+            System.out.println("chec kLock error:"+e);
+        }finally {
             lock.unlock();
         }
         // 该条信息已被反审核,不可编辑(tag为 表单disable的标志)
@@ -614,36 +619,8 @@ public class AppmanageServiceImpl implements AppmanageService {
         return false;
     }
 
-
-    // 加入流程
-    private <T> void sendCheckWordFlow(T object, String flowNo, String username) throws Exception {
-        Hashtable<String, String> hashtable = new Hashtable<>();
-        Class<?> clazz = object.getClass();
-        // 获取所有字段
-        Field[] fields = clazz.getDeclaredFields();
-        // 遍历所有字段
-        for (Field field : fields) {
-            // 设置访问权限
-            field.setAccessible(true);
-            try {
-                Object value = field.get(object);
-                if (value != null) {
-                    // 将值转换为字符串
-                    String stringValue = value.toString();
-                    hashtable.put(field.getName(), stringValue);
-                }
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException("Failed to access field: " + field.getName(), e);
-            }
-        }
-
-
-//      微服务调用 审核加入流程
-        workFlowClient.startFlow(flowNo, username, hashtable);
-    }
-
     // 判断当前用户是否有编辑当前信息的权限
-    private boolean hasEditCurrentInfoPermission(String appid){
+    public boolean hasEditCurrentInfoPermission(String appid){
         // 获取当前登录用户
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         // 查询基础信息的应用管理员id,比较是否和当前登录用户一致
@@ -678,24 +655,29 @@ public class AppmanageServiceImpl implements AppmanageService {
 
 
     // 应用审核通过后一系列创建应用一级菜单、默认角色、授权操作(完整注册时)
-    public void afterAppCheckPass(String appid) {
-
-        System.out.println("审核完成后续处理:"+appid);
-        // 将基础信息删除标志位恢复
-        baseInfoMapper.recoverAppInfo(appid);
+    public <T> void afterAppCheckPass(String appid, T formData) {
+        AppBaseInfo appBaseInfo = baseInfoMapper.queryAppBaseInfoById(appid);
+        appManageUtil.CompareOldAppBaseInfoAndNewAppBaseInfo(appBaseInfo, formData);
+        // 以通过审批的应用信息为准更新应用信息
+        baseInfoMapper.undateBaseInfo(appBaseInfo);
+//        QueryWrapper<AppBaseInfo> appBaseInfoQueryWrapper = new QueryWrapper<>();
+//        appBaseInfoQueryWrapper.eq("id", appid);
+//        int i = baseInfoMapper.update(appBaseInfo, appBaseInfoQueryWrapper);
         // 查询该应用信息
-        AppBaseInfo appBaseInfo = baseInfoMapper.selectById(appid);
+
         String toUser = baseInfoMapper.queryUsernameById(appBaseInfo.getCreateBy());
         //给申请注册应用信息的用户发送系统消息
         TemplateMessageDTO message = new TemplateMessageDTO();
         message.setAppId("0");
         message.setToUser(toUser);
+        // 设置消息模板编码
         message.setTemplateCode("app_examineAndapprove");
         Map<String, String> templateParam = new HashMap<>();
         templateParam.put("resultText","通过");
         message.setTemplateParam(templateParam);
         sysBaseApi.sendTemplateAnnouncement(message);
 
+
         // 判断该信息是否为完整注册
         if (appBaseInfo.getAddType().equals("full")){
             // 添加默认角色信息

+ 83 - 0
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/AppManageUtil.java

@@ -1,15 +1,23 @@
 package org.jeecg.modules.system.util;
 
+import org.apache.poi.ss.formula.functions.T;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.SpringContextUtils;
+import org.jeecg.modules.client.AppManage.WorkFlowClient;
 import org.jeecg.modules.system.entity.AppmanageEntity.APP_Register_workFlow_FormEntity;
 import org.jeecg.modules.system.entity.AppmanageEntity.AppBaseInfo;
+import org.jeecg.modules.system.entity.AppmanageEntity.AppDocInfo;
 import org.jeecg.modules.system.entity.AppmanageEntity.AppEnvInfo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 功能描述 应用管理工具类
@@ -19,6 +27,8 @@ import java.util.List;
  */
 @Component
 public class AppManageUtil {
+    @Autowired
+    private WorkFlowClient workFlowClient;
 
     public APP_Register_workFlow_FormEntity TransitionEnvInfoToAppRegisterWorkFlowForm(APP_Register_workFlow_FormEntity appRegisterWorkFlowForm, List<AppEnvInfo> appEnvInfoList){
         for (AppEnvInfo appEnvInfo : appEnvInfoList){
@@ -101,4 +111,77 @@ public class AppManageUtil {
         return roleNameInfo;
     }
 
+    /**
+     *
+     * 将表单数据加入对应流程
+     * @param object 表单数据对象
+     * @param flowNo 流程编号
+     * @param username 发起流程的用户账号
+     * @param toEmps 流程发送目标用户账号
+     *                 @RequestParam("toEmps") String toEmps,
+     *                           @RequestParam("execUserNo") String execUserNo,
+     */
+    public <T> void sendCheckWordFlow(T object, String flowNo, String username, String toEmps) throws Exception {
+        Hashtable<String, String> hashtable = new Hashtable<>();
+        Class<?> clazz = object.getClass();
+        // 获取所有字段
+        Field[] fields = clazz.getDeclaredFields();
+        // 遍历所有字段
+        for (Field field : fields) {
+            // 设置访问权限
+            field.setAccessible(true);
+            try {
+                Object value = field.get(object);
+                if (value != null) {
+                    // 将值转换为字符串
+                    String stringValue = value.toString();
+                    hashtable.put(field.getName(), stringValue);
+                }
+            } catch (IllegalAccessException e) {
+                throw new RuntimeException("Failed to access field: " + field.getName(), e);
+            }
+        }
+//      微服务调用 审核加入流程
+        workFlowClient.startFlow(flowNo, username, toEmps, username, hashtable);
+    }
+
+    // 审核完成将审核通过的最终数据插入数据库,因为应用注册审核已经提前将数据插入数据库表(应用基础信息)
+    public <T> void CompareOldAppBaseInfoAndNewAppBaseInfo(AppBaseInfo appBaseInfo, T formData) {
+
+        String formDataStr = formData.toString();
+        Field[] baseInfoFields = appBaseInfo.getClass().getDeclaredFields();
+        Map<String, String> formDataMap = new HashMap<>();
+        // 去掉多余的文本
+        int startIndex = formDataStr.indexOf("{") + 1;
+        int endIndex = formDataStr.indexOf("}");
+        String innerData = formDataStr.substring(startIndex, endIndex);
+
+        // 分割成多个键值对
+        String[] keyValuePairs = innerData.split(", ");
+
+        for (String pair : keyValuePairs) {
+            // 分割键值对
+            int equalsIndex = pair.indexOf('=');
+            if (equalsIndex > 0) {
+                String key = pair.substring(0, equalsIndex).trim();
+                String value = pair.substring(equalsIndex + 1).trim();
+                formDataMap.put(key, value);
+            }
+        }
+        for (Field field : baseInfoFields) {
+            field.setAccessible(true);
+            String fieldName = field.getName();
+            String fieldValue = formDataMap.get(fieldName);
+            if (fieldValue != null) {
+                try {
+                    field.set(appBaseInfo, fieldValue);
+                } catch (IllegalAccessException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        // 将删除标志位恢复为 0,信息状态位变更为 1:已审核状态
+        appBaseInfo.setDelFlag(0);
+        appBaseInfo.setInfo_status(1);
+    }
 }

+ 2 - 0
jeecg-boot/jeecg-server-cloud/jeecg-cloud-nacos/src/main/resources/application.yml

@@ -14,8 +14,10 @@ db:
   num: 1
   password:
     '0': ${MYSQL-PWD:Lttc123!}
+#    '0': ${MYSQL-PWD:158780}
   url:
     '0': jdbc:mysql://10.200.1.115:3306/luthai-basis-platform-nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
+#    '0': jdbc:mysql://localhost:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
   user:
     '0': ${MYSQL-USER:root}
 management:

+ 3 - 1
jeecg-boot/jeecg-server-cloud/jflow-cloud-start/src/main/java/org/jeecg/config/DevelopAPI.java

@@ -1844,10 +1844,12 @@ public class DevelopAPI extends HttpHandlerBase {
     @PostMapping("/startFlow")
     public void startFlow(@RequestParam("flowNo") String flowNo,
                           @RequestParam("username") String username,
+                          @RequestParam("toEmps") String toEmps,
+                          @RequestParam("execUserNo") String execUserNo,
                           @RequestBody Hashtable<String, String> hashtable) throws Exception {
         long workID = Dev2Interface.Node_CreateBlankWork(flowNo, username);
         if (hashtable.size() > 0) {
-            Dev2Interface.Node_SendWork(flowNo, workID, hashtable);
+            Dev2Interface.Node_SendWork(flowNo, workID, hashtable, null, 0, toEmps, execUserNo);
         }
     }
 }

+ 0 - 3
jeecg-boot/jeecg-server-cloud/jflow-cloud-start/src/main/resources/application.yml

@@ -1,6 +1,3 @@
-server:
-  port: 7002
-
 spring:
   debug: true
   application:

+ 3 - 1
jeecg-boot/jflow-core/src/main/java/bp/difference/client/SystemClient.java

@@ -1,5 +1,6 @@
 package bp.difference.client;
 
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -11,5 +12,6 @@ public interface SystemClient {
 
     // 应用注册审核结束,对应用相关信息的后续处理
     @GetMapping("/sys/applicationInfo/afterAppCheckPass")
-    void afterAppCheckPass(@RequestParam("appid") String appid);
+    <T> void afterAppCheckPass(@RequestParam("appid") String appid,
+                           @RequestParam("formData") T formData);
 }

+ 5 - 7
jeecg-boot/jflow-core/src/main/java/bp/wf/Dev2Interface.java

@@ -8782,11 +8782,10 @@ c	*/
 	 @return 执行信息
 	*/
 
-	// 新增方法,为了在通过微服务调用时在新增列表中显示正常的标题(填补流程上一节点处理人用户名与部门名称为空)
-	// 弃用,在Feign的微服务调用中直接添加cookie即可解决
-//	public static SendReturnObjs Node_SendWork(String fk_flow, long workID, Hashtable htWork, String execUserNo, String execUserName, String execDeptNo, String execDeptName) throws Exception {
-//		return Node_SendWork(fk_flow, workID, htWork, null, 0, null, execUserNo, execUserName, execUserName, execDeptName, null, 0, 0);
-//	}
+	// 新增方法,为了退回功能正常使用(解决获取不到退回节点问题)
+	public static SendReturnObjs Node_SendWork(String fk_flow, long workID, Hashtable htWork, DataSet workDtls, int toNodeID, String nextWorkers,String execUserNo) throws Exception {
+		return Node_SendWork(fk_flow, workID, htWork, workDtls, toNodeID, nextWorkers, execUserNo, WebUser.getName(), WebUser.getDeptNo(), WebUser.getDeptName(), null, 0, 0);
+	}
 
 	public static SendReturnObjs Node_SendWork(String fk_flow, long workID, Hashtable htWork, DataSet workDtls, int toNodeID, String nextWorkers) throws Exception {
 		return Node_SendWork(fk_flow, workID, htWork, workDtls, toNodeID, nextWorkers, WebUser.getNo(), WebUser.getName(), WebUser.getDeptNo(), WebUser.getDeptName(), null, 0, 0);
@@ -8879,8 +8878,7 @@ c	*/
 		}
 
 
-
-			///#region 更新发送参数.
+		// #region 更新发送参数.
 		if (htWork != null)
 		{
 			String dbstr = SystemConfig.getAppCenterDBVarStr();

+ 1 - 3
jeecg-boot/jflow-core/src/main/java/bp/wf/WorkNode.java

@@ -10551,12 +10551,10 @@ public class WorkNode {
 			case "App_Register":  // 应用注册审批流程
 				SystemClient systemClient = BeanUtils.getBean(SystemClient.class);
 				String appid = this.rptGe.getRow().GetValStrByKey("id");
-				systemClient.afterAppCheckPass(appid);
+				systemClient.afterAppCheckPass(appid, this.rptGe.getRow());
 				break;
 		}
 		UserTokenContext.remove();
 	}
-
-
 		///#endregion
 }

+ 3 - 0
jeecgboot-vue3/src/views/appmanage/addForm/Step1.vue

@@ -139,6 +139,9 @@ const infoDeptUseroptions = ref<SelectProps['options']>([]);
         if (this.formType === 'isAdd'){  // 处于添加表单下的关闭事件,需收集表单已填数据进行存储
           if (tag === 'filling'){  // 填写过程中关闭表单,需要保存草稿数据
             obj.data = getFieldsValue()
+            console.log("注册过程填写数据关闭事件")
+            console.dir(obj.data)
+            if ((obj.data as any).type === '') delete obj.data?.type
           }
         }else { // 处于编辑表单下的关闭事件
           console.log("表单一编辑状态下关闭")