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

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

@@ -3,6 +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 org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -26,6 +27,6 @@ public interface ExpenseAccountMapper {
 
     List<OutExpenseAccount> selectByaidAndType(@Param("aid") String aid,@Param("depId")String depId, @Param("type")Integer type);
 
-    List<OutExpenseAccount> selectStatistics(@Param("name") String name, @Param("depId") String depId,
-                                             @Param("startTime") String startTime, @Param("endTime") String endTime);
+    List<OutExpenseAccountStatistics> selectStatistics(@Param("name") String name, @Param("depId") String depId,
+                                                       @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

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

@@ -426,10 +426,11 @@
       WHERE a.status=2
       and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
     </select>
-  <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
-    SELECT
-    <include refid="selectDtailsSql"/>
-    FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
+  <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)bxAmout,if(a.`type`=4 ,a.total_amount ,0)jzAmount,if(a.`type`=5,a.total_amount,0)dkAmount,
+    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 t_order_mid tm on a.order_no =tm.order_no left join admin ad on a.aid=ad.id
     where a.status=2

+ 195 - 0
src/main/java/com/goafanti/expenseAccount/bo/OutExpenseAccountStatistics.java

@@ -1,4 +1,199 @@
 package com.goafanti.expenseAccount.bo;
 
+import java.math.BigDecimal;
+
 public class OutExpenseAccountStatistics {
+    private String aid;
+    private String aname;
+    /**
+     * 报销
+     */
+    private Integer bx;
+    /**
+     * 借支
+     */
+    private Integer jz;
+    /**
+     * 抵扣
+     */
+    private Integer dk;
+
+    /**
+     * 抵扣编号
+     */
+    private Integer debitId;
+    /**
+     * 目标类型 0=固定费用,1=报销订单
+     */
+    private Integer targetType;
+    /**
+     * 报销金额
+     */
+    private BigDecimal bxAmout;
+    /**
+     * 借支金额
+     */
+    private BigDecimal jzAmount;
+    /**
+     * 抵扣金额
+     */
+    private BigDecimal dkAmount;
+
+    private BigDecimal TotalAmount;
+    /**
+     * 未审核数
+     */
+    private Integer wshs;
+    /**
+     * 驳回数
+     */
+    private Integer bhs;
+    /**
+     * 固定费用金额
+     */
+    private BigDecimal gdfyAmount;
+    /**
+     * 报销订单金额
+     */
+    private BigDecimal bxddAmount;
+
+
+    public OutExpenseAccountStatistics() {
+    }
+
+    public OutExpenseAccountStatistics(String aid) {
+        this.aid = aid;
+        this.bx=0;
+        this.jz=0;
+        this.dk=0;
+        this.bxAmout=new BigDecimal(0);
+        this.jzAmount=new BigDecimal(0);
+        this.dkAmount=new BigDecimal(0);
+        this.TotalAmount=new BigDecimal(0);
+        this.gdfyAmount=new BigDecimal(0);
+        this.bxddAmount=new BigDecimal(0);
+        this.wshs=0;
+        this.bhs=0;
+
+    }
+
+    public String getAname() {
+        return aname;
+    }
+
+    public void setAname(String aname) {
+        this.aname = aname;
+    }
+
+    public BigDecimal getTotalAmount() {
+        return TotalAmount;
+    }
+
+    public void setTotalAmount(BigDecimal totalAmount) {
+        TotalAmount = totalAmount;
+    }
+
+    public BigDecimal getGdfyAmount() {
+        return gdfyAmount;
+    }
+
+    public void setGdfyAmount(BigDecimal gdfyAmount) {
+        this.gdfyAmount = gdfyAmount;
+    }
+
+    public BigDecimal getBxddAmount() {
+        return bxddAmount;
+    }
+
+    public void setBxddAmount(BigDecimal bxddAmount) {
+        this.bxddAmount = bxddAmount;
+    }
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public Integer getBx() {
+        return bx;
+    }
+
+    public void setBx(Integer bx) {
+        this.bx = bx;
+    }
+
+    public Integer getJz() {
+        return jz;
+    }
+
+    public void setJz(Integer jz) {
+        this.jz = jz;
+    }
+
+    public Integer getDk() {
+        return dk;
+    }
+
+    public void setDk(Integer dk) {
+        this.dk = dk;
+    }
+
+    public Integer getDebitId() {
+        return debitId;
+    }
+
+    public void setDebitId(Integer debitId) {
+        this.debitId = debitId;
+    }
+
+    public Integer getTargetType() {
+        return targetType;
+    }
+
+    public void setTargetType(Integer targetType) {
+        this.targetType = targetType;
+    }
+
+    public BigDecimal getBxAmout() {
+        return bxAmout;
+    }
+
+    public void setBxAmout(BigDecimal bxAmout) {
+        this.bxAmout = bxAmout;
+    }
+
+    public BigDecimal getJzAmount() {
+        return jzAmount;
+    }
+
+    public void setJzAmount(BigDecimal jzAmount) {
+        this.jzAmount = jzAmount;
+    }
+
+    public BigDecimal getDkAmount() {
+        return dkAmount;
+    }
+
+    public void setDkAmount(BigDecimal dkAmount) {
+        this.dkAmount = dkAmount;
+    }
+
+    public Integer getWshs() {
+        return wshs;
+    }
+
+    public void setWshs(Integer wshs) {
+        this.wshs = wshs;
+    }
+
+    public Integer getBhs() {
+        return bhs;
+    }
+
+    public void setBhs(Integer bhs) {
+        this.bhs = bhs;
+    }
 }

+ 51 - 3
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -373,11 +373,59 @@ 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<OutExpenseAccount> list = expenseAccountMapper.selectStatistics(name, depId, startTime, endTime);
+        List<OutExpenseAccountStatistics> list = expenseAccountMapper.selectStatistics(name, depId, startTime, endTime);
         List<OutExpenseAccountStatistics> results=new ArrayList<>();
-        for (OutExpenseAccount e : list) {
+        Map<String ,Object> map=new HashMap<>();
+        for (OutExpenseAccountStatistics e : list) {
+
+            //如果是报销有选择抵扣预借支则算入抵扣
+            if (e.getBx()==1){
+                if (e.getDebitId()!=null){
+                    e.setDk(1);
+                    e.setDkAmount(e.getBxAmout());
+                }
+                if (e.getTargetType()==0){
+                    e.setGdfyAmount(e.getBxAmout());
+                }else if (e.getTargetType()==1){
+                    e.setBxddAmount(e.getBxAmout());
+                }
+            }
+            //如果不存在就新增
+            if (!map.keySet().contains(e.getAid())){
+                List<OutExpenseAccountStatistics> list2=new ArrayList<>();
+                list2.add(e);
+                map.put(e.getAid(),list2);
+            }else {
+                List<OutExpenseAccountStatistics> list2 = (List<OutExpenseAccountStatistics>) map.get(e.getAid());
+                list2.add(e);
+            }
+        }
+
+        for (String s : map.keySet()) {
+            List<OutExpenseAccountStatistics> list3 = (List<OutExpenseAccountStatistics>) map.get(s);
+            if (!list3.isEmpty()){
+                OutExpenseAccountStatistics out =new OutExpenseAccountStatistics(s);
+
+                for (OutExpenseAccountStatistics e : list3) {
+                    if (out.getAname()==null)out.setAname(e.getAname());
+                    if (e.getBx()!=null)out.setBx(out.getBx()+e.getBx());
+                    if (e.getJz()!=null)out.setJz(out.getJz()+e.getJz());
+                    if (e.getDk()!=null)out.setDk(out.getDk()+e.getDk());
+                    if (e.getBxAmout()!=null)out.setBxAmout(out.getBxAmout().add(e.getBxAmout()));
+                    if (e.getJzAmount()!=null)out.setJzAmount(out.getJzAmount().add(e.getJzAmount()));
+                    if (e.getDkAmount()!=null)out.setDkAmount(out.getDkAmount().add(e.getDkAmount()));
+                    if (e.getGdfyAmount()!=null)out.setGdfyAmount(out.getGdfyAmount().add(e.getGdfyAmount()));
+                    if (e.getBxddAmount()!=null)out.setBxddAmount(out.getBxddAmount().add(e.getBxddAmount()));
+                    if (e.getWshs()!=null)out.setWshs(out.getWshs()+e.getWshs());
+                    if (e.getBhs()!=null)out.setBhs(out.getBhs()+e.getBhs());
+                }
+                BigDecimal totalAmount=new BigDecimal(0);
+                totalAmount=totalAmount.add(out.getBxAmout()).add(out.getJzAmount()).subtract(out.getDkAmount());
+                out.setTotalAmount(totalAmount);
+                results.add(out);
+            }
 
         }
-        return null;
+        return results;
     }
 }