package com.nationalelectric.greenH5; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.nationalelectirc.Constant.Constant; import com.nationalelectirc.utils.RestResult; import com.nationalelectric.greenH5.DTO.GreenMealTicketApplyDTO; import com.nationalelectric.greenH5.DTO.UserDTO; import com.nationalelectric.greenH5.bizc.BaseServiceImpl; import com.nationalelectric.greenH5.bizc.IGreenOperateLogBizc; import com.sgcc.uap.service.validator.ServiceValidatorBaseException; import com.sgcc.uap.persistence.IHibernateDao; import org.springframework.web.bind.annotation.RequestMapping; import java.text.SimpleDateFormat; import java.util.*; import com.nationalelectric.greenH5.po.GreenUserInfo; 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.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; /** * 概述
*

* 功能
* * @author BOWEI */ @Controller @RequestMapping("/greenWeekMenu") public class GreenWeekMenuController extends GreenBaseController { @Resource private IHibernateDao hibernateDao; @Resource private IGreenOperateLogBizc greenOperateLogBizc; @Autowired private BaseServiceImpl baseService; // /** 外卖点餐列表 */ // @RequestMapping(value = "/list", method = RequestMethod.POST) // @ResponseBody // public RestResult list(Map map) { // String userId = map.get("userId").toString(); // String date = map.get("date").toString(); // String locationId = map.get("locationId").toString(); // String menuType = map.get("menuType").toString(); // GreenUserInfo info = getUserInfo(userId); // if (info == null) { // return new RestResult(Constant.FAILED, "非法用户"); // } // try { // List> menuList1 = new ArrayList>(); // if("0".equals(menuType)){ // String sql = "select * from green_week_menu m where m.sell_date = ? AND m.menu_type = ? AND m.location_id = ? "; // menuList1 = hibernateDao.queryForListWithSql(sql,new Object[]{date,menuType,locationId}); // }else{ // String sql = "SELECT k.* FROM green_week_variety v" // + " LEFT JOIN green_week_menu m ON v.menu_id = m.id" // + " LEFT JOIN green_week_kinds k ON v.kinds_id = k.id" // + " WHERE m.sell_date = ? AND m.menu_type = ? AND m.location_id = ? and v.is_deleted='N' and m.is_deleted='N' and k.is_deleted='N'"; // menuList1 = hibernateDao.queryForListWithSql(sql,new Object[]{date,menuType,locationId}); // for (Map map1 : menuList1) { // String pictureString = map1.get("picture"); // map1.put("picture", baseService.getImageBase64ForWeek(pictureString)); // } // } // return new RestResult(Constant.SUCCESS, "成功", menuList1); // } catch (ServiceValidatorBaseException e) { // throw e; // } catch (Exception e) { // e.printStackTrace(); // // greenOperateLogBizc.addLog(Constant.TAKE_OUT_FOOD, // // Constant.QUERY, Constant.OPERATE_FAIL, "查询外卖预定列表", // // Constant.LOG_ERROR, userDTO.getUserId()); // return new RestResult(Constant.FAILED, "返回异常"); // } // } @RequestMapping(value = "/list", method = RequestMethod.POST) @ResponseBody public RestResult list(Map map) { String userId = map.get("userId").toString(); // String date = map.get("date").toString(); GreenUserInfo info = getUserInfo(userId); if (info == null) { return new RestResult(Constant.FAILED, "非法用户"); } try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String today = sdf.format(new Date()); List> menuList1 = new ArrayList>(); String sql = "select * from green_week_carte where is_deleted='N' and start_date<=? and end_date>=?"; menuList1 = hibernateDao.queryForListWithSql(sql,new Object[]{today,today}); for (Map map1 : menuList1) { String pictureString = map1.get("lunch"); map1.put("lunch", baseService.getImageBase64ForWeek(pictureString)); String pictureString1 = map1.get("breakfast"); map1.put("breakfast", baseService.getImageBase64ForWeek(pictureString1)); } return new RestResult(Constant.SUCCESS, "成功", menuList1); } catch (ServiceValidatorBaseException e) { throw e; } catch (Exception e) { e.printStackTrace(); // greenOperateLogBizc.addLog(Constant.TAKE_OUT_FOOD, // Constant.QUERY, Constant.OPERATE_FAIL, "查询外卖预定列表", // Constant.LOG_ERROR, userDTO.getUserId()); return new RestResult(Constant.FAILED, "返回异常"); } } }