|
@@ -256,9 +256,16 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
|
|
|
List<ProductCategoryTrendVO> trendVOS = new ArrayList<>();
|
|
|
//存储所有产品的营销数据
|
|
|
List<ProductMarketData> marketData = new ArrayList<>();
|
|
|
+ //存储所有
|
|
|
+ ProductCategoryTrendVO trendAllVO = new ProductCategoryTrendVO();
|
|
|
+ trendAllVO.setProductId(0);
|
|
|
+ trendAllVO.setProductName("总产品");
|
|
|
+ Map<String, Object> allMarketDataMap = new HashMap<>();
|
|
|
//根据产品类别ID获得产品id和产品名称
|
|
|
LambdaQueryWrapper<Product> productWrapper = new LambdaQueryWrapper<>();
|
|
|
productWrapper.eq(Product::getProductCategoryId, dto.getCategoryId());
|
|
|
+ if(dto.getCompanyName()!=null&&dto.getCompanyName()!=""){
|
|
|
+ productWrapper.eq(Product::getCompanyName,dto.getCompanyName());}
|
|
|
List<Product> products = productService.list(productWrapper);
|
|
|
if (products.size() != 0) {
|
|
|
List<Integer> productIds = products.stream().map(Product::getId).collect(Collectors.toList());
|
|
@@ -286,37 +293,65 @@ public class ProductCategoryServiceImpl implements IProductCategoryService {
|
|
|
temMarketData.forEach(item -> {
|
|
|
//获得营销数据的时间
|
|
|
String date = item.getSaleTime();
|
|
|
- double saleCount = item.getSaleCount() * item.getSaleMoney();
|
|
|
+ double saleCount = item.getSaleMoney();
|
|
|
if (dto.getTimeUnit() == 1) {
|
|
|
try {
|
|
|
Date dateForm = new SimpleDateFormat("yyyy-MM").parse(date);
|
|
|
- int month = dateForm.getMonth();
|
|
|
- int year = dateForm.getYear();
|
|
|
- int season = (month - 1) / 3;
|
|
|
+ Calendar ca = Calendar.getInstance();
|
|
|
+ ca.setTime(dateForm);
|
|
|
+ int month = ca.get(Calendar.MONTH);//第几个月
|
|
|
+ int year = ca.get(Calendar.YEAR);//年份数值
|
|
|
+ int season = (month - 1) / 3+1;
|
|
|
date = year + "-" + season;
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ else if(dto.getTimeUnit() == 2){
|
|
|
+ try {
|
|
|
+ Date dateForm = new SimpleDateFormat("yyyy-MM").parse(date);
|
|
|
+ Calendar ca = Calendar.getInstance();
|
|
|
+ ca.setTime(dateForm);
|
|
|
+ int year = ca.get(Calendar.YEAR);//年份数值
|
|
|
+ date = year+"";
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
//计算销售额
|
|
|
if (marketDataMap.get(date) != null) {
|
|
|
saleCount += Double.parseDouble(marketDataMap.get(date).toString());
|
|
|
}
|
|
|
marketDataMap.put(date, saleCount);
|
|
|
+
|
|
|
+ //产品总体部分
|
|
|
+ if (allMarketDataMap.get(date) != null) {
|
|
|
+ saleCount += Double.parseDouble(allMarketDataMap.get(date).toString());
|
|
|
+ }
|
|
|
+ allMarketDataMap.put(date, saleCount);
|
|
|
}
|
|
|
);
|
|
|
Set keyset = marketDataMap.keySet();
|
|
|
List<ProductCategoryTrendVO.saleVO> saleVOS = new ArrayList<>();
|
|
|
for (Object key : keyset) {
|
|
|
ProductCategoryTrendVO.saleVO saleVO = new ProductCategoryTrendVO.saleVO();
|
|
|
- saleVO.setMarketData(key.toString());
|
|
|
+ saleVO.setMarketDate(key.toString());
|
|
|
saleVO.setSaleTotalMoney(Double.parseDouble(marketDataMap.get(key).toString()));
|
|
|
saleVOS.add(saleVO);
|
|
|
}
|
|
|
trendVO.setSaleVOS(saleVOS);
|
|
|
trendVOS.add(trendVO);
|
|
|
}
|
|
|
-
|
|
|
+ Set keyset = allMarketDataMap.keySet();
|
|
|
+ List<ProductCategoryTrendVO.saleVO> saleVOS = new ArrayList<>();
|
|
|
+ for (Object key : keyset) {
|
|
|
+ ProductCategoryTrendVO.saleVO saleVO = new ProductCategoryTrendVO.saleVO();
|
|
|
+ saleVO.setMarketDate(key.toString());
|
|
|
+ saleVO.setSaleTotalMoney(Double.parseDouble(allMarketDataMap.get(key).toString()));
|
|
|
+ saleVOS.add(saleVO);
|
|
|
+ }
|
|
|
+ trendAllVO.setSaleVOS(saleVOS);
|
|
|
+ trendVOS.add(trendAllVO);
|
|
|
return trendVOS;
|
|
|
}
|
|
|
|