package	com.sw.mes.fb.checkout.service.impl;


import com.alibaba.fastjson.JSON;
import com.sw.mes.core.base.BaseServiceImpl;
import com.sw.mes.core.dto.mes.pc.fb.FbCheckOutDataDto;
import com.sw.mes.core.response.ResponsePage;
import com.sw.mes.fb.checkout.dao.OperateCheckOutDataLogDao;
import com.sw.mes.fb.checkout.entity.OperateCheckOutDataLog;
import com.sw.mes.fb.checkout.service.OperateCheckOutDataLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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


/**
* @Author
* @Description：
* @Date: Create in
* @Modified By:
*/
@Service
@Transactional
public class OperateCheckOutDataLogServiceImpl extends BaseServiceImpl<OperateCheckOutDataLog> implements OperateCheckOutDataLogService {
    OperateCheckOutDataLogDao dao;
	@Autowired
    public void setDao(OperateCheckOutDataLogDao dao) {
        super.setBaseDao(dao);
        this.dao=dao;
    }

    @Override
    public ResponsePage<FbCheckOutDataDto> getListPageInfo(String search_EQ_fbSectionNo, String search_EQ_ybSectionNo, String search_EQ_checkUserName,
                                                           String search_GTE_checkTime, String search_LT_checkTime, Pageable pageable) {
        Page<Map<String, Object>> page = dao.getPageListInfo(search_EQ_fbSectionNo, search_EQ_ybSectionNo, search_EQ_checkUserName,
                search_GTE_checkTime,search_LT_checkTime, pageable);
        List<FbCheckOutDataDto> list = JSON.parseArray(JSON.toJSONString(page.getContent()), FbCheckOutDataDto.class);

        return new ResponsePage(list, page.getTotalElements());
    }

    @Override
    public List<FbCheckOutDataDto> getListInfo(String search_EQ_fbSectionNo, String search_EQ_ybSectionNo, String search_EQ_checkUserName,
                                               String search_GTE_checkTime, String search_LT_checkTime) {
        Page<Map<String, Object>> page = dao.getPageListInfo(search_EQ_fbSectionNo, search_EQ_ybSectionNo, search_EQ_checkUserName,
                search_GTE_checkTime,search_LT_checkTime, null);
        List<FbCheckOutDataDto> list = JSON.parseArray(JSON.toJSONString(page.getContent()), FbCheckOutDataDto.class);
//        for (int q = 0;q < list.size();q++){
//            list.get(q).setState(list.get(q).getState() != null ? (list.get(q).getState().equals("1") ? "已入库" : "") : "");
//        }
        return JSON.parseArray(JSON.toJSONString(list), FbCheckOutDataDto.class);
    }
}
