订单分析and素材路线管理
This commit is contained in:
parent
ad6c63c4a1
commit
9bc659cd5e
@ -0,0 +1,136 @@
|
|||||||
|
package com.aircraft.api.fly.controller;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.entity.CpMaterial;
|
||||||
|
import com.aircraft.api.fly.service.CpMaterialService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.base.annotation.SysLog;
|
||||||
|
import com.base.helper.BaseController;
|
||||||
|
import com.base.helper.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
@Api(tags = "素材管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cpMaterial")
|
||||||
|
public class CpMaterialController extends BaseController {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(CpMaterialController.class);
|
||||||
|
@Autowired
|
||||||
|
private CpMaterialService entityService;
|
||||||
|
|
||||||
|
@SysLog(action = "findByPage", value = "分页查询素材")
|
||||||
|
@ApiOperation(value = "分页查询素材", notes = "分页查询素材")
|
||||||
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
|
@ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "current", value = "当前页面:从1开始", paramType = "query")})
|
||||||
|
public Result<IPage<CpMaterial>> findByPage(final CpMaterial example, final Page page) {
|
||||||
|
IPage<CpMaterial> records = entityService.page(example,page);
|
||||||
|
return new Result(true, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "delete", value = "删除素材")
|
||||||
|
@ApiOperation(value = "删除素材")
|
||||||
|
@RequestMapping(value = "{id}", method = {RequestMethod.DELETE})
|
||||||
|
@ApiImplicitParam(name = "id", value = "素材ID", required = true, paramType = "path")
|
||||||
|
public Result delete(@PathVariable final Integer id) {
|
||||||
|
try {
|
||||||
|
entityService.removeById(id);
|
||||||
|
return new Result(true, "成功删除素材", null);
|
||||||
|
} catch (DataIntegrityViolationException e) {
|
||||||
|
LOG.error("删除素材失败", e);
|
||||||
|
return new Result(false, "删除素材失败", "该素材不能删除,存在其他关联数据");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("删除素材失败", e);
|
||||||
|
return new Result(false, "删除素材失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "one", value = "查询单个素材")
|
||||||
|
@ApiOperation(value = "查询单个素材")
|
||||||
|
@RequestMapping(value = "{id}", method = {RequestMethod.GET})
|
||||||
|
@ApiImplicitParam(name = "id", value = "素材ID", required = true, paramType = "path")
|
||||||
|
public Result one(@PathVariable final Integer id) {
|
||||||
|
try {
|
||||||
|
CpMaterial entity = entityService.getById(id);
|
||||||
|
return new Result(true, entity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("查询单个素材失败", e);
|
||||||
|
return new Result(false, new CpMaterial());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "add", value = "添加素材")
|
||||||
|
@ApiOperation(value = "添加素材")
|
||||||
|
@RequestMapping(method = {RequestMethod.POST})
|
||||||
|
public Result add(@Valid @RequestBody final CpMaterial entity, final BindingResult result) {
|
||||||
|
try {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
Map<String, String> map = this.getErrors(result);
|
||||||
|
String errorMsg = map.entrySet().iterator().next().getValue();
|
||||||
|
return new Result(false, "保存素材失败", errorMsg, map);
|
||||||
|
} else {
|
||||||
|
entityService.save(entity);
|
||||||
|
return new Result(true, "成功保存素材", null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("添加素材失败", e);
|
||||||
|
return new Result(false, "保存素材失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "update", value = "修改素材")
|
||||||
|
@ApiOperation(value = "修改素材")
|
||||||
|
@RequestMapping(method = {RequestMethod.PUT})
|
||||||
|
public Result update(@Valid @RequestBody final CpMaterial entity, final BindingResult result) {
|
||||||
|
try {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
Map<String, String> map = this.getErrors(result);
|
||||||
|
String errorMsg = map.entrySet().iterator().next().getValue();
|
||||||
|
return new Result(false, "修改素材失败", errorMsg, map);
|
||||||
|
} else {
|
||||||
|
if (null == entity.getId()) {
|
||||||
|
throw new RuntimeException("id不能为空");
|
||||||
|
}
|
||||||
|
entityService.updateById(entity);
|
||||||
|
return new Result(true, "成功修改素材", null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("修改素材失败", e);
|
||||||
|
return new Result(false, "修改素材失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "全部素材")
|
||||||
|
@RequestMapping(value = "all", method = RequestMethod.GET)
|
||||||
|
public Result<List<CpMaterial>> all(CpMaterial example) {
|
||||||
|
List<CpMaterial> entitys = entityService.list(example);
|
||||||
|
if (null != entitys) {
|
||||||
|
return new Result<>(true, entitys);
|
||||||
|
}
|
||||||
|
return new Result<>(true, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.aircraft.api.fly.controller;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.service.OdOrderAnalysisService;
|
||||||
|
import com.aircraft.api.fly.vo.OdOrderAnalysisResult;
|
||||||
|
import com.base.helper.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Api(tags = "订单分析")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/order/analysis")
|
||||||
|
public class OdOrderAnalysisController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OdOrderAnalysisService analysisService;
|
||||||
|
|
||||||
|
@ApiOperation("按时间维度分析订单")
|
||||||
|
@PostMapping("/time")
|
||||||
|
//传入day/month/year,返回某周,某月,某年的总订单量,总销售额及其趋势
|
||||||
|
public Result<OdOrderAnalysisResult> analyzeOrdersByTimeDimension(String TimeDimension) {
|
||||||
|
OdOrderAnalysisResult result = analysisService.analyzeOrdersByTimeDimension(TimeDimension);
|
||||||
|
return new Result<>(true, result);
|
||||||
|
}
|
||||||
|
@ApiOperation("按时间范围分析订单")
|
||||||
|
@GetMapping("/timeRange")
|
||||||
|
public OdOrderAnalysisResult analyzeByDateRange(
|
||||||
|
@RequestParam("startDate") String startDate,
|
||||||
|
@RequestParam("endDate") String endDate
|
||||||
|
) {
|
||||||
|
return analysisService.analyzeOrdersByDateRange(startDate, endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
package com.aircraft.api.fly.controller;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.entity.Route;
|
||||||
|
import com.aircraft.api.fly.service.RouteService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.base.annotation.SysLog;
|
||||||
|
import com.base.helper.BaseController;
|
||||||
|
import com.base.helper.Result;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 路线信息表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
@Api(tags = "路线管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/route")
|
||||||
|
public class RouteController extends BaseController {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(RouteController.class);
|
||||||
|
@Autowired
|
||||||
|
private RouteService entityService;
|
||||||
|
|
||||||
|
@SysLog(action = "findByPage", value = "分页查询路线")
|
||||||
|
@ApiOperation(value = "分页查询路线", notes = "分页查询路线")
|
||||||
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
|
@ApiImplicitParams({@ApiImplicitParam(name = "size", value = "分页大小", paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "current", value = "当前页面:从1开始", paramType = "query")})
|
||||||
|
public Result<IPage<Route>> findByPage(final Route example, final Page page) {
|
||||||
|
IPage<Route> records = entityService.page(example,page);
|
||||||
|
return new Result(true, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "delete", value = "删除路线")
|
||||||
|
@ApiOperation(value = "删除路线")
|
||||||
|
@RequestMapping(value = "{id}", method = {RequestMethod.DELETE})
|
||||||
|
@ApiImplicitParam(name = "id", value = "路线ID", required = true, paramType = "path")
|
||||||
|
public Result delete(@PathVariable final Integer id) {
|
||||||
|
try {
|
||||||
|
entityService.removeById(id);
|
||||||
|
return new Result(true, "成功删除路线", null);
|
||||||
|
} catch (DataIntegrityViolationException e) {
|
||||||
|
LOG.error("删除路线失败", e);
|
||||||
|
return new Result(false, "删除路线失败", "该路线不能删除,存在其他关联数据");
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("删除路线失败", e);
|
||||||
|
return new Result(false, "删除路线失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "one", value = "查询单个路线")
|
||||||
|
@ApiOperation(value = "查询单个路线")
|
||||||
|
@RequestMapping(value = "{id}", method = {RequestMethod.GET})
|
||||||
|
@ApiImplicitParam(name = "id", value = "路线ID", required = true, paramType = "path")
|
||||||
|
public Result one(@PathVariable final Integer id) {
|
||||||
|
try {
|
||||||
|
Route entity = entityService.getById(id);
|
||||||
|
return new Result(true, entity);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("查询单个路线失败", e);
|
||||||
|
return new Result(false, new Route());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "add", value = "添加路线")
|
||||||
|
@ApiOperation(value = "添加路线")
|
||||||
|
@RequestMapping(method = {RequestMethod.POST})
|
||||||
|
public Result add(@Valid @RequestBody final Route entity, final BindingResult result) {
|
||||||
|
try {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
Map<String, String> map = this.getErrors(result);
|
||||||
|
String errorMsg = map.entrySet().iterator().next().getValue();
|
||||||
|
return new Result(false, "保存路线失败", errorMsg, map);
|
||||||
|
} else {
|
||||||
|
entityService.save(entity);
|
||||||
|
return new Result(true, "成功保存路线", null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("添加路线失败", e);
|
||||||
|
return new Result(false, "保存路线失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SysLog(action = "update", value = "修改路线")
|
||||||
|
@ApiOperation(value = "修改路线")
|
||||||
|
@RequestMapping(method = {RequestMethod.PUT})
|
||||||
|
public Result update(@Valid @RequestBody final Route entity, final BindingResult result) {
|
||||||
|
try {
|
||||||
|
if (result.hasErrors()) {
|
||||||
|
Map<String, String> map = this.getErrors(result);
|
||||||
|
String errorMsg = map.entrySet().iterator().next().getValue();
|
||||||
|
return new Result(false, "修改路线失败", errorMsg, map);
|
||||||
|
} else {
|
||||||
|
if (null == entity.getId()) {
|
||||||
|
throw new RuntimeException("id不能为空");
|
||||||
|
}
|
||||||
|
entityService.updateById(entity);
|
||||||
|
return new Result(true, "成功修改路线", null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("修改路线失败", e);
|
||||||
|
return new Result(false, "修改路线失败", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "全部路线")
|
||||||
|
@RequestMapping(value = "all", method = RequestMethod.GET)
|
||||||
|
public Result<List<Route>> all(Route example) {
|
||||||
|
List<Route> entitys = entityService.list(example);
|
||||||
|
if (null != entitys) {
|
||||||
|
return new Result<>(true, entitys);
|
||||||
|
}
|
||||||
|
return new Result<>(true, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
17
src/main/java/com/aircraft/api/fly/dao/CpMaterialMapper.java
Normal file
17
src/main/java/com/aircraft/api/fly/dao/CpMaterialMapper.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.aircraft.api.fly.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.entity.CpMaterial;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
public interface CpMaterialMapper extends BaseMapper<CpMaterial> {
|
||||||
|
|
||||||
|
}
|
||||||
17
src/main/java/com/aircraft/api/fly/dao/RouteMapper.java
Normal file
17
src/main/java/com/aircraft/api/fly/dao/RouteMapper.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.aircraft.api.fly.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.entity.Route;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 路线信息表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
public interface RouteMapper extends BaseMapper<Route> {
|
||||||
|
|
||||||
|
}
|
||||||
56
src/main/java/com/aircraft/api/fly/entity/CpMaterial.java
Normal file
56
src/main/java/com/aircraft/api/fly/entity/CpMaterial.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package com.aircraft.api.fly.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="CpMaterial", description="")
|
||||||
|
public class CpMaterial implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "素材名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "素材存储路径")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "素材类型:1:轮播图,2:宣传视频")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序号,数值越小越靠前")
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "链接地址")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态:t:启用,f:禁用")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
78
src/main/java/com/aircraft/api/fly/entity/Route.java
Normal file
78
src/main/java/com/aircraft/api/fly/entity/Route.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package com.aircraft.api.fly.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 路线信息表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="Route", description="路线信息表")
|
||||||
|
public class Route implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "路线名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "城市名称,例如:广东,北京")
|
||||||
|
private String cityName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关联景区id")
|
||||||
|
private Integer scenicId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "起点,手动存储经纬度,不调用地图")
|
||||||
|
private String startPoint;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "终点")
|
||||||
|
private String endPoint;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "文章链接")
|
||||||
|
private String link;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "跳转地址")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "封面图存储路径")
|
||||||
|
private String imgPath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序号")
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否展示在用户列表,“1”展示 “0”不展示(如超级管理员账号不展示在用户列表)")
|
||||||
|
private String show;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态,“1”有效 “0”删除")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.aircraft.api.fly.service;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.entity.CpMaterial;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
public interface CpMaterialService extends IService<CpMaterial> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件查询
|
||||||
|
* @param example
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CpMaterial> list(CpMaterial example);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param example
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<CpMaterial> page(CpMaterial example,IPage page);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.aircraft.api.fly.service;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.vo.OdOrderAnalysisResult;
|
||||||
|
|
||||||
|
public interface OdOrderAnalysisService {
|
||||||
|
|
||||||
|
OdOrderAnalysisResult analyzeOrdersByTimeDimension(String TimeDimension);
|
||||||
|
|
||||||
|
OdOrderAnalysisResult analyzeOrdersByDateRange(String startDate, String endDate);
|
||||||
|
}
|
||||||
34
src/main/java/com/aircraft/api/fly/service/RouteService.java
Normal file
34
src/main/java/com/aircraft/api/fly/service/RouteService.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.aircraft.api.fly.service;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.entity.Route;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 路线信息表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
public interface RouteService extends IService<Route> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件查询
|
||||||
|
* @param example
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Route> list(Route example);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param example
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<Route> page(Route example,IPage page);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package com.aircraft.api.fly.service.impl;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.dao.CpMaterialMapper;
|
||||||
|
import com.aircraft.api.fly.entity.CpMaterial;
|
||||||
|
import com.aircraft.api.fly.service.CpMaterialService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CpMaterialServiceImpl extends ServiceImpl<CpMaterialMapper, CpMaterial> implements CpMaterialService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CpMaterial> list(CpMaterial example) {
|
||||||
|
return this.list(buildWrapper(example));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<CpMaterial> page(CpMaterial example, IPage page) {
|
||||||
|
return this.page(page,buildWrapper(example));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询
|
||||||
|
*
|
||||||
|
* @param example
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private QueryWrapper<CpMaterial> buildWrapper(CpMaterial example) {
|
||||||
|
QueryWrapper<CpMaterial> wrapper = new QueryWrapper<>();
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,183 @@
|
|||||||
|
package com.aircraft.api.fly.service.impl;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.service.OdOrderAnalysisService;
|
||||||
|
import com.aircraft.api.fly.vo.OdOrderAnalysisResult;
|
||||||
|
import com.aircraft.api.od.entity.OdOrder;
|
||||||
|
import com.aircraft.api.od.service.OdOrderService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OdOrderAnalysisServiceImpl implements OdOrderAnalysisService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OdOrderService orderService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//按日月年(传入day/month/year),分别统计本周每日、本周每月、近7年的订单数量和销售额
|
||||||
|
public OdOrderAnalysisResult analyzeOrdersByTimeDimension(String timeDimension) {
|
||||||
|
OdOrderAnalysisResult result = new OdOrderAnalysisResult();
|
||||||
|
switch (timeDimension.toLowerCase()) {
|
||||||
|
case "day":
|
||||||
|
// 处理按日统计逻辑,获取本周内每一天的数据
|
||||||
|
List<OdOrderAnalysisResult.DailyData> dailyDataList = new ArrayList<>();
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
// 获取本周一
|
||||||
|
LocalDate monday = today.with(DayOfWeek.MONDAY);
|
||||||
|
|
||||||
|
// 遍历本周七天
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
LocalDate currentDay = monday.plusDays(i);
|
||||||
|
LocalDate nextDay = currentDay.plusDays(1);
|
||||||
|
|
||||||
|
// 查询当天订单
|
||||||
|
List<OdOrder> dailyOrders = orderService.findByCreateTimeBetween(
|
||||||
|
currentDay.atStartOfDay(),
|
||||||
|
nextDay.atStartOfDay()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 处理当天数据
|
||||||
|
OdOrderAnalysisResult.DailyData dailyData = new OdOrderAnalysisResult.DailyData();
|
||||||
|
dailyData.setDate(currentDay.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||||
|
dailyData.setOrderCount(dailyOrders.size());
|
||||||
|
|
||||||
|
double dailySales = 0;
|
||||||
|
for (OdOrder order : dailyOrders) {
|
||||||
|
dailySales += order.getAmount();
|
||||||
|
}
|
||||||
|
dailyData.setSalesAmount(dailySales);
|
||||||
|
|
||||||
|
dailyDataList.add(dailyData);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setDailyDataList(dailyDataList);
|
||||||
|
result.setTimeDimensionDesc("本周每日");
|
||||||
|
break;
|
||||||
|
case "month":
|
||||||
|
// 处理按月统计逻辑(保持原有逻辑不变)
|
||||||
|
List<OdOrderAnalysisResult.MonthlyData> monthlyDataList = new ArrayList<>();
|
||||||
|
for (int month = 1; month <= 12; month++) {
|
||||||
|
LocalDate monthStart = LocalDate.of(LocalDate.now().getYear(), month, 1);
|
||||||
|
LocalDate monthEnd = monthStart.plusMonths(1);
|
||||||
|
List<OdOrder> monthOrders = orderService.findByCreateTimeBetween(monthStart.atStartOfDay(), monthEnd.atStartOfDay());
|
||||||
|
OdOrderAnalysisResult.MonthlyData monthlyData = new OdOrderAnalysisResult.MonthlyData();
|
||||||
|
monthlyData.setMonth(month + "月");
|
||||||
|
monthlyData.setOrderCount(monthOrders.size());
|
||||||
|
|
||||||
|
double monthlySales = 0;
|
||||||
|
for (OdOrder order : monthOrders) {
|
||||||
|
monthlySales += order.getAmount();
|
||||||
|
}
|
||||||
|
monthlyData.setSalesAmount(monthlySales);
|
||||||
|
|
||||||
|
monthlyDataList.add(monthlyData);
|
||||||
|
}
|
||||||
|
result.setMonthlyDataList(monthlyDataList);
|
||||||
|
result.setTimeDimensionDesc("每月");
|
||||||
|
break;
|
||||||
|
case "year":
|
||||||
|
// 处理按年统计逻辑,查询最近7年的数据
|
||||||
|
List<OdOrderAnalysisResult.YearlyData> yearlyDataList = new ArrayList<>();
|
||||||
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
|
||||||
|
// 计算近7年的年份范围
|
||||||
|
for (int i = 6; i >= 0; i--) {
|
||||||
|
int year = currentDate.minus(i, ChronoUnit.YEARS).getYear();
|
||||||
|
LocalDate yearStart = LocalDate.of(year, 1, 1);
|
||||||
|
LocalDate yearEnd = yearStart.plusYears(1);
|
||||||
|
|
||||||
|
List<OdOrder> yearOrders = orderService.findByCreateTimeBetween(yearStart.atStartOfDay(), yearEnd.atStartOfDay());
|
||||||
|
|
||||||
|
OdOrderAnalysisResult.YearlyData yearlyData = new OdOrderAnalysisResult.YearlyData();
|
||||||
|
yearlyData.setYear(year);
|
||||||
|
yearlyData.setOrderCount(yearOrders.size());
|
||||||
|
|
||||||
|
double yearlySales = 0;
|
||||||
|
for (OdOrder order : yearOrders) {
|
||||||
|
yearlySales += order.getAmount();
|
||||||
|
}
|
||||||
|
yearlyData.setSalesAmount(yearlySales);
|
||||||
|
|
||||||
|
yearlyDataList.add(yearlyData);
|
||||||
|
}
|
||||||
|
result.setYearlyDataList(yearlyDataList);
|
||||||
|
result.setTimeDimensionDesc("近7年");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("无效的时间维度,支持 'day'(本周每日)、'month'(每月)、'year'(每年)");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//传入时间范围,查询该时间范围内每日的数据,以及总订单量和销售额
|
||||||
|
public OdOrderAnalysisResult analyzeOrdersByDateRange(String startDateStr, String endDateStr) {
|
||||||
|
// 解析日期
|
||||||
|
LocalDate startDate = parseDate(startDateStr);
|
||||||
|
LocalDate endDate = parseDate(endDateStr);
|
||||||
|
|
||||||
|
// 验证日期有效性
|
||||||
|
if (startDate.isAfter(endDate)) {
|
||||||
|
throw new IllegalArgumentException("开始日期不能晚于结束日期");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化结果对象
|
||||||
|
OdOrderAnalysisResult result = new OdOrderAnalysisResult();
|
||||||
|
result.setTimeDimensionDesc(String.format("%s至%s", startDateStr, endDateStr));
|
||||||
|
List<OdOrderAnalysisResult.DailyData> dailyDataList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 计算总天数
|
||||||
|
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
|
||||||
|
|
||||||
|
// 遍历日期范围,按天查询数据
|
||||||
|
for (int i = 0; i < daysBetween; i++) {
|
||||||
|
LocalDate currentDate = startDate.plusDays(i);
|
||||||
|
LocalDate nextDate = currentDate.plusDays(1);
|
||||||
|
|
||||||
|
// 查询当天订单
|
||||||
|
List<OdOrder> dailyOrders = orderService.findByCreateTimeBetween(
|
||||||
|
currentDate.atStartOfDay(),
|
||||||
|
nextDate.atStartOfDay()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 处理单日数据
|
||||||
|
OdOrderAnalysisResult.DailyData dailyData = new OdOrderAnalysisResult.DailyData();
|
||||||
|
dailyData.setDate(currentDate.toString());
|
||||||
|
dailyData.setOrderCount(dailyOrders.size());
|
||||||
|
|
||||||
|
double dailySales = 0;
|
||||||
|
for (OdOrder order : dailyOrders) {
|
||||||
|
dailySales += order.getAmount();
|
||||||
|
}
|
||||||
|
dailyData.setSalesAmount(dailySales);
|
||||||
|
|
||||||
|
dailyDataList.add(dailyData);
|
||||||
|
}
|
||||||
|
// 设置结果
|
||||||
|
result.setDailyDataList(dailyDataList);
|
||||||
|
// 计算总计
|
||||||
|
int totalOrderCount = dailyDataList.stream().mapToInt(OdOrderAnalysisResult.DailyData::getOrderCount).sum();
|
||||||
|
double totalSalesAmount = dailyDataList.stream().mapToDouble(OdOrderAnalysisResult.DailyData::getSalesAmount).sum();
|
||||||
|
result.setTotalOrderCount(totalOrderCount);
|
||||||
|
result.setTotalSalesAmount(totalSalesAmount);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析日期字符串,支持 yyyy-MM-dd 格式
|
||||||
|
*/
|
||||||
|
private LocalDate parseDate(String dateStr) {
|
||||||
|
try {
|
||||||
|
return LocalDate.parse(dateStr, DateTimeFormatter.ISO_LOCAL_DATE);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalArgumentException("日期格式不正确,支持格式:yyyy-MM-dd", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package com.aircraft.api.fly.service.impl;
|
||||||
|
|
||||||
|
import com.aircraft.api.fly.dao.RouteMapper;
|
||||||
|
import com.aircraft.api.fly.entity.Route;
|
||||||
|
import com.aircraft.api.fly.service.RouteService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 路线信息表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author gjj
|
||||||
|
* @since 2025-07-05
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implements RouteService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Route> list(Route example) {
|
||||||
|
return this.list(buildWrapper(example));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<Route> page(Route example, IPage page) {
|
||||||
|
return this.page(page,buildWrapper(example));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询
|
||||||
|
*
|
||||||
|
* @param example
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private QueryWrapper<Route> buildWrapper(Route example) {
|
||||||
|
QueryWrapper<Route> wrapper = new QueryWrapper<>();
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.aircraft.api.fly.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("订单分析查询条件")
|
||||||
|
public class OdOrderAnalysisQuery {
|
||||||
|
|
||||||
|
@ApiModelProperty("分析时间维度(日/月/年)")
|
||||||
|
private String timeDimension; // day/month/year
|
||||||
|
|
||||||
|
@ApiModelProperty("开始时间")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("结束时间")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("订单状态")
|
||||||
|
private String orderStatus;
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
package com.aircraft.api.fly.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OdOrderAnalysisResult {
|
||||||
|
|
||||||
|
// 通用字段,用于周、年统计时的总订单量
|
||||||
|
private int totalOrderCount;
|
||||||
|
// 通用字段,用于周、年统计时的总销售额
|
||||||
|
private double totalSalesAmount;
|
||||||
|
// 时间维度描述,如“本周”“每月”“当年”
|
||||||
|
private String timeDimensionDesc;
|
||||||
|
// 按日统计时,存储每日数据的列表
|
||||||
|
private List<DailyData> dailyDataList;
|
||||||
|
// 按月统计时,存储每月数据的列表
|
||||||
|
private List<MonthlyData> monthlyDataList;
|
||||||
|
// 按年统计时,存储近7年数据的列表
|
||||||
|
private List<YearlyData> yearlyDataList;
|
||||||
|
|
||||||
|
// 内部类,用于存储按日统计时每日的订单数量和销售额
|
||||||
|
@Data
|
||||||
|
public static class DailyData {
|
||||||
|
// 日期,如“2025-07-01”
|
||||||
|
private String date;
|
||||||
|
// 当日订单数量
|
||||||
|
private int orderCount;
|
||||||
|
// 当日销售额
|
||||||
|
private double salesAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内部类,用于存储按月统计时每个月的订单数量和销售额
|
||||||
|
@Data
|
||||||
|
public static class MonthlyData {
|
||||||
|
// 月份,如“1月”“2月”等
|
||||||
|
private String month;
|
||||||
|
// 当月订单数量
|
||||||
|
private int orderCount;
|
||||||
|
// 当月销售额
|
||||||
|
private double salesAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内部类,用于存储按年统计时每年的订单数量和销售额
|
||||||
|
@Data
|
||||||
|
public static class YearlyData {
|
||||||
|
private int year;
|
||||||
|
private int orderCount;
|
||||||
|
private double salesAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user