diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/item/ItemMapper.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/item/ItemMapper.java index bab8f4c..1d4c4e0 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/item/ItemMapper.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/item/ItemMapper.java @@ -1,5 +1,6 @@ package com.win.module.eam.dal.mysql.item; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.win.framework.common.pojo.CustomConditions; @@ -32,6 +33,36 @@ public interface ItemMapper extends BaseMapperX { if("1".equals(reqVO.getFlag())){//查询排除有台账的备件 wrapperX.notInSql(ItemDO::getNumber,"select DISTINCT a.item_number from basic_item_accounts a where a.available = 'TRUE' and a.deleted = 0"); } + if("2".equals(reqVO.getFlag())){//查询备件预警库存总数小于备件最低库存 + wrapperX.inSql(ItemDO::getNumber,"SELECT\n" + + "\td.item_number\n" + + "FROM\n" + + "\t(\n" + + "\tSELECT\n" + + "\t\tSUM( qty ) AS qty,\n" + + "\t\tt.item_number,\n" + + "\t\tt.location_number \n" + + "\tFROM\n" + + "\t\tbasic_item_accounts t \n" + + "\tWHERE\n" + + "\t\tdeleted = 0 \n" + + "\t\tAND available = 'TRUE' \n" + + "\tGROUP BY\n" + + "\t\tt.item_number,\n" + + "\t\tt.location_number \n" + + "\t) d \n" + + "WHERE\n" + + "d.qty < (\n" + + "\tSELECT\n" + + "\t\ti.min_inventory \n" + + "\tFROM\n" + + "\t\tbasic_item i \n" + + "\tWHERE\n" + + "\t\ti.deleted = 0 \n" + + "\t\tAND i.available = 'TRUE' \n" + + "and \n" + + "\ti.number = d.item_number)"); + } wrapperX.orderByDesc(ItemDO::getId); return selectPage(reqVO,wrapperX); } @@ -73,9 +104,43 @@ public interface ItemMapper extends BaseMapperX { List scanCodeByNumber(@Param("number") String number); default PageResult getItemSenior(CustomConditions conditions) { + QueryWrapper structure = QueryWrapperUtils.structure(conditions); return selectPage(conditions, QueryWrapperUtils.structure(conditions)); } + default PageResult getItemWarningSenior(CustomConditions conditions) { + QueryWrapper wrapperX = QueryWrapperUtils.structure(conditions); + wrapperX.inSql("number","SELECT\n" + + "\td.item_number\n" + + "FROM\n" + + "\t(\n" + + "\tSELECT\n" + + "\t\tSUM( qty ) AS qty,\n" + + "\t\tt.item_number,\n" + + "\t\tt.location_number \n" + + "\tFROM\n" + + "\t\tbasic_item_accounts t \n" + + "\tWHERE\n" + + "\t\tdeleted = 0 \n" + + "\t\tAND available = 'TRUE' \n" + + "\tGROUP BY\n" + + "\t\tt.item_number,\n" + + "\t\tt.location_number \n" + + "\t) d \n" + + "WHERE\n" + + "d.qty < (\n" + + "\tSELECT\n" + + "\t\ti.min_inventory \n" + + "\tFROM\n" + + "\t\tbasic_item i \n" + + "\tWHERE\n" + + "\t\ti.deleted = 0 \n" + + "\t\tAND i.available = 'TRUE' \n" + + "and \n" + + "\ti.number = d.item_number)"); + return selectPage(conditions,wrapperX); + } + default List selectNoPage(ItemPageReqVO reqVO) { return selectList(new LambdaQueryWrapperX() .eqIfPresent(ItemDO::getNumber, reqVO.getNumber()) diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java index 5e4d775..482c3ef 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java @@ -346,6 +346,7 @@ public class ItemServiceImpl implements ItemService { @Override public PageResult getWarningPage(ItemPageReqVO pageReqVO) { + pageReqVO.setFlag("2"); PageResult pageResult = itemMapper.selectPage(pageReqVO); List itemNewList=new ArrayList(); for (ItemDO itemDO : pageResult.getList()) { @@ -370,7 +371,7 @@ public class ItemServiceImpl implements ItemService { @Override public PageResult getItemWarningSenior(CustomConditions conditions) { - PageResult pageResult = itemMapper.getItemSenior(conditions); + PageResult pageResult = itemMapper.getItemWarningSenior(conditions); for (ItemDO itemDO : pageResult.getList()) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("item_number",itemDO.getNumber());