Commit 2b280eb3 authored by 赵啸非's avatar 赵啸非

测试 事项查询

parent 79651f17
...@@ -7,9 +7,11 @@ import com.mortals.framework.annotation.UnAuth; ...@@ -7,9 +7,11 @@ import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseJsonBodyController; import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.common.code.DxTypeEnum; import com.mortals.xhx.common.code.DxTypeEnum;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.keys.RedisCacheKeys; import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
...@@ -40,15 +42,13 @@ import org.apache.http.impl.client.HttpClientBuilder; ...@@ -40,15 +42,13 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.framework.ap.SysConstains.MESSAGE_INFO; import static com.mortals.framework.ap.SysConstains.MESSAGE_INFO;
...@@ -205,13 +205,68 @@ public class DemoWebApiController { ...@@ -205,13 +205,68 @@ public class DemoWebApiController {
return Rest.ok(); return Rest.ok();
} }
@PostMapping(value = "testAllMatter")
@UnAuth
public Rest<String> testAllMatter(@RequestBody SiteEntity siteEntity) {
StopWatch stopWatch = new StopWatch("stopwatch syncmatter");
log.info("开始查询事项==");
stopWatch.start("开始同步事项方法");
MatterQuery matterQuery = new MatterQuery();
matterQuery.setAreaCode(siteEntity.getAreaCode());
matterQuery.setSource(SourceEnum.政务网.getValue());
List<MatterEntity> matterList = matterService.getDao().getMatterListByAreaCode(matterQuery);
stopWatch.stop();
log.info("本地事项总数:{},{}s", matterList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
return Rest.ok();
}
@PostMapping(value = "testAllMatterPage")
@UnAuth
public Rest<String> testAllMatterPage(@RequestBody SiteEntity siteEntity) {
StopWatch stopWatch = new StopWatch("stopwatch syncmatter");
log.info("开始查询事项==");
stopWatch.start("开始同步事项方法");
MatterQuery matterQuery = new MatterQuery();
matterQuery.setAreaCode(siteEntity.getAreaCode());
matterQuery.setSource(SourceEnum.政务网.getValue());
ParamDto param = new ParamDto();
param.getCondition().put("areaCode", matterQuery.getAreaCode());
if (!ObjectUtils.isEmpty(matterQuery.getSource())) {
param.getCondition().put("source", matterQuery.getSource());
}
int count = matterService.getDao().getMatterListByAreaCodeCount(param);
ArrayList<MatterEntity> allList = new ArrayList<>();
if (count > 0) {
//分页获取
int pages = count / 500+1;
for (int i = 1; i <= pages; i++) {
PageInfo pageInfo = new PageInfo();
pageInfo.setCurrPage(i);
pageInfo.setPrePageResult(500);
Result<MatterEntity> rest = matterService.getDao().getMatterListByAreaCodePage(matterQuery, pageInfo);
allList.addAll(rest.getList());
}
stopWatch.stop();
log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
}
return Rest.ok();
}
public static void main(String[] args) { public static void main(String[] args) {
HttpClient http = null; System.out.println(1001/500);
/* HttpClient http = null;
CookieStore httpCookieStore = new BasicCookieStore(); CookieStore httpCookieStore = new BasicCookieStore();
http = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore).build(); http = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore).build();
/* do stuff */ *//* do stuff *//*
HttpGet httpRequest = new HttpGet("http://zxbl.sczwfw.gov.cn/app/account/imageCode"); HttpGet httpRequest = new HttpGet("http://zxbl.sczwfw.gov.cn/app/account/imageCode");
HttpResponse httpResponse = null; HttpResponse httpResponse = null;
try { try {
...@@ -228,9 +283,9 @@ public class DemoWebApiController { ...@@ -228,9 +283,9 @@ public class DemoWebApiController {
} catch (Exception e) { } catch (Exception e) {
log.error("异常", e); log.error("异常", e);
} }
/* check cookies */ *//* check cookies *//*
String cookieStr = Arrays.asList(httpCookieStore.getCookies()).stream().map(item -> JSON.toJSONString(item)).collect(Collectors.joining("|")); String cookieStr = Arrays.asList(httpCookieStore.getCookies()).stream().map(item -> JSON.toJSONString(item)).collect(Collectors.joining("|"));
// log.info("cookies:{}", cookieStr); // log.info("cookies:{}", cookieStr);*/
} }
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.dao; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.dao;
import com.mortals.framework.dao.ICRUDDao; import com.mortals.framework.dao.ICRUDDao;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
...@@ -21,7 +22,19 @@ public interface MatterDao extends ICRUDDao<MatterEntity, Long> { ...@@ -21,7 +22,19 @@ public interface MatterDao extends ICRUDDao<MatterEntity, Long> {
String SQLID_SUB_COUNT = "getSubListCount"; String SQLID_SUB_COUNT = "getSubListCount";
String SQLID_MATTERLIST_AREACODE = "getMatterListByAreaCode";
String SQLID_MATTERLIST_AREACODE_COUNT = "getMatterListByAreaCodeCount";
Result<MatterEntity> getSubList(MatterEntity matterQuery, PageInfo pageInfo); Result<MatterEntity> getSubList(MatterEntity matterQuery, PageInfo pageInfo);
List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery); List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery);
Result<MatterEntity> getMatterListByAreaCodePage(MatterEntity matterQuery, PageInfo pageInfo);
int getMatterListByAreaCodeCount(ParamDto paramDto);
} }
...@@ -51,6 +51,10 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem ...@@ -51,6 +51,10 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem
public int getSubCount(ParamDto paramDto) { public int getSubCount(ParamDto paramDto) {
return this.getSqlSession().selectOne(this.getSqlId(SQLID_SUB_COUNT), this.cpyQueryParamDto(paramDto)); return this.getSqlSession().selectOne(this.getSqlId(SQLID_SUB_COUNT), this.cpyQueryParamDto(paramDto));
} }
@Override
public int getMatterListByAreaCodeCount(ParamDto paramDto) {
return this.getSqlSession().selectOne(this.getSqlId(SQLID_MATTERLIST_AREACODE_COUNT), this.cpyQueryParamDto(paramDto));
}
@Override @Override
public List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery) { public List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery) {
...@@ -63,4 +67,29 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem ...@@ -63,4 +67,29 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem
return this.getSqlSession().selectList(this.getSqlId("getMatterListByAreaCode"), param); return this.getSqlSession().selectList(this.getSqlId("getMatterListByAreaCode"), param);
} }
/**
* @param matterQuery
* @param pageInfo
* @return
*/
@Override
public Result<MatterEntity> getMatterListByAreaCodePage(MatterEntity matterQuery, PageInfo pageInfo) {
Result<MatterEntity> result = new Result();
ParamDto paramDto = this.getQueryParam(matterQuery);
int count = this.getMatterListByAreaCodeCount(paramDto);
List list = null;
if (count == 0) {
list = new ArrayList();
} else if (pageInfo.getPrePageResult() == -1) {
list = this.getSqlSession().selectList(this.getSqlId(SQLID_MATTERLIST_AREACODE), paramDto);
} else {
RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
list = this.getSqlSession().selectList(this.getSqlId(SQLID_MATTERLIST_AREACODE), this.cpyQueryParamDto(paramDto), rowBounds);
}
pageInfo.setTotalResult(count);
result.setPageInfo(pageInfo);
result.setList(list);
return result;
}
} }
...@@ -65,6 +65,27 @@ ...@@ -65,6 +65,27 @@
</trim> </trim>
</select> </select>
<select id="getMatterListByAreaCodeCount" parameterType="paramDto" resultMap="int">
select
count( 1 )
FROM
mortals_sys_matter AS a
where
<trim prefixOverrides="and" prefix="">
<if test="condition.areaCode!=null and condition.areaCode!=''">
and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
</if>
</trim>
<if test="condition.source!=null and condition.source!=''">
and a.source = #{condition.source,jdbcType=INTEGER}
</if>
</select>
<select id="getMatterListByAreaCode" parameterType="paramDto" resultMap="MatterEntity-Map"> <select id="getMatterListByAreaCode" parameterType="paramDto" resultMap="MatterEntity-Map">
select select
a.id, a.id,
......
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