package com.th.demo.service.impl.ware;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.th.demo.mapping.ware.DistributionRecordMapper;
import com.th.demo.model.system.Type;
import com.th.demo.model.ware.*;
import com.th.demo.service.ware.DistributionRecordService;
import com.th.demo.tools.JSONTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("DistributionRecordService")
public class DistributionRecordServiceImpl implements DistributionRecordService {

    @Autowired
    public DistributionRecordMapper distributionRecordMapper;
    int num = 0;
    String result = Type.FAIL;

    @Override
    public String query(int page,
                        int rows,
                        String truckNo,
                        String wareName,
                        String stackName,
                        String model,
                        String materialName,
                        String standard,
                        String customerName,
                        String plateNo,
                        String type,
                        Date fromDate
                        , Date toDate
                        , String userId,
                        String belongId) {
        PageHelper.startPage(page, rows);
        List<DistributionRecord> list=distributionRecordMapper.selectDistribution( wareName,   stackName,model,materialName, standard, customerName,
                plateNo, truckNo, type, fromDate,toDate, userId,    belongId);
        PageInfo<DistributionRecord> pageInfo = new PageInfo<>(list);
        result = JSONTools.toStringyyyyMMddHHmmss(pageInfo);
        return result;
    }

    @Override
    public String queryTotal(int page, int rows, String truckNo, String wareName, String stackName, String model, String materialName, String standard, String customerName, String plateNo, String type, Date fromDate, Date toDate, String userId, String belongId) {
        List<DistributionRecord> list=distributionRecordMapper.selectTotal( wareName,   stackName,model,materialName, standard, customerName,
                plateNo, truckNo, type, fromDate,toDate, userId,    belongId);
        result = JSONTools.toStringyyyyMMddHHmmss(list);
        return result;
    }
}
