src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java
@@ -3,15 +3,11 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.cms.entity.CuttingInventory; import org.jeecg.modules.cms.service.ICuttingInventoryService; @@ -20,18 +16,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import com.alibaba.fastjson.JSON; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.aspect.annotation.AutoLog; @@ -174,4 +162,18 @@ return super.importExcel(request, response, CuttingInventory.class); } /** * 刀具库存统计 */ @ApiOperation(value = "刀具库存-统计分页查询", notes = "刀具库存-统计分页查询") @GetMapping(value = "/statistics") public Result<IPage<Map<String, Object>>> statistics( @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { Page<Map<String, Object>> page = new Page<>(pageNo, pageSize); IPage<Map<String, Object>> pageList = cuttingInventoryService.statisticsByCuttingIdAndStatus(page); return Result.OK(pageList); } } src/main/java/org/jeecg/modules/cms/mapper/CuttingInventoryMapper.java
@@ -1,8 +1,9 @@ package org.jeecg.modules.cms.mapper; import java.util.List; import java.util.Map; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.jeecg.modules.cms.entity.CuttingInventory; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -13,5 +14,4 @@ * @Version: V1.0 */ public interface CuttingInventoryMapper extends BaseMapper<CuttingInventory> { } IPage<Map<String, Object>> statisticsByCuttingIdAndStatus(Page<Map<String, Object>> page);} src/main/java/org/jeecg/modules/cms/mapper/xml/CuttingInventoryMapper.xml
@@ -1,5 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.cms.mapper.CuttingInventoryMapper"> <select id="statisticsByCuttingIdAndStatus" resultType="map"> SELECT t1.cutting_id as cuttingId, count(*) AS cuttingIdNumber, t1.inventory_status as inventoryStatus, t2.cutting_code AS cuttingCode FROM cms_cutting_inventory t1 LEFT JOIN cms_cutting_tool t2 ON t1.cutting_id = t2.id AND t2.del_flag = 0 GROUP BY cutting_id, inventory_status, cutting_code </select> </mapper> src/main/java/org/jeecg/modules/cms/service/ICuttingInventoryService.java
@@ -1,7 +1,12 @@ package org.jeecg.modules.cms.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.jeecg.modules.cms.entity.CuttingInventory; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; import java.util.Map; /** * @Description: 刀具库存 @@ -11,4 +16,6 @@ */ public interface ICuttingInventoryService extends IService<CuttingInventory> { IPage<Map<String, Object>> statisticsByCuttingIdAndStatus(Page<Map<String, Object>> page); } src/main/java/org/jeecg/modules/cms/service/impl/CuttingInventoryServiceImpl.java
@@ -1,11 +1,21 @@ package org.jeecg.modules.cms.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.jeecg.modules.cms.entity.CuttingInventory; import org.jeecg.modules.cms.mapper.CuttingInventoryMapper; import org.jeecg.modules.cms.mapper.CuttingToolMapper; import org.jeecg.modules.cms.service.ICuttingInventoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; /** * @Description: 刀具库存 @@ -15,5 +25,9 @@ */ @Service public class CuttingInventoryServiceImpl extends ServiceImpl<CuttingInventoryMapper, CuttingInventory> implements ICuttingInventoryService { @Override public IPage<Map<String, Object>> statisticsByCuttingIdAndStatus(Page<Map<String, Object>> page) { // 执行分页统计查询 IPage<Map<String, Object>> result = baseMapper.statisticsByCuttingIdAndStatus(page); return result; } }