Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/test' into test

wks 2 rokov pred
rodič
commit
aa949076ba

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+/.idea/
+/src/main/resources/application-dev.yml
+/target/
+/src/test/
+
+/src/main/resources/application-pre.yml
+/..gitignore

+ 3 - 0
src/main/java/com/ydtech/modules/inv/model/InvAccountOpDto.java

@@ -13,4 +13,7 @@ import java.util.Map;
 public class InvAccountOpDto {
     private List<Map<String, String>> head;
     private List<Map<String, String>> maps;
+    private int pageNo;
+    private int pageSize;
+    private int total;
 }

+ 3 - 3
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountExcelServiceImpl.java

@@ -151,11 +151,11 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
             if (!insAccountOperateService.saveBatch(list)) {
                 throw new RuntimeException("添加转账信息失败");
             }
-
             JSONObject outProfit = invAccountExcel.getOutProfit();
             JSONObject entProfit = invAccountExcel.getEntProfit();
-            outJsonUtil(invAccountExcel, outProfit, outAccount, outAccountCard,list.get(0).getAccountOperateId());
-            entJsonUtil(invAccountExcel, entProfit, enterAccount, enterAccountCard, list.get(1).getAccountOperateId());
+
+            outJsonUtil(invAccountExcel, outProfit, outAccount, outAccountCard,invAccountOperate.getAccountOperateId());
+            entJsonUtil(invAccountExcel, entProfit, enterAccount, enterAccountCard, invAccountOperate1.getAccountOperateId());
 
         } else {
             //内转外部转账

+ 12 - 1
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountServiceImpl.java

@@ -2,6 +2,7 @@ package com.ydtech.modules.inv.service.impl;
 
 import com.alibaba.excel.util.ListUtils;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
@@ -275,14 +276,24 @@ public class InvAccountServiceImpl extends ServiceImpl<InvAccountMapper, InvAcco
     @Override
     public HttpResult look(InvAccountQueryVo invAccountQueryVo) {
         List<InvAccount> insAccounts = insAccountMapper.selectAccountsList(invAccountQueryVo);
+
+
+
         List<InvAccountProfit> invAccountProfitList = invAccountProfitService.list();
         List<InvAccountOp> list = invAccountOpService.list();
 
         List<Map<String, String>> head = head(invAccountProfitList);
         List<Map<String, String>> maps = dataList(insAccounts, list, invAccountProfitList);
+
+        List<Map<String, String>> subList = maps.stream().skip((invAccountQueryVo.getPageNo()-1)*invAccountQueryVo.getPageSize()).limit(invAccountQueryVo.getPageSize()).
+                collect(Collectors.toList());
+
         InvAccountOpDto invAccountOpDto = new InvAccountOpDto();
         invAccountOpDto.setHead(head);
-        invAccountOpDto.setMaps(maps);
+        invAccountOpDto.setMaps(subList);
+        invAccountOpDto.setTotal(maps.size());
+        invAccountOpDto.setPageSize(invAccountQueryVo.getPageSize());
+        invAccountOpDto.setPageNo(invAccountQueryVo.getPageNo());
         return HttpResult.ok("",invAccountOpDto);
     }
 

+ 30 - 1
src/main/java/com/ydtech/modules/inv/utils/EasyExcelUtils.java

@@ -14,7 +14,9 @@ import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
@@ -230,12 +232,22 @@ public class EasyExcelUtils {
      */
     @SneakyThrows
     public String downAccountExcel(String uploadFilePath, List<InvAccountExcel> invAccountExcel, List<InvAccountProfit> invAccountProfit) {
+
         // 加载模板
         InputStream inputStream = getClass().getResourceAsStream("/template/资金申请单模板.xlsx");
 
+        byte[] bytes = saveaIns(inputStream);
+
+        if (inputStream != null) {
+            inputStream.close();
+        }
+
+
+
         List<InvAccountExcel> list = new ArrayList<>();
         // 获取工作表并填充
         for (InvAccountExcel excel : invAccountExcel) {
+            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
             // 写入文件
             Date date = new Date();
             String file = date.getTime() + ".xlsx";
@@ -275,13 +287,16 @@ public class EasyExcelUtils {
             excel.setPayMethod(a.toString());
             // 生成工作簿对象
             ExcelWriterBuilder workBookWriter = EasyExcel.write(fileName, InvAccountExcel.class)
-                    .withTemplate(inputStream);
+                    .withTemplate(byteArrayInputStream);
 
             workBookWriter.sheet().doFill(excel);
             excel.setUplodePath(file);
             excel.setPayMethod(payMethod);
             list.add(excel);
+            byteArrayInputStream.close();
+
         }
+
         insAccountExcelService.updateBatchById(list);
 
         File[] srcFiles = new File[list.size()];
@@ -296,4 +311,18 @@ public class EasyExcelUtils {
         return a;
     }
 
+
+    //保存流对象(输入流在第二次使用的时候会失效)
+    public byte[] saveaIns(InputStream ins){
+        byte[] buf = null;
+        try {
+            if(ins!=null){
+                buf = org.apache.commons.io.IOUtils.toByteArray(ins);//ins为InputStream流
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return buf;
+    }
+
 }

+ 4 - 13
src/main/java/com/ydtech/modules/inv/utils/TransferUtils.java

@@ -68,7 +68,7 @@ public class TransferUtils {
                 invAccountOp.setCardName(outAccountCard.getBankName());
                 invAccountOp.setProfit(entry.getKey());
                 invAccountOp.setAccountOperateId(operateId);
-                invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(applyAmount)).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).negate().toString());
+                invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(applyAmount)).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).toString());
                 list.add(invAccountOp);
             }
         }
@@ -80,20 +80,14 @@ public class TransferUtils {
      * 转账成功后添加支出账户操作信息
      */
     public static InvAccountOperate insertOutAccountOperate(InvAccountExcel insAccountExcel) {
-        JSONObject outProfit1 = insAccountExcel.getOutProfit();
         //支出公司
         InvAccountOperate insAccountOperate = new InvAccountOperate();
         InvAccountOperate operate = operate(insAccountExcel, insAccountOperate);
         operate.setRevenueOutlay("1");
-        JSONObject outProfit = insAccountExcel.getOutProfit();
-        for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
-            outProfit.put(entry.getKey(), new BigDecimal(String.valueOf(entry.getValue())).negate().toString());
-        }
-        operate.setOutProfit(outProfit);
+        operate.setOutProfit(insAccountExcel.getOutProfit());
         operate.setCreateTime(LocalDateTime.now());
         operate.setRemark(insAccountExcel.getRemark());
         operate.setOutCardNum(insAccountExcel.getOutCardNum());
-        insAccountExcel.setOutProfit(outProfit1);
         return operate;
     }
 
@@ -227,11 +221,8 @@ public class TransferUtils {
         for (Map.Entry<String, Object> entry : entProfit.entrySet()) {
             entAmount = entAmount.add(new BigDecimal(entry.getValue().toString()));
         }
-        if (!String.valueOf(outAmount).equals("100")) {
-            throw new SystemException("支出金额未完全分配");
-        }
-        if (!String.valueOf(entAmount).equals("100")) {
-            throw new SystemException("收入金额未完全分配");
+        if (!(new BigDecimal(String.valueOf(entAmount)).add(new BigDecimal(String.valueOf(outAmount)))).toString().equals("0")) {
+            throw new SystemException("金额未完全分配");
         }
         return true;
     }