Commit 7759c1d7 by Suvalue

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

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