فهرست منبع

merge main.cpp card.cpp

lixioayao 6 سال پیش
والد
کامیت
13fb70e05c
38فایلهای تغییر یافته به همراه3066 افزوده شده و 2426 حذف شده
  1. 5 0
      .gitignore
  2. 40 13
      CMakeLists.txt
  3. 194 99
      aclocal.m4
  4. 1 1
      ant.cpp
  5. 1 1
      area.cpp
  6. 56 5
      autom4te.cache/output.1
  7. 117 25
      autom4te.cache/requests
  8. 46 1
      autom4te.cache/traces.1
  9. 59 0
      autoscan.log
  10. 50 33
      card.cpp
  11. 11 12
      card.h
  12. 2 1
      cardMgr.cpp
  13. 4 0
      common.h
  14. 11 1
      common_tool.h
  15. 56 5
      configure
  16. 51 0
      configure.scan
  17. 108 108
      db_api/CDBCommon.h
  18. 36 15
      db_api/CDBConnPool.cpp
  19. 289 285
      db_api/CDBConnPool.h
  20. 293 290
      db_api/CDBConnect.cpp
  21. 332 332
      db_api/CDBConnect.h
  22. 45 45
      db_api/CDBHelper.cpp
  23. 86 86
      db_api/CDBHelper.h
  24. 451 451
      db_api/CDBResultSet.cpp
  25. 573 573
      db_api/CDBResultSet.h
  26. 11 0
      db_api/CDBSingletonDefine.h
  27. 1 1
      depcomp
  28. 1 1
      his_location.h
  29. 1 1
      install-sh
  30. 1 1
      landmark.cpp
  31. 22 20
      main.cpp
  32. 87 0
      main_test.h
  33. 1 1
      mine.h
  34. 1 1
      missing
  35. 15 12
      module_service/module_meta_date_changed.cpp
  36. 6 4
      module_service/module_meta_date_changed.h
  37. 1 1
      special_area.cpp
  38. 1 1
      ya_event.h

+ 5 - 0
.gitignore

@@ -14,4 +14,9 @@ test
 yals
 async
 client
+cmake-build-debug/
+CMakeFiles/
+.idea/
+.git/
+.vscode/
 

+ 40 - 13
CMakeLists.txt

@@ -1,4 +1,24 @@
 cmake_minimum_required(VERSION 2.8)
+#set(CMAKE_VERBOSE_MAKEFILE  ON)
+
+SET(CMAKE_C_COMPILER "/usr/local/bin/gcc")
+
+SET(CMAKE_CXX_COMPILER "/usr/local/bin/g++")
+
+#输出项目名称
+project(ya-serv)
+
+message(STATUS "src dir = ${ya-serv_SOURCE_DIR}")
+message(STATUS "binary dir = ${ya-serv_BINARY_DIR}")
+
+message(STATUS "leoox src dir = ${CMAKE_SOURCE_DIR}")
+
+message(STATUS "leoox binary dir = ${CMAKE_BINARY_DIR}")
+
+message(STATUS "CMAKE_CXX_FLAGS_DEBUG = " ${CMAKE_C_FLAGS_DEBUG})
+
+message(STATUS "CMAKE_CXX_FLAGS_RELEASE = " ${CMAKE_C_FLAGS_RELEASE})
+
 #在项目中显示所有源码
 file(GLOB files_ya-serv ./*.cpp ./*.h ./websocket/* ./db_api/* ./src/* ./src/internal/*
     ./module_service/* ./monkey_car/*)
@@ -6,24 +26,29 @@ add_custom_target(files_ya-serv SOURCES ${files_ya-serv})
 MESSAGE(STATUS "module: ya-serv")
 
 #g++编译参数
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -m64 -std=c++11 -fPIC -fno-strict-aliasing")
-#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -pthread -m64 -std=c++11 -fPIC -fno-strict-aliasing")
+# 版本
+
+SET(CMAKE_BUILD_TYPE DEBUG)
+
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pthread -m64 -std=c++11 -fPIC -fno-strict-aliasing")
+#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -pthread -m64 -std=c++11 -fPIC -fno-strict-aliasing")
+
 #第三方库库文件目录
-link_directories( "/root/soft/boost_1_67_0/lib" "/usr/lib64/mysql" "/root/projection/out/lib")
+link_directories( "/usr/local/mysql/lib" "${CMAKE_CURRENT_SOURCE_DIR}/../dist/lib")
+
 #第三方库头文件目录
-include_directories("/home/user/libev-4.24" "." "/root/soft/boost_1_67_0/include/"
-    "/root/projection/out/"
-    "/root/projection/out/websocketpp"
-    "/usr/include/mysql/"  "src/" "src/internal/"
+include_directories("/usr/local/include" "." "usr/include"
+    "../dist/include"
+    "../rapidjson/include"
+    "/usr/local/mysql/include"  "src/" "src/internal/"
     "websocket/" "db_api/" "module_service/")
 
-#输出项目名称
-project(ya-serv)
+
 #编译项目所需源码
 set(SRC_YASL "ant.cpp" "ant.h" "base64.cpp" "base64.h" "card.cpp" "card.h" "clock.h"
     "io_buf.h" "line.h" "message.cpp" "message.h" "point.cpp"
     "point.h" "tdoa_sync.cpp" "tdoa_sync.h" "web-client.cpp" "web-client.h" "worker.cpp" "worker.h" "zio.h"
-    "zloop.h" "znet.cpp" "znet.h" "zstream.h" "log.h"  "card_path.h" "card_path.cpp"
+    "zloop.h" "znet.cpp" "znet.h" "zstream.h" "card_path.h" "card_path.cpp"
     "select_tool.h" "select_tool.cpp" "loc_point.h" "loc_point.cpp" "line_fit.h" "line_fit.cpp"
     "net-service.h" "net-service.cpp" "loc_tool.h" "loc_tool.cpp"
 
@@ -31,6 +56,7 @@ set(SRC_YASL "ant.cpp" "ant.h" "base64.cpp" "base64.h" "card.cpp" "card.h" "cloc
     "db_api/CDBConnPool.h" "db_api/CDBConnPool.cpp"
     "db_api/CDBHelper.h" "db_api/CDBHelper.cpp"
     "db_api/CDBResultSet.h" "db_api/CDBResultSet.cpp"
+    "db_api/CDBSingletonDefine.h"
 
     "src/sio_client.h" "src/sio_client.cpp" "src/sio_message.h"
     "src/sio_socket.h" "src/sio_socket.cpp"
@@ -86,7 +112,7 @@ set(SRC_MODULE
 
 add_executable(${PROJECT_NAME} "main.cpp" ${SRC_YASL}  ${SRC_MODULE})
 
-target_link_libraries (${PROJECT_NAME}  zlog rt ev boost_chrono boost_system boost_thread mysqlclient)
+target_link_libraries (${PROJECT_NAME}  zlog rt ev boost_chrono boost_system boost_thread mysqlclient three_rates)
 
 #file(COPY data_reader_antenna.txt DESTINATION ${PROJECT_BINARY_DIR})
 #file(COPY path_tof.txt DESTINATION ${PROJECT_BINARY_DIR})
@@ -94,8 +120,9 @@ target_link_libraries (${PROJECT_NAME}  zlog rt ev boost_chrono boost_system boo
 #file(COPY /root/projection/out/bin/logger DESTINATION ${PROJECT_BINARY_DIR})
 #file(COPY /root/projection/out/etc DESTINATION ${PROJECT_SOURCE_DIR})
 #file(COPY /root/projection/out/log DESTINATION ${PROJECT_SOURCE_DIR})
-#file(COPY /root/projection/out/include/log.h DESTINATION ${PROJECT_SOURCE_DIR})
-#file(COPY /root/projection/out/include/config_file.h DESTINATION ${PROJECT_SOURCE_DIR})
+#file(COPY /root/projection/out/include/ DESTINATION ${PROJECT_SOURCE_DIR})
+
+
 
 
 

+ 194 - 99
aclocal.m4

@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.12.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
 
-# Copyright (C) 1996-2012 Free Software Foundation, Inc.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -11,6 +11,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
@@ -19,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -31,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.12'
+[am__api_version='1.13'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.12.3], [],
+m4_if([$1], [1.13.4], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -50,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.12.3])dnl
+[AM_AUTOMAKE_VERSION([1.13.4])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -110,7 +111,7 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2012 Free Software Foundation, Inc.
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -141,7 +142,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -332,7 +333,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -343,7 +344,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 [{
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
   case $CONFIG_FILES in
@@ -372,7 +373,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
@@ -408,7 +409,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2012 Free Software Foundation, Inc.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -429,7 +430,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # arguments mandatory, and then we can depend on a new Autoconf
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.62])dnl
+[AC_PREREQ([2.65])dnl
 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 dnl the ones we care about.
 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@@ -459,8 +460,7 @@ AC_SUBST([CYGPATH_W])
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
 [AC_DIAGNOSE([obsolete],
-[$0: two- and three-arguments forms are deprecated.  For more info, see:
-http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation])
+             [$0: two- and three-arguments forms are deprecated.])
 m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
@@ -514,18 +514,15 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
 		  [_AM_DEPENDENCIES([OBJC])],
 		  [m4_define([AC_PROG_OBJC],
 			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
-dnl Support for Objective C++ was only introduced in Autoconf 2.65,
-dnl but we still cater to Autoconf 2.62.
-m4_ifdef([AC_PROG_OBJCXX],
-[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
 		  [_AM_DEPENDENCIES([OBJCXX])],
 		  [m4_define([AC_PROG_OBJCXX],
-			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
 ])
-_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
-dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the
-dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
-dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
 AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
@@ -559,7 +556,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -580,7 +577,7 @@ if test x"${install_sh}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -601,7 +598,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -651,7 +648,7 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2012 Free Software Foundation, Inc.
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -666,8 +663,8 @@ AC_SUBST($1)])
 
 # AM_MISSING_HAS_RUN
 # ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
@@ -680,8 +677,8 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
   AC_MSG_WARN(['missing' script is too old or missing])
@@ -690,7 +687,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -721,7 +718,7 @@ AC_DEFUN([_AM_IF_OPTION],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2012 Free Software Foundation, Inc.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -802,7 +799,67 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2001-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+   [am_cv_make_support_nested_variables],
+   [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -830,7 +887,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -849,7 +906,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -868,76 +925,114 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 # Substitute a variable $(am__untar) that extract such
 # a tarball read from stdin.
 #     $(am__untar) < result.tar
+#
 AC_DEFUN([_AM_PROG_TAR],
 [# Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AC_SUBST([AMTAR], ['$${TAR-tar}'])
-m4_if([$1], [v7],
-     [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
-     [m4_case([$1], [ustar],, [pax],,
-              [m4_fatal([Unknown tar format])])
-AC_MSG_CHECKING([how to create a $1 tar archive])
-# Loop over all known methods to create a tar archive until one works.
+
+# We'll loop over all known methods to create a tar archive until one works.
 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
-_am_tools=${am_cv_prog_tar_$1-$_am_tools}
-# Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of '-'.
-for _am_tool in $_am_tools
-do
-  case $_am_tool in
-  gnutar)
-    for _am_tar in tar gnutar gtar;
-    do
-      AM_RUN_LOG([$_am_tar --version]) && break
-    done
-    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
-    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
-    am__untar="$_am_tar -xf -"
-    ;;
-  plaintar)
-    # Must skip GNU tar: if it does not support --format= it doesn't create
-    # ustar tarball either.
-    (tar --version) >/dev/null 2>&1 && continue
-    am__tar='tar chf - "$$tardir"'
-    am__tar_='tar chf - "$tardir"'
-    am__untar='tar xf -'
-    ;;
-  pax)
-    am__tar='pax -L -x $1 -w "$$tardir"'
-    am__tar_='pax -L -x $1 -w "$tardir"'
-    am__untar='pax -r'
-    ;;
-  cpio)
-    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
-    am__untar='cpio -i -H $1 -d'
-    ;;
-  none)
-    am__tar=false
-    am__tar_=false
-    am__untar=false
-    ;;
-  esac
 
-  # If the value was cached, stop now.  We just wanted to have am__tar
-  # and am__untar set.
-  test -n "${am_cv_prog_tar_$1}" && break
+m4_if([$1], [v7],
+  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+  [m4_case([$1],
+    [ustar],
+     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+      # There is notably a 21 bits limit for the UID and the GID.  In fact,
+      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+      # and bug#13588).
+      am_max_uid=2097151 # 2^21 - 1
+      am_max_gid=$am_max_uid
+      # The $UID and $GID variables are not portable, so we need to resort
+      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
+      # below are definitely unexpected, so allow the users to see them
+      # (that is, avoid stderr redirection).
+      am_uid=`id -u || echo unknown`
+      am_gid=`id -g || echo unknown`
+      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+      if test $am_uid -le $am_max_uid; then
+         AC_MSG_RESULT([yes])
+      else
+         AC_MSG_RESULT([no])
+         _am_tools=none
+      fi
+      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+      if test $am_gid -le $am_max_gid; then
+         AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+        _am_tools=none
+      fi],
+
+  [pax],
+    [],
+
+  [m4_fatal([Unknown tar format])])
+
+  AC_MSG_CHECKING([how to create a $1 tar archive])
+
+  # Go ahead even if we have the value already cached.  We do so because we
+  # need to set the values for the 'am__tar' and 'am__untar' variables.
+  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+  for _am_tool in $_am_tools; do
+    case $_am_tool in
+    gnutar)
+      for _am_tar in tar gnutar gtar; do
+        AM_RUN_LOG([$_am_tar --version]) && break
+      done
+      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+      am__untar="$_am_tar -xf -"
+      ;;
+    plaintar)
+      # Must skip GNU tar: if it does not support --format= it doesn't create
+      # ustar tarball either.
+      (tar --version) >/dev/null 2>&1 && continue
+      am__tar='tar chf - "$$tardir"'
+      am__tar_='tar chf - "$tardir"'
+      am__untar='tar xf -'
+      ;;
+    pax)
+      am__tar='pax -L -x $1 -w "$$tardir"'
+      am__tar_='pax -L -x $1 -w "$tardir"'
+      am__untar='pax -r'
+      ;;
+    cpio)
+      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__untar='cpio -i -H $1 -d'
+      ;;
+    none)
+      am__tar=false
+      am__tar_=false
+      am__untar=false
+      ;;
+    esac
 
-  # tar/untar a dummy directory, and stop if the command works
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  echo GrepMe > conftest.dir/file
-  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    # If the value was cached, stop now.  We just wanted to have am__tar
+    # and am__untar set.
+    test -n "${am_cv_prog_tar_$1}" && break
+
+    # tar/untar a dummy directory, and stop if the command works.
+    rm -rf conftest.dir
+    mkdir conftest.dir
+    echo GrepMe > conftest.dir/file
+    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    rm -rf conftest.dir
+    if test -s conftest.tar; then
+      AM_RUN_LOG([$am__untar <conftest.tar])
+      AM_RUN_LOG([cat conftest.dir/file])
+      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+    fi
+  done
   rm -rf conftest.dir
-  if test -s conftest.tar; then
-    AM_RUN_LOG([$am__untar <conftest.tar])
-    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
-  fi
-done
-rm -rf conftest.dir
 
-AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
 AC_SUBST([am__tar])
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR

+ 1 - 1
ant.cpp

@@ -3,7 +3,7 @@
 #include <string.h>
 #include <math.h>
 #include "ant.h"
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 
 template<> std::shared_ptr<sit_list> 
 single_base<sit_list, int, std::shared_ptr<site>>::m_instance=std::make_shared<sit_list>();

+ 1 - 1
area.cpp

@@ -1,6 +1,6 @@
 #include <memory>
 #include <write-copy.h>
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include "log.h"
 
 #include <area.h>

+ 56 - 5
autom4te.cache/output.1

@@ -652,6 +652,10 @@ CPPFLAGS
 LDFLAGS
 CXXFLAGS
 CXX
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
 am__untar
 am__tar
 AMTAR
@@ -716,6 +720,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+enable_silent_rules
 enable_dependency_tracking
 '
       ac_precious_vars='build_alias
@@ -1344,6 +1349,8 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
   --enable-dependency-tracking 
                           do not reject slow dependency extractors
   --disable-dependency-tracking 
@@ -2368,7 +2375,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-am__api_version='1.12'
+am__api_version='1.13'
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@@ -2581,8 +2588,8 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
@@ -2822,6 +2829,45 @@ else
 fi
 rmdir .tst 2>/dev/null
 
+@%:@ Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules; 
+fi
+
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
 if test "`cd $srcdir && pwd`" != "`pwd`"; then
   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
   # is not polluted with repeated "-I."
@@ -2884,6 +2930,10 @@ mkdir_p='$(MKDIR_P)'
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
 
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar  pax cpio none'
+
 am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
@@ -2892,6 +2942,7 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
+
 # Checks for programs.
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
@@ -6321,7 +6372,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
   case $CONFIG_FILES in
@@ -6372,7 +6423,7 @@ $as_echo X"$mf" |
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the

+ 117 - 25
autom4te.cache/requests

@@ -62,8 +62,8 @@
                         'AM_CONDITIONAL' => 1,
                         'AM_SET_DEPDIR' => 1,
                         '_AM_DEPENDENCIES' => 1,
-                        'm4_include' => 1,
                         'AM_PROG_INSTALL_SH' => 1,
+                        'm4_include' => 1,
                         '_AC_AM_CONFIG_HEADER_HOOK' => 1,
                         'AU_DEFUN' => 1,
                         'AM_MAKE_INCLUDE' => 1
@@ -81,64 +81,156 @@
                         'configure.ac'
                       ],
                       {
-                        '_LT_AC_TAGCONFIG' => 1,
                         'AM_PROG_F77_C_O' => 1,
-                        'AC_INIT' => 1,
+                        '_LT_AC_TAGCONFIG' => 1,
                         'm4_pattern_forbid' => 1,
                         'AC_CANONICAL_TARGET' => 1,
-                        '_AM_COND_IF' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
+                        'AM_EXTRA_RECURSIVE_TARGETS' => 1,
+                        'AC_PROG_LIBTOOL' => 1,
+                        'AM_PROG_MKDIR_P' => 1,
+                        'AM_AUTOMAKE_VERSION' => 1,
+                        'AC_CHECK_HEADERS' => 1,
+                        'LT_CONFIG_LTDL_DIR' => 1,
+                        'm4_sinclude' => 1,
+                        'AC_PROG_CXX' => 1,
+                        'AM_NLS' => 1,
+                        '_m4_warn' => 1,
+                        'AC_PREREQ' => 1,
+                        'AM_PROG_CXX_C_O' => 1,
+                        '_AM_MAKEFILE_INCLUDE' => 1,
+                        'AM_PROG_MOC' => 1,
+                        'AC_TYPE_INT64_T' => 1,
+                        'LT_INIT' => 1,
+                        'AC_LIBSOURCE' => 1,
+                        'AM_PROG_FC_C_O' => 1,
+                        'AC_CANONICAL_BUILD' => 1,
+                        'AC_CONFIG_AUX_DIR' => 1,
+                        '_AM_SUBST_NOTMAKE' => 1,
+                        'm4_pattern_allow' => 1,
+                        'sinclude' => 1,
+                        'AC_TYPE_UINT64_T' => 1,
+                        'AC_DEFINE_TRACE_LITERAL' => 1,
+                        'AC_TYPE_INT16_T' => 1,
+                        'AC_PROG_CC' => 1,
+                        '_AM_COND_ELSE' => 1,
+                        'AC_SUBST_TRACE' => 1,
+                        'AC_INIT' => 1,
+                        '_AM_COND_IF' => 1,
                         'AC_SUBST' => 1,
                         'AC_CANONICAL_HOST' => 1,
                         'AC_FC_SRCEXT' => 1,
-                        'AC_PROG_LIBTOOL' => 1,
-                        'AM_PROG_MKDIR_P' => 1,
                         'AM_INIT_AUTOMAKE' => 1,
                         'AC_CONFIG_SUBDIRS' => 1,
                         'AM_PATH_GUILE' => 1,
-                        'AM_AUTOMAKE_VERSION' => 1,
-                        'LT_CONFIG_LTDL_DIR' => 1,
+                        'AC_TYPE_INT8_T' => 1,
+                        'AC_FUNC_REALLOC' => 1,
+                        'AC_TYPE_SIZE_T' => 1,
                         'AC_REQUIRE_AUX_FILE' => 1,
                         'AC_CONFIG_LINKS' => 1,
                         'LT_SUPPORTED_TAG' => 1,
-                        'm4_sinclude' => 1,
                         'AM_MAINTAINER_MODE' => 1,
-                        'AM_NLS' => 1,
+                        'AC_TYPE_UINT32_T' => 1,
                         'AC_FC_PP_DEFINE' => 1,
                         'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
-                        '_m4_warn' => 1,
                         'AM_MAKEFILE_INCLUDE' => 1,
-                        'AM_PROG_CXX_C_O' => 1,
+                        'AC_PROG_CPP' => 1,
+                        'AC_C_INLINE' => 1,
                         '_AM_COND_ENDIF' => 1,
-                        '_AM_MAKEFILE_INCLUDE' => 1,
                         'AM_ENABLE_MULTILIB' => 1,
-                        'AM_PROG_MOC' => 1,
                         'AM_SILENT_RULES' => 1,
                         'AC_CONFIG_FILES' => 1,
                         'include' => 1,
-                        'LT_INIT' => 1,
+                        'AC_TYPE_INT32_T' => 1,
                         'AM_PROG_AR' => 1,
                         'AM_GNU_GETTEXT' => 1,
-                        'AC_LIBSOURCE' => 1,
-                        'AC_CANONICAL_BUILD' => 1,
-                        'AM_PROG_FC_C_O' => 1,
+                        'AC_FUNC_MALLOC' => 1,
                         'AC_FC_FREEFORM' => 1,
                         'AC_FC_PP_SRCEXT' => 1,
                         'AH_OUTPUT' => 1,
-                        '_AM_SUBST_NOTMAKE' => 1,
-                        'AC_CONFIG_AUX_DIR' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'sinclude' => 1,
-                        'm4_pattern_allow' => 1,
+                        'AC_FUNC_MKTIME' => 1,
                         'AM_CONDITIONAL' => 1,
                         'AC_CANONICAL_SYSTEM' => 1,
                         'AM_XGETTEXT_OPTION' => 1,
                         'AC_CONFIG_HEADERS' => 1,
-                        'AC_DEFINE_TRACE_LITERAL' => 1,
+                        'AC_TYPE_UINT16_T' => 1,
                         'AM_POT_TOOLS' => 1,
                         'm4_include' => 1,
-                        '_AM_COND_ELSE' => 1,
-                        'AC_SUBST_TRACE' => 1
+                        'AC_CHECK_HEADER_STDBOOL' => 1,
+                        'AC_CHECK_FUNCS' => 1,
+                        'AC_TYPE_UINT8_T' => 1
+                      }
+                    ], 'Autom4te::Request' ),
+             bless( [
+                      '2',
+                      1,
+                      [
+                        '/usr/share/autoconf'
+                      ],
+                      [
+                        '/usr/share/autoconf/autoconf/autoconf.m4f',
+                        '-',
+                        '/usr/share/aclocal-1.13/internal/ac-config-macro-dirs.m4',
+                        '/usr/share/aclocal-1.13/amversion.m4',
+                        '/usr/share/aclocal-1.13/auxdir.m4',
+                        '/usr/share/aclocal-1.13/cond.m4',
+                        '/usr/share/aclocal-1.13/depend.m4',
+                        '/usr/share/aclocal-1.13/depout.m4',
+                        '/usr/share/aclocal-1.13/init.m4',
+                        '/usr/share/aclocal-1.13/install-sh.m4',
+                        '/usr/share/aclocal-1.13/lead-dot.m4',
+                        '/usr/share/aclocal-1.13/make.m4',
+                        '/usr/share/aclocal-1.13/missing.m4',
+                        '/usr/share/aclocal-1.13/options.m4',
+                        '/usr/share/aclocal-1.13/runlog.m4',
+                        '/usr/share/aclocal-1.13/sanity.m4',
+                        '/usr/share/aclocal-1.13/silent.m4',
+                        '/usr/share/aclocal-1.13/strip.m4',
+                        '/usr/share/aclocal-1.13/substnot.m4',
+                        '/usr/share/aclocal-1.13/tar.m4',
+                        'configure.ac'
+                      ],
+                      {
+                        'm4_pattern_forbid' => 1,
+                        'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
+                        '_AM_SET_OPTION' => 1,
+                        'AC_DEFUN' => 1,
+                        'AM_INIT_AUTOMAKE' => 1,
+                        'AM_AUTOMAKE_VERSION' => 1,
+                        'AM_MISSING_HAS_RUN' => 1,
+                        'AM_SUBST_NOTMAKE' => 1,
+                        'AM_MISSING_PROG' => 1,
+                        'AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
+                        'AC_DEFUN_ONCE' => 1,
+                        '_AM_CONFIG_MACRO_DIRS' => 1,
+                        'AM_PROG_INSTALL_STRIP' => 1,
+                        '_m4_warn' => 1,
+                        'AM_SANITY_CHECK' => 1,
+                        'AM_SILENT_RULES' => 1,
+                        'include' => 1,
+                        '_AM_PROG_TAR' => 1,
+                        'AM_AUX_DIR_EXPAND' => 1,
+                        'AM_DEP_TRACK' => 1,
+                        '_AM_SET_OPTIONS' => 1,
+                        '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
+                        'AM_RUN_LOG' => 1,
+                        'AC_CONFIG_MACRO_DIR' => 1,
+                        '_AM_IF_OPTION' => 1,
+                        '_AM_SUBST_NOTMAKE' => 1,
+                        'm4_pattern_allow' => 1,
+                        '_AM_AUTOCONF_VERSION' => 1,
+                        '_AM_MANGLE_OPTION' => 1,
+                        'AM_CONDITIONAL' => 1,
+                        'AM_SET_LEADING_DOT' => 1,
+                        'AC_CONFIG_MACRO_DIR_TRACE' => 1,
+                        'AM_SET_DEPDIR' => 1,
+                        '_AM_DEPENDENCIES' => 1,
+                        'AM_PROG_INSTALL_SH' => 1,
+                        'm4_include' => 1,
+                        '_AC_AM_CONFIG_HEADER_HOOK' => 1,
+                        'AU_DEFUN' => 1,
+                        'AM_MAKE_INCLUDE' => 1
                       }
                     ], 'Autom4te::Request' )
            );

+ 46 - 1
autom4te.cache/traces.1

@@ -1,3 +1,4 @@
+m4trace:configure.ac:4: -1- AC_PREREQ([2.69])
 m4trace:configure.ac:5: -1- AC_INIT([yals], [1.0], [BUG-REPORT-ADDRESS])
 m4trace:configure.ac:5: -1- m4_pattern_forbid([^_?A[CHUM]_])
 m4trace:configure.ac:5: -1- m4_pattern_forbid([_AC_])
@@ -147,8 +148,9 @@ m4trace:configure.ac:5: -1- AC_SUBST([target_alias])
 m4trace:configure.ac:5: -1- AC_SUBST_TRACE([target_alias])
 m4trace:configure.ac:5: -1- m4_pattern_allow([^target_alias$])
 m4trace:configure.ac:8: -1- AM_INIT_AUTOMAKE([foreign -Wall])
+m4trace:configure.ac:8: -1- AC_PREREQ([2.65])
 m4trace:configure.ac:8: -1- m4_pattern_allow([^AM_[A-Z]+FLAGS$])
-m4trace:configure.ac:8: -1- AM_AUTOMAKE_VERSION([1.12.3])
+m4trace:configure.ac:8: -1- AM_AUTOMAKE_VERSION([1.13.4])
 m4trace:configure.ac:8: -1- AC_REQUIRE_AUX_FILE([install-sh])
 m4trace:configure.ac:8: -1- AC_SUBST([INSTALL_PROGRAM])
 m4trace:configure.ac:8: -1- AC_SUBST_TRACE([INSTALL_PROGRAM])
@@ -180,6 +182,7 @@ m4trace:configure.ac:8: -1- AC_DEFINE_TRACE_LITERAL([VERSION])
 m4trace:configure.ac:8: -1- m4_pattern_allow([^VERSION$])
 m4trace:configure.ac:8: -1- AH_OUTPUT([VERSION], [/* Version number of package */
 @%:@undef VERSION])
+m4trace:configure.ac:8: -1- AC_PREREQ([2.50])
 m4trace:configure.ac:8: -1- AC_REQUIRE_AUX_FILE([missing])
 m4trace:configure.ac:8: -1- AC_SUBST([ACLOCAL])
 m4trace:configure.ac:8: -1- AC_SUBST_TRACE([ACLOCAL])
@@ -230,6 +233,23 @@ m4trace:configure.ac:8: -1- m4_pattern_allow([^am__tar$])
 m4trace:configure.ac:8: -1- AC_SUBST([am__untar])
 m4trace:configure.ac:8: -1- AC_SUBST_TRACE([am__untar])
 m4trace:configure.ac:8: -1- m4_pattern_allow([^am__untar$])
+m4trace:configure.ac:8: -1- AM_SILENT_RULES
+m4trace:configure.ac:8: -1- AC_SUBST([AM_V])
+m4trace:configure.ac:8: -1- AC_SUBST_TRACE([AM_V])
+m4trace:configure.ac:8: -1- m4_pattern_allow([^AM_V$])
+m4trace:configure.ac:8: -1- _AM_SUBST_NOTMAKE([AM_V])
+m4trace:configure.ac:8: -1- AC_SUBST([AM_DEFAULT_V])
+m4trace:configure.ac:8: -1- AC_SUBST_TRACE([AM_DEFAULT_V])
+m4trace:configure.ac:8: -1- m4_pattern_allow([^AM_DEFAULT_V$])
+m4trace:configure.ac:8: -1- _AM_SUBST_NOTMAKE([AM_DEFAULT_V])
+m4trace:configure.ac:8: -1- AC_SUBST([AM_DEFAULT_VERBOSITY])
+m4trace:configure.ac:8: -1- AC_SUBST_TRACE([AM_DEFAULT_VERBOSITY])
+m4trace:configure.ac:8: -1- m4_pattern_allow([^AM_DEFAULT_VERBOSITY$])
+m4trace:configure.ac:8: -1- AC_SUBST([AM_BACKSLASH])
+m4trace:configure.ac:8: -1- AC_SUBST_TRACE([AM_BACKSLASH])
+m4trace:configure.ac:8: -1- m4_pattern_allow([^AM_BACKSLASH$])
+m4trace:configure.ac:8: -1- _AM_SUBST_NOTMAKE([AM_BACKSLASH])
+m4trace:configure.ac:12: -1- AC_PROG_CXX
 m4trace:configure.ac:12: -1- AC_SUBST([CXX])
 m4trace:configure.ac:12: -1- AC_SUBST_TRACE([CXX])
 m4trace:configure.ac:12: -1- m4_pattern_allow([^CXX$])
@@ -267,6 +287,7 @@ m4trace:configure.ac:12: -1- AC_SUBST([am__quote])
 m4trace:configure.ac:12: -1- AC_SUBST_TRACE([am__quote])
 m4trace:configure.ac:12: -1- m4_pattern_allow([^am__quote$])
 m4trace:configure.ac:12: -1- AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+m4trace:configure.ac:12: -1- AC_PREREQ([2.52])
 m4trace:configure.ac:12: -1- AC_SUBST([AMDEP_TRUE])
 m4trace:configure.ac:12: -1- AC_SUBST_TRACE([AMDEP_TRUE])
 m4trace:configure.ac:12: -1- m4_pattern_allow([^AMDEP_TRUE$])
@@ -289,6 +310,7 @@ m4trace:configure.ac:12: -1- m4_pattern_allow([^CXXDEPMODE$])
 m4trace:configure.ac:12: -1- AM_CONDITIONAL([am__fastdepCXX], [
   test "x$enable_dependency_tracking" != xno \
   && test "$am_cv_CXX_dependencies_compiler_type" = gcc3])
+m4trace:configure.ac:12: -1- AC_PREREQ([2.52])
 m4trace:configure.ac:12: -1- AC_SUBST([am__fastdepCXX_TRUE])
 m4trace:configure.ac:12: -1- AC_SUBST_TRACE([am__fastdepCXX_TRUE])
 m4trace:configure.ac:12: -1- m4_pattern_allow([^am__fastdepCXX_TRUE$])
@@ -297,6 +319,7 @@ m4trace:configure.ac:12: -1- AC_SUBST_TRACE([am__fastdepCXX_FALSE])
 m4trace:configure.ac:12: -1- m4_pattern_allow([^am__fastdepCXX_FALSE$])
 m4trace:configure.ac:12: -1- _AM_SUBST_NOTMAKE([am__fastdepCXX_TRUE])
 m4trace:configure.ac:12: -1- _AM_SUBST_NOTMAKE([am__fastdepCXX_FALSE])
+m4trace:configure.ac:13: -1- AC_PROG_CC
 m4trace:configure.ac:13: -1- AC_SUBST([CC])
 m4trace:configure.ac:13: -1- AC_SUBST_TRACE([CC])
 m4trace:configure.ac:13: -1- m4_pattern_allow([^CC$])
@@ -333,6 +356,7 @@ m4trace:configure.ac:13: -1- m4_pattern_allow([^CCDEPMODE$])
 m4trace:configure.ac:13: -1- AM_CONDITIONAL([am__fastdepCC], [
   test "x$enable_dependency_tracking" != xno \
   && test "$am_cv_CC_dependencies_compiler_type" = gcc3])
+m4trace:configure.ac:13: -1- AC_PREREQ([2.52])
 m4trace:configure.ac:13: -1- AC_SUBST([am__fastdepCC_TRUE])
 m4trace:configure.ac:13: -1- AC_SUBST_TRACE([am__fastdepCC_TRUE])
 m4trace:configure.ac:13: -1- m4_pattern_allow([^am__fastdepCC_TRUE$])
@@ -349,6 +373,7 @@ m4trace:configure.ac:19: -1- AH_OUTPUT([HAVE_LIBZLOG], [/* Define to 1 if you ha
 @%:@undef HAVE_LIBZLOG])
 m4trace:configure.ac:19: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBZLOG])
 m4trace:configure.ac:19: -1- m4_pattern_allow([^HAVE_LIBZLOG$])
+m4trace:configure.ac:22: -1- AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdint.h string.h sys/socket.h unistd.h])
 m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_ARPA_INET_H], [/* Define to 1 if you have the <arpa/inet.h> header file. */
 @%:@undef HAVE_ARPA_INET_H])
 m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_FCNTL_H], [/* Define to 1 if you have the <fcntl.h> header file. */
@@ -363,6 +388,7 @@ m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_SYS_SOCKET_H], [/* Define to 1 if y
 @%:@undef HAVE_SYS_SOCKET_H])
 m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
 @%:@undef HAVE_UNISTD_H])
+m4trace:configure.ac:22: -1- AC_PROG_CPP
 m4trace:configure.ac:22: -1- AC_SUBST([CPP])
 m4trace:configure.ac:22: -1- AC_SUBST_TRACE([CPP])
 m4trace:configure.ac:22: -1- m4_pattern_allow([^CPP$])
@@ -382,6 +408,8 @@ m4trace:configure.ac:22: -1- AC_DEFINE_TRACE_LITERAL([STDC_HEADERS])
 m4trace:configure.ac:22: -1- m4_pattern_allow([^STDC_HEADERS$])
 m4trace:configure.ac:22: -1- AH_OUTPUT([STDC_HEADERS], [/* Define to 1 if you have the ANSI C header files. */
 @%:@undef STDC_HEADERS])
+m4trace:configure.ac:22: -1- AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h], [], [], [$ac_includes_default])
 m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_SYS_TYPES_H], [/* Define to 1 if you have the <sys/types.h> header file. */
 @%:@undef HAVE_SYS_TYPES_H])
 m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_SYS_STAT_H], [/* Define to 1 if you have the <sys/stat.h> header file. */
@@ -400,44 +428,53 @@ m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_STDINT_H], [/* Define to 1 if you h
 @%:@undef HAVE_STDINT_H])
 m4trace:configure.ac:22: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
 @%:@undef HAVE_UNISTD_H])
+m4trace:configure.ac:25: -1- AC_CHECK_HEADER_STDBOOL
 m4trace:configure.ac:25: -1- AC_DEFINE_TRACE_LITERAL([HAVE__BOOL])
 m4trace:configure.ac:25: -1- m4_pattern_allow([^HAVE__BOOL$])
 m4trace:configure.ac:25: -1- AH_OUTPUT([HAVE__BOOL], [/* Define to 1 if the system has the type `_Bool\'. */
 @%:@undef HAVE__BOOL])
+m4trace:configure.ac:26: -1- AC_C_INLINE
 m4trace:configure.ac:26: -1- AH_OUTPUT([inline], [/* Define to `__inline__\' or `__inline\' if that\'s what the C compiler
    calls it, or to nothing if \'inline\' is not supported under any name.  */
 #ifndef __cplusplus
 #undef inline
 #endif])
+m4trace:configure.ac:27: -1- AC_TYPE_INT16_T
 m4trace:configure.ac:27: -1- AC_DEFINE_TRACE_LITERAL([int16_t])
 m4trace:configure.ac:27: -1- m4_pattern_allow([^int16_t$])
 m4trace:configure.ac:27: -1- AH_OUTPUT([int16_t], [/* Define to the type of a signed integer type of width exactly 16 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef int16_t])
+m4trace:configure.ac:28: -1- AC_TYPE_INT32_T
 m4trace:configure.ac:28: -1- AC_DEFINE_TRACE_LITERAL([int32_t])
 m4trace:configure.ac:28: -1- m4_pattern_allow([^int32_t$])
 m4trace:configure.ac:28: -1- AH_OUTPUT([int32_t], [/* Define to the type of a signed integer type of width exactly 32 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef int32_t])
+m4trace:configure.ac:29: -1- AC_TYPE_INT64_T
 m4trace:configure.ac:29: -1- AC_DEFINE_TRACE_LITERAL([int64_t])
 m4trace:configure.ac:29: -1- m4_pattern_allow([^int64_t$])
 m4trace:configure.ac:29: -1- AH_OUTPUT([int64_t], [/* Define to the type of a signed integer type of width exactly 64 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef int64_t])
+m4trace:configure.ac:30: -1- AC_TYPE_INT8_T
 m4trace:configure.ac:30: -1- AC_DEFINE_TRACE_LITERAL([int8_t])
 m4trace:configure.ac:30: -1- m4_pattern_allow([^int8_t$])
 m4trace:configure.ac:30: -1- AH_OUTPUT([int8_t], [/* Define to the type of a signed integer type of width exactly 8 bits if such
    a type exists and the standard includes do not define it. */
 @%:@undef int8_t])
+m4trace:configure.ac:31: -1- AC_TYPE_SIZE_T
 m4trace:configure.ac:31: -1- AC_DEFINE_TRACE_LITERAL([size_t])
 m4trace:configure.ac:31: -1- m4_pattern_allow([^size_t$])
 m4trace:configure.ac:31: -1- AH_OUTPUT([size_t], [/* Define to `unsigned int\' if <sys/types.h> does not define. */
 @%:@undef size_t])
+m4trace:configure.ac:32: -1- AC_TYPE_UINT16_T
 m4trace:configure.ac:32: -1- AC_DEFINE_TRACE_LITERAL([uint16_t])
 m4trace:configure.ac:32: -1- m4_pattern_allow([^uint16_t$])
 m4trace:configure.ac:32: -1- AH_OUTPUT([uint16_t], [/* Define to the type of an unsigned integer type of width exactly 16 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef uint16_t])
+m4trace:configure.ac:33: -1- AC_TYPE_UINT32_T
 m4trace:configure.ac:33: -1- AC_DEFINE_TRACE_LITERAL([_UINT32_T])
 m4trace:configure.ac:33: -1- m4_pattern_allow([^_UINT32_T$])
 m4trace:configure.ac:33: -1- AH_OUTPUT([_UINT32_T], [/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
@@ -449,6 +486,7 @@ m4trace:configure.ac:33: -1- m4_pattern_allow([^uint32_t$])
 m4trace:configure.ac:33: -1- AH_OUTPUT([uint32_t], [/* Define to the type of an unsigned integer type of width exactly 32 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef uint32_t])
+m4trace:configure.ac:34: -1- AC_TYPE_UINT64_T
 m4trace:configure.ac:34: -1- AC_DEFINE_TRACE_LITERAL([_UINT64_T])
 m4trace:configure.ac:34: -1- m4_pattern_allow([^_UINT64_T$])
 m4trace:configure.ac:34: -1- AH_OUTPUT([_UINT64_T], [/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
@@ -460,6 +498,7 @@ m4trace:configure.ac:34: -1- m4_pattern_allow([^uint64_t$])
 m4trace:configure.ac:34: -1- AH_OUTPUT([uint64_t], [/* Define to the type of an unsigned integer type of width exactly 64 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef uint64_t])
+m4trace:configure.ac:35: -1- AC_TYPE_UINT8_T
 m4trace:configure.ac:35: -1- AC_DEFINE_TRACE_LITERAL([_UINT8_T])
 m4trace:configure.ac:35: -1- m4_pattern_allow([^_UINT8_T$])
 m4trace:configure.ac:35: -1- AH_OUTPUT([_UINT8_T], [/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
@@ -471,6 +510,8 @@ m4trace:configure.ac:35: -1- m4_pattern_allow([^uint8_t$])
 m4trace:configure.ac:35: -1- AH_OUTPUT([uint8_t], [/* Define to the type of an unsigned integer type of width exactly 8 bits if
    such a type exists and the standard includes do not define it. */
 @%:@undef uint8_t])
+m4trace:configure.ac:38: -1- AC_FUNC_MALLOC
+m4trace:configure.ac:38: -1- AC_CHECK_HEADERS([stdlib.h])
 m4trace:configure.ac:38: -1- AH_OUTPUT([HAVE_STDLIB_H], [/* Define to 1 if you have the <stdlib.h> header file. */
 @%:@undef HAVE_STDLIB_H])
 m4trace:configure.ac:38: -1- AC_DEFINE_TRACE_LITERAL([HAVE_STDLIB_H])
@@ -490,6 +531,8 @@ m4trace:configure.ac:38: -1- AC_DEFINE_TRACE_LITERAL([malloc])
 m4trace:configure.ac:38: -1- m4_pattern_allow([^malloc$])
 m4trace:configure.ac:38: -1- AH_OUTPUT([malloc], [/* Define to rpl_malloc if the replacement function should be used. */
 @%:@undef malloc])
+m4trace:configure.ac:39: -1- AC_FUNC_REALLOC
+m4trace:configure.ac:39: -1- AC_CHECK_HEADERS([stdlib.h])
 m4trace:configure.ac:39: -1- AH_OUTPUT([HAVE_STDLIB_H], [/* Define to 1 if you have the <stdlib.h> header file. */
 @%:@undef HAVE_STDLIB_H])
 m4trace:configure.ac:39: -1- AC_DEFINE_TRACE_LITERAL([HAVE_STDLIB_H])
@@ -509,6 +552,7 @@ m4trace:configure.ac:39: -1- AC_DEFINE_TRACE_LITERAL([realloc])
 m4trace:configure.ac:39: -1- m4_pattern_allow([^realloc$])
 m4trace:configure.ac:39: -1- AH_OUTPUT([realloc], [/* Define to rpl_realloc if the replacement function should be used. */
 @%:@undef realloc])
+m4trace:configure.ac:40: -1- AC_CHECK_FUNCS([inet_ntoa memset socket])
 m4trace:configure.ac:40: -1- AH_OUTPUT([HAVE_INET_NTOA], [/* Define to 1 if you have the `inet_ntoa\' function. */
 @%:@undef HAVE_INET_NTOA])
 m4trace:configure.ac:40: -1- AH_OUTPUT([HAVE_MEMSET], [/* Define to 1 if you have the `memset\' function. */
@@ -523,6 +567,7 @@ m4trace:configure.ac:43: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
 m4trace:configure.ac:43: -1- AC_SUBST_TRACE([LTLIBOBJS])
 m4trace:configure.ac:43: -1- m4_pattern_allow([^LTLIBOBJS$])
 m4trace:configure.ac:43: -1- AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])
+m4trace:configure.ac:43: -1- AC_PREREQ([2.52])
 m4trace:configure.ac:43: -1- AC_SUBST([am__EXEEXT_TRUE])
 m4trace:configure.ac:43: -1- AC_SUBST_TRACE([am__EXEEXT_TRUE])
 m4trace:configure.ac:43: -1- m4_pattern_allow([^am__EXEEXT_TRUE$])

+ 59 - 0
autoscan.log

@@ -0,0 +1,59 @@
+autoscan: warning: missing AC_CHECK_FUNCS([alarm]) wanted by: 
+	module_service/module_call_help.h:115
+autoscan: warning: missing AC_CHECK_FUNCS([atexit]) wanted by: 
+	main.cpp:153
+autoscan: warning: missing AC_CHECK_FUNCS([clock_gettime]) wanted by: 
+	clock.h:50
+	clock.h:55
+	clock.h:61
+	clock.h:77
+autoscan: warning: missing AC_CHECK_FUNCS([floor]) wanted by: 
+	monkey_car/monkey_fit.h:93
+autoscan: warning: missing AC_CHECK_FUNCS([ftime]) wanted by: 
+	timestamp.h:16
+autoscan: warning: missing AC_CHECK_FUNCS([gettimeofday]) wanted by: 
+	net-service.cpp:55
+	timestamp.h:12
+autoscan: warning: missing AC_CHECK_FUNCS([localtime_r]) wanted by: 
+	common_tool.h:64
+	common_tool.h:137
+	loc_point.cpp:39
+	message_file.cpp:94
+autoscan: warning: missing AC_CHECK_FUNCS([memmove]) wanted by: 
+	znet.cpp:333
+autoscan: warning: missing AC_CHECK_FUNCS([pow]) wanted by: 
+	message.cpp:54
+	src/internal/sio_client_impl.cpp:338
+autoscan: warning: missing AC_CHECK_FUNCS([realpath]) wanted by: 
+	test.cpp:289
+autoscan: warning: missing AC_CHECK_FUNCS([sqrt]) wanted by: 
+	ant.h:255
+	line.h:65
+	line.h:75
+	line.h:144
+	point.h:95
+	point.h:102
+	point.h:109
+	point.h:129
+	monkey_car/base_data.h:52
+autoscan: warning: missing AC_CHECK_FUNCS([strchr]) wanted by: 
+	znet.cpp:157
+autoscan: warning: missing AC_CHECK_FUNCS([strstr]) wanted by: 
+	web-client.cpp:76
+autoscan: warning: missing AC_CHECK_HEADERS([float.h]) wanted by: 
+	monkey_car/linear_fit.h:8
+autoscan: warning: missing AC_CHECK_HEADERS([limits.h]) wanted by: 
+	test.cpp:2
+autoscan: warning: missing AC_CHECK_HEADERS([sys/time.h]) wanted by: 
+	common_tool.h:14
+	net-service.cpp:13
+	timestamp.h:5
+autoscan: warning: missing AC_CHECK_HEADERS([sys/timeb.h]) wanted by: 
+	timestamp.h:3
+autoscan: warning: missing AC_FUNC_MKTIME wanted by: 
+	common_tool.h:74
+	common_tool.h:83
+	common_tool.h:96
+	message_file.cpp:134
+	websocket/wsTimerThread.cpp:82
+	websocket/wsTimerThread.cpp:82

+ 50 - 33
card.cpp

@@ -7,7 +7,7 @@
 #include <site_area.h>
 #include <card.h>
 #include "config_file.h"
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include "websocket/wsTimerThread.h"
 #include "websocket/wsClientMgr.h"
 #include "timestamp.h"
@@ -21,7 +21,6 @@
 #include "visit.h"
 #include "his_location.h"
 #include "three_rates.h"
-
 extern config_file config;
 //一张卡一个ct的所有不同天线的信息
 struct one_ct_message_handle
@@ -121,6 +120,7 @@ struct one_ct_message_handle
 
     void calc_location()
 	{
+		log_info("calc_location:%d begin",m_card->m_id);
         auto v = m_msg_list;
 
 		std::vector<point> rc=std::move(m_loc_tool.calc_location(v));
@@ -128,6 +128,7 @@ struct one_ct_message_handle
 		if(!rc.empty()) m_card->on_location(std::move(rc),v);
 
 		reset();
+		log_info("calc_location:%d end",m_card->m_id);
 	}
 };
 struct card_message_handle
@@ -217,7 +218,6 @@ struct person:card_location_base, card_area
 
     void clear()
     {
-		log_info("__thread_id reset:%d,%x  [%x]",m_id,std::this_thread::get_id(),m_site_area.get());
         //m_site_area.reset(new site_area_hover);
         m_area_tool.reset(new area_tool);
         m_mine_tool.reset(new mine_tool);
@@ -367,7 +367,7 @@ struct car:card_location_base,card_area
 		m_area_tool->on_point(m_id,pt,m_speed,m_type);
         m_site_area->on_point(m_id,0,this, m_type);
         m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);
-		handle_three_rates(pt);
+	    handle_three_rates(pt);
 	}
 
     int get_vehicle_type_id()
@@ -456,7 +456,7 @@ uint64_t card_list::getId(uint32_t cardid,uint64_t type)
 	return type<<32|cardid;
 }
 
-void card_list::init_staffer(int32_t id)
+void card_list::init_staffer(int64_t id64)
 {
     std::string strategy = config.get("person.strategy","person1");
     std::string sql = "SELECT staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
@@ -465,11 +465,10 @@ void card_list::init_staffer(int32_t id)
             LEFT JOIN dat_card c ON s.card_id = c.card_id \
             LEFT JOIN dat_occupation o ON s.occupation_id = o.occupation_id \
             LEFT JOIN dat_occupation_level ol ON ol.occupation_level_id = o.occupation_level_id \
-            WHERE c.card_type_id = 1 AND s.duty_id = 0 AND c.state_id = 0";
+            WHERE s.duty_id = 0 AND c.state_id = 0";
 
-    int type = CT_PERSON;
-    std::string card_id_str = card_list::to_id64_str(type, static_cast<uint32_t>(id));
-    if(-1 == id)
+    std::string card_id_str = tool_other::to13str(id64);
+    if(-1 == id64)
     {
         sql.append(";");
     }
@@ -527,18 +526,18 @@ void card_list::init_staffer(int32_t id)
         //for now;
         //staff_id = vsid;
 
-        if(-1 == id)
+        if(-1 == id64)
         {
             std::shared_ptr<card_location_base> clb =
                     std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
-            uint64_t cardid = getId(vsid,type);
+            uint64_t cardid = getId(vsid,card_type_id);
             log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d",
                      cardid,vsid,dept_id,need_display,card_id.c_str(),work_line,staff_id,card_type_id);
             map.insert({cardid,clb});
         }
         else
         {
-            auto card_id64 = card_list::to_id64(type, static_cast<uint32_t>(id));
+            auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
             auto card_ptr = card_list::instance()->get(card_id64);
             if(card_ptr)
             {
@@ -556,21 +555,21 @@ void card_list::init_staffer(int32_t id)
                 card_list::instance()->add(card_id64, clb);
             }
 
-            log_info("基础数据 增加或修改人卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,occupation_level_id:%d",
-                     id,type,dept_id,need_display,occupation_level_id);
-            std_debug("基础数据 增加或修改人卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,occupation_level_id:%d",
-                     id,type,dept_id,need_display,occupation_level_id);
+            log_info("基础数据 增加或修改人卡成功:卡id:%ld, dept_id:%d,need_display:%d,occupation_level_id:%d",
+                     id64,dept_id,need_display,occupation_level_id);
+            std_debug("基础数据 增加或修改人卡成功:卡id:%ld, dept_id:%d,need_display:%d,occupation_level_id:%d",
+                     id64,dept_id,need_display,occupation_level_id);
         }
     }
 
-    if(-1 == id)
+    if(-1 == id64)
     {
         log_info( "init_staffer. The record count=%d\n", nCount );
         card_list::instance()->add(map);
     }
 }
 
-void card_list::init_vehicle(int32_t id)
+void card_list::init_vehicle(int64_t id64)
 {
     std::string strategy = config.get("car.strategy","car1");
     std::string sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
@@ -584,11 +583,10 @@ void card_list::init_vehicle(int32_t id)
                         LEFT JOIN dat_group g ON ve.group_id = g.group_id \
                         LEFT JOIN dat_vehicle_type vt ON v.vehicle_type_id = vt.vehicle_type_id \
                         LEFT JOIN dat_vehicle_category vc ON vc.vehicle_category_id = vt.vehicle_category_id \
-                        WHERE c.card_type_id = 2 AND c.state_id = 0";
+                        WHERE c.state_id = 0";
 
-    int type = CT_VEHICLE;
-    std::string card_id_str = card_list::to_id64_str(type, static_cast<uint32_t>(id));
-    if(-1 == id)
+    std::string card_id_str = tool_other::to13str(id64);
+    if(-1 == id64)
     {
         sql.append(";");
     }
@@ -656,18 +654,18 @@ void card_list::init_vehicle(int32_t id)
         //for now
         //vehicle_id = vsid;
 
-        if(-1 == id)
+        if(-1 == id64)
         {
             auto clb = std::make_shared<car>(strategy,vsid,need_display,card_type_id,
                                              dept_id,vehicle_category_id, vehicle_type_id,vehicle_level_id,vehicle_id);
-            uint64_t cardid = getId(vsid,type);
+            uint64_t cardid = getId(vsid,card_type_id);
             log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d-cardid:%s,categoryid:%d,vchile_id:%d,type:%d",
                      cardid,vsid,dept_id,need_display,card_id.c_str(),vehicle_category_id,vehicle_id,card_type_id);
             map.insert({cardid,clb});
         }
         else
         {
-            auto card_id64 = card_list::to_id64(type, static_cast<uint32_t>(id));
+            auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
             auto card_ptr = card_list::instance()->get(card_id64);
             if(card_ptr)
             {
@@ -685,14 +683,14 @@ void card_list::init_vehicle(int32_t id)
                 card_list::instance()->add(card_id64, clb);
             }
 
-            log_info("基础数据 增加或修改车卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,categoryid:%d",
-                     vsid,type,dept_id,need_display,vehicle_category_id);
-            std_debug("基础数据 增加或修改车卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,categoryid:%d",
-                     vsid,type,dept_id,need_display,vehicle_category_id);
+            log_info("基础数据 增加或修改车卡成功:卡id:%ld, dept_id:%d,need_display:%d,categoryid:%d",
+                     id64,dept_id,need_display,vehicle_category_id);
+            std_debug("基础数据 增加或修改车卡成功:卡id:%ld, dept_id:%d,need_display:%d,categoryid:%d",
+                     id64,dept_id,need_display,vehicle_category_id);
         }
     }
 
-    if(-1 == id)
+    if(-1 == id64)
     {
         log_info( "init_vehicle. The record count=%d\n", nCount );
         card_list::instance()->add(map);
@@ -1137,6 +1135,14 @@ struct local_visit:visitor<std::shared_ptr<card_location_base>>
 		return true;	
 	}
 };
+
+// TODO : 停止进程
+void card_list::onStopRun()
+{
+    card_list::instance()->m_bflag = true; 
+    card_list::instance()->m_pThread->join();
+}
+
 void card_list::onTimer()
 {
 	local_visit lv;
@@ -1171,9 +1177,9 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
 		x = pt.x;
 		y = pt.y;
 
-		Msg m;
-		m.type=m_type;m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
-		cardMgr::instance()->tryPut(m);
+		//Msg m;
+		//m.type=m_type;m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
+		//cardMgr::instance()->tryPut(m);
 		double acc = lm[0].m_acc;
 		log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%.2f,y:%.2f acc:%.2f",m_id,m_ct,m_time,pt.x,pt.y,acc);
 		do_business(pt,acc);
@@ -1256,6 +1262,17 @@ void card_location_base::put_three_rates(card_pos & cp)
 	log_info("three_rates:type:%d,id:%d,cid:%d",cp.type,cp.id,cp.identifier_id);
 	three_rates::get_instance()->put(cp);
 }
+
+bool card_location_base::is_person() const
+{
+    return tool_other::is_person(m_type);
+}
+
+bool card_location_base::is_vehicle() const
+{
+    return tool_other::is_vehicle(m_type);
+}
+
 card_location_base::~card_location_base()
 {
 }

+ 11 - 12
card.h

@@ -82,24 +82,19 @@ struct card_location_base:card
 	void del_card_pos();
 	int get_stat();
 	void put_three_rates(card_pos &);
-    bool is_person() const
-    {
-        return CT_PERSON == m_type;
-    }
 
-    bool is_vehicle() const
-    {
-        return CT_VEHICLE == m_type;
-    }
+    bool is_person() const;
+    bool is_vehicle() const;
+
 	virtual ~card_location_base();
 };
 
 struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
 {
-    ///id=-1为初始化所有卡
-    void init_staffer(int32_t id);
-    ///id=-1为初始化所有卡
-    void init_vehicle(int32_t id);
+    ///id64=-1为初始化所有卡, id格式为:10000001016
+    void init_staffer(int64_t id64);
+    ///id64=-1为初始化所有卡, id格式为:10000001016
+    void init_vehicle(int64_t id64);
     //void init_staffer();
     //void init_vehicle();
     uint64_t getId(uint32_t cardid,uint64_t);
@@ -116,6 +111,9 @@ struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_ba
 	{
 		m_pThread.reset(new std::thread(std::bind(&card_list::onTimer,this)));
 	}
+	// TODO : 停止进程
+	void onStopRun(); 
+	
 	void onTimer();
     /// (类型<<32)|卡号
 	//公用函数最好不要使用成员函数,改成公共函数。
@@ -131,6 +129,7 @@ struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_ba
 
         return std::string(sql);
     }
+
     ~card_list(){m_bflag=true;}
 };
 

+ 2 - 1
cardMgr.cpp

@@ -1,6 +1,7 @@
 #include "cardMgr.h" 
 #include "bindmorecard.h"
 #include "common.h"
+#include"common_tool.h"
 
 cardMgr::cardMgr()
 :m_queue(2048)
@@ -46,7 +47,7 @@ void cardMgr::clear(uint64_t cardid)
 void cardMgr::handleMessage(const Msg &m)
 {
 	m_glist.update(m.x,m.y,m.cardid);
-	if(m.type==CT_VEHICLE) return;
+    if(tool_other::is_vehicle( m.type) ) return;
 	std::vector<uint64_t> rc=m_glist.find_near(m.cardid,1);
 	
 	log_info("LemonHash+..%d,size:%d,(%d,%d)",m.cardid,rc.size(),m.x,m.y);

+ 4 - 0
common.h

@@ -55,6 +55,10 @@ enum CARD_TYPE
 	CT_PERSON=1,
 	///卡类型 车卡
 	CT_VEHICLE=2,
+    ///    4 采煤机
+    CT_COAL_CUTTER=4,
+    ///    5  掘进机
+    CT_HEADING_MACHINE=5
 };
 
 enum AREA_TYPE

+ 11 - 1
common_tool.h

@@ -12,7 +12,7 @@
 #include <chrono>
 #include <string>
 #include <sys/time.h>
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include "websocket/wsClientMgr.h"
 #include "card.h"
 #include "mine.h"
@@ -174,6 +174,16 @@ public:
         return std::stoi(to13str(str).substr(0, 3));
     }
 
+    static bool is_person(int32_t type)
+    {
+        return CT_PERSON == type;
+    }
+
+    static bool is_vehicle(int32_t type)
+    {
+        return CT_VEHICLE == type || CT_COAL_CUTTER == type || CT_HEADING_MACHINE == type;
+    }
+
 //    static uint32_t id64_to_id(uint64_t card_id)
 //    {
 //        return static_cast<uint32_t>(card_id);

+ 56 - 5
configure

@@ -652,6 +652,10 @@ CPPFLAGS
 LDFLAGS
 CXXFLAGS
 CXX
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
 am__untar
 am__tar
 AMTAR
@@ -716,6 +720,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+enable_silent_rules
 enable_dependency_tracking
 '
       ac_precious_vars='build_alias
@@ -1344,6 +1349,8 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
   --enable-dependency-tracking
                           do not reject slow dependency extractors
   --disable-dependency-tracking
@@ -2368,7 +2375,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-am__api_version='1.12'
+am__api_version='1.13'
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@@ -2581,8 +2588,8 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
@@ -2822,6 +2829,45 @@ else
 fi
 rmdir .tst 2>/dev/null
 
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
 if test "`cd $srcdir && pwd`" != "`pwd`"; then
   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
   # is not polluted with repeated "-I."
@@ -2884,6 +2930,10 @@ mkdir_p='$(MKDIR_P)'
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
 
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar  pax cpio none'
+
 am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
@@ -2892,6 +2942,7 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
+
 # Checks for programs.
 ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
@@ -6321,7 +6372,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
   case $CONFIG_FILES in
@@ -6372,7 +6423,7 @@ $as_echo X"$mf" |
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the

+ 51 - 0
configure.scan

@@ -0,0 +1,51 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
+AC_CONFIG_SRCDIR([ant.cpp])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_CPP
+
+# Checks for libraries.
+# FIXME: Replace `main' with a function in `-lboost_chrono':
+AC_CHECK_LIB([boost_chrono], [main])
+# FIXME: Replace `main' with a function in `-lboost_system':
+AC_CHECK_LIB([boost_system], [main])
+# FIXME: Replace `main' with a function in `-lboost_thread':
+AC_CHECK_LIB([boost_thread], [main])
+# FIXME: Replace `main' with a function in `-lmysqlclient':
+AC_CHECK_LIB([mysqlclient], [main])
+# FIXME: Replace `main' with a function in `-lrt':
+AC_CHECK_LIB([rt], [main])
+# FIXME: Replace `main' with a function in `-lzlog':
+AC_CHECK_LIB([zlog], [main])
+
+# Checks for header files.
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h limits.h memory.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_CHECK_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_SIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_MKTIME
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([alarm atexit clock_gettime floor ftime gettimeofday inet_ntoa localtime_r memmove memset pow realpath socket sqrt strchr strstr])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT

+ 108 - 108
db_api/CDBCommon.h

@@ -1,108 +1,108 @@
-/**
-* @brief
-数据库公共头文件
-
-* @version
-V 1.0.0
-
-* @author
-王益俊
-
-* @date
-创建时间:  2018-04-19\n
-
-* @note
-2018-04-19  初次创建。\n
-
-* @warning
-
-* @bug
-
-*/
-
-#ifndef DB_COMMON_H
-#define DB_COMMON_H
-
-#include <mysql.h>
-
-namespace YADB
-{
-    //----------------------------------------------------------------------------
-	//                                 数据库错误定义
-	//----------------------------------------------------------------------------
-	const int DB_ERR_NO_ERROR               = 0;//无错误
-	const int DB_ERR_NOT_CONNECT_DB         = -1;//未连接数据库
-	const int DB_ERR_EXCUTE_QUERY           = -1;//执行查询失败
-	const int DB_ERR_QUERY_RES_NOT_INITED   = -1;//查询结果集还未初始化
-
-	//----------------------------------------------------------------------------
-	//                                 其它定义
-	//----------------------------------------------------------------------------
-	const int MAX_ASYNC_EXEC_FAILED_COUNT   = 3;//最大异步执行失败次数
-	const int MAX_ASYNC_QUEQUE_CAPACITY     = 32 * 1024;//异步执行队列最大容量
-
-	/**
-	* @brief
-	数据库连接数枚举
-	*/
-	enum _DB_CONNECT_COUNT_
-	{
-		DCC_MIN_COUNT = 1,//最小连接数
-		DCC_MAX_COUNT = 60,//最大连接数
-	};
-
-	/**
-	* @brief
-	数据库连接设置结构体
-	*/
-    struct _DB_CONN_SETTING_
-	{
-		std::string Host;//数据库主机地址
-		std::string User;//用户名
-		std::string PWD;//密码
-		std::string DBName;//数据库名
-		std::string CharSet;//字符集
-		std::string stmtSQL;//预处理SQL
-		int TimeOut;//连接数据库超时(单位:秒)
-		_DB_CONN_SETTING_()
-		{
-			TimeOut = 0;
-		}
-	};
-
-	/**
-	* @brief
-	数据库连接池设置结构体
-	*/
-	struct _DB_POOL_SETTING_ : public _DB_CONN_SETTING_
-	{
-		int PoolSize;//连接池大小
-		_DB_POOL_SETTING_()
-		{
-			PoolSize = 0;
-		}
-	};
-
-    /**
-    * @brief
-    异步执行结构体
-    */
-	struct _ASYNC_SQL_
-	{
-		int FailedCount;//执行失败次数
-		std::string SQL; //SQ语句
-		_ASYNC_SQL_()
-		{
-			FailedCount = 0;
-		}
-		~_ASYNC_SQL_()
-		{
-
-		}
-	};
-}
-
-#endif
-
-
-
+/**
+* @brief
+数据库公共头文件
+
+* @version
+V 1.0.0
+
+* @author
+王益俊
+
+* @date
+创建时间:  2018-04-19\n
+
+* @note
+2018-04-19  初次创建。\n
+
+* @warning
+
+* @bug
+
+*/
+
+#ifndef DB_COMMON_H
+#define DB_COMMON_H
+
+#include <mysql.h>
+
+namespace YADB
+{
+    //----------------------------------------------------------------------------
+	//                                 数据库错误定义
+	//----------------------------------------------------------------------------
+	const int DB_ERR_NO_ERROR               = 0;//无错误
+	const int DB_ERR_NOT_CONNECT_DB         = -1;//未连接数据库
+	const int DB_ERR_EXCUTE_QUERY           = -1;//执行查询失败
+	const int DB_ERR_QUERY_RES_NOT_INITED   = -1;//查询结果集还未初始化
+
+	//----------------------------------------------------------------------------
+	//                                 其它定义
+	//----------------------------------------------------------------------------
+	const int MAX_ASYNC_EXEC_FAILED_COUNT   = 3;//最大异步执行失败次数
+	const int MAX_ASYNC_QUEQUE_CAPACITY     = 32 * 1024;//异步执行队列最大容量
+
+	/**
+	* @brief
+	数据库连接数枚举
+	*/
+	enum _DB_CONNECT_COUNT_
+	{
+		DCC_MIN_COUNT = 1,//最小连接数
+		DCC_MAX_COUNT = 60,//最大连接数
+	};
+
+	/**
+	* @brief
+	数据库连接设置结构体
+	*/
+    struct _DB_CONN_SETTING_
+	{
+		std::string Host;//数据库主机地址
+		std::string User;//用户名
+		std::string PWD;//密码
+		std::string DBName;//数据库名
+		std::string CharSet;//字符集
+		std::string stmtSQL;//预处理SQL
+		int TimeOut;//连接数据库超时(单位:秒)
+		_DB_CONN_SETTING_()
+		{
+			TimeOut = 0;
+		}
+	};
+
+	/**
+	* @brief
+	数据库连接池设置结构体
+	*/
+	struct _DB_POOL_SETTING_ : public _DB_CONN_SETTING_
+	{
+		int PoolSize;//连接池大小
+		_DB_POOL_SETTING_()
+		{
+			PoolSize = 0;
+		}
+	};
+
+    /**
+    * @brief
+    异步执行结构体
+    */
+	struct _ASYNC_SQL_
+	{
+		int FailedCount;//执行失败次数
+		std::string SQL; //SQ语句
+		_ASYNC_SQL_()
+		{
+			FailedCount = 0;
+		}
+		~_ASYNC_SQL_()
+		{
+
+		}
+	};
+}
+
+#endif
+
+
+

+ 36 - 15
db_api/CDBConnPool.cpp

@@ -43,39 +43,44 @@ namespace YADB
 		return pConn;
 	}
 
-	bool CDBConnPool::Create( const _DB_POOL_SETTING_& Setting, std::string& Error )
+	bool CDBConnPool::Create( const _DB_POOL_SETTING_& Setting, std::string& szError )
+	{
+		return Create(Setting,true,szError);
+	}
+
+	bool CDBConnPool::Create( const _DB_POOL_SETTING_& Setting,bool bAsync, std::string& szError )
 	{
 		std::unique_lock<std::mutex> lock( __mtx );
 
 		if ( Setting.PoolSize < DCC_MIN_COUNT )
 		{
-			Error = "PoolSize is too small!";
+			szError = "PoolSize is too small!";
 			return false;
 		}
 
 		if ( Setting.PoolSize > DCC_MAX_COUNT )
 		{
-			Error = "PoolSize is too big!";
+			szError = "PoolSize is too big!";
 			return false;
 		}
 
 		__Setting = Setting;
-		std::string ConnErr;
 		for ( int i = 0; i < __Setting.PoolSize; i++ )
 		{
-			CDBConnect* pConn = __CreateIdleConn( Error );
+			CDBConnect* pConn = __CreateIdleConn( szError );
 			if ( !pConn )
 			{
 				return false;
 			}
 		}
+		if (bAsync)
+		{
+			//创建异步执行线程
+			__CreateAsyncThrdConn();
 
-		//创建异步执行线程
-		__CreateAsyncThrdConn();
-
-		//启动异步执行线程
-		__StartAsyncThrd();
-
+			//启动异步执行线程
+			__StartAsyncThrd();
+		}
 		return true;
 	}
 
@@ -126,6 +131,7 @@ namespace YADB
 		else
 		{
 			//如果已经没有空闲连接,只要当前连接池数量没有超过最大连接数就创建一个临时连接
+			// 这个判断没有意义(进入这个 __IdleConnList.size() <= 0 )
 			if ( __IdleConnList.size() < DCC_MAX_COUNT )
 			{
 				pConn = __CreateIdleConn( Error, true );
@@ -195,6 +201,7 @@ namespace YADB
     	while( pOwner->__Running )
 	    {
     		_ASYNC_SQL_* pData = 0;
+		
     		while ( __AsyncQueue.pop( pData ) )
 			{
 				if ( pData )
@@ -202,11 +209,11 @@ namespace YADB
 					if ( __pAsyncDBConn )
 					{
 						my_ulonglong llRes = 0;
-						llRes = __pAsyncDBConn->ExecuteRealSql( pData->SQL.c_str(), Error );
+						llRes = __pAsyncDBConn->ExecuteRealSql( pData->SQL.c_str(), Error ); 
 						if ( (my_ulonglong)-1 == llRes )
 						{
 							//Execute failed, write log...
-							printf( "Error,调用ExcuteRealSql失败,Err=%s,[%s]\n", Error.c_str(), pData->SQL.c_str());
+							printf( "Error,调用ExcuteRealSql失败,Err=%s \n sql=%s \n", Error.c_str(),  pData->SQL.c_str());
 							//如果失败了看是不是数据库断开连接了,尝试重新连接一次
 							if ( __pAsyncDBConn->ConnctionTest( Error ) != 0 )
 							{
@@ -327,9 +334,21 @@ namespace YADB
 		}
 
 		MYSQL_RES* pRes = pConn->Query( szSql, Error );
+	GiveBack( pConn );
         return DBRes.Bind( pRes, Error );
     }
+    
+    MYSQL_RES* CDBConnPool::Query( const char *szSql, std::string& Error)
+    {
+        CDBConnect *pConn = GetDBConnect(Error);
+        if( 0 == pConn){
+            return nullptr;
+        }
 
+        MYSQL_RES* pRes = pConn->Query(szSql,Error);
+        GiveBack(pConn);
+        return pRes;
+    }
     my_ulonglong CDBConnPool::ExecuteSql( const char *szSql, std::string& Error )
     {
     	CDBConnect *pConn = GetDBConnect( Error );
@@ -337,7 +356,9 @@ namespace YADB
 		{
 			return -1;
 		}
-
-		return pConn->ExecuteSql( szSql, Error );
+	my_ulonglong nRet = pConn->ExecuteSql( szSql, Error );
+		GiveBack( pConn );
+		return nRet;
+		//return pConn->ExecuteSql( szSql, Error );
     }
 }

+ 289 - 285
db_api/CDBConnPool.h

@@ -1,285 +1,289 @@
-/**
-* @brief
-数据库连接池类
-
-* @version
-V 1.0.0
-
-* @author
-王益俊
-
-* @date
-创建时间:  2018-04-17\n
-
-* @note
-2018-04-17  创建类。\n
-
-* @warning
-
-* @bug
-
-*/
-
-#pragma once
-
-#include <boost/atomic.hpp>
-#include <boost/thread/thread.hpp>
-#include <boost/lockfree/queue.hpp>
-#include <boost/serialization/singleton.hpp>
-
-#include <list>
-#include <string>
-#include <mutex>
-
-#include "CDBCommon.h"
-#include "CDBConnect.h"
-
-namespace YADB
-{
-	class CDBConnPool
-	{
-	private:
-		std::list<CDBConnect*> __BusyConnList;//正在使用的数据库连接列表
-		std::list<CDBConnect*> __IdleConnList;//没有使用的数据库连接列表
-		_DB_POOL_SETTING_ __Setting;//数据库连接池设置
-		std::mutex __mtx;//互斥量
-		boost::atomic<bool> __Running{ true };//线程是否运行的标识
-		boost::atomic<bool> __IsExited{ false };//线程是否已退出的标识
-		CDBConnect* __pAsyncDBConn;//异步执行线程用的数据库连接
-	private:
-		/**
-	    * @brief
-	    创建一个空闲连接函数。
-
-        * @param  [out] std::string& Error  错误信息\n
-	    * @param  [in] bool IsTemp  创建的连接是否是临时的\n
-
-	    * @return 返回创建的连接
-	    * @return  >0   成功\n
-	    * @return  ==0  失败\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		CDBConnect* __CreateIdleConn( std::string& Error, bool IsTemp = false );
-		/**
-	    * @brief
-	    创建异步执行线程所用连接函数。
-
-	    * @param  无\n
-
-	    * @return 无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void __CreateAsyncThrdConn();
-		/**
-	    * @brief
-	    刪除创建异步执行线程所用连接函数。
-
-	    * @param  无\n
-
-	    * @return 无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void __DestroyAsyncThrdConn();
-		/**
-		* @brief
-		启动异步执行线程函数。
-
-		* @param  无\n
-
-		* @return 无
-
-		* @note
-
-		* @warning
-
-		* @bug
-
-		*/
-		void __StartAsyncThrd();
-	    /**
-	    * @brief
-	    停止异步执行线程函数。
-
-	    * @param  无\n
-
-	    * @return 无
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void __StopAsyncThrd();
-	protected:
-	    /**
-	    * @brief
-	    异步执行线程函数。
-
-	    * @param  [in] CDBConnPool* pOwner  线程所属对象\n
-
-	    * @return 无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void _AsyncThreadFunc( CDBConnPool* pOwner );//线程函数
-	public:
-		CDBConnPool();
-		~CDBConnPool();
-		/**
-	    * @brief
-	    创建数据库连接池函数。
-
-	    * @param  [in] const _DB_POOL_SETTING_& Setting  数据库连接池设置\n
-	    * @param  [out] std::string& Error  错误信息\n
-
-	    * @return 返回创建数据库连接池是否成功
-	    * @return  true   成功
-	    * @return  false  失败
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		bool Create( const _DB_POOL_SETTING_& Setting, std::string& Error );
-		/**
-	    * @brief
-	    关闭线程池函数。
-
-	    * @param  无\n
-
-	    * @return  无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void Close();
-		/**
-	    * @brief
-	    从连接池中获得一个数据库连接函数。
-
-	    * @param  [out] std::string& Error  错误信息\n
-
-	    * @return 返回获得一个数据库连接是否成功
-	    * @return  0 失败\n
-	    * @return  !=0 获得的数据库连接\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		CDBConnect* GetDBConnect( std::string& Error );
-		/**
-	    * @brief
-	    归还一个数据库连接到连接池中函数。
-
-	    * @param  [in] CDBConnect* pConn  数据库连接\n
-
-	    * @return  无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void GiveBack( CDBConnect* pConn );
-	    /**
-	    * @brief
-	    把SQL语句加入异步执行队列函数。
-
-	    * @param  [in] const std::string& strSQL  要执行的SQL语句\n
-
-	    * @return  加入异步执行队列是否成功\n
-	    * @return  true成功\n
-	    * @return  false失败\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		bool PushAsync( const std::string& strSQL );
-		/**
-		 * @brief
-		 执行SQL语句返回结果集函数。
-
-		 * @param [in] const char *szSql  SQL语句\n
-		 * @param [out] CDBResultSet& DBRes  结果集\n
-		 * @param [out] std::string& Error  错误信息\n
-
-		 * @return 返回查询是否成功
-		 * @return  true  成功\n
-		 * @return  false  失败\n
-
-		 * @note
-
-		 * @warning
-
-		 * @bug
-
-		*/
-		bool Query( const char *szSql, CDBResultSet& DBRes,std::string& Error );
-		/**
-		* @brief
-		执行SQL语句函数。
-
-		* @param [in] const char *szSql  SQL语句\n
-		* @param [out] std::string& Error  错误信息\n
-
-		* @return 返回影响到的记录数量
-		* @return  -1  失败\n
-		* @return  >=0  成功\n
-
-		* @note
-
-		* @warning
-
-		* @bug
-
-		*/
-		my_ulonglong ExecuteSql( const char *szSql, std::string& Error );
-	};
-}
-
-//单件相关定义
-typedef boost::serialization::singleton<YADB::CDBConnPool> singleton_CDBConnPool;
-#define sDBConnPool singleton_CDBConnPool::get_mutable_instance()
-#define sDBConnPool_const singleton_CDBConnPool::get_const_instance()
+/**
+* @brief
+数据库连接池类
+
+* @version
+V 1.0.0
+
+* @author
+王益俊
+
+* @date
+创建时间:  2018-04-17\n
+
+* @note
+2018-04-17  创建类。\n
+
+* @warning
+
+* @bug
+
+*/
+
+//#pragma once
+#ifndef YADB_CONNECT_POOL_H
+#define YADB_CONNECT_POOL_H
+
+#include <boost/atomic.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/lockfree/queue.hpp>
+
+#include <list>
+#include <string>
+#include <mutex>
+
+#include "CDBCommon.h"
+#include "CDBConnect.h"
+
+namespace YADB
+{
+	class CDBConnPool
+	{
+	private:
+		std::list<CDBConnect*> __BusyConnList;//正在使用的数据库连接列表
+		std::list<CDBConnect*> __IdleConnList;//没有使用的数据库连接列表
+		_DB_POOL_SETTING_ __Setting;//数据库连接池设置
+		std::mutex __mtx;//互斥量
+		boost::atomic<bool> __Running{ true };//线程是否运行的标识
+		boost::atomic<bool> __IsExited{ false };//线程是否已退出的标识
+		CDBConnect* __pAsyncDBConn;//异步执行线程用的数据库连接
+	private:
+		/**
+	    * @brief
+	    创建一个空闲连接函数。
+
+        * @param  [out] std::string& Error  错误信息\n
+	    * @param  [in] bool IsTemp  创建的连接是否是临时的\n
+
+	    * @return 返回创建的连接
+	    * @return  >0   成功\n
+	    * @return  ==0  失败\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		CDBConnect* __CreateIdleConn( std::string& Error, bool IsTemp = false );
+		/**
+	    * @brief
+	    创建异步执行线程所用连接函数。
+
+	    * @param  无\n
+
+	    * @return 无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void __CreateAsyncThrdConn();
+		/**
+	    * @brief
+	    刪除创建异步执行线程所用连接函数。
+
+	    * @param  无\n
+
+	    * @return 无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void __DestroyAsyncThrdConn();
+		/**
+		* @brief
+		启动异步执行线程函数。
+
+		* @param  无\n
+
+		* @return 无
+
+		* @note
+
+		* @warning
+
+		* @bug
+
+		*/
+		void __StartAsyncThrd();
+	    /**
+	    * @brief
+	    停止异步执行线程函数。
+
+	    * @param  无\n
+
+	    * @return 无
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void __StopAsyncThrd();
+	protected:
+	    /**
+	    * @brief
+	    异步执行线程函数。
+
+	    * @param  [in] CDBConnPool* pOwner  线程所属对象\n
+
+	    * @return 无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void _AsyncThreadFunc( CDBConnPool* pOwner );//线程函数
+	public:
+		CDBConnPool();
+		~CDBConnPool();
+		/**
+	    * @brief
+	    创建数据库连接池函数。
+
+	    * @param  [in] const _DB_POOL_SETTING_& Setting  数据库连接池设置\n
+		* @param  [in] bool bAsync  是否创建异步队列及处理线程\n
+	    * @param  [out] std::string& szError  错误信息\n
+
+	    * @return 返回创建数据库连接池是否成功
+	    * @return  true   成功
+	    * @return  false  失败
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+	   	bool Create( const _DB_POOL_SETTING_& Setting, std::string& szError );
+		bool Create( const _DB_POOL_SETTING_& Setting,bool bAsync, std::string& szError );
+		/**
+	    * @brief
+	    关闭线程池函数。
+
+	    * @param  无\n
+
+	    * @return  无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void Close();
+		/**
+	    * @brief
+	    从连接池中获得一个数据库连接函数。
+
+	    * @param  [out] std::string& Error  错误信息\n
+
+	    * @return 返回获得一个数据库连接是否成功
+	    * @return  0 失败\n
+	    * @return  !=0 获得的数据库连接\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		CDBConnect* GetDBConnect( std::string& Error );
+		/**
+	    * @brief
+	    归还一个数据库连接到连接池中函数。
+
+	    * @param  [in] CDBConnect* pConn  数据库连接\n
+
+	    * @return  无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void GiveBack( CDBConnect* pConn );
+	    /**
+	    * @brief
+	    把SQL语句加入异步执行队列函数。
+
+	    * @param  [in] const std::string& strSQL  要执行的SQL语句\n
+
+	    * @return  加入异步执行队列是否成功\n
+	    * @return  true成功\n
+	    * @return  false失败\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		bool PushAsync( const std::string& strSQL );
+		/**
+		 * @brief
+		 执行SQL语句返回结果集函数。
+
+		 * @param [in] const char *szSql  SQL语句\n
+		 * @param [out] CDBResultSet& DBRes  结果集\n
+		 * @param [out] std::string& Error  错误信息\n
+
+		 * @return 返回查询是否成功
+		 * @return  true  成功\n
+		 * @return  false  失败\n
+
+		 * @note
+
+		 * @warning
+
+		 * @bug
+
+		*/
+		bool Query( const char *szSql, CDBResultSet& DBRes,std::string& Error );
+        MYSQL_RES* Query( const char *szSql, std::string& Error);      
+        
+        
+		/**
+		* @brief
+		执行SQL语句函数。
+
+		* @param [in] const char *szSql  SQL语句\n
+		* @param [out] std::string& Error  错误信息\n
+
+		* @return 返回影响到的记录数量
+		* @return  -1  失败\n
+		* @return  >=0  成功\n
+
+		* @note
+
+		* @warning
+
+		* @bug
+
+		*/
+		my_ulonglong ExecuteSql( const char *szSql, std::string& Error );
+	};
+}
+
+
+#endif

+ 293 - 290
db_api/CDBConnect.cpp

@@ -1,290 +1,293 @@
-#include "CDBConnect.h"
-#include <string.h>
-
-namespace YADB
-{
-	CDBConnect::CDBConnect( bool IsTemp )
-	{
-		__pConn  = 0;
-		__IsTemp = IsTemp;
-		__pstmt  = 0;
-	}
-
-
-	CDBConnect::~CDBConnect()
-	{
-		Close();
-	}
-
-	bool CDBConnect::Connect( const _DB_CONN_SETTING_ & DBSetting, std::string & Error )
-	{
-		//创建
-		__pConn = mysql_init( NULL );
-
-		//超时设置
-		if ( mysql_options( __pConn, MYSQL_OPT_CONNECT_TIMEOUT, &(DBSetting.TimeOut) ) != 0 )
-		{
-			Error = "Failed to call mysql_options,";
-			Error += " LastError=";
-			Error += GetLastError();
-			return false;
-		}
-
-		//设置字符集
-		if ( mysql_set_character_set( __pConn, DBSetting.CharSet.c_str() ) != 0 )
-		{
-			Error = "Failed to call mysql_set_character_set,";
-			Error += " LastError=";
-			Error += GetLastError();
-			return false;
-		}
-
-		//连接数据库
-		if ( !mysql_real_connect( __pConn, DBSetting.Host.c_str(), DBSetting.User.c_str(), DBSetting.PWD.c_str(), DBSetting.DBName.c_str(), 0, NULL, 0 ) )
-		{
-			Error = "Failed to connect database,";
-			Error += " LastError=";
-			Error += GetLastError();
-			return false;
-		}
-
-		return true;
-	}
-
-	void CDBConnect::Close()
-	{
-		stmtClose();
-
-		if ( __pConn )
-		{
-			mysql_close( __pConn );
-			__pConn = 0;
-		}
-	}
-
-	int CDBConnect::ConnctionTest( std::string& Error )
-	{
-		int nRet = -1;
-
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			nRet = DB_ERR_NOT_CONNECT_DB;
-		}
-		else
-		{
-			nRet = mysql_ping( __pConn );
-			if ( nRet != 0 )
-			{
-				Error = "Failed to mysql_ping,";
-				Error += " LastError=";
-				Error += GetLastError();
-			}			
-		}
-
-		return nRet;
-	}
-
-	int CDBConnect::AutoCommit( bool Mode, std::string& Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		return mysql_autocommit( __pConn, Mode );
-	}
-
-	int CDBConnect::Commit( std::string& Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		return mysql_commit( __pConn );
-	}
-
-	int CDBConnect::RollBack( std::string& Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		return mysql_rollback( __pConn );
-	}
-
-	CDBResultSet * CDBConnect::ExecuteQuery( const char * szSql, std::string & Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return 0;
-		}
-
-		if ( mysql_query( __pConn, szSql ) )
-		{
-			Error = "Failed to execute SQL!";
-			Error += " LastError=";
-			Error += GetLastError();
-			return 0;
-		}
-
-		if ( !__RessultSet.Bind( mysql_store_result( __pConn ), Error ) )
-		{
-			return 0;
-		}
-
-		return &__RessultSet;
-	}
-
-	MYSQL_RES* CDBConnect::Query( const char *szSql, std::string& Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return 0;
-		}
-
-		if ( mysql_query( __pConn, szSql ) )
-		{
-			Error = "Failed to execute SQL!";
-			Error += " LastError=";
-			Error += GetLastError();
-			return 0;
-		}
-
-		return mysql_store_result( __pConn );
-	}
-
-	my_ulonglong CDBConnect::ExecuteSql( const char * szSql, std::string& Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		if ( mysql_query( __pConn, szSql ) )
-		{
-			Error = "Failed to execute SQL!";
-			Error += " LastError=";
-			Error += GetLastError();
-			return DB_ERR_EXCUTE_QUERY;
-		}
-
-		return mysql_affected_rows( __pConn );
-	}
-
-	my_ulonglong CDBConnect::ExecuteRealSql( const char * szSql, std::string & Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		unsigned long uSqlLen = strlen( szSql );
-		if ( mysql_real_query( __pConn, szSql, uSqlLen ) )
-		{
-			Error = "Failed to execute SQL,";
-			Error += " LastError=";
-			Error += GetLastError();
-			return DB_ERR_EXCUTE_QUERY;
-		}
-
-		return mysql_affected_rows( __pConn );
-	}
-
-	const char * CDBConnect::GetLastError()
-	{
-		if ( 0 == __pConn )
-		{
-			return "";
-		}
-
-		return mysql_error( __pConn );
-	}
-
-	my_ulonglong CDBConnect::GetLastInsertID( std::string& Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		return mysql_insert_id( __pConn  );
-	}
-
-	bool CDBConnect::IsTemp()
-	{
-		return __IsTemp;
-	}
-
-	bool CDBConnect::Preparestmt( const char *szSql, std::string & Error )
-	{
-		if ( 0 == __pConn )
-		{
-			Error = "Error,not connected to database!";
-			return DB_ERR_NOT_CONNECT_DB;
-		}
-
-		stmtClose();
-
-		__pstmt = mysql_stmt_init( __pConn );
-
-		if ( mysql_stmt_prepare( __pstmt, szSql, strlen( szSql ) ) != 0 )
-		{
-			Error = "Error, failed to mysql_stmt_prepare!";
-			Error += " LastError=";
-			Error += GetLastError();
-			return false;
-		}
-
-		return true;
-	}
-
-	bool CDBConnect::stmtExcute( MYSQL_BIND *stBinds, uint64_t * piId, std::string & Error )
-	{
-		if ( __pstmt == NULL )
-		{
-			Error = "Bind error, not called Preparestmt function!";
-			return false;
-		}
-
-		if ( mysql_stmt_bind_param( __pstmt, stBinds ) != 0 )
-		{
-			Error = "mysql_stmt_bind_param error,";
-			Error += mysql_stmt_error( __pstmt );
-			return false;
-		}
-
-		if ( mysql_stmt_execute( __pstmt ) != 0 )
-		{
-			Error = "mysql_stmt_execute error,";
-			Error += mysql_stmt_error( __pstmt );
-			return false;
-		}
-
-		if ( piId )
-		{
-			*piId = mysql_stmt_insert_id( __pstmt );
-		}
-
-		return true;
-	}
-
-	void CDBConnect::stmtClose()
-	{
-		if ( __pstmt )
-		{
-			mysql_stmt_close( __pstmt );
-			__pstmt = 0;
-		}
-	}
-}
+#include "CDBConnect.h"
+#include <string.h>
+
+namespace YADB
+{
+	CDBConnect::CDBConnect( bool IsTemp )
+	{
+		__pConn  = 0;
+		__IsTemp = IsTemp;
+		__pstmt  = 0;
+	}
+
+
+	CDBConnect::~CDBConnect()
+	{
+		Close();
+	}
+
+	bool CDBConnect::Connect( const _DB_CONN_SETTING_ & DBSetting, std::string & Error )
+	{
+		//创建
+		__pConn = mysql_init( NULL );
+
+		//超时设置
+		if ( mysql_options( __pConn, MYSQL_OPT_CONNECT_TIMEOUT, &(DBSetting.TimeOut) ) != 0 )
+		{
+			Error = "Failed to call mysql_options,";
+			Error += " LastError=";
+			Error += GetLastError();
+			return false;
+		}
+
+		//设置字符集
+		if ( mysql_set_character_set( __pConn, DBSetting.CharSet.c_str() ) != 0 )
+		{
+			Error = "Failed to call mysql_set_character_set,";
+			Error += " LastError=";
+			Error += GetLastError();
+			return false;
+		}
+
+		//连接数据库
+		if ( !mysql_real_connect( __pConn, DBSetting.Host.c_str(), DBSetting.User.c_str(), DBSetting.PWD.c_str(), DBSetting.DBName.c_str(), 0, NULL, 0 ) )
+		{
+			Error = "Failed to connect database,";
+			Error += " LastError=";
+			Error += GetLastError();
+			return false;
+		}
+		//依靠 mysql_ping 无法做到重连
+		char value = 1;
+		mysql_options(__pConn, MYSQL_OPT_RECONNECT, &value);
+
+		return true;
+	}
+
+	void CDBConnect::Close()
+	{
+		stmtClose();
+
+		if ( __pConn )
+		{
+			mysql_close( __pConn );
+			__pConn = 0;
+		}
+	}
+
+	int CDBConnect::ConnctionTest( std::string& Error )
+	{
+		int nRet = -1;
+
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			nRet = DB_ERR_NOT_CONNECT_DB;
+		}
+		else
+		{
+			nRet = mysql_ping( __pConn );
+			if ( nRet != 0 )
+			{
+				Error = "Failed to mysql_ping,";
+				Error += " LastError=";
+				Error += GetLastError();
+			}			
+		}
+
+		return nRet;
+	}
+
+	int CDBConnect::AutoCommit( bool Mode, std::string& Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		return mysql_autocommit( __pConn, Mode );
+	}
+
+	int CDBConnect::Commit( std::string& Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		return mysql_commit( __pConn );
+	}
+
+	int CDBConnect::RollBack( std::string& Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		return mysql_rollback( __pConn );
+	}
+
+	CDBResultSet * CDBConnect::ExecuteQuery( const char * szSql, std::string & Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return 0;
+		}
+
+		if ( mysql_query( __pConn, szSql ) )
+		{
+			Error = "Failed to execute SQL!";
+			Error += " LastError=";
+			Error += GetLastError();
+			return 0;
+		}
+
+		if ( !__RessultSet.Bind( mysql_store_result( __pConn ), Error ) )
+		{
+			return 0;
+		}
+
+		return &__RessultSet;
+	}
+
+	MYSQL_RES* CDBConnect::Query( const char *szSql, std::string& Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return 0;
+		}
+
+		if ( mysql_query( __pConn, szSql ) )
+		{
+			Error = "Failed to execute SQL!";
+			Error += " LastError=";
+			Error += GetLastError();
+			return 0;
+		}
+
+		return mysql_store_result( __pConn );
+	}
+
+	my_ulonglong CDBConnect::ExecuteSql( const char * szSql, std::string& Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		if ( mysql_query( __pConn, szSql ) )
+		{
+			Error = "Failed to execute SQL!";
+			Error += " LastError=";
+			Error += GetLastError();
+			return DB_ERR_EXCUTE_QUERY;
+		}
+
+		return mysql_affected_rows( __pConn );
+	}
+
+	my_ulonglong CDBConnect::ExecuteRealSql( const char * szSql, std::string & Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		unsigned long uSqlLen = strlen( szSql );
+		if ( mysql_real_query( __pConn, szSql, uSqlLen ) )
+		{
+			Error = "Failed to execute SQL,";
+			Error += " LastError=";
+			Error += GetLastError();
+			return DB_ERR_EXCUTE_QUERY;
+		}
+
+		return mysql_affected_rows( __pConn );
+	}
+
+	const char * CDBConnect::GetLastError()
+	{
+		if ( 0 == __pConn )
+		{
+			return "";
+		}
+
+		return mysql_error( __pConn );
+	}
+
+	my_ulonglong CDBConnect::GetLastInsertID( std::string& Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		return mysql_insert_id( __pConn  );
+	}
+
+	bool CDBConnect::IsTemp()
+	{
+		return __IsTemp;
+	}
+
+	bool CDBConnect::Preparestmt( const char *szSql, std::string & Error )
+	{
+		if ( 0 == __pConn )
+		{
+			Error = "Error,not connected to database!";
+			return DB_ERR_NOT_CONNECT_DB;
+		}
+
+		stmtClose();
+
+		__pstmt = mysql_stmt_init( __pConn );
+
+		if ( mysql_stmt_prepare( __pstmt, szSql, strlen( szSql ) ) != 0 )
+		{
+			Error = "Error, failed to mysql_stmt_prepare!";
+			Error += " LastError=";
+			Error += GetLastError();
+			return false;
+		}
+
+		return true;
+	}
+
+	bool CDBConnect::stmtExcute( MYSQL_BIND *stBinds, uint64_t * piId, std::string & Error )
+	{
+		if ( __pstmt == NULL )
+		{
+			Error = "Bind error, not called Preparestmt function!";
+			return false;
+		}
+
+		if ( mysql_stmt_bind_param( __pstmt, stBinds ) != 0 )
+		{
+			Error = "mysql_stmt_bind_param error,";
+			Error += mysql_stmt_error( __pstmt );
+			return false;
+		}
+
+		if ( mysql_stmt_execute( __pstmt ) != 0 )
+		{
+			Error = "mysql_stmt_execute error,";
+			Error += mysql_stmt_error( __pstmt );
+			return false;
+		}
+
+		if ( piId )
+		{
+			*piId = mysql_stmt_insert_id( __pstmt );
+		}
+
+		return true;
+	}
+
+	void CDBConnect::stmtClose()
+	{
+		if ( __pstmt )
+		{
+			mysql_stmt_close( __pstmt );
+			__pstmt = 0;
+		}
+	}
+}

+ 332 - 332
db_api/CDBConnect.h

@@ -1,332 +1,332 @@
-/**
-* @brief
-数据库连接类
-
-* @version
-V 1.0.0
-
-* @author
-王益俊
-
-* @date
-创建时间:  2018-04-17\n
-
-* @note
-2018-04-17  创建类。\n
-
-* @warning
-
-* @bug
-
-*/
-
-#pragma once
-
-#include <string>
-#include <mysql.h>
-#include "CDBResultSet.h"
-#include "CDBCommon.h"
-
-namespace YADB
-{
-	class CDBConnect
-	{
-	private:
-    	MYSQL * __pConn;//数据库连接
-    	CDBResultSet __RessultSet;//结果集
-    	bool __IsTemp;//是否是临时的(如果是临时使用的,归还到连接池中时会自动删除,以保持总体连接数不变)
-    	MYSQL_STMT *__pstmt;//预处理
-	public:
-		CDBConnect( bool IsTemp = false );
-		~CDBConnect();
-		/**
-		* @brief
-		连接数据库函数。
-
-		* @param  [in] const _DB_POOL_SETTING_& Setting  数据库连接设置\n
-		* @param  [out] std::string& Error  错误信息\n
-
-		* @return 返回连接数据库是否成功
-		* @return  true   成功\n
-		* @return  false  失败\n
-
-		* @note
-
-		* @warning
-
-		* @bug
-
-		*/
-		bool Connect( const _DB_CONN_SETTING_& DBSetting, std::string& Error );
-		/**
-	    * @brief
-	    关闭连接函数。
-
-	    * @param  无\n
-
-	    * @return  无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void Close();
-		/**
-	    * @brief
-	    测试连接函数。
-
-	    * @param [out] std::string& Error 错误信息\n
-
-	    * @return 返回测试连接是否成功
-	    * @return  0  连接测试成功\n
-	    * @return  !=0  连接测试失败\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		int ConnctionTest( std::string& Error );
-		/**
-	    * @brief
-	    设置自动提交的函数。
-
-	    * @param [in] bool Mode 是否是否自动提交\n
-	    * @param [out] std::string& Error 错误信息\n
-
-	    * @return 返回设置自动提交是否成功
-	    * @return  0  成功\n
-	    * @return  !=0  失败\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		int AutoCommit( bool Mode, std::string& Error );
-		/**
-	    * @brief
-	    提交函数。
-
-	    * @param [out] std::string& Error 错误信息\n
-
-	    * @return 返回提交是否成功
-	    * @return  0  成功\n
-	    * @return  !=0  失败\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		int Commit( std::string& Error  );
-		/**
-	    * @brief
-	    回滚函数。
-
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回回滚是否成功
-	    * @return  0  成功\n
-	    * @return  !=0  失败\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		int RollBack( std::string& Error );
-		/**
-	    * @brief
-	    执行SQL语句返回结果集函数。
-
-	    * @param [in] const char *szSql  SQL语句\n
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回结果集
-	    * @return  0  失败\n
-	    * @return  !=0  成功\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		CDBResultSet* ExecuteQuery( const char *szSql, std::string& Error );
-		/**
-	    * @brief
-	    执行SQL语句返回mysql原始结果集函数。
-
-	    * @param [in] const char *szSql  SQL语句\n
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回的mysql原始结果集
-	    * @return  ==0  失败\n
-	    * @return  !=0  成功\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		MYSQL_RES* Query( const char *szSql, std::string& Error );
-		/**
-		* @brief
-		执行SQL语句函数。
-
-		* @param [in] const char *szSql  SQL语句\n
-		* @param [out] std::string& Error  错误信息\n
-
-		* @return 返回影响到的记录数量
-		* @return  -1  失败\n
-		* @return  >=0  成功\n
-
-		* @note
-
-		* @warning
-
-		* @bug
-
-		*/
-		my_ulonglong ExecuteSql( const char *szSql, std::string& Error );
-		/**
-	    * @brief
-	    执行SQL语句函数。
-
-	    * @param [in] const char *szSql  SQL语句\n
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回影响到的记录数量
-	    * @return  -1  失败\n
-	    * @return  >=0  成功\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		my_ulonglong ExecuteRealSql( const char *szSql, std::string& Error );
-		/**
-	    * @brief
-	    获得最后一次错误信息函数。
-
-	    * @param 无\n
-
-	    * @return 返回最后一次错误
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		const char* GetLastError();
-		/**
-	    * @brief
-	    获得最后一次插入的ID函数。
-
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回最后一次插入的ID
-	    * @return  -1  失败\n
-	    * @return  >=0  成功\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		my_ulonglong GetLastInsertID( std::string& Error );
-		/**
-		* @brief
-		获得是否是临时的连接函数。
-
-		* @param 无\n
-
-		* @return 返回是否是临时的
-
-		* @note
-
-		* @warning
-
-		* @bug
-
-		*/
-		bool IsTemp();
-		/**
-	    * @brief
-	    准备stmt函数。
-
-	    * @param const char *szSql 预处理SQL语句\n
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回准备stmt是否成功
-	    * @return  false  失败\n
-	    * @return  true  成功\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		bool Preparestmt( const char *szSql, std::string& Error );
-		/**
-	    * @brief
-	    执行stmt函数。
-
-	    * @param [in] MYSQL_BIND *stBinds  要执行的BIND\n
-	    * @param [in] uint64_t *piId  执行后获得的ID\n
-	    * @param [out] std::string& Error  错误信息\n
-
-	    * @return 返回执行stmt成功还是失败
-	    * @return  false  失败\n
-	    * @return  true  成功\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		bool stmtExcute( MYSQL_BIND *stBinds, uint64_t *piId, std::string& Error );
-		/**
-	    * @brief
-	    关闭stmt函数。
-
-	    * @param 无\n
-
-	    * @return 无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void stmtClose();
-	};
-}
+/**
+* @brief
+数据库连接类
+
+* @version
+V 1.0.0
+
+* @author
+王益俊
+
+* @date
+创建时间:  2018-04-17\n
+
+* @note
+2018-04-17  创建类。\n
+
+* @warning
+
+* @bug
+
+*/
+
+#pragma once
+
+#include <string>
+#include <mysql.h>
+#include "CDBResultSet.h"
+#include "CDBCommon.h"
+
+namespace YADB
+{
+	class CDBConnect
+	{
+	private:
+    	MYSQL * __pConn;//数据库连接
+    	CDBResultSet __RessultSet;//结果集
+    	bool __IsTemp;//是否是临时的(如果是临时使用的,归还到连接池中时会自动删除,以保持总体连接数不变)
+    	MYSQL_STMT *__pstmt;//预处理
+	public:
+		CDBConnect( bool IsTemp = false );
+		~CDBConnect();
+		/**
+		* @brief
+		连接数据库函数。
+
+		* @param  [in] const _DB_POOL_SETTING_& Setting  数据库连接设置\n
+		* @param  [out] std::string& Error  错误信息\n
+
+		* @return 返回连接数据库是否成功
+		* @return  true   成功\n
+		* @return  false  失败\n
+
+		* @note
+
+		* @warning
+
+		* @bug
+
+		*/
+		bool Connect( const _DB_CONN_SETTING_& DBSetting, std::string& Error );
+		/**
+	    * @brief
+	    关闭连接函数。
+
+	    * @param  无\n
+
+	    * @return  无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void Close();
+		/**
+	    * @brief
+	    测试连接函数。
+
+	    * @param [out] std::string& Error 错误信息\n
+
+	    * @return 返回测试连接是否成功
+	    * @return  0  连接测试成功\n
+	    * @return  !=0  连接测试失败\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		int ConnctionTest( std::string& Error );
+		/**
+	    * @brief
+	    设置自动提交的函数。
+
+	    * @param [in] bool Mode 是否是否自动提交\n
+	    * @param [out] std::string& Error 错误信息\n
+
+	    * @return 返回设置自动提交是否成功
+	    * @return  0  成功\n
+	    * @return  !=0  失败\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		int AutoCommit( bool Mode, std::string& Error );
+		/**
+	    * @brief
+	    提交函数。
+
+	    * @param [out] std::string& Error 错误信息\n
+
+	    * @return 返回提交是否成功
+	    * @return  0  成功\n
+	    * @return  !=0  失败\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		int Commit( std::string& Error  );
+		/**
+	    * @brief
+	    回滚函数。
+
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回回滚是否成功
+	    * @return  0  成功\n
+	    * @return  !=0  失败\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		int RollBack( std::string& Error );
+		/**
+	    * @brief
+	    执行SQL语句返回结果集函数。
+
+	    * @param [in] const char *szSql  SQL语句\n
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回结果集
+	    * @return  0  失败\n
+	    * @return  !=0  成功\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		CDBResultSet* ExecuteQuery( const char *szSql, std::string& Error );
+		/**
+	    * @brief
+	    执行SQL语句返回mysql原始结果集函数。
+
+	    * @param [in] const char *szSql  SQL语句\n
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回的mysql原始结果集
+	    * @return  ==0  失败\n
+	    * @return  !=0  成功\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		MYSQL_RES* Query( const char *szSql, std::string& Error );
+		/**
+		* @brief
+		执行SQL语句函数。
+
+		* @param [in] const char *szSql  SQL语句\n
+		* @param [out] std::string& Error  错误信息\n
+
+		* @return 返回影响到的记录数量
+		* @return  -1  失败\n
+		* @return  >=0  成功\n
+
+		* @note
+
+		* @warning
+
+		* @bug
+
+		*/
+		my_ulonglong ExecuteSql( const char *szSql, std::string& Error );
+		/**
+	    * @brief
+	    执行SQL语句函数。
+
+	    * @param [in] const char *szSql  SQL语句\n
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回影响到的记录数量
+	    * @return  -1  失败\n
+	    * @return  >=0  成功\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		my_ulonglong ExecuteRealSql( const char *szSql, std::string& Error );
+		/**
+	    * @brief
+	    获得最后一次错误信息函数。
+
+	    * @param 无\n
+
+	    * @return 返回最后一次错误
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		const char* GetLastError();
+		/**
+	    * @brief
+	    获得最后一次插入的ID函数。
+
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回最后一次插入的ID
+	    * @return  -1  失败\n
+	    * @return  >=0  成功\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		my_ulonglong GetLastInsertID( std::string& Error );
+		/**
+		* @brief
+		获得是否是临时的连接函数。
+
+		* @param 无\n
+
+		* @return 返回是否是临时的
+
+		* @note
+
+		* @warning
+
+		* @bug
+
+		*/
+		bool IsTemp();
+		/**
+	    * @brief
+	    准备stmt函数。
+
+	    * @param const char *szSql 预处理SQL语句\n
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回准备stmt是否成功
+	    * @return  false  失败\n
+	    * @return  true  成功\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		bool Preparestmt( const char *szSql, std::string& Error );
+		/**
+	    * @brief
+	    执行stmt函数。
+
+	    * @param [in] MYSQL_BIND *stBinds  要执行的BIND\n
+	    * @param [in] uint64_t *piId  执行后获得的ID\n
+	    * @param [out] std::string& Error  错误信息\n
+
+	    * @return 返回执行stmt成功还是失败
+	    * @return  false  失败\n
+	    * @return  true  成功\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		bool stmtExcute( MYSQL_BIND *stBinds, uint64_t *piId, std::string& Error );
+		/**
+	    * @brief
+	    关闭stmt函数。
+
+	    * @param 无\n
+
+	    * @return 无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void stmtClose();
+	};
+}

+ 45 - 45
db_api/CDBHelper.cpp

@@ -1,45 +1,45 @@
-#include "CDBHelper.h"
-#include <stdio.h>
-#include <string.h>
-
-namespace YADB
-{
-	CDBHelper::CDBHelper()
-	{
-
-	}
-
-	CDBHelper::~CDBHelper()
-	{
-
-	}
-
-	void CDBHelper::String2DateTime( const char* szString, MYSQL_TIME & value )
-	{
-		sscanf( szString, "%d-%d-%d %d:%d:%d", &value.year, &value.month, &value.day, &value.hour, &value.minute, &value.second );
-		value.second_part = 0;//microseconds
-		value.neg = false;
-		value.time_type = MYSQL_TIMESTAMP_DATE;
-	}
-
-	void CDBHelper::DateTime2String( const MYSQL_TIME & value, char * szString, int Length )
-	{
-		char szTemp[20] = { 0 };
-		sprintf( szTemp, "%d-%d-%d %02d:%02d:%02d", \
-			value.year, value.month, value.day, value.hour, value.minute, value.second );
-		strncpy( szString, szTemp, Length );
-	}
-
-	void CDBHelper::InitMySQLTime( MYSQL_TIME & value )
-	{
-		value.year         = 0;
-		value.month        = 0;
-		value.day          = 0;
-		value.hour         = 0;
-		value.minute       = 0;
-		value.second       = 0;
-		value.neg          = false;
-		value.second_part  = 0;
-		value.time_type    = MYSQL_TIMESTAMP_DATETIME;
-	}
-}
+#include "CDBHelper.h"
+#include <stdio.h>
+#include <string.h>
+
+namespace YADB
+{
+	CDBHelper::CDBHelper()
+	{
+
+	}
+
+	CDBHelper::~CDBHelper()
+	{
+
+	}
+
+	void CDBHelper::String2DateTime( const char* szString, MYSQL_TIME & value )
+	{
+		sscanf( szString, "%d-%d-%d %d:%d:%d", &value.year, &value.month, &value.day, &value.hour, &value.minute, &value.second );
+		value.second_part = 0;//microseconds
+		value.neg = false;
+		value.time_type = MYSQL_TIMESTAMP_DATE;
+	}
+
+	void CDBHelper::DateTime2String( const MYSQL_TIME & value, char * szString, int Length )
+	{
+		char szTemp[20] = { 0 };
+		sprintf( szTemp, "%d-%d-%d %02d:%02d:%02d", \
+			value.year, value.month, value.day, value.hour, value.minute, value.second );
+		strncpy( szString, szTemp, Length );
+	}
+
+	void CDBHelper::InitMySQLTime( MYSQL_TIME & value )
+	{
+		value.year         = 0;
+		value.month        = 0;
+		value.day          = 0;
+		value.hour         = 0;
+		value.minute       = 0;
+		value.second       = 0;
+		value.neg          = false;
+		value.second_part  = 0;
+		value.time_type    = MYSQL_TIMESTAMP_DATETIME;
+	}
+}

+ 86 - 86
db_api/CDBHelper.h

@@ -1,86 +1,86 @@
-/**
-* @brief
-数据库助手类
-
-* @version
-V 1.0.0
-
-* @author
-王益俊
-
-* @date
-创建时间:  2018-04-19\n
-
-* @note
-2018-04-19  创建类。\n
-
-* @warning
-
-* @bug
-
-*/
-
-#pragma once
-
-#include <mysql.h>
-
-namespace YADB
-{
-	class CDBHelper
-	{
-	public:
-		CDBHelper();
-		~CDBHelper();
-		/**
-	    * @brief
-	    把时间字符串转成MYSQL_TIME的函数。
-
-	    * @param  [in] char* szdtString  时间字符串\n
-	    * @param  [out] MYSQL_TIME & value  转换好的MYSQL_TIME类型的值\n
-
-	    * @return 无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void String2DateTime( const char* szString, MYSQL_TIME & value );
-		/**
-	    * @brief
-	    把MYSQL_TIME转成时间字符串转成函数。
-
-	    * @param  [in] MYSQL_TIME & value  要转换的MYSQL_TIME类型的值\n
-	    * @param  [out] char* szdtString  时间字符串\n
-
-	    * @return 无\n
-
-	    * @note
-
-	    * @warning
-
-	    * @bug
-
-	    */
-		void DateTime2String( const MYSQL_TIME & value, char* szString, int Length );
-		/**
-		* @brief
-		把MYSQL_TIME初始化函数。
-
-		* @param  [out] MYSQL_TIME & value  要初始化的MYSQL_TIME值\n
-
-		* @return 无\n
-
-		* @note
-
-		* @warning
-
-		* @bug
-
-		*/
-		void InitMySQLTime( MYSQL_TIME & value );
-	};
-
-}
+/**
+* @brief
+数据库助手类
+
+* @version
+V 1.0.0
+
+* @author
+王益俊
+
+* @date
+创建时间:  2018-04-19\n
+
+* @note
+2018-04-19  创建类。\n
+
+* @warning
+
+* @bug
+
+*/
+
+#pragma once
+
+#include <mysql.h>
+
+namespace YADB
+{
+	class CDBHelper
+	{
+	public:
+		CDBHelper();
+		~CDBHelper();
+		/**
+	    * @brief
+	    把时间字符串转成MYSQL_TIME的函数。
+
+	    * @param  [in] char* szdtString  时间字符串\n
+	    * @param  [out] MYSQL_TIME & value  转换好的MYSQL_TIME类型的值\n
+
+	    * @return 无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void String2DateTime( const char* szString, MYSQL_TIME & value );
+		/**
+	    * @brief
+	    把MYSQL_TIME转成时间字符串转成函数。
+
+	    * @param  [in] MYSQL_TIME & value  要转换的MYSQL_TIME类型的值\n
+	    * @param  [out] char* szdtString  时间字符串\n
+
+	    * @return 无\n
+
+	    * @note
+
+	    * @warning
+
+	    * @bug
+
+	    */
+		void DateTime2String( const MYSQL_TIME & value, char* szString, int Length );
+		/**
+		* @brief
+		把MYSQL_TIME初始化函数。
+
+		* @param  [out] MYSQL_TIME & value  要初始化的MYSQL_TIME值\n
+
+		* @return 无\n
+
+		* @note
+
+		* @warning
+
+		* @bug
+
+		*/
+		void InitMySQLTime( MYSQL_TIME & value );
+	};
+
+}

+ 451 - 451
db_api/CDBResultSet.cpp

@@ -1,451 +1,451 @@
-#include "CDBResultSet.h"
-#include <string.h>
-
-namespace YADB
-{
-	CDBResultSet::CDBResultSet()
-	{
-		__pQueryRes  = 0;
-		__CurRow     = 0;
-		__FieldCount = 0;
-	}
-
-	CDBResultSet::~CDBResultSet()
-	{
-		Close();
-	}
-
-	void CDBResultSet::__BuildFNameIdxLst()
-	{
-		if (0 == __pQueryRes)
-		{
-			return;
-		}
-
-		for ( int i = 0; i < __FieldCount; i++ )
-		{
-			MYSQL_FIELD *pField = mysql_fetch_field_direct( __pQueryRes, i );
-			if ( pField == NULL )
-			{
-				continue;
-			}
-
-			__FNameIndexList.insert( std::make_pair( pField->name, i ) );
-		}
-	}
-
-	bool CDBResultSet::Bind( MYSQL_RES *pQueryRes, std::string& Error )
-	{
-		Close();
-
-		__pQueryRes = pQueryRes;
-		if ( __pQueryRes != 0 )
-		{
-			__FieldCount = mysql_num_fields( pQueryRes );
-		}
-		else
-		{
-			Error = "Error,pQueryRes is null!";
-			__FieldCount = 0;
-			return false;
-		}
-
-		__BuildFNameIdxLst();
-
-		return true;
-	}
-
-	void CDBResultSet::Close()
-	{
-		if ( 0 == __pQueryRes )
-		{
-			return;
-		}
-
-		mysql_free_result( __pQueryRes );
-		__pQueryRes  = 0;
-		__CurRow     = 0;
-		__FieldCount = 0;
-		__FNameIndexList.clear();
-	}
-
-	bool CDBResultSet::SeekData( my_ulonglong Offset, std::string& Error )
-	{
-		if ( 0 == __pQueryRes )
-		{
-			Error = "Error,__pQueryRes is not initialized!";
-			return false;
-		}
-
-		mysql_data_seek( __pQueryRes, Offset );
-
-		return true;
-	}
-
-	bool CDBResultSet::GetNextRecod( std::string & Error )
-	{
-		if ( 0 == __pQueryRes )
-		{
-			Error = "Error,__pQueryRes is not initialized!";
-			return false;
-		}
-
-		if ( ( __CurRow = mysql_fetch_row( __pQueryRes ) ) != NULL )
-		{
-			return true;
-		}
-		else
-		{
-			Error = "Error, failed to mysql_fetch_row!";
-			return false;
-		}
-
-		return true;
-	}
-
-	my_ulonglong CDBResultSet::GetRecordCount( std::string & Error )
-	{
-		if ( 0 == __pQueryRes )
-		{
-			Error = "Error,__pQueryRes is not initialized!";
-			return DB_ERR_QUERY_RES_NOT_INITED;
-		}
-
-		return mysql_num_rows( __pQueryRes );
-	}
-
-	bool CDBResultSet::__GetField( int fdIndex, char*& szValue, bool& IsNull, std::string& Error )
-	{
-		IsNull = false;
-
-		if ( 0 == __CurRow )
-		{
-			Error = "Error,__CurRow is not initialized!";
-			return false;
-		}
-
-		if ( fdIndex < 0 || fdIndex >= __FieldCount )
-		{
-			Error = "fdIndex is invalid!";
-			return false;
-		}
-
-		szValue = __CurRow[fdIndex];
-		if ( szValue == NULL || szValue[0] == 0)
-		{
-			IsNull = true;
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, int & value, std::string & Error )
-	{
-		value = 0;
-		char* pField = 0;
-		bool IsNull = false;
-        if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-        {
-            return false;
-        }
-
-        if ( !IsNull )
-        {
-        	value = atoi( pField );
-        }
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, unsigned int & value, std::string & Error )
-	{
-		value = 0;
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			value = atoi( pField );
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, long long & value, std::string & Error )
-	{
-		value = 0;
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			value = atoll(pField);
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, std::string & value, std::string & Error )
-	{
-		value = "";
-
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			value = pField;
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, char * value, int Length, std::string & Error )
-	{
-		memset( value, 0, Length );
-
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			strncpy( value, pField, Length );
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, bool & value, std::string & Error )
-	{
-		value = false;
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			value = atoi( pField );
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, float & value, std::string & Error )
-	{
-		value = 0.0;
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			value = atof( pField );
-		}
-
-		return true;
-    }
-
-	bool CDBResultSet::GetField( int fdIndex, double & value, std::string & Error )
-	{
-		value = 0.0;
-		char* pField = 0;
-		bool IsNull = false;
-		if (!__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			value = std::stod( pField );
-		}
-
-		return true;
-	}
-
-	bool CDBResultSet::GetField( int fdIndex, MYSQL_TIME & value, std::string & Error )
-	{
-		__DBHelper.InitMySQLTime( value );
-		char* pField = 0;
-		bool IsNull = false;
-		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
-		{
-			return false;
-		}
-
-		if ( !IsNull )
-		{
-			__DBHelper.String2DateTime( pField, value );
-		}
-
-		return true;
-	}
-
-	int CDBResultSet::GetFdIndexByName( const char * fdName, std::string & Error )
-	{
-		std::map<std::string,int>::iterator mit_fi;
-		mit_fi = __FNameIndexList.find( fdName );
-		if ( mit_fi != __FNameIndexList.end() )
-		{
-			return mit_fi->second;
-		}
-
-		Error = "Failed to find field: ";
-		Error += fdName;
-
-		return -1;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, int & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, long long & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, unsigned int & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, std::string & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, char * value, int Length, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Length, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, bool & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, float & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, double & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	bool CDBResultSet::GetField( const char * fdName, MYSQL_TIME & value, std::string & Error )
-	{
-		int fdIndex = GetFdIndexByName( fdName, Error );
-
-		if ( fdIndex >= 0 )
-		{
-			return GetField( fdIndex, value, Error );
-		}
-
-		return false;
-	}
-
-	int CDBResultSet::IsNull( int fdIndex, std::string& Error )
-	{
-		if (0 == __CurRow)
-		{
-			Error = "Error,__CurRow is not initialized!";
-			return -1;
-		}
-
-		if ( fdIndex < 0 || fdIndex >= __FieldCount )
-		{
-			Error = "fdIndex is invalid!";
-			return -1;
-		}
-
-		char* pField = __CurRow[fdIndex];
-		if ( pField == NULL || pField[0] == 0 )
-		{
-			return 1;
-		}
-
-		return 0;
-	}
-}
+#include "CDBResultSet.h"
+#include <string.h>
+
+namespace YADB
+{
+	CDBResultSet::CDBResultSet()
+	{
+		__pQueryRes  = 0;
+		__CurRow     = 0;
+		__FieldCount = 0;
+	}
+
+	CDBResultSet::~CDBResultSet()
+	{
+		Close();
+	}
+
+	void CDBResultSet::__BuildFNameIdxLst()
+	{
+		if (0 == __pQueryRes)
+		{
+			return;
+		}
+
+		for ( int i = 0; i < __FieldCount; i++ )
+		{
+			MYSQL_FIELD *pField = mysql_fetch_field_direct( __pQueryRes, i );
+			if ( pField == NULL )
+			{
+				continue;
+			}
+
+			__FNameIndexList.insert( std::make_pair( pField->name, i ) );
+		}
+	}
+
+	bool CDBResultSet::Bind( MYSQL_RES *pQueryRes, std::string& Error )
+	{
+		Close();
+
+		__pQueryRes = pQueryRes;
+		if ( __pQueryRes != 0 )
+		{
+			__FieldCount = mysql_num_fields( pQueryRes );
+		}
+		else
+		{
+			Error = "Error,pQueryRes is null!";
+			__FieldCount = 0;
+			return false;
+		}
+
+		__BuildFNameIdxLst();
+
+		return true;
+	}
+
+	void CDBResultSet::Close()
+	{
+		if ( 0 == __pQueryRes )
+		{
+			return;
+		}
+
+		mysql_free_result( __pQueryRes );
+		__pQueryRes  = 0;
+		__CurRow     = 0;
+		__FieldCount = 0;
+		__FNameIndexList.clear();
+	}
+
+	bool CDBResultSet::SeekData( my_ulonglong Offset, std::string& Error )
+	{
+		if ( 0 == __pQueryRes )
+		{
+			Error = "Error,__pQueryRes is not initialized!";
+			return false;
+		}
+
+		mysql_data_seek( __pQueryRes, Offset );
+
+		return true;
+	}
+
+	bool CDBResultSet::GetNextRecod( std::string & Error )
+	{
+		if ( 0 == __pQueryRes )
+		{
+			Error = "Error,__pQueryRes is not initialized!";
+			return false;
+		}
+
+		if ( ( __CurRow = mysql_fetch_row( __pQueryRes ) ) != NULL )
+		{
+			return true;
+		}
+		else
+		{
+			Error = "Error, failed to mysql_fetch_row!";
+			return false;
+		}
+
+		return true;
+	}
+
+	my_ulonglong CDBResultSet::GetRecordCount( std::string & Error )
+	{
+		if ( 0 == __pQueryRes )
+		{
+			Error = "Error,__pQueryRes is not initialized!";
+			return DB_ERR_QUERY_RES_NOT_INITED;
+		}
+
+		return mysql_num_rows( __pQueryRes );
+	}
+
+	bool CDBResultSet::__GetField( int fdIndex, char*& szValue, bool& IsNull, std::string& Error )
+	{
+		IsNull = false;
+
+		if ( 0 == __CurRow )
+		{
+			Error = "Error,__CurRow is not initialized!";
+			return false;
+		}
+
+		if ( fdIndex < 0 || fdIndex >= __FieldCount )
+		{
+			Error = "fdIndex is invalid!";
+			return false;
+		}
+
+		szValue = __CurRow[fdIndex];
+		if ( szValue == NULL || szValue[0] == 0)
+		{
+			IsNull = true;
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, int & value, std::string & Error )
+	{
+		value = 0;
+		char* pField = 0;
+		bool IsNull = false;
+        if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+        {
+            return false;
+        }
+
+        if ( !IsNull )
+        {
+        	value = atoi( pField );
+        }
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, unsigned int & value, std::string & Error )
+	{
+		value = 0;
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			value = atoi( pField );
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, long long & value, std::string & Error )
+	{
+		value = 0;
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			value = atoll(pField);
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, std::string & value, std::string & Error )
+	{
+		value = "";
+
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			value = pField;
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, char * value, int Length, std::string & Error )
+	{
+		memset( value, 0, Length );
+
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			strncpy( value, pField, Length );
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, bool & value, std::string & Error )
+	{
+		value = false;
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			value = atoi( pField );
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, float & value, std::string & Error )
+	{
+		value = 0.0;
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			value = atof( pField );
+		}
+
+		return true;
+    }
+
+	bool CDBResultSet::GetField( int fdIndex, double & value, std::string & Error )
+	{
+		value = 0.0;
+		char* pField = 0;
+		bool IsNull = false;
+		if (!__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			value = std::stod( pField );
+		}
+
+		return true;
+	}
+
+	bool CDBResultSet::GetField( int fdIndex, MYSQL_TIME & value, std::string & Error )
+	{
+		__DBHelper.InitMySQLTime( value );
+		char* pField = 0;
+		bool IsNull = false;
+		if ( !__GetField( fdIndex, pField, IsNull, Error ) )
+		{
+			return false;
+		}
+
+		if ( !IsNull )
+		{
+			__DBHelper.String2DateTime( pField, value );
+		}
+
+		return true;
+	}
+
+	int CDBResultSet::GetFdIndexByName( const char * fdName, std::string & Error )
+	{
+		std::map<std::string,int>::iterator mit_fi;
+		mit_fi = __FNameIndexList.find( fdName );
+		if ( mit_fi != __FNameIndexList.end() )
+		{
+			return mit_fi->second;
+		}
+
+		Error = "Failed to find field: ";
+		Error += fdName;
+
+		return -1;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, int & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, long long & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, unsigned int & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, std::string & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, char * value, int Length, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Length, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, bool & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, float & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, double & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	bool CDBResultSet::GetField( const char * fdName, MYSQL_TIME & value, std::string & Error )
+	{
+		int fdIndex = GetFdIndexByName( fdName, Error );
+
+		if ( fdIndex >= 0 )
+		{
+			return GetField( fdIndex, value, Error );
+		}
+
+		return false;
+	}
+
+	int CDBResultSet::IsNull( int fdIndex, std::string& Error )
+	{
+		if (0 == __CurRow)
+		{
+			Error = "Error,__CurRow is not initialized!";
+			return -1;
+		}
+
+		if ( fdIndex < 0 || fdIndex >= __FieldCount )
+		{
+			Error = "fdIndex is invalid!";
+			return -1;
+		}
+
+		char* pField = __CurRow[fdIndex];
+		if ( pField == NULL || pField[0] == 0 )
+		{
+			return 1;
+		}
+
+		return 0;
+	}
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 573 - 573
db_api/CDBResultSet.h


+ 11 - 0
db_api/CDBSingletonDefine.h

@@ -0,0 +1,11 @@
+#pragma once
+
+//数据单实例创建
+
+#include <boost/serialization/singleton.hpp>
+#include "CDBConnPool.h"
+
+//单件相关定义
+typedef boost::serialization::singleton<YADB::CDBConnPool> singleton_CDBConnPool;
+#define sDBConnPool singleton_CDBConnPool::get_mutable_instance()
+#define sDBConnPool_const singleton_CDBConnPool::get_const_instance()

+ 1 - 1
depcomp

@@ -1 +1 @@
-/usr/share/automake-1.12/depcomp
+/usr/share/automake-1.13/depcomp

+ 1 - 1
his_location.h

@@ -4,7 +4,7 @@
 #include <queue>
 #include "point.h"
 #include "log.h"
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 //速度
 //区域 地图变换
 //运动方向

+ 1 - 1
install-sh

@@ -1 +1 @@
-/usr/share/automake-1.12/install-sh
+/usr/share/automake-1.13/install-sh

+ 1 - 1
landmark.cpp

@@ -1,6 +1,6 @@
 #include "landmark.h"
 #include <cfloat>
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include "log.h"
 
 

+ 22 - 20
main.cpp

@@ -1,7 +1,7 @@
 #include <ev++.h>
 #include <log.h>
 #include <net-service.h>
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include "websocket/wsClientMgr.h"
 #include "websocket/wsTimerThread.h"
 
@@ -18,6 +18,7 @@
 
 #include <config_file.h>
 #include "three_rates.h"
+#include "main_test.h"
 
 config_file config;
 static void handlereader(uint32_t readerid,bool duration,uint32_t t)
@@ -37,9 +38,9 @@ struct Init_Setting
 
         YADB::_DB_POOL_SETTING_ DBSetting;
 
-        DBSetting.Host = config.get("db.host","192.168.0.102");
+        DBSetting.Host = config.get("db.host","127.0.0.1");
         DBSetting.User = config.get("db.user","root");
-        DBSetting.PWD = config.get("db.passwd","root");
+        DBSetting.PWD = config.get("db.passwd","123456");
         DBSetting.DBName = config.get("db.dbname","yaxt");
         DBSetting.CharSet = config.get("db.charset","utf8");
         DBSetting.TimeOut = config.get("db.conn_timeout",5);
@@ -53,22 +54,22 @@ struct Init_Setting
         area_list::instance()->init_from_db();
         std_info("here....");
         //test
-        point pt(3348,100);
-        int id = area_list::instance()->get_area(pt)->id();
-        std_info("test area:%d",id);
+        //point pt(3348,100);
+        //int id = area_list::instance()->get_area(pt)->id();
+        //std_info("test area:%d",id);
 
         Landmark_list::instance()->init_from_db();
-        auto a = Landmark_list::instance()->get(5,id,pt);
-        std_info("test landmark:id:%d,dir:%d,dis:%.2f",std::get<0>(a),std::get<1>(a),std::get<2>(a));
+        //auto a = Landmark_list::instance()->get(5,id,pt);
+        //std_info("test landmark:id:%d,dir:%d,dis:%.2f",std::get<0>(a),std::get<1>(a),std::get<2>(a));
 
         special_area_list::instance()->init_from_db();
-        auto s = special_area_list::instance()->get_special_id(1013,point(4727,-254),2);
-        std_info("test special_area:%d",s);
+        //auto s = special_area_list::instance()->get_special_id(1013,point(4727,-254),2);
+        //std_info("test special_area:%d",s);
 
         card_list::instance()->load_his_card_postion_from_db();
         event_list::instance()->load_his_data_from_db();
-		db_para dp;	
-
+		
+        db_para dp;	
         dp.Host=DBSetting.Host;
         dp.User=DBSetting.User;
         dp.PWD=DBSetting.PWD ;
@@ -77,6 +78,8 @@ struct Init_Setting
         dp.TimeOut=DBSetting.TimeOut;
         dp.PoolSize=DBSetting.PoolSize;
 		init_three_rates(dp);
+
+        printf("Init_Setting::init  Success. \n" );
     }
 	void init_three_rates(const db_para& dbs)
 	{
@@ -156,13 +159,6 @@ void usage(char ** argv)
 
 }
 
-void test_find_path(const point&p1,const point&p2)
-{
-	printf("\nfind-path:  from=(%.3lf,%.3lf),to=(%.3lf,%.3lf)\n",p1.x,p1.y,p2.x,p2.y);
-	std::vector<point> rc=card_path::inst().find_path(p1,p2);
-	for(uint32_t i=0;i<rc.size();i++)
-		printf("x=%.3lf,y=%.3lf\n",rc[i].x,rc[i].y);
-}
 int main(int argc ,char * argv[])
 {
     if(argc >1)
@@ -184,10 +180,16 @@ int main(int argc ,char * argv[])
     module_mgr::start();
     atexit(&cleanup);
 
-
+    printf("\nservice_handle::instance(&mh)->run(%d); \n",4000);
     net_service mh;
     int port=config.get("service.port",4000);
     service_handle::instance(&mh)->run(port);
+    
+    sDBConnPool.Close();
+    card_list::instance()->onStopRun();
+
+    sleep(1);
+    printf("YA-SERV Server Exit ...\n");
 
     return 0;
 }

+ 87 - 0
main_test.h

@@ -0,0 +1,87 @@
+#pragma once 
+
+#include "db_api/CDBSingletonDefine.h"
+#include"module_service/module_area.h"
+#include"module_service/module_mgr.h"
+
+void test_find_path(const point&p1,const point&p2)
+{
+	printf("\nfind-path:  from=(%.3lf,%.3lf),to=(%.3lf,%.3lf)\n",p1.x,p1.y,p2.x,p2.y);
+	std::vector<point> rc=card_path::inst().find_path(p1,p2);
+	for(uint32_t i=0;i<rc.size();i++)
+		printf("x=%.3lf,y=%.3lf\n",rc[i].x,rc[i].y);
+}
+
+struct test_Sa{
+    static void test_savedata2db(void * p)
+    {
+        while(true)
+        {
+            std::string sql = "CALL add_att_staff(0010000002323, 2323, '2018-12-14 14:00:14', '2018-12-14 14:00:14', 0, 0, 0.000);";
+            sDBConnPool.PushAsync(sql.c_str());
+            //boost::this_thread::sleep( boost::posix_time::microseconds( 10000 ) );
+            usleep(1000*1000);
+        }
+    }
+
+    static void test_query(void *p)
+    {
+        std::string sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
+                            ve.dept_id, ve.group_id, v.vehicle_type_id, vt.vehicle_level_id, \
+                            vt.is_railroad AS vt_is_railroad,ve.need_display ,ve.power_alarm,\
+                            vt.vehicle_category_id,v.bigger_car_flag,vc.over_speed \
+                            FROM dat_vehicle_extend ve \
+                            LEFT JOIN dat_vehicle v ON ve.vehicle_id = v.vehicle_id \
+                            LEFT JOIN dat_card c ON ve.card_id = c.card_id \
+                            LEFT JOIN dat_dept d ON ve.dept_id = d.dept_id \
+                            LEFT JOIN dat_group g ON ve.group_id = g.group_id \
+                            LEFT JOIN dat_vehicle_type vt ON v.vehicle_type_id = vt.vehicle_type_id \
+                            LEFT JOIN dat_vehicle_category vc ON vc.vehicle_category_id = vt.vehicle_category_id \
+                            WHERE c.state_id = 0";
+
+        std::string Error;
+        YADB::CDBResultSet DBRes;
+        while(true)
+        {
+            if (!sDBConnPool.Query(sql.c_str(),DBRes,Error))
+            {
+                printf(" Error = %s \n",Error.c_str());
+            }
+            usleep(10);
+        }
+    }
+
+    static void Test_JsonDataSend(void * p)
+    {
+        std::string text = "";
+        FILE * pfile = fopen("message_error.json","r");
+        if ( NULL != pfile)
+        {
+            
+            char p[10240] = {0};
+            while(!feof(pfile))
+            {
+                memset(p,0,sizeof(p));
+                fread(p,1,sizeof(p) - 1,pfile);
+                text += std::string(p);
+            }
+            fclose(pfile); 
+        }
+        int count = 0;
+        while(true)
+        {
+            swsClientMgr.send(JSON_CMD_VALUE_PUSH,text);
+            usleep(1000*1000*2);
+            printf("WSClient Send DataLen=%d count=%d \n",(int)text.length(),count++);
+        }
+    }
+};
+
+
+void test_createthread()
+{
+    for (int i = 1 ; i < 1 ; i++)
+    {
+        new  std::thread( std::bind( &test_Sa::Test_JsonDataSend, &i ) );
+    }
+}

+ 1 - 1
mine.h

@@ -8,7 +8,7 @@
  */
 
 #include <unordered_map>
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include <log.h>
 #include "common.h"
 struct mine_tool

+ 1 - 1
missing

@@ -1 +1 @@
-/usr/share/automake-1.12/missing
+/usr/share/automake-1.13/missing

+ 15 - 12
module_service/module_meta_date_changed.cpp

@@ -4,43 +4,46 @@
 #include"ant.h"
 
 
-void module_meta_date_changed::deal_call_edit_vehicle(int id, EDIT_TYPE_ID edit_type_id)
+void module_meta_date_changed::deal_call_edit_vehicle(int64_t id64, EDIT_TYPE_ID edit_type_id)
 {
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
     {
-        card_list::instance()->init_vehicle(id);
+        card_list::instance()->init_vehicle(id64);
     }
     else if(ET_DELETE == edit_type_id)
     {
-        remove_card(static_cast<uint32_t>(id), CT_VEHICLE);
+        auto str = tool_other::to13str(id64);
+
+        remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
     }
 }
 
-void module_meta_date_changed::deal_call_edit_staff(int id, EDIT_TYPE_ID edit_type_id)
+void module_meta_date_changed::deal_call_edit_staff(int64_t id64, EDIT_TYPE_ID edit_type_id)
 {
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
     {
-        card_list::instance()->init_staffer(id);
+        card_list::instance()->init_staffer(id64);
     }
     else if(ET_DELETE == edit_type_id)
     {
-        remove_card(static_cast<uint32_t>(id), CT_PERSON);
+        auto str = tool_other::to13str(id64);
+
+        remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
     }
 }
 
-void module_meta_date_changed::deal_call_edit_card(int id64, EDIT_TYPE_ID edit_type_id)
+void module_meta_date_changed::deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id)
 {
     std::string card_id64_str = tool_other::to13str(static_cast<uint64_t>(id64));
     int type = tool_other::id64_to_type(card_id64_str);
-    int id = static_cast<int32_t>(tool_other::id64_to_id(card_id64_str));
 
-    if(CT_PERSON==type)
+    if(tool_other::is_person(type))
     {
-        deal_call_edit_staff(id, edit_type_id);
+        deal_call_edit_staff(id64, edit_type_id);
     }
-    else if(CT_VEHICLE==type)
+    else if(tool_other::is_vehicle(type))
     {
-        deal_call_edit_vehicle(id, edit_type_id);
+        deal_call_edit_vehicle(id64, edit_type_id);
     }
     else
     {

+ 6 - 4
module_service/module_meta_date_changed.h

@@ -44,7 +44,7 @@ public:
 
         std_debug("基础数据 receive meta_data_changed: %s", name.c_str());
 
-        int id=-1;
+        int64_t id=-1;
         tool_map::try_get_value(id, JSON_KEY_ID, data);
 
         std::string op_type="";
@@ -148,12 +148,14 @@ public:
     }
 
 private:
-    void deal_call_edit_vehicle(int id, EDIT_TYPE_ID edit_type_id);
+    ///id64格式为:10000001016
+    void deal_call_edit_vehicle(int64_t id64, EDIT_TYPE_ID edit_type_id);
 
-    void deal_call_edit_staff(int id, EDIT_TYPE_ID edit_type_id);
+    ///id64格式为:10000001016
+    void deal_call_edit_staff(int64_t id64, EDIT_TYPE_ID edit_type_id);
 
     ///id64格式为10000006666
-    void deal_call_edit_card(int id64, EDIT_TYPE_ID edit_type_id);
+    void deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id);
 
     void deal_call_edit_reader(int id, EDIT_TYPE_ID edit_type_id);
 

+ 1 - 1
special_area.cpp

@@ -1,6 +1,6 @@
 #include "special_area.h"
 
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include "log.h"
 
 special_area_list * special_area_list::instance()

+ 1 - 1
ya_event.h

@@ -12,7 +12,7 @@
 #include<memory>
 #include"write-copy.h"
 #include"log.h"
-#include "db_api/CDBConnPool.h"
+#include "db_api/CDBSingletonDefine.h"
 #include"card.h"
 #include"common_tool.h"