ccjgmwz 4 years ago
parent
commit
f20721adef

+ 40 - 41
unimall-app-api/src/main/java/com/iotechn/unimall/app/api/contract/ContractAppServiceImpl.java

@@ -107,34 +107,28 @@ public class ContractAppServiceImpl implements ContractAppService {
             List<TaskDTO> taskDTOList = new ArrayList<>();
             List<TaskDTO> taskDTOList = new ArrayList<>();
             List<TaskDTO> taskDTOList1 = new ArrayList<>();
             List<TaskDTO> taskDTOList1 = new ArrayList<>();
             Double sumTotal = 0.00;
             Double sumTotal = 0.00;
+            Double sumTotalClose = 0.00;
             Float sumNet = 0f;
             Float sumNet = 0f;
             Double payMoney = 0.00;
             Double payMoney = 0.00;
             Float sumNetClose = 0f;
             Float sumNetClose = 0f;
+            Float payNotMoneyClose = 0f;
             Double payMoneyClose = 0.00;
             Double payMoneyClose = 0.00;
             // 采购交易
             // 采购交易
             if (tradeDO.getType() == 1) {
             if (tradeDO.getType() == 1) {
 
 
                 List<BuyReportDO> buyReportDOS = buyReportMapper.selectList(new EntityWrapper<BuyReportDO>().eq("contract_no", contractNo));
                 List<BuyReportDO> buyReportDOS = buyReportMapper.selectList(new EntityWrapper<BuyReportDO>().eq("contract_no", contractNo));
                 for(BuyReportDO buyReportDO : buyReportDOS){
                 for(BuyReportDO buyReportDO : buyReportDOS){
-                    if(buyReportDO.getBuy() > 0){
+                    if(buyReportDO.getBuy() == 0){
                         // 查询任务表
                         // 查询任务表
-                        List<TaskDO> taskDOList = taskMapper.selectList(new EntityWrapper<TaskDO>().eq("report_id", buyReportDO.getReportId()));
+                        List<TaskDO> taskDOList = taskMapper.selectList(new EntityWrapper<TaskDO>().eq("report_id", buyReportDO.getId()).eq("task_type", "入库任务").eq("task_status",TaskStatusType.STATUS2.getCode()));
                         if (CollectionUtils.isNotEmpty(taskDOList)) {
                         if (CollectionUtils.isNotEmpty(taskDOList)) {
                             for (TaskDO taskDO : taskDOList) {
                             for (TaskDO taskDO : taskDOList) {
                                 TaskDTO taskDTO = new TaskDTO();
                                 TaskDTO taskDTO = new TaskDTO();
-                                // 查询统计表
-                                BuyReportDO buyReportDO = buyReportMapper.selectById(taskDO.getReportId());
-                                if (buyReportDO != null) {
-                                    // 结算单价
-                                    Double sumTotalSingal = Double.valueOf(buyReportDO.getUnitPrice1() - taskDO.getDeduction()) * taskDO.getNetWeight();
-                                    sumTotal = sumTotal + sumTotalSingal;
-                                    taskDTO.setSumPrice(sumTotalSingal);
-                                    payMoney = payMoney + (buyReportDO.getMoney() - buyReportDO.getNotMoney());
-                                    if (buyReportDO.getBuy() != null && buyReportDO.getBuy() != 0) {
-
-                                    }
-                                }
-
+                                // 结算单价
+                                Double sumTotalSingal = Double.valueOf(buyReportDO.getUnitPrice1()) * taskDO.getNetWeight();
+                                sumTotal = sumTotal + sumTotalSingal;
+                                taskDTO.setSumPrice(sumTotalSingal);
+                                payMoney = payMoney + (buyReportDO.getMoney() - buyReportDO.getNotMoney());
                                 taskDTO.setCarNo(taskDO.getCarNo());
                                 taskDTO.setCarNo(taskDO.getCarNo());
                                 taskDTO.setNetWeight(taskDO.getNetWeight());
                                 taskDTO.setNetWeight(taskDO.getNetWeight());
                                 sumNet = sumNet + taskDO.getNetWeight();
                                 sumNet = sumNet + taskDO.getNetWeight();
@@ -148,40 +142,43 @@ public class ContractAppServiceImpl implements ContractAppService {
                         taskDTO1.setCloseTon(buyReportDO.getNetWeight());
                         taskDTO1.setCloseTon(buyReportDO.getNetWeight());
                         taskDTO1.setSumPriceClose(Double.valueOf(buyReportDO.getUnitPrice1() + buyReportDO.getBasis()) * buyReportDO.getBuy());
                         taskDTO1.setSumPriceClose(Double.valueOf(buyReportDO.getUnitPrice1() + buyReportDO.getBasis()) * buyReportDO.getBuy());
                         sumNetClose = sumNetClose + buyReportDO.getNetWeight();
                         sumNetClose = sumNetClose + buyReportDO.getNetWeight();
+                        sumTotalClose = sumTotalClose + taskDTO1.getSumPriceClose();
                         payMoneyClose = payMoneyClose + taskDTO1.getSumPriceClose();
                         payMoneyClose = payMoneyClose + taskDTO1.getSumPriceClose();
+                        payNotMoneyClose = payNotMoneyClose + (buyReportDO.getMoney() - buyReportDO.getNotMoney());
                         taskDTOList1.add(taskDTO1);
                         taskDTOList1.add(taskDTO1);
                     }
                     }
                 }
                 }
 
 
             } else {
             } else {
-                // 查询任务表
-                List<TaskDO> taskDOList = taskMapper.selectList(new EntityWrapper<TaskDO>().eq("order_no", tradeDO.getOrderNo()).eq("task_type", "出库任务").eq("task_status", TaskStatusType.STATUS2.getCode()));
-                if (CollectionUtils.isNotEmpty(taskDOList)) {
-                    for (TaskDO taskDO : taskDOList) {
-                        TaskDTO taskDTO = new TaskDTO();
-                        // 查询统计表
-                        SaleReportDO saleReportDO = saleReportMapper.selectById(taskDO.getReportId());
-                        if (saleReportDO != null) {
-                            // 结算单价
-                            Double sumTotalSingal = Double.valueOf(saleReportDO.getUnitPrice1()) * taskDO.getNetWeight();
-                            sumTotal = sumTotal + sumTotalSingal;
-                            taskDTO.setSumPrice(sumTotalSingal);
-                            payMoney = payMoney + (saleReportDO.getMoney());
-                            // 平仓
-                            if (saleReportDO.getBuy() != null && saleReportDO.getBuy() != 0) {
-                                TaskDTO taskDTO1 = new TaskDTO();
-                                taskDTO1.setCloseTon(saleReportDO.getNetWeight());
-                                taskDTO1.setSumPriceClose(Double.valueOf(saleReportDO.getUnitPrice1() + saleReportDO.getBasis()) * saleReportDO.getBuy());
-                                sumNetClose = sumNetClose + saleReportDO.getNetWeight();
-                                payMoneyClose = payMoneyClose + taskDTO1.getSumPriceClose();
-                                taskDTOList1.add(taskDTO1);
+
+                List<SaleReportDO> saleReportDOS = saleReportMapper.selectList(new EntityWrapper<SaleReportDO>().eq("contract_no", contractNo));
+                for(SaleReportDO saleReportDO:saleReportDOS){
+                    if(saleReportDO.getBuy() == 0){
+                        // 查询任务表
+                        List<TaskDO> taskDOList = taskMapper.selectList(new EntityWrapper<TaskDO>().eq("report_id", saleReportDO.getId()).eq("task_type", "出库任务").eq("task_status",TaskStatusType.STATUS2.getCode()));
+                        if (CollectionUtils.isNotEmpty(taskDOList)) {
+                            for (TaskDO taskDO : taskDOList) {
+                                TaskDTO taskDTO = new TaskDTO();
+                                // 结算单价
+                                Double sumTotalSingal = Double.valueOf(saleReportDO.getUnitPrice1()) * taskDO.getNetWeight();
+                                sumTotal = sumTotal + sumTotalSingal;
+                                taskDTO.setSumPrice(sumTotalSingal);
+                                payMoney = payMoney + (saleReportDO.getMoney());
+                                taskDTO.setCarNo(taskDO.getCarNo());
+                                taskDTO.setNetWeight(taskDO.getNetWeight());
+                                sumNet = sumNet + taskDO.getNetWeight();
+                                taskDTOList.add(taskDTO);
                             }
                             }
                         }
                         }
-
-                        taskDTO.setCarNo(taskDO.getCarNo());
-                        taskDTO.setNetWeight(taskDO.getNetWeight());
-                        sumNet = sumNet + taskDO.getNetWeight();
-                        taskDTOList.add(taskDTO);
+                    }
+                    else{
+                        TaskDTO taskDTO1 = new TaskDTO();
+                        taskDTO1.setCloseTon(saleReportDO.getNetWeight());
+                        taskDTO1.setSumPriceClose(Double.valueOf(saleReportDO.getUnitPrice1() + saleReportDO.getBasis()) * saleReportDO.getBuy());
+                        sumNetClose = sumNetClose + saleReportDO.getNetWeight();
+                        payMoneyClose = payMoneyClose + taskDTO1.getSumPriceClose();
+                        payNotMoneyClose = payNotMoneyClose + (saleReportDO.getNotPayMoney());
+                        taskDTOList1.add(taskDTO1);
                     }
                     }
                 }
                 }
             }
             }
@@ -192,8 +189,10 @@ public class ContractAppServiceImpl implements ContractAppService {
             map.put("sumNet", sumNet);
             map.put("sumNet", sumNet);
             map.put("taskDTOList", taskDTOList);
             map.put("taskDTOList", taskDTOList);
 
 
+            map.put("sumTotalClose", sumTotalClose);
             map.put("sumNetClose", sumNetClose);
             map.put("sumNetClose", sumNetClose);
             map.put("payMoneyClose", payMoneyClose);
             map.put("payMoneyClose", payMoneyClose);
+            map.put("notPayMoneyClose", payNotMoneyClose);
             map.put("taskDTOList1", taskDTOList1);
             map.put("taskDTOList1", taskDTOList1);
 
 
 
 

+ 0 - 3
unimall-data/src/main/java/com/iotechn/unimall/data/domain/BuyReportDO.java

@@ -109,8 +109,5 @@ public class BuyReportDO  extends SuperDO {
     /* 库点 */
     /* 库点 */
     @TableField(exist = false)
     @TableField(exist = false)
     private String store;
     private String store;
-    /* 报表id */
-    @TableField("report_id")
-    private Long reportId;
 
 
 }
 }