Browse Source

审核列表修改

anderx 2 years ago
parent
commit
e595f599a0

+ 4 - 3
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -363,7 +363,8 @@
     left join t_order_mid tm on a.order_no =tm.order_no left join department f on d.department_id =f.id
     left join admin d2 on f.finance_id =d2.id
     <if test="processStatus ==1">
-    inner join (select eaid ,auditor,min(type)`type` from expense_account_examine ) eae on a.id=eae.eaid
+    inner join (select eaid ,auditor,min(type)`type` from expense_account_examine
+      where auditor= #{aid} group by eaid) eae on a.id=eae.eaid
     </if>
     where 1=1
     <if test="processStatus ==0">
@@ -372,7 +373,6 @@
     <if test="processStatus ==1">
       and a.process_status>0
       and a.process_status >=eae.`type`
-      and eae.auditor = #{aid}
     </if>
     <if test="status != null">
       and a.status= #{status}
@@ -407,7 +407,8 @@
     left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
     left join t_order_mid tm on a.order_no =tm.order_no
     <if test="processStatus ==1">
-    inner join (select eaid ,auditor,min(type)`type` from expense_account_examine ) eae on a.id=eae.eaid
+      inner join (select eaid ,auditor,min(type)`type` from expense_account_examine
+      where auditor= #{aid} group by eaid) eae on a.id=eae.eaid
     </if>
     where 1=1
     <if test="processStatus ==0">

+ 1 - 0
src/main/java/com/goafanti/expenseAccount/Enums/EAProcessStatus.java

@@ -11,6 +11,7 @@ public enum EAProcessStatus {
     CWSH(2,"财务审核"),
     ZJLSH(3,"总经理审核"),
     DSZSH(4,"董事长审核"),
+    WCSH(5,"完成审核"),
     NOT(99,"未知");
 
     private Integer code;

+ 43 - 24
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -152,11 +152,34 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         expenseAccountLogMapper.insertSelective(eaLog);
     }
 
+    /**
+     *
+     * @param eaid 报销编号
+     * @param status 状态 0创建 1发起 2通过 3驳回 4修改
+     * @param str 备注
+     */
+    private void addExpenseAccountLog(Integer eaid, Integer status,String aid, String str,Date date) {
+        if (aid==null)aid=TokenManager.getAdminId();
+        ExpenseAccountLog eaLog=new ExpenseAccountLog();
+        eaLog.setEaid(eaid);
+        eaLog.setStatus(status);
+        eaLog.setRemarks(str);
+        eaLog.setAuditor(aid);
+        eaLog.setCreateTime(date);
+        expenseAccountLogMapper.insertSelective(eaLog);
+    }
+
     private void addExpenseAccountLogAndNoticEmail(InputExpenseAccount in, Integer status, String str) {
         String aid=TokenManager.getAdminId();
         addExpenseAccountLog(in.getId(),status,aid,str);
         //正常是走入上级审核,但是可能会跳过
         if(status>0){
+            Admin admin = adminMapper.selectByPrimaryKey(aid);
+            if (admin.getSuperiorId()==null||admin.getId().equals(admin.getSuperiorId())){
+                String str2=String.format("重复审核人跳过[%s]。",EAProcessStatus.getDesc(in.getProcessStatus()));
+                addExpenseAccountLog(in.getId(),1,aid,str2);
+                in.setProcessStatus(in.getProcessStatus()+1);
+            }
             createExamineByProcess(in);
         }
     }
@@ -188,7 +211,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             in.setExamineName(getAdmins(list));
         }
         StringBuffer str=new StringBuffer().append("您有报销需要审核,").append("报销编号[").append(in.getId()).append("]").append(",请查看并审核。");
-        addLogAndNoticeAndEmail(in,  1,str.toString(), admin.getName(),aids);
+        addNoticeAndEmail(in,  1,str.toString(), admin.getName(),aids);
     }
 
     @Override
@@ -303,8 +326,6 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         ExpenseAccount useEa = expenseAccountMapper.selectByPrimaryKey(in.getId());
         ExpenseAccount newEa=new ExpenseAccount();
         newEa.setId(useEa.getId());
-        if (useEa.getStatus()==0)throw new BusinessException("审核状态错误");
-        if (useEa.getProcessStatus()!=in.getProcessStatus())throw new BusinessException(String.format("审核流程错误use=%s",useEa.getProcessStatus()));
         //审核通知 获取发送人
         addExamineExpenseAccountLog(in, useEa, newEa);
         //完成申请
@@ -341,7 +362,7 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
     }
 
     private void pushExpenseAccountExamine(InputExpenseAccount in) {
-        if (in.getStatus()==2){
+        if (in.getStatus()==1){
             expenseAccountExamineMapper.updateStatusByEaidAndAid(in.getId(),TokenManager.getAdminId(),1);
         }else if (in.getStatus()==3){
             expenseAccountExamineMapper.updateStatusByEaidAndAid(in.getId(),null,0);
@@ -355,33 +376,24 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         AdminListBo admin = adminMapper.getDeptNameByAid(useEa.getAid());
         if (status==1){
             str=str.append("您有报销需要审核,").append("报销编号[").append(in.getId()).append("]").append(",请查看并审核。");
-            newEa.setProcessStatus(in.getProcessStatus());
+            newEa.setProcessStatus(useEa.getProcessStatus()+1);
             pushExamineProcess(newEa);
-            if(useEa.getProcessStatus()== EAProcessStatus.FQ.getCode()){
-                //获取上级
-                Admin superAdmin = adminMapper.selectByPrimaryKey(admin.getSuperiorId());
-                aids.add(superAdmin);
-                newEa.setProcessStatus(EAProcessStatus.SJSH.getCode());
-                newEa.setUserNames(superAdmin.getName());
-            }else if (useEa.getProcessStatus()== EAProcessStatus.SJSH.getCode()){
+            if (newEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()){
                 //获取财务负责人
                 Admin finaceAdmin = adminMapper.selectByPrimaryKey(admin.getDepFinance());
                 aids.add(finaceAdmin);
-                newEa.setProcessStatus(EAProcessStatus.CWSH.getCode());
                 newEa.setExamineName(finaceAdmin.getName());
-            }else if (useEa.getProcessStatus()== EAProcessStatus.CWSH.getCode()){
+            }else if (newEa.getProcessStatus()== EAProcessStatus.ZJLSH.getCode()){
                 //获取部门负责人
                 List<Admin> list = adminMapper.listAdminBydepIdAndRoleType(admin.getDepartmentId(), AFTConstants.SALESMAN_ADMIN);
                 if (!list.isEmpty())aids.addAll(list);
-                newEa.setProcessStatus(EAProcessStatus.ZJLSH.getCode());
                 newEa.setExamineName(getAdmins(list));
-            }else if (useEa.getProcessStatus()== EAProcessStatus.ZJLSH.getCode()){
+            }else if (newEa.getProcessStatus()== EAProcessStatus.DSZSH.getCode()){
                 //获取总裁、董事长等审核
                 List<Admin> list = adminMapper.selectAdminByRoleType(AFTConstants.All_CED_AND_CHAIRMAN);
                 if (!list.isEmpty())aids.addAll(list);
-                newEa.setProcessStatus(EAProcessStatus.DSZSH.getCode());
                 newEa.setExamineName(getAdmins(list));
-            }else if (useEa.getProcessStatus()== EAProcessStatus.DSZSH.getCode()){
+            }else if (newEa.getProcessStatus()== EAProcessStatus.WCSH.getCode()){
                 //获取报销申请人
                 status =2;
                 aids.add(adminMapper.selectByPrimaryKey(admin.getId()));
@@ -393,16 +405,18 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         }else {
             aids.add(adminMapper.selectByPrimaryKey(admin.getId()));
             newEa.setStatus(3);
+            newEa.setProcessStatus(0);
             str.setLength(0);
             str=str.append("您的报销审核已驳回,报销编号[").append(in.getId()).append("],请注意查看。");
         }
         if (newEa.getStatus()==null)newEa.setStatus(1);
-        addLogAndNoticeAndEmail(in,  status,str.toString(),admin.getName(),aids);
+        addExpenseAccountLog(in.getId(),status,null,in.getReason());
+        addNoticeAndEmail(in,  status,str.toString(),admin.getName(),aids);
     }
 
     private void pushExamineProcess( ExpenseAccount newEa) {
         //如果到了董事长审核,无需判断了
-        if (newEa.getProcessStatus()<EAProcessStatus.DSZSH.getCode()){
+        if (newEa.getProcessStatus()<EAProcessStatus.WCSH.getCode()){
             //判断没一个流程是否可以跳过
              examineByprocess(newEa);
         }
@@ -418,9 +432,12 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             }
         }
         if (flag){
-            addExpenseAccountLog(newEa.getId(),1,null,"重复审核人跳过当前审核。");
+            String str=String.format("重复审核人跳过[%s]。",EAProcessStatus.getDesc(newEa.getProcessStatus()));
+            Date date=new Date();
+            date.setTime(date.getTime()+1000l);
+            addExpenseAccountLog(newEa.getId(),1,null,str,date);
             newEa.setProcessStatus(newEa.getProcessStatus()+1);
-            if (newEa.getProcessStatus()<5)examineByprocess(newEa);
+            if (newEa.getProcessStatus()<EAProcessStatus.WCSH.getCode())examineByprocess(newEa);
         }
 
     }
@@ -433,9 +450,9 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         return str.substring(0,str.length()-1);
     }
 
-    private void addLogAndNoticeAndEmail(InputExpenseAccount in, Integer status, String str,String aname, List<Admin> aids) {
+    private void addNoticeAndEmail(InputExpenseAccount in, Integer status, String str,String aname, List<Admin> aids) {
         Date date= new Date();
-        if (status!=1)addExpenseAccountLog(in.getId(),status,null,in.getReason());
+
         Integer noticeStatus=NoticeStatus.EXPENSE_NOTICE.getCode();
         if (status==2){
             noticeStatus=NoticeStatus.EXPENSE_COMPLETE.getCode();
@@ -511,6 +528,8 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         if (in.getStatus()!=null)param.put("status",in.getStatus());
         if (in.getProcessStatus()==null){
             param.put("processStatus",0);
+        }else {
+            param.put("processStatus",in.getProcessStatus());
         }
         if (in.getContractNo()!=null)param.put("contractNo",in.getContractNo());
         if (in.getDepId()!=null)param.put("depId",in.getDepId());