Sfoglia il codice sorgente

修复文件路径找不到报错

y 2 anni fa
parent
commit
63f1990a87

+ 17 - 2
src/main/java/com/ydtech/modules/inv/controller/InvAccountIncoiceController.java

@@ -11,9 +11,11 @@ import com.ydtech.modules.inv.model.InvAccountIncoice;
 import com.ydtech.modules.inv.model.InvAccountIncoiceResult;
 import com.ydtech.modules.inv.model.vo.InvAccountIncoiceQueryVo;
 import com.ydtech.modules.inv.service.InvAccountIncoiceService;
+import com.ydtech.modules.inv.service.InvAccountOpService;
 import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -39,6 +41,8 @@ public class InvAccountIncoiceController {
      */
     @Resource
     private InvAccountIncoiceService invAccountIncoiceService;
+    @Autowired
+    private InvAccountOpService invAccountOpService;
 
 
     @PostMapping("excel")
@@ -145,14 +149,25 @@ public class InvAccountIncoiceController {
             entAmount = entAmount.add(new BigDecimal(entry.getValue().toString()));
         }
         if (!String.valueOf(outAmount).equals("100")){
-            throw new SystemException("金额未完全分配");
+            throw new SystemException("支出金额未完全分配");
         }
         if (!String.valueOf(entAmount).equals("100")){
-            throw new SystemException("金额未完全分配");
+            throw new SystemException("收入金额未完全分配");
         }
         return this.invAccountIncoiceService.updateInvAccountIncoice(invAccountIncoice);
     }
 
+    @PostMapping("updateIncoice")
+    @ApiOperation("修改发票信息")
+    public HttpResult updateIncoice(@RequestBody InvAccountIncoice invAccountIncoice) {
+        if (!invAccountIncoice.getPayoutMoney().equals("0") && !invAccountIncoice.getNotPayoutMoney().equals(invAccountIncoice.getInvoiceMoney())){
+            throw new SystemException("已进账 如需修改请撤销");
+        }
+
+        return HttpResult.ok(invAccountIncoiceService.updateById(invAccountIncoice));
+    }
+
+
 
     /**
      * 撤销

+ 2 - 2
src/main/java/com/ydtech/modules/inv/controller/InvAccountOperateController.java

@@ -62,10 +62,10 @@ public class InvAccountOperateController {
             entAmount = entAmount.add(new BigDecimal(String.valueOf(entry.getValue())));
         }
         if (!String.valueOf(outAmount).equals("100")){
-            throw new SystemException("金额未完全分配");
+            throw new SystemException("支出金额未完全分配");
         }
         if (!String.valueOf(entAmount).equals("100")){
-            throw new SystemException("金额未完全分配");
+            throw new SystemException("收入金额未完全分配");
         }
         return invAccountOperateService.insert(accountOperate);
     }

+ 2 - 2
src/main/java/com/ydtech/modules/inv/controller/invAccountExcelController.java

@@ -57,10 +57,10 @@ public class invAccountExcelController {
             entAmount = entAmount.add(new BigDecimal(entry.getValue().toString()));
         }
         if (String.valueOf(outAmount).equals("1000")){
-            throw new SystemException("金额未完全分配");
+            throw new SystemException("支出金额未完全分配");
         }
         if (String.valueOf(entAmount).equals("1000")){
-            throw new SystemException("金额未完全分配");
+            throw new SystemException("收入金额未完全分配");
         }
 
 

+ 2 - 0
src/main/java/com/ydtech/modules/inv/model/InvAccountOp.java

@@ -29,6 +29,8 @@ public class InvAccountOp extends Model<InvAccountOp> {
     private String profit;
     //金额
     private String money;
+    //发票序号
+    private String invoiceId;
 
 }
 

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

@@ -11,6 +11,7 @@ import com.google.gson.JsonObject;
 import com.ydtech.constants.enums.inv.InvPayMethodEnum;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.inv.dao.InvAccountExcelMapper;
 import com.ydtech.modules.inv.model.InvAccount;
@@ -26,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -57,8 +59,19 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
     public HttpResult excelAccount(List<String> idList) {
         List<InvAccountExcel> insAccountExcels = insAccountExcelMapper.selectBatchIds(idList);
         if (!insAccountExcels.isEmpty()) {
-            return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels));
+            File folder = new File(uploadFilePath);
+            if (folder.exists()){
+                return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels));
+            }else {
+                if (folder.mkdirs()){
+                    return HttpResult.ok("", easyExcelUtils.downAccountExcel(uploadFilePath, insAccountExcels));
+                }else {
+                    throw new SystemException("文件导出失败");
+                }
+            }
         }
+
+
         return HttpResult.error("导出失败");
     }
 

+ 20 - 1
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountIncoiceServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
+import java.io.File;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
@@ -130,6 +131,7 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
             invAccountOp.setCardName(entCard.getBankName());
             invAccountOp.setProfit(entry.getKey());
             invAccountOp.setMoney(entry.getValue().toString());
+            invAccountOp.setInvoiceId(invAccountIncoice1.getInvoiceId());
             list.add(invAccountOp);
         }
 
@@ -170,6 +172,7 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
             invAccountOp.setCardName(outCard.getBankName());
             invAccountOp.setProfit(entry.getKey());
             invAccountOp.setMoney(entry.getValue().toString());
+            invAccountOp.setInvoiceId(invAccountIncoice1.getInvoiceId());
             list.add(invAccountOp);
         }
 
@@ -251,11 +254,17 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
 
         lambdaQuery1.eq(InvAccountOperate::getInvoiceId, invAccountIncoice.getInvoiceId());
 
+        LambdaQueryWrapper<InvAccountOp> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+
+        lambdaQueryWrapper.eq(InvAccountOp::getInvoiceId, invAccountIncoice.getInvoiceId());
+
+
         try {
             invAccountIncoiceMapper.updateById(invAccountIncoice);
             invAccountCardService.updateBatchById(invAccount);
             invAccountOperateService.remove(lambdaQuery);
             invAccountOperateService.remove(lambdaQuery1);
+            invAccountOpService.remove(lambdaQueryWrapper);
         } catch (Exception e) {
             return HttpResult.error("撤销失败");
         }
@@ -296,7 +305,17 @@ public class InvAccountIncoiceServiceImpl extends ServiceImpl<InvAccountIncoiceM
                 invAccountIncoice.setRate(invAccountIncoice.getRate() + "%");
             }
         });
-        return EasyExcelUtils.downExcel(uploadFilePath, InvAccountIncoice.class, invAccountIncoices);
+        File folder = new File(uploadFilePath);
+        if (folder.exists()){
+            return EasyExcelUtils.downExcel(uploadFilePath, InvAccountIncoice.class, invAccountIncoices);
+        }else {
+            if (folder.mkdirs()){
+                return EasyExcelUtils.downExcel(uploadFilePath, InvAccountIncoice.class, invAccountIncoices);
+            }else {
+                throw new SystemException("文件导出失败");
+            }
+
+        }
     }
 
 }

+ 13 - 1
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountOperateServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.constants.enums.inv.InvPayMethodEnum;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.inv.model.*;
 import com.ydtech.modules.inv.service.*;
 import com.ydtech.modules.inv.dao.InvAccountOperateMapper;
@@ -15,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
@@ -143,8 +145,18 @@ public class InvAccountOperateServiceImpl extends ServiceImpl<InvAccountOperateM
                 record.setPlate(buffer.toString());
             }
         }
+        File folder = new File(uploadFilePath);
+        if (folder.exists()){
+            return HttpResult.ok("", EasyExcelUtils.downExcel(uploadFilePath, InvAccountOperate.class, invAccountOperates));
+        }else {
+            if (folder.mkdirs()){
+                return HttpResult.ok("", EasyExcelUtils.downExcel(uploadFilePath, InvAccountOperate.class, invAccountOperates));
+            }else {
+                throw new SystemException("文件导出失败");
+            }
+
+        }
 
-        return HttpResult.ok("", EasyExcelUtils.downExcel(uploadFilePath, InvAccountOperate.class, invAccountOperates));
     }
 
 }

+ 13 - 2
src/main/java/com/ydtech/modules/inv/service/impl/InvAccountServiceImpl.java

@@ -5,6 +5,7 @@ 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;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.inv.dao.InvAccountMapper;
 import com.ydtech.modules.inv.dao.InvAccountOperateMapper;
 import com.ydtech.modules.inv.model.*;
@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -161,8 +163,17 @@ public class InvAccountServiceImpl extends ServiceImpl<InvAccountMapper, InvAcco
         List<InvAccount> insAccounts = insAccountMapper.selectAccountsList(invAccountQueryVo);
         List<InvAccountProfit> invAccountProfitList = invAccountProfitService.list();
         List<InvAccountOp> list = invAccountOpService.list();
-        String s = EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list);
-        return HttpResult.ok("",s);
+
+        File folder = new File(uploadFilePath);
+        if (folder.exists()){
+            return HttpResult.ok( EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list));
+        }else {
+            if (folder.mkdirs()){
+                return HttpResult.ok( EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list));
+            }else {
+                throw new SystemException("文件导出失败");
+            }
+        }
     }
 
 }

+ 0 - 0
src/main/resources/mapper/modules/InvAccountOpDao.xml → src/main/resources/mapper/modules/inv/InvAccountOpDao.xml