Browse Source

删除修改成无日志物理删除,有日志逻辑删除

anderx 2 years ago
parent
commit
3a356fe56c

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

@@ -933,7 +933,7 @@
   <select id="ExpenseDetailsList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountDetailsList">
     select mea.check_no checkNo ,ead.`type`,ead.type_other typeOther,
            ead.amount ,ead.real_amount realAmount ,o.contract_no contractNo ,dep.name applyDepName,
-    a.type sonType ,a.type_other sonTypeOther ,
+    a.id sonId,a.type sonType ,a.type_other sonTypeOther ,
     dep2.name payDepName ,a.aname ,ad2.name financeName,a.status ,mea.process_status processStatus ,mea.id mainId,mea.target_type targetType,
     tm.buyer_name buyerName ,date_format(mea.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr
     from expense_account_details  ead left join expense_account a on ead.eaid =a.id

+ 9 - 0
src/main/java/com/goafanti/expenseAccount/bo/OutExpenseAccountDetailsList.java

@@ -14,6 +14,7 @@ public class OutExpenseAccountDetailsList {
     private Integer type;
     @Excel(name = "类型")
     private String  typeOther;
+    private Integer sonId;
     private Integer sonType;
     private String  sonTypeOther;
     /**
@@ -82,6 +83,14 @@ public class OutExpenseAccountDetailsList {
     private String createTimeStr;
     private Integer targetType;
 
+    public Integer getSonId() {
+        return sonId;
+    }
+
+    public void setSonId(Integer sonId) {
+        this.sonId = sonId;
+    }
+
     public String getTargetName() {
         return targetName;
     }

+ 9 - 5
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -298,12 +298,16 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
             if (expenseAccount.getStatus()!=0&&expenseAccount.getStatus()!=3){
                 throw new BusinessException("该费用单状态无法删除");
             }
-            ExpenseAccount update =new ExpenseAccount();
-            update.setId(id);
-            update.setStatus(4);
-            expenseAccountMapper.updateByPrimaryKeySelective(update);
+            List<OutExpenseAccountLog> logs = expenseAccountLogMapper.selectByEaid(id);
+            if (logs.isEmpty()){
+                expenseAccountMapper.deleteByPrimaryKey(id);
+            }else {
+                ExpenseAccount update =new ExpenseAccount();
+                update.setId(id);
+                update.setStatus(4);
+                expenseAccountMapper.updateByPrimaryKeySelective(update);
+            }
         }
-
         return 1;
     }