소스 검색

2022年11月29日16:31:19

纪新园 2 년 전
부모
커밋
a2553aae44

+ 4 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/ProfitController.java

@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.finance.domain.TWareHouseFees;
 import com.ruoyi.finance.domain.dto.FeeDTO;
 import com.ruoyi.finance.domain.excel.GeneralLedgerDetailExcel;
+import com.ruoyi.finance.domain.excel.GeneralLedgerDetailTotalExcel;
 import com.ruoyi.finance.domain.excel.ProfitGeneralLedgerExcel;
 import com.ruoyi.finance.service.ITFeeService;
 import com.ruoyi.reportManagement.excel.Profit;
@@ -81,9 +82,9 @@ public class ProfitController extends BaseController {
     @DataScope(deptAlias = "d", userAlias = "u")
     @GetMapping("/export/detail")
     public AjaxResult exportDetail(FeeDTO feeDTO) throws Exception {
-        List<GeneralLedgerDetailExcel> list = tFeeService.financialLedgerDetailsExport(feeDTO);
-        ExcelUtil<GeneralLedgerDetailExcel> util = new ExcelUtil<GeneralLedgerDetailExcel>(GeneralLedgerDetailExcel.class);
-        return util.exportExcel(list, "应收总账明细");
+        List<GeneralLedgerDetailTotalExcel> list = tFeeService.financialLedgerDetailsTotalExport(feeDTO);
+        ExcelUtil<GeneralLedgerDetailTotalExcel> util = new ExcelUtil<>(GeneralLedgerDetailTotalExcel.class);
+        return util.exportExcel(list, "利润总账明细");
     }
 
 }

+ 48 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/domain/excel/GeneralLedgerDetailTotalExcel.java

@@ -0,0 +1,48 @@
+package com.ruoyi.finance.domain.excel;
+
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class GeneralLedgerDetailTotalExcel implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Excel(name = "客户")
+    private String fFeesName;
+
+    @Excel(name = "费用类别")
+    private String fBilltype;
+
+    @Excel(name = "重量(净吨)")
+    private BigDecimal receivableFQty;
+
+    @Excel(name = "天数")
+    private int fBillingDays;
+
+    @Excel(name = "单价")
+    private BigDecimal receivablePrice;
+
+    @Excel(name = "应收金额")
+    private BigDecimal receivableAmount;
+
+    @Excel(name = "成本项目")
+    private String fBilltypeC;
+
+    @Excel(name = "重量(净吨)")
+    private BigDecimal copeWithFQty;
+
+    @Excel(name = "单价")
+    private BigDecimal copeWithPrice;
+
+    @Excel(name = "应付金额")
+    private BigDecimal copeWithAmount;
+
+    @Excel(name = "利润")
+    private BigDecimal nnfinished;
+
+
+
+}

+ 1 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/domain/vo/FeeVO.java

@@ -1,6 +1,7 @@
 package com.ruoyi.finance.domain.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.finance.domain.TFee;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;

+ 3 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/ITFeeService.java

@@ -6,6 +6,7 @@ import com.ruoyi.finance.domain.TFee;
 import com.ruoyi.finance.domain.TWareHouseFees;
 import com.ruoyi.finance.domain.dto.FeeDTO;
 import com.ruoyi.finance.domain.excel.GeneralLedgerDetailExcel;
+import com.ruoyi.finance.domain.excel.GeneralLedgerDetailTotalExcel;
 import com.ruoyi.finance.domain.excel.GeneralLedgerExcel;
 import com.ruoyi.finance.domain.excel.ProfitGeneralLedgerExcel;
 import com.ruoyi.finance.domain.vo.FeeVO;
@@ -354,4 +355,6 @@ public interface ITFeeService {
     List<GeneralLedgerDetailExcel> financialLedgerDetailsExport(FeeDTO feeDTO);
 
     AjaxResult financialLedgerDetailsTotal(FeeDTO feeDTO);
+
+    List<GeneralLedgerDetailTotalExcel> financialLedgerDetailsTotalExport(FeeDTO feeDTO);
 }

+ 121 - 13
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -25,6 +25,7 @@ import com.ruoyi.finance.domain.TFeeDo;
 import com.ruoyi.finance.domain.TWareHouseFees;
 import com.ruoyi.finance.domain.dto.FeeDTO;
 import com.ruoyi.finance.domain.excel.GeneralLedgerDetailExcel;
+import com.ruoyi.finance.domain.excel.GeneralLedgerDetailTotalExcel;
 import com.ruoyi.finance.domain.excel.GeneralLedgerExcel;
 import com.ruoyi.finance.domain.excel.ProfitGeneralLedgerExcel;
 import com.ruoyi.finance.domain.vo.FeeVO;
@@ -76,7 +77,6 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 import java.math.BigDecimal;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -767,14 +767,50 @@ public class TFeeServiceImpl implements ITFeeService {
         if (tWareHouseFees.getGroupBy() == 0) {
             return tFeeMapper.warehouseBillsFeesProfitList(tWareHouseFees);
         }
-        if (tWareHouseFees.getSwitchSection() == 1) {
+        if (tWareHouseFees.getSwitchSection() == 0) {
             tWareHouseFees.setTimeExamine(tWareHouseFees.getTimeExamine());
             tWareHouseFees.setfBstimeExamine(null);
         } else {
             tWareHouseFees.setfBstimeExamine(tWareHouseFees.getTimeExamine());
             tWareHouseFees.setTimeExamine(null);
         }
-        return tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
+        List<Map<String, Object>> mapList = tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
+        for (Map<String, Object> map : mapList) {
+            FeeDTO feeDTO = new FeeDTO();
+            feeDTO.setFToCorpid(Long.parseLong(map.get("fCorpid").toString()));
+            BigDecimal amount = new BigDecimal("0.00");
+            BigDecimal stlamount = new BigDecimal("0.00");
+//            if (tWareHouseFees.getSwitchSection() == 0) {
+                if (ObjectUtils.isNotNull(map.get("reviewDate"))) {
+                    List<String> list1 = new ArrayList<>();
+                    list1.add(map.get("reviewDate").toString());
+                    list1.add(map.get("reviewDate").toString());
+                    feeDTO.setFAuditList(list1);
+                }
+           /* } else {
+                if (ObjectUtils.isNotNull(map.get("f_bstime"))) {
+                    List<String> list1 = new ArrayList<>();
+                    list1.add(map.get("f_bstime").toString());
+                    list1.add(map.get("f_bstime").toString());
+                    feeDTO.setFBstimeExamine(list1);
+                }
+            }*/
+            List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
+            for (FeeVO feeVO : feeVOList) {
+                if ("D".equals(feeVO.getfDc())) {
+                    amount = amount.add(feeVO.getFAmount());
+                } else {
+                    stlamount = stlamount.add(feeVO.getFAmount());
+                }
+            }
+            map.put("fAmount", amount);
+            map.put("fStlamount", stlamount);
+            map.put("nnfinished", amount.subtract(stlamount));
+            /*list.get(i).setFAmount(amount);
+            list.get(i).setNnfinished(amount.subtract(stlamount));
+            list.get(i).setFStlamount(stlamount);*/
+        }
+        return mapList;
     }
 
     public static BigDecimal calculation1(String fTotalgross, String fGrossweightblc) {
@@ -2357,6 +2393,10 @@ public class TFeeServiceImpl implements ITFeeService {
     public AjaxResult financialLedgerDetailsTotal(FeeDTO feeDTO) {
         feeDTO.setFToCorpid(feeDTO.getFCorpId());
         feeDTO.setFCorpId(null);
+        if (ObjectUtils.isNotNull(feeDTO.getFBstimeExamine())){
+            feeDTO.setFAuditList(feeDTO.getFBstimeExamine());
+            feeDTO.setFBstimeExamine(null);
+        }
         List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
 
         feeDTO.setFDc("D");
@@ -2370,8 +2410,10 @@ public class TFeeServiceImpl implements ITFeeService {
             Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
             map.forEach((key, value) -> {
 
+                List<FeeVO> feeVODList = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
                 FeeVO feeVOD = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
 
+                List<FeeVO> feeVOCList = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
                 FeeVO feeVOC = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
 
                 FeeVO vo = new FeeVO();
@@ -2380,11 +2422,11 @@ public class TFeeServiceImpl implements ITFeeService {
                 BeanUtils.copyProperties(feeVO, vo);
                 BigDecimal D = new BigDecimal("0.00");
                 BigDecimal C = new BigDecimal("0.00");
-                if (ObjectUtils.isNotNull(feeVOD)){
-                    if(ObjectUtils.isNotNull(feeVOD.getFAmount())){
-                        D = feeVOD.getFAmount();
-                        vo.setReceivableAmount(feeVOD.getFAmount());
-                    }else{
+                if (ObjectUtils.isNotNull(feeVOD)) {
+                    if (ObjectUtils.isNotNull(feeVOD)) {
+                        D = feeVODList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+                        vo.setReceivableAmount(D);
+                    } else {
                         vo.setReceivableAmount(D);
                     }
                     vo.setReceivableFQty(feeVOD.getFQty());
@@ -2393,11 +2435,11 @@ public class TFeeServiceImpl implements ITFeeService {
                     vo.setfBilltype(storageType.getName());
                     vo.setFBillingDays(feeVOD.getFBillingDays());
                 }
-                if (ObjectUtils.isNotNull(feeVOC)){
-                    if(ObjectUtils.isNotNull(feeVOC.getFAmount())){
-                        C = feeVOC.getFAmount();
-                        vo.setCopeWithAmount(feeVOC.getFAmount());
-                    }else{
+                if (ObjectUtils.isNotNull(feeVOC)) {
+                    if (ObjectUtils.isNotNull(feeVOC.getFAmount())) {
+                        C = feeVOCList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);;
+                        vo.setCopeWithAmount(C);
+                    } else {
                         vo.setCopeWithAmount(C);
                     }
                     WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOC.getfBilltype(), "storageType");
@@ -2413,6 +2455,72 @@ public class TFeeServiceImpl implements ITFeeService {
         return AjaxResult.success(feeVOList);
     }
 
+    @Override
+    public List<GeneralLedgerDetailTotalExcel> financialLedgerDetailsTotalExport(FeeDTO feeDTO) {
+        List<GeneralLedgerDetailTotalExcel> list = new ArrayList<>();
+        feeDTO.setFToCorpid(feeDTO.getFCorpId());
+        feeDTO.setFCorpId(null);
+        if (ObjectUtils.isNotNull(feeDTO.getFBstimeExamine())){
+            feeDTO.setFAuditList(feeDTO.getFBstimeExamine());
+            feeDTO.setFBstimeExamine(null);
+        }
+        List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
+
+        feeDTO.setFDc("D");
+        List<FeeVO> feeVOListD = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
+
+        feeDTO.setFDc("C");
+        List<FeeVO> feeVOListC = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
+
+        if (CollectionUtils.isNotEmpty(feeVOList)) {
+            Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
+            map.forEach((key, value) -> {
+                GeneralLedgerDetailTotalExcel generalLedgerDetailTotalExcel = new GeneralLedgerDetailTotalExcel();
+                List<FeeVO> feeVODList = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
+                FeeVO feeVOD = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
+
+                List<FeeVO> feeVOCList = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
+                FeeVO feeVOC = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
+
+                FeeVO feeVO = value.stream().findFirst().orElseThrow(() ->
+                        new WarehouseException("获取费用异常"));
+                BeanUtils.copyProperties(feeVO, generalLedgerDetailTotalExcel);
+
+                BigDecimal D = new BigDecimal("0.00");
+                BigDecimal C = new BigDecimal("0.00");
+                if (ObjectUtils.isNotNull(feeVOD)) {
+                    if (ObjectUtils.isNotNull(feeVOD)) {
+                        D = feeVODList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+                        generalLedgerDetailTotalExcel.setReceivableAmount(D);
+                    } else {
+                        generalLedgerDetailTotalExcel.setReceivableAmount(D);
+                    }
+                    generalLedgerDetailTotalExcel.setReceivableFQty(feeVOD.getFQty());
+                    generalLedgerDetailTotalExcel.setReceivablePrice(feeVOD.getPrice());
+                    WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOD.getfBilltype(), "storageType");
+                    generalLedgerDetailTotalExcel.setFBilltype(storageType.getName());
+                    generalLedgerDetailTotalExcel.setFBillingDays(feeVOD.getFBillingDays());
+                }
+                if (ObjectUtils.isNotNull(feeVOC)) {
+                    if (ObjectUtils.isNotNull(feeVOC.getFAmount())) {
+                        C = feeVOCList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);;
+                        generalLedgerDetailTotalExcel.setCopeWithAmount(C);
+                    } else {
+                        generalLedgerDetailTotalExcel.setCopeWithAmount(C);
+                    }
+                    WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOC.getfBilltype(), "storageType");
+                    generalLedgerDetailTotalExcel.setFBilltypeC(storageType.getName());
+                    generalLedgerDetailTotalExcel.setCopeWithFQty(feeVOC.getFQty());
+                    generalLedgerDetailTotalExcel.setCopeWithPrice(feeVOC.getPrice());
+                }
+                generalLedgerDetailTotalExcel.setNnfinished(D.subtract(C));
+                list.add(generalLedgerDetailTotalExcel);
+            });
+            return list;
+        }
+        return list;
+    }
+
 
     @Override
     public List<ReceivableExcel> receivable(TWareHouseFees tWareHouseFees) {

+ 2 - 2
ruoyi-warehouse/src/main/resources/mapper/finance/TFeeMapper.xml

@@ -1997,7 +1997,7 @@
     </select>
 
     <select id="warehouseBillsFeesCustomProfitList" resultType="java.util.Map">
-        SELECT
+        SELECT distinct
             c.f_name AS fName,
                c.f_id AS fCorpid,
             DATE_FORMAT(w.f_review_date,'%Y-%m') AS reviewDate,
@@ -2889,7 +2889,7 @@
             w.f_amount, w.f_stlamount AS fStlamount,
             ifnull( w.f_amount, 0 ) - ifnull( w.f_stlamount, 0 ) AS nnfinished,
             t.f_bstime AS fBstime,
-            w.f_dc AS fDC,
+            w.f_dc,
             w.f_unitprice AS price,
                w.f_qty AS fQty,
                w.f_billing_days AS fBillingDays