Commit 7f4d4c51 by wuchengwu

森林高支队sql查询优化

parent 877f0dd3
......@@ -308,7 +308,13 @@ public interface KhtjDao {
* @param map
* @return
*/
public List<RstBean> getZwzltjListrst(Map<String, String> map);
public List<RstBean> getZwzltjListrst1(Map<String, String> map);
/**
* 指纹统计
* @param map
* @return
*/
public List<RstBean> getZwzltjListrst2(Map<String, String> map);
/**
* 合格率统计
......
......@@ -692,4 +692,104 @@ public class FileUtils {
//JSONObject jsonResult= requestByPost_new(urlstr,pairs);
log.info(jsonResult.toJSONString());*/
}
/**
* @Description: 整合两个操作,一个是文件夹的所有目录,然后复制目录下的所有文件到相应的目录
* @param srcPath 需要复制的目录
* @param targetPath 复制到哪里
* @author L.Eric
* create: 2013-4-16
*/
public static void copyFileOrDir(String srcPath, String targetPath){
parseDir(srcPath,targetPath);
copyAllFile(srcPath, targetPath);
}
public static void copyAllFile(String srcPath, String targetPath){
File f = new File(srcPath);
File[] fileList = f.listFiles();
for(File f1 : fileList){
if(f1.isFile()) {
copyFile(srcPath + "//" + f1.getName(), targetPath + "//" + f1.getName());
}
//判断是否是目录
if(f1.isDirectory()) {
copyAllFile(f1.getPath().toString(), targetPath + "//" + f1.getName());
}
}
}
/**
* @Description: 通过字节流复制一个文件
* @param src 源文件的路径
* @param target 目标文件的路径
* @author L.Eric
* create: 2013-4-16
*/
public static void copyFile(String src, String target){
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(src);
os = new FileOutputStream(target);
byte[] buff = new byte[1024];
int len = 0;
while((len = is.read(buff, 0, buff.length)) != -1) {
os.write(buff, 0, len);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if(os!=null){
try {
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if(is!=null){
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}
/**
* @Description: 复制一个目录下的所有目录文件(只复制目录结构)
* @param pathName 需要复制的目标目录
* @param target 生成的目标文件目录
* @author L.Eric
* create: 2013-4-16
*/
public static void parseDir(String pathName, String target){
//创建一个新的目录
File targetFile = new File(target);
if(!targetFile.exists()) {
targetFile.mkdirs();
}
//创建一个抽象路径
File file = new File(pathName);
if(file.isDirectory()){
File[] files = file.listFiles();
for(File f : files){
if(f.isDirectory()) {
parseDir(f.getPath(), target + "//" + f.getName());
}
}
}
}
}
......@@ -115,7 +115,7 @@
</resultMap>
<!-- 通过条件查询,返回数据集 -->
<select id="getZwzltjListrst" parameterType="map" resultType="com.founder.khtj.domain.RstBean">
<select id="getZwzltjListrst1" parameterType="map" resultType="com.founder.khtj.domain.RstBean">
select * from
(select count(*) zycs from TB_RY_RYCJ where (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1')
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
......@@ -206,25 +206,12 @@
END) else 17 end))
from dual) >= 16
AND rybh not in ( SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR( WCJX, '04' ) > 0)
)t43,
<!-- (select count(*) swxzcjs from TB_RY_RYCJ p,(select rybh swrybh from tb_xw_ythcj_sw group by rybh) s where p.rybh=s.swrybh(+) and (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1') and tbbz = '0' and s.swrybh is not null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
<if test="minccsj != null and minccsj != ''"> and lrsj <![CDATA[>=]]> to_date(#{minccsj , jdbcType=VARCHAR },'YYYY-MM-DD')</if>
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
AND (select ((case
when p.GMSFHM is not null then
(case
when LENGTH(p.GMSFHM) <![CDATA[<]]>18 then
17
when SUBSTR(p.GMSFHM, 7, 4)>1900 and SUBSTR(p.GMSFHM, 7, 4)<![CDATA[<]]>2100 and SUBSTR(p.GMSFHM, 11, 2)>0 and SUBSTR(p.GMSFHM, 11, 2) <![CDATA[<]]> 13 and SUBSTR(p.GMSFHM, 13, 2)<![CDATA[<]]>32 and SUBSTR(GMSFHM, 13, 2)>0 then
round((lrsj - to_date(SUBSTR(p.GMSFHM, 7, 8), 'YYYYMMDD')) / 365)
else
17
END) else 17 end))
from dual) >= 16
AND p.rybh not in ( SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR( WCJX, '04' ) > 0)
)t41,-->
)t43
</select>
<!-- 通过条件查询,返回数据集 -->
<select id="getZwzltjListrst2" parameterType="map" resultType="com.founder.khtj.domain.RstBean">
select * from
(select count(*) swwcjs from TB_RY_RYCJ p,(select rybh swrybh from tb_xw_ythcj_sw group by rybh) s where p.rybh=s.swrybh(+) and (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1') and s.swrybh is null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
......@@ -268,13 +255,6 @@
AND rybh not in ( SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR( WCJX, '05' ) > 0)
)t53,
<!--(select count(*) zjxzcjs from TB_RY_RYCJ p,(select rybh swrybh from tb_xw_ythcj_zj group by rybh) s where p.rybh=s.swrybh(+) and (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1') and tbbz = '0' and s.swrybh is not null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
<if test="minccsj != null and minccsj != ''"> and lrsj <![CDATA[>=]]> to_date(#{minccsj , jdbcType=VARCHAR },'YYYY-MM-DD')</if>
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
AND p.rybh not in ( SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR( WCJX, '05' ) > 0)
)t51,-->
(
select count(*) as zjwcjs from (SELECT (select count(1) from tb_xw_ythcj_zj s where s.rybh = TB_RY_RYCJ.rybh and sfts = '1' and (s.xzsl ='1' or s.xzsl is null)) as zj
from TB_RY_RYCJ where (SCBZ = '0' or SCBZ is null) AND (IFHB <![CDATA[<>]]> '1' OR IFHB IS NULL)
......@@ -350,13 +330,6 @@
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
AND rybh not in ( SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR( WCJX, '06' ) > 0)
)t63,
<!-- (select count(*) hmxzcjs from TB_RY_RYCJ p,(select rybh swrybh from tb_xw_ythcj_hm group by rybh) s where p.rybh=s.swrybh(+) and (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1') and tbbz = '0' and s.swrybh is not null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
<if test="minccsj != null and minccsj != ''"> and lrsj <![CDATA[>=]]> to_date(#{minccsj , jdbcType=VARCHAR },'YYYY-MM-DD')</if>
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
AND p.rybh not in ( SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR( WCJX, '06' ) > 0)
)t61,-->
(
select count(*) as hmwcjs from (SELECT (select count(1) from tb_xw_ythcj_hm s where s.rybh = TB_RY_RYCJ.rybh and (sfts = '1' or sbcsdm like '%536U')) as hm
from TB_RY_RYCJ where (TB_RY_RYCJ.SCBZ = '0' or TB_RY_RYCJ.SCBZ is null) AND (IFHB <![CDATA[<>]]> '1' OR IFHB IS NULL)
......@@ -367,26 +340,7 @@
AND rybh not in (SELECT rybh ryxxwfcjbh FROM TB_XW_YTHCJ_RYXXWCJSM WHERE INSTR(WCJX, '06') > 0)
)
where HM = 0
)t62,
(select count(*) dnacjs from TB_RY_RYCJ where (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1') and (tbbz = '1' or tbbz = '2') and dnabh is not null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
<if test="minccsj != null and minccsj != ''"> and lrsj <![CDATA[>=]]> to_date(#{minccsj , jdbcType=VARCHAR },'YYYY-MM-DD')</if>
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
)t7,
(select count(*) dnaxzcjs from TB_RY_RYCJ where (SCBZ='0' or SCBZ is null) and tbbz = '0' and (ifhb is null or ifhb<![CDATA[<>]]>'1') and dnabh is not null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
<if test="minccsj != null and minccsj != ''"> and lrsj <![CDATA[>=]]> to_date(#{minccsj , jdbcType=VARCHAR },'YYYY-MM-DD')</if>
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
)t71,
(select count(*) dnawcjs from TB_RY_RYCJ where (SCBZ='0' or SCBZ is null) and (ifhb is null or ifhb<![CDATA[<>]]>'1') and dnabh is null
<if test="lrdwdm != null and lrdwdm != ''"> and lrdwdm like #{lrdwdm , jdbcType=VARCHAR }||'%'</if>
<if test="maxccsj != null and maxccsj != ''"> and lrsj <![CDATA[<]]> to_date(#{maxccsj , jdbcType=VARCHAR },'YYYY-MM-DD')+1</if>
<if test="minccsj != null and minccsj != ''"> and lrsj <![CDATA[>=]]> to_date(#{minccsj , jdbcType=VARCHAR },'YYYY-MM-DD')</if>
<if test="sqlwhere != null and sqlwhere != ''"> and ${sqlwhere}</if>
)t72
)t62
</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