• 服务大厅流程


     

     

     

      1 package com.gwt.flow.service.impl;
      2 
      3 import java.text.SimpleDateFormat;
      4 import java.util.ArrayList;
      5 import java.util.Date;
      6 import java.util.HashMap;
      7 import java.util.List;
      8 import java.util.Map;
      9 
     10 import org.springframework.beans.factory.annotation.Autowired;
     11 import org.springframework.stereotype.Service;
     12 
     13 import com.gwt.flow.entity.FuwuFlow;
     14 import com.gwt.flow.entity.FuwuFlowAudit;
     15 import com.gwt.flow.mapper.FuwuFlowAuditMapper;
     16 import com.gwt.flow.mapper.FuwuFlowMapper;
     17 import com.gwt.flow.mapper.FuwuFlowRecordMapper;
     18 import com.gwt.flow.service.FuwuFlowService;
     19 import com.gwt.flow.service.FuwuFlowStateService;
     20 import com.gwt.system.entity.SysUser;
     21 import com.gwt.system.mapper.SysUserMapper;
     22 
     23 @Service
     24 public class FuwuFlowServiceImpl implements FuwuFlowService{
     25 
     26     @Autowired
     27     private FuwuFlowStateService fuwuFlowStateService;
     28     
     29     @Autowired 
     30     private FuwuFlowRecordMapper fuwuFlowRecordMapper;
     31     
     32     @Autowired 
     33     private FuwuFlowAuditMapper fuwuFlowAuditMapper;
     34     
     35     @Autowired
     36     private SysUserMapper sysUserMapper;
     37     
     38     @Autowired
     39     private FuwuFlowMapper fuwuFlowMapper;
     40     
     41     @Override
     42     public String applyAndAuditFuwuFlow(FuwuFlowAudit fuwuFlowAudit,String bussionOrder,Double input) {
     43         // TODO Auto-generated method stub
     44         String flowCode = fuwuFlowAudit.getFlowCode();
     45         String flowTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
     46         //表示同意与不同意,1表示同意,2表示不同意,0表示流程结束
     47         String isAudit = "1";
     48         //通过 查找下个节点以及下个审核人
     49         List<Map<String, String>> nodeUser = null;
     50         
     51         if(null!=bussionOrder) {
     52             //因为会议费的特殊性:他申请时无预约单号,因此预约单号放置与此处
     53             fuwuFlowAudit.setBussionOrder(bussionOrder);
     54         }
     55         
     56         //最后一位可能是0 1 2  0表示流程结束
     57         if(flowCode.substring(2, 3).equals("1")||flowCode.substring(2, 3).equals("2")) {
     58             //如果节点同意,就查找下个节点
     59             nodeUser = fuwuFlowStateService.getNodeUser(fuwuFlowAudit.getFlowCode(), fuwuFlowAudit.getFlowKey(), fuwuFlowAudit.getFlowAchieveAccount(), fuwuFlowAudit.getFlowAchieveUsername(),input);
     60 
     61             //处理特殊状态,特殊状态长度必然是1
     62             if(null!=nodeUser&&nodeUser.size()==1) {
     63                 if(null!=nodeUser.get(0).get("error")&&nodeUser.get(0).get("error").equals("-01")) {
     64                     // 返回 -01 表示不同意
     65                     //fuwuFlowAudit.setFlowTime(flowTime);
     66                     isAudit = "2";    
     67                     nodeUser = null;
     68                 }else if(null!=nodeUser.get(0).get("error")&&nodeUser.get(0).get("error").equals("-00")) {
     69                     // 返回 -00 表示流程结束
     70                     isAudit = "0";
     71                 }else if(null!=nodeUser.get(0).get("error")&&nodeUser.get(0).get("error").equals("-0")) {
     72                     // 返回 -0 表示 没有查询到下个节点用户,由用户自行定义处理结果
     73                     return "noUser";
     74                 }else if(null!=nodeUser.get(0).get("error")&&nodeUser.get(0).get("error").equals("-1#")) {
     75                     //表示回到第一步,取当前配置的节点,取流程保存的全局唯一用户
     76                 }else if(null!=nodeUser.get(0).get("error")&&nodeUser.get(0).get("error").indexOf("-2#")==0) {
     77                     //如果成立,那么第二个参数表示角色编号
     78                     String flowLastCode = nodeUser.get(0).get("flowLastCode");
     79                     String flowLastName = nodeUser.get(0).get("flowLastName");
     80                     //获得负责人信息
     81                     List<SysUser> userByDeptCode = sysUserMapper.getUserByDeptCode(fuwuFlowAudit.getFlowRole(),nodeUser.get(0).get("error").split("#")[1]);
     82                     
     83                     //表示未有查询到下个节点的用户信息
     84                     if(null==userByDeptCode||userByDeptCode.size()==0) {
     85                         return "noUser";
     86                     }
     87                     Map<String, String> tempMap =  null;
     88                     nodeUser = new ArrayList<Map<String,String>>();
     89                     for(SysUser sysUser:userByDeptCode) {
     90                         tempMap = new HashMap<String, String>();
     91                         tempMap.put("flowLastCode", flowLastCode);
     92                         tempMap.put("flowLastName", flowLastName);
     93                         tempMap.put("account", sysUser.getAccount());
     94                         tempMap.put("username", sysUser.getUsername());    
     95                         nodeUser.add(tempMap);
     96                     }
     97                 }
     98             }
     99             fuwuFlowAudit.setFlowTime(flowTime);
    100         }else if(flowCode.substring(2, 3).equals("0")){
    101             //表示流程结束(似乎是多余的,后续删)
    102             isAudit = "0";
    103         }
    104 
    105         if(null==fuwuFlowAudit.getfId()) {
    106             //为空表示申请,申请时无需删除记录
    107             //填充预约单号已放置与上面
    108             //fuwuFlowAudit.setBussionOrder(bussionOrder);
    109             fuwuFlowAudit.setFlowAchieveNowTime(flowTime);
    110         }else {
    111             //删除记录
    112             FuwuFlowAudit deleteFuwuFlowAudit= new FuwuFlowAudit();
    113             deleteFuwuFlowAudit.setfId(fuwuFlowAudit.getfId());
    114             Long myDelete = fuwuFlowAuditMapper.myDelete(deleteFuwuFlowAudit);
    115             if(myDelete == 0) {
    116                 //返回flase
    117                 return "noAuth";
    118             }
    119         }
    120         //保存当前的下个节点,即默认节点
    121         String flowLastNodeCode = fuwuFlowAudit.getFlowLastNodeCode();
    122         String flowLastNodeName = fuwuFlowAudit.getFlowLastNodeName();
    123         
    124         
    125         //插入记录表开始
    126         //记录表的下个节点为审核节点
    127         if(null==nodeUser && isAudit.equals("2")) {
    128             //为空或不同意,下个节点不做处理
    129         }else {
    130             //同意,下个节点暂时设置为真实的下个节点
    131             fuwuFlowAudit.setFlowLastNodeCode(nodeUser.get(0).get("flowLastCode"));
    132             fuwuFlowAudit.setFlowLastNodeName(nodeUser.get(0).get("flowLastName"));
    133         }
    134         fuwuFlowRecordMapper.insertMySelective(fuwuFlowAudit);
    135         //插入记录表结束
    136         
    137         if(!isAudit.equals("0")) {
    138             if(null==nodeUser && isAudit.equals("2")) {
    139                 //表示不同意
    140                 fuwuFlowAudit.setFlowTime(null);
    141                 fuwuFlowAudit.setFlowAudityj(null);
    142                 fuwuFlowAudit.setFlowCode(null);
    143                 fuwuFlowAudit.setFlowState(null);
    144                 fuwuFlowAudit.setFlowAccount(fuwuFlowAudit.getFlowAchieveAccount());
    145                 fuwuFlowAudit.setFlowUsername(fuwuFlowAudit.getFlowAchieveUsername());
    146                 fuwuFlowAudit.setFlowAchieveLastTime(flowTime);
    147                 fuwuFlowAudit.setFlowNowNodeCode(flowLastNodeCode);
    148                 fuwuFlowAudit.setFlowNowNodeName(flowLastNodeName);
    149                 //下个节点始终插入默认
    150                 fuwuFlowAudit.setFlowLastNodeCode(flowLastNodeCode);
    151                 fuwuFlowAudit.setFlowLastNodeName(flowLastNodeName);
    152                 fuwuFlowAuditMapper.insertSelective(fuwuFlowAudit);
    153             }else {
    154                 for(Map<String, String> map:nodeUser) {
    155                     fuwuFlowAudit.setFlowTime(null);
    156                     fuwuFlowAudit.setFlowAudityj(null);
    157                     fuwuFlowAudit.setFlowCode(null);
    158                     fuwuFlowAudit.setFlowState(null);
    159                     fuwuFlowAudit.setFlowAccount(map.get("account"));
    160                     fuwuFlowAudit.setFlowUsername(map.get("username"));
    161                     fuwuFlowAudit.setFlowAchieveLastTime(flowTime);
    162                     fuwuFlowAudit.setFlowNowNodeCode(map.get("flowLastCode"));
    163                     fuwuFlowAudit.setFlowNowNodeName(map.get("flowLastName"));
    164                     //下个节点始终插入默认
    165                     fuwuFlowAudit.setFlowLastNodeCode(flowLastNodeCode);
    166                     fuwuFlowAudit.setFlowLastNodeName(flowLastNodeName);
    167                     fuwuFlowAuditMapper.insertSelective(fuwuFlowAudit);
    168                 }
    169             }    
    170         }
    171 
    172         return "success#"+isAudit;
    173     }
    174 
    175     @Override
    176     public void sendJhApply(String yyorderCode,String applyUser,String applyTime,String flowKey) {
    177         //通过key查询规则
    178         FuwuFlow fu= fuwuFlowMapper.selectByflowKey(flowKey);
    179         Map<String, String> map=new HashMap<String, String>();
    180         map.put("yyorderCode", yyorderCode);
    181         map.put("applyUser", applyUser);
    182         map.put("applyTime", applyTime);
    183         map.put("rule", fu.getFlowRule());
    184         // send
    185     }
    186     @Override
    187     public void sendJhAudit(String yyorderCode,String auditUser,String auditTime) {
    188         
    189         Map<String, String> map=new HashMap<String, String>();
    190         map.put("yyorderCode", yyorderCode);
    191         map.put("auditUser", auditUser);
    192         map.put("applyTime", auditTime);
    193         // send
    194     }
    195 }
    package com.gwt.flow.service.impl;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    
    import com.gwt.flow.entity.FuwuFlowState;
    import com.gwt.flow.mapper.FuwuFlowStateMapper;
    import com.gwt.flow.service.FuwuFlowStateService;
    import com.gwt.system.entity.SysRole;
    import com.gwt.system.entity.SysUser;
    import com.gwt.system.mapper.RoleUserMapper;
    import com.gwt.system.mapper.SysRoleMapper;
    import com.gwt.utils.MvelJavaFlow;
    
    @Service
    public class FuwuFlowStateServiceImpl implements FuwuFlowStateService {
        
        @Autowired
        private RoleUserMapper roleUserMapper;
        @Autowired
        private SysRoleMapper roleMapper;
        @Autowired
        private FuwuFlowStateMapper fuwuFlowStateMapper;
        
        @Override
        public List<Map<String, String>> getNodeUser(String flowCode, String flowKey, String account, String username,Double input) {
            List<Map<String, String>> reList = new ArrayList<Map<String, String>>();
            
            Map<String, String> reMap = new HashMap<String, String>();
            FuwuFlowState fuwuFlowState = new FuwuFlowState();
            fuwuFlowState.setFlowCode(flowCode);
            fuwuFlowState.setFlowKey(flowKey);
            List<FuwuFlowState> selectListSelective = fuwuFlowStateMapper.selectListSelective(fuwuFlowState);
            
            if(null == selectListSelective || selectListSelective.size()==0) {
                // 表示未查询到数据,数据异常
                reMap.put("flowLastCode", "");
                reMap.put("flowLastName", "");
                reMap.put("account", "");
                reMap.put("username", "");
                reMap.put("error", "-0");
                reList.add(reMap);
                return reList;
            }else {
                if(selectListSelective.size() == 1) {
                    //需要判断是否有表达式,如果有就先执行表达式,查询如下个节点和下个节点的审批角色
                    FuwuFlowState fuwuFlowState2 = selectListSelective.get(0);
                    
                    String flowLastCode = "";
                    String flowLastName = "";
                    List<SysUser> userByRole = null;
                    if(fuwuFlowState2.getFlowLastCode().equals("01")) {
                        //返回的不同意节点是01,不做处理,标识符01必须传递
                        reMap.put("flowLastCode", "");
                        reMap.put("flowLastName", "");
                        reMap.put("account", "");
                        reMap.put("username", "");
                        
                        reMap.put("error", "-01");
                        reList.add(reMap);
                        return reList;
                    }else if(fuwuFlowState2.getFlowLastCode().equals("00")) {
                        //表示流程结束
                        flowLastCode =  fuwuFlowState2.getFlowLastCode();
                        flowLastName = fuwuFlowState2.getFlowLastName();
                        reMap.put("flowLastCode", flowLastCode);
                        reMap.put("flowLastName", flowLastName);
                        reMap.put("account", "");
                        reMap.put("username", "");
                        
                        reMap.put("error", "-00");
                        reList.add(reMap);
                        return reList;
                    }else if(null ==fuwuFlowState2.getFlowExpression()) {
                        // 未有表达式,执行下一步
                        flowLastCode =  fuwuFlowState2.getFlowLastCode();
                        flowLastName = fuwuFlowState2.getFlowLastName();
                        reMap.put("flowLastCode", flowLastCode);
                        reMap.put("flowLastName", flowLastName);
                        if(null==fuwuFlowState2.getFlowLastRole()) {
                            //没有配置角色,默认前端传递过来
                            reMap.put("account", "");
                            reMap.put("username", "");
                            reMap.put("error", "-0");
                            reList.add(reMap);
                            return reList;
                        }else {
                            userByRole = getUserByRole(fuwuFlowState2.getFlowLastRole());
                        }
                    }else {
                        //有表达式,按照表达式获得节点信息
                        //通过表达式获得节点信息
                        MvelJavaFlow mvelJavaFlow = new MvelJavaFlow(fuwuFlowState2.getFlowExpression(),input);
                        String score = mvelJavaFlow.getScore();
                        if(score.equals("00")) {
                            reMap.put("flowLastCode", "00");
                            reMap.put("flowLastName", "已支付");
                            reMap.put("account", "");
                            reMap.put("username", "");
                            reMap.put("error", "-00");
                            reList.add(reMap);
                            return reList;
                        }else if(score.equals("-1#")) {
                            //表示无需查询节点,直接获取申请人信息
                            reMap.put("flowLastCode", selectListSelective.get(0).getFlowLastCode());
                            reMap.put("flowLastName", selectListSelective.get(0).getFlowLastName());
                            reMap.put("account", account);
                            reMap.put("username", username);
                            reList.add(reMap);
                            return reList;
                        }else if(score.indexOf("-2#")==0) {
                            //表示查询单位负责人
                            //根据申请人查询所属部门查询部门负责人
                            reMap.put("error", score);
                            reMap.put("flowLastCode", fuwuFlowState2.getFlowLastCode());
                            reMap.put("flowLastName", fuwuFlowState2.getFlowLastName());
                            reList.add(reMap);
                            return reList;
                        }else{
                            FuwuFlowState flowNode = new FuwuFlowState();
                            flowNode.setFlowKey(flowKey);
                            flowNode.setFlowLastCode(score);
                            //通过流程key和节点信息查询到下个节点信息,主要是获得下个节点信息和下个审核的角色信息
                            List<FuwuFlowState> selectListSelective2 = fuwuFlowStateMapper.selectListSelective(flowNode);
                            
                            //至少会查询到一个,未有查询到表示配置错误
                            FuwuFlowState fuwuFlowState3 = selectListSelective2.get(0);
                            //将节点信息保存
                            flowLastCode = fuwuFlowState3.getFlowLastCode();
                            flowLastName = fuwuFlowState3.getFlowLastName();
                            reMap.put("flowLastCode", flowLastCode);
                            reMap.put("flowLastName", flowLastName);
                            //获得审批人
                            if(null==fuwuFlowState3.getFlowLastRole()) {
                                //表示未配置,由前端传递
                                reMap.put("account", "");
                                reMap.put("username", "");
                                reMap.put("error", "-0");
                                reList.add(reMap);
                                return reList;
                            }else {
                                userByRole = getUserByRole(fuwuFlowState3.getFlowLastRole());
                            }    
                        }
                    }
                    
                    if(null==userByRole||userByRole.size()==0) {
                        //表示根据角色未查询到人
                        reMap.put("account", "");
                        reMap.put("username", "");
                        reMap.put("error", "-0");
                        reList.add(reMap);
                        return reList;
                    }else {
                        for(SysUser sysUser:userByRole) {
                            reMap = new HashMap<String, String>();
                            reMap.put("flowLastCode", flowLastCode);
                            reMap.put("flowLastName", flowLastName);
                            reMap.put("account", sysUser.getAccount());
                            reMap.put("username", sysUser.getUsername());
                            reList.add(reMap);
                        }
                    }
                }else {
                    //节点配置异常,应该查询到一条数据
                    reMap.put("flowLastCode", "");
                    reMap.put("flowLastName", "");
                    reMap.put("account", "");
                    reMap.put("username", "");
                    reMap.put("error", "-0");
                    reList.add(reMap);
                }
            }
            
            return reList;
        }
    
        private List<SysUser> getUserByRole(String flowLastRole) {
            List<SysUser> reSysUser = null;
            // 查询角色下的有用户
            SysRole sysRole = new SysRole();
            sysRole.setCode(flowLastRole);
            List<SysRole> selectListSelective = roleMapper.selectListSelective(sysRole);
            if(null==selectListSelective||selectListSelective.size()==0) {
            }else {
                reSysUser = roleUserMapper.selectRoleUsersByRole(selectListSelective.get(0).getId());
            }
            return reSysUser;
        }
    
    }
  • 相关阅读:
    因文件夹取名为system才导致的错误
    如何排除一些不需要SVN版本管理的文件和目录
    ext
    svn忽略文件和文件夹
    TortoiseSVN设置忽略的文件类型或文件夹
    X++学习(一)
    X++学习(三)
    X++学习(二)
    X++学习(四)
    X++学习(五)
  • 原文地址:https://www.cnblogs.com/wcss/p/11821564.html
Copyright © 2020-2023  润新知