@ -1,5 +1,8 @@
package com.yxt.supervise.report.biz.reportsalesdaygather ;
import cn.hutool.core.date.DateTime ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.StrUtil ;
import com.alibaba.excel.EasyExcel ;
import com.alibaba.excel.ExcelWriter ;
import com.alibaba.excel.util.ListUtils ;
@ -9,17 +12,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yxt.common.base.service.MybatisBaseService ;
import com.yxt.common.core.query.PagerQuery ;
import com.yxt.supervise.report.api.reportsalesdaygather.ReportSalesDayGather ;
import com.yxt.supervise.report.api.reportsalesdaygather.ReportSalesDayGatherDto ;
import com.yxt.supervise.report.api.reportsalesdaygather.ReportSalesDayGatherQuery ;
import com.yxt.supervise.report.api.reportsalesdaygather.ReportSalesDayGatherVo ;
import com.yxt.supervise.report.api.reportsalesdaylog.MyHandler ;
import com.yxt.supervise.report.api.reportsalesdaystore.ReportSalesDayStoreVo ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.poi.ss.util.CellRangeAddress ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import java.io.IOException ;
import java.math.BigDecimal ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.List ;
import java.util.Map ;
@ -29,7 +35,8 @@ import java.util.Map;
* /
@Service
public class ReportSalesDayGatherService extends MybatisBaseService < ReportSalesDayGatherMapper , ReportSalesDayGather > {
@Autowired
ReportSalesDayGatherMapper reportSalesDayGatherMapper ;
public List < ReportSalesDayGatherVo > getReportSalesDayGather ( PagerQuery < ReportSalesDayGatherQuery > pq ) {
ReportSalesDayGatherQuery query = pq . getParams ( ) ;
QueryWrapper < ReportSalesDayGather > qw = new QueryWrapper < > ( ) ;
@ -71,4 +78,184 @@ public class ReportSalesDayGatherService extends MybatisBaseService<ReportSalesD
excelWriter . fill ( SalesVos , fillConfig , writeSheet ) ;
}
public ReportSalesDayGather fetchByOrderDate ( String orderDate ) {
QueryWrapper < ReportSalesDayGather > qw = new QueryWrapper < > ( ) ;
qw . eq ( "orderDate" , orderDate ) ;
List < ReportSalesDayGather > list = list ( qw ) ;
if ( list = = null | | list . isEmpty ( ) ) return null ;
return list . get ( 0 ) ;
}
/ * *
* 清理数据日期的数据
*
* @param orderDate
* /
public void clearByOrderDate ( String orderDate ) {
reportSalesDayGatherMapper . clearByOrderDate ( orderDate ) ;
}
private String dayAgo ( String orderDate , int offset ) {
if ( offset = = 0 ) return orderDate ;
DateTime nowDate = DateUtil . parse ( orderDate , "yyyy-MM-dd" ) ;
DateTime preDate = DateUtil . offsetDay ( nowDate , offset ) ;
return DateUtil . format ( preDate , "yyyy-MM-dd" ) ;
}
public ReportSalesDayGather clearAndInitByOrderDate ( String orderDate ) {
this . clearByOrderDate ( orderDate ) ; // 清除数据日的数据
Date curDate = new Date ( ) ;
String dfmt = DateUtil . format ( curDate , "yyyy-MM-dd" ) ;
String dfmt2 = DateUtil . format ( curDate , "yyyy-MM-dd HH:mm" ) ;
String preOrderDate = dayAgo ( orderDate , - 1 ) ; // 前一天
String befOrderDate = dayAgo ( orderDate , - 2 ) ; // 前两天
String thrOrderDate = dayAgo ( orderDate , - 3 ) ; // 前三天
ReportSalesDayGather preRp = fetchByOrderDate ( preOrderDate ) ;
if ( preRp = = null ) preRp = new ReportSalesDayGather ( ) ;
ReportSalesDayGather rp = new ReportSalesDayGather ( ) ;
rp . setOrderDate ( orderDate ) ; // 单据日期
rp . setSerialNumber ( "xsjyrbb" + orderDate . replace ( "-" , "" ) ) ; // 编号
rp . setReportTime ( dfmt + " 11:00" ) ; // 上报时间
rp . setKmDateA ( befOrderDate ) ; // 科目/日,大前天
rp . setKmDateB ( preOrderDate ) ; // 科目/日,前天
rp . setKmDateC ( orderDate ) ; // 科目/日,昨天
// rp.setXjlla(""); // 现金流量-经营活动产生的现金流量(元),大前天
// rp.setXjllb(""); // 现金流量-经营活动产生的现金流量(元),前天
// rp.setXjllc(""); // 现金流量-经营活动产生的现金流量(元),昨天
rp . setXsxjA ( preRp . getXsxjB ( ) ) ; // 销售商品收到的现金(元),大前天
rp . setXsxjB ( preRp . getXsxjC ( ) ) ; // 销售商品收到的现金(元),前天
rp . setXsxjC ( 0 ) ; // 销售商品收到的现金(元),昨天 //后面计算
// rp.setQtxja(""); // 收到其他与经营活动有关的现金(元),大前天
// rp.setQtxjb(""); // 收到其他与经营活动有关的现金(元),前天
// rp.setQtxjc(""); // 收到其他与经营活动有关的现金(元),昨天
rp . setCwfxhjA ( preRp . getCwfxhjB ( ) ) ; // 财务分析本项合计,大前天
rp . setCwfxhjB ( preRp . getCwfxhjC ( ) ) ; // 财务分析本项合计,前天
rp . setCwfxhjC ( 0 ) ; // 财务分析本项合计,昨天 //后面计算
// rp.setZcfza(""); // 资产负债-流动资产(元),大前天
// rp.setZcfzb(""); // 资产负债-流动资产(元),前天
// rp.setZcfzc(""); // 资产负债-流动资产(元),昨天
// rp.setYszka(""); // 应收账款(元),大前天
// rp.setYszkb(""); // 应收账款(元),前天
// rp.setYszkc(""); // 应收账款(元),昨天
// rp.setLdfza(""); // 流动负债(元),大前天
// rp.setLdfzb(""); // 流动负债(元),前天
// rp.setLdfzc(""); // 流动负债(元),昨天
// rp.setYskxa(""); // 预收款项(元),大前天
// rp.setYskxb(""); // 预收款项(元),前天
// rp.setYskxc(""); // 预收款项(元),昨天
// rp.setQczhz(""); // 期初总货值
// rp.setYcqchz(""); // 烟草期初货值
rp . setXmDateA ( StrUtil . isBlank ( preRp . getXmDateB ( ) ) ? preOrderDate : preRp . getXmDateB ( ) ) ; // 项目/日,前天
rp . setXmDateB ( StrUtil . isBlank ( preRp . getXmDateC ( ) ) ? orderDate : preRp . getXmDateC ( ) ) ; // 项目/日,昨天
rp . setXmDateC ( dfmt ) ; // 项目/日,今天
rp . setZthzA ( preRp . getZthzB ( ) ) ; // 在途货值(元),前天
rp . setZthzB ( preRp . getZthzC ( ) ) ; // 在途货值(元),昨天
rp . setZthzC ( 0 ) ; // 在途货值(元),今天 // 计算
rp . setKchzA ( preRp . getKchzB ( ) ) ; // 库存货值(元),前天
rp . setKchzB ( preRp . getKchzC ( ) ) ; // 库存货值(元),昨天
rp . setKchzC ( 0 ) ; // 库存货值(元),今天 // 计算
// rp.setZhyea(""); // 帐户余额(元)账户余额为前一天余额,前天
// rp.setZhyeb(""); // 帐户余额(元)账户余额为前一天余额,昨天
// rp.setZhyec(""); // 帐户余额(元)账户余额为前一天余额,今天
// rp.setYjyszka(""); // 预警应收帐款(元),前天
// rp.setYjyszkb(""); // 预警应收帐款(元),昨天
// rp.setYjyszkc(""); // 预警应收帐款(元),今天
// rp.setYjhja(""); // 主要预警指标本项合计,前天
// rp.setYjhjb(""); // 主要预警指标本项合计,昨天
// rp.setYjhjc(""); // 主要预警指标本项合计,今天
double xsLwlsd = amountOfLwlsdDay ( orderDate ) ;
rp . setLwlsdze ( xsLwlsd ) ; // 连网连锁店,总额(元)
// rp.setLwlsdyszk(""); // 连网连锁店,应收帐款(元)
rp . setLwlsdkcje ( xsLwlsd ) ; // 连网连锁店,扣除应收金额(元)
double xsLsnjm = amountOfLsnjmDay ( orderDate ) ;
rp . setLsnjmze ( xsLsnjm ) ; // 连锁内加盟,总额(元)
// rp.setLsnjmyszk(""); // 连锁内加盟,应收帐款(元)
rp . setLsnjmkcje ( xsLsnjm ) ; // 连锁内加盟,扣除应收金额(元)
double xsPszx = amountOfPszxDay ( orderDate ) ;
rp . setPszxze ( xsPszx ) ; // 配送中心,总额(元)
// rp.setPszxyszk(""); // 配送中心,应收帐款(元)
rp . setPszxkcje ( xsPszx ) ; // 配送中心,扣除应收金额(元)
double xsLswjm = amountOfLswjmDay ( orderDate ) ;
rp . setLswjmze ( xsLswjm ) ; // 连锁外加盟(销配结算),总额(元)
// rp.setLswjmyszk(""); // 连锁外加盟(销配结算),应收帐款(元)
rp . setLswjmkcje ( xsLswjm ) ; // 连锁外加盟(销配结算),扣除应收金额(元)
double xsYc = amountOfYcDay ( orderDate ) ;
rp . setYcmdze ( xsYc ) ; // 36524集团报烟门店仓,总额(元)
// rp.setYcmdyszk(""); // 36524集团报烟门店仓,应收帐款(元)
rp . setYcmdkcje ( xsYc ) ; // 36524集团报烟门店仓,扣除应收金额(元)
double xsYcJmd = amountOfDayJmd ( orderDate ) ;
rp . setYcjmdze ( xsYcJmd ) ; // 烟草连锁外加盟(销配结算),总额(元)
// rp.setYcjmdyszk(""); // 烟草连锁外加盟(销配结算),应收帐款(元)
rp . setYcjmdkcje ( xsYcJmd ) ; // 烟草连锁外加盟(销配结算),扣除应收金额(元)
// double xshz1 = ((double) Math.round((xsLwlsd + xsLsnjm + xsPszx + xsLswjm + xsYc + xsYcJmd) * 100)) / 100;
double xshz1 = xsLwlsd + xsLsnjm + xsPszx + xsLswjm + xsYc + xsYcJmd ;
rp . setXsxjC ( xshz1 ) ; // 销售商品收到的现金(元),昨天 //后面计算
rp . setCwfxhjC ( xshz1 ) ; // 财务分析本项合计,昨天 //后面计算
//在途货值
double zthz = amountZaitu ( ) ;
double zthzyc = amountZaituYc ( ) ;
rp . setZthzC ( zthz + zthzyc ) ; // 在途货值(元),今天 // 计算
//库存货值
double kzhz = amountCurrent ( ) ;
double kzhzyc = amountYcCurrent ( ) ;
// double kzhz1 = ((double) Math.round((kzhz + kzhzyc) * 100)) / 100;
double kzhz1 = kzhz + kzhzyc ;
rp . setKchzC ( kzhz1 ) ; // 库存货值(元),今天 // 计算
reportSalesDayGatherMapper . insert ( rp ) ;
//clearAndInsertBySalesReportday(rp);
return rp ;
}
public double amountOfLwlsdDay ( String orderDate ) {
return reportSalesDayGatherMapper . amountOfLsdOnDay ( orderDate ) ;
}
public double amountOfLsnjmDay ( String orderDate ) {
return reportSalesDayGatherMapper . amountOfLsnjmOnDay ( orderDate ) ;
}
public double amountOfPszxDay ( String orderDate ) {
return reportSalesDayGatherMapper . amountOfPszxDay ( orderDate ) ;
}
public double amountOfLswjmDay ( String orderDate ) {
return reportSalesDayGatherMapper . amountOfLswjmDay ( orderDate ) ;
}
public double amountOfYcDay ( String orderDate ) {
return reportSalesDayGatherMapper . amountOfYcDay ( orderDate ) ;
}
public double amountOfDayJmd ( String orderDate ) {
return reportSalesDayGatherMapper . amountOfDayJmd ( orderDate ) ;
}
public double amountZaitu ( ) {
double wdhjz = 0 ;
List < Map < String , Object > > list = reportSalesDayGatherMapper . gysdhhzb ( ) ;
for ( Map < String , Object > map : list ) {
wdhjz = wdhjz + Double . valueOf ( map . get ( "wdhjz" ) . toString ( ) ) ;
}
return wdhjz ;
}
public double amountZaituYc ( ) {
double wdhjz = 0 ;
List < Map < String , Object > > list = reportSalesDayGatherMapper . ycddmxb ( ) ;
for ( Map < String , Object > map : list ) {
//wdhjz = wdhjz + ExcelTool.toDouble(map.get("zthjz"));
wdhjz = wdhjz + Double . valueOf ( map . get ( "zthjz" ) . toString ( ) ) ;
}
return wdhjz ;
}
public double amountCurrent ( ) {
return reportSalesDayGatherMapper . amountCurrent ( ) ;
}
public double amountYcCurrent ( ) {
return reportSalesDayGatherMapper . amountYcCurrent ( ) ;
}
}