DirectiveController.java 4.32 KB
package com.bsth.vehicle.directive.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
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.RestController;

import com.bsth.entity.sys.SysUser;
import com.bsth.security.util.SecurityUtils;
import com.bsth.vehicle.directive.entity.Directive80;
import com.bsth.vehicle.directive.service.DirectiveService;

/**
 * 
 * @ClassName: DirectiveController 
 * @Description: TODO(页面下发调度指令) .0
 * @author PanZhao
 * @date 2016年6月8日 上午9:34:51 
 *
 */
@RestController
@RequestMapping("/directive")
public class DirectiveController {
	
	@Autowired
	DirectiveService directiveService;
	
	/**
	 * 
	 * @Title: send60 
	 * @Description: TODO(60协议短语下发) 
	 * @throws
	 */
	@RequestMapping(value = "/phrase", method = RequestMethod.POST)
	public int send60Phrase(@RequestParam String nbbm, @RequestParam String text){
		SysUser user = SecurityUtils.getCurrentUser();
		return directiveService.send60Phrase(nbbm, text, user.getUserName());
	}
	
	/**
	 * 
	 * @Title: send60Dispatch 
	 * @Description: TODO(班次信息下发) 
	 * @param @param id
	 * @throws
	 */
	@RequestMapping(value = "/dispatch", method = RequestMethod.POST)
	public int send60Dispatch(@RequestParam Long id){
		SysUser user = SecurityUtils.getCurrentUser();
		return directiveService.send60Dispatch(id, user.getUserName());
	}
	
	/**
	 * 
	 * @Title: lineChange 
	 * @Description: TODO(切换线路) 
	 * @param @param nbbm 车辆内部编码
	 * @param @param lineId 新线路编码
	 * @throws
	 */
	@RequestMapping(value = "/lineChnage", method = RequestMethod.POST)
	public int lineChange(@RequestParam String nbbm, @RequestParam Integer lineId){
		SysUser user = SecurityUtils.getCurrentUser();
		return directiveService.lineChange(nbbm, lineId, user.getUserName());
	}
	
	/**
	 * 
	 * @Title: upDownChange 
	 * @Description: TODO(上下行切换) 
	 * @param @param nbbm 车辆内部编码
	 * @param @param upDon
	 * @throws
	 */
	@RequestMapping(value = "/upDownChange", method = RequestMethod.POST)
	public int upDownChange(@RequestParam String nbbm, @RequestParam Integer upDown){
		SysUser user = SecurityUtils.getCurrentUser();
		return directiveService.upDownChange(nbbm, upDown, user.getUserName());
	}
	
	/**
	 * 
	 * @Title: findNoCofm80 
	 * @Description: TODO(根据线路获取未确认的80驾驶员上报数据) 
	 * @throws
	 */
	@RequestMapping(value = "/findNoCofm80", method = RequestMethod.GET)
	public Map<String, List<Directive80>> findNoCofm80(@RequestParam String lineCodes){
		return directiveService.findNoCofm80(lineCodes);
	}
	
	@RequestMapping(value = "/findAll80", method = RequestMethod.GET)
	public Page<Directive80> findAll80(@RequestParam Map<String, Object> map,
			@RequestParam(defaultValue = "0") int page,
			@RequestParam(defaultValue = "12") int size){
		
		return directiveService.findAll80(map, new PageRequest(page, size, new Sort(Direction.DESC, "timestamp")));
	}
	
	/**
	 * 
	 * @Title: reply80 
	 * @Description: TODO(回复80) 
	 * @param @param reply 0:同意  -1:不同意
	 * @throws
	 */
	@RequestMapping(value = "/reply80", method = RequestMethod.POST)
	public Map<String, Object> reply80(@RequestParam int id, @RequestParam int reply){
		return directiveService.reply80(id, reply);
	}
	
	/**
	 * 
	 * @Title: findDirective 
	 * @Description: TODO(查询调度指令) 
	 * @param @param nbbm 车辆
	 * @param @param dType 类型
	 * @param @param page 页号
	 * @param @param size 每页数量
	 * @throws
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public Map<String, Object> findDirective(String nbbm,@RequestParam int dType
							, @RequestParam(defaultValue = "0") int page,
							@RequestParam(defaultValue = "10") int size){
		
		return directiveService.findDirective(nbbm, dType, page, size);
	}
}