package org.linlinjava.jz.hm.web.butler;

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

import javax.servlet.http.HttpServletRequest;

import org.linlinjava.jz.db.dto.hm.EmployListDto;
import org.linlinjava.jz.db.dto.hm.HmTaskListData;
import org.linlinjava.jz.hm.service.HmEmployRelationService;
import org.linlinjava.jz.hm.util.HmResponseUtil;
import org.linlinjava.jz.service.HmButlerTaskParentService;
import org.linlinjava.jz.service.HmTaskCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "管家中心-统计", description = "管家中心-统计")
@RestController
@RequestMapping("butlerCenter")
public class ButlerCenterController {

	@Autowired
	HmEmployRelationService hmEmployRelationService;

	@Autowired
	HmButlerTaskParentService hmButlerTaskParentService;

	@Autowired
	HmTaskCenterService hmTaskCenterService;

	@ApiOperation(value = "统计我的任务，顾客数", notes = "统计我的任务，顾客数")
	@GetMapping(value = "statistics")
	public Object statistics(Long userId) {
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("taskcurrentDay", hmButlerTaskParentService.getTaskcurrentDaySize(userId));
		data.put("taskTwentyFour", hmButlerTaskParentService.getTaskTwentyFourSize(userId));
		data.put("customer", hmEmployRelationService.butlerCustomerNumber(userId));

		return HmResponseUtil.ok(data);
	}

	@ApiOperation(value = "管家-客户列表", notes = "管家-客户列表,userButlerId是管家的userid，querystr是搜索条件")
	@GetMapping(value = "customerList")
	public Object customerList(Long userButlerId, String queryStr) {//, int page, int size
		List<EmployListDto> employList = hmEmployRelationService.getEmployList(userButlerId, queryStr);

		return HmResponseUtil.ok(employList);
	}

	// 我的任务，历史任务
	@ApiOperation(value = "管家-我的任务-历史任务", notes = "管家-我的任务-历史任务status 0我的任务，2历史任务")
	@GetMapping(value = "myTaskList")
	public Object myTaskList(String queryStr, String yaerMonth, int status,Long userButlerId) {
		if(null==userButlerId) {
			return HmResponseUtil.fail("userButlerId不能为空");
		}
		List<HmTaskListData> selectTaskList = hmTaskCenterService.selectTaskList( queryStr, yaerMonth,
				status,userButlerId);
		return HmResponseUtil.ok(selectTaskList);
	}

}
