SapTaskLogController.java 3.55 KB
package com.huaheng.pc.sap.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.sap.domain.SapTaskLog;
import com.huaheng.pc.sap.service.SapTaskLogService;

import io.swagger.annotations.Api;

/**
 * sap下发任务日志
 * @author huaheng
 * @date   2022-05-11
 */
@Api(tags = "sap下发任务日志")
@Controller
@RequestMapping("/sap/sapTaskLog")
public class SapTaskLogController extends BaseController {
    private String prefix = "sap/saptasklist";

    @Resource
    private SapTaskLogService sapTaskLogService;

//    @RequiresPermissions("sap:sapTaskLog:view")
    @GetMapping()
    public String zarsh() {
        return prefix + "/list";
    }

//    @RequiresPermissions("sap:sapTaskLog:view")
    @GetMapping("/list/{id}")
    public String apiLogDetail(@PathVariable("id") Integer id, ModelMap mmap) {
        mmap.put("sapTaskLog", sapTaskLogService.getById(id));
        return prefix + "/detail";
    }

    /**
     * 查询中间表列表
     */
//    @RequiresPermissions("sap:sapTaskLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SapTaskLog sapTaskLog) {
        LambdaQueryWrapper<SapTaskLog> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getUniqueIds()), SapTaskLog::getUniqueIds, sapTaskLog.getUniqueIds());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getLgnum()), SapTaskLog::getLgnum, sapTaskLog.getLgnum());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getCFlag()), SapTaskLog::getCFlag, sapTaskLog.getCFlag());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getMFlag()), SapTaskLog::getMFlag, sapTaskLog.getMFlag());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getLocation()), SapTaskLog::getLocation, sapTaskLog.getLocation());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getDrumId()), SapTaskLog::getDrumId, sapTaskLog.getDrumId());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getFromPos()), SapTaskLog::getFromPos, sapTaskLog.getFromPos());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(sapTaskLog.getToPos()), SapTaskLog::getToPos, sapTaskLog.getToPos());
        lambdaQueryWrapper.orderByDesc(SapTaskLog::getCreated);
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
            /* 使用分页查询 */
            Page<SapTaskLog> page = new Page<>(pageNum, pageSize);
            IPage<SapTaskLog> iPage = sapTaskLogService.page(page, lambdaQueryWrapper);
            return getMpDataTable(iPage.getRecords(), iPage.getTotal());
        } else {
            List<SapTaskLog> list = sapTaskLogService.list(lambdaQueryWrapper);
            return getDataTable(list);
        }
    }

}