Commit 50ca4183 by gechengyang

解决Oracle数据库表字段类型为Long的dbRead缺陷

parent e11a7235
......@@ -4,6 +4,7 @@ import java.util.*;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableField;
import com.brilliance.mda.runtime.mda.*;
import com.brilliance.mda.runtime.mda.impl.*;
import com.brilliance.mda.runtime.annotation.*;
......@@ -17,6 +18,7 @@ import lombok.Getter;
import lombok.Setter;
import com.ceb.gjjs.mda.global.Platform;
import org.apache.ibatis.type.JdbcType;
/**
......@@ -42,6 +44,10 @@ public class Acd extends AbstractModule
return "acd";
}
//经营范围
@TableField(jdbcType = JdbcType.LONGVARBINARY)
private String busiscope ;
//唯一索引
private String inr ;
//业务参号
......@@ -97,8 +103,6 @@ public class Acd extends AbstractModule
private String enttype ;
//注册地址
private String regaddr ;
//经营范围
private String busiscope ;
//经营状态
private String busistatus ;
//行业代码
......@@ -203,4 +207,6 @@ public class Acd extends AbstractModule
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.ceb.gjjs.mda.dao;
import org.apache.ibatis.annotations.Mapper;
import com.ceb.gjjs.mda.bo.Acd;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.Map;
import java.util.List;
......
......@@ -72,7 +72,7 @@ public class Mardav extends AbstractTransaction{
{
this.getMarp().setMargrpHolder(()->this.getMargrp());
this.getTrnmod().setCurHolder(new FieldConstantHolder<>(""));
this.getTrnmod().setAmtHolder(new FieldConstantHolder<>(new BigDecimal(" 0")));
this.getTrnmod().setAmtHolder(new FieldConstantHolder<>(new BigDecimal("0")));
this.getTrnmod().setOwnrefHolder( new FieldHolder<String>(){
public String getPath(){return Mardav.this.getFieldPath("margrp.mar.ownref");}
public void setValue(String arg){Mardav.this.getMargrp().getMar().setOwnref(arg);}
......
......@@ -3,6 +3,7 @@
<mapper namespace="com.ceb.gjjs.mda.dao.AcdMapper">
<resultMap id="BaseResultMap" type="com.ceb.gjjs.mda.bo.Acd">
<result property="inr" column="inr" jdbcType="VARCHAR" />
<result property="ownref" column="ownref" jdbcType="VARCHAR" />
<result property="transid" column="transid" jdbcType="VARCHAR" />
......@@ -29,7 +30,7 @@
<result property="industry" column="industry" jdbcType="VARCHAR" />
<result property="enttype" column="enttype" jdbcType="VARCHAR" />
<result property="regaddr" column="regaddr" jdbcType="VARCHAR" />
<result property="busiscope" column="busiscope" jdbcType="VARCHAR" />
<result property="busiscope" column="busiscope" jdbcType="LONGVARCHAR"/>
<result property="busistatus" column="busistatus" jdbcType="VARCHAR" />
<result property="industrycode" column="industrycode" jdbcType="VARCHAR" />
<result property="msgref" column="msgref" jdbcType="VARCHAR" />
......@@ -41,10 +42,11 @@
<result property="reason" column="reason" jdbcType="VARCHAR" />
<result property="account" column="account" jdbcType="VARCHAR" />
<result property="senddat" column="senddat" jdbcType="DATE" />
<!--<result property="busiscope" column="busiscope" jdbcType="LONGVARCHAR" typeHandler="com.brilliance.mda.support.mybatis.typehandle.OracleLongTypeHandle"/>-->
</resultMap>
<sql id="Base_Column_List">
inr,ownref,transid,entname,accounttype,contactaddress,enttel,openoutletibk,legalrepresentative,financialadmin,transactor,transverifier1,transverifier2,producttype,openfea,socialcrdtcd,legalname,registerfund,registercurrency,appointmentdate,opendate,operatefrom,operateend,industry,enttype,regaddr,busiscope,busistatus,industrycode,msgref,bchcod,credat,ncid,status,acdno,reason,account,senddat
inr,ownref,transid,entname,accounttype,contactaddress,enttel,openoutletibk,legalrepresentative,financialadmin,transactor,transverifier1,transverifier2,producttype,openfea,socialcrdtcd,legalname,registerfund,registercurrency,appointmentdate,opendate,operatefrom,operateend,industry,enttype,regaddr,busistatus,industrycode,msgref,bchcod,credat,ncid,status,acdno,reason,account,senddat,busiscope
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
......@@ -289,7 +291,6 @@
<select id="dyncRead" resultMap="BaseResultMap">
${sql}
</select>
</mapper>
......@@ -20,4 +20,4 @@ mybatis:
counter:
name: oracleSequence
start: 1500
setp: 1
setp: 1
\ No newline at end of file
......@@ -48,6 +48,12 @@
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.5.3.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -11,6 +11,7 @@ import com.brilliance.mda.runtime.request.BaseVO;
import com.brilliance.mda.support.mybatis.count.CounterService;
import com.brilliance.mda.support.mybatis.dync.mapper.DbExecuteMapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.beanutils.MethodUtils;
import org.mybatis.spring.SqlSessionTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.*;
......@@ -66,6 +68,8 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
private static final String SQLID_DELBYIDS = "deleteByIds";
private static final String SQLID_DYNCREAD = "dyncRead";
private static final String SQLID_DYNCDEL = "dyncDelete";
private static final String SQLID_SELECTBYID = "selectByInr";
private static final String SQLID_SELECTBYPRIMARYKEY = "selectByPrimaryKey";
@Autowired
......@@ -161,6 +165,19 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
return entity;
}
@Override
public <T extends IModule> T dbReadByInr(T module, String inr) {
String moduleDB = MdaUtils.getModuleDB(module);
DynamicDataSourceContextHolder.setDataSourceType(moduleDB);
Map<String, Object> dyncMap = new HashMap<>();
dyncMap.put("inr", inr);
T entity = this.dyncReadByInr(module.getClass(), dyncMap);
if (entity != null) {
MdaDriver.copyValues(module, entity);
}
return entity;
}
@Override
public <T extends IModule> int dbReadset(ModuleList<T> list, CacheOption cacheOption, Argument... args) {
......@@ -364,7 +381,6 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
private <T> T dyncReadOne(Class<? extends IModule> clazz, MybatisArgumentAdapter adapter) {
String sqlId = getSqlId(clazz, SQLID_DYNCREAD);
T entity = sqlSessionTemplate.selectOne(sqlId, adapter.getSqlParams());
if (entity == null) {
......@@ -373,6 +389,37 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
return entity;
}
private <T> T dyncReadByInr(Class<? extends IModule> clazz, Map<String, Object> dyncMap) {
String sqlId = getSqlId(clazz, SQLID_SELECTBYPRIMARYKEY);
try {
Object obj = clazz.newInstance();
MethodUtils.invokeMethod(obj, "setInr", dyncMap.get("inr"));
T entity = sqlSessionTemplate.selectOne(sqlId, obj);
if (entity == null) {
setNoMoreRow();
}
return entity;
}catch (InvocationTargetException e) {
throw new RuntimeException(e.getMessage());
} catch (InstantiationException e) {
throw new RuntimeException(e.getMessage());
} catch (IllegalAccessException e) {
throw new RuntimeException(e.getMessage());
} catch (NoSuchMethodException e) {
throw new RuntimeException(e.getMessage());
}
}
private <T> T readByInr(Class<? extends IModule> clazz, MybatisArgumentAdapter adapter) {
String sqlId = getSqlId(clazz, SQLID_SELECTBYID);
T entity = sqlSessionTemplate.selectOne(sqlId, adapter.getSqlParams());
if (entity == null) {
setNoMoreRow();
}
return entity;
}
private <T> List<T> dyncRead(Class<T> clazz, MybatisArgumentAdapter adapter) {
String sqlId = getSqlId(clazz, SQLID_DYNCREAD);
......
package com.brilliance.mda.support.mybatis.typehandle;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.io.StringReader;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@MappedTypes({Object.class, String.class})
@MappedJdbcTypes(value = {JdbcType.LONGVARCHAR})
public class OracleLongTypeHandle extends BaseTypeHandler<Object> {
@Override
public void setNonNullParameter(PreparedStatement preparedStatement, int i, Object parameter, JdbcType jdbcType) throws SQLException {
String parameterStr = (String) parameter;
StringReader reader = new StringReader(parameterStr);
preparedStatement.setCharacterStream(i, reader, parameterStr.length());
}
@Override
public Object getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
String str = resultSet.getString(columnName);
return str != null ? str : "";
}
@Override
public Object getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
String str = resultSet.getString(columnIndex);
return str != null ? str : "";
}
@Override
public Object getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
String str = callableStatement.getString(columnIndex);
return str != null ? str : "";
}
}
\ No newline at end of file
......@@ -17,6 +17,9 @@ public interface IDaoSession {
@SuppressWarnings("rawtypes")
<T extends IModule> T dbRead(T module, Argument... args);
<T extends IModule> T dbReadByInr(T module, String inr);
@SuppressWarnings("rawtypes")
<T extends IModule> int dbDelete(T module, Argument... args);
@SuppressWarnings("rawtypes")
......
......@@ -1445,7 +1445,7 @@ public class MdaUtils {
log.debug("{}", "transdb.properties DefaultDB=" + db);
setDefaultDB(db);
} else {
db = "eibs";
db = "ipsnew";
}
}
}
......@@ -1511,7 +1511,7 @@ public class MdaUtils {
String db = null;
for (IModuleList list : lists) {
db = getModuleListDB(list);
if (!"eibs".equals(db))
if (!"ipsnew".equals(db))
return db;
}
return db;
......
......@@ -187,3 +187,4 @@ emepcap=fxd
stachk=swd
dyctsk=swd
sxitsk=swd
acdopn=ipsnew
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment