Переглянути джерело

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/VehicleMonitor

wyyay 2 роки тому
батько
коміт
90c6a82c33

+ 7 - 4
business-service/src/main/java/com/ozs/entity/BaseVehicle.java

@@ -2,12 +2,12 @@ package com.ozs.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
-import java.util.Date;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.io.Serializable;
+import java.util.Date;
+
 /**
  * <p>
  * 机车信息表
@@ -63,5 +63,8 @@ public class BaseVehicle implements Serializable {
      */
     private String remark;
 
-
+    /**
+     * 挂载终端ID terminal_id
+     */
+    private long terminalId;
 }

+ 62 - 0
business-service/src/main/java/com/ozs/entity/vo/BaseVehicleVo.java

@@ -0,0 +1,62 @@
+package com.ozs.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ozs.common.vo.PageVo;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @Author : sunhh
+ * @create 2023/4/14 15:31
+ */
+@Data
+public class BaseVehicleVo extends PageVo {
+
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 机车编码
+     */
+    private String vehicleCode;
+
+    /**
+     * 机车名称
+     */
+    private String vehicleName;
+
+    /**
+     * 创建者
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 挂载终端ID terminal_id
+     */
+    private long terminalId;
+}

+ 9 - 1
business-service/src/main/java/com/ozs/service/BaseVehicleService.java

@@ -1,7 +1,10 @@
 package com.ozs.service;
 
-import com.ozs.entity.BaseVehicle;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.entity.BaseVehicle;
+import com.ozs.entity.vo.BaseVehicleVo;
 
 /**
  * <p>
@@ -13,4 +16,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface BaseVehicleService extends IService<BaseVehicle> {
 
+    IPage<BaseVehicle> vehicleList(BaseVehicleVo baseVehicle);
+
+    AjaxResult vehicleAdd(BaseVehicle baseVehicle, String userId);
+
+    AjaxResult vehicleUpdate(BaseVehicle baseVehicle, String userId);
 }

+ 76 - 1
business-service/src/main/java/com/ozs/service/impl/BaseVehicleServiceImpl.java

@@ -1,11 +1,21 @@
 package com.ozs.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.utils.StringUtils;
 import com.ozs.entity.BaseVehicle;
+import com.ozs.entity.vo.BaseVehicleVo;
 import com.ozs.mapper.BaseVehicleMapper;
 import com.ozs.service.BaseVehicleService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 机车信息表 服务实现类
@@ -17,4 +27,69 @@ import org.springframework.stereotype.Service;
 @Service
 public class BaseVehicleServiceImpl extends ServiceImpl<BaseVehicleMapper, BaseVehicle> implements BaseVehicleService {
 
+    @Autowired
+    private BaseVehicleMapper baseVehicleMapper;
+
+    @Override
+    public IPage<BaseVehicle> vehicleList(BaseVehicleVo baseVehicle) {
+        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
+        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleName())) {
+            wrapper.eq(BaseVehicle::getVehicleName, baseVehicle.getVehicleName());
+        }
+        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
+        }
+        int pageNum = Integer.parseInt(baseVehicle.getPageNum().toString());
+        int pageSize = Integer.parseInt(baseVehicle.getPageSize().toString());
+        com.github.pagehelper.Page<BaseVehicle> page = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> baseVehicleMapper.selectList(wrapper));
+        com.baomidou.mybatisplus.extension.plugins.pagination.Page<BaseVehicle> pageR =
+                new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
+        pageR.setRecords(page.getResult());
+        pageR.setTotal(page.getTotal());
+        return pageR;
+    }
+
+    @Override
+    public AjaxResult vehicleAdd(BaseVehicle baseVehicle, String userId) {
+        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
+        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
+        }
+        List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
+        if (baseVehicles.size() > 0) {
+            return AjaxResult.error("机车编码已存在!");
+        }
+        Date date = new Date();
+        baseVehicle.setCreateBy(userId);
+        baseVehicle.setUpdateBy(userId);
+        baseVehicle.setCreateTime(date);
+        baseVehicle.setUpdateTime(date);
+        int insert = baseVehicleMapper.insert(baseVehicle);
+        if (insert > 0) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+    }
+
+    @Override
+    public AjaxResult vehicleUpdate(BaseVehicle baseVehicle, String userId) {
+        LambdaQueryWrapper<BaseVehicle> wrapper = new LambdaQueryWrapper<BaseVehicle>();
+        if (!StringUtils.isEmptySunhh(baseVehicle) && !StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+            wrapper.eq(BaseVehicle::getVehicleCode, baseVehicle.getVehicleCode());
+        }
+        List<BaseVehicle> baseVehicles = baseVehicleMapper.selectList(wrapper);
+        if (baseVehicles.size() > 0) {
+            return AjaxResult.error("机车编码已存在!");
+        }
+        baseVehicle.setUpdateBy(userId);
+        baseVehicle.setUpdateTime(new Date());
+        int update = baseVehicleMapper.updateById(baseVehicle);
+        if (update > 0) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+    }
 }

+ 94 - 4
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseVehicleController.java

@@ -1,8 +1,21 @@
 package com.ozs.web.controller.accountmanagment;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ozs.common.annotation.Log;
+import com.ozs.common.core.controller.BaseController;
+import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.enums.BusinessType;
+import com.ozs.common.utils.StringUtils;
+import com.ozs.entity.BaseVehicle;
+import com.ozs.entity.vo.BaseVehicleVo;
+import com.ozs.service.BaseVehicleService;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -13,8 +26,85 @@ import org.springframework.web.bind.annotation.RestController;
  * @since 2023-04-11
  */
 @RestController
-@RequestMapping("/base-vehicle")
-public class BaseVehicleController {
+@RequestMapping("/baseVehicle")
+@Slf4j
+public class BaseVehicleController extends BaseController {
+
+    @Autowired
+    private BaseVehicleService baseVehicleService;
+
+    public static void main(String[] args) {
+        System.out.println(new Date().getTime());
+    }
+
+    /**
+     * 机车信息表 分页查询
+     *
+     * @param baseVehicle
+     * @return
+     */
+    @ApiOperation(value = "机车信息表 分页查询")
+    @PostMapping("/vehicleList")
+    @Log(title = "机车信息表 分页查询", businessType = BusinessType.SELECT)
+    public AjaxResult vehicleList(@RequestBody BaseVehicleVo baseVehicle) {
+        IPage<BaseVehicle> baseVehicleList = baseVehicleService.vehicleList(baseVehicle);
+        return AjaxResult.success(baseVehicleList);
+    }
+
+    /**
+     * 机车信息表 新增
+     *
+     * @param baseVehicle
+     * @return
+     */
+    @ApiOperation(value = "机车信息表 新增")
+    @PostMapping("/vehicleAdd")
+    @Log(title = "机车信息表 新增", businessType = BusinessType.SELECT)
+    public AjaxResult vehicleAdd(@RequestBody BaseVehicle baseVehicle) {
+        if (StringUtils.isEmptySunhh(baseVehicle) || StringUtils.isEmptySunhh(baseVehicle.getVehicleName())
+                || StringUtils.isEmptySunhh(baseVehicle.getVehicleCode())) {
+            return AjaxResult.error("机车名称、机车编码不能为空!");
+        }
+        return baseVehicleService.vehicleAdd(baseVehicle, getUserId());
+    }
+
+    /**
+     * 机车信息表 修改
+     *
+     * @param baseVehicle
+     * @return
+     */
+    @ApiOperation(value = "机车信息表 修改")
+    @PostMapping("/vehicleUpdate")
+    @Log(title = "机车信息表 修改", businessType = BusinessType.SELECT)
+    public AjaxResult vehicleUpdate(@RequestBody BaseVehicle baseVehicle) {
+        if (StringUtils.isEmptySunhh(baseVehicle) || StringUtils.isEmptySunhh(baseVehicle.getId())) {
+            return AjaxResult.error("修改ID不能为空!");
+        }
+        return baseVehicleService.vehicleUpdate(baseVehicle,getUserId());
+    }
+
+    /**
+     * 机车信息表 删除
+     *
+     * @param ids
+     * @return
+     */
+    @ApiOperation(value = "机车信息表 删除")
+    @PostMapping("/vehicleDelete")
+    @Log(title = "机车信息表 删除", businessType = BusinessType.SELECT)
+    public AjaxResult vehicleDelete(@PathVariable List<Long> ids) {
+        if (StringUtils.isEmptySunhh(ids)) {
+            return AjaxResult.error("删除ID不能为空!");
+        }
+        boolean delete = baseVehicleService.removeByIds(ids);
+        if (delete) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+    }
+
 
 }