feat:项目优化,细节处理
parent
06fbdd9fdb
commit
aa8d06e57d
|
@ -10,6 +10,10 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>zhiLian-business</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>zhiLian-data-plus</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -19,7 +23,5 @@
|
|||
<description>
|
||||
zhiLian-business系统模块
|
||||
</description>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zhiLian</groupId>
|
||||
<artifactId>zhiLian-business</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zhiLian-data-plus</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
|
@ -20,6 +20,16 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join</artifactId>
|
||||
<version>1.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<!--rabbitMQ-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ManyJob {
|
|||
@Autowired
|
||||
private EntinfoServiceImpl entinfoService;
|
||||
|
||||
@Scheduled(cron = "*/10 * * * * *") // 每10分钟执行一次
|
||||
// @Scheduled(cron = "*/10 * * * * *") // 每10分钟执行一次
|
||||
public void manyJob(){
|
||||
redisService.deleteObject("entinfo");
|
||||
List<Entinfo> list = entinfoService.list();
|
||||
|
|
|
@ -10,6 +10,7 @@ public class RabbitmqConfig {
|
|||
// 消息转换配置
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter() {
|
||||
// 使用json序列化方式,进行消息转换
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,12 @@ import java.util.List;
|
|||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhiLian.business.domain.Cart;
|
||||
import com.zhiLian.business.domain.CartVo;
|
||||
import com.zhiLian.business.domain.Entinfo;
|
||||
import com.zhiLian.business.service.IEntinfoService;
|
||||
import com.zhiLian.business.service.PlusService;
|
||||
import com.zhiLian.business.service.impl.PlusServiceImpl;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.core.utils.poi.ExcelUtil;
|
||||
import com.zhiLian.common.core.web.controller.BaseController;
|
||||
|
@ -36,6 +40,16 @@ public class EntinfoController extends BaseController
|
|||
@Autowired
|
||||
private IEntinfoService entinfoService;
|
||||
|
||||
@Autowired
|
||||
private PlusService plusService;
|
||||
|
||||
@PostMapping("cartLiat")
|
||||
public Result cartList(@RequestBody CartVo cartVo){
|
||||
List<Cart> list = plusService.list();
|
||||
System.out.println(list);
|
||||
return plusService.cartList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询多数据源列表
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.zhiLian.business.controller;
|
||||
|
||||
|
||||
import com.zhiLian.business.domain.Business;
|
||||
import com.zhiLian.business.mapper.BusinessMapper;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName PlusController
|
||||
* @Date 2024/06/09 15:28
|
||||
*/
|
||||
public class PlusController{
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.zhiLian.business.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName Cart
|
||||
* @Date 2024/06/09 15:40
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("cart")
|
||||
public class Cart {
|
||||
|
||||
// @TableId
|
||||
private Long id;
|
||||
|
||||
// @TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
// @TableField(value = "type_id")
|
||||
private Long typeId;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.zhiLian.business.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.zhiLian.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName BusinessVo
|
||||
* @Date 2024/06/09 15:34
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class CartVo {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String typeName;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.zhiLian.business.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName Type
|
||||
* @Date 2024/06/09 15:40
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("type")
|
||||
public class Type {
|
||||
|
||||
// @TableId
|
||||
private Long id;
|
||||
|
||||
// @TableField(value = "type_name")
|
||||
private String typeName;
|
||||
}
|
|
@ -10,8 +10,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 企业Mapper接口
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-26
|
||||
*/
|
||||
public interface BusinessMapper extends BaseMapper<Business>
|
||||
|
|
|
@ -60,4 +60,6 @@ public interface EntinfoMapper extends BaseMapper<Entinfo>
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteEntinfoByIds(Long[] ids);
|
||||
|
||||
Entinfo selectEntinfo(Entinfo business);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.zhiLian.business.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.zhiLian.business.domain.Cart;
|
||||
import com.zhiLian.business.domain.CartVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName PlusMapper
|
||||
* @Date 2024/06/09 15:33
|
||||
*/
|
||||
@Mapper
|
||||
public interface PlusMapper extends MPJBaseMapper<Cart> {
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.zhiLian.business.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.zhiLian.business.domain.Cart;
|
||||
import com.zhiLian.business.domain.Type;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName PlusMapper
|
||||
* @Date 2024/06/09 15:33
|
||||
*/
|
||||
@Mapper
|
||||
public interface TypeMapper extends BaseMapper<Type> {
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.zhiLian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhiLian.business.domain.Business;
|
||||
import com.zhiLian.business.domain.Entinfo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -60,4 +61,6 @@ public interface IEntinfoService extends IService<Entinfo>
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteEntinfoById(Long id);
|
||||
|
||||
Entinfo selectEntinfo(Entinfo business);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.zhiLian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
import com.zhiLian.business.domain.Cart;
|
||||
import com.zhiLian.business.domain.CartVo;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
|
||||
/**
|
||||
* @ClassName PlusService
|
||||
* @Description 描述
|
||||
* @Author BingRui.Hou
|
||||
* @Date 2024/06/09 15:36
|
||||
*/
|
||||
public interface PlusService extends IService<Cart> {
|
||||
Result cartList();
|
||||
|
||||
}
|
|
@ -108,7 +108,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
.email(business.getBusinessEmail())
|
||||
.phonenumber(business.getBusinessPhone())
|
||||
.loginIp("111.229.102.61")
|
||||
.roleId(Long.valueOf(2))
|
||||
.roleId(Long.valueOf(101))
|
||||
.userType(String.valueOf(business.getId()))
|
||||
.build();
|
||||
Result add = remoteUserService.add(sysUser);
|
||||
|
@ -139,11 +139,22 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
public void httpConnectMysql(Business business){
|
||||
redisService.deleteObject("entinfo");
|
||||
List<Entinfo> list = entinfoService.list();
|
||||
redisService.setCacheList("entinfo",list);
|
||||
if (business.getBusinessStates().equals("2")) {
|
||||
extracted(business);
|
||||
if(list.size()!=0){
|
||||
redisService.setCacheList("entinfo",list);
|
||||
}
|
||||
if (business.getBusinessStates().equals("2")) {
|
||||
SysUser sysUser = remoteUserService.userById(business.getId());
|
||||
sysUser.setRoleId(Long.valueOf(2));
|
||||
remoteUserService.updateById(sysUser);
|
||||
Entinfo build = Entinfo.builder()
|
||||
.entCode("test_" + business.getId())
|
||||
.ip("192.168.120.128")
|
||||
.port(Integer.valueOf(3306 + Integer.valueOf(String.valueOf(business.getId())))).build();
|
||||
Entinfo entinfo =entinfoService.selectEntinfo(build);
|
||||
if (entinfo==null){
|
||||
extracted(business);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
@ -159,7 +170,6 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
hashMap.put("businessId",business.getId()+ business.getName());
|
||||
hashMap.put("mysqlPort",String.valueOf(3306+ business.getId()));
|
||||
String json = JSON.toJSONString(hashMap);
|
||||
|
||||
// 3.创建连接与设置连接参数
|
||||
URL urlObj = null;
|
||||
try {
|
||||
|
@ -186,21 +196,21 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business>
|
|||
new InputStreamReader(httpConn.getInputStream()));
|
||||
String resultData = br.readLine();
|
||||
System.out.println("从服务端返回结果: " + resultData);
|
||||
Entinfo build = Entinfo.builder()
|
||||
.entCode("test_" + business.getId())
|
||||
.ip("192.168.120.128")
|
||||
.port(Integer.valueOf(3306 + Integer.valueOf(String.valueOf(business.getId())))).build();
|
||||
entinfoService.insertEntinfo(build);
|
||||
rabbitTemplate.convertAndSend("zhiLian-vehicle-exchange",JSON.toJSONString(build),message ->{
|
||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
return message;
|
||||
} );
|
||||
|
||||
// 7.关闭HttpURLConnection连接
|
||||
httpConn.disconnect();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Entinfo build = Entinfo.builder()
|
||||
.entCode("test_" + business.getId())
|
||||
.ip("192.168.120.128")
|
||||
.port(Integer.valueOf(3306 + Integer.valueOf(String.valueOf(business.getId())))).build();
|
||||
entinfoService.insertEntinfo(build);
|
||||
rabbitTemplate.convertAndSend("zhiLian-vehicle-exchange",JSON.toJSONString(build),message ->{
|
||||
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
return message;
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.zhiLian.business.service.impl;
|
|||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhiLian.business.domain.Business;
|
||||
import com.zhiLian.business.domain.Entinfo;
|
||||
import com.zhiLian.business.mapper.EntinfoMapper;
|
||||
import com.zhiLian.business.service.IEntinfoService;
|
||||
|
@ -93,4 +94,9 @@ public class EntinfoServiceImpl extends ServiceImpl<EntinfoMapper, Entinfo>
|
|||
{
|
||||
return entinfoMapper.deleteEntinfoById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entinfo selectEntinfo(Entinfo business) {
|
||||
return entinfoMapper.selectEntinfo(business);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.zhiLian.business.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.zhiLian.business.domain.Cart;
|
||||
import com.zhiLian.business.domain.CartVo;
|
||||
import com.zhiLian.business.domain.Type;
|
||||
import com.zhiLian.business.mapper.PlusMapper;
|
||||
import com.zhiLian.business.mapper.TypeMapper;
|
||||
import com.zhiLian.business.service.PlusService;
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName PlusServiceImpl
|
||||
* @Date 2024/06/09 15:37
|
||||
*/
|
||||
@Service
|
||||
public class PlusServiceImpl extends MPJBaseServiceImpl<PlusMapper, Cart> implements PlusService {
|
||||
|
||||
@Autowired
|
||||
private PlusMapper plusMapper;
|
||||
|
||||
@Autowired
|
||||
private TypeMapper typeMapper;
|
||||
|
||||
@Override
|
||||
public Result cartList() {
|
||||
MPJLambdaWrapper<Cart> mpjLambdaWrapper = new MPJLambdaWrapper<Cart>()
|
||||
.selectAll( Cart.class) //查询主表所有的字段
|
||||
.select(Type::getTypeName) //查询类型名称
|
||||
.leftJoin(Type.class, Type::getId, Cart::getTypeId);//左连接查询,相当于 left join type on dept.id=user.dept_id
|
||||
List<CartVo> cartList = plusMapper.selectJoinList(CartVo.class, mpjLambdaWrapper);
|
||||
return Result.success(cartList);
|
||||
// MPJLambdaWrapper<Cart> mpjLambdaWrapper1 = new MPJLambdaWrapper<>();
|
||||
// MPJLambdaWrapper<Cart> lambdaWrapper = mpjLambdaWrapper1.eq(Cart::getId, "1");
|
||||
|
||||
|
||||
// List<Cart> list = this.list();
|
||||
// list.stream().forEach(cart -> {
|
||||
// LambdaQueryWrapper<Type> typeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// Type type = typeMapper.selectOne(typeLambdaQueryWrapper.eq(Type::getId, cart.getTypeId()));
|
||||
// cart.setName(type.getTypeName());
|
||||
// });
|
||||
// System.out.println(list);
|
||||
// return Result.success(list,cartList.toString());
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ spring:
|
|||
password: guest
|
||||
virtualHost: /
|
||||
port: 5672
|
||||
host: 192.168.120.128
|
||||
host: 111.229.102.61
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
|
|
|
@ -28,6 +28,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectEntinfoVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectEntinfo" resultType="com.zhiLian.business.domain.Entinfo">
|
||||
<include refid="selectEntinfoVo"/>
|
||||
<where>
|
||||
<if test="entCode != null and entCode != ''"> and ent_code = #{entCode}</if>
|
||||
<if test="ip != null and ip != ''"> and ip = #{ip}</if>
|
||||
<if test="port != null "> and port = #{port}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertEntinfo" parameterType="com.zhiLian.business.domain.Entinfo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into entinfo
|
||||
|
|
|
@ -50,4 +50,9 @@ public interface RemoteUserService {
|
|||
|
||||
@GetMapping("/user/selectByUserId/{userId}")
|
||||
public SysUser selectByUserId (@PathVariable("userId") Long userId);
|
||||
|
||||
@GetMapping("/user/userById/{userId}")
|
||||
public SysUser userById (@PathVariable("userId") Long UserType);
|
||||
@PostMapping("/user/updateById")
|
||||
public Result updateById (@RequestBody SysUser user);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,16 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser userById(Long userType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateById(SysUser user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.zhiLian.system.domain.resp.AuthRoleResp;
|
|||
import com.zhiLian.system.domain.resp.UserDetailInfoResp;
|
||||
import com.zhiLian.system.domain.resp.UserInfoResp;
|
||||
import com.zhiLian.system.service.*;
|
||||
import org.apache.catalina.User;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -295,4 +296,14 @@ public class SysUserController extends BaseController {
|
|||
public Result deptTree (SysDept dept) {
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
@GetMapping("/userById/{userId}")
|
||||
public SysUser userById (@PathVariable("userId") Long UserType) {
|
||||
SysUser user=userService.selectUserByUserType(UserType);
|
||||
return user;
|
||||
}
|
||||
@PostMapping("/updateById")
|
||||
public Result updateById (@RequestBody SysUser user) {
|
||||
return success(userService.updateByUserId(user));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,4 +139,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique (String email);
|
||||
|
||||
void updateByUserId(SysUser user);
|
||||
|
||||
SysUser selectUserByUserType(String userType);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zhiLian.system.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhiLian.common.system.domain.SysUser;
|
||||
import org.apache.catalina.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -225,4 +226,8 @@ public interface SysUserService extends IService<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
String updateByUserId(SysUser user);
|
||||
|
||||
SysUser selectUserByUserType(Long userType);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.zhiLian.system.domain.SysUserRole;
|
|||
import com.zhiLian.system.mapper.*;
|
||||
import com.zhiLian.system.service.SysUserService;
|
||||
import com.zhiLian.system.service.SysConfigService;
|
||||
import org.apache.catalina.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -241,9 +242,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
if (2 == user.getRoleId()){
|
||||
if (101 == user.getRoleId()){
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setRoleId(Long.valueOf(2));
|
||||
sysUserRole.setRoleId(Long.valueOf(101));
|
||||
sysUserRole.setUserId(user.getUserId());
|
||||
userRoleMapper.insertUserRole(sysUserRole);
|
||||
}
|
||||
|
@ -506,4 +507,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateByUserId(SysUser user) {
|
||||
userMapper.updateByUserId(user);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectUserByUserType(Long userType) {
|
||||
String userType1=String.valueOf(userType);
|
||||
SysUser user = userMapper.selectUserByUserType(userType1);
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -185,6 +185,12 @@
|
|||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectUserByUserType" resultType="com.zhiLian.common.system.domain.SysUser">
|
||||
select user_id, user_type, nick_name, email, avatar, phonenumber, sex, status, create_time
|
||||
from sys_user
|
||||
where user_type = #{userType}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertUser" parameterType="com.zhiLian.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
@ -259,6 +265,9 @@
|
|||
set password = #{password}
|
||||
where user_name = #{userName}
|
||||
</update>
|
||||
<update id="updateByUserId">
|
||||
update sys_user_role set role_id = #{roleId} where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserById" parameterType="Long">
|
||||
update sys_user
|
||||
|
|
|
@ -41,6 +41,21 @@ import java.util.Map;
|
|||
public class ManyDataSource {
|
||||
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
|
@ -52,6 +67,13 @@ public class ManyDataSource {
|
|||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||
public void smsConfig(String msg, Message message, Channel channel){
|
||||
//获取消息的ID
|
||||
// new Thread(() -> {
|
||||
// try {
|
||||
// Thread.sleep(10000);
|
||||
// } catch (InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }).start();
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
try {
|
||||
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
|
||||
|
@ -59,41 +81,17 @@ public class ManyDataSource {
|
|||
//添加成功 正常消费信息
|
||||
if (count == 1) {
|
||||
log.info("开始消费");
|
||||
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||
Entinfo entinfo1 = JSON.parseObject(msg, Entinfo.class);
|
||||
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entinfo1.getEntCode(), entinfo1.getIp(), entinfo1.getPort());
|
||||
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
|
||||
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
||||
// List<Entinfo> databaseNameList = new ArrayList<>();
|
||||
// entinfo.forEach(string -> {
|
||||
// Entinfo entInfo = JSON.parseObject(string, Entinfo.class);
|
||||
// databaseNameList.add(entInfo);
|
||||
// });
|
||||
// databaseNameList.forEach(enterpriseInfo -> {
|
||||
// DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(enterpriseInfo.getEntCode(), enterpriseInfo.getIp(), enterpriseInfo.getPort());
|
||||
// DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
|
||||
// dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
|
||||
// });
|
||||
}).start();
|
||||
druidData(msg);
|
||||
//确认消费
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
log.info("消费成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//删除队列ID
|
||||
log.info("消费重复");
|
||||
log.info("消费失败,尝试重连");
|
||||
try {
|
||||
//回退消息
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
|
||||
//回退消息,尝试重连
|
||||
druidData(msg);
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
|
||||
log.info("消费失败");
|
||||
} catch (IOException ex) {
|
||||
//回退失败
|
||||
|
@ -102,6 +100,17 @@ public class ManyDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
private void druidData(String msg) {
|
||||
Entinfo entinfo1 = JSON.parseObject(msg, Entinfo.class);
|
||||
log.info("消息为:{}",entinfo1);
|
||||
|
||||
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entinfo1.getEntCode(), entinfo1.getIp(), entinfo1.getPort());
|
||||
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
|
||||
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
|
||||
}
|
||||
|
||||
@Lazy
|
||||
private List<Entinfo> dataSourceInfoList(){
|
||||
List<Entinfo> databaseNameList = new ArrayList<>(){{
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zhiLian.vehicle.datasource.config.factory;
|
|||
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.zhiLian.vehicle.datasource.domain.DataSourceInfo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -31,13 +32,9 @@ public class DruidDataSourceFactory {
|
|||
druidDataSource.setPassword(dataSourceInfo.getPassword());
|
||||
druidDataSource.setBreakAfterAcquireFailure(true);
|
||||
druidDataSource.setConnectionErrorRetryAttempts(0);
|
||||
try {
|
||||
druidDataSource.getConnection(2000);
|
||||
log.info("{} -> 数据源连接成功", dataSourceInfo);
|
||||
return druidDataSource;
|
||||
} catch (SQLException throwables) {
|
||||
log.error("数据源 {} 连接失败,用户名:{},密码 {}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword());
|
||||
return null;
|
||||
}
|
||||
druidDataSource.setInitialSize(5);
|
||||
druidDataSource.setMaxActive(15);
|
||||
log.info("{} -> 数据源连接成功", dataSourceInfo);
|
||||
return druidDataSource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ package com.zhiLian.vehicle.datasource.contents;
|
|||
*/
|
||||
public class DatasourceContent {
|
||||
|
||||
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 DATASOURCE_URL = "jdbc:mysql://{}:{}/zhiLian-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&failOverReadOnly=false";
|
||||
|
||||
public final static String USER_NAME = "root";
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.zhiLian.vehicle.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName Type
|
||||
* @Date 2024/06/09 15:40
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("type")
|
||||
public class Type {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
@TableField(value = "type_name")
|
||||
private String typeName;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.zhiLian.vehicle.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhiLian.common.core.annotation.Excel;
|
||||
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 车辆录入对象 vehicle
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-27
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleVo extends BaseEntity
|
||||
{
|
||||
|
||||
|
||||
/** 车辆主键 */
|
||||
private Long id;
|
||||
|
||||
/** 车辆vin */
|
||||
private String number;
|
||||
|
||||
/** 电子围栏ID */
|
||||
private Long electonicId;
|
||||
|
||||
/** 电机厂商 */
|
||||
private String motor;
|
||||
|
||||
/** 电池厂商 */
|
||||
private String battery;
|
||||
|
||||
/** 电机编号 */
|
||||
private Long motorNumber;
|
||||
|
||||
/** 电池编号 */
|
||||
private Long batteryNumber;
|
||||
|
||||
/** 企业ID */
|
||||
// @Excel(name = "企业ID")
|
||||
// private Long businessId;
|
||||
private Long groupId;
|
||||
|
||||
private String typeName;
|
||||
|
||||
}
|
|
@ -9,7 +9,7 @@ spring:
|
|||
password: guest
|
||||
virtualHost: /
|
||||
port: 5672
|
||||
host: 192.168.120.128
|
||||
host: 111.229.102.61
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
|
|
Loading…
Reference in New Issue