肖凡3.31代码提交

vehicle-yinyuyang
肖凡 2024-03-31 08:36:24 +08:00
parent de5ebb32e7
commit db1b9baa1e
9 changed files with 219 additions and 234 deletions

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<PageResult<Car>> list(@Validated CarVo carVo){
log.info("执行操作:查询车辆列表,请求URL:{},请求方法:{},请求参数:{}",request.getRequestURI(),
request.getMethod(), carVo);
Result<PageResult<Car>> 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<Car> list = carService.selectCarList(car);
ExcelUtil<Car> util = new ExcelUtil<>(Car.class);
util.exportExcel(response, list, "车辆信息数据");
}
/**
*
*/
@GetMapping("/findById/{carId}")
// @RequiresPermissions("system:car:query")
@Log(title = "车辆管理")
public Result<Car> 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<Fence> list=carService.selectFence();
return Result.success(list);
}
@GetMapping("/selectState")
@Log(title = "查询字典表")
public Result<List<SysDictData>> selectState(){
log.info("执行操作:查询规则,请求URL:{},请求方式:{}",request.getRequestURI(),
request.getMethod());
List<SysDictData> list=carService.selectState();
return Result.success(list);
}
}

View File

@ -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<Car> {
List<SysDictData> selectState();
public interface CarMapper extends BaseMapper<Car>
{
/**
*
*
* @param car
* @return
*/
public List<Car> selectCarList(Car car);
List<Fence> selectFence();
// List<Car> list(carVo carVo);
// void add(Car car);
//
//void update(car car);
//
// void del(Integer carId);
}

View File

@ -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<Car> {
public interface CarService extends IService<Car>
{
/**
*
*/
Result<PageResult<Car>> list(CarVo carVo);
/**
*
*
* @param car
* @return
*/
public List<Car> selectCarList(Car car);
void add(Car car);
void update(Car car);
void del(Integer carId);
int deleteBatch(Long[] carIds);
Car findById(Integer carId);
List<SysDictData> selectState();
List<Fence> selectFence();

View File

@ -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<CarMapper,Car> implements CarService {
public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarService
{
@Autowired
private CarMapper carMapper;
/**
*
* @param carVo
*/
@Override
public Result<PageResult<Car>> list(CarVo carVo) {
PageHelper.startPage(carVo.getPageNum(),carVo.getPageSize());
@ -48,20 +52,46 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> 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<Car> 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<CarMapper,Car> implements CarSer
return carMapper.selectById(carId);
}
@Override
public List<SysDictData> selectState() {
return carMapper.selectState();
}
@Override
public List<Fence> selectFence() {
return carMapper.selectFence();
}
}

View File

@ -1,103 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.system.mapper.CarMapper">
<!-- <resultMap type="com.muyu.system.common.domain.Car" id="list">-->
<!-- <id property="carId" column="cat_id"></id>-->
<!-- <result property="carVin" column="car_vin"></result>-->
<!-- <result property="carType" column="car_type"></result>-->
<!-- <result property="carFenceId" column="car_fence_id"></result>-->
<!-- <result property="carState" column="car_state"></result>-->
<!-- <result property="carElectricalmachiney" column="car_electricalmachiney"></result>-->
<!-- <result property="carBattery" column="car_battery"></result>-->
<!-- <result property="carElectricalmachineyId" column="car_electricalmachiney_id"></result>-->
<!-- <result property="carBatteryId" column="car_battery_id"></result>-->
<!-- </resultMap>-->
<!-- <insert id="add">-->
<!-- insert into t_car(-->
<!-- <if test="carVin!=null and carVin!=''">car_vin,</if>-->
<!-- <if test="carType!=null">car_type,</if>-->
<!-- <if test="carFenceId!=null">car_fence_id,</if>-->
<!-- <if test="carState!=null">car_state,</if>-->
<!-- <if test="carElectricalmachiney!=null and carElectricalmachiney!=''">car_electricalmachiney,</if>-->
<!-- <if test="carBattery!=null and carBattery!=''">car_battery,</if>-->
<!-- <if test="carElectricalmachineyId!=null">car_electricalmachiney_id,</if>-->
<!-- <if test="carBatteryId!=null">car_battery_id</if>-->
<!-- )values (-->
<!-- <if test="carVin!=null and carVin!=''">#{carVin,jdbcType=VARCHAR},</if>-->
<!-- <if test="carType!=null">#{carType,jdbcType=BIGINT},</if>-->
<!-- <if test="carFenceId!=null">#{carFenceId,jdbcType=BIGINT},</if>-->
<!-- <if test="carState!=null">#{carState,jdbcType=BIGINT},</if>-->
<!-- <if test="carElectricalmachiney!=null and carElectricalmachiney!=''">#{carElectricalmachiney,jdbcType=VARCHAR},</if>-->
<!-- <if test="carBattery!=null and carBattery!=''">#{carBattery,jdbcType=VARCHAR},</if>-->
<!-- <if test="carElectricalmachineyId!=null">#{carElectricalmachineyId,jdbcType=BIGINT},</if>-->
<!-- <if test="carBatteryId!=null">#{carBatteryId,jdbcType=BIGINT}</if>-->
<!-- )-->
<!-- </insert>-->
<!-- <update id="update">-->
<!-- update t_car set-->
<!-- <if test="carVin!=null and carVin!=''">car_vin=#{carVin,jdbcType=VARCHAR},</if>-->
<!-- <if test="carType!=null">car_type=#{carType,jdbcType=BIGINT},</if>-->
<!-- <if test="carFenceId!=null">car_fence_id=#{carFenceId,jdbcType=BIGINT},</if>-->
<!-- <if test="carState!=null">car_state=#{carState,jdbcType=BIGINT},</if>-->
<!-- <if test="carElectricalmachiney!=null and carElectricalmachiney!=''">car_electricalmachiney=#{carElectricalmachiney,jdbcType=VARCHAR},</if>-->
<!-- <if test="carBattery!=null and carBattery!=''">car_battery=#{carBattery,jdbcType=VARCHAR},</if>-->
<!-- <if test="carElectricalmachineyId!=null">car_electricalmachiney_id=#{carElectricalmachineyId,jdbcType=BIGINT},</if>-->
<!-- <if test="carBatteryId!=null">car_battery_id=#{carBatteryId,jdbcType=BIGINT}</if>-->
<!-- where-->
<!-- <if test="carId!=null">car_id=#{carId,jdbcType=BIGINT}</if>-->
<!-- </update>-->
<!-- <delete id="del">-->
<!-- delete from t_car-->
<!-- <where>-->
<!-- <if test="carId!=null">car_id=#{carId,jdbcType=BIGINT}</if>-->
<!-- </where>-->
<!-- </delete>-->
<!-- <select id="list" parameterType="com.muyu.system.common.domain.Car" resultMap="list">-->
<!-- <include refid="list"></include>-->
<!-- <where>-->
<!-- <if test="carVin!=null and carVin!=''">-->
<!-- and car_vin like concat('%',#{carVin},'%')-->
<!-- </if>-->
<!-- <if test="carType!=null">-->
<!-- and car_type = #{carType}-->
<!-- </if>-->
<!-- <if test="carFenceId!=null">-->
<!-- and car_fence_id=#{carFenceId}-->
<!-- </if>-->
<!-- <if test="carState!=null">-->
<!-- and car_state=#{carState}-->
<!-- </if>-->
<!-- <if test="carElectricalmachiney!=null and carElectricalmachiney!=''">-->
<!-- and car_electricalmachiney like concat('%',#{carElectricalmachiney},'%')-->
<!-- </if>-->
<!-- <if test="carBattery!=null and carBattery!=''">-->
<!-- and car_battery like concat('%',#{carBattery},'%')-->
<!-- </if>-->
<!-- <if test="carElectricalmachineyId!=null">-->
<!-- and car_electricalmachiney_id=#{carElectricalmachineyId}-->
<!-- </if>-->
<!-- <if test="carBatteryId!=null">-->
<!-- and car_battery_id=#{carBatteryId}-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<!-- <sql id="list">-->
<!-- select car_id,car_vin,car_type,car_fence_id,car_state,-->
<!-- car_electricalmachiney,car_battery,-->
<!-- car_electricalmachiney_id,car_battery_id-->
<!-- from t_car-->
<!-- </sql>-->
<select id="selectState" resultType="com.muyu.system.common.domain.SysDictData">
select dict_value,dict_label from sys_dict_data where dict_type='car_state'
<sql id="list">
select car_id,car_vin,car_type,car_fence_id,state,
car_electricalmachiney,car_battery,
car_electricalmachiney_id,car_battery_id,
create_by,create_time,update_by,update_time,
remark
from car
</sql>
<select id="selectCarList" resultType="com.muyu.system.common.domain.Car">
<include refid="list"></include>
</select>
<select id="selectFence" resultType="com.muyu.system.common.domain.Fence">
select fence_id,fence_name from t_fence
select fence_id,fence_name from fence
</select>
</mapper>