Commit 0409136a by Suvalue

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

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