Commit 7759c1d7 by Suvalue

板块数值接口修改,采用map传参

parent 44ebb846
...@@ -13,11 +13,13 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -13,11 +13,13 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List; import java.util.List;
@Api(tags = "板块数值Api") @Api(tags = "板块数值Api")
@RestController @RestController
public class BlockValuesController { public class BlockValuesController {
@Autowired @Autowired
...@@ -29,7 +31,8 @@ public class BlockValuesController { ...@@ -29,7 +31,8 @@ public class BlockValuesController {
* @return * @return
* @throws Exception * @throws Exception
*/ */
@PostMapping("blockValues") @ApiIgnore
// @PostMapping("blockValues")
@Token @Token
@ApiOperation("根据Page查询板块数值") @ApiOperation("根据Page查询板块数值")
public Object getBlockValuesByPageID(@RequestBody BlockValues blockValues) throws InterruptedException { public Object getBlockValuesByPageID(@RequestBody BlockValues blockValues) throws InterruptedException {
......
package com.bsoft.api.mapper; package com.bsoft.api.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface BlockValuesMapper { public interface BlockValuesMapper {
List<Map<String,Object>> selectByWhere(String tableName,String whereSql); List<Map<String,Object>> selectByWhere(String tableName,String whereSql);
List<Map<String,Object>> selectByWhereNew(Map<String, String> map);
} }
...@@ -15,6 +15,16 @@ public class SerPageBlockRs { ...@@ -15,6 +15,16 @@ public class SerPageBlockRs {
private Long pageId; private Long pageId;
private String whereClause;
public String getWhereClause() {
return whereClause;
}
public void setWhereClause(String whereClause) {
this.whereClause = whereClause;
}
public Long getId() { public Long getId() {
return id; return id;
} }
......
package com.bsoft.api.service; package com.bsoft.api.service;
import com.bsoft.api.common.handlers.GlobalExceptionHandler;
import com.bsoft.api.model.respmodel.BlockValue; import com.bsoft.api.model.respmodel.BlockValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
public interface AsynBlockValuesService { public interface AsynBlockValuesService {
static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
void getBlockValues(List<BlockValue> list, Long blockId, String tableName, void getBlockValues(List<BlockValue> list, Long blockId, String tableName,
String whereClause, CountDownLatch latch); String whereClause, CountDownLatch latch);
void getBlockValuesNew(List<BlockValue> list, Long blockId,Map<String,String> dim, CountDownLatch latch);
} }
...@@ -24,15 +24,44 @@ public class AsynBlockValuesServiceImpl implements AsynBlockValuesService { ...@@ -24,15 +24,44 @@ public class AsynBlockValuesServiceImpl implements AsynBlockValuesService {
@Override @Override
public void getBlockValues(List<BlockValue> list, Long blockId, String tableName, public void getBlockValues(List<BlockValue> list, Long blockId, String tableName,
String whereClause, CountDownLatch latch) { String whereClause, CountDownLatch latch) {
System.out.println("开始"+tableName); try{
System.out.println("开始"+tableName);
List<Map<String, Object>> dataList = blockValuesMapper.selectByWhere(tableName, whereClause); List<Map<String, Object>> dataList = blockValuesMapper.selectByWhere(tableName, whereClause);
BlockValue blockValue = new BlockValue(blockId, dataList); BlockValue blockValue = new BlockValue(blockId, dataList);
synchronized (obj){ synchronized (obj){
list.add(blockValue); list.add(blockValue);
}
System.out.println("结束"+tableName);
}catch (Exception e){
log.error(e.getMessage(), e);
}finally {
latch.countDown();
} }
System.out.println("结束"+tableName);
latch.countDown();
}
@Async
@Override
public void getBlockValuesNew(List<BlockValue> list, Long blockId, Map<String,String> whereClause, CountDownLatch latch) {
try{
System.out.println("开始"+whereClause.get("tableName"));
List<Map<String,Object>> dataList = blockValuesMapper.selectByWhereNew(whereClause);
BlockValue blockValue = new BlockValue(blockId, dataList);
synchronized (obj){
list.add(blockValue);
}
System.out.println("结束"+whereClause.get("tableName"));
}catch (Exception e){
log.error(e.getMessage(), e);
}finally {
latch.countDown();
}
} }
} }
...@@ -111,9 +111,7 @@ public class BlockValuesServiceImpl implements BlockValuesService { ...@@ -111,9 +111,7 @@ public class BlockValuesServiceImpl implements BlockValuesService {
int count = 0; int count = 0;
String inField = ""; String inField = "";
String whereClause = "where 1=1";
for (Map.Entry<String, String> entry : dim.entrySet()) { for (Map.Entry<String, String> entry : dim.entrySet()) {
whereClause += String.format(" and "+entry.getKey()+"='%s'", entry.getValue());
inField += "'"+entry.getKey()+"',"; inField += "'"+entry.getKey()+"',";
count++; count++;
} }
...@@ -136,7 +134,9 @@ public class BlockValuesServiceImpl implements BlockValuesService { ...@@ -136,7 +134,9 @@ public class BlockValuesServiceImpl implements BlockValuesService {
//获取表名 //获取表名
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;
asynBlockValuesServiceImpl.getBlockValues(list, blockId, tableName, whereClause, latch); dim.put("tableName",tableName);
dim.put("whereSql", data.getWhereClause());
asynBlockValuesServiceImpl.getBlockValuesNew(list, blockId,dim, latch);
} }
latch.await(); latch.await();
......
...@@ -5,4 +5,8 @@ ...@@ -5,4 +5,8 @@
select * from ${tableName} select * from ${tableName}
${whereSql} ${whereSql}
</select> </select>
<select id="selectByWhereNew" resultType="java.util.Map">
select * from ${tableName}
${whereSql}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -61,10 +61,17 @@ ...@@ -61,10 +61,17 @@
where ID = #{id,jdbcType=DECIMAL} where ID = #{id,jdbcType=DECIMAL}
</select> </select>
<select id="selectByCode" resultMap="BaseResultMap"> <select id="selectByCode" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, STATE, MDC_CODE, MDC_NAME, "DATE", MDC_NUM, select d.ID, d.CREATE_DATE, d.CREATE_USERID, d.STATE, d.MDC_CODE, d.MDC_NAME, d."DATE",d.MDC_NUM,
PARENT_ID, "LEVEL", ORG_ID, ORG_NAME d.PARENT_ID, d."LEVEL", d.ORG_ID, d.ORG_NAME
from SER_DISEASE from SER_DISEASE d,SER_DISEASE_DOC_RS rs
where MDC_CODE = #{code,jdbcType=VARCHAR} and "DATE" = #{date,jdbcType=VARCHAR} where d.STATE=1
and rs.MDC_CODE=d.MDC_CODE and rs.MDC_CODE = #{code,jdbcType=VARCHAR} and rs."DATE" = #{date,jdbcType=VARCHAR} and d."DATE" =#{date,jdbcType=VARCHAR}
<if test="docCode!=null">
and rs.DOC_CODE=#{docCode,jdbcType=VARCHAR}
</if>
<if test="deptCode!=null">
and rs.DEPT_CODE=#{deptCode,jdbcType=VARCHAR}
</if>
</select> </select>
<select id="selectAll" resultMap="BaseResultMap"> <select id="selectAll" resultMap="BaseResultMap">
select ID, CREATE_DATE, CREATE_USERID, STATE, MDC_CODE, MDC_NAME, DATE, MDC_NUM, select ID, CREATE_DATE, CREATE_USERID, STATE, MDC_CODE, MDC_NAME, DATE, MDC_NUM,
...@@ -84,27 +91,39 @@ ...@@ -84,27 +91,39 @@
</if> </if>
</select> </select>
<select id="selectByLevel" resultMap="DiseaseLevel"> <select id="selectByLevel" resultMap="DiseaseLevel">
select ID, CREATE_DATE, CREATE_USERID, STATE, MDC_CODE, MDC_NAME, "DATE", MDC_NUM, select DISTINCT d.ID, d.CREATE_DATE, d.CREATE_USERID, d.STATE, d.MDC_CODE, d.MDC_NAME, d."DATE",d.MDC_NUM,
PARENT_ID,"LEVEL", ORG_ID, ORG_NAME d.PARENT_ID, d."LEVEL", d.ORG_ID, d.ORG_NAME
from SER_DISEASE from SER_DISEASE d,SER_DISEASE_DOC_RS rs
where 1 = 1 and STATE=1 where 1 = 1 and STATE=1 and rs.MDC_CODE=d.MDC_CODE
<if test="date!=null"> <if test="date!=null">
and "DATE" = #{date,jdbcType=VARCHAR} and d."DATE" = #{date,jdbcType=VARCHAR} and rs."DATE" = #{date,jdbcType=VARCHAR}
</if> </if>
<if test="level!=null"> <if test="level!=null">
and "LEVEL" = #{level,jdbcType=DECIMAL} and d."LEVEL" = #{level,jdbcType=DECIMAL}
</if> </if>
<if test="docCode!=null">
and rs.DOC_CODE=#{docCode,jdbcType=VARCHAR}
</if>
<if test="deptCode!=null">
and rs.DEPT_CODE=#{deptCode,jdbcType=VARCHAR}
</if>
</select> </select>
<select id="selectByParentId" resultMap="DiseaseLevel"> <select id="selectByParentId" resultMap="DiseaseLevel">
select ID, CREATE_DATE, CREATE_USERID, STATE, MDC_CODE, MDC_NAME, "DATE", MDC_NUM, select DISTINCT d.ID, d.CREATE_DATE, d.CREATE_USERID, d.STATE, d.MDC_CODE, d.MDC_NAME, d."DATE",d.MDC_NUM,
PARENT_ID,"LEVEL", ORG_ID, ORG_NAME d.PARENT_ID, d."LEVEL", d.ORG_ID, d.ORG_NAME
from SER_DISEASE from SER_DISEASE d,SER_DISEASE_DOC_RS rs
where 1 = 1 and STATE=1 where 1 = 1 and STATE=1 and STATE=1 and rs.MDC_CODE=d.MDC_CODE
<if test="date!=null"> <if test="date!=null">
and "DATE" = #{date,jdbcType=VARCHAR} and d."DATE" = #{date,jdbcType=VARCHAR} and rs."DATE" = #{date,jdbcType=VARCHAR}
</if> </if>
<if test="parentId!=null"> <if test="parentId!=null">
and PARENT_ID = #{parentId,jdbcType=DECIMAL} and d.PARENT_ID = #{parentId,jdbcType=DECIMAL}
</if>
<if test="docCode!=null">
and rs.DOC_CODE=#{docCode,jdbcType=VARCHAR}
</if>
<if test="deptCode!=null">
and rs.DEPT_CODE=#{deptCode,jdbcType=VARCHAR}
</if> </if>
</select> </select>
<select id="selectParentById" resultMap="DiseaseLevel"> <select id="selectParentById" resultMap="DiseaseLevel">
...@@ -119,14 +138,21 @@ ...@@ -119,14 +138,21 @@
</if> </if>
</select> </select>
<select id="selectSonById" resultMap="DiseaseLevel"> <select id="selectSonById" resultMap="DiseaseLevel">
select * select DISTINCT d.ID, d.CREATE_DATE, d.CREATE_USERID, d.STATE, d.MDC_CODE, d.MDC_NAME, d."DATE",d.MDC_NUM,
from SER_DISEASE d.PARENT_ID, d."LEVEL", d.ORG_ID, d.ORG_NAME
where 1 = 1 and STATE=1 from SER_DISEASE d,SER_DISEASE_DOC_RS rs
where 1 = 1 and STATE=1 and STATE=1 and rs.MDC_CODE=d.MDC_CODE
<if test="date!=null"> <if test="date!=null">
and "DATE" = #{date,jdbcType=VARCHAR} and d."DATE" = #{date,jdbcType=VARCHAR} and rs."DATE" = #{date,jdbcType=VARCHAR}
</if> </if>
<if test="diseaseId!=null"> <if test="diseaseId!=null">
and PARENT_ID=#{diseaseId,jdbcType=DECIMAL} and d.PARENT_ID=#{diseaseId,jdbcType=DECIMAL}
</if> </if>
<if test="docCode!=null">
and rs.DOC_CODE=#{docCode,jdbcType=VARCHAR}
</if>
<if test="deptCode!=null">
and rs.DEPT_CODE=#{deptCode,jdbcType=VARCHAR}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<result column="STATE" jdbcType="DECIMAL" property="state" /> <result column="STATE" jdbcType="DECIMAL" property="state" />
<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>
</resultMap> </resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from SER_PAGE_BLOCK_RS delete from SER_PAGE_BLOCK_RS
...@@ -18,9 +19,9 @@ ...@@ -18,9 +19,9 @@
select SEQ_SER_PAGE_BLOCK_RS_ID.nextval from dual select SEQ_SER_PAGE_BLOCK_RS_ID.nextval from dual
</selectKey> </selectKey>
insert into SER_PAGE_BLOCK_RS (CREATE_DATE, CREATE_USERID, STATE, insert into SER_PAGE_BLOCK_RS (CREATE_DATE, CREATE_USERID, STATE,
BLOCK_ID, PAGE_ID) BLOCK_ID, PAGE_ID,WHERE_CLAUSE)
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}) #{blockId,jdbcType=DECIMAL}, #{pageId,jdbcType=DECIMAL},#{whereClause,jdbcType=DECIMAL})
</insert> </insert>
<update id="updateByPrimaryKey" parameterType="com.bsoft.api.model.SerPageBlockRs"> <update id="updateByPrimaryKey" parameterType="com.bsoft.api.model.SerPageBlockRs">
update SER_PAGE_BLOCK_RS update SER_PAGE_BLOCK_RS
...@@ -28,20 +29,21 @@ ...@@ -28,20 +29,21 @@
CREATE_USERID = #{createUserid,jdbcType=DECIMAL}, CREATE_USERID = #{createUserid,jdbcType=DECIMAL},
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=DECIMAL}
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 select ID, CREATE_DATE, CREATE_USERID, STATE, BLOCK_ID, PAGE_ID,WHERE_CLAUSE
from SER_PAGE_BLOCK_RS from SER_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 select ID, CREATE_DATE, CREATE_USERID, STATE, BLOCK_ID, PAGE_ID,WHERE_CLAUSE
from SER_PAGE_BLOCK_RS from SER_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 select ID, CREATE_DATE, CREATE_USERID, STATE, BLOCK_ID, PAGE_ID,WHERE_CLAUSE
from SER_PAGE_BLOCK_RS from SER_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