重构车辆项目,还不可以添加数据,多数据源是死的

master
xiaohuang 2024-06-07 22:10:54 +08:00
parent 7a30291286
commit 92ef1f8437
22 changed files with 476 additions and 142 deletions

View File

@ -19,6 +19,12 @@
</properties>
<dependencies>
<!--rabbitMQ-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-system</artifactId>

View File

@ -0,0 +1,15 @@
package com.muyu.business.config;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitmqConfig {
// 消息转换配置
@Bean
public MessageConverter jsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
}

View File

@ -0,0 +1,100 @@
package com.muyu.business.controller;
import com.muyu.business.domain.Entinfo;
import com.muyu.business.service.IEntinfoService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* EntinfoController
*
* @author xiaohuang
* on 2024/6/7
*/
@RestController
@RequestMapping("/entinfo")
public class EntinfoController extends BaseController {
@Autowired
private IEntinfoService entinfoService;
/**
*
*/
// @RequiresPermissions("system:entinfo:list")
@GetMapping("/list")
public Result<TableDataInfo<Entinfo>> list(Entinfo entinfo)
{
startPage();
List<Entinfo> list = entinfoService.selectEntinfoList(entinfo);
return getDataTable(list);
}
/**
*
*/
// @RequiresPermissions("system:entinfo:export")
@Log(title = "多数据源", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Entinfo entinfo)
{
List<Entinfo> list = entinfoService.selectEntinfoList(entinfo);
ExcelUtil<Entinfo> util = new ExcelUtil<Entinfo>(Entinfo.class);
util.exportExcel(response, list, "多数据源数据");
}
/**
*
*/
// @RequiresPermissions("system:entinfo:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(entinfoService.selectEntinfoById(id));
}
/**
*
*/
// @RequiresPermissions("system:entinfo:add")
@Log(title = "多数据源", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody Entinfo entinfo)
{
return toAjax(entinfoService.insertEntinfo(entinfo));
}
/**
*
*/
// @RequiresPermissions("system:entinfo:edit")
@Log(title = "多数据源", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody Entinfo entinfo)
{
return toAjax(entinfoService.updateEntinfo(entinfo));
}
/**
*
*/
// @RequiresPermissions("system:entinfo:remove")
@Log(title = "多数据源", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(entinfoService.deleteEntinfoByIds(ids));
}
}

View File

@ -0,0 +1,54 @@
package com.muyu.business.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* Entinfo
*
* @author xiaohuang
* on 2024/6/7
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("entinfo")
public class Entinfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* key
*/
@Excel(name = "数据源key")
private String entCode;
/**
* ip
*/
@Excel(name = "数据源ip")
private String ip;
/**
*
*/
@Excel(name = "数据源端口")
private Integer port;
/**
* id
*/
private Long id;
}

View File

@ -0,0 +1,24 @@
package com.muyu.business.job;
import com.muyu.common.redis.service.RedisService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* ManyJob
*
* @author xiaohuang
* on 2024/6/7
*/
@Component
@Log4j2
public class ManyJob {
@Autowired
private RedisService redisService;
}

View File

@ -0,0 +1,64 @@
package com.muyu.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.business.domain.Entinfo;
import java.util.List;
/**
* Mapper
*
* @author muyu
* @date 2024-06-06
*/
public interface EntinfoMapper extends BaseMapper<Entinfo>
{
/**
*
*
* @param id
* @return
*/
public Entinfo selectEntinfoById(Long id);
/**
*
*
* @param entinfo
* @return
*/
public List<Entinfo> selectEntinfoList(Entinfo entinfo);
/**
*
*
* @param entinfo
* @return
*/
public int insertEntinfo(Entinfo entinfo);
/**
*
*
* @param entinfo
* @return
*/
public int updateEntinfo(Entinfo entinfo);
/**
*
*
* @param id
* @return
*/
public int deleteEntinfoById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteEntinfoByIds(Long[] ids);
}

View File

@ -1,25 +0,0 @@
package com.muyu.business.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.system.domain.SysUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* RemoteUserLoginFactory
*
* @author xiaohuang
* on 2024/6/4
*/
@FeignClient("muyu-system")
public interface RemoteUserLoginFactory {
@Log(title = "用户管理",businessType = BusinessType.IMPORT)
@PostMapping("/user")
public Result add (@Validated @RequestBody SysUser user);
}

View File

@ -0,0 +1,63 @@
package com.muyu.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.business.domain.Entinfo;
import java.util.List;
/**
* IEntinfoService
*
* @author xiaohuang
* on 2024/6/7
*/
public interface IEntinfoService extends IService<Entinfo> {
/**
*
*
* @param id
* @return
*/
public Entinfo selectEntinfoById(Long id);
/**
*
*
* @param entinfo
* @return
*/
public List<Entinfo> selectEntinfoList(Entinfo entinfo);
/**
*
*
* @param entinfo
* @return
*/
public int insertEntinfo(Entinfo entinfo);
/**
*
*
* @param entinfo
* @return
*/
public int updateEntinfo(Entinfo entinfo);
/**
*
*
* @param ids
* @return
*/
public int deleteEntinfoByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteEntinfoById(Long id);
}

View File

@ -0,0 +1,23 @@
package com.muyu.business.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.business.domain.Entinfo;
import com.muyu.business.mapper.EntinfoMapper;
import com.muyu.business.service.IEntinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* EntinfoServiceImpl
*
* @author xiaohuang
* on 2024/6/7
*/
@Service
public class EntinfoServiceImpl extends ServiceImpl<EntinfoMapper, Entinfo> implements IEntinfoService {
@Autowired
private EntinfoMapper entinfoMapper;
}

View File

@ -7,17 +7,15 @@ import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.vehicle.domain.Group;
import com.muyu.vehicle.service.IGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.muyu.vehicle.domain.Group;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author BingRui.Hou
* @date 2024-06-02
*/
@RestController

View File

@ -1,5 +1,6 @@
package com.muyu.vehicle.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
@ -13,38 +14,47 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* VehicleController
* Controller
*
* @author xiaohuang
* on 2024/6/5
*
* @date 2024-05-27
*/
@RestController
@RequestMapping("/vehicle")
public class VehicleController extends BaseController {
public class VehicleController extends BaseController
{
@Autowired
private IVehicleService vehicleService;
/**
*
*/
@GetMapping("list")
public Result<TableDataInfo<Vehicle>> list(Vehicle vehicle)
// @RequiresPermissions("system:vehicle:list")
@GetMapping("/list")
public Result<TableDataInfo<Vehicle>> list(Vehicle vehicle)
{
startPage();
List<Vehicle> list = vehicleService.selectVehicleList(vehicle);
return getDataTable(list);
}
/**
*
*/
// @RequiresPermissions("system:vehicle:export")
// @Log(title = "车辆录入", businessType = BusinessType.EXPORT)
// @PostMapping("/export")
// public void export(HttpServletResponse response, Vehicle vehicle)
// {
// List<Vehicle> list = vehicleService.selectVehicleList(vehicle);
// ExcelUtil<Vehicle> util = new ExcelUtil<Vehicle>(Vehicle.class);
// util.exportExcel(response, list, "车辆录入数据");
// }
/**
*
*/
// @RequiresPermissions("system:vehicle:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
@ -54,6 +64,7 @@ public class VehicleController extends BaseController {
/**
*
*/
// @RequiresPermissions("system:vehicle:add")
@Log(title = "车辆录入", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody Vehicle vehicle)
@ -64,6 +75,7 @@ public class VehicleController extends BaseController {
/**
*
*/
// @RequiresPermissions("system:vehicle:edit")
@Log(title = "车辆录入", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody Vehicle vehicle)
@ -74,12 +86,11 @@ public class VehicleController extends BaseController {
/**
*
*/
// @RequiresPermissions("system:vehicle:remove")
@Log(title = "车辆录入", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(vehicleService.deleteVehicleByIds(ids));
}
}

View File

@ -16,22 +16,21 @@ import java.util.List;
import java.util.Map;
/**
* ManyDataSource
*
* @author xiaohuang
* on 2024/6/5
* @author DongZl
* @description:
* @Date 2023-8-1 11:05
*/
@Log4j2
@Configuration
public class ManyDataSource {
private List<EntInfo> dataSourceInfoList(){
List<EntInfo> databaseNameList = new ArrayList<>(){{
add(EntInfo.builder()
.entCode("test_1")
.ip("175.24.138.82")
.port(6666)
.port(7777)
.build());
}};
return databaseNameList;
@ -49,8 +48,8 @@ public class ManyDataSource {
.stream()
.map(entInfo-> DataSourceInfo.hostAndPortBuild(entInfo.getEntCode(),entInfo.getIp(),entInfo.getPort()))
.forEach(dataSourceInfo -> {
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
});
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
});
//设置动态数据源
DynamicDataSource dynamicDataSource = new DynamicDataSource();
// dynamicDataSource.setDefaultTargetDataSource(masterDataSource());

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
import java.sql.SQLException;
/**
* BingRui.Hou
*
* @Description
* @ClassName DruidDataSourceFactory

View File

@ -7,7 +7,7 @@ package com.muyu.vehicle.datasource.contents;
*/
public class DatasourceContent {
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/zhiLian-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
public final static String USER_NAME = "root";

View File

@ -10,7 +10,7 @@ import lombok.NoArgsConstructor;
* BingRui.Hou
*
* @Description
* @ClassName EntInfo
* @ClassName Entinfo
* @Date 2024/06/04 14:34
*/
@Data

View File

@ -1,8 +1,7 @@
package com.muyu.vehicle.datasource.util;
import com.alibaba.druid.pool.DruidDataSource;
import com.muyu.vehicle.datasource.ManyDataSource;
import com.muyu.vehicle.datasource.config.factory.DruidDataSourceFactory;
import com.muyu.vehicle.datasource.config.role.DynamicDataSource;

View File

@ -10,7 +10,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.poi.ss.formula.functions.T;
import java.util.Date;

View File

@ -1,9 +1,10 @@
package com.muyu.vehicle.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -11,21 +12,19 @@ import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* Vehicle
* vehicle
*
* @author xiaohuang
* on 2024/6/5
* @author muyu
* @date 2024-05-27
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("vehicle")
public class Vehicle extends BaseEntity {
public class Vehicle extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 车辆主键 */
@ -66,5 +65,4 @@ public class Vehicle extends BaseEntity {
@Excel(name="围栏组ID")
private Long groupId;
}

View File

@ -1,81 +1,54 @@
package com.muyu.vehicle.domain.vo;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* VehicleReq
* vehicle
*
* @author xiaohuang
* on 2024/6/5
* @author muyu
* @date 2024-05-27
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class VehicleReq {
public class VehicleReq
{
/**
*
*/
/** 车辆主键 */
private Long id;
/**
* vin
*/
/** 车辆vin */
private String number;
/**
*
*/
/** 车辆类型 */
private Long typeId;
/**
* id
*/
/** 电子围栏ID */
private Long electonicId;
/**
*
*/
/** 电机厂商 */
private String motor;
/**
*
*/
/** 电池厂商 */
private String battery;
/**
*
*/
/** 电机编号 */
private Long motorNumber;
/**
*
*/
/** 电池编号 */
private Long batteryNumber;
/**
* id
*/
/** 企业ID */
private Long businessId;
/**
*
*/
private String businessNam;
}

View File

@ -1,51 +1,65 @@
package com.muyu.vehicle.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.vehicle.domain.Vehicle;
import java.util.List;
/**
* mapper VehicleMapper
* Mapper
*
* @author xiaohuang
* on 2024/6/5
* @author muyu
* @date 2024-05-27
*/
public interface VehicleMapper extends BaseMapper<Vehicle> {
public interface VehicleMapper extends BaseMapper<Vehicle>
{
/**
*
*
* @param id
* @return
*/
public Vehicle selectVehicleById(Long id);
/**
*
*
* @param vehicle
* @return
*/
public List<Vehicle> selectVehicleList(Vehicle vehicle);
/**
*
*
* @param vehicle
* @return
*/
public int insertVehicle(Vehicle vehicle);
/**
*
*
*
* @param vehicle
* @return
*/
public int updateVehicle(Vehicle vehicle);
/**
*
*
*
* @param id
* @return
*/
public int deleteVehicleById(Long id);
/**
*
*
*
* @param ids
* @return
*/
public int deleteVehicleByIds(Long[] ids);
}

View File

@ -1,18 +1,20 @@
package com.muyu.vehicle.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.vehicle.domain.Vehicle;
import java.util.List;
/**
* IVehicleService
* Service
*
* @author xiaohuang
* on 2024/6/5
* @author muyu
* @date 2024-05-27
*/
public interface IVehicleService extends IService<Vehicle> {
public interface IVehicleService extends IService<Vehicle>
{
/**
*

View File

@ -1,6 +1,8 @@
package com.muyu.vehicle.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
@ -16,31 +18,46 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* VehicleServiceImpl
* Service
*
* @author xiaohuang
* on 2024/6/5
* @author muyu
* @date 2024-05-27
*/
@Service
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements IVehicleService {
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle>
implements IVehicleService
{
@Autowired
private VehicleMapper vehicleMapper;
@Autowired
private RemoteFileService remoteFileService;
@Autowired
private RemoteUserService remoteUserService;
// @Autowired
// private IBusinessService businessService;
@Autowired
private RemoteFileService remoteFileService;
/**
*
*
* @param id
* @return
*/
@Override
public Vehicle selectVehicleById(Long id) {
public Vehicle selectVehicleById(Long id)
{
return vehicleMapper.selectVehicleById(id);
}
/**
*
*
* @param vehicle
* @return
*/
@Override
public List<Vehicle> selectVehicleList(Vehicle vehicle)
{