| package com.matrix.system.hive.action; | 
|   | 
| import com.matrix.core.anotations.RemoveRequestToken; | 
| import com.matrix.core.anotations.SaveRequestToken; | 
| import com.matrix.core.pojo.AjaxResult; | 
| import com.matrix.core.pojo.PaginationVO; | 
| import com.matrix.core.tools.DateUtil; | 
| import com.matrix.core.tools.WebUtil; | 
| import com.matrix.system.constance.Dictionary; | 
| import com.matrix.system.hive.bean.SysWorktime; | 
| import com.matrix.system.hive.service.SysWorktimeService; | 
| import org.springframework.stereotype.Controller; | 
| import org.springframework.web.bind.annotation.RequestMapping; | 
| import org.springframework.web.bind.annotation.ResponseBody; | 
|   | 
| import javax.annotation.Resource; | 
| import java.util.Arrays; | 
| import java.util.Date; | 
|   | 
| /** | 
|  * 设置早中晚班的时间 | 
|  * | 
|  * @author jyy | 
|  * @Title: WorkTimeController.java   | 
|  * @Package com.zkingsoft.actions.admin   | 
|  * @description | 
|  * @email 18075895212@qq.com | 
|  * @date 2016年8月23日 下午8:45:00 | 
|  */ | 
| @Controller | 
| @RequestMapping(value = "admin/workTime") | 
| public class WorkTimeController extends BaseController { | 
|     @Resource | 
|     private SysWorktimeService worktimeService; | 
|   | 
|   | 
|     /** | 
|      * 上下班时间列表 | 
|      */ | 
|     @RequestMapping(value = "/showList") | 
|     public @ResponseBody | 
|     AjaxResult showIntrumentList(SysWorktime sysWorktime, PaginationVO pageVo) { | 
|   | 
| //        if(!getMe().getShopRole().equals(Dictionary.FLAG_YES_Y)){ | 
|         sysWorktime.setShopId(getMe().getShopId()); | 
| //        } | 
|         return showList(worktimeService, sysWorktime, pageVo); | 
|     } | 
|   | 
|     /** | 
|      * 新增或修改页面 | 
|      * jyy | 
|      */ | 
|     @RequestMapping(value = "/addOrModify") | 
|     @RemoveRequestToken | 
|     public @ResponseBody | 
|     AjaxResult addOrModifyInstrument(SysWorktime sysWorktime) { | 
| //        if(!getMe().getShopRole().equals(Dictionary.FLAG_YES_Y)){ | 
|         sysWorktime.setShopId(getMe().getShopId()); | 
| //        } | 
|         if (sysWorktime.getId() != null) { | 
|   | 
|             return modify(worktimeService, sysWorktime, "上下班时间"); | 
|         } else { | 
|   | 
|             return add(worktimeService, sysWorktime, "上下班时间"); | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 进入修改界面 | 
|      * | 
|      * @authorjyy | 
|      */ | 
|     @RequestMapping(value = "/editForm") | 
|     @SaveRequestToken | 
|     public String editInstrumentForm(Long id) { | 
|         SysWorktime sysWorktime; | 
|         if (id != null) { | 
|             sysWorktime = worktimeService.findById(id); | 
|             WebUtil.getRequest().setAttribute("obj", sysWorktime); | 
|         } | 
|         return "admin/hive/orgment/workTime-form"; | 
|     } | 
|   | 
|     /** | 
|      * 删除 | 
|      * | 
|      * @authorjyy | 
|      */ | 
|     @RequestMapping(value = "/del") | 
|     public @ResponseBody | 
|     AjaxResult delInstrument(String keys) { | 
|   | 
|         return remove(worktimeService, keys); | 
|     } | 
|   | 
|     /** | 
|      * 获取工作时间 | 
|      */ | 
|     @RequestMapping(value = "/getWorkTime") | 
|     public @ResponseBody | 
|     AjaxResult getWorkTime() { | 
|         Long shopId = getMe().getShopId(); | 
|         Date minTime = worktimeService.findMinTime(shopId); | 
|         Date maxTime = worktimeService.findMaxTime(shopId); | 
|         if (minTime == null || maxTime == null) { | 
|             return AjaxResult.buildFailInstance("门店没有班次信息,请先设置门店班次"); | 
|         } else { | 
|             return AjaxResult.buildSuccessInstance(Arrays.asList( | 
|                     DateUtil.dateToString(minTime, "HH:mm"), | 
|                     DateUtil.dateToString(maxTime, "HH:mm"))); | 
|         } | 
|   | 
|     } | 
|   | 
|   | 
|     /** | 
|      * 保存菜单 | 
|      */ | 
|     @RequestMapping(value = "/editWorkTime") | 
|     public @ResponseBody | 
|     AjaxResult editWorkTime(SysWorktime sysWorktime) { | 
|   | 
|         sysWorktime.setShopId(getMe().getShopId()); | 
|         return modify(worktimeService, sysWorktime, "上下班时间"); | 
|     } | 
|   | 
| } |