package com.palmnest.webapp.controller.backstage;

import cn.superdesk.libs.common.util.BeanUtils;

import com.alibaba.fastjson.JSON;
import com.palmnest.application.AppConstants;
import com.palmnest.application.CodeConstants;
import com.palmnest.application.bean.AppResultDto;
import com.palmnest.application.bean.Page;
import com.palmnest.application.core.util.AppResultUtil;
import com.palmnest.application.core.util.DateHelper;
import com.palmnest.application.core.util.LogExceptionStackUtil;
import com.palmnest.application.core.util.StringUtil;
import com.palmnest.application.dto.OrgDto;
import com.palmnest.application.dto.PeoplecOrderDto;
import com.palmnest.application.dto.RepairSelectDto;
import com.palmnest.application.dto.WebPageResultDto;
import com.palmnest.application.dto.output.RepairBillStateStatisticsDto;
import com.palmnest.model.User;
import com.palmnest.service.AppUserService;
import com.palmnest.service.dinner.service.OrderDinnerService;
import com.palmnest.service.repair.RepairBillStatisticsManager;
import com.palmnest.webapp.controller.BaseFormController;

import org.apache.commons.lang3.StringUtils;
import org.directwebremoting.util.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 服务之窗1L- RepairStatisticsController
 * 工程维修统计
 *
 * @Description TODO
 * @author: jiangyong
 * @since: 2020/9/2 9:52
 */
@Controller
@RequestMapping(value = "/repairStatistics")
public class RepairBillStatisticsController extends BaseFormController {
    private Logger LOG = Logger.getLogger(getClass());

    @Autowired
    private RepairBillStatisticsManager statisticsManager;
    @Autowired
    private AppUserService appUserService;
    /**
     * 状态统计
     *
     * @param orgId
     * @param type
     * @param date
     * @return
     */
    @RequestMapping(value = "/getRepairStateList")
    @ResponseBody
    public WebPageResultDto getRepairStateList(@RequestParam(value = "orgId") Integer orgId,
                                               @RequestParam(value = "type") Integer type,
                                               @RequestParam(value = "date") String date,
                                               @RequestParam(value = "endDate", required = false) String endDate) {
        LOG.info("RepairBillStatisticsController.getRepairStateList orgId:" + orgId + ",type:" + type + ",date:" +
                date + ",endDate:" + endDate);
        try {
            List<RepairBillStateStatisticsDto> repairBillStateStatisticsDtos =
                    statisticsManager.getRepairBillStatisticsByStatus(orgId, type, date, endDate);

            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功",
                    repairBillStateStatisticsDtos);
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "状态统计异常",
                    LogExceptionStackUtil.LogExceptionStack(e));
        }

    }

    /**
     * 工程维修状态统计导出
     *
     * @param orgId
     * @param type
     * @param date
     * @param endDate
     * @return
     */
    @RequestMapping(value = "/getRepairStateListExcel")
    @ResponseBody
    public WebPageResultDto getRepairStateListExcel(@RequestParam(value = "orgId") Integer orgId,
                                                    @RequestParam(value = "type") Integer type,
                                                    @RequestParam(value = "date") String date,
                                                    @RequestParam(value = "endDate", required = false) String endDate)
            throws IOException {
        LOG.info("RepairBillStatisticsController.getRepairStateList orgId:" + orgId + ",type:" + type + ",date:" +
                date + ",endDate:" + endDate);
        try {
            List<RepairBillStateStatisticsDto> repairBillStateStatisticsDtos =
                    statisticsManager.getRepairBillStatisticsByStatus(orgId, type, date, endDate);

            //生成Excel
            WebPageResultDto dto = statisticsManager.getRepairStateListExcel(repairBillStateStatisticsDtos);
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "工程维修状态导出异常",
                    LogExceptionStackUtil.LogExceptionStack(e));
        }

    }

    /**
     * 看板 数据列表
     *
     * @param orgId
     * @param request
     * @return
     */
    @RequestMapping(value = "/getRepairBoardList")
    @ResponseBody
    public WebPageResultDto getRepairBoardList(@RequestParam(value = "orgId", required = false) Integer orgId,
                                               HttpServletRequest request) {
        LOG.info("RepairBillStatisticsController.getRepairBoardList orgId:" + orgId + " ");
        try {
            User user = (User) request.getSession().getAttribute("UserCache");
            String orgIds = "";
            if (orgId == null) {
                List<OrgDto> dtos = appUserService.getUserOrgs(user.getId());

                if (dtos != null && dtos.size() > 0) {
                    for (OrgDto org : dtos) {
                        orgIds += "," + org.getId();
                    }
                    orgIds = orgIds.substring(1);
                }
            } else {
                orgIds = orgId.toString();
            }

            int pageSize = Integer.parseInt(request.getParameter("limit"));
            int pageNo = Integer.parseInt(request.getParameter("page"));
            Page page =
                    statisticsManager.getRepairBillBoard(orgIds, pageSize, pageNo);
            if (page.getItems() != null && page.getItems().size() > 0) {
                List items = page.getItems();
                for (int i = 0; i < items.size(); i++) {
                    Map<String, Object> item = (Map<String, Object>) items.get(i);
                    if (null == item.get("meetingTime")) {
                        item.put("meetingTime", "立即上门");
                    }
                    Integer status = (Integer) item.get("status");
                    //状态
                    if (status.intValue() == CodeConstants.TO_AUDIT) {
                        item.put("statusStr", "待审核");
                    } else if (status.intValue() == CodeConstants.IS_SINGLE) {
                        item.put("statusStr", "可抢单");
                    } else if (status.intValue() == CodeConstants.IN_PROGRESS) {
                        item.put("statusStr", "进行中");
                    } else if (status.intValue() == CodeConstants.IN) {
                        item.put("statusStr", "挂单中");
                    } else if (status.intValue() == CodeConstants.TRANSFERED) {
                        item.put("statusStr", "转单中");
                    } else if (status.intValue() == CodeConstants.COMPLETED) {
                        item.put("statusStr", "已完成");
                    } else if (status.intValue() == CodeConstants.UNAUDIT) {
                        item.put("statusStr", "审核未通过");
                    } else if (status.intValue() == CodeConstants.CANCEL) {
                        item.put("statusStr", "已取消");
                    } else if (status.intValue() == CodeConstants.TO_SEND) {
                        item.put("statusStr", "待派单");
                    }
                    //耗时
                    Date startTime = DateHelper.parseToDate((String) item.get("createTime"));
                    //计算两时间的分钟差，再转成小时，精确小数点后1位
                    int minutes = DateHelper.getMinutesBetween(startTime, new Date());

                    double jumpingTime = new BigDecimal(minutes).divide(new BigDecimal(60), 1,
                            BigDecimal.ROUND_HALF_UP).doubleValue();
                    item.put("jumpingTime", jumpingTime);
                }

            }

            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
            dto.setCount(page.getTotalCount());
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "工程维修看板列表查询失败",
                    LogExceptionStackUtil.LogExceptionStack(e));
        }

    }


    @RequestMapping(value = "/getRepairBoardTotal")
    @ResponseBody
    public WebPageResultDto getRepairBoardTotal(@RequestParam(value = "orgId", required = false) Integer orgId,
                                                HttpServletRequest request) {
        LOG.info("RepairBillStatisticsController.getRepairBoardTotal orgId:" + orgId + " ");
        User user = (User) request.getSession().getAttribute("UserCache");
        try {
            String orgIds = "";
            if (orgId == null) {
                List<OrgDto> dtos = appUserService.getUserOrgs(user.getId());

                if (dtos != null && dtos.size() > 0) {
                    for (OrgDto org : dtos) {
                        orgIds += "," + org.getId();
                    }
                    orgIds = orgIds.substring(1);
                }
            } else {
                orgIds = orgId.toString();
            }

            RepairBillStateStatisticsDto repairBoardTotal = statisticsManager.getRepairBoardTotal(orgIds);

            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功",
                    repairBoardTotal);
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "维修看板统计异常",
                    LogExceptionStackUtil.LogExceptionStack(e));
        }

    }
    
    
    
    /**
     * 工程维修工单管理查询
     * @param orgId
     * @param request
     * @return
     */
    @RequestMapping(value = "/getAllWxOrder")
    @ResponseBody
    public WebPageResultDto getAllWxOrder(@ModelAttribute RepairSelectDto repairDto, HttpServletRequest request) {
        LOG.info("RepairBillStatisticsController.getAllWxOrder repairDto:" + repairDto + " ");
        try {
            int pageSize = Integer.parseInt(request.getParameter("limit"));
            int pageNo = Integer.parseInt(request.getParameter("page"));
            
            String res=checkDto(repairDto,1);
            if(StringUtils.isNotBlank(res)){
            	return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, res,"");
            }
            
            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
    			//当类型为季度时
    			Map<String, String> map = getQuarter(repairDto.getDate());
    			if (map != null) {
    				repairDto.setDate(map.get("year"));
    				repairDto.setEndDate(map.get("quarter"));
    			}
    		}
            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
    			//当类型为季度时
    			Map<String, String> map = getQuarter(repairDto.getDate());
    			if (map != null) {
    				repairDto.setDate(map.get("year"));
    				repairDto.setEndDate(map.get("quarter"));
    			}
    		}
            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
            conditions.put("dateString",dateString);
            Page page =  statisticsManager.getAllWxOrder(conditions, repairDto.getType(), pageNo, pageSize);
            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
            dto.setCount(page.getTotalCount());
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "工程维修工单管理查询失败", LogExceptionStackUtil.LogExceptionStack(e));
        }

    }
    
    /**
     * 工程维修工单管理-收费订单详录查询
     * @param orgId
     * @param request
     * @return
     */
    @RequestMapping(value = "/getWxAmountOrder")
    @ResponseBody
    public WebPageResultDto getWxAmountOrder(@ModelAttribute RepairSelectDto repairDto, HttpServletRequest request) {
        LOG.info("RepairBillStatisticsController.getAllWxOrder repairDto:" + repairDto + " ");
        try {
            int pageSize = Integer.parseInt(request.getParameter("limit"));
            int pageNo = Integer.parseInt(request.getParameter("page"));
            
            String res=checkDto(repairDto,2);
            if(StringUtils.isNotBlank(res)){
            	return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, res,"");
            }
            repairDto.setIsFree(0);
            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
    			//当类型为季度时
    			Map<String, String> map = getQuarter(repairDto.getDate());
    			if (map != null) {
    				repairDto.setDate(map.get("year"));
    				repairDto.setEndDate(map.get("quarter"));
    			}
    		}
            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
    			//当类型为季度时
    			Map<String, String> map = getQuarter(repairDto.getDate());
    			if (map != null) {
    				repairDto.setDate(map.get("year"));
    				repairDto.setEndDate(map.get("quarter"));
    			}
    		}
            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
            conditions.put("dateString",dateString);
            Page page =  statisticsManager.getWxAmountOrder(conditions, repairDto.getIsFree(), repairDto.getType(), pageNo, pageSize);
            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
            dto.setCount(page.getTotalCount());
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "工程维修工单管理查询失败", LogExceptionStackUtil.LogExceptionStack(e));
        }

    }
    /**
     * 检验必录项
     * @param repairDto
     * @param type
     * @return
     */
    private String checkDto(RepairSelectDto repairDto, int type){
    	String res="";
    	if(null == repairDto.getOrgId()){
	       	 res="项目必选";
	       	 return res;
        }
        if(null == repairDto.getVirtId() && 2 == type){
    	     res="企业必选";
      	     return res;
        }
        if(null == repairDto.getType()){
    	     res="统计周期必选";
    	     return res;
        }
        if(StringUtils.isBlank(repairDto.getDate())){
    	     res="统计时间必选";
    	     return res;
        }
        return res;
    }
    
    /**
	 * 导出企业订单统计
	 *
	 */
	@RequestMapping(value = "exportAllWxOrderStatistics")
	@ResponseBody
	public AppResultDto exportAllWxOrderStatistics(@ModelAttribute RepairSelectDto repairDto, HttpServletRequest request) {
		String res=checkDto(repairDto,1);
        if(StringUtils.isNotBlank(res)){
        	return AppResultUtil.createErrorDto(AppConstants.REPAIR_BILL_LIST_ERROR, res);
        }
        
        if (2 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
			//当类型为季度时
			Map<String, String> map = getQuarter(repairDto.getDate());
			if (map != null) {
				repairDto.setDate(map.get("year"));
				repairDto.setEndDate(map.get("quarter"));
			}
		}
        if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
			//当类型为季度时
			Map<String, String> map = getQuarter(repairDto.getDate());
			if (map != null) {
				repairDto.setDate(map.get("year"));
				repairDto.setEndDate(map.get("quarter"));
			}
		}
        String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
        Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
        conditions.put("dateString",dateString);
		return statisticsManager.exportAllWxOrderStatistics(conditions, repairDto.getType());
	}
	
	  /**
		 * 导出企业订单明细统计
		 *
		 */
		@RequestMapping(value = "exportWxAmountOrderStatistics")
		@ResponseBody
		public AppResultDto exportWxAmountOrderStatistics(@ModelAttribute RepairSelectDto repairDto, HttpServletRequest request) {
			String res=checkDto(repairDto,1);
	        if(StringUtils.isNotBlank(res)){
	        	return AppResultUtil.createErrorDto(AppConstants.REPAIR_BILL_LIST_ERROR, res);
	        }
	        if (2 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
				//当类型为季度时
				Map<String, String> map = getQuarter(repairDto.getDate());
				if (map != null) {
					repairDto.setDate(map.get("year"));
					repairDto.setEndDate(map.get("quarter"));
				}
			}
	        if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
				//当类型为季度时
				Map<String, String> map = getQuarter(repairDto.getDate());
				if (map != null) {
					repairDto.setDate(map.get("year"));
					repairDto.setEndDate(map.get("quarter"));
				}
			}
	        repairDto.setIsFree(0);
	        String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
	        Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
	        conditions.put("dateString",dateString);
			return statisticsManager.exportWxAmountOrderStatistics(conditions, repairDto.getIsFree(), repairDto.getType());
		}

    /**
     * 人员工单统计
     * @return
     */
    @RequestMapping(value = "/getPeoplecOrderList")
    @ResponseBody
    public WebPageResultDto getPeoplecOrderList(@ModelAttribute PeoplecOrderDto repairDto, HttpServletRequest request) {

        LOG.info("RepairBillStatisticsController.getPeoplecOrderList repairDto:" + JSON.toJSONString(repairDto) + " ");
        try {
            int pageSize = Integer.parseInt(request.getParameter("limit"));
            int pageNo = Integer.parseInt(request.getParameter("page"));

            //String res=checkDto(repairDto,1);
            //if(StringUtils.isNotBlank(res)){
            //    return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, res,"");
            //}

            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
            conditions.put("dateString",dateString);
            Page page =  statisticsManager.getPeoplecOrderList(conditions,repairDto.getType().intValue(),pageNo, pageSize);
            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
            dto.setCount(page.getTotalCount());
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "人员工单统计查询失败", LogExceptionStackUtil.LogExceptionStack(e));
        }

    }


    /**
     * 人员工单统计导出
     * @return
     */
    @RequestMapping(value = "/getPeoplecOrderListExcel")
    @ResponseBody
    public WebPageResultDto getPeoplecOrderListExcel(@ModelAttribute PeoplecOrderDto repairDto, HttpServletRequest request)
            throws IOException {

        LOG.info("RepairBillStatisticsController.getPeoplecOrderListExcel repairDto:" + JSON.toJSONString(repairDto) + " ");

        try {
            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
            conditions.put("dateString",dateString);
            Page page =  statisticsManager.getPeoplecOrderList(conditions,repairDto.getType().intValue(),1, 9999);

            List<Map<String, Object>> list  = page.getItems();

            //生成Excel
            WebPageResultDto dto = statisticsManager.getPeoplecOrderListExcel(list);
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "人员工单统计导出异常",
                    LogExceptionStackUtil.LogExceptionStack(e));
        }

    }


    /**
     * 工单评价统计
     * @return
     */
    @RequestMapping(value = "/getBillCommentList")
    @ResponseBody
    public WebPageResultDto getBillCommentList(@ModelAttribute PeoplecOrderDto repairDto, HttpServletRequest request) {

        LOG.info("工单评价统计-RepairBillStatisticsController.getBillCommentList repairDto:" + JSON.toJSONString(repairDto) + " ");
        try {
            int pageSize = Integer.parseInt(request.getParameter("limit"));
            int pageNo = Integer.parseInt(request.getParameter("page"));

            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
            conditions.put("dateString",dateString);

            Page page =  statisticsManager.getBillCommentList(conditions,repairDto.getType().intValue(),pageNo, pageSize);
            WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
            dto.setCount(page.getTotalCount());
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "人员工单统计查询失败", LogExceptionStackUtil.LogExceptionStack(e));
        }

    }

    /**
     * 工单评价统计导出
     * @return
     */
    @RequestMapping(value = "/getBillCommentListExcel")
    @ResponseBody
    public WebPageResultDto getBillCommentListExcel(@ModelAttribute PeoplecOrderDto repairDto, HttpServletRequest request)
            throws IOException {

        LOG.info("工单评价统计导出-RepairBillStatisticsController.getBillCommentListExcel repairDto:" + JSON.toJSONString(repairDto) + " ");

        try {
            if (2 == repairDto.getType() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            if (3 == repairDto.getType().intValue() && StringUtil.isNotEmpty(repairDto.getDate())) {
                //当类型为季度时
                Map<String, String> map = getQuarter(repairDto.getDate());
                if (map != null) {
                    repairDto.setDate(map.get("year"));
                    repairDto.setEndDate(map.get("quarter"));
                }
            }
            String dateString=StringUtil.getDateString(repairDto.getType(), repairDto.getDate(), repairDto.getEndDate(),1);
            Map<String,Object> conditions=BeanUtils.beanToMap(repairDto);
            conditions.put("dateString",dateString);
            Page page =  statisticsManager.getBillCommentList(conditions,repairDto.getType().intValue(),1, 9999);

            List<Map<String, Object>> list  = page.getItems();

            //生成Excel
            WebPageResultDto dto = statisticsManager.getBillCommentListExcel(list);
            return dto;
        } catch (Exception e) {
            e.printStackTrace();
            return new WebPageResultDto(AppConstants.REPAIR_BILL_LIST_ERROR, "人员工单统计导出异常",
                    LogExceptionStackUtil.LogExceptionStack(e));
        }

    }

}
