Commit 0409136a by Suvalue

value表名从数据库配置表中读取

parent 3375b31f
......@@ -17,6 +17,8 @@ public class SerPageBlockRs {
private String whereClause;
private String tableName;
public Long getId() {
return id;
}
......@@ -72,4 +74,12 @@ public class SerPageBlockRs {
public void setWhereClause(String whereClause) {
this.whereClause = whereClause;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
}
\ No newline at end of file
......@@ -27,7 +27,7 @@ public class BlockValuesServiceImpl implements BlockValuesService {
@Override
public List<BlockValue> getBlockValuesByPageCode(Integer pageCode,Integer disease,Integer doctor,Integer department,Integer time) throws InterruptedException {
public List<BlockValue> getBlockValuesByPageCode(Integer pageCode, Integer disease, Integer doctor, Integer department, Integer time) throws InterruptedException {
/**
* 1.根据pageCode,disease,doctor,department,time查询所有对应的pageId
* 查询要求为pageCode为当前pageCode,相同pageId的所有数据有且仅有DIM_ID为
......@@ -40,32 +40,32 @@ public class BlockValuesServiceImpl implements BlockValuesService {
int count = 0;
String inField = "";
String whereClause = "where 1=1";
if(disease != null){
whereClause += String.format(" and disease='%s'",disease);
if (disease != null) {
whereClause += String.format(" and disease='%s'", disease);
inField += "'disease',";
count++;
}
if(doctor != null){
whereClause += String.format(" and doctor='%s'",doctor);
if (doctor != null) {
whereClause += String.format(" and doctor='%s'", doctor);
inField += "'doctor',";
count++;
}
if(department != null){
whereClause += String.format(" and department='%s'",department);
if (department != null) {
whereClause += String.format(" and department='%s'", department);
inField += "'department',";
count++;
}
if(time != null){
whereClause += String.format(" and time='%s'",time);
if (time != null) {
whereClause += String.format(" and time='%s'", time);
inField += "'time',";
count++;
}
if(count > 0){
inField = inField.substring(0,inField.length() - 1);
if (count > 0) {
inField = inField.substring(0, inField.length() - 1);
}
List<SerPage> pageList = serPageMapper.selectByCodeAndDim(pageCode,inField,count);
if(pageList.size() == 0){
List<SerPage> pageList = serPageMapper.selectByCodeAndDim(pageCode, inField, count);
if (pageList.size() == 0) {
throw new DBConfigurationError("页面维度配置表错误,请联系管理员");
}
......@@ -75,11 +75,11 @@ public class BlockValuesServiceImpl implements BlockValuesService {
List<SerPageBlockRs> pageBlocklist = serPageBlockRsMapper.selectByPageId(page.getId());
//循环获取数据
CountDownLatch latch = new CountDownLatch(pageBlocklist.size());
for(SerPageBlockRs data : pageBlocklist){
for (SerPageBlockRs data : pageBlocklist) {
//获取表名
Long blockId = data.getBlockId();
String tableName = "VAL_BLOCK_VALUES_" + blockId;
asynBlockValuesServiceImpl.getBlockValues(list,blockId,tableName,whereClause,latch);
asynBlockValuesServiceImpl.getBlockValues(list, blockId, tableName, whereClause, latch);
}
latch.await();
......@@ -88,7 +88,7 @@ public class BlockValuesServiceImpl implements BlockValuesService {
}
@Override
public List<BlockValue> getBlockValuesByPageCodeNew(Long userId,Integer pageCode,Map<String,String> dim) throws InterruptedException {
public List<BlockValue> getBlockValuesByPageCodeNew(Long userId, Integer pageCode, Map<String, String> dim) throws InterruptedException {
/**
* 1.根据pageCode查询所有对应的pageId
* 查询要求为pageCode为当前pageCode,相同pageId的所有数据有且仅有DIM_ID为
......@@ -109,24 +109,24 @@ public class BlockValuesServiceImpl implements BlockValuesService {
// inField = inField.substring(0, inField.length()-1);
// }
for(Iterator iterator = inFields.iterator();iterator.hasNext();){
for (Iterator iterator = inFields.iterator(); iterator.hasNext(); ) {
Object obj = iterator.next();
Object value = dim.get(obj);
if(value instanceof String){
if (value instanceof String) {
String valueNew = dim.get(obj);
dim.put(String.valueOf(obj),valueNew.trim());
dim.put(String.valueOf(obj), valueNew.trim());
}
remove(value,iterator);
remove(value, iterator);
}
List<SerPage> pageList = serPageMapper.selectByCodeAndDimList(pageCode,inFields,inFields.size());
List<SerPage> pageList = serPageMapper.selectByCodeAndDimList(pageCode, inFields, inFields.size());
// List<SerPage> pageList = serPageMapper.selectByCodeAndDim(pageCode, inField, count);
if(pageList.size() == 0){
if (pageList.size() == 0) {
throw new DBConfigurationError("页面维度配置表错误,请联系管理员");
}
//将用户信息配置进参数
dim.put("USER",String.valueOf(userId));
dim.put("USER", String.valueOf(userId));
SerPage page = pageList.get(0);
......@@ -134,18 +134,19 @@ public class BlockValuesServiceImpl implements BlockValuesService {
List<SerPageBlockRs> pageBlocklist = serPageBlockRsMapper.selectByPageId(page.getId());
//循环获取数据
CountDownLatch latch = new CountDownLatch(pageBlocklist.size());
for(SerPageBlockRs data : pageBlocklist){
for (SerPageBlockRs data : pageBlocklist) {
//获取表名
Long blockId = data.getBlockId();
String tableName = "VAL_BLOCK_VALUES_" + pageCode + "_" + page.getId() + "_" + blockId;
Map<String,String> map = new HashMap<String,String>() {
// String tableName = "VAL_BLOCK_VALUES_" + pageCode + "_" + page.getId() + "_" + blockId;
String tableName = data.getTableName();
Map<String, String> map = new HashMap<String, String>() {
{
put("tableName",tableName);
put("whereSql",data.getWhereClause());
put("tableName", tableName);
put("whereSql", data.getWhereClause());
putAll(dim);
}
};
asynBlockValuesServiceImpl.getBlockValuesNew(list,blockId,map,latch);
asynBlockValuesServiceImpl.getBlockValuesNew(list, blockId, map, latch);
}
latch.await();
......@@ -154,32 +155,32 @@ public class BlockValuesServiceImpl implements BlockValuesService {
}
private static void remove(Object obj,Iterator iterator) {
if(obj instanceof String){
String str = (String)obj;
if(StringUtils.isBlank(str)){
private static void remove(Object obj, Iterator iterator) {
if (obj instanceof String) {
String str = (String) obj;
if (StringUtils.isBlank(str)) {
iterator.remove();
}
}else if(obj instanceof Collection){
Collection col = (Collection)obj;
if(col == null || col.isEmpty()){
} else if (obj instanceof Collection) {
Collection col = (Collection) obj;
if (col == null || col.isEmpty()) {
iterator.remove();
}
}else if(obj instanceof Map){
Map temp = (Map)obj;
if(temp == null || temp.isEmpty()){
} else if (obj instanceof Map) {
Map temp = (Map) obj;
if (temp == null || temp.isEmpty()) {
iterator.remove();
}
}else if(obj instanceof Object[]){
Object[] array = (Object[])obj;
if(array == null || array.length <= 0){
} else if (obj instanceof Object[]) {
Object[] array = (Object[]) obj;
if (array == null || array.length <= 0) {
iterator.remove();
}
}else{
if(obj == null){
} else {
if (obj == null) {
iterator.remove();
}
}
......
......@@ -4,6 +4,7 @@ spring.datasource.username=root
spring.datasource.password=Suvalue2016
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
project.path=sy2/test
#spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
#spring.datasource.username=scml_zp_cs
#spring.datasource.password=123
......
......@@ -7,7 +7,7 @@
<property name="log.test.level" value="DEBUG" />
<property name="log.prod.level" value="DEBUG" />
<property name="log.max.size" value="10MB" /> <!-- 日志文件大小 -->
<springProperty scope="context" name="log.profile" source="spring.profiles.active" defaultValue="app"/>
<springProperty scope="context" name="log.profile" source="project.path" defaultValue="app"/>
<property name="log.base" value="/logs/${log.profile}"/>
<springProperty scope="context" name="log.moduleName" source="spring.application.name" defaultValue="app"/>
......
......@@ -9,6 +9,7 @@
<result column="BLOCK_ID" jdbcType="DECIMAL" property="blockId"/>
<result column="PAGE_ID" jdbcType="DECIMAL" property="pageId"/>
<result column="WHERE_CLAUSE" jdbcType="VARCHAR" property="whereClause"/>
<result column="TABLE_NAME" jdbcType="VARCHAR" property="tableName"/>
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
......@@ -20,10 +21,11 @@
SELECT LAST_INSERT_ID()
</selectKey>
insert into dic_page_block_rs (CREATE_DATE, CREATE_USERID, `STATE`,
BLOCK_ID, PAGE_ID, WHERE_CLAUSE
BLOCK_ID, PAGE_ID, WHERE_CLAUSE,`TABLE_NAME`
)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{blockId,jdbcType=DECIMAL}, #{pageId,jdbcType=DECIMAL}, #{whereClause,jdbcType=VARCHAR}
#{blockId,jdbcType=DECIMAL}, #{pageId,jdbcType=DECIMAL},
#{whereClause,jdbcType=VARCHAR},#{tableName,jdbcType=VARCHAR}
)
</insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.api.model.SerPageBlockRs">
......@@ -33,20 +35,42 @@
`STATE` = #{state,jdbcType=DECIMAL},
BLOCK_ID = #{blockId,jdbcType=DECIMAL},
PAGE_ID = #{pageId,jdbcType=DECIMAL},
WHERE_CLAUSE = #{whereClause,jdbcType=VARCHAR}
WHERE_CLAUSE = #{whereClause,jdbcType=VARCHAR},
`TABLE_NAME` = #{tableName,jdbcType=VARCHAR}
where ID = #{id,jdbcType=DECIMAL}
</update>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, BLOCK_ID, PAGE_ID, WHERE_CLAUSE
select ID,
CREATE_DATE,
CREATE_USERID,
`STATE`,
BLOCK_ID,
PAGE_ID,
WHERE_CLAUSE,
`TABLE_NAME`
from dic_page_block_rs
where ID = #{id,jdbcType=DECIMAL}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, BLOCK_ID, PAGE_ID, WHERE_CLAUSE
select ID,
CREATE_DATE,
CREATE_USERID,
`STATE`,
BLOCK_ID,
PAGE_ID,
WHERE_CLAUSE,
`TABLE_NAME`
from dic_page_block_rs
</select>
<select id="selectByPageId" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, `STATE`, BLOCK_ID, PAGE_ID, WHERE_CLAUSE
select ID,
CREATE_DATE,
CREATE_USERID,
`STATE`,
BLOCK_ID,
PAGE_ID,
WHERE_CLAUSE,
`TABLE_NAME`
from dic_page_block_rs
where PAGE_ID = #{pageID,jdbcType=DECIMAL}
</select>
......
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