Explorar o código

会山流程引擎 二版 修改条件判定逻辑 添加审批组件中配置人员APP端选择接口

xianwait %!s(int64=2) %!d(string=hai) anos
pai
achega
43dd349359

+ 2 - 1
willalp-clocking-in/src/main/java/com/willalp/files/mapper/HsOrgPersonnelFilesMapper.java

@@ -30,7 +30,8 @@ public interface HsOrgPersonnelFilesMapper extends BaseMapper<HsOrgPersonnelFile
             "FROM\n" +
             "\ths_org_personnel_files hopf\n" +
             "\tleft JOIN sys_user_organization suo on hopf.user_code = suo.login_name\n" +
-            "\tWHERE suo.organization_code = 'G00000007'" +
+            "\tWHERE suo.organization_code = 'G00000007' " +
+            "AND hopf.is_delete = 0" +
             "\tGROUP BY hopf.user_code")
     List<HsOrgPersonnelFiles> templateHsOrgPersonnelFilesList();
 }

+ 4 - 2
willalp-clocking-in/src/main/java/com/willalp/flow/mapper/HsFlowConditionModelMapper.java

@@ -2,6 +2,7 @@ package com.willalp.flow.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.willalp.flow.domain.HsFlowConditionModel;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -24,10 +25,11 @@ public interface HsFlowConditionModelMapper extends BaseMapper<HsFlowConditionMo
     /**
      * 查询条件组
      *
-     * @param id
+     * @param groupId
+     * @param parentId
      * @return
      */
-    List<HsFlowConditionModel> queryConditionGroup(String id);
+    List<HsFlowConditionModel> queryConditionGroup(@Param("groupId") String groupId, @Param("parentId") String parentId);
 
 
 }

+ 5 - 2
willalp-clocking-in/src/main/java/com/willalp/flow/mapper/xml/HsFlowBaseMapper.xml

@@ -85,7 +85,10 @@
     </select>
     <select id="firstFlowBase" resultType="com.willalp.flow.domain.HsFlowBase">
         <include refid="selectHsFlowBaseVo"/>
-        where examples_id = #{examplesId} AND
-        group_id = id
+        where
+        id = (SELECT down_step_id FROM
+        from hs_flow_base
+        examples_id = #{examplesId} AND
+        group_id = id)
     </select>
 </mapper>

+ 8 - 4
willalp-clocking-in/src/main/java/com/willalp/flow/mapper/xml/HsFlowConditionModelMapper.xml

@@ -52,9 +52,13 @@
         </where>
     </select>
     <select id="queryConditionGroup" resultType="com.willalp.flow.domain.HsFlowConditionModel">
-        <include refid="selectHsFlowConditionModelVo"/>
-        <where>
-            group_id = #{id}
-        </where>
+        SELECT hfcm.id,
+               hfcm.param_name,
+               hfcm.condition_char,
+               hfcm.threshold_value
+        FROM `hs_flow_base` hfb
+                 LEFT JOIN hs_flow_condition_model hfcm ON hfb.term_module_id = hfcm.id
+        WHERE hfb.group_id = #{groupId}
+          AND hfb.up_step_id = #{parentId}
     </select>
 </mapper>

+ 10 - 1
willalp-clocking-in/src/main/java/com/willalp/flow/service/HsFlowEngineService.java

@@ -3,6 +3,7 @@ package com.willalp.flow.service;
 import com.willalp.flow.domain.HsFlowRunningRecord;
 import com.willalp.flow.domain.HsFlowTask;
 import com.willalp.flow.domain.req.FLowReq;
+import com.willalp.system.domain.vo.PostTreeVo;
 
 import java.util.List;
 import java.util.Map;
@@ -29,7 +30,7 @@ public interface HsFlowEngineService {
     int nextStep(FLowReq flow);
 
     /**
-     * 获取待办
+     * 获取指定待办任务
      *
      * @param taskId
      * @return
@@ -67,4 +68,12 @@ public interface HsFlowEngineService {
      * @return
      */
     int revoke(String taskId);
+
+    /**
+     * 获取树岗位
+     *
+     * @return
+     * @param taskId
+     */
+    List<PostTreeVo> getTreePost(String taskId);
 }

+ 4 - 4
willalp-clocking-in/src/main/java/com/willalp/flow/service/impl/HsFlowConditionModelServiceImpl.java

@@ -41,13 +41,13 @@ public class HsFlowConditionModelServiceImpl extends ServiceImpl<HsFlowCondition
                     Double aDouble = Double.valueOf(fcm.getThresholdValue());
                     Double objDbl = Double.valueOf((Integer) obj);
                     switch (fcm.getConditionChar()) {
-                        case "&gt;":
+                        case ">":
                             return objDbl > aDouble;
-                        case "&lt;":
+                        case "<":
                             return objDbl < aDouble;
-                        case "&gt;=":
+                        case ">=":
                             return objDbl >= aDouble;
-                        case "&lt;=":
+                        case "<=":
                             return objDbl <= aDouble;
                         case "!=":
                             return !objDbl.equals(aDouble);

+ 81 - 8
willalp-clocking-in/src/main/java/com/willalp/flow/service/impl/HsFlowEngineServiceImpl.java

@@ -1,8 +1,11 @@
 package com.willalp.flow.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.json.JSONObject;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.willalp.common.core.domain.DeptOrUserResp;
 import com.willalp.common.exception.base.BaseException;
 import com.willalp.common.utils.DateUtils;
 import com.willalp.common.utils.SecurityUtils;
@@ -17,6 +20,9 @@ import com.willalp.flow.service.IHsFlowConditionModelService;
 import com.willalp.flow.service.IHsFlowRunningRecordService;
 import com.willalp.msg.domain.HsAppUserMsg;
 import com.willalp.msg.service.IHsAppUserMsgService;
+import com.willalp.system.domain.HsPostConfig;
+import com.willalp.system.domain.vo.PostTreeVo;
+import com.willalp.system.service.IHsPostConfigService;
 import com.willalp.wx.domain.WxMsgTemplateApproval;
 import com.willalp.wx.domain.WxMsgTemplateApprovalResult;
 import com.willalp.wx.enums.WxTemplateKeyEnum;
@@ -69,6 +75,8 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
     @Resource
     private IHsAppUserMsgService userMsgService;
 
+    @Resource
+    private IHsPostConfigService postConfigService;
 
     @Override
     public void submitATask(HsFlowTask task, Map<String, String> params) {
@@ -88,11 +96,9 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
             if (ObjectUtils.isNotNull(params)) {
                 String userName = params.get("candidate");
                 if (StringUtils.isNotBlank(userName)) {
-                    hsFlowBase.setOperator(userName);
                     task.setOperator(userName);
                 }
             }
-            hsFlowBaseMapper.updateById(hsFlowBase);
             hsFlowTaskMapper.insert(task);
         } catch (Exception e) {
             e.printStackTrace();
@@ -148,18 +154,18 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
         } else {
             //查看有无条件组件
             if (StringUtils.isNotBlank(hsFlowBase.getTermModuleId()) &&
+                    hsFlowBase.getTermModuleId().contains(FlowEnum.NODE.getValue()) &&
                     null != jsonObject && resultTrue) {
                 //遍历绑定的条件组件 查找下一步 (待添加条件级别优化)
-                List<HsFlowConditionModel> hsFlowConditionModels = flowConditionModelMapper.queryConditionGroup(hsFlowBase.getTermModuleId());
+                List<HsFlowConditionModel> hsFlowConditionModels = flowConditionModelMapper.queryConditionGroup(hsFlowBase.getUpStepId(), hsFlowBase.getTermModuleId());
                 for (HsFlowConditionModel item : hsFlowConditionModels) {
                     String paramName = item.getParamName();
                     if (null != jsonObject.get(paramName)) {
-                        if (conditionModelService.executeConditionJudgment(item, jsonObject.get(paramName)) && item.getConditionType().equals("2")) {
-                            stepId = item.getDownStepId();
-                            break;
-                        }
                         if (conditionModelService.executeConditionJudgment(item, jsonObject.get(paramName))) {
-                            stepId = item.getDownStepId();
+                            //获取当前基础组件
+                            HsFlowBase newHsFlowBase = hsFlowBaseMapper.selectById(item.getId());
+                            stepId = newHsFlowBase.getDownStepId();
+                            break;
                         }
                     }
                 }
@@ -369,4 +375,71 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
         }
         return 0;
     }
+
+    @Override
+    public List<PostTreeVo> getTreePost(String taskId) {
+        if (StringUtils.isNotBlank(taskId)) {
+            HsFlowTask hsFlowTask = hsFlowTaskMapper.selectById(taskId);
+            if (null != hsFlowTask) {
+                String baseId = hsFlowTask.getBaseId();
+                if (StringUtils.isNotBlank(baseId)) {
+                    HsFlowBase hsFlowBase = hsFlowBaseMapper.selectById(baseId);
+                    if (null != hsFlowBase) {
+                        String operator = hsFlowBase.getOperator();
+                        if (StringUtils.isNotBlank(operator)) {
+                            PostTreeVo postTreeVo = new PostTreeVo();
+                            postTreeVo.setText("默认");
+                            postTreeVo.setValue("defaultId");
+                            List<DeptOrUserResp> deptOrUserResps = JSON.parseArray(operator, DeptOrUserResp.class);
+                            List<PostTreeVo> childrens = new ArrayList<PostTreeVo>();
+                            if (CollUtil.isNotEmpty(deptOrUserResps)) {
+                                for (DeptOrUserResp deptOrUserResp : deptOrUserResps) {
+                                    PostTreeVo pv = new PostTreeVo();
+                                    pv.setText(deptOrUserResp.getName());
+                                    pv.setValue(deptOrUserResp.getId());
+                                    childrens.add(pv);
+                                }
+                            }
+                            postTreeVo.setChildren(childrens);
+                        }
+                    }
+                }
+            }
+        }
+        List<HsPostConfig> hsPostConfigs = postConfigService.selectHsPostConfigList(null);
+        if (0 != hsPostConfigs.size()) {
+            List<PostTreeVo> list = new ArrayList<>();
+            String userBS = "AA";
+            hsPostConfigs.forEach(item -> {
+                PostTreeVo postTreeVo = new PostTreeVo();
+                postTreeVo.setText(item.getPostName());
+                postTreeVo.setValue(item.getId());
+                String postUserG = item.getPostUserG();
+                List<PostTreeVo> postTreeCVos = new ArrayList<>();
+                if (postUserG != null) {
+                    String[] split = postUserG.split(",");
+                    for (int i = 0; i < split.length; i++) {
+                        PostTreeVo postTreeCVo = new PostTreeVo();
+                        String nick;
+                        String userId;
+                        int of = split[i].indexOf(userBS);
+                        if (of != -1) {
+                            nick = split[i].substring(0, of);
+                            userId = split[i].substring(of);
+                        } else {
+                            nick = "WILLALP";
+                            userId = "admin";
+                        }
+                        postTreeCVo.setText(nick);
+                        postTreeCVo.setValue(userId);
+                        postTreeCVos.add(postTreeCVo);
+                    }
+                }
+                postTreeVo.setChildren(postTreeCVos);
+                list.add(postTreeVo);
+            });
+            return list;
+        }
+        return null;
+    }
 }