diff --git a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Car.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Car.java index 7d0a3bc..b07e698 100644 --- a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Car.java +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Car.java @@ -32,7 +32,7 @@ public class Car { /** * 车辆表ID */ - private Integer carId; + private Long carId; /** * 车辆表vin */ @@ -40,11 +40,11 @@ public class Car { /** * 车辆类型 */ - private Integer carType; + private String carType; /** * 电子围栏ID */ - private Integer carFenceId; + private String carFenceId; /** * 车辆状态 */ @@ -98,6 +98,7 @@ public class Car { .carBattery(carAddReq.getCarBattery()) .carElectricalmachineyId(carAddReq.getCarElectricalmachineyId()) .carBatteryId(carAddReq.getCarBatteryId()) + .remark(carAddReq.getRemark()) .build(); } @@ -112,6 +113,7 @@ public class Car { .carBattery(carUpdateReq.getCarBattery()) .carElectricalmachineyId(carUpdateReq.getCarElectricalmachineyId()) .carBatteryId(carUpdateReq.getCarBatteryId()) + .remark(carUpdateReq.getRemark()) .build(); } diff --git a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarAddReq.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarAddReq.java index 513f90a..d9735bb 100644 --- a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarAddReq.java +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarAddReq.java @@ -23,30 +23,31 @@ public class CarAddReq { /** * 车俩表vin */ - @NotEmpty - @Length(max = 255) - @Pattern(regexp = "^[0-9a-zA-Z]{17}$",message = "请输入正确的vin码") +// @NotEmpty +// @Length(max = 255) +// @Pattern(regexp = "^[0-9a-zA-Z]{17}$",message = "请输入正确的vin码") @ApiModelProperty(value = "车辆vin码") private String carVin; /** * 车辆类型 */ @NotNull - @Min(value = 1, message = "车辆类型必须大于等于1") + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的车辆类型") @ApiModelProperty(value = "车辆类型") - private Integer carType; + private String carType; /** * 电子围栏ID */ @NotNull - @Min(value = 1, message = "电子围栏必须大于等于1") + @Length(max = 255) @ApiModelProperty(value = "电子围栏ID") - private Integer carFenceId; + private String carFenceId; /** * 车辆状态 */ @NotNull - @Min(value = 1, message = "车辆状态必须大于等于1") + @Min(value = 0, message = "车辆状态必须大于等于0") @ApiModelProperty(value = "车辆状态") private Integer state; /** @@ -80,4 +81,13 @@ public class CarAddReq { @ApiModelProperty(value = "电池编号") private Integer carBatteryId; + /** + * 备注 + */ + @NotEmpty + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的备注") + @ApiModelProperty(value = "备注") + private String remark; + } diff --git a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarRequest.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarRequest.java index a152fe1..aa2e05b 100644 --- a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarRequest.java +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarRequest.java @@ -13,7 +13,7 @@ import lombok.Data; */ @Data public class CarRequest { - private Integer pageNum; - private Integer pageSize; + private Integer pageNum=1; + private Integer pageSize=10; } diff --git a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarUpdateReq.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarUpdateReq.java index 45ac5d1..1dbd515 100644 --- a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarUpdateReq.java +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarUpdateReq.java @@ -26,34 +26,35 @@ public class CarUpdateReq { * 车辆表id */ @ApiModelProperty(value = "车辆表id") - private Integer carId; + private Long carId; /** * 车俩表vin */ - @NotEmpty - @Length(max = 255) - @Pattern(regexp = "^[0-9a-zA-Z]{17}$",message = "请输入正确的vin码") +// @NotEmpty +// @Length(max = 255) +// @Pattern(regexp = "^[0-9a-zA-Z]{17}$",message = "请输入正确的vin码") @ApiModelProperty(value = "车辆vin码") private String carVin; /** * 车辆类型 */ @NotNull - @Min(value = 1, message = "车辆类型必须大于等于1") + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的车辆类型") @ApiModelProperty(value = "车辆类型") - private Integer carType; + private String carType; /** * 电子围栏ID */ @NotNull - @Min(value = 1, message = "电子围栏必须大于等于1") + @Length(max = 255) @ApiModelProperty(value = "电子围栏ID") - private Integer carFenceId; + private String carFenceId; /** * 车辆状态 */ @NotNull - @Min(value = 1, message = "车辆状态必须大于等于1") + @Min(value = 0, message = "车辆状态必须大于等于0") @ApiModelProperty(value = "车辆状态") private Integer state; /** @@ -86,5 +87,13 @@ public class CarUpdateReq { @Min(value = 1, message = "电池编号必须大于等于1") @ApiModelProperty(value = "电池编号") private Integer carBatteryId; + /** + * 备注 + */ + @NotEmpty + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的备注") + @ApiModelProperty(value = "备注") + private String remark; } diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/controller/CarController.java b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/controller/CarController.java index 89b141f..caaacac 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/controller/CarController.java +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/controller/CarController.java @@ -1,62 +1,100 @@ package com.muyu.system.controller; -import com.alibaba.fastjson.JSON; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import com.alibaba.fastjson.JSONObject; +import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.muyu.common.core.domain.PageResult; import com.muyu.common.core.domain.Result; -import com.muyu.common.core.web.controller.BaseController; -import com.muyu.common.log.annotation.Log; -import com.muyu.common.log.enums.BusinessType; -import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.system.common.domain.Car; import com.muyu.system.common.domain.Fence; -import com.muyu.system.common.domain.SysDept; -import com.muyu.system.common.domain.SysDictData; import com.muyu.system.common.domain.req.CarAddReq; import com.muyu.system.common.domain.req.CarUpdateReq; import com.muyu.system.common.domain.vo.CarVo; import com.muyu.system.service.CarService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.common.security.annotation.RequiresPermissions; + +import com.muyu.common.core.web.controller.BaseController; + +import com.muyu.common.core.utils.poi.ExcelUtil; -import javax.servlet.http.HttpServletRequest; import java.util.List; /** - * 车辆管理 - * @ProjectName: colud-vehicles - * @PackageName: com.muyu.system.controller - * @Description TODO - * @Author XiaoFan - * @Date 2024/3/26 19:57 - * @Version 1.0 + * 车辆信息Controller + * + * @author muyu + * @date 2024-03-29 */ - @RestController -@Slf4j @RequestMapping("/car") -public class CarController extends BaseController{ +@Slf4j +public class CarController extends BaseController +{ @Autowired private CarService carService; @Autowired - private HttpServletRequest request; - + private HttpServletRequest request; + /** + * 查询车辆信息列表 + */ @GetMapping("/list") - @RequiresPermissions("system:car:list") +// @RequiresPermissions("system:car:list") @Log(title = "车辆列表") public Result> list(@Validated CarVo carVo){ log.info("执行操作:查询车辆列表,请求URL:{},请求方法:{},请求参数:{}",request.getRequestURI(), request.getMethod(), carVo); Result> list=carService.list(carVo); log.info("执行操作:查询车辆列表,请求URL:{},请求方式:{},响应结果:{}",request.getRequestURI(), - request.getMethod(),JSONObject.toJSONString(list)); + request.getMethod(), JSONObject.toJSONString(list)); return list; } + + /** + * 导出车辆信息列表 + */ +// @RequiresPermissions("system:car:export") + @Log(title = "车辆信息", businessType = BusinessType.EXPORT) + @PostMapping("/exportA") + public void exportA(HttpServletResponse response, Car car) + { + List list = carService.selectCarList(car); + ExcelUtil util = new ExcelUtil<>(Car.class); + util.exportExcel(response, list, "车辆信息数据"); + } + + /** + * 获取车辆信息详细信息 + */ + @GetMapping("/findById/{carId}") +// @RequiresPermissions("system:car:query") + @Log(title = "车辆管理") + public Result findById(@PathVariable Integer carId){ + Car car=carService.findById(carId); + return Result.success(car); + } + /** + * 新增车辆信息 + */ @PostMapping("/add") - @RequiresPermissions("system:config:add") +// @RequiresPermissions("system:car:add") @Log(title = "车辆管理",businessType = BusinessType.INSERT) public Result add(@RequestBody @Validated CarAddReq carAddReq){ log.info("执行操作:添加车辆数据,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), @@ -67,8 +105,12 @@ public class CarController extends BaseController{ request.getMethod(),JSONObject.toJSONString(carAddReq)); return result; } + + /** + * 修改车辆信息 + */ @PostMapping("/update") - @RequiresPermissions("system:config:edit") +// @RequiresPermissions("system:car:edit") @Log(title = "车辆管理",businessType = BusinessType.UPDATE) public Result update(@RequestBody @Validated CarUpdateReq carUpdateReq){ log.info("执行操作:修改车辆数据,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), @@ -79,28 +121,15 @@ public class CarController extends BaseController{ request.getMethod(),JSONObject.toJSONString(result)); return result; } - @PostMapping("/del/{carId}") - @RequiresPermissions("system:config:remove") - @Log(title = "车辆管理",businessType = BusinessType.DELETE) - public Result del(@PathVariable Integer carId){ - log.info("执行操作:删除,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), - request.getMethod(),JSONObject.toJSONString(carId)); - Result result=Result.success(carId); - carService.del(carId); - log.info("执行操作:删除,请求URL:{},请求方式:{},响应结果:{}",request.getRequestURI(), - request.getMethod(),JSONObject.toJSONString(result)); - return result; - } - @GetMapping("/findById/{carId}") - @RequiresPermissions("system:car:query") - @Log(title = "车辆管理") - public Car findById(@PathVariable Integer carId){ - log.info("执行操作:根据id查询数据,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), - request.getMethod(),JSONObject.toJSONString(carId)); - Car car=carService.findById(carId); - log.info("执行操作:根据id查询数据,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), - request.getMethod(), JSONObject.toJSONString(car)); - return car; + + /** + * 删除车辆信息 + */ + @PostMapping("/del/{carIds}") +// @RequiresPermissions("system:car:remove") + @Log(title = "车辆管理", businessType = BusinessType.DELETE) + public Result deleteBatch(@PathVariable Long[] carIds) { + return Result.success(carService.deleteBatch(carIds)); // 调用服务层方法,获取被删除的记录数 } @GetMapping("/selectFence") @Log(title = "查询电子围栏表") @@ -110,12 +139,5 @@ public class CarController extends BaseController{ List list=carService.selectFence(); return Result.success(list); } - @GetMapping("/selectState") - @Log(title = "查询字典表") - public Result> selectState(){ - log.info("执行操作:查询规则,请求URL:{},请求方式:{}",request.getRequestURI(), - request.getMethod()); - List list=carService.selectState(); - return Result.success(list); - } + } diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/mapper/CarMapper.java b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/mapper/CarMapper.java index 232f6c7..5addeab 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/mapper/CarMapper.java +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/mapper/CarMapper.java @@ -1,36 +1,31 @@ package com.muyu.system.mapper; - import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.system.common.domain.Car; import com.muyu.system.common.domain.Fence; -import com.muyu.system.common.domain.SysDictData; -import org.apache.ibatis.annotations.Mapper; import java.util.List; + /** - * 车辆管理 数据层 - * @ProjectName: colud-vehicles - * @PackageName: com.muyu.system.mapper - * @Description TODO - * @Author XiaoFan - * @Date 2024/3/26 19:59 - * @Version 1.0 + * 车辆信息Mapper接口 + * + * @author muyu + * @date 2024-03-29 */ -@Mapper -public interface CarMapper extends BaseMapper { - List selectState(); +public interface CarMapper extends BaseMapper +{ + + + /** + * 查询车辆信息列表 + * + * @param car 车辆信息 + * @return 车辆信息集合 + */ + public List selectCarList(Car car); + List selectFence(); - - -// List list(carVo carVo); - -// void add(Car car); -// -//void update(car car); -// -// void del(Integer carId); } diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/CarService.java b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/CarService.java index 702a03f..544fcef 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/CarService.java +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/CarService.java @@ -5,39 +5,43 @@ import com.muyu.common.core.domain.PageResult; import com.muyu.common.core.domain.Result; import com.muyu.system.common.domain.Car; import com.muyu.system.common.domain.Fence; -import com.muyu.system.common.domain.SysDept; -import com.muyu.system.common.domain.SysDictData; import com.muyu.system.common.domain.vo.CarVo; import java.util.List; /** - * 车辆管理 服务层 - * @ProjectName: colud-vehicles - * @PackageName: com.muyu.system.service - * @Description TODO - * @Author XiaoFan - * @Date 2024/3/26 19:58 - * @Version 1.0 + * 车辆信息Service接口 + * + * @author muyu + * @date 2024-03-29 */ -public interface CarService extends IService { +public interface CarService extends IService +{ + /** + * 查询车辆列表 + */ Result> list(CarVo carVo); + + /** + * 查询车辆信息列表 + * + * @param car 车辆信息 + * @return 车辆信息集合 + */ + public List selectCarList(Car car); + void add(Car car); void update(Car car); - void del(Integer carId); + int deleteBatch(Long[] carIds); Car findById(Integer carId); - List selectState(); - - - List selectFence(); diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/impl/CarServiceImpl.java b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/impl/CarServiceImpl.java index 59a66e0..75661b9 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/impl/CarServiceImpl.java +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/impl/CarServiceImpl.java @@ -1,40 +1,44 @@ package com.muyu.system.service.impl; +import java.util.Arrays; +import java.util.List; +import com.alibaba.nacos.client.naming.utils.CollectionUtils; +import com.alibaba.nacos.common.utils.UuidUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.muyu.common.core.domain.PageResult; import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.DateUtils; import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.uuid.IdUtils; import com.muyu.system.common.domain.Car; import com.muyu.system.common.domain.Fence; -import com.muyu.system.common.domain.SysDept; -import com.muyu.system.common.domain.SysDictData; import com.muyu.system.common.domain.vo.CarVo; import com.muyu.system.mapper.CarMapper; -import com.muyu.system.service.CarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; +import com.muyu.system.service.CarService; /** - * 车辆管理 业务层 - * @ProjectName: colud-vehicles - * @PackageName: com.muyu.system.service.impl - * @Description TODO - * @Author XiaoFan - * @Date 2024/3/26 19:58 - * @Version 1.0 + * 车辆信息Service业务层处理 + * + * @author muyu + * @date 2024-03-29 */ @Service -public class CarServiceImpl extends ServiceImpl implements CarService { +public class CarServiceImpl extends ServiceImpl implements CarService +{ @Autowired private CarMapper carMapper; + /** + * 查询车辆信息 + * @param carVo + */ @Override public Result> list(CarVo carVo) { PageHelper.startPage(carVo.getPageNum(),carVo.getPageSize()); @@ -48,20 +52,46 @@ public class CarServiceImpl extends ServiceImpl implements CarSer return PageResult.toResult(info.getTotal(),info.getList()); } + /** + * 查询车辆信息列表 + * + * @param car 车辆信息 + * @return 车辆信息 + */ @Override - public void add(Car car) { - car.setCarVin("vin"+IdUtils.fastSimpleUUID()); - carMapper.insert(car); + public List selectCarList(Car car) + { + return carMapper.selectCarList(car); } + /** + * 新增车辆信息 + * + * @param car 车辆信息 + * @return 结果 + */ + @Override + public void add(Car car) { + car.setCreateTime(DateUtils.getNowDate()); + car.setCarVin("vin"+ IdUtils.fastSimpleUUID()); + carMapper.insert(car); + } + /** + * 修改车辆信息 + * + * @param car 车辆信息 + * @return 结果 + */ @Override public void update(Car car) { + car.setUpdateTime(DateUtils.getNowDate()); carMapper.updateById(car); } @Override - public void del(Integer carId) { - carMapper.deleteById(carId); + public int deleteBatch(Long[] carIds) { + System.out.println(Arrays.toString(carIds)); + return carMapper.deleteBatchIds(Arrays.asList(carIds)); } @Override @@ -69,15 +99,10 @@ public class CarServiceImpl extends ServiceImpl implements CarSer return carMapper.selectById(carId); } - @Override - public List selectState() { - return carMapper.selectState(); - } - - - @Override public List selectFence() { return carMapper.selectFence(); } + + } diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/CarMapper.xml b/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/CarMapper.xml index 0185653..81898ae 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/CarMapper.xml +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/CarMapper.xml @@ -1,103 +1,21 @@ - + +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +