Просмотр исходного кода

撤销重新发起保留驳回和撤销的记录

anderx лет назад: 2
Родитель
Сommit
c491270b27

+ 4 - 0
src/main/java/com/goafanti/common/dao/ExpenseAccountLogMapper.java

@@ -2,6 +2,7 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.ExpenseAccountLog;
 import com.goafanti.expenseAccount.bo.OutExpenseAccountLog;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -21,4 +22,7 @@ public interface ExpenseAccountLogMapper {
     List<OutExpenseAccountLog> selectByEaid(Integer eaid);
 
 
+    void updateUseLogByUseId(@Param("id") Integer id, @Param("useId") Integer useId);
+
+    void deleteByeaid(Integer id);
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/ExpenseAccountMapper.java

@@ -68,4 +68,6 @@ public interface ExpenseAccountMapper {
     void updateSonByMainId(Integer id);
 
     MainExpenseAccount selectbySonId(Integer id);
+
+    Integer selectDeleteIdBySonId(Integer integer);
 }

+ 12 - 2
src/main/java/com/goafanti/common/mapper/ExpenseAccountLogMapper.xml

@@ -23,6 +23,7 @@
     delete from expense_account_log
     where id = #{id,jdbcType=INTEGER}
   </delete>
+
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccountLog" useGeneratedKeys="true">
     insert into expense_account_log (eaid, process_status, `status`,
       remarks, auditor, create_time
@@ -109,12 +110,21 @@
     where id = #{id,jdbcType=INTEGER}
   </update>
 
-  <select id="selectByEaid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountLog">
+
+    <select id="selectByEaid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountLog">
     select a.id,a.eaid ,a.status ,a.remarks ,a.auditor ,b.name auditorName,a.process_status processStatus,
            date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr
     from expense_account_log a left join admin b on a.auditor =b.id
     where a.eaid= #{eaid}
     order by a.create_time
   </select>
-
+  <update id="updateUseLogByUseId" parameterType="java.lang.Integer">
+    update expense_account_log
+    set eaid = #{id}
+    where eaid = #{useId} and status in (3,4)
+  </update>
+  <delete id="deleteByeaid" parameterType="java.lang.Integer">
+    delete from expense_account_log
+    where eaid = #{id,jdbcType=INTEGER}
+  </delete>
 </mapper>

+ 6 - 0
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -1042,5 +1042,11 @@
   left join admin ad on b.aid=ad.id left join department adDep on ad.department_id=adDep.id
   where c.id in (#{id})
   </select>
+  <select id="selectDeleteIdBySonId" resultType="java.lang.Integer">
+    select b.id
+    from expense_account a left join expense_relationship b on a.id =b.ea_id
+                           left join expense_account c on b.id =c.id
+    where a.id= #{id} and c.id is null
+  </select>
 
 </mapper>

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

@@ -623,7 +623,11 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
                 list.add(notice);
                 EmailBo emailBo=new EmailBo(NoticeStatus.getValueByCode(noticeStatus),a.getEmail(),str);
                 asyncUtils.send(emailBo);
-                weChatUtils.addExpenseAccountWeChatNotice(a.getExpenseOpenId(),status,in.getId(),date,aname,str);
+                try {
+                    weChatUtils.addExpenseAccountWeChatNotice(a.getExpenseOpenId(),status,in.getId(),date,aname,str);
+                }catch (Exception e){
+                    throw new BusinessException("网络通信异常,请稍后再试。");
+                }
             }
         asyncUtils.addNoticeBatch(list);
         }
@@ -736,7 +740,9 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         List<ExpenseAccountExamine> expenseAccountExamines = expenseAccountExamineMapper.selectByEaidAndProcessStatus(id, res.getProcessStatus());
         for (ExpenseAccountExamine e : expenseAccountExamines) {
             if (e.getAuditor().equals(TokenManager.getAdminId())){
-                res.setExamine(1);
+                if (res.getStatus()==1){
+                    res.setExamine(1);
+                }
                 break;
             }
         }
@@ -765,19 +771,30 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             if (in.getEaaid()!=null)update.setEaaid(in.getEaaid());
             addExpenseAccountExamine(in.getId(),update);
             if (outExpenseAccount.getStatus()==0){
+                //补旧日志
+                MainExpenseAccount mianEA = expenseAccountMapper.selectByMainId(in.getId());
+                List<Integer> collect = mianEA.getSonList().stream().map(SonExpenseAccount::getId).collect(Collectors.toList());
+                if (!collect.isEmpty()){
+                    Integer i = expenseAccountMapper.selectDeleteIdBySonId(collect.get(0));
+                    if (i !=null)
+                        expenseAccountLogMapper.updateUseLogByUseId(in.getId(),i);
+                        expenseAccountLogMapper.deleteByeaid(i);
+                }
                 addExpenseAccountLogAndNoticEmail(outExpenseAccount,outExpenseAccount.getStatus(),"发起报销审核");
             }else if (outExpenseAccount.getStatus()==3){
                 addExpenseAccountLogAndNoticEmail(outExpenseAccount,4,"修改并发起审核");
             }
+            update.setStatus(in.getStatus());
+            update.setProcessStatus(outExpenseAccount.getProcessStatus());
+            update.setId(in.getId());
+            update.setExamineName(outExpenseAccount.getExamineName());
+            expenseAccountMapper.updateByPrimaryKeySelective(update);
         }else if (in.getStatus()==4){
             expenseAccountMapper.updateByMainId(in.getId(),0);
+            expenseAccountMapper.deleteByPrimaryKey(in.getId());
             addExpenseAccountLog(in.getId(),4,0,in.getAid(),"撤销报销审核");
         }
-        update.setStatus(in.getStatus());
-        update.setProcessStatus(outExpenseAccount.getProcessStatus());
-        update.setId(in.getId());
-        update.setExamineName(outExpenseAccount.getExamineName());
-        return expenseAccountMapper.updateByPrimaryKeySelective(update);
+        return 1;
     }
 
     @Override