60

同城货运智能配送运力优化调度系统V1.0

package com.henglian.sun.action;

import java.io.File;

import java.io.IOException;

import java.math.BigInteger;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;

import org.apache.struts2.ServletActionContext;

import org.apache.struts2.convention.annotation.Action;

import org.apache.struts2.convention.annotation.Namespace;

import org.apache.struts2.convention.annotation.ParentPackage;

import org.aspectj.weaver.ast.Var;

import org.springframework.beans.factory.annotation.Autowired;

import org.apache.commons.lang.StringUtils;

import org.hibernate.usertype.UserVersionType;

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONObject;

import com.henglian.sun.dao.SUserDaoI;

import com.henglian.sun.dao.impl.SUserDaoImpl;

import com.henglian.sun.dao.impl.TUserveicheDaoImpl;

import com.henglian.sun.huanxin.comm.SendSMSHuaXing;

import com.henglian.sun.model.Customer;

import com.henglian.sun.model.Json;

import com.henglian.sun.model.SUser;

import com.henglian.sun.model.SessionInfo;

import com.henglian.sun.model.TUserveiche;

import com.henglian.sun.service.impl.SUserServiceImpl;

import com.henglian.sun.util.Base64Conversion;

import com.henglian.sun.util.ConfigUtil;

import com.henglian.sun.util.LoginValidate;

import com.henglian.sun.util.MD5Util;

import com.opensymphony.xwork2.ActionSupport;

import com.opensymphony.xwork2.ModelDriven;

import com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor;

import com.sms.SendSMS;

public class SUsersAction extends ActionSupport implements ModelDriven {

private SUserDaoImpl sUserDao;

private String loginId;

private String searchValue;

private Integer rows;

private Integer page;

public Integer getUserId() {

return userId;

}

public void setUserId(Integer userId) {

this.userId = userId;

}

public HttpSession getSession() {

return ServletActionContext.getRequest().getSession();

}

private Integer userId;

public String getLoginId() {

return loginId;

}

public void setLoginId(String loginId) {

this.loginId = loginId;

}

JSONArray array = new JSONArray();

Map<String, Object> m = new HashMap<String, Object>();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

SUser user = new SUser();

LoginValidate lv = new LoginValidate();

public void userRegist() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

user.setAddDate(new Date());

String sqlString="select count(*) from s_user where Mobile='" + user.getMobile().replaceAll("'", "")+"'";

BigInteger sCout = sUserDao.countBySql(sqlString);

if (sCout.intValue()!=0) {

m.put("msg", 0);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

return;

}

try {

sUserDao.save(user);

if(user.getUserType()==Short.parseShort("2")){

String mysql="INSERT INTO t_userveiche(UserId)VALUES("+user.getUserId()+")";

sUserDao.executeSql(mysql);

}

m.put("msg", 1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

e.printStackTrace();

}

}

public void userRegist1() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

user.setAddDate(new Date());

String sqlString="select count(*) from s_user where Mobile='" + user.getMobile().replaceAll("'", "")+"'";

BigInteger sCout = sUserDao.countBySql(sqlString);

if (sCout.intValue()!=0) {

m.put("msg", 0);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

return;

}

try {

sUserDao.save(user);

if(user.getUserType()==Short.parseShort("2")){

String mysql="INSERT INTO t_userveiche(UserId)VALUES("+user.getUserId()+")";

sUserDao.executeSql(mysql);

}

m.put("msg", user);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

e.printStackTrace();

}

}

public void sendMsg()throws IOException{

HttpServletRequest request = ServletActionContext.getRequest();

String mobile = request.getParameter("mobile");

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

if(!uid.endsWith("")){

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

}

JSONObject jsonObj = new JSONObject();

try {

SendSMSHuaXing s=new SendSMSHuaXing();

String code = "";

for(int i = 0;i<6;i++){

int rand = (int)(Math.random()*9);

code+=rand;

}

if( s.sendRegionCode(mobile,code)){

jsonObj.put("flag", "1");

jsonObj.put("code", code);

}

else {

jsonObj.put("flag", "0");

jsonObj.put("code", "");

}

} catch (Exception e) {

jsonObj.put("flag", "0");

jsonObj.put("code", "");

e.printStackTrace();

}

array.add(jsonObj);

ServletActionContext.getResponse().setCharacterEncoding("UTF-8");

m.put("msg", array);

try {

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (IOException e) {

e.printStackTrace();

}

}

public void updatePwd() throws IOException{

HttpServletRequest request = ServletActionContext.getRequest();

String mobile=request.getParameter("mobile");

String passWord=request.getParameter("passWord");

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

String userType = request.getParameter("userType");

if(org.springframework.util.StringUtils.hasText(uid))

{

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

}

try {

sUserDao.executeSql("update s_user set PassWord='"+passWord.replaceAll("'", "")+"' where Mobile='"+mobile.replaceAll("'", "").replaceAll("-", "")+"' and userType='"+userType.replaceAll("'", "").replaceAll("-", "")+"'");

m.put("msg", 1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

}

}

public void login() throws IOException{

HttpServletRequest request = ServletActionContext.getRequest();

String userType=request.getParameter("userType");

String passWord=request.getParameter("passWord");

String mobile=request.getParameter("mobile");

String hql = "SELECT UserId,Mobile,ifnull(UserName,'')UserName,ifnull(HeadImg,'')HeadImg,IntState,UserType,IsAcceptBill,IsLogin,AddDate,LoginDate FROM s_user where Mobile = '"+mobile.replaceAll("'", "")+"' and PassWord='"+passWord.replaceAll("'", "")+"' and UserType='"+userType.replaceAll("'", "")+"' ";

Long mylogintime=System.currentTimeMillis();

List<Map<String,Object> usermodeList = sUserDao.findBySql(hql);

String updateStr="update s_user set LoginDate='"+mylogintime+"' where Mobile = '"+mobile.replaceAll("'", "")+"' and PassWord='"+passWord.replaceAll("'", "")+"' and UserType='"+userType.replaceAll("'", "")+"'";

try {

if(usermodeList.size()>0){

JSONObject jsonObj = new JSONObject();

Map<String,Object> obj= usermodeList.get(0);

for(Map.Entry<String,Object> entry : obj.entrySet()){ String aString = entry.getKey();

String bString = entry.getValue()==null?"":entry.getValue().toString();

if(aString.endsWith("LoginDate")){

jsonObj.put(aString, mylogintime);

}else{

jsonObj.put(aString, bString);

}

}

sUserDao.executeSql(updateStr);

m.put("msg", jsonObj);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

}else{

m.put("msg", -1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

}

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

}

}

public void updateCusInfo() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

String utype=request.getParameter("userType");

if(!utype.equals("1")){

m.put("msg", 0);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

return;

}

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

String userId=request.getParameter("userId");

String userName=request.getParameter("userName");

StringBuilder sb=new StringBuilder();

sb.append("update s_user set UserName='"+userName+"' ");

String headImg=request.getParameter("headImg");

Long time = System.currentTimeMillis();

if(!headImg.equals("")){

String imgFilePath =ServletActionContext.getRequest().getRealPath("/resource/images/customer")+"/"+time+"."+"jpg";

Base64Conversion.GenerateImage(headImg,imgFilePath);

String FilePath="/HXRProject/resource/images/customer"+"/"+time+"."+"jpg";

sb.append(",HeadImg='"+FilePath+"'");

}

sb.append(" where UserId="+userId.replaceAll("'", "")+"");

try {

sUserDao.executeSql(sb.toString());

m.put("msg", sUserDao.getById(SUser.class, Integer.parseInt(userId)));

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter()

.write(JSON.toJSONString(m));

}

}

public void getUserInfoById()throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

String loginId=request.getParameter("loginId");

if(!lv.getloginDate(loginId, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

try {

String sqlString="SELECT UserId,Mobile,ifnull(UserName,'')UserName,ifnull(HeadImg,'')HeadImg,IntState,UserType,AddDate,LoginDate,ifnull(VeicheTypeId,0)VeicheTypeId,ifnull(VecheType,'')VecheType,ifnull(StarPrice,0)StarPrice,ifnull(StarTotalKm,0)StarTotalKm,ifnull(PricePerKm,0)PricePerKm,ifnull(PlateNum,'')PlateNum,ifnull(standard,'')standard,ifnull(IDCardImg,'')IDCardImg,ifnull(DriverImg,'')DriverImg,ifnull(VeicheImg,'')VeicheImg,ifnull(DriveLicenceImg,'')DriveLicenceImg,ifnull(VeicheLicenceImg,'')VeicheLicenceImg,ifnull(OperationLicImg,'')OperationLicImg FROM V_UserInfo where UserId='"+uid.replaceAll("'", "")+"'";

m.put("msg", sUserDao.findBySql(sqlString));

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

}

}

public void logout() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

String sqlString="UPDATE s_user SET IsLogin=0 WHERE UserId="+uid.replaceAll("'", "")+";";

String sqlString2="UPDATE t_DriverPosition SET IntState=0 WHERE DriverId="+uid.replaceAll("'", "")+";";

try {

sUserDao.executeSql(sqlString);

sUserDao.executeSql(sqlString2);

m.put("msg", 1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

e.printStackTrace();

}

}

public void startOrStopAcceptBill() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

String isAcceptBill=request.getParameter("isAcceptBill");

String intState=request.getParameter("intState");

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

if(!intState.equals("1") & isAcceptBill.equals("1")){

m.put("msg", -3);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

String sqlString="UPDATE t_DriverPosition SET IntState='"+isAcceptBill+"' WHERE DriverId="+uid.replaceAll("'", "")+";";

try {

sUserDao.executeSql(sqlString);

m.put("msg", 1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

e.printStackTrace();

}

}

public void getCustScore() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

String uid= request.getParameter("userId");

String loginDate=request.getParameter("loginDate");

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

String sqlString="SELECT a.userid,mobile,ifnull(username,'')username,ifnull(headimg,'')headimg,ifnull(score,0)score FROM s_user a LEFT JOIN (SELECT UserId,COUNT(UserId)*50 score FROM t_order WHERE intState=3 GROUP BY userId)b on a.userid=b.userid WHERE a.userid="+uid.replaceAll("'", "")+";";

try {

m.put("msg", sUserDao.findBySql(sqlString));

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

e.printStackTrace();

}

}

public Object getModel() {

return user;

}

public void clogin() throws IOException {

MD5Util cipher = new MD5Util();

String is="0";

String hql="from SUser where mobile="+user.getMobile()+" and passWord='"+cipher.generatePassword(user.getPassWord())+"'";

SUser user1=sUserDao.getByHql(hql);

if (user1==null){

m.put("msg", "0");

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

}else{

SessionInfo sessionInfo = new SessionInfo();

m.put("msg", "1");

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

sessionInfo.setUser(user);

ServletActionContext.getRequest().getSession().setAttribute(ConfigUtil.getSessionInfoName(), sessionInfo);

System.out.println(sessionInfo.getUser().getUserId());

}

}

public void getDriver() throws IOException{

searchValue=ServletActionContext.getRequest().getParameter("searchValue");

page=(Integer) ServletActionContext.getRequest().getAttribute("page");

rows=(Integer) ServletActionContext.getRequest().getAttribute("rows");

if(searchValue==null || searchValue.equals("")){

String hql="from SUser where userType="+2;

String hql0="select count(*) from SUser where userType="+2;

Long t=sUserDao.count(hql0);

List<SUser> listuser=sUserDao.find(hql, page, rows);

m.put("rows", listuser);

m.put("total", t);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

}else{

searchValue= new String(searchValue.toString().toLowerCase().getBytes("ISO-8859-1"), "UTF-8");

String hql="from SUser where userType=2 and mobile like '%" + searchValue + "%'";

String hql0="select count(*) from SUser where userType=2 and mobile like '%" + searchValue + "%'";

List<SUser> listuser=sUserDao.find(hql, page, rows);

Long t=sUserDao.count(hql0);

m.put("rows", listuser);

m.put("total", t);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m)); }

}

public String getSearchValue() {

return searchValue;

}

public void setSearchValue(String searchValue) {

this.searchValue = searchValue;

}

public Integer getRows() {

return rows;

}

public void setRows(Integer rows) {

this.rows = rows;

}

public Integer getPage() {

return page;

}

public void setPage(Integer page) {

this.page = page;

}

public void getcustomer() throws IOException{

searchValue=ServletActionContext.getRequest().getParameter("searchValue");

page=(Integer) ServletActionContext.getRequest().getAttribute("page");

rows=(Integer) ServletActionContext.getRequest().getAttribute("rows");

if(searchValue==null || searchValue.equals("")){

String hql="from SUser where userType="+1;

String hql0="select count(*) from SUser where userType="+1;

Long t=sUserDao.count(hql0);

List<SUser> listuser=sUserDao.find(hql, page, rows);

m.put("rows", listuser);

m.put("total", t);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

}else{

searchValue= new String(searchValue.toString().toLowerCase().getBytes("ISO-8859-1"), "UTF-8");

String hql="from SUser where userType=1 and mobile like '%" + searchValue + "%'";

String hql0="select count(*) from SUser where userType=1 and mobile like '%" + searchValue + "%'";

List<SUser> listuser=sUserDao.find(hql, page, rows);

Long t=sUserDao.count(hql0);

m.put("rows", listuser);

m.put("total", t);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m)); }

}

public void deletecustomer() throws IOException{

userId=(Integer) ServletActionContext.getRequest().getAttribute("userId");

SUser user = new SUser();

user=sUserDao.getById(SUser.class, userId);

try {

sUserDao.delete(user);

m.put("msg", true);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m)); } catch (Exception e) {

m.put("msg",false);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m)); e.printStackTrace();

}

}

public void logout1() throws IOException {

if (getSession() != null) {

getSession().invalidate();

}

Json j = new Json();

j.setSuccess(true);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(j));

}

}

package com.henglian.sun.action;

import java.io.IOException;

import java.io.PrintWriter;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.HashMap;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

import java.util.concurrent.locks.Lock;

import java.util.concurrent.locks.ReentrantLock;

import javax.ejb.Local;

import javax.enterprise.inject.New;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.apache.struts2.ServletActionContext;

import org.apache.struts2.convention.annotation.Action;

import org.apache.struts2.convention.annotation.Namespace;

import org.apache.struts2.convention.annotation.ParentPackage;

import org.aspectj.weaver.ast.Var;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.druid.stat.TableStat.Condition;

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONObject;

import com.alibaba.fastjson.parser.deserializer.StringFieldDeserializer;

import com.alipay.util.AlipayNotify;

import com.google.gson.JsonObject;

import com.henglian.sun.dao.impl.SUserDaoImpl;

import com.henglian.sun.dao.impl.TOrderDaoImpl;

import com.henglian.sun.dao.impl.TVeichetypeDaoImpl;

import com.henglian.sun.model.SUser;

import com.henglian.sun.model.TOrder;

import com.henglian.sun.model.TVeichetype;

import com.henglian.sun.model.Users;

import com.henglian.sun.util.CommonFunction;

import com.henglian.sun.util.LoginValidate;

import com.jpush.PushExample;

import com.jpush.PushHXR;

import com.opensymphony.xwork2.ActionSupport;

import com.opensymphony.xwork2.ModelDriven;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.Locale;

public class TOrderAction extends ActionSupport implements ModelDriven {

private TOrderDaoImpl tOrderDao;

private TVeichetypeDaoImpl tVeichetypeDao;

private SUserDaoImpl sUserDao;

JSONArray array = new JSONArray();

Map<String, Object> m = new HashMap<String, Object>();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm",Locale.US); TOrder order = new TOrder();

SUser user=new SUser();

LoginValidate lv = new LoginValidate();

private Long loginDate;

private Integer userType;

private Integer pageIndex;

private Integer pageRow;

private String payment_type;

private String price;

private String quantity;

private String seller_email;

private String seller_id;

private String sign;

private String sign_type;

private String subject;

private String total_fee;

private String trade_no;

private String trade_status;

private String use_coupon;

private String body;

private String buyer_email;

private String buyer_id;

private String discount;

private String gmt_create;

private String gmt_payment;

private String is_total_fee_adjust;

private String notify_id;

private String notify_type;

private String notify_time;

private String out_trade_no;

private String searchValue;

private Integer page;

private Integer rows;

private String id;

private String useveicheDate;

private String userState;

public String getUseveicheDate() {

return useveicheDate;

} public void setUseveicheDate(String useveicheDate) {

this.useveicheDate = useveicheDate;

} public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getPayment_type() {

return payment_type;

} public void setPayment_type(String payment_type) {

this.payment_type = payment_type;

} public String getPrice() {

return price;

} public void setPrice(String price) {

this.price = price;

} public String getQuantity() {

return quantity;

} public void setQuantity(String quantity) {

this.quantity = quantity;

} public String getSeller_email() {

return seller_email;

} public void setSeller_email(String seller_email) {

this.seller_email = seller_email;

} public String getSeller_id() {

return seller_id;

} public void setSeller_id(String seller_id) {

this.seller_id = seller_id;

} public String getSign() {

return sign;

} public void setSign(String sign) {

this.sign = sign;

} public String getSign_type() {

return sign_type;

} public void setSign_type(String sign_type) {

this.sign_type = sign_type;

} public String getSubject() {

return subject;

} public void setSubject(String subject) {

this.subject = subject;

} public String getTotal_fee() {

return total_fee;

} public void setTotal_fee(String total_fee) {

this.total_fee = total_fee;

} public String getTrade_no() {

return trade_no;

} public void setTrade_no(String trade_no) {

this.trade_no = trade_no;

} public String getTrade_status() {

return trade_status;

} public void setTrade_status(String trade_status) {

this.trade_status = trade_status;

} public String getUse_coupon() {

return use_coupon;

} public void setUse_coupon(String use_coupon) {

this.use_coupon = use_coupon;

}

public String getBody() {

return body;

} public void setBody(String body) {

this.body = body;

} public String getBuyer_email() {

return buyer_email;

} public void setBuyer_email(String buyer_email) {

this.buyer_email = buyer_email;

} public String getBuyer_id() {

return buyer_id;

} public void setBuyer_id(String buyer_id) {

this.buyer_id = buyer_id;

} public String getDiscount() {

return discount;

} public void setDiscount(String discount) {

this.discount = discount;

} public String getGmt_create() {

return gmt_create;

} public void setGmt_create(String gmt_create) {

this.gmt_create = gmt_create;

} public String getGmt_payment() {

return gmt_payment;

} public void setGmt_payment(String gmt_payment) {

this.gmt_payment = gmt_payment;

} public String getIs_total_fee_adjust() {

return is_total_fee_adjust;

} public void setIs_total_fee_adjust(String is_total_fee_adjust) {

this.is_total_fee_adjust = is_total_fee_adjust;

} public String getNotify_id() {

return notify_id;

} public void setNotify_id(String notify_id) {

this.notify_id = notify_id;

} public String getNotify_type() {

return notify_type;

} public void setNotify_type(String notify_type) {

this.notify_type = notify_type;

} public String getNotify_time() {

return notify_time;

} public void setNotify_time(String notify_time) {

this.notify_time = notify_time;

} public String getOut_trade_no() {

return out_trade_no;

} public void setOut_trade_no(String out_trade_no) {

this.out_trade_no = out_trade_no;

} public Integer getPageIndex() {

return pageIndex;

}

public void setPageIndex(Integer pageIndex) {

this.pageIndex = pageIndex;

}

public Integer getPageRow() {

return pageRow;

}

public void setPageRow(Integer pageRow) {

this.pageRow = pageRow;

}

public Integer getUserType() {

return userType;

}

public void setUserType(Integer userType) {

this.userType = userType;

}

public Long getLoginDate() {

return loginDate;

}

public void setLoginDate(Long loginDate) {

this.loginDate = loginDate;

}

public void addOrUpdateOrder() throws IOException, ParseException {

HttpServletRequest request = ServletActionContext.getRequest();

String uid = request.getParameter("userId");

String loginDate = request.getParameter("loginDate");

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

order.setAddDate(new Date());

order.setIntState(Short.parseShort("0"));

String orderId=request.getParameter("orderId");

try {

if(orderId.equals("0")||orderId.equals("")){

order.setOrderId(orderCode());

tOrderDao.save(order);

}

else { tOrderDao.update(order);

}

m.put("msg", order.getOrderId());

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

e.printStackTrace();

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

}

public void pushOrder() {

HttpServletRequest request = ServletActionContext.getRequest();

String ordeId=request.getParameter("orderId");

Double startY=Double.valueOf(request.getParameter("startPointY")) ;

Double startX=Double.valueOf(request.getParameter("startPointX")) ;

String sqlString="SELECT DriverId,PositionAddr,PositionX,PositionY,BillRadio,startx,starty,endx,endy FROM t_DriverPosition a LEFT JOIN t_DriveRoute b ON a.DriverId=b.UserId where a.intState=1 ORDER BY RAND()";

List<Map<String, Object>list = tOrderDao.findBySql(sqlString);

JsonObject jsonobj=new JsonObject();

jsonobj.addProperty("orderId",ordeId);

StringBuilder tag=new StringBuilder();

for(Map<String,Object> eMap : list){

String did=eMap.get("DriverId").toString();

Double px=Double.valueOf(eMap.get("PositionX")==null||eMap.get("PositionX")==""||eMap.get("PositionX").toString().toLowerCase()=="null"?"0":eMap.get("PositionX").toString());

Double py=Double.valueOf(eMap.get("PositionY")==null||eMap.get("PositionY")==""||eMap.get("PositionY").toString().toLowerCase()=="null"?"0":eMap.get("PositionY").toString()); Double radio=Double.valueOf(eMap.get("BillRadio")==null||eMap.get("BillRadio").toString().toLowerCase()=="null"?"0":eMap.get("BillRadio").toString());

Double startx=Double.valueOf( eMap.get("startx")==null||eMap.get("startx")==""||eMap.get("startx").toString().toLowerCase()=="null"?"-1":eMap.get("startx").toString());

Double starty=Double.valueOf( eMap.get("starty")==null||eMap.get("starty")==""||eMap.get("starty").toString().toLowerCase()=="null"?"-1":eMap.get("starty").toString());
Double endx=Double.valueOf( eMap.get("endx")==null||eMap.get("endx")==""||eMap.get("endx").toString().toLowerCase()=="null"?"-1":eMap.get("endx").toString());

Double endy=Double.valueOf( eMap.get("endy")==null||eMap.get("endy")==""||eMap.get("endy").toString().toLowerCase()=="null"?"-1":eMap.get("endy").toString());

Double midx=(startx+endx)/2.0;

Double midy=(starty+endy)/2.0;

Double distance = CommonFunction.GetDistance(startY, startX, py, px);

Double routRadio= 0.0;

Double custDistance=0.0;

Boolean bool=false;

if(startx!=-1){

custDistance=CommonFunction.GetDistance(startY, startX, midy, midx)/2;

routRadio= CommonFunction.GetDistance(starty, startx, endy, endx)/2;

if(custDistance<=routRadio||distance<=radio){

bool=true;

}

}else{

if(distance<=radio){bool=true;}

}

if(bool){

tag.append(did+",");

}

}

String mytag=tag.toString();

if(mytag.length()>1){

String[] arrStr=mytag.substring(0,tag.length()-1).split(",");

for(Integer f=0;f<arrStr.length;f++){

PushHXR.sendOrderList(arrStr[f],jsonobj);

}

}else{

return;

}

}

public String orderCode(){

String code = "OR";

SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmmss");

code+=sdf.format(new Date());

for(int i = 0;i<3;i++){

int rand = (int)(Math.random()*9);

code+=rand;

}

return code;

}

public void getCustOrDriveList() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();

String uid=request.getParameter("userId") ;

String loginDate = request.getParameter("loginDate");

String uType=request.getParameter("userType");

String intState=request.getParameter("intState");

Integer pIndex=Integer.parseInt(request.getParameter("pageIndex"));

Integer pNum=Integer.parseInt(request.getParameter("pageRow"));

String hqlString="";

if (uType.equals("1")) {

if(intState.equals("")){

hqlString="from TOrder where userId="+uid+" order by addDate desc ";

}else {

hqlString="from TOrder where userId="+uid+" and intState="+intState+" order by addDate desc ";

}

}else if(uType.equals("2")) {

if(intState.equals("")){

hqlString="from TOrder where driveId="+uid+" order by addDate desc";

}else if(intState.equals("1")) {

hqlString="from TOrder where driveId="+uid+" and intState=1 order by addDate desc";

}

else {

hqlString="from TOrder where driveId="+uid+" and intState>1 order by addDate desc";

}

}else{

m.put("msg", -1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

if(!lv.getloginDate(uid, sUserDao, loginDate)){

m.put("msg", -2);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

return;

}

try {

List<TOrder>list = tOrderDao.find(hqlString, pIndex, pNum);

for(TOrder mOrder:list){

mOrder.setUseVeicheDate(mOrder.getUseVeicheDate().substring(0, 19));

}

m.put("msg", list);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

} catch (Exception e) {

m.put("msg", -1);

ServletActionContext.getResponse().getWriter().write(JSON.toJSONString(m));

}

}

private final Lock lock = new ReentrantLock();

public void robOrder() throws IOException {

HttpServletRequest request = ServletActionContext.getRequest();