初始代码

This commit is contained in:
wangmingwei
2026-04-21 16:49:46 +08:00
parent aae9dc4036
commit f0453ff3a3
2396 changed files with 256575 additions and 0 deletions

50
yunzhupaas-system/pom.xml Normal file
View File

@@ -0,0 +1,50 @@
<?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">
<parent>
<artifactId>yunzhupaas-java-boot</artifactId>
<groupId>com.yunzhupaas</groupId>
<version>5.2.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yunzhupaas-system</artifactId>
<packaging>pom</packaging>
<modules>
<module>yunzhupaas-system-entity</module>
<module>yunzhupaas-system-biz</module>
<module>yunzhupaas-system-controller</module>
</modules>
<dependencies>
<!-- Apache POI dependencies -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
<!-- Apache POI dependencies for OOXML (.docx) -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<!-- Apache POI dependencies for OLE2 (.doc) -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,60 @@
<?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">
<parent>
<artifactId>yunzhupaas-system</artifactId>
<groupId>com.yunzhupaas</groupId>
<version>5.2.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yunzhupaas-system-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-provider</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-oauth-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-message-entity</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.vertical-blank</groupId>
<artifactId>sql-formatter</artifactId>
</dependency>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-common-ai</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,9 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.AdvancedQueryEntity;
public interface AdvancedQueryMapper extends SuperMapper<AdvancedQueryEntity> {
}

View File

@@ -0,0 +1,13 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.AiChatEntity;
/**
* @author 云筑产品开发平台组
* @version v5.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2025/2/20 17:33:21
*/
public interface AiChatMapper extends SuperMapper<AiChatEntity> {
}

View File

@@ -0,0 +1,13 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.AiHistoryEntity;
/**
* @author 云筑产品开发平台组
* @version v5.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2025/2/20 17:33:21
*/
public interface AiHistoryMapper extends SuperMapper<AiHistoryEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ComFieldsEntity;
/**
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/3/12 15:28
*/
public interface BaseComFieldsMapper extends SuperMapper<ComFieldsEntity> {
}

View File

@@ -0,0 +1,14 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.BaseLangEntity;
/**
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/6/20 10:02:18
*/
public interface BaseLangMapper extends SuperMapper<BaseLangEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.BillRuleEntity;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface BillRuleMapper extends SuperMapper<BillRuleEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.CommonWordsEntity;
/**
* 审批常用语
*
* @author 云筑产品开发平台组
* @version v3.4.6
* @copyrignt 深圳市乐程软件有限公司
* @date 2023-01-06
*/
public interface CommonWordsMapper extends SuperMapper<CommonWordsEntity> {
}

View File

@@ -0,0 +1,18 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.DataInterfaceLogEntity;
/**
* 数据接口调用日志
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2024-06-03
*/
public interface DataInterfaceLogMapper extends SuperMapper<DataInterfaceLogEntity> {
}

View File

@@ -0,0 +1,20 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.DataInterfaceEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/3/12 15:30
*/
@Mapper
public interface DataInterfaceMapper extends SuperMapper<DataInterfaceEntity> {
}

View File

@@ -0,0 +1,18 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.DataInterfaceEntity;
import com.yunzhupaas.base.entity.DataInterfaceUserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @author 云筑产品开发平台组
* @version V3.4.7
* @copyright 深圳市乐程软件有限公司
* @date 2024/9/20 9:22
*/
@Mapper
public interface DataInterfaceUserMapper extends SuperMapper<DataInterfaceUserEntity> {
}

View File

@@ -0,0 +1,18 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.DataInterfaceVariateEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 数据接口
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2024-03-23
*/
@Mapper
public interface DataInterfaceVariateMapper extends SuperMapper<DataInterfaceVariateEntity> {
}

View File

@@ -0,0 +1,20 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.VisualDataMapEntity;
/**
*
* 大屏地图
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-09-26 上午9:18
*/
public interface DataMapMapper extends SuperMapper<VisualDataMapEntity> {
}

View File

@@ -0,0 +1,14 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.DataSetEntity;
/**
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/5/7 9:15:22
*/
public interface DataSetMapper extends SuperMapper<DataSetEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.database.model.entity.DbLinkEntity;
/**
* 数据连接
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DbLinkMapper extends SuperMapper<DbLinkEntity> {
}

View File

@@ -0,0 +1,14 @@
package com.yunzhupaas.base.mapper;
/**
* 数据管理
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DbTableMapper {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.DictionaryDataEntity;
/**
* 字典数据
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DictionaryDataMapper extends SuperMapper<DictionaryDataEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.DictionaryTypeEntity;
/**
* 字典分类
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DictionaryTypeMapper extends SuperMapper<DictionaryTypeEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.InterfaceOauthEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 接口认证
*
* @author 云筑产品开发平台组
* @version V3.4.2
* @copyright 深圳市乐程软件有限公司
* @date 2024/6/8 9:51
*/
@Mapper
public interface InterfaceOauthMapper extends SuperMapper<InterfaceOauthEntity> {
}

View File

@@ -0,0 +1,22 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.MessageTemplateEntity;
/**
* 消息模板
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024年12月8日17:40:37
*/
public interface MessageTemplateMapper extends SuperMapper<MessageTemplateEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleButtonEntity;
/**
* 按钮权限
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleButtonMapper extends SuperMapper<ModuleButtonEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleColumnEntity;
/**
* 列表权限
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleColumnMapper extends SuperMapper<ModuleColumnEntity> {
}

View File

@@ -0,0 +1,20 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeLinkEntity;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeSchemeEntity;
/**
* 数据权限方案
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleDataAuthorizeLinkDataMapper extends SuperMapper<ModuleDataAuthorizeLinkEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeEntity;
/**
* 数据权限配置
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleDataAuthorizeMapper extends SuperMapper<ModuleDataAuthorizeEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeSchemeEntity;
/**
* 数据权限方案
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleDataAuthorizeSchemeMapper extends SuperMapper<ModuleDataAuthorizeSchemeEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.ModuleDataEntity;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleDataMapper extends SuperMapper<ModuleDataEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleFormEntity;
/**
* 表单权限
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleFormMapper extends SuperMapper<ModuleFormEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ModuleEntity;
/**
* 系统功能
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleMapper extends SuperMapper<ModuleEntity> {
}

View File

@@ -0,0 +1,35 @@
package com.yunzhupaas.base.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.yunzhupaas.base.entity.PortalManageEntity;
import com.yunzhupaas.base.model.portalManage.PortalManagePage;
import com.yunzhupaas.base.model.portalManage.PortalManagePageDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 虎门管理
*
* @author 云筑产品开发平台组
* @version V3.4.6
* @copyright 深圳市乐程软件有限公司
* @date 2023.02.17
*/
public interface PortalManageMapper extends SuperMapper<PortalManageEntity> {
@Select("SELECT f_full_name FROM base_portal WHERE F_Id = #{portalId}")
String getPortalFullName(String portalId);
@Select("SELECT f_category FROM base_portal WHERE F_Id = #{portalId}")
String getPortalCategoryId(String portalId);
PageDTO<PortalManagePageDO> selectPortalManageDoPage(PageDTO<PortalManagePageDO> page, @Param("pmPage") PortalManagePage pmPage);
List<PortalManagePageDO> selectPortalManageDoList(@Param("pmPage") PortalManagePage pmPage);
List<PortalManagePageDO> selectPortalBySystemIds(@Param("systemIds") List<String> systemIds, @Param("collect") List<String> collect);
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.yunzhupaas.base.entity.PrintDevEntity;
/**
* 打印模板-mapper
*
* @author 云筑产品开发平台组 YY
* @version V3.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-09-30
*/
public interface PrintDevMapper extends SuperMapper<PrintDevEntity> {
}

View File

@@ -0,0 +1,12 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.yunzhupaas.base.entity.PrintLogEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface PrintLogMapper extends SuperMapper<PrintLogEntity> {
}

View File

@@ -0,0 +1,14 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.PrintVersionEntity;
/**
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/5/6 14:07:21
*/
public interface PrintVersionMapper extends SuperMapper<PrintVersionEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.ProvinceAtlasEntity;
/**
* 行政区划-地图
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2023/09/27
*/
public interface ProvinceAtlasMapper extends SuperMapper<ProvinceAtlasEntity> {
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.ProvinceEntity;
/**
* 行政区划
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ProvinceMapper extends SuperMapper<ProvinceEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.ScheduleLogEntity;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2023/09/27
*/
public interface ScheduleLogMapper extends SuperMapper<ScheduleLogEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.ScheduleNewEntity;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2023/09/27
*/
public interface ScheduleNewMapper extends SuperMapper<ScheduleNewEntity> {
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.ScheduleNewUserEntity;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2023/09/27
*/
public interface ScheduleNewUserMapper extends SuperMapper<ScheduleNewUserEntity> {
}

View File

@@ -0,0 +1,16 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.permission.entity.SignEntity;
/**
* 个人签名
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/28
*/
public interface SignMapper extends SuperMapper<SignEntity> {
}

View File

@@ -0,0 +1,16 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.SignatureEntity;
/**
* 电子签章
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/28
*/
public interface SignatureMapper extends SuperMapper<SignatureEntity> {
}

View File

@@ -0,0 +1,16 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.SignatureUserEntity;
/**
* 电子签章
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/28
*/
public interface SignatureUserMapper extends SuperMapper<SignatureUserEntity> {
}

View File

@@ -0,0 +1,20 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.SmsTemplateEntity;
/**
* @author Administrator
* @description 针对表【base_sms_template】的数据库操作Mapper
* @createDate 2021-12-09 10:12:52
* @Entity generator.domain.SmsTemplate
*/
public interface SmsTemplateMapper extends SuperMapper<SmsTemplateEntity> {
}

View File

@@ -0,0 +1,24 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.SysConfigEntity;
/**
* 系统配置
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface SysconfigMapper extends SuperMapper<SysConfigEntity> {
int deleteFig();
int deleteMpFig();
int deleteQyhFig();
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunzhupaas.base.entity.SystemEntity;
/**
* 系统
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface SystemMapper extends SuperMapper<SystemEntity> {
}

View File

@@ -0,0 +1,15 @@
package com.yunzhupaas.base.mapper;
import com.yunzhupaas.base.entity.VisualKitEntity;
/**
* 表单套件
*
* @author 云筑产品开发平台组
* @version v5.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/8/22 11:03:36
*/
public interface VisualKitMapper extends SuperMapper<VisualKitEntity> {
}

View File

@@ -0,0 +1,27 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.base.entity.AdvancedQueryEntity;
import java.util.List;
/**
*
*
* @author 云筑产品开发平台组
* @version V3.4.2
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2022/5/30
*/
public interface AdvancedQueryService extends SuperService<AdvancedQueryEntity> {
void create(AdvancedQueryEntity advancedQueryEntity);
AdvancedQueryEntity getInfo(String id,String userId);
List<AdvancedQueryEntity> getList(String moduleId, UserInfo userInfo);
}

View File

@@ -0,0 +1,50 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.AiChatEntity;
import com.yunzhupaas.base.model.ai.AiChatVo;
import com.yunzhupaas.base.model.ai.AiForm;
import com.yunzhupaas.base.model.ai.AiHisVo;
import java.util.List;
/**
* ai会话服务
*
* @author 云筑产品开发平台组
* @version v5.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/12/2 10:10:10
*/
public interface AiChatService extends SuperService<AiChatEntity> {
/**
* ai对话发送
*
* @param keyword
*/
String send(String keyword);
/**
* ai会话列表
*/
List<AiChatVo> historyList();
/**
* ai会话记录
*/
List<AiHisVo> historyGet(String id);
/**
* 会话记录保存
*/
String historySave(AiForm form);
/**
* 删除ai会话记录
*
* @param id
*/
void delete(String id);
}

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.AiHistoryEntity;
/**
* ai会话记录服务
*
* @author 云筑产品开发平台组
* @version v5.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/12/2 10:10:10
*/
public interface AiHistoryService extends SuperService<AiHistoryEntity> {
}

View File

@@ -0,0 +1,60 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.BaseLangEntity;
import com.yunzhupaas.base.model.language.BaseLangForm;
import com.yunzhupaas.base.model.language.BaseLangListVO;
import com.yunzhupaas.base.model.language.BaseLangPage;
import java.util.List;
import java.util.Locale;
/**
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/4/28 16:05:49
*/
public interface BaseLangService extends SuperService<BaseLangEntity> {
/**
* 标记翻译列表(使用时)
*
* @param pagination
* @return
*/
BaseLangListVO getList(Pagination pagination);
/**
* 标记翻译列表(管理页面)
*
* @param pagination
* @return
*/
BaseLangListVO list(BaseLangPage pagination);
void create(BaseLangForm form);
void update(BaseLangForm form);
BaseLangForm getInfo(String groupId);
void delete(String groupId);
/**
* 存在则更新,不存在则新增
*
* @param list
*/
void importSaveOrUpdate(List<BaseLangEntity> list);
/**
* 获取语种json
*
* @param locale
* @return
*/
String getLanguageJson(Locale locale);
List<BaseLangEntity> getServerLang(Locale locale);
}

View File

@@ -0,0 +1,147 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.model.billrule.BillRulePagination;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.BillRuleEntity;
import com.yunzhupaas.exception.DataException;
import java.util.List;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface BillRuleService extends SuperService<BillRuleEntity> {
/**
* 列表
*
* @param pagination 条件
* @return 单据规则列表
*/
List<BillRuleEntity> getList(BillRulePagination pagination);
/**
* 列表
*
* @return 单据规则集合
*/
List<BillRuleEntity> getList();
/**
* 信息
*
* @param id 主键值
* @return 单据规则
*/
BillRuleEntity getInfo(String id);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 验证编码
*
* @param enCode 编码
* @param id 主键值
* @return ignore
*/
boolean isExistByEnCode(String enCode, String id);
/**
* 获取流水号
*
* @param enCode 流水编码
* @return ignore
* @throws DataException ignore
*/
String getNumber(String enCode) throws DataException;
/**
* 创建
*
* @param entity 实体对象
*/
void create(BillRuleEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, BillRuleEntity entity);
/**
* 删除
*
* @param entity 实体对象
*/
void delete(BillRuleEntity entity);
/**
* 上移
*
* @param id 主键值
* @return ignore
*/
boolean first(String id);
/**
* 下移
*
* @param id 主键值
* @return ignore
*/
boolean next(String id);
/**
* 获取单据流水号
*
* @param enCode 流水编码
* @param isCache 是否缓存:每个用户会自动占用一个流水号,这个刷新页面也不会跳号
* @return ignore
* @throws DataException ignore
*/
String getBillNumber(String enCode, boolean isCache) throws DataException;
/**
* 使用单据流水号(注意:必须是缓存的单据才可以调用这个方法,否则无效)
*
* @param enCode 流水编码
*/
void useBillNumber(String enCode);
/**
* 单据规则导入
*
* @param entity 实体对象
* @param type
* @return ignore
* @throws DataException ignore
*/
ActionResult ImportData(BillRuleEntity entity, Integer type) throws DataException;
/**
*
*
* @param pagination 根据业务条件
* @return 单据规则列表
*/
List<BillRuleEntity> getListByCategory(String id,Pagination pagination);
}

View File

@@ -0,0 +1,66 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.entity.ComFieldsEntity;
import java.util.List;
/**
* 常用字段
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/3/12 15:31
*/
public interface ComFieldsService extends SuperService<ComFieldsEntity> {
/**
* 获取常用字段列表
*
* @return ignore
*/
List<ComFieldsEntity> getList();
/**
* 获取常用字段
*
* @param id 主键
* @return ignore
*/
ComFieldsEntity getInfo(String id);
/**
* 创建常用字段
*
* @param entity 实体
*/
void create(ComFieldsEntity entity);
/**
* 修改常用字段
*
* @param id 主键
* @param entity 实体
* @return ignore
*/
boolean update(String id, ComFieldsEntity entity);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 删除常用字段
*
* @param entity 实体
*/
void delete(ComFieldsEntity entity);
}

View File

@@ -0,0 +1,60 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.CommonWordsEntity;
import com.yunzhupaas.base.model.commonword.ComWordsPagination;
import java.util.List;
/**
* 审批常用语 Service
*
* @author 云筑产品开发平台组
* @version v3.4.6
* @copyrignt 深圳市乐程软件有限公司
* @date 2023-01-06
*/
public interface CommonWordsService extends SuperService<CommonWordsEntity> {
/**
* 系统常用语列表
*
* @param comWordsPagination 页面对象
* @return 打印实体类
*/
List<CommonWordsEntity> getSysList(ComWordsPagination comWordsPagination, Boolean currentSysFlag);
/**
* 个人常用语列表
*
* @param type 类型
* @return 集合
*/
List<CommonWordsEntity> getListModel(String type);
/**
* 系统是否被使用
*
* @param systemId 系统ID
* @return 返回判断
*/
Boolean existSystem(String systemId);
/**
* 常用语判重
*
* @param id 原id
* @param commonWordsText 常用语
* @return 返回判断
*/
Boolean existCommonWord(String id, String commonWordsText, Integer commonWordsType);
/**
* 添加常用语次数
*
* @param commonWordsText 常用语
* @return 返回判断
*/
void addCommonWordsNum(String commonWordsText);
}

View File

@@ -0,0 +1,55 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.DataInterfaceLogEntity;
import com.yunzhupaas.base.model.InterfaceOauth.PaginationIntrfaceLog;
import java.util.List;
/**
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/3/12 15:31
*/
public interface DataInterfaceLogService extends SuperService<DataInterfaceLogEntity> {
/**
* 添加日志
*
* @param dateInterfaceId 接口Id
* @param invokWasteTime 执行时间
*/
void create(String dateInterfaceId, Integer invokWasteTime);
/**
* 通过权限判断添加日志
*
* @param dateInterfaceId 接口Id
* @param invokWasteTime 执行时间
*/
void create(String dateInterfaceId, Integer invokWasteTime,String appId,String invokType);
/**
* 获取调用日志列表
*
* @param invokId 接口id
* @param pagination 分页参数
* @return ignore
*/
List<DataInterfaceLogEntity> getList(String invokId, Pagination pagination);
/**
* 获取调用日志列表(多id)
*
* @param invokIds 接口ids
* @param pagination 分页参数
* @return ignore
*/
List<DataInterfaceLogEntity> getListByIds(String appId,List<String> invokIds, PaginationIntrfaceLog pagination);
}

View File

@@ -0,0 +1,188 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.base.entity.DataInterfaceEntity;
import com.yunzhupaas.base.model.datainterface.*;
import com.yunzhupaas.exception.DataException;
import java.util.List;
import java.util.Map;
/**
* 数据接口业务层
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2024-03-23
*/
public interface DataInterfaceService extends SuperService<DataInterfaceEntity> {
/**
* 获取接口列表(分页)
*
* @param pagination 分页参数
* @return ignore
*/
List<DataInterfaceEntity> getList(PaginationDataInterface pagination, Integer isSelector);
/**
* 分页下拉框选择列表
*
* @param pagination
* @return
*/
List<DataInterfaceEntity> getList(PaginationDataInterfaceSelector pagination);
/**
* 通过ids获取列表
*
* @param ids
* @return
*/
List<DataInterfaceEntity> getList(List<String> ids);
/**
* 获取接口列表下拉框
*
* @return ignore
* @param filterPage
*/
List<DataInterfaceEntity> getList(boolean filterPage);
/**
* 获取接口数据
*
* @param id 主键
* @return ignore
*/
DataInterfaceEntity getInfo(String id);
/**
* 添加数据接口
*
* @param entity 实体
*/
void create(DataInterfaceEntity entity);
/**
* 修改接口
*
* @param entity 实体
* @param id 主键
* @return 实体
* @throws DataException ignore
*/
boolean update(DataInterfaceEntity entity, String id) throws DataException;
/**
* 删除接口
*
* @param entity 实体
*/
void delete(DataInterfaceEntity entity);
/**
* 判断接口名称是否重复
*
* @param fullName 名称
* @param id 主键
* @return ignore
*/
boolean isExistByFullNameOrEnCode(String id, String fullName, String enCode);
/**
* 获取接口分页数据
*
* @param id 主键
* @param page 分页参数
* @return ignore
*/
ActionResult infoToIdPageList(String id, DataInterfacePage page);
/**
* 获取接口详情数据
*
* @param id 主键
* @param page 分页参数
* @return ignore
*/
List<Map<String, Object>> infoToInfo(String id, DataInterfacePage page);
/**
* 访问接口路径的应用认证
*
* @param id 主键
* @param tenantId 租户encode
* @param model 需要替换的参数
* @return ignore
*/
ActionResult infoToIdNew(String id, String tenantId, DataInterfaceActionModel model);
/**
* 检查参数
* @param
* @return
* @copyright 深圳市乐程软件有限公司
* @date 2024/6/14
*/
DataInterfaceActionModel checkParams(Map<String,String> map);
/**
* 访问接口路径
*
* @param id 主键
* @param tenantId 租户encode
* @param map 需要替换的参数
* @return ignore
*/
ActionResult infoToId(String id, String tenantId, Map<String, String> map);
/**
* 任务调度使用
* @param id 主键
* @param tenantId 租户encode
* @param map 需要替换的参数
* @param token token
* @return
*/
ActionResult infoToId(String id, String tenantId, Map<String, String> map, String token, String appId, String invokType, Pagination pagination, Map<String,Object> showMap);
/**
* 按sourceType替换数据接口参数
* @param listJson
* @param map
*/
void paramSourceTypeReplaceValue(List<DataInterfaceModel> listJson, Map<String,String> map);
/**
* 获取系统参数值
* @param templateJsonModel
* @return
*/
String getSystemFieldValue(DataInterfaceModel templateJsonModel);
/**
* 处理系统参数
*
* @param sql
* @return
*/
Map<Double, DataInterfaceMarkModel> systemParameterOne(String sql, UserInfo userInfo);
/**
* 自定义参数替换
*
* @param parameterJson 参数配置
* @param sql sql
* @param map 参数
* @param systemParameter 参数集合
*/
String customizationParameter(String parameterJson, String sql, Map<String, Object> map,
Map<Double, DataInterfaceMarkModel> systemParameter);
String getHandleArraysSql(String sql, List<Object> values, Map<Double, DataInterfaceMarkModel> systemParameter);
}

View File

@@ -0,0 +1,41 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.DataInterfaceUserEntity;
import com.yunzhupaas.base.model.InterfaceOauth.InterfaceUserForm;
import java.util.List;
/**
* @author 云筑产品开发平台组
* @version V3.4.7
* @copyright 深圳市乐程软件有限公司
* @date 2024/9/20 9:22
*/
public interface DataInterfaceUserService extends SuperService<DataInterfaceUserEntity> {
/**
* 授权用户
*
* @param interfaceUserForm
*/
void saveUserList(InterfaceUserForm interfaceUserForm);
/**
* 根据认证接口id查询授权用户列表
*
* @param oauthId
* @return
*/
List<DataInterfaceUserEntity> select(String oauthId);
/**
* 通过用户密钥获取用户token
*
* @param oauthId
* @param userKey
* @return
*/
String getInterfaceUserToken(String tenantId, String oauthId, String userKey);
}

View File

@@ -0,0 +1,84 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.entity.DataInterfaceVariateEntity;
import java.util.List;
import java.util.Map;
/**
* 数据接口业务层
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2024-03-23
*/
public interface DataInterfaceVariateService extends SuperService<DataInterfaceVariateEntity> {
/**
* 列表
* @param id
* @param page
* @return
*/
List<DataInterfaceVariateEntity> getList(String id, Page page);
/**
* 详情
*
* @param id
* @return
*/
DataInterfaceVariateEntity getInfo(String id);
/**
* 判断名称是否重复
*
* @param entity
* @return
*/
boolean isExistByFullName(DataInterfaceVariateEntity entity);
/**
* 添加
*
* @param entity
* @return
*/
boolean create(DataInterfaceVariateEntity entity);
/**
* 修改
*
* @param entity
* @return
*/
boolean update(DataInterfaceVariateEntity entity);
/**
* 删除
*
* @param entity
* @return
*/
boolean delete(DataInterfaceVariateEntity entity);
/**
* 通过id获取列表
*
* @param ids
* @return
*/
List<DataInterfaceVariateEntity> getListByIds(List<String> ids);
boolean update(Map<String, String> map, List<DataInterfaceVariateEntity> variateEntities);
/**
* 通过名称获取变量
*
* @param fullName
*/
DataInterfaceVariateEntity getInfoByFullName(String fullName);
}

View File

@@ -0,0 +1,85 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.VisualDataMapEntity;
import java.util.List;
/**
* 大屏地图
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-09-26 上午9:18
*/
public interface DataMapService extends SuperService<VisualDataMapEntity> {
/**
* 获取大屏列表(分页)
*
* @param pagination 分页参数
* @return ignore
*/
List<VisualDataMapEntity> getList(Pagination pagination);
/**
* 获取大屏列表
*
* @return ignore
*/
List<VisualDataMapEntity> getList();
/**
* 获取大屏基本信息
*
* @param id 主键
* @return ignore
*/
VisualDataMapEntity getInfo(String id);
/**
* 新增
*
* @param entity 实体
*/
void create(VisualDataMapEntity entity);
/**
* 修改
*
* @param id 主键
* @param entity 实体
* @return ignore
*/
boolean update(String id, VisualDataMapEntity entity);
/**
* 删除
*
* @param entity 实体
*/
void delete(VisualDataMapEntity entity);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 验证编码
*
* @param enCode 编码
* @param id 主键值
* @return ignore
*/
boolean isExistByEnCode(String enCode, String id);
}

View File

@@ -0,0 +1,78 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.DataSetEntity;
import com.yunzhupaas.base.model.dataset.*;
import com.yunzhupaas.util.treeutil.SumTree;
import java.util.List;
import java.util.Map;
/**
* 数据集合
*
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/5/7 9:15:47
*/
public interface DataSetService extends SuperService<DataSetEntity> {
/**
* 获取关键数据集列表
*
* @param pagination
* @return
*/
List<DataSetEntity> getList(DataSetPagination pagination);
/**
* 创建数据集
*
* @param form
*/
void create(List<DataSetForm> form, String ObjectType, String ObjectId);
/**
* 获取表字段结构
*
* @param item 数据集对象
* @return 打印树形模型
* @throws Exception ignore
*/
SumTree<TableTreeModel> getTabFieldStruct(DataSetEntity item) throws Exception;
/**
* 根据sql获取数据
*
* @param entity
* @param params
* @param outIsMap 输出接口是map(否则输出list)
* @return
*/
Map<String, Object> getDataMapOrList(DataSetEntity entity, Map<String, Object> params, String formId, boolean outIsMap);
/**
* 拼接sql
*
* @param query
* @return
*/
Map<String, Object> getDataList(DataSetQuery query);
/**
* 数据预览
*
* @param dataSetForm
* @return
*/
DataSetViewInfo getPreviewData(DataSetForm dataSetForm);
/**
* 接口数据预览
*
* @param dataSetForm
* @return
*/
DataSetViewInfo getPreviewDataInterface(DataSetForm dataSetForm);
}

View File

@@ -0,0 +1,113 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.model.dblink.PaginationDbLink;
import com.yunzhupaas.database.model.dto.DbConnDTO;
import com.yunzhupaas.database.model.entity.DbLinkEntity;
import com.yunzhupaas.exception.DataException;
import java.util.List;
/**
* 数据连接
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DbLinkService extends SuperService<DbLinkEntity> {
/**
* 列表
*
* @return ignore
*/
List<DbLinkEntity> getList();
/**
* 列表关键字查询
*
* @param pagination 数据连接分页
* @return ignore
*/
List<DbLinkEntity> getList(PaginationDbLink pagination);
/**
* 信息
*
* @param id 主键
* @return ignore
*/
DbLinkEntity getInfo(String id);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 创建
*
* @param entity 实体对象
*/
void create(DbLinkEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, DbLinkEntity entity);
/**
* 删除
*
* @param entity 实体对象
*/
void delete(DbLinkEntity entity);
/**
* 上移
*
* @param id 主键值
* @return ignore
*/
boolean first(String id);
/**
* 下移
*
* @param id 主键值
* @return ignore
*/
boolean next(String id);
/**
* 测试连接
*
* @param entity 实体对象
* @return ignore
* @throws DataException ignore
*/
boolean testDbConnection(DbLinkEntity entity) throws Exception;
/**
* 获取动态数据源
*
* @param dbLinkId 数据连接ID
* @return 动态数据库源
* @throws DataException ignore
*/
DbLinkEntity getResource(String dbLinkId) throws Exception;
}

View File

@@ -0,0 +1,60 @@
package com.yunzhupaas.base.service;
import java.util.List;
import java.util.Map;
/**
* 数据同步
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DbSyncService {
/**
* 数据表同步验证
*
* @param dbLinkIdFrom 数据库连接From
* @param dbLinkIdTo 数据库连接To
* @param table 表名
* @return 1:初始库表中没有数据
* 2:目标库中该表不存在,是否在目标库中创建该表,并同步数据?
* 3:目标表存在数据,是否自动清除并同步数据?
* 0:同步成功
* -1:请检查,同一数据库下无法同步数据
* @throws Exception ignore
*/
Integer executeCheck(String dbLinkIdFrom, String dbLinkIdTo, Map<String, String> convertRuleMap, String table) throws Exception;
/**
* 同步表执行
*
* @param dbLinkIdFrom 数据库连接From
* @param dbLinkIdTo 数据库连接To
* @param table 表名
* @throws Exception ignore
*/
void execute(String dbLinkIdFrom, String dbLinkIdTo, Map<String, String> convertRuleMap, String table) throws Exception;
/**
* 批量执行
*
* @param dbLinkIdFrom 数据库连接From
* @param dbLinkIdTo 数据库连接To
* @param tableList 表名
* @throws Exception ignore
*/
Map<String, Integer> executeBatch(String dbLinkIdFrom, String dbLinkIdTo, Map<String, String> convertRuleMap, List<String> tableList) ;
/**
* 打印初始脚本
*
* @param printType dbInit:初始脚本、dbStruct:表结构、dbData:数据、tenant:多租户
*/
Map<String, Integer> printDbInit(String dbLinkIdFrom, String dbTypeTo, List<String> tableList, Map<String, String> convertRuleMap, String printType) throws Exception;
}

View File

@@ -0,0 +1,169 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.database.model.dbfield.DbFieldModel;
import com.yunzhupaas.database.model.dbtable.DbTableFieldModel;
import com.yunzhupaas.database.model.page.DbTableDataForm;
import com.yunzhupaas.exception.DataException;
import java.util.List;
import java.util.Map;
/**
* 数据管理
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DbTableService {
/**
* 1:表列表
*
* @param dbLinkId 连接Id
* @param methodName
* @return 表集合信息
* @throws DataException ignore
*/
List<DbTableFieldModel> getList(String dbLinkId, String methodName) throws Exception;
/**
* 1:表列表
*
* @param dbLinkId 连接Id
* @param page 关键字
* @return 表集合信息
* @throws DataException ignore
*/
List<DbTableFieldModel> getListPage(String dbLinkId, Page page) throws Exception;
/**
* 1:表列表
*
* @param dbLinkId 连接Id
* @return 表集合信息
* @throws DataException ignore
*/
List<DbTableFieldModel> getListPage(String dbLinkId, Pagination pagination) throws Exception;
/**
* 2:单表信息
*
* @param dbLinkId 连接Id
* @return 表集合信息
* @throws DataException ignore
*/
DbTableFieldModel getTable(String dbLinkId, String table) throws Exception;
/**
* 3:表字段
*
* @param dbLinkId 连接Id
* @param table 表名
* @return 字段集合信息
* @throws DataException ignore
*/
List<DbFieldModel> getFieldList(String dbLinkId, String table) throws Exception;
/**
* 4:表数据
*
* @param dbTableDataForm 分页
* @param dbLinkId 连接Id
* @param table 表名
* @return 表数据集合
* @throws Exception ignore
*/
List<Map<String, Object>> getData(DbTableDataForm dbTableDataForm, String dbLinkId, String table) throws Exception;
/**
* 5:校验:表名重名
*
* @param dbLinkId 连接Id
* @return 重名标识
* @throws Exception ignore
*/
boolean isExistTable(String dbLinkId, String table) throws Exception;
/**
* 6:删除存在表
*
* @param dbLinkId 连接ID
* @param table 删除表
*/
boolean dropExistsTable(String dbLinkId, String table) throws Exception;
/**
* 7:删除表
*
* @param dbLinkId 连接Id
* @param table 表名
* @throws DataException ignore
*/
void delete(String dbLinkId, String table) throws Exception;
/**
* 删除全部表(慎用)
* @param dbLinkId 连接Id
*/
void deleteAllTable(String dbLinkId, String dbType) throws Exception;
/**
* 8:创建表
*
* @param dbTableFieldModel 前端创表表单信息
* @return 执行状态1成功0重名
* @throws DataException ignore
*/
int createTable(DbTableFieldModel dbTableFieldModel) throws Exception;
/**
* 9:获取表模型
* @param dbLinkId 数据连接ID
* @param tableName 表名
* @return 表模板
* @throws Exception ignore
*/
DbTableFieldModel getDbTableModel(String dbLinkId, String tableName) throws Exception;
/**
* 10:修改表
*
* @param dbTableFieldModel 修改表参数对象
* @throws DataException ignore
*/
void update(DbTableFieldModel dbTableFieldModel) throws Exception;
/**
* 11:添加字段
* @param dbTableFieldModel 数据表字段模型
* @throws DataException ignore
*/
void addField(DbTableFieldModel dbTableFieldModel) throws Exception;
/**
* 12:获取表数据行数
*
* @param dbLinkId 数据连接Id
* @param table 表名
* @return 数据行数
* @throws DataException ignore
*/
int getSum(String dbLinkId, String table) throws Exception;
/**
* 13:获取动态数据源
*
* @param dbLinkId 数据连接ID
* @return 动态数据库源
* @throws DataException ignore
*/
// DbConnDTO getResource(String dbLinkId) throws DataException;
}

View File

@@ -0,0 +1,100 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.entity.DictionaryTypeEntity;
import java.util.List;
/**
* 字典分类
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface DictionaryTypeService extends SuperService<DictionaryTypeEntity> {
/**
* 列表
*
* @return ignore
*/
List<DictionaryTypeEntity> getList();
/**
* 信息
*
* @param enCode 代码
* @return ignore
*/
DictionaryTypeEntity getInfoByEnCode(String enCode);
/**
* 信息
*
* @param id 主键值
* @return ignore
*/
DictionaryTypeEntity getInfo(String id);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 验证编码
*
* @param enCode 编码
* @param id 主键值
* @return ignore
*/
boolean isExistByEnCode(String enCode, String id);
/**
* 创建
*
* @param entity 实体对象
*/
void create(DictionaryTypeEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, DictionaryTypeEntity entity);
/**
* 删除
*
* @param entity 实体对象
* @return ignore
*/
boolean delete(DictionaryTypeEntity entity);
/**
* 上移
*
* @param id 主键值
* @return ignore
*/
boolean first(String id);
/**
* 下移
*
* @param id 主键值
* @return ignore
*/
boolean next(String id);
}

View File

@@ -0,0 +1,87 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.entity.InterfaceOauthEntity;
import com.yunzhupaas.base.model.InterfaceOauth.PaginationOauth;
import com.yunzhupaas.exception.DataException;
import java.util.List;
/**
* 接口认证服务
*
* @author 云筑产品开发平台组
* @version V3.4.2
* @copyright 深圳市乐程软件有限公司
* @date 2024/6/8 9:26
*/
public interface InterfaceOauthService extends SuperService<InterfaceOauthEntity> {
/**
* 判断接口认证名称是否重复
*
* @param appName 名称
* @param id 主键
* @return ignore
*/
boolean isExistByAppName(String appName, String id);
/**
* 判断appId是否重复
*
* @param appId 名称
* @param id 主键
* @return ignore
*/
boolean isExistByAppId(String appId, String id);
/**
* 获取接口列表(分页)
*
* @param pagination 分页参数
* @return ignore
*/
List<InterfaceOauthEntity> getList(PaginationOauth pagination);
/**
* 获取接口认证数据
*
* @param id 主键
* @return ignore
*/
InterfaceOauthEntity getInfo(String id);
/**
* 添加接口认证数据
*
* @param entity 实体
*/
void create(InterfaceOauthEntity entity);
/**
* 修改接口
*
* @param entity 实体
* @param id 主键
* @return 实体
* @throws DataException ignore
*/
boolean update(InterfaceOauthEntity entity, String id) throws DataException;
/**
* 删除接口
*
* @param entity 实体
*/
void delete(InterfaceOauthEntity entity);
/**
* 获取接口认证数据
*
* @param appId 主键
* @return ignore
*/
InterfaceOauthEntity getInfoByAppId(String appId);
}

View File

@@ -0,0 +1,84 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.MessageTemplateEntity;
import java.util.List;
/**
* 消息模板表
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024年12月8日17:40:37
*/
public interface MessageTemplateService extends SuperService<MessageTemplateEntity> {
/**
* 列表(无分页)
*
* @return
*/
List<MessageTemplateEntity> getList();
/**
* 列表
*
* @param pagination 条件
* @return 单据规则列表
*/
List<MessageTemplateEntity> getList(Pagination pagination, Boolean filter);
/**
* 信息
*
* @param id 主键值
* @return 单据规则
*/
MessageTemplateEntity getInfo(String id);
/**
* 创建
*
* @param entity 实体
*/
void create(MessageTemplateEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, MessageTemplateEntity entity);
/**
* 删除
*
* @param entity 实体
*/
void delete(MessageTemplateEntity entity);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 验证编码
*
* @param enCode 编码
* @param id 主键值
* @return ignore
*/
boolean isExistByEnCode(String enCode, String id);
}

View File

@@ -0,0 +1,25 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeLinkEntity;
/**
* 数据权限配置
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleDataAuthorizeLinkDataService extends SuperService<ModuleDataAuthorizeLinkEntity> {
/**
* 根据菜单id获取数据连接
* @param menuId
* @return
*/
ModuleDataAuthorizeLinkEntity getLinkDataEntityByMenuId(String menuId,Integer type);
}

View File

@@ -0,0 +1,85 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeEntity;
import java.util.List;
/**
* 数据权限配置
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ModuleDataAuthorizeService extends SuperService<ModuleDataAuthorizeEntity> {
/**
* 列表
*
* @return ignore
*/
List<ModuleDataAuthorizeEntity> getList();
/**
* 列表
*
* @param moduleId 功能主键
* @return ignore
*/
List<ModuleDataAuthorizeEntity> getList(String moduleId);
/**
* 信息
*
* @param id 主键值
* @return ignore
*/
ModuleDataAuthorizeEntity getInfo(String id);
/**
* 创建
*
* @param entity 实体对象
*/
void create(ModuleDataAuthorizeEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, ModuleDataAuthorizeEntity entity);
/**
* 删除
*
* @param entity 实体对象
*/
void delete(ModuleDataAuthorizeEntity entity);
/**
* 验证编码是否重复
*
* @param moduleId
* @param enCode
* @param id
* @return
*/
boolean isExistByEnCode(String moduleId, String enCode, String id);
/**
* 验证名称是否重复
*
* @param moduleId
* @param fullName
* @param id
* @return
*/
boolean isExistByFullName(String moduleId, String fullName, String id);
}

View File

@@ -0,0 +1,72 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.ModuleDataEntity;
import com.yunzhupaas.model.login.AllMenuSelectVO;
import java.util.List;
/**
* @author :云筑产品开发平台组
* @version: V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/5/6 上午10:48
*/
public interface ModuleDataService extends SuperService<ModuleDataEntity> {
/**
* 列表
*
* @return
*/
List<ModuleDataEntity> getList(String category, Page page);
/**
* 创建
*
*/
void create(String moduleId);
/**
* 信息
*
* @param ObjectId 对象主键
* @return
*/
ModuleDataEntity getInfo(String ObjectId);
/**
* 验证名称
*
* @param objectId 对象主键
* @return
*/
boolean isExistByObjectId(String objectId);
/**
* 删除
*
* @param entity 实体对象
*/
void delete(ModuleDataEntity entity);
/**
* 删除
*
*/
void delete(String objectId);
/**
* app菜单
* @return
*/
List<AllMenuSelectVO> getDataList(Page page);
/**
* app常用菜单详情
* @return
*/
List<AllMenuSelectVO> getAppDataList(Pagination pagination);
}

View File

@@ -0,0 +1,40 @@
package com.yunzhupaas.base.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.yunzhupaas.base.entity.PortalManageEntity;
import com.yunzhupaas.base.model.portalManage.PortalManagePage;
import com.yunzhupaas.base.model.portalManage.PortalManagePageDO;
import com.yunzhupaas.base.model.portalManage.PortalManagePrimary;
import com.yunzhupaas.base.model.portalManage.PortalManageVO;
import java.util.List;
/**
* <p>
* 门户管理 服务类
* </p>
*
* @author
* @since 2023-02-16
*/
public interface PortalManageService extends SuperService<PortalManageEntity> {
void checkCreUp(PortalManageEntity portalManageEntity) throws Exception;
PortalManageVO convertVO(PortalManageEntity entity);
List<PortalManageVO> getList(PortalManagePrimary primary);
List<PortalManageVO> getListByEnable(PortalManagePrimary primary);
PageDTO<PortalManagePageDO> getPage(PortalManagePage portalPagination);
List<PortalManagePageDO> getSelectList(PortalManagePage pmPage);
List<PortalManagePageDO> selectPortalBySystemIds(List<String> systemIds, List<String> collect);
void createBatch(List<PortalManagePrimary> primaryLit) throws Exception;
}

View File

@@ -0,0 +1,124 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.OperatorRecordEntity;
import com.yunzhupaas.base.entity.PrintDevEntity;
import com.yunzhupaas.base.model.print.*;
import com.yunzhupaas.base.model.vo.PrintDevVO;
import java.util.List;
import java.util.Map;
/**
* 打印模板-服务类
*
* @author 云筑产品开发平台组 YY
* @version V3.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-09-30
*/
public interface PrintDevService extends SuperService<PrintDevEntity> {
/**
* 列表
*
* @return 打印实体类
*/
List<PrintDevEntity> getList(PaginationPrint paginationPrint);
/**
* 创建
*/
void create(PrintDevFormDTO dto);
/**
* 获取详情
*
* @return PrintDevInfoVO
*/
PrintDevInfoVO getVersionInfo(String versionId);
/**
* 保存或者发布 通过type0-保存1-发布
*
* @param form
*/
void saveOrRelease(PrintDevUpForm form);
/**
* 获取打印模板对象树形模型(selector)
*
* @param category 打印模板类型
* @return 打印模型树
* @throws Exception 字典分类不存在BUG
*/
List<PrintDevVO> getTreeModel(String category);
/**
* 新增更新校验
*
* @param printDevEntity 打印模板对象
* @param fullNameCheck 重名校验开关
* @param encodeCheck 重码校验开关
*/
void creUpdateCheck(PrintDevEntity printDevEntity, Boolean fullNameCheck, Boolean encodeCheck);
/**
* 查询打印列表
*
* @param ids
* @return
*/
List<PrintOption> getPrintTemplateOptions(List<String> ids);
/**
* 导入打印模板
*
* @param infoVO
* @param type
* @return
*/
String importData(PrintDevInfoVO infoVO, Integer type);
/**
* 获取流程经办记录集合
*
* @param taskId 任务ID
* @return 经办记录集合
*/
List<OperatorRecordEntity> getFlowTaskOperatorRecordList(String taskId);
/**
* 根据sql获取数据
*
* @param templateId 打印模板id
* @param formId 表达数据id
* @param params 参数
* @return
*/
Map<String, Object> getDataMap(String templateId, String formId, String flwoTaskId, Map<String, Object> params);
/**
* 复制打印模板
*
* @param templateId 打印模板id
* @return
*/
void copyPrintdev(String templateId);
/**
* 获取打印业务列表
*
* @param pagination
* @return
*/
List<PrintDevEntity> getWorkSelector(PaginationPrint pagination);
/**
* 获取打印业务列表
*
* @return 打印模型树
*/
List<PrintDevEntity> getWorkSelector(List<String> id);
}

View File

@@ -0,0 +1,19 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.PaginationTime;
import com.yunzhupaas.base.model.vo.PrintLogVO;
import com.yunzhupaas.base.entity.PrintLogEntity;
import java.util.List;
public interface PrintLogService extends SuperService<PrintLogEntity> {
/**
* 列表
* @param printId
* @param page
* @return
*/
List<PrintLogVO> list(String printId, PaginationTime page);
}

View File

@@ -0,0 +1,46 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.PrintVersionEntity;
import com.yunzhupaas.base.model.print.PrintDevFormDTO;
import java.util.List;
/**
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/5/6 14:06:40
*/
public interface PrintVersionService extends SuperService<PrintVersionEntity> {
/**
* 创建版本
*
* @param dto
*/
void create(PrintDevFormDTO dto);
/**
* 获取版本列表
*
* @param templateId
* @return
*/
List<PrintVersionEntity> getList(String templateId);
/**
* 复制版本(点击新增打印版本)
*
* @param versionId
*/
String copyVersion(String versionId);
/**
* 根据打印id删除版本
*
* @param templateId
* @return
*/
void removeByTemplateId(String templateId);
}

View File

@@ -0,0 +1,23 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.ProvinceAtlasEntity;
import java.util.List;
/**
* 行政区划
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2023/09/27
*/
public interface ProvinceAtlasService extends SuperService<ProvinceAtlasEntity> {
List<ProvinceAtlasEntity> getList();
List<ProvinceAtlasEntity> getListByPid(String pid);
ProvinceAtlasEntity findOneByCode(String code);
}

View File

@@ -0,0 +1,144 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.model.province.PaginationProvince;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.util.List;
/**
* 行政区划
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface ProvinceService extends SuperService<ProvinceEntity> {
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 验证编码
*
* @param enCode 编码
* @param id 主键值
* @return ignore
*/
boolean isExistByEnCode(String enCode, String id);
/**
* 普通列表
*
* @param parentId 节点Id
* @return ignore
*/
List<ProvinceEntity> getList(String parentId);
/**
* 普通列表
*
* @param parentId 节点Id
* @param page
* @return ignore
*/
List<ProvinceEntity> getList(String parentId, PaginationProvince page);
/**
* 普通列表
*
* @return ignore
*/
List<ProvinceEntity> getAllList();
/**
* 省市区单条数据集合(代码生成器)
* @param ProIdList 省市区id集合
* @return
*/
List<ProvinceEntity> getProList(List<String> ProIdList);
/**
* 地域名列表(在线开发)
*
* @return ignore
*/
List<ProvinceEntity> getProListBytype(String type);
/**
* 信息
*
* @param id 主键值
* @return ignore
*/
ProvinceEntity getInfo(String id);
/**
* 信息
*
* @param fullName
* @param parentId
* @return ignore
*/
ProvinceEntity getInfo(String fullName,List<String> parentId);
/**
* 删除
*
* @param entity 实体对象
*/
void delete(ProvinceEntity entity);
/**
* 创建
*
* @param entity 实体对象
*/
void create(ProvinceEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, ProvinceEntity entity);
/**
* 上移
*
* @param id 主键值
* @return ignore
*/
boolean first(String id);
/**
* 下移
*
* @param id 主键值
* @return ignore
*/
boolean next(String id);
/**
* 获取行政规划列表
*
* @param list 数组
* @return ignore
*/
List<ProvinceEntity> infoList(List<String> list);
}

View File

@@ -0,0 +1,52 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.ScheduleLogEntity;
import java.util.List;
/**
* 日程
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
*/
public interface ScheduleLogService extends SuperService<ScheduleLogEntity> {
/**
* 列表
*
* @return
*/
List<ScheduleLogEntity> getListAll(List<String> scheduleIdList);
/**
* 信息
*
* @param id 主键值
* @return 单据规则
*/
ScheduleLogEntity getInfo(String id);
/**
* 创建
*
* @param entity 实体
*/
void create(ScheduleLogEntity entity);
/**
* 删除
* @param scheduleIdList
*/
void delete(List<String> scheduleIdList,String operationType);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, ScheduleLogEntity entity);
}

View File

@@ -0,0 +1,110 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.ScheduleNewEntity;
import com.yunzhupaas.base.model.schedule.ScheduleDetailModel;
import com.yunzhupaas.base.model.schedule.ScheduleJobModel;
import com.yunzhupaas.base.model.schedule.ScheduleNewTime;
import com.yunzhupaas.exception.WorkFlowException;
import java.util.Date;
import java.util.List;
/**
* 日程
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
*/
public interface ScheduleNewService extends SuperService<ScheduleNewEntity> {
/**
* 列表
*
* @return
*/
List<ScheduleNewEntity> getList(ScheduleNewTime scheduleNewTime);
/**
* 列表
*
* @return
*/
List<ScheduleNewEntity> getList(String groupId, Date date);
/**
* 列表
*
* @return
*/
List<ScheduleNewEntity> getStartDayList(String groupId, Date date);
/**
* 列表
*
* @return
*/
List<ScheduleNewEntity> getListAll(Date date);
/**
* 信息
*
* @param id 主键值
* @return 单据规则
*/
ScheduleNewEntity getInfo(String id);
/**
* 信息
*
* @return 单据规则
*/
List<ScheduleNewEntity> getGroupList(ScheduleDetailModel detailModel);
/**
* 创建
*
* @param entity 实体
* @param operationType 1.新增 2.修改
*/
void create(ScheduleNewEntity entity, List<String> toUserIds, String groupId, String operationType,List<String> idList) throws WorkFlowException;
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @param type 1.此日程 2.此日程及后续 3.所有日程
* @return ignore
*/
boolean update(String id, ScheduleNewEntity entity, List<String> toUserIds, String type) throws WorkFlowException;
/**
* 删除
*
* @param idList
*/
void deleteScheduleList(List<String> idList);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
*/
boolean update(String id, ScheduleNewEntity entity);
/**
* 删除
*
* @param entity 实体
* @param type 1.此日程 2.此日程及后续 3.所有日程
*/
void delete(ScheduleNewEntity entity, String type);
/**
* 发送重复提醒
* @param scheduleJobModel
*/
void scheduleMessage(ScheduleJobModel scheduleJobModel);
}

View File

@@ -0,0 +1,48 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.ScheduleNewUserEntity;
import java.util.List;
/**
* 日程
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
*/
public interface ScheduleNewUserService extends SuperService<ScheduleNewUserEntity> {
/**
* 列表
*
* @return
*/
List<ScheduleNewUserEntity> getList(String scheduleId,Integer type);
/**
* 列表
*
* @return
*/
List<ScheduleNewUserEntity> getList();
/**
* 创建
*
* @param entity 实体
*/
void create(ScheduleNewUserEntity entity);
/**
* 删除
*
*/
void deleteByScheduleId(List<String> scheduleIdList);
/**
* 删除
*
*/
void deleteByUserId(List<String> scheduleIdList);
}

View File

@@ -0,0 +1,51 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.permission.entity.SignEntity;
import java.util.List;
/**
* 个人签名
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/28
*/
public interface SignService extends SuperService<SignEntity> {
/**
* 列表
*
* @return 个人签名集合
*/
List<SignEntity> getList();
/**
* 创建
*
* @param entity 实体对象
*/
boolean create(SignEntity entity);
/**
* 删除
*
*/
boolean delete(String id);
boolean updateDefault(String id);
//获取默认
SignEntity getDefaultByUserId(String id);
}

View File

@@ -0,0 +1,79 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.SignatureEntity;
import com.yunzhupaas.base.model.signature.*;
import java.util.List;
/**
* 电子签章
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/28
*/
public interface SignatureService extends SuperService<SignatureEntity> {
/**
* 列表
*
* @return 电子签章集合
*/
List<SignatureListVO> getList(PaginationSignature pagination);
/**
* 下拉框
* @return
*/
List<SignatureEntity> getList();
/**
* 通过主键id集合获取有权限的电子签章列表
* @param model
* @return
*/
List<SignatureSelectorListVO> getListByIds(SignatureListByIdsModel model);
SignatureEntity getInfoById(String id);
SignatureInfoVO getInfo(String id);
/**
* 验证名称
*
* @param fullName 名称
* @param id 主键值
* @return ignore
*/
boolean isExistByFullName(String fullName, String id);
/**
* 验证编码
*
* @param enCode 编码
* @param id 主键值
* @return ignore
*/
boolean isExistByEnCode(String enCode, String id);
/**
* 创建
*
* @param entity 实体对象
*/
void create(SignatureEntity entity,List<String> userIds);
/**
* 修改
*
* @param signatureUpForm 实体对象
*/
boolean update(String id, SignatureUpForm signatureUpForm);
/**
* 删除
*
*/
boolean delete(String id);
}

View File

@@ -0,0 +1,51 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.SignatureUserEntity;
import java.util.List;
/**
* 电子签章
*
* @author 云筑产品开发平台组
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/28
*/
public interface SignatureUserService extends SuperService<SignatureUserEntity> {
/**
* 列表
*
* @return
*/
List<SignatureUserEntity> getList(List<String> signatureId,List<String> userId);
/**
* 列表
*
* @return
*/
List<SignatureUserEntity> getList(String signatureId);
/**
* 通过userId获取列表
*
* @param userId
* @return
*/
List<SignatureUserEntity> getListByUserId(String userId);
/**
* 创建
*
* @param entity 实体对象
*/
void create(SignatureUserEntity entity);
/**
* 删除
*
*/
void delete(String signatureId);
}

View File

@@ -0,0 +1,89 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.SmsTemplateEntity;
import com.yunzhupaas.base.SmsModel;
import java.util.List;
/**
* @author Administrator
* @description 针对表【base_sms_template】的数据库操作Service
* @createDate 2021-12-09 10:12:52
*/
public interface SmsTemplateService extends SuperService<SmsTemplateEntity> {
/**
* 列表(不分页)
*
* @return
*/
List<SmsTemplateEntity> getList(String keyword);
/**
* 列表
*
* @param pagination 条件
* @return 单据规则列表
*/
List<SmsTemplateEntity> getList(Pagination pagination);
/**
* 信息
*
* @param id 主键值
* @return 单据规则
*/
SmsTemplateEntity getInfo(String id);
/**
* 创建
*
* @param entity 实体
*/
void create(SmsTemplateEntity entity);
/**
* 更新
*
* @param id 主键值
* @param entity 实体对象
* @return ignore
*/
boolean update(String id, SmsTemplateEntity entity);
/**
* 删除
*
* @param entity 实体
*/
void delete(SmsTemplateEntity entity);
/**
* 判断模板编号是否重复
*
* @param templateName
* @param id
* @return
*/
boolean isExistByTemplateName(String templateName, String id);
/**
* 判断模板编号是否重复
*
* @param enCode
* @param id
* @return
*/
boolean isExistByEnCode(String enCode, String id);
/**
* 获取短信配置
* @return
*/
SmsModel getSmsConfig();
}

View File

@@ -0,0 +1,80 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.service.SuperService;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhupaas.base.entity.EmailConfigEntity;
import com.yunzhupaas.base.entity.SysConfigEntity;
import com.yunzhupaas.model.BaseSystemInfo;
import java.util.List;
/**
* 系统配置
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
public interface SysconfigService extends SuperService<SysConfigEntity> {
/**
* 列表
*
* @param type 类型
* @return ignore
*/
List<SysConfigEntity> getList(String type);
/**
* 信息
*
* @return ignore
*/
BaseSystemInfo getWeChatInfo();
/**
* 获取系统配置信息
*
* @return ignore
*/
BaseSystemInfo getSysInfo();
/**
* 保存系统配置
*
* @param entitys 实体对象
*/
void save(List<SysConfigEntity> entitys);
/**
* 保存公众号配置
*
* @param entitys 实体对象
* @return ignore
*/
boolean saveMp(List<SysConfigEntity> entitys);
/**
* 保存企业号配置
*
* @param entitys 实体对象
*/
void saveQyh(List<SysConfigEntity> entitys);
/**
* 邮箱验证
*
* @param configEntity ignore
* @return ignore
*/
String checkLogin(EmailConfigEntity configEntity);
/**
* 根据key获取value
* @param keyStr
* @return
*/
String getValueByKey(String keyStr);
}

View File

@@ -0,0 +1,34 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.message.model.UserOnlineModel;
import java.util.List;
/**
* 在线用户
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-09-26 上午9:18
*/
public interface UserOnlineService {
/**
* 列表
*
* @param page 分页参数
* @return ignore
*/
List<UserOnlineModel> getList(Pagination page);
/**
* 删除
*
* @param tokens 主键值
*/
void delete(String... tokens);
}

View File

@@ -0,0 +1,70 @@
package com.yunzhupaas.base.service;
import com.yunzhupaas.base.entity.VisualKitEntity;
import com.yunzhupaas.base.model.visualkit.KitPagination;
import com.yunzhupaas.base.model.visualkit.KitTreeVo;
import com.yunzhupaas.base.model.visualkit.VisualKitForm;
import com.yunzhupaas.base.model.visualkit.VisualKitInfoVo;
import com.yunzhupaas.base.vo.ListVO;
import java.util.List;
/**
* 表单套件
*
* @author 云筑产品开发平台组
* @version v5.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/8/22 11:10:30
*/
public interface VisualKitService extends SuperService<VisualKitEntity> {
/**
* 列表查询
*
* @param page
* @return
*/
List<VisualKitEntity> getList(KitPagination page);
/**
* 名称编码是否重复
*
* @param visualKitEntity
* @param fullNameCheck
* @param encodeCheck
*/
void saveCheck(VisualKitEntity visualKitEntity, Boolean fullNameCheck, Boolean encodeCheck);
/**
* 创建
*
* @param form
*/
void create(VisualKitForm form);
/**
* 修改
*
* @param id
* @param form
*/
boolean update(String id, VisualKitForm form);
List<KitTreeVo> selectorList();
/**
* 复制
*
* @param id
*/
void actionsCopy(String id);
/**
* 导入套件
*
* @param entity
* @param type
*/
String importData(VisualKitEntity entity, Integer type);
}

View File

@@ -0,0 +1,50 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.base.entity.AdvancedQueryEntity;
import com.yunzhupaas.base.entity.ModuleDataAuthorizeSchemeEntity;
import com.yunzhupaas.base.mapper.AdvancedQueryMapper;
import com.yunzhupaas.base.service.AdvancedQueryService;
import com.yunzhupaas.util.RandomUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
/**
*
*
* @author 云筑产品开发平台组
* @version V3.4.2
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2022/5/30
*/
@Service
public class AdvancedQueryServiceImpl extends SuperServiceImpl<AdvancedQueryMapper, AdvancedQueryEntity> implements AdvancedQueryService {
@Override
public void create(AdvancedQueryEntity advancedQueryEntity) {
String mainId = Optional.ofNullable(advancedQueryEntity.getId()).orElse(RandomUtil.uuId());
advancedQueryEntity.setId(mainId);
this.save(advancedQueryEntity);
}
@Override
public AdvancedQueryEntity getInfo(String id,String userId) {
QueryWrapper<AdvancedQueryEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(AdvancedQueryEntity::getId, id).eq(AdvancedQueryEntity::getCreatorUserId, userId);
return this.getOne(queryWrapper);
}
@Override
public List<AdvancedQueryEntity> getList(String moduleId, UserInfo userInfo) {
QueryWrapper<AdvancedQueryEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(AdvancedQueryEntity::getModuleId, moduleId).eq(AdvancedQueryEntity::getCreatorUserId, userInfo.getUserId());
List<AdvancedQueryEntity> list = this.list(queryWrapper);
return list;
}
}

View File

@@ -0,0 +1,164 @@
package com.yunzhupaas.base.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.unfbx.chatgpt.entity.chat.BaseMessage;
import com.unfbx.chatgpt.entity.chat.Message;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.base.entity.AiChatEntity;
import com.yunzhupaas.base.entity.AiHistoryEntity;
import com.yunzhupaas.base.mapper.AiChatMapper;
import com.yunzhupaas.base.model.ai.AiChatVo;
import com.yunzhupaas.base.model.ai.AiForm;
import com.yunzhupaas.base.model.ai.AiHisVo;
import com.yunzhupaas.base.service.AiChatService;
import com.yunzhupaas.base.service.AiHistoryService;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.service.OpenAiService;
import com.yunzhupaas.util.JsonUtil;
import com.yunzhupaas.util.RandomUtil;
import com.yunzhupaas.util.StringUtil;
import com.yunzhupaas.util.UserProvider;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* ai会话服务
*
* @author 云筑产品开发平台组
* @version v5.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/12/2 10:05:25
*/
@Service
public class AiChatServiceImpl extends SuperServiceImpl<AiChatMapper, AiChatEntity> implements AiChatService {
@Autowired
private OpenAiService openAiService;
@Autowired
private AiHistoryService aiHistoryService;
@Override
public String send(String keyword) {
if ("YUNZHUPAAS是什么".equals(keyword)) {
return "YUNZHUPAAS 是一款基于 Java 的低代码开发平台,旨在简化企业级应用的开发流程。以下是其核心特点:" +
"1. 低代码开发:\n" +
"提供可视化界面,通过拖拽组件和配置参数快速构建应用,减少代码编写。\n" +
"自动生成前后端代码,提升开发效率。\n" +
"2. 功能丰富:\n" +
"包含表单设计、流程引擎、报表工具等模块,满足企业多样化需求。\n" +
"支持移动端开发,便于创建跨平台应用。\n" +
"3. 灵活扩展:\n" +
"支持二次开发,允许根据需求深度定制。\n" +
"提供丰富的 API 接口,便于与其他系统集成。\n" +
"4. 国产化支持:\n" +
"兼容国产操作系统和数据库,适合国内企业使用。\n" +
"总结YUNZHUPAAS 通过低代码方式简化开发流程,提供丰富的功能和灵活的扩展性,适合快速构建企业级应用。";
}
if ("YUNZHUPAAS的性能特点".equals(keyword)) {
return "YUNZHUPAAS 作为低代码开发平台,其性能特点主要体现在以下几个方面:\n" +
"1. 高效开发:\n" +
"可视化开发: 通过拖拽组件和配置参数,快速构建应用,减少代码编写。\n" +
"代码生成: 自动生成前后端代码,提升开发效率。\n" +
"模块化设计: 提供丰富的功能模块,避免重复开发。\n" +
"2. 高稳定性:\n" +
"标准化开发: 统一的开发框架和规范,提升代码质量。\n" +
"持续更新: 平台不断更新,提供最新技术支持。\n" +
"3. 高扩展性:\n" +
"支持二次开发: 可根据需求进行深度定制。\n" +
"丰富接口: 提供多种接口,便于与其他系统集成。\n" +
"多环境部署: 支持多种部署方式,适应不同场景。\n" +
"4. 高性能:\n" +
"优化架构: 采用高性能架构,确保应用流畅运行。\n" +
"缓存机制: 内置缓存机制,提升数据访问速度。\n" +
"负载均衡: 支持负载均衡,有效应对高并发。\n" +
"5. 高安全性:\n" +
"权限控制: 提供细粒度的权限管理,保障数据安全。\n" +
"数据加密: 支持数据加密传输和存储。\n" +
"安全审计: 提供操作日志和审计功能,便于追踪问题。\n" +
"总结: YUNZHUPAAS 在开发效率、稳定性、扩展性、性能及安全性方面表现优异,适合快速构建高性能的企业级应用。";
}
if ("YUNZHUPAAS支持哪些数据库".equals(keyword)) {
return "YUNZHUPAAS 作为一款低代码开发平台,支持多种数据库,具体支持的数据库类型可能因版本和配置而异,但通常包括以下几类:\n" +
"1. 关系型数据库 (SQL):\n" +
"MySQL: 开源、流行的关系型数据库。\n" +
"PostgreSQL: 功能强大、开源的关系型数据库。\n" +
"Oracle: 商业级关系型数据库。\n" +
"SQL Server: 微软开发的关系型数据库。\n" +
"达梦数据库 (DM): 国产关系型数据库。\n" +
"人大金仓数据库 (KingbaseES): 国产关系型数据库。\n" +
"2. 非关系型数据库 (NoSQL):\n" +
"MongoDB: 文档型数据库,适合存储非结构化数据。\n" +
"Redis: 内存数据库,常用于缓存和消息队列。\n" +
"3. 国产数据库:\n" +
"达梦数据库 (DM)\n" +
"人大金仓数据库 (KingbaseES)\n" +
"总结: YUNZHUPAAS 支持多种数据库,包括主流的关系型数据库、非关系型数据库以及国产数据库,用户可根据需求选择合适的数据库。建议参考官方文档或咨询技术支持以获取最新的数据库支持信息。";
}
// if(!AiLimitUtil.tryAcquire(UserProvider.getUser().getUserId())){
// return MsgCode.SYS182.get();
// }
Message sysMessage = Message.builder().role(BaseMessage.Role.USER).content(keyword).build();
return openAiService.completion(sysMessage);
}
@Override
public List<AiChatVo> historyList() {
// 当前用户信息
UserInfo userInfo = UserProvider.getUser();
QueryWrapper<AiChatEntity> queryWrapper = new QueryWrapper();
queryWrapper.lambda().eq(AiChatEntity::getCreatorUserId, userInfo.getUserId());
queryWrapper.lambda().orderByDesc(AiChatEntity::getCreatorTime);
List<AiChatEntity> list = this.list(queryWrapper);
List<AiChatVo> listVo = JsonUtil.getJsonToList(list, AiChatVo.class);
return listVo;
}
@Override
public List<AiHisVo> historyGet(String id) {
QueryWrapper<AiHistoryEntity> queryWrapper = new QueryWrapper();
queryWrapper.lambda().eq(AiHistoryEntity::getChatId, id);
List<AiHistoryEntity> list = aiHistoryService.list(queryWrapper);
List<AiHisVo> listVo = JsonUtil.getJsonToList(list, AiHisVo.class);
return listVo;
}
@Override
public String historySave(AiForm form) {
String chatId = form.getId();
AiChatEntity chatEntity;
if (StringUtil.isNotEmpty(chatId)) {
chatEntity = this.getById(chatId);
} else {
chatEntity = new AiChatEntity();
chatId = RandomUtil.uuId();
chatEntity.setId(chatId);
}
if (StringUtil.isNotEmpty(form.getFullName())) {
chatEntity.setFullName(form.getFullName());
}
this.saveOrUpdate(chatEntity);
List<AiHisVo> data = form.getData();
if (CollectionUtils.isNotEmpty(data)) {
AiHisVo last = data.get(data.size() - 1);
if (StringUtil.isEmpty(last.getId())) {
AiHistoryEntity entity = JsonUtil.getJsonToBean(last, AiHistoryEntity.class);
entity.setId(RandomUtil.uuId());
entity.setChatId(chatId);
aiHistoryService.save(entity);
}
}
return chatId;
}
@Override
public void delete(String id) {
this.removeById(id);
QueryWrapper<AiHistoryEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(AiHistoryEntity::getChatId, id);
aiHistoryService.remove(queryWrapper);
}
}

View File

@@ -0,0 +1,22 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.entity.AiHistoryEntity;
import com.yunzhupaas.base.mapper.AiHistoryMapper;
import com.yunzhupaas.base.service.AiHistoryService;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.stereotype.Service;
/**
* ai会话记录服务
*
* @author 云筑产品开发平台组
* @version v5.2.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/12/2 10:05:25
*/
@Service
public class AiHistoryServiceImpl extends SuperServiceImpl<AiHistoryMapper, AiHistoryEntity> implements AiHistoryService {
}

View File

@@ -0,0 +1,617 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.BaseLangEntity;
import com.yunzhupaas.base.entity.DictionaryDataEntity;
import com.yunzhupaas.base.mapper.BaseLangMapper;
import com.yunzhupaas.base.model.language.BaseLangForm;
import com.yunzhupaas.base.model.language.BaseLangListVO;
import com.yunzhupaas.base.model.language.BaseLangPage;
import com.yunzhupaas.base.service.BaseLangService;
import com.yunzhupaas.base.service.DictionaryDataService;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.constant.ConfigConst;
import com.yunzhupaas.constant.GlobalConst;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.consts.ProjectEventConst;
import com.yunzhupaas.event.ProjectEventListener;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.i18n.config.I18nProperties;
import com.yunzhupaas.i18n.constant.I18nConst;
import com.yunzhupaas.module.ProjectEventBuilder;
import com.yunzhupaas.module.ProjectEventInstance;
import com.yunzhupaas.util.*;
import lombok.Cleanup;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* 多语言
*
* @author 云筑产品开发平台组
* @version v5.0.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/4/28 16:05:49
*/
@Service
public class BaseLangServiceImpl extends SuperServiceImpl<BaseLangMapper, BaseLangEntity> implements BaseLangService {
@Autowired
private ConfigValueUtil configValueUtil;
@Autowired
private DictionaryDataService dictionaryDataApi;
@Autowired
private RedisUtil redisUtil;
@Autowired
private I18nProperties i18nProperties;
// 未使用的情况下, 默认48小时失效, 使用后重新计算缓存时效 租户/语种/前端json
private TimedCache<String, Map<String, String>> tenantMessageProperties = CacheUtil.newTimedCache(48 * 60 * 60000L);
// 租户语言加载锁
private final ConcurrentHashMap<String, ReentrantLock> lockMap = new ConcurrentHashMap<>();
@Override
public BaseLangListVO getList(Pagination pagination) {
List<DictionaryDataEntity> langTypeList = dictionaryDataApi.getListByTypeDataCode(ConfigConst.BASE_LANGUAGE);
String path = FileUploadUtils.getLocalBasePath() + configValueUtil.getBaseLanguagePath();
List<Map<String, Object>> tableHead = new ArrayList<>();
List<Map<String, String>> list = new ArrayList<>();
List<Map<String, String>> resList = new ArrayList<>();
tableHead.add(new HashMap() {{
put("prop", "code");
put("label", "翻译标记");
}});
//不同语言的转换map
Map<String, LinkedHashMap<String, String>> langKeyMap = new HashMap<>();
for (DictionaryDataEntity item : langTypeList) {
tableHead.add(new HashMap() {{
put("prop", item.getEnCode());
put("label", item.getFullName());
}});
String filePath = path + "java/" + item.getEnCode() + ".json";
LinkedHashMap<String, String> resMap = new LinkedHashMap<>();
try {
File file = new File(filePath);
@Cleanup FileInputStream fileInputStream = new FileInputStream(file);
LinkedHashMap<String, Object> jsonObject = JSONObject.parseObject(fileInputStream, LinkedHashMap.class);
this.parseMap(jsonObject, resMap, null);
} catch (Exception e) {
e.printStackTrace();
}
langKeyMap.put(item.getEnCode(), resMap);
}
for (DictionaryDataEntity item : langTypeList) {
LinkedHashMap<String, String> eachMap = langKeyMap.get(item.getEnCode());
for (String key : eachMap.keySet()) {
Map<String, String> map = list.stream().filter(t -> t.get("code").equals(key)).findFirst().orElse(null);
if (map != null) {
map.put(item.getEnCode(), eachMap.get(key));
} else {
map = new HashMap<>();
map.put("code", key);
map.put(item.getEnCode(), eachMap.get(key));
list.add(map);
}
}
}
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
list = list.stream().filter(t -> {
for (String tkey : t.keySet()) {
if (t.get(tkey).contains(pagination.getKeyword())) return true;
}
return false;
}).collect(Collectors.toList());
}
//假分页
if (CollectionUtils.isNotEmpty(list)) {
List<List<Map<String, String>>> partition = Lists.partition(list, (int) pagination.getPageSize());
int i = (int) pagination.getCurrentPage() - 1;
resList = partition.size() > i ? partition.get(i) : Collections.emptyList();
pagination.setTotal(list.size());
}
BaseLangListVO vo = new BaseLangListVO();
PaginationVO page = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
vo.setList(resList);
vo.setTableHead(tableHead);
vo.setPagination(page);
return vo;
}
/**
* 多层map解析成单层keyvalue
*
* @param sourMap
* @param resMap
* @param supKey
*/
public void parseMap(LinkedHashMap<String, Object> sourMap, LinkedHashMap<String, String> resMap, String supKey) {
for (String key : sourMap.keySet()) {
if (sourMap.get(key).toString().startsWith("{") && sourMap.get(key).toString().endsWith("}")) {
LinkedHashMap<String, Object> childSourMap = JSONObject.parseObject(sourMap.get(key).toString(), LinkedHashMap.class);
String newSupKey = key;
if (StringUtil.isNotEmpty(supKey)) {
newSupKey = supKey + "." + key;
}
this.parseMap(childSourMap, resMap, newSupKey);
} else {
String value = sourMap.get(key).toString();
if (supKey != null) {
String skey = supKey + "." + key;
resMap.put(skey, value);
} else {
String skey = key;
resMap.put(skey, value);
}
}
}
}
/**
* 根据不同语种查询列表最大列表
*
* @param pagination
* @param langTypeList
* @param idList
* @return
*/
private IPage<BaseLangEntity> getList(BaseLangPage pagination, List<DictionaryDataEntity> langTypeList, List<String> idList) {
IPage<BaseLangEntity> listRes = null;
for (DictionaryDataEntity item : langTypeList) {
String enCode = item.getEnCode();
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseLangEntity::getLanguage, enCode);
if (CollectionUtils.isNotEmpty(idList)) {
queryWrapper.lambda().in(BaseLangEntity::getId, idList);
}
if (Objects.nonNull(pagination.getType())) {
queryWrapper.lambda().eq(BaseLangEntity::getType, pagination.getType());
}
queryWrapper.lambda().orderByDesc(BaseLangEntity::getCreatorTime);
Page<BaseLangEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
IPage<BaseLangEntity> list = this.page(page, queryWrapper);
if (listRes == null) {
listRes = list;
} else {
if (listRes.getTotal() < list.getTotal()) {
listRes = list;
}
}
}
return listRes;
}
@Override
public BaseLangListVO list(BaseLangPage pagination) {
List<DictionaryDataEntity> langTypeList = dictionaryDataApi.getListByTypeDataCode(ConfigConst.BASE_LANGUAGE);
List<Map<String, Object>> tableHead = new ArrayList<>();
tableHead.add(new HashMap() {{
put("prop", "code");
put("label", "翻译标记");
}});
for (DictionaryDataEntity item : langTypeList) {
tableHead.add(new HashMap() {{
put("prop", item.getEnCode());
put("label", item.getFullName());
}});
}
String keyword = pagination.getKeyword();
List<String> idList = new ArrayList<>();
if (StringUtil.isNotEmpty(keyword)) {
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().and(t -> t.like(BaseLangEntity::getEnCode, keyword)
.or().like(BaseLangEntity::getFullName, keyword));
List<BaseLangEntity> list = list(queryWrapper);
if (CollectionUtils.isEmpty(list)) {
return new BaseLangListVO(new ArrayList<>(), tableHead, pagination);
} else {
idList = list.stream().map(BaseLangEntity::getId).collect(Collectors.toList());
}
}
IPage<BaseLangEntity> list = getList(pagination, langTypeList, idList);
List<BaseLangEntity> baseLangEntities = pagination.setData(list.getRecords(), list.getTotal());
List<Map<String, String>> resList = new ArrayList<>();
for (BaseLangEntity item : baseLangEntities) {
String groupId = item.getGroupId();
Map<String, String> resMap = new LinkedHashMap<>();
List<BaseLangEntity> byGroupId = this.getByGroupId(item.getGroupId());
resMap.put("id", groupId);
resMap.put("code", item.getEnCode());
resMap.put("typeName", Objects.equals(item.getType(), 0) ? "客户端" : "服务端");
for (BaseLangEntity entity : byGroupId) {
resMap.put(entity.getLanguage(), entity.getFullName());
}
resList.add(resMap);
}
BaseLangListVO vo = new BaseLangListVO();
PaginationVO pagevo = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
vo.setList(resList);
vo.setTableHead(tableHead);
vo.setPagination(pagevo);
return vo;
}
@Override
public void create(BaseLangForm form) {
List<BaseLangEntity> byEnode = this.getByEnodeLang(form.getEnCode(), null);
if (CollectionUtils.isNotEmpty(byEnode)) {
throw new DataException(MsgCode.SYS051.get());
}
Map<String, String> map = form.getMap();
boolean atLeastOne = false;
if (MapUtils.isNotEmpty(map)) {
atLeastOne = map.values().stream().anyMatch(v -> v != null && !v.trim().isEmpty());
}
if (!atLeastOne) {
throw new DataException(MsgCode.SYS052.get());
}
String groupId = RandomUtil.uuId();
for (String key : map.keySet()) {
BaseLangEntity entity = JsonUtil.getJsonToBean(form, BaseLangEntity.class);
entity.setGroupId(groupId);
entity.setLanguage(key);
entity.setFullName(map.get(key));
saveEntity(entity);
}
this.createReids(form.getType());
}
@Override
public void update(BaseLangForm form) {
List<BaseLangEntity> langList = getByGroupId(form.getId());
if (CollectionUtils.isEmpty(langList)) {
throw new DataException(MsgCode.FA002.get());
}
List<BaseLangEntity> byEnodeLang = getByEnodeLang(form.getEnCode(), null);
List<BaseLangEntity> hasLang = byEnodeLang.stream().filter(t -> !t.getGroupId().equals(form.getId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(hasLang)) {
throw new DataException(MsgCode.SYS051.get());
}
Map<String, String> map = form.getMap();
boolean atLeastOne = false;
if (MapUtils.isNotEmpty(map)) {
atLeastOne = map.values().stream().anyMatch(v -> v != null && !v.trim().isEmpty());
}
if (!atLeastOne) {
throw new DataException(MsgCode.SYS052.get());
}
List<String> keyList = new ArrayList<>(map.keySet());
String groupId = "";
List<BaseLangEntity> deleteList = new ArrayList<>();
for (BaseLangEntity t : langList) {
if (!keyList.contains(t.getLanguage())) {
deleteList.add(t);
}
groupId = t.getGroupId();
}
//删除移除的
if (CollectionUtils.isNotEmpty(deleteList)) {
this.removeBatchByIds(deleteList.stream().map(BaseLangEntity::getId).collect(Collectors.toList()));
}
for (String key : keyList) {
BaseLangEntity entity = langList.stream().filter(t -> key.equals(t.getLanguage())).findFirst().orElse(new BaseLangEntity());
if (StringUtil.isNotEmpty(entity.getId())) {
entity.setEnCode(form.getEnCode());
entity.setType(form.getType());
entity.setFullName(map.get(key));
entity.setLastModifyTime(DateUtil.getNowDate());
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
this.updateById(entity);
} else {
entity.setId(RandomUtil.uuId());
entity.setGroupId(groupId);
entity.setEnCode(form.getEnCode());
entity.setType(form.getType());
entity.setLanguage(key);
entity.setFullName(map.get(key));
entity.setCreatorTime(new Date());
entity.setCreatorUserId(UserProvider.getUser().getUserId());
this.save(entity);
}
}
this.createReids(form.getType());
}
@Override
public BaseLangForm getInfo(String groupId) {
List<BaseLangEntity> byEnodeLang = getByGroupId(groupId);
BaseLangForm form = new BaseLangForm();
form.setId(groupId);
LinkedHashMap<String, String> map = new LinkedHashMap<>();
for (BaseLangEntity entity : byEnodeLang) {
form.setEnCode(entity.getEnCode());
form.setType(entity.getType());
map.put(entity.getLanguage(), entity.getFullName());
}
form.setMap(map);
return form;
}
@Override
public void delete(String groupId) {
List<BaseLangEntity> byGroupId = getByGroupId(groupId);
Integer type = byGroupId.get(0).getType();
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseLangEntity::getGroupId, groupId);
this.remove(queryWrapper);
this.createReids(type);
}
@Override
public void importSaveOrUpdate(List<BaseLangEntity> list) {
Map<String, String> enCodeGroupId = new HashMap<>();
boolean hasFront = false;
boolean hasServer = false;
for (BaseLangEntity item : list) {
if (Objects.equals(item.getType(), 0)) {
hasFront = true;
}
if (Objects.equals(item.getType(), 1) || Objects.equals(item.getType(), 2)) {
hasServer = true;
}
List<BaseLangEntity> byEnodeLang = getByEnodeLang(item.getEnCode(), null);
String groupId = RandomUtil.uuId();
if (CollectionUtils.isNotEmpty(byEnodeLang)) {
groupId = byEnodeLang.get(0).getGroupId();
if (!enCodeGroupId.containsKey(byEnodeLang.get(0).getEnCode())) {
enCodeGroupId.put(item.getEnCode(), groupId);
}
BaseLangEntity entity = byEnodeLang.stream().filter(t -> t.getLanguage().equals(item.getLanguage())).findFirst().orElse(null);
if (entity != null) {
boolean modify = false;
if(!Objects.equals(entity.getType(), item.getType())) {
entity.setType(item.getType());
modify = true;
}
if(!Objects.equals(entity.getFullName(), item.getFullName())) {
entity.setFullName(item.getFullName());
modify = true;
}
if(modify) {
entity.setLastModifyTime(new Date());
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
this.updateById(entity);
}
} else {
entity = JsonUtil.getJsonToBean(item, BaseLangEntity.class);
entity.setGroupId(groupId);
saveEntity(entity);
}
} else {
if (enCodeGroupId.containsKey(item.getEnCode())) {
groupId = enCodeGroupId.get(item.getEnCode());
} else {
enCodeGroupId.put(item.getEnCode(), groupId);
}
BaseLangEntity entity = BeanUtil.copyProperties(item, BaseLangEntity.class);
entity.setGroupId(groupId);
saveEntity(entity);
}
}
if (hasFront) {
this.createReids(0);
}
if (hasServer) {
this.createReids(1);
}
}
private void saveEntity(BaseLangEntity entity) {
entity.setId(RandomUtil.uuId());
entity.setCreatorTime(new Date());
entity.setCreatorUserId(UserProvider.getUser().getUserId());
this.save(entity);
}
/**
* 根据翻译标记和语种获取数据
*
* @param enCode
* @param language
* @return
*/
private List<BaseLangEntity> getByEnodeLang(String enCode, String language) {
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
if (StringUtil.isNotEmpty(enCode)) {
queryWrapper.lambda().eq(BaseLangEntity::getEnCode, enCode);
}
if (StringUtil.isNotEmpty(language)) {
queryWrapper.lambda().eq(BaseLangEntity::getLanguage, language);
}
return this.list(queryWrapper);
}
/**
* 根据翻译标记id获取数据
*
* @param groupId
* @return
*/
private List<BaseLangEntity> getByGroupId(String groupId) {
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseLangEntity::getGroupId, groupId);
queryWrapper.lambda().orderByAsc(BaseLangEntity::getSortCode).orderByAsc(BaseLangEntity::getCreatorTime);
return this.list(queryWrapper);
}
/**
* 创建修改添加缓存触发
*
* @param type
*/
private void createReids(Integer type) {
String tenantId = GlobalConst.DEFAULT_TENANT_VALUE;
if (configValueUtil.isMultiTenancy()) {
tenantId = TenantHolder.getDatasourceId();
}
String cacheType = I18nConst.CACHE_KEY_FRONT;
if (Objects.equals(type, 1)) {
cacheType = I18nConst.CACHE_KEY_SERVER;
}
String redisKey = cacheType + tenantId;
PublishEventUtil.publish(new ProjectEventBuilder(redisKey, System.currentTimeMillis()).setMessageModel(ProjectEventConst.EVENT_PUBLISH_MODEL_BROADCASTING));
}
/**
* 组装语种json
*
* @param language
* @return
*/
private String makeLanguageJson(String language) {
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseLangEntity::getLanguage, language);
queryWrapper.lambda().eq(BaseLangEntity::getType, 0);
JSONObject json = new JSONObject();
List<BaseLangEntity> list = list(queryWrapper);
for (BaseLangEntity baseLangEntity : list) {
// 不需要组装成对象。组装成对象父级key如果被存储信息了转换json对象有问题
// addJsonTree(baseLangEntity.getEnCode(), json, baseLangEntity.getFullName());
json.put(baseLangEntity.getEnCode(), baseLangEntity.getFullName());
}
return json.toJSONString();
}
/**
* 递归添加属性
*
* @param enCode
* @param json
* @param fullName
*/
private void addJsonTree(String enCode, JSONObject json, String fullName) {
if (enCode.contains(".")) {
String one = enCode.substring(0, enCode.indexOf("."));
String two = enCode.substring(enCode.indexOf(".") + 1);
JSONObject towJson = new JSONObject();
if (json.containsKey(one)) {
towJson = (JSONObject) json.get(one);
}
addJsonTree(two, towJson, fullName);
json.put(one, towJson);
} else {
if (!json.containsKey(enCode)) {
json.put(enCode, fullName);
}
}
}
/**
* 监听缓存修改语种信息
*
* @param redisEvent
*/
@ProjectEventListener(channelRegex = I18nConst.CACHE_KEY_FRONT + ".*")
public void onRedisKeySetEvent(ProjectEventInstance redisEvent) {
String key = redisEvent.getChannel();
// 获取多租户编码
key = key.substring(I18nConst.CACHE_KEY_FRONT.length());
tenantMessageProperties.remove(key);
}
/**
* 初始化语种
*
* @param tenantId
* @param locale
*/
public void loadTenantMessage(String tenantId, Locale locale) {
String languageJson = this.makeLanguageJson(locale.toLanguageTag());
Map<String, String> tenantLangJson = tenantMessageProperties.get(tenantId);
if (tenantLangJson == null) {
tenantLangJson = new HashMap<>();
tenantMessageProperties.put(tenantId, tenantLangJson);
}
tenantLangJson.put(locale.toLanguageTag(), languageJson);
}
/**
* 前端获取语种json
*
* @param locale 语种
* @return
*/
@Override
public String getLanguageJson(Locale locale) {
// 默认租户或者当前租户
String tenantId = GlobalConst.DEFAULT_TENANT_VALUE;
if (configValueUtil.isMultiTenancy()) {
tenantId = TenantHolder.getDatasourceId();
}
// 开启租户未获取到租户 不进行翻译获取
if (tenantId != null) {
String language;
// 租户配置中的语言配置
String languageTag = locale.toLanguageTag();
if (!tenantMessageProperties.containsKey(tenantId) || !tenantMessageProperties.get(tenantId).containsKey(languageTag)) {
// 租户其他线程正在加载多语言则直接返回
ReentrantLock lock = lockMap.computeIfAbsent(tenantId, k -> new ReentrantLock());
boolean isLock = false;
try {
// 如果其他线程正在处理租户翻译则最多等待十秒钟
isLock = lock.tryLock(5L, TimeUnit.SECONDS);
if (isLock) {
if (!tenantMessageProperties.containsKey(tenantId) || !tenantMessageProperties.get(tenantId).containsKey(languageTag)) {
loadTenantMessage(tenantId, locale);
}
}
} catch (InterruptedException e) {
} finally {
if (isLock) {
lock.unlock();
}
}
}
language = tenantMessageProperties.get(tenantId).get(languageTag);
// 语言不存在翻译配置, 强制返回默认配置语言, 已经是默认语言无法处理
if ((language == null || "{}".equals(language)) && !Objects.equals(locale.toLanguageTag(), i18nProperties.getDefaultLanguage())) {
return getLanguageJson(Locale.forLanguageTag(i18nProperties.getDefaultLanguage()));
}
return language;
}
return null;
}
@Override
public List<BaseLangEntity> getServerLang(Locale locale) {
QueryWrapper<BaseLangEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseLangEntity::getLanguage, locale.toLanguageTag());
List<Integer> type = ImmutableList.of(0, 1);
queryWrapper.lambda().in(BaseLangEntity::getType, type);
return list(queryWrapper);
}
}

View File

@@ -0,0 +1,360 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.yunzhupaas.base.model.billrule.BillRulePagination;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.BillRuleEntity;
import com.yunzhupaas.base.mapper.BillRuleMapper;
import com.yunzhupaas.base.service.BillRuleService;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* 单据规则
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
@Service
public class BillRuleServiceImpl extends SuperServiceImpl<BillRuleMapper, BillRuleEntity> implements BillRuleService {
@Autowired
private RedisUtil redisUtil;
@Override
public List<BillRuleEntity> getList(BillRulePagination pagination) {
// 定义变量判断是否需要使用修改时间倒序
boolean flag = false;
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
if (!StringUtil.isEmpty(pagination.getKeyword())) {
flag = true;
queryWrapper.lambda().and(
t -> t.like(BillRuleEntity::getFullName, pagination.getKeyword())
.or().like(BillRuleEntity::getEnCode, pagination.getKeyword())
);
}
if (!StringUtil.isEmpty(pagination.getCategoryId())) {
flag = true;
queryWrapper.lambda().and(
t -> t.like(BillRuleEntity::getCategory, pagination.getCategoryId())
);
}
if (pagination.getEnabledMark() != null) {
flag = true;
queryWrapper.lambda().eq(BillRuleEntity::getEnabledMark, pagination.getEnabledMark());
}
// 排序
queryWrapper.lambda().orderByAsc(BillRuleEntity::getSortCode).orderByDesc(BillRuleEntity::getCreatorTime);
if (flag) {
queryWrapper.lambda().orderByDesc(BillRuleEntity::getLastModifyTime);
}
Page<BillRuleEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
IPage<BillRuleEntity> userPage = this.page(page, queryWrapper);
return pagination.setData(userPage.getRecords(), page.getTotal());
}
@Override
public List<BillRuleEntity> getList() {
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getEnabledMark, 1);
// 排序
queryWrapper.lambda().orderByAsc(BillRuleEntity::getSortCode).orderByDesc(BillRuleEntity::getCreatorTime);
return this.list(queryWrapper);
}
@Override
public BillRuleEntity getInfo(String id) {
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public boolean isExistByFullName(String fullName, String id) {
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getFullName, fullName);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(BillRuleEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
public boolean isExistByEnCode(String enCode, String id) {
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getEnCode, enCode);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(BillRuleEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
@DSTransactional
public String getNumber(String enCode) throws DataException {
StringBuilder strNumber = new StringBuilder();
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getEnCode, enCode);
BillRuleEntity entity = this.getOne(queryWrapper);
if (entity != null) {
Integer startNumber = StringUtil.isEmpty(entity.getStartNumber()) ? 0 : Integer.parseInt(entity.getStartNumber());
//拼接单据编码
strNumber.append(StringUtil.isNotEmpty(entity.getPrefix()) ? entity.getPrefix() : "");
if (ObjectUtil.equal(entity.getType(), 2)) {
// 随机数编号
if (ObjectUtil.equal(entity.getRandomType(), 1)) {
strNumber.append(cn.hutool.core.util.RandomUtil.randomNumbers(entity.getRandomDigit()));
} else {
strNumber.append(cn.hutool.core.util.RandomUtil.randomStringUpper(entity.getRandomDigit()));
}
} else if (ObjectUtil.equal(entity.getType(), 3)) {
// UUID
strNumber.append(IdUtil.randomUUID().toUpperCase());
} else {
// 时间格式
String dateFor = entity.getDateFormat();
String dateForValue = "no";
switch (dateFor) {
case "YYYY":
dateForValue = "yyyy";
break;
case "YYYYMM":
dateForValue = "yyyyMM";
break;
case "YYYYMMDD":
dateForValue = "yyyyMMdd";
break;
case "YYYYMMDDHH":
dateForValue = "yyyyMMddHH";
break;
case "YYYYMMDDHHmm":
dateForValue = "yyyyMMddHHmm";
break;
case "YYYYMMDDHHmmss":
dateForValue = "yyyyMMddHHmmss";
break;
case "YYYYMMDDHHmmssSSS":
dateForValue = "yyyyMMddHHmmssSSS";
break;
}
//处理隔天流水号归0
if (entity.getOutputNumber() != null) {
String serialDate = "";
entity.setThisNumber(entity.getThisNumber() + 1);
if (!"no".equals(dateForValue)) {
String thisDate = DateUtil.dateNow(dateForValue);
int suffixLength = entity.getSuffix() != null ? entity.getSuffix().length() : 0;
try{
serialDate= entity.getOutputNumber().substring((entity.getOutputNumber().length() - dateForValue.length() - entity.getDigit() - suffixLength), (entity.getOutputNumber().length() - entity.getDigit() - suffixLength));
}catch (Exception e){
}
if (!serialDate.equals(thisDate)) {
entity.setThisNumber(0);
}
}
} else {
entity.setThisNumber(0);
}
if (!"no".equals(dateForValue)) {
strNumber.append(DateUtil.dateNow(dateForValue));
}
strNumber.append(PadUtil.padRight(String.valueOf(startNumber + entity.getThisNumber()), entity.getDigit(), '0'));
}
strNumber.append(StringUtil.isNotEmpty(entity.getSuffix()) ? entity.getSuffix() : "");
//更新流水号
entity.setOutputNumber(strNumber.toString());
this.updateById(entity);
} else {
throw new DataException("单据规则不存在");
}
return strNumber.toString();
}
@Override
public void create(BillRuleEntity entity) {
entity.setId(RandomUtil.uuId());
entity.setCreatorUserId(UserProvider.getUser().getUserId());
this.save(entity);
}
@Override
public boolean update(String id, BillRuleEntity entity) {
entity.setId(id);
entity.setLastModifyTime(new Date());
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
return this.updateById(entity);
}
@Override
public void delete(BillRuleEntity entity) {
this.removeById(entity.getId());
}
@Override
@DSTransactional
public boolean first(String id) {
boolean isOk = false;
//获取要上移的那条数据的信息
BillRuleEntity upEntity = this.getById(id);
Long upSortCode = upEntity.getSortCode() == null ? 0 : upEntity.getSortCode();
//查询上几条记录
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.lt(BillRuleEntity::getSortCode, upSortCode)
.orderByDesc(BillRuleEntity::getSortCode);
List<BillRuleEntity> downEntity = this.list(queryWrapper);
if (downEntity.size() > 0) {
//交换两条记录的sort值
Long temp = upEntity.getSortCode();
upEntity.setSortCode(downEntity.get(0).getSortCode());
downEntity.get(0).setSortCode(temp);
this.updateById(downEntity.get(0));
this.updateById(upEntity);
isOk = true;
}
return isOk;
}
@Override
@DSTransactional
public boolean next(String id) {
boolean isOk = false;
//获取要下移的那条数据的信息
BillRuleEntity downEntity = this.getById(id);
Long upSortCode = downEntity.getSortCode() == null ? 0 : downEntity.getSortCode();
//查询下几条记录
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.gt(BillRuleEntity::getSortCode, upSortCode)
.orderByAsc(BillRuleEntity::getSortCode);
List<BillRuleEntity> upEntity = this.list(queryWrapper);
if (upEntity.size() > 0) {
//交换两条记录的sort值
Long temp = downEntity.getSortCode();
downEntity.setSortCode(upEntity.get(0).getSortCode());
upEntity.get(0).setSortCode(temp);
this.updateById(upEntity.get(0));
this.updateById(downEntity);
isOk = true;
}
return isOk;
}
@Override
public String getBillNumber(String enCode, boolean isCache) throws DataException {
String strNumber;
String tenantId = !StringUtil.isEmpty(UserProvider.getUser().getTenantId()) ? UserProvider.getUser().getTenantId() : "";
if (isCache) {
String cacheKey = tenantId + UserProvider.getUser().getUserId() + enCode;
if (!redisUtil.exists(cacheKey)) {
strNumber = this.getNumber(enCode);
redisUtil.insert(cacheKey, strNumber);
} else {
strNumber = String.valueOf(redisUtil.getString(cacheKey));
}
} else {
strNumber = this.getNumber(enCode);
}
return strNumber;
}
@Override
public void useBillNumber(String enCode) {
String cacheKey = UserProvider.getUser().getTenantId() + UserProvider.getUser().getUserId() + enCode;
redisUtil.remove(cacheKey);
}
@Override
@Transactional
public ActionResult ImportData(BillRuleEntity entity, Integer type) throws DataException {
if (entity != null) {
StringJoiner stringJoiner = new StringJoiner("");
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getId, entity.getId());
if (this.count(queryWrapper) > 0) {
if (Objects.equals(type, 0)) {
stringJoiner.add("ID");
} else {
entity.setId(RandomUtil.uuId());
}
}
queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getEnCode, entity.getEnCode());
if (this.count(queryWrapper) > 0) {
stringJoiner.add("编码");
}
queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BillRuleEntity::getFullName, entity.getFullName());
if (this.count(queryWrapper) > 0) {
stringJoiner.add("名称");
}
if (stringJoiner.length() > 0 && ObjectUtil.equal(type, 1)) {
String copyNum = UUID.randomUUID().toString().substring(0, 5);
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
entity.setEnCode(entity.getEnCode() + copyNum);
} else if (ObjectUtil.equal(type, 0) && stringJoiner.length() > 0) {
return ActionResult.fail(stringJoiner.toString() + "重复");
}
entity.setCreatorTime(new Date());
entity.setCreatorUserId(UserProvider.getLoginUserId());
entity.setLastModifyTime(null);
entity.setLastModifyUserId(null);
try {
this.setIgnoreLogicDelete().removeById(entity);
entity.setEnabledMark(0);
entity.setThisNumber(null);
entity.setOutputNumber(null);
this.setIgnoreLogicDelete().saveOrUpdate(entity);
} catch (Exception e) {
throw new DataException(MsgCode.IMP003.get());
}finally {
this.clearIgnoreLogicDelete();
}
return ActionResult.success(MsgCode.IMP001.get());
}
return ActionResult.fail(MsgCode.IMP004.get());
}
@Override
public List<BillRuleEntity> getListByCategory(String id,Pagination pagination) {
// 定义变量判断是否需要使用修改时间倒序
boolean flag = false;
QueryWrapper<BillRuleEntity> queryWrapper = new QueryWrapper<>();
if (!StringUtil.isEmpty(pagination.getKeyword())) {
flag = true;
queryWrapper.lambda().and(
t -> t.like(BillRuleEntity::getFullName, pagination.getKeyword())
.or().like(BillRuleEntity::getEnCode, pagination.getKeyword())
);
}
if (!StringUtil.isEmpty(id)) {
flag = true;
queryWrapper.lambda().eq(BillRuleEntity::getCategory, id);
}
queryWrapper.lambda().eq(BillRuleEntity::getEnabledMark, 1);
// 排序
queryWrapper.lambda().orderByAsc(BillRuleEntity::getSortCode).orderByDesc(BillRuleEntity::getCreatorTime);
if (flag) {
queryWrapper.lambda().orderByDesc(BillRuleEntity::getLastModifyTime);
}
Page<BillRuleEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
IPage<BillRuleEntity> userPage = this.page(page, queryWrapper);
return pagination.setData(userPage.getRecords(), page.getTotal());
}
}

View File

@@ -0,0 +1,81 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.entity.ComFieldsEntity;
import com.yunzhupaas.base.mapper.BaseComFieldsMapper;
import com.yunzhupaas.base.service.ComFieldsService;
import com.yunzhupaas.util.RandomUtil;
import com.yunzhupaas.util.StringUtil;
import com.yunzhupaas.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024/3/12 15:31
*/
@Service
public class ComFieldsServiceImpl extends SuperServiceImpl<BaseComFieldsMapper, ComFieldsEntity> implements ComFieldsService {
@Override
public List<ComFieldsEntity> getList() {
QueryWrapper<ComFieldsEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().orderByAsc(ComFieldsEntity::getSortCode).orderByDesc(ComFieldsEntity::getCreatorTime);
return this.list(queryWrapper);
}
@Override
public ComFieldsEntity getInfo(String id) {
QueryWrapper<ComFieldsEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(ComFieldsEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public boolean isExistByFullName(String fullName, String id) {
QueryWrapper<ComFieldsEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(ComFieldsEntity::getFieldName, fullName);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(ComFieldsEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
public void create(ComFieldsEntity entity) {
entity.setId(RandomUtil.uuId());
entity.setCreatorTime(new Date());
entity.setCreatorUserId(UserProvider.getUser().getUserId());
entity.setEnabledMark(1);
this.save(entity);
}
@Override
public boolean update(String id, ComFieldsEntity entity) {
entity.setId(id);
entity.setLastModifyTime(new Date());
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
return this.updateById(entity);
}
@Override
public void delete(ComFieldsEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
}

View File

@@ -0,0 +1,135 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunzhupaas.base.entity.CommonWordsEntity;
import com.yunzhupaas.base.entity.SystemEntity;
import com.yunzhupaas.base.mapper.CommonWordsMapper;
import com.yunzhupaas.base.model.commonword.ComWordsPagination;
import com.yunzhupaas.base.service.CommonWordsService;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.base.service.SystemService;
import com.yunzhupaas.util.StringUtil;
import com.yunzhupaas.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 审批常用语 ServiceImpl
*
* @author 云筑产品开发平台组
* @version v3.4.6
* @copyrignt 深圳市乐程软件有限公司
* @date 2023-01-06
*/
@Service
public class CommonWordsServiceImpl extends SuperServiceImpl<CommonWordsMapper, CommonWordsEntity> implements CommonWordsService {
@Autowired
private SystemService systemService;
@Override
public List<CommonWordsEntity> getSysList(ComWordsPagination comWordsPagination, Boolean currentSysFlag) {
QueryWrapper<SystemEntity> sysQuery = new QueryWrapper<>();
// 匹配
QueryWrapper<CommonWordsEntity> query = new QueryWrapper<>();
if (Objects.nonNull(comWordsPagination.getCommonWordsType())) {
query.lambda().eq(CommonWordsEntity::getCommonWordsType, comWordsPagination.getCommonWordsType());
if (Objects.equals(comWordsPagination.getCommonWordsType(), 1)) {
query.lambda().eq(CommonWordsEntity::getCreatorUserId, UserProvider.getUser().getUserId());
}
}
// if(currentSysFlag) query.lambda().like(CommonWordsEntity::getSystemIds, UserProvider.getUser().getSystemId());
if (StringUtil.isNotEmpty(comWordsPagination.getKeyword())) {
sysQuery.lambda().like(SystemEntity::getFullName, comWordsPagination.getKeyword());
List<String> ids = systemService.list(sysQuery).stream().map(SystemEntity::getId).collect(Collectors.toList());
query.lambda().and(t -> {
// 应用名称
for (String id : ids) {
t.like(CommonWordsEntity::getSystemIds, id).or();
}
t.like(CommonWordsEntity::getCommonWordsText, comWordsPagination.getKeyword()); // 常用语
});
}
if (comWordsPagination.getEnabledMark() != null) {
query.lambda().eq(CommonWordsEntity::getEnabledMark, comWordsPagination.getEnabledMark());
}
// 排序
if(Objects.equals(comWordsPagination.getCommonWordsType(),1)){
query.lambda().orderByDesc(CommonWordsEntity::getUsesNum);
}
query.lambda().orderByAsc(CommonWordsEntity::getSortCode).orderByDesc(CommonWordsEntity::getCreatorTime);
Page<CommonWordsEntity> page = this.page(comWordsPagination.getPage(), query);
comWordsPagination.setTotal(page.getTotal());
return page.getRecords();
}
@Override
public List<CommonWordsEntity> getListModel(String type) {
QueryWrapper<CommonWordsEntity> query = new QueryWrapper<>();
query.lambda().eq(CommonWordsEntity::getEnabledMark, 1)
.and(t ->
t.and(t2 -> t2.eq(CommonWordsEntity::getCreatorUserId, UserProvider.getUser().getUserId()).or().eq(CommonWordsEntity::getCommonWordsType, 0))
);
// 排序
query.lambda()
.orderByDesc(CommonWordsEntity::getCommonWordsType)
.orderByDesc(CommonWordsEntity::getUsesNum)
.orderByAsc(CommonWordsEntity::getSortCode)
.orderByDesc(CommonWordsEntity::getCreatorTime);
return this.list(query);
}
@Override
public Boolean existSystem(String systemId) {
QueryWrapper<CommonWordsEntity> query = new QueryWrapper<>();
query.lambda().like(CommonWordsEntity::getSystemIds, systemId);
return count(query) > 0;
}
@Override
public Boolean existCommonWord(String id, String commonWordsText, Integer commonWordsType) {
QueryWrapper<CommonWordsEntity> query = new QueryWrapper<>();
if (StringUtil.isNotEmpty(id)) {
query.lambda().ne(CommonWordsEntity::getId, id);
}
if (ObjectUtil.isNotEmpty(commonWordsType)) {
if (Objects.equals(commonWordsType, 1)) {
query.lambda().and(t ->
t.eq(CommonWordsEntity::getCreatorUserId, UserProvider.getUser().getUserId()).or().eq(CommonWordsEntity::getCommonWordsType, 0)
);
} else {
query.lambda().eq(CommonWordsEntity::getCommonWordsType, commonWordsType);
}
}
query.lambda().eq(CommonWordsEntity::getCommonWordsText, commonWordsText);
return count(query) > 0;
}
@Override
public void addCommonWordsNum(String commonWordsText) {
QueryWrapper<CommonWordsEntity> query = new QueryWrapper<>();
query.lambda().eq(CommonWordsEntity::getCommonWordsText, commonWordsText);
query.lambda().eq(CommonWordsEntity::getCreatorUserId, UserProvider.getUser().getUserId());
query.lambda().eq(CommonWordsEntity::getCommonWordsType, 1);
List<CommonWordsEntity> list = list(query);
if (list.size() > 0) {
for (CommonWordsEntity item : list) {
long num = item.getUsesNum() == null ? 0 : item.getUsesNum();
item.setUsesNum(num + 1);
this.updateById(item);
}
}
}
}

View File

@@ -0,0 +1,105 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.base.entity.DataInterfaceEntity;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.DataInterfaceLogEntity;
import com.yunzhupaas.base.mapper.DataInterfaceLogMapper;
import com.yunzhupaas.base.model.InterfaceOauth.PaginationIntrfaceLog;
import com.yunzhupaas.base.service.DataInterfaceLogService;
import com.yunzhupaas.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司http://www.szlecheng.cn
* @date 2024-06-03
*/
@Service
public class DataInterfaceLogServiceImpl extends SuperServiceImpl<DataInterfaceLogMapper, DataInterfaceLogEntity> implements DataInterfaceLogService {
@Override
public void create(String dateInterfaceId, Integer invokWasteTime) {
DataInterfaceLogEntity entity = new DataInterfaceLogEntity();
entity.setId(RandomUtil.uuId());
entity.setInvokTime(DateUtil.getNowDate());
entity.setUserId(UserProvider.getUser().getUserId());
entity.setInvokId(dateInterfaceId);
entity.setInvokIp(IpUtil.getIpAddr());
entity.setInvokType("GET");
entity.setInvokDevice(ServletUtil.getUserAgent());
entity.setInvokWasteTime(invokWasteTime);
this.save(entity);
}
@Override
public void create(String dateInterfaceId, Integer invokWasteTime,String appId,String invokType) {
DataInterfaceLogEntity entity = new DataInterfaceLogEntity();
entity.setId(RandomUtil.uuId());
entity.setInvokTime(DateUtil.getNowDate());
entity.setUserId(UserProvider.getUser().getUserId());
entity.setInvokId(dateInterfaceId);
entity.setInvokIp(IpUtil.getIpAddr());
entity.setInvokType(invokType);
entity.setInvokDevice(ServletUtil.getUserAgent());
entity.setInvokWasteTime(invokWasteTime);
entity.setOauthAppId(appId);
this.save(entity);
}
@Override
public List<DataInterfaceLogEntity> getList(String invokId, Pagination pagination) {
QueryWrapper<DataInterfaceLogEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DataInterfaceLogEntity::getInvokId, invokId).orderByDesc(DataInterfaceLogEntity::getInvokTime);
if (StringUtil.isNotEmpty(pagination.getKeyword())){
queryWrapper.lambda().and(
t->t.like(DataInterfaceLogEntity::getUserId, pagination.getKeyword())
.or().like(DataInterfaceLogEntity::getInvokIp, pagination.getKeyword())
.or().like(DataInterfaceLogEntity::getInvokDevice, pagination.getKeyword())
.or().like(DataInterfaceLogEntity::getInvokType, pagination.getKeyword())
);
}
// 排序
queryWrapper.lambda().orderByDesc(DataInterfaceLogEntity::getInvokTime);
Page<DataInterfaceLogEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
IPage<DataInterfaceLogEntity> iPage = this.page(page, queryWrapper);
return pagination.setData(iPage.getRecords(), page.getTotal());
}
@Override
public List<DataInterfaceLogEntity> getListByIds(String appId,List<String> invokIds, PaginationIntrfaceLog pagination) {
MPJLambdaWrapper<DataInterfaceLogEntity> queryWrapper = JoinWrappers
.lambda(DataInterfaceLogEntity.class)
.leftJoin(DataInterfaceEntity.class,DataInterfaceEntity::getId,DataInterfaceLogEntity::getInvokId);
queryWrapper.eq(DataInterfaceLogEntity::getOauthAppId,appId);
queryWrapper.in(DataInterfaceLogEntity::getInvokId, invokIds);
if (StringUtil.isNotEmpty(pagination.getKeyword())){
queryWrapper.and(
t->t.like(DataInterfaceEntity::getEnCode, pagination.getKeyword())
.or().like(DataInterfaceEntity::getFullName, pagination.getKeyword())
);
}
//日期范围近7天、近1月、近3月、自定义
if (ObjectUtil.isNotEmpty(pagination.getStartTime()) && ObjectUtil.isNotEmpty(pagination.getEndTime())) {
queryWrapper.between(DataInterfaceLogEntity::getInvokTime, new Date(pagination.getStartTime()), new Date(pagination.getEndTime()));
}
// 排序
queryWrapper.orderByDesc(DataInterfaceLogEntity::getInvokTime);
Page<DataInterfaceLogEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
IPage<DataInterfaceLogEntity> iPage = this.selectJoinListPage(page, DataInterfaceLogEntity.class,queryWrapper);
return pagination.setData(iPage.getRecords(), page.getTotal());
}
}

View File

@@ -0,0 +1,87 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunzhupaas.base.entity.DataInterfaceUserEntity;
import com.yunzhupaas.base.mapper.DataInterfaceUserMapper;
import com.yunzhupaas.base.model.InterfaceOauth.InterfaceUserForm;
import com.yunzhupaas.base.service.DataInterfaceUserService;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.permission.service.UserService;
import com.yunzhupaas.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author 云筑产品开发平台组
* @version V3.4.7
* @copyright 深圳市乐程软件有限公司
* @date 2024/9/20 9:22
*/
@Service
@Slf4j
public class DataInterfaceUserServiceImpl extends SuperServiceImpl<DataInterfaceUserMapper, DataInterfaceUserEntity> implements DataInterfaceUserService {
@Autowired
protected AuthUtil authUtil;
@Override
public void saveUserList(InterfaceUserForm interfaceUserForm) {
if (interfaceUserForm.getUserIds() != null) {
List<String> userList = interfaceUserForm.getUserIds();
List<DataInterfaceUserEntity> select = this.select(interfaceUserForm.getInterfaceIdentId());
List<String> dbList = select.stream().map(DataInterfaceUserEntity::getUserId).collect(Collectors.toList());
List<String> saveList = userList.stream().filter(t -> !dbList.contains(t)).collect(Collectors.toList());
List<DataInterfaceUserEntity> updateList = select.stream().filter(t -> userList.contains(t.getUserId())).collect(Collectors.toList());
List<DataInterfaceUserEntity> deleteList = select.stream().filter(t -> !userList.contains(t.getUserId())).collect(Collectors.toList());
for (String userId : saveList) {
DataInterfaceUserEntity entity = new DataInterfaceUserEntity();
entity.setId(RandomUtil.uuId());
entity.setUserKey(RandomUtil.uuId().substring(2));
entity.setOauthId(interfaceUserForm.getInterfaceIdentId());
entity.setUserId(userId);
entity.setCreatorUserId(UserProvider.getUser().getUserId());
entity.setCreatorTime(DateUtil.getNowDate());
this.save(entity);
}
for (DataInterfaceUserEntity updateE : updateList) {
this.updateById(updateE);
}
for (DataInterfaceUserEntity deleteE : deleteList) {
this.removeById(deleteE.getId());
}
}
}
@Override
public List<DataInterfaceUserEntity> select(String oauthId) {
QueryWrapper<DataInterfaceUserEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DataInterfaceUserEntity::getOauthId, oauthId);
return this.list(queryWrapper);
}
@Override
public String getInterfaceUserToken(String tenantId, String oauthId, String userKey) {
List<DataInterfaceUserEntity> select = this.select(oauthId);
if (CollectionUtil.isEmpty(select)) {
return null;
}
if (StringUtil.isEmpty(userKey)) {
throw new RuntimeException("未填写UserKey请确认");
}
DataInterfaceUserEntity entity = select.stream().filter(item -> item.getUserKey().equals(userKey)).findFirst().orElse(null);
if (entity == null) {
throw new RuntimeException("UserKey不匹配请填写正确的UserKey");
}
String token = authUtil.loginTempUser(entity.getUserId(), tenantId, true);
return token;
}
}

View File

@@ -0,0 +1,97 @@
package com.yunzhupaas.base.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.entity.DataInterfaceVariateEntity;
import com.yunzhupaas.base.mapper.DataInterfaceVariateMapper;
import com.yunzhupaas.base.service.DataInterfaceVariateService;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.util.*;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Service
public class DataInterfaceVariateServiceImpl extends SuperServiceImpl<DataInterfaceVariateMapper, DataInterfaceVariateEntity> implements DataInterfaceVariateService {
@Override
public List<DataInterfaceVariateEntity> getList(String id, Page page) {
QueryWrapper<DataInterfaceVariateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().orderByDesc(DataInterfaceVariateEntity::getCreatorTime);
if (StringUtil.isNotEmpty(id)) {
queryWrapper.lambda().eq(DataInterfaceVariateEntity::getInterfaceId, id);
}
if (page != null && StringUtil.isNotEmpty(page.getKeyword())) {
queryWrapper.lambda().like(DataInterfaceVariateEntity::getFullName, page.getKeyword());
// queryWrapper.lambda().orderByDesc(DataInterfaceVariateEntity::getLastModifyTime);
}
return this.list(queryWrapper);
}
@Override
public DataInterfaceVariateEntity getInfo(String id) {
QueryWrapper<DataInterfaceVariateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DataInterfaceVariateEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public boolean isExistByFullName(DataInterfaceVariateEntity entity) {
QueryWrapper<DataInterfaceVariateEntity> queryWrapper = new QueryWrapper<>();
if (StringUtil.isNotEmpty(entity.getId())) {
queryWrapper.lambda().ne(DataInterfaceVariateEntity::getId, entity.getId());
}
queryWrapper.lambda().eq(DataInterfaceVariateEntity::getFullName, entity.getFullName());
return this.count(queryWrapper) > 0;
}
@Override
public boolean create(DataInterfaceVariateEntity entity) {
entity.setId(RandomUtil.uuId());
entity.setCreatorUserId(UserProvider.getLoginUserId());
entity.setCreatorTime(DateUtil.getNowDate());
return this.save(entity);
}
@Override
public boolean update(DataInterfaceVariateEntity entity) {
return this.updateById(entity);
}
@Override
public boolean delete(DataInterfaceVariateEntity entity) {
return this.removeById(entity);
}
@Override
public List<DataInterfaceVariateEntity> getListByIds(List<String> ids) {
if (ids.size() == 0) {
return new ArrayList<>();
}
QueryWrapper<DataInterfaceVariateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(DataInterfaceVariateEntity::getId, ids);
return this.list(queryWrapper);
}
@Override
public boolean update(Map<String, String> map, List<DataInterfaceVariateEntity> variateEntities) {
if (map == null || map.size() == 0) {
return true;
}
variateEntities.forEach(t -> {
t.setValue(map.get(t.getId()));
});
return this.updateBatchById(variateEntities);
}
@Override
public DataInterfaceVariateEntity getInfoByFullName(String fullName) {
QueryWrapper<DataInterfaceVariateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DataInterfaceVariateEntity::getFullName, fullName);
return this.getOne(queryWrapper);
}
}

View File

@@ -0,0 +1,118 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.entity.VisualDataMapEntity;
import com.yunzhupaas.base.mapper.DataMapMapper;
import com.yunzhupaas.base.service.DataMapService;
import com.yunzhupaas.util.DateUtil;
import com.yunzhupaas.util.RandomUtil;
import com.yunzhupaas.util.StringUtil;
import com.yunzhupaas.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 大屏地图
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-09-26 上午9:18
*/
@Service
public class DataMapServiceImpl extends SuperServiceImpl<DataMapMapper, VisualDataMapEntity> implements DataMapService {
@Override
public List<VisualDataMapEntity> getList(Pagination pagination) {
// 定义变量判断是否需要使用修改时间倒序
boolean flag = false;
QueryWrapper<VisualDataMapEntity> queryWrapper = new QueryWrapper<>();
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
flag = true;
queryWrapper.lambda().and(
t -> t.like(VisualDataMapEntity::getFullName, pagination.getKeyword())
.or().like(VisualDataMapEntity::getEnCode, pagination.getKeyword())
);
}
//排序
queryWrapper.lambda().orderByAsc(VisualDataMapEntity::getSortCode)
.orderByDesc(VisualDataMapEntity::getCreatorTime);
if (flag) {
queryWrapper.lambda().orderByDesc(VisualDataMapEntity::getLastModifyTime);
}
Page page = new Page(pagination.getCurrentPage(), pagination.getPageSize());
IPage<VisualDataMapEntity> iPages = this.page(page, queryWrapper);
return pagination.setData(iPages.getRecords(), page.getTotal());
}
@Override
public List<VisualDataMapEntity> getList() {
QueryWrapper<VisualDataMapEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().orderByDesc(VisualDataMapEntity::getSortCode)
.orderByDesc(VisualDataMapEntity::getCreatorTime);
return this.list(queryWrapper);
}
@Override
public VisualDataMapEntity getInfo(String id) {
QueryWrapper<VisualDataMapEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(VisualDataMapEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public void create(VisualDataMapEntity entity) {
entity.setId(RandomUtil.uuId());
entity.setCreatorTime(DateUtil.getNowDate());
entity.setCreatorUser(UserProvider.getUser().getUserId());
entity.setEnabledMark(1);
this.save(entity);
}
@Override
public boolean update(String id, VisualDataMapEntity entity) {
entity.setId(id);
entity.setLastModifyTime(DateUtil.getNowDate());
entity.setLastModifyUser(UserProvider.getUser().getUserId());
return this.updateById(entity);
}
@Override
public void delete(VisualDataMapEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
@Override
public boolean isExistByFullName(String fullName, String id) {
QueryWrapper<VisualDataMapEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(VisualDataMapEntity::getFullName, fullName);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(VisualDataMapEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
public boolean isExistByEnCode(String enCode, String id) {
QueryWrapper<VisualDataMapEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(VisualDataMapEntity::getEnCode, enCode);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(VisualDataMapEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
}

View File

@@ -0,0 +1,229 @@
package com.yunzhupaas.base.service.impl;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunzhupaas.base.model.dblink.PaginationDbLink;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.database.model.dto.PrepSqlDTO;
import com.yunzhupaas.database.model.entity.DbLinkEntity;
import com.yunzhupaas.base.mapper.DbLinkMapper;
import com.yunzhupaas.base.service.DbLinkService;
import com.yunzhupaas.database.source.DbBase;
import com.yunzhupaas.database.util.*;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.util.RandomUtil;
import com.yunzhupaas.util.StringUtil;
import com.yunzhupaas.util.TenantHolder;
import lombok.Cleanup;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import java.sql.Connection;
import java.util.Date;
import java.util.List;
/**
* 数据连接
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
@Service
public class DbLinkServiceImpl extends SuperServiceImpl<DbLinkMapper, DbLinkEntity> implements DbLinkService, InitializingBean {
@Autowired
private DbLinkService dblinkService;
@Autowired
private DataSourceUtil dataSourceUtils;
@Override
public List<DbLinkEntity> getList() {
QueryWrapper<DbLinkEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().orderByAsc(DbLinkEntity::getSortCode)
.orderByDesc(DbLinkEntity::getCreatorTime);
return this.list(queryWrapper);
}
@Override
public List<DbLinkEntity> getList(PaginationDbLink pagination) {
// 定义变量判断是否需要使用修改时间倒序
boolean flag = false;
QueryWrapper<DbLinkEntity> queryWrapper = new QueryWrapper<>();
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
flag = true;
queryWrapper.lambda().and(
t -> t.like(DbLinkEntity::getFullName, pagination.getKeyword())
.or().like(DbLinkEntity::getHost, pagination.getKeyword())
);
}
if (StringUtil.isNotEmpty(pagination.getDbType())) {
flag = true;
queryWrapper.lambda().eq(DbLinkEntity::getDbType, pagination.getDbType());
}
queryWrapper.lambda().orderByAsc(DbLinkEntity::getSortCode)
.orderByDesc(DbLinkEntity::getCreatorTime);
if (flag) {
queryWrapper.lambda().orderByDesc(DbLinkEntity::getLastModifyTime);
}
Page<DbLinkEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
IPage<DbLinkEntity> iPage = this.page(page, queryWrapper);
return pagination.setData(iPage.getRecords(), page.getTotal());
}
@Override
public DbLinkEntity getInfo(String id) {
QueryWrapper<DbLinkEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DbLinkEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public boolean isExistByFullName(String fullName, String id) {
QueryWrapper<DbLinkEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DbLinkEntity::getFullName, fullName);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(DbLinkEntity::getId, id);
}
return this.count(queryWrapper) > 0;
}
@Override
public void create(DbLinkEntity entity) {
entity.setId(RandomUtil.uuId());
this.save(entity);
}
@Override
public boolean update(String id, DbLinkEntity entity) {
entity.setId(id);
return this.updateById(entity);
}
@Override
public void delete(DbLinkEntity entity) {
this.removeById(entity.getId());
}
@Override
@DSTransactional
public boolean first(String id) {
boolean isOk = false;
//获取要上移的那条数据的信息
DbLinkEntity upEntity = this.getById(id);
Long upSortCode = upEntity.getSortCode() == null ? 0 : upEntity.getSortCode();
//查询上几条记录
QueryWrapper<DbLinkEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.lt(DbLinkEntity::getSortCode, upSortCode)
.orderByDesc(DbLinkEntity::getSortCode);
List<DbLinkEntity> downEntity = this.list(queryWrapper);
if (downEntity.size() > 0) {
//交换两条记录的sort值
Long temp = upEntity.getSortCode();
upEntity.setSortCode(downEntity.get(0).getSortCode());
downEntity.get(0).setSortCode(temp);
this.updateById(downEntity.get(0));
this.updateById(upEntity);
isOk = true;
}
return isOk;
}
@Override
@DSTransactional
public boolean next(String id) {
boolean isOk = false;
//获取要下移的那条数据的信息
DbLinkEntity downEntity = this.getById(id);
Long upSortCode = downEntity.getSortCode() == null ? 0 : downEntity.getSortCode();
//查询下几条记录
QueryWrapper<DbLinkEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.gt(DbLinkEntity::getSortCode, upSortCode)
.orderByAsc(DbLinkEntity::getSortCode);
List<DbLinkEntity> upEntity = this.list(queryWrapper);
if (upEntity.size() > 0) {
//交换两条记录的sort值
Long temp = downEntity.getSortCode();
downEntity.setSortCode(upEntity.get(0).getSortCode());
downEntity.setLastModifyTime(new Date());
upEntity.get(0).setSortCode(temp);
this.updateById(upEntity.get(0));
this.updateById(downEntity);
isOk = true;
}
return isOk;
}
@Override
public boolean testDbConnection(DbLinkEntity entity) {
//判断字典数据类型编码是否错误,大小写不敏感
DbBase db = DbTypeUtil.getDb(entity);
if(db == null){
throw new DataException(MsgCode.DB001.get());
}
try{
@Cleanup Connection conn = ConnUtil.getConn(entity.getUserName(), entity.getPassword(), ConnUtil.getUrl(entity));
return conn != null;
}catch (Exception e){
e.printStackTrace();
}
return false;
}
/**
* 设置数据源
* @param dbLinkId 数据连接id
* @throws DataException ignore
*/
@Override
public DbLinkEntity getResource(String dbLinkId) throws Exception {
DbLinkEntity dbLinkEntity = new DbLinkEntity();
//多租户是否开启
if("0".equals(dbLinkId)){
if(TenantDataSourceUtil.isTenantAssignDataSource()){
// 默认数据库, 租户管理指定租户数据源
dbLinkEntity = TenantDataSourceUtil.getTenantAssignDataSource(TenantHolder.getDatasourceId()).toDbLink(new DbLinkEntity());
dbLinkEntity.setId("0");
}else {
// 默认数据库查询,从配置获取数据源信息
BeanUtils.copyProperties(dataSourceUtils, dbLinkEntity);
dbLinkEntity.setId("0");
// 是系统默认的多租户
TenantDataSourceUtil.initDataSourceTenantDbName(dbLinkEntity);
}
}else {
try {
DynamicDataSourceUtil.switchToDataSource(null);
dbLinkEntity = dblinkService.getInfo(dbLinkId);
}finally {
DynamicDataSourceUtil.clearSwitchDataSource();
}
}
// 添加并且切换数据源
return dbLinkEntity;
}
@Override
public void afterPropertiesSet(){
PrepSqlDTO.DB_LINK_FUN = (dbLinkId)-> {
try {
return (DbLinkEntity) getResource(dbLinkId);
} catch (Exception e) {
e.printStackTrace();
}
return null;
};
}
}

View File

@@ -0,0 +1,344 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.druid.proxy.jdbc.NClobProxyImpl;
import com.yunzhupaas.base.service.DbLinkService;
import com.yunzhupaas.base.service.DbSyncService;
import com.yunzhupaas.base.service.DbTableService;
import com.yunzhupaas.constant.TableFieldsNameConst;
import com.yunzhupaas.database.datatype.model.DtModelDTO;
import com.yunzhupaas.database.datatype.sync.util.DtSyncUtil;
import com.yunzhupaas.database.model.dbfield.DbFieldModel;
import com.yunzhupaas.database.model.dbfield.JdbcColumnModel;
import com.yunzhupaas.database.model.dbtable.DbTableFieldModel;
import com.yunzhupaas.database.model.dbtable.JdbcTableModel;
import com.yunzhupaas.database.model.dto.PrepSqlDTO;
import com.yunzhupaas.database.model.entity.DbLinkEntity;
import com.yunzhupaas.database.source.DbBase;
import com.yunzhupaas.database.sql.enums.base.SqlComEnum;
import com.yunzhupaas.database.sql.model.SqlPrintHandler;
import com.yunzhupaas.database.sql.param.FormatSqlDM;
import com.yunzhupaas.database.sql.param.FormatSqlKingbaseES;
import com.yunzhupaas.database.sql.param.FormatSqlMySQL;
import com.yunzhupaas.database.sql.param.FormatSqlOracle;
import com.yunzhupaas.database.sql.util.SqlFastUtil;
import com.yunzhupaas.database.util.DataSourceUtil;
import com.yunzhupaas.database.util.DbTypeUtil;
import com.yunzhupaas.database.util.JdbcUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.exception.DataTypeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 数据同步
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
@Slf4j
@Service
public class DbSyncServiceImpl implements DbSyncService {
@Autowired
private DbLinkService dblinkService;
@Autowired
private DbTableService dbTableService;
@Autowired
private SqlPrintHandler sqlPrintHandler;
@Autowired
private DataSourceUtil dataSourceUtil;
private static Properties props;
static {
Properties props = new Properties();
props.setProperty("remarks", "true"); //设置可以获取remarks信息
props.setProperty("useInformationSchema", "true");//设置可以获取tables remarks信息
DbSyncServiceImpl.props = props;
}
@Override
public Integer executeCheck(String fromId, String toId, Map<String, String> convertRuleMap, String table) throws Exception {
DbLinkEntity dbLinkFrom;
DbLinkEntity dbLinkTo;
if("0".equals(fromId)){
dbLinkFrom = dataSourceUtil.init();
}else {
dbLinkFrom = DbLinkEntity.newInstance(fromId);
}
if("0".equals(toId)){
dbLinkTo = dataSourceUtil.init();
}else {
dbLinkTo = DbLinkEntity.newInstance(toId);
}
//验证一(同库无法同步数据)
if (fromId.equals(toId) ||
(Objects.equals(dbLinkFrom.getHost(), dbLinkTo.getHost()) &&
(Objects.equals(dbLinkFrom.getPort(), dbLinkTo.getPort()) &&
(Objects.equals(dbLinkFrom.getDbName(), dbLinkTo.getDbName())
)))){
if(DbBase.ORACLE.equals(dbLinkFrom.getDbType()) || DbBase.DM.equals(dbLinkFrom.getDbType())){
if(dbLinkFrom.getUserName().equals(dbLinkTo.getUserName())){
return -1;
}
}else {
return -1;
}
}
//验证二(表存在)
if (dbTableService.isExistTable(toId, table)) {
//验证三(验证表数据)
if (SqlFastUtil.tableDataExist(toId, table)) {
//被同步表存在数据
return 3;
}
}
// 表不存在
if (!dbTableService.isExistTable(toId, table)) {
return 2;
}
return 0;
}
@Override
public void execute(String dbLinkIdFrom, String dbLinkIdTo, Map<String, String> convertRuleMap, String table) throws Exception {
executeTableCommon(dbLinkIdFrom, dbLinkIdTo, convertRuleMap, table);
}
@Override
public Map<String, Integer> executeBatch(String dbLinkIdFrom, String dbLinkIdTo, Map<String, String> convertRuleMap, List<String> tableList) {
Map<String, Integer> messageMap = new HashMap<>(16);
for (int i = 0; i < tableList.size(); i++) {
String table = tableList.get(i);
int total = tableList.size();
try{
executeTableCommon(dbLinkIdFrom, dbLinkIdTo, convertRuleMap, table);
messageMap.put(table, 1);
log.info("表:(" + table + ")同步成功!" + "(" + (i + 1) + "/" + total + ")");
}catch (Exception e){
e.printStackTrace();
messageMap.put(table, 0);
log.info("表:(" + table + ")同步失败!" + "(" + (i + 1) + "/" + total + ")");
}
}
return messageMap;
}
/**
* 【主要】同步建表操作
*/
public void executeTableCommon(String fromLinkId, String toLinkId, Map<String, String> convertRuleMap, String table) throws Exception {
sqlPrintHandler.tableInfo(table);
DbLinkEntity dbLinkFrom = dblinkService.getResource(fromLinkId);
DbLinkEntity dbLinkTo = dblinkService.getResource(toLinkId);
// 1、删除To表
try{
// 2、创建To表
DbTableFieldModel tableMod = convertFileDataType(dbTableService.getDbTableModel(fromLinkId, table), convertRuleMap, dbLinkFrom.getDbType(), dbLinkTo.getDbType());
if(!sqlPrintHandler.getPrintFlag()) SqlFastUtil.dropTable(dbLinkTo, table);
SqlFastUtil.creTable(dbLinkTo, tableMod);
// 3、同步数据 From -> To
SqlFastUtil.batchInsert(table, dbLinkTo, getInsertMapList(dbLinkFrom, dbLinkTo.getDbType(), table));
}catch (Exception ignore){
ignore.printStackTrace();
}
}
/**
* 打印初始脚本
*
* @param dbLinkIdFrom 数据连接ID
* @param printType dbInit:初始脚本、dbStruct:表结构、dbData:数据、tenant:多租户
*/
public Map<String, Integer> printDbInit(String dbLinkIdFrom, String dbTypeTo, List<String> tableList, Map<String, String> convertRuleMap, String printType) throws Exception {
DbLinkEntity dbLinkEntity = DbLinkEntity.newInstance(dbLinkIdFrom);
if(CollectionUtil.isEmpty(tableList)){
tableList = SqlFastUtil.getTableList(dbLinkEntity).stream().map(DbTableFieldModel::getTable).collect(Collectors.toList());
}
List<String> tableNameList = new ArrayList<>();
Map<String, Integer> messageMap = new HashMap<>(16);
for (int i = 0; i < tableList.size(); i++) {
String table = tableList.get(i);
sqlPrintHandler.tableInfo(table);
tableNameList.add(table);
DbTableFieldModel dbTableFieldModel;
if(true){
// 方式一通过JDBC查询表字段信息
dbTableFieldModel = convertFileDataType(new JdbcTableModel(dbLinkEntity, table).convertDbTableFieldModel(), convertRuleMap, dbLinkEntity.getDbType(), dbTypeTo);
}else {
// 方式二通过SQL语句获取的表字段信息
dbTableFieldModel = convertFileDataType(dbTableService.getDbTableModel(dbLinkIdFrom, table), convertRuleMap, dbLinkEntity.getDbType(), dbTypeTo);
}
List<Map<String, Object>> tableData = getInsertMapList(dbLinkEntity, dbTypeTo, table);
DbLinkEntity dbLink = new DbLinkEntity(dbTypeTo);
try{
switch (printType){
case "dbInit":
case "dbNull":
// SqlFastUtil.dropTable(dbLink, table);
SqlFastUtil.creTable(dbLink, dbTableFieldModel);
SqlFastUtil.batchInsert(table, dbLink, tableData);
break;
case "tenantCre":
if(DbBase.POSTGRE_SQL.equals(dbTypeTo) || DbBase.KINGBASE_ES.equals(dbTypeTo)){
// dbTableFieldModel.setTable("${dbName}." + dbTableFieldModel.getTable());
} else if (DbBase.ORACLE.equals(dbTypeTo) ){
// dbTableFieldModel.setTable("{schema}." + dbTableFieldModel.getTable());
}
case "dbStruct":
// SqlFastUtil.dropTable(dbLink, table);
SqlFastUtil.creTable(dbLink, dbTableFieldModel);
break;
case "dbData":
SqlFastUtil.batchInsert(table, dbLink, tableData);
break;
}
messageMap.put(table, 1);
log.info("表:(" + table + ")同步成功!" + "(" + (i + 1) + "/" + tableList.size() + ")");
}catch (Exception e){
e.printStackTrace();
messageMap.put(table, 0);
log.info("表:(" + table + ")同步失败!" + "(" + (i + 1) + "/" + tableList.size() + ")");
}
}
if(printType.equals("tenantCreNoTab") || printType.equals("tenantCre")){
sqlPrintHandler.append("\n\n").append(creTenant(tableNameList, dbTypeTo));
}
return messageMap;
}
/**
* 多租户创库
*/
public static String creTenant(List<String> tableNameList, String dbEncode){
List<String> ignoreTables = Arrays.asList("undo_log");
StringBuilder insertTenant = new StringBuilder();
for (String table : tableNameList) {
if(ignoreTables.contains(table.toLowerCase())){
continue;
}
String intoTable = table;
String fromTable = "${dbName}." + table;
switch (dbEncode){
case DbBase.SQL_SERVER:
fromTable = "${dbName}.dbo." + table;
break;
// case DbBase.POSTGRE_SQL:
// intoTable = "${dbName}." + table;
// fromTable = "\"public\"." + table;
// break;
case DbBase.ORACLE:
// intoTable = "{schema}." + table;
fromTable = "{initSchema}." + table;
break;
case DbBase.DM:
case DbBase.KINGBASE_ES:
case DbBase.MYSQL:
}
insertTenant.append("INSERT INTO ").append(intoTable).append(" SELECT * FROM ").append(fromTable)
.append(" where ").append(TableFieldsNameConst.F_TENANT_ID).append(" = '0'").append(";").append("\n");
}
return insertTenant.toString();
}
/**
* 获取插入数据map
*/
public List<Map<String, Object>> getInsertMapList(DbLinkEntity dbLinkFrom, String toDbType, String table) throws Exception {
List<List<JdbcColumnModel>> modelList = JdbcUtil.queryJdbcColumns(new PrepSqlDTO(SqlComEnum.SELECT_TABLE.getOutSql(table)).withConn(dbLinkFrom)).get();
List<Map<String, Object>> insertMapList = new ArrayList<>();
for (List<JdbcColumnModel> jdbcColumnModels : modelList) {
Map<String, Object> map = new HashMap<>();
for (JdbcColumnModel jdbcColumnModel : jdbcColumnModels) {
map.put(jdbcColumnModel.getField(), checkValue(jdbcColumnModel, dbLinkFrom.getDbType()));
FormatSqlOracle.nullValue(toDbType, jdbcColumnModel, map); // Oracle空串处理
FormatSqlKingbaseES.nullValue(toDbType, jdbcColumnModel, map); // KingbaseES空串处理
}
insertMapList.add(map);
}
return insertMapList;
}
// 不同数据库之间,特殊数据类型与值校验
private Object checkValue(JdbcColumnModel model, String dbType) throws Exception {
Function<String, Boolean> checkVal = (dataType) ->
model.getDataType().equalsIgnoreCase(dataType) && model.getValue() != null;
switch (dbType){
case DbBase.MYSQL:
/* MySQL设置tinyint类型且长度为1时JDBC读取时会变成BIT类型java类型为Boolean类型。
1:true , 0:false */
if(checkVal.apply("BIT")) return String.valueOf(model.getValue());
case DbBase.ORACLE:
if(checkVal.apply("NCLOB")) return String.valueOf(model.getValue());
return FormatSqlOracle.timestamp(model.getValue());
case DbBase.SQL_SERVER:
case DbBase.KINGBASE_ES:
case DbBase.DM:
if(checkVal.apply("CLOB")){
if(model.getValue() instanceof NClobProxyImpl) FormatSqlDM.getClob((NClobProxyImpl)(model.getValue()));
}
case DbBase.POSTGRE_SQL:
// TODO 等待补充
default:
return model.getValue();
}
}
/**
* 【处理字段类型】
*/
private DbTableFieldModel convertFileDataType(DbTableFieldModel dbTableFieldModel, Map<String, String> convertRuleMap,
String fromDbEncode, String toDbEncode) throws Exception {
String table = dbTableFieldModel.getTable();
List<DbFieldModel> fields = dbTableFieldModel.getDbFieldModelList();
// 规则Map里的默认去除
if(convertRuleMap != null){
convertRuleMap.forEach((key, val) ->{
convertRuleMap.put(key, val.replace(" (默认)", ""));
});
}
for (DbFieldModel field : fields) {
try {
// 设置转换数据类型
field.getDtModelDTO().setConvertTargetDtEnum(DtSyncUtil.getToCovert(fromDbEncode, toDbEncode, field.getDataType(), convertRuleMap));
if(toDbEncode.equals(DbBase.MYSQL)){
FormatSqlMySQL.checkMysqlFieldPrimary(field, table);
}
}catch (DataException d){
System.out.println("表_" + table + ":" + d.getMessage());
DataException dataException = new DataException("目前还未支持数据类型" + toDbEncode + "." + table + "" + field.getDataType() + "");
dataException.printStackTrace();
// 类型寻找失败转换成字符串
field.setDataType(DtModelDTO.getStringFixedDt(toDbEncode));
throw dataException;
}catch (Exception e) {
e.printStackTrace();
if(e instanceof DataTypeException){
throw e;
}
log.info(e.getMessage());
}
}
return dbTableFieldModel;
}
}

View File

@@ -0,0 +1,341 @@
package com.yunzhupaas.base.service.impl;
import com.google.common.collect.ImmutableMap;
import com.yunzhupaas.base.Page;
import com.yunzhupaas.base.Pagination;
import com.yunzhupaas.base.service.DbLinkService;
import com.yunzhupaas.base.service.DbTableService;
import com.yunzhupaas.base.util.dbutil.TableUtil;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.database.datatype.db.DtDMEnum;
import com.yunzhupaas.database.datatype.db.interfaces.DtInterface;
import com.yunzhupaas.database.datatype.viewshow.ViewDataTypeEnum;
import com.yunzhupaas.database.datatype.viewshow.constant.DtViewConst;
import com.yunzhupaas.database.enums.DbAliasEnum;
import com.yunzhupaas.database.model.dbfield.DbFieldModel;
import com.yunzhupaas.database.model.dbtable.DbTableFieldModel;
import com.yunzhupaas.database.model.dto.PrepSqlDTO;
import com.yunzhupaas.database.model.entity.DbLinkEntity;
import com.yunzhupaas.database.model.page.DbTableDataForm;
import com.yunzhupaas.database.model.page.JdbcPageMod;
import com.yunzhupaas.database.source.DbBase;
import com.yunzhupaas.database.source.impl.DbPostgre;
import com.yunzhupaas.database.sql.enums.base.SqlComEnum;
import com.yunzhupaas.database.sql.util.SqlFastUtil;
import com.yunzhupaas.database.sql.util.SqlFrameUtil;
import com.yunzhupaas.database.util.DbTypeUtil;
import com.yunzhupaas.database.util.JdbcUtil;
import com.yunzhupaas.database.util.NotTenantPluginHolder;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 数据管理
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
@Slf4j
@Service
public class DbTableServiceImpl implements DbTableService {
@Autowired
private DbLinkService dblinkService;
@Autowired
private DbTableService dbTableService;
@Override
public List<DbTableFieldModel> getList(String dbLinkId, String methodName) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
return SqlFastUtil.getTableList(dbLinkEntity, methodName);
}
@Override
public List<DbTableFieldModel> getListPage(String dbLinkId, Page page) throws Exception {
List<DbTableFieldModel> list = getList(dbLinkId, DbAliasEnum.TABLE_TYPE.getAlias());
if(StringUtil.isNotEmpty(page.getKeyword())){
// 过滤不符条件的元素
String keyWord = SqlFrameUtil.keyWordTrim(page.getKeyword()).toLowerCase();
list = list.stream().filter(t->
(StringUtil.isNotEmpty(t.getComment()) && t.getComment().toLowerCase().contains(keyWord))
|| t.getTable().toLowerCase().contains(keyWord)
).collect(Collectors.toList());
}
return list;
}
@Override
public List<DbTableFieldModel> getListPage(String dbLinkId, Pagination pagination) throws Exception {
List<DbTableFieldModel> list = getList(dbLinkId, null);
if(StringUtil.isNotEmpty(pagination.getKeyword())){
// 过滤不符条件的元素
String keyWord = SqlFrameUtil.keyWordTrim(pagination.getKeyword()).toLowerCase();
list = list.stream().filter(t->
(StringUtil.isNotEmpty(t.getComment()) && t.getComment().toLowerCase().contains(keyWord))
|| t.getTable().toLowerCase().contains(keyWord)
).collect(Collectors.toList());
}
long beginIndex = (pagination.getCurrentPage() -1) * pagination.getPageSize();
long endIndex = beginIndex + pagination.getPageSize();
List<DbTableFieldModel> listVO = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
if(beginIndex <= i && i < endIndex){
listVO.add(list.get(i));
}
}
pagination.setTotal(list.size());
return listVO;
}
@Override
public DbTableFieldModel getTable(String dbLinkId, String table) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
DbTableFieldModel dbTableFieldModel = SqlFastUtil.getTable(dbLinkEntity, table);
dbTableFieldModel.setHasTableData(getSum(dbLinkId, table) > 0);
return dbTableFieldModel;
}
@Override
public List<DbFieldModel> getFieldList(String dbLinkId, String table) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
return SqlFastUtil.getFieldList(dbLinkEntity, table);
}
@Override
public boolean isExistTable(String dbLinkId, String table) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
return SqlFastUtil.isExistTable(dbLinkEntity, table);
}
@Override
public boolean dropExistsTable(String dbLinkId, String table) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
if(isExistTable(dbLinkId, table)){
return SqlFastUtil.dropTable(dbLinkEntity, table);
}
return true;
}
@Override
public List<Map<String, Object>> getData(DbTableDataForm dbTableDataForm, String dbLinkId, String table) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
JdbcPageMod result = new JdbcPageMod();
String orderKey = dbTableDataForm.getField();
// 防止SQL注入
String finalOrderKey = orderKey;
if(getFieldList(dbLinkId, table).stream().noneMatch(field -> field.getField().equals(finalOrderKey))){
throw new DataException("排序字段不存在");
}
if (dbLinkEntity != null) {
List<Object> dataList = new ArrayList<>();
if(DbTypeUtil.checkPostgre(dbLinkEntity)){
table = DbPostgre.getTable(table);
orderKey = DbPostgre.getTable(orderKey);
// String schema = dbLinkEntity.getDbSchema();
// if(StringUtil.isNotEmpty(schema)){
// table = schema + "." + table;
// }
}
StringBuilder sql = new StringBuilder(SqlComEnum.SELECT_TABLE.getOutSql(table));
//模糊查询
if (!StringUtil.isEmpty(dbTableDataForm.getKeyword()) && !StringUtil.isEmpty(orderKey)) {
sql.append(" where " + orderKey + " like ?");
dataList.add("%" + SqlFrameUtil.keyWordTrim(dbTableDataForm.getKeyword()) + "%");
}
result = JdbcUtil.queryPage(
new PrepSqlDTO(sql.toString(), dataList).withConn(dbLinkEntity),
checkOrderKey(orderKey, dbLinkId, table, dbLinkEntity.getDbType()),
(int) dbTableDataForm.getCurrentPage(),
(int) dbTableDataForm.getPageSize())
.setIsLowerCase(true).setIsAlias(true).get();
}
dbTableDataForm.setTotal(result.getTotalRecord());
return (List<Map<String, Object>>)result.getDataList();
}
private String checkOrderKey(String orderKey, String dbLinkId, String table, String dbEncode){
try {
if(DbBase.DM.equals(dbEncode)){
List<DbFieldModel> fieldList = getFieldList(dbLinkId, table);
Optional<DbFieldModel> first = fieldList.stream().filter(field -> field.getField().equals(orderKey)).findFirst();
if(first.isPresent()){
String dataType = first.get().getDataType();
if(dataType.equals(DtDMEnum.CLOB.getDataType()) || dataType.equals(DtDMEnum.TEXT.getDataType())){
// throw new Exception("无法使用CLOB、TEXT作为字段排序条件");
Optional<DbFieldModel> first1 = fieldList.stream().filter(field -> field.getField().toLowerCase().contains("id")).findFirst();
if(first1.isPresent()){
return first1.get().getField();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return orderKey;
}
@Override
public int getSum(String dbLinkId,String table)throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
return SqlFastUtil.getSum(dbLinkEntity, table);
}
/**=====================增删改========================**/
@Override
public void delete(String dbLinkId, String table) throws Exception {
// 校验
checkTab(table, dbLinkId, 1);
SqlFastUtil.dropTable(dblinkService.getResource(dbLinkId), table);
}
@Override
public void deleteAllTable(String dbLinkId, String dbType) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbLinkId);
if(!dbLinkEntity.getDbType().equals(dbType)) throw new Exception("数据库类型不符");
for (DbTableFieldModel dbTableFieldModel : SqlFastUtil.getTableList(dbLinkEntity)) {
SqlFastUtil.dropTable(dbLinkEntity, dbTableFieldModel.getTable());
}
}
@Override
public int createTable(DbTableFieldModel dbTableFieldModel) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbTableFieldModel.getDbLinkId());
// 数据库编码查询校验 (打印模板校验)
String opeDb = dbLinkEntity.getDbType();
String creDb = dbTableFieldModel.getDbEncode();
if(StringUtil.isNotEmpty(creDb) && !creDb.equals(opeDb)){
throw new DataException(MsgCode.DB008.get() + "" + creDb + " -> " + opeDb);
}
// 表重名判断
if (isExistTable(dbTableFieldModel.getDbLinkId(), dbTableFieldModel.getTable())) {
return 0;
}
// 表主键检验
checkPrimary(dbTableFieldModel.getDbFieldModelList(), dbLinkEntity.getDbType());
// 创建表
SqlFastUtil.creTable(dbLinkEntity, dbTableFieldModel);
return 1;
}
@Override
public void update(DbTableFieldModel dbTableFieldModel) throws Exception {
// 校验
checkTab(dbTableFieldModel.getUpdateOldTable(), dbTableFieldModel.getDbLinkId(), 2);
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbTableFieldModel.getDbLinkId());
//临时表名
String oldTable = dbTableFieldModel.getUpdateOldTable();
String newTable = dbTableFieldModel.getUpdateNewTable();
String tempTabName = "Temp_" + TableUtil.getStringRandom(5);
// 第一步:创建新表 (成功则删除旧表,失败则回滚)
checkPrimary(dbTableFieldModel.getDbFieldModelList(), dbLinkEntity.getDbType());
SqlFastUtil.creTable(dbLinkEntity,
new DbTableFieldModel(
tempTabName,
dbTableFieldModel.getComment(),
dbTableFieldModel.getDbFieldModelList()
));
// 第二步:删除旧表
SqlFastUtil.dropTable(dbLinkEntity, oldTable);
// 第三步:新表改名
SqlFastUtil.reTableName(dbLinkEntity, tempTabName, newTable);
}
@Override
public void addField(DbTableFieldModel dbTableFieldModel) throws Exception {
DbLinkEntity dbLinkEntity = dblinkService.getResource(dbTableFieldModel.getDbLinkId());
SqlFastUtil.addField(dbLinkEntity, dbTableFieldModel.getUpdateNewTable(), dbTableFieldModel.getDbFieldModelList());
}
@Override
public DbTableFieldModel getDbTableModel(String dbLinkId, String tableName)throws Exception {
NotTenantPluginHolder.setNotSwitchFlag();
DbTableFieldModel dbTableModel = getList(dbLinkId, null).stream().filter(m -> m.getTable().equals(tableName)).findFirst().orElse(null);
if(dbTableModel != null){
dbTableModel.setDbFieldModelList(getFieldList(dbLinkId, tableName));
return dbTableModel;
}else {
throw new DataException("请在数据库中添加对应的数据表");
}
}
/* ================复用代码================== */
/**
* 校验表可操作
*
* @param table 表
* @param dbLinkId 数据连接ID
* @param type 1:删除 2:编辑
* @throws Exception 错误信息
*/
private void checkTab(String table, String dbLinkId, Integer type) throws Exception {
if (TableUtil.checkByoTable(table)) throw new DataException(type == 1 ? MsgCode.DB101.get() : MsgCode.DB102.get());
if (getSum(dbLinkId, table) > 0) throw new DataException(type == 1 ? MsgCode.DB201.get() : MsgCode.DB202.get());
}
/**
* 检查主键
* @param tableFieldList 表字段集合
* @throws DataException ignore
*/
private void checkPrimary(List<DbFieldModel> tableFieldList, String dbEncode) throws Exception {
// 默认主键为字符串类型
// 主键会自动添加"非空"限制,所以不用做判断。(为空不加语句,且数据库默认字段可为空)
int autoIncrementNum = 0;
for(DbFieldModel field : tableFieldList) {
if(field.getIsAutoIncrement() != null && field.getIsAutoIncrement()){
field.setNullSign("NOT NULL");
// 一张表最多只有一个自增主键且此字段必须为primary key或者unique key。
autoIncrementNum += 1;
if(autoIncrementNum > 1){
throw new DataException("一张表最多只运行有一个自增主键");
}
if(!(field.getDataType().equals(DtViewConst.INT) || field.getDataType().equals(DtViewConst.BIGINT))){
throw new DataException("自增字段类型必须为数字类型");
}
if(!field.getIsPrimaryKey()){
throw new DataException("自增字段类型必须为主键");
}
}else {
if (field.getIsPrimaryKey()) {
field.setNullSign("NOT NULL");
Method method = ViewDataTypeEnum.class.getMethod("getDt" + dbEncode + "Enum");
Map<ViewDataTypeEnum, String> allowDtMap = ImmutableMap.of(
ViewDataTypeEnum.VARCHAR, DtViewConst.VARCHAR,
ViewDataTypeEnum.INT, DtViewConst.INT,
ViewDataTypeEnum.BIGINT, DtViewConst.BIGINT
);
boolean primaryFlag = false;
for (Map.Entry<ViewDataTypeEnum, String> mapEntity : allowDtMap.entrySet()) {
DtInterface primaryVarcharEnum = (DtInterface)(method.invoke(mapEntity.getKey()));
boolean enumFlag = field.getDataType().equalsIgnoreCase(primaryVarcharEnum.getDataType());
boolean viewFlag = field.getDataType().equalsIgnoreCase(mapEntity.getValue());
if(enumFlag || viewFlag){
primaryFlag = true;
}
}
if(!primaryFlag){
throw new DataException("主键必须为字符串或整型、长整型");
}
}
}
}
}
}

View File

@@ -0,0 +1,414 @@
package com.yunzhupaas.base.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunzhupaas.base.entity.DictionaryDataEntity;
import com.yunzhupaas.base.entity.DictionaryTypeEntity;
import com.yunzhupaas.base.mapper.DictionaryDataMapper;
import com.yunzhupaas.base.model.dictionarydata.DictionaryDataExportModel;
import com.yunzhupaas.base.model.dictionarytype.DictionaryExportModel;
import com.yunzhupaas.base.service.DictionaryDataService;
import com.yunzhupaas.base.service.DictionaryTypeService;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.constant.MsgCode;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.util.*;
import com.yunzhupaas.emnus.ModuleTypeEnum;
import com.yunzhupaas.util.FileExport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.*;
import java.util.stream.Collectors;
/**
* 字典数据
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2023/09/27
*/
@Service
public class DictionaryDataServiceImpl extends SuperServiceImpl<DictionaryDataMapper, DictionaryDataEntity> implements DictionaryDataService {
@Autowired
private DictionaryTypeService dictionaryTypeService;
@Autowired
private FileExport fileExport;
@Autowired
private ConfigValueUtil configValueUtil;
@Override
public List<DictionaryDataEntity> getList(String dictionaryTypeId, Boolean enable) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId);
if (enable) {
queryWrapper.lambda().eq(DictionaryDataEntity::getEnabledMark, 1);
}
queryWrapper.lambda().orderByAsc(DictionaryDataEntity::getSortCode).orderByDesc(DictionaryDataEntity::getCreatorTime).orderByDesc(DictionaryDataEntity::getLastModifyTime);
return this.list(queryWrapper);
}
@Override
public List<DictionaryDataEntity> getList(String dictionaryTypeId) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId);
queryWrapper.lambda().orderByAsc(DictionaryDataEntity::getSortCode)
.orderByDesc(DictionaryDataEntity::getCreatorTime);
return this.list(queryWrapper);
}
@Override
public List<DictionaryDataEntity> getDicList(String dictionaryTypeId) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().and(
t -> t.eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId)
.or().eq(DictionaryDataEntity::getEnCode, dictionaryTypeId)
);
queryWrapper.lambda().select(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName, DictionaryDataEntity::getEnCode);
return this.list(queryWrapper);
}
@Override
public List<DictionaryDataEntity> geDicList(String dictionaryTypeId) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().and(
t -> t.eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId)
.or().eq(DictionaryDataEntity::getEnCode, dictionaryTypeId)
);
queryWrapper.lambda().select(DictionaryDataEntity::getId, DictionaryDataEntity::getFullName, DictionaryDataEntity::getEnabledMark);
return this.list(queryWrapper);
}
@Override
public Boolean isExistSubset(String parentId) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getParentId, parentId);
return this.list(queryWrapper).size() > 0;
}
@Override
public DictionaryDataEntity getInfo(String id) {
if (id == null) {
return null;
}
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getId, id);
return this.getOne(queryWrapper);
}
@Override
public DictionaryDataEntity getSwapInfo(String value, String dictionaryTypeId) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId).and(
t -> t.eq(DictionaryDataEntity::getId, value)
.or().eq(DictionaryDataEntity::getEnCode, value)
);
return this.getOne(queryWrapper);
}
@Override
public boolean isExistByFullName(String dictionaryTypeId, String fullName, String id) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getFullName, fullName).eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(DictionaryDataEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
public boolean isExistByEnCode(String dictionaryTypeId, String enCode, String id) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getEnCode, enCode).eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeId);
if (!StringUtil.isEmpty(id)) {
queryWrapper.lambda().ne(DictionaryDataEntity::getId, id);
}
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
public void delete(DictionaryDataEntity entity) {
this.removeById(entity.getId());
}
@Override
public void create(DictionaryDataEntity entity) {
//判断id是否为空,为空则为新建
if (StringUtil.isEmpty(entity.getId())) {
entity.setId(RandomUtil.uuId());
entity.setSimpleSpelling(PinYinUtil.getFirstSpell(entity.getFullName()).toUpperCase());
entity.setCreatorUserId(UserProvider.getUser().getUserId());
}
this.save(entity);
}
@Override
public boolean update(String id, DictionaryDataEntity entity) {
entity.setId(id);
entity.setLastModifyTime(DateUtil.getNowDate());
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
return this.updateById(entity);
}
@Override
public boolean first(String id) {
boolean isOk = false;
//获取要上移的那条数据的信息
DictionaryDataEntity upEntity = this.getById(id);
Long upSortCode = upEntity.getSortCode() == null ? 0 : upEntity.getSortCode();
//查询上几条记录
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(DictionaryDataEntity::getDictionaryTypeId, upEntity.getDictionaryTypeId())
.eq(DictionaryDataEntity::getParentId, upEntity.getParentId())
.lt(DictionaryDataEntity::getSortCode, upSortCode)
.orderByDesc(DictionaryDataEntity::getSortCode);
List<DictionaryDataEntity> downEntity = this.list(queryWrapper);
if (downEntity.size() > 0) {
//交换两条记录的sort值
Long temp = upEntity.getSortCode();
upEntity.setSortCode(downEntity.get(0).getSortCode());
downEntity.get(0).setSortCode(temp);
updateById(downEntity.get(0));
updateById(upEntity);
isOk = true;
}
return isOk;
}
@Override
public boolean next(String id) {
boolean isOk = false;
//获取要下移的那条数据的信息
DictionaryDataEntity downEntity = this.getById(id);
Long upSortCode = downEntity.getSortCode() == null ? 0 : downEntity.getSortCode();
//查询下几条记录
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(DictionaryDataEntity::getDictionaryTypeId, downEntity.getDictionaryTypeId())
.eq(DictionaryDataEntity::getParentId, downEntity.getParentId())
.gt(DictionaryDataEntity::getSortCode, upSortCode)
.orderByAsc(DictionaryDataEntity::getSortCode);
List<DictionaryDataEntity> upEntity = this.list(queryWrapper);
if (upEntity.size() > 0) {
//交换两条记录的sort值
Long temp = downEntity.getSortCode();
downEntity.setSortCode(upEntity.get(0).getSortCode());
upEntity.get(0).setSortCode(temp);
updateById(upEntity.get(0));
updateById(downEntity);
isOk = true;
}
return isOk;
}
@Override
public List<DictionaryDataEntity> getDictionName(List<String> id) {
List<DictionaryDataEntity> dictionList = new ArrayList<>();
if (id != null && id.size() > 0) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().and(
t -> t.in(DictionaryDataEntity::getEnCode, id)
.or().in(DictionaryDataEntity::getId, id)
);
queryWrapper.lambda().orderByAsc(DictionaryDataEntity::getParentId);
dictionList = this.list(queryWrapper);
}
return dictionList;
}
@Override
public DownloadVO exportData(String id) {
//获取数据分类字段详情
DictionaryTypeEntity typeEntity = dictionaryTypeService.getInfo(id);
if (typeEntity == null) {
throw new DataException(MsgCode.FA001.get());
}
DictionaryExportModel exportModel = new DictionaryExportModel();
//递归子分类
List<DictionaryTypeEntity> typeList = new ArrayList<>();
List<DictionaryTypeEntity> typeEntityList = dictionaryTypeService.getList();
typeList.add(typeEntity);
getDictionaryTypeEntitySet(typeEntity, typeList, typeEntityList);
List<DictionaryTypeEntity> collect = typeList.stream().distinct().collect(Collectors.toList());
//判断是否有子分类
if (collect.size() > 0) {
exportModel.setList(collect);
}
//获取该类型下的数据
List<DictionaryDataExportModel> modelList = new ArrayList<>();
for (DictionaryTypeEntity dictionaryTypeEntity : exportModel.getList()) {
List<DictionaryDataEntity> entityList = getList(dictionaryTypeEntity.getId());
for (DictionaryDataEntity dictionaryDataEntity : entityList) {
DictionaryDataExportModel dataExportModel = JsonUtil.getJsonToBean(dictionaryDataEntity, DictionaryDataExportModel.class);
modelList.add(dataExportModel);
}
}
exportModel.setModelList(modelList);
//导出文件
DownloadVO downloadVO = fileExport.exportFile(exportModel, configValueUtil.getTemporaryFilePath(), typeEntity.getFullName(), ModuleTypeEnum.SYSTEM_DICTIONARYDATA.getTableName());
return downloadVO;
}
/**
* 递归字典分类
*
* @param dictionaryTypeEntity 数据字典类型实体
*/
private void getDictionaryTypeEntitySet(DictionaryTypeEntity dictionaryTypeEntity, List<DictionaryTypeEntity> set, List<DictionaryTypeEntity> typeEntityList) {
//是否含有子分类
List<DictionaryTypeEntity> collect = typeEntityList.stream().filter(t -> dictionaryTypeEntity.getId().equals(t.getParentId())).collect(Collectors.toList());
if (collect.size() > 0) {
for (DictionaryTypeEntity typeEntity : collect) {
set.add(typeEntity);
getDictionaryTypeEntitySet(typeEntity, set, typeEntityList);
}
}
}
@Override
@DSTransactional
public ActionResult importData(DictionaryExportModel exportModel, Integer type) throws DataException {
try {
StringBuilder message = new StringBuilder();
StringJoiner exceptionMessage = new StringJoiner("");
List<DictionaryTypeEntity> list = JsonUtil.getJsonToList(exportModel.getList(), DictionaryTypeEntity.class);
List<DictionaryDataEntity> entityList = JsonUtil.getJsonToList(exportModel.getModelList(), DictionaryDataEntity.class);
//遍历插入分类
StringJoiner IDMessage = new StringJoiner("");
StringJoiner fullNameMessage = new StringJoiner("");
StringJoiner enCodeMessage = new StringJoiner("");
Map<String, String> idFor = new HashMap<>();
for (DictionaryTypeEntity entity : list) {
String copyNum = UUID.randomUUID().toString().substring(0, 5);
if (dictionaryTypeService.getInfo(entity.getId()) != null) {
IDMessage.add(entity.getId());
}
if (dictionaryTypeService.isExistByFullName(entity.getFullName(), null)) {
fullNameMessage.add(entity.getFullName());
}
if (dictionaryTypeService.isExistByEnCode(entity.getEnCode(), null)) {
enCodeMessage.add(entity.getEnCode());
}
if ((IDMessage.length() > 0 || fullNameMessage.length() > 0 || enCodeMessage.length() > 0)) {
if (ObjectUtil.equal(type, 1)) {
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
entity.setEnCode(entity.getEnCode() + copyNum);
String oldId = entity.getId();
entity.setId(RandomUtil.uuId());
dictionaryTypeService.setIgnoreLogicDelete().removeById(entity);
if (Optional.ofNullable(idFor.get(entity.getParentId())).isPresent()) {
entity.setParentId(idFor.get(entity.getParentId()));
}
dictionaryTypeService.setIgnoreLogicDelete().saveOrUpdate(entity);
idFor.put(oldId, entity.getId());
}
} else {
dictionaryTypeService.setIgnoreLogicDelete().removeById(entity);
dictionaryTypeService.setIgnoreLogicDelete().saveOrUpdate(entity);
}
}
if (IDMessage.length() > 0) {
exceptionMessage.add("ID" + IDMessage.toString() + ")重复");
}
if (enCodeMessage.length() > 0) {
exceptionMessage.add("编码(" + IDMessage.toString() + ")重复");
}
if (fullNameMessage.length() > 0) {
exceptionMessage.add("名称(" + IDMessage.toString() + ")重复");
}
if (exceptionMessage.length() > 0) {
message.append(exceptionMessage.toString()).append("");
exceptionMessage = new StringJoiner("");
IDMessage = new StringJoiner("");
fullNameMessage = new StringJoiner("");
enCodeMessage = new StringJoiner("");
}
for (DictionaryDataEntity entity1 : entityList) {
String copyNum = UUID.randomUUID().toString().substring(0, 5);
if (this.getInfo(entity1.getId()) != null) {
IDMessage.add(entity1.getId());
}
if (this.isExistByFullName(entity1.getDictionaryTypeId(), entity1.getFullName(), null)) {
fullNameMessage.add(entity1.getFullName());
}
if (this.isExistByEnCode(entity1.getDictionaryTypeId(), entity1.getEnCode(), null)) {
enCodeMessage.add(entity1.getEnCode());
}
if (ObjectUtil.equal(type, 1)) {
entity1.setId(RandomUtil.uuId());
if (Optional.ofNullable(idFor.get(entity1.getDictionaryTypeId())).isPresent()) {
entity1.setDictionaryTypeId(idFor.get(entity1.getDictionaryTypeId()));
}
if (this.isExistByFullName(entity1.getDictionaryTypeId(), entity1.getFullName(), null)
|| this.isExistByEnCode(entity1.getDictionaryTypeId(), entity1.getEnCode(), null)) {
entity1.setFullName(entity1.getFullName() + ".副本" + copyNum);
entity1.setEnCode(entity1.getEnCode() + copyNum);
}
this.setIgnoreLogicDelete().saveOrUpdate(entity1);
} else if (IDMessage.length() == 0 && fullNameMessage.length() == 0 && enCodeMessage.length() == 0) {
this.setIgnoreLogicDelete().removeById(entity1);
this.setIgnoreLogicDelete().saveOrUpdate(entity1);
}
}
if (IDMessage.length() > 0) {
exceptionMessage.add("ID" + IDMessage.toString() + ")重复");
}
if (enCodeMessage.length() > 0) {
exceptionMessage.add("编码(" + enCodeMessage.toString() + ")重复");
}
if (fullNameMessage.length() > 0) {
exceptionMessage.add("名称(" + fullNameMessage.toString() + ")重复");
}
if (exceptionMessage.length() > 0) {
message.append("modelList" + exceptionMessage.toString() + "");
}
if (ObjectUtil.equal(type, 0) && message.length() > 0) {
return ActionResult.fail(message.toString().substring(0, message.lastIndexOf("")));
}
return ActionResult.success(MsgCode.IMP001.get());
} catch (Exception e) {
//手动回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new DataException(e.getMessage());
} finally {
this.clearIgnoreLogicDelete();
dictionaryTypeService.clearIgnoreLogicDelete();
this.clearIgnoreLogicDelete();
}
}
@Override
public List<DictionaryDataEntity> getListByTypeDataCode(String typeCode) {
DictionaryTypeEntity dictionaryTypeEntity = dictionaryTypeService.getInfoByEnCode(typeCode);
List<DictionaryDataEntity> list = new ArrayList<>();
if (dictionaryTypeEntity != null) {
list = this.getList(dictionaryTypeEntity.getId());
}
return list;
}
@Override
public List<DictionaryDataEntity> getByTypeCodeEnable(String typeCode) {
DictionaryTypeEntity dictionaryTypeEntity = dictionaryTypeService.getInfoByEnCode(typeCode);
List<DictionaryDataEntity> list = new ArrayList<>();
if (dictionaryTypeEntity != null) {
QueryWrapper<DictionaryDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(DictionaryDataEntity::getDictionaryTypeId, dictionaryTypeEntity.getId());
queryWrapper.lambda().eq(DictionaryDataEntity::getEnabledMark, 1);
queryWrapper.lambda().orderByAsc(DictionaryDataEntity::getSortCode)
.orderByDesc(DictionaryDataEntity::getCreatorTime);
list= this.list(queryWrapper);
}
return list;
}
}

Some files were not shown because too many files have changed in this diff Show More