💖💖作者:计算机毕业设计江挽 💙💙个人简介:曾长期从事计算机专业培训教学,本人也热爱上课教学,语言擅长Java、微信小程序、Python、Golang、安卓Android等,开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目
扶贫助农系统介绍
扶贫助农系统是一个基于SpringBoot框架开发的综合性农副产品销售平台,旨在通过信息化手段连接农户与消费者,促进农副产品的有效流通。系统采用Java语言作为后端开发核心,结合SpringBoot、Spring、SpringMVC、Mybatis等主流技术框架,确保系统的稳定性和可扩展性。前端采用uni-app跨平台开发框架,同时支持微信小程序和安卓应用,为用户提供多样化的访问方式。系统以MySQL作为数据存储解决方案,采用C/S与B/S混合架构模式,满足不同用户群体的使用需求。功能模块涵盖系统首页、用户管理、农户管理、产品类型管理、农副产品管理、充值记录管理、系统管理、订单管理、个人中心等九大核心板块,形成了完整的农产品电商生态链。通过该平台,农户可以直接发布自己的农副产品信息,城市消费者可以便捷地浏览和购买优质农产品,实现农产品从田间到餐桌的数字化管理流程。
扶贫助农系统演示视频
扶贫助农系统演示图片
扶贫助农系统代码展示
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Service
public class AgricultureProductService {
@Autowired
private ProductMapper productMapper;
private SparkSession spark = SparkSession.builder().appName("AgricultureProductAnalysis").master("local[*]").getOrCreate();
public Result addProduct(Product product) {
if (product.getProductName() == null || product.getProductName().trim().isEmpty()) {
return Result.error("产品名称不能为空");
}
if (product.getPrice() == null || product.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
return Result.error("产品价格必须大于0");
}
if (product.getStock() == null || product.getStock() < 0) {
return Result.error("库存数量不能为负数");
}
product.setCreateTime(LocalDateTime.now());
product.setUpdateTime(LocalDateTime.now());
product.setStatus(1);
int result = productMapper.insert(product);
if (result > 0) {
Dataset<Row> productData = spark.sql("SELECT * FROM products WHERE farmer_id = " + product.getFarmerId());
long totalProducts = productData.count();
if (totalProducts > 50) {
productMapper.updateFarmerLevel(product.getFarmerId(), "高级农户");
}
return Result.success("农副产品添加成功");
}
return Result.error("添加失败");
}
public Result updateProductStock(Long productId, Integer quantity) {
Product product = productMapper.selectById(productId);
if (product == null) {
return Result.error("产品不存在");
}
if (quantity < 0) {
return Result.error("库存数量不能为负数");
}
product.setStock(quantity);
product.setUpdateTime(LocalDateTime.now());
int result = productMapper.updateById(product);
if (result > 0) {
Dataset<Row> stockAnalysis = spark.sql("SELECT AVG(stock) as avg_stock FROM products WHERE category_id = " + product.getCategoryId());
Double avgStock = stockAnalysis.first().getDouble(0);
if (quantity < avgStock * 0.3) {
productMapper.updateProductWarning(productId, "库存不足");
}
return Result.success("库存更新成功");
}
return Result.error("更新失败");
}
}
@Service
public class OrderManagementService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private ProductMapper productMapper;
private SparkSession spark = SparkSession.builder().appName("OrderAnalysis").master("local[*]").getOrCreate();
public Result createOrder(Order order) {
if (order.getUserId() == null) {
return Result.error("用户ID不能为空");
}
if (order.getOrderItems() == null || order.getOrderItems().isEmpty()) {
return Result.error("订单商品不能为空");
}
BigDecimal totalAmount = BigDecimal.ZERO;
for (OrderItem item : order.getOrderItems()) {
Product product = productMapper.selectById(item.getProductId());
if (product == null) {
return Result.error("商品不存在:" + item.getProductId());
}
if (product.getStock() < item.getQuantity()) {
return Result.error("商品库存不足:" + product.getProductName());
}
BigDecimal itemTotal = product.getPrice().multiply(new BigDecimal(item.getQuantity()));
totalAmount = totalAmount.add(itemTotal);
item.setPrice(product.getPrice());
item.setSubtotal(itemTotal);
}
order.setOrderNo("FP" + System.currentTimeMillis());
order.setTotalAmount(totalAmount);
order.setOrderStatus(1);
order.setCreateTime(LocalDateTime.now());
int result = orderMapper.insert(order);
if (result > 0) {
for (OrderItem item : order.getOrderItems()) {
productMapper.reduceStock(item.getProductId(), item.getQuantity());
}
Dataset<Row> orderAnalysis = spark.sql("SELECT COUNT(*) as order_count FROM orders WHERE user_id = " + order.getUserId());
long userOrderCount = orderAnalysis.first().getLong(0);
if (userOrderCount >= 10) {
orderMapper.updateUserLevel(order.getUserId(), "VIP用户");
}
return Result.success("订单创建成功", order.getOrderNo());
}
return Result.error("订单创建失败");
}
public Result processOrderPayment(String orderNo, String paymentMethod) {
Order order = orderMapper.selectByOrderNo(orderNo);
if (order == null) {
return Result.error("订单不存在");
}
if (order.getOrderStatus() != 1) {
return Result.error("订单状态异常,无法支付");
}
order.setOrderStatus(2);
order.setPaymentMethod(paymentMethod);
order.setPaymentTime(LocalDateTime.now());
int result = orderMapper.updateById(order);
if (result > 0) {
Dataset<Row> paymentAnalysis = spark.sql("SELECT SUM(total_amount) as total_sales FROM orders WHERE DATE(payment_time) = CURDATE()");
Double todaySales = paymentAnalysis.first().getDouble(0);
if (todaySales > 10000) {
orderMapper.recordSalesAchievement(LocalDateTime.now().toLocalDate(), "日销售破万");
}
return Result.success("支付成功");
}
return Result.error("支付失败");
}
}
@Service
public class FarmerManagementService {
@Autowired
private FarmerMapper farmerMapper;
private SparkSession spark = SparkSession.builder().appName("FarmerAnalysis").master("local[*]").getOrCreate();
public Result registerFarmer(Farmer farmer) {
if (farmer.getFarmerName() == null || farmer.getFarmerName().trim().isEmpty()) {
return Result.error("农户姓名不能为空");
}
if (farmer.getPhoneNumber() == null || !farmer.getPhoneNumber().matches("^1[3-9]\\d{9}__CODEBLOCK_0__quot;)) {
return Result.error("请输入正确的手机号码");
}
if (farmer.getIdCard() == null || !farmer.getIdCard().matches("^\\d{17}[\\dXx]__CODEBLOCK_0__quot;)) {
return Result.error("请输入正确的身份证号码");
}
Farmer existingFarmer = farmerMapper.selectByPhoneNumber(farmer.getPhoneNumber());
if (existingFarmer != null) {
return Result.error("该手机号码已被注册");
}
farmer.setRegistrationTime(LocalDateTime.now());
farmer.setStatus(1);
farmer.setFarmerLevel("普通农户");
farmer.setTotalSales(BigDecimal.ZERO);
int result = farmerMapper.insert(farmer);
if (result > 0) {
Dataset<Row> regionAnalysis = spark.sql("SELECT COUNT(*) as farmer_count FROM farmers WHERE region = '" + farmer.getRegion() + "'");
long regionFarmerCount = regionAnalysis.first().getLong(0);
if (regionFarmerCount >= 100) {
farmerMapper.updateRegionStatus(farmer.getRegion(), "重点扶持区域");
}
return Result.success("农户注册成功");
}
return Result.error("注册失败");
}
public Result updateFarmerSalesData(Long farmerId, BigDecimal salesAmount) {
Farmer farmer = farmerMapper.selectById(farmerId);
if (farmer == null) {
return Result.error("农户不存在");
}
BigDecimal newTotalSales = farmer.getTotalSales().add(salesAmount);
farmer.setTotalSales(newTotalSales);
if (newTotalSales.compareTo(new BigDecimal("50000")) >= 0) {
farmer.setFarmerLevel("金牌农户");
} else if (newTotalSales.compareTo(new BigDecimal("20000")) >= 0) {
farmer.setFarmerLevel("银牌农户");
} else if (newTotalSales.compareTo(new BigDecimal("5000")) >= 0) {
farmer.setFarmerLevel("铜牌农户");
}
int result = farmerMapper.updateById(farmer);
if (result > 0) {
Dataset<Row> salesRanking = spark.sql("SELECT farmer_id, total_sales, ROW_NUMBER() OVER (ORDER BY total_sales DESC) as ranking FROM farmers");
salesRanking.filter("farmer_id = " + farmerId).show();
return Result.success("销售数据更新成功");
}
return Result.error("更新失败");
}
}
扶贫助农系统文档展示
💖💖作者:计算机毕业设计江挽 💙💙个人简介:曾长期从事计算机专业培训教学,本人也热爱上课教学,语言擅长Java、微信小程序、Python、Golang、安卓Android等,开发项目包括大数据、深度学习、网站、小程序、安卓、算法。平常会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 深度学习实战项目