hz-zhhq-app-service/greenH5modul/.svn/pristine/73/73b29c534fb73c137c24e1b6325...

156 lines
5.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.nationalelectric.greenH5;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
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.ResponseBody;
import com.jysoft.weChat.service.WechatService;
import com.jysoft.weChat.vo.ContentVo;
import com.nationalelectirc.Constant.Constant;
import com.nationalelectirc.utils.RestResult;
import com.nationalelectric.greenH5.bizc.BaseServiceImpl;
import com.nationalelectric.greenH5.bizc.IGreenUserInfoBizc;
import com.nationalelectric.greenH5.po.GreenApplyList;
import com.nationalelectric.greenH5.po.GreenEAccount;
import com.nationalelectric.greenH5.po.GreenLicenseplateApproval;
import com.nationalelectric.greenH5.po.GreenParkRecord;
import com.nationalelectric.greenH5.po.GreenUserInfo;
import com.nationalelectric.greenH5.po.Result;
import com.nationalelectric.greenH5.service.EAccountService;
import com.nationalelectric.greenH5.utils.AesEncryptUtil;
import com.nationalelectric.greenH5.utils.Base64Utils;
import com.sgcc.uap.persistence.IHibernateDao;
/**
* <b>概述</b><br>
* <p>
* <b>功能</b><br>
*
* @author chenweikang
*/
@Controller
@RequestMapping("/greenParkRecord")
public class GreenParkRecordController extends GreenBaseController {
@Autowired
private BaseServiceImpl BaseService;
/**
* 访客预约service
*/
@Resource
private WechatService wService;
/**
* 用户controller
*/
@Resource
private GreenUserInfoController greenUserInfoController;
/**
* 用户service
*/
@Resource
private IGreenUserInfoBizc greenuserinfoBizc;
@Resource
private GreenImageInfoController greenImageInfoController;
@Autowired
private EAccountService eAccountService;
/**
* HibernateDao逻辑构件
*/
@Autowired
IHibernateDao hibernateDao;
@Autowired
private BaseServiceImpl baseService;
/**
* 查询车牌审批记录
*
* @param result
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/getParkRecordList", method = RequestMethod.POST)
public @ResponseBody RestResult getParkRecordList(@RequestBody Result result) {
try {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
ArrayList<Object> params = new ArrayList<Object>();
String page = result.getPage();
String pageSize = result.getPageSize();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String sql = "select *,DATE_FORMAT(gmt_created,'%Y-%m-%d %H:%h:%i') as gmtcreated from green_park_record where 1=1";
if(!"".equals(result.getType())){
sql+=" and car_type=?";
params.add(result.getType());
}
if(!"".equals(result.getStartDate())){
sql+=" and DATE_FORMAT(gmt_created,'%Y-%m-%d %H:%h:%i')>='"+result.getStartDate()+" 00:00:00"+"'";
}
if(!"".equals(result.getEndDate())){
sql+=" and DATE_FORMAT(gmt_created,'%Y-%m-%d %H:%h:%i')<='"+result.getEndDate()+" 23:59:59"+"'";
}
if(!"".equals(result.getOverTime())){
sql+=" and overtime=?";
params.add(result.getOverTime());
}
if(!"".equals(result.getInOrOut())){
sql+=" and in_out=?";
params.add(result.getInOrOut());
}
if(page.matches("\\d+") && pageSize.matches("\\d+")){
Integer x = Integer.valueOf(page);
Integer y = Integer.valueOf(pageSize);
params.add((x-1)*y);
params.add(y);
sql+=" ORDER BY gmt_created DESC LIMIT ?,?";
}
list = hibernateDao.queryForListWithSql(sql.toString(), params.toArray());
return new RestResult(Constant.SUCCESS, "查询成功", list);
}catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "查询失败!");
}
}
/**
* 查询车牌审批记录
*
* @param result
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/getParkRecordCount", method = RequestMethod.POST)
public @ResponseBody RestResult getParkRecordCount(@RequestBody Result result) {
try {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String sql = "SELECT car_type, sum( CASE WHEN in_out = 0 THEN 1 ELSE 0 END ) AS innum, "
+ "sum( CASE WHEN in_out = 1 THEN 1 ELSE 0 END ) AS outnum, "
+ "sum( CASE WHEN overtime = 1 THEN 1 ELSE 0 END ) AS overtimenum "
+ "FROM green_park_record WHERE "
+ "DATE_FORMAT( gmt_created, '%Y-%m-%d %H:%h:%i' ) >= '"+result.getStartDate()+" 00:00:00"+"'"
+ "AND DATE_FORMAT( gmt_created, '%Y-%m-%d %H:%h:%i' ) <= '"+result.getEndDate()+" 23:59:59"+"' "
+ "GROUP BY car_type";
list = hibernateDao.queryForListWithSql(sql.toString());
return new RestResult(Constant.SUCCESS, "查询成功", list);
}catch (Exception e) {
e.printStackTrace();
return new RestResult(Constant.FAILED, "查询失败!");
}
}
}