package com.emr.controller.exportTaskDetails;


import com.alibaba.fastjson.JSON;
import com.emr.annotation.OptionalLog;
import com.emr.dao.ExportTaskDetailsMapper;
import com.emr.dao.ExportTaskMapper;
import com.emr.entity.ExportTask;
import com.emr.entity.ExportTaskDetails;
import com.emr.util.ExceptionPrintUtil;
import com.emr.vo.ExportTaskDetailsVo;
import com.emr.vo.ExportTaskVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 任务清单控制层
 */
@Controller
@RequestMapping("exportTaskDetails/")
public class ExportTaskDetailsController {

    @Autowired
    private ExportTaskMapper exportTaskMapper;

    @Autowired
    private ExportTaskDetailsMapper exportTaskDetailsMapper;


    @OptionalLog(module = "任务清单明细查询", methods = "任务清单明细查询页面")
    @RequestMapping("exportTaskDetailsList")
    public String exportTaskDetailsList() {
        return "recordManage/exportTaskDetails/exportTaskDetailsList";
    }

    @OptionalLog(module = "任务清单明细列表", methods = "任务清单明细列表页面")
    @RequestMapping("getExportTaskDetailsList")
    @ResponseBody
    public String getExportTaskDetailsList(Integer page, Integer limit, ExportTaskDetails exportTaskDetails,String startTime,String endTime) {
        if (null != page && null != limit) {
            PageHelper.startPage(page, limit);
        }
        try {
            List<ExportTaskDetailsVo> list = exportTaskDetailsMapper.getExportTaskDetailsList(exportTaskDetails,startTime,endTime);

            PageInfo pageInfo = new PageInfo<>(list);
            return JSON.toJSONString(pageInfo);
        } catch (Exception e) {
            ExceptionPrintUtil.printException(e);
            e.printStackTrace();
            return null;
        }
    }

}
