版本查询问题修复

web_backend_develope
chenlw 9 years ago
parent 3829dabbbf
commit 7d4bec698f

@ -29,9 +29,12 @@ public class Custom4exception {
/**
* ---
*/
public final static String threadVolume_Oracle_Except = "3002001002";
public final static String threadVolume_Oracle_Except = "3002001001";
/** * SQL执行错误 */
public final static String OracleSQL_Except = "3002001002";
/** * MySQL错误 */
public final static String MySQL_Except = "3002002003";
}

@ -76,7 +76,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
</if>
<if test="array !=null and array.length > 0">
<foreach collection="array" item="item" index="index">
AND CONCAT(regionalism_code,system_code,data_version,city_name,district_name,system_name) LIKE CONCAT('%',CONCAT(#{item},'%'))
AND CONCAT(regionalism_code,system_code,city_name,district_name,system_name,data_year) LIKE CONCAT('%',CONCAT(#{item},'%'))
</foreach>
</if>
</sql>

@ -1,6 +1,7 @@
package com.platform.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
@ -12,6 +13,7 @@ import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntity;
@ -41,18 +43,49 @@ public class DataInfoServiceImp implements DataInfoService {
String querystr = pagerOptions.getKeyQuery();
String[] querys = null;
try {
List<String> removelist = new ArrayList<String>();
List<String> alllist = new ArrayList<String>();
List<String> list = new ArrayList<String>();
//去掉版本字段
Pattern pattern = Pattern.compile("^版本\\d+$");
if (null != querystr && !"".equals(querystr)) {
querys = querystr.split(" ");
list = Arrays.asList(querys);
}
//遍历 list
for (String ss : alllist) {
ss = ss.trim();
alllist.add(ss);
}
for (String ss : alllist) {
Matcher matcher2 = pattern.matcher(ss);
// 去掉 最后 的 / 符合
if (matcher2.find()) {
String s2 = matcher2.group();
removelist.add(ss);
}
}
alllist.removeAll(removelist);
Object[] strs = alllist.toArray();
int length = strs.length;
String[] arrays = new String[length];
for (int i = 0; i < length; i++) {
arrays[i] = strs[i].toString();
}
for (String version : removelist) {
pagerOptions.setDataVersion(Integer.valueOf(version.replace("版本", "")));
}
if (arrays.length > 0) {
pagerOptions.setArray(arrays);
}
pagerOptions.setArray(querys);
int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
System.out.println("total colume " + count);
log.info("total colume " + count);
int offset = 0;
if (pagerOptions.getCurrentPageNum() > 1) {
pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1)
* pagerOptions.getPriorTableSize());
offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
System.out.println(offset);
log.info(offset);
}
pagerOptions.setOffset(offset + 1);
List<DataInfoEntity> result = dfdDao
@ -112,8 +145,8 @@ public class DataInfoServiceImp implements DataInfoService {
try {
result = dfdDao.save(data);
} catch (Exception e) {
// TODO: handle exception
System.out.println("");
result = -1;
new CustomException(Custom4exception.MySQL_Except, e, data);
}
return result;
}

Loading…
Cancel
Save