Browse Source

报销审核流程修改

anderx 2 years ago
parent
commit
69baf79150

+ 1 - 2
src/main/java/com/goafanti/common/dao/ExpenseAccountLogMapper.java

@@ -1,7 +1,6 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.common.model.ExpenseAccountLog;
-import com.goafanti.common.model.ExpenseRelationship;
 import com.goafanti.expenseAccount.bo.OutExpenseAccountLog;
 import org.apache.ibatis.annotations.Param;
 
@@ -27,5 +26,5 @@ public interface ExpenseAccountLogMapper {
 
     void deleteByeaid(Integer id);
 
-    void insertBatch(List<ExpenseRelationship> list);
+    void insertBatch(List<OutExpenseAccountLog> list);
 }

+ 95 - 102
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -166,7 +166,6 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
      * @param str 备注
      */
     private void addExpenseAccountLog(Integer eaid, Integer status,Integer processStatus,String aid, String str,Date date) {
-        if (aid==null)aid=TokenManager.getAdminId();
         ExpenseAccountLog eaLog=new ExpenseAccountLog();
         eaLog.setEaid(eaid);
         eaLog.setStatus(status);
@@ -185,12 +184,20 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         addExpenseAccountLog(in.getId(),status,in.getProcessStatus(),aid,str);
         if (status==0)in.setProcessStatus(1);
         Admin admin = adminMapper.selectByPrimaryKey(aid);
-        if (admin.getSuperiorId()==null||admin.getId().equals(admin.getSuperiorId())){
-            String str2=String.format("重复审核人跳过[%s]。",EAProcessStatus.getDesc(in.getProcessStatus()));
+        if (admin.getExpenseSuperExamine()==0){
+            String str2=String.format("未设置[%s]审核。",EAProcessStatus.getDesc(in.getProcessStatus()));
             Date date=new Date();
             date.setTime(date.getTime()+1000L);
             addExpenseAccountLog(in.getId(),1,in.getProcessStatus(),aid,str2,date);
             in.setProcessStatus(in.getProcessStatus()+1);
+        }else {
+            if (admin.getSuperiorId()==null||admin.getId().equals(admin.getSuperiorId())){
+                String str2=String.format("重复审核人跳过[%s]。",EAProcessStatus.getDesc(in.getProcessStatus()));
+                Date date=new Date();
+                date.setTime(date.getTime()+1000L);
+                addExpenseAccountLog(in.getId(),1,in.getProcessStatus(),aid,str2,date);
+                in.setProcessStatus(in.getProcessStatus()+1);
+            }
         }
         createExamineByProcess(in);
     }
@@ -202,7 +209,9 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
     private void createExamineByProcess(ExpenseAccount in) {
         //审核流程推送到最新
         AdminListBo admin = adminMapper.getDeptNameByAid(in.getAid());
-        List<ExpenseAccountExamine> list=examineByprocess(in,admin);
+        OrganizationListOut dep = departmentMapper.selectAllById(in.getApplyDep());
+        List<ExpenseConfigDetails>  configDetailsList = expenseConfigDetailsMapper.selectByDepId(in.getApplyDep());
+        List<ExpenseAccountExamine> list=examineByprocess(in,admin,dep,configDetailsList);
         List<Admin> aids=new ArrayList<>();
         StringBuffer aname =new StringBuffer();
         for (ExpenseAccountExamine e : list) {
@@ -438,12 +447,11 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         if (!list.isEmpty()) {
             OutExpenseAccountLog lastout = list.get(list.size() - 1);
             ExpenseAccount expenseAccount = expenseAccountMapper.selectByPrimaryKey(eaid);
-            Integer processStatus = expenseAccount.getProcessStatus();
+            Integer processStatus = lastout.getProcessStatus();
             if (processStatus<8){
-                if (processStatus <4){
+                if (processStatus <3){
                     List<OutExpenseAccountLog> outExpenseAccountLogs = expenseAccountExamineMapper.selectNotExamineByEaidAndProcessStatus(eaid, processStatus);
                     list.addAll(outExpenseAccountLogs);
-                    processStatus=3;
                 }
                 if (lastout.getStatus() != 3) {
                     addDetailsLog(list, expenseAccount,processStatus);
@@ -454,50 +462,49 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             return list;
     }
 
-    private void addDetailsLog(List<OutExpenseAccountLog> list, ExpenseAccount expenseAccount,Integer processStatus) {
+    private void addDetailsLog(List<OutExpenseAccountLog> list, ExpenseAccount expenseAccount,Integer useStatus) {
         OrganizationListOut dep = departmentMapper.selectAllById(expenseAccount.getApplyDep());
         List<ExpenseConfigDetails> configDetails = expenseConfigDetailsMapper.selectByDepId(expenseAccount.getApplyDep());
-        if (processStatus ==3){
+        for (int processStatus = 3; processStatus < 8; processStatus++) {
+            processStatus=useStatus;
+            if (processStatus ==3){
                 if (dep.getExpenseRetrialFinanceExamine()==1){
                     List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 1).collect(Collectors.toList());
                     for (ExpenseConfigDetails e : collect) {
                         addDetailsTypeLog(list, expenseAccount, e);
                     }
                 }
-            processStatus++;
-        }
-        if (processStatus ==4){
-            if (dep.getCeoExamine()==1){
-                List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 2).collect(Collectors.toList());
-                for (ExpenseConfigDetails e : collect) {
-                    addDetailsTypeLog(list, expenseAccount, e);
+            }else if (processStatus ==4){
+                if (expenseAccount.getApproval()==1&&dep.getCeoExamine()==1){
+                    List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 2).collect(Collectors.toList());
+                    for (ExpenseConfigDetails e : collect) {
+                        addDetailsTypeLog(list, expenseAccount, e);
+                    }
                 }
-            }
-            processStatus++;
-        }if (processStatus ==5){
-            if (dep.getCfoExamine()==1){
-                List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 3).collect(Collectors.toList());
-                for (ExpenseConfigDetails e : collect) {
-                    addDetailsTypeLog(list, expenseAccount, e);
+            }else if (processStatus ==5){
+                if (dep.getCfoExamine()==1){
+                    List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 3).collect(Collectors.toList());
+                    for (ExpenseConfigDetails e : collect) {
+                        addDetailsTypeLog(list, expenseAccount, e);
+                    }
                 }
-            }
-            processStatus++;
-        }if (processStatus ==6){
-            if (dep.getViceCeoExamine()==1){
-                List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 4).collect(Collectors.toList());
-                for (ExpenseConfigDetails e : collect) {
-                    addDetailsTypeLog(list, expenseAccount, e);
+            }else if (processStatus ==6){
+                if (dep.getViceCeoExamine()==1){
+                    List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 4).collect(Collectors.toList());
+                    for (ExpenseConfigDetails e : collect) {
+                        addDetailsTypeLog(list, expenseAccount, e);
+                    }
                 }
-            }
-            processStatus++;
-        }if (processStatus ==7){
-            if (dep.getCashierExamine()==1){
-                List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 5).collect(Collectors.toList());
-                for (ExpenseConfigDetails e : collect) {
-                    addDetailsTypeLog(list, expenseAccount, e);
+            }else if (processStatus ==7){
+                if (dep.getCashierExamine()==1){
+                    List<ExpenseConfigDetails> collect = configDetails.stream().filter(e -> e.getType() == 5).collect(Collectors.toList());
+                    for (ExpenseConfigDetails e : collect) {
+                        addDetailsTypeLog(list, expenseAccount, e);
+                    }
                 }
             }
         }
+
     }
 
     private static void addDetailsTypeLog(List<OutExpenseAccountLog> list, ExpenseAccount expenseAccount, ExpenseConfigDetails e) {
@@ -629,29 +636,33 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             newEa.setAid(useEa.getAid());
             newEa.setCreateTime(useEa.getCreateTime());
             newEa.setApplyDep(useEa.getApplyDep());
+            //在跳入董事长审核的时候非特批直接跳过,原则上下个流程不可再跳过
+            OrganizationListOut dep = departmentMapper.selectAllById(newEa.getApplyDep());
+            List<ExpenseConfigDetails>  configDetailsList = expenseConfigDetailsMapper.selectByDepId(newEa.getApplyDep());
             if(useEa.getProcessStatus()==EAProcessStatus.CNSH.getCode()){
-                status =2;
-                expenseAccountExamineMapper.updateStatusByEaidAndAid(in.getId(),TokenManager.getAdminId(),1,1);
-                addExpenseAccountLog(in.getId(),status,useEa.getProcessStatus(),TokenManager.getAdminId(),in.getReason());
-                //完成后的流程
-                aids.add(adminMapper.selectByPrimaryKey(admin.getId()));
-                newEa.setStatus(status);
-                newEa.setExamineName("");
-            }else {
-                addExpenseAccountLog(in.getId(),status,useEa.getProcessStatus(),TokenManager.getAdminId(),in.getReason());
-                //新的流程是当前流程+1
-                newEa.setProcessStatus(useEa.getProcessStatus()+1);
-                newEa.setStatus(1);
-                if (newEa.getApproval()==null)newEa.setApproval(useEa.getApproval());
-                List<ExpenseAccountExamine> list=examineByprocess(newEa,admin);
-                //未设置推送到完成
-                if (newEa.getProcessStatus()==8 && newEa.getStatus()==2){
+                boolean expenseExamine = pushExpenseExamine(configDetailsList, newEa, null, EAProcessStatus.CNSH.getCode());
+                if (expenseExamine){
                     //完成后的流程
                     status =2;
+                    expenseAccountExamineMapper.updateStatusByEaidAndAid(in.getId(),TokenManager.getAdminId(),1,1);
                     aids.add(adminMapper.selectByPrimaryKey(admin.getId()));
                     newEa.setStatus(status);
                     newEa.setExamineName("");
                 }else {
+                    status =1;
+                }
+                addExpenseAccountLog(in.getId(),status,useEa.getProcessStatus(),TokenManager.getAdminId(),in.getReason());
+            }else {
+                addExpenseAccountLog(in.getId(),status,useEa.getProcessStatus(),TokenManager.getAdminId(),in.getReason());
+                newEa.setStatus(1);
+                if (useEa.getProcessStatus()<EAProcessStatus.CWFS.getCode()){
+                    newEa.setProcessStatus(useEa.getProcessStatus()+1);
+                }else {
+                    newEa.setProcessStatus(useEa.getProcessStatus());
+                }
+                if (newEa.getApproval()==null)newEa.setApproval(useEa.getApproval());
+                //流程的推动
+                List<ExpenseAccountExamine> list=examineByprocess(newEa,admin,dep,configDetailsList);
                     StringBuffer aname =new StringBuffer();
                     for (ExpenseAccountExamine e : list) {
                         if (e.getProcessStatus()==newEa.getProcessStatus()&&e.getStatus()==0){
@@ -662,7 +673,6 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                     }
                     newEa.setExamineName(aname.substring(0,aname.length()-1));
                 }
-            }
         }else {
             aids.add(adminMapper.selectByPrimaryKey(admin.getId()));
             newEa.setStatus(3);
@@ -707,31 +717,15 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
 
 
     }
-    private List<ExpenseAccountExamine> examineByprocess( ExpenseAccount newEa,AdminListBo admin) {
-        return examineByprocess(newEa,admin,null,null);
-    }
-
 
     /**
      * 审核流程推送,只要不是完成状态就继续判断是否跳过
      * @param newEa
      */
     private List<ExpenseAccountExamine> examineByprocess( ExpenseAccount newEa,AdminListBo admin,OrganizationListOut dep,List<ExpenseConfigDetails> list) {
-        //在跳入董事长审核的时候非特批直接跳过,原则上下个流程不可再跳过
-        if (dep==null) dep = departmentMapper.selectAllById(newEa.getApplyDep());
-        if (list==null)list = expenseConfigDetailsMapper.selectByDepId(newEa.getApplyDep());
         List<ExpenseAccountExamine> examineList=new ArrayList<>();
+        //小于财务复审的,走单审核
         if (newEa.getProcessStatus()<EAProcessStatus.CWFS.getCode()){
-            if (newEa.getProcessStatus()==EAProcessStatus.SJSH.getCode()){
-                if (admin.getExpenseSuperExamine()==0){
-                    Date date = new Date();
-                    date.setTime(date.getTime()+1000l);
-                    addExpenseAccountLog(newEa.getId(),1,newEa.getProcessStatus(),null,"未设置[上级审核]需求,跳过此流程",date);
-                    newEa.setProcessStatus(newEa.getProcessStatus()+1);
-                }
-
-            }
-            //获取当前流程审核人,如果有已审核则跳过当前审核
             examineList = expenseAccountExamineMapper.selectByEaidAndProcessStatus(newEa.getId(), newEa.getProcessStatus());
             boolean flag=false;
             String aid="";
@@ -742,10 +736,6 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                         aid=e.getAuditor();
                         break;
                     }
-                    if(e.getAuditor().equals(newEa.getAid())){
-                        flag=true;
-                        break;
-                    }
                 }
             }
             //如果当前审核人已经审核,则跳过当前审核
@@ -762,11 +752,16 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                 examineByprocess(newEa,admin,dep,list);
             }
         }else {
+            //大于等于财务复审的,走多审核
             String str=null;
+            //跳过标记
             boolean flag2= false;
+            //审核通过标记
+            boolean flag3= false;
             Date date2=new Date();
             date2.setTime(date2.getTime()+1000l);
             String tip=null;
+            String aid=null;
             if (newEa.getProcessStatus()==EAProcessStatus.CWFS.getCode()){
                 //财务复审财务复审
                 if (dep.getExpenseRetrialFinanceExamine()==0){
@@ -775,36 +770,33 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                 }else {
                     boolean expenseExamine = pushExpenseExamine(list, newEa, examineList, EAProcessStatus.CWFS.getCode());
                     if (expenseExamine){
-                        flag2=true;
-                        str=String.format("[%s]通过审核,步入下个流程",EAProcessStatus.CWFS.getDesc());
+                        flag3=true;
                     }
                 }
             }else if (newEa.getProcessStatus()==EAProcessStatus.DSZSH.getCode()){
-                if (dep.getCeoExamine()==1){
-                    if (newEa.getApproval()!=1){
-                        flag2=true;
-                        tip="特批(财务选择)";
-                    }else {
+                if (newEa.getApproval()!=1){
+                    flag2=true;
+                    tip="特批(财务选择)";
+                }else {
+                    if (dep.getCeoExamine()==1){
                         boolean expenseExamine = pushExpenseExamine(list, newEa, examineList, EAProcessStatus.DSZSH.getCode());
                         if (expenseExamine){
-                            flag2=true;
-                            str=String.format("[%s]通过审核,步入下个流程",EAProcessStatus.DSZSH.getDesc());
+                            flag3=true;
                         }
+                    }else {
+                        flag2=true;
+                        tip="特批(部门设置)";
                     }
-                }else {
-                    flag2=true;
-                    tip="特批(部门设置)";
                 }
-
             }else if (newEa.getProcessStatus()==EAProcessStatus.CWGGLYSH.getCode()){
                 if (dep.getExpenseRetrialFinanceExamine()==0){
                     flag2=true;
                     tip=EAProcessStatus.CWGGLYSH.getDesc();
+                    aid=null;
                 }else {
                     boolean expenseExamine = pushExpenseExamine(list, newEa, examineList, EAProcessStatus.CWGGLYSH.getCode());
                     if (expenseExamine){
-                        flag2=true;
-                        str=String.format("[%s]通过审核,步入下个流程",EAProcessStatus.CWGGLYSH.getDesc());
+                        flag3=true;
                     }
                 }
             }else if (newEa.getProcessStatus()==EAProcessStatus.GSFSSH.getCode()){
@@ -814,8 +806,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                 }else {
                     boolean expenseExamine = pushExpenseExamine(list, newEa, examineList, EAProcessStatus.GSFSSH.getCode());
                     if (expenseExamine){
-                        flag2=true;
-                        str=String.format("[%s]通过审核,步入下个流程",EAProcessStatus.GSFSSH.getDesc());
+                        flag3=true;
                     }
                 }
             }else if (newEa.getProcessStatus()==EAProcessStatus.CNSH.getCode()){
@@ -825,24 +816,24 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                 }else {
                     boolean expenseExamine = pushExpenseExamine(list, newEa, examineList, EAProcessStatus.CNSH.getCode());
                     if (expenseExamine){
-                        flag2=true;
-                        str=String.format("[%s]通过审核,完成报销流程",EAProcessStatus.CNSH.getDesc());
+                        flag3=true;
                     }
                 }
             }
             if (flag2){
-                if (str==null)str=String.format("未设置[%s]审核,跳过此流程",tip);
                 if (newEa.getProcessStatus()<EAProcessStatus.CNSH.getCode()){
-                    addExpenseAccountLog(newEa.getId(),1,newEa.getProcessStatus(),"1",str,date2);
+                    if (str==null)str=String.format("未设置[%s]审核,跳过此流程",tip);
+                    addExpenseAccountLog(newEa.getId(),1,newEa.getProcessStatus(),aid,str,date2);
                     newEa.setProcessStatus(newEa.getProcessStatus()+1);
                     examineByprocess(newEa,admin,dep,list);
-
                 }else {
-                    addExpenseAccountLog(newEa.getId(),2,newEa.getProcessStatus(),"1",str,date2);
+                    addExpenseAccountLog(newEa.getId(),2,newEa.getProcessStatus(),aid,str,date2);
                     newEa.setProcessStatus(newEa.getProcessStatus());
                     newEa.setStatus(2);
                 }
-
+            }else if (flag3){
+                newEa.setProcessStatus(newEa.getProcessStatus()+1);
+                examineByprocess(newEa,admin,dep,list);
             }
         }
         examineList=expenseAccountExamineMapper.selectByEaidAndProcessStatus(newEa.getId(), newEa.getProcessStatus());
@@ -859,7 +850,8 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         int finalConfigDetails = configDetails;
         List<ExpenseConfigDetails> collect = list.stream().filter(e -> e.getType() == finalConfigDetails).collect(Collectors.toList());
         int count = 0;
-        examineList.clear();
+        if (examineList==null)examineList=new ArrayList<>();
+        else examineList.clear();
         for (ExpenseConfigDetails e : collect) {
             ExpenseAccountExamine eae=new ExpenseAccountExamine(newEa.getId(),status);
             eae.setAuditor(e.getAid());
@@ -1066,11 +1058,12 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             }else {
                 List<OutExpenseAccountLog> outExpenseAccountLogs = expenseAccountLogMapper.selectByEaid(in.getId());
                 for (int i=0;i<list.size();i++){
-                    ExpenseRelationship e =list.get(0);
+                    ExpenseRelationship e =list.get(i);
                     for (OutExpenseAccountLog eal : outExpenseAccountLogs) {
+
                         eal.setEaid(e.getEaId());
                     }
-                    expenseAccountLogMapper.insertBatch(list);
+                    expenseAccountLogMapper.insertBatch(outExpenseAccountLogs);
                 }
             }
             expenseAccountLogMapper.deleteByeaid(in.getId());

+ 1 - 1
src/main/resources/props/config_local.properties

@@ -52,7 +52,7 @@ yxjl_max=100
 amb.maxLvl=6
 
 avatar.host=//static.jishutao.com
-static.host=//static.jishutao.com/1.3.02
+static.host=//static.jishutao.com/1.3.03
 rd.static.host=//static.jishutao.com/RD/1.0.03
 #avatar.host=//172.16.0.255:3000
 #static.host=//172.16.0.255:3000/1.2.62