diff --git a/muyu-common/muyu-common-core/pom.xml b/muyu-common/muyu-common-core/pom.xml index 3eb8ecc..0bf6adb 100644 --- a/muyu-common/muyu-common-core/pom.xml +++ b/muyu-common/muyu-common-core/pom.xml @@ -105,6 +105,22 @@ commons-io commons-io + + + com.baomidou + mybatis-plus-boot-starter + 3.5.3.1 + + + com.github.jsqlparser + jsqlparser + + + org.mybatis + mybatis + + + diff --git a/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/domain/PageResult.java b/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/domain/PageResult.java new file mode 100644 index 0000000..589a420 --- /dev/null +++ b/muyu-common/muyu-common-core/src/main/java/com/muyu/common/core/domain/PageResult.java @@ -0,0 +1,35 @@ +package com.muyu.common.core.domain; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 列表返回结果集 + * @author XiaoFan + * @description: 列表返回结果集 + */ +@Data +public class PageResult implements Serializable { + /** + * 总条数 + */ + private long total; + /** + * 结果集合 + */ + private List list; + public PageResult() { + } + public PageResult(long total, List list) { + this.total = total; + this.list = list; + } + public static PageResult toPageResult(long total, List list){ + return new PageResult(total , list); + } + public static Result> toResult(long total, List list){ + return Result.success(PageResult.toPageResult(total,list)); + } +} 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 new file mode 100644 index 0000000..b07e698 --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Car.java @@ -0,0 +1,123 @@ +package com.muyu.system.common.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.system.common.domain.req.CarAddReq; +import com.muyu.system.common.domain.req.CarUpdateReq; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 车辆管理表 car + * @ProjectName: colud-vehicles + * @PackageName: com.muyu.system.common.domain + * @Description TODO + * @Author XiaoFan + * @Date 2024/3/28 21:49 + * @Version 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("car") +public class Car { + @TableId(value = "car_id",type = IdType.AUTO) + /** + * 车辆表ID + */ + private Long carId; + /** + * 车辆表vin + */ + private String carVin; + /** + * 车辆类型 + */ + private String carType; + /** + * 电子围栏ID + */ + private String carFenceId; + /** + * 车辆状态 + */ + private Integer state; + /** + * 电机厂商 + */ + private String carElectricalmachiney; + /** + * 电池厂商 + */ + private String carBattery; + /** + * 电机编号 + */ + private Integer carElectricalmachineyId; + /** + * 电池厂商 + */ + private Integer carBatteryId; + /** + * 创建者 + */ + private String createBy; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /** + * 更新者 + */ + private String updateBy; + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + /** + * 备注 + */ + private String remark; + + public static Car addReqBuild(CarAddReq carAddReq){ + return Car.builder() + .carVin(carAddReq.getCarVin()) + .carType(carAddReq.getCarType()) + .carFenceId(carAddReq.getCarFenceId()) + .state(carAddReq.getState()) + .carElectricalmachiney(carAddReq.getCarElectricalmachiney()) + .carBattery(carAddReq.getCarBattery()) + .carElectricalmachineyId(carAddReq.getCarElectricalmachineyId()) + .carBatteryId(carAddReq.getCarBatteryId()) + .remark(carAddReq.getRemark()) + .build(); + } + + public static Car updateReqBuild(CarUpdateReq carUpdateReq){ + return Car.builder() + .carId(carUpdateReq.getCarId()) + .carVin(carUpdateReq.getCarVin()) + .carType(carUpdateReq.getCarType()) + .carFenceId(carUpdateReq.getCarFenceId()) + .state(carUpdateReq.getState()) + .carElectricalmachiney(carUpdateReq.getCarElectricalmachiney()) + .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/CarInfo.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/CarInfo.java new file mode 100644 index 0000000..b63f620 --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/CarInfo.java @@ -0,0 +1,58 @@ +package com.muyu.system.common.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 车辆上线记录 car_info + * @ProjectName: colud-vehicles + * @PackageName: com.muyu.system.common.domain + * @Description TODO + * @Author XiaoFan + * @Date 2024/3/26 19:46 + * @Version 1.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CarInfo extends BaseEntity{ + /** + * 日志表ID + */ + private Integer logId; + /** + * 车辆表vin + */ + private String carVin; + /** + * 上线时间 + */ + private Date logDate; + /** + * 创建者 + */ + private String createBy; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + /** + * 更新者 + */ + private String updateBy; + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + /** + * 备注 + */ + private String remark; +} diff --git a/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Fence.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Fence.java new file mode 100644 index 0000000..63cb7e1 --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/Fence.java @@ -0,0 +1,62 @@ +package com.muyu.system.common.domain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.experimental.SuperBuilder; + +/** + * 电子围栏实体类 Fence + * @ClassName Fence + * @Description 电子围栏实体类 + * @Author YinYuYang + * @Date 2024/3/26 20:48 + * Version 1.0 + */ +@Data +@SuperBuilder +@AllArgsConstructor +@NoArgsConstructor +@TableName("fence_info") +public class Fence{ + + /** + * 围栏ID + */ + @TableId(value = "fence_id", type = IdType.AUTO) + private Integer fenceId; + + /** + * 围栏编码 + */ + @TableField("fence_encoding") + private String fenceEncoding; + + /** + * 围栏名称 + */ + @TableField("fence_name") + private String fenceName; + + /** + * 围栏类型 + */ + @TableField("fence_type") + private Integer fenceType; + + /** + * 围栏状态 + */ + @TableField("fence_state") + private Integer fenceState; + + /** + * 经纬度信息 + */ + @TableField("fence_radius") + private String fenceRadius; + +} 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 new file mode 100644 index 0000000..d9735bb --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarAddReq.java @@ -0,0 +1,93 @@ +package com.muyu.system.common.domain.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.*; + +/** + * 车辆表添加 + * @ProjectName: cloud-vehicles + * @PackageName: com.muyu.system.common.domain.req + * @Description TODO + * @Author XiaoFan + * @Date 2024/3/29 19:04 + * @Version 1.0 + */ + +@Data +@ApiModel(value = "请求参数") +public class CarAddReq { + /** + * 车俩表vin + */ +// @NotEmpty +// @Length(max = 255) +// @Pattern(regexp = "^[0-9a-zA-Z]{17}$",message = "请输入正确的vin码") + @ApiModelProperty(value = "车辆vin码") + private String carVin; + /** + * 车辆类型 + */ + @NotNull + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的车辆类型") + @ApiModelProperty(value = "车辆类型") + private String carType; + /** + * 电子围栏ID + */ + @NotNull + @Length(max = 255) + @ApiModelProperty(value = "电子围栏ID") + private String carFenceId; + /** + * 车辆状态 + */ + @NotNull + @Min(value = 0, message = "车辆状态必须大于等于0") + @ApiModelProperty(value = "车辆状态") + private Integer state; + /** + * 电机厂商 + */ + @NotEmpty + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的电机厂商") + @ApiModelProperty(value = "电机厂商") + private String carElectricalmachiney; + /** + * 电池厂商 + */ + @NotEmpty + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的电池厂商") + @ApiModelProperty(value = "电池厂商") + private String carBattery; + /** + * 电机编号 + */ + @NotNull + @Min(value = 1, message = "电机编号必须大于等于1") + @ApiModelProperty(value = "电机编号") + private Integer carElectricalmachineyId; + /** + * 电池编号 + */ + @NotNull + @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-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 new file mode 100644 index 0000000..aa2e05b --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarRequest.java @@ -0,0 +1,19 @@ +package com.muyu.system.common.domain.req; + +import lombok.Data; + +/** + * 列表分页参数 + * @ProjectName: cloud-vehicles + * @PackageName: com.muyu.system.common.domain.req + * @Description TODO + * @Author XiaoFan + * @Date 2024/3/29 19:03 + * @Version 1.0 + */ +@Data +public class CarRequest { + 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 new file mode 100644 index 0000000..1dbd515 --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/req/CarUpdateReq.java @@ -0,0 +1,99 @@ +package com.muyu.system.common.domain.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +/** + * 车辆表修改 + * @ProjectName: cloud-vehicles + * @PackageName: com.muyu.system.common.domain.req + * @Description TODO + * @Author XiaoFan + * @Date 2024/3/29 19:05 + * @Version 1.0 + */ +@Data +@ApiModel(value = "请求参数") +public class CarUpdateReq { + /** + * 车辆表id + */ + @ApiModelProperty(value = "车辆表id") + private Long carId; + /** + * 车俩表vin + */ +// @NotEmpty +// @Length(max = 255) +// @Pattern(regexp = "^[0-9a-zA-Z]{17}$",message = "请输入正确的vin码") + @ApiModelProperty(value = "车辆vin码") + private String carVin; + /** + * 车辆类型 + */ + @NotNull + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的车辆类型") + @ApiModelProperty(value = "车辆类型") + private String carType; + /** + * 电子围栏ID + */ + @NotNull + @Length(max = 255) + @ApiModelProperty(value = "电子围栏ID") + private String carFenceId; + /** + * 车辆状态 + */ + @NotNull + @Min(value = 0, message = "车辆状态必须大于等于0") + @ApiModelProperty(value = "车辆状态") + private Integer state; + /** + * 电机厂商 + */ + @NotEmpty + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的电机厂商") + @ApiModelProperty(value = "电机厂商") + private String carElectricalmachiney; + /** + * 电池厂商 + */ + @NotEmpty + @Length(max = 255) + @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$",message = "请输入正确的电池厂商") + @ApiModelProperty(value = "电池厂商") + private String carBattery; + /** + * 电机编号 + */ + @NotNull + @Min(value = 1, message = "电机编号必须大于等于1") + @ApiModelProperty(value = "电机编号") + private Integer carElectricalmachineyId; + /** + * 电池编号 + */ + @NotNull + @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-common/src/main/java/com/muyu/system/common/domain/vo/CarVo.java b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/vo/CarVo.java new file mode 100644 index 0000000..a2b5dae --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-common/src/main/java/com/muyu/system/common/domain/vo/CarVo.java @@ -0,0 +1,26 @@ +package com.muyu.system.common.domain.vo; + +import com.muyu.system.common.domain.req.CarRequest; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 列表条件查询参数 + * @ProjectName: cloud-vehicles + * @PackageName: com.muyu.system.common.domain.vo + * @Description TODO + * @Author XiaoFan + * @Date 2024/3/29 19:03 + * @Version 1.0 + */ +@Data +@ApiModel(value = "请求参数") +public class CarVo extends CarRequest { + @ApiModelProperty(value = "车辆vin码") + private String carVin; + + + + +} diff --git a/muyu-modules/muyu-system/muyu-system-server/pom.xml b/muyu-modules/muyu-system/muyu-system-server/pom.xml index d837819..5c958b6 100644 --- a/muyu-modules/muyu-system/muyu-system-server/pom.xml +++ b/muyu-modules/muyu-system/muyu-system-server/pom.xml @@ -22,6 +22,12 @@ com.muyu muyu-system-common + + + io.springfox + springfox-boot-starter + 3.0.0 + com.alibaba.cloud diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/MuYuSystemApplication.java b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/MuYuSystemApplication.java index db15ed3..e8f19a2 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/MuYuSystemApplication.java +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/MuYuSystemApplication.java @@ -3,6 +3,7 @@ package com.muyu.system; import com.muyu.common.security.annotation.EnableCustomConfig; import com.muyu.common.security.annotation.EnableRyFeignClients; import com.muyu.common.swagger.annotation.EnableCustomSwagger2; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @EnableCustomSwagger2 @EnableRyFeignClients @SpringBootApplication +@MapperScan("com.muyu.system.mapper") public class MuYuSystemApplication { public static void main(String[] args) 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 new file mode 100644 index 0000000..11cd310 --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/controller/CarController.java @@ -0,0 +1,132 @@ +package com.muyu.system.controller; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson.JSONObject; +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.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.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +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.core.web.controller.BaseController; +import com.muyu.common.core.utils.poi.ExcelUtil; +import java.util.List; + +/** + * 车辆信息Controller + * + * @author muyu + * @date 2024-03-29 + */ +@RestController +@RequestMapping("/car") +@Slf4j +public class CarController extends BaseController +{ + @Autowired + private CarService carService; + @Autowired + private HttpServletRequest request; + + /** + * 查询车辆信息列表 + */ + @GetMapping("/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)); + 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:car:add") + @Log(title = "车辆管理",businessType = BusinessType.INSERT) + public Result add(@RequestBody @Validated CarAddReq carAddReq){ + log.info("执行操作:添加车辆数据,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(carAddReq)); + Result result=Result.success(carAddReq); + carService.add(Car.addReqBuild(carAddReq)); + log.info("执行操作:添加车辆数据,请求URL:{},请求方式:{},响应结果:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(carAddReq)); + return result; + } + + /** + * 修改车辆信息 + */ + @PostMapping("/update") +// @RequiresPermissions("system:car:edit") + @Log(title = "车辆管理",businessType = BusinessType.UPDATE) + public Result update(@RequestBody @Validated CarUpdateReq carUpdateReq){ + log.info("执行操作:修改车辆数据,请求URL:{},请求方式:{},请求参数:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(carUpdateReq)); + Result result=Result.success(carUpdateReq); + carService.update(Car.updateReqBuild(carUpdateReq)); + log.info("执行操作:修改车辆数据,请求URL:{},请求方式:{},响应结果:{}",request.getRequestURI(), + request.getMethod(),JSONObject.toJSONString(result)); + return result; + } + + /** + * 删除车辆信息 + */ + @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 = "查询电子围栏表") + public Result> selectFence(){ + log.info("执行操作:根据id查询电子围栏表,请求URL:{},请求方式:{}",request.getRequestURI(), + request.getMethod()); + List list=carService.selectFence(); + 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 new file mode 100644 index 0000000..5addeab --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/mapper/CarMapper.java @@ -0,0 +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 java.util.List; + + +/** + * 车辆信息Mapper接口 + * + * @author muyu + * @date 2024-03-29 + */ +public interface CarMapper extends BaseMapper +{ + + + /** + * 查询车辆信息列表 + * + * @param car 车辆信息 + * @return 车辆信息集合 + */ + public List selectCarList(Car car); + + + List selectFence(); + +} 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 new file mode 100644 index 0000000..544fcef --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/CarService.java @@ -0,0 +1,48 @@ +package com.muyu.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +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.vo.CarVo; + +import java.util.List; + + +/** + * 车辆信息Service接口 + * + * @author muyu + * @date 2024-03-29 + */ +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); + + + int deleteBatch(Long[] carIds); + + Car findById(Integer carId); + + 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 new file mode 100644 index 0000000..75661b9 --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/java/com/muyu/system/service/impl/CarServiceImpl.java @@ -0,0 +1,108 @@ +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.vo.CarVo; +import com.muyu.system.mapper.CarMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.muyu.system.service.CarService; + +/** + * 车辆信息Service业务层处理 + * + * @author muyu + * @date 2024-03-29 + */ +@Service +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()); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + //判断一个字符串是否为空字符串 + if (StringUtils.isNotEmpty(carVo.getCarVin())){ + lambdaQueryWrapper.like(Car::getCarVin,carVo.getCarVin()); + } + List list=this.list(lambdaQueryWrapper); + PageInfo info = new PageInfo<>(list); + return PageResult.toResult(info.getTotal(),info.getList()); + } + + /** + * 查询车辆信息列表 + * + * @param car 车辆信息 + * @return 车辆信息 + */ + @Override + 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 int deleteBatch(Long[] carIds) { + System.out.println(Arrays.toString(carIds)); + return carMapper.deleteBatchIds(Arrays.asList(carIds)); + } + + @Override + public Car findById(Integer carId) { + return carMapper.selectById(carId); + } + + @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 new file mode 100644 index 0000000..81898ae --- /dev/null +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/CarMapper.xml @@ -0,0 +1,21 @@ + + + + + + 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 + + + + diff --git a/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/EnterpriseInfoMapper.xml b/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/EnterpriseInfoMapper.xml index eaf2890..952576b 100644 --- a/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/EnterpriseInfoMapper.xml +++ b/muyu-modules/muyu-system/muyu-system-server/src/main/resources/mapper/system/EnterpriseInfoMapper.xml @@ -2,36 +2,39 @@ - + - + - + + + + - - - - - + - select enterprise_id, enterprise_name, email, enterprise_address, phone_number, industry, status, dept_id, update_time, create_time, del_flag, leader from enterprise_info + select enterprise_id, enterprise_name, contact_person, contact_email, user_id, enterprise_address, phone_number, industry, employee_count, status, identifier from enterprise_info - and enterprise_name like concat('%', #{enterpriseName}, '%') + and contact_person = #{contactPerson} + and contact_email = #{contactEmail} + and user_id = #{userId} and enterprise_address = #{enterpriseAddress} + and phone_number = #{phoneNumber} and industry = #{industry} + and employee_count = #{employeeCount} and status = #{status} - and dept_id = #{deptId} - and leader = #{leader} + and identifier = #{identifier} @@ -40,57 +43,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where enterprise_id = #{enterpriseId} - - - - - - + insert into enterprise_info enterprise_name, - email, + contact_person, + contact_email, + user_id, enterprise_address, phone_number, industry, + employee_count, status, - dept_id, - update_time, - create_time, - del_flag, - leader, + identifier, #{enterpriseName}, - #{email}, + #{contactPerson}, + #{contactEmail}, + #{userId}, #{enterpriseAddress}, #{phoneNumber}, #{industry}, + #{employeeCount}, #{status}, - #{deptId}, - #{updateTime}, - #{createTime}, - #{delFlag}, - #{leader}, + #{identifier}, - + update enterprise_info enterprise_name = #{enterpriseName}, - email = #{email}, + contact_person = #{contactPerson}, + contact_email = #{contactEmail}, + user_id = #{userId}, enterprise_address = #{enterpriseAddress}, phone_number = #{phoneNumber}, industry = #{industry}, + employee_count = #{employeeCount}, status = #{status}, - dept_id = #{deptId}, - update_time = #{updateTime}, - create_time = #{createTime}, - del_flag = #{delFlag}, - leader = #{leader}, + identifier = #{identifier}, where enterprise_id = #{enterpriseId}