Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -37,7 +37,7 @@ public interface SummaryService {
|
||||
*/
|
||||
void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException;
|
||||
|
||||
List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto, Date startTime, Date endTime);
|
||||
List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto);
|
||||
|
||||
List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime);
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.vo.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.beust.ah.A;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -450,16 +452,16 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto, Date startTime, Date endTime) {
|
||||
public List<TbOrderPayCountVo> summaryCount(ShopSummaryDto summaryDto) {
|
||||
List<TbOrderPayCountVo> list = new ArrayList<>();
|
||||
Long start = 1704038400000L;
|
||||
Long end = Instant.now().toEpochMilli();
|
||||
if (startTime != null || endTime != null) {
|
||||
start = startTime.getTime();
|
||||
end = endTime.getTime();
|
||||
if (summaryDto.getStartTime() != null || summaryDto.getEndTime() != null) {
|
||||
start = summaryDto.getStartTime().getTime();
|
||||
end = summaryDto.getEndTime().getTime();
|
||||
} else {
|
||||
startTime = DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L));
|
||||
endTime = new Date();
|
||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
summaryDto.setEndTime(new Date());
|
||||
}
|
||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {
|
||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(summaryDto.getShopId(), start, end);
|
||||
@@ -474,7 +476,7 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
refCount.setIcon("el-icon-money");
|
||||
list.add(refCount);
|
||||
|
||||
TbOrderSalesCountByDayVo numCount = detailRepository.queryTbOrderSalesCount(Integer.valueOf(summaryDto.getShopId()), startTime, endTime);
|
||||
TbOrderSalesCountByDayVo numCount = detailRepository.queryTbOrderSalesCount(Integer.valueOf(summaryDto.getShopId()), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
TbOrderPayCountVo salesNum =new TbOrderPayCountVo("el-icon-goods","销售量","0",numCount.getSalesNum()-numCount.getRefNum());
|
||||
TbOrderPayCountVo refNum =new TbOrderPayCountVo("el-icon-goods","退单量","0",numCount.getRefNum());
|
||||
list.add(salesNum);
|
||||
@@ -557,38 +559,77 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
Map<String, List<TbOrderSalesCountByTable>> countByTableMap = countByTables.stream()
|
||||
.collect(Collectors.groupingBy(TbOrderSalesCountByTable::getTableId));
|
||||
|
||||
ConcurrentLinkedQueue<Map<String, Object>> list = new ConcurrentLinkedQueue<>();
|
||||
|
||||
ArrayList<Integer> mergeRowIndex = new ArrayList<>();
|
||||
// 比较 shopTableSeleInfoDto 的 startTime 和 endTime 是不是同一天
|
||||
boolean sameDay = cn.hutool.core.date.DateUtil.isSameDay(shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
|
||||
String queryDate = cn.hutool.core.date.DateUtil.format(shopTableSeleInfoDto.getStartTime(), "yyyy-MM-dd");
|
||||
if (!sameDay) {
|
||||
queryDate += " 至 " + cn.hutool.core.date.DateUtil.format(shopTableSeleInfoDto.getEndTime(), "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
|
||||
List<List<Integer>> mergeList = new ArrayList<>();
|
||||
Map<String, Integer> tableStartIndexMap = new HashMap<>();
|
||||
int rowIndex = 1;
|
||||
for (ShopTableSaleInfoVo all : infoVos) {
|
||||
List<TbOrderSalesCountByTable> tables = countByTableMap.get(all.getTableCode());
|
||||
if (tables == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (TbOrderSalesCountByTable table : tables) {
|
||||
total = total.add(table.getSalesAmount().abs());
|
||||
}
|
||||
|
||||
String tableCode = all.getTableName().toString();
|
||||
if (!tableStartIndexMap.containsKey(tableCode)) {
|
||||
tableStartIndexMap.put(tableCode, rowIndex);
|
||||
}
|
||||
|
||||
for (TbOrderSalesCountByTable table : tables) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("开始时间", shopTableSeleInfoDto.getStartTime());
|
||||
map.put("结束时间", shopTableSeleInfoDto.getEndTime());
|
||||
map.put("区域名称", all.getAreaName());
|
||||
map.put("桌台名称", all.getTableName());
|
||||
map.put("日期", queryDate);
|
||||
map.put("台桌", all.getTableName());
|
||||
map.put("商品分类", table.getCateName());
|
||||
map.put("商品名称", table.getProductName());
|
||||
map.put("单位", table.getUnitName());
|
||||
map.put("商品规格", table.getProductSkuName());
|
||||
map.put("销量", table.getSalesNum());
|
||||
map.put("销售额", table.getSalesAmount());
|
||||
map.put("单价", table.getPrice());
|
||||
map.put("金额", table.getSalesAmount());
|
||||
map.put("销售额", total);
|
||||
map.put("退单量", table.getRefNum());
|
||||
map.put("退单额", table.getRefAmount());
|
||||
list.add(map);
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
if (!tables.isEmpty()) {
|
||||
if (mergeRowIndex.isEmpty()) {
|
||||
mergeRowIndex.add(tables.size());
|
||||
}else {
|
||||
mergeRowIndex.add(mergeRowIndex.get(mergeRowIndex.size() - 1) + tables.size());
|
||||
}
|
||||
int start = tableStartIndexMap.get(tableCode);
|
||||
int end = rowIndex - 1;
|
||||
if (end - start > 0) {
|
||||
mergeList.add(Arrays.asList(start, end, 0, 0));
|
||||
mergeList.add(Arrays.asList(start, end, 1, 1));
|
||||
mergeList.add(Arrays.asList(start, end, 9, 9));
|
||||
}
|
||||
}
|
||||
FileUtil.downloadExcelAndMerge(list, 4, response, mergeRowIndex);
|
||||
|
||||
List<String> keyList = new ArrayList<>();
|
||||
keyList.add("日期");
|
||||
keyList.add("台桌");
|
||||
keyList.add("商品分类");
|
||||
keyList.add("商品名称");
|
||||
keyList.add("单位");
|
||||
keyList.add("商品规格");
|
||||
keyList.add("销量");
|
||||
keyList.add("单价");
|
||||
keyList.add("金额");
|
||||
keyList.add("销售额");
|
||||
keyList.add("退单量");
|
||||
keyList.add("退单额");
|
||||
|
||||
FileUtil.downloadAndMergeExcel(list, mergeList, keyList, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
PageRequest sort = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
|
||||
Page<TbProductGroup> page = tbProductGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
|
||||
QueryHelp.getPredicate(root,criteria,criteriaBuilder),sort);
|
||||
|
||||
return PageUtil.toPage(page.map(tbProductGroupMapper::toDto));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user