From f48385158d74c007ba9f3425615b865bd6284be5 Mon Sep 17 00:00:00 2001 From: fanzongzhe0036 Date: Mon, 17 Mar 2025 16:15:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E6=AC=BE=E6=83=85=E5=86=B5=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoanRepaymentHistoryFeign.java | 7 +- .../LoanRepaymentHistoryFeignFallback.java | 5 + .../LoanRepaymentHistoryMapper.java | 3 +- .../LoanRepaymentHistoryMapper.xml | 113 +++ .../LoanRepaymentHistoryRest.java | 11 +- .../LoanRepaymentHistoryService.java | 125 ++- .../asbusrepairbill/AsBusrepairBillMapper.xml | 949 ++++++++++-------- 7 files changed, 778 insertions(+), 435 deletions(-) diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeign.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeign.java index 4a22d31aa3..f5ba8ced8c 100644 --- a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeign.java +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeign.java @@ -1,8 +1,6 @@ package com.yxt.anrui.riskcenter.api.loanrepaymenthistory; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit; -import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterQuery; -import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; @@ -108,6 +106,11 @@ public interface LoanRepaymentHistoryFeign { @PostMapping("/repaymentStatistics") public ResultBean> repaymentStatistics(@RequestBody PagerQuery pq); + @ApiOperation("客户还款情况统计表不分页") + @PostMapping("/repaymentStatisticsList") + public ResultBean> repaymentStatisticsList(@RequestBody RepaymentStatisticsQuery pq); + + @ApiOperation("客户还款明细查询") @PostMapping("/repaymentDetailsList") public ResultBean> repaymentDetailsList(@RequestBody PagerQuery pq); diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeignFallback.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeignFallback.java index 57efc17fa2..7f7a7f4ed4 100644 --- a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeignFallback.java +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanrepaymenthistory/LoanRepaymentHistoryFeignFallback.java @@ -102,6 +102,11 @@ public class LoanRepaymentHistoryFeignFallback implements LoanRepaymentHistoryFe return null; } + @Override + public ResultBean> repaymentStatisticsList(RepaymentStatisticsQuery pq) { + return null; + } + @Override public ResultBean> repaymentDetailsList(PagerQuery pq) { return null; diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.java index e9c3346b28..ca2de25866 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.java @@ -9,7 +9,6 @@ import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPayme import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo; -import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.AppRepaymentHistoryRecord; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -88,4 +87,6 @@ public interface LoanRepaymentHistoryMapper extends BaseMapper selSchSidAndVinNo(@Param("scheduleSid") String scheduleSid,@Param("vinNo") String vinNo); IPage repaymentStatistics2(IPage page, @Param(Constants.WRAPPER)QueryWrapper qw); + + List repaymentStatisticsList(@Param(Constants.WRAPPER)QueryWrapper qw); } diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.xml b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.xml index 5a648dec51..f7bd75b2a3 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.xml +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryMapper.xml @@ -1008,4 +1008,117 @@ ${ew.sqlSegment} + diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryRest.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryRest.java index 163e88390c..873aa4f0ab 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryRest.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryRest.java @@ -1,16 +1,12 @@ package com.yxt.anrui.riskcenter.biz.loanrepaymenthistory; -import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempExportVo; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit; -import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo; -import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsDto; -import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsFeign; import com.yxt.common.base.utils.ExportExcelUtils; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; @@ -157,6 +153,13 @@ public class LoanRepaymentHistoryRest implements LoanRepaymentHistoryFeign { return rb.success().setData(pv); } + @Override + public ResultBean> repaymentStatisticsList(RepaymentStatisticsQuery pq) { + ResultBean> rb = ResultBean.fireFail(); + List list = loanRepaymentHistoryService.repaymentStatisticsList(pq); + return rb.success().setData(list); + } + @Override public ResultBean> repaymentDetailsList(PagerQuery pq) { ResultBean> rb = ResultBean.fireFail(); diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryService.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryService.java index f4b801c1fb..0fb5140195 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryService.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymenthistory/LoanRepaymentHistoryService.java @@ -2,12 +2,8 @@ package com.yxt.anrui.riskcenter.biz.loanrepaymenthistory; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateTime; -import cn.hutool.core.math.Money; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.yxt.anrui.base.api.basemodelmodprice.BaseModelModpriceImportReturn; -import com.yxt.anrui.base.api.basemodelmodprice.BaseModelModpriceImportVo; import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemDetailsVo; import com.yxt.anrui.base.api.basepurchasesystem.BasePurchaseSystemFeign; import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder; @@ -16,10 +12,6 @@ import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerDe import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerFeign; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle; import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign; -import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTemp; -import com.yxt.anrui.crm.api.crmcustomertemp.CrmCustomerTempExportVo; -import com.yxt.anrui.fin.api.finmanufacturerbank.FinManufacturerBank; -import com.yxt.anrui.fin.api.finpaymentrecord.FinPaymentrecordDto; import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJR; import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJRFeign; import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign; @@ -28,31 +20,21 @@ import com.yxt.anrui.fin.api.kingdee.voucher.GeneralVoucher; import com.yxt.anrui.portal.api.sysorganization.SysOrganizationFeign; import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo; import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; -import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgVo; import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; import com.yxt.anrui.portal.api.sysuser.SysUserFeign; -import com.yxt.anrui.portal.api.sysuser.SysUserVo; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleApplyInit; import com.yxt.anrui.riskcenter.api.loanbuckleapply.LoanBuckleHistoryRecord; import com.yxt.anrui.riskcenter.api.loanfinbank.LoanFinBank; -import com.yxt.anrui.riskcenter.api.loanmonthlyaccrualapply.LoanMonthlyAccrualApply; -import com.yxt.anrui.riskcenter.api.loanmonthlyaccrualrecord.LoanMonthlyAccrualRecord; -import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameter; -import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterQuery; -import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.PreTransferPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RecordCountVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.RepaymentDetailsExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.export.TransferedPaymentExportVo; import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.utils.CollectorsUtil; -import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.CheckPayStateVo; import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanPlanDetailsVoForLateVoucher; import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; -import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsDto; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.AppRepaymentHistoryRecord; import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentSchedule; -import com.yxt.anrui.riskcenter.api.loantransferpaymentrecord.LoanTransferPaymentRecord; import com.yxt.anrui.riskcenter.biz.loanfinbank.LoanFinBankService; import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; import com.yxt.anrui.riskcenter.biz.loanrepaymentschedule.LoanRepaymentScheduleService; @@ -61,7 +43,6 @@ import com.yxt.common.base.utils.PagerUtil; import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; -import com.yxt.messagecenter.api.messageurgeList.MessageUrgeListVo; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; @@ -85,11 +66,9 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.*; import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collector; import java.util.stream.Collectors; @@ -1501,6 +1480,108 @@ public class LoanRepaymentHistoryService extends MybatisBaseService repaymentStatisticsList(RepaymentStatisticsQuery pagerQuery) { + QueryWrapper qw = new QueryWrapper<>(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //======================= + PrivilegeQuery privilegeQuery = new PrivilegeQuery(); + privilegeQuery.setOrgPath(pagerQuery.getOrgPath()); + privilegeQuery.setMenuSid(pagerQuery.getMenuSid()); + privilegeQuery.setMenuUrl(pagerQuery.getMenuUrl()); + privilegeQuery.setUserSid(pagerQuery.getUserSid()); + ResultBean defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); + if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { + //数据权限ID(1集团、2事业部、3分公司、4部门、5个人) + String orgSidPath = pagerQuery.getOrgPath(); + orgSidPath = orgSidPath + "/"; + System.out.println(orgSidPath+"================="); + int i1 = orgSidPath.indexOf("/"); + int i2 = orgSidPath.indexOf("/", i1 + 1); + int i3 = orgSidPath.indexOf("/", i2 + 1); + int i4 = orgSidPath.indexOf("/", i3 + 1); + String orgLevelKey = defaultIdReltBean.getData(); + if ("1".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i1); + qw.like("a.orgSidPath", orgSidPath); + } else if ("2".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i2); + qw.like("a.orgSidPath", orgSidPath); + } else if ("3".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i3); + qw.like("a.orgSidPath", orgSidPath); + } else if ("4".equals(orgLevelKey)) { + orgSidPath = orgSidPath.substring(0, i4); + qw.like("a.orgSidPath", orgSidPath); + } else if ("5".equals(orgLevelKey)) { + qw.eq("a.createBySid", pagerQuery.getUserSid()); + } else { + List p = new ArrayList<>(); + return p; + } + } else { + List p = new ArrayList<>(); + return p; + } + //======================= + if (StringUtils.isNotBlank(pagerQuery.getUseOrgName())) { + qw.like("a.useOrgName", pagerQuery.getUseOrgName()); + } + if (StringUtils.isNotBlank(pagerQuery.getVinNo())) { + qw.like("a.vinNo", pagerQuery.getVinNo()); + } + if (StringUtils.isNotBlank(pagerQuery.getDept())) { + qw.like("a.dept", pagerQuery.getDept()); + } + if (StringUtils.isNotBlank(pagerQuery.getReturnState())) { + qw.eq("a.returnState", pagerQuery.getReturnState()); + } + if (StringUtils.isNotBlank(pagerQuery.getStaffName())) { + qw.like("a.staffName", pagerQuery.getStaffName()); + } + if (StringUtils.isNotBlank(pagerQuery.getLoanContractNo())) { + qw.like("a.loanContractNo", pagerQuery.getLoanContractNo()); + } + if (StringUtils.isNotBlank(pagerQuery.getPeriod())) { + qw.eq("a.period", pagerQuery.getPeriod()); + } + if (StringUtils.isNotBlank(pagerQuery.getBankName())) { + qw.like("a.bankName", pagerQuery.getBankName()); + } + if (StringUtils.isNotBlank(pagerQuery.getBankContractNo())) { + qw.like("a.bankContractNo", pagerQuery.getBankContractNo()); + } + if (StringUtils.isNotBlank(pagerQuery.getCustomer())) { + qw.like("a.customer", pagerQuery.getCustomer()); + } + if (StringUtils.isNotBlank(pagerQuery.getBorrowerName())) { + qw.like("a.borrowerName", pagerQuery.getBorrowerName()); + } + if (StringUtils.isNotBlank(pagerQuery.getDueOverdue())) { + qw.eq("a.dueOverdue", pagerQuery.getDueOverdue()); + } + if (StringUtils.isNotBlank(pagerQuery.getNowOverdue())) { + qw.eq("a.nowOverdue", pagerQuery.getNowOverdue()); + } + String dueStartDate = pagerQuery.getDueStartDate(); + String dueEndDate = pagerQuery.getDueEndDate(); + qw.apply(StringUtils.isNotEmpty(dueStartDate), "date_format (a.dueDate,'%Y-%m-%d') >= date_format('" + dueStartDate + "','%Y-%m-%d')"). + apply(StringUtils.isNotEmpty(dueEndDate), "date_format (a.dueDate,'%Y-%m-%d') <= date_format('" + dueEndDate + "','%Y-%m-%d')" + ); + String updateStartDate = pagerQuery.getUpdateStartDate(); + String updateEndDate = pagerQuery.getUpdateEndDate(); + qw.apply(StringUtils.isNotEmpty(updateStartDate), "date_format (a.updateDate,'%Y-%m-%d') >= date_format('" + updateStartDate + "','%Y-%m-%d')"). + apply(StringUtils.isNotEmpty(updateEndDate), "date_format (a.updateDate,'%Y-%m-%d') <= date_format('" + updateEndDate + "','%Y-%m-%d')" + ); + qw.orderBy(true, true, "a.useOrgName") + .orderBy(true, true, "a.vinNo") + .orderBy(true, true, "a.period") + .orderBy(true, true, "a.loanContractNo") + ; + List p = baseMapper.repaymentStatisticsList(qw); + return p; + } + /** * 分页方法 */ @@ -2339,4 +2420,6 @@ public class LoanRepaymentHistoryService extends MybatisBaseService selSchSidAndVinNo(String scheduleSid, String vinNo) { return baseMapper.selSchSidAndVinNo(scheduleSid, vinNo); } + + } diff --git a/yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml b/yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml index 96c526fcee..a5ab843643 100644 --- a/yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml +++ b/yxt-as/src/main/java/com/yxt/anrui/as/biz/asbusrepairbill/AsBusrepairBillMapper.xml @@ -61,67 +61,92 @@ SELECT * FROM - (SELECT n.*, - (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) turnover, - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) cost, - ((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost)) grossProfit, - (n.packsHourAmount + n.packsGoodsAmount + n.packsOtherAmount) packsReceivable, - (n.outHourAmount + n.outGoodsAmount + n.outOtherAmount) outReceivable - FROM - (SELECT - a.orgSidPath, - a.`deptName`, - a.`useOrgName`, - COUNT(*) billNum, - IFNULL(SUM(IFNULL(hourAmount,0)),0) hourAmount, - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0) as goodsAmount, - IFNULL(SUM(IFNULL(addAmount,0)),0) otherAmount, - (IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount, - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) as backAmount, - (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE - b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) as hourAmountCost, - ( (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) ) goodsAmountCost, - ((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE - b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s LEFT JOIN as_busrepair_bill as b ON s.billSid = b.sid WHERE - b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ))) otherAmountCost, - (SELECT IFNULL(SUM(IFNULL(b.hourAmount,0)),0) FROM as_busrepair_bill as b WHERE - b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保内') as packsHourAmount, - ( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0 and b.`subject` = '保内') - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1 and b.`subject` = '保内') ) packsGoodsAmount, - (SELECT IFNULL(SUM(IFNULL(addAmount,0)),0) + IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0) FROM as_busrepair_bill as b WHERE - b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保内') as packsOtherAmount, - (SELECT IFNULL(SUM(IFNULL(b.hourAmount,0)),0) FROM as_busrepair_bill as b WHERE - b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保外') as outHourAmount, - ( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 0 and b.`subject` = '保外') - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1 and b.`subject` = '保外') ) outGoodsAmount, - (SELECT IFNULL(SUM(IFNULL(addAmount,0)),0) + IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0) FROM as_busrepair_bill as b WHERE - b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and b.`subject` = '保外') as outOtherAmount, - date_format ( a.settleTime, '%Y-%m-%d' ) settleTime - FROM - as_busrepair_bill AS a - WHERE a.nodeCode = '6' - GROUP BY - date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid) as n) as m - - ${ew.sqlSegment} - + (SELECT n.*, + (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) turnover, + (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) cost, + ((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount - n.backAmount) - (n.hourAmountCost + + n.goodsAmountCost + n.otherAmountCost)) grossProfit, + (n.packsHourAmount + n.packsGoodsAmount + n.packsOtherAmount) packsReceivable, + (n.outHourAmount + n.outGoodsAmount + n.outOtherAmount) outReceivable + FROM + (SELECT + a.orgSidPath, + a.`deptName`, + a.`useOrgName`, + COUNT(*) billNum, + IFNULL(SUM(IFNULL(hourAmount,0)),0) hourAmount, + (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = + b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, + '%Y-%m-%d' ) and ab.busTypeKey = 0) as goodsAmount, + IFNULL(SUM(IFNULL(addAmount,0)),0) otherAmount, + (IFNULL(SUM(IFNULL(outAmount,0)),0) + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + + IFNULL(SUM(IFNULL(rescueAmount,0)),0)) addAmount, + (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = + b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, + '%Y-%m-%d' ) and ab.busTypeKey = 1) as backAmount, + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s LEFT JOIN as_busrepair_bill as b + ON s.billSid = b.sid WHERE + b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) + as hourAmountCost, + ( (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = + b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, + '%Y-%m-%d' ) and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM + as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT + JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( + b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1) ) goodsAmountCost, + ((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s LEFT JOIN as_busrepair_bill as b + ON s.billSid = b.sid WHERE + b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' )) + + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s LEFT JOIN as_busrepair_bill + as b ON s.billSid = b.sid WHERE + b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ))) + otherAmountCost, + (SELECT IFNULL(SUM(IFNULL(b.hourAmount,0)),0) FROM as_busrepair_bill as b WHERE + b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) + and b.`subject` = '保内') as packsHourAmount, + ( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = + b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, + '%Y-%m-%d' ) and ab.busTypeKey = 0 and b.`subject` = '保内') - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM + as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT + JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( + b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1 and b.`subject` = + '保内') ) packsGoodsAmount, + (SELECT IFNULL(SUM(IFNULL(addAmount,0)),0) + IFNULL(SUM(IFNULL(outAmount,0)),0) + + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0) FROM as_busrepair_bill as b WHERE + b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and + b.`subject` = '保内') as packsOtherAmount, + (SELECT IFNULL(SUM(IFNULL(b.hourAmount,0)),0) FROM as_busrepair_bill as b WHERE + b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) + and b.`subject` = '保外') as outHourAmount, + ( (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT JOIN as_busrepair_bill AS b ON ab.sourceBillSid = + b.sid WHERE b.deptSid = a.deptSid and date_format ( b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, + '%Y-%m-%d' ) and ab.busTypeKey = 0 and b.`subject` = '保外') - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM + as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid LEFT + JOIN as_busrepair_bill AS b ON ab.sourceBillSid = b.sid WHERE b.deptSid = a.deptSid and date_format ( + b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and ab.busTypeKey = 1 and b.`subject` = + '保外') ) outGoodsAmount, + (SELECT IFNULL(SUM(IFNULL(addAmount,0)),0) + IFNULL(SUM(IFNULL(outAmount,0)),0) + + IFNULL(SUM(IFNULL(subsidyAmount,0)),0) + IFNULL(SUM(IFNULL(rescueAmount,0)),0) FROM as_busrepair_bill as b WHERE + b.deptSid = a.deptSid and date_format (b.settleTime, '%Y-%m-%d' ) = date_format ( a.settleTime, '%Y-%m-%d' ) and + b.`subject` = '保外') as outOtherAmount, + date_format ( a.settleTime, '%Y-%m-%d' ) settleTime + FROM + as_busrepair_bill AS a + WHERE a.nodeCode = '6' + GROUP BY + date_format ( a.settleTime, '%Y-%m-%d' ),a.deptSid) as n) as m + + ${ew.sqlSegment} + SELECT * FROM - (SELECT n.*, - (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount, - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) costTotal, - ((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost)) profit, - IF(n.debt > 0, ( DATEDIFF( NOW(), n.paymentDate )), '0') overDueDays - FROM - (SELECT - a.orgSidPath, - a.useOrgName, - a.deptName, - a.billNo, - date_format (a.createTime,'%Y-%m-%d') createTime, - date_format (a.finishTime,'%Y-%m-%d') finishTime, - date_format (a.settleTime,'%Y-%m-%d') settleTime, - '维修工单' busType, - a.billType, - a.`subject`, - a.customerName, - v.vehMark, - v.vinNo, - IFNULL(a.hourAmount,0) hourAmount, - ((SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 1)) goodsAmount, - IFNULL(a.addAmount,0) otherAmount, - IFNULL(a.outAmount,0) + IFNULL(a.subsidyAmount,0) + IFNULL(a.rescueAmount,0) addAmount, - (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s WHERE s.billSid = a.sid) as hourAmountCost, - ((SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 0) - (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 1)) goodsAmountCost, - ((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s WHERE s.billSid = a.sid) + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s WHERE s.billSid = a.sid)) otherAmountCost, - (SELECT IFNULL(SUM(sd.subscriptionMoney),0) FROM anrui_fin.fin_selected_receivables_detailed as sd LEFT JOIN anrui_fin.fin_uncollected_receivables_detailed as fd ON sd.receivablesSid - = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid) receivedAmount, - ((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE d.contractSid = a.sid) - - (SELECT IFNULL(SUM(sd.subscriptionMoney),0) FROM anrui_fin.fin_selected_receivables_detailed as sd LEFT JOIN anrui_fin.fin_uncollected_receivables_detailed as fd ON sd.receivablesSid - = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid)) debt, - date_format (aa.promisePaymentDate,'%Y-%m-%d') paymentDate, - a.dockingPeople, - a.waitorName - FROM - as_busrepair_bill AS a - LEFT JOIN as_busrepair_bill_vech as v ON a.sid = v.billSid - LEFT JOIN as_arrearsout_apply as aa ON a.sid = aa.pairBillSid) as n) m + (SELECT n.*, + (n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) totalAmount, + (n.hourAmountCost + n.goodsAmountCost + n.otherAmountCost) costTotal, + ((n.hourAmount + n.goodsAmount + n.otherAmount + n.addAmount) - (n.hourAmountCost + n.goodsAmountCost + + n.otherAmountCost)) profit, + IF(n.debt > 0, ( DATEDIFF( NOW(), n.paymentDate )), '0') overDueDays + FROM + (SELECT + a.orgSidPath, + a.useOrgName, + a.deptName, + a.billNo, + date_format (a.createTime,'%Y-%m-%d') createTime, + date_format (a.finishTime,'%Y-%m-%d') finishTime, + date_format (a.settleTime,'%Y-%m-%d') settleTime, + '维修工单' busType, + a.billType, + a.`subject`, + a.customerName, + v.vehMark, + v.vinNo, + IFNULL(a.hourAmount,0) hourAmount, + ((SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 0) - + (SELECT IFNULL(SUM(IFNULL(d.amount,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 1)) + goodsAmount, + IFNULL(a.addAmount,0) otherAmount, + IFNULL(a.outAmount,0) + IFNULL(a.subsidyAmount,0) + IFNULL(a.rescueAmount,0) addAmount, + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_sitem as s WHERE s.billSid = a.sid) as + hourAmountCost, + ((SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 0) - + (SELECT IFNULL(SUM(IFNULL(d.costTotal,0)),0) FROM as_busrepair_inventorybill_detail as d LEFT JOIN + as_busrepair_inventorybill as ab ON d.billSid = ab.sid WHERE ab.sourceBillSid = a.sid and ab.busTypeKey = 1)) + goodsAmountCost, + ((SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitem as s WHERE s.billSid = a.sid) + + (SELECT IFNULL(SUM(IFNULL(s.costTotal,0)),0) FROM as_busrepair_bill_aitemspec as s WHERE s.billSid = a.sid)) + otherAmountCost, + (SELECT IFNULL(SUM(sd.subscriptionMoney),0) FROM anrui_fin.fin_selected_receivables_detailed as sd LEFT JOIN + anrui_fin.fin_uncollected_receivables_detailed as fd ON sd.receivablesSid + = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid) receivedAmount, + ((SELECT IFNULL(SUM(reveivableMoney),0) FROM anrui_fin.fin_uncollected_receivables_detailed as d WHERE + d.contractSid = a.sid) + - (SELECT IFNULL(SUM(sd.subscriptionMoney),0) FROM anrui_fin.fin_selected_receivables_detailed as sd LEFT JOIN + anrui_fin.fin_uncollected_receivables_detailed as fd ON sd.receivablesSid + = fd.sid WHERE sd.auditState = '3' AND fd.contractSid = a.sid)) debt, + date_format (aa.promisePaymentDate,'%Y-%m-%d') paymentDate, + a.dockingPeople, + a.waitorName + FROM + as_busrepair_bill AS a + LEFT JOIN as_busrepair_bill_vech as v ON a.sid = v.billSid + LEFT JOIN as_arrearsout_apply as aa ON a.sid = aa.pairBillSid) as n) m ${ew.sqlSegment}