123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- package com.sinosoft.cm.chart.dao;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import com.sinosoft.cm.CMTemplate;
- import com.sinosoft.cm.common.StringUtils;
- import com.sinosoft.cm.ex.SQLStringException;
- public class ChartDaoImpl implements IChartDao {
- private Log log = LogFactory.getLog(ChartDaoImpl.class);
- protected CMTemplate cmt=null;
- protected Map<String,String> map;
- public ChartDaoImpl(){
- cmt=new CMTemplate();
- map=new HashMap<String,String>();
-
-
-
-
- }
-
- /**
- * 通过sql语句名查询
- * @param sqlName sql语句名
- * @param list 替换列表
- * @param args 参数
- * @return
- * @throws SQLStringException
- */
- public List<Map<String,String>> findAllByNameAndIN(String sqlName,List<String> list,Object...args) throws SQLStringException {
- List<Map<String,String>> listMap=null;
- String strSql=map.get(sqlName);
- if(strSql.toLowerCase()==null || "".equals(strSql))
- throw new SQLStringException("sql语句不存在;sqlName="+sqlName);
-
- if(list!=null)
- try {
- strSql=StringUtils.replace(strSql,"_\\?_",list);
- } catch (Exception e) {
- log.error(e.getMessage());;
- }
- log.info("sql======"+strSql);
- listMap=cmt.queryMoreTypeToMap(strSql, args);
- return listMap;
- }
-
- /**
- * 重载findAllByNameAndIN方法
- * @param sqlName sql语句名
- * @param str 替换的字符串
- * @param sprateStr str的切割字符串
- * @param args 可变参数
- * @return
- * @throws SQLStringException
- */
- public List<Map<String,String>> findAllByNameAndIN(String sqlName,String str,String sprateStr,Object...args) throws SQLStringException{
- List<Map<String,String>> listMap=null;
- if(str==null || str.toLowerCase().equals("null") ||"".equals(str.trim()))
- throw new SQLStringException("替换字段异常=="+str);
- String sqlStr=map.get(sqlName);
- if(sprateStr==null ||"".equals(sprateStr.trim())){
- sqlStr=sqlStr.replace("_?_", str);
- }else{
- String[] arr=str.split(sprateStr);
- try {
- sqlStr=StringUtils.replace(sqlStr, "_\\?_", arr);
- arr=null;
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- }
- log.info("sql:"+sqlName+"======"+sqlStr);
- listMap=cmt.queryMoreTypeToMap(sqlStr, args);
- sqlStr=null;
- return listMap;
- }
-
- /**
- * 重载findAllByNameAndIN方法 查询最新一条已发布事件
- * 2016/11/13 谢仲铠修改
- * @param sqlName sql语句名
- * @param year 年份
- * @param compId id
- * @return
- * @throws SQLStringException
- *
- */
- public List<Map<String,String>> findAllByNameAndIN(String sqlName,Object...args) throws SQLStringException{
- List<Map<String,String>> listMap=null;
- /*if(str==null || str.toLowerCase().equals("null") ||"".equals(str.trim()))
- throw new SQLStringException("替换字段异常=="+str);*/
- String sqlStr=map.get(sqlName);
- /*if(sprateStr==null ||"".equals(sprateStr.trim())){
- sqlStr=sqlStr.replace("_?_", str);
- }else{
- String[] arr=str.split(sprateStr);
- try {
- sqlStr=StringUtils.replace(sqlStr, "_\\?_", arr);
- arr=null;
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- }*/
- log.info("sql:"+sqlName+"======"+sqlStr);
- listMap=cmt.queryMoreTypeToMap(sqlStr, args);
- sqlStr=null;
- return listMap;
- }
-
-
- /**
- * findAllByNameAndINNumber方法 通过事件查询最新一条已发布的通知单
- * 2016/11/13 谢仲铠修改
- * @param sqlName sql语句名
- * @param year 年份
- * @param compId id
- * @return
- * @throws SQLStringException
- *
- */
- public List<Map<String,String>> findAllByNameAndINNumber(String sqlName,Object...args) throws SQLStringException{
- List<Map<String,String>> listMap=null;
- String sqlStr=map.get(sqlName);
- log.info("sql:"+sqlName+"======"+sqlStr);
- listMap=cmt.queryMoreTypeToMap(sqlStr, args);
- sqlStr=null;
- return listMap;
- }
-
-
-
- /**
- * 重载findAllByNameAndIN方法
- * @param sqlName sql语句名
- * @param str 替换的字符串
- * @param sprateStr str的切割字符串
- * @param str1 替换的字符串
- * @param sprateStr1 str1的切割字符串
- * @param args 可变参数
- * @return
- * @throws SQLStringException
- */
- public List<Map<String,String>> findAllByNameAndIN1(String sqlName,String str,String sprateStr,String str1,String sprateStr1,Object...args) throws SQLStringException{
- List<Map<String,String>> listMap=null;
- if(str==null || str.toLowerCase().equals("null") ||"".equals(str.trim()))
- throw new SQLStringException("替换字段异常=="+str);
- String sqlStr=map.get(sqlName);
- if(sprateStr==null ||"".equals(sprateStr.trim())){
- sqlStr=sqlStr.replace("_?_", str);
-
- }else{
- String[] arr=str.split(sprateStr);
- try {
- sqlStr=StringUtils.replace(sqlStr, "_\\?_", arr);
- arr=null;
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- }
- log.info("sql======"+sqlStr);
-
- if(str1==null || str1.toLowerCase().equals("null") ||"".equals(str1.trim()))
- throw new SQLStringException("替换字段异常=="+str1);
- if(sprateStr1==null ||"".equals(sprateStr1.trim())){
- sqlStr=sqlStr.replace("%?%", str);
-
- }else{
- String[] arr=str1.split(sprateStr1);
- try {
- sqlStr=StringUtils.replace(sqlStr, "%\\?%", arr);
- arr=null;
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- }
- log.info("sql======"+sqlStr);
-
-
- listMap=cmt.queryMoreTypeToMap(sqlStr, args);
- sqlStr=null;
- return listMap;
- }
-
-
- }
|