修改数据源驱动
This commit is contained in:
parent
c90ab1a102
commit
d41e02aea7
@ -0,0 +1,18 @@
|
||||
package com.czlis.common.core.domain.entity.lis;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LabInstrgroupdetail {
|
||||
|
||||
private String fzdh;
|
||||
private String yq;
|
||||
private Integer seq;
|
||||
private String yljg;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.czlis.common.core.domain.entity.lis;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LabInstrgroupmain {
|
||||
|
||||
private String fzdh;
|
||||
private String fzmc;
|
||||
private String bz;
|
||||
private String tj_flag;
|
||||
private String yljg;
|
||||
private String yq;
|
||||
private Integer seq;
|
||||
|
||||
}
|
||||
@ -14,4 +14,7 @@ public class XmComp {
|
||||
private String xmdh;
|
||||
private String bz;
|
||||
private Integer seq;
|
||||
private String zhmcold;
|
||||
private String zhlxold;
|
||||
private String xmdhold;
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ public class SysLogConstants {
|
||||
public static final String LISWORK_LOG = "主界面";
|
||||
public static final String COMOPT_LOG = "后台参数";
|
||||
public static final String LABINPUTMDL_LOG = "项目模板";
|
||||
public static final String LabInstrgroupdetail_LOG="仪器组合";
|
||||
public static final String LabInstrgroupmain_LOG="仪器组合明细";
|
||||
public static final String LABINSTRVSREQCLASS_LOG = "仪器条码类别对照";
|
||||
public static final String LABTATCTRL_LOG = "TAT设定";
|
||||
public static final String XMCOMP_LOG = "项目组合";
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.com.kingbase</groupId>
|
||||
<groupId>com.kingbase</groupId>
|
||||
<artifactId>kingbase8</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.czlis.system.config;
|
||||
|
||||
import com.czlis.common.utils.StringUtils;
|
||||
import com.czlis.system.interceptor.SqlServerSqlConvertInterceptor;
|
||||
import org.apache.ibatis.io.VFS;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
|
||||
@ -105,6 +107,13 @@ public class MyBatisConfig {
|
||||
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
|
||||
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
|
||||
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
|
||||
|
||||
// ============ 新增:注册自定义MyBatis拦截器 ============
|
||||
Interceptor[] plugins = new Interceptor[]{
|
||||
new SqlServerSqlConvertInterceptor()
|
||||
};
|
||||
sessionFactory.setPlugins(plugins);
|
||||
|
||||
return sessionFactory.getObject();
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
package com.czlis.system.config;
|
||||
|
||||
import com.czlis.system.interceptor.SqlPlusToConcatInterceptor;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class MyBatisPluginConfig {
|
||||
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Bean
|
||||
public ApplicationListener<ContextRefreshedEvent> registerInterceptor() {
|
||||
return event -> {
|
||||
Map<String, SqlSessionFactory> map = applicationContext.getBeansOfType(SqlSessionFactory.class);
|
||||
SqlPlusToConcatInterceptor interceptor = new SqlPlusToConcatInterceptor();
|
||||
for (SqlSessionFactory sf : map.values()) {
|
||||
sf.getConfiguration().addInterceptor(interceptor);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,153 +0,0 @@
|
||||
package com.czlis.system.interceptor;
|
||||
|
||||
import org.apache.ibatis.executor.statement.StatementHandler;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* SQLServer转达梦 MyBatis SQL兼容拦截器
|
||||
* 全部正则模式,不依赖JSqlParser解析器,解决低版本jar包类缺失问题
|
||||
* 注意:该模式无法区分数字相加和字符串拼接,SQL尽量不要同时出现数字+运算
|
||||
*/
|
||||
@Intercepts({
|
||||
@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})
|
||||
})
|
||||
public class SqlPlusToConcatInterceptor implements Interceptor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SqlPlusToConcatInterceptor.class);
|
||||
|
||||
// '常量'+col 或者 col+'常量'
|
||||
private static final Pattern CONCAT_PATTERN = Pattern.compile("(\\s*'[^']*'\\s*\\+|\\+\\s*'[^']*')");
|
||||
|
||||
// CHARINDEX(a,b)
|
||||
private static final Pattern CHARINDEX_PATTERN = Pattern.compile("CHARINDEX\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
// ISNULL(a,b)
|
||||
private static final Pattern ISNULL_2PARAM_PATTERN = Pattern.compile("ISNULL\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
// RIGHT(REPLICATE(' ',N)+expr,N)
|
||||
private static final Pattern RIGHT_REPLICATE_PATTERN = Pattern.compile(
|
||||
"RIGHT\\s*\\(\\s*REPLICATE\\s*\\(\\s*'\\s*'\\s*,\\s*(\\d+)\\s*\\)\\s*\\+\\s*(.+?)\\s*,\\s*(\\d+)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.DOTALL
|
||||
);
|
||||
|
||||
// REPLICATE(str,N)
|
||||
private static final Pattern REPLICATE_PATTERN = Pattern.compile(
|
||||
"REPLICATE\\s*\\(\\s*(.+?)\\s*,\\s*(\\d+)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.DOTALL
|
||||
);
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
log.info("====进入SQL兼容拦截器====");
|
||||
StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
|
||||
BoundSql boundSql = statementHandler.getBoundSql();
|
||||
String originSql = boundSql.getSql();
|
||||
Connection connection = (Connection) invocation.getArgs()[0];
|
||||
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
String productName = metaData.getDatabaseProductName();
|
||||
boolean enableConvert = productName != null && productName.toUpperCase().contains("DM");
|
||||
log.info("识别数据库产品名称:[{}], 是否开启SQL兼容转换:{}", productName, enableConvert);
|
||||
|
||||
try {
|
||||
if (!enableConvert) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
String lowerSql = originSql.trim().toLowerCase();
|
||||
if (lowerSql.startsWith("call ") || lowerSql.startsWith("exec ")) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
String targetSql = originSql;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
//1. RIGHT(REPLICATE(' ',N)+expr,N) → SUBSTR(LPAD(expr,N,' '),1,N)
|
||||
Matcher mRightRep = RIGHT_REPLICATE_PATTERN.matcher(targetSql);
|
||||
sb.setLength(0);
|
||||
while (mRightRep.find()) {
|
||||
String num = mRightRep.group(1).trim();
|
||||
String expr = mRightRep.group(2).trim();
|
||||
String newExpr = String.format("SUBSTR(LPAD(%s,%s,' '),1,%s)", expr, num, num);
|
||||
mRightRep.appendReplacement(sb, Matcher.quoteReplacement(newExpr));
|
||||
}
|
||||
mRightRep.appendTail(sb);
|
||||
targetSql = sb.toString();
|
||||
|
||||
//2. 'xxx' + col / col + 'xxx' 加号替换为 ||
|
||||
Matcher mConcat = CONCAT_PATTERN.matcher(targetSql);
|
||||
sb.setLength(0);
|
||||
while (mConcat.find()) {
|
||||
String found = mConcat.group();
|
||||
mConcat.appendReplacement(sb, Matcher.quoteReplacement(found.replace("+", "||")));
|
||||
}
|
||||
mConcat.appendTail(sb);
|
||||
targetSql = sb.toString();
|
||||
|
||||
//3. CHARINDEX(a,b) → INSTR(b,a)
|
||||
Matcher mCharIndex = CHARINDEX_PATTERN.matcher(targetSql);
|
||||
sb.setLength(0);
|
||||
while (mCharIndex.find()) {
|
||||
String p1 = mCharIndex.group(1).trim();
|
||||
String p2 = mCharIndex.group(2).trim();
|
||||
String newFunc = String.format("INSTR(%s,%s)", p2, p1);
|
||||
mCharIndex.appendReplacement(sb, Matcher.quoteReplacement(newFunc));
|
||||
}
|
||||
mCharIndex.appendTail(sb);
|
||||
targetSql = sb.toString();
|
||||
|
||||
//4. ISNULL(a,b) → NVL(a,b)
|
||||
Matcher mIsnull = ISNULL_2PARAM_PATTERN.matcher(targetSql);
|
||||
sb.setLength(0);
|
||||
while (mIsnull.find()) {
|
||||
String p1 = mIsnull.group(1).trim();
|
||||
String p2 = mIsnull.group(2).trim();
|
||||
String newFunc = String.format("NVL(%s,%s)", p1, p2);
|
||||
mIsnull.appendReplacement(sb, Matcher.quoteReplacement(newFunc));
|
||||
}
|
||||
mIsnull.appendTail(sb);
|
||||
targetSql = sb.toString();
|
||||
|
||||
//5. REPLICATE(str,N) → REPEAT(str,N)
|
||||
Matcher mRep = REPLICATE_PATTERN.matcher(targetSql);
|
||||
sb.setLength(0);
|
||||
while (mRep.find()) {
|
||||
String src = mRep.group(1).trim();
|
||||
String cnt = mRep.group(2).trim();
|
||||
String newFunc = String.format("REPEAT(%s,%s)", src, cnt);
|
||||
mRep.appendReplacement(sb, Matcher.quoteReplacement(newFunc));
|
||||
}
|
||||
mRep.appendTail(sb);
|
||||
targetSql = sb.toString();
|
||||
|
||||
//回填修改后的SQL
|
||||
if (!originSql.equals(targetSql)) {
|
||||
log.debug("【SQL兼容转换】\n原SQL:\n{}\n转换后:\n{}", originSql, targetSql);
|
||||
org.apache.ibatis.reflection.MetaObject metaObject
|
||||
= org.apache.ibatis.reflection.SystemMetaObject.forObject(statementHandler);
|
||||
metaObject.setValue("delegate.boundSql.sql", targetSql);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("【SQL转换处理异常,直接放行原始SQL】sql:{} , ex:{}", originSql, e.getMessage());
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
package com.czlis.system.interceptor;
|
||||
|
||||
import org.apache.ibatis.executor.statement.StatementHandler;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.plugin.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 统一SQL跨数据库转换拦截器
|
||||
* 源SQL标准:SQL Server语法
|
||||
* 目标适配:达梦 DM8 / 人大金仓 KingbaseES
|
||||
* 转换清单:
|
||||
* 1. 字符串 +拼接 → ||
|
||||
* 2. REPLICATE(str,n) → REPEAT(str,n)
|
||||
* 3. CHARINDEX(needle,haystack) 差异化转换
|
||||
* - DM:INSTR(haystack,needle)
|
||||
* - Kingbase:POSITION(needle IN haystack)
|
||||
* 4. ISNULL(expr,default) 差异化转换
|
||||
* - DM:NVL(expr,default)
|
||||
* - Kingbase:COALESCE(expr,default)
|
||||
* 5. Kingbase:GETDATE() → CURRENT_TIMESTAMP
|
||||
* 6. Kingbase:sys_xxx 系统表补schema dbo.
|
||||
*/
|
||||
@Intercepts({
|
||||
@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})
|
||||
})
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public class SqlServerSqlConvertInterceptor implements Interceptor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SqlServerSqlConvertInterceptor.class);
|
||||
|
||||
// ============ 配置项,生产环境建议关闭完整SQL打印 ============
|
||||
private static final boolean PRINT_FULL_SQL_LOG = false;
|
||||
|
||||
// ==================== 通用正则 ====================
|
||||
// 规避:数字加法 1+2,只匹配一侧/两侧存在字符串常量的加号拼接(仍有局限,极致方案需要SQL解析器)
|
||||
private static final Pattern SQL_PLUS_CONCAT_PATTERN = Pattern.compile(
|
||||
"((['\"].*?['\"])|[a-zA-Z0-9_.]+)\\s*\\+\\s*((['\"].*?['\"])|[a-zA-Z0-9_.]+)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
|
||||
private static final Pattern REPLICATE_PATTERN = Pattern.compile(
|
||||
"REPLICATE\\s*\\(\\s*(.+?)\\s*,\\s*(\\d+)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
|
||||
// ==================== 达梦DM正则 ====================
|
||||
private static final Pattern DM_CHARINDEX_PATTERN = Pattern.compile(
|
||||
"CHARINDEX\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
private static final Pattern DM_ISNULL_PATTERN = Pattern.compile(
|
||||
"ISNULL\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
|
||||
// ==================== 金仓Kingbase正则 ====================
|
||||
private static final Pattern KINGBASE_CHARINDEX_PATTERN = Pattern.compile(
|
||||
"CHARINDEX\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
private static final Pattern KINGBASE_ISNULL_PATTERN = Pattern.compile(
|
||||
"ISNULL\\s*\\(\\s*(.+?)\\s*,\\s*(.+?)\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
private static final Pattern KINGBASE_GETDATE_PATTERN = Pattern.compile(
|
||||
"\\bGETDATE\\s*\\(\\s*\\)",
|
||||
Pattern.CASE_INSENSITIVE
|
||||
);
|
||||
private static final Pattern[] KINGBASE_SYS_TABLE_PATTERNS = {
|
||||
Pattern.compile("\\bsys_config\\b", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("\\bsys_user\\b", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("\\bsys_role\\b", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("\\bsys_sequence\\b", Pattern.CASE_INSENSITIVE)
|
||||
};
|
||||
private static final String KINGBASE_SYS_TABLE_REPLACE = "dbo.$0";
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
|
||||
BoundSql boundSql = statementHandler.getBoundSql();
|
||||
String originSql = boundSql.getSql();
|
||||
Connection connection = (Connection) invocation.getArgs()[0];
|
||||
|
||||
// 获取数据库类型
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
String rawDbName = metaData.getDatabaseProductName();
|
||||
String productName = rawDbName.toUpperCase().trim();
|
||||
boolean isDm = productName.contains("DM");
|
||||
boolean isKingbase = productName.contains("KINGBASE");
|
||||
|
||||
if (!isDm && !isKingbase) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
// 跳过存储过程调用
|
||||
String lowerSql = originSql.trim().toLowerCase();
|
||||
if (lowerSql.startsWith("call ") || lowerSql.startsWith("exec ")) {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
String targetSql = originSql;
|
||||
try {
|
||||
// 1. REPLICATE -> REPEAT
|
||||
targetSql = replaceAll(targetSql, REPLICATE_PATTERN, m -> {
|
||||
String expr = Matcher.quoteReplacement(m.group(1));
|
||||
String num = Matcher.quoteReplacement(m.group(2));
|
||||
return "REPEAT(" + expr + "," + num + ")";
|
||||
});
|
||||
|
||||
// 2. 字符串 + 拼接 转为 ||
|
||||
targetSql = replaceAll(targetSql, SQL_PLUS_CONCAT_PATTERN, m -> {
|
||||
String g1 = Matcher.quoteReplacement(m.group(1));
|
||||
String g2 = Matcher.quoteReplacement(m.group(2));
|
||||
// 简单过滤:两边都是数字则不转换,防止破坏数值运算(简易策略)
|
||||
if (isNumeric(g1) && isNumeric(g2)) {
|
||||
return m.group();
|
||||
}
|
||||
return g1 + " || " + g2;
|
||||
});
|
||||
|
||||
if (isDm) {
|
||||
// CHARINDEX(a,b) → INSTR(b,a)
|
||||
targetSql = replaceAll(targetSql, DM_CHARINDEX_PATTERN, m -> {
|
||||
String p1 = Matcher.quoteReplacement(m.group(1));
|
||||
String p2 = Matcher.quoteReplacement(m.group(2));
|
||||
return "INSTR(" + p2 + "," + p1 + ")";
|
||||
});
|
||||
// ISNULL → NVL
|
||||
targetSql = replaceAll(targetSql, DM_ISNULL_PATTERN, m -> {
|
||||
String p1 = Matcher.quoteReplacement(m.group(1));
|
||||
String p2 = Matcher.quoteReplacement(m.group(2));
|
||||
return "NVL(" + p1 + "," + p2 + ")";
|
||||
});
|
||||
} else if (isKingbase) {
|
||||
// CHARINDEX(a,b) → POSITION(a IN b)
|
||||
targetSql = replaceAll(targetSql, KINGBASE_CHARINDEX_PATTERN, m -> {
|
||||
String p1 = Matcher.quoteReplacement(m.group(1));
|
||||
String p2 = Matcher.quoteReplacement(m.group(2));
|
||||
return "POSITION(" + p1 + " IN " + p2 + ")";
|
||||
});
|
||||
// ISNULL → COALESCE
|
||||
targetSql = replaceAll(targetSql, KINGBASE_ISNULL_PATTERN, m -> {
|
||||
String p1 = Matcher.quoteReplacement(m.group(1));
|
||||
String p2 = Matcher.quoteReplacement(m.group(2));
|
||||
return "COALESCE(" + p1 + "," + p2 + ")";
|
||||
});
|
||||
// 【修复】GETDATE() → LOCALTIMESTAMP,无时区timestamp
|
||||
targetSql = replaceAll(targetSql, KINGBASE_GETDATE_PATTERN, matcher -> "LOCALTIMESTAMP");
|
||||
|
||||
// 系统表补schema,负向断言防止重复生成 dbo.dbo.xxx
|
||||
for (Pattern tablePat : KINGBASE_SYS_TABLE_PATTERNS) {
|
||||
targetSql = replaceAll(targetSql, tablePat, m -> "dbo." + m.group());
|
||||
}
|
||||
}
|
||||
|
||||
// 改写BoundSql
|
||||
if (!originSql.equals(targetSql)) {
|
||||
org.apache.ibatis.reflection.MetaObject metaObject
|
||||
= org.apache.ibatis.reflection.SystemMetaObject.forObject(statementHandler);
|
||||
metaObject.setValue("delegate.boundSql.sql", targetSql);
|
||||
if (PRINT_FULL_SQL_LOG) {
|
||||
log.info("【SQL转换生效】数据库:{} \n原SQL:\n{}\n转换后:\n{}", productName, originSql, targetSql);
|
||||
} else {
|
||||
log.debug("【SQL转换生效】数据库:{}", productName);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("【SQL语法转换异常,放行原始SQL】msg={}", e.getMessage(), e);
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用正则替换工具,消除重复StringBuffer样板代码
|
||||
*/
|
||||
private String replaceAll(String sql, Pattern pattern, java.util.function.Function<Matcher, String> replacer) {
|
||||
Matcher matcher = pattern.matcher(sql);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(sb, Matcher.quoteReplacement(replacer.apply(matcher)));
|
||||
}
|
||||
matcher.appendTail(sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 简易判断是否纯数字,用于区分字符串加号与数值加法
|
||||
*/
|
||||
private boolean isNumeric(String str) {
|
||||
return str.matches("^\\d+(\\.\\d+)?$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
}
|
||||
}
|
||||
61
lis-system/src/main/resources/application-dm.yml
Normal file
61
lis-system/src/main/resources/application-dm.yml
Normal file
@ -0,0 +1,61 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: dm.jdbc.driver.DmDriver
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:dm://118.31.187.160:5238?schema=DBO&zeroDateTimeBehavior=convertToNull
|
||||
username: SYSDBA
|
||||
password: Aa123$%^
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置连接超时时间
|
||||
connectTimeout: 30000
|
||||
# 配置网络超时时间
|
||||
socketTimeout: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username: czlis
|
||||
login-password: 123456
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 10000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
61
lis-system/src/main/resources/application-kingbase.yml
Normal file
61
lis-system/src/main/resources/application-kingbase.yml
Normal file
@ -0,0 +1,61 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.kingbase8.Driver
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:kingbase8://192.168.100.110:54321/lisnet?currentSchema=dbo
|
||||
username: system
|
||||
password: Aa123$%^
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置连接超时时间
|
||||
connectTimeout: 30000
|
||||
# 配置网络超时时间
|
||||
socketTimeout: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username: czlis
|
||||
login-password: 123456
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 10000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
@ -134,9 +134,12 @@ mybatis:
|
||||
|
||||
# PageHelper分页插件
|
||||
pagehelper:
|
||||
helperDialect: sqlserver
|
||||
# helperDialect: postgresql
|
||||
auto-runtime-dialect: true
|
||||
supportMethodsArguments: true
|
||||
params: count=countSql
|
||||
params: count=countSql;pageNum=pageNum;pageSize=pageSize
|
||||
reasonable: true # 页码合理化,按需开启
|
||||
pageSizeZero: false # pageSize=0 是否查询全部
|
||||
|
||||
# Swagger配置
|
||||
swagger:
|
||||
|
||||
@ -193,7 +193,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="loginDate != null">login_date = #{loginDate, jdbcType=TIMESTAMP},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
update_time = getdate()
|
||||
|
||||
@ -18,5 +18,4 @@ PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
<!--默认为null 的值也显示出来-->
|
||||
<setting name="callSettersOnNulls" value="true"/>
|
||||
</settings>
|
||||
|
||||
</configuration>
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.czlis.liswork.controller.xtwh;
|
||||
|
||||
import com.czlis.common.annotation.Log;
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupdetail;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupmain;
|
||||
import com.czlis.common.enums.BusinessType;
|
||||
import com.czlis.interfaceCommon.constants.SysLogConstants;
|
||||
import com.czlis.liswork.pojo.DTO.LabInstrgroupmainDTO;
|
||||
import com.czlis.liswork.service.LabInstrgroupmainService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "仪器组合")
|
||||
@RestController
|
||||
@RequestMapping("/instrgroup")
|
||||
@Slf4j
|
||||
public class LabInstrgroupmainController {
|
||||
|
||||
@Resource
|
||||
private LabInstrgroupmainService labInstrgroupmainService;
|
||||
@ApiOperation("查询仪器组合列表")
|
||||
@GetMapping("/query")
|
||||
public Result query(LabInstrgroupmain LabInstrgroupmain) {
|
||||
return labInstrgroupmainService.query(LabInstrgroupmain);
|
||||
}
|
||||
|
||||
@ApiOperation("查询明细数据")
|
||||
@GetMapping("/queryDetail")
|
||||
public Result queryDetail(LabInstrgroupdetail LabInstrgroupmainDetail){
|
||||
return labInstrgroupmainService.queryDetail(LabInstrgroupmainDetail);
|
||||
}
|
||||
|
||||
@Log(title = SysLogConstants.LabInstrgroupmain_LOG,businessType = BusinessType.INSERT)
|
||||
@ApiOperation("新增仪器组合")
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody LabInstrgroupmainDTO LabInstrgroupmainDTO){
|
||||
return labInstrgroupmainService.add(LabInstrgroupmainDTO);
|
||||
}
|
||||
|
||||
@Log(title = SysLogConstants.LabInstrgroupmain_LOG,businessType = BusinessType.UPDATE)
|
||||
@ApiOperation("修改仪器组合")
|
||||
@PostMapping("/update")
|
||||
public Result update(@RequestBody LabInstrgroupmainDTO LabInstrgroupmainDTO){
|
||||
return labInstrgroupmainService.update(LabInstrgroupmainDTO);
|
||||
}
|
||||
|
||||
@Log(title = SysLogConstants.LabInstrgroupmain_LOG,businessType = BusinessType.DELETE)
|
||||
@ApiOperation("删除仪器组合")
|
||||
@GetMapping("/delete")
|
||||
public Result delete(LabInstrgroupmain LabInstrgroupmain){
|
||||
return labInstrgroupmainService.delete(LabInstrgroupmain);
|
||||
}
|
||||
|
||||
@Log(title = SysLogConstants.LabInstrgroupdetail_LOG,businessType = BusinessType.DELETE_DETAIL)
|
||||
@ApiOperation("删除明细数据")
|
||||
@PostMapping("/deleteDetail")
|
||||
public Result deleteDetail(@RequestBody List<LabInstrgroupdetail> LabInstrgroupmainDetailList){
|
||||
return labInstrgroupmainService.deleteDetail(LabInstrgroupmainDetailList);
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.XmComp;
|
||||
import com.czlis.common.enums.BusinessType;
|
||||
import com.czlis.interfaceCommon.constants.SysLogConstants;
|
||||
import com.czlis.liswork.pojo.DTO.XmCompDTO;
|
||||
import com.czlis.liswork.service.XmCompService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -33,14 +34,15 @@ public class XmCompController {
|
||||
@Log(title = SysLogConstants.XMCOMP_LOG,businessType = BusinessType.INSERT)
|
||||
@ApiOperation("增加项目组合")
|
||||
@PostMapping("/add")
|
||||
public Result addXmComp(@RequestBody List<XmComp> xmComp) {
|
||||
public Result addXmComp(@RequestBody XmCompDTO xmComp) {
|
||||
|
||||
return xmCompService.addXmComp(xmComp);
|
||||
}
|
||||
|
||||
@Log(title = SysLogConstants.XMCOMP_LOG,businessType = BusinessType.UPDATE)
|
||||
@ApiOperation("修改项目组合")
|
||||
@PostMapping("/update")
|
||||
public Result updateXmComp(@RequestBody List<XmComp> xmComp) {
|
||||
public Result updateXmComp(@RequestBody XmCompDTO xmComp) {
|
||||
return xmCompService.updateXmComp(xmComp);
|
||||
}
|
||||
|
||||
@ -50,4 +52,15 @@ public class XmCompController {
|
||||
public Result deleteXmComp(XmComp xmComp) {
|
||||
return xmCompService.deleteXmComp(xmComp);
|
||||
}
|
||||
@ApiOperation("查询明细数据")
|
||||
@GetMapping("/queryDetail")
|
||||
public Result queryDetail(XmComp xmComp){
|
||||
return xmCompService.queryDetail(xmComp);
|
||||
}
|
||||
@Log(title = SysLogConstants.LABINPUTMDL_LOG,businessType = BusinessType.DELETE_DETAIL)
|
||||
@ApiOperation("删除明细数据")
|
||||
@PostMapping("/deleteDetail")
|
||||
public Result deleteDetail(@RequestBody List<XmComp> xmComp){
|
||||
return xmCompService.deleteDetail(xmComp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package com.czlis.liswork.mapper.xtwh;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupdetail;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupmain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabInstrgroupmainMapper {
|
||||
List<LabInstrgroupmain> getLabInstrgroupmainList(LabInstrgroupmain xmComp);
|
||||
void addLabInstrgroupmain(LabInstrgroupmain xmComp);
|
||||
void updateLabInstrgroupmain(LabInstrgroupmain xmComp);
|
||||
void deleteLabInstrgroupmain(LabInstrgroupmain xmComp);
|
||||
List<LabInstrgroupdetail> getLabInstrgroupdetailList(LabInstrgroupdetail xmComp);
|
||||
void addLabInstrgroupdetail(LabInstrgroupdetail xmComp);
|
||||
void updateLabInstrgroupdetail(LabInstrgroupdetail xmComp);
|
||||
void deleteLabInstrgroupdetail(LabInstrgroupdetail xmComp);
|
||||
}
|
||||
@ -6,10 +6,10 @@ import java.util.List;
|
||||
|
||||
public interface XmCompMapper {
|
||||
List<XmComp> getXmCompList(XmComp xmComp);
|
||||
|
||||
List<XmComp> getXmCompMainList(XmComp xmComp);
|
||||
void addXmComp(XmComp xmComp);
|
||||
|
||||
void updateXmComp(XmComp xmComp);
|
||||
|
||||
XmComp queryDetail(XmComp xmComp);
|
||||
void deleteXmComp(XmComp xmComp);
|
||||
void deleteXmCompOld(XmComp xmComp);
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.czlis.liswork.pojo.DTO;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.LabInputmdl;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInputmdlDetail;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupdetail;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupmain;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LabInstrgroupmainDTO {
|
||||
private LabInstrgroupmain labInstrgroupmain;
|
||||
private List<LabInstrgroupdetail> labInstrgroupdetailList;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.czlis.liswork.pojo.DTO;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.XmComp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class XmCompDTO {
|
||||
private XmComp xmComp;
|
||||
private List<XmComp> xmCompList;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.czlis.liswork.service;
|
||||
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInputmdl;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInputmdlDetail;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupdetail;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInstrgroupmain;
|
||||
import com.czlis.liswork.pojo.DTO.LabInputmdlDTO;
|
||||
import com.czlis.liswork.pojo.DTO.LabInstrgroupmainDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LabInstrgroupmainService {
|
||||
Result query(LabInstrgroupmain labInstrgroupmain);
|
||||
|
||||
Result queryDetail(LabInstrgroupdetail labInstrgroupdetail);
|
||||
|
||||
Result add(LabInstrgroupmainDTO labInstrgroupmainDTO);
|
||||
|
||||
Result update(LabInstrgroupmainDTO labInstrgroupmainDTO);
|
||||
|
||||
Result delete(LabInstrgroupmain labInstrgroupmain);
|
||||
|
||||
Result deleteDetail(List<LabInstrgroupdetail> labInstrgroupdetail);
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.czlis.liswork.service;
|
||||
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.XmComp;
|
||||
import com.czlis.liswork.pojo.DTO.XmCompDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -9,9 +10,11 @@ import java.util.List;
|
||||
public interface XmCompService {
|
||||
Result getXmCompList(XmComp xmComp);
|
||||
|
||||
Result addXmComp(List<XmComp> xmComp);
|
||||
Result addXmComp(XmCompDTO xmComp);
|
||||
|
||||
Result updateXmComp(List<XmComp> xmComp);
|
||||
Result updateXmComp(XmCompDTO xmComp);
|
||||
|
||||
Result deleteXmComp(XmComp xmComp);
|
||||
Result queryDetail(XmComp xmComp);
|
||||
Result deleteDetail(List<XmComp> xmComp);
|
||||
}
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
package com.czlis.liswork.service.impl.xtwh;
|
||||
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.*;
|
||||
import com.czlis.liswork.mapper.xtwh.LabInstrgroupmainMapper;
|
||||
import com.czlis.liswork.pojo.DTO.LabInstrgroupmainDTO;
|
||||
import com.czlis.liswork.service.LabInstrgroupmainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LabInstrgroupmainServiceImpl implements LabInstrgroupmainService {
|
||||
@Autowired
|
||||
LabInstrgroupmainMapper labInstrgroupmainMapper;
|
||||
@Override
|
||||
public Result query(LabInstrgroupmain labInstrgroupmain) {
|
||||
List<LabInstrgroupmain> labInstrgroupmainList = labInstrgroupmainMapper.getLabInstrgroupmainList(labInstrgroupmain);
|
||||
return new Result("0","查询成功!",labInstrgroupmainList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryDetail(LabInstrgroupdetail labInstrgroupdetail) {
|
||||
List<LabInstrgroupdetail> labInstrgroupdetailList = labInstrgroupmainMapper.getLabInstrgroupdetailList(labInstrgroupdetail);
|
||||
return new Result("0","查询成功!",labInstrgroupdetailList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result add(LabInstrgroupmainDTO labInstrgroupmainDTO) {
|
||||
labInstrgroupmainMapper.addLabInstrgroupmain(labInstrgroupmainDTO.getLabInstrgroupmain());
|
||||
List<LabInstrgroupdetail> labInstrgroupdetailList = labInstrgroupmainDTO.getLabInstrgroupdetailList();
|
||||
for (LabInstrgroupdetail labInstrgroupdetail : labInstrgroupdetailList) {
|
||||
labInstrgroupmainMapper.addLabInstrgroupdetail(labInstrgroupdetail);
|
||||
}
|
||||
return new Result("0","新增成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result update(LabInstrgroupmainDTO labInstrgroupmainDTO) {
|
||||
labInstrgroupmainMapper.updateLabInstrgroupmain(labInstrgroupmainDTO.getLabInstrgroupmain());
|
||||
List<LabInstrgroupdetail> labInstrgroupdetailList = labInstrgroupmainDTO.getLabInstrgroupdetailList();
|
||||
for (LabInstrgroupdetail labInstrgroupdetail : labInstrgroupdetailList) {
|
||||
List<LabInstrgroupdetail> labInstrgroupdetailList1 = labInstrgroupmainMapper.getLabInstrgroupdetailList(labInstrgroupdetail);
|
||||
if(labInstrgroupdetailList1.size() > 0){
|
||||
labInstrgroupmainMapper.updateLabInstrgroupdetail(labInstrgroupdetail);
|
||||
}else{
|
||||
labInstrgroupmainMapper.addLabInstrgroupdetail(labInstrgroupdetail);
|
||||
}
|
||||
|
||||
}
|
||||
return new Result("0","修改数据成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result delete(LabInstrgroupmain labInstrgroupmain) {
|
||||
//删除列表
|
||||
labInstrgroupmainMapper.deleteLabInstrgroupmain(labInstrgroupmain);
|
||||
//删除明细
|
||||
LabInstrgroupdetail labInstrgroupdetail = new LabInstrgroupdetail();
|
||||
labInstrgroupdetail.setYq(labInstrgroupmain.getYq());
|
||||
labInstrgroupdetail.setFzdh(labInstrgroupmain.getFzdh());
|
||||
labInstrgroupmainMapper.deleteLabInstrgroupdetail(labInstrgroupdetail);
|
||||
return new Result("0","删除成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteDetail(List<LabInstrgroupdetail> labInstrgroupdetailList) {
|
||||
for (LabInstrgroupdetail labInstrgroupdetail : labInstrgroupdetailList) {
|
||||
if(labInstrgroupdetail.getYq() == null) return new Result("-1","仪器不能为空!");
|
||||
labInstrgroupmainMapper.deleteLabInstrgroupdetail(labInstrgroupdetail);
|
||||
}
|
||||
return new Result("0","删除明细成功!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
package com.czlis.liswork.service.impl.xtwh;
|
||||
|
||||
import com.czlis.common.core.domain.Result;
|
||||
import com.czlis.common.core.domain.entity.lis.LabInputmdlDetail;
|
||||
import com.czlis.common.core.domain.entity.lis.XmComp;
|
||||
import com.czlis.liswork.mapper.xtwh.XmCompMapper;
|
||||
import com.czlis.liswork.pojo.DTO.XmCompDTO;
|
||||
import com.czlis.liswork.service.XmCompService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -19,22 +21,39 @@ public class XmCompServiceImpl implements XmCompService {
|
||||
|
||||
@Override
|
||||
public Result getXmCompList(XmComp xmComp) {
|
||||
List<XmComp> xmCompList = xmCompMapper.getXmCompList(xmComp);
|
||||
List<XmComp> xmCompList = xmCompMapper.getXmCompMainList(xmComp);
|
||||
return new Result("0","查询成功!",xmCompList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addXmComp(List<XmComp> xmCompList) {
|
||||
public Result addXmComp(XmCompDTO xmCompList0) {
|
||||
XmComp head=xmCompList0.getXmComp();
|
||||
List<XmComp> xmCompList = xmCompList0.getXmCompList();
|
||||
for (XmComp xmComp : xmCompList) {
|
||||
xmCompMapper.addXmComp(xmComp);
|
||||
xmComp.setZhlx(head.getZhlx());
|
||||
xmComp.setZhmc(head.getZhmc());
|
||||
List<XmComp> xmCompList1 = xmCompMapper.getXmCompList(xmComp);
|
||||
if(xmCompList1.size() > 0){
|
||||
}else{
|
||||
xmCompMapper.addXmComp(xmComp);
|
||||
}
|
||||
}
|
||||
return new Result("0","新增数据成功!");
|
||||
return new Result("0","新增成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateXmComp(List<XmComp> xmCompList) {
|
||||
public Result updateXmComp(XmCompDTO xmCompList0) {
|
||||
XmComp head=xmCompList0.getXmComp();
|
||||
xmCompMapper.deleteXmCompOld(head);
|
||||
List<XmComp> xmCompList = xmCompList0.getXmCompList();
|
||||
for (XmComp xmComp : xmCompList) {
|
||||
xmCompMapper.updateXmComp(xmComp);
|
||||
xmComp.setZhlx(head.getZhlx());
|
||||
xmComp.setZhmc(head.getZhmc());
|
||||
List<XmComp> xmCompList1 = xmCompMapper.getXmCompList(xmComp);
|
||||
if(xmCompList1.size() > 0){
|
||||
}else{
|
||||
xmCompMapper.addXmComp(xmComp);
|
||||
}
|
||||
}
|
||||
return new Result("0","修改成功!");
|
||||
}
|
||||
@ -44,4 +63,18 @@ public class XmCompServiceImpl implements XmCompService {
|
||||
xmCompMapper.deleteXmComp(xmComp);
|
||||
return new Result("0","删除数据成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryDetail(XmComp xmComp) {
|
||||
List<XmComp> xmCompList = xmCompMapper.getXmCompList(xmComp);
|
||||
return new Result("0","查询成功!",xmCompList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteDetail(List<XmComp> xmCompList) {
|
||||
for (XmComp xmComp : xmCompList) {
|
||||
xmCompMapper.deleteXmComp(xmComp);
|
||||
}
|
||||
return new Result("0","删除数据成功!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.czlis.liswork.mapper.xtwh.LabInstrgroupmainMapper">
|
||||
|
||||
<select id="getLabInstrgroupmainList" resultType="com.czlis.common.core.domain.entity.lis.LabInstrgroupmain">
|
||||
select * from lab_instrgroupmain
|
||||
<where>
|
||||
<if test="fzdh != null and yq != ''"> and fzdh = #{fzdh}</if>
|
||||
<if test="fzmc != null and fzmc != ''"> and fzmc = #{fzmc}</if>
|
||||
<if test="bz != null and bz != ''"> and bz = #{bz}</if>
|
||||
<if test="yljg != null and yljg != ''"> and yljg = #{yljg}</if>
|
||||
<if test="tj_flag != null and tj_flag != ''"> and tj_flag = #{tj_flag}</if>
|
||||
</where>
|
||||
</select>
|
||||
<insert id="addLabInstrgroupmain">
|
||||
insert into lab_instrgroupmain(fzdh,fzmc,bz,yljg,tj_flag)values(#{fzdh},#{fzmc},#{bz},#{yljg},#{tj_flag})
|
||||
</insert>
|
||||
|
||||
<update id="updateLabInstrgroupmain">
|
||||
update lab_instrgroupmain
|
||||
set
|
||||
fzdh = #{fzdh},
|
||||
fzmc = #{fzmc},
|
||||
bz = #{bz},
|
||||
yljg = #{yljg},
|
||||
tj_flag = #{yljg}
|
||||
where fzdh = #{fzdh}
|
||||
</update>
|
||||
|
||||
<delete id="deleteLabInstrgroupmain">
|
||||
delete from lab_instrgroupmain where fzdh = #{fzdh}
|
||||
</delete>
|
||||
|
||||
<select id="getLabInstrgroupdetailList" resultType="com.czlis.common.core.domain.entity.lis.LabInstrgroupdetail">
|
||||
select * from lab_instrgroupdetail
|
||||
<where>
|
||||
<if test="fzdh != null and yq != ''"> and fzdh = #{fzdh}</if>
|
||||
<if test="yq != null and yq != ''"> and yq = #{yq}</if>
|
||||
<if test="seq != null "> and seq = #{seq}</if>
|
||||
<if test="yljg != null and yljg != ''"> and yljg = #{yljg}</if>
|
||||
</where>
|
||||
</select>
|
||||
<insert id="addLabInstrgroupdetail">
|
||||
insert into lab_instrgroupdetail(fzdh,yq,seq,yljg)values(#{fzdh},#{yq},#{seq},#{yljg})
|
||||
</insert>
|
||||
|
||||
<update id="updateLabInstrgroupdetail">
|
||||
update lab_instrgroupdetail
|
||||
set
|
||||
fzdh = #{fzdh},
|
||||
yq = #{yq},
|
||||
seq = #{seq},
|
||||
yljg = #{yljg}
|
||||
where fzdh = #{fzdh}
|
||||
</update>
|
||||
|
||||
<delete id="deleteLabInstrgroupdetail">
|
||||
delete from lab_instrgroupdetail
|
||||
<where>
|
||||
<if test="fzdh != null and yq != ''"> and fzdh = #{fzdh}</if>
|
||||
<if test="yq != null and yq != ''"> and yq = #{yq}</if>
|
||||
<if test="seq != null "> and seq = #{seq}</if>
|
||||
<if test="yljg != null and yljg != ''"> and yljg = #{yljg}</if>
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.czlis.liswork.mapper.xtwh.XmCompMapper">
|
||||
|
||||
<select id="getXmCompList" resultType="com.czlis.common.core.domain.entity.lis.XmComp">
|
||||
select * from xm_comp
|
||||
select *,zhmc as zhmcold,zhlx as zhlxold,xmdh as xmdhold from xm_comp
|
||||
<where>
|
||||
<if test="yq != null and yq != ''"> and yq = #{yq}</if>
|
||||
<if test="zhmc != null and zhmc != ''"> and zhmc = #{zhmc}</if>
|
||||
@ -14,7 +14,23 @@
|
||||
<if test="seq != null"> and seq = #{seq}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryDetail" resultType="com.czlis.common.core.domain.entity.lis.XmComp">
|
||||
select * from xm_comp
|
||||
<where>
|
||||
<if test="yq != null and yq != ''"> and yq = #{yq}</if>
|
||||
<if test="zhmc != null and zhmc != ''"> and zhmc = #{zhmc}</if>
|
||||
<if test="zhlx != null and zhlx != ''"> and zhlx = #{zhlx}</if>
|
||||
<if test="xmdh != null and xmdh != ''"> and xmdh = #{xmdh}</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getXmCompMainList" resultType="com.czlis.common.core.domain.entity.lis.XmComp">
|
||||
select distinct yq,zhmc,zhlx from xm_comp
|
||||
<where>
|
||||
<if test="yq != null and yq != ''"> and yq = #{yq}</if>
|
||||
<if test="zhmc != null and zhmc != ''"> and zhmc = #{zhmc}</if>
|
||||
<if test="zhlx != null and zhlx != ''"> and zhlx = #{zhlx}</if>
|
||||
</where>
|
||||
</select>
|
||||
<insert id="addXmComp">
|
||||
insert into xm_comp(
|
||||
yq,zhmc,zhlx,xmdh,bz,seq
|
||||
@ -23,6 +39,7 @@
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="updateXmComp">
|
||||
update xm_comp
|
||||
<set>
|
||||
@ -32,13 +49,15 @@
|
||||
<if test="seq != null">seq = #{seq},</if>
|
||||
yq = #{yq},zhmc = #{zhmc}
|
||||
</set>
|
||||
where yq = #{yq},zhmc = #{zhmc} and zhlx = #{zhlx} and xmdh = #{xmdh}
|
||||
where yq = #{yq} and zhmc = #{zhmcold} and zhlx = #{zhlxold} and xmdh = #{xmdhold}
|
||||
</update>
|
||||
|
||||
<delete id="deleteXmComp">
|
||||
delete from xm_comp where yq = #{yq} and zhmc = #{zhmc} and zhlx = #{zhlx}
|
||||
<if test="xmdh != null and xmdh != ''"> and xmdh = #{xmdh}</if>
|
||||
</delete>
|
||||
<delete id="deleteXmCompOld">
|
||||
delete from xm_comp where yq = #{yq} and zhmc = #{zhmcold} and zhlx = #{zhlxold}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user