package com.red.controller;
//Create By MyBatisTools
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Timestamp;
//Create Datetime:2017-11-27 17:11:41
//SpringMVC Controller
//
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.red.entity.XqYzmd;
import com.red.service.XqYzmdService;
import com.red.util.SysMsg;
import com.red.util.SysUuid;
@Controller
@RequestMapping("/")
// @RestController
public class XqYzmdController {
private static Logger log = LoggerFactory.getLogger(XqYzmdController.class);
@Autowired
public XqYzmdService xqYzmdService;
@RequestMapping(value = "/xqYzmdInsert")
@ResponseBody
public SysMsg xqYzmdInsert(@RequestBody XqYzmd xqYzmd, HttpServletRequest request,
HttpServletResponse response) {
log.info(">>>>>>>>>");
SysMsg msg = new SysMsg();
try {
log.info("xqYzmdInsert insert log ");
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String result = "";
if (xqYzmd != null) {
log.info(JSON.toJSONString(xqYzmd));
//xqYzmd.setId(SysUuid.getId());
xqYzmd.setPxid(System.currentTimeMillis());
xqYzmd.setYzxqldhfh(xqYzmd.getYzxqldh() + '-' + xqYzmd.getYzxqlfh());
xqYzmd.setXgsj(new Timestamp(System.currentTimeMillis()) );
xqYzmd.setTbsj(new Timestamp(System.currentTimeMillis()) );
int i1 = xqYzmdService.insert(xqYzmd);
msg.setSuccess(true);
msg.setCode(1);
msg.setMsg("成功" + i1);
log.info("insert line:" + i1);
// msg.setMsg("OK");
// msg.setData(posBankBill);
} else {
log.info("error");
}
} catch (Exception e) {
msg.setCode(0);
msg.setMsg("保存失败.");
log.error("Insert保存错误", e);
}
log.info("-------------------");
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg", msg);
log.info(jsonObject.toString());
return msg;
}
@RequestMapping(value = "/xqYzmdInsertObj")
@ResponseBody
public SysMsg xqYzmdInsertObj(@RequestBody XqYzmd xqYzmd, HttpServletRequest request,
HttpServletResponse response) {
log.info(">>>>>>>>>");
SysMsg msg = new SysMsg();
try {
log.info("xqYzmdInsert insert log ");
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String result = "";
if (xqYzmd != null) {
log.info(JSON.toJSONString(xqYzmd));
//xqYzmd.setId(SysUuid.getId());
xqYzmd.setPxid(System.currentTimeMillis());
xqYzmd.setQt("未确认");
xqYzmd.setHdbz(false);
xqYzmd.setYzxqldhfh(xqYzmd.getYzxqldh() + '-' + xqYzmd.getYzxqlfh());
xqYzmd.setXgsj(new Timestamp(System.currentTimeMillis()) );
xqYzmd.setTbsj(new Timestamp(System.currentTimeMillis()) );
int i1 = xqYzmdService.insertObj(xqYzmd);
msg.setSuccess(true);
msg.setCode(1);
msg.setMsg("成功" + i1);
log.info("insert line:" + i1);
// msg.setMsg("OK");
// msg.setData(posBankBill);
} else {
log.info("error");
}
} catch (Exception e) {
msg.setCode(0);
msg.setMsg("保存失败.");
log.error("Insert保存错误", e);
}
log.info("-------------------");
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg", msg);
log.info(jsonObject.toString());
return msg;
}
@RequestMapping(value = "/xqYzmdUpdate")
@ResponseBody
public SysMsg xqYzmdUpdate(@RequestBody XqYzmd xqYzmd, HttpServletRequest request,
HttpServletResponse response) {
log.info(">>>>>>>>>");
SysMsg msg = new SysMsg();
try {
log.info("xqYzmd修改 log ");
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String result = "";
if (xqYzmd != null) {
log.info(JSON.toJSONString(xqYzmd));
xqYzmd.setYzxqldhfh(xqYzmd.getYzxqldh() + '-' + xqYzmd.getYzxqlfh());
xqYzmd.setXgsj(new Timestamp(System.currentTimeMillis()) );
int i1 = xqYzmdService.update(xqYzmd);
msg.setSuccess(true);
msg.setCode(1);
msg.setMsg("成功" + i1);
log.info("insert line:" + i1);
// msg.setMsg("OK");
// msg.setData(posBankBill);
} else {
log.info("error");
}
} catch (Exception e) {
msg.setCode(0);
msg.setMsg("保存失败.");
log.error("Insert保存错误", e);
}
log.info("-------------------");
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg", msg);
log.info(jsonObject.toString());
return msg;
}
@RequestMapping(value = "/xqYzmdUpdateHdbz")
@ResponseBody
public SysMsg xqYzmdUpdateHdbz(@RequestBody XqYzmd xqYzmd, HttpServletRequest request,
HttpServletResponse response) {
log.info(">>>>>>>>>");
SysMsg msg = new SysMsg();
try {
log.info("xqYzmdInsert insert log ");
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String result = "";
if (xqYzmd != null) {
log.info(JSON.toJSONString(xqYzmd));
xqYzmd.setXgsj(new Timestamp(System.currentTimeMillis()) );
int i1 = xqYzmdService.updateObjHdbz(xqYzmd);
msg.setSuccess(true);
msg.setCode(1);
msg.setMsg("成功" + i1);
log.info("insert line:" + i1);
// msg.setMsg("OK");
// msg.setData(posBankBill);
} else {
log.info("error");
}
} catch (Exception e) {
msg.setCode(0);
msg.setMsg("保存失败.");
log.error("Insert保存错误", e);
}
log.info("-------------------");
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg", msg);
log.info(jsonObject.toString());
return msg;
}
@RequestMapping("xqYzmdSelectPageData")
@ResponseBody
public JSONObject xqYzmdSelectPageData(@RequestBody JSONObject jsonObjectIn, HttpServletRequest request,
HttpServletResponse response , HttpSession session) throws Exception {
JSONObject jsonObject = new JSONObject();
String mc =session.getAttribute("loginmc" ).toString();
System.out.println("----"+mc);
if (mc!=null) {
try {
// Map<String, Object> map1,
System.out.println(JSON.toJSONString(jsonObjectIn));
System.out.println(jsonObjectIn.get("yzxm"));
System.out.println("----");
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
//{"offset":0,"mcc2":"eee","limit":10}
// Map<String, Object> map = new HashMap();
Map<String, Object> map = new HashMap<String, Object>();
map.put("yzxm", jsonObjectIn.get("yzxm"));
map.put("yzxqldh", jsonObjectIn.get("yzxqldh"));
map.put("yzxqldhfh", jsonObjectIn.get("yzxqldhfh"));
map.put("hdbz", jsonObjectIn.get("hdbz"));
map.put("limit", jsonObjectIn.get("limit"));
map.put("offset", jsonObjectIn.get("offset"));
//System.out.println(JSON.toJSONString(map));
Long total = xqYzmdService.selectPageDataCount(map);
List<XqYzmd> list = xqYzmdService.selectPageData(map);
//log.info(JSON.toJSONString(list));
jsonObject.put("total", total);
jsonObject.put("rows", list);
//System.out.println(JSON.toJSONString(jsonObject));
} catch (Exception e) {
// TODO Auto-generated catch block
log.error("Error", e);
}
}
return jsonObject;
}
}