Browse Source

统计列表修改

anderx 2 years ago
parent
commit
bdf95626bc

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

@@ -3,7 +3,7 @@ package com.goafanti.common.dao;
 import com.goafanti.common.model.ExpenseAccount;
 import com.goafanti.expenseAccount.bo.InputExpenseAccount;
 import com.goafanti.expenseAccount.bo.OutExpenseAccount;
-import com.goafanti.expenseAccount.bo.OutExpenseAccountStatistics;
+import com.goafanti.expenseAccount.bo.OutMyEAStatistics;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -27,8 +27,8 @@ public interface ExpenseAccountMapper {
 
     List<OutExpenseAccount> selectByaidAndType(@Param("aid") String aid,@Param("depId")String depId, @Param("type")Integer type);
 
-    List<OutExpenseAccountStatistics> selectStatistics(@Param("name") String name, @Param("depId") String depId,
-                                                       @Param("startTime") String startTime, @Param("endTime") String endTime);
+    List<OutMyEAStatistics> selectStatistics(@Param("aid") String aid, @Param("depId") String depId,
+                                             @Param("startTime") String startTime, @Param("endTime") String endTime);
 
     List<ExpenseAccount> selectByDebitId(Integer debitId);
 

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

@@ -472,17 +472,13 @@
       and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
         order by a.create_time desc
     </select>
-  <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountStatistics">
-    select a.aid,a.aname ,if(a.`type` &lt;4 ,1,0)bx,if(a.`type`=4 ,1,0)jz,if(a.`type`=5 ,1,0)dk,a.debit_id debitId ,a.target_type targetType ,
-    if(a.`type`&lt; 4 ,a.total_amount ,0)bxAmount,if(a.`type`=4 ,a.total_amount ,0)jzAmount,if(a.`type`=5,a.total_amount,0)dkAmount,
-    ifnull(a2.total_amount,0) bxdkAmount,if(a.status&lt; 2,1,0)wshs,if(a.status=3,1,0)bhs
-    from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
-    left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
-    left join expense_account a2 on a.debit_id =a2.id
-    left join t_order_mid tm on a.order_no =tm.order_no left join admin ad on a.aid=ad.id
+  <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutMyEAStatistics">
+    select a.aid,a.aname ,a.type,a.status ,a.total_amount totalAmount ,ifnull(a.debit_id,0) debitId ,a.target_type targetType ,ifnull(a2.total_amount,0) bxdkAmount
+    from expense_account a
+    left join expense_account a2 on a.debit_id =a2.id left join admin ad on a.aid=ad.id
     where 1=1
-    <if test="name != null">
-      and ad.name like concat('%',#{name},'%')
+    <if test="aid != null">
+      and a.aid like concat('%',#{aid},'%')
     </if>
     <if test="depId != null">
       and ad.department_id = #{depId}

+ 78 - 0
src/main/java/com/goafanti/expenseAccount/bo/OutMyEAStatistics.java

@@ -0,0 +1,78 @@
+package com.goafanti.expenseAccount.bo;
+
+import java.math.BigDecimal;
+
+public class OutMyEAStatistics {
+    private String aid;
+    private String aname;
+    private Integer status;
+    private Integer type;
+    private BigDecimal totalAmount;
+    private String debitId;
+    private Integer targetType;
+    private BigDecimal bxdkAmount;
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public String getAname() {
+        return aname;
+    }
+
+    public void setAname(String aname) {
+        this.aname = aname;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public BigDecimal getTotalAmount() {
+        return totalAmount;
+    }
+
+    public void setTotalAmount(BigDecimal totalAmount) {
+        this.totalAmount = totalAmount;
+    }
+
+    public String getDebitId() {
+        return debitId;
+    }
+
+    public void setDebitId(String debitId) {
+        this.debitId = debitId;
+    }
+
+    public Integer getTargetType() {
+        return targetType;
+    }
+
+    public void setTargetType(Integer targetType) {
+        this.targetType = targetType;
+    }
+
+    public BigDecimal getBxdkAmount() {
+        return bxdkAmount;
+    }
+
+    public void setBxdkAmount(BigDecimal bxdkAmount) {
+        this.bxdkAmount = bxdkAmount;
+    }
+}

+ 32 - 16
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -588,31 +588,47 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
     @Override
     public Object statistics(String name,String depId,String startTime,String endTime) {
         if (endTime!=null)endTime=endTime+" 23:59:59";
-        List<OutExpenseAccountStatistics> list = expenseAccountMapper.selectStatistics(name, depId, startTime, endTime);
+        List<OutMyEAStatistics> list = expenseAccountMapper.selectStatistics(name, depId, startTime, endTime);
         List<OutExpenseAccountStatistics> results=new ArrayList<>();
         Map<String ,Object> map=new HashMap<>();
-        for (OutExpenseAccountStatistics e : list) {
+        for (OutMyEAStatistics e : list) {
+            OutExpenseAccountStatistics out = new OutExpenseAccountStatistics(e.getAid());
+            out.setAname(e.getAname());
+            if (e.getStatus() == 2) {
+                if (e.getType() < 4) {
+                    out.setBx(1);
+                    out.setBxAmount(e.getTotalAmount());
+                    if (!e.getDebitId().equals(0)) {
+                        out.setDk(1);
+                        out.setDkAmount(e.getBxdkAmount());
+                    }
+                } else if (e.getType() == 4) {
+                    out.setJz(1);
+                    out.setJzAmount(e.getTotalAmount());
+                } else if (e.getType() == 5) {
+                    out.setDk(1);
+                    out.setDkAmount(e.getTotalAmount());
+                }
 
-            //如果是报销有选择抵扣预借支则算入抵扣
-            if (e.getBx()==1){
-                if (e.getDebitId()!=null){
-                    e.setDk(1);
-                    e.setDkAmount(e.getBxdkAmount());
+                if (e.getTargetType() == 0) {
+                    out.setGdfyAmount(e.getTotalAmount());
+                } else if (e.getTargetType() == 1) {
+                    out.setBxddAmount(e.getTotalAmount());
                 }
-            }
-            if (e.getTargetType()==0){
-                e.setGdfyAmount(e.getBxAmount().add(e.getJzAmount()));
-            }else if (e.getTargetType()==1){
-                e.setBxddAmount(e.getBxAmount().add(e.getJzAmount()));
+
+            } else if (e.getStatus() < 2) {
+                out.setWshs(1);
+            } else if (e.getStatus() == 3) {
+                out.setBhs(1);
             }
             //如果不存在就新增
-            if (!map.keySet().contains(e.getAid())){
+            if (!map.keySet().contains(out.getAid())){
                 List<OutExpenseAccountStatistics> list2=new ArrayList<>();
-                list2.add(e);
-                map.put(e.getAid(),list2);
+                list2.add(out);
+                map.put(out.getAid(),list2);
             }else {
                 List<OutExpenseAccountStatistics> list2 = (List<OutExpenseAccountStatistics>) map.get(e.getAid());
-                list2.add(e);
+                list2.add(out);
             }
         }
         for (String s : map.keySet()) {