package com.skyland.interactions.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import system.SysUserAccount;
import com.skyland.charge.ChargeItemDetail;
import com.skyland.dynajpa.DynaEntityManagerFactory;
import com.skyland.property.PropCustomer;
import com.skyland.utils.HttpInvoker;
/**
* 信息同步接口
* @author limiao
*
*/
public class PropertyMessageInterface extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse rsp){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd HH:mm");
String beginDate=req.getParameter("StartTime");
String endDate=req.getParameter("EndTime");
System.out.println("开始时间:"+beginDate);
System.out.println("结束时间:"+endDate);
Log log=LogFactory.getLog(PropertyMessageInterface.class);
log.info("SynchronizationMessageInterfaceAction接口开始运行....");
try {
req.setCharacterEncoding("UTF-8");//设置请求编码
rsp.setCharacterEncoding("UTF-8");//设置返回编码
rsp.setContentType("text/html;charset=UTF-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
EntityManager jpa=DynaEntityManagerFactory.getInstance().createEntityManager();
JSONObject json_res=new JSONObject();
InteractionDataHelper helper = new InteractionDataHelper();
String Code = "0";
boolean IsSuccess=false;
String Message="";
try {
/*
* 以下代码负责接口返回
*/
//List<PropCustomer> customerlist = helper.findPropCustomerList(jpa,beginDate,endDate);
try {
// if (customerlist != null) {
// if (customerlist.size() > 0) {
// }
// }
for (int i = 0; i < 5; i++) {
//PropCustomer customer=customerlist.get(i);
json_res.put("PropRegion_ID","3303");
json_res.put("PropBuilding_ID", "2205");
json_res.put("Floor", "10");
json_res.put("PropRoom_ID", "5713");
json_res.put("RoomNo", "5-324");
json_res.put("CustomerName", "孙小九("+i+")");
json_res.put("Telephone", "13061974393");
json_res.put("BuildArea", "60.4");
json_res.put("ReceiveTime", "2016-03-01");
PrintWriter out;
out = rsp.getWriter();
out.print(json_res.toString());// 返回消息
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(jpa.isOpen()){
jpa.close();
}
}
return null;
}
}