Compare commits

...

10 Commits

Author SHA1 Message Date
Saisai Liu e7336a4f59 feat():引擎版本单增删改查 2024-05-07 13:56:31 +08:00
Saisai Liu 1abb6e89b9 feat():规则引擎简易版 2024-05-04 17:43:45 +08:00
Saisai Liu e10817cb1b feat():个人理解创建4个模块代码的引擎库 2024-05-04 15:29:53 +08:00
Saisai Liu d4ac304b07 feat():个人理解创建4个模块代码的引擎库 2024-05-03 19:49:45 +08:00
Saisai Liu 8a33e76f51 feat():规则引擎模块 2024-05-03 11:40:33 +08:00
Saisai Liu 9b76b6fae4 fix:优化资产结构接口 2024-04-30 08:31:34 +08:00
Saisai Liu 8a1699ddfd fix:修改bug、优化
1、线程中提前关闭了conn连接导致主线程无法继续;
2、将并发多线程放入线程池,由线程池系统性管理,提法并发或异步性能
3、开启资产授权模块
2024-04-28 21:53:29 +08:00
Saisai Liu 389f0be640 fix:连接postgre数据库 2024-04-28 09:04:26 +08:00
Saisai Liu 07a2fc9618 fix:解决bug
1、数据同步时,数据库连接未添加,添加报错。
2、前台进行字典修改-》后台同步不正确
2024-04-27 18:34:07 +08:00
Saisai Liu e69291cd38 fix:重构完成;重构点:表的数量较大,在遍历表用于查询的时候安排给线程异步执行,减少执行时间,完成同步 2024-04-26 22:27:35 +08:00
48 changed files with 2487 additions and 215 deletions

View File

@ -3,12 +3,16 @@ package com.muyu.common.system.remote;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
import com.muyu.common.system.domain.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
*
@ -37,4 +41,24 @@ public interface RemoteUserService {
*/
@PostMapping("/user/register")
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
* @param user
* @return
*/
@PostMapping("/user/list")
public Result<List<SysUser>> list (@RequestBody SysUser user, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
* @param deptId
* @return
*/
@PostMapping(value = "/dept/{deptId}")
public Result<SysDept> getInfo (@PathVariable("deptId") Long deptId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping(value = "/dept/list")
Result<List<SysDept>> list(@RequestBody SysDept dept, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

View File

@ -1,14 +1,17 @@
package com.muyu.common.system.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
*
@ -19,18 +22,33 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
@Override
public RemoteUserService create (Throwable throwable) {
public RemoteUserService create(Throwable throwable) {
log.error("用户服务调用失败:{}", throwable.getMessage());
return new RemoteUserService() {
@Override
public Result<LoginUser> getUserInfo (String username, String source) {
public Result<LoginUser> getUserInfo(String username, String source) {
return Result.error("获取用户失败:" + throwable.getMessage());
}
@Override
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
public Result<Boolean> registerUserInfo(SysUser sysUser, String source) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
@Override
public Result<List<SysUser>> list(SysUser user, String source) {
return Result.error("用户列表获取失败" + throwable.getMessage());
}
@Override
public Result<SysDept> getInfo(Long deptId, String source) {
return Result.error("用户获取失败" + throwable.getMessage());
}
@Override
public Result<List<SysDept>> list(SysDept dept, String source) {
return Result.error("部门列表获取失败" + throwable.getMessage());
}
};
}
}

View File

@ -0,0 +1,30 @@
<?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.muyu</groupId>
<artifactId>muyu-ruleEngine</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-ruleEngine-common</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>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,65 @@
package com.muyu.engine.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_engine
*
* @author Saisai
* @date 2024-05-03
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class RuleEngine extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/** 规则名称 */
@Excel(name = "规则名称")
private String name;
/** 规则类型 */
@Excel(name = "规则类型")
private String type;
/** 规则作用域 */
@Excel(name = "规则作用域")
private String level;
/** 规则编码 */
@Excel(name = "规则编码")
private String code;
/** 引擎编码 */
@Excel(name = "引擎编码")
private String engineCode;
/** 描述 */
@Excel(name = "描述")
private String description;
/** 是否激活 */
@Excel(name = "是否激活")
private String isActivate;
/** 规则状态 */
@Excel(name = "规则状态")
private String status;
}

View File

@ -0,0 +1,66 @@
package com.muyu.engine.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* rule_engine_version
*
* @author Saisai
* @date 2024-05-06
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class RuleEngineVersion extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 引擎id */
@Excel(name = "引擎id")
private Long ruleEngineId;
/** 版本类 */
@Excel(name = "版本类")
private String versionCode;
/** 版本名称 */
@Excel(name = "版本名称")
private String name;
/** 版本code */
@Excel(name = "版本code")
private String code;
/** 引擎编码 */
@Excel(name = "引擎编码")
private String codeIng;
/** 是否激活 */
@Excel(name = "是否激活")
private String isActivate;
/** 测试状态 */
@Excel(name = "是否激活")
private String isTest;
/** 版本状态 */
@Excel(name = "版本状态")
private String status;
/** 描述 */
@Excel(name = "描述")
private String description;
}

View File

@ -0,0 +1,20 @@
<?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.muyu</groupId>
<artifactId>muyu-ruleEngine</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-ruleEngine-remote</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>

View File

@ -0,0 +1,120 @@
<?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.muyu</groupId>
<artifactId>muyu-ruleEngine</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-ruleEngine-service</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>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.8</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-ruleEngine-common</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-log</artifactId>
</dependency>
<!-- MuYu Common Swagger -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-swagger</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,24 @@
package com.muyu;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @ClassName RuleEngineApplication
* @Description
* @Author SaiSai.Liu
* @Date 2024/5/3 11:43
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
public class RuleEngineApplication {
public static void main(String[] args) {
SpringApplication.run(RuleEngineApplication.class);
}
}

View File

@ -0,0 +1,93 @@
package com.muyu.engine.controller;
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 com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.engine.domain.RuleEngine;
import com.muyu.engine.service.RuleEngineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author Saisai
* @date 2024-05-03
*/
@RestController
@RequestMapping("/engine")
public class RuleEngineController extends BaseController {
@Autowired
private RuleEngineService ruleEngineService;
/**
*
*/
@RequiresPermissions("engine:engine:list")
@GetMapping("/list")
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) {
startPage();
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("engine:engine:export")
@Log(title = "规则引擎", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, RuleEngine ruleEngine) {
List<RuleEngine> list = ruleEngineService.selectRuleEngineList(ruleEngine);
ExcelUtil<RuleEngine> util = new ExcelUtil<RuleEngine>(RuleEngine.class);
util.exportExcel(response, list, "规则引擎数据");
}
/**
*
*/
@RequiresPermissions("engine:engine:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) {
return success(ruleEngineService.selectRuleEngineById(id));
}
/**
*
*/
@RequiresPermissions("engine:engine:add")
@Log(title = "规则引擎", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody RuleEngine ruleEngine) {
return toAjax(ruleEngineService.insertRuleEngine(ruleEngine));
}
/**
*
*/
@RequiresPermissions("engine:engine:edit")
@Log(title = "规则引擎", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody RuleEngine ruleEngine) {
return toAjax(ruleEngineService.updateRuleEngine(ruleEngine));
}
/**
*
*/
@RequiresPermissions("engine:engine:remove")
@Log(title = "规则引擎", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) {
return toAjax(ruleEngineService.deleteRuleEngineByIds(ids));
}
}

View File

@ -0,0 +1,103 @@
package com.muyu.engine.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
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.engine.domain.RuleEngineVersion;
import com.muyu.engine.service.RuleEngineVersionService;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author Saisai
* @date 2024-05-06
*/
@RestController
@RequestMapping("/version")
public class RuleEngineVersionController extends BaseController
{
@Autowired
private RuleEngineVersionService ruleEngineVersionService;
/**
*
*/
@RequiresPermissions("engine:version:list")
@GetMapping("/list/{ruleEngineId}")
public Result<TableDataInfo<RuleEngineVersion>> list(@PathVariable Long ruleEngineId)
{
List<RuleEngineVersion> list = ruleEngineVersionService.selectRuleEngineVersionList(ruleEngineId);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("engine:version:export")
@Log(title = "规则版本", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Long ruleEngineId)
{
List<RuleEngineVersion> list = ruleEngineVersionService.selectRuleEngineVersionList(ruleEngineId);
ExcelUtil<RuleEngineVersion> util = new ExcelUtil<RuleEngineVersion>(RuleEngineVersion.class);
util.exportExcel(response, list, "规则版本数据");
}
/**
*
*/
@RequiresPermissions("engine:version:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(ruleEngineVersionService.selectRuleEngineVersionById(id));
}
/**
*
*/
@RequiresPermissions("engine:version:add")
@Log(title = "规则版本", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody RuleEngineVersion ruleEngineVersion)
{
return toAjax(ruleEngineVersionService.insertRuleEngineVersion(ruleEngineVersion));
}
/**
*
*/
@RequiresPermissions("engine:version:edit")
@Log(title = "规则版本", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody RuleEngineVersion ruleEngineVersion)
{
return toAjax(ruleEngineVersionService.updateRuleEngineVersion(ruleEngineVersion));
}
/**
*
*/
@RequiresPermissions("engine:version:remove")
@Log(title = "规则版本", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(ruleEngineVersionService.deleteRuleEngineVersionByIds(ids));
}
}

View File

@ -0,0 +1,63 @@
package com.muyu.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.engine.domain.RuleEngine;
import java.util.List;
/**
* Mapper
*
* @author Saisai
* @date 2024-05-03
*/
public interface RuleEngineMapper extends BaseMapper<RuleEngine>
{
/**
*
*
* @param id
* @return
*/
public RuleEngine selectRuleEngineById(Long id);
/**
*
*
* @param ruleEngine
* @return
*/
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine);
/**
*
*
* @param ruleEngine
* @return
*/
public int insertRuleEngine(RuleEngine ruleEngine);
/**
*
*
* @param ruleEngine
* @return
*/
public int updateRuleEngine(RuleEngine ruleEngine);
/**
*
*
* @param id
* @return
*/
public int deleteRuleEngineById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteRuleEngineByIds(Long[] ids);
}

View File

@ -0,0 +1,63 @@
package com.muyu.engine.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.engine.domain.RuleEngineVersion;
/**
* Mapper
*
* @author Saisai
* @date 2024-05-06
*/
public interface RuleEngineVersionMapper extends BaseMapper<RuleEngineVersion>
{
/**
*
*
* @param id
* @return
*/
public RuleEngineVersion selectRuleEngineVersionById(Long id);
/**
*
*
* @param ruleEngineVersion
* @return
*/
public List<RuleEngineVersion> selectRuleEngineVersionList(RuleEngineVersion ruleEngineVersion);
/**
*
*
* @param ruleEngineVersion
* @return
*/
public int insertRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
/**
*
*
* @param ruleEngineVersion
* @return
*/
public int updateRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
/**
*
*
* @param id
* @return
*/
public int deleteRuleEngineVersionById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteRuleEngineVersionByIds(Long[] ids);
}

View File

@ -0,0 +1,66 @@
package com.muyu.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.engine.domain.RuleEngine;
import javax.servlet.ServletException;
import java.util.List;
/**
* Service
*
* @author Saisai
* @date 2024-05-03
*/
public interface RuleEngineService extends IService<RuleEngine>
{
/**
*
*
* @param id
* @return
*/
public RuleEngine selectRuleEngineById(Long id);
/**
*
*
* @param ruleEngine
* @return
*/
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine);
/**
*
*
* @param ruleEngine
* @return
*/
public int insertRuleEngine(RuleEngine ruleEngine);
/**
*
*
* @param ruleEngine
* @return
*/
public int updateRuleEngine(RuleEngine ruleEngine);
/**
*
*
* @param ids
* @return
*/
public int deleteRuleEngineByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteRuleEngineById(Long id);
}

View File

@ -0,0 +1,63 @@
package com.muyu.engine.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.engine.domain.RuleEngineVersion;
/**
* Service
*
* @author Saisai
* @date 2024-05-06
*/
public interface RuleEngineVersionService extends IService<RuleEngineVersion>
{
/**
*
*
* @param id
* @return
*/
public RuleEngineVersion selectRuleEngineVersionById(Long id);
/**
*
*
* @param ruleEngineVersion
* @return
*/
public List<RuleEngineVersion> selectRuleEngineVersionList(Long ruleEngineVersion);
/**
*
*
* @param ruleEngineVersion
* @return
*/
public int insertRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
/**
*
*
* @param ruleEngineVersion
* @return
*/
public int updateRuleEngineVersion(RuleEngineVersion ruleEngineVersion);
/**
*
*
* @param ids
* @return
*/
public int deleteRuleEngineVersionByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteRuleEngineVersionById(Long id);
}

View File

@ -0,0 +1,100 @@
package com.muyu.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.engine.domain.RuleEngine;
import com.muyu.engine.mapper.RuleEngineMapper;
import com.muyu.engine.service.RuleEngineService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author Saisai
* @date 2024-05-03
*/
@Service
@Log4j2
public class RuleEngineServiceImpl extends ServiceImpl<RuleEngineMapper, RuleEngine> implements RuleEngineService {
@Autowired
private RuleEngineMapper ruleEngineMapper;
/**
*
*
* @param id
* @return
*/
@Override
public RuleEngine selectRuleEngineById(Long id) {
return ruleEngineMapper.selectRuleEngineById(id);
}
/**
*
*
* @param ruleEngine
* @return
*/
@Override
public List<RuleEngine> selectRuleEngineList(RuleEngine ruleEngine) {
return ruleEngineMapper.selectRuleEngineList(ruleEngine);
}
/**
*
*
* @param ruleEngine
* @return
*/
@Override
public int insertRuleEngine(RuleEngine ruleEngine) {
ruleEngine.setCreateTime(DateUtils.getNowDate());
ruleEngine.setEngineCode("engine_custom_" + ruleEngine.getCode());
boolean save = this.save(ruleEngine);
if (save) {
return 1;
}
return 0;
}
/**
*
*
* @param ruleEngine
* @return
*/
@Override
public int updateRuleEngine(RuleEngine ruleEngine) {
ruleEngine.setUpdateTime(DateUtils.getNowDate());
return ruleEngineMapper.updateRuleEngine(ruleEngine);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteRuleEngineByIds(Long[] ids) {
return ruleEngineMapper.deleteRuleEngineByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteRuleEngineById(Long id) {
return ruleEngineMapper.deleteRuleEngineById(id);
}
}

View File

@ -0,0 +1,204 @@
package com.muyu.engine.service.impl;
import java.io.*;
import java.util.List;
import com.alibaba.nacos.shaded.com.google.common.base.Supplier;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.engine.domain.RuleEngine;
import com.muyu.engine.service.RuleEngineService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.engine.mapper.RuleEngineVersionMapper;
import com.muyu.engine.domain.RuleEngineVersion;
import com.muyu.engine.service.RuleEngineVersionService;
import javax.servlet.ServletException;
/**
* Service
*
* @author Saisai
* @date 2024-05-06
*/
@Service
@Log4j2
public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionMapper,RuleEngineVersion> implements RuleEngineVersionService
{
@Autowired
private RuleEngineVersionMapper ruleEngineVersionMapper;
@Autowired
private RuleEngineService ruleEngineService;
/**
*
*
* @param id
* @return
*/
@Override
public RuleEngineVersion selectRuleEngineVersionById(Long id)
{
return ruleEngineVersionMapper.selectRuleEngineVersionById(id);
}
/**
*
*
* @param ruleEngineId
* @return
*/
@Override
public List<RuleEngineVersion> selectRuleEngineVersionList(Long ruleEngineId)
{
return list(new LambdaQueryWrapper<RuleEngineVersion>(){{
eq(RuleEngineVersion::getRuleEngineId,ruleEngineId);
}});
}
/**
*
*
* @param ruleEngineVersion
* @return
*/
@Override
public int insertRuleEngineVersion(RuleEngineVersion ruleEngineVersion)
{
ruleEngineVersion.setCreateTime(DateUtils.getNowDate());
return ruleEngineVersionMapper.insertRuleEngineVersion(ruleEngineVersion);
}
/**
*
*
* @param ruleEngineVersion
* @return
*/
@Override
public int updateRuleEngineVersion(RuleEngineVersion ruleEngineVersion)
{
ruleEngineVersion.setUpdateTime(DateUtils.getNowDate());
return ruleEngineVersionMapper.updateRuleEngineVersion(ruleEngineVersion);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteRuleEngineVersionByIds(Long[] ids)
{
return ruleEngineVersionMapper.deleteRuleEngineVersionByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteRuleEngineVersionById(Long id)
{
return ruleEngineVersionMapper.deleteRuleEngineVersionById(id);
}
// @Override
public boolean testEngine(Long id) throws Exception {
// RuleEngine ruleEngine = ruleEngineService.getById(id);
// if (ruleEngine.getIsActivate().contains("no")) throw new ServletException("未激活");
// if (ruleEngine.getStatus().contains("1")) throw new ServletException("已停用");
// Scope scope = this.getOne(new LambdaQueryWrapper<Scope>() {{
// eq(Scope::getRuleEngineId, ruleEngine.getId());
// eq(Scope::getValue, "taskContext");
// }});
// String code = scope.getCode();
// String path = code.substring(code.indexOf("com"), code.indexOf(";")).replaceAll("/.", "/").trim();
// String fileName = code.substring(code.indexOf("class") + 6, code.indexOf("{")).trim();
// String name = path+"."+fileName;
// String javaPackageName = name.replace(".", File.separator)+".java";
// String javaAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/" +javaPackageName;
// String jarAbsolutePath = "D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/target/classes/com/muyu/engine/controller";
// Process process = Runtime.getRuntime().exec("javac -classpath "+ jarAbsolutePath+ " " + javaAbsolutePath);
// try {
// int exitVal = process.waitFor();
// System.out.println("Process exitValue: " + exitVal);
// ClassLoader classLoader = ReflectionUtils.class.getClassLoader();
// Class aClass = classLoader.loadClass(name);
// Object o = aClass.newInstance();
// Method[] methods = aClass.getMethods();
// for (Method method : methods) {
// method.invoke(o,null);
// }
// } catch (Exception e) {
// log.error(e.getMessage());
// }
return true;
}
/**
*
*
* @param id
* @return
*/
// @Override
public boolean init(Long id) throws ServletException {
RuleEngine ruleEngine = ruleEngineService.getById(id);
if (ruleEngine.getIsActivate().contains("no")) throw new ServletException("未激活");
if (ruleEngine.getStatus().contains("1")) throw new ServletException("已停用");
Supplier<Boolean> booleanSupplier = () -> {
try {
return testEngine(ruleEngine);
} catch (Exception e) {
throw new RuntimeException(e);
}
};
System.out.println();
return booleanSupplier.get();
}
private Boolean testEngine(RuleEngine ruleEngine) throws ServletException, IOException {
// System.out.println("初始化");
// System.out.println(ruleEngine);
// Scope scope = this.getOne(new LambdaQueryWrapper<Scope>() {{
// eq(Scope::getRuleEngineId, ruleEngine.getId());
// eq(Scope::getValue, "taskContext");
// }});
// String code = scope.getCode();
// String path = code.substring(code.indexOf("com"), code.indexOf(";")).replaceAll("\\.", "/").trim();
// String fileName = code.substring(code.indexOf("class") + 6, code.indexOf("{")).trim();
// //代码编译
// File file = new File("D:/ruoyi/FinallyTest/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/" + path + "/" + fileName + ".java");
// if (!file.exists()) {
// //不存在创建
// file.createNewFile();
// }else {
// //存在测重新创建
// file.delete();
// file.createNewFile();
// }
// String[] split = code.split("/n");
// //OutputStreamWriter对象将字符转换为字节流指定了文件输出流和编码方式。
// OutputStreamWriter outputStreamWriter =
// new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8");
// //BufferedWriter对象用于缓冲写入数据提高写入效率。
// BufferedWriter bw = new BufferedWriter(outputStreamWriter);
// for (String str : split) {
// bw.write(str);
// bw.newLine();
// }
// bw.close();
// outputStreamWriter.close();
return true;
}
}

View File

@ -0,0 +1,30 @@
# Tomcat
server:
port: 9206
# Spring
spring:
application:
# 应用名称
name: muyu-engine
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 43.142.100.73:8848
config:
# 配置中心地址
server-addr: 43.142.100.73:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
main:
allow-circular-references: true
logging:
level:
com.muyu.engine.mapper: DEBUG

View File

@ -0,0 +1,113 @@
<?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">
<mapper namespace="com.muyu.engine.mapper.RuleEngineMapper">
<resultMap type="com.muyu.engine.domain.RuleEngine" id="RuleEngineResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="type" column="type" />
<result property="level" column="level" />
<result property="code" column="code" />
<result property="engineCode" column="engine_code" />
<result property="description" column="description" />
<result property="isActivate" column="is_activate" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectRuleEngineVo">
select id, name, type, level, code,engine_code,description, is_activate, status, remark, create_by, create_time, update_by, update_time from rule_engine
</sql>
<select id="selectRuleEngineList" parameterType="com.muyu.engine.domain.RuleEngine" resultMap="RuleEngineResult">
<include refid="selectRuleEngineVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="level != null and level != ''"> and level = #{level}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="engineCode != null and engineCode != ''"> and engine_code = #{engineCode}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="isActivate != null and isActivate != ''"> and is_activate = #{isActivate}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectRuleEngineById" parameterType="Long" resultMap="RuleEngineResult">
<include refid="selectRuleEngineVo"/>
where id = #{id}
</select>
<insert id="insertRuleEngine" parameterType="com.muyu.engine.domain.RuleEngine">
insert into rule_engine
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="name != null">name,</if>
<if test="type != null">type,</if>
<if test="level != null">level,</if>
<if test="code != null">code,</if>
<if test="engineCode != null">engine_code,</if>
<if test="description != null">description,</if>
<if test="isActivate != null">is_activate,</if>
<if test="status != null">status,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="name != null">#{name},</if>
<if test="type != null">#{type},</if>
<if test="level != null">#{level},</if>
<if test="code != null">#{code},</if>
<if test="engine_code != null">#{engineCode},</if>
<if test="description != null">#{description},</if>
<if test="isActivate != null">#{isActivate},</if>
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateRuleEngine" parameterType="com.muyu.engine.domain.RuleEngine">
update rule_engine
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
<if test="level != null">level = #{level},</if>
<if test="code != null">code = #{code},</if>
<if test="engineCode != null">engine_code = #{engineCode},</if>
<if test="description != null">description = #{description},</if>
<if test="isActivate != null">is_activate = #{isActivate},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteRuleEngineById" parameterType="Long">
delete from rule_engine where id = #{id}
</delete>
<delete id="deleteRuleEngineByIds" parameterType="String">
delete from rule_engine where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,116 @@
<?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">
<mapper namespace="com.muyu.engine.mapper.RuleEngineVersionMapper">
<resultMap type="com.muyu.engine.domain.RuleEngineVersion" id="RuleEngineVersionResult">
<result property="id" column="id" />
<result property="ruleEngineId" column="rule_engine_id" />
<result property="versionCode" column="version_code" />
<result property="name" column="name" />
<result property="code" column="code" />
<result property="codeIng" column="codeIng" />
<result property="isActivate" column="is_activate" />
<result property="isTest" column="is_test" />
<result property="status" column="status" />
<result property="description" column="description" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectRuleEngineVersionVo">
select id, rule_engine_id, version_code, name, code, code_ing, is_activate,is_test, status, description, remark, create_by, create_time, update_by, update_time from rule_engine_version
</sql>
<select id="selectRuleEngineVersionList" parameterType="com.muyu.engine.domain.RuleEngineVersion" resultMap="RuleEngineVersionResult">
<include refid="selectRuleEngineVersionVo"/>
<where>
<if test="ruleEngineId != null "> and rule_engine_id = #{ruleEngineId}</if>
<if test="versionCode != null and versionCode != ''"> and version_code = #{versionCode}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="codeIng != null and codeIng != ''"> and code_ing = #{codeIng}</if>
<if test="isActivate != null and isActivate != ''"> and is_activate = #{isActivate}</if>
<if test="isTest != null and isTest != ''"> and is_test = #{isTest}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
</where>
</select>
<select id="selectRuleEngineVersionById" parameterType="Long" resultMap="RuleEngineVersionResult">
<include refid="selectRuleEngineVersionVo"/>
where id = #{id}
</select>
<insert id="insertRuleEngineVersion" parameterType="com.muyu.engine.domain.RuleEngineVersion" useGeneratedKeys="true" keyProperty="id">
insert into rule_engine_version
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ruleEngineId != null">rule_engine_id,</if>
<if test="versionCode != null">version_code,</if>
<if test="name != null">name,</if>
<if test="code != null">code,</if>
<if test="codeIng != null">code_ing,</if>
<if test="isActivate != null">is_activate,</if>
<if test="isTest != null">is_test,</if>
<if test="status != null">status,</if>
<if test="description != null">description,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ruleEngineId != null">#{ruleEngineId},</if>
<if test="versionCode != null">#{versionCode},</if>
<if test="name != null">#{name},</if>
<if test="code != null">#{code},</if>
<if test="codeIng != null">#{codeIng},</if>
<if test="isActivate != null">#{isActivate},</if>
<if test="isTest != null">#{isTest},</if>
<if test="status != null">#{status},</if>
<if test="description != null">#{description},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateRuleEngineVersion" parameterType="com.muyu.engine.domain.RuleEngineVersion">
update rule_engine_version
<trim prefix="SET" suffixOverrides=",">
<if test="ruleEngineId != null">rule_engine_id = #{ruleEngineId},</if>
<if test="versionCode != null">version_code = #{versionCode},</if>
<if test="name != null">name = #{name},</if>
<if test="code != null">code = #{code},</if>
<if test="codeIng != null">code_ing = #{codeIng},</if>
<if test="isActivate != null">is_activate = #{isActivate},</if>
<if test="isTest != null">is_test = #{isTest},</if>
<if test="status != null">status = #{status},</if>
<if test="description != null">description = #{description},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteRuleEngineVersionById" parameterType="Long">
delete from rule_engine_version where id = #{id}
</delete>
<delete id="deleteRuleEngineVersionByIds" parameterType="String">
delete from rule_engine_version where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,27 @@
<?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.muyu</groupId>
<artifactId>muyu-modules</artifactId>
<version>3.6.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>muyu-ruleEngine</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-ruleEngine-common</module>
<module>muyu-ruleEngine-remote</module>
<module>muyu-ruleEngine-service</module>
</modules>
<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>

View File

@ -34,7 +34,7 @@ public class SysDeptController extends BaseController {
*/
@RequiresPermissions("system:dept:list")
@GetMapping("/list")
public Result list (SysDept dept) {
public Result<List<SysDept>> list (SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
}

View File

@ -0,0 +1,65 @@
package com.muyu.etl.domain;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* asset_impower
*
* @author Saisai
* @date 2024-04-28
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class AssetImpower extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
/**
* id
*/
@Excel(name = "表id")
private Long tableId;
/**
* id
*/
@Excel(name = "部门id")
private Long deptId;
/**
* id
*/
@Excel(name = "接入id")
private Long basicId;
/**
* id
*/
@Excel(name = "用户id")
private Long userId;
public static AssetImpower saveAssetImpower(Long deptId,Long userId,AssetImpower assetImpower){
return AssetImpower.builder()
.basicId(assetImpower.getBasicId())
.tableId(assetImpower.getTableId())
.deptId(deptId)
.userId(userId)
.build();
}
}

View File

@ -24,8 +24,6 @@ public class TableInfo extends TreeEntity
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ -39,6 +37,11 @@ public class TableInfo extends TreeEntity
@Excel(name = "表备注")
private String tableRemark;
/** 表备注 */
@Excel(name = "数据来源类型")
private String type;
/** 数据量 */
@Excel(name = "数据量")
private Long dataNum;

View File

@ -0,0 +1,55 @@
package com.muyu.etl.domain.req;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @ClassName AssetImpowerReq
* @Description
* @Author SaiSai.Liu
* @Date 2024/4/29 14:04
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class AssetImpowerReq {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
* id
*/
@Excel(name = "表id")
private Long tableId;
/**
* id
*/
@Excel(name = "接入id")
private Long basicId;
/**
* id
*/
@Excel(name = "部门id")
private Long deptId;
/**
* id
*/
@Excel(name = "用户id")
private Long userId;
}

View File

@ -0,0 +1,63 @@
package com.muyu.etl.domain.resp;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* --
*
* @ClassName BasicTableInfoResp
* @Description
* @Author SaiSai.Liu
* @Date 2024/4/30 11:58
*/
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class BasicTableInfoResp {
/**
* id
*/
private Long id;
/**
* id
*/
private Long basicId;
/**
*
*/
private String dataResourceName;
/**
*
*/
private String dataSourcesSystemName;
/**
*
*/
private String databaseName;
/**
*
*/
private String tableRemark;
/**
*
*/
private String tableName;
/**
*
*/
private Long totalNum;
}

View File

@ -45,10 +45,14 @@ public class TableInfoStructureResp
/** 数据量 */
@Excel(name = "数据量")
private Long dataNum;
/** 表备注 */
@Excel(name = "数据来源类型")
private String type;
/** 是否核心 'Y'是 'N'不是 */
@Excel(name = "是否核心 'Y'是 'N'不是")
private String center;
private String databaseType;
private List<Structure> structureList;

View File

@ -11,10 +11,18 @@
<artifactId>muyu-etl-remote</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>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</project>

View File

@ -18,6 +18,11 @@
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.8</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
@ -85,6 +90,7 @@
<artifactId>muyu-common-swagger</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -5,10 +5,12 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@EnableFeignClients
@SpringBootApplication
public class MuYuEtlApplication {
public static void main(String[] args) {

View File

@ -0,0 +1,119 @@
package com.muyu.etl.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
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.etl.domain.AssetImpower;
import com.muyu.etl.service.AssetImpowerService;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author Saisai
* @date 2024-04-28
*/
@RestController
@RequestMapping("/impower")
public class AssetImpowerController extends BaseController
{
@Autowired
private AssetImpowerService assetImpowerService;
/**
*
*/
@RequiresPermissions("etl:impower:list")
@GetMapping("/list")
public Result<TableDataInfo<AssetImpower>> list(AssetImpower assetImpower)
{
startPage();
List<AssetImpower> list = assetImpowerService.selectAssetImpowerList(assetImpower);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("etl:impower:export")
@Log(title = "资产赋权", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AssetImpower assetImpower)
{
List<AssetImpower> list = assetImpowerService.selectAssetImpowerList(assetImpower);
ExcelUtil<AssetImpower> util = new ExcelUtil<AssetImpower>(AssetImpower.class);
util.exportExcel(response, list, "资产赋权数据");
}
/**
*
*/
@RequiresPermissions("etl:impower:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(assetImpowerService.selectAssetImpowerById(id));
}
/**
*
*/
@RequiresPermissions("etl:impower:add")
@Log(title = "资产赋权", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody AssetImpower assetImpower)
{
return toAjax(assetImpowerService.insertAssetImpower(assetImpower));
}
/**
*
*/
@RequiresPermissions("etl:impower:edit")
@Log(title = "资产赋权", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody AssetImpower assetImpower)
{
return toAjax(assetImpowerService.updateAssetImpower(assetImpower));
}
/**
*
*/
@RequiresPermissions("etl:impower:remove")
@Log(title = "资产赋权", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(assetImpowerService.deleteAssetImpowerByIds(ids));
}
/**
*
*/
@RequiresPermissions("etl:impower:list")
@Log(title = "资产赋权", businessType = BusinessType.DELETE)
@DeleteMapping("getPowerByTableId/{tableId}")
public Result getPowerByTableId(@PathVariable Long tableId)
{
return Result.success(assetImpowerService.getPowerByTableId(tableId));
}
}

View File

@ -10,11 +10,11 @@ import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.etl.domain.AssetDataDict;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.DictInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.resp.BasicDictResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import com.muyu.etl.service.AssetDataDictService;
import com.muyu.etl.service.BasicConfigInfoService;
import com.muyu.etl.service.DictInfoService;
import com.muyu.etl.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -36,7 +36,12 @@ public class BasicConfigInfoController extends BaseController {
@Autowired
private AssetDataDictService assetDataDictService;
@Autowired
private TableInfoService tableInfoService;
@Autowired
private DictInfoService dictInfoService;
@Autowired
private StructureService structureService;
/**
*
*/
@ -109,12 +114,16 @@ public class BasicConfigInfoController extends BaseController {
return toAjax(basicConfigInfoService.connectionTest(basicConfigInfo));
}
@RequiresPermissions("etl:info:test")
@Log(title = "获取成功链接中的")
@GetMapping("/dataConstruct")
public Result<TableDataInfo<List>> getData() {
return getDataTable(basicConfigInfoService.getDataByEtl());
}
// /**
// * 获取成功链接中的
// * @return
// */
// @RequiresPermissions("etl:info:test")
// @Log(title = "获取成功链接中的")
// @GetMapping("/dataConstruct")
// public Result<TableDataInfo<List>> getData() {
// return getDataTable(basicConfigInfoService.getDataByEtl());
// }
/**
*
@ -129,7 +138,7 @@ public class BasicConfigInfoController extends BaseController {
}
/**
*
* id
*
* @return
*/
@ -140,8 +149,22 @@ public class BasicConfigInfoController extends BaseController {
return Result.success(assetDataDictService.getDict(basicId));
}
/**
* tableId
*
* @return
*/
@Log(title = "描述")
@GetMapping("/getTableInfo/{tableId}")
public Result<TableInfoStructureResp> getTableInfo(@PathVariable Long tableId) {
return Result.success(basicConfigInfoService.getTableInfo(tableId));
}
/**
*
*
* @param assetDataDict
* @return
*/
@ -151,17 +174,42 @@ public class BasicConfigInfoController extends BaseController {
public Result insertDictInfo(@RequestBody AssetDataDict assetDataDict) throws ServletException {
return Result.success(assetDataDictService.insertAssetDataDict(assetDataDict));
}
/**
/**
*
*
* @return
*/
@RequiresPermissions("etl:table:list")
@RequiresPermissions("etl:table:add")
@Log(title = "添加字典表")
@PostMapping("/insertDictInfo")
public Result insertDict(@RequestBody DictInfo dictInfo) throws ServletException {
return Result.success(dictInfoService.insertDictInfo(dictInfo));
}
/**
*
*
* @return
*/
@RequiresPermissions("etl:table:list")
@Log(title = "获取具体表的所有基础信息")
@GetMapping("/getBasicTableInfo/{tableId}")
public Result getBasicTableInfo(@PathVariable Long tableId) throws ServletException {
return Result.success(basicConfigInfoService.getBasicTableInfo(tableId));
}
/**
*
*
* @return
*/
@RequiresPermissions("etl:table:update")
@Log(title = "修改资产结构中字典信息")
@PutMapping("/updateStructureInfo")
public Result updateStructureInfo(@RequestBody Structure structure) {
return Result.success(structureService.updateStructureInfoDict(structure), "修改成功");
}
// /**
// * 模板

View File

@ -0,0 +1,63 @@
package com.muyu.etl.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.etl.domain.AssetImpower;
/**
* Mapper
*
* @author Saisai
* @date 2024-04-28
*/
public interface AssetImpowerMapper extends BaseMapper<AssetImpower>
{
/**
*
*
* @param id
* @return
*/
public AssetImpower selectAssetImpowerById(Long id);
/**
*
*
* @param assetImpower
* @return
*/
public List<AssetImpower> selectAssetImpowerList(AssetImpower assetImpower);
/**
*
*
* @param assetImpower
* @return
*/
public int insertAssetImpower(AssetImpower assetImpower);
/**
*
*
* @param assetImpower
* @return
*/
public int updateAssetImpower(AssetImpower assetImpower);
/**
*
*
* @param id
* @return
*/
public int deleteAssetImpowerById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteAssetImpowerByIds(Long[] ids);
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.AssetDataDict;
import com.muyu.etl.domain.resp.BasicDictResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import javax.servlet.ServletException;
@ -65,4 +66,5 @@ public interface AssetDataDictService extends IService<AssetDataDict>
public int deleteAssetDataDictById(Long id);
List<BasicDictResp> getDict(Long basicId);
}

View File

@ -0,0 +1,65 @@
package com.muyu.etl.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.AssetImpower;
/**
* Service
*
* @author Saisai
* @date 2024-04-28
*/
public interface AssetImpowerService extends IService<AssetImpower>
{
/**
*
*
* @param id
* @return
*/
public AssetImpower selectAssetImpowerById(Long id);
/**
*
*
* @param assetImpower
* @return
*/
public List<AssetImpower> selectAssetImpowerList(AssetImpower assetImpower);
/**
*
*
* @param assetImpower
* @return
*/
public int insertAssetImpower(AssetImpower assetImpower);
/**
*
*
* @param assetImpower
* @return
*/
public int updateAssetImpower(AssetImpower assetImpower);
/**
*
*
* @param ids
* @return
*/
public int deleteAssetImpowerByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteAssetImpowerById(Long id);
List<AssetImpower> getPowerByTableId(Long tableId);
}

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.resp.BasicTableInfoResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import javax.servlet.ServletException;
@ -67,7 +69,11 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo>
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
List getDataByEtl();
// List getDataByEtl();
List<TableTreeResp> getTableTree();
TableInfoStructureResp getTableInfo(Long tableId);
BasicTableInfoResp getBasicTableInfo(Long tableId);
}

View File

@ -60,4 +60,6 @@ public interface StructureService extends IService<Structure>
* @return
*/
public int deleteStructureById(Long id);
boolean updateStructureInfoDict(Structure structure);
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
/**
* Service

View File

@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.etl.domain.DictInfo;
import com.muyu.etl.domain.resp.BasicDictResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.service.DictInfoService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
@ -71,11 +72,10 @@ public class AssetDataDictServiceImpl extends ServiceImpl<AssetDataDictMapper, A
if (one!=null){
throw new ServletException("该字典已存在");
}
boolean b = this.saveOrUpdate(assetDataDict, new LambdaUpdateWrapper<AssetDataDict>(AssetDataDict.class) {{
return this.saveOrUpdate(assetDataDict, new LambdaUpdateWrapper<AssetDataDict>(AssetDataDict.class) {{
eq(AssetDataDict::getDictType,assetDataDict.getDictType());
eq(AssetDataDict::getBasicId,assetDataDict.getBasicId());
}});
return b;
}
/**
@ -134,4 +134,6 @@ public class AssetDataDictServiceImpl extends ServiceImpl<AssetDataDictMapper, A
}).collect(Collectors.toList());
return collect;
}
}

View File

@ -0,0 +1,161 @@
package com.muyu.etl.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.etl.domain.AssetImpower;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.mapper.AssetImpowerMapper;
import com.muyu.etl.service.AssetImpowerService;
import com.muyu.etl.service.TableInfoService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
* @author Saisai
* @date 2024-04-28
*/
@Service
@Log4j2
public class AssetImpowerServiceImpl extends ServiceImpl<AssetImpowerMapper, AssetImpower> implements AssetImpowerService {
@Autowired
private AssetImpowerMapper assetImpowerMapper;
@Autowired
private TableInfoService tableInfoService;
@Autowired
private RemoteUserService remoteUserService;
/**
*
*
* @param id
* @return
*/
@Override
public AssetImpower selectAssetImpowerById(Long id) {
return assetImpowerMapper.selectAssetImpowerById(id);
}
/**
*
*
* @param assetImpower
* @return
*/
@Override
public List<AssetImpower> selectAssetImpowerList(AssetImpower assetImpower) {
return assetImpowerMapper.selectAssetImpowerList(assetImpower);
}
/**
*
*
* @param assetImpower
* @return
*/
@Override
public int insertAssetImpower(AssetImpower assetImpower) {
List<AssetImpower> rows = new ArrayList<>();
assetImpower.setCreateTime(DateUtils.getNowDate());
//创建一个部门容器和用户容器
List<SysDept> deptList = remoteUserService.list(new SysDept(), SecurityConstants.INNER).getData();
System.out.println(remoteUserService.list(new SysDept(), SecurityConstants.INNER));
//单表单个用户赋权
if (assetImpower.getTableId() != null && assetImpower.getUserId() != null) {
rows.add(assetImpower);
}
//单表多用户赋权
if (assetImpower.getTableId() != null) {
//根据id过滤部门
SysDept dept = remoteUserService.getInfo(assetImpower.getDeptId(), SecurityConstants.INNER).getData();
deptList.addAll(getChildSysDept(deptList, dept));
List<AssetImpower> finalRows = rows;
deptList.stream().distinct().forEach(sysDept -> {
//该部门下的用户列表
remoteUserService.list(new SysUser() {{
setDeptId(sysDept.getDeptId());
}}, SecurityConstants.INNER).getData()
.forEach(sysUser -> finalRows.add(AssetImpower.saveAssetImpower(sysDept.getDeptId(), sysUser.getUserId(), assetImpower)));
});
rows = rows.stream().distinct().toList();
}
//多表单用户赋权
if (assetImpower.getUserId() != null) {
List<TableInfo> tableInfoList = tableInfoService.selectTableInfoList(new TableInfo() {{
setBasicId(assetImpower.getBasicId());
}});
List<AssetImpower> finalRows = rows;
tableInfoList.forEach(tableInfo -> finalRows.add(AssetImpower.saveAssetImpower(
assetImpower.getDeptId(), assetImpower.getUserId(), new AssetImpower() {{
setBasicId(assetImpower.getBasicId());
setTableId(tableInfo.getId());
}})));
}
boolean b = this.saveBatch(rows);
return 1;
}
//递归获取子级部门
public List<SysDept> getChildSysDept(List<SysDept> deptList, SysDept sysDept) {
List<SysDept> list = new ArrayList<>();
List<SysDept> deptChildList = new ArrayList<>(deptList);
list.addAll(deptChildList.stream()
.distinct()
.filter(dept -> dept.getParentId().equals(sysDept.getDeptId())).toList());
if (!list.isEmpty()) {
list.forEach(sysDeptChild -> deptChildList.addAll(this.getChildSysDept(deptChildList, sysDeptChild)));
}
return list;
}
/**
*
*
* @param assetImpower
* @return
*/
@Override
public int updateAssetImpower(AssetImpower assetImpower) {
assetImpower.setUpdateTime(DateUtils.getNowDate());
return assetImpowerMapper.updateAssetImpower(assetImpower);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteAssetImpowerByIds(Long[] ids) {
return assetImpowerMapper.deleteAssetImpowerByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteAssetImpowerById(Long id) {
return assetImpowerMapper.deleteAssetImpowerById(id);
}
@Override
public List<AssetImpower> getPowerByTableId(Long tableId) {
return this.selectAssetImpowerList(new AssetImpower() {{
setTableId(tableId);
}});
}
}

View File

@ -7,6 +7,7 @@ import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.domain.resp.BasicTableInfoResp;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import com.muyu.etl.mapper.BasicConfigInfoMapper;
@ -17,11 +18,16 @@ import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletException;
import java.sql.*;
import java.util.Date;
import java.util.*;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
/**
@ -32,8 +38,7 @@ import java.util.stream.Collectors;
*/
@Service
@Log4j2
public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapper, BasicConfigInfo> implements BasicConfigInfoService
{
public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapper, BasicConfigInfo> implements BasicConfigInfoService {
@Autowired
private BasicConfigInfoMapper basicConfigInfoMapper;
@ -51,8 +56,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
* @return
*/
@Override
public BasicConfigInfo selectBasicConfigInfoById(Long id)
{
public BasicConfigInfo selectBasicConfigInfoById(Long id) {
return basicConfigInfoMapper.selectBasicConfigInfoById(id);
}
@ -63,8 +67,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
* @return
*/
@Override
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo)
{
public List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo) {
return basicConfigInfoMapper.selectBasicConfigInfoList(basicConfigInfo);
}
@ -75,8 +78,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
* @return
*/
@Override
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq)
{
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq) {
return basicConfigInfoMapper.insertBasicConfigInfo(configQueryReq);
}
@ -87,8 +89,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
* @return
*/
@Override
public int updateBasicConfigInfo(BasicConfigInfo configQueryReq)
{
public int updateBasicConfigInfo(BasicConfigInfo configQueryReq) {
return basicConfigInfoMapper.updateBasicConfigInfo(configQueryReq);
}
@ -99,8 +100,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
* @return
*/
@Override
public int deleteBasicConfigInfoByIds(Long[] ids)
{
public int deleteBasicConfigInfoByIds(Long[] ids) {
return basicConfigInfoMapper.deleteBasicConfigInfoByIds(ids);
}
@ -111,93 +111,135 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
* @return
*/
@Override
public int deleteBasicConfigInfoById(Long id)
{
public int deleteBasicConfigInfoById(Long id) {
return basicConfigInfoMapper.deleteBasicConfigInfoById(id);
}
/**
*
*
* @param basicConfigInfo
* @return
* @throws ServletException
*/
@Override
@Transactional
public boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException {
//定义下面需要的对象
String host = basicConfigInfo.getHost();
String port = basicConfigInfo.getPort();
String databaseName = basicConfigInfo.getDatabaseName();
String databaseType = basicConfigInfo.getDatabaseType();
String url = "jdbc:"+databaseType+"://"+host+":"+port+"/"+databaseName+"?"+basicConfigInfo.getConnectionParams();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
String user = basicConfigInfo.getUsername();
String password = basicConfigInfo.getPassword();
Connection conn= null;
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
System.out.println("Connected to the MySQL server successfully.");
//同步数据库信息
//树级结构,库,表
TableInfo tableInfo = TableInfo.builder()
.basicId(basicConfigInfo.getId())
.parentId(0L)
.tableRemark("")
TableInfo tableInfoInsert = TableInfo.builder()
.basicId(basicConfigInfo.getId())
.parentId(0L)
.tableRemark("")
.center("Y")
.tableName(basicConfigInfo.getDataSourcesSystemName() + "(" + databaseName + ")")
.createBy(SecurityUtils.getUsername())
.createTime(new Date())
.build();
tableInfoService.saveOrUpdate(tableInfo,new LambdaUpdateWrapper<TableInfo>(TableInfo.class){{
eq(TableInfo::getTableName,tableInfo.getTableName());
eq(TableInfo::getBasicId,basicConfigInfo.getId());
.type("dataSource")
.tableName(basicConfigInfo.getDataSourcesSystemName() + "(" + databaseName + ")")
.createBy(SecurityUtils.getUsername())
.createTime(new Date())
.build();
tableInfoService.saveOrUpdate(tableInfoInsert, new LambdaUpdateWrapper<TableInfo>(TableInfo.class) {{
eq(TableInfo::getTableName, tableInfoInsert.getTableName());
eq(TableInfo::getBasicId, basicConfigInfo.getId());
}});
//查询列表中的所有tableInfo basic_id 不存在删除
//通过查询或去当前tableinfo对象的id
TableInfo tableInfo = tableInfoService.selectTableInfoByName(tableInfoInsert);
DatabaseMetaData metaData = conn.getMetaData();
ResultSet rs = metaData.getTables(databaseName,
null, "%", new String[]{"TABLE", "VIEW"});
while (rs.next()) {
//表名
String tableName1 = rs.getString("TABLE_NAME");
String tableRemark = rs.getString("REMARKS");
Connection finalConn = conn;
PreparedStatement ps = conn.prepareStatement("select* from " + tableName1);
ResultSet rset = ps.executeQuery();
Long rowCount = 0L;
while(rset.next()) {rowCount++;}
TableInfo build = TableInfo.builder()
.basicId(basicConfigInfo.getId())
.tableName(tableName1)
.tableRemark(tableRemark.isEmpty()? "null":tableRemark)
.parentId(tableInfo.getId())
.center("Y")
.updateBy(SecurityUtils.getUsername())
.dataNum(rowCount)
.updateTime(new Date())
.build();
tableInfoService.saveOrUpdate(build,new LambdaUpdateWrapper<TableInfo>(TableInfo.class){{
eq(TableInfo::getTableName,build.getTableName());
eq(TableInfo::getBasicId,basicConfigInfo.getId());
}});
TableInfo table = tableInfoService.selectTableInfoByName(build);
Runnable thread = new Runnable() {
@SneakyThrows
@Override
public void run() {
try {
syncData(finalConn, databaseName, table);
} catch (SQLException e) {
throw new ServletException("连接失败");
}
}
};
thread.run();
while (rs.next()) {
//表名
String tableName = rs.getString("TABLE_NAME");
String tableRemark = rs.getString("REMARKS");
Connection finalConn = conn;
PreparedStatement ps = conn.prepareStatement("select * from " + tableName);
ResultSet rset = ps.executeQuery();
Long rowCount = 0L;
while (rset.next()) {
rowCount++;
}
TableInfo build = TableInfo.builder()
.basicId(basicConfigInfo.getId())
.tableName(tableName)
//bug点tableRemark为空造成空指针异常
.tableRemark(tableRemark == null ? "" : tableRemark)
.parentId(tableInfo.getId())
.type("dataTable")
.center("Y")
.updateBy(SecurityUtils.getUsername())
.dataNum(rowCount)
.updateTime(new Date())
.build();
tableInfoService.saveOrUpdate(build, new LambdaUpdateWrapper<>(TableInfo.class) {{
eq(TableInfo::getTableName, build.getTableName());
eq(TableInfo::getBasicId, basicConfigInfo.getId());
}});
TableInfo table = tableInfoService.selectTableInfoByName(build);
//线程池
ExecutorService threadPool = Executors.newCachedThreadPool();
threadPool.submit(() -> {
try {
syncData(finalConn, databaseName, table);
} catch (SQLException e) {
try {
throw new ServletException("同步数据失败");
} catch (ServletException ex) {
throw new RuntimeException(ex.getMessage());
}
}
});
Runnable thread = new Runnable() {
@SneakyThrows
@Override
public void run() {
try {
//同步
syncData(finalConn, databaseName, table);
} catch (SQLException e) {
log.error(e.getMessage());
throw new ServletException("连接失败");
}
}
};
thread.run();
ps.close();
}
conn.close();
} catch (SQLException e) {
log.error(e.getMessage());
throw new ServletException("连接失败");
}
return true;
}
public void syncData (Connection conn, String databaseName, TableInfo table) throws SQLException {
/**
*
*
* @param conn
* @param databaseName
* @param table
* @throws SQLException
*/
public void syncData(Connection conn, String databaseName, TableInfo table) throws SQLException {
ExecutorService threadPool = Executors.newCachedThreadPool();
PreparedStatement ps = conn.prepareStatement(
" SELECT " +
" COLUMN_NAME AS '字段', " +
" COLUMN_COMMENT AS '字段注释', " +
" CASE WHEN COLUMN_KEY = 'PRI' THEN '是' ELSE '否' END AS '是否主键'," +
" SELECT " +
" COLUMN_NAME , " +
" COLUMN_COMMENT ," +
" CASE WHEN COLUMN_KEY = 'PRI' THEN '是' ELSE '否' END ," +
" CASE \n" +
" WHEN DATA_TYPE = 'int' THEN 'Integer' " +
" WHEN DATA_TYPE = 'bigint' THEN 'Long' " +
@ -205,13 +247,13 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
" WHEN DATA_TYPE = 'decimal' THEN 'BigDecimal' " +
" WHEN DATA_TYPE = 'tinyint' AND COLUMN_TYPE = 'tinyint(1)' THEN 'Boolean'" +
" ELSE DATA_TYPE -- 如果无法映射,则返回原始数据库类型 \n" +
" END AS 'Java类型', " +
" DATA_TYPE AS '数据库类型', -- 原始的数据库类型 \n" +
" COLUMN_TYPE AS '详细的数据库类型', -- 更详细的数据库类型,可能包含长度、精度等 \n" +
" CHARACTER_MAXIMUM_LENGTH AS '长度', \n" +
" NUMERIC_SCALE AS '小数位', \n" +
" IS_NULLABLE AS '是否为空', \n" +
" COLUMN_DEFAULT AS '默认值' \n" +
" END , " +
" DATA_TYPE , -- 原始的数据库类型 \n" +
" COLUMN_TYPE , -- 更详细的数据库类型,可能包含长度、精度等 \n" +
" CHARACTER_MAXIMUM_LENGTH , \n" +
" NUMERIC_SCALE , \n" +
" IS_NULLABLE , \n" +
" COLUMN_DEFAULT \n" +
"FROM INFORMATION_SCHEMA.COLUMNS WHERE \n" +
"TABLE_SCHEMA = '" + databaseName + "' -- 替换为你的数据库名称 \n" +
"AND TABLE_NAME = '" + table.getTableName() + "'");
@ -220,117 +262,149 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
// NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS
// WHERE TABLE_SCHEMA = '数据库名' AND TABLE_NAME = '表名'"
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()){
String columnName = String.valueOf( resultSet.getString(1));
String columnComment = String.valueOf( resultSet.getObject(2));
String columnKey = String.valueOf( resultSet.getObject(3));
String end = String.valueOf( resultSet.getObject(4));
String dataType = String.valueOf( resultSet.getObject(5));
String columnType = String.valueOf( resultSet.getObject(6));
while (resultSet.next()) {
String columnName = String.valueOf(resultSet.getString(1));
String columnComment = String.valueOf(resultSet.getObject(2));
String columnKey = String.valueOf(resultSet.getObject(3));
String end = String.valueOf(resultSet.getObject(4));
String dataType = String.valueOf(resultSet.getObject(5));
String columnType = String.valueOf(resultSet.getObject(6));
String characterMaximumLength = String.valueOf(resultSet.getInt(7));
String NumericScale = String.valueOf(resultSet.getInt(8));
String isNullable = String.valueOf( resultSet.getObject(9));
String columnDefault = String.valueOf( resultSet.getObject(10));
String isNullable = String.valueOf(resultSet.getObject(9));
String columnDefault = String.valueOf(resultSet.getObject(10));
Structure build = Structure.builder()
.tableId(table.getId())
.columnName(String.valueOf(columnName))
.columnRemark(columnComment)
.isPrimary("是".equals(columnKey) ? "Y" : "N")
.javaType( end)
.columnType( dataType)
.javaType(end)
.columnType(dataType)
.columnType(columnType)
.columnLength(characterMaximumLength)
.columnDecimals( NumericScale)
.columnDecimals(NumericScale)
.isNull("YES".equals(isNullable) ? "Y" : "N")
.defaultValue( columnDefault)
.defaultValue(columnDefault)
.build();
structureService.saveOrUpdate(build,new LambdaUpdateWrapper<Structure>(){{
eq(Structure::getTableId,build.getTableId());
eq(Structure::getColumnName,build.getColumnName());
eq(Structure::getColumnRemark,build.getColumnRemark());
}});
threadPool.submit(() -> {
structureService.saveOrUpdate(build, new LambdaUpdateWrapper<Structure>() {{
eq(Structure::getTableId, build.getTableId());
eq(Structure::getColumnName, build.getColumnName());
eq(Structure::getColumnRemark, build.getColumnRemark());
}});
});
}
}
/**
*
* @return
*/
@Override
public List getDataByEtl() {
List<BasicConfigInfo> list = this.list();
List<Map<String,List<String>>> mapList = new ArrayList<>();
for (BasicConfigInfo info : list) {
//定义下面需要的对象
String url = "jdbc:" + info.getDatabaseType() + "://" + info.getHost() + ":" + info.getPort() + "/" + info.getDatabaseName() + "";
String user = info.getUsername();
String password = info.getPassword();
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
DatabaseMetaData metaData = conn.getMetaData();
ResultSet resultSet = metaData.getCatalogs();
while (resultSet.next()){
//库名
String catalogs = resultSet.getString("TABLE_CAT");
log.info(catalogs);
// 获取表名
ResultSet rs = metaData.getTables(info.getDatabaseName(),null, "%", new String[]{"TABLE", "VIEW"});
try {
ArrayList<String> tableName = new ArrayList<>();
while (rs.next()) {
//表名
String tableName1 = rs.getString("TABLE_NAME");
tableName.add( rs.getString("TABLE_NAME"));
}
mapList.add(new HashMap<>(){{
//库名,表名
put(catalogs,tableName);
}});
}catch (Exception exception){
continue;
}
}
} catch (Exception e){
log.error(e.getMessage());
continue;
}
}
return mapList;
threadPool.shutdown();
ps.close();
}
/**
*
*
* @return
*/
@Override
public List<TableTreeResp> getTableTree() {
List<TableTreeResp> tableTreeRespList = tableInfoService.selectTableInfoList(new TableInfo(){{setParentId(0L);}}).stream().map(tableInfo ->{
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
setParentId(tableInfo.getId());
}}).stream().map(info -> {
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>().eq(Structure::getTableId,info.getId()));
return TableInfoStructureResp.builder()
.id(info.getId())
.tableName(info.getTableName())
.center(info.getCenter())
.tableRemark(info.getTableRemark())
.dataNum(info.getDataNum())
.parentId(info.getParentId())
.databaseType(basicConfigInfo.getDatabaseType())
.structureList(structureList)
.basicId(info.getBasicId())
.build();
}).collect(Collectors.toList());
return TableTreeResp.builder()
.tableInfo(tableInfo)
.basicConfigInfo(basicConfigInfo)
.Children(tableInfoStructureRespList)
ExecutorService threadPool = Executors.newCachedThreadPool();
List<TableTreeResp> tableTreeRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
setParentId(0L);
}}).stream().map(tableInfo -> {
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
setParentId(tableInfo.getId());
}}).stream().map(info -> {
TableInfoStructureResp tableInfoStructureResp = null;
Future<TableInfoStructureResp> submit = threadPool.submit(() -> {
return TableInfoStructureResp.builder()
.id(info.getId())
.tableName(info.getTableName())
.center(info.getCenter())
.tableRemark(info.getTableRemark())
.type(info.getType())
.dataNum(info.getDataNum())
.parentId(info.getParentId())
.databaseType(basicConfigInfo.getDatabaseType())
.structureList(null)
.basicId(info.getBasicId())
.build();
}).collect(Collectors.toList());
});
try {
tableInfoStructureResp = submit.get();
} catch (Exception e) {
log.error(e.getMessage());
throw new RuntimeException(e);
}
return tableInfoStructureResp;
}).collect(Collectors.toList());
return TableTreeResp.builder()
.tableInfo(tableInfo)
.basicConfigInfo(basicConfigInfo)
.Children(tableInfoStructureRespList)
.build();
}).collect(Collectors.toList());
threadPool.shutdown();
while (true) if (threadPool.isTerminated()) break;
return tableTreeRespList;
}
}
@Override
public TableInfoStructureResp getTableInfo(Long tableId) {
TableInfo tableInfo = tableInfoService.selectTableInfoById(tableId);
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>()
.eq(Structure::getTableId, tableInfo.getId()));
return TableInfoStructureResp.builder()
.id(tableInfo.getId())
.tableName(tableInfo.getTableName())
.center(tableInfo.getCenter())
.tableRemark(tableInfo.getTableRemark())
.dataNum(tableInfo.getDataNum())
.parentId(tableInfo.getParentId())
.databaseType(basicConfigInfo.getDatabaseType())
.structureList(structureList)
.basicId(tableInfo.getBasicId())
.build();
}
@Override
public BasicTableInfoResp getBasicTableInfo(Long tableId) {
TableInfo tableInfo = tableInfoService.selectTableInfoById(tableId);
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
String host = basicConfigInfo.getHost();
String port = basicConfigInfo.getPort();
String databaseName = basicConfigInfo.getDatabaseName();
String databaseType = basicConfigInfo.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
String user = basicConfigInfo.getUsername();
String password = basicConfigInfo.getPassword();
Long totalNum = null;
BasicTableInfoResp basicTableInfoResp = null;
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
PreparedStatement ps = conn.prepareStatement("select Count(0) from " + tableInfo.getTableName());
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()){
String a = String.valueOf(resultSet.getObject(1));
totalNum = resultSet.getLong(1);
}
basicTableInfoResp = BasicTableInfoResp.builder()
.dataResourceName(basicConfigInfo.getDataResourceName())
.dataSourcesSystemName(basicConfigInfo.getDataSourcesSystemName())
.databaseName(basicConfigInfo.getDatabaseName())
.tableName(tableInfo.getTableName())
.tableRemark(tableInfo.getTableRemark())
.id(tableId)
.basicId(basicConfigInfo.getId())
.totalNum(totalNum)
.build();
ps.close();
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
return basicTableInfoResp;
}
}

View File

@ -97,4 +97,12 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
{
return structureMapper.deleteStructureById(id);
}
@Override
public boolean updateStructureInfoDict(Structure structure) {
if ("N".equals(structure.getIsDictionary())){
structure.setDictionaryTable("");
}
return this.saveOrUpdate(structure);
}
}

View File

@ -1,9 +1,16 @@
package com.muyu.etl.service.impl;
import java.util.List;
import java.util.concurrent.Future;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.service.BasicConfigInfoService;
import com.muyu.etl.service.StructureService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -19,10 +26,12 @@ import com.muyu.etl.service.TableInfoService;
*/
@Log4j2
@Service
public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> implements TableInfoService
{
public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableInfo> implements TableInfoService {
@Autowired
private TableInfoMapper tableInfoMapper;
@Autowired
private StructureService structureService;
/**
*
@ -31,8 +40,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
* @return
*/
@Override
public TableInfo selectTableInfoById(Long id)
{
public TableInfo selectTableInfoById(Long id) {
return tableInfoMapper.selectTableInfoById(id);
}
@ -43,8 +51,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
* @return
*/
@Override
public List<TableInfo> selectTableInfoList(TableInfo tableInfo)
{
public List<TableInfo> selectTableInfoList(TableInfo tableInfo) {
return tableInfoMapper.selectTableInfoList(tableInfo);
}
@ -55,8 +62,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
* @return
*/
@Override
public int insertTableInfo(TableInfo tableInfo)
{
public int insertTableInfo(TableInfo tableInfo) {
tableInfo.setCreateTime(DateUtils.getNowDate());
return tableInfoMapper.insertTableInfo(tableInfo);
}
@ -68,8 +74,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
* @return
*/
@Override
public int updateTableInfo(TableInfo tableInfo)
{
public int updateTableInfo(TableInfo tableInfo) {
tableInfo.setUpdateTime(DateUtils.getNowDate());
return tableInfoMapper.updateTableInfo(tableInfo);
}
@ -81,8 +86,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
* @return
*/
@Override
public int deleteTableInfoByIds(Long[] ids)
{
public int deleteTableInfoByIds(Long[] ids) {
return tableInfoMapper.deleteTableInfoByIds(ids);
}
@ -93,8 +97,7 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
* @return
*/
@Override
public int deleteTableInfoById(Long id)
{
public int deleteTableInfoById(Long id) {
return tableInfoMapper.deleteTableInfoById(id);
}
@ -102,4 +105,6 @@ public class TableInfoServiceImpl extends ServiceImpl<TableInfoMapper, TableIn
public TableInfo selectTableInfoByName(TableInfo table) {
return tableInfoMapper.selectTableInfoByName(table);
}
}

View File

@ -0,0 +1,90 @@
<?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">
<mapper namespace="com.muyu.etl.mapper.AssetImpowerMapper">
<resultMap type="com.muyu.etl.domain.AssetImpower" id="AssetImpowerResult">
<result property="id" column="id" />
<result property="basicId" column="basic_id" />
<result property="tableId" column="table_id" />
<result property="deptId" column="dept_id" />
<result property="userId" column="user_id" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectAssetImpowerVo">
select id,basic_id , table_id, dept_id, user_id, remark, create_by, create_time, update_by, update_time from asset_impower
</sql>
<select id="selectAssetImpowerList" parameterType="com.muyu.etl.domain.AssetImpower" resultMap="AssetImpowerResult">
<include refid="selectAssetImpowerVo"/>
<where>
<if test="tableId != null "> and table_id = #{tableId}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
</where>
</select>
<select id="selectAssetImpowerById" parameterType="Long" resultMap="AssetImpowerResult">
<include refid="selectAssetImpowerVo"/>
where id = #{id}
</select>
<insert id="insertAssetImpower" parameterType="com.muyu.etl.domain.AssetImpower" useGeneratedKeys="true" keyProperty="id">
insert into asset_impower
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="basicId != null">basic_id,</if>
<if test="tableId != null">table_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="userId != null">user_id,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="basicId != null">#{basicId},</if>
<if test="tableId != null">#{tableId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="userId != null">#{userId},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateAssetImpower" parameterType="com.muyu.etl.domain.AssetImpower">
update asset_impower
<trim prefix="SET" suffixOverrides=",">
<if test="basicId != null">basic_id = #{basicId},</if>
<if test="tableId != null">table_id = #{tableId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAssetImpowerById" parameterType="Long">
delete from asset_impower where id = #{id}
</delete>
<delete id="deleteAssetImpowerByIds" parameterType="String">
delete from asset_impower where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -72,10 +72,10 @@
<if test="dataSourcesSystemName != null">#{dataSourcesSystemName},</if>
<if test="host != null">#{host},</if>
<if test="port != null">#{port},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="databaseType != null">#{databaseType},</if>
<if test="databaseName != null">#{databaseName},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="initLinkNum != null">#{initLinkNum},</if>
<if test="maxLinkNum != null">#{maxLinkNum},</if>
<if test="maxWaitTime != null">#{maxWaitTime},</if>

View File

@ -12,6 +12,7 @@
<result property="tableRemark" column="table_remark" />
<result property="dataNum" column="data_num" />
<result property="center" column="center" />
<result property="type" column="type" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -20,18 +21,18 @@
</resultMap>
<sql id="selectTableInfoVo">
select id, parent_id, basic_id,table_name, table_remark, data_num, center, remark, create_by, create_time, update_by, update_time from table_info
select id, parent_id,type, basic_id,table_name, table_remark, data_num, center, remark, create_by, create_time, update_by, update_time from table_info
</sql>
<select id="selectTableInfoList" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
<include refid="selectTableInfoVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="basicId != null "> and basic_id = #{basicId}</if>
<if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if>
<if test="tableRemark != null and tableRemark != ''"> and table_remark = #{tableRemark}</if>
<if test="dataNum != null "> and data_num = #{dataNum}</if>
<if test="center != null and center != ''"> and center = #{center}</if>
<if test="parentId != null ">and parent_id = #{parentId}</if>
<if test="basicId != null ">and basic_id = #{basicId}</if>
<if test="tableName != null and tableName != ''">and table_name like concat('%', #{tableName}, '%')</if>
<if test="tableRemark != null and tableRemark != ''">and table_remark = #{tableRemark}</if>
<if test="dataNum != null ">and data_num = #{dataNum}</if>
<if test="center != null and center != ''">and center = #{center}</if>
</where>
</select>
@ -42,8 +43,8 @@
<select id="selectTableInfoByName" parameterType="com.muyu.etl.domain.TableInfo" resultMap="TableInfoResult">
select * from table_info
where basic_id = #{basicId} and table_name = #{tableName}
</select>
where basic_id = #{basicId} and (table_name = #{tableName} or parent_id = #{parentId})
</select>
<insert id="insertTableInfo" parameterType="com.muyu.etl.domain.TableInfo" useGeneratedKeys="true" keyProperty="id">
@ -51,6 +52,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="basicId != null">basic_id,</if>
<if test="type != null and type != ''">type,</if>
<if test="tableName != null and tableName != ''">table_name,</if>
<if test="tableRemark != null and tableRemark != ''">table_remark,</if>
<if test="dataNum != null">data_num,</if>
@ -64,6 +66,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="basicId != null">#{basicId},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="tableName != null and tableName != ''">#{tableName},</if>
<if test="tableRemark != null and tableRemark != ''">#{tableRemark},</if>
<if test="dataNum != null">#{dataNum},</if>
@ -81,6 +84,7 @@
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="basicId != null">basic_id = #{basicId},</if>
<if test="type != null">type = #{type},</if>
<if test="tableName != null and tableName != ''">table_name = #{tableName},</if>
<if test="tableRemark != null and tableRemark != ''">table_remark = #{tableRemark},</if>
<if test="dataNum != null">data_num = #{dataNum},</if>

View File

@ -14,6 +14,7 @@
<module>muyu-job</module>
<module>muyu-file</module>
<module>muyv-etl</module>
<module>muyu-ruleEngine</module>
</modules>
<artifactId>muyu-modules</artifactId>

View File

@ -213,6 +213,13 @@
<version>${muyu.version}</version>
</dependency>
<!-- 规则引擎 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-ruleEngine-common</artifactId>
<version>${muyu.version}</version>
</dependency>
</dependencies>
</dependencyManagement>