package com.cqupt.th.supermarket.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cqupt.th.supermarket.constants.EmployeeConstant;
import com.cqupt.th.supermarket.constants.IncomeExpenseConstant;
import com.cqupt.th.supermarket.constants.PurchaseOrderConstant;
import com.cqupt.th.supermarket.entity.*;
import com.cqupt.th.supermarket.mapper.*;
import com.cqupt.th.supermarket.service.RegionService;
import com.cqupt.th.supermarket.service.StatisticsService;
import com.cqupt.th.supermarket.service.WarehouseService;
import com.cqupt.th.supermarket.utils.CommonResult;
import com.cqupt.th.supermarket.vo.InventoryVo;
import com.cqupt.th.supermarket.vo.PurchaseOrderVo;
import com.cqupt.th.supermarket.vo.PurchaseVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author th
* @date 2023/4/16 16:57
*/
@Service("statisticsService")
public class StatisticsServiceImpl implements StatisticsService {
@Resource
private PurchaseMapper purchaseMapper;
@Resource
private PurchaseOrderMapper purchaseOrderMapper;
@Resource
private ProductMapper productMapper;
@Resource
private SupplierMapper supplierMapper;
@Resource
private StoreMapper storeMapper;
@Autowired
@Qualifier("warehouseService")
private WarehouseService warehouseService;
@Autowired
@Qualifier("regionService")
private RegionService regionService;
@Resource
private MemberMapper memberMapper;
@Resource
private IncomeExpenseMapper incomeExpenseMapper;
@Resource
private OutstockMapper outstockMapper;
@Resource
private EmployeeMapper employeeMapper;
@Resource
private UserBrowsingHistoryMapper userBrowsingHistoryMapper;
@Resource
private InventoryMapper inventoryMapper;
@Override
public CommonResult getPriceComparison(Product product) {
List<PurchaseOrder> purchaseOrders = purchaseOrderMapper.selectList(new QueryWrapper<PurchaseOrder>().ne("is_pay", PurchaseOrderConstant.IS_CANCEL.getCode()));
List<Integer> ids = purchaseOrders.stream().map(PurchaseOrder::getPurchaseId).collect(Collectors.toList());
if (ids == null || ids.size() == 0) {
return CommonResult.ok();
}
QueryWrapper<Purchase> purchaseQueryWrapper = new QueryWrapper<Purchase>().in("id", ids).orderByDesc("gmt_modified");
if (product != null) {
if (product.getId() != null) {
purchaseQueryWrapper.eq("product_id", product.getId());
}
}
List<Purchase> purchases = purchaseMapper.selectList(purchaseQueryWrapper);
List<Integer> productIds = purchases.stream().map(Purchase::getProductId).distinct().collect(Collectors.toList());
ArrayList<JSONObject> jsonObjects = new ArrayList<>();
for (Integer productId : productIds) {
Product product1 = productMapper.selectById(productId);
JSONObject oneMeun = new JSONObject();
oneMeun.put("name", product1.getName());
oneMeun.put("type", "line");
List<BigDecimal> data = new ArrayList<>();
for (Purchase purchase : purchases) {
if (purchase.getProductId().equals(productId)) {
data.add(purchase.getPurchasePrice());
}
}
oneMeun.put("data", data);
jsonObjects.add(oneMeun);
}
return CommonResult.ok().data("items", jsonObjects);
}
@Override
public CommonResult getSupplierPriceChange(Product product) {
List<PurchaseOrder> purchaseOrders = purchaseOrderMapper.selectList(new QueryWrapper<PurchaseOrder>().ne("is_pay", PurchaseOrderConstant.IS_CANCEL.getCode()));
List<Integer> ids = purchaseOrders.stream().map(PurchaseOrder::getPurchaseId).collect(Collectors.toList());
if (ids == null || ids.size() == 0) {
return CommonResult.ok();
}
QueryWrapper<Purchase> purchaseQueryWrapper = new QueryWrapper<Purchase>().in("id", ids).orderByDesc("gmt_modified");
if (product != null) {
if (product.getId() != null) {
purchaseQueryWrapper.eq("product_id", product.getId());
} else {
//查询数据库第一条数据productMapper
purchaseQueryWrapper.eq("product_id", productMapper.selectOne(new QueryWrapper<Product>().last("limit 1")));
}
}
List<Purchase> purchases = purchaseMapper.selectList(purchaseQueryWrapper);
List<Integer> supplierIds = purchases.stream().map(Purchase::getSupplierId).distinct().collect(Collectors.toList());
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "进价");
jsonObject.put("type", "bar");
jsonObject.put("barWidth", "60%");
List<BigDecimal> data = new ArrayList<>();
ArrayList<String> list = new ArrayList<>();
for (Integer supplierId : supplierIds) {
list.add(supplierMapper.selectById(supplierId).getName());
for (Purchase purchase : purchases) {
if (purchase.getSupplierId().equals(supplierId)) {
data.add(purchase.getPurchasePrice());
break;
}
}
}
jsonObject.put("data", data);
jsonObject.put("list", list);
return CommonResult.ok().data("items", jsonObject);
}
@Override
public CommonResult getMemberRegister() {
//统计当月会员注册数量
Long aLong = memberMapper.selectCount(new QueryWrapper<Member>().last("where DATE_FORMAT(gmt_create,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')"));
return CommonResult.ok().data("items", aLong);
}
@Override
public CommonResult getOrders() {
//统计当月订单数量,排除未支付订单is_pay=3
Long aLong = purchaseOrderMapper.selectCount(new QueryWrapper<PurchaseOrder>().last("where is_pay <> 3 and DATE_FORMAT(gmt_create,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')"));
return CommonResult.ok().data("items", aLong);
}
@Override
public CommonResult getIncome() {
//查找上月的收入
IncomeExpense incomeExpense = incomeExpenseMapper.selectOne(new QueryWrapper<IncomeExpense>().last("where type = 1 and DATE_FORMAT(gmt_create,'%Y%m') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH),'%Y%m')"));
return CommonResult.ok().data("items", incomeExpense == null ? null : incomeExpense.getAmount());
}
@Override
public CommonResult getExpendse() {
//查找上月的支出
IncomeExpense incomeExpense = incomeExpenseMapper.selectOne(new QueryWrapper<IncomeExpense>().last("where type = 0 and DATE_FORMAT(gmt_create,'%Y%m') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH),'%Y%m')"));
return CommonResult.ok().data("items", incomeExpense == null ? null : incomeExpense.getAmount());
}
@Override
public CommonResult getIncomeAndExpendse() {
//查找每个月的收入和支出
List<IncomeExpense> incomeExpenses = incomeExpenseMapper.selectList(new QueryWrapper<IncomeExpense>().orderByAsc("gmt_create"));
ArrayList<BigDecimal> inCome = new ArrayList<>();
ArrayList<BigDecimal> expendse = new ArrayList<>();
incomeExpenses.stream().forEach(incomeExpense -> {
if (incomeExpense.getType().equals(IncomeExpenseConstant.INCOME.getCode())) {
inCome.add(incomeExpense.getAmount());
} else {
expendse.add(incomeExpense.getAmount());
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于java和JavaScript开发的连锁超市管理系统前端和后端系统源码+sql数据库(毕业设计).zip
共320个文件
java:175个
js:46个
vue:38个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 8 浏览量
2023-06-29
22:39:09
上传
评论 2
收藏 464KB ZIP 举报
温馨提示
【资源说明】 该项目是个人毕设项目源码,评审分达到95分,都经过严格调试,确保可以运行!放心下载使用。 该项目资源主要针对计算机、自动化等相关专业的学生或从业者下载使用,也可作为期末课程设计、课程大作业、毕业设计等。 具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现类似其他功能。 基于java和JavaScript开发的连锁超市管理系统前端和后端系统源码+sql数据库(毕业设计).zip 采用vue-admin-template模板进行二次开发,使用Element-UI、Echarts开源组件进行开发 后端采用SpringBoot、SpringMVC、MybatisPLus、SpringSecurity、Jwt、FastJson、WebSocket、Mysql8.0进行开发
资源推荐
资源详情
资源评论
收起资源包目录
基于java和JavaScript开发的连锁超市管理系统前端和后端系统源码+sql数据库(毕业设计).zip (320个子文件)
.env.development 89B
.editorconfig 243B
.eslintignore 34B
.gitignore 190B
index.html 620B
favicon.ico 66KB
StatisticsServiceImpl.java 18KB
EmployeeServiceImpl.java 15KB
StoreServiceImpl.java 11KB
ProductServiceImpl.java 11KB
OutstockServiceImpl.java 10KB
RegionServiceImpl.java 10KB
InstockServiceImpl.java 9KB
WarehouseServiceImpl.java 9KB
UserServiceImpl.java 9KB
PurchaseServiceImpl.java 8KB
MemberPointServiceImpl.java 8KB
SupplierServiceImpl.java 8KB
MemberServiceImpl.java 6KB
PurchaseOrderServiceImpl.java 6KB
CategoryServiceImpl.java 6KB
SupermarketScheduleTask.java 6KB
RoleServiceImpl.java 6KB
PositionServiceImpl.java 5KB
BrandServiceImpl.java 5KB
InventoryServiceImpl.java 5KB
JwtUtil.java 4KB
EmployeeController.java 4KB
PermissionServiceImpl.java 4KB
ProductController.java 4KB
SecurityConfig.java 3KB
WarehouseController.java 3KB
WebSocketServer.java 3KB
StatisticsController.java 3KB
JwtAuthenticationTokenFilter.java 3KB
StoreController.java 3KB
SnowFlakeUtil.java 3KB
UserController.java 3KB
SupplierController.java 2KB
MemberPointController.java 2KB
PositionController.java 2KB
MemberController.java 2KB
OutstockController.java 2KB
MemuHelper.java 2KB
RoleController.java 2KB
PurchaseController.java 2KB
InstockController.java 2KB
BrandController.java 2KB
RedisConfig.java 2KB
PurchaseOrderController.java 2KB
SecurityUser.java 2KB
CommonResult.java 2KB
CategoryController.java 1KB
UserDetailsServiceImpl.java 1KB
RegionController.java 1KB
EmployeeService.java 1KB
ProductService.java 1KB
InventoryController.java 1KB
Employee.java 1KB
UnAuthenticationEntryPoint.java 1KB
WarehouseService.java 1KB
GlobalExceptionHandler.java 1KB
Product.java 1KB
Member.java 1KB
StoreService.java 1KB
PermissionController.java 1KB
MybatisPlusConfig.java 1KB
Permission.java 1KB
Purchase.java 1KB
UnAccessDeniedHandler.java 1KB
Store.java 1KB
PurchaseOrder.java 990B
Inventory.java 986B
Supplier.java 962B
ProductMapper.java 959B
CorsConfig.java 958B
Warehouse.java 947B
MemberPointService.java 937B
StatisticsService.java 936B
SupplierService.java 928B
OutstockService.java 910B
PositionService.java 909B
RegionService.java 895B
MemberService.java 881B
EmployeeMapper.java 879B
MemberPoint.java 867B
PermissionMapper.java 849B
RoleService.java 849B
PurchaseMapper.java 848B
PurchaseService.java 840B
ExceptionUtil.java 839B
User.java 839B
Instock.java 834B
PurchaseVo.java 832B
RolePermission.java 828B
InstockService.java 826B
UserService.java 824B
PurchaseOrderService.java 823B
Outstock.java 816B
UserRole.java 804B
共 320 条
- 1
- 2
- 3
- 4
资源评论
onnx
- 粉丝: 9641
- 资源: 5598
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功