老系统对接

This commit is contained in:
2018-07-12 14:08:55 +08:00
commit 5f41fe5df1
420 changed files with 50883 additions and 0 deletions

46
.classpath Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="properties"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/activation-1.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/baiduDecoder.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-beanutils-1.7.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-codec-1.5.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-dbutils-1.6.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-digester-1.6.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-fileupload-1.3.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-httpclient-3.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-io-2.4.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-lang-2.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-logging-1.0.4.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/dom4j-1.5-rc1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/fastjson-1.1.23.jar" sourcepath="E:/SVNCSWorkSpace/SinoGYS/webapp/WEB-INF/lib/fastjson-1.1.23.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/GPSconvert.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/httpclient-4.5.2.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/httpclient-cache-4.1.2.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/httpcore-4.4.4.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/httpmime-4.1.2.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jaxen-1.1-beta-9.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jdom-1.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jdom.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jsmartcom_zh_CN.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jstl-1.2.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jxl-2.6.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/log4j-1.2.8.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/ojdbc14.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/poi-3.9-20121203.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/poi-ooxml-3.9-20121203.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/poi-ooxml-schemas-3.9-20121203.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/proxool-0.9.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/proxool-cglib.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/servlet-api.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/stax-api-1.0.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/upload.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/xmlbeans-2.3.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/xstream-1.3.1-sae-liufeng.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_43"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
<classpathentry kind="output" path="webapp/WEB-INF/classes"/>
</classpath>

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SinoGYS</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

16
.settings/.jsdtscope Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="">
<attributes>
<attribute name="provider" value="org.eclipse.wst.jsdt.web.core.internal.project.ModuleSourcePathProvider"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@ -0,0 +1,3 @@
eclipse.preferences.version=1
validator.Checked=/,webapp/js/static/jquery.min.js
validator.Unchecked=webapp/js

View File

@ -0,0 +1,7 @@
eclipse.preferences.version=1
encoding//src/com/sino/weixin/oauth/util/HttpsUtil.java=UTF-8
encoding//src/com/sino/weixin/util/MapUtil.java=UTF-8
encoding//webapp/js/jquery-weui.js=UTF-8
encoding//webapp/js/jquery-weui.min.js=UTF-8
encoding//webapp/js/static=UTF-8
encoding//webapp/supplier/uploadPhoto.jsp=UTF-8

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

View File

@ -0,0 +1 @@
Window

BIN
assets/newArea.xlsx Normal file

Binary file not shown.

View File

@ -0,0 +1,9 @@
runmode=product
#runmode=product ,test
sms.server.ip=222.73.237.104
sms.server.port=95
webserver.url=http://222.73.237.104/services/RentService
dbServer.id=SERVER_TANWAY

View File

@ -0,0 +1,22 @@
jdbc-0.usepool=true
jdbc-0.proxool.alias=property-default
jdbc-0.proxool.driver-class=com.mysql.jdbc.Driver
#jdbc-0.proxool.driver-url=jdbc:mysql://175.102.6.165:10022/weixin?useUnicode=true&characterEncoding=utf8
#jdbc-0.user=root
#jdbc-0.password=sino#308
jdbc-0.proxool.driver-url=jdbc:mysql://180.166.184.66:3306/weixin?useUnicode=true&characterEncoding=utf8
jdbc-0.user=root
jdbc-0.password=gkxl650
jdbc-0.proxool.maximum-connection-count=300
jdbc-0.proxool.minimum-connection-count=10
##jdbc-0.proxool.maximum-active-time=600000
jdbc-0.proxool.simultaneous-build-throttle=150
jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE

View File

@ -0,0 +1,17 @@
log4j.rootLogger=info, stdout, fileLogger
# stdout is set to be a ConsoleAppender.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# stdout uses PatternLayout.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c %x - %m%n
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# fileLogger
log4j.appender.fileLogger=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileLogger.File=/data/SinoGYS/bin/webapp.log
log4j.appender.fileLogger.DatePattern='.'yyyy-MM-dd
log4j.appender.fileLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.fileLogger.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %x - %m%n

View File

@ -0,0 +1,2 @@
version=1.0.1
apk_url=http\://www.sino-assist.com\:8090//update/dealerApp/CarRescueDealer.apk

View File

@ -0,0 +1,411 @@
package com.sino.publicclass.base;
import java.sql.Connection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sino.publicclass.common.HttpDataParser;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.publicclass.util.StaticVar;
public abstract class BaseAction {
public BaseAction() {
log = LogFactory.getLog(getClass().getName());
}
private Log log = null;
private String failureMsg = StaticVar.NO_MESSAGE;
private String successMsg = StaticVar.NO_MESSAGE;
private String nextPage = "no";
private Connection conn = null;
private boolean isConnection = false;
private boolean isAutoCommit = false;
private boolean isTransition = false;
private boolean isRollback = false;
private String cmd = "";
private String transitionURI = null;
private Memory memory = new Memory();
public HttpServletRequest request;
public HttpServletResponse response;
private HttpSession session = null;
private boolean isNext = true;
/**
* service <20><><EFBFBD><EFBFBD>ע<EFBFBD>
*/
public void service(HttpServletRequest req, HttpServletResponse res) throws Exception {
try {
request = req;
response = res;
// init();
if (userVaildate(req,res)) {
performTask();
}
if (isNext) {
saveMemory();
nextPage();
}
} catch (Exception exs) {
this.isRollback = true;
throw exs;
} finally {
try {
closeConnection();
} catch (Exception ex) {
throw new CException("closeConnection() error");
}
}
req.setAttribute("failureMsg", failureMsg);
req.setAttribute("successMsg", successMsg);
}
/*public void init() throws CException {
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (PageTools.validateMemory(name)) {
this.memory.put(name, getParameter(name));
}
}
}*/
public void performTask() throws CException {
String CMD = "";
try {
CMD = readCMD();
log.info("method:" + CMD + "()");
this.getClass().getMethod(CMD, null).invoke(this, null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public String[] getParameterValues(String parameterName) {
return request.getParameterValues(parameterName);
}
public String getParameter(String parameterName, String defaultValue) {
String paramValue = getParameter(parameterName);
// <20><><EFBFBD><EFBFBD><EFBFBD>޸ñ<DEB8><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱʡֵ
if (paramValue == null) {
paramValue = defaultValue;
}
return paramValue.trim();
}
public String getParameter(String parameterName) {
String paramValue = null;
String[] parameterValues = getParameterValues(parameterName);
if (parameterValues != null) {
paramValue = parameterValues[0];
}
return paramValue;
}
public String getParameter(String parameterName, String defaultValue, boolean isMemory) {
String value = getParameter(parameterName, defaultValue);
if (isMemory) {
setMemory(parameterName, value);
} else {
removeMemory(parameterName);
}
return value;
}
/**
* @param parameterName
* String
* @param defaultValue
* int <20>Ҳ<EFBFBD><D2B2><EFBFBD>parameterName<6D><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>defaultValue
* @param defaultValue2
* int <20>ҵ<EFBFBD>parameterName<6D><65><EFBFBD><EFBFBD>ֵΪ""<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>defaultValue2
* @return int
*/
public int getParameter(String parameterName, int defaultValue, int defaultValue2) throws CException {
String paramValue = getParameter(parameterName, String.valueOf(defaultValue));
int value = 0;
if (paramValue.equals("")) {
value = defaultValue2;
} else {
try {
value = Integer.parseInt(paramValue);
} catch (Exception ex) {
throw new CException("[" + parameterName + "] isn't int type!");
}
}
return value;
}
public int getParameter(String parameterName, int defaultValue, int defaultValue2, boolean isMemory) throws CException {
String paramValue = getParameter(parameterName, String.valueOf(defaultValue));
int value = 0;
if (paramValue.equals("")) {
value = defaultValue2;
} else {
try {
value = Integer.parseInt(paramValue);
} catch (Exception ex) {
throw new CException("[" + parameterName + "] isn't int type!");
}
}
if (isMemory) {
setMemory(parameterName, String.valueOf(value));
} else {
removeMemory(parameterName);
}
return value;
}
public int getParameter(String parameterName, int defaultValue) throws CException {
return getParameter(parameterName, defaultValue, 0);
}
public int getParameter(String parameterName, int defaultValue, boolean isMemory) throws CException {
return getParameter(parameterName, defaultValue, 0, isMemory);
}
public String getParameter(HttpDataParser parser, String parameterName, String defaultValue) {
String paramValue = parser.getParameterValue(parameterName);
if (paramValue == null) {
paramValue = defaultValue;
}
return paramValue;
}
public int getParameter(HttpDataParser parser, String parameterName, int defaultValue) {
String paramValue = parser.getParameterValue(parameterName);
if (paramValue == null) {
return defaultValue;
}
if (paramValue.equals("")) {
return defaultValue;
}
return Integer.parseInt(paramValue.trim());
}
private String readCMD() throws CException {
String cmdstr = getParameter("CMD", "list");
return cmdstr;
}
private boolean userVaildate(HttpServletRequest req, HttpServletResponse res) throws Exception {
boolean login = false;
String cmd = getParameter("CMD", "");
if (",queryAllPhotos,deleteSelectedPhoto,login,sendInformation,vehicleHistoryOrder,getAllSuppliersByLoginName,getManagerByRescueCode,getProvinceByLoginName,getAllCityByParentid,getSuppliersByParentid,findCurrentOrderDetail,vehicleChanged1,queryVehicleOrder,findAccountOrder,queryOrder,sendJoinUsMail,connection,connectionImg,signature,smsSend,verify,upload,updateVehicle,modifyIdentity,register,regist,choosedVehicleName,checkLoginName,acceptOrRecvOrder,queryRescueVehicle,managerRegist,queryCurrentFlow,updateSupplyOrderState,vehicleCurrentOrderDetail,finishedOrderDetail,arriveAgoCheck,distributeOrder,updateCompanyNotice,updateVehicleNotice,changeDistributeOrder,changedVehicle,vehicleChanged,getVehicles,updateOrderState,updateStatus,uploadOrderMileage,uploadPhoto,showOrderDetail,companyHistoryOrder,orderCount,list,getOrgList,query,find,update,cancle,getProvince,getAreaByCode,getLocal,getBrand,getOrgById,findChild,buy,".indexOf("," + cmd + ",") >= 0) {
login = true;
}else if(req.getServletPath().indexOf("callCenter")>=0){
login = true;
}else {
session = request.getSession();
}
if (!login) {
setNextPage("/jsp/pub/exit.jsp");
setFailureMsg("<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱ, <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>˳<EFBFBD>ϵͳ, <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>δ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>½, <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>½.");
}
return login;
}
protected void nextPage() throws CException {
if (this.isTransition) {
transition(cmd);
} else if (this.nextPage.equals("no")) {
throw new CException("no config nextpage!");
} else if (this.nextPage.equals("need_not_nextpage")) {
log.info("don't need nextpage");
}
}
private void transition(String cmdstr) throws CException {
if (transitionURI == null) {
request.setAttribute("transitionURI", request.getRequestURI().toString());
} else {
request.setAttribute("transitionURI", transitionURI);
}
request.setAttribute("transitionCMD", cmdstr);
}
public Connection getConnection(boolean AutoCommit) throws CException {
try {
if (!isConnection) {
this.conn = ConnectionPool.getConnection();
}
this.conn.setAutoCommit(AutoCommit);
this.isConnection = true;
this.isAutoCommit = AutoCommit;
} catch (Exception ex) {
throw new CException(ex.getMessage());
}
return this.conn;
}
public Connection getConnection() throws Exception {
if (!isConnection) {
getConnection(true);
}
return this.conn;
}
public Connection getConnection_comm() throws CException {
try {
if (!isConnection) {
this.conn = ConnectionPool.getConnection_comm();
}
this.conn.setAutoCommit(true);
this.isConnection = true;
this.isAutoCommit = true;
} catch (Exception ex) {
throw new CException(ex.getMessage());
}
return this.conn;
}
public void closeConnection() throws Exception {
if (this.isConnection) {
if (!this.isAutoCommit) {
if (this.isRollback) {
log.info("-----------conn.rollback()");
conn.rollback();
} else {
log.info("-----------conn.commit()");
conn.commit();
}
}
if (this.conn != null) {
conn.close();
}
this.isConnection = false;
}
}
private void saveMemory() {
request.setAttribute("MEMOTY", this.memory);
}
public void setIsAutoCommit(boolean bool) {
this.isAutoCommit = bool;
}
public void setNextPage(String str) {
this.nextPage = str;
}
public void setTransition(String nextCMD) throws CException {
this.isTransition = true;
this.cmd = nextCMD;
}
public void setTransition(String URI, String nextCMD) throws CException {
this.transitionURI = URI;
this.isTransition = true;
this.cmd = nextCMD;
}
public void setTransition(boolean bool, String nextCMD) throws CException {
getConnection(bool);
this.isTransition = true;
this.cmd = nextCMD;
}
public void logInfo(String value) {
log.info(value);
}
public void logDebug(String value) {
log.debug(value);
}
public void logFatal(String value) {
log.fatal(value);
}
public void logError(String value) {
log.error(value);
}
public void setMemory(String key, String value) {
this.memory.put(key, value);
}
public void setMemory(String key, Object value) {
this.memory.put(key, value);
}
public void removeMemory(String key) {
this.memory.remove(key);
}
public void setFailureMsg(String str) {
this.failureMsg = str;
this.memory.put("failureMsg", str);
}
public void setSuccessMsg(String str) {
this.successMsg = str;
this.memory.put("successMsg", str);
}
public void setAttribute(String name, Object o) {
request.setAttribute(name, o);
}
public String getNextPage() {
return nextPage;
}
public boolean isAutoCommit() {
return isAutoCommit;
}
public boolean isTransition() {
return isTransition;
}
public void setRollback(boolean bool) {
this.isRollback = bool;
}
/**
* @param isNext
* Ҫ<><D2AA><EFBFBD>õ<EFBFBD> isNext<78><74>
*/
public void setNext(boolean bool) {
this.isNext = bool;
}
/**
* @return <20><><EFBFBD><EFBFBD> isNext<78><74>
*/
public boolean isNext() {
return isNext;
}
public Memory getMemory() {
return memory;
}
/**
* <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>sql
* @param contractCompanyFieldName <20><>ͬ<EFBFBD>ֶ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),<2C>磺C.CODE; null<6C><6C><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param rescueCompanyFieldName <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),<2C>磺RC.CODE; null<6C><6C><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return Ȩ<>޹<EFBFBD><DEB9><EFBFBD>sql<71><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(); <20><>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7>ǿո<C7BF>;
* <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>or<6F><72>ϵ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊһ<CEAA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶζ<D6B6>Ϊnull<6C><6C>ϵͳ<CFB5><CDB3>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>޹<EFBFBD><DEB9>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD> (1=1)
*/
/*
public String getDataPermissionSql(String contractCompanyFieldName, String rescueCompanyFieldName){
if (null != user){
return BaseBean.getDataPermissionSql(user.getId(), user.getPermission_flag(), contractCompanyFieldName, rescueCompanyFieldName);
} else {
return BaseBean.getDataPermissionSql(null, 0, contractCompanyFieldName, rescueCompanyFieldName);
}
}
*/
}

View File

@ -0,0 +1,702 @@
package com.sino.publicclass.base;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sino.publicclass.util.StringTools;
public abstract class BaseBean {
protected static final String SELECT = " SELECT ";
protected static final String SELECT_ALL_FROM = " SELECT * FROM ";
protected static final String DELETE_FROM = " DELETE FROM ";
protected static final String UPDATE = " UPDATE ";
protected static final String ALL = " * ";
protected static final String FROM = " FROM ";
protected static final String WHERE = " WHERE ";
protected static final String ROWNUM = " ROWNUM ";
protected static final String BETWEEN = " BETWEEN ";
protected static final String SET = " SET ";
protected static final String DISTINCT = " DISTINCT ";
protected static final String EQ = " = ";
protected static final String LT = " < ";
protected static final String LE = " <= ";
protected static final String GT = " > ";
protected static final String GE = " >= ";
protected static final String NE = " <> ";
protected static final String LIKE = " LIKE ";
protected static final String AND = " AND ";
protected static final String OR = " OR ";
protected static final String AS = " AS ";
protected static final String IN = " IN ";
protected static final String NOTIN = " NOT IN ";
protected static final String ORDERSIBLINGSBY = " ORDER SIBLINGS BY ";
protected static final String ORDERBY = " ORDER BY ";
protected static final String STARTWITH = " START WITH ";
protected static final String CONNECTBY = " CONNECT BY ";
protected static final String PRIOR = " PRIOR ";
protected static final String GROUPBY = " GROUP BY ";
protected static final String DESC = " DESC ";
protected static final String ASC = " ASC ";
protected static final String C = " , ";
protected static final String JOIN = "(+)";
// public static String SEQUENCENAME = "";
// public static String NEXTVAL = "";
// protected PrivControl privControl = PrivControl.getInstance();
protected ResultSet result = null;
private Statement st = null;
private Connection connection = null;
protected List resultList = null;
protected BaseBean(Connection curConn) {
this.connection = curConn;
}
protected final Log log = LogFactory.getLog(getClass().getName());
protected String getLocalString(String columnName) throws SQLException {
String value = resultGet(columnName);
if (value == null) {
value = "";
} else if (value.equals(null)) {
value = "";
}
return value;
}
protected String getString(String columnName) throws SQLException {
String value = resultGet(columnName);
if (value == null) {
value = "";
} else if (value.equals(null)) {
value = "";
}
return StringTools.convertForHtml(value);
}
protected int getInt(String columnName) throws SQLException {
String value = resultGet(columnName);
if (value == null) {
return 0;
} else if (value.equals(null)) {
return 0;
}
return Integer.parseInt(value);
}
protected long getLong(String columnName) throws SQLException {
String value = resultGet(columnName);
if (value == null) {
return 0;
} else if (value.equals(null)) {
return 0;
}
return Long.parseLong(value);
}
protected double getDouble(String columnName) throws SQLException {
String value = resultGet(columnName);
if (value == null) {
return 0;
} else if (value.equals(null)) {
return 0;
}
return Double.parseDouble(value);
}
protected String getDate10(String columnName) throws SQLException {
Date temp = this.result.getDate(columnName);
if (temp == null) {
return "";
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return formatter.format(temp);
}
protected String getDate16(String columnName) throws SQLException {
Date temp = this.result.getTimestamp(columnName);
if (temp == null) {
return "";
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return formatter.format(temp);
}
protected String getStringFromTimestamp(String columnName)
throws SQLException {
Date temp = this.result.getTimestamp(columnName);
if (temp == null) {
return "";
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
return formatter.format(temp);
}
protected Date getDate(String columnName) throws SQLException {
Date temp = this.result.getTimestamp(columnName);
return temp;
}
private String resultGet(String columnName) throws SQLException {
String value = "";
try {
value = this.result.getString(columnName);
} catch (Exception ex) {
String ems = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>columnName<EFBFBD><EFBFBD>" + columnName;
log.error(ems);
throw new SQLException(ems);
}
return value;
}
protected int executeUpdate(String strSQL, boolean outprt)
throws CException {
int count = 0;
try {
st = createStatement();
// if (outprt)
// log.info(strSQL);
st.executeUpdate(strSQL);
count = st.getUpdateCount();
} catch (Exception e) {
// log.error("", e);
if (e.getMessage().indexOf("ORA-02289") >= 0) {
// createSequence();
executeUpdate(strSQL, outprt);
return count;
}
if (!outprt)
log.error(strSQL);
throw new CException("<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>޸<EFBFBD>û<EFBFBD>гɹ<EFBFBD>," + e.getMessage());
} finally {
close();
}
return count;
}
public long getSequence() throws CException {
String sql = "SELECT " + getNextVal() + " FROM DUAL";
return findCount(sql);
}
public long getSequence(String trigger) throws CException {
String sql = "SELECT " + trigger + ".NEXTVAL" + " FROM DUAL";
return findCount(sql);
}
/*public void createSequence() throws CException {
if (getSequenceName().length() == 0)
throw new CException(" SEQUENCENAME is no define");
String sql = "CREATE SEQUENCE " + getSequenceName()
+ " INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE CACHE 10 ";
executeUpdate(sql, false);
}*/
protected abstract String getTableName();
protected String getSequenceName() {
return "SEQ_" + getTableName();
}
protected String getNextVal() {
return "SEQ_" + getTableName() + ".NEXTVAL";
}
protected int update(String strSQL) throws CException {
log.info("==================<3D><><EFBFBD>빩Ӧ<EBB9A9>̵<EFBFBD><CCB5>ȱ<EFBFBD>"+strSQL);
int count = executeUpdate(strSQL, true);
return count;
}
protected void update(String strSQL, boolean outpr) throws CException {
executeUpdate(strSQL, outpr);
}
protected void executeQuery(String strSQL) throws CException {
try {
st = createStatement();
long start = System.currentTimeMillis();
this.result = st.executeQuery(strSQL);
// log.info(" query time=" + (System.currentTimeMillis() - start));
} catch (Exception ex) {
if (ex.getMessage().indexOf("ORA-02289") >= 0) {
// createSequence();
executeQuery(strSQL);
System.err.println("<EFBFBD><EFBFBD>ѯ<EFBFBD>ɹ<EFBFBD>12323432132342");
return;
}
// log.error("", ex);
throw new CException("<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD>ѯû<EFBFBD>гɹ<EFBFBD>" + ex.getMessage());
}
}
protected void executeUpdate(String strSQL) throws CException {
try {
st = createStatement();
int result1 = st.executeUpdate(strSQL);
if (result1 > 0) {
executeUpdate(strSQL);
System.err.println("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>12323432132342");
return;
}
} catch (Exception ex) {
throw new CException("<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>ɾ<EFBFBD><EFBFBD>û<EFBFBD>гɹ<EFBFBD>" + ex.getMessage());
}
}
protected List findAll(String sql) throws CException {
resultList = new ArrayList();
try {
/*log.info(sql);*/
executeQuery(sql);
resultList = listAdaptor();
} catch (Exception ex) {
throw new CException(ex.getMessage());
} finally {
close();
}
return resultList;
}
protected List findAll(String sql, String resultAdaptorMode)
throws CException {
resultList = new ArrayList();
try {
// log.info(sql);
executeQuery(sql);
resultList = listAdaptor(resultAdaptorMode);
} catch (Exception ex) {
throw new CException(ex.getMessage());
} finally {
close();
}
return resultList;
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
protected boolean deleteOne(String sql) throws CException{
log.info(sql+"ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʲô");
executeUpdate(sql);
return true;
}
protected Object findOne(String sql) throws CException {
return findOne(sql, true);
}
protected Object findOne(String sql, boolean outpr) throws CException {
Object obj = null;
// if (outpr)
log.info(sql);
executeQuery(sql);
try {
if (this.result.next()) {
obj = resultAdaptor();
}
} catch (Exception ex) {
throw new CException(ex.getMessage());
}
close();
return obj;
}
protected Object findOne(String sql, String resultAdaptorMode)
throws CException {
Object obj = null;
log.info(sql);
executeQuery(sql);
try {
if (this.result.next()) {
obj = this.getClass().getMethod(resultAdaptorMode, null)
.invoke(this, null);
}
} catch (Exception ex) {
throw new CException(ex.getMessage());
}
close();
return obj;
}
public long findCount(String sql) throws CException {
return findCount(sql, true);
}
public long findCount(String sql, boolean outpr) throws CException {
int count = 0;
// String countsql = "select count(*) as num " + sql;
// if (outpr)
//log.info(sql);
executeQuery(sql);
try {
if (result.next()) {
count = result.getInt(1);
}
this.result.close();
} catch (Exception ex) {
throw new CException(ex.getMessage());
}
return count;
}
public long selectRowCount(String sql) throws CException {
return selectRowCount(sql, true);
}
public long selectRowCount(String sql, boolean outpr) throws CException {
return findCount("select count(*) from (" + sql + ")", outpr);
}
protected List listAdaptor() throws Exception {
return listAdaptor("resultAdaptor");
}
/**
* <20>ѽ<EFBFBD><D1BD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ArrayList
*
* @param methodName
* String
* @throws CException
* @return ArrayList
*/
protected List listAdaptor(String methodName) throws Exception {
List list = new ArrayList();
Object entity = null;
try {
while (this.result.next()) {
entity = this.getClass().getMethod(methodName, null)
.invoke(this, null);
list.add(entity);
}
} catch (Exception ex) {
log.error("", ex);
throw new Exception("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>listAdaptor() Exception");
}
return list;
}
protected boolean resultNext() throws Exception {
return this.result.next();
}
protected abstract Object resultAdaptor() throws Exception;
protected boolean queryValidateByText(String value) {
if (value != null) {
if (!(value.equals("") || value.equals("&nbsp;") || value
.equals("-1"))) {
return true;
}
}
return false;
}
protected boolean queryValidateByText(int value) {
if (value != -1) {
return true;
}
return false;
}
protected boolean queryValidateByText(long value) {
if (value != -1) {
return true;
}
return false;
}
protected void close() {
try {
if (this.result != null) {
this.result.close();
this.result = null;
}
if (this.st != null) {
this.st.close();
this.st = null;
}
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
/**
* <20>رյ<D8B1>ǰ<EFBFBD><C7B0>statment<6E><74>result(<28><><EFBFBD><EFBFBD><EFBFBD>еĻ<D0B5>),<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD>Ϊnull
*/
public void closeCurrentStatementResultSet(){
close();
}
protected Statement createStatement() throws Exception {
if (this.connection != null) {
return this.connection.createStatement();
} else {
throw new Exception("have not connection,can't createStatement!!!");
}
}
protected PreparedStatement createPrepareStatement(String sql)
throws Exception {
if (this.connection != null) {
return this.connection.prepareStatement(sql);
} else {
throw new Exception("have not connection,can't createStatement!!!");
}
}
protected static String bracket(String sql) {
return " (" + sql + ") ";
}
protected static String convert(String sql) {
return StringTools.convertSqlStr(sql);
}
protected static long convert(long sql) {
return sql;
}
protected static int convert(int sql) {
return sql;
}
protected static String LIKE(String str) {
return " LIKE " + StringTools.convertLikeStr(str) + " ";
}
protected static String COUNT(String str) {
return " count(" + str + ")";
}
protected static String SUM(String str) {
return " SUM(" + str + ")";
}
protected static String MAX(String str) {
return " MAX(" + str + ")";
}
protected static String MIN(String str) {
return " MIN(" + str + ")";
}
protected static String SUBSTR(String str, int beginPosi, int length) {
return " SUBSTR(" + str + "," + beginPosi + "," + length + ")";
}
protected static String TODATE(String str, String format) {
return " to_date ('" + str + "','" + format + "')";
}
protected static String TOTIMESTAMP(Date date) {
String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
.format(date);
return " to_timestamp ('" + dateStr + "','syyyy-mm-dd hh24:mi:ss.ff')";
}
protected Connection getConnection() {
return connection;
}
protected void setConnection(Connection conn) {
this.connection = conn;
}
protected String convertStr(String str) {
return StringTools.convertSqlStr(str);
}
protected String convertLikeStr(String str) {
return StringTools.convertLikeStr(str);
}
protected ResultSet getResult() {
return result;
}
protected void setResult(ResultSet resultset) {
this.result = resultset;
}
public List getResultList() {
return resultList;
}
/**
* <20><>Blob<6F>л<EFBFBD>ȡ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
*
* @param columnName
* @return
* @throws SQLException
*/
protected byte[] getBlobToBytes(String columnName) throws SQLException {
oracle.sql.BLOB blob = null;
try {
blob = (oracle.sql.BLOB) this.result.getBlob(columnName);
if (null == blob) {
return null;
}
} catch (Exception ex) {
String ems = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>columnName<EFBFBD><EFBFBD>" + columnName;
log.error(ems);
throw new SQLException(ems);
}
ArrayList<byte[]> al = new ArrayList<byte[]>();
InputStream blobStream = null;
int totalSize = 0;
try {
blobStream = blob.getBinaryStream();
int bufferSize = 10 * 1024;
byte[] buffer = new byte[bufferSize];
int nbytes = 0; // Number of bytes read
while ((nbytes = blobStream.read(buffer)) != -1) {// Read from Blob
// stream
totalSize += nbytes;
if (nbytes == bufferSize) {
al.add(buffer);
buffer = new byte[bufferSize];
} else {
byte[] temp = new byte[nbytes];
System.arraycopy(buffer, 0, temp, 0, nbytes);
al.add(temp);
}
}
} catch (Exception e) {
throw new SQLException(e);
} finally {
if (null != blobStream) {
try {
blobStream.close();
} catch (Exception e) {
}
}
}
if (totalSize <= 0) {
return null;
}
if (al.size() == 1) {
return al.get(0);
}
byte[] result = new byte[totalSize];
byte[] temp;
for (int destPos = 0, i = 0, n = al.size(); i < n; i++) {
temp = al.get(i);
System.arraycopy(temp, 0, result, destPos, temp.length);
destPos += temp.length;
}
return result;
}
/**
* <20><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
*
* @param bytes
* <20>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
* @return
* @throws Exception
*/
protected String getStringFromBytes(byte[] bytes) throws Exception {
if (null == bytes || bytes.length <= 0) {
return "";
}
return new String(bytes);
}
/**
* <20><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
*
* @param bytes
* @param charsetName
* @return
* @throws Exception
*/
protected String getStringFromBytes(byte[] bytes, String charsetName)
throws Exception {
if (null == bytes || bytes.length <= 0) {
return "";
}
return new String(bytes, charsetName);
}
public Date findTime() throws CException {
String sql = "SELECT SYSTIMESTAMP FROM DUAL";
Date time = null;
executeQuery(sql);
try {
if (result.next()) {
time = result.getTimestamp(1);
}
this.result.close();
} catch (Exception ex) {
throw new CException(ex.getMessage());
}
return time;
}
/**
* <20>ر<EFBFBD>connection
* @param conn
*/
public static void close(Connection conn){
if (null != conn){
try {
conn.close();
} catch (Exception ee){
}
}
}
/**
* <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>sql
* @param loginUserId <20><>½<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ID, null<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>,ϵͳ<CFB5><EFBFBD><E1B7B5> (1=1)
* @param permissionFlag <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>(lUserPO.getPermission_flag<61><67><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>),<2C><><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>ϵͳ<CFB5><EFBFBD><E1B7B5> (1=1)
* @param contractCompanyFieldName <20><>ͬ<EFBFBD>ֶ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),<2C>磺C.CODE; null<6C><6C><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param rescueCompanyFieldName <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),<2C>磺RC.CODE; null<6C><6C><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return Ȩ<>޹<EFBFBD><DEB9><EFBFBD>sql<71><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(); <20><>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7>ǿո<C7BF>;
* <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>or<6F><72>ϵ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊһ<CEAA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶζ<D6B6>Ϊnull<6C><6C>ϵͳ<CFB5><CDB3>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>޹<EFBFBD><DEB9>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD> (1=1)
*/
public static String getDataPermissionSql(String loginUserId, int permissionFlag , String contractCompanyFieldName){
StringBuilder sb = new StringBuilder(256);
sb.append(" (");
if (permissionFlag == 1 && null != loginUserId && Integer.parseInt(loginUserId) >= 0 ){//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
if (null != contractCompanyFieldName && contractCompanyFieldName.length() > 0){//<2F><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>
sb.append("(exists (select * from involve_contracting_company icc_123 where icc_123.system_user_id = ")
.append(loginUserId)
.append(" and icc_123.contracting_company_code = ").append(contractCompanyFieldName)
.append("))");
}
} else {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
sb.append("1=1");
}
sb.append(") ");
return sb.toString();
}
}

View File

@ -0,0 +1,452 @@
package com.sino.publicclass.base;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPalette;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class BaseExcel {
protected OutputStream os;
protected HSSFWorkbook workbook;
protected HSSFRow row;
protected HSSFCell cell;
protected HSSFCellStyle style_title1;
protected HSSFCellStyle style_title2;
protected HSSFCellStyle style_title3;
protected HSSFCellStyle style_input;
protected HSSFCellStyle style_input_int;
protected HSSFCellStyle style_input_double;
protected HSSFCellStyle style_input_formula;
protected HSSFCellStyle caption9;//9<><39><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
protected HSSFCellStyle caption10;//10<31><30><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
protected HSSFCellStyle caption11;//11<31><31><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
protected HSSFCellStyle caption12;//12<31><32><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
protected HSSFCellStyle caption16;//16<31><36><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
protected HSSFCellStyle caption20;//20<32><30><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
protected HSSFCellStyle data9;//9<><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
protected HSSFCellStyle data10;//10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
protected HSSFCellStyle data11;//11<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
protected HSSFCellStyle data12;//12<31><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
protected HSSFCellStyle data16;//16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
protected HSSFCellStyle data9Right;//9<><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>
protected HSSFCellStyle data10Right;//10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>
protected HSSFCellStyle data11Right;//11<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>
protected HSSFCellStyle data12Right;//12<31><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>
protected HSSFCellStyle data16Right;//16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>
protected int rowNum;
protected int cellNum;
protected DecimalFormat df;
protected SimpleDateFormat sdfLong;
protected void init(HttpServletResponse res, String filename) throws Exception {
workbook = new HSSFWorkbook();
HSSFFont font = workbook.createFont();
font.setFontHeightInPoints((short) 13);
font.setBoldweight((short) 700);
HSSFFont font1 = workbook.createFont();
font1.setFontHeightInPoints((short) 10);
font1.setBoldweight((short) 700);
HSSFFont font2 = workbook.createFont();
font2.setFontHeightInPoints((short) 10);
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex(HSSFColor.BLUE.index, (byte) 214, (byte) 244, (byte) 244);
style_title1 = createCellStyle(workbook, font, 1, 1, 1, 1, 2, 1, false, false, 0x31);
style_title1.setFillForegroundColor(HSSFColor.BLUE.index);
style_title1.setFillPattern(CellStyle.SOLID_FOREGROUND);
style_title2 = createCellStyle(workbook, font1, 1, 1, 1, 1, 2, 1, false, false, 0x31);
style_title2.setFillForegroundColor(HSSFColor.BLUE.index);
style_title2.setFillPattern(CellStyle.SOLID_FOREGROUND);
style_title3 = createCellStyle(workbook, font2, 1, 1, 1, 1, 1, 1, false, false, 0x31);
style_input = createCellStyle(workbook, font2, 1, 1, 1, 1, 1, 1, false, false, 0x31);
style_input_int = createCellStyle(workbook, font2, 1, 1, 1, 1, 1, 1, false, false, 1);
style_input_double = createCellStyle(workbook, font2, 1, 1, 1, 1, 1, 1, false, false, 0);
style_input_formula = createCellStyle(workbook, font2, 1, 1, 1, 1, 1, 1, false, false, 0);
caption9 = createCellStyle(workbook, createFont(9, true) , 1, 1, 1, 1, 2, 1, false, false, 0x31);
caption10 = createCellStyle(workbook, createFont(10, true), 1, 1, 1, 1, 2, 1, false, false, 0x31);
caption11 = createCellStyle(workbook, createFont(11, true), 1, 1, 1, 1, 2, 1, false, false, 0x31);
caption12 = createCellStyle(workbook, createFont(12, true), 1, 1, 1, 1, 2, 1, false, false, 0x31);
caption16 = createCellStyle(workbook, createFont(16, true), 1, 1, 1, 1, 2, 1, false, false, 0x31);
caption20 = createCellStyle(workbook, createFont(20, true), 1, 1, 1, 1, 2, 1, false, false, 0x31);
data9 = createCellStyle(workbook, createFont(9, false) , 1, 1, 1, 1, 1, 1, false, false, 0x31);
data10 = createCellStyle(workbook, createFont(10, false), 1, 1, 1, 1, 1, 1, false, false, 0x31);
data11 = createCellStyle(workbook, createFont(11, false), 1, 1, 1, 1, 1, 1, false, false, 0x31);
data12 = createCellStyle(workbook, createFont(12, false), 1, 1, 1, 1, 1, 1, false, false, 0x31);
data16 = createCellStyle(workbook, createFont(16, false), 1, 1, 1, 1, 1, 1, false, false, 0x31);
data9Right = createCellStyle(workbook, createFont(9, false) , 1, 1, 1, 1, 3, 1, false, false, 0x31);
data10Right = createCellStyle(workbook, createFont(10, false), 1, 1, 1, 1, 3, 1, false, false, 0x31);
data11Right = createCellStyle(workbook, createFont(11, false), 1, 1, 1, 1, 3, 1, false, false, 0x31);
data12Right = createCellStyle(workbook, createFont(12, false), 1, 1, 1, 1, 3, 1, false, false, 0x31);
data16Right = createCellStyle(workbook, createFont(16, false), 1, 1, 1, 1, 3, 1, false, false, 0x31);
rowNum = 0;
cellNum = 0;
df = new java.text.DecimalFormat("0.#");
sdfLong = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
res.reset();
res.setContentType("application/octet-stream; charset=UTF-8");
res.addHeader("Content-Disposition", "attachment; filename=" + filename + ".xls");
os = res.getOutputStream();
}
protected HSSFCellStyle createCellStyle(int fontSize, boolean boldweight, int align) {
return createCellStyle(workbook, createFont(fontSize, boldweight), 1, 1, 1, 1, align, 1, false, false, 0x31);
}
protected HSSFCellStyle createCellStyle(HSSFWorkbook hworkbook, HSSFFont font, int border_top, int border_bottom, int border_left, int border_right, int align, int v_align, boolean islock,
boolean iswrap, int format) {
HSSFCellStyle style = hworkbook.createCellStyle();
style.setFont(font);
style.setBorderTop((short) border_top);
style.setBorderBottom((short) border_bottom);
style.setBorderLeft((short) border_left);
style.setBorderRight((short) border_right);
style.setAlignment((short) align);
style.setVerticalAlignment((short) v_align);
style.setLocked(islock);
style.setWrapText(iswrap);
style.setDataFormat((short) format);
return style;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param fontSize
* @return
*/
protected HSSFFont createFont(int fontSize, boolean boldweight){
HSSFFont font = workbook.createFont();
font.setFontHeightInPoints((short) fontSize);
font.setBoldweight((short) (boldweight ? 700 : 400));
return font;
}
protected double format(double value) {
return Double.parseDouble(df.format(value));
}
protected HSSFCell createCell(HSSFRow hrow, int cellnum, HSSFCellStyle style, String value) {
HSSFCell hcell = hrow.createCell((short) cellnum);
//hcell.setEncoding((short) 1);
hcell.setCellStyle(style);
hcell.setCellType(Cell.CELL_TYPE_STRING);
hcell.setCellValue(value);
return hcell;
}
protected HSSFCell createCell(HSSFRow hrow, int cellnum, HSSFCellStyle style, int value) {
HSSFCell hcell = hrow.createCell((short) cellnum);
//hcell.setEncoding((short) 1);
hcell.setCellStyle(style);
hcell.setCellType(Cell.CELL_TYPE_NUMERIC);
hcell.setCellValue(value);
return hcell;
}
protected HSSFCell createCell(HSSFRow hrow, int hcellNum, HSSFCellStyle style, double value) {
HSSFCell hcell = hrow.createCell((short) hcellNum);
//hcell.setEncoding((short) 1);
hcell.setCellStyle(style);
hcell.setCellType(Cell.CELL_TYPE_NUMERIC);
hcell.setCellValue(value);
return hcell;
}
protected HSSFCell createCellNumeric(HSSFRow hrow, int hcellNum, HSSFCellStyle style) {
HSSFCell hcell = hrow.createCell((short) hcellNum);
//hcell.setEncoding((short) 1);
hcell.setCellStyle(style);
hcell.setCellType(Cell.CELL_TYPE_NUMERIC);
return hcell;
}
protected HSSFCell createCellFormula(HSSFRow hrow, int hcellNum, HSSFCellStyle style) {
HSSFCell hcell = hrow.createCell((short) hcellNum);
//hcell.setEncoding((short) 1);
hcell.setCellStyle(style);
hcell.setCellType(Cell.CELL_TYPE_FORMULA);
return hcell;
}
protected String praseFormula(List list, int column) {
String str = "";
int offset = 7 + 1;
char col = (char) (65 + column);
String sign = "";
for (int i = 0; i < list.size(); i++) {
int value = ((Integer) list.get(i)).intValue() + offset;
str += sign + col + value;
sign = "+";
}
return "SUM(" + str + ")";
}
protected String praseFormula(int hrow, char column1, char column2) {
String str = "";
String sign = "+";
str = "" + column1 + hrow + sign + column2 + hrow;
return "SUM(" + str + ")";
}
protected String praseFormula(int hrow, char column1, char column2, char column3) {
String str = "";
String sign = "+";
str = "" + column1 + hrow + sign + column2 + hrow + sign + column3 + hrow;
return "SUM(" + str + ")";
}
/**
* <20><>ȡexcel, ֻ<><D6BB> sheet 0
* @param file
* @return <20>кź<D0BA>list<73>±<EFBFBD>һһ<D2BB><D2BB>Ӧ,<2C><><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
* @throws IOException
*/
public static List<List<String>> readExcel(File file) throws IOException{
return readExcel(file,0);
}
/**
* <20><>ȡexcel
* @param file
* @param sheetIndex sheet <20>±<EFBFBD>,<2C><>0<EFBFBD><30>ʼ
* @return <20>кź<D0BA>list<73>±<EFBFBD>һһ<D2BB><D2BB>Ӧ,<2C><><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
* @throws IOException
*/
public static List<List<String>> readExcel(File file, int sheetIndex) throws IOException{
String fileName = file.getName();
System.out.println("BaseExcel.readExcel(" + fileName + "," + sheetIndex + ")");
String extension = fileName.lastIndexOf(".")==-1 ? "" : fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
if ("xls".equals(extension)){
return read2003Excel(file, sheetIndex);
} else if ("xlsx".equals(extension)){
return read2007Excel(file, sheetIndex);
}else{
throw new IOException("<EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[" + extension + "]");
}
}
/**
* <20><>ȡ office 2003 excel
* @param file
* @param sheetIndex sheet <20>±<EFBFBD>,<2C><>0<EFBFBD><30>ʼ
* @return <20>кź<D0BA>list<73>±<EFBFBD>һһ<D2BB><D2BB>Ӧ,<2C><><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
* @throws IOException
*/
private static List<List<String>> read2003Excel(File file, int sheetIndex) throws IOException{
DecimalFormat df = new DecimalFormat("0");// <20><>ʽ<EFBFBD><CABD> number String <20>ַ<EFBFBD>
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
DecimalFormat nf = new DecimalFormat("0.00");// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
HSSFWorkbook hwb = new HSSFWorkbook(new FileInputStream(file));
HSSFSheet sheet = hwb.getSheetAt(sheetIndex);
int rows = sheet.getLastRowNum(); //sheet.getPhysicalNumberOfRows();
List<List<String>> list = new ArrayList<List<String>>(rows + 2);
String value = null;
HSSFRow row = null;
HSSFCell cell = null;
List<String> listRow;
int cols,j;
for(int i = 0; i <= rows ;i++){
row = sheet.getRow(i);
if (row == null) {
list.add(null);
continue;
}
cols = row.getLastCellNum();
listRow = new ArrayList<String>(cols + 1);
for (j = 0; j < cols; j++) {
cell = row.getCell(j);
if (cell == null) {
listRow.add(null);
continue;
}
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
// System.out.println(i+"<22><>"+j+" <20><> is String type");
value = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
// System.out.println(i+"<22><>"+j+" <20><> is Number type ; DateFormt:"+cell.getCellStyle().getDataFormatString());
if ("@".equals(cell.getCellStyle().getDataFormatString())){
value = df.format(cell.getNumericCellValue());
} else if ("General".equals(cell.getCellStyle().getDataFormatString())){
value = nf.format(cell.getNumericCellValue());
}else{
value = sdf.format(DateUtil.getJavaDate(cell.getNumericCellValue()));
}
break;
case Cell.CELL_TYPE_BOOLEAN:
// System.out.println(i+"<22><>"+j+" <20><> is Boolean type");
value = cell.getBooleanCellValue() ? "true" : "false";
break;
case Cell.CELL_TYPE_BLANK:
// System.out.println(i+"<22><>"+j+" <20><> is Blank type");
value = "";
break;
default:
System.out.println(i+"<EFBFBD><EFBFBD>"+j+" <20><> is default type");
value = cell.toString();
}
listRow.add(value);
}
list.add(listRow);
}
return list;
}
/**
* <20><>ȡOffice 2007 excel
* @param file
* @param sheetIndex sheet <20>±<EFBFBD>,<2C><>0<EFBFBD><30>ʼ
* @return <20>кź<D0BA>list<73>±<EFBFBD>һһ<D2BB><D2BB>Ӧ,<2C><><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
* @throws IOException
*/
private static List<List<String>> read2007Excel(File file, int sheetIndex) throws IOException {
DecimalFormat df = new DecimalFormat("0");// <20><>ʽ<EFBFBD><CABD> number String <20>ַ<EFBFBD>
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
DecimalFormat nf = new DecimalFormat("0.00");// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> XSSFWorkbook <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>strPath <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file));
// <20><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
XSSFSheet sheet = xwb.getSheetAt(sheetIndex);
int rows = sheet.getLastRowNum(); //sheet.getPhysicalNumberOfRows();
List<List<String>> list = new ArrayList<List<String>>(rows + 2);
String value = null;
XSSFRow row = null;
XSSFCell cell = null;
List<String> listRow;
int cols,j;
for (int i = 0; i <= rows; i++) {
row = sheet.getRow(i);
if (row == null) {
list.add(null);
continue;
}
cols = row.getLastCellNum();
listRow = new ArrayList<String>(cols + 1);
for (j = 0; j < cols; j++) {
cell = row.getCell(j);
if (cell == null) {
listRow.add(null);
continue;
}
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
// System.out.println(i+"<22><>"+j+" <20><> is String type");
value = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
// System.out.println(i+"<22><>"+j+" <20><> is Number type ; DateFormt:"+cell.getCellStyle().getDataFormatString());
if ("@".equals(cell.getCellStyle().getDataFormatString())){
value = df.format(cell.getNumericCellValue());
} else if ("General".equals(cell.getCellStyle().getDataFormatString())){
value = nf.format(cell.getNumericCellValue());
} else {
value = sdf.format(DateUtil.getJavaDate(cell.getNumericCellValue()));
}
break;
case Cell.CELL_TYPE_BOOLEAN:
// System.out.println(i+"<22><>"+j+" <20><> is Boolean type");
value = cell.getBooleanCellValue() ? "true" : "false";
break;
case Cell.CELL_TYPE_BLANK:
// System.out.println(i+"<22><>"+j+" <20><> is Blank type");
value = "";
break;
default:
// System.out.println(i+"<22><>"+j+" <20><> is default type");
value = cell.toString();
}
listRow.add(value);
}
list.add(listRow);
}
return list;
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>
* @param points <20><><EFBFBD><EFBFBD>(һӢ<D2BB><D3A2>=72<37><32>)
* @return
*/
protected short getRowHeight(int points){
//equals points * 20
return (short) ((points << 4) + (points << 2));
}
/**
* <20>п<EFBFBD>
* @param characters <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD> <= 255
* @return
*/
protected int getColumnWidth(int characters){
return characters << 8;
}
public static void main(String[] args){
try {
File file = new File("f:\\vehicleUser.xls");
List<List<String>> list = readExcel(file,0);
System.out.println("listsize="+list.size());
List<String> clist= list.get(3);
System.out.println("clist="+clist.size());
for(String str : clist){
System.out.println(str);
}
} catch (Exception e){
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,31 @@
package com.sino.publicclass.base;
/**
* <20><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3>
* <p>Title: seagoer.com</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: SG</p>
* @author shi.wf
* @version 1.0
*/
public class CException extends Exception{
/**
*
*/
private static final long serialVersionUID = 1L;
private String message=null;
public CException() {
this.message="error";
}
@Override
public String getMessage() {
return this.message;
}
public void setMsg(String msg) {
this.message = msg;
}
public CException(String ex) {
super(ex);
this.message =ex;
}
}

View File

@ -0,0 +1,65 @@
package com.sino.publicclass.base;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* config<69>ļ<EFBFBD><C4BC><EFBFBD>
* <p>
* Title: seagoer.com
* </p>
* <p>
* Description:
* </p>
* <p>
* Copyright: Copyright (c) 2004
* </p>
* <p>
* Company: SG
* </p>
*
* @author shi.wf
* @version 1.0
*/
public class Config {
private static Config instance;
private Properties prop;
private final static String PROPFILE = "/config.properties";
public final static String SMS_SERVER_IP = "sms.server.ip";
public final static String SMS_SERVER_PORT = "sms.server.port";
public final static String RUNMODE = "runmode";
public final static String WEBSERVICEURL = "webserver.url";
public final static String DBSERVER_ID="dbServer.id";
private static Config getInstance() {
try {
if (instance == null) {
instance = new Config();
instance.init();
}
} catch (Exception e) {
e.printStackTrace();
}
return instance;
}
private void init() throws IOException {
InputStream is = null;
is = getClass().getResourceAsStream(PROPFILE);
prop = new Properties();
prop.load(is);
}
public static String get(String key) {
if (key == null) {
return "";
}
String value = getInstance().prop.getProperty(key);
if (value != null) {
value = value.trim();
} else {
value = "";
}
return value;
}
}

View File

@ -0,0 +1,38 @@
package com.sino.publicclass.base;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.business.WeixinSignatureThread;
public class InitServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private final Log log = LogFactory.getLog(getClass().getName());
@Override
public void init() throws ServletException {
try {
log.info("init servlet......");
ConnectionPool.getInstance();
WeixinSignatureThread signThread = new WeixinSignatureThread();
new Thread(signThread).start();
log.info("WeixinSignatureThread<EFBFBD>߳̿<EFBFBD><EFBFBD><EFBFBD>......");
} catch (Exception ex) {
log.error(ex);
throw new ServletException(ex.getMessage());
}
}
@Override
public void destroy() {
}
}

View File

@ -0,0 +1,58 @@
package com.sino.publicclass.base;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class Memory extends HashMap {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
public Memory() {
super();
}
public String getString(String key) {
if (get(key) == null) {
return "";
} else {
return (String) get(key);
}
}
public int getInt(String key) {
if (getString(key).equals("")) {
return -1;
} else {
return Integer.parseInt(getString(key));
}
}
public Object getObject(String key) {
if (get(key) == null) {
return null;
} else {
return get(key);
}
}
public List getList(String key) {
return (List) getObject(key);
}
public void print(){
Iterator iter=this.keySet().iterator();
while(iter.hasNext()){
String name=(String)iter.next();
System.out.println(name+"="+this.get(iter.next()));
}
}
}

View File

@ -0,0 +1,132 @@
package com.sino.publicclass.base;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sino.publicclass.util.StringTools;
public class RequestHandle extends HttpServlet {
private static final long serialVersionUID = -1243187676403055994L;
private final Log log = LogFactory.getLog(getClass().getName());
private ServletConfig servletConfig;
private static String default_actionName = "BaseAction";
private static String default_action_url = ".do";
private static String default_per_package = "com.sino.rrs.action";
private static String default_error_page = "exception.jsp";
private static String default_wait_page = "wait.jsp";
private static String per_package;
private String error_Page = "";
private String wait_Page = "";
private String actionName = "";
private String action_url = "";
public RequestHandle() {
}
@Override
public void init() {
log.info("");
servletConfig = getServletConfig();
per_package = getInitPara("perpackage");
error_Page = getInitPara("errorPage");
wait_Page = getInitPara("waitPage");
actionName = getInitPara("actionName");
action_url = getInitPara("actionUrl");
if (StringTools.ValidateStr(per_package)) {
per_package = default_per_package;
}
if (StringTools.ValidateStr(error_Page)) {
error_Page = default_error_page;
}
if (StringTools.ValidateStr(wait_Page)) {
wait_Page = default_wait_page;
}
if (StringTools.ValidateStr(action_url)) {
action_url = default_action_url;
}
if (StringTools.ValidateStr(actionName)) {
actionName = default_actionName;
}
}
@Override
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
BaseAction action;
String pathinfo = "";
try {
if (VAR.getRealpath().trim().length() < 1) {
VAR.setRealpath(getServletContext().getRealPath(""));
}
pathinfo = getPathinfo(req.getServletPath());
action = (BaseAction) Class.forName(pathinfo).newInstance();
action.service(req, res);
if(action.isNext()){
if (action.isTransition()) {
callpage(wait_Page, req, res);
} else {
callpage(action.getNextPage(), req, res);
}
}
} catch (ClassNotFoundException ex) {
String em = "ClassNotFoundException " + pathinfo;
em = "<p align='center'><font color='#ff0000'>" + em + "</font>";
log.error(em);
req.setAttribute("failureMsg", em);
callpage(error_Page, req, res);
} catch (Exception ex) {
String em = ex.getMessage();
log.error("",ex);
log.error("pathinfo=" + pathinfo);
if(em==null)em="";
if (em.indexOf("page:") != 0) {
em = "<p align='center'><font color='#ff0000'>" + StringTools.convertForTextArea(em) + "</font>";
} else {
em = "<p align='left'><font color='#ff0000'>" + em + "</font>";
}
req.setAttribute("failureMsg", em);
callpage(error_Page, req, res);
}
}
private String getPathinfo(String path) {
if (path == null)
path = "";
String pathinfo = per_package + path;
pathinfo = pathinfo.replace('/', '.');
pathinfo = pathinfo.substring(0, pathinfo.lastIndexOf(action_url));
return pathinfo;
}
private void callpage(String page, HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
try {
getServletContext().getRequestDispatcher(page).forward(req, res);
} catch (Exception ex) {
log.error("", ex);
throw new ServletException("page: " + page + " compile error <br>" + ex.getMessage());
}
}
private String getInitPara(String name) {
String temp = servletConfig.getInitParameter(name);
if (StringTools.ValidateStr(temp)) {
temp = Config.get(name);
}
return temp;
}
}

View File

@ -0,0 +1,82 @@
package com.sino.publicclass.base;
/**
* config<69>ļ<EFBFBD><C4BC><EFBFBD>
* <p>
* Title: seagoer.com
* </p>
* <p>
* Description:
* </p>
* <p>
* Copyright: Copyright (c) 2004
* </p>
* <p>
* Company: SG
* </p>
*
* @author shi.wf
* @version 1.0
*/
public class VAR {
// private static VAR instance;
private static String realpath = "";
private static String uploadPath = "upload";
private static String cameraPath = "camera";
private static String dataBackupPath = "databackup";
private static String tmpUploadPath = "temp";// <20>»۵<C2BB><DBB5><EFBFBD>excel<65><6C><EFBFBD><EFBFBD>ʱĿ¼
// public static VAR getInstance() {
// try {
// if (instance == null) {
// instance = new VAR();
//
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// return instance;
// }
public static String getRealpath() {
return realpath;
}
public static void setRealpath(String path) {
realpath = path;
}
public static String getUploadPath() {
return uploadPath;
}
/**
* @return the tmpUploadPath
*/
public static String getTmpUploadPath() {
return tmpUploadPath;
}
/**
* @param tmpUploadPath
* the tmpUploadPath to set
*/
public static void setTmpUploadPath(String tmpUploadPath) {
VAR.tmpUploadPath = tmpUploadPath;
}
public static void setUploadPath(String path) {
uploadPath = path;
}
public static String getCameraPath() {
return cameraPath;
}
public static void setCameraPath(String cameraPath) {
VAR.cameraPath = cameraPath;
}
public static String getDataBackupPath() {
return dataBackupPath;
}
}

View File

@ -0,0 +1,126 @@
package com.sino.publicclass.common;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class HttpClientDownload {
private ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
private MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
private boolean stop = false;
protected final Log log = LogFactory.getLog(HttpClientDownload.class);
private String fileUrl = "http://umsa.careland.com.cn/tmc/get_zone_traffic_snapshoot.ums?cdid=30000&cpid=12&kcard=108001100000002007697598&devidcode=22844C70CCTJ1&actcode=7142549098995416&verid=4C707502252C&zlibcomp=1";
private int buffer = 1024 * 10;
private String fileName = "TSPService.txt";
public boolean isStop() {
return stop;
}
public void setStop(boolean stop) {
this.stop = stop;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public int getBuffer() {
return buffer;
}
public void setBuffer(int buffer) {
this.buffer = buffer;
}
public byte[] getData() {
return dataStream.toByteArray();
}
public ByteArrayOutputStream getDataStream() {
return dataStream;
}
public void setDataStream(ByteArrayOutputStream dataStream) {
this.dataStream = dataStream;
}
public boolean download() {
HttpClient client = null;
GetMethod httpGet = null;
try {
manager.getParams().setConnectionTimeout(100000);
manager.getParams().setSoTimeout(100000);
client = new HttpClient(manager);
httpGet = new GetMethod(fileUrl);
client.executeMethod(httpGet);
String path = httpGet.getPath();
int offset = path.lastIndexOf("/");
if (offset != -1) {
fileName = path.substring(offset + 1);
} else {
fileName = path;
}
if (fileName.indexOf(".") == -1) {
fileName = fileName + ".htm";
}
if (fileName.equals(".htm")) {
fileName = "123.htm";
}
InputStream in = httpGet.getResponseBodyAsStream();
byte[] b = new byte[buffer];
int len = 0;
while ((len = in.read(b)) != -1 && !isStop()) {
dataStream.write(b, 0, len);
}
in.close();
} catch (Exception e) {
log.error(e);
return false;
} finally {
try {
httpGet.releaseConnection();
} catch (Exception e) {
log.error(2);
}
}
return true;
}
public static void main(String args[]) throws Exception {
HttpClientDownload d = new HttpClientDownload();
d.setFileUrl("http://api.map.baidu.com/?qt=cur&ie=utf-8&oue=3&res=json&wd=%E4%B8%8A%E6%B5%B7%E5%B8%82");
if (d.download()) {
System.out.println(1);
}
}
}

View File

@ -0,0 +1,453 @@
package com.sino.publicclass.common;
import java.io.*;
import java.util.Enumeration;
import java.util.Vector;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
public class HttpDataParser {
private static final String READLINE_IOEXCEPTION =
"Fail to read data sent by the browser.";
private static final String CORRUPTED_INPUT_STREAM =
"Data stream is corrupted.";
private static final String FILE_OUTPUT_STREAM_IOEXCEPTION =
"Fail to create the attachment file.";
private static final String CLOSE_IOEXCEPTION =
"Fail to close the attachment file.";
private static final String WRITE_IOEXCEPTION =
"Fail to read the attachment file.";
private static final String WORKING_DIR_IS_FILE =
"The working directory is a file.";
private static final String WORKING_DIR_CREATE_ERROR =
"Cannot create the file working directory.";
private static final String FILE_SIZE_ERROR =
"<EFBFBD>ϴ<EFBFBD><EFBFBD>ļ<EFBFBD>̫<EFBFBD><EFBFBD>.";
private static final String MULTIDATATYPE = "multipart/form-data";
private static final int BUF_SIZE = 0x64000;
private static final String NAME_STRING =
"Content-Disposition: form-data; name=\"";
private static final String FILENAME_STRING = "\"; filename=\"";
private static final String CONTENT_TYPE_STRING = "Content-Type:";
protected Vector parameterNames;
protected Vector parameterValues;
protected Vector uploadParameterNames;
protected Vector uploadSrcFileNames;
protected Vector uploadFileNames;
protected Vector uploadFileTypes;
protected Vector uploadFileSizes;
private int maxFileSize = 1024 * 1024 * 10;
public HttpDataParser() {
}
public HttpDataParser(int maxSize) {
setMaxFileSize(maxSize);
}
public void parser(HttpServletRequest httpservletrequest, String path, int maxSize)
throws Exception {
setMaxFileSize(maxSize);
parser(httpservletrequest, path);
}
public void parser(HttpServletRequest httpservletrequest, String path)
throws Exception {
parameterNames = new Vector(0);
parameterValues = new Vector(0);
uploadParameterNames = new Vector(0);
uploadSrcFileNames = new Vector(0);
uploadFileNames = new Vector(0);
uploadFileTypes = new Vector(0);
uploadFileSizes = new Vector(0);
byte abyte0[] = new byte[BUF_SIZE];
String parameterName = "";
String s12 = "";
Integer integer = null;
int len = 0; //<2F><><EFBFBD><EFBFBD>
int cursor = 0; //<2F>α<EFBFBD>
String contentType = httpservletrequest.getContentType();
if (contentType != null) {
contentType = contentType.trim();
}
//ENCTYPE<50><45><EFBFBD><EFBFBD>multipart/form-data<74><61>
if (contentType == null || contentType.indexOf(MULTIDATATYPE) < 0) {
String parValue;
for (Enumeration enumeration = httpservletrequest.getParameterNames(); enumeration.hasMoreElements();
parameterValues.addElement(parValue)) {
parameterName = (String) enumeration.nextElement();
parameterNames.addElement(parameterName);
parValue = getParameter(httpservletrequest, parameterName);
}
return;
}
ServletInputStream servletinputstream = httpservletrequest.getInputStream();
int contentLength = httpservletrequest.getContentLength();
try {
len = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += len;
String s1 = new String(abyte0, 0, len);
String code = s1.substring(0, s1.length() - 2);
int i2 = 0;
while (contentLength > cursor) {
int k;
try {
k = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += k;
String s2 = null;
s2 = new String(abyte0, 0, k);
boolean isFile = false; //<2F>Ƿ<EFBFBD><C7B7><EFBFBD>file
if (k > NAME_STRING.length()) {
if (s2.substring(0, NAME_STRING.length()).equals(NAME_STRING)) {
int l1 = s2.indexOf("\"", NAME_STRING.length());
parameterName = s2.substring(NAME_STRING.length(), l1);
l1 = s2.indexOf(FILENAME_STRING, l1);
if (l1 >= 0) {
isFile = true;
s12 = s2.substring(l1 + FILENAME_STRING.length(), s2.indexOf("\"",
l1 + FILENAME_STRING.length())).
trim();
} else {
isFile = false;
}
} else {
throw new Exception(CORRUPTED_INPUT_STREAM);
}
}
try {
k = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += k;
if (isFile) {
// is file
String s14;
String filetype;
String s20 = "";
if (s12 == null || s12.equals("")) {
filetype = "";
integer = new Integer(0);
s14 = "";
boolean flag1 = true;
do {
try {
k = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += k;
String s3 = new String(abyte0, 0, k);
if (s3.length() >= code.length() &&
s3.substring(0, code.length()).equals(code)) {
flag1 = false;
}
}
while (flag1);
} else {
String s4 = new String(abyte0, 0, k);
//read filetype
if (k > CONTENT_TYPE_STRING.length()) {
if (s4.substring(0,
CONTENT_TYPE_STRING.length()).equals(CONTENT_TYPE_STRING)) {
filetype = s4.substring(CONTENT_TYPE_STRING.length(), s4.length()).trim();
} else {
filetype = "";
}
} else {
filetype = "";
}
try {
k = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += k;
File file = new File(path);
if (file.isFile()) {
throw new Exception(WORKING_DIR_IS_FILE);
}
if (!file.exists() && !file.mkdirs()) {
throw new Exception(WORKING_DIR_CREATE_ERROR);
}
i2++;
FileOutputStream fileoutputstream = null;
try {
String s18;
for (s18 = String.valueOf(i2); s18.length() < 3; s18 = '0' + s18) {
;
}
//ת<><D7AA><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
s20 = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + s18;
int j2 = s12.lastIndexOf(46);
if (j2 > 0) {
String s19 = s12.substring(j2, s12.length());
s20 = s20 + s19;
}
s14 = path + File.separator + s20;
fileoutputstream = new FileOutputStream(s14);
}
catch (IOException _ex) {
throw new Exception(FILE_OUTPUT_STREAM_IOEXCEPTION);
}
int k1 = 0;
boolean flag2 = true;
boolean flag5 = false;
int k2 = 0;
int l2 = 0;
do {
int l;
try {
l = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += l;
k1 += l;
if (k1 > maxFileSize)throw new Exception(FILE_SIZE_ERROR);
String s5 = null;
s5 = new String(abyte0, 0, l);
if (s5.length() >= code.length() &&
s5.substring(0, code.length()).equals(code)) {
try {
fileoutputstream.close();
}
catch (IOException _ex) {
throw new Exception(CLOSE_IOEXCEPTION);
}
k1 -= l;
k1 -= 2;
integer = new Integer(k1);
flag2 = false;
}
if (flag2) {
try {
if (flag5) {
fileoutputstream.write(k2);
fileoutputstream.write(l2);
}
if (l >= 2) {
k2 = abyte0[l - 2];
l2 = abyte0[l - 1];
fileoutputstream.write(abyte0, 0, l - 2);
flag5 = true;
} else {
k2 = 0;
l2 = 0;
fileoutputstream.write(abyte0, 0, l);
flag5 = false;
}
}
catch (IOException _ex) {
throw new Exception(WRITE_IOEXCEPTION);
}
}
}
while (flag2 && contentLength > cursor);
}
String srcname = "";
int b;
b = s12.lastIndexOf(92);
if (b < 0) b = s12.lastIndexOf(47);
if (b > -1) {
srcname = s12.substring(b + 1, s12.length());
}
uploadParameterNames.addElement(parameterName);
uploadSrcFileNames.addElement(srcname);
uploadFileNames.addElement(s20);
uploadFileTypes.addElement(filetype);
uploadFileSizes.addElement(integer);
} else {
// is not file
boolean flag3 = true;
String tempvalue = "";
do {
int i1;
try {
i1 = servletinputstream.readLine(abyte0, 0, BUF_SIZE);
}
catch (IOException _ex) {
throw new Exception(READLINE_IOEXCEPTION);
}
cursor += i1;
String s6 = null;
s6 = new String(abyte0, 0, i1);
if (s6.length() >= code.length() &&
s6.substring(0, code.length()).equals(code)) {
flag3 = false;
}
if (flag3) {
tempvalue = tempvalue + s6.substring(0, s6.length());
}
}
while (flag3 && contentLength > cursor);
tempvalue = tempvalue.substring(0, tempvalue.length() - 2);
parameterNames.addElement(parameterName);
parameterValues.addElement(tempvalue);
}
}
}
private String getParameter(HttpServletRequest httpservletrequest, String s)
throws
Exception {
String as[] = null;
String s1 = null;
as = httpservletrequest.getParameterValues(s);
if (as != null) {
s1 = as[0];
}
return s1;
}
public String[] getParameterNames() {
int j = parameterNames.size();
String as[] = new String[j];
for (int i = 0; i < j; i++) {
as[i] = (String) parameterNames.elementAt(i);
}
return as;
}
public String getParameterValue(String s) {
int i = parameterNames.indexOf(s);
String s1;
if (i < 0) {
s1 = null;
} else {
s1 = (String) parameterValues.elementAt(i);
}
if (s1 == null) {
return "";
} else {
return s1;
}
}
public String getUploadFileName(String s) {
int i = uploadParameterNames.indexOf(s);
String s1;
if (i < 0) {
s1 = null;
} else {
s1 = (String) uploadFileNames.elementAt(i);
}
return s1;
}
public String[] getUploadFileName() {
int j = uploadParameterNames.size();
String as[] = new String[j];
for (int i = 0; i < j; i++) {
as[i] = (String) uploadParameterNames.elementAt(i);
}
return as;
}
public Integer getUploadFileSize(String s) {
int i = uploadParameterNames.indexOf(s);
Integer integer;
if (i < 0) {
integer = null;
} else {
integer = (Integer) uploadFileSizes.elementAt(i);
}
return integer;
}
public String getUploadFileType(String s) {
int i = uploadParameterNames.indexOf(s);
String s1;
if (i < 0) {
s1 = null;
} else {
s1 = (String) uploadFileTypes.elementAt(i);
}
return s1;
}
public String[] getUploadParameterNames() {
int j = uploadParameterNames.size();
String as[] = new String[j];
for (int i = 0; i < j; i++) {
as[i] = (String) uploadParameterNames.elementAt(i);
}
return as;
}
public String getUploadSrcFileName(String s) {
int i = uploadParameterNames.indexOf(s);
String s1;
if (i < 0) {
s1 = null;
} else {
s1 = (String) uploadSrcFileNames.elementAt(i);
}
if (s1 == null) {
return "";
} else {
return s1;
}
}
public void release() {
parameterNames.removeAllElements();
parameterValues.removeAllElements();
uploadParameterNames.removeAllElements();
uploadSrcFileNames.removeAllElements();
uploadFileNames.removeAllElements();
uploadFileTypes.removeAllElements();
uploadFileSizes.removeAllElements();
}
/**
* <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD>ΪСд<D0A1><D0B4>ĸ<EFBFBD><C4B8>
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>(2002-9-28 16:54:47)
* @return java.lang.String
* @param filename java.lang.String
*/
public static String convertSuffix(String filename) {
int strNum = 0; //<2F>ַ<EFBFBD>"."<22><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB>
strNum = filename.indexOf(".");
if (strNum > -1) {
String firstname = ""; //<2F>ļ<EFBFBD><C4BC><EFBFBD>
firstname = filename.substring(0, strNum);
String secondname = ""; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
secondname = filename.substring(strNum + 1);
secondname = secondname.toLowerCase(); //<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>ΪСд<D0A1><D0B4>ĸ
filename = firstname + "." + secondname; //<2F><><EFBFBD>ºϳ<C2BA><CFB3>ļ<EFBFBD><C4BC><EFBFBD>
}
return filename;
}
public int getMaxFileSize() {
return maxFileSize;
}
public void setMaxFileSize(int msize) {
this.maxFileSize = msize;
}
}

View File

@ -0,0 +1,106 @@
package com.sino.publicclass.common;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
* <p>Filter that sets the character encoding to be used in parsing the
* incoming request, either unconditionally or only if the client did not
* specify a character encoding. Configuration of this filter is based on
* the following initialization parameters:</p>
* <ul>
* <li><strong>encoding</strong> - The character encoding to be configured
* for this request, either conditionally or unconditionally based on
* the <code>ignore</code> initialization parameter. This parameter
* is required, so there is no default.</li>
* <li><strong>ignore</strong> - If set to "true", any character encoding
* specified by the client is ignored, and the value returned by the
* <code>selectEncoding()</code> method is set. If set to "false,
* <code>selectEncoding()</code> is called <strong>only</strong> if the
* client has not already specified an encoding. By default, this
* parameter is set to "true".</li>
* </ul>
*
* <p>Although this filter can be used unchanged, it is also easy to
* subclass it and make the <code>selectEncoding()</code> method more
* intelligent about what encoding to choose, based on characteristics of
* the incoming request (such as the values of the <code>Accept-Language</code>
* and <code>User-Agent</code> headers, or a value stashed in the current
* user's session.</p>
*
* Creation date: (2002-07-02 12:03:06)
* @author: redbeans
*/
public class SetCharacterEncodingFilter implements Filter {
/**
* The default character encoding
*/
private final static java.lang.String DEFAULT_ENCODING = "utf-8";
/**
* The default character encoding to set for requests that pass through
* this filter.
*/
protected String encoding = null;
/**
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
*/
protected FilterConfig filterConfig = null;
/**
* Should a character encoding specified by the client be ignored?
*/
protected boolean ignore = true;
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
try {
// Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
if (encoding != null) {
request.setCharacterEncoding(encoding);
} else {
request.setCharacterEncoding(DEFAULT_ENCODING);
}
}
} catch (Exception e) {
System.out.println(e.toString());
}
chain.doFilter(request, response);
}
public FilterConfig getFilterConfig() {
return filterConfig;
}
@Override
public void init(FilterConfig fConfig) throws ServletException {
this.filterConfig = fConfig;
this.encoding = fConfig.getInitParameter("CharacterEncoding");
String value = fConfig.getInitParameter("ignore");
if (value == null) {
this.ignore = true;
} else if (value.equalsIgnoreCase("true")) {
this.ignore = true;
} else if (value.equalsIgnoreCase("yes")) {
this.ignore = true;
} else {
this.ignore = false;
}
}
public void setFilterConfig(FilterConfig fConfig) {
this.filterConfig = fConfig;
}
}

View File

@ -0,0 +1,114 @@
package com.sino.publicclass.database;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.logicalcobwebs.proxool.ProxoolFacade;
import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;
import com.sino.publicclass.base.CException;
public class ConnectionPool {
private static Log log;
private static String configFile = ""; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>
private static String driver = "";
private static String url = "";
private static String usrID = "";
private static String password = "";
private static boolean usePool = false;
private static ConnectionPool instance = null;
private static Integer lock = new Integer(1);
public static void startup() throws CException {
getInstance();
}
public static ConnectionPool getInstance() throws CException {
if (instance == null) {
synchronized (lock) {
if (instance == null) {
instance = new ConnectionPool();
instance.init();
}
}
}
return instance;
}
public static Connection getConnection() throws CException {
return getConnection("proxool.property-default");
}
public static Connection getConnectionStock() throws CException {
return getConnection("proxool.property-default_stock");
}
public static Connection getConnection_comm() throws CException {
return getConnection("proxool.property-comm");
}
public static Connection getConnectionGPS() throws CException {
return getConnection("proxool.property-gps");
}
public static Connection getConnection(String alias) throws CException {
try {
getInstance();
Connection dbCon = DriverManager.getConnection(alias);
int i = 0;
while (dbCon.isClosed()) {
if (i > 100) {
throw new Exception("can't get commection");
}
killConnection(dbCon);
dbCon = DriverManager.getConnection(alias);
i++;
}
return dbCon;
} catch (Exception e) {
log.error("", e);
throw new CException("getConnection() error");
}
}
private static void killConnection(Connection dbCon) throws CException {
try {
ProxoolFacade.killConnecton(dbCon, false);
} catch (Exception e) {
log.error("", e);
throw new CException("killAllConnections_comm() error");
}
}
public static Connection getConnection104() throws CException {
try {
getInstance();
return DriverManager.getConnection("proxool.property-default104");
} catch (Exception e) {
log.error(e.getMessage());
throw new CException("getConnection() error");
}
}
void init() throws CException {
try {
log = LogFactory.getLog(getClass().getName());
log.info("start init connectionPool!!");
configFile = "/dbconfig.properties";
InputStream is = null;
is = getClass().getResourceAsStream(configFile);
Properties dbProps = null;
dbProps = new Properties();
dbProps.load(is);
PropertyConfigurator.configure(dbProps);
} catch (Exception e) {
log.error("ConnectionPool init error", e);
throw new CException("getConnection() init error" + e.getMessage());
}
}
}

View File

@ -0,0 +1,94 @@
package com.sino.publicclass.mapService;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import sun.misc.BASE64Decoder;
import com.alibaba.fastjson.JSON;
import com.sino.publicclass.common.HttpClientDownload;
public class PoiAddress {
private static Log log = LogFactory.getLog(PoiAddress.class);
public static String getWeixinAddress(String lon,String lat){
String convertGps = convertGps(lon,lat);
String[] lonlat = convertGps.split("&");
String address = getPoiAddress(lonlat[0],lonlat[1]);
if(address!=null && !address.equals("")){
address.replace("-", "").replace(" ", "").replace("-", "");
}
return address;
}
private static String convertGps(String lon,String lat){
try {
if (lon != null && lat != null) {
String urlString = "http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x="+lon+"&y="+lat;
HttpClientDownload httpDown = new HttpClientDownload();
httpDown.setFileUrl(urlString);
if (httpDown.download()) {
byte[] httpb = httpDown.getData();
String data = new String(httpb, "utf-8");
Map map = (Map) JSON.parse(data);
String x = (String)map.get("x");
String y = (String)map.get("y");
BASE64Decoder decoder = new BASE64Decoder();
String lonX =new String(decoder.decodeBuffer(x),"UTF-8");
String latY =new String(decoder.decodeBuffer(y),"UTF-8");
//log.error(lonX+"&"+latY);
return lonX+"&"+latY;
}
}
} catch (Exception ee) {
log.error(ee.getMessage());
}
return "";
}
private static String getPoiAddress(String lon,String lat){
try {
if (lon != null && lat != null) {
String urlString = "http://api.map.baidu.com/geocoder/v2/?" +
"ak=UbOsORKwX7HCIbmaBxrEzg0D" +
"&callback=renderReverse" +
"&location="+lat+","+lon +
"&output=json&pois=1";
HttpClientDownload httpDown = new HttpClientDownload();
httpDown.setFileUrl(urlString);
if (httpDown.download()) {
byte[] httpb = httpDown.getData();
String data = new String(httpb, "utf-8");
String jsonStr = data.substring(data.indexOf("{"), data.length()-1);
Map map = (Map) JSON.parse(jsonStr);
Map resultMap = (Map)map.get("result");
String address = (String)resultMap.get("formatted_address");
return address;
}
}
} catch (Exception ee) {
log.error(ee.getMessage());
}
return "";
}
public static void main(String[] args) throws UnsupportedEncodingException, IOException{
String dd = PoiAddress.getPoiAddress("121.494867", "31.205209");
System.out.println(dd);
}
}

View File

@ -0,0 +1,59 @@
package com.sino.publicclass.mapService;
import java.util.Map;
public class SpatialInfo {
private String province;
private String city;
private Map<String,String> crossMap;
private Map<String,String> roadMap;
private Map<String,String> poiMap;
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Map<String, String> getCrossMap() {
return crossMap;
}
public void setCrossMap(Map<String, String> crossMap) {
this.crossMap = crossMap;
}
public Map<String, String> getRoadMap() {
return roadMap;
}
public void setRoadMap(Map<String, String> roadMap) {
this.roadMap = roadMap;
}
public Map<String, String> getPoiMap() {
return poiMap;
}
public void setPoiMap(Map<String, String> poiMap) {
this.poiMap = poiMap;
}
}

View File

@ -0,0 +1,181 @@
package com.sino.publicclass.mapService;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.alibaba.fastjson.JSON;
public class SpatialInfoCenter {
private static Log log = LogFactory.getLog(SpatialInfoCenter.class);
/**
* <20><><EFBFBD>ݾ<EFBFBD>γ<EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD>ѯ<EFBFBD><D1AF>ǰ<EFBFBD><C7B0><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ
* @param lon
* @param lat
* @return
*/
public static String getSpatialInfo(String lon,String lat){
String address = "";
try{
Map<String,String> spatialMap = null;
SpatialInfo info = SpatialInfoCenter.getSpatialMessage(lon, lat);
if(info != null){
Map<String,String> poiMap=info.getPoiMap();
Map<String,String> crossMap=info.getCrossMap();
Map<String,String> roadMap=info.getRoadMap();
if(poiMap!=null && !"".equals(poiMap.get("name")) ){
spatialMap = poiMap;
}else if(crossMap!=null && !"".equals(crossMap.get("name"))){
spatialMap = crossMap;
}else if(roadMap!=null && !"".equals(roadMap.get("name"))){
spatialMap = roadMap;
}else{
}
}
if(spatialMap.get("address")!=null){
address = spatialMap.get("address");
}
if(spatialMap.get("name")!=null && !spatialMap.get("name").equals("")){
address = address + "(" + spatialMap.get("name") + ")";
}
}catch (Exception ee) {
}
return address;
}
public static SpatialInfo getSpatialMessage(String x,String y){
SpatialInfo info = null;
//String a_k = "9777c99f8e963972429e689974a35b0bd9ee35a5c8306ae139ac98f432932286151dc0ec55580eca";
String a_k = "8ba7c38d14da8249f144e8505c49278c2476d8f994db5243eb32207e56ac9d44cb5faf15e2e2a132";
String urlString = null;
String spXml = null;
String postParam = null;
try {
if (x != null && y != null) {
spXml = "<?xml version=\"1.0\" encoding=\"GB2312\"?><spatial_request method=\"searchPoint\"><x>"
+ String.valueOf(x)
+ "</x><y>"
+ String.valueOf(y)
+ "</y><poiNumber>10</poiNumber><range>300</range><pattern>0</pattern><roadLevel>0</roadLevel></spatial_request>";
spXml = URLEncoder.encode(spXml, "GB2312");
postParam = "highLight=false&config=SPAS&ver=2.0&resType=json&enc=GB2312&a_k="+ a_k + "&spatialXml=" + spXml;
//urlString = "http://www.sino-assist.net:8081/sisserver";
urlString = "http://search1.mapabc.com/sisserver";
URL url = new URL(urlString);
URLConnection urlc = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) urlc;
httpConnection.setRequestMethod("POST");
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
httpConnection.connect();
OutputStreamWriter osw = new OutputStreamWriter(
new BufferedOutputStream(
httpConnection.getOutputStream()));
osw.write(postParam);
osw.flush();
osw.close();
BufferedReader br = new BufferedReader(
new InputStreamReader(
httpConnection.getInputStream()));
String line = null;
StringBuffer sb = new StringBuffer("");
while ((line = br.readLine()) != null)
sb.append(line);
httpConnection.disconnect();
//System.out.println(sb.toString());
info = parseMessage(sb.toString());
}
} catch (Exception ee) {
log.error("exception", ee);
}
return info;
}
private static SpatialInfo parseMessage(String message){
SpatialInfo info =new SpatialInfo();
Map<String,String> crossMap = null;
Map<String,String> roadMap = null;
Map<String,String> poiMap = null;
String province = "";
String city = "";
Map map = (Map) JSON.parse(message);
Map spatialMap=(Map)map.get("SpatialBean");
if(spatialMap.get("Province")!=null && !spatialMap.get("Province").equals("")){
province=(String)((Map)spatialMap.get("Province")).get("name");
province = province==null?"":province;
}
if(spatialMap.get("District")!=null && !spatialMap.get("District").equals("")){
city=(String)((Map)spatialMap.get("District")).get("name");
city = city==null?"":city;
}
if(spatialMap.get("crossPoiList")!=null && !spatialMap.get("crossPoiList").equals("")){
List crossList=(List)spatialMap.get("crossPoiList");
if(crossList!=null&&crossList.size()>0){
crossMap=new HashMap<String,String>();
String crossName=(String)((Map)crossList.get(0)).get("name");
crossMap.put("name", crossName);
}
}
if(spatialMap.get("roadList")!=null && !spatialMap.get("roadList").equals("")){
List roadList = (List)spatialMap.get("roadList");
if(roadList.size()>0){
roadMap = new HashMap<String,String>();
String roadName=(String)((Map)roadList.get(0)).get("name");
roadMap.put("name", roadName);
}
}
if(spatialMap.get("poiList")!=null && !spatialMap.get("poiList").equals("")){
List poiList = (List)spatialMap.get("poiList");
if(poiList.size()>0){
Map pMap = (Map)poiList.get(0);
String poiName=(String)pMap.get("name");
String address = (String)pMap.get("address");
String tel = (String)pMap.get("tel");
poiMap = new HashMap<String,String>();
poiMap.put("name", poiName);
poiMap.put("address", province+city+address);
poiMap.put("tel", tel);
}
}
info.setCrossMap(crossMap);
info.setRoadMap(roadMap);
info.setPoiMap(poiMap);
return info;
}
public static void main(String[] args){
String name = SpatialInfoCenter.getSpatialInfo("121.49879196221", "31.213175825735");
System.out.println(name);
}
}

View File

@ -0,0 +1,287 @@
package com.sino.publicclass.sql;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.poi.ss.formula.functions.Now;
import oracle.sql.BLOB;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.util.StaticVar;
import com.sino.publicclass.util.StringTools;
public class ConstructInsertSQL implements ConstructSQL {
private String tableName = "";
private String columns = "";
private String values = "";
private String insertSQL = "";
public ConstructInsertSQL() {
}
public ConstructInsertSQL(String tableName) {
this.tableName = tableName;
}
@Override
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public void setColumn(String columnName, String StringValue) {
if (StringValue != null) {
if (!(StringValue.equals("") || StringValue.equals(null) || StringValue
.equals("null"))) {
if (StringValue.equals("-1")) {
StringValue = "";
}
if (this.columns.equals("")) {
this.columns = columnName;
this.values = StringTools.convertSqlStr(StringValue);
} else {
this.columns += "," + columnName;
this.values += "," + StringTools.convertSqlStr(StringValue);
}
}
}
}
@Override
public void setColumnSql(String columnName, String sqlString) {
if (sqlString != null) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values = sqlString;
} else {
this.columns += "," + columnName;
this.values += "," + sqlString;
}
}
}
@Override
public void setColumn(String columnName, int intValue) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += intValue;
} else {
this.columns += "," + columnName;
this.values += "," + intValue;
}
}
public void setColumn(String columnName, Now time) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += time;
} else {
this.columns += "," + columnName;
this.values += "," + time;
}
}
@Override
public void setColumn(String columnName, double doubleValue) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += doubleValue;
} else {
this.columns += "," + columnName;
this.values += "," + doubleValue;
}
}
@Override
public void setColumn(String columnName, float floatValue) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += floatValue;
} else {
this.columns += "," + columnName;
this.values += "," + floatValue;
}
}
@Override
public void setCondition(String condition) {
}
@Override
public void setColumnSelect(String columnName, String StringValue) {
if (StringValue != null) {
if (!StringValue.equals("-1")) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values = StringTools.convertSqlStr(StringValue);
} else {
this.columns += "," + columnName;
this.values += "," + StringTools.convertSqlStr(StringValue);
}
}
}
}
public void setColumnFull(String columnName, String StringValue) {
if (StringValue != null) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values = StringTools.convertSqlStr(StringValue);
} else {
this.columns += "," + columnName;
this.values += "," + StringTools.convertSqlStr(StringValue);
}
}
}
public void setColumnFull(String columnName, int intValue) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += intValue;
} else {
this.columns += "," + columnName;
this.values += "," + intValue;
}
}
@Override
public void setColumnSelect(String columnName, int intValue) {
if (intValue != -1) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += intValue;
} else {
this.columns += "," + columnName;
this.values += "," + intValue;
}
}
}
@Override
public void setColumnDate(String columnName) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += " SYSDATE ";
} else {
this.columns += "," + columnName;
this.values += "," + "SYSDATE";
}
}
@Override
public void setColumnDate(String columnName, String StringValue) {
if (!StringValue.equals(StaticVar.DONOTUPDATE)) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += " SYSDATE ";
} else {
this.columns += "," + columnName;
this.values += "," + "SYSDATE";
}
}
}
/*public void setColumnDate(String columnName, String StringValue,
String formot) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += "to_date('" + StringValue + "','" + formot + "' )";
} else {
this.columns += "," + columnName;
this.values += "," + "to_date('" + StringValue + "','" + formot
+ "' )";
}
}*/
@Override
public void setColumnDate(String columnName, String StringValue,
String formot) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += "to_date('" + StringValue + "','" + formot + "' )";
} else {
this.columns += "," + columnName;
this.values += "," + "date_format('" + StringValue + "','" + formot
+ "' )";
}
}
public void setColumn(String columnName, Date date) {
if (date == null)
return;
String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(date);
setColumnDate(columnName, dateStr, TIME_FORMAT);
}
@Override
public String getSQL() throws CException {
if (this.tableName.equals("")) {
throw new CException("tableName has not define!");
}
if (this.columns.equals("")) {
throw new CException("column has not define!");
}
this.insertSQL = "insert into " + this.tableName + " (" + this.columns
+ ") values (" + values + ") ";
return insertSQL;
}
@Override
public void setColumn(String columnName, long longValue) {
if (this.columns.equals("")) {
this.columns = columnName;
this.values += longValue;
} else {
this.columns += "," + columnName;
this.values += "," + longValue;
}
}
@Override
public void setColumnTimestamp(String columnName, Date date) {
if (date == null)
return;
if (this.columns.equals("")) {
this.columns = columnName;
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
try {
date = sf.parse(sf.format(date));
this.columns += "," + columnName;
this.values += "," + date;
} catch (ParseException e) {
e.printStackTrace();
}
this.values += date;
} else {
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
date = sf.parse(sf.format(date));
this.columns += "," + columnName;
this.values += "," + "'"+sf.format(date)+"'";
} catch (ParseException e) {
e.printStackTrace();
}
}
/*String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
if (this.columns.equals("")) {
this.columns = columnName;
this.values += "to_date('" + dateStr
+ "','syyyy-mm-dd hh24:mi:ss.ff' )";
} else {
this.columns += "," + columnName;
this.values += "," + "to_date('" + dateStr
+ "','syyyy-mm-dd hh24:mi:ss.ff' )";
}*/
}
@Override
public void setColumn(String columnName, BLOB blob) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,44 @@
package com.sino.publicclass.sql;
import java.util.Date;
import com.sino.publicclass.base.CException;
public interface ConstructSQL {
public static String DAY_FORMAT = "'yyyy-mm-dd'";
public static String TIME_FORMAT = "yyyy-mm-dd hh24:mi:ss";
public static String TIME_FORMAT1 = "yyyymmddhh24miss";
public void setTableName(String tableName);
public void setColumn(String columnName, String StringValue);
public void setColumnSql(String columnName, String SqlString);
public void setColumn(String columnName, int intValue);
public void setColumn(String columnName, double doubleValue);
public void setColumn(String columnName, float floatValue);
public void setColumn(String columnName, long longValue);
public void setColumn(String columnName, oracle.sql.BLOB blob);
public void setColumnDate(String columnName);
public void setColumnDate(String columnName, String StringValue);
public void setColumnDate(String columnName, String StringValue,
String formot);
public void setColumnSelect(String columnName, String StringValue);
public void setColumnSelect(String columnName, int intValue);
public String getSQL() throws CException;
public void setCondition(String condition);
public void setColumnTimestamp(String columnName, Date date);
}

View File

@ -0,0 +1,215 @@
package com.sino.publicclass.sql;
import java.text.SimpleDateFormat;
import java.util.Date;
import oracle.sql.BLOB;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.util.StaticVar;
import com.sino.publicclass.util.StringTools;
public class ConstructUpdateSQL implements ConstructSQL {
private String tableName = "";
private String columns = "";
private String condition = "";
private String updateSQL = "";
public ConstructUpdateSQL() {
}
public ConstructUpdateSQL(String tableName) {
this.tableName = tableName;
}
@Override
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public void setColumn(String columnName, String StringValue) {
if (StringValue != null) {
if (this.columns.equals("")) {
this.columns = columnName + "="
+ StringTools.convertSqlStr(StringValue);
} else {
this.columns += "," + columnName + "="
+ StringTools.convertSqlStr(StringValue);
}
}
}
@Override
public void setColumnSql(String columnName, String sqlString) {
if (sqlString != null) {
if (this.columns.equals("")) {
this.columns = columnName + "=" + sqlString;
} else {
this.columns += "," + columnName + "=" + sqlString;
}
}
}
@Override
public void setColumn(String columnName, int intValue) {
if (this.columns.equals("")) {
this.columns = columnName + "=" + intValue;
} else {
this.columns += "," + columnName + "=" + intValue;
}
}
@Override
public void setColumn(String columnName, float floatValue) {
if (this.columns.equals("")) {
this.columns = columnName + "=" + floatValue;
} else {
this.columns += "," + columnName + "=" + floatValue;
}
}
@Override
public void setColumnSelect(String columnName, String StringValue) {
if (StringValue != null) {
if (StringValue.equals("-1")) {
StringValue = "null";
} else {
StringValue = StringTools.convertSqlStr(StringValue);
}
}
if (this.columns.equals("")) {
this.columns = columnName + "=" + StringValue;
} else {
this.columns += "," + columnName + "=" + StringValue;
}
}
@Override
public void setColumnSelect(String columnName, int intValue) {
String StringValue = "";
if (intValue == -1) {
StringValue = "null";
} else {
StringValue += intValue;
}
if (this.columns.equals("")) {
this.columns = columnName + "=" + StringValue;
} else {
this.columns += "," + columnName + "=" + StringValue;
}
}
@Override
public void setColumn(String columnName, double doubleValue) {
if (this.columns.equals("")) {
this.columns = columnName + "=" + doubleValue;
} else {
this.columns += "," + columnName + "=" + doubleValue;
}
}
@Override
public void setColumnDate(String columnName) {
if (this.columns.equals("")) {
this.columns = columnName + "=SYSDATE";
} else {
this.columns += "," + columnName + "=SYSDATE";
}
}
@Override
public void setColumnDate(String columnName, String StringValue) {
if (!StringValue.equals(StaticVar.DONOTUPDATE)) {
if (this.columns.equals("")) {
this.columns = columnName + "=SYSDATE";
} else {
this.columns += "," + columnName + "=SYSDATE";
}
}
}
@Override
public void setColumnDate(String columnName, String StringValue,
String formot) {
if (this.columns.equals("")) {
this.columns = columnName + "=" + "to_date('" + StringValue + "','"
+ formot + "' )";
} else {
this.columns += "," + columnName + "=" + "to_date('" + StringValue
+ "','" + formot + "' )";
}
}
public void setColumn(String columnName, Date date) {
if (date == null)
return;
String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(date);
setColumnDate(columnName, dateStr, TIME_FORMAT);
}
@Override
public String getSQL() throws CException {
if (this.tableName.equals("")) {
throw new CException("tableName has not define!");
}
if (this.columns.equals("")) {
throw new CException("column has not define!");
}
if (!this.condition.equals("")) {
this.condition = " where " + this.condition;
}
this.updateSQL = "update " + this.tableName + " set " + this.columns
+ this.condition;
return updateSQL;
}
@Override
public void setCondition(String condition) {
this.condition = condition;
}
@Override
public void setColumn(String columnName, long longValue) {
if (this.columns.equals("")) {
this.columns = columnName + "=" + longValue;
} else {
this.columns += "," + columnName + "=" + longValue;
}
}
@Override
public void setColumnTimestamp(String columnName, Date date) {
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (date == null)
return;
if (this.columns.equals("")) {
this.columns = columnName;
this.columns += columnName+"='"+sf.format(date)+"'";
} else {
this.columns += "," + columnName+"='"+sf.format(date)+"'";
}
/*if (date == null)
return;
String dateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
.format(date);
if (this.columns.equals("")) {
this.columns = columnName + "=" + "to_date('" + dateStr
+ "','syyyy-mm-dd hh24:mi:ss.ff' )";
} else {
this.columns += "," + columnName + "=" + "to_date('" + dateStr
+ "','syyyy-mm-dd hh24:mi:ss.ff' )";
}*/
}
@Override
public void setColumn(String columnName, BLOB blob) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,31 @@
package com.sino.publicclass.util;
public class BLOBObject {
public static String ConvertBLOBtoString(oracle.sql.BLOB BlobContent)
{
byte[] msgContent= BlobContent.getBytes(); //BLOBת<42><D7AA>Ϊ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
byte[] bytes; //BLOB<4F><42>ʱ<EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
String newStr = ""; //<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
int i=1; //ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
long BlobLength; //BLOB<4F>ֶγ<D6B6><CEB3><EFBFBD>
try
{
BlobLength=BlobContent.length(); //<2F><>ȡBLOB<4F><42><EFBFBD><EFBFBD>
if (msgContent == null || BlobLength==0) //<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD>ؿ<EFBFBD>ֵ
{
return "";
}
else //<2F><><EFBFBD><EFBFBD>BLOBΪ<42>ַ<EFBFBD><D6B7><EFBFBD>
{
newStr = new String(BlobContent.getBytes(1,900),"utf-8"); //<2F>򻯴<EFBFBD><F2BBAFB4><EFBFBD><EFBFBD><EFBFBD>ֻȡǰ900<30>ֽ<EFBFBD>
return newStr;
}
}catch(Exception e) //oracle<6C><EFBFBD><ECB3A3><EFBFBD><EFBFBD>
{
e.printStackTrace();
}
return newStr;
}
}

View File

@ -0,0 +1,54 @@
package com.sino.publicclass.util;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.RcNewAreaPO;
import com.sino.rrs.oper.RcNewAreaOper;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class CommonType {
/**
* <20><>ѯ<EFBFBD><D1AF><EFBFBD>е<EFBFBD>ʡ<EFBFBD><CAA1>
* @return
*/
public static String getAllProvince(String loginName){
StringBuilder sb=new StringBuilder();
JSONObject jsonObject=new JSONObject();
Connection conn=null;
jsonObject.put("loginName", loginName);
jsonObject.put("action", 18);
JSONObject jsonList=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"UTF-8"));
String managerArea = (String) jsonList.get("managerArea");
if(null!=managerArea){
try {
conn=ConnectionPool.getConnection();
RcNewAreaOper oper=new RcNewAreaOper(conn);
List<RcNewAreaPO> provinceList = oper.queryPrivince(managerArea.toString());
for(RcNewAreaPO province:provinceList){
sb.append("<li class='provinceListItem' areaid='").append(province.getAreaid()).append("'>").append(province.getAreaname()).append("</li><li class='border-1px'></li>");
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
return sb.toString();
}
public static void main(String[] args) {
CommonType.getAllProvince("");
}
}

View File

@ -0,0 +1,54 @@
package com.sino.publicclass.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBUtils {
private static String url = "jdbc:mysql://www.sino-assist.com:3306/weixin";
private static String user = "root";
private static String password = "123456";
static {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
private DBUtils() {
}
/**
* <20><EFBFBD><E1B9A9><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
*
* @return
*/
public static Connection getConnection() {
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
e.printStackTrace();
System.out.println("<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD>󴴽<EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
return conn;
}
/**
* <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
* @param conn
*/
public static void close(Connection conn){
try {
if(conn!=null&&!conn.isClosed()){
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
System.out.println(getConnection());
}
}

View File

@ -0,0 +1,262 @@
package com.sino.publicclass.util;
import java.util.*;
import java.text.*;
import java.util.Date;
/**
* <p>
* Title: workflow
* </p>
* <p>
* Description:
* </p>
* <p>
* Copyright: Copyright (c) 2002
* </p>
* <p>
* Company: china317
* </p>
*
* @author maple.shi
* @version 1.0
*/
public class DateTime {
/*
* yyyyMMddHHmmss
*/
public static final String PATTERN_0 = "yyyyMMddHHmmss";
/*
* yyyy-MM-dd HH:mm:ss
*/
public static final String PATTERN_1 = "yyyy-MM-dd HH:mm:ss";
/*
* yyyy-MM-dd
*/
public static final String PATTERN_2 = "yyyy-MM-dd";
/*
* yyyy<79><79>MM<4D><4D>dd<64><64> HHʱmm<6D><6D>ss<73><73>
*/
public static final String PATTERN_3 = "yyyy<EFBFBD><EFBFBD>MM<EFBFBD><EFBFBD>dd<EFBFBD><EFBFBD> HHʱmm<6D><6D>ss<73><73>";
/*
* yyyy<79><79>MM<4D><4D>dd<64><64>
*/
public static final String PATTERN_4 = "yyyy<EFBFBD><EFBFBD>MM<EFBFBD><EFBFBD>dd<EFBFBD><EFBFBD>";
/*
* yyyy-MM-dd HH:mm
*/
public static final String PATTERN_5 = "yyyy-MM-dd HH:mm";
/*
* yyyy<79><79>MM<4D><4D>dd<64><64> HHʱmm<6D><6D>
*/
public static final String PATTERN_6 = "yyyy<EFBFBD><EFBFBD>MM<EFBFBD><EFBFBD>dd<EFBFBD><EFBFBD> HHʱmm<6D><6D>";
/**
* yyyyMMdd
*/
public static final String PATTERN_7 = "yyyyMMdd";
public static String getCurrentTime() {
return new SimpleDateFormat(PATTERN_1).format(new Date());
}
public static String getSysTime() {
return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
}
public static String getToday() {
return new SimpleDateFormat("yyyyMMdd").format(new Date());
}
public static String getDateAndTimeString(Date t) {
if (null != t){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = formatter.format(t);
return time;
} else {
return "";
}
}
public static String getDateTimeShortString(Date t) {
if (null != t){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String time = formatter.format(t);
return time;
} else {
return "";
}
}
public static byte[] getSimpleSysTime() {
byte[] ret = new byte[3];
Calendar now = Calendar.getInstance();
ret[0] = (byte) now.get(Calendar.HOUR_OF_DAY);
ret[1] = (byte) now.get(Calendar.MINUTE);
ret[2] = (byte) now.get(Calendar.SECOND);
return ret;
}
/*
*
*/
public static String getTime(String pattern, Calendar cal) {
return new SimpleDateFormat(pattern).format(cal.getTime());
}
public static String getTime(String pattern, Date date) {
return new SimpleDateFormat(pattern).format(date.getTime());
}
public static String getSysTime(String pattern) {
return new SimpleDateFormat(pattern).format(new Date());
}
public static Calendar getDateTime(String dateTime) {
Calendar date = (Calendar) Calendar.getInstance().clone();
int year = parseInt(dateTime.substring(0, 4), 1900);
int Month = parseInt(dateTime.substring(4, 6), 1) - 1;
int day = parseInt(dateTime.substring(6, 8), 1);
int hh = parseInt(dateTime.substring(8, 10), 0);
int mm = parseInt(dateTime.substring(10, 12), 0);
int ss = parseInt(dateTime.substring(12, 14), 0);
date.set(year, Month, day, hh, mm, ss);
return date;
}
public static String getDateTimeString(Date t) {
if (null != t) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
return formatter.format(t);
} else {
return "";
}
}
public static String reFormatTime(String str, String oldPattern, String newPattern) {
try {
SimpleDateFormat oldFormat = new SimpleDateFormat(oldPattern);
SimpleDateFormat newFormat = new SimpleDateFormat(newPattern);
return newFormat.format(oldFormat.parse(str));
} catch (Exception e) {
System.out.println("format tiem Error (" + e.toString() + ")");
return null;
}// try//
}
public static String formatTime(String str, String pattern) {
try {
if (str == null)
return null;
int size = str.length();
if (size == 0) {
return "";
}
if (size < 14) {
for (int i = 0; i < 14 - size; i++)
str = str + "0";
}
int nYear = Integer.parseInt(str.substring(0, 4), 10);
int nMonth = Integer.parseInt(str.substring(4, 6), 10);
int nDay = Integer.parseInt(str.substring(6, 8), 10);
int nHour = Integer.parseInt(str.substring(8, 10), 10);
int nMinute = Integer.parseInt(str.substring(10, 12), 10);
int nSecond = Integer.parseInt(str.substring(12, 14), 10);
Calendar tmpCalendar = Calendar.getInstance(TimeZone.getTimeZone("CTT"));
tmpCalendar.set(nYear, nMonth - 1, nDay, nHour, nMinute, nSecond);
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
Date tmpDate = tmpCalendar.getTime();
return formatter.format(tmpDate);
} catch (Exception e) {
return null;
}
}
public static String formatTime(String str) {
try {
if (str == null)
return null;
int size = str.length();
if (size < 6) {
for (int i = 0; i < 6 - size; i++)
str = "0" + str;
}
return str.substring(0, 2) + ":" + str.substring(2, 4) + ":" + str.substring(4, 6);
} catch (Exception e) {
return "";
}
}
public static int parseInt(String str, int defaultvalue) {
try {
return Integer.parseInt(str);
} catch (Exception e) {
e.printStackTrace();
return defaultvalue;
}
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>,<2C><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
*
* @param time1
* @param time2
* @return
*/
public static int accountTime(String time1, String time2) {
Calendar c1 = getDateTime(time1);
Calendar c2 = getDateTime(time2);
return (int) ((c2.getTimeInMillis() - c1.getTimeInMillis()) / 1000);
}
/**
* <20><><EFBFBD>ڸ<EFBFBD>ʽyyyy-MM-dd HH:mm:ss ת yyyyMMddHHmmss
* @param str
* @return
*/
public static String transDateTime(String str) {
try {
if (str == null)
return null;
int size = str.length();
if (size < 19) {
return "";
}
String nYear = str.substring(0, 4);
String nMonth = str.substring(5, 7);
String nDay = str.substring(8, 10);
String nHour = str.substring(11, 13);
String nMinute = str.substring(14, 16);
String nSecond = str.substring(17, 19);
return nYear+nMonth+nDay+nHour+nMinute+nSecond;
} catch (Exception e) {
return null;
}
}
public static Date StringToDate(String dateStr,String formatStr){
DateFormat sdf=new SimpleDateFormat(formatStr);
Date date=null;
try {
date = sdf.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static void main(String[] args) {
// System.out.println(getTime(PATTERN_7, Calendar.getInstance()));
//DateTime.getDateTime("2011-08-18 15:01:21");
//String dd=DateTime.formatTime("20110915132345",PATTERN_0);
DateFormat sdf=new SimpleDateFormat(PATTERN_0);
Date date=null;
try {
date = sdf.parse("20110915132345");
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(date);
}
}

View File

@ -0,0 +1,132 @@
package com.sino.publicclass.util;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.alibaba.fastjson.JSON;
public class DecodeAddress {
private static Log log = LogFactory.getLog(DecodeAddress.class);
public static String getAddressName(double lon,double lat){
String address = "";
String a_k = "c82012c4404abebdb9d8f2978db2a37d81cdfde1ee06475c4a0261f8cce311c9e6e78d14bf99d397";
String urlString = null;
String spXml = null;
String postParam = null;
try {
if (lon>0 && lon<180 && lat>0 && lat<180) {
spXml = "<?xml version=\"1.0\" encoding=\"GB2312\"?><spatial_request method=\"searchPoint\"><x>"
+ String.valueOf(lon)
+ "</x><y>"
+ String.valueOf(lat)
+ "</y><poiNumber>10</poiNumber><range>300</range><pattern>0</pattern><roadLevel>0</roadLevel></spatial_request>";
spXml = URLEncoder.encode(spXml, "GB2312");
postParam = "highLight=false&config=SPAS&ver=2.0&resType=json&enc=GB2312&a_k="+ a_k + "&spatialXml=" + spXml;
urlString = "http://search1.mapabc.com/sisserver";
URL url = new URL(urlString);
URLConnection urlc = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) urlc;
httpConnection.setRequestMethod("POST");
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
httpConnection.connect();
OutputStreamWriter osw = new OutputStreamWriter(
new BufferedOutputStream(
httpConnection.getOutputStream()));
osw.write(postParam);
osw.flush();
osw.close();
BufferedReader br = new BufferedReader(
new InputStreamReader(
httpConnection.getInputStream()));
String line = null;
StringBuffer sb = new StringBuffer("");
while ((line = br.readLine()) != null)
sb.append(line);
httpConnection.disconnect();
//System.out.println(sb.toString());
address = parseMessage(sb.toString());
}
} catch (Exception ee) {
log.error("exception", ee);
}
return address;
}
private static String parseMessage(String message){
String addressName = "";
Map<String,String> crossMap = null;
Map<String,String> roadMap = null;
Map<String,String> poiMap = null;
Map map = (Map) JSON.parse(message);
Map spatialMap=(Map)map.get("SpatialBean");
List crossList=(List)spatialMap.get("crossPoiList");
if(crossList.size()>0){
crossMap=new HashMap<String,String>();
String crossName=(String)((Map)crossList.get(0)).get("name");
crossMap.put("name", crossName);
}
List roadList = (List)spatialMap.get("roadList");
if(roadList.size()>0){
roadMap = new HashMap<String,String>();
String roadName=(String)((Map)roadList.get(0)).get("name");
roadMap.put("name", roadName);
}
List poiList = (List)spatialMap.get("poiList");
if(poiList.size()>0){
Map pMap = (Map)poiList.get(0);
String poiName=(String)pMap.get("name");
String address = (String)pMap.get("address");
String tel = (String)pMap.get("tel");
poiMap = new HashMap<String,String>();
poiMap.put("name", poiName);
poiMap.put("address", address);
poiMap.put("tel", tel);
}
Map provinceMap=(Map)spatialMap.get("Province");
String provinceName = (String)provinceMap.get("name");
Map areaMap=(Map)spatialMap.get("District");
String areaName = (String)areaMap.get("name");
if(poiMap!=null && !"".equals(poiMap.get("name")) ){
addressName = poiMap.get("address")+" " +poiMap.get("name");
}else if(crossMap!=null && !"".equals(crossMap.get("name"))){
addressName = crossMap.get("name");
}else if(roadMap!=null && !"".equals(roadMap.get("name"))){
addressName = roadMap.get("name");
}
return provinceName+areaName+addressName;
}
public static void main(String[] args){
//SpatialInfoCenter.getSpatialInfo("121.4614627778", "31.2294658333");
String info = DecodeAddress.getAddressName(121.4614627778, 31.2294658333);
java.net.URLEncoder.encode("");
System.out.println("info="+info);
}
}

View File

@ -0,0 +1,52 @@
package com.sino.publicclass.util;
public class DistanceUtil {
private static final double EARTH_RADIUS = 6378.137;
private static final double DISTANCE_RATIO = 1.3;
private static double rad(double d) {
return d * Math.PI / 180.0;
}
/**
* ????}?????????????/<2F><>???
*
* @param lat1
* @param lng1
* @param lat2
* @param lng2
* @return
*/
public static double GetDistance(double lat1, double lng1, double lat2,
double lng2) {
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
+ Math.cos(radLat1) * Math.cos(radLat2)
* Math.pow(Math.sin(b / 2), 2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) * DISTANCE_RATIO/ 10000d;
return s;
}
public static double D_jw(double wd1, double jd1, double wd2, double jd2) {
double x, y, out;
double PI = 3.14159265;
double R = 6.371229 * 1e6;
x = (jd2 - jd1) * PI * R * Math.cos(((wd1 + wd2) / 2) * PI / 180) / 180;
y = (wd2 - wd1) * PI * R / 180;
out = Math.hypot(x, y);
return out / 1000;
}
public static void main(String args[]) {
// 31.1795100,121.394481031.1822952
System.out.println((int)DistanceUtil.GetDistance(121.393,31.3151, 169.501, 31.9985));
}
}

View File

@ -0,0 +1,373 @@
/************************************************
MD5 <20><EFBFBD><E3B7A8>Java Bean
*************************************************/
package com.sino.publicclass.util;
/*************************************************
md5 <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>RSA Data Security, Inc.<2E><><EFBFBD><EFBFBD><E1BDBB>IETF
<20><>RFC1321<32>е<EFBFBD>MD5 message-digest <20><EFBFBD><E3B7A8>
*************************************************/
public class MD5 {
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ЩS11-S44ʵ<34><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>4*4<>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><43><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>#define ʵ<>ֵģ<D6B5>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ֳ<EFBFBD>Ϊstatic final<61>DZ<EFBFBD>ʾ<EFBFBD><CABE>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD><EFBFBD><EFBFBD>̿ռ<CCBF><D5BC>ڵĶ<DAB5><C4B6><EFBFBD>
Instance<63><EFBFBD><E4B9B2>*/
static final int S11 = 7;
static final int S12 = 12;
static final int S13 = 17;
static final int S14 = 22;
static final int S21 = 5;
static final int S22 = 9;
static final int S23 = 14;
static final int S24 = 20;
static final int S31 = 4;
static final int S32 = 11;
static final int S33 = 16;
static final int S34 = 23;
static final int S41 = 6;
static final int S42 = 10;
static final int S43 = 15;
static final int S44 = 21;
static final byte[] PADDING = {
-128, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>MD5<44><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>ԭʼ<D4AD><CABC><43><CAB5><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD>嵽MD5_CTX<54><EFBFBD><E1B9B9>
*/
private long[] state = new long[4]; // state (ABCD)
private long[] count = new long[2]; // number of bits, modulo 2^64 (lsb first)
private byte[] buffer = new byte[64]; // input buffer
/* digestHexStr<74><72>MD5<44><35>Ψһһ<D2BB><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><> 16<31><36><EFBFBD><EFBFBD>ASCII<49><49>ʾ.
*/
public String digestHexStr;
/* digest,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ128bit<69><74>MD5ֵ.
*/
private byte[] digest = new byte[16];
/*
getMD5ofStr<74><72><EFBFBD><EFBFBD>MD5<44><35><EFBFBD><EFBFBD>Ҫ<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>MD5<44><EFBFBD><E4BBBB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
<20><><EFBFBD>ص<EFBFBD><D8B5>DZ任<C7B1><E4BBBB><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵӹ<C7B4><D3B9><EFBFBD><EFBFBD><EFBFBD>ԱdigestHexStrȡ<72>õģ<C3B5>
*/
public String getMD5ofStr(String inbuf) {
md5Init();
md5Update(inbuf.getBytes(), inbuf.length());
md5Final();
digestHexStr = "";
for (int i = 0; i < 16; i++) {
digestHexStr += byteHEX(digest[i]);
}
return digestHexStr;
}
// <20><><EFBFBD><EFBFBD>MD5<44><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><ECBAAF><EFBFBD><EFBFBD>JavaBeanҪ<6E><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>public<69>IJ<EFBFBD><C4B2><EFBFBD>û<EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><ECBAAF>
public MD5() {
md5Init();
return;
}
/* md5Init<69><74>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>׼<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD> */
private void md5Init() {
count[0] = 0L;
count[1] = 0L;
///* Load magic initialization constants.
state[0] = 0x67452301L;
state[1] = 0xefcdab89L;
state[2] = 0x98badcfeL;
state[3] = 0x10325476L;
return;
}
/* F, G, H ,I <20><>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MD5<44><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC>MD5<44><35><43><CAB5><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20>򵥵<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><E3A3AC><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>Ч<EFBFBD>ʵĿ<CAB5><C4BF>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ֳ<EFBFBD><D6B3>˺꣬<CBBA><EAA3AC>java<76>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>ʵ<EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>private<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>C<EFBFBD>еġ<D0B5> */
private long F(long x, long y, long z) {
return (x & y) | ( (~x) & z);
}
private long G(long x, long y, long z) {
return (x & z) | (y & (~z));
}
private long H(long x, long y, long z) {
return x ^ y ^ z;
}
private long I(long x, long y, long z) {
return y ^ (x | (~z));
}
/*
FF,GG,HH<48><48>II<49><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>F,G,H,I<><49><EFBFBD>н<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>
FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
private long FF(long a, long b, long c, long d, long x, long s,
long ac) {
a += F(b, c, d) + x + ac;
a = ( (int) a << s) | ( (int) a >>> (32 - s));
a += b;
return a;
}
private long GG(long a, long b, long c, long d, long x, long s,
long ac) {
a += G(b, c, d) + x + ac;
a = ( (int) a << s) | ( (int) a >>> (32 - s));
a += b;
return a;
}
private long HH(long a, long b, long c, long d, long x, long s,
long ac) {
a += H(b, c, d) + x + ac;
a = ( (int) a << s) | ( (int) a >>> (32 - s));
a += b;
return a;
}
private long II(long a, long b, long c, long d, long x, long s,
long ac) {
a += I(b, c, d) + x + ac;
a = ( (int) a << s) | ( (int) a >>> (32 - s));
a += b;
return a;
}
/*
md5Update<74><65>MD5<44><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣<EFBFBD>inbuf<75><66>Ҫ<EFBFBD><EFBFBD><E4BBBB><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD>inputlen<65>dz<EFBFBD><C7B3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>getMD5ofStr<74><72><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>md5init<69><74><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>private<74><65>
*/
private void md5Update(byte[] inbuf, int inputLen) {
int i, index, partLen;
byte[] block = new byte[64];
index = (int) (count[0] >>> 3) & 0x3F;
// /* Update number of bits */
if ( (count[0] += (inputLen << 3)) < (inputLen << 3)) {
count[1]++;
}
count[1] += (inputLen >>> 29);
partLen = 64 - index;
// Transform as many times as possible.
if (inputLen >= partLen) {
md5Memcpy(buffer, inbuf, index, 0, partLen);
md5Transform(buffer);
for (i = partLen; i + 63 < inputLen; i += 64) {
md5Memcpy(block, inbuf, 0, i, 64);
md5Transform(block);
}
index = 0;
}
else {
i = 0;
///* Buffer remaining input */
}
md5Memcpy(buffer, inbuf, index, i, inputLen - i);
}
/*
md5Final<61><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
private void md5Final() {
byte[] bits = new byte[8];
int index, padLen;
///* Save number of bits */
Encode(bits, count, 8);
///* Pad out to 56 mod 64.
index = (int) (count[0] >>> 3) & 0x3f;
padLen = (index < 56) ? (56 - index) : (120 - index);
md5Update(PADDING, padLen);
///* Append length (before padding) */
md5Update(bits, 8);
///* Store state in digest */
Encode(digest, state, 16);
}
/* md5Memcpy<70><79>һ<EFBFBD><D2BB><EFBFBD>ڲ<EFBFBD>ʹ<EFBFBD>õ<EFBFBD>byte<74><65><EFBFBD><EFBFBD><EFBFBD>Ŀ鿽<C4BF><E9BFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>input<75><74>inpos<6F><73>ʼ<EFBFBD><CABC>len<65><6E><EFBFBD>ȵ<EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ֽڿ<D6BD><DABF><EFBFBD><EFBFBD><EFBFBD>output<75><74>outposλ<73>ÿ<EFBFBD>ʼ
*/
private void md5Memcpy(byte[] output, byte[] input,
int outpos, int inpos, int len) {
int i;
for (i = 0; i < len; i++) {
output[outpos + i] = input[inpos + i];
}
}
/*
md5Transform<72><6D>MD5<44><35><EFBFBD>ı<C4B1><E4BBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>md5Update<74><65><EFBFBD>ã<EFBFBD>block<63>Ƿֿ<C7B7><D6BF><EFBFBD>ԭʼ<D4AD>ֽ<EFBFBD>
*/
private void md5Transform(byte block[]) {
long a = state[0], b = state[1], c = state[2], d = state[3];
long[] x = new long[16];
Decode(x, block, 64);
/* Round 1 */
a = FF(a, b, c, d, x[0], S11, 0xd76aa478L); /* 1 */
d = FF(d, a, b, c, x[1], S12, 0xe8c7b756L); /* 2 */
c = FF(c, d, a, b, x[2], S13, 0x242070dbL); /* 3 */
b = FF(b, c, d, a, x[3], S14, 0xc1bdceeeL); /* 4 */
a = FF(a, b, c, d, x[4], S11, 0xf57c0fafL); /* 5 */
d = FF(d, a, b, c, x[5], S12, 0x4787c62aL); /* 6 */
c = FF(c, d, a, b, x[6], S13, 0xa8304613L); /* 7 */
b = FF(b, c, d, a, x[7], S14, 0xfd469501L); /* 8 */
a = FF(a, b, c, d, x[8], S11, 0x698098d8L); /* 9 */
d = FF(d, a, b, c, x[9], S12, 0x8b44f7afL); /* 10 */
c = FF(c, d, a, b, x[10], S13, 0xffff5bb1L); /* 11 */
b = FF(b, c, d, a, x[11], S14, 0x895cd7beL); /* 12 */
a = FF(a, b, c, d, x[12], S11, 0x6b901122L); /* 13 */
d = FF(d, a, b, c, x[13], S12, 0xfd987193L); /* 14 */
c = FF(c, d, a, b, x[14], S13, 0xa679438eL); /* 15 */
b = FF(b, c, d, a, x[15], S14, 0x49b40821L); /* 16 */
/* Round 2 */
a = GG(a, b, c, d, x[1], S21, 0xf61e2562L); /* 17 */
d = GG(d, a, b, c, x[6], S22, 0xc040b340L); /* 18 */
c = GG(c, d, a, b, x[11], S23, 0x265e5a51L); /* 19 */
b = GG(b, c, d, a, x[0], S24, 0xe9b6c7aaL); /* 20 */
a = GG(a, b, c, d, x[5], S21, 0xd62f105dL); /* 21 */
d = GG(d, a, b, c, x[10], S22, 0x2441453L); /* 22 */
c = GG(c, d, a, b, x[15], S23, 0xd8a1e681L); /* 23 */
b = GG(b, c, d, a, x[4], S24, 0xe7d3fbc8L); /* 24 */
a = GG(a, b, c, d, x[9], S21, 0x21e1cde6L); /* 25 */
d = GG(d, a, b, c, x[14], S22, 0xc33707d6L); /* 26 */
c = GG(c, d, a, b, x[3], S23, 0xf4d50d87L); /* 27 */
b = GG(b, c, d, a, x[8], S24, 0x455a14edL); /* 28 */
a = GG(a, b, c, d, x[13], S21, 0xa9e3e905L); /* 29 */
d = GG(d, a, b, c, x[2], S22, 0xfcefa3f8L); /* 30 */
c = GG(c, d, a, b, x[7], S23, 0x676f02d9L); /* 31 */
b = GG(b, c, d, a, x[12], S24, 0x8d2a4c8aL); /* 32 */
/* Round 3 */
a = HH(a, b, c, d, x[5], S31, 0xfffa3942L); /* 33 */
d = HH(d, a, b, c, x[8], S32, 0x8771f681L); /* 34 */
c = HH(c, d, a, b, x[11], S33, 0x6d9d6122L); /* 35 */
b = HH(b, c, d, a, x[14], S34, 0xfde5380cL); /* 36 */
a = HH(a, b, c, d, x[1], S31, 0xa4beea44L); /* 37 */
d = HH(d, a, b, c, x[4], S32, 0x4bdecfa9L); /* 38 */
c = HH(c, d, a, b, x[7], S33, 0xf6bb4b60L); /* 39 */
b = HH(b, c, d, a, x[10], S34, 0xbebfbc70L); /* 40 */
a = HH(a, b, c, d, x[13], S31, 0x289b7ec6L); /* 41 */
d = HH(d, a, b, c, x[0], S32, 0xeaa127faL); /* 42 */
c = HH(c, d, a, b, x[3], S33, 0xd4ef3085L); /* 43 */
b = HH(b, c, d, a, x[6], S34, 0x4881d05L); /* 44 */
a = HH(a, b, c, d, x[9], S31, 0xd9d4d039L); /* 45 */
d = HH(d, a, b, c, x[12], S32, 0xe6db99e5L); /* 46 */
c = HH(c, d, a, b, x[15], S33, 0x1fa27cf8L); /* 47 */
b = HH(b, c, d, a, x[2], S34, 0xc4ac5665L); /* 48 */
/* Round 4 */
a = II(a, b, c, d, x[0], S41, 0xf4292244L); /* 49 */
d = II(d, a, b, c, x[7], S42, 0x432aff97L); /* 50 */
c = II(c, d, a, b, x[14], S43, 0xab9423a7L); /* 51 */
b = II(b, c, d, a, x[5], S44, 0xfc93a039L); /* 52 */
a = II(a, b, c, d, x[12], S41, 0x655b59c3L); /* 53 */
d = II(d, a, b, c, x[3], S42, 0x8f0ccc92L); /* 54 */
c = II(c, d, a, b, x[10], S43, 0xffeff47dL); /* 55 */
b = II(b, c, d, a, x[1], S44, 0x85845dd1L); /* 56 */
a = II(a, b, c, d, x[8], S41, 0x6fa87e4fL); /* 57 */
d = II(d, a, b, c, x[15], S42, 0xfe2ce6e0L); /* 58 */
c = II(c, d, a, b, x[6], S43, 0xa3014314L); /* 59 */
b = II(b, c, d, a, x[13], S44, 0x4e0811a1L); /* 60 */
a = II(a, b, c, d, x[4], S41, 0xf7537e82L); /* 61 */
d = II(d, a, b, c, x[11], S42, 0xbd3af235L); /* 62 */
c = II(c, d, a, b, x[2], S43, 0x2ad7d2bbL); /* 63 */
b = II(b, c, d, a, x[9], S44, 0xeb86d391L); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
}
/*Encode<64><65>long<6E><67><EFBFBD>鰴˳<E9B0B4><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>byte<74><65><EFBFBD><EFBFBD><E9A3AC>Ϊjava<76><61>long<6E><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>64bit<69>ģ<EFBFBD>
ֻ<><D6BB><EFBFBD><EFBFBD>32bit<69><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧԭʼ<43>ֵ<EFBFBD><D6B5><EFBFBD>;
*/
private void Encode(byte[] output, long[] input, int len) {
int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (byte) (input[i] & 0xffL);
output[j + 1] = (byte) ( (input[i] >>> 8) & 0xffL);
output[j + 2] = (byte) ( (input[i] >>> 16) & 0xffL);
output[j + 3] = (byte) ( (input[i] >>> 24) & 0xffL);
}
}
/*Decode<64><65>byte<74><65><EFBFBD>鰴˳<E9B0B4><CBB3><EFBFBD>ϳɳ<CFB3>long<6E><67><EFBFBD><EFBFBD><E9A3AC>Ϊjava<76><61>long<6E><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>64bit<69>ģ<EFBFBD>
ֻ<>ϳɵ<CFB3>32bit<69><74><EFBFBD><EFBFBD>32bit<69><74><EFBFBD><EFBFBD><E3A3AC><EFBFBD><EFBFBD>Ӧԭʼ<43>ֵ<EFBFBD><D6B5><EFBFBD>;
*/
private void Decode(long[] output, byte[] input, int len) {
int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[i] = b2iu(input[j]) |
(b2iu(input[j + 1]) << 8) |
(b2iu(input[j + 2]) << 16) |
(b2iu(input[j + 3]) << 24);
}
return;
}
/*
b2iu<69><75>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>byte<74><65><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊjavaû<61><C3BB>unsigned<65><64><EFBFBD><EFBFBD>
*/
public static long b2iu(byte b) {
return b < 0 ? b & 0x7F + 128 : b;
}
/*byteHEX()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>byte<74><65><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>ASCII<49><49>ʾ<EFBFBD><CABE>
<20><><EFBFBD><EFBFBD>Ϊjava<76>е<EFBFBD>byte<74><65>toString<6E>޷<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>
sprintf(outbuf,"%02X",ib)
*/
public static String byteHEX(byte ib) {
char[] Digit = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'};
char[] ob = new char[2];
ob[0] = Digit[ (ib >>> 4) & 0X0F];
ob[1] = Digit[ib & 0X0F];
String s = new String(ob);
return s;
}
}

View File

@ -0,0 +1,39 @@
/*
* Created on 2006-3-17
*
*
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.sino.publicclass.util;
/**
* @author JosephZhou
*
*
* Window - Preferences - Java - Code Style - Code Templates
*/
public class MapUtil {
/**
*
*/
public MapUtil() {
super();
//
}
public static long distance(double lon1,double lat1,double lon2,double lat2)
{
double R=6378136.49;
double PI=Math.PI;
double dlon=Math.abs(lon1-lon2);
if(dlon>180)dlon=360-dlon;
double lsqure=2-2*Math.sin(lat1*PI/180)*Math.sin(lat2*PI/180)-2*Math.cos(lat1*PI/180)*Math.cos(lat2*PI/180)*Math.cos(dlon*PI/180);
double d=Math.asin(Math.sqrt(lsqure)*0.5)*2*R;
return Math.round(d*100);
}
public static void main(String[] args) {
System.out.println(MapUtil.distance(0.0075,31.236111,0.0041667,31.237222));
}
}

View File

@ -0,0 +1,30 @@
package com.sino.publicclass.util;
public class PageForm {
public static String radio(String name, String value, String parament, String checkvalue, String lable) {
String checked = ((checkvalue.equals(value))) ? "checked" : "";
return "<input type='radio' name=" + name + " value='" + value + "' " + parament + " " + checked + ">" + lable;
}
public static String radio(String name, int value, String parament, int checkvalue, String lable) {
return radio(name, String.valueOf(value), parament, String.valueOf(checkvalue), lable);
}
public static String checkBox(String name, String value, String parament, String checkvalue) {
String checked = ((checkvalue.equals(value))) ? "checked" : "";
return "<input type='checkbox' name=" + name + " value='" + value + "' " + parament + " " + checked + ">";
}
public static String checkBox(String name, String value, String parament, boolean checked) {
String str = ((checked)) ? "checked" : "";
return "<input type='checkbox' name=" + name + " value='" + value + "' " + parament + " " + str + ">";
}
public static String checkBox(String name, String value, String parament, boolean checked,String lable) {
String str = ((checked)) ? "checked" : "";
return "<input type='checkbox' name=" + name + " value='" + value + "' " + parament + " " + str + ">"+lable;
}
public static String checkBox(String name, int value, String parament, int checkvalue) {
return checkBox(name, String.valueOf(value), parament, String.valueOf(checkvalue));
}
}

View File

@ -0,0 +1,302 @@
package com.sino.publicclass.util;
import java.util.*;
import java.io.*;
/**
* Manages properties for the entire web application system. Properties are merely
* pieces of information that need to be saved in between server restarts.
* <p>
* At the moment, properties are stored in a Java Properties file.
* <p>
* <p>
* This class is implemented as a singleton since many classloaders seem to
* take issue with doing classpath resource loading from a static context.
*/
public class PropertyManager {
private static PropertyManager manager = null;
private static Object managerLock = new Object();
private static String propsName = "/redbeans.properties";
private Properties properties = null;
private Object propertiesLock = new Object();
private String resourceURI;
/**
* Creates a new PropertyManager. Singleton access only.
*/
private PropertyManager(String resourceURI) {
this.resourceURI = resourceURI;
}
protected void deleteProp(String name) {
//Only one thread should be writing to the file system at once.
synchronized (propertiesLock) {
//Create the properties object if necessary.
if (properties == null) {
loadProps();
}
properties.remove(name);
saveProps();
}
}
/**
* Deletes a Jive property. If the property doesn't exist, the method
* does nothing.
*
* @param name the name of the property to delete.
*/
public static void deleteProperty(String name) {
if (manager == null) {
synchronized(managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
manager.deleteProp(name);
}
/**
* Gets a property. properties are stored in a properties file.
* The properties file should be accesible from the classpath. Additionally,
* it should have a path field that gives the full path to where the
* file is located. Getting properties is a fast operation.
*
* @param name the name of the property to get.
* @return the property specified by name.
*/
protected String getProp(String name) {
//If properties aren't loaded yet. We also need to make this thread
//safe, so synchronize...
if (properties == null) {
synchronized (propertiesLock) {
//Need an additional check
if (properties == null) {
loadProps();
}
}
}
String property = properties.getProperty(name);
if (property == null) {
return null;
} else {
return property.trim();
}
}
/**
* Returns a Jive property.
*
* @param name the name of the property to return.
* @return the property value specified by name.
*/
public static String getProperty(String name) {
if (manager == null) {
synchronized(managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
return manager.getProp(name);
}
/**
* Loads properties file from the disk.
*/
private void loadProps() {
properties= new Properties();
InputStream in= null;
try {
in= getClass().getResourceAsStream(resourceURI);
properties.load(in);
} catch (Exception e) {
System.err.println("Error reading properties in PropertyManager.loadProps() " + e);
e.printStackTrace();
} finally {
try {
in.close();
} catch (Exception e) {
System.err.println("Error reading properties in PropertyManager.loadProps() " + e);
e.printStackTrace();
}
}
}
/**
* Returns true if the jive.properties file exists where the path property
* purports that it does.
*/
public static boolean propertyFileExists() {
if (manager == null) {
synchronized(managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
return manager.propFileExists();
}
/**
* Returns true if the properties are readable. This method is mainly
* valuable at setup time to ensure that the properties file is setup
* correctly.
*/
public static boolean propertyFileIsReadable() {
if (manager == null) {
synchronized(managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
return manager.propFileIsReadable();
}
/**
* Returns true if the properties are writable. This method is mainly
* valuable at setup time to ensure that the properties file is setup
* correctly.
*/
public static boolean propertyFileIsWritable() {
if (manager == null) {
synchronized(managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
return manager.propFileIsWritable();
}
/**
* Returns the names of the properties.
*
* @return an Enumeration of the property names.
*/
public static Enumeration propertyNames() {
if (manager == null) {
synchronized (managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
return manager.propNames();
}
/**
* Returns true if the jive.properties file exists where the path property
* purports that it does.
*/
public boolean propFileExists() {
String path = getProp("path");
File file = new File(path);
if (file.isFile()) {
return true;
}
else {
return false;
}
}
/**
* Returns true if the properties are readable. This method is mainly
* valuable at setup time to ensure that the properties file is setup
* correctly.
*/
public boolean propFileIsReadable() {
try {
InputStream in = getClass().getResourceAsStream(resourceURI);
return true;
}
catch (Exception e) {
return false;
}
}
/**
* Returns true if the properties are writable. This method is mainly
* valuable at setup time to ensure that the properties file is setup
* correctly.
*/
public boolean propFileIsWritable() {
String path = getProp("path");
File file = new File(path);
if (file.isFile()) {
//See if we can write to the file
if (file.canWrite()) {
return true;
} else {
return false;
}
} else {
return false;
}
}
protected Enumeration propNames() {
//If properties aren't loaded yet. We also need to make this thread
//safe, so synchronize...
if (properties == null) {
synchronized(propertiesLock) {
//Need an additional check
if (properties == null) {
loadProps();
}
}
}
return properties.propertyNames();
}
/**
* Saves properties to disk.
*/
private void saveProps() {
//Now, save the properties to disk. In order for this to work, the user
//needs to have set the path field in the properties file. Trim
//the String to make sure there are no extra spaces.
String path = properties.getProperty("path").trim();
OutputStream out = null;
try {
out = new FileOutputStream(path);
properties.store(out, "redbeans.properties -- " + (new java.util.Date()));
} catch (Exception ioe) {
System.err.println(
"There was an error writing redbeans.properties to "
+ path
+ ". "
+ "Ensure that the path exists and that the Jive process has permission "
+ "to write to it -- "
+ ioe);
ioe.printStackTrace();
} finally {
try {
out.close();
} catch (Exception e) {
}
}
}
/**
* Sets a property. Because the properties must be saved to disk
* every time a property is set, property setting is relatively slow.
*/
protected void setProp(String name, String value) {
//Only one thread should be writing to the file system at once.
synchronized (propertiesLock) {
//Create the properties object if necessary.
if (properties == null) {
loadProps();
}
properties.setProperty(name, value);
saveProps();
}
}
/**
* Sets a Jive property. If the property doesn't already exists, a new
* one will be created.
*
* @param name the name of the property being set.
* @param value the value of the property being set.
*/
public static void setProperty(String name, String value) {
if (manager == null) {
synchronized(managerLock) {
if (manager == null) {
manager = new PropertyManager(propsName);
}
}
}
manager.setProp(name, value);
}
}

View File

@ -0,0 +1,170 @@
package com.sino.publicclass.util;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
/**
* 生成20位序列号(年月日时分秒+x位随机数)
*
*/
public class SequenceUtil {
private static Integer temp = 100001;
/**
* 默认生成20<32><30>?年月日时分秒+<2B><>?00001~999999累加<E7B4AF><E58AA0>?位数)
*
* @return sequence 序列<E5BA8F><E58897>?
*/
public static synchronized String getSequence() {
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
String sequence = date + temp;
if (temp < 999999)
temp++;
else
temp = 100001;
return sequence;
}
/**
* 生成20位序列号(年月日时分秒+6位随机数)
*
* @return sequence 序列<E5BA8F><E58897>?
*/
public static synchronized String getSeqByRandom() {
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
Random random = new Random();
int temp = Math.abs(random.nextInt());
String sequence = date + (temp % (999999 - 100000 + 1) + 100000);
return sequence;
}
/**
* 生成6位随机数
*
* @return sequence 序列<E5BA8F><E58897>?
*/
public static synchronized String getSixRandom() {
Random random = new Random();
int temp = Math.abs(random.nextInt());
String sequence = String.valueOf(temp % (999999 - 100000 + 1) + 100000);
return sequence;
}
//控制台的<E58FB0><E79A84>? 你可以用循环来取中奖号将其存入list或set里<E9878C><EFBC88>?<3F><>是set因为set本来就不会重复。如果用list存就另外写一个循环方法来挨个判定该元素是不是已经在list中存在了如果存在就让选号的再加<E5868D>?<3F><>?<3F><>如果不重复就放到list里去
public static void main(String[] args) {
Random rand = new Random();// 定义随机数产生器
List<Integer> list_One = new ArrayList<Integer>();// 定义<E5AE9A><E4B989>?<3F><>奖数字集<E5AD97><E99B86>?
List<Integer> list = null;
// 用list<73><74>?
/*
* list = new ArrayList<Integer>();//定义100个随机数 集合
*
* for(int i = 0; i < 100;){//产生100<30><30>?位数 的随机不重复数字
* if(check(rand.nextInt(899) + 100,list)){ i++; } }
*/
// 用set<65><74>?
Set<Integer> set = new HashSet<Integer>();
while (set.size() < 100) {
set.add(rand.nextInt(899) + 100);
}
list = new ArrayList<Integer>(set);
for (int k = 0; k < 5;) {// 产生5个随机一等奖
if (check(rand.nextInt(100), list, list_One)) {
k++;
}
}
for (int a = 0; a < list_One.size(); a++) {
if (731==list_One.get(a)) {
//return true;
}
System.out.println(list_One.get(a));
}
}
//抽奖测试
public void testChoujian() {
Random rand = new Random();// 定义随机数产生器
List<Integer> list_One = new ArrayList<Integer>();// 定义<E5AE9A><E4B989>?<3F><>奖数字集<E5AD97><E99B86>?
List<Integer> list = null;
// 用list<73><74>?
/*
* list = new ArrayList<Integer>();//定义100个随机数 集合
*
* for(int i = 0; i < 100;){//产生100<30><30>?位数 的随机不重复数字
* if(check(rand.nextInt(899) + 100,list)){ i++; } }
*/
// 用set<65><74>?
Set<Integer> set = new HashSet<Integer>();
while (set.size() < 100) {
set.add(rand.nextInt(899) + 100);
}
list = new ArrayList<Integer>(set);
for (int k = 0; k < 5;) {// 产生5个随机一等奖
if (check(rand.nextInt(100), list, list_One)) {
k++;
}
}
for (int a = 0; a < list_One.size(); a++) {
if (731==list_One.get(a)) {
//return true;
}
System.out.println(list_One.get(a));
}
}
/**
* 验证该数字是否在集合<E99B86><E59088>?
*
* @param i
* @param list
* @return
*/
public static boolean check(int i, List<Integer> list) {
if (list.size() == 0) {
list.add(i);
} else {
for (int j = 0; j < list.size(); j++) {
if (i == list.get(j)) {
return false;
}
}
list.add(i);
}
return true;
}
/**
* 抽取随机数作为中奖的下标(重载)
*
* @param i
* @param list
* @param list_One
* @return
*/
public static boolean check(int i, List<Integer> list,
List<Integer> list_One) {
if (list.size() == 0) {
list_One.add(list.get(i));
} else {
for (int j = 0; j < list.size(); j++) {
if (i == list.get(j)) {
return false;
}
}
list_One.add(list.get(i));
}
return true;
}
}

View File

@ -0,0 +1,20 @@
package com.sino.publicclass.util;
public class StaticVar {
public final static String DONOTUPDATE = "DONOT_UPDATE";
public final static String NO_MESSAGE = "no message";
public final static String ERROR_USER = "<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>";
public final static String ERROR_PASSWORD = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
public final static String ERROR_SESSION = "<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>½<EFBFBD><EFBFBD>";
public final static String SESSION_USER = "TW_SESSION_USER";
public final static String SESSION_USER_ID = "TW_SESSION_USER_ID";
public static String SYSTEMADMIN = "0"; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
public static String COMMONUSER = "1"; // <20><>ͨ<EFBFBD>û<EFBFBD>
public static final int WEIXIN_CONTRACT_CODE = 5053; //
public static final String WEIXIN_PLAT_CODE = "ZD_LLT"; //<2F>е<EFBFBD>··ͨ
public static final int dispatch_flag_o=0; //δ<>ɵ<EFBFBD>
}

View File

@ -0,0 +1,264 @@
package com.sino.publicclass.util;
import java.util.StringTokenizer;
public class StringTools {
public static boolean ValidateStr(String value) {
if (value == null)
return true;
else if (value.trim().length() == 0)
return true;
else
return false;
}
/**
* <20><>""ת<><D7AA>&nbsp;
*
* @param string
* String
* @return String
*/
public static String getEmpty(String string) {
String temp = "&nbsp;";
if (string.trim().equals("")) {
return temp;
}
return string;
}
public static String convertForHtml(String s) {
if (s == null) {
return s;
}
if (s.equals("")) {
return s;
}
int i = s.length();
StringBuffer stringbuffer = new StringBuffer();
for (int j = 0; j < i; j++) {
switch (s.charAt(j)) {
case 60: // '<'
stringbuffer.append("&lt;");
break;
case 62: // '>'
stringbuffer.append("&gt;");
break;
case 34: // '"'
stringbuffer.append("&quot;");
break;
// case 32: // ' '
// stringbuffer.append("&nbsp;");
// break;
// case 10: // '\n'
// stringbuffer.append("<br>");
// break;
default:
stringbuffer.append(s.charAt(j));
break;
}
}
return stringbuffer.toString();
}
public static String convertForTextArea(String s) {
if (s == null || s.equals("")) {
return "&nbsp;";
}
int i = s.length();
StringBuffer stringbuffer = new StringBuffer();
for (int j = 0; j < i; j++) {
switch (s.charAt(j)) {
case 60: // '<'
stringbuffer.append("&lt;");
break;
case 62: // '>'
stringbuffer.append("&gt;");
break;
case 34: // '"'
stringbuffer.append("&quot;");
break;
case 32: // ' '
stringbuffer.append("&nbsp;");
break;
case 10: // '\n'
stringbuffer.append("<br>");
break;
default:
stringbuffer.append(s.charAt(j));
break;
}
}
return stringbuffer.toString();
}
public static String convertForWrap(String s) {
if (s == null || s.equals("")) {
return "";
}
int i = s.length();
StringBuffer stringbuffer = new StringBuffer();
for (int j = 0; j < i; j++) {
if ((j + 1) < i && s.charAt(j) == 13 && s.charAt(j + 1) == 10) {
stringbuffer.append("$wrap$");
} else if (s.charAt(j) != 13 && s.charAt(j ) != 10) {
stringbuffer.append(s.charAt(j));
}
}
return stringbuffer.toString();
}
/***************************************************************************
* <20><><EFBFBD><EFBFBD>/function: <20>÷<EFBFBD><C3B7><EFBFBD>ʹ<EFBFBD><CAB9>ת<EFBFBD><D7AA><EFBFBD>ַ<EFBFBD>"\" ת<><D7AA>SQL<51><4C><EFBFBD><EFBFBD>Like<6B><65><EFBFBD>е<EFBFBD> "% _" ת<><D7AA><EFBFBD><EFBFBD>SQL<51><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ESCAPE '\\' "
* <20><><EFBFBD><EFBFBD>/parameter: <20><><EFBFBD><EFBFBD>String <20><><EFBFBD><EFBFBD>/return: ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>String <20><><EFBFBD><EFBFBD>/steps : <20>޸ļ<DEB8>¼/Revision <20><><EFBFBD><EFBFBD>
* <20>޸<EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD>
*
**************************************************************************/
public static String convertLikeStr(String s) {
if (s == null) {
return "";
}
// ת<><D7AA>SQL<51><4C><EFBFBD><EFBFBD>Like<6B><65><EFBFBD>е<EFBFBD>"\"
String s1 = s, s2 = "";
int i = 0;
while (i >= 0) {
i = s1.indexOf("\\");
if (i >= 0) {
s2 += s1.substring(0, i) + "\\\\";
s1 = s1.substring(i + 1, s1.length());
}
}
s2 += s1;
// ת<><D7AA>SQL<51><4C><EFBFBD><EFBFBD>Like<6B><65><EFBFBD>е<EFBFBD>"%"
s1 = s2;
s2 = "";
i = 0;
while (i >= 0) {
i = s1.indexOf("%");
if (i >= 0) {
s2 += s1.substring(0, i) + "\\%";
s1 = s1.substring(i + 1, s1.length());
}
}
s2 += s1;
// ת<><D7AA>SQL<51><4C><EFBFBD><EFBFBD>Like<6B><65><EFBFBD>е<EFBFBD>"_"
s1 = s2;
s2 = "";
i = 0;
while (i >= 0) {
i = s1.indexOf("_");
if (i >= 0) {
s2 += s1.substring(0, i) + "\\_";
s1 = s1.substring(i + 1, s1.length());
}
}
s2 += s1;
s2 = "'%" + s2 + "%'";
return s2;
}
public static String convertSqlStr(String s) {
if (s == null) {
return "";
}
// ת<><D7AA>SQL<51><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"'"
String s1 = s, s2 = "";
int i = 0;
while (i >= 0) {
i = s1.indexOf("'");
if (i >= 0) {
s2 += s1.substring(0, i) + "''";
s1 = s1.substring(i + 1, s1.length());
}
}
s2 += s1;
return "'" + s2 + "'";
}
public static String[] separate(String str, String separator) {
StringTokenizer st = new StringTokenizer(str, separator);
String[] result = new String[st.countTokens()];
int i = 0;
while (st.hasMoreTokens()) {
result[i] = st.nextToken();
i++;
}
return result;
}
public static String toGBK(String str) {
try {
if (str == null) {
return null;
} else {
str = new String(str.getBytes("ISO8859_1"), "GBK");
return str;
}
} catch (Exception e) {
return null;
}
}
public static String convertTime(long time) {
String value;
int h, m, s;
h = (int) (time / 3600);
m = (int) ((time % 3600) / 60);
s = (int) ((time % 3600) % 60);
value = s + "<EFBFBD><EFBFBD>";
value = m + "<EFBFBD><EFBFBD>" + value;
value = h + "Сʱ" + value;
return value;
}
public static String convertToMS(long time) {
String rt="";
if(time>60) {
int m,s;
m=(int)time/60;
s=(int)time%60;
return m+"<EFBFBD><EFBFBD>"+s+"<EFBFBD><EFBFBD>";
}else {
return time+"<EFBFBD><EFBFBD>";
}
}
/**
* <20><> null <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ <20>մ<EFBFBD> "",<2C><> null <20><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
* @param src
* @return
*/
public static String convertNullToEmpty(String src){
if (null != src){
return src;
} else {
return "";
}
}
public static String getJavascript(String message){
return "<script>" + message + "</script>";
}
public static String getJavascriptAlert(String message){
return "<script>alert(\"" + message.replaceAll("\"", "'").replaceAll("\\n", "") + "\");</script>";
}
public static String getJavascriptAlertAndClose(String message){
return "<script>alert(\"" + message.replaceAll("\"", "'").replaceAll("\\n", "") + "\");window.close();</script>";
}
/*
public static String convertStartToEnd(String start, String end) {
String value = "";
start = DateTime.reFormatTime(start, DateTime.PATTERN_0, DateTime.PATTERN_1);
end = DateTime.reFormatTime(end, DateTime.PATTERN_0, DateTime.PATTERN_1);
if (start.substring(0, 10).equals(end.substring(0, 10))) {
value = start + " <20><> " + end.substring(11);
} else {
value = start + " <20><> " + end;
}
return value;
}
*/
}

View File

@ -0,0 +1,48 @@
package com.sino.rescue.oauth.entity;
public class SNSUserInfo {
private String openid;
private String nickname;
private String sex;
private String province;
private String city;
private String country;
public String getOpenid() {
return openid;
}
public void setOpenid(String openid) {
this.openid = openid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}

View File

@ -0,0 +1,42 @@
package com.sino.rescue.oauth.entity;
public class WeixinOauth2Token {
private String access_token;
private int expires_in;
private String refresh_token;
private String openid;
private String scope;
public String getAccess_token() {
return access_token;
}
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
public int getExpires_in() {
return expires_in;
}
public void setExpires_in(int expires_in) {
this.expires_in = expires_in;
}
public String getRefresh_token() {
return refresh_token;
}
public void setRefresh_token(String refresh_token) {
this.refresh_token = refresh_token;
}
public String getOpenid() {
return openid;
}
public void setOpenid(String openid) {
this.openid = openid;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
}

View File

@ -0,0 +1,101 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
//<2F><>Ӧ<EFBFBD>̶<EFBFBD><CCB6><EFBFBD>
public class BillCheckServlet extends HttpServlet{
private static final long serialVersionUID = 1L;
private AdvancedUtil util=new AdvancedUtil();
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
request.setAttribute("weixinUserId", String.valueOf(weixinUser.getId()));
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
Map<String,Object> regist=weixinOper.findUserByOpenID(openId);
if(!regist.get("company_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
String rescueCode=(String) regist.get("company_rescue_code");
request.getRequestDispatcher("/supplier/billCheck.jsp?rescueCode="+rescueCode).forward(request, response);
}else if(!regist.get("vehicle_rescue_code").equals("")){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}else{
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUser.getId())).forward(request, response);
}
}catch (CException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUserId)).forward(request, response);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,31 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.weixin.oauth.util.AdvancedUtil;
public class ConformServiceServlet extends HttpServlet{
private static final long serialVersionUID = 1L;
private AdvancedUtil util = new AdvancedUtil();
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
String cmd=request.getParameter("cmd");
if(cmd.equals("notice")){ //<2F>е<EFBFBD>֪ͨ
response.sendRedirect("https://mp.weixin.qq.com/mp/homepage?__biz=MjM5NzEzOTkwNw%3D%3D&hid=10&sn=6d3ca4446f031c10222ca8a232478f6f");
}else if(cmd.equals("system")){ //<2F>е<EFBFBD><D0B5>ƶ<EFBFBD>
response.sendRedirect("https://mp.weixin.qq.com/mp/homepage?__biz=MjM5NzEzOTkwNw%3D%3D&hid=11&sn=1debd0fd682bd8c28d8ba46a8dda6925");
}else if(cmd.equals("parameter")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
response.sendRedirect("https://mp.weixin.qq.com/mp/homepage?__biz=MjM5NzEzOTkwNw%3D%3D&hid=12&sn=a0cb93af7b306572efac15456884df74");
}
}
}
}

View File

@ -0,0 +1,140 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
public class CurrentOrderServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private AdvancedUtil util=new AdvancedUtil();
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
request.setAttribute("weixinUserId", String.valueOf(weixinUser.getId()));
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
JSONObject json=new JSONObject();
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
UserOrderOper orderOper=new UserOrderOper(conn);
Map<String,Object> regist=weixinOper.findUserByOpenID(openId);
if(!regist.get("company_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
int dispatchMode=(Integer) regist.get("company_dispatch_mode");
if(dispatchMode==3){ //΢<>ŵ<EFBFBD><C5B5><EFBFBD>
String rescueCode=(String) regist.get("company_rescue_code");
List<String> orderList = orderOper.findOrderListByRescueCode(rescueCode);
json.put("orderList", orderList);
json.put("rescueCode", rescueCode);
json.put("action", 10);
if(orderList!=null&&orderList.size()>0){
JSONObject list=JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8")); //Զ<>̵<EFBFBD><CCB5>ò<EFBFBD>ѯ<EFBFBD><D1AF>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
request.setAttribute("list", list.get("currentOrderList"));
request.getRequestDispatcher("/supplier/currentOrder.jsp?rescueCode="+rescueCode+"&openId="+openId).forward(request, response);
}else{
request.setAttribute("list", "");
request.getRequestDispatcher("/supplier/currentOrder.jsp?rescueCode="+rescueCode+"&openId="+openId).forward(request, response);
}
}else{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}
}else if(!regist.get("vehicle_rescue_code").equals("")){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
int dispatchMode=(Integer) regist.get("vehicle_dispatch_mode");
if(dispatchMode==3){ //΢<>ŵ<EFBFBD><C5B5><EFBFBD>
String rescueCode=(String) regist.get("vehicle_rescue_code");
int vehicleId=(Integer) regist.get("ID"); //ʦ<><CAA6>id
Map<String,String> vehicleOrders= orderOper.findVehicleOrderDetailByVehicleId(vehicleId); //<2F><>ѯ˾<D1AF><CBBE><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
if(vehicleOrders!=null&&vehicleOrders.size()>0){
request.setAttribute("list",vehicleOrders);
}else{
request.setAttribute("list","");
}
request.getRequestDispatcher("/supplier/vehicleCurrentOrder.jsp?rescueCode="+rescueCode+"&openId="+openId+"&rescueVehicleId="+vehicleId).forward(request, response);
}else{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}
}else{
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUser.getId())).forward(request, response);
}
}catch (CException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUserId)).forward(request, response);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,97 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class JoinRescueCompanyServlet extends HttpServlet{
private AdvancedUtil util=new AdvancedUtil();
private static final long serialVersionUID = -1847238807216447030L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
request.setAttribute("weixinUserId", String.valueOf(weixinUser.getId()));
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
//<2F>жϸ<D0B6><CFB8>û<EFBFBD><C3BB>Ƿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
Map<String,Object> register=weixinOper.findUserByOpenID(openId);
if(register.get("company_rescue_code").equals("")&&register.get("vehicle_rescue_code").equals("")){ //<2F><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>˾<EFBFBD><CBBE>
request.getRequestDispatcher("/supplier/rescueJoinUs.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}else{ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
System.out.println(snsUserInfo.getNickname()+"<EFBFBD>dz<EFBFBD>");
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/rescueJoinUs.jsp").forward(request, response);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,154 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class TodayFinishedOrderServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private AdvancedUtil util = new AdvancedUtil();
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
UserOrderOper orderOper=new UserOrderOper(conn);
Map<String,Object> regist = weixinOper.findUserByOpenID(openId);
if(!regist.get("company_rescue_code").equals("")){ //<2F><><EFBFBD>û<EFBFBD><C3BB>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>
int dispatchMode=(Integer) regist.get("company_dispatch_mode");
if(dispatchMode==3){ //΢<>ŵ<EFBFBD><C5B5><EFBFBD>
String rescueCode=(String) regist.get("company_rescue_code");
request.getRequestDispatcher("/supplier/companyFinishedOrder.jsp?rescueCode="+rescueCode).forward(request, response);
}else{
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}
}else if(!regist.get("vehicle_rescue_code").equals("")){ //˾<><CBBE><EFBFBD>û<EFBFBD>
int dispatchMode=(Integer) regist.get("vehicle_dispatch_mode");
if(dispatchMode==3){ //΢<>ŵ<EFBFBD><C5B5><EFBFBD>
String rescueCode=(String) regist.get("vehicle_rescue_code");
String rescueVehicleId=regist.get("ID").toString();
request.getRequestDispatcher("/supplier/vehicleFinishedOrder.jsp?rescueCode=" + rescueCode + "&rescueVehicleId=" + rescueVehicleId).forward(request, response);
}else{
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}
}else{
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUser.getId())).forward(request, response);
}
}catch (CException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUserId)).forward(request, response);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public String getMonthTime(){
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>µ<EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1>
Calendar c=Calendar.getInstance();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
return(sf.format(c.getTime()));
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public String getWeekTime(){
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ܵ<EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1>
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
System.err.println("####"+sf.format(cal.getTime())+"$$$$$$$$$"+cal.getTime());
return(sf.format(cal.getTime()));
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public String getTodayTime(){
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
Calendar c=Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
return(sf.format(c.getTime()));
}
}

View File

@ -0,0 +1,104 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class TranslateMessageServlet extends HttpServlet{
private AdvancedUtil util=new AdvancedUtil();
private static final long serialVersionUID = -1847238807216447030L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
request.setAttribute("weixinUserId", String.valueOf(weixinUser.getId()));
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
//<2F>жϸ<D0B6><CFB8>û<EFBFBD><C3BB>Ƿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
Map<String,Object> register=weixinOper.findUserByOpenID(openId);
if(!register.get("manager_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
request.setAttribute("managerLoginName", register.get("loginName").toString());
request.getRequestDispatcher("/supplier/messageTranslation.jsp?flag="+1).forward(request, response);
}else if(!register.get("company_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
request.setAttribute("rescueCode", register.get("company_rescue_code").toString());
request.getRequestDispatcher("/supplier/messageTranslation.jsp?flag="+2).forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}else if(!register.get("vehicle_rescue_code").equals("")){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
request.getRequestDispatcher("/supplier/power.jsp").forward(request, response); //Ȩ<><C8A8>ҳ<EFBFBD><D2B3>
}else{
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUser.getId())).forward(request, response);
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
System.out.println(snsUserInfo.getNickname()+"<EFBFBD>dz<EFBFBD>");
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/userRegister.jsp").forward(request, response);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,100 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class UploadPhotoServlet extends HttpServlet{
private static final long serialVersionUID = 1L;
private AdvancedUtil util=new AdvancedUtil();
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
request.setAttribute("weixinUserId", String.valueOf(weixinUser.getId()));
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
Map<String,Object> regist=weixinOper.findUserByOpenID(openId);
if(!regist.get("company_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
response.sendRedirect("http://www.sino-assist.com:8099/jsp/clientCustomer/jsp/takePhoto.jsp?rescueCode="+regist.get("company_rescue_code")+"&code="+""); //<2F><><EFBFBD><EFBFBD>
//response.sendRedirect("http://www.sinoassistance.com/jsp/clientCustomer/jsp/takePhoto.jsp?rescueCode="+regist.get("company_rescue_code")+"&code="+""); //<2F>ϴ<EFBFBD><CFB4><EFBFBD>Ƭ
}else if(!regist.get("vehicle_rescue_code").equals("")){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
response.sendRedirect("http://www.sino-assist.com:8099/jsp/clientCustomer/jsp/takePhoto.jsp?rescueCode="+regist.get("vehicle_rescue_code")+"&code="+"");
//response.sendRedirect("http://www.sinoassistance.com/jsp/clientCustomer/jsp/takePhoto.jsp?rescueCode="+regist.get("vehicle_rescue_code")+"&code="+""); //<2F>ϴ<EFBFBD><CFB4><EFBFBD>Ƭ
}else{
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUser.getId())).forward(request, response);
}
}catch (CException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUserId)).forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,113 @@
package com.sino.rescue.oauth.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rescue.oauth.entity.SNSUserInfo;
import com.sino.rescue.oauth.entity.WeixinOauth2Token;
import com.sino.rrs.business.SnsVehicleUserManager;
import com.sino.rrs.entity.RcRescueCompanyPO;
import com.sino.rrs.entity.RcRescueVehiclePO;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.rrs.oper.RescueCompanyDispatchOper;
import com.sino.rrs.oper.RescueVehicleDispatchOper;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class UserRegisterServiceServlet extends HttpServlet{
private AdvancedUtil util=new AdvancedUtil();
private static final long serialVersionUID = -1847238807216447030L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("gb2312"); // <20>û<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1>code
String code=request.getParameter("code");
if (!"authdeny".equals(code)) {
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3>Ȩaccess_token
WeixinOauth2Token weixinOauth2Token = util.getOauth2AccessToken(Constants.AppId, Constants.AppSecret, code);
// <20><>ҳ<EFBFBD><D2B3>Ȩ<EFBFBD>ӿڷ<D3BF><DAB7><EFBFBD>ƾ֤
String accessToken = weixinOauth2Token.getAccess_token();
// <20>û<EFBFBD><C3BB><EFBFBD>ʶ
String openId = weixinOauth2Token.getOpenid();
RcWeixinUserPO weixinUser=SnsVehicleUserManager.getWeixinDispatcherUserByOpenId(openId);
if(weixinUser!=null){
request.setAttribute("weixinUserId", String.valueOf(weixinUser.getId()));
System.out.println(String.valueOf(weixinUser.getId())+"ooooooooooooooooo");
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
//<2F>жϸ<D0B6><CFB8>û<EFBFBD><C3BB>Ƿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
Map<String,Object> register=weixinOper.findUserByOpenID(openId);
if(!register.get("company_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>Ϣ
RescueCompanyDispatchOper oper=new RescueCompanyDispatchOper(conn);
RcRescueCompanyPO companyInfo = oper.findRescueCompanyInfo(weixinUser.getId());
request.setAttribute("companyInfo",companyInfo);
request.getRequestDispatcher("/supplier/userManInfo.jsp?weixinUserId="+String.valueOf(weixinUser.getId())+"&openId="+openId+"&flag="+companyInfo.getAcceptFlag()).forward(request, response);
}else if(!register.get("vehicle_rescue_code").equals("")){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
//<2F><>ѯ˾<D1AF><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
RescueVehicleDispatchOper vehicleOper=new RescueVehicleDispatchOper(conn);
RcRescueVehiclePO vehicleInfo = vehicleOper.findRescueVehicleInfo(weixinUser.getId());
request.setAttribute("vehicleInfo",vehicleInfo);
request.getRequestDispatcher("/supplier/vehicleManInfo.jsp?weixinUserId="+String.valueOf(weixinUser.getId())+"&openId="+openId+"&flag="+vehicleInfo.getAcceptFlag()).forward(request, response);
}else{
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUser.getId())).forward(request, response);
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}else{
// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
SNSUserInfo snsUserInfo = util.getSNSUserInfo(accessToken, openId); // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ݵIJ<DDB5><C4B2><EFBFBD>
System.out.println(snsUserInfo.getNickname()+"<EFBFBD>dz<EFBFBD>");
RcWeixinUserPO snsUser = new RcWeixinUserPO();
snsUser.setOpen_id(snsUserInfo.getOpenid());
snsUser.setNick_name(snsUserInfo.getNickname());
// snsUser.setNick_name("");
snsUser.setSex(snsUserInfo.getSex());
snsUser.setProvince(snsUserInfo.getProvince());
snsUser.setCity(snsUserInfo.getCity());
snsUser.setCountry(snsUserInfo.getCountry());
SnsVehicleUserManager.createWeixinUserDispatch(snsUser);
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
int weixinUserId= dispatchOper.findRescueCode(openId).getId();
request.setAttribute("weixinUserId", String.valueOf(weixinUserId));
request.getRequestDispatcher("/supplier/userRegister.jsp?weixinUserId="+String.valueOf(weixinUserId)).forward(request, response);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,33 @@
package com.sino.rrs.action;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class ApiSignatureAction extends BaseAction{
private AdvancedUtil util = new AdvancedUtil();
public void signature() throws Exception {
String url = request.getParameter("url");
int index = url.indexOf("#");
if (index > 0) {
url = url.substring(0, index);
}
System.out.println("Constants.API_TICKET=="+Constants.API_TICKET+"<"+Constants.TIME_STAMP);
String timestap = Long.toString(System.currentTimeMillis() / 1000);
String signature = util.getSha1Signature(Constants.API_TICKET, Constants.NONCESTR,timestap,url);
JSONObject jsonObject = new JSONObject();
jsonObject.put("appId",Constants.AppId);
jsonObject.put("nonce",Constants.NONCESTR);
jsonObject.put("timestamp",timestap);
jsonObject.put("signature",signature);
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
}

View File

@ -0,0 +1,20 @@
package com.sino.rrs.action;
import com.sino.publicclass.base.BaseAction;
public class ArriveAgoCheckAction extends BaseAction{
/*
public void arriveAgoCheck() throws CException, Exception{
String orderCode=getParameter("orderCode","");
String openId=getParameter("openId", "");
String rescueCode=getParameter("rescueCode","");
WeixinOrderPO weixinOrderPO=new WeixinOrderPO();
weixinOrderPO.setOPENID(openId);
weixinOrderPO.setORDERCODE(orderCode);
WeixinOrderOper weinxinOrder=new WeixinOrderOper(getConnection());
weinxinOrder.insertWeixinOrder(weixinOrderPO);
setNextPage("/SinoGYS/CurrentOrderAction.do?CMD=currentOrderDetail&orderCode="+orderCode+"&rescueCode="+rescueCode);
setNext(false);
}
*/
}

View File

@ -0,0 +1,35 @@
package com.sino.rrs.action;
import com.sino.publicclass.base.BaseAction;
import com.sino.rrs.oper.RcRescueVehicleOper;
import com.sino.rrs.oper.RcWeixinUserOper;
public class CompanyOrVehicleNoticeAction extends BaseAction{
//<2F><><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD><CCB8><EFBFBD><EFBFBD><EFBFBD>Ϣ
public boolean updateCompanyNotice() throws Exception {
boolean flag=false;
int acceptFlag=Integer.parseInt(getParameter("acceptFlag"));
String openId=getParameter("openId");
RcWeixinUserOper weixinOper=new RcWeixinUserOper(getConnection());
int count=weixinOper.updateCompanyAcceptFlag(acceptFlag, openId);
if(count>0){
flag=true;
}
setNext(false);
return flag;
}
public boolean updateVehicleNotice() throws Exception{
boolean flag=false;
int acceptFlag=Integer.parseInt(getParameter("acceptFlag"));
String staffName=getParameter("staffName");
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(getConnection());
int count=vehicleOper.updateVehicleAcceptFlag(acceptFlag, staffName);
if(count>0){
flag=true;
}
setNext(false);
return flag;
}
}

View File

@ -0,0 +1,74 @@
package com.sino.rrs.action;
import java.io.IOException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class ConnectionAction extends BaseAction{
public void connection(){
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><EFBFBD>˴<EFBFBD>");
setNextPage("/supplier/uploadPhoto.jsp");
}
//<2F><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>ͼƬ
public void connectionImg(){
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><EFBFBD>˴<EFBFBD>");
setNextPage("/supplier/photo.jsp");
}
//ģ<><C4A3><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void queryOrder() throws IOException{
String rescueCode=getParameter("rescueCode");
String code=getParameter("code");
JSONObject jsonObject=new JSONObject();
jsonObject.put("rescue_company_id", rescueCode);
jsonObject.put("taskCode", code);
JSONObject list=JSON.parseObject(HttpsUtil.doPost(Constants.url+"/getSupplierTasks", jsonObject, "utf-8"));
response.setContentType("text/html;charset=utf-8");
response.getWriter().print(list);
setNext(false);
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC>Ϣ
public void queryAllPhotos() throws IOException{
String taskOrderId=getParameter("taskOrderId");
String taskState=getParameter("taskState");
JSONObject jsonObject=new JSONObject();
jsonObject.put("taskOrderId", taskOrderId);
jsonObject.put("taskState", taskState);
JSONObject list=JSON.parseObject(HttpsUtil.doPost(Constants.url+"/queryImages", jsonObject, "utf-8"));
response.setContentType("text/html;charset=utf-8");
response.getWriter().print(list);
setNext(false);
}
//ɾ<><C9BE><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC>Ϣ
public void deleteSelectedPhoto() throws IOException{
String photoId=getParameter("photoId");
String url=getParameter("imageUrl");
String imageUrl=url.substring(url.indexOf("8888/")+5);
JSONObject jsonObject=new JSONObject();
jsonObject.put("id", photoId);
jsonObject.put("imageUrl", imageUrl);
boolean flag=false;
JSONObject httpRsponse=JSON.parseObject(HttpsUtil.doPost(Constants.url+"/deleteImages", jsonObject, "utf-8"));
if(httpRsponse.getIntValue("errorCode")==0){
flag=true;
}
httpRsponse.put("code", flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(httpRsponse.toJSONString());
setNext(false);
}
public static void main(String[] args) {
String str="http://192.168.1.220:8888//group1/M00/00/03/wKgB3FqqFYmAPHBZAAHv6Iz0LJk34.jpeg";
String qw=str.substring(str.indexOf("8888/")+5);
System.out.println(qw);
}
}

View File

@ -0,0 +1,120 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.oper.RescueCompanyDispatchOper;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class CurrentOrderAction extends BaseAction{
/**
* <20><><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD><CCBD>ܻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܾ<EFBFBD>ҳ<EFBFBD><D2B3>
* @throws SQLException
* @throws IOException
* @throws RemoteException
* @throws Exception
*/
public void acceptOrRecvOrder() throws SQLException{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String orderId=getParameter("orderId","");
String rescueCode=getParameter("rescueCode","");
String orderCode=getParameter("orderCode","");
String name=getParameter("serviceName", "");
String templeteId=getParameter("templeteId","");
String acceptFlag=getParameter("acceptFlag",""); // 1<><31><EFBFBD><EFBFBD> <20><>2 <20>ܾ<EFBFBD>
JSONObject jsonObject=new JSONObject();
JSONObject json=new JSONObject();
JSONObject httpRequest=null;
Connection conn=null;
try {
conn = ConnectionPool.getConnection();
RescueCompanyDispatchOper oper = new RescueCompanyDispatchOper(conn);
UserOrderOper userOrderOper=new UserOrderOper(conn);
jsonObject.put("orderId", orderId);
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("acceptFlag", acceptFlag);
jsonObject.put("orderCode", orderCode);
jsonObject.put("action", 4);
json.put("action", 5);
json.put("orderCode", orderCode);
httpRequest=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
if(httpRequest.getBoolean("result")==true){ //Զ<>̵<EFBFBD><CCB5>óɹ<C3B3>
if(Integer.parseInt(acceptFlag) ==1){ //<2F><><EFBFBD>ܶ<EFBFBD><DCB6><EFBFBD>
//<2F><><EFBFBD><EFBFBD>user_order state=1,rescue_company_dispatch flag=1
int result1=oper.updateRescueCompanyFlag(templeteId,1);
int result2=userOrderOper.updateUserOrderByOrderId(Integer.parseInt(orderId), 1);
if(result1>0&&result2>0){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
Map<String,Object> order = JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8"));
System.out.println(order.get("staffName")+"<EFBFBD><EFBFBD><EFBFBD>ǿյ<EFBFBD>");
if(order!=null){
request.setAttribute("detailPO",order);
setNextPage("/supplier/companyCurrentOrderDetail.jsp?rescueCode="+rescueCode+"&orderId="+orderId+"&orderCode="+orderCode+"&serviceName="+name);
}
}
}else if(Integer.parseInt(acceptFlag) ==2){
int result1=oper.updateRescueCompanyFlag(templeteId,2);
int result2=userOrderOper.updateUserOrderByOrderId(Integer.parseInt(orderId), 2);
if(result1>0&&result2>0){
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD>ѳɹ<D1B3><C9B9>ܾ<EFBFBD><DCBE>ö<EFBFBD><C3B6><EFBFBD>");
}
}
}else{ //<2F>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><D1B8>ɣ<EFBFBD>");
}
} catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
}
/**
* <20><>Ӧ<EFBFBD>̽<EFBFBD><CCBD>ܺ<EFBFBD><DCBA>
*/
public void findCurrentOrderDetail(){
String orderCode=getParameter("orderCode", ""); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String rescueCode=getParameter("rescueCode","");
String name=getParameter("serviceName", "");
JSONObject jsonObject=new JSONObject();
jsonObject.put("orderCode", orderCode);
jsonObject.put("action", 5);
Map<String, Object> order = JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
if(order!=null&&order.size()>0){
request.setAttribute("detailPO",order);
setNextPage("/supplier/companyCurrentOrderDetail.jsp?rescueCode="+rescueCode+"&orderCode="+orderCode+"&serviceName="+name);
}else{
setNext(false);
}
}
public static void main(String[] args) {
JSONObject jsonObject=new JSONObject();
jsonObject.put("orderId", 975528);
jsonObject.put("rescueCode", 1252);
jsonObject.put("acceptFlag", 1);
jsonObject.put("orderCode", "ZDADMIN-20170808-0002");
System.out.println("ֵ===="+JSON.parseObject(HttpsUtil.doPost("http://175.102.6.163:8380/RescueCompanyWeixinServlet.do?action=2", jsonObject, "utf-8")));
}
}

View File

@ -0,0 +1,17 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.rmi.RemoteException;
import com.sino.publicclass.base.BaseAction;
public class CurrentOrderDetailAction extends BaseAction {
public void detail() throws IOException, RemoteException, Exception{
int id=Integer.parseInt(request.getParameter("id"));
String rescueCode=request.getParameter("rescueCode");
int serviceStatus=Integer.parseInt(request.getParameter("serviceStatus"));
// request.setAttribute("detailPO",WeixinClientMthod.updateOrderState(rescueCode, id, serviceStatus, serviceStatus, serviceStatus, rescueCode, rescueCode, rescueCode)); //Զ<>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><E1BDBB><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
setNextPage("/supplier/distance.jsp");
}
}

View File

@ -0,0 +1,146 @@
package com.sino.rrs.action;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import sun.misc.BASE64Encoder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class DownLoadImageAction extends BaseAction{
public void upload() throws Exception {
String orderId = getParameter("orderId", "");
String state=getParameter("state","");
String photo_1 = getParameter("image_0", "");
String photo_2 = getParameter("image_1", "");
String photo_3 = getParameter("image_2", "");
String photo_4 = getParameter("image_3", "");
String imagePath_1_stream = photo_1.equals("") ? "" : downLoadWeixinImage(photo_1);
String imagePath_2_stream = photo_2.equals("") ? "" : downLoadWeixinImage(photo_2);
String imagePath_3_stream = photo_3.equals("") ? "" : downLoadWeixinImage(photo_3);
String imagePath_4_stream = photo_4.equals("") ? "" : downLoadWeixinImage(photo_4);
JSONObject httpResult = null;
boolean flag=false;
JSONObject bodyJson = new JSONObject();
bodyJson.put("orderId",orderId);
bodyJson.put("state", state);
bodyJson.put("photo_1",imagePath_1_stream);
bodyJson.put("photo_2",imagePath_2_stream);
bodyJson.put("photo_3",imagePath_3_stream);
bodyJson.put("photo_4",imagePath_4_stream);
bodyJson.put("action",8);
httpResult=JSONObject.parseObject(HttpsUtil.doPost(Constants.url,bodyJson,"UTF-8"));
if(httpResult.size()>0){
if(httpResult.getIntValue("errorCode")==0){
flag=true;
}
}
httpResult.put("code", flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(httpResult.toJSONString());
setNext(false);
}
public String downLoadWeixinImage(String mediaId) {
InputStream is = null;
String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token="
+ Constants.ACCESS_TOKEN + "&media_id=" + mediaId;
try {
URL urlGet = new URL(url);
HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
http.setRequestMethod("GET"); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>get<65><74>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
http.setRequestProperty("Charset", "UTF-8");
http.setDoOutput(true);
http.setDoInput(true);
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");// <20><><EFBFBD>ӳ<EFBFBD>ʱ30<33><30>
System.setProperty("sun.net.client.defaultReadTimeout", "10000"); // <20><>ȡ<EFBFBD><C8A1>ʱ30<33><30>
http.connect();
String contentType=http.getContentType();
// <20><>ȡ<EFBFBD>ļ<EFBFBD>ת<EFBFBD><D7AA>Ϊbyte<74><65>
is = http.getInputStream();
return readInputStream(is); //<2F><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC>Ϣ<EFBFBD><CFA2>jpg<70><67>
*
* @param mediaId
* <20>ļ<EFBFBD><C4BC><EFBFBD>id
* @throws Exception
*/
public String readInputStream(InputStream input) throws Exception {
byte[] data = new byte[1024];
int len = 0;
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
try {
while ((len = input.read(data)) != -1) {
outSteam.write(data, 0, len);
}
byte[] bytes= outSteam.toByteArray();
String str = new BASE64Encoder().encode(bytes);
return str;
} catch (IOException e) {
e.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (outSteam != null) {
try {
outSteam.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
public static void main(String[] args) throws Exception {
// DownLoadImageAction a=new DownLoadImageAction();
// a.upload();
// System.out.println(a.downLoadWeixinImage("-1IZPDHgsisuImsj8JIhj-nhJIRasjV4FYVw3ge3Tsz9FAwjQaFdQvoiRo-ZzT8l"));
JSONObject json1 = new JSONObject();
// JSONObject json2 = new JSONObject();
JSONArray jsonArray=new JSONArray();
for(int i =1;i<5;i++){
JSONObject map = new JSONObject();
map.put("q1"+i, "12"+i);
map.put("q2"+i, "13"+i);
jsonArray.add(map);
}
json1.put("q", "12");
json1.put("er", jsonArray);
System.out.println(json1);
}
}

View File

@ -0,0 +1,236 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.Pager;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class HistoryOrderAction extends BaseAction{
//<2F><><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD>ѯ<EFBFBD><D1AF>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
public void companyHistoryOrder() throws CException, IOException{
String rescueCode=getParameter("rescueCode");
String beginTime=getParameter("beginTime");
int startRow=Integer.parseInt(getParameter("startRow"));
int limit=new Pager().getLimit(); //ÿҳ<C3BF><D2B3>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
JSONObject jsonObject=new JSONObject();
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("beginTime", beginTime);
jsonObject.put("start", (startRow-1)*limit);
jsonObject.put("end", limit);
jsonObject.put("action", 11);
JSONObject json = new JSONObject();
json.put("rescueCode", rescueCode);
json.put("beginTime", beginTime);
json.put("action", 12);
JSONObject orderList= JSONObject.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
if(orderList.get("finishOrderList")!=null&&!orderList.get("finishOrderList").equals("")){
jsonObject.put("historyOrderList", orderList.get("finishOrderList"));
}else{
jsonObject.put("historyOrderList", "");
}
JSONObject jsonCpunt = JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8"));
if(jsonCpunt.getIntValue("count")>0){
jsonObject.put("count", jsonCpunt.getIntValue("count"));
}else{
jsonObject.put("count", 0);
}
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
//<2F><>Ԯʦ<D4AE><CAA6><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
public void vehicleHistoryOrder() {
String beginTime = getParameter("beginTime");
int rescueVehicleId = Integer.parseInt(getParameter("rescueVehicleId"));
int startRow = Integer.parseInt(getParameter("startRow"));
JSONObject jsonObject = new JSONObject();
Connection conn = null;
try {
conn = ConnectionPool.getConnection();
UserOrderOper orderOper = new UserOrderOper(conn);
List vehicleOrderList = orderOper.findVehicleOrderListByVehicleId(rescueVehicleId, beginTime, (startRow - 1) * 4);
if ((vehicleOrderList != null) && (vehicleOrderList.size() > 0))
jsonObject.put("historyOrderList", vehicleOrderList);
else {
jsonObject.put("historyOrderList", "");
}
long count = orderOper.findVehicleOrderListCount(rescueVehicleId, beginTime);
if (count > 0L)
jsonObject.put("count", Long.valueOf(count));
else {
jsonObject.put("count", Integer.valueOf(0));
}
this.response.setContentType("text/html;charset=UTF-8");
this.response.getWriter().print(jsonObject.toJSONString());
setNext(false);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
//<2F><EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void orderCount() throws CException, IOException{
String rescueCode=getParameter("rescueCode");
String beginTime=getParameter("beginTime");
JSONObject jsonObject=new JSONObject();
JSONObject json=null;
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("beginTime", beginTime);
jsonObject.put("action", 12);
json=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
if(json.getIntValue("count")>0){
jsonObject.put("count", json.getIntValue("count"));
}else{
jsonObject.put("count", 0);
}
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
//ģ<><C4A3><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
public void queryOrder() throws CException, IOException{
System.out.println("ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
JSONObject jsonObject=new JSONObject();
JSONObject jsonObject2=new JSONObject();
JSONObject json=null;
String code=getParameter("code");
String rescueCode=getParameter("rescueCode");
int searchFlag=Integer.parseInt(getParameter("searchFlag"));
int startRow=Integer.parseInt(getParameter("startRow"));
int limit=new Pager().getLimit();
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("code", code);
jsonObject.put("searchFlag", searchFlag);
jsonObject.put("begin", (startRow-1)*limit);
jsonObject.put("end", startRow*limit);
jsonObject.put("action", 14);
jsonObject2.put("rescueCode", rescueCode);
jsonObject2.put("code", code);
jsonObject2.put("searchFlag", searchFlag);
jsonObject2.put("action", 15);
json=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
if(json!=null&&json.size()>0){
jsonObject.put("orderList", json.get("likeQueryOrders"));
}else{
jsonObject.put("orderList", "");
}
JSONObject jsonCount=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject2, "utf-8"));
if(jsonCount.getIntValue("count")>0){
jsonObject.put("count", jsonCount.getIntValue("count"));
}else{
jsonObject.put("count", 0);
}
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>
public void findAccountOrder() throws CException, IOException{
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD><EFBFBD>");
int checkState=0;
JSONObject jsonObject=new JSONObject();
JSONObject json=new JSONObject();
String rescueCode=getParameter("rescueCode");
String paneltype=getParameter("paneltype");
String code="";
if(paneltype.equals("noAccount")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
checkState=1;
}
if(paneltype.equals("waitCheck"))checkState=2; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //<2F>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD> 4
if(paneltype.equals("checked"))checkState=5; //<2F><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>
if(paneltype.equals("non-checked"))checkState=3; //<2F><><EFBFBD><EFBFBD>δͨ<CEB4><CDA8>
int startRow=Integer.parseInt(getParameter("startRow"));
int limit=new Pager().getLimit();
//Զ<>̵<EFBFBD><CCB5>ö<EFBFBD><C3B6>˶<EFBFBD><CBB6><EFBFBD>
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("startRow", (startRow-1)*limit);
jsonObject.put("limit", startRow*limit);
jsonObject.put("searchFlag", checkState);
jsonObject.put("code", code);
jsonObject.put("action", 16);
json.put("rescueCode", rescueCode);
json.put("code", code);
json.put("searchFlag", checkState);
json.put("action", 15);
JSONObject jsonOrderList=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
if(jsonOrderList!=null&&jsonOrderList.size()>0){
jsonObject.put("accountList", jsonOrderList.get("accountOrders"));
}else{
jsonObject.put("accountList", "");
}
JSONObject jsonCount=JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8"));
if(jsonCount.getIntValue("count")>0){
jsonObject.put("count", jsonCount.getIntValue("count"));
}else{
jsonObject.put("count", 0);
}
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
//<2F><><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ʼ<EFBFBD>
public void sendJoinUsMail() throws CException, IOException{
JSONObject jsonObject=new JSONObject();
System.out.println("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>=============");
String rescueCompanyName=getParameter("rescueCompanyName");
String companyAddress=getParameter("companyAddress");
String userName=getParameter("userName");
String userPhone=getParameter("userPhone");
String tuoche=getParameter("tuoche");
String diaoche=getParameter("diaoche");
String qiangxiuche=getParameter("qiangxiuche");
String privateChe=getParameter("privateChe");
String serviceRange=getParameter("serviceRange");
jsonObject.put("rescueCompanyName", rescueCompanyName);
jsonObject.put("companyAddress", companyAddress);
jsonObject.put("userName", userName);
jsonObject.put("userPhone", userPhone);
jsonObject.put("tuoche", tuoche);
jsonObject.put("diaoche", diaoche);
jsonObject.put("qiangxiuche", qiangxiuche);
jsonObject.put("privateChe", privateChe);
jsonObject.put("serviceRange", serviceRange);
jsonObject.put("action", 17);
JSONObject sendMail=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8"));
jsonObject.put("flag", sendMail.getBoolean("flag"));
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
}

View File

@ -0,0 +1,25 @@
package com.sino.rrs.action;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.mapService.PoiAddress;
public class QueryAddressAction extends BaseAction{
public void query() throws Exception {
String latitude = getParameter("latitude", "0");
String longitude = getParameter("longitude", "0");
System.out.println("<EFBFBD><EFBFBD>γ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+latitude+"//"+longitude);
String orderCode=getParameter("orderCode", "");
JSONObject jsonObject = new JSONObject();
//Զ<>̵<EFBFBD><CCB5><EFBFBD><EFBFBD>ϴ<EFBFBD>˾<EFBFBD><CBBE>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
String name = PoiAddress.getWeixinAddress(longitude, latitude);
jsonObject.put("message", name);
jsonObject.put("code", true);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
}

View File

@ -0,0 +1,291 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.business.WeixinSignatureThread;
import com.sino.rrs.entity.RcNewAreaPO;
import com.sino.rrs.entity.SendInformation;
import com.sino.rrs.oper.RcNewAreaOper;
import com.sino.rrs.oper.RcRescueCompanyOper;
import com.sino.rrs.oper.RcRescueManagerOper;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class QueryAreaSupplierAction extends BaseAction{
private SendInformation sendPo=new SendInformation();
//<2F>鿴ij<E9BFB4><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD><CAA1>
public void getProvinceByLoginName(){
JSONObject jsonObject=new JSONObject();
Connection conn=null;
String loginName=getParameter("loginName");
jsonObject.put("loginName", loginName);
jsonObject.put("action", 18);
JSONObject jsonList=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"UTF-8"));
String managerArea = (String) jsonList.get("managerArea");
if(null!=managerArea){
try {
conn=ConnectionPool.getConnection();
RcNewAreaOper oper=new RcNewAreaOper(conn);
List<RcNewAreaPO> provinceList = oper.queryPrivince(managerArea.toString());
jsonObject.put("provinceList", provinceList);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
//<2F><>ѯʡ<D1AF>µ<EFBFBD><C2B5><EFBFBD>
public void getAllCityByParentid(){
JSONObject jsonObject=new JSONObject();
int areaid=Integer.parseInt(getParameter("areaid"));
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcNewAreaOper oper=new RcNewAreaOper(conn);
List<RcNewAreaPO> provinceCityList = oper.queryPrivinceCity(areaid);
jsonObject.put("provinceCityList", provinceCityList);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>Ϣ
public void getAllSuppliersByLoginName(){
JSONObject jsonObject=new JSONObject();
JSONObject json=new JSONObject();
boolean sendFlag=false;
String loginName=getParameter("loginName");
String title=getParameter("title");
String content=getParameter("content");
jsonObject.put("loginName", loginName);
jsonObject.put("action", 21);
List<String> rescueCodes =new ArrayList<String>();
JSONObject jsonList=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"UTF-8"));
List<Map<String,String>>provinceSupplierList = (List<Map<String, String>>) jsonList.get("provinceSupplierList");
if(null!=provinceSupplierList&&provinceSupplierList.size()>0){
for(Map<String,String> supplierMap:provinceSupplierList){
String rescueCode=supplierMap.get("code");
rescueCodes.add(rescueCode);
}
}else{
rescueCodes.add(null);
}
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcNewAreaOper oper=new RcNewAreaOper(conn);
List<Map<String,String>> suppliers = oper.queryPrivinceCitySupplier(rescueCodes.toString());
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>Ϣ
for(Map<String,String> supplier:suppliers){
int result=sendPo.sendInformation(title, content, supplier.get("open_id"));
if(result == 40001){
WeixinSignatureThread signature = new WeixinSignatureThread();
signature.bulidApiAccessToken();
result = sendPo.sendInformation(title, content, supplier.get("open_id"));
}
if(result==0){
sendFlag = true;
}
}
json.put("code", sendFlag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--><3E><>--<2D><><EFBFBD>Ĺ<EFBFBD>Ӧ<EFBFBD><D3A6>
public void getSuppliersByParentid(){
JSONObject jsonObject=new JSONObject();
JSONObject json=new JSONObject();
String areaCode=getParameter("city_area_code"); //<2F>б<EFBFBD><D0B1><EFBFBD>
String loginName=getParameter("loginName");
jsonObject.put("loginName", loginName);
jsonObject.put("areaCode", areaCode);
jsonObject.put("action", 19);
List<String> rescueCodes =new ArrayList<String>();
JSONObject jsonList=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"UTF-8"));
List<Map<String,String>>supplierList = (List<Map<String, String>>) jsonList.get("supplierList");
if(null!=supplierList&&supplierList.size()>0){
for(Map<String,String> supplierMap:supplierList){
String rescueCode=supplierMap.get("code");
rescueCodes.add(rescueCode);
}
}else{
rescueCodes.add(null);
}
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcRescueCompanyOper oper=new RcRescueCompanyOper(conn);
List<Map<String,String>> suppliers=oper.queryPrivinceCitySupplierName(rescueCodes.toString());
json.put("suppliers", suppliers);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
//<2F><>ѯ<EFBFBD><D1AF>Ӧ<EFBFBD>̶<EFBFBD>Ӧ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>Ϣ
public void getManagerByRescueCode(){
JSONObject jsonObject=new JSONObject();
JSONObject json=new JSONObject();
Connection conn=null;
boolean sendFlag=false;
String rescueCode=getParameter("rescueCode");
String title=getParameter("title");
String content=getParameter("content");
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("action", 20);
JSONObject jsonList=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"UTF-8"));
String managerLoginName = (String) jsonList.get("managerLoginName");
if(null!=managerLoginName){
try {
conn=ConnectionPool.getConnection();
RcRescueManagerOper managerOper=new RcRescueManagerOper(conn);
List<String> managerList = managerOper.queryManager(managerLoginName);
if(null!=managerList&&managerList.size()>0){
for(int i=0;i<managerList.size();i++){
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>Ϣ
System.out.println(managerList.get(i));
int result=sendPo.sendInformation(title, content, managerList.get(i));
if(result == 40001){
WeixinSignatureThread signature = new WeixinSignatureThread();
signature.bulidApiAccessToken();
result = sendPo.sendInformation(title, content, managerList.get(i));
}
if(result==0){
sendFlag = true;
}
}
}
json.put("code", sendFlag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
public void sendInformation() throws IOException{
JSONObject json=new JSONObject();
boolean sendFlag=false;
List<String> openIdList=new ArrayList<String>();
String title=getParameter("title");
String content=getParameter("content");
String rescueCodes=getParameter("rescueCodes").toString();
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcNewAreaOper oper=new RcNewAreaOper(conn);
List<Map<String,String>> suppliers = oper.queryPrivinceCitySupplier(rescueCodes);
if(null!=suppliers&&suppliers.size()>0){
for(Map<String,String> supplierId:suppliers){
String openid=supplierId.get("open_id");
openIdList.add(openid);
}
}
System.out.println("openIdList==="+openIdList);
for(int j=0;j<openIdList.size();j++){
int result=sendPo.sendInformation(title, content, openIdList.get(j));
if(result == 40001){
WeixinSignatureThread signature = new WeixinSignatureThread();
signature.bulidApiAccessToken();
result = sendPo.sendInformation(title, content, openIdList.get(j));
}
if(result==0){
sendFlag = true;
}
}
json.put("code", sendFlag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) throws IOException {
/*Date time=new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
String a=sdf.format(time);
// String aw=(Math.random()*9+1)*1000;
Random random = new Random();
int num = random.nextInt(900);
num = num + 1000;
System.out.println(a+"-"+num);*/
QueryAreaSupplierAction a=new QueryAreaSupplierAction();
a.sendInformation();
}
}

View File

@ -0,0 +1,136 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.oper.RcRescueUpdateOper;
import com.sino.rrs.oper.RcWeixinUserOper;
import com.sino.rrs.oper.RescueCompanyDispatchOper;
import com.sino.rrs.oper.RescueVehicleDispatchOper;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.ProgressProcess;
public class ReceiveOrderAction extends BaseAction{
/**
* <20><><EFBFBD><EFBFBD><EFBFBD>̲鿴<CCB2><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @throws CException
* @throws IOException
* @throws Exception
*/
public void showOrderDetail(){
Connection conn=null;
String openid=request.getParameter("openid");
String orderId=request.getParameter("orderId");
System.out.println("orderId==="+orderId);
String templeteId=request.getParameter("templeteId");
try {
conn=ConnectionPool.getConnection();
RcWeixinUserOper weixinOper=new RcWeixinUserOper(conn);
UserOrderOper userOrderOper=new UserOrderOper(conn);
RescueCompanyDispatchOper dispatchOper=new RescueCompanyDispatchOper(conn);
Map<String,Object> regist=weixinOper.findUserByOpenID(openid);
if(!regist.get("company_rescue_code").equals("")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
Map<String,String>map= dispatchOper.queryOrderFlag(templeteId);
if(Integer.parseInt(map.get("flag"))==19||Integer.parseInt(map.get("flag"))==4){ //ȡ<><C8A1>
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ѱ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>");
}else if(Integer.parseInt(map.get("flag"))==2){ //<2F>ܾ<EFBFBD>
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ѱ<EFBFBD><D1B1>ܾ<EFBFBD><DCBE><EFBFBD><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}else if(Integer.parseInt(map.get("flag"))==3){ //<2F><>ʱ
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><D1B8>ɣ<EFBFBD>");
}else{
//΢<>Ŷ<EFBFBD><C5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
Map<String,String> list = userOrderOper.findOrderDetailByTempleteId(templeteId);
if(list==null){ //<2F><EFBFBD><E9B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}else{
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ƿ񱻸<C7B7><F1B1BBB8>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
if(regist.get("company_rescue_code").equals(list.get("rescueCode"))){
request.setAttribute("list", list);
setNextPage("/supplier/weixinDetail.jsp?templeteId="+templeteId);
}else{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD>ɣ<EFBFBD>");
}
}
}
}else if(!regist.get("vehicle_rescue_code").equals("")){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>
int rescueVehicleId=Integer.parseInt(regist.get("ID").toString());
queryVehicleDetail(Integer.parseInt(orderId) ,rescueVehicleId);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public void queryVehicleOrder(){
int orderId=Integer.parseInt(getParameter("orderId",""));
int rescueVehicleId=Integer.parseInt(getParameter("rescueVehicleId",""));
queryVehicleDetail(orderId,rescueVehicleId);
}
/**
* ʦ<><CAA6><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 1.<2E><><EFBFBD><EFBFBD>id<69><64>ʦ<EFBFBD><CAA6>id<69><64>ѯʦ<D1AF><CAA6><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD>
* 2.<2E><><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ѯʦ<D1AF><CAA6><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9A3BB><EFBFBD>򣬲<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>ɱ<EFBFBD>
* 3.state=19 <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param orderCode
* @param rescueVehicleId
* @throws SQLException
* @throws Exception
*/
public void queryVehicleDetail(int orderId,int rescueVehicleId){ //<2F><>ѯ˾<D1AF><CBBE><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
UserOrderOper userOper=new UserOrderOper(conn);
RcRescueUpdateOper updateOper=new RcRescueUpdateOper(conn);
RescueVehicleDispatchOper vehicleOper=new RescueVehicleDispatchOper(conn);
Map<String,String> vehicle = vehicleOper.existVehicleByRecueCompany(orderId,String.valueOf(rescueVehicleId));
if(vehicle!=null){
Map<String,String> list = userOper.findOrderByOrderId(orderId);
if(list!=null){
if(list.get("STATE").equals("19")){
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ѱ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>"); //<2F><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
}else{
int state=Integer.parseInt(list.get("STATE"));
int flow_id=Integer.parseInt(list.get("FLOW_ID"));
int nextState=ProgressProcess.getProcess(state,flow_id);
request.setAttribute("list", list);
setNextPage("/supplier/currentOrderDetail.jsp?&nextState="+nextState+"&rescueVehicleId="+rescueVehicleId);
}
}
}else{
Map<String,String> update = updateOper.findOrderChangeVehicleOrCancel(orderId,rescueVehicleId);
if(update!=null){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
setNextPage("/supplier/point.jsp?message=<3D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,278 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.RcRescueCompanyPO;
import com.sino.rrs.entity.RcRescueVehiclePO;
import com.sino.rrs.oper.RcRescueCompanyOper;
import com.sino.rrs.oper.RcRescueManagerOper;
import com.sino.rrs.oper.RcRescueVehicleOper;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class RescueVehicleAction extends BaseAction{
/**
* <20>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>̻<EFBFBD><CCBB><EFBFBD>˾<EFBFBD><CBBE>
* @throws Exception
*/
public void modifyIdentity() throws Exception{
String weixinUserId=getParameter("weixinUserId","");
JSONObject jsonObject=new JSONObject();
boolean flag=false;
RcRescueCompanyOper oper=new RcRescueCompanyOper(getConnection());
Map<String,String> comapanyModify=oper.queryModifyIdentity(weixinUserId);
Map<String,String> vehicleModify=oper.queryVehicleModifyIdentity(weixinUserId);
if(comapanyModify!=null){ //<2F>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
oper.deleteModifyUser(weixinUserId);
flag=true;
}else if(vehicleModify!=null){ //˾<><CBBE>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(getConnection());
vehicleOper.deleteModifyUser(weixinUserId);
}
jsonObject.put("code", flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
/**
* <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ӫע<D3AA><D7A2>
* @throws SQLException
* @throws CException
* @throws IOException
* @throws Exception
*/
public void managerRegist() throws SQLException{
String loginName=getParameter("loginName","");
String password=getParameter("password","");
String weixinUserId=getParameter("weixinUserId", "");
String identity=getParameter("identity",""); //1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20><>Ӧ<EFBFBD><D3A6>
JSONObject jsonObject = new JSONObject();
Connection conn=null;
boolean flag=false;
jsonObject.put("loginName", loginName);
jsonObject.put("password", password);
jsonObject.put("action", 1);
try {
conn=ConnectionPool.getConnection();
JSONObject httpResponse=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8")); //Զ<>̵<EFBFBD>ע<EFBFBD><EFBFBD><E1B7BD>
if(httpResponse!=null){ //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(loginName.equals(httpResponse.get("login_name"))&&password.equals(httpResponse.get("password"))){
//ע<><D7A2><EFBFBD>ɹ<EFBFBD>
RcRescueCompanyPO rcRescueCompanyPO=new RcRescueCompanyPO();
rcRescueCompanyPO.setRescueCompanyCode(httpResponse.getString("rescue_company_code"));
rcRescueCompanyPO.setWeixinUserId(Integer.parseInt(weixinUserId));
rcRescueCompanyPO.setCompanyName(httpResponse.getString("companyName"));
rcRescueCompanyPO.setDispatchMode(Integer.parseInt(httpResponse.getString("dispatchMode")));
RcRescueCompanyOper oper=new RcRescueCompanyOper(conn);
RcRescueManagerOper manageOper=new RcRescueManagerOper(conn);
if(null!=identity&&!("").equals(identity)){
if(identity.equals("1")){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Map<String,String> manager=manageOper.queryManagerByWeixinId(weixinUserId);
if(manager==null){
int result= manageOper.insertAreaManager(loginName,password,rcRescueCompanyPO); //<2F><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
if(result>0){ //<2F><><EFBFBD>ӳɹ<D3B3>
flag=true;
}else{
flag=false;
}
}
}
if(identity.equals("2")){ //<2F><>Ӧ<EFBFBD><D3A6>
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
Map<String,String>map= oper.queryModifyIdentity(weixinUserId);
if(map==null){
int result= oper.createPatch(rcRescueCompanyPO); //<2F><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
if(result>0){ //<2F><><EFBFBD>ӳɹ<D3B3>
flag=true;
}else{
flag=false;
}
}
}
jsonObject.put("code", flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
}else{
//ע<><D7A2>ʧ<EFBFBD><CAA7>
System.err.println("failth");
jsonObject.put("code", flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
}else{
//ע<><D7A2>ʧ<EFBFBD><CAA7>
jsonObject.put("code", flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
}
/**
* <20><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD><CCB1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
* @throws CException
* @throws IOException
* @throws Exception
*/
public void checkLoginName() throws IOException{
JSONObject json=new JSONObject();
JSONObject httpRequest=null;
boolean checkFlag = false;
String rescueCode=getParameter("rescueCode","");
json.put("rescueCode", rescueCode);
json.put("action", Integer.valueOf(2));
httpRequest=JSON.parseObject(HttpsUtil.doPost(Constants.url, json,"UTF-8"));
if(httpRequest.getIntValue("errorCode") == 0){
checkFlag = true;
}
json.put("code", checkFlag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
}
/**
* <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD>Ԯ<EFBFBD><D4AE><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
* @throws CException
* @throws IOException
* @throws Exception
*/
public void queryRescueVehicle() throws IOException{
String rescueCode=getParameter("rescueCode","");
JSONObject jsonObject=new JSONObject();
JSONObject htppRequest=null;
jsonObject.put("rescueCode", rescueCode);
jsonObject.put("action", 3);
htppRequest = JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"UTF-8"));
jsonObject.put("vehicleList", htppRequest.get("vehicleList"));
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
/**
* <20><>Ԯ˾<D4AE><CBBE>ע<EFBFBD><D7A2>
* @throws SQLException
* @throws CException
* @throws IOException
* @throws Exception
*/
public void regist() throws SQLException {
String weixinUserID=getParameter("weixinUserId","");
String name=getParameter("name","");
String phone=getParameter("phone","");
String rescueCode=getParameter("rescueCode","");
String vehicleId=getParameter("vehicleId","");
String vehicleName=getParameter("vehicleName","");
JSONObject jsonObject = new JSONObject();
Connection conn=null;
jsonObject.put("rescueCode", rescueCode); //<2F><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>
jsonObject.put("action", 2);
Map rescueVehiclePO = JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject, "utf-8")); //Զ<>̵<EFBFBD>˾<EFBFBD><CBBE>ע<EFBFBD><EFBFBD><E1B7BD>
try {
conn=ConnectionPool.getConnection();
if(rescueVehiclePO !=null){ //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
RcRescueVehiclePO rcRescueVehiclePO=new RcRescueVehiclePO();
rcRescueVehiclePO.setRescue_company_code(rescueVehiclePO.get("CODE").toString());
rcRescueVehiclePO.setDispatchMode(Integer.parseInt(rescueVehiclePO.get("dispatchMode").toString()));
rcRescueVehiclePO.setWeixin_user_id(Integer.parseInt(weixinUserID));
rcRescueVehiclePO.setComapny_login_name(rescueCode);
rcRescueVehiclePO.setStaff_name(name);
rcRescueVehiclePO.setStaff_phone(phone);
rcRescueVehiclePO.setVehicle_id(Integer.parseInt(vehicleId));
rcRescueVehiclePO.setVehicle_name(vehicleName);
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(conn);
vehicleOper.insertVehicle(rcRescueVehiclePO); //<2F><><EFBFBD><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>Ϣ
jsonObject.put("code", true);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}else{
jsonObject.put("code", false);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (CException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
conn.close();
}
}
//<2F>޸<EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><E7BBB0>Ϣ
public void update() throws Exception{
String phone=getParameter("phone");
int id=Integer.parseInt(getParameter("id"));
JSONObject jsonObject = new JSONObject();
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(getConnection());
vehicleOper.updateVehicle(id, phone);
jsonObject.put("code", true);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
//<2F>޸<EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
public void updateVehicle() throws Exception{
String vehicle_name=getParameter("vehicle_name");
int id=Integer.parseInt(getParameter("id"));
int vehicleID=Integer.parseInt(getParameter("vehicleID"));
JSONObject jsonObject = new JSONObject();
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(getConnection());
vehicleOper.updateVehicleMessage(id, vehicleID,vehicle_name);
jsonObject.put("code", true);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
//<2F><>ѯ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>˾<EFBFBD><CBBE>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
public void choosedVehicleName() throws Exception{
int vehicleID=Integer.parseInt(getParameter("vehicleID"));
JSONObject jsonObject = new JSONObject();
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(getConnection());
long count=vehicleOper.choosedVehicleName(vehicleID);
jsonObject.put("code", count);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
}

View File

@ -0,0 +1,431 @@
package com.sino.rrs.action;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.publicclass.base.BaseAction;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.business.ChangeOrderMessageDispatch;
import com.sino.rrs.business.RescueVehicleDispatchMessage;
import com.sino.rrs.entity.RcRescueVehiclePO;
import com.sino.rrs.entity.RescueVehicleDispatchPO;
import com.sino.rrs.oper.RcRescueUpdateOper;
import com.sino.rrs.oper.RcRescueVehicleOper;
import com.sino.rrs.oper.RescueVehicleDispatchOper;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
import com.sino.weixin.oauth.util.ProgressProcess;
public class UpdateOrderStateAction extends BaseAction{
/**
* <20><>ѯij<D1AF><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>Ϣ
* <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD>̱<EFBFBD><CCB1><EFBFBD>rescueCode
* @throws IOException
* @throws SQLException
* @throws CException
* @throws Exception
*/
public void getVehicles() throws IOException, SQLException{
Connection conn=null;
String rescueCode=getParameter("rescueCode", "");
JSONObject jsonObject=new JSONObject();
JSONObject json=new JSONObject();
json.put("rescueCode", rescueCode);
json.put("action", 13);
List<RcRescueVehiclePO> vehicleList=null;
try {
conn=ConnectionPool.getConnection();
RcRescueVehicleOper vehicleOper=new RcRescueVehicleOper(conn);
vehicleList = vehicleOper.rescueVehicles(rescueCode);
//Զ<>̲<EFBFBD>ѯæµ<C3A6><C2B5><EFBFBD><EFBFBD>
JSONObject httpRequest=JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8"));
List<String> busyVehicleIds= (List<String>) httpRequest.get("busyVehicles");
for(RcRescueVehiclePO po:vehicleList){
if(busyVehicleIds.contains(String.valueOf(po.getVehicle_id()) )){
// System.out.println("<22><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>˴<EFBFBD>===");
po.setDispatch_flag(7);//<2F><><EFBFBD><EFBFBD>Ϊæµ<C3A6><C2B5><EFBFBD><EFBFBD>
}
}
} catch (CException e) {
e.printStackTrace();
}finally{
conn.close();
}
// System.out.println("jihe===="+vehicleList.get(0).getDispatch_flag()+vehicleList.get(0).getVehicle_id());
jsonObject.put("vehicleList",vehicleList);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
/**
* <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>˾<EFBFBD><CBBE>
* 1.<2E><><EFBFBD><EFBFBD>id<69><64>ѯʦ<D1AF><CAA6><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>Ϣ
* 2.ʦ<><CAA6><EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD>æµ<C3A6><C2B5><EFBFBD><EFBFBD>æµ<C3A6><C2B5>Զ<EFBFBD><D4B6><EFBFBD>ɵ<EFBFBD>
* 3.΢<><CEA2>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
* 4.<2E><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>Ϣ
* id ʦ<><CAA6>id
* @throws CException
* @throws Exception
*/
public void distributeOrder() throws CException, Exception{
String rescueCode=getParameter("rescueCode","");
int id=Integer.parseInt(getParameter("id", "")); //Ա<><D4B1>id
int orderId=Integer.parseInt(getParameter("orderId", ""));
String orderCode=getParameter("orderCode","");
String serviceName=getParameter("serviceName","");
String address=getParameter("address","");
String dispatchFlag = "0"; //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
Connection conn =null;
try {
conn = ConnectionPool.getConnection();
RcRescueVehicleOper vehicleOper = new RcRescueVehicleOper(conn);
RescueVehicleDispatchOper vehiDispatchOper = new RescueVehicleDispatchOper(conn);
UserOrderOper orderOper=new UserOrderOper(conn);
JSONObject json=new JSONObject();
JSONObject httpRequest=null;
Map<String,String> orderMap=orderOper.findOrderDetailByOrderId(orderId);
if(orderMap!=null){
int state=Integer.parseInt(orderMap.get("STATE"));
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>user_order state=1 <20><><EFBFBD><EFBFBD>״̬<D7B4>£<EFBFBD>
if(orderMap.get("rescueCode").equals(rescueCode)){
if(state==1){
RcRescueVehiclePO vehiclePO = vehicleOper.findByPrimaryKey(id);
if (vehiclePO != null) {
Map<String, String> vehicleService = vehiDispatchOper.vehicleDistributeService(id);
if (vehicleService == null) {
json.put("orderId", orderId);
json.put("vehicleId", vehiclePO.getVehicle_id()); //<2F><><EFBFBD><EFBFBD>id
json.put("staff_name", vehiclePO.getStaff_name()); //Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
json.put("staff_phone", vehiclePO.getStaff_phone()); //Ա<><D4B1><EFBFBD>
json.put("action", 6);
httpRequest = JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8"));
if(httpRequest.getIntValue("errorCode")==0){
dispatchFlag="1"; //<2F><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
vehiDispatchOper.insertVehicleDispatcher(orderId, id);
orderOper.updateUserOrderByOrderId(orderId, 7);
Constants.poolExecutor.execute(new RescueVehicleDispatchMessage(id,orderId,orderCode,serviceName,address));
}
}
}
}else if(state==4){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dispatchFlag="4";
}else if(state==19){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
dispatchFlag="19";
}
}else{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dispatchFlag="5"; //<2F>޸ľ<DEB8>Ԯ<EFBFBD><D4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD>
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("code",dispatchFlag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
/**
* <20><>Ӧ<EFBFBD≯<EFBFBD><CCB8><EFBFBD>˾<EFBFBD><CBBE>
* 1.֪ͨ<CDA8>ϼ<EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 2.<2E>ж<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ɵ<EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD>Ƿ<EFBFBD>æµ
* 3.ϵͳ¼<CDB3><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 4.<2E><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>Ϣ
* @throws CException
* @throws Exception
*/
public void changeDistributeOrder() throws CException, Exception{
int id=Integer.parseInt(getParameter("id", ""));
int orderId=Integer.parseInt(getParameter("orderId", ""));
String orderCode=getParameter("orderCode", "");
String rescueCode=getParameter("rescueCode");
String serviceName=getParameter("serviceName","");
String address=getParameter("address","");
String changeService="1";
JSONObject json=new JSONObject();
JSONObject httpRequest=null;
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RescueVehicleDispatchOper vehiDispatchOper = new RescueVehicleDispatchOper(conn);
UserOrderOper orderOper=new UserOrderOper(conn);
RcRescueVehicleOper vehicleOper = new RcRescueVehicleOper(conn);
Map<String,String> orderMap=orderOper.findOrderDetailByOrderId(orderId);
if(orderMap!=null){
int state=Integer.parseInt(orderMap.get("STATE"));
if(orderMap.get("rescueCode").equals(rescueCode)){
if(state==4){
changeService="4";
}else if(state==15){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
changeService="15";
}else if(state==19){
changeService="19";
}else{
RescueVehicleDispatchPO rescueVehiclePO= vehiDispatchOper.changedVehicle(orderId);
if(rescueVehiclePO!=null){
int staff_name_id=rescueVehiclePO.getRESCUE_VEHICLE_ID();
String openId = vehiDispatchOper.getRescueVehicleCode(staff_name_id);
Constants.poolExecutor.execute(new ChangeOrderMessageDispatch(openId,orderCode,staff_name_id,orderId,rescueCode));
}
RcRescueVehiclePO vehiclePO = vehicleOper.findByPrimaryKey(id);
if (vehiclePO != null) {
Map<String, String> vehicleService = vehiDispatchOper.vehicleDistributeService(id);
if (vehicleService == null) {
json.put("orderId", orderId);
json.put("vehicleId", vehiclePO.getVehicle_id()); //<2F><><EFBFBD><EFBFBD>id
json.put("staff_name", vehiclePO.getStaff_name()); //Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
json.put("staff_phone", vehiclePO.getStaff_phone());
json.put("action", 6);
httpRequest = JSON.parseObject(HttpsUtil.doPost(Constants.url, json, "utf-8"));
if(httpRequest.getIntValue("errorCode")==0){
vehiDispatchOper.updateVehicleDispatcher(orderId,id);
orderOper.updateUserOrderByOrderId(orderId, 7);
Constants.poolExecutor.execute(new RescueVehicleDispatchMessage(id,orderId,orderCode,serviceName,address));
}
}
}
}
}else{
changeService="5";
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
JSONObject jsonObject=new JSONObject();
jsonObject.put("code",changeService);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(jsonObject.toJSONString());
setNext(false);
}
/**
* <20>жϴ˶<CFB4><CBB6><EFBFBD><EFBFBD>Ƿ񻹴<C7B7><F1BBB9B4>ڸ<EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>û<EFBFBD><C3BB>ȡ<EFBFBD><C8A1><EFBFBD>͸<EFBFBD><CDB8>ɣ<EFBFBD>
* 1.<2E><>ѯʦ<D1AF><CAA6><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><CAA6>id<69><64>
* 2.<2E><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
* 3.<2E><><EFBFBD>ڣ<EFBFBD>user_order <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ȡ<EFBFBD><C8A1>
* 4.<2E>񣬲鿴<F1A3ACB2><E9BFB4><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
* 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ķ<DEB8><C4B6><EFBFBD>״̬
* @throws IOException
* @throws Exception
*/
public void vehicleChanged1() throws IOException{
int orderID=Integer.parseInt(request.getParameter("orderID")); //<2F><><EFBFBD><EFBFBD>id
String rescueVehicleId=request.getParameter("rescueVehicleId");
boolean flag=false;
JSONObject json=new JSONObject();
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcRescueUpdateOper updateOper=new RcRescueUpdateOper(conn);
RescueVehicleDispatchOper vehicleOper=new RescueVehicleDispatchOper(conn);
UserOrderOper orderOper=new UserOrderOper(conn);
Map<String,String> vehicleMap=vehicleOper.existVehicleByRecueCompany(orderID,rescueVehicleId);
if(vehicleMap!=null){
if(vehicleMap.get("rescueVehicleId").equals(rescueVehicleId)){
Map<String,String> orderMap=orderOper.findOrderByOrderId(orderID);
if(orderMap!=null){
if(Integer.parseInt(orderMap.get("STATE"))==19){
flag=false; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
}else{
flag=true; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
}
}
}
}else{ //<2F>ж϶<D0B6><CFB6><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
Map<String,String> updateMap=updateOper.findOrderChangeVehicleOrCancel(orderID,Integer.parseInt(rescueVehicleId));
if(updateMap!=null){
flag=false; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
json.put("code",flag);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
}
/**
* <20>жϴ˶<CFB4><CBB6><EFBFBD><EFBFBD>Ƿ񻹴<C7B7><F1BBB9B4>ڸ<EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>û<EFBFBD><C3BB>ȡ<EFBFBD><C8A1><EFBFBD>͸<EFBFBD><CDB8>ɣ<EFBFBD>
* 1.<2E><>ѯʦ<D1AF><CAA6><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><CAA6>id<69><64>
* 2.<2E><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
* 3.<2E><><EFBFBD>ڣ<EFBFBD>user_order <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ȡ<EFBFBD><C8A1>
* 4.<2E>񣬲鿴<F1A3ACB2><E9BFB4><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
* 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ķ<DEB8><C4B6><EFBFBD>״̬
* @throws Exception
*/
public void vehicleChanged(){
int state=Integer.parseInt(request.getParameter("state"));
int flow_id=Integer.parseInt(request.getParameter("flow_id"));
int orderID=Integer.parseInt(request.getParameter("orderID"));
double lon=Double.valueOf(getParameter("lon","0"));
double lat=Double.valueOf(getParameter("lat","0"));
String rescueVehicleId=request.getParameter("rescueVehicleId"); //˾<><CBBE><EFBFBD><EFBFBD>id
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
UserOrderOper orderOper=new UserOrderOper(conn);
Map<String,String> orderMap=orderOper.findOrderByOrderId(orderID);
int nextState=ProgressProcess.getProcess(state,flow_id);
if(Integer.parseInt(orderMap.get("STATE"))==state){ //<2F>жϵ<D0B6>ǰ״̬<D7B4>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>һ<EFBFBD><D2BB>
System.out.println("<EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>״̬"+nextState);
updateOrderState(nextState,orderID,lon,lat,rescueVehicleId);
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* <20><EFBFBD><E1BDBB><EFBFBD><EFBFBD>״̬
* 1.һ<>µ<EFBFBD><C2B5><EFBFBD>Զ<EFBFBD>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
* 2.<2E>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5>ض<EFBFBD><D8B6><EFBFBD>״̬
* @throws CException
* @throws Exception
*/
public void updateOrderState(int currentState,int orderId,double lon,double lat,String rescueVehicleId){
JSONObject json=new JSONObject();
JSONObject httpRequest=null;
Connection conn=null;
json.put("orderId", orderId);
json.put("currentState", currentState);
json.put("lon", lon);
json.put("lat", lat);
json.put("action", 7);
try {
conn=ConnectionPool.getConnection();
UserOrderOper orderOper=new UserOrderOper(conn);
httpRequest=JSON.parseObject(HttpsUtil.doPost(Constants.url, json,"utf-8"));
if(httpRequest.getIntValue("errorCode")==0){
orderOper.updateUserOrderByOrderId(orderId, currentState);
Map<String,String> orderMap=orderOper.findOrderByOrderId(orderId);
int nextState=ProgressProcess.getProcess(currentState,Integer.parseInt(orderMap.get("FLOW_ID")));
request.setAttribute("list", orderMap);
setNextPage("/supplier/currentOrderDetail.jsp?&nextState="+nextState+"&rescueVehicleId="+rescueVehicleId);
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* <20><EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 1.Զ<><D4B6><EFBFBD><EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 2.<2E><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @throws IOException
* @throws CException
* @throws Exception
*/
public void uploadOrderMileage() throws Exception {
int orderId=Integer.parseInt(getParameter("orderID", ""));
double milesage1=Double.valueOf(getParameter("milesage1","0"));
double milesage2=Double.valueOf(getParameter("milesage2","0"));
int state=Integer.parseInt(request.getParameter("state"));
int flow_id=Integer.parseInt(request.getParameter("flow_id"));
double lon=Double.valueOf(getParameter("lon","0")).doubleValue();
double lat=Double.valueOf(getParameter("lat","0")).doubleValue();
int nextState=ProgressProcess.getProcess(state,flow_id);
JSONObject json=new JSONObject();
JSONObject jsonObject=new JSONObject();
JSONObject httpRequest1=null;
JSONObject httpRequest2=null;
boolean isSuccess=false;
Connection conn=null;
json.put("orderId",orderId );
json.put("mileage1",milesage1*1000 );
json.put("mileage2",milesage2*1000 );
json.put("currentState", nextState);
json.put("lon", lon);
json.put("lat", lat);
json.put("action", 7);
jsonObject.put("action", 9);
jsonObject.put("orderId",orderId);
jsonObject.put("mileage1",milesage1*1000);
jsonObject.put("mileage2",milesage2*1000);
try {
conn=ConnectionPool.getConnection();
System.out.println(nextState+"<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
UserOrderOper orderOper=new UserOrderOper(conn);
httpRequest1=JSON.parseObject(HttpsUtil.doPost(Constants.url, jsonObject,"utf-8"));
httpRequest2=JSONObject.parseObject(HttpsUtil.doPost(Constants.url, json,"utf-8"));
if(httpRequest1.getIntValue("errorCode")==0 && httpRequest2.getIntValue("errorCode")==0){
orderOper.updateUserOrderMilesByOrderId(orderId,milesage1*1000,milesage2*1000);
orderOper.updateUserOrderByOrderId(orderId, 15);
isSuccess=true;
}
} catch (CException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
conn.close();
}
json.put("code",isSuccess);
response.setContentType("text/html;charset=UTF-8");
response.getWriter().print(json.toJSONString());
setNext(false);
}
}

View File

@ -0,0 +1,34 @@
package com.sino.rrs.business;
import java.util.List;
import java.util.Map;
import com.sino.rrs.entity.DeleteOrderMessage;
import com.sino.weixin.oauth.util.Constants;
/**
* ϵͳȡ<CDB3><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳߳<DFB3>
* @author Administrator
*
*/
public class CancelOrderMessageDispatch implements Runnable{
private static DeleteOrderMessage deleteOrderMessage=new DeleteOrderMessage();
public List<Map<String,String>> companyList;
public String orderCode;
public String supplyRemark;
public CancelOrderMessageDispatch(List<Map<String,String>> list,String orderCode,String supplyRemark){
this.companyList=list;
this.orderCode=orderCode;
this.supplyRemark=supplyRemark;
}
@Override
public void run() {
for(Map<String,String> map:companyList){
deleteOrderMessage.delete_template_message(Constants.AppId, Constants.AppSecret, map.get("open_id"), orderCode, supplyRemark);
}
}
}

View File

@ -0,0 +1,63 @@
package com.sino.rrs.business;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.CancelOrderMessage;
import com.sino.rrs.oper.RcRescueUpdateOper;
import com.sino.weixin.oauth.util.Constants;
/**
* <20><>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>֪ͨ
* 1.<2E><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
* 2.<2E><><EFBFBD>͸<EFBFBD><CDB8><EFBFBD>֪ͨ
* 3.¼<><C2BC><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>Ϣ
* @author Administrator
*
*/
public class ChangeOrderMessageDispatch implements Runnable{
private CancelOrderMessage cancelOrder = new CancelOrderMessage();
public String openId;
public String orderCode;
public int orderId;
public String rescueCode;
public int old_vehicle_id;
public ChangeOrderMessageDispatch(String openId,String orderCode,int old_vehicle_id,int orderId,String rescueCode){
this.openId=openId;
this.orderCode=orderCode;
this.orderId=orderId;
this.rescueCode=rescueCode;
this.old_vehicle_id=old_vehicle_id;
}
@Override
public void run() {
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RcRescueUpdateOper updateOper=new RcRescueUpdateOper(conn);
int result=updateOper.insertVehicleChangedMessage(orderId,1,old_vehicle_id,rescueCode,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); //<2F><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>update<74><65>
if (result>0){
cancelOrder.cancel_template_message(Constants.AppId, Constants.AppSecret,openId,orderCode,new Date(System.currentTimeMillis()));
}
} catch (CException e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,224 @@
package com.sino.rrs.business;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.RescueCompanyDispatchPO;
import com.sino.rrs.entity.RescueVehicleDispatchPO;
import com.sino.rrs.entity.SendOrderMessage;
import com.sino.rrs.oper.RcRescueUpdateOper;
import com.sino.rrs.oper.RcTempleteOrder;
import com.sino.rrs.oper.RescueCompanyDispatchOper;
import com.sino.rrs.oper.RescueVehicleDispatchOper;
import com.sino.rrs.oper.UserOrderOper;
import com.sino.weixin.oauth.util.Constants;
/**
* ϵͳ<CFB5><CDB3><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD>̳߳<DFB3>
* @author Administrator
*
*/
public class RescueCompanyDispatchMessage implements Runnable{
public static Log log=LogFactory.getLog(RescueCompanyDispatchMessage.class);
public RescueCompanyDispatchPO rescueCompanyDispatchPO;
private SendOrderMessage sendMessage= new SendOrderMessage();
Connection conn = null;
PreparedStatement pstmt = null;
public RescueCompanyDispatchMessage(RescueCompanyDispatchPO rescueCompanyDispatchPO){
this.rescueCompanyDispatchPO=rescueCompanyDispatchPO;
}
@Override
public void run() {
try {
conn=ConnectionPool.getConnection();
RescueCompanyDispatchOper rescueOper=new RescueCompanyDispatchOper(conn);
RescueVehicleDispatchOper vehicleOper=new RescueVehicleDispatchOper(conn);
UserOrderOper orderOper=new UserOrderOper(conn);
RcTempleteOrder templeteOrder=new RcTempleteOrder(conn);
RcRescueUpdateOper updateOper=new RcRescueUpdateOper(conn);
String tempID=templeteOrder.insertTempleteMessage(rescueCompanyDispatchPO.getOrder_id(), rescueCompanyDispatchPO.getRESCUE_COMPANY_CODE());
if(tempID!=null){
List<Map<String,String>> rescueCompanyList= rescueOper.getRescueCompanyCode(rescueCompanyDispatchPO.getRESCUE_COMPANY_CODE());
if(rescueCompanyList!=null&&rescueCompanyList.size()>0){ //<2F><>ע<EFBFBD><D7A2>
boolean sendFlag = false;
for(Map<String,String> rescueCompanyMap:rescueCompanyList){
if(Integer.parseInt(rescueCompanyMap.get("accept_flag"))==0 ){ //<2F><>Ӧ<EFBFBD>̴<EFBFBD><CCB4><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ״̬
rescueCompanyDispatchPO.setOpenId(rescueCompanyMap.get("open_id"));
rescueCompanyDispatchPO.setTempleteId(tempID);
int result = sendMessage.send_template_message(Constants.AppId, Constants.AppSecret,rescueCompanyDispatchPO);
if(result == 40001){
WeixinSignatureThread signature = new WeixinSignatureThread();
signature.bulidApiAccessToken();
result = sendMessage.send_template_message(Constants.AppId, Constants.AppSecret,rescueCompanyDispatchPO);
}
if(result==0){
sendFlag = true;
}
}
}
if(sendFlag){
log.info("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>ͳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
//<2F>ж϶<D0B6><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڸö<DAB8><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Map<String,String> map=orderOper.findOrderByOrderId(rescueCompanyDispatchPO.getOrder_id());
if(map!=null){ //<2F><><EFBFBD>ڸö<DAB8><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
updateMessage();
}else{
log.info("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>ͳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4444");
insertMessage();
}
//<2F>жϷ<D0B6><CFB7><EFBFBD><EFBFBD>̵<EFBFBD><CCB5>ȱ<EFBFBD><C8B1>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
log.info("¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><EFBFBD>ȱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
rescueOper.updateRescueCompanyDispatchOverTime(rescueCompanyDispatchPO.getOrder_id());
rescueOper.insertRescueCompanyMessage(rescueCompanyDispatchPO);
//<2F>ж<EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڸö<DAB8><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԯ<EFBFBD><D4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ľ<DEB8>Ԯ<EFBFBD><D4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>֮ǰ<D6AE><C7B0>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>
RescueVehicleDispatchPO vehiclePO=vehicleOper.changedVehicle(rescueCompanyDispatchPO.getOrder_id());
if(vehiclePO!=null){
updateOper.insertVehicleChangedMessage(rescueCompanyDispatchPO.getOrder_id(),5,vehiclePO.getRESCUE_VEHICLE_ID(),"","<EFBFBD><EFBFBD>Ԯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>");
vehicleOper.deleteVehicleMessageByOrderId(rescueCompanyDispatchPO.getOrder_id());
}
}else{
log.info("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
}
}catch (Exception e) {
e.printStackTrace();
log.equals(e.getMessage());
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
*/
public void updateMessage(){
try {
String sql = "update RC_USER_ORDER set ORDER_CODE=?,FLOW_ID=?,SERVICE_NAME=?,LICENSE=?,STYLE=?,USER_NAME=?,USER_PHONE=?,LON=?,LAT=?,ADDRESS=?,ADDRESS_ADD=?,DEST_ADDRESS=?,REMARK=?,STATE=?,CREATE_TIME=?,DISPATCH_USER=?,ADDRESS_PROPERTY=?,CONTRACTING_NAME=?,MILEAGE1=?,MILEAGE2=?,UPDATE_TIME=?,FINISHTIME=? where ORDER_ID=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, rescueCompanyDispatchPO.getOrder_code());
pstmt.setInt(2,rescueCompanyDispatchPO.getFlow_id());
pstmt.setString(3, rescueCompanyDispatchPO.getService_name());
pstmt.setString(4, rescueCompanyDispatchPO.getLicense());
pstmt.setString(5, rescueCompanyDispatchPO.getStyle());
pstmt.setString(6, rescueCompanyDispatchPO.getUserName());
pstmt.setString(7, rescueCompanyDispatchPO.getUserPhone());
pstmt.setDouble(8, rescueCompanyDispatchPO.getLon());
pstmt.setDouble(9, rescueCompanyDispatchPO.getLat());
pstmt.setString(10, rescueCompanyDispatchPO.getAddress());
pstmt.setString(11, rescueCompanyDispatchPO.getAddressAdd());
pstmt.setString(12, rescueCompanyDispatchPO.getDest_address());
pstmt.setString(13, rescueCompanyDispatchPO.getRemark());
pstmt.setInt(14, 62);
pstmt.setTimestamp(15, new Timestamp(System.currentTimeMillis()));
pstmt.setString(16, rescueCompanyDispatchPO.getDispatchUser());
pstmt.setString(17, rescueCompanyDispatchPO.getADDRESS_PROPERTY());
pstmt.setString(18, rescueCompanyDispatchPO.getCONTRACTING_NAME());
pstmt.setDouble(19, rescueCompanyDispatchPO.getMileage1());
pstmt.setDouble(20, rescueCompanyDispatchPO.getMileage2());
pstmt.setTimestamp(21, new Timestamp(System.currentTimeMillis()));
pstmt.setTimestamp(22, (Timestamp)rescueCompanyDispatchPO.getFinish_time());
pstmt.setInt(23,rescueCompanyDispatchPO.getOrder_id());
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
log.error("<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",e);
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
} finally {
if (pstmt != null)
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/**
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
*/
public void insertMessage(){
try {
String sql="insert into RC_USER_ORDER(ORDER_ID,ORDER_CODE,FLOW_ID,SERVICE_NAME,LICENSE,STYLE," +
"USER_NAME,USER_PHONE,LON,LAT,ADDRESS,ADDRESS_ADD,DEST_ADDRESS,REMARK,STATE,CREATE_TIME," +
"DISPATCH_USER,ADDRESS_PROPERTY,CONTRACTING_NAME,MILEAGE1,MILEAGE2,UPDATE_TIME,FINISHTIME) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1,rescueCompanyDispatchPO.getOrder_id()); //<2F><><EFBFBD><EFBFBD>id
pstmt.setString(2, rescueCompanyDispatchPO.getOrder_code());
pstmt.setInt(3,rescueCompanyDispatchPO.getFlow_id());
pstmt.setString(4, rescueCompanyDispatchPO.getService_name());
pstmt.setString(5, rescueCompanyDispatchPO.getLicense());
pstmt.setString(6, rescueCompanyDispatchPO.getStyle());
pstmt.setString(7, rescueCompanyDispatchPO.getUserName());
pstmt.setString(8, rescueCompanyDispatchPO.getUserPhone());
pstmt.setDouble(9, rescueCompanyDispatchPO.getLon());
pstmt.setDouble(10, rescueCompanyDispatchPO.getLat());
pstmt.setString(11, rescueCompanyDispatchPO.getAddress());
pstmt.setString(12, rescueCompanyDispatchPO.getAddressAdd());
pstmt.setString(13, rescueCompanyDispatchPO.getDest_address());
pstmt.setString(14, rescueCompanyDispatchPO.getRemark());
pstmt.setInt(15, 62);
pstmt.setTimestamp(16, new Timestamp(System.currentTimeMillis()));
pstmt.setString(17, rescueCompanyDispatchPO.getDispatchUser());
pstmt.setString(18, rescueCompanyDispatchPO.getADDRESS_PROPERTY());
pstmt.setString(19, rescueCompanyDispatchPO.getCONTRACTING_NAME());
pstmt.setDouble(20, rescueCompanyDispatchPO.getMileage1());
pstmt.setDouble(21, rescueCompanyDispatchPO.getMileage2());
pstmt.setTimestamp(22, (Timestamp) rescueCompanyDispatchPO.getUpdate_time());
pstmt.setTimestamp(23, (Timestamp)rescueCompanyDispatchPO.getFinish_time());
pstmt.executeUpdate();
System.out.println("----------zhixing<6E><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
} catch (Exception e) {
e.printStackTrace();
log.error("<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", e);
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
} finally {
if (pstmt != null)
try {
pstmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
/*public static void main(String[] args) {
RescueCompanyDispatchMessage a=new RescueCompanyDispatchMessage();
}*/
}

View File

@ -0,0 +1,68 @@
package com.sino.rrs.business;
import java.sql.Connection;
import java.sql.SQLException;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.RescueCompanyDispatchPO;
import com.sino.rrs.entity.SendOrderMessage;
import com.sino.rrs.oper.RescueVehicleDispatchOper;
import com.sino.weixin.oauth.util.Constants;
/**
* <20><>Ӧ<EFBFBD>̵<EFBFBD><CCB5><EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD>̳߳<DFB3>
* @author Administrator
*
*/
public class RescueVehicleDispatchMessage implements Runnable{
private SendOrderMessage sendOrder = new SendOrderMessage();
public int id;
public int orderId; //<2F><><EFBFBD><EFBFBD>id
public String orderCode;
public String serviceName;
public String address;
public RescueVehicleDispatchMessage(int id,int orderId,String orderCode,String serviceName,String address){
this.id=id;
this.orderId=orderId;
this.orderCode=orderCode;
this.serviceName=serviceName;
this.address=address;
}
@Override
public void run() {
Connection conn=null;
try {
conn=ConnectionPool.getConnection();
RescueCompanyDispatchPO rescueCompanyDispatchPO=new RescueCompanyDispatchPO();
RescueVehicleDispatchOper dispatchOper=new RescueVehicleDispatchOper(conn);
String openId = dispatchOper.getRescueVehicleCode(id);
rescueCompanyDispatchPO.setOpenId(openId);
rescueCompanyDispatchPO.setOrder_id(orderId);
rescueCompanyDispatchPO.setOrder_code(orderCode);
rescueCompanyDispatchPO.setService_name(serviceName);
rescueCompanyDispatchPO.setAddress(address);
int result=sendOrder.send_template_message(Constants.AppId, Constants.AppSecret,rescueCompanyDispatchPO);
if(result==40001){ //access_tokenʧЧ
WeixinSignatureThread signature = new WeixinSignatureThread();
signature.bulidApiAccessToken();
sendOrder.send_template_message(Constants.AppId, Constants.AppSecret,rescueCompanyDispatchPO);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (CException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,63 @@
package com.sino.rrs.business;
import java.sql.Connection;
import java.sql.SQLException;
import com.sino.publicclass.database.ConnectionPool;
import com.sino.rrs.entity.RcWeixinUserPO;
import com.sino.rrs.oper.RcWeixinUserOper;
public class SnsVehicleUserManager {
//WeixinUserDispatcher
public static RcWeixinUserPO getWeixinDispatcherUserByOpenId(String openId){
Connection conn = null;
try{
conn = ConnectionPool.getConnection();
//<2F><>ѯ<EFBFBD>ó<EFBFBD><C3B3>ĵ<EFBFBD>ǰ<EFBFBD><C7B0>Ԯ<EFBFBD><D4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
RcWeixinUserOper userOper = new RcWeixinUserOper(conn);
RcWeixinUserPO snsUser = userOper.findByOpenId(openId);
return snsUser;
}catch (Exception e) {
e.printStackTrace();
}finally {
if (conn != null)
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
}
//WeixinUserDispatch
public static int createWeixinUserDispatch(RcWeixinUserPO snsUser){
Connection conn = null;
try{
conn = ConnectionPool.getConnection();
// conn.setAutoCommit(false);
//<2F><>ѯ<EFBFBD>ó<EFBFBD><C3B3>ĵ<EFBFBD>ǰ<EFBFBD><C7B0>Ԯ<EFBFBD><D4AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
RcWeixinUserOper dispatchOper = new RcWeixinUserOper(conn);
return dispatchOper.create(snsUser);
}catch (Exception e) {
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
}finally {
if (conn != null)
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return 0;
}
}

View File

@ -0,0 +1,67 @@
package com.sino.rrs.business;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sino.weixin.api.entity.WeixinApiTicket;
import com.sino.weixin.api.entity.WeixinApiToken;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
public class WeixinSignatureThread implements Runnable{
private AdvancedUtil util = new AdvancedUtil();
private static Log log = LogFactory.getLog(WeixinSignatureThread.class);
private static final long QUERY_OUTTIME = 60*60*1000; //1Сʱ
@Override
public void run() {
while(true){
Constants.ACCESS_TOKEN = null ;
Constants.API_TICKET = null;
bulidApiAccessToken();
try {
Thread.sleep(QUERY_OUTTIME);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void bulidApiAccessToken(){
Constants.TIME_STAMP = Long.toString(System.currentTimeMillis() / 1000); //<2F><><EFBFBD><EFBFBD>
WeixinApiToken apiToken = util.getWeixinApiToken(Constants.AppId, Constants.AppSecret);
if(apiToken == null){
apiToken = util.getWeixinApiToken(Constants.AppId, Constants.AppSecret);
}
Constants.ACCESS_TOKEN = apiToken.getAccess_token();
WeixinApiTicket ticket = util.getJSApiTicket(Constants.ACCESS_TOKEN );
if(ticket == null){
ticket = util.getJSApiTicket(Constants.ACCESS_TOKEN );
}
Constants.API_TICKET = ticket.getTicket();
}
public static void main(String[] ss){
AdvancedUtil util = new AdvancedUtil();
Constants.TIME_STAMP = String.valueOf(new Date().getTime()/1000); //<2F><><EFBFBD><EFBFBD>
WeixinApiToken apiToken = util.getWeixinApiToken(Constants.AppId, Constants.AppSecret);
Constants.ACCESS_TOKEN = apiToken.getAccess_token();
WeixinApiTicket ticket = util.getJSApiTicket(Constants.ACCESS_TOKEN );
Constants.API_TICKET = ticket.getTicket();
System.out.println("ticket="+Constants.API_TICKET );
}
}

View File

@ -0,0 +1,67 @@
package com.sino.rrs.entity;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class CancelOrderMessage {
Logger log=Logger.getLogger(SendOrderMessage.class);
/**
* appID <20><><EFBFBD>ں<EFBFBD>ID
* appsecret <20><><EFBFBD>ں<EFBFBD><DABA><EFBFBD>Կ
* openid
*/
public int cancel_template_message(String appID,String appsecret,String openId,String orderCode,Date time){
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+Constants.ACCESS_TOKEN;
WXplate plate=new WXplate();
//plate.setTemplate_id("8zo9iq4LPgSUOwaimNqFXgMVeyAgb6UITBVIyhH3Or0"); //<2F><>ʽ
plate.setTemplate_id("rciW09p6ITTZ6eL2fcZ5uR1LsLwNsdz1n-O3xxI6ejs"); //<2F><><EFBFBD><EFBFBD>
plate.setTouser(openId);
Map<String,TemplateData> data=new HashMap<String, TemplateData>();
TemplateData first=new TemplateData();
first.setValue("<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
first.setColor("#173177");
data.put("first", first);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TemplateData number=new TemplateData();
number.setValue(orderCode);
number.setColor("#173177");
data.put("keyword1", number);
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
TemplateData type=new TemplateData();
type.setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time));
type.setColor("#173177");
data.put("keyword2", type);
TemplateData remark=new TemplateData();
remark.setValue("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
remark.setColor("#173177");
data.put("remark", remark);
plate.setData(data);
String objectString=JSON.toJSONString(plate);
String jsonObject=HttpsUtil.sendPost(url, objectString);
int result = 0;
if (null != jsonObject) {
JSONObject jsonobj = JSON.parseObject(jsonObject);
if (0 != jsonobj.getIntValue("errcode")) {
result = jsonobj.getIntValue("errcode");
log.error("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> errcode:{} errmsg:{}"+jsonobj.getIntValue("errcode")+jsonobj.getString("errmsg"));
}
}
log.error("ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+result);
return result;
}
}

View File

@ -0,0 +1,75 @@
package com.sino.rrs.entity;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.weixin.oauth.util.AdvancedUtil;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
import common.Logger;
public class DeleteOrderMessage {
Logger log=Logger.getLogger(SendOrderMessage.class);
private AdvancedUtil util=new AdvancedUtil();
/**
* appID <20><><EFBFBD>ں<EFBFBD>ID
* appsecret <20><><EFBFBD>ں<EFBFBD><DABA><EFBFBD>Կ
* openid
*/
public int delete_template_message(String appID,String appsecret,String openId,String orderCode,String supplyRemark){
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+Constants.ACCESS_TOKEN;
WXplate plate=new WXplate();
// plate.setTemplate_id("1-kQlbOcRhmnkLZSiu5h3KeFwUKU5kXhJ-Th3_A_i9w"); //<2F><>ʽ
// plate.setTemplate_id("UfCEkcVJXoHvP6xy32h7UqmsHzbhbmyp6Fmdhc1F50w"); //<2F><><EFBFBD><EFBFBD>
plate.setTemplate_id("rciW09p6ITTZ6eL2fcZ5uR1LsLwNsdz1n-O3xxI6ejs"); //<2F><><EFBFBD><EFBFBD>
plate.setTouser(openId);
Map<String,TemplateData> data=new HashMap<String, TemplateData>();
TemplateData first=new TemplateData();
first.setValue("<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
first.setColor("#173177");
data.put("first", first);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TemplateData order=new TemplateData();
order.setValue(orderCode);
order.setColor("#173177");
data.put("keyword1", order);
//ȡ<><C8A1>ԭ<EFBFBD><D4AD>
TemplateData reason=new TemplateData();
if(supplyRemark.equals("")){
reason.setValue("<EFBFBD><EFBFBD>");
}else{
reason.setValue(supplyRemark);
}
reason.setColor("#173177");
data.put("keyword2", reason);
TemplateData remark=new TemplateData();
remark.setValue("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
remark.setColor("#173177");
data.put("remark", remark);
plate.setData(data);
String objectString=JSON.toJSONString(plate);
String jsonObject=HttpsUtil.sendPost(url, objectString);
int result = 0;
if (null != jsonObject) {
JSONObject jsonobj = JSON.parseObject(jsonObject);
if (0 != jsonobj.getIntValue("errcode")) {
result = jsonobj.getIntValue("errcode");
log.error("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> errcode:{} errmsg:{}"+jsonobj.getIntValue("errcode")+jsonobj.getString("errmsg"));
}
}
log.error("ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+result);
return result;
}
}

View File

@ -0,0 +1,82 @@
package com.sino.rrs.entity;
/**
* <20><>ǰҳ ÿҳ<C3BF><D2B3>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> <20><>ҳ<EFBFBD><D2B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
public class Pager {
public static final int page_size=2; //Ĭ<><C4AC>ÿҳ<C3BF><D2B3>ʾ<EFBFBD><CABE>
public static final int page_num=1; //Ĭ<><C4AC>ҳ<EFBFBD><D2B3>
private int page; //ҳ<><D2B3>
private int limit=page_size; //ÿҳ<C3BF><D2B3>ʾ<EFBFBD><CABE>
private int totalPageNum; //<2F><>ҳ<EFBFBD><D2B3>
private int totalCount; //<2F><><EFBFBD><EFBFBD>
// private List<T> rows=new ArrayList<T>(); //<2F><>ҳ<EFBFBD><D2B3>Ϣ
private int start; //<2F><>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼֵ
private int endIndex; //<2F><>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getTotalPageNum() {
return totalPageNum;
}
public void setTotalPageNum(int totalPageNum) {
this.totalPageNum = totalPageNum;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getStart() {
if(page==1){
}
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getEndIndex() {
return endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
}

View File

@ -0,0 +1,27 @@
package com.sino.rrs.entity;
public class RcNewAreaPO {
public int areaid;
public String areaname;
public int parentid;
public int getAreaid() {
return areaid;
}
public void setAreaid(int areaid) {
this.areaid = areaid;
}
public String getAreaname() {
return areaname;
}
public void setAreaname(String areaname) {
this.areaname = areaname;
}
public int getParentid() {
return parentid;
}
public void setParentid(int parentid) {
this.parentid = parentid;
}
}

View File

@ -0,0 +1,58 @@
package com.sino.rrs.entity;
import org.apache.poi.ss.formula.functions.Now;
public class RcRescueCompanyPO {
private int id;
private String rescueCompanyCode;
private int weixinUserId;
private Now createTime;
private String companyName;
private int acceptFlag;
private int dispatchMode;
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getRescueCompanyCode() {
return rescueCompanyCode;
}
public void setRescueCompanyCode(String rescueCompanyCode) {
this.rescueCompanyCode = rescueCompanyCode;
}
public int getWeixinUserId() {
return weixinUserId;
}
public void setWeixinUserId(int weixinUserId) {
this.weixinUserId = weixinUserId;
}
public Now getCreateTime() {
return createTime;
}
public void setCreateTime(Now createTime) {
this.createTime = createTime;
}
public int getAcceptFlag() {
return acceptFlag;
}
public void setAcceptFlag(int acceptFlag) {
this.acceptFlag = acceptFlag;
}
public int getDispatchMode() {
return dispatchMode;
}
public void setDispatchMode(int dispatchMode) {
this.dispatchMode = dispatchMode;
}
}

View File

@ -0,0 +1,55 @@
package com.sino.rrs.entity;
public class RcRescueUpdatePO {
private int id;
private int rescueDispatchId;
private int orderType;
private String orderCode;
private String rescueCode;
private int rescueVehicleId;
private String remark;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getOrderType() {
return orderType;
}
public void setOrderType(int orderType) {
this.orderType = orderType;
}
public String getRescueCode() {
return rescueCode;
}
public void setRescueCode(String rescueCode) {
this.rescueCode = rescueCode;
}
public int getRescueVehicleId() {
return rescueVehicleId;
}
public void setRescueVehicleId(int rescueVehicleId) {
this.rescueVehicleId = rescueVehicleId;
}
public int getRescueDispatchId() {
return rescueDispatchId;
}
public void setRescueDispatchId(int rescueDispatchId) {
this.rescueDispatchId = rescueDispatchId;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
}

View File

@ -0,0 +1,90 @@
package com.sino.rrs.entity;
import java.util.Date;
public class RcRescueVehiclePO {
private int id;
private int vehicle_id;
private String vehicle_name;
private String staff_name;
private String staff_phone;
private String rescue_company_code;
private int weixin_user_id;
private String comapny_login_name;
private int dispatch_flag;
private int acceptFlag;
private int dispatchMode;
private Date create_time;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getVehicle_id() {
return vehicle_id;
}
public void setVehicle_id(int vehicle_id) {
this.vehicle_id = vehicle_id;
}
public String getVehicle_name() {
return vehicle_name;
}
public void setVehicle_name(String vehicle_name) {
this.vehicle_name = vehicle_name;
}
public String getStaff_name() {
return staff_name;
}
public void setStaff_name(String staff_name) {
this.staff_name = staff_name;
}
public String getStaff_phone() {
return staff_phone;
}
public void setStaff_phone(String staff_phone) {
this.staff_phone = staff_phone;
}
public String getRescue_company_code() {
return rescue_company_code;
}
public void setRescue_company_code(String rescue_company_code) {
this.rescue_company_code = rescue_company_code;
}
public int getWeixin_user_id() {
return weixin_user_id;
}
public void setWeixin_user_id(int weixin_user_id) {
this.weixin_user_id = weixin_user_id;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public String getComapny_login_name() {
return comapny_login_name;
}
public void setComapny_login_name(String comapny_login_name) {
this.comapny_login_name = comapny_login_name;
}
public int getDispatch_flag() {
return dispatch_flag;
}
public void setDispatch_flag(int dispatch_flag) {
this.dispatch_flag = dispatch_flag;
}
public int getAcceptFlag() {
return acceptFlag;
}
public void setAcceptFlag(int acceptFlag) {
this.acceptFlag = acceptFlag;
}
public int getDispatchMode() {
return dispatchMode;
}
public void setDispatchMode(int dispatchMode) {
this.dispatchMode = dispatchMode;
}
}

View File

@ -0,0 +1,78 @@
package com.sino.rrs.entity;
import java.util.Date;
public class RcWeixinUserPO {
private Integer id;
private String open_id;
private String nick_name;
private String sex;
private String province;
private String city;
private String country;
private Date create_time;
private int delete_flag;
private int weixin_user_id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOpen_id() {
return open_id;
}
public void setOpen_id(String open_id) {
this.open_id = open_id;
}
public String getNick_name() {
return nick_name;
}
public void setNick_name(String nick_name) {
this.nick_name = nick_name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public int getDelete_flag() {
return delete_flag;
}
public void setDelete_flag(int delete_flag) {
this.delete_flag = delete_flag;
}
public int getWeixin_user_id() {
return weixin_user_id;
}
public void setWeixin_user_id(int weixin_user_id) {
this.weixin_user_id = weixin_user_id;
}
}

View File

@ -0,0 +1,223 @@
package com.sino.rrs.entity;
import java.util.Date;
public class RescueCompanyDispatchPO
{
private int Id;
private int order_id;
private int flow_id;
private String order_code;
private String service_name;
private String license;
private String style;
private String userName;
private String userPhone;
private double lon;
private double lat;
private String address;
private String addressAdd;
private String dest_address;
private String remark;
private Date create_time;
private String RESCUE_COMPANY_CODE;
private String dispatchUser;
private String ADDRESS_PROPERTY;
private String CONTRACTING_NAME;
private String openId;
private String templeteId;
private int flag;
private double mileage1;
private double mileage2;
private Date update_time;
private Date finish_time;
private int dispatch_state;
private int dispatch_flag;
private int orderType;
public String getUserName()
{
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPhone() {
return this.userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
public double getLon() {
return this.lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public double getLat() {
return this.lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public String getRemark() {
return this.remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getDispatchUser() {
return this.dispatchUser;
}
public void setDispatchUser(String dispatchUser) {
this.dispatchUser = dispatchUser;
}
public String getADDRESS_PROPERTY() {
return this.ADDRESS_PROPERTY;
}
public void setADDRESS_PROPERTY(String aDDRESS_PROPERTY) {
this.ADDRESS_PROPERTY = aDDRESS_PROPERTY;
}
public String getCONTRACTING_NAME() {
return this.CONTRACTING_NAME;
}
public void setCONTRACTING_NAME(String cONTRACTING_NAME) {
this.CONTRACTING_NAME = cONTRACTING_NAME;
}
public int getDispatch_state()
{
return this.dispatch_state;
}
public void setDispatch_state(int dispatch_state) {
this.dispatch_state = dispatch_state;
}
public String getService_name() {
return this.service_name;
}
public void setService_name(String service_name) {
this.service_name = service_name;
}
public String getLicense() {
return this.license;
}
public void setLicense(String license) {
this.license = license;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getDest_address() {
return this.dest_address;
}
public void setDest_address(String dest_address) {
this.dest_address = dest_address;
}
public Date getCreate_time() {
return this.create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
public Integer getId()
{
return Integer.valueOf(this.Id);
}
public void setId(Integer id) {
this.Id = id.intValue();
}
public int getOrder_id() {
return this.order_id;
}
public void setOrder_id(int order_id) {
this.order_id = order_id;
}
public String getOrder_code() {
return this.order_code;
}
public void setOrder_code(String order_code) {
this.order_code = order_code;
}
public String getRESCUE_COMPANY_CODE() {
return this.RESCUE_COMPANY_CODE;
}
public void setRESCUE_COMPANY_CODE(String rESCUE_COMPANY_CODE) {
this.RESCUE_COMPANY_CODE = rESCUE_COMPANY_CODE;
}
public int getDispatch_flag() {
return this.dispatch_flag;
}
public void setDispatch_flag(int dispatch_flag) {
this.dispatch_flag = dispatch_flag;
}
public int getFlow_id() {
return this.flow_id;
}
public void setFlow_id(int flow_id) {
this.flow_id = flow_id;
}
public int getOrderType() {
return this.orderType;
}
public void setOrderType(int orderType) {
this.orderType = orderType;
}
public String getStyle() {
return this.style;
}
public void setStyle(String style) {
this.style = style;
}
public String getAddressAdd() {
return this.addressAdd;
}
public void setAddressAdd(String addressAdd) {
this.addressAdd = addressAdd;
}
public String getOpenId() {
return this.openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getTempleteId() {
return this.templeteId;
}
public void setTempleteId(String templeteId) {
this.templeteId = templeteId;
}
public int getFlag() {
return this.flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public double getMileage1() {
return this.mileage1;
}
public void setMileage1(double mileage1) {
this.mileage1 = mileage1;
}
public double getMileage2() {
return this.mileage2;
}
public void setMileage2(double mileage2) {
this.mileage2 = mileage2;
}
public Date getUpdate_time() {
return this.update_time;
}
public void setUpdate_time(Date update_time) {
this.update_time = update_time;
}
public Date getFinish_time() {
return this.finish_time;
}
public void setFinish_time(Date finish_time) {
this.finish_time = finish_time;
}
}

View File

@ -0,0 +1,26 @@
package com.sino.rrs.entity;
public class RescueVehicleDispatchPO {
private Integer ID;
private int RESCUE_VEHICLE_ID;
private int orderId;
public Integer getID() {
return ID;
}
public void setID(Integer iD) {
ID = iD;
}
public int getRESCUE_VEHICLE_ID() {
return RESCUE_VEHICLE_ID;
}
public void setRESCUE_VEHICLE_ID(int rESCUE_VEHICLE_ID) {
RESCUE_VEHICLE_ID = rESCUE_VEHICLE_ID;
}
public int getOrderId() {
return orderId;
}
public void setOrderId(int orderId) {
this.orderId = orderId;
}
}

View File

@ -0,0 +1,77 @@
package com.sino.rrs.entity;
import java.util.Date;
public class RescueVehiclePO {
private Date UPDATE_TIME;
private String SIM;
private String SERVICE_IDS;
private String RESCUE_COMPANY_CODE;
private int RANGE;
private String PHONE;
private String NAME;
private int IS_EXIST;
private int ID;
private int DELETE_FLAG;
public Date getUPDATE_TIME() {
return UPDATE_TIME;
}
public void setUPDATE_TIME(Date uPDATE_TIME) {
UPDATE_TIME = uPDATE_TIME;
}
public String getSIM() {
return SIM;
}
public void setSIM(String sIM) {
SIM = sIM;
}
public String getSERVICE_IDS() {
return SERVICE_IDS;
}
public void setSERVICE_IDS(String sERVICE_IDS) {
SERVICE_IDS = sERVICE_IDS;
}
public String getRESCUE_COMPANY_CODE() {
return RESCUE_COMPANY_CODE;
}
public void setRESCUE_COMPANY_CODE(String rESCUE_COMPANY_CODE) {
RESCUE_COMPANY_CODE = rESCUE_COMPANY_CODE;
}
public int getRANGE() {
return RANGE;
}
public void setRANGE(int rANGE) {
RANGE = rANGE;
}
public String getPHONE() {
return PHONE;
}
public void setPHONE(String pHONE) {
PHONE = pHONE;
}
public String getNAME() {
return NAME;
}
public void setNAME(String nAME) {
NAME = nAME;
}
public int getIS_EXIST() {
return IS_EXIST;
}
public void setIS_EXIST(int iS_EXIST) {
IS_EXIST = iS_EXIST;
}
public int getID() {
return ID;
}
public void setID(int iD) {
ID = iD;
}
public int getDELETE_FLAG() {
return DELETE_FLAG;
}
public void setDELETE_FLAG(int dELETE_FLAG) {
DELETE_FLAG = dELETE_FLAG;
}
}

View File

@ -0,0 +1,59 @@
package com.sino.rrs.entity;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class SendInformation {
Logger log=Logger.getLogger(SendInformation.class); //ʹ<><CAB9>log4j<34>ķ<EFBFBD>ʽ<EFBFBD><CABD>¼<EFBFBD><C2BC>־
//private static Log log=LogFactory.getLog(SendInformation.class); //<2F><><EFBFBD><EFBFBD>apache<68><65>common-logging<6E><67>
//<2F><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>----<2D><>Ӧ<EFBFBD><D3A6> <20><>Ϣ
public int sendInformation(String contentTitle,String content,String openId){
String url="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+Constants.ACCESS_TOKEN;
WXplate plate=new WXplate();
plate.setUrl("http://www.sino-assistance.com.cn/SinoGYS/supplier/messageDetail.jsp?contentTitle="+contentTitle+"&content="+content);
plate.setTouser(openId); //<2F><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>openid
plate.setTemplate_id("8MzfuJDHYKcjAJzf76ay71RNP9zQnvhlmS5BAuRpk1w"); //ģ<><C4A3>id
Map<String,TemplateData> data=new HashMap<String,TemplateData>();
TemplateData title=new TemplateData();
title.setValue(contentTitle); //<2F><><EFBFBD><EFBFBD>
data.put("first", title);
TemplateData message=new TemplateData();
message.setValue(content); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>1
data.put("keyword1", message);
TemplateData message1=new TemplateData();
message1.setValue("֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2"); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>2
data.put("keyword2", message1);
TemplateData message2=new TemplateData();
message2.setValue("֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>3"); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>3
data.put("keyword3", message2);
plate.setData(data);
String objectString=JSON.toJSONString(plate);
String jsonObject=HttpsUtil.sendPost(url, objectString);
int result=0;
if(null!=jsonObject){
JSONObject jsonobj = JSON.parseObject(jsonObject);
if(0!=jsonobj.getIntValue("errcode")){
result=jsonobj.getIntValue("errcode");
log.info("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>errcode errmsg"+jsonobj.getIntValue("errcode")+jsonobj.getIntValue("errmsg"));
}
}
log.info("ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD><EFBFBD>"+result);
return result;
}
}

View File

@ -0,0 +1,81 @@
package com.sino.rrs.entity;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sino.weixin.oauth.util.Constants;
import com.sino.weixin.oauth.util.HttpsUtil;
public class SendOrderMessage {
Logger log=Logger.getLogger(SendOrderMessage.class);
/**
* appID <20><><EFBFBD>ں<EFBFBD>ID
* appsecret <20><><EFBFBD>ں<EFBFBD><DABA><EFBFBD>Կ
* openid
*/
public int send_template_message(String appID,String appsecret,RescueCompanyDispatchPO rescueCompanyDispatchPO){
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+Constants.ACCESS_TOKEN;
WXplate plate=new WXplate();
plate.setUrl(Constants.TEMPLATE_URL+"/SinoGYS/ReceiveOrderAction.do?CMD=showOrderDetail"+"&orderId="+rescueCompanyDispatchPO.getOrder_id()+"&openid="+rescueCompanyDispatchPO.getOpenId()+"&templeteId="+rescueCompanyDispatchPO.getTempleteId());
plate.setTemplate_id("TJ7Dod5OX_Fng9GVMzXrrXTTR_r9_WyDt9uJ6tw0PyM"); //<2F><><EFBFBD><EFBFBD>
// plate.setTemplate_id("o4YA98uGQUBOsASQenh1zpJUFp40schuiaG5I5VcVPM"); //<2F><><EFBFBD><EFBFBD>
// plate.setTemplate_id("NaZAB0VmrCyqgod5CSEyeVqpJA-5Zyp4nrT87vAbPbM"); //<2F><>ʽ
plate.setTouser(rescueCompanyDispatchPO.getOpenId());
Map<String,TemplateData> data=new HashMap<String, TemplateData>();
TemplateData first=new TemplateData();
first.setValue("<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
first.setColor("#173177");
data.put("first", first);
//<2F>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>
TemplateData number=new TemplateData();
number.setValue(rescueCompanyDispatchPO.getOrder_code());
number.setColor("#173177");
data.put("keyword1", number);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TemplateData type=new TemplateData();
type.setValue(rescueCompanyDispatchPO.getService_name());
type.setColor("#173177");
data.put("keyword2", type);
//<2F><><EFBFBD>ϵص<CFB5>
TemplateData place=new TemplateData();
place.setValue(rescueCompanyDispatchPO.getAddress());
place.setColor("#173177");
data.put("keyword3", place);
TemplateData remark=new TemplateData();
remark.setValue("<EFBFBD><EFBFBD>ӭ<EFBFBD>ٴ<EFBFBD>ȷ<EFBFBD>ϣ<EFBFBD>");
remark.setColor("#173177");
data.put("remark", remark);
plate.setData(data);
String objectString=JSON.toJSONString(plate);
String jsonObject=HttpsUtil.sendPost(url, objectString);
int result = 0;
if (null != jsonObject) {
JSONObject jsonobj = JSON.parseObject(jsonObject);
if (0 != jsonobj.getIntValue("errcode")) {
result = jsonobj.getIntValue("errcode");
log.error("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> errcode:{} errmsg:{}"+jsonobj.getIntValue("errcode")+jsonobj.getString("errmsg"));
}
}
log.error("ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+result);
return result;
}
/*public static void main(String[] args) {
SendOrderMessage send=new SendOrderMessage();
RescueCompanyDispatchPO po=new RescueCompanyDispatchPO();
po.setOpenId("oioxCwZDGQIdzfsZs9I5wYw7KfQo");
po.setOrder_code("14124512112");
po.setService_name("<22><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>");
po.setAddress("<22>Ϻ<EFBFBD><CFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>԰");
send.send_template_message(Constants.AppId, Constants.AppSecret,po);
}*/
}

View File

@ -0,0 +1,26 @@
package com.sino.rrs.entity;
public class SystemUserPO {
private String login_name;
private String password;
private String rescue_company_code;
public String getLogin_name() {
return login_name;
}
public void setLogin_name(String login_name) {
this.login_name = login_name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRescue_company_code() {
return rescue_company_code;
}
public void setRescue_company_code(String rescue_company_code) {
this.rescue_company_code = rescue_company_code;
}
}

View File

@ -0,0 +1,19 @@
package com.sino.rrs.entity;
public class TemplateData {
private String value;
private String color;
public String getValue() {
return value;
}
public void setValue(Object object) {
this.value = (String) object;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}

View File

@ -0,0 +1,199 @@
package com.sino.rrs.entity;
import java.util.Date;
public class VehicleUserPO {
private int id;
private String code;
private String identity;
private String license;
private String frame_code;
private String style;
private String brands;
private String name;
private String phone;
private String contract_company_code;
private String service_group_code;
private int service_times;
private int has_service_times;
private Date start_time;
private Date end_time;
private String city;
private String remark;
private String email;
private Date update_time;
private String visit_msg;
private String visit_user;
private Date visit_time;
private int visit_result;
private String create_user;
private int contract_organize_id;
private String contract_organize_name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getIdentity() {
return identity;
}
public void setIdentity(String identity) {
this.identity = identity;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = license;
}
public String getFrame_code() {
return frame_code;
}
public void setFrame_code(String frame_code) {
this.frame_code = frame_code;
}
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
public String getBrands() {
return brands;
}
public void setBrands(String brands) {
this.brands = brands;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getContract_company_code() {
return contract_company_code;
}
public void setContract_company_code(String contract_company_code) {
this.contract_company_code = contract_company_code;
}
public String getService_group_code() {
return service_group_code;
}
public void setService_group_code(String service_group_code) {
this.service_group_code = service_group_code;
}
public int getService_times() {
return service_times;
}
public void setService_times(int service_times) {
this.service_times = service_times;
}
public int getHas_service_times() {
return has_service_times;
}
public void setHas_service_times(int has_service_times) {
this.has_service_times = has_service_times;
}
public String getContract_organize_name() {
return contract_organize_name;
}
public void setContract_organize_name(String contract_organize_name) {
this.contract_organize_name = contract_organize_name;
}
/**
* ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return
*/
public int getRestServiceTimes(){
return service_times - has_service_times;
}
public Date getStart_time() {
return start_time;
}
public void setStart_time(Date start_time) {
this.start_time = start_time;
}
public Date getEnd_time() {
return end_time;
}
public void setEnd_time(Date end_time) {
this.end_time = end_time;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Date getUpdate_time() {
return update_time;
}
public void setUpdate_time(Date update_time) {
this.update_time = update_time;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getVisit_msg() {
return visit_msg;
}
public void setVisit_msg(String visit_msg) {
this.visit_msg = visit_msg;
}
public String getVisit_user() {
return visit_user;
}
public void setVisit_user(String visit_user) {
this.visit_user = visit_user;
}
public Date getVisit_time() {
return visit_time;
}
public void setVisit_time(Date visit_time) {
this.visit_time = visit_time;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCreate_user() {
return create_user;
}
public void setCreate_user(String create_user) {
this.create_user = create_user;
}
public int getVisit_result() {
return visit_result;
}
public void setVisit_result(int visit_result) {
this.visit_result = visit_result;
}
public int getContract_organize_id() {
return contract_organize_id;
}
public void setContract_organize_id(int contract_organize_id) {
this.contract_organize_id = contract_organize_id;
}
}

View File

@ -0,0 +1,46 @@
package com.sino.rrs.entity;
import java.util.Map;
public class WXplate {
private String template_id; //ģ<><C4A3><EFBFBD><EFBFBD>ϢID
private String touser; //<2F>û<EFBFBD>ID
private String url; //<2F><><EFBFBD>ӵ<EFBFBD>ַ
//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Map<String,TemplateData> data;
public String getTemplate_id() {
return template_id;
}
public void setTemplate_id(String template_id) {
this.template_id = template_id;
}
public String getTouser() {
return touser;
}
public void setTouser(Object object) {
this.touser = (String) object;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Map<String, TemplateData> getData() {
return data;
}
public void setData(Map<String, TemplateData> data) {
this.data = data;
}
}

View File

@ -0,0 +1,25 @@
package com.sino.rrs.entity;
public class WeixinOrderPO {
private int ID;
private String OPENID;
private String ORDERCODE;
public int getID() {
return ID;
}
public void setID(int iD) {
ID = iD;
}
public String getOPENID() {
return OPENID;
}
public void setOPENID(String oPENID) {
OPENID = oPENID;
}
public String getORDERCODE() {
return ORDERCODE;
}
public void setORDERCODE(String oRDERCODE) {
ORDERCODE = oRDERCODE;
}
}

View File

@ -0,0 +1,44 @@
package com.sino.rrs.entity;
import java.util.Date;
public class WeixinOrderRelaPO {
private String staff_name;
private String code;
private String serviceName;
private String address;
private Date finishTime;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getStaff_name() {
return staff_name;
}
public void setStaff_name(String staff_name) {
this.staff_name = staff_name;
}
public Date getFinishTime() {
return finishTime;
}
public void setFinishTime(Date finishTime) {
this.finishTime = finishTime;
}
}

View File

@ -0,0 +1,65 @@
package com.sino.rrs.entity;
import java.util.Date;
public class WeixinUserOrderPO {
private int id;
private int vehicle_user_id;
private String phone;
private int service_id;
private String address;
private double lon;
private double lat;
private Date create_time;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getVehicle_user_id() {
return vehicle_user_id;
}
public void setVehicle_user_id(int vehicle_user_id) {
this.vehicle_user_id = vehicle_user_id;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public int getService_id() {
return service_id;
}
public void setService_id(int service_id) {
this.service_id = service_id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public Date getCreate_time() {
return create_time;
}
public void setCreate_time(Date create_time) {
this.create_time = create_time;
}
}

View File

@ -0,0 +1,68 @@
package com.sino.rrs.oper;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sino.publicclass.base.BaseBean;
import com.sino.publicclass.base.CException;
import com.sino.rrs.entity.RcNewAreaPO;
public class RcNewAreaOper extends BaseBean{
public static final String TABLENAME="RC_NEW_AREA";
public RcNewAreaOper(Connection curConn) {
super(curConn);
}
@Override
protected String getTableName() {
return TABLENAME;
}
@Override
public Object resultAdaptor() throws Exception {
RcNewAreaPO areaPO=new RcNewAreaPO();
areaPO.setAreaid(getInt("AREAID"));
areaPO.setAreaname(getString("AREANAME"));
areaPO.setParentid(getInt("PARENTID"));
return areaPO;
}
//<2F><EFBFBD><E9BFB4><EFBFBD><EFBFBD>ʡ
public List<RcNewAreaPO> queryPrivince(String areaCode) throws CException{
String sql="select * from RC_NEW_AREA where PARENTID=0 and AREAID in ("+areaCode+")";
return findAll(sql);
}
//<2F>鿴ʡ--<2D><>
public List<RcNewAreaPO> queryPrivinceCity(int parentid) throws CException{
String sql="select * from RC_NEW_AREA where PARENTID="+parentid;
return findAll(sql);
}
//<2F>鿴ʡ--<2D><><EFBFBD><EFBFBD>--<2D><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6> (<28><><EFBFBD><EFBFBD>ʡ--<2D><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>open id)
public List<Map<String,String>> queryPrivinceCitySupplier(String rescueCode) throws CException{
String sql="select a.open_id,b.COMPANYNAME from RC_WEIXIN_USER a LEFT JOIN RC_RESCUE_COMPANY b ON a.ID=b.WEIXIN_USER_ID where b.RESCUE_COMPANY_CODE in"+rescueCode.replace("[", "(").replace("]", ")");
return findAll(sql,"resultFindPrivinceCitySupplier");
}
public Map<String,String> resultFindPrivinceCitySupplier() throws SQLException{
Map<String,String> map=new HashMap<String, String>();
map.put("open_id", getString("open_id"));
map.put("companyName", getString("COMPANYNAME"));
return map;
}
//<2F><><EFBFBD><EFBFBD>
/*public void insertNewArea(List<String> data) throws CException{
ConstructSQL sql=new ConstructInsertSQL();
sql.setTableName(TABLENAME);
sql.setColumn("AREAID", data.get(0).trim());
sql.setColumn("AREANAME", data.get(1).trim());
sql.setColumn("PARENTID", data.get(2).trim());
update(sql.getSQL());
}*/
}

View File

@ -0,0 +1,94 @@
package com.sino.rrs.oper;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sino.publicclass.base.BaseBean;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.sql.ConstructInsertSQL;
import com.sino.publicclass.sql.ConstructSQL;
import com.sino.rrs.entity.RcRescueCompanyPO;
public class RcRescueCompanyOper extends BaseBean{
public static final String TABLENAME="RC_RESCUE_COMPANY";
public RcRescueCompanyOper(Connection curConn) {
super(curConn);
}
@Override
protected String getTableName() {
return TABLENAME;
}
@Override
protected Object resultAdaptor() throws Exception {
Map<String,String> entity=new HashMap<String, String>();
entity.put("rescue_company_code", getString("RESCUE_COMPANY_CODE"));
entity.put("vehicleId", getString("VEHICLE_ID"));
/*RcRescueCompanyPO entity = new RcRescueCompanyPO();
entity.setRescueCompanyCode(getString("rescue_company_code"));
entity.setWeixinUserId(getInt("weixinUserId"));*/
return entity;
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE>Ƿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
public Map<String,String> queryModifyIdentity(String weixinUserId) throws CException{
String sql="select a.RESCUE_COMPANY_CODE from RC_RESCUE_COMPANY a where a.WEIXIN_USER_ID="+weixinUserId;
return (Map<String, String>) findOne(sql,"resultQueryModifyIdentity");
}
public Map<String,String> resultQueryModifyIdentity() throws SQLException{
Map<String,String> map=new HashMap<String, String>();
map.put("rescueCode", getString("RESCUE_COMPANY_CODE"));
return map;
}
//<2F><>ѯ˾<D1AF><CBBE>֮ǰ<D6AE>Ƿ<EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>
public Map<String,String> queryVehicleModifyIdentity(String weixinUserId) throws CException{
String sql="select b.VEHICLE_ID from RC_RESCUE_VEHICLE b where b.WEIXIN_USER_ID="+weixinUserId;
return (Map<String, String>) findOne(sql,"resultQueryVehicleModifyIdentity");
}
public Map<String,String> resultQueryVehicleModifyIdentity() throws SQLException{
Map<String,String> map=new HashMap<String, String>();
map.put("VEHICLE_ID", getString("VEHICLE_ID"));
return map;
}
//<2F><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
public int createPatch(RcRescueCompanyPO rcRescueCompanyPO) throws CException{
ConstructSQL sql = new ConstructInsertSQL();
sql.setTableName(TABLENAME);
sql.setColumn("RESCUE_COMPANY_CODE",rcRescueCompanyPO.getRescueCompanyCode());
sql.setColumn("WEIXIN_USER_ID",rcRescueCompanyPO.getWeixinUserId());
sql.setColumn("COMPANYNAME",rcRescueCompanyPO.getCompanyName());
sql.setColumn("DISPATCH_MODE", rcRescueCompanyPO.getDispatchMode());
sql.setColumn("ACCEPT_FLAG", 0);
sql.setColumnTimestamp("CREATE_TIME",new Date());
return update(sql.getSQL());
}
//<2F><><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD><CCB8><EFBFBD><EFBFBD>û<EFBFBD>ʱɾ<CAB1><C9BE>֮ǰ<D6AE><C7B0>Ϣ
public boolean deleteModifyUser(String weixinUserId) throws CException{
String sql="delete from RC_RESCUE_COMPANY where WEIXIN_USER_ID="+weixinUserId;
return deleteOne(sql);
}
//<2F><EFBFBD><E9BFB4>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public List<Map<String,String>> queryPrivinceCitySupplierName(String rescueCode) throws CException{
String sql="SELECT RESCUE_COMPANY_CODE,COMPANYNAME from RC_RESCUE_COMPANY WHERE RESCUE_COMPANY_CODE IN "+rescueCode.replace("[", "(").replace("]", ")");
return findAll(sql,"resultFindPrivinceCitySupplierName");
}
public Map<String,String> resultFindPrivinceCitySupplierName() throws SQLException{
Map<String,String> map=new HashMap<String, String>();
map.put("rescueCode", getString("RESCUE_COMPANY_CODE"));
map.put("companyName", getString("COMPANYNAME"));
return map;
}
}

View File

@ -0,0 +1,63 @@
package com.sino.rrs.oper;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sino.publicclass.base.BaseBean;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.sql.ConstructInsertSQL;
import com.sino.publicclass.sql.ConstructSQL;
import com.sino.rrs.entity.RcRescueCompanyPO;
public class RcRescueManagerOper extends BaseBean{
public static final String TABLENAME="RC_RESCUE_MANAGER";
public RcRescueManagerOper(Connection curConn) {
super(curConn);
}
@Override
protected String getTableName() {
return TABLENAME;
}
@Override
protected Object resultAdaptor() throws Exception {
Map<String,String> map=new HashMap<String,String>();
map.put("id", getString("id"));
map.put("login_name", getString("login_name"));
map.put("password", getString("password"));
map.put("rescue_company_code", getString("rescue_company_code"));
return map;
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>½<EFBFBD><C2BD>
public Map<String,String> queryManagerByWeixinId(String weixinUserId) throws CException{
String sql="select id,login_name,password,rescue_company_code from rc_rescue_manager where weixin_user_id="+weixinUserId;
return (Map<String, String>) findOne(sql);
}
//<2F><><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
public int insertAreaManager(String loginName,String password,RcRescueCompanyPO rcRescueCompanyPO) throws CException{
ConstructSQL sql=new ConstructInsertSQL();
sql.setTableName(TABLENAME);
sql.setColumn("LOGIN_NAME", loginName);
sql.setColumn("PASSWORD", password);
sql.setColumn("WEIXIN_USER_ID", rcRescueCompanyPO.getWeixinUserId());
sql.setColumn("RESCUE_COMPANY_CODE", rcRescueCompanyPO.getRescueCompanyCode());
return update(sql.getSQL());
}
//<2F><EFBFBD><E9BFB4>Ӧ<EFBFBD>̶<EFBFBD>Ӧ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public List<String> queryManager(String loginName) throws CException{
String sql="select a.open_id from rc_weixin_user a LEFT JOIN rc_rescue_manager b on a.ID=b.WEIXIN_USER_ID where b.LOGIN_NAME='"+loginName+"'";
return findAll(sql,"resultQueryManager");
}
public String resultQueryManager() throws SQLException{
return getString("open_id");
}
}

View File

@ -0,0 +1,78 @@
package com.sino.rrs.oper;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.sino.publicclass.base.BaseBean;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.sql.ConstructInsertSQL;
import com.sino.publicclass.sql.ConstructSQL;
import com.sino.rrs.entity.RcRescueUpdatePO;
public class RcRescueUpdateOper extends BaseBean{
public static final String TABLENAME="RC_RESCUE_UPDATE";
public RcRescueUpdateOper(Connection curConn) {
super(curConn);
}
@Override
protected String getTableName() {
return TABLENAME;
}
@Override
protected Object resultAdaptor() throws Exception {
RcRescueUpdatePO po=new RcRescueUpdatePO();
po.setId(getInt("ID"));
po.setOrderType(getInt("ORDER_TYPE"));
po.setRescueCode(getString("RESCUE_COMPANY_CODE"));
po.setRescueVehicleId(getInt("RESCUE_VEHICLE_ID"));
return null;
}
//<2F>鿴ȡ<E9BFB4><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Map<String,String> queryCanceledOrder(String orderCode) throws CException{
String sql="select a.REMARK,a.ORDER_CODE,c.open_id,a.RESCUE_VEHICLE_ID from RC_RESCUE_UPDATE a left join RC_RESCUE_COMPANY b on a.RESCUE_COMPANY_CODE=b.RESCUE_COMPANY_CODE left join RC_RESCUE_VEHICLE d on d.ID=a.RESCUE_VEHICLE_ID left join RC_WEIXIN_USER c "+
"on b.WEIXIN_USER_ID=c.ID where a.ORDER_TYPE=19 and a.ORDER_CODE='"+orderCode+"' union "+
"(select a.REMARK,a.ORDER_CODE,c.open_id,a.RESCUE_VEHICLE_ID from RC_RESCUE_UPDATE a left join RC_RESCUE_COMPANY b on a.RESCUE_COMPANY_CODE=b.RESCUE_COMPANY_CODE left join RC_RESCUE_VEHICLE d on d.ID=a.RESCUE_VEHICLE_ID left join RC_WEIXIN_USER c "+
"on d.WEIXIN_USER_ID=c.ID where a.ORDER_TYPE=19 and a.ORDER_CODE='"+orderCode+"')";
return (Map<String, String>)findAll(sql,"resultQueryCanceledOrder");
}
public Map<String,String> resultQueryCanceledOrder() throws Exception{
Map<String,String> entity=new HashMap<String, String>();
entity.put("orderCode", getString("ORDER_CODE"));
entity.put("remark", getString("REMARK"));
entity.put("openId", getString("open_id"));
entity.put("rescueVehicleId", getString("RESCUE_VEHICLE_ID"));
return entity;
}
//<2F><><EFBFBD>Ӹ<EFBFBD><D3B8><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>Ϣ(1) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4
public int insertVehicleChangedMessage(int orderId,int orderType,int olderVehicleId,String rescueCode,String remark) throws CException{
ConstructSQL sql = new ConstructInsertSQL();
sql.setTableName(TABLENAME);
sql.setColumn("ORDER_ID", orderId);
sql.setColumn("ORDER_TYPE",orderType);
sql.setColumn("RESCUE_COMPANY_CODE",rescueCode);
sql.setColumn("RESCUE_VEHICLE_ID",olderVehicleId);
sql.setColumn("REMARK", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
sql.setColumnTimestamp("CREATE_TIME", new Date());
return update(sql.getSQL());
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>(11)
public Map<String,String> findOrderChangeVehicleOrCancel(int orderId,int rescueVehicleId) throws CException{
String sql="SELECT ORDER_TYPE from RC_RESCUE_UPDATE where ORDER_ID="+orderId+" and RESCUE_VEHICLE_ID="+ rescueVehicleId;
return (Map<String,String>)findOne(sql, "resultFindOrderChangeVehicleOrCancel");
}
public Map<String,String> resultFindOrderChangeVehicleOrCancel() throws SQLException {
Map<String,String> map=new HashMap<String, String>();
map.put("orderType", getString("ORDER_TYPE"));
return map;
}
}

View File

@ -0,0 +1,147 @@
package com.sino.rrs.oper;
import java.sql.Connection;
import java.util.Date;
import java.util.List;
import com.sino.publicclass.base.BaseBean;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.sql.ConstructInsertSQL;
import com.sino.publicclass.sql.ConstructSQL;
import com.sino.publicclass.sql.ConstructUpdateSQL;
import com.sino.rrs.entity.RcRescueVehiclePO;
import com.sino.rrs.entity.WeixinOrderRelaPO;
public class RcRescueVehicleOper extends BaseBean{
public static final String TABLENAME="RC_RESCUE_VEHICLE";
public RcRescueVehicleOper(Connection curConn) {
super(curConn);
}
@Override
protected String getTableName() {
return TABLENAME;
}
@Override
protected Object resultAdaptor() throws Exception {
RcRescueVehiclePO entity = new RcRescueVehiclePO();
entity.setCreate_time(getDate("CREATE_TIME"));
entity.setRescue_company_code(getString("RESCUE_COMPANY_CODE"));
entity.setWeixin_user_id(getInt("WEIXIN_USER_ID"));
entity.setStaff_name(getString("STAFF_NAME"));
entity.setStaff_phone(getString("STAFF_PHONE"));
entity.setVehicle_id(getInt("vehicle_id"));
entity.setVehicle_name(getString("vehicle_name"));
return entity;
}
//<2F><>ѯ˾<D1AF><CBBE>ѡ<EFBFBD><D1A1><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
public long choosedVehicleName(int vehicle_id) throws CException{
String sql="select count(ID) from RC_RESCUE_VEHICLE where VEHICLE_ID="+vehicle_id;
return findCount(sql);
}
/*public RcRescueVehiclePO resultChoosedVehicleName() throws Exception{
RcRescueVehiclePO po=new RcRescueVehiclePO();
po.setId(getInt("ID"));
po.setWeixin_user_id(getInt("WEIXIN_USER_ID"));
return po;
}*/
//<2F><><EFBFBD><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>Ϣ
public boolean insertVehicle(RcRescueVehiclePO rcRescueVehiclePO) throws CException{
ConstructSQL sql = new ConstructInsertSQL();
sql.setTableName(TABLENAME);
sql.setColumn("RESCUE_COMPANY_CODE",rcRescueVehiclePO.getRescue_company_code());
sql.setColumn("WEIXIN_USER_ID",rcRescueVehiclePO.getWeixin_user_id());
sql.setColumn("STAFF_NAME",rcRescueVehiclePO.getStaff_name());
sql.setColumn("STAFF_PHONE",rcRescueVehiclePO.getStaff_phone());
sql.setColumn("VEHICLE_ID",rcRescueVehiclePO.getVehicle_id());
sql.setColumn("VEHICLE_NAME",rcRescueVehiclePO.getVehicle_name());
sql.setColumn("COMPANY_LOGIN_NAME",rcRescueVehiclePO.getComapny_login_name());
sql.setColumn("DISPATCH_MODE", rcRescueVehiclePO.getDispatchMode());
sql.setColumnTimestamp("CREATE_TIME",new Date());
update(sql.getSQL());
return true;
}
//<2F><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD>̱<EFBFBD><CCB1><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD>µ<EFBFBD>˾<EFBFBD><CBBE>(11)
public List<RcRescueVehiclePO> rescueVehicles(String rescueCode) throws CException{
String sql="select a.ID,a.STAFF_NAME,a.VEHICLE_ID,a.STAFF_PHONE,a.WEIXIN_USER_ID,a.ACCEPT_FLAG,b.STATE from RC_RESCUE_VEHICLE a LEFT JOIN "+
"(select b.RESCUE_VEHICLE_ID,c.STATE from RC_RESCUE_VEHICLE_DISPATCHE b LEFT JOIN RC_USER_ORDER c on b.ORDER_ID=c.ORDER_ID "+
"where c.STATE<>15 and c.STATE<>19 and c.STATE<>4) b on a.ID=b.RESCUE_VEHICLE_ID WHERE a.RESCUE_COMPANY_CODE='"+rescueCode+"'";
System.out.println(sql+"//////////");
return findAll(sql,"resultRescueVehicles");
}
public RcRescueVehiclePO resultRescueVehicles() throws Exception{
RcRescueVehiclePO PO=new RcRescueVehiclePO();
PO.setId(getInt("ID"));
PO.setStaff_name(getString("STAFF_NAME"));
PO.setVehicle_id(getInt("VEHICLE_ID"));
PO.setStaff_phone(getString("STAFF_PHONE"));
PO.setWeixin_user_id(getInt("WEIXIN_USER_ID"));
PO.setAcceptFlag(getInt("ACCEPT_FLAG"));
PO.setDispatch_flag(getInt("STATE"));
return PO;
}
/**
* <20><>ѯ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڸ<EFBFBD>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD>11<31><31>
* @param id
* @return
* @throws CException
*/
public RcRescueVehiclePO findByPrimaryKey(int id) throws CException {
String sql = SELECT_ALL_FROM + TABLENAME + WHERE + "id" + EQ + id;
return (RcRescueVehiclePO) findOne(sql);
}
//<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
public WeixinOrderRelaPO findDealerAndFinishTime(String orderCode) throws CException{
String sql="SELECT a.STAFF_NAME,b.FINISHTIME from RC_RESCUE_VEHICLE a LEFT JOIN RC_RESCUE_VEHICLE_DISPATCHE b on a.ID=b.RESCUE_VEHICLE_ID LEFT JOIN RC_RESCUE_COMPANY_DISPATCH "+
"c on c.ID=b.RESCUE_COMPANY_DIPATCH_ID WHERE c.ORDER_CODE='"+orderCode+"'";
return (WeixinOrderRelaPO)findOne(sql,"resultFindDealerAndFinishTime");
}
public WeixinOrderRelaPO resultFindDealerAndFinishTime() throws Exception{
WeixinOrderRelaPO PO=new WeixinOrderRelaPO();
PO.setStaff_name(getString("STAFF_NAME"));
PO.setFinishTime(getDate("FINISHTIME"));
return PO;
}
//<2F><><EFBFBD><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
public boolean updateVehicle(int id,String STAFF_PHONE) throws CException{
ConstructSQL sql = new ConstructUpdateSQL();
sql.setTableName("RC_RESCUE_VEHICLE");
sql.setCondition("ID="+id);
sql.setColumn("STAFF_PHONE",STAFF_PHONE);
update(sql.getSQL());
return true;
}
//<2F><><EFBFBD><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>Ϣ
public boolean updateVehicleMessage(int id,int vehicleId,String vehicleName) throws CException{
ConstructSQL sql = new ConstructUpdateSQL();
sql.setTableName("RC_RESCUE_VEHICLE");
sql.setCondition("ID="+id);
sql.setColumn("VEHICLE_ID",vehicleId);
sql.setColumn("VEHICLE_NAME",vehicleName);
update(sql.getSQL());
return true;
}
//<2F><>˾<EFBFBD><CBBE>ѡ<EFBFBD><D1A1><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD>޸<EFBFBD><DEB8><EFBFBD>Ӧ״̬<D7B4><CCAC>11<31><31>
public int updateVehicleAcceptFlag(int flag,String staffName) throws Exception{
String sql="update RC_RESCUE_VEHICLE a set a.accept_flag="+flag+" where a.STAFF_NAME='"+staffName+"'";
return update(sql);
}
//˾<><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ʱɾ<CAB1><C9BE>֮ǰ<D6AE><C7B0>Ϣ <09><>11<31><31>
public boolean deleteModifyUser(String weixinUserId) throws CException{
String sql="delete from RC_RESCUE_VEHICLE where WEIXIN_USER_ID="+weixinUserId;
return deleteOne(sql);
}
}

View File

@ -0,0 +1,72 @@
package com.sino.rrs.oper;
import java.sql.Connection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import com.sino.publicclass.base.BaseBean;
import com.sino.publicclass.base.CException;
import com.sino.publicclass.sql.ConstructInsertSQL;
import com.sino.publicclass.sql.ConstructSQL;
public class RcTempleteOrder extends BaseBean{
public static final String TABLENAME="RC_TEMPLETE_ORDER";
public RcTempleteOrder(Connection curConn) {
super(curConn);
}
@Override
protected String getTableName() {
return TABLENAME;
}
public static String getUUID() {
Random random = new Random();
int num = random.nextInt(900);
num = num + 100;
return String.valueOf(System.currentTimeMillis()+num);
}
public static void main(String[] args) {
System.out.println(getUUID());
}
@Override
protected Map<String,String> resultAdaptor() throws Exception {
Map<String,String> map=new HashMap<String,String>();
map.put("id", getString("ID"));
map.put("orderId", getString("ORDER_ID"));
map.put("rescueCompanyCode", getString("RESCUE_COMPANY_CODE"));
return map;
}
/**
* <20><>Ӧģ<D3A6><C4A3><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
* @param orderId
* @param rescueCode
* @return
* @throws CException
*/
public String insertTempleteMessage(int orderId,String rescueCode) throws CException{
ConstructSQL sql=new ConstructInsertSQL();
String id = getUUID();
sql.setTableName(TABLENAME);
sql.setColumn("ID", id);
sql.setColumn("ORDER_ID", orderId);
sql.setColumn("RESCUE_COMPANY_CODE", rescueCode);
sql.setColumnTimestamp("CREATE_TIME", new Date());
update(sql.getSQL());
return id;
}
public Map<String,String> queryTemplete(int orderId,String rescueCode) throws CException{
String sql="select a.ID,a.ORDER_ID,a.RESCUE_COMPANY_CODE from RC_TEMPLETE_ORDER a inner join (select max(create_time) 'maxgdtime' from " +
"RC_TEMPLETE_ORDER order by create_time DESC) b on a.create_time=b.maxgdtime where a.ORDER_ID="+orderId+" and a.RESCUE_COMPANY_CODE='"+rescueCode+"'";
//String sql="";
return (Map<String, String>) findOne(sql);
}
}

Some files were not shown because too many files have changed in this diff Show More