From 5263bcc4b513a699c490a583b99aa56bacc224d3 Mon Sep 17 00:00:00 2001 From: dimengzhe Date: Tue, 16 Apr 2024 16:04:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=87=91=E8=9E=8D=E6=96=B9=E6=A1=88?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E9=A6=96=E4=BB=98=E6=AF=94=E4=BE=8B=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../loansolutions/LoanSolutionsService.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansolutions/LoanSolutionsService.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansolutions/LoanSolutionsService.java index 12ea36172e..334520dcb0 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansolutions/LoanSolutionsService.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loansolutions/LoanSolutionsService.java @@ -1213,6 +1213,8 @@ public class LoanSolutionsService extends MybatisBaseService Date: Tue, 16 Apr 2024 16:44:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B5=84=E9=87=91=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E8=B4=B9=E8=AE=A1=E6=8F=90=E4=B8=8B=E8=BD=BDpdf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinCollectionConfirmationService.java | 9 + .../LoanPushFundHistory.java | 6 + .../LoanPushFundHistoryFeign.java | 17 + .../LoanPushFundHistoryFeignFallback.java | 18 + .../LoanPushFundHistoryPdfVo.java | 22 + .../LoanPushFundHistoryQuery.java | 23 + .../LoanPushFundHistoryVo.java | 21 + .../LoanPushFundHistoryMapper.java | 11 + .../LoanPushFundHistoryMapper.xml | 54 +- .../LoanPushFundHistoryRest.java | 23 + .../LoanPushFundHistoryService.java | 153 +- .../ScheduledRepaymentPlanDetailsService.java | 11 + .../src/main/resources/ftl/vouchers/fund.ftl | 1919 +++++++++++++++++ .../计提资金占用费/fund.ftl | 3 + .../计提资金占用费.docx | Bin 0 -> 17798 bytes 15 files changed, 2285 insertions(+), 5 deletions(-) create mode 100644 anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryPdfVo.java create mode 100644 anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryQuery.java create mode 100644 anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryVo.java create mode 100644 anrui-riskcenter/anrui-riskcenter-biz/src/main/resources/ftl/vouchers/fund.ftl create mode 100644 工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/fund.ftl create mode 100644 工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/计提资金占用费.docx diff --git a/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java b/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java index 825366b23a..b5dd939aba 100644 --- a/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java +++ b/anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java @@ -3819,6 +3819,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService fundHistoryList); + @ApiOperation("资金占用费计提列表") + @PostMapping("/listPage") + public ResultBean> listPage(@RequestBody PagerQuery pq); + + @ApiOperation("根据busVinSid查询上次计提时间") + @PostMapping("/getLastDateByBusVinSid") + public ResultBean getLastDateByBusVinSid(@RequestParam("busVinSid") String busVinSid); + + @ApiOperation("下载资金占用费计提记录dpf") + @PostMapping("/fundCreatePdf") + public ResultBean fundCreatePdf(@RequestParam("times") String times, @RequestParam("orgPath") String orgPath); } \ No newline at end of file diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryFeignFallback.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryFeignFallback.java index 8bd71a9c63..4d1deb3677 100644 --- a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryFeignFallback.java +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryFeignFallback.java @@ -1,6 +1,9 @@ package com.yxt.anrui.riskcenter.api.loanpushfundhistory; +import com.yxt.common.core.query.PagerQuery; +import com.yxt.common.core.result.ResultBean; +import com.yxt.common.core.vo.PagerVo; import org.springframework.stereotype.Component; import java.util.List; @@ -14,4 +17,19 @@ public class LoanPushFundHistoryFeignFallback implements LoanPushFundHistoryFeig public int saveHistory(List fundHistoryList) { return 0; } + + @Override + public ResultBean> listPage(PagerQuery pq) { + return null; + } + + @Override + public ResultBean getLastDateByBusVinSid(String busVinSid) { + return null; + } + + @Override + public ResultBean fundCreatePdf(String times, String orgPath) { + return null; + } } \ No newline at end of file diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryPdfVo.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryPdfVo.java new file mode 100644 index 0000000000..e4c6fca88a --- /dev/null +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryPdfVo.java @@ -0,0 +1,22 @@ +package com.yxt.anrui.riskcenter.api.loanpushfundhistory; + +import lombok.Data; + +/** + * @author Fan + * @description + * @date 2024/4/16 10:32 + */ +@Data +public class LoanPushFundHistoryPdfVo { + private Integer sortNo; + private String bankName; + private String bankNo; + private String vinNo; + private String borrowerName; + private String saleDept; + private String lastDate; + private String days; + private String money; + private String loanNo; +} diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryQuery.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryQuery.java new file mode 100644 index 0000000000..c98a2d64d8 --- /dev/null +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryQuery.java @@ -0,0 +1,23 @@ +package com.yxt.anrui.riskcenter.api.loanpushfundhistory; + +import com.yxt.common.core.query.Query; +import lombok.Data; + +/** + * @author Fan + * @description + * @date 2024/4/16 8:38 + */ +@Data +public class LoanPushFundHistoryQuery implements Query { + +// private String loanContractNo;//贷款合同号 +// private String bankName; //资方 +// private String bankContractNo;//资方合同号 +// private String vinNo;//车架号 +// private String borrowerName; //贷款人 +// private String salesDept; //销售部门 + private String startTimes; //计提开始时间 + private String endTimes; //计提结束时间 + private String orgPath; +} diff --git a/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryVo.java b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryVo.java new file mode 100644 index 0000000000..a247d28298 --- /dev/null +++ b/anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpushfundhistory/LoanPushFundHistoryVo.java @@ -0,0 +1,21 @@ +package com.yxt.anrui.riskcenter.api.loanpushfundhistory; + +import com.yxt.common.core.vo.Vo; +import lombok.Data; + +/** + * @author Fan + * @description + * @date 2024/4/16 8:37 + */ +@Data +public class LoanPushFundHistoryVo implements Vo { +// private String loanContractNo;//贷款合同号 +// private String bankName; //资方 +// private String bankContractNo;//资方合同号 +// private String vinNo;//车架号 +// private String borrowerName; //贷款人 +// private String salesDept; //销售部门 + private String times; //计提时间 + private String money; //本次计提金额 +} diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.java index 3d03a2f02b..b2aefc38a4 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.java @@ -1,7 +1,12 @@ package com.yxt.anrui.riskcenter.biz.loanpushfundhistory; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistory; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryPdfVo; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryVo; import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanPlanDetailsVoForFundVoucher; import com.yxt.anrui.riskcenter.api.loantransferpaymentrecord.LoanTransferPaymentRecord; import org.apache.ibatis.annotations.Mapper; @@ -15,4 +20,10 @@ public interface LoanPushFundHistoryMapper extends BaseMapper list); + + String getLastDateByBusVinSid(@Param("busVinSid") String busVinSid); + + IPage listPage(IPage page, @Param(Constants.WRAPPER) QueryWrapper qw); + + List getFundPdfList(@Param("times") String times, @Param("useOrgSid") String useOrgSid); } diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.xml b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.xml index fb5c3044bd..a2d0718078 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.xml +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryMapper.xml @@ -4,10 +4,60 @@ - insert into loan_push_fund_history(sid,busVinSid,useOrgSid,useOrgName,fund) + insert into loan_push_fund_history(sid,busVinSid,useOrgSid,useOrgName,fund,lastAccrualDate) values - (#{item.sid},#{item.busVinSid},#{item.useOrgSid},#{item.useOrgName},#{item.fund}) + (#{item.sid},#{item.busVinSid},#{item.useOrgSid},#{item.useOrgName},#{item.fund},#{item.lastAccrualDate}) + + + \ No newline at end of file diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryRest.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryRest.java index d31184bb03..38006462e4 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryRest.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryRest.java @@ -2,6 +2,12 @@ package com.yxt.anrui.riskcenter.biz.loanpushfundhistory; import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistory; import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryFeign; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryQuery; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryVo; +import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistoryVo; +import com.yxt.common.core.query.PagerQuery; +import com.yxt.common.core.result.ResultBean; +import com.yxt.common.core.vo.PagerVo; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -22,4 +28,21 @@ public class LoanPushFundHistoryRest implements LoanPushFundHistoryFeign { public int saveHistory(List fundHistoryList) { return loanPushFundHistoryService.saveLists(fundHistoryList); } + + @Override + public ResultBean> listPage(PagerQuery pq) { + ResultBean> rb = ResultBean.fireFail(); + PagerVo pv = loanPushFundHistoryService.listPage(pq); + return rb.success().setData(pv); + } + + @Override + public ResultBean getLastDateByBusVinSid(String busVinSid) { + return loanPushFundHistoryService.getLastDateByBusVinSid(busVinSid); + } + + @Override + public ResultBean fundCreatePdf(String times, String orgPath) { + return loanPushFundHistoryService.fundCreatePdf(times,orgPath); + } } diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryService.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryService.java index c804eea8e7..7ba89a0906 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryService.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpushfundhistory/LoanPushFundHistoryService.java @@ -1,13 +1,34 @@ package com.yxt.anrui.riskcenter.biz.loanpushfundhistory; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +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.riskcenter.api.loanpushfundhistory.LoanPushFundHistory; -import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanPlanDetailsVoForFundVoucher; -import com.yxt.anrui.riskcenter.api.loantransferpaymentrecord.LoanTransferPaymentRecord; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryPdfVo; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryQuery; +import com.yxt.anrui.riskcenter.api.loanpushfundhistory.LoanPushFundHistoryVo; +import com.yxt.common.base.config.component.DocPdfComponent; import com.yxt.common.base.service.MybatisBaseService; +import com.yxt.common.base.utils.PagerUtil; +import com.yxt.common.base.utils.WordConvertUtils; +import com.yxt.common.core.query.PagerQuery; +import com.yxt.common.core.result.ResultBean; +import com.yxt.common.core.vo.PagerVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; +import java.io.File; +import java.io.InputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +import static java.util.Comparator.comparing; /** * @description: @@ -17,8 +38,134 @@ import java.util.List; @Service public class LoanPushFundHistoryService extends MybatisBaseService { + @Autowired + private SysStaffOrgFeign sysStaffOrgFeign; + @Autowired + private SysOrganizationFeign sysOrganizationFeign; + @Autowired + private DocPdfComponent docPdfComponent; + public int saveLists(List list) { return baseMapper.saveLists(list); } + public PagerVo listPage(PagerQuery pq) { + LoanPushFundHistoryQuery pagerQuery = pq.getParams(); + QueryWrapper qw = new QueryWrapper<>(); + ResultBean orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(pagerQuery.getOrgPath()); + if (orgSidByPath.getSuccess()) { + qw.eq("a.useOrgSid", orgSidByPath.getData()); + } + String startDate = pagerQuery.getStartTimes(); + String endDate = pagerQuery.getEndTimes(); + qw.apply(StringUtils.isNotEmpty(startDate), "date_format(a.times,'%Y-%m-%d %H:%I') >= date_format('" + startDate + "','%Y-%m-%d %H:%I')"). + apply(StringUtils.isNotEmpty(endDate), "date_format(a.times,'%Y-%m-%d %H:%I') <= date_format('" + endDate + "','%Y-%m-%d %H:%I')" + ); + qw.groupBy("a.times", "a.useOrgSid"); + qw.orderByDesc("a.times"); + IPage page = PagerUtil.queryToPage(pq); + IPage pagging = baseMapper.listPage(page, qw); + PagerVo p = PagerUtil.pageToVo(pagging, null); + return p; + } + + public ResultBean getLastDateByBusVinSid(String busVinSid) { + ResultBean rb = ResultBean.fireFail(); + String returnTimes = baseMapper.getLastDateByBusVinSid(busVinSid); + if (StringUtils.isNotBlank(returnTimes)) { + return rb.success().setData(returnTimes); + } + return rb.success().setData(""); + } + + public ResultBean fundCreatePdf(String times, String orgPath) { + ResultBean rb = ResultBean.fireFail(); + String finalPath = ""; + Map dataMap = new HashMap(); + List> newList = new ArrayList<>(); + dataMap.put("percent", "日万七"); + String useOrgSid = ""; + ResultBean orgSidByPath = sysStaffOrgFeign.getOrgSidByPath(orgPath); + if (orgSidByPath.getSuccess()) { + useOrgSid = orgSidByPath.getData(); + ResultBean organizationVo = sysOrganizationFeign.fetchBySid(useOrgSid); + if (organizationVo.getSuccess()) { + SysOrganizationVo organizationVoData = organizationVo.getData(); + if (null != organizationVoData) { + dataMap.put("company", organizationVoData.getName()); + } + } + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date parse = null; + try { + parse = sdf.parse(times); + dataMap.put("times", sdf.format(parse)); + } catch (ParseException e) { + e.printStackTrace(); + } + List records = baseMapper.getFundPdfList(times, useOrgSid); + if (!records.isEmpty()) { + for (LoanPushFundHistoryPdfVo details : records) { + Map map = new HashMap<>(); + if (null != details) { + map.put("sortNo", details.getSortNo()); + if (StringUtils.isNotBlank(details.getLoanNo())) { + map.put("loanNo", details.getLoanNo()); + } + if (StringUtils.isNotBlank(details.getVinNo())) { + map.put("vinNo", details.getVinNo()); + } + if (StringUtils.isNotBlank(details.getBankName())) { + map.put("bankName", details.getBankName()); + } + if (StringUtils.isNotBlank(details.getBankNo())) { + map.put("bankNo", details.getBankNo()); + } + if (StringUtils.isNotBlank(details.getBorrowerName())) { + map.put("borrowerName", details.getBorrowerName()); + } + if (StringUtils.isNotBlank(details.getSaleDept())) { + map.put("saleDept", details.getSaleDept()); + } + if (StringUtils.isNotBlank(details.getLastDate())) { + map.put("lastDate", details.getLastDate()); + } + if (StringUtils.isNotBlank(details.getDays())) { + map.put("days", details.getDays()); + } + if (StringUtils.isNotBlank(details.getMoney())) { + map.put("money", details.getMoney()); + } + + } + newList.add(map); + } + } + dataMap.put("newList", newList); + String temp = "/template/"; + String targetPath = docPdfComponent.getUploadTemplateUrl(); + try { + //获取模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("ftl/vouchers/fund.ftl"); + //生成word文件名 + String dateStr = DateUtil.format(new Date(), "yyyyMMdd"); + long seconds = System.currentTimeMillis(); + String typeName = dateStr + seconds + ".doc"; + File file = new File(targetPath + "templateVouchers" + seconds + ".ftl"); + File dir = new File(targetPath); + WordConvertUtils.inputStreamToFile(inputStream, file); + WordConvertUtils.creatWord1(dataMap, file, targetPath, typeName, dir); + //新生成的word路径 + String wordPath = targetPath + typeName; + String pdfName = "资金占用费计提" + dateStr + seconds + ".pdf"; + WordConvertUtils.doc2pdf(wordPath, targetPath, pdfName); + finalPath = temp + pdfName; + } catch (NoClassDefFoundError e) { + e.printStackTrace(); + finalPath = targetPath; + } + + return rb.success().setData(finalPath); + } } diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/ScheduledRepaymentPlanDetailsService.java b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/ScheduledRepaymentPlanDetailsService.java index d5ded521d1..3cd0d64035 100644 --- a/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/ScheduledRepaymentPlanDetailsService.java +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/ScheduledRepaymentPlanDetailsService.java @@ -34,6 +34,8 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -164,6 +166,7 @@ public class ScheduledRepaymentPlanDetailsService { public void pushFundVoucher() { List useOrgSidList = loanRepaymentPlanDetailsService.selUseOrgSidListForFundVoucher(); useOrgSidList.removeAll(Collections.singleton(null)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (!useOrgSidList.isEmpty()) { for (String u : useOrgSidList) { List fundVouchers = loanRepaymentPlanDetailsService.getFundForVoucher(u); @@ -255,6 +258,14 @@ public class ScheduledRepaymentPlanDetailsService { if (null != v.getDuePushMoney()) { loanPushFundHistory.setFund(v.getDuePushMoney()); } + String times = loanPushFundHistoryService.getLastDateByBusVinSid(v.getBusVinSid()).getData(); + if (StringUtils.isNotBlank(times)) { + try { + loanPushFundHistory.setLastAccrualDate(sdf.parse(times)); + } catch (ParseException e) { + e.printStackTrace(); + } + } fundHistoryList.add(loanPushFundHistory); } generalVoucher.setVoucherDetails(voucherDetails); diff --git a/anrui-riskcenter/anrui-riskcenter-biz/src/main/resources/ftl/vouchers/fund.ftl b/anrui-riskcenter/anrui-riskcenter-biz/src/main/resources/ftl/vouchers/fund.ftl new file mode 100644 index 0000000000..b87aa30224 --- /dev/null +++ b/anrui-riskcenter/anrui-riskcenter-biz/src/main/resources/ftl/vouchers/fund.ftl @@ -0,0 +1,1919 @@ + + + + Administrator + FAN + 2024-04-12T01:09:00Z + 2024-04-16T02:24:10Z + 7200 + 1 + 0 + 0 + 0 + 0 + 0 + 14 + + + 2052-12.1.0.16729 + CBA12F6EAE3B4999AC52E9A4CB71CC29_13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 资金占用费计提 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${company!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 计提率:${percent!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 计提时间:${times!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 计提明细 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 序号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 贷款合同号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 资方 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 资方合同号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 车架号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 贷款人 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 销售部门 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 上次计提日期 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 计提天数 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 本次计提金额 + + + + + <#list newList as list> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.sortNo!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.loanNo!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.bankName!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.bankNo!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.vinNo!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.borrowerName!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.saleDept!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.lastDate!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.days!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${list.money!} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PAGE \* MERGEFORMAT + + + + + + 1 + + + + + + 页 共 + + + + + + NUMPAGES \* MERGEFORMAT + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/fund.ftl b/工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/fund.ftl new file mode 100644 index 0000000000..efc4a0b9c4 --- /dev/null +++ b/工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/fund.ftl @@ -0,0 +1,3 @@ + + +AdministratorFAN2024-04-12T01:09:00Z2024-04-16T02:24:10Z7200100000142052-12.1.0.16729CBA12F6EAE3B4999AC52E9A4CB71CC29_13资金占用费计提 ${company!}计提率:${percent!}计提时间:${times!}计提明细序号贷款合同号资方资方合同号车架号贷款人销售部门上次计提日期计提天数本次计提金额${list.sortNo!}${list.loanNo!}${list.bankName!}${list.bankNo!}${list.vinNo!}${list.borrowerName!}${list.saleDept!}${list.lastDate!}${list.days!}${list.money!} PAGE \* MERGEFORMAT 1 页 共 NUMPAGES \* MERGEFORMAT 1 \ No newline at end of file diff --git a/工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/计提资金占用费.docx b/工作内容需要的文档/单据模板/财务凭证打印模板/计提资金占用费/计提资金占用费.docx new file mode 100644 index 0000000000000000000000000000000000000000..af39633d7426e7a904ddfcd5442bf10f78ebe8ae GIT binary patch literal 17798 zcmaKU19)Z2(spdyHYd)+ww+8cv2EL&*yhBxZA>z;F|o}*Ip^MU?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*>ce;;x1JN)+q{lDR)@22{1_+RPz|Etj-Y3P5Jk4F1| z{L9Y&FUZHN@n`vffN=j~YWTgfzt18cz&|xb`%mC|z5m*^_>VFF_Y?a2UdP{@rm6l_ zh5zL7dqsYK!T1}V#`Z6`(YtZ}>viLI{O@tyf8!0%{=)wi<^4PQ_Z*|Y(P-~V{685- zzr%k&72t1p-oJb7?=u4a1pjx-^v}LCC;6A`e+MS~bCmxcn((*O_ Date: Tue, 16 Apr 2024 17:01:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/databases/报表.sql | 731 ------------ doc/databases/报表中心.sql | 1144 ------------------ doc/databases/报表新增修改.sql | 77 -- doc/databases/统计报表.sql | 10 + doc/databases/统计报表clear.sql | 7 + doc/databases/统计报表create.sql | 16 + doc/databases/统计报表update.sql | 1622 ++++++++++++++++++++++++++ 7 files changed, 1655 insertions(+), 1952 deletions(-) delete mode 100644 doc/databases/报表.sql delete mode 100644 doc/databases/报表中心.sql delete mode 100644 doc/databases/报表新增修改.sql create mode 100644 doc/databases/统计报表.sql create mode 100644 doc/databases/统计报表clear.sql create mode 100644 doc/databases/统计报表create.sql create mode 100644 doc/databases/统计报表update.sql diff --git a/doc/databases/报表.sql b/doc/databases/报表.sql deleted file mode 100644 index a3e4b9533e..0000000000 --- a/doc/databases/报表.sql +++ /dev/null @@ -1,731 +0,0 @@ -CREATE - DEFINER = `root`@`%` PROCEDURE `pro_daily_report_update`() -BEGIN - -- 更新库存-未定 - UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState <> '04' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`stock_unreserve`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - -- 更新库存-已定 - UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState = '04' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`stock_reserve`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - -- 更新库存-小计 - UPDATE daily_report - SET stock_subtotal=stock_unreserve + stock_reserve - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - -- 更新库存-买断-未定 - UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState <> '04' - AND settlementStatus = '2' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`stock_buyout_unreserve`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - -- 更新库存-买断-已定 - UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState = '04' - AND settlementStatus = '2' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`stock_buyout_reserve`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - -- 更新库存-买断-小计 - UPDATE daily_report - SET `stock_buyout_subtotal`=`stock_buyout_unreserve` + `stock_buyout_reserve` - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - -- 更新库存-排产-未定 - UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - select bo.platformNo as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where si.nodeState != '已办结' - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - and bo.sid not in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - union all - select bo.platformNo as scount, bo.useOrgSid, bd.vehicleSid modelSid, bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd - on bd.sid = bo.purchaseApplyMediumModelSid - where LENGTH(offlineDate) < 1 - and bo.sid not in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo)) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`pcOrder_unreserve` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 更新库存-排产-未定 - UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - select bo.platformNo as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where si.nodeState != '已办结' - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - and bo.sid not in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - union all - select bo.platformNo as scount, bo.useOrgSid, bd.vehicleSid modelSid, bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd - on bd.sid = bo.purchaseApplyMediumModelSid - where LENGTH(offlineDate) < 1 - and bo.sid not in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo)) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`pcOrder_unreserve` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 更新库存-排产已定 - - UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - select bo.platformNo as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where si.nodeState != '已办结' - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - and bo.sid in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - union all - select bo.platformNo as scount, bo.useOrgSid, bd.vehicleSid modelSid, bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd - on bd.sid = bo.purchaseApplyMediumModelSid - where LENGTH(offlineDate) < 1 - and bo.sid in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo)) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`pcOrder_reserve` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 更新库存- 排产小计 - - UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - select bo.platformNo as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where si.nodeState != '已办结' - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - union all - select bo.platformNo as scount, bo.useOrgSid, bd.vehicleSid modelSid, bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd - on bd.sid = bo.purchaseApplyMediumModelSid - where LENGTH(offlineDate) < 1) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`pcOrder_subtotal` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 简易订单-每日 - - UPDATE daily_report r - INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid - from anrui_buscenter.bus_main_deposit bbm - left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid - where bbm.createTime like concat('%', CURDATE(), '%') - GROUP BY `useOrgSid`, - `modelSid`, - `modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`simpleOrder_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 简易订单-每月 - - UPDATE daily_report r - INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid - from anrui_buscenter.bus_main_deposit bbm - left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid - where bbm.createTime like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - GROUP BY `useOrgSid`, - `modelSid`, - `modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`simpleOrder_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 销售订单-本日-小计 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', CURDATE(), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_subtotal_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 销售订单-本日-全款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = 1 - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_full_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 销售订单-本日-贷款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = 2 - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_loan_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 销售订单-本月-小计 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_subtotal_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 销售订单-本月-全款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = 1 - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_full_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 销售订单-本月-贷款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = 2 - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_loan_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 销售订单-待交车累计 - UPDATE daily_report r - INNER JOIN (select count(bs.id) as scount, bo.useOrgSid, bm.modelSid, bm.modelConfigSid - from anrui_base.base_vehicle_state bs - left join anrui_buscenter.bus_sales_order bo on bo.sid = bs.saleOrderSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - where bs.busState = '401' - and (bs.finState = 1 or bs.carryVehicleState = 1) - group by bo.useOrgSid, bm.modelSid, bm.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`saleOrder_waitVeh_total` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - -- 销售 --- 本日销售小计 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.salesDate like concat('%', CURDATE(), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_subtotal_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本日销售全款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', CURDATE(), '%') - and bvoa.saleTypeKey = '001' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_full_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 本日销售贷款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', CURDATE(), '%') - and bvoa.saleTypeKey = '002' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_loan_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本月销售小计 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_subtotal_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本月销售全款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bvoa.saleTypeKey = '001' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_full_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 本月销售贷款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bvoa.saleTypeKey = '002' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_loan_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本年销售小计 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_subtotal_year` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本年销售全款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bvoa.saleTypeKey = '001' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_full_year` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 本年销售贷款 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bvoa.saleTypeKey = '002' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`sale_loan_year` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本日买断的台数 - - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.solidDate like concat('%', CURDATE(), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`buyout_day` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本月买断的台数 - - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.solidDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`buyout_month` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本年买断的台数 - UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.solidDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid - SET r.`buyout_year` = s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 交付-贷款-本日 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = '2' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_loan_day = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-全款-本日 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = '1' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_full_day = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-小计-本日 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', CURDATE(), '%') - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_subtotal_day = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-贷款-本月 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = '2' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_loan_month = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-全款-本月 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = '1' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_full_month = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-小计-本月 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_subtotal_month = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-贷款-本年 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bo.payTypeKey = '2' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_loan_year = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-全款-本年 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bo.payTypeKey = '1' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_full_year = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-小计-本年 - update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid - set deliver_subtotal_year = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 存销比 - update daily_report r inner join ( - select ifnull(sum(dr.sale_subtotal_month), 0) as subtotal, dr.useOrgSid, dr.vehModelSid, dr.vehMConfigSid - from daily_report dr - where (DATE_FORMAT(createTime, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') - OR DATE_FORMAT(createTime, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') - OR DATE_FORMAT(createTime, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') - ) - group by dr.useOrgSid, dr.vehModelSid, dr.vehMConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid - set saleOfStockRatio =if(s.subtotal = 0, stock_subtotal + pcOrder_subtotal, - ROUND((stock_subtotal + pcOrder_subtotal) / ROUND(s.subtotal / 3, 2), 2)), - stock_total = (stock_subtotal + pcOrder_subtotal) - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 欠款出库数量--截止当日欠款出库申请通过且未回清款的台数 - update daily_report r inner join ( - select count(bdad.id) as scount, ba.useOrgSid, bm.modelConfigSid as vehMConfigSid, bm.modelSid as vehModelSid - from anrui_buscenter.bus_delivered_apply_details bdad - left join anrui_buscenter.bus_delivered_apply ba on ba.sid = bdad.applySid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = bdad.sid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bdad.busVinSid - left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid - where ba.nodeState = '已办结' - and ba.typeState = 1 - group by bdad.busVinSid, ba.useOrgSid, bm.modelSid, bm.modelConfigSid - having sum(fd.reveivableMoney) > ifnull(sum(fs.subscriptionMoney), 0)) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid - set arrears_carry_veh_count = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 欠款出库金融--截止当日欠款出库申请通过且未回清款的台数欠款总额 - update daily_report r inner join ( - select (sum(fd.reveivableMoney) - sum(fs.subscriptionMoney)) as scount, - ba.useOrgSid, - bm.modelConfigSid as vehMConfigSid, - bm.modelSid as vehModelSid - from anrui_buscenter.bus_delivered_apply_details bdad - left join anrui_buscenter.bus_delivered_apply ba on ba.sid = bdad.applySid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = bdad.sid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_base.base_vehicle_state bs on bs.busSid = bdad.busVinSid - left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bdad.busVinSid - left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid - where ba.nodeState = '已办结' - and ba.typeState = 1 - group by bdad.busVinSid, ba.useOrgSid, bm.modelSid, bm.modelConfigSid - having sum(fd.reveivableMoney) > ifnull(sum(fs.subscriptionMoney), 0) - ) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid - set arrears_carry_veh_amount = s.scount - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 金融未放款数量--- 截止当日贷款业务已出库且融资放款未认款的台数 - update daily_report r inner join ( - select count(bv.id) as scount, bo.useOrgSid, bm.modelSid, bm.modelConfigSid, fd.reveivableMoney - from anrui_buscenter.bus_sales_order_vehicle bv - left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid - left join anrui_base.base_vehicle bbv on bbv.sid = bv.linkSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bv.salesOrderSid - left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bv.sid - left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid - where bo.payTypeKey = 2 - and fd.receivablesName = '融资放款' - and bbv.vehicleState = '0002' - group by bv.sid, bo.useOrgSid, bm.modelSid, bm.modelConfigSid - having fd.reveivableMoney > ifnull(sum(fs.subscriptionMoney), 0)) as s on - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`loan_not_count`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 金融未放款金额-- 截止当日贷款业务已出库且融资放款未认款的台数融资放款金额之和 - - update daily_report r inner join ( - select sum(fd.reveivableMoney) as scount, bo.useOrgSid, bm.modelSid, bm.modelConfigSid, fd.reveivableMoney - from anrui_buscenter.bus_sales_order_vehicle bv - left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid - left join anrui_base.base_vehicle bbv on bbv.sid = bv.linkSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bv.salesOrderSid - left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bv.sid - left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid - where bo.payTypeKey = 2 - and fd.receivablesName = '融资放款' - and bbv.vehicleState = '0002' - group by bv.sid, bo.useOrgSid, bm.modelSid, bm.modelConfigSid - having fd.reveivableMoney > ifnull(sum(fs.subscriptionMoney), 0)) as s on - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`loan_not_amount`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 全年厂家开票数 - UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE manDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid - SET r.`manufacturer_invoicing_year`=s.scount - WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - -END \ No newline at end of file diff --git a/doc/databases/报表中心.sql b/doc/databases/报表中心.sql deleted file mode 100644 index ef002e3b56..0000000000 --- a/doc/databases/报表中心.sql +++ /dev/null @@ -1,1144 +0,0 @@ --- 更新库存-排产-未定 -UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - select ifnull(sum(si.num), 0) as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where (si.nodeState != '已办结' and si.nodeState != '终止') - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - and bo.sid not in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - group by bo.createOrgSid - union all - select ifnull(sum(bo.platformNo), 0) as scount, - bo.useOrgSid, - bd.vehicleSid, - bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd on bd.sid = bo.purchaseApplyMediumModelSid - where bo.isDelete <> 1 - and LENGTH(offlineDate) = 0 - and bo.orderStatus != '已作废' - and bo.sid not in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - group by bo.createOrgSid - ) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`pcOrder_unreserve` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 更新库存-排产已定 - -UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - /* select ifnull(sum(si.num), 0) as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where (si.nodeState != '已办结' and si.nodeState != '终止') - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - and bo.sid in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - group by bo.createOrgSid - union all - select ifnull(sum(bo.platformNo), 0) as scount, bo.useOrgSid, bd.vehicleSid, bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd on bd.sid = bo.purchaseApplyMediumModelSid - where - bo.isDelete <> 1 - and LENGTH(offlineDate) >0 - and bo.sid in (select bbbbo.linkSid from anrui_buscenter.bus_sales_vehicle_order bbbbo) - group by bo.createOrgSid*/ - SELECT si.useOrgSid, - si.modelSid, - si.configSid modelConfigSid, - bo.sid, - ifnull(ab.counts, 0) as scount - FROM anrui_base.bus_vehicle_order bo - LEFT JOIN anrui_scm.scm_apply_inbound si ON bo.purchaseRequisitionSid = si.vehicleOrderSid - LEFT JOIN ( - SELECT bbbbo.linkSid, - ifnull(count(bbbbo.linkSid), 0) as counts - FROM anrui_buscenter.bus_sales_vehicle_order bbbbo - LEFT JOIN anrui_buscenter.bus_sales_order bb ON bb.sid = bbbbo.salesOrderSid - WHERE LENGTH(bb.nodeState) > 0 - AND bb.nodeState != '终止' - group by bbbbo.linkSid - ) ab ON ab.linkSid = bo.sid - WHERE (si.nodeState != '已办结' AND si.nodeState != '终止') - AND bo.isDelete <> 1 - AND LENGTH(offlineDate) > 0 - group by bo.createOrgSid - ) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`pcOrder_reserve` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 更新库存- 排产小计 - -/*UPDATE daily_report r - INNER JOIN ( - select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid - from ( - select bo.platformNo as scount, si.useOrgSid, si.modelSid, si.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_scm.scm_apply_inbound si on bo.purchaseRequisitionSid = si.vehicleOrderSid - where si.nodeState != '已办结' - and bo.isDelete <> 1 - and LENGTH(offlineDate) > 0 - union all - select bo.platformNo as scount, bo.useOrgSid, bd.vehicleSid modelSid, bd.configSid modelConfigSid - from anrui_base.bus_vehicle_order bo - left join anrui_base.bus_vehicle_apply_detail bd on bd.sid = bo.purchaseApplyMediumModelSid - where LENGTH(offlineDate) < 1) as v - GROUP BY v.`useOrgSid`, - v.`modelSid`, - v.`modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`pcOrder_subtotal` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ - -UPDATE daily_report -SET pcOrder_subtotal=pcOrder_reserve + pcOrder_unreserve -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 简易订单-每日 - -UPDATE daily_report r - INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid - from anrui_buscenter.bus_main_deposit bbm - left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid - where bbm.createTime like concat('%', CURDATE(), '%') - and bbm.nodeState = '已办结' - GROUP BY `useOrgSid`, - `modelSid`, - `modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`simpleOrder_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 简易订单-每月 - -UPDATE daily_report r - INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid - from anrui_buscenter.bus_main_deposit bbm - left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid - where bbm.createTime like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bbm.nodeState = '已办结' - GROUP BY `useOrgSid`, - `modelSid`, - `modelConfigSid` - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`simpleOrder_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 销售订单-本日-全款 -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = 1 - and bo.nodeState = '已办结' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_full_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 销售订单-本日-贷款 -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = 2 - and bo.nodeState = '已办结' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_loan_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); -/*-- 销售订单-本日-小计 -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', CURDATE(), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_subtotal_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ - --- 销售订单本日-小计 -UPDATE daily_report -SET saleOrder_subtotal_day=saleOrder_loan_day + saleOrder_full_day -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 销售订单-本月-全款 -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = 1 - and bo.nodeState = '已办结' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_full_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 销售订单-本月-贷款 -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = 2 - and bo.nodeState = '已办结' - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_loan_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 销售订单-本月-小计 -/*UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid - from anrui_buscenter.bus_sales_order bo - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid - where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_subtotal_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ -UPDATE daily_report -SET saleOrder_subtotal_month=saleOrder_loan_month + saleOrder_full_month -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 销售订单-待交车累计 -/*UPDATE daily_report r - INNER JOIN (select count(bs.id) as scount, bo.useOrgSid, bm.modelSid, bm.modelConfigSid - from anrui_base.base_vehicle_state bs - left join anrui_buscenter.bus_sales_order bo on bo.sid = bs.saleOrderSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid - where bs.busState = '401' - and (bs.finState = 1 or bs.carryVehicleState = 1) - group by bo.useOrgSid, bm.modelSid, bm.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_waitVeh_total` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ - -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount,bv.useOrgSid,bv.modelSid,bv.modelConfigSid,bo.contractNo from anrui_base.base_vehicle bv - left join anrui_buscenter.bus_sales_order_vehicle bov on bov.linkSid = bv.sid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bov.salesOrderSid - where bo.nodeState = '已办结' and bv.vehicleState <> '0002' - group by bo.useOrgSid, bv.modelSid, bv.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`saleOrder_waitVeh_total` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 销售 - - --- 本日销售全款 -UPDATE daily_report r - INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', CURDATE(), '%') - and bvoa.saleTypeKey = '001' - and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_full_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 本日销售贷款 -UPDATE daily_report r - INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', CURDATE(), '%') - and bvoa.saleTypeKey = '002' - and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_loan_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本日销售小计 -/*UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.salesDate like concat('%', CURDATE(), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_subtotal_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ -UPDATE daily_report -SET sale_subtotal_day=sale_loan_day + sale_full_day -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 本月销售全款 -UPDATE daily_report r - INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bvoa.saleTypeKey = '001' - and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_full_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 本月销售贷款 -UPDATE daily_report r - INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bvoa.saleTypeKey = '002' - and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_loan_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本月销售小计 -/*UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_subtotal_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ -UPDATE daily_report -SET sale_subtotal_month=sale_loan_month + sale_full_month -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 本年销售全款 -UPDATE daily_report r - INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bvoa.saleTypeKey = '001' - and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_full_year` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 本年销售贷款 -UPDATE daily_report r - INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bvoa.saleTypeKey = '002' - and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_loan_year` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本年销售小计 -/*UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`sale_subtotal_year` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ -UPDATE daily_report -SET sale_subtotal_year=sale_loan_year + sale_full_year -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本日买断的台数 - -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.solidDate like concat('%', CURDATE(), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`buyout_day` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本月买断的台数 - -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.solidDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`buyout_month` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 本年买断的台数 -UPDATE daily_report r - INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - where bv.solidDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - group by useOrgSid, modelSid, modelConfigSid - ) AS s ON r.useOrgSid = s.useOrgSid - AND r.vehModelSid = s.modelSid - AND r.vehMConfigSid = s.modelConfigSid -SET r.`buyout_year` = s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 交付-贷款-本日 -update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = '2' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_loan_day = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-全款-本日 -update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', CURDATE(), '%') - and bo.payTypeKey = '1' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_full_day = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-小计-本日 -/*update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', CURDATE(), '%') - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_subtotal_day = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ - -UPDATE daily_report -SET deliver_subtotal_day=deliver_full_day + deliver_loan_day -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-贷款-本月 -update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = '2' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_loan_month = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-全款-本月 -update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - and bo.payTypeKey = '1' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_full_month = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-小计-本月 -/*update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_subtotal_month = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ -UPDATE daily_report -SET deliver_subtotal_month=deliver_full_month + deliver_loan_month -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-贷款-本年 -update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bo.payTypeKey = '2' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_loan_year = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-全款-本年 -update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - and bo.payTypeKey = '1' - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_full_year = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 交付-小计-本年 -/*update daily_report r inner join ( - select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid - from anrui_buscenter.bus_handover_items bhi - left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid - left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid - left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid - where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - group by bh.useOrgSid, bm.modelSid, modelConfigSid) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.modelSid - and r.vehMConfigSid = s.modelConfigSid -set deliver_subtotal_year = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ -UPDATE daily_report -SET deliver_subtotal_year=deliver_full_year + deliver_loan_year -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 存销比 -update daily_report r inner join ( - select ddr.useOrgSid, - ddr.vehModelSid, - ddr.vehMConfigSid, - (select ifnull(sum(ss.scount), 0) as scount - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where (DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE - DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') - OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE - DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') - OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE - DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') - ) - and (bvoa.saleTypeKey = '001' or bvoa.saleTypeKey = '002') and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - where ss.useOrgSid = ddr.useOrgSid - and ss.modelSid = ddr.vehModelSid - and ss.modelConfigSid = ddr.vehMConfigSid) as subtotal - from daily_report ddr - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE() - group by ddr.useOrgSid, ddr.vehModelSid, ddr.vehMConfigSid -) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid -set saleOfStockRatio =if(ROUND(s.subtotal / 3, 2) = 0, - stock_subtotal + pcOrder_subtotal, - ROUND((stock_subtotal + pcOrder_subtotal) / ROUND(s.subtotal / 3, 2), 2)) -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 前三个月的销售台数之和 -update daily_report r inner join ( - select ddr.useOrgSid, - ddr.vehModelSid, - ddr.vehMConfigSid, - (select ifnull(sum(ss.scount), 0) as scount - from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid - from anrui_base.base_vehicle bv - left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid - left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid - where (DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE - DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') - OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE - DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') - OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE - DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') - ) - and (bvoa.saleTypeKey = '001' or bvoa.saleTypeKey = '002') and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or - length(bvo.materialTypeValue) = 0) - group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss - where ss.useOrgSid = ddr.useOrgSid - and ss.modelSid = ddr.vehModelSid - and ss.modelConfigSid = ddr.vehMConfigSid) as subtotal - from daily_report ddr - where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE() - group by ddr.useOrgSid, ddr.vehModelSid, ddr.vehMConfigSid -) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid -set saleAllToThree =s.subtotal -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - - - - --- 库存小计 -update daily_report -set stock_total = (stock_subtotal + pcOrder_subtotal) -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- ============================================== --- 欠款出库数量、欠款出库金额万元、金融未放款数量、金融未放款金额(万元) --- 欠款出库数量--截止当日欠款出库申请通过且未回清款的台数 -update daily_report r inner join (SELECT SUM(cc.scount) AS scount, - cc.useOrgSid, - cc.vehMConfigSid, - cc.vehModelSid - FROM ( - SELECT COUNT(a.id) AS scount, - a.useOrgSid, - a.NAME, - a.contractNo, - a.vehMConfigSid, - a.vehModelSid - FROM ( - SELECT bdad.id, - ba.useOrgSid, - bm.modelConfigSid AS vehMConfigSid, - bm.modelSid AS vehModelSid, - so.NAME, - SUM(s.reveivableMoney), - SUM(s.subscriptionMoney), - bo.contractNo - FROM anrui_buscenter.bus_delivered_apply_details bdad - LEFT JOIN anrui_buscenter.bus_delivered_apply ba ON ba.sid = bdad.applySid - LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.sid = bdad.busVinSid - LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid - LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid - LEFT JOIN ( - SELECT fd.reveivableMoney, - fd.busVinSid, - IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd - LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs - ON fs.receivablesSid = fd.sid - WHERE fd.kxState = '01' - AND fs.auditState = 3 - GROUP BY fd.sid - UNION ALL - SELECT - fd.reveivableMoney, - fd.busVinSid,0 AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd - left join (select fs.* from anrui_fin.fin_selected_receivables_detailed fs where fs.auditState = 3) s on s.receivablesSid = fd.sid - WHERE fd.kxState = '01' and s.id is null - GROUP BY - fd.sid - ) s ON s.busVinSid = bv.sid - LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid - WHERE ba.nodeState = '已办结' - AND ba.typeState = 1 - GROUP BY bv.sid, - ba.useOrgSid, - bm.modelSid, - bm.modelConfigSid - HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a - GROUP BY a.useOrgSid, - a.vehMConfigSid, - a.vehModelSid - UNION ALL - SELECT COUNT(a.id) AS scount, - a.useOrgSid, - a.name, - a.contractNo, - a.vehMConfigSid, - a.vehModelSid - FROM (SELECT bdad.id, - ba.useOrgSid, - bm.modelConfigSid AS vehMConfigSid, - bm.modelSid AS vehModelSid, - so.name, - SUM(s.reveivableMoney), - SUM(s.subscriptionMoney), - bo.contractNo - FROM anrui_buscenter.bus_arrears_carry_vehicle_details bdad - LEFT JOIN anrui_buscenter.bus_arrears_carry_vehicle_apply ba - ON ba.sid = bdad.applySid - LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.linkSid = bdad.vinSid - LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid - LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid - LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid - LEFT JOIN (SELECT fd.reveivableMoney, - fd.busVinSid, - IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd - LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs - ON fs.receivablesSid = fd.sid - WHERE fd.kxState = '01' - AND fs.auditState = 3 - GROUP BY fd.sid - UNION ALL - SELECT - fd.reveivableMoney, - fd.busVinSid,0 AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd - left join (select fs.* from anrui_fin.fin_selected_receivables_detailed fs where fs.auditState = 3) s on s.receivablesSid = fd.sid - WHERE fd.kxState = '01' and s.id is null - GROUP BY - fd.sid - ) s ON s.busVinSid = bv.sid - LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid - WHERE ba.nodeState = '已办结' - AND ba.paymentMethodKey = 1 - AND bbv.vehicleState = '0002' - GROUP BY bv.sid, - ba.useOrgSid, - bm.modelSid, - bm.modelConfigSid - HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a - GROUP BY a.useOrgSid, - a.vehMConfigSid, a.vehModelSid) cc - GROUP BY cc.useOrgSid, - cc.vehMConfigSid, - cc.vehModelSid -) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid -set arrears_carry_veh_count = s.scount -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 欠款出库金融--截止当日欠款出库申请通过且未回清款的台数欠款总额 -update daily_report r inner join (SELECT - sum( cc.scount ) AS scount, - cc.useOrgSid, - cc.vehMConfigSid, - cc.vehModelSid - FROM - ( - SELECT - SUM( a.scount ) AS scount, - a.useOrgSid, - a.NAME, - a.contractNo, - a.vehMConfigSid, - a.vehModelSid - FROM - ( - SELECT - bdad.id, - ba.useOrgSid, - bm.modelConfigSid AS vehMConfigSid, - bm.modelSid AS vehModelSid, - so.NAME, - SUM( s.reveivableMoney ), - SUM( s.subscriptionMoney ), - bo.contractNo, - ( - SUM( s.reveivableMoney ) - SUM( s.subscriptionMoney )) AS scount - FROM - anrui_buscenter.bus_delivered_apply_details bdad - LEFT JOIN anrui_buscenter.bus_delivered_apply ba ON ba.sid = bdad.applySid - LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.sid = bdad.busVinSid - LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid - LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid - LEFT JOIN ( - SELECT - fd.reveivableMoney, - fd.busVinSid, - IFNULL( SUM( fs.subscriptionMoney ), 0 ) AS subscriptionMoney - FROM - anrui_fin.fin_uncollected_receivables_detailed fd - LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs ON fs.receivablesSid = fd.sid - WHERE - fd.kxState = '01' - AND fs.auditState = 3 - GROUP BY - fd.sid - UNION ALL - SELECT - fd.reveivableMoney, - fd.busVinSid,0 AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd - left join (select fs.* from anrui_fin.fin_selected_receivables_detailed fs where fs.auditState = 3) s on s.receivablesSid = fd.sid - WHERE fd.kxState = '01' and s.id is null - GROUP BY - fd.sid - ) s ON s.busVinSid = bv.sid - LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid - WHERE - ba.nodeState = '已办结' - AND ba.typeState = 1 - GROUP BY - bv.sid, - ba.useOrgSid, - bm.modelSid, - bm.modelConfigSid - HAVING - SUM( s.reveivableMoney ) > SUM( s.subscriptionMoney )) a - GROUP BY - a.useOrgSid, - a.vehMConfigSid, - a.vehModelSid UNION ALL - SELECT - SUM( a.scount ) AS scount, - a.useOrgSid, - a.NAME, - a.contractNo, - a.vehMConfigSid, - a.vehModelSid - FROM - ( - SELECT - bdad.id, - ba.useOrgSid, - bm.modelConfigSid AS vehMConfigSid, - bm.modelSid AS vehModelSid, - so.NAME, - SUM( s.reveivableMoney ), - SUM( s.subscriptionMoney ), - bo.contractNo, - ( - SUM( s.reveivableMoney ) - SUM( s.subscriptionMoney )) AS scount - FROM - anrui_buscenter.bus_arrears_carry_vehicle_details bdad - LEFT JOIN anrui_buscenter.bus_arrears_carry_vehicle_apply ba ON ba.sid = bdad.applySid - LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.linkSid = bdad.vinSid - LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid - LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid - LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid - LEFT JOIN ( - SELECT - fd.reveivableMoney, - fd.busVinSid, - IFNULL( SUM( fs.subscriptionMoney ), 0 ) AS subscriptionMoney - FROM - anrui_fin.fin_uncollected_receivables_detailed fd - LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs ON fs.receivablesSid = fd.sid - WHERE - fd.kxState = '01' - AND fs.auditState = 3 - GROUP BY - fd.sid - UNION ALL - SELECT - fd.reveivableMoney, - fd.busVinSid,0 AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd - left join (select fs.* from anrui_fin.fin_selected_receivables_detailed fs where fs.auditState = 3) s on s.receivablesSid = fd.sid - WHERE fd.kxState = '01' and s.id is null - GROUP BY - fd.sid - ) s ON s.busVinSid = bv.sid - LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid - WHERE - ba.nodeState = '已办结' - AND ba.paymentMethodKey = 1 - AND bbv.vehicleState = '0002' - GROUP BY - bv.sid, - ba.useOrgSid, - bm.modelSid, - bm.modelConfigSid - HAVING - SUM( s.reveivableMoney ) > SUM( s.subscriptionMoney )) a - GROUP BY - a.useOrgSid, - a.vehMConfigSid, - a.vehModelSid - ) cc - GROUP BY - cc.useOrgSid, - cc.vehMConfigSid, - cc.vehModelSid -) s - on r.useOrgSid = s.useOrgSid - and r.vehModelSid = s.vehModelSid - and r.vehMConfigSid = s.vehMConfigSid -set arrears_carry_veh_amount = ROUND(s.scount / 10000, 2) -where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 金融未放款数量--- 截止当日贷款业务已出库且融资放款未认款的台数 -update daily_report r inner join ( - SELECT - count( a.id ) AS scount, - a.useOrgSid, - a.NAME, - a.contractNo, - a.vehMConfigSid, - a.vehModelSid - FROM - (SELECT bv.id, - bo.useOrgSid, - bm.modelConfigSid AS vehMConfigSid, - bm.modelSid AS vehModelSid, - so.NAME, - SUM(s.reveivableMoney), - SUM(s.subscriptionMoney), - bo.contractNo - from anrui_buscenter.bus_sales_order_vehicle bv - left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid - left join anrui_base.base_vehicle bbv on bbv.sid = bv.linkSid - left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bv.salesOrderSid - LEFT JOIN ( - SELECT - fd.reveivableMoney, - fd.busVinSid, - IFNULL( SUM( fs.subscriptionMoney ), 0 ) AS subscriptionMoney - FROM - anrui_fin.fin_uncollected_receivables_detailed fd - LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs ON fs.receivablesSid = fd.sid - WHERE - fd.kxState = '01' - AND fs.auditState = 3 - and fd.receivablesName = '融资放款' - GROUP BY - fd.sid - UNION ALL - SELECT - fd.reveivableMoney, - fd.busVinSid,0 AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd WHERE fd.kxState = '01' AND fd.receivablesName = '融资放款' AND fd.sid NOT IN (SELECT fs.`receivablesSid` FROM anrui_fin.fin_selected_receivables_detailed fs WHERE fs.`auditState` = 3 AND fs.`receivablesName` = '融资放款') - GROUP BY - fd.sid - ) s ON s.busVinSid = bv.sid - LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid - where bo.payTypeKey = 2 - - and bbv.vehicleState = '0002' - group by bv.sid, bo.useOrgSid, bm.modelSid, bm.modelConfigSid - HAVING - SUM( s.reveivableMoney ) > SUM( s.subscriptionMoney )) a - GROUP BY - a.useOrgSid, - a.vehMConfigSid, - a.vehModelSid) as s on - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.vehModelSid AND r.vehMConfigSid = s.vehMConfigSid -SET r.`loan_not_count`=s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - --- 金融未放款金额-- 截止当日贷款业务已出库且融资放款未认款的台数融资放款金额之和 - -update daily_report r inner join ( - SELECT - SUM( a.scount ) AS scount, - a.useOrgSid, - a.NAME, - a.contractNo, - a.vehMConfigSid, - a.vehModelSid - FROM - (SELECT - bv.id, - bo.useOrgSid, - bm.modelConfigSid AS vehMConfigSid, - bm.modelSid AS vehModelSid, - so.NAME, - SUM( s.reveivableMoney ), - SUM( s.subscriptionMoney ), - bo.contractNo, - ( - SUM( s.reveivableMoney ) - SUM( s.subscriptionMoney )) AS scount - FROM anrui_buscenter.bus_sales_order_vehicle bv - LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid - LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid - LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bv.salesOrderSid - LEFT JOIN ( - SELECT - fd.reveivableMoney, - fd.busVinSid, - IFNULL( SUM( fs.subscriptionMoney ), 0 ) AS subscriptionMoney - FROM - anrui_fin.fin_uncollected_receivables_detailed fd - LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs ON fs.receivablesSid = fd.sid - WHERE - fd.kxState = '01' - AND fs.auditState = 3 - AND fd.receivablesName = '融资放款' - GROUP BY - fd.sid - UNION ALL - SELECT - fd.reveivableMoney, - fd.busVinSid,0 AS subscriptionMoney - FROM anrui_fin.fin_uncollected_receivables_detailed fd WHERE fd.kxState = '01' AND fd.receivablesName = '融资放款' AND fd.sid NOT IN (SELECT fs.`receivablesSid` FROM anrui_fin.fin_selected_receivables_detailed fs WHERE fs.`auditState` = 3 AND fs.`receivablesName` = '融资放款') - GROUP BY - fd.sid - ) s ON s.busVinSid = bv.sid - LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid - WHERE bo.payTypeKey = 2 - - AND bbv.vehicleState = '0002' - GROUP BY bv.sid, bo.useOrgSid, bm.modelSid, bm.modelConfigSid - HAVING - SUM( s.reveivableMoney ) > SUM( s.subscriptionMoney )) a - GROUP BY - a.useOrgSid, - a.vehMConfigSid, - a.vehModelSid) as s on - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.vehModelSid AND r.vehMConfigSid = s.vehMConfigSid -SET r.`loan_not_amount`=ROUND(s.scount / 10000, 2) -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - --- 全年厂家开票数 -UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE manDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid -SET r.`manufacturer_invoicing_year`=s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/databases/报表新增修改.sql b/doc/databases/报表新增修改.sql deleted file mode 100644 index 42dd00c09f..0000000000 --- a/doc/databases/报表新增修改.sql +++ /dev/null @@ -1,77 +0,0 @@ -INSERT INTO daily_report(busOrgSid, busOrgName, useOrgSid, useOrgName, brandSid, brandName, vehModelSid, vehMConfigSid) -SELECT DISTINCT o.`psid` AS busOrgSid, - op.`name` AS busOrgName, - o.`sid` AS useOrgSid, - o.`name` AS useOrgName, - m.`carBrand` AS brandSid, - m.`brandName` AS brandName, - bv.`modelSid` AS vehModelSid, - bv.`modelConfigSid` AS vehMConfigSid -FROM anrui_base.`base_vehicle` bv - LEFT JOIN anrui_base.`base_vehicle_model` m ON m.sid = bv.`modelSid` - LEFT JOIN anrui_portal.`sys_organization` o ON bv.`useOrgSid` = o.`sid` - JOIN anrui_portal.`sys_organization` op ON op.sid = o.`psid` -WHERE bv.vehicleState != '0004' - AND bv.isDelete != 1; - - - --- 修改 --- 更新库存-未定 -UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState <> '02' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid -SET r.`stock_unreserve`=s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 更新库存-已定 -UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState = '02' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid -SET r.`stock_reserve`=s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 更新库存-小计 -UPDATE daily_report -SET stock_subtotal=stock_unreserve + stock_reserve -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 更新库存-买断-未定 -UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState <> '02' - AND settlementStatus = '2' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid -SET r.`stock_buyout_unreserve`=s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 更新库存-买断-已定 -UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` - FROM anrui_base.`base_vehicle` - WHERE vehicleState <> '0002' - AND vehicleState <> '0004' - AND vehicleState <> '0007' - AND isDelete <> 1 - AND lockedState = '02' - AND settlementStatus = '2' - GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON - r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid -SET r.`stock_buyout_reserve`=s.scount -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); --- 更新库存-买断-小计 -UPDATE daily_report -SET `stock_buyout_subtotal`=`stock_buyout_unreserve` + `stock_buyout_reserve` -WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); \ No newline at end of file diff --git a/doc/databases/统计报表.sql b/doc/databases/统计报表.sql new file mode 100644 index 0000000000..2dcf79bbb1 --- /dev/null +++ b/doc/databases/统计报表.sql @@ -0,0 +1,10 @@ +CREATE DEFINER=`root`@`%` PROCEDURE `pro_daily_report`() +BEGIN + -- 创建数据过程 + CALL pro_daily_report_create(); + -- 更新数据过程 + CALL pro_daily_report_update(); + -- 清理所有为0的数据过程 + CALL pro_daily_report_clear(); + +END \ No newline at end of file diff --git a/doc/databases/统计报表clear.sql b/doc/databases/统计报表clear.sql new file mode 100644 index 0000000000..409a8ef8b0 --- /dev/null +++ b/doc/databases/统计报表clear.sql @@ -0,0 +1,7 @@ +CREATE DEFINER=`root`@`%` PROCEDURE `pro_daily_report_clear`() +BEGIN + -- 清理所有数据为0的记录 + DELETE FROM `daily_report` WHERE `stock_total`=0 AND `stock_subtotal`=0 AND `simpleOrder_month`=0 AND `saleOrder_subtotal_month`=0 AND `saleOrder_waitVeh_total`=0 AND `sale_subtotal_year`=0 AND `deliver_subtotal_year`=0 AND `manufacturer_invoicing_year`=0 AND `buyout_year`=0 AND `arrears_carry_veh_count`=0 AND `loan_not_count`=0 and saleAllToThree = 0; + -- 删除临时表中数据 + DELETE FROM daily_report_temp; +END \ No newline at end of file diff --git a/doc/databases/统计报表create.sql b/doc/databases/统计报表create.sql new file mode 100644 index 0000000000..1ce26bd783 --- /dev/null +++ b/doc/databases/统计报表create.sql @@ -0,0 +1,16 @@ +CREATE DEFINER=`root`@`%` PROCEDURE `pro_daily_report_create`() +BEGIN + -- 生成记录,从车辆台账中获取非厂家退车和删除的车型、配置 + -- INSERT INTO daily_report(busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid,vehModeName,vehMConfigName ) SELECT o.`psid` AS busOrgSid,op.`name` AS busOrgName,mc.`useOrgSid`,o.`name` AS useOrgName,m.`carBrand` AS brandSid,m.`brandName`,mc.`modelSid` AS vehModelSid,mc.`configurationItemsSid` AS vehMConfigSid,m.`modelName` AS vehModeName,c.`configName` AS vehMConfigName FROM anrui_base.`base_vehmodel_config` mc JOIN anrui_base.`base_model_config` c ON c.sid=mc.`configurationItemsSid` JOIN anrui_base.`base_vehicle_model` m ON m.sid=mc.`modelSid` JOIN anrui_portal.`sys_organization` o ON mc.`useOrgSid`=o.`sid` JOIN anrui_portal.`sys_organization` op ON op.sid=o.`psid`; + -- INSERT INTO daily_report(busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid) SELECT DISTINCT o.`psid` AS busOrgSid,op.`name` AS busOrgName,bv.`useOrgSid`,bv.`useOrgName`,bv.`carBrandSid` AS brandSid,bv.`carBrandName` AS brandName,bv.`modelSid` AS vehModelSid,bv.`modelConfigSid` AS vehMConfigSid FROM anrui_base.`base_vehicle` bv JOIN anrui_portal.`sys_organization` o ON bv.`useOrgSid`=o.`sid` JOIN anrui_portal.`sys_organization` op ON op.sid=o.`psid` WHERE bv.vehicleState!='0004' AND bv.isDelete!=1; + -- INSERT INTO daily_report(busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid) SELECT DISTINCT o.`psid` AS busOrgSid,op.`name` AS busOrgName,o.`sid` as useOrgSid,o.`name` as useOrgName,bv.`carBrandSid` AS brandSid,bv.`carBrandName` AS brandName,bv.`modelSid` AS vehModelSid,bv.`modelConfigSid` AS vehMConfigSid FROM anrui_base.`base_vehicle` bv JOIN anrui_portal.`sys_organization` o ON bv.`useOrgSid`=o.`sid` JOIN anrui_portal.`sys_organization` op ON op.sid=o.`psid` WHERE bv.vehicleState!='0004' AND bv.isDelete!=1; + -- 插入当天日期数据前,先删除当天的旧数据 + DELETE FROM daily_report WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 从车辆台账中生成数据,到临时表中 + INSERT INTO daily_report_temp(busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid) SELECT DISTINCT o.`psid` AS busOrgSid,op.`name` AS busOrgName,o.`sid` AS useOrgSid,o.`name` AS useOrgName,m.`carBrand` AS brandSid,m.`brandName` AS brandName,bv.`modelSid` AS vehModelSid,bv.`modelConfigSid` AS vehMConfigSid FROM anrui_base.`base_vehicle` bv LEFT JOIN anrui_base.`base_vehicle_model` m ON m.sid=bv.`modelSid` LEFT JOIN anrui_portal.`sys_organization` o ON bv.`useOrgSid`=o.`sid` JOIN anrui_portal.`sys_organization` op ON op.sid=o.`psid` WHERE bv.vehicleState!='0004' AND bv.isDelete!=1; + -- 再从厂家采购订单中获取排产中的数据到临时表中 + INSERT INTO daily_report_temp(busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid) SELECT DISTINCT o.`psid` AS busOrgSid,op.`name` AS busOrgName,o.`sid` AS useOrgSid,o.`name` AS useOrgName,va.`carBrandSid`AS brandSid,va.`carBrandName` AS brandName,vad.`vehicleSid` AS vehModelSid,vad.`configSid` AS vehMConfigSid FROM anrui_base.`bus_vehicle_apply_detail` vad JOIN anrui_base.`bus_vehicle_apply` va ON va.sid=vad.`applySid` JOIN anrui_portal.`sys_organization` o ON va.`createOrgSid`=o.`sid` JOIN anrui_portal.`sys_organization` op ON op.sid=o.`psid` WHERE va.`nodeState`='已办结'; + -- 把临时表中数据去重后,插入到正式表 + INSERT INTO daily_report(busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid) SELECT DISTINCT busOrgSid,busOrgName,useOrgSid,useOrgName,brandSid,brandName,vehModelSid,vehMConfigSid FROM daily_report_temp; + +END \ No newline at end of file diff --git a/doc/databases/统计报表update.sql b/doc/databases/统计报表update.sql new file mode 100644 index 0000000000..881e51eec9 --- /dev/null +++ b/doc/databases/统计报表update.sql @@ -0,0 +1,1622 @@ +CREATE + DEFINER = `root`@`%` PROCEDURE `pro_daily_report_update`() +BEGIN + -- 更新库存-未定(库存状态不是出库0002且不是内销0007、且不是退库0004的。非删除、销售订单未锁定) + UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` + FROM anrui_base.`base_vehicle` + WHERE vehicleState <> '0002' + AND vehicleState <> '0004' + AND vehicleState <> '0007' + AND isDelete <> 1 + AND lockedState <> '02' + GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid + SET r.`stock_unreserve`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 更新库存-已定(库存状态不是出库0002且不是内销0007且不是退库0004的,非删除,锁定状态为销售订单锁定02) + UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` + FROM anrui_base.`base_vehicle` + WHERE vehicleState <> '0002' + AND vehicleState <> '0004' + AND vehicleState <> '0007' + AND isDelete <> 1 + AND lockedState = '02' + GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid + SET r.`stock_reserve`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 更新库存-小计 + UPDATE daily_report + SET stock_subtotal=stock_unreserve + stock_reserve + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 更新库存-买断-未定(库存状态不是出库0002且不是内销0007且不是退库0004的,非删除,非销售订单锁定、已买断) + UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` + FROM anrui_base.`base_vehicle` + WHERE vehicleState <> '0002' + AND vehicleState <> '0004' + AND vehicleState <> '0007' + AND isDelete <> 1 + AND lockedState <> '02' + AND settlementStatus = '2' + GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid + SET r.`stock_buyout_unreserve`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 更新库存-买断-已定(库存状态不是出库0002且不是内销0007且不是退库0004的,非删除,销售订单锁定,已买断) + UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` + FROM anrui_base.`base_vehicle` + WHERE vehicleState <> '0002' + AND vehicleState <> '0004' + AND vehicleState <> '0007' + AND isDelete <> 1 + AND lockedState = '02' + AND settlementStatus = '2' + GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid + SET r.`stock_buyout_reserve`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 更新库存-买断-小计 + UPDATE daily_report + SET `stock_buyout_subtotal`=`stock_buyout_unreserve` + `stock_buyout_reserve` + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + -- 更新库存-排产-未定(排产订单中未入库,且未被销售订单锁定) + UPDATE daily_report r + INNER JOIN ( + select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid, v.carBrand, v.orderNo + from ( + select ifnull(si.num, 0) as scount, + si.useOrgSid, + si.modelSid, + si.configSid modelConfigSid, + bbm.carBrand, + bbo.orderNo + from anrui_base.bus_vehicle_apply bo + left join anrui_scm.scm_apply_inbound si on bo.sid = si.vehicleOrderSid + left join anrui_base.bus_vehicle_order bbo on bbo.purchaseRequisitionSid = bo.sid + left join anrui_base.base_vehicle_model bbm on bbm.sid = si.modelSid + where (si.nodeState != '已办结' and si.nodeState != '终止') + and bo.isDelete <> 1 + and bo.applyTypeKey = '001' + and bo.sid not in (select bbbbo.linkSid + from anrui_buscenter.bus_sales_vehicle_order bbbbo + LEFT JOIN anrui_buscenter.bus_sales_order bb ON bb.sid = bbbbo.salesOrderSid + WHERE LENGTH(bb.nodeState) > 0 + AND bb.nodeState != '终止' + and bb.nodeState != '销售订单申请' + group by bbbbo.linkSid) + group by si.applicationCode, bo.createOrgSid, si.modelSid, si.configSid + union all + select ifnull(sum(bo.platformNo), 0) - ifnull(sum(ab.counts), 0) as scount, + bo.useOrgSid, + bd.vehicleSid, + bd.configSid modelConfigSid, + bbm.carBrand, + bo.orderNo + + from anrui_base.bus_vehicle_order bo + left join anrui_base.bus_vehicle_apply_detail bd + on bd.sid = bo.purchaseApplyMediumModelSid + left join anrui_base.base_vehicle_model bbm on bbm.sid = bd.vehicleSid + LEFT JOIN ( + SELECT bbbbo.linkSid, + ifnull(sum(bbbbo.usingNum), 0) as counts + FROM anrui_buscenter.bus_sales_vehicle_order bbbbo + LEFT JOIN anrui_buscenter.bus_sales_order bb ON bb.sid = bbbbo.salesOrderSid + WHERE LENGTH(bb.nodeState) > 0 + AND bb.nodeState != '终止' + and bb.nodeState != '销售订单申请' + group by bbbbo.linkSid + ) ab ON ab.linkSid = bo.sid + where bo.isDelete <> 1 + and (offlineDate is null or offlineDate = '') + and bo.orderStatus != '已作废' + and LENGTH(bo.orderNo) > 0 + group by bo.sid, bo.createOrgSid, bd.vehicleSid, bd.configSid + union all + select ifnull(si.num, 0) as scount, + si.useOrgSid, + si.modelSid, + si.configSid modelConfigSid, + bbm.carBrand, + 0 + from anrui_base.bus_vehicle_apply bo + left join anrui_scm.scm_apply_inbound si on bo.sid = si.vehicleOrderSid + left join anrui_base.base_vehicle_model bbm on bbm.sid = si.modelSid + where (si.nodeState != '已办结' and si.nodeState != '终止') + and bo.isDelete <> 1 + and bo.applyTypeKey = '004' + group by si.applicationCode, bo.createOrgSid, si.modelSid, si.configSid + ) as v + GROUP BY v.`useOrgSid`, + v.`modelSid`, + v.`modelConfigSid` + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`pcOrder_unreserve` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 更新库存-排产已定(未入库且被销售订单锁定的台数) + UPDATE daily_report r + INNER JOIN ( + select sum(v.scount) as scount, v.useOrgSid, v.modelSid, v.modelConfigSid + from ( + SELECT si.useOrgSid, + si.modelSid, + si.configSid modelConfigSid, + bo.sid, + ifnull(ab.counts, 0) as scount + FROM anrui_base.bus_vehicle_apply bo + LEFT JOIN anrui_scm.scm_apply_inbound si ON bo.sid = si.vehicleOrderSid + LEFT JOIN ( + SELECT bbbbo.linkSid, + ifnull(sum(bbbbo.usingNum), 0) as counts + FROM anrui_buscenter.bus_sales_vehicle_order bbbbo + LEFT JOIN anrui_buscenter.bus_sales_order bb ON bb.sid = bbbbo.salesOrderSid + WHERE LENGTH(bb.nodeState) > 0 + AND bb.nodeState != '终止' + and bb.nodeState != '销售订单申请' + group by bbbbo.linkSid + ) ab ON ab.linkSid = bo.sid + WHERE (si.nodeState != '已办结' AND si.nodeState != '终止') + AND bo.isDelete <> 1 + group by si.applicationCode, bo.createOrgSid, si.modelSid, si.configSid + UNION ALL + SELECT bo.useOrgSid, + bd.vehicleSid modelSid, + bd.configSid, + bo.sid, + ifnull(ab.counts, 0) as scount + FROM anrui_base.bus_vehicle_order bo + LEFT JOIN anrui_base.bus_vehicle_apply_detail bd + ON bd.sid = bo.purchaseApplyMediumModelSid + LEFT JOIN anrui_base.base_vehicle_model bbm ON bbm.sid = bd.vehicleSid + LEFT JOIN ( + SELECT bbbbo.linkSid, + ifnull(sum(bbbbo.usingNum), 0) as counts + FROM anrui_buscenter.bus_sales_vehicle_order bbbbo + LEFT JOIN anrui_buscenter.bus_sales_order bb ON bb.sid = bbbbo.salesOrderSid + WHERE LENGTH(bb.nodeState) > 0 + AND bb.nodeState != '终止' + and bb.nodeState != '销售订单申请' + group by bbbbo.linkSid + ) ab ON ab.linkSid = bo.sid + WHERE bo.isDelete <> 1 + AND LENGTH(offlineDate) = 0 + AND bo.orderStatus != '已作废' + group by bo.createOrgSid, bd.vehicleSid, bd.configSid + ) as v + GROUP BY v.`useOrgSid`, + v.`modelSid`, + v.`modelConfigSid` + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`pcOrder_reserve` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 更新库存- 排产小计 + + UPDATE daily_report + SET pcOrder_subtotal=pcOrder_reserve + pcOrder_unreserve + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 简易订单-每日(简易订单今日已办结的) + + UPDATE daily_report r + INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid + from anrui_buscenter.bus_main_deposit bbm + left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid + where bbm.createTime like concat('%', CURDATE(), '%') + and bbm.nodeState = '已办结' + GROUP BY `useOrgSid`, + `modelSid`, + `modelConfigSid` + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`simpleOrder_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 简易订单-每月(简易订单本月已办结的) + + UPDATE daily_report r + INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid + from anrui_buscenter.bus_main_deposit bbm + left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid + where bbm.createTime like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bbm.nodeState = '已办结' + GROUP BY `useOrgSid`, + `modelSid`, + `modelConfigSid` + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`simpleOrder_month` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 销售订单-本日-全款 + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid + from anrui_buscenter.bus_sales_order bo + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid + where bo.closingDate like concat('%', CURDATE(), '%') + and bo.payTypeKey = 1 + and bo.nodeState = '已办结' + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`saleOrder_full_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); +-- 销售订单-本日-贷款 + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid + from anrui_buscenter.bus_sales_order bo + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid + where bo.closingDate like concat('%', CURDATE(), '%') + and bo.payTypeKey = 2 + and bo.nodeState = '已办结' + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`saleOrder_loan_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + /*-- 销售订单-本日-小计 + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid + from anrui_buscenter.bus_sales_order bo + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid + where bo.closingDate like concat('%', CURDATE(), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`saleOrder_subtotal_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + +-- 销售订单本日-小计 + UPDATE daily_report + SET saleOrder_subtotal_day=saleOrder_loan_day + saleOrder_full_day + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 销售订单-本月-全款 + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid + from anrui_buscenter.bus_sales_order bo + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid + where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bo.payTypeKey = 1 + and bo.nodeState = '已办结' + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`saleOrder_full_month` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); +-- 销售订单-本月-贷款 + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid + from anrui_buscenter.bus_sales_order bo + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid + where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bo.payTypeKey = 2 + and bo.nodeState = '已办结' + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`saleOrder_loan_month` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 销售订单-本月-小计 +/*UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bm.modelSid, bm.modelConfigSid, bo.useOrgSid + from anrui_buscenter.bus_sales_order bo + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid + where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid +SET r.`saleOrder_subtotal_month` = s.scount +WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + UPDATE daily_report + SET saleOrder_subtotal_month=saleOrder_loan_month + saleOrder_full_month + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 销售订单-待交车累计 +/*UPDATE daily_report r + INNER JOIN (select count(bs.id) as scount, bo.useOrgSid, bm.modelSid, bm.modelConfigSid + from anrui_base.base_vehicle_state bs + left join anrui_buscenter.bus_sales_order bo on bo.sid = bs.saleOrderSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid + where bs.busState = '401' + and (bs.finState = 1 or bs.carryVehicleState = 1) + group by bo.useOrgSid, bm.modelSid, bm.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid +SET r.`saleOrder_waitVeh_total` = s.scount +WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + +-- UPDATE daily_report r +-- INNER JOIN (select count(bv.id) as scount,bv.useOrgSid,bv.modelSid,bv.modelConfigSid,bo.contractNo from anrui_base.base_vehicle bv +-- left join anrui_buscenter.bus_sales_order_vehicle bov on bov.linkSid = bv.sid +-- left join anrui_buscenter.bus_sales_order bo on bo.sid = bov.salesOrderSid +-- where bo.nodeState = '已办结' and (bv.vehicleState = '0001' or bv.vehicleState = '0005') +-- group by bo.useOrgSid, bv.modelSid, bv.modelConfigSid +-- ) AS s ON r.useOrgSid = s.useOrgSid +-- AND r.vehModelSid = s.modelSid +-- AND r.vehMConfigSid = s.modelConfigSid +-- SET r.`saleOrder_waitVeh_total` = s.scount +-- WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- -- 销售订单-待交车累计(销售订单已办结且库存状态为库存和在途的)已办结的销售订单的台数-已出库的台数 + UPDATE daily_report r + INNER JOIN (select sum(c.scount) as scount, c.useOrgSid, c.modelSid, c.modelConfigSid + from (select (b.scount - b.ssscount1 - b.ssscount) as scount, + b.ssscount1 s1, + b.ssscount s2, + b.useOrgSid, + b.modelConfigSid, + b.modelSid, + b.contractNo + from (SELECT a.scount, + a.useOrgSid, + a.modelConfigSid, + a.modelSid, + a.contractNo, + (SELECT count(bov.id) AS scount + from anrui_buscenter.bus_sales_order_vehicle bov + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bov.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + left join anrui_base.base_vehicle_state bs on bs.busSid = bov.sid + WHERE bo.nodeState = '已办结' + AND (bs.busState = '602' or bs.busState = '501' or bs.busState = '502' or + bs.busState = '503' or bs.busState = '601' or bs.busState = '602') + and bo.useOrgSid = a.useOrgSid + and bm.modelSid = a.modelSid + and bm.modelConfigSid = a.modelConfigSid + and bo.contractNo = a.contractNo) as ssscount1, + (SELECT count(bov.id) AS scount + FROM anrui_base.base_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bov ON bov.linkSid = bv.sid + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bov.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + left join anrui_base.base_vehicle_state bs on bs.busSid = bov.sid + WHERE bo.nodeState = '已办结' + AND bv.vehicleState = '0002' + and bo.useOrgSid = a.useOrgSid + and bm.modelSid = a.modelSid + and bm.modelConfigSid = a.modelConfigSid + and bs.busSid is null + and bo.contractNo = a.contractNo) as ssscount + FROM ( + SELECT count(bov.id) AS scount, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + FROM anrui_buscenter.bus_sales_order_vehicle bov + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bov.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + WHERE bo.nodeState = '已办结' + GROUP BY bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid, + bo.contractNo + ) a) b) c + group by c.useOrgSid, c.modelSid, c.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`saleOrder_waitVeh_total` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 本日销售全款(销售日期为本日、全款、主车(包含value为空的)) + UPDATE daily_report r + INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where bv.salesDate like concat('%', CURDATE(), '%') + and bvoa.saleTypeKey = '001' + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`sale_full_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); +-- 本日销售贷款(贷款、销售日期为本日、主车(包含value为空的)) + UPDATE daily_report r + INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where bv.salesDate like concat('%', CURDATE(), '%') + and bvoa.saleTypeKey = '002' + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`sale_loan_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 本日销售小计 +/*UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + where bv.salesDate like concat('%', CURDATE(), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid +SET r.`sale_subtotal_day` = s.scount +WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + UPDATE daily_report + SET sale_subtotal_day=sale_loan_day + sale_full_day + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 本月销售全款(全款、销售日期本月、主车(包含value为空的)) + UPDATE daily_report r + INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bvoa.saleTypeKey = '001' + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`sale_full_month` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); +-- 本月销售贷款(贷款、销售日期为本月、主车(包含value为空的)) + UPDATE daily_report r + INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bvoa.saleTypeKey = '002' + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`sale_loan_month` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 本月销售小计 +/*UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid +SET r.`sale_subtotal_month` = s.scount +WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + UPDATE daily_report + SET sale_subtotal_month=sale_loan_month + sale_full_month + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 本年销售全款(全款、销售日期为本年、主车(包含value为空的)) + UPDATE daily_report r + INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + and bvoa.saleTypeKey = '001' + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`sale_full_year` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); +-- 本年销售贷款(贷款、销售日期本年、主车(value为空的))) + UPDATE daily_report r + INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + and bvoa.saleTypeKey = '002' + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`sale_loan_year` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 本年销售小计 +/*UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid +SET r.`sale_subtotal_year` = s.scount +WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + UPDATE daily_report + SET sale_subtotal_year=sale_loan_year + sale_full_year + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 本日买断的台数 + + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + where bv.solidDate like concat('%', CURDATE(), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`buyout_day` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 本月买断的台数 + + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + where bv.solidDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`buyout_month` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 本年买断的台数 + UPDATE daily_report r + INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + where bv.solidDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + group by useOrgSid, modelSid, modelConfigSid + ) AS s ON r.useOrgSid = s.useOrgSid + AND r.vehModelSid = s.modelSid + AND r.vehMConfigSid = s.modelConfigSid + SET r.`buyout_year` = s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 交付-贷款-本日 + update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', CURDATE(), '%') + and bo.payTypeKey = '2' + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid + set deliver_loan_day = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 交付-全款-本日 + update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', CURDATE(), '%') + and bo.payTypeKey = '1' + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid + set deliver_full_day = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 交付-小计-本日 +/*update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', CURDATE(), '%') + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid +set deliver_subtotal_day = s.scount +where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + + UPDATE daily_report + SET deliver_subtotal_day=deliver_full_day + deliver_loan_day + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 交付-贷款-本月 + update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bo.payTypeKey = '2' + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid + set deliver_loan_month = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 交付-全款-本月 + update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + and bo.payTypeKey = '1' + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid + set deliver_full_month = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 交付-小计-本月 +/*update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid +set deliver_subtotal_month = s.scount +where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + UPDATE daily_report + SET deliver_subtotal_month=deliver_full_month + deliver_loan_month + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 交付-贷款-本年 + update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + and bo.payTypeKey = '2' + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid + set deliver_loan_year = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 交付-全款-本年 + update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + and bo.payTypeKey = '1' + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid + set deliver_full_year = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 交付-小计-本年 +/*update daily_report r inner join ( + select count(bhi.id) as scount, bm.modelSid, bm.modelConfigSid, bh.useOrgSid + from anrui_buscenter.bus_handover_items bhi + left join anrui_buscenter.bus_handover bh on bh.sid = bhi.handoverSid + left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bh.orderSid + left join anrui_buscenter.bus_sales_order_vehicle bv on bhi.vinSid = bv.linkSid + left join anrui_buscenter.bus_sales_order bo on bo.sid = bh.orderSid + where bh.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + group by bh.useOrgSid, bm.modelSid, modelConfigSid) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.modelSid + and r.vehMConfigSid = s.modelConfigSid +set deliver_subtotal_year = s.scount +where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE();*/ + UPDATE daily_report + SET deliver_subtotal_year=deliver_full_year + deliver_loan_year + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 存销比 + update daily_report r inner join ( + select ddr.useOrgSid, + ddr.vehModelSid, + ddr.vehMConfigSid, + (select ifnull(sum(ss.scount), 0) as scount + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where (DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE + DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') + OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE + DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') + OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE + DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') + ) + and (bvoa.saleTypeKey = '001' or bvoa.saleTypeKey = '002') + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + where ss.useOrgSid = ddr.useOrgSid + and ss.modelSid = ddr.vehModelSid + and ss.modelConfigSid = ddr.vehMConfigSid) as subtotal + from daily_report ddr + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE() + group by ddr.useOrgSid, ddr.vehModelSid, ddr.vehMConfigSid + ) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.vehModelSid + and r.vehMConfigSid = s.vehMConfigSid + set saleOfStockRatio =if(ROUND(s.subtotal / 3, 2) = 0, + stock_subtotal + pcOrder_subtotal, + ROUND((stock_subtotal + pcOrder_subtotal) / ROUND(s.subtotal / 3, 2), 2)) + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 前三个月的销售台数之和 + update daily_report r inner join ( + select ddr.useOrgSid, + ddr.vehModelSid, + ddr.vehMConfigSid, + (select ifnull(sum(ss.scount), 0) as scount + from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid + from anrui_base.base_vehicle bv + left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid + left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid + where (DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE + DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') + OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE + DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') + OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE + DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') + ) + and (bvoa.saleTypeKey = '001' or bvoa.saleTypeKey = '002') + and (bvo.materialTypeKey = '001' or bvo.materialTypeValue is null or + length(bvo.materialTypeValue) = 0) + group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss + where ss.useOrgSid = ddr.useOrgSid + and ss.modelSid = ddr.vehModelSid + and ss.modelConfigSid = ddr.vehMConfigSid) as subtotal + from daily_report ddr + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE() + group by ddr.useOrgSid, ddr.vehModelSid, ddr.vehMConfigSid + ) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.vehModelSid + and r.vehMConfigSid = s.vehMConfigSid + set saleAllToThree =s.subtotal + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 库存小计 + update daily_report + set stock_total = (stock_subtotal + pcOrder_subtotal) + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + -- 欠款出库数量--截止当日欠款出库申请通过且未回清款的台数 +-- 欠款出库数量--截止当日欠款出库申请通过且未回清款的台数(欠款出库申请通过,且未认完款的台数总和加上欠款提车申请通过,且全款已出库未认完款的台数总和) + update daily_report r inner join (SELECT SUM(cc.scount) AS scount, + cc.useOrgSid, + cc.vehMConfigSid, + cc.vehModelSid + FROM ( + SELECT COUNT(a.id) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bdad.id, + ba.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo + FROM anrui_buscenter.bus_delivered_apply_details bdad + LEFT JOIN anrui_buscenter.bus_delivered_apply ba ON ba.sid = bdad.applySid + LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.sid = bdad.busVinSid + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + left join (select fs.* + from anrui_fin.fin_selected_receivables_detailed fs + where fs.auditState = 3) s + on s.receivablesSid = fd.sid + WHERE fd.kxState = '01' + and s.id is null + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid + WHERE ba.nodeState = '已办结' + AND ba.typeState = 1 + GROUP BY bv.sid, + ba.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + UNION ALL + SELECT COUNT(a.id) AS scount, + a.useOrgSid, + a.name, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM (SELECT bdad.id, + ba.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.name, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo + FROM anrui_buscenter.bus_arrears_carry_vehicle_details bdad + LEFT JOIN anrui_buscenter.bus_arrears_carry_vehicle_apply ba + ON ba.sid = bdad.applySid + LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.linkSid = bdad.vinSid + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN (SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + left join (select fs.* + from anrui_fin.fin_selected_receivables_detailed fs + where fs.auditState = 3) s + on s.receivablesSid = fd.sid + WHERE fd.kxState = '01' + and s.id is null + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid + WHERE ba.nodeState = '已办结' + AND ba.paymentMethodKey = 1 + AND bbv.vehicleState = '0002' + GROUP BY bv.sid, + ba.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.useOrgSid, + a.vehMConfigSid, a.vehModelSid) cc + GROUP BY cc.useOrgSid, + cc.vehMConfigSid, + cc.vehModelSid + ) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.vehModelSid + and r.vehMConfigSid = s.vehMConfigSid + set arrears_carry_veh_count = s.scount + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + + -- 欠款出库金融--截止当日欠款出库申请通过且未回清款的台数欠款总额 +-- 欠款出库金融--截止当日欠款出库申请通过且未回清款的台数欠款总额(欠款出库申请通过,且未认完款的剩余认款总和加上欠款提车申请通过,且全款已出库未认完款的剩余认款总和) + update daily_report r inner join (SELECT sum(cc.scount) AS scount, + cc.useOrgSid, + cc.vehMConfigSid, + cc.vehModelSid + FROM ( + SELECT SUM(a.scount) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bdad.id, + ba.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo, + ( + SUM(s.reveivableMoney) - SUM(s.subscriptionMoney)) AS scount + FROM anrui_buscenter.bus_delivered_apply_details bdad + LEFT JOIN anrui_buscenter.bus_delivered_apply ba ON ba.sid = bdad.applySid + LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.sid = bdad.busVinSid + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + left join (select fs.* + from anrui_fin.fin_selected_receivables_detailed fs + where fs.auditState = 3) s + on s.receivablesSid = fd.sid + WHERE fd.kxState = '01' + and s.id is null + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid + WHERE ba.nodeState = '已办结' + AND ba.typeState = 1 + GROUP BY bv.sid, + ba.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + UNION ALL + SELECT SUM(a.scount) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bdad.id, + ba.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo, + ( + SUM(s.reveivableMoney) - SUM(s.subscriptionMoney)) AS scount + FROM anrui_buscenter.bus_arrears_carry_vehicle_details bdad + LEFT JOIN anrui_buscenter.bus_arrears_carry_vehicle_apply ba + ON ba.sid = bdad.applySid + LEFT JOIN anrui_buscenter.bus_sales_order_vehicle bv ON bv.linkSid = bdad.vinSid + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bo.sid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + left join (select fs.* + from anrui_fin.fin_selected_receivables_detailed fs + where fs.auditState = 3) s + on s.receivablesSid = fd.sid + WHERE fd.kxState = '01' + and s.id is null + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = ba.useOrgSid + WHERE ba.nodeState = '已办结' + AND ba.paymentMethodKey = 1 + AND bbv.vehicleState = '0002' + GROUP BY bv.sid, + ba.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + ) cc + GROUP BY cc.useOrgSid, + cc.vehMConfigSid, + cc.vehModelSid + ) s + on r.useOrgSid = s.useOrgSid + and r.vehModelSid = s.vehModelSid + and r.vehMConfigSid = s.vehMConfigSid + set arrears_carry_veh_amount = ROUND(s.scount / 10000, 2) + where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 金融未放款数量--- 截止当日贷款业务已出库且融资放款未认款的台数。 + update daily_report r inner join ( + SELECT sum(b.scount) AS scount, + b.useOrgSid, + b.NAME, + b.contractNo, + b.vehMConfigSid, + b.vehModelSid + from (SELECT count(a.id) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + AND fd.receivablesName = '融资放款' + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + WHERE fd.kxState = '01' + AND fd.receivablesName = '融资放款' + AND fd.sid NOT IN (SELECT fs.`receivablesSid` + FROM anrui_fin.fin_selected_receivables_detailed fs + WHERE fs.`auditState` = 3 + AND fs.`receivablesName` = '融资放款') + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + WHERE bo.payTypeKey = 2 + AND bbv.vehicleState = '0002' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.contractNo, + a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + union all + SELECT count(a.id) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + bo.contractNo, + IFNULL(sss.money, '0') as money + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + LEFT JOIN (SELECT furd.busVinSid + FROM anrui_fin.fin_uncollected_receivables_detailed furd + WHERE furd.receivablesName = '融资放款' + group by furd.busVinSid) ss ON ss.busVinSid = bv.sid + LEFT JOIN ( + SELECT (ls.loanTotal - lo.loanDownPay) AS money, + ls.salesOrderSid + FROM anrui_riskcenter.loan_solutions ls + LEFT JOIN anrui_riskcenter.loan_solutions_otherpolicy lo ON lo.solutionsSid = ls.sid + ) sss ON sss.salesOrderSid = bv.salesOrderSid + WHERE bo.payTypeKey = 2 + and ss.busVinSid is null + AND bbv.vehicleState = '0002' + and bo.nodeState = '已办结' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + having money > 0 + ) a + GROUP BY a.contractNo, + a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid) b + group by b.useOrgSid, b.vehModelSid, b.vehMConfigSid) as s on + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.vehModelSid AND r.vehMConfigSid = s.vehMConfigSid + SET r.`loan_not_count`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 金融未放款金额-- 截止当日贷款业务已出库且融资放款未认款的台数融资放款金额之和++未生成融资放款的总贷款金额。 + + update daily_report r inner join ( + select SUM(b.scount) AS scount, + b.useOrgSid, + b.NAME, + b.contractNo, + b.vehMConfigSid, + b.vehModelSid + from (SELECT SUM(a.scount) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM (SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo, + ( + SUM(s.reveivableMoney) - SUM(s.subscriptionMoney)) AS scount + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + AND fd.receivablesName = '融资放款' + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + WHERE fd.kxState = '01' + AND fd.receivablesName = '融资放款' + AND fd.sid NOT IN (SELECT fs.`receivablesSid` + FROM anrui_fin.fin_selected_receivables_detailed fs + WHERE fs.`auditState` = 3 + AND fs.`receivablesName` = '融资放款') + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + WHERE bo.payTypeKey = 2 + + AND bbv.vehicleState = '0002' + GROUP BY bv.sid, bo.useOrgSid, bm.modelSid, bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.contractNo, a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + union all + + SELECT sum(a.money) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + bo.contractNo, + IFNULL(sss.money, '0') as money + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + LEFT JOIN (SELECT furd.busVinSid + FROM anrui_fin.fin_uncollected_receivables_detailed furd + WHERE furd.receivablesName = '融资放款' + group by furd.busVinSid) ss ON ss.busVinSid = bv.sid + LEFT JOIN ( + SELECT (ls.loanTotal - lo.loanDownPay) AS money, + ls.salesOrderSid + FROM anrui_riskcenter.loan_solutions ls + LEFT JOIN anrui_riskcenter.loan_solutions_otherpolicy lo ON lo.solutionsSid = ls.sid + ) sss ON sss.salesOrderSid = bv.salesOrderSid + WHERE bo.payTypeKey = 2 + and ss.busVinSid is null + AND bbv.vehicleState = '0002' + and bo.nodeState = '已办结' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + having money > 0 + ) a + GROUP BY a.contractNo, + a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid) b + group by b.useOrgSid, b.vehModelSid, b.vehMConfigSid) as s on + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.vehModelSid AND r.vehMConfigSid = s.vehMConfigSid + SET r.`loan_not_amount`=ROUND(s.scount / 10000, 2) + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 金融未放款数量已信审终审--- 截止当日贷款业务已信审终审且融资放款未认款的台数。 + update daily_report r inner join ( + select sum(b.scount) AS scount, + b.useOrgSid, + b.NAME, + b.contractNo, + b.vehMConfigSid, + b.vehModelSid + from (SELECT count(a.id) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + AND fd.receivablesName = '融资放款' + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + WHERE fd.kxState = '01' + AND fd.receivablesName = '融资放款' + AND fd.sid NOT IN (SELECT fs.`receivablesSid` + FROM anrui_fin.fin_selected_receivables_detailed fs + WHERE fs.`auditState` = 3 + AND fs.`receivablesName` = '融资放款') + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + LEFT JOIN anrui_riskcenter.loan_capital_credit_result lr + ON lr.loanContractSid = bv.loanContractSid + WHERE bo.payTypeKey = 2 + AND lr.capCarefulResult = '通过' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.contractNo, a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + union all + SELECT count(a.id) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + AND fd.receivablesName = '融资放款' + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + WHERE fd.kxState = '01' + AND fd.receivablesName = '融资放款' + AND fd.sid NOT IN (SELECT fs.`receivablesSid` + FROM anrui_fin.fin_selected_receivables_detailed fs + WHERE fs.`auditState` = 3 + AND fs.`receivablesName` = '融资放款') + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + LEFT JOIN anrui_riskcenter.loan_noguarantee_credit_review lr + ON lr.borrowerSid = bv.borrowerSid + WHERE bo.payTypeKey = 2 + AND lr.creditReview = '通过' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.contractNo, a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid) b + group by b.useOrgSid, b.vehModelSid, b.vehMConfigSid) as s on + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.vehModelSid AND r.vehMConfigSid = s.vehMConfigSid + SET r.`loan_not_counts`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + +-- 金融未放款金额已信审终审-- 截止当日贷款业务已信审终审且融资放款未认款的台数融资放款金额之和 + + update daily_report r inner join ( + SELECT SUM(b.scount) AS scount, + b.useOrgSid, + b.NAME, + b.contractNo, + b.vehMConfigSid, + b.vehModelSid + from ( + SELECT SUM(a.scount) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo, + ( + SUM(s.reveivableMoney) - SUM(s.subscriptionMoney)) AS scount + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + AND fd.receivablesName = '融资放款' + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + WHERE fd.kxState = '01' + AND fd.receivablesName = '融资放款' + AND fd.sid NOT IN (SELECT fs.`receivablesSid` + FROM anrui_fin.fin_selected_receivables_detailed fs + WHERE fs.`auditState` = 3 + AND fs.`receivablesName` = '融资放款') + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + LEFT JOIN anrui_riskcenter.loan_capital_credit_result lr + ON lr.loanContractSid = bv.loanContractSid + WHERE bo.payTypeKey = 2 + AND lr.capCarefulResult = '通过' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.contractNo, a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid + UNION ALL + SELECT SUM(a.scount) AS scount, + a.useOrgSid, + a.NAME, + a.contractNo, + a.vehMConfigSid, + a.vehModelSid + FROM ( + SELECT bv.id, + bo.useOrgSid, + bm.modelConfigSid AS vehMConfigSid, + bm.modelSid AS vehModelSid, + so.NAME, + SUM(s.reveivableMoney), + SUM(s.subscriptionMoney), + bo.contractNo, + ( + SUM(s.reveivableMoney) - SUM(s.subscriptionMoney)) AS scount + FROM anrui_buscenter.bus_sales_order_vehicle bv + LEFT JOIN anrui_buscenter.bus_sales_order bo ON bo.sid = bv.salesOrderSid + LEFT JOIN anrui_base.base_vehicle bbv ON bbv.sid = bv.linkSid + LEFT JOIN anrui_buscenter.bus_sales_order_model bm + ON bm.salesOrderSid = bv.salesOrderSid + LEFT JOIN ( + SELECT fd.reveivableMoney, + fd.busVinSid, + IFNULL(SUM(fs.subscriptionMoney), 0) AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + LEFT JOIN anrui_fin.fin_selected_receivables_detailed fs + ON fs.receivablesSid = fd.sid + WHERE fd.kxState = '01' + AND fs.auditState = 3 + AND fd.receivablesName = '融资放款' + GROUP BY fd.sid + UNION ALL + SELECT fd.reveivableMoney, + fd.busVinSid, + 0 AS subscriptionMoney + FROM anrui_fin.fin_uncollected_receivables_detailed fd + WHERE fd.kxState = '01' + AND fd.receivablesName = '融资放款' + AND fd.sid NOT IN (SELECT fs.`receivablesSid` + FROM anrui_fin.fin_selected_receivables_detailed fs + WHERE fs.`auditState` = 3 + AND fs.`receivablesName` = '融资放款') + GROUP BY fd.sid + ) s ON s.busVinSid = bv.sid + LEFT JOIN anrui_portal.sys_organization so ON so.sid = bo.useOrgSid + LEFT JOIN anrui_riskcenter.loan_noguarantee_credit_review lr + ON lr.borrowerSid = bv.borrowerSid + WHERE bo.payTypeKey = 2 + AND lr.creditReview = '通过' + GROUP BY bv.sid, + bo.useOrgSid, + bm.modelSid, + bm.modelConfigSid + HAVING SUM(s.reveivableMoney) > SUM(s.subscriptionMoney)) a + GROUP BY a.contractNo, a.useOrgSid, + a.vehMConfigSid, + a.vehModelSid) b + group by b.useOrgSid, b.vehModelSid + , b.vehMConfigSid) as s on + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.vehModelSid AND r.vehMConfigSid = s.vehMConfigSid + SET r.`loan_not_amounts`=ROUND(s.scount / 10000, 2) + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +-- 全年厂家开票数 + UPDATE daily_report r INNER JOIN (SELECT COUNT(id) AS scount, `useOrgSid`, `modelSid`, `modelConfigSid` + FROM anrui_base.`base_vehicle` + WHERE manDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') + GROUP BY `useOrgSid`, `modelSid`, `modelConfigSid`) AS s ON + r.useOrgSid = s.useOrgSid AND r.vehModelSid = s.modelSid AND r.vehMConfigSid = s.modelConfigSid + SET r.`manufacturer_invoicing_year`=s.scount + WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); + + +END \ No newline at end of file