From 5e55f215845be701ef495c986203894ee97abd12 Mon Sep 17 00:00:00 2001 From: FOAM <491460741@qq.com> Date: Fri, 26 Sep 2025 14:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ImportPointServiceImpl.java | 7 +- .../rest/InventoryController.java | 7 +- .../rest/PickDetailController.java | 2 +- .../service/InventoryService.java | 2 +- .../service/dto/InventoryQueryDto.java | 45 +++++++++ .../service/impl/InventoryServiceImpl.java | 99 +++++++++++++++---- 6 files changed, 136 insertions(+), 26 deletions(-) create mode 100644 youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportPointServiceImpl.java b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportPointServiceImpl.java index 1332c68..552a498 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportPointServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportPointServiceImpl.java @@ -130,9 +130,10 @@ public class ImportPointServiceImpl implements ImportPointService { "品番", "库存下限", "纳所", - "标签类型", - "总分类型", - "关联总库位" + "标签类型" +// , +// "总分类型", +// "关联总库位" ); List headers = FastExcelUtil.readHeadContent(file, 0, 0); if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) { diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java index 6cbd81d..906c668 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/InventoryController.java @@ -111,10 +111,11 @@ public class InventoryController { @ApiOperation("查询inventory") @AnonymousAccess public ResponseEntity queryInventory(InventoryQueryCriteria criteria, Pageable pageable) { - if (criteria.getItemCodeOne() != null && criteria.getItemCode() != null) { - criteria.setItemCodeOne(null); - } +// if (criteria.getItemCodeOne() != null && criteria.getItemCode() != null) { +// criteria.setItemCodeOne(null); +// } return new ResponseEntity<>(inventoryService.queryAll(criteria, pageable), HttpStatus.OK); +// return new ResponseEntity<>(inventoryService.queryInvAll(criteria, pageable), HttpStatus.OK); } @GetMapping(value = "/queryInventoryZz") diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/PickDetailController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/PickDetailController.java index 016ba68..2b2ddd0 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/PickDetailController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/PickDetailController.java @@ -261,7 +261,7 @@ public class PickDetailController { inventoryService.update(inventory); InventoryLog inventoryLog = inventoryLogService.storeInventoryLog(BizStatus.ZZKW_RK, BizStatus.ADD, "制造入库APP", point.getArea(), itemKey, inventory.getPoint(), inventory.getPoint(), null, null, srcQty, cxjldto.getOrder_qty() + 0d, null, null, BizStatus.ZZKW_TL, null, inventory.getId(), "制造入库APP"); - inventoryLog.setZzkw(point); +// inventoryLog.setZzkw(point); inventoryLogService.update(inventoryLog); }else { throw new BadRequestException("扫描错误"); diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java index aa8a9ca..a0b2aaf 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/InventoryService.java @@ -59,6 +59,7 @@ public interface InventoryService { List queryAll(InventoryQueryCriteria criteria); List queryAll(InvQueryCriteria criteria); + Map queryInvAll(InventoryQueryCriteria criteria, Pageable pageable); /** * 根据ID查询 @@ -121,7 +122,6 @@ public interface InventoryService { * 满足线边耗用库存 * @param item * @param area - * @param gw * @param zzkw * @param type * @return diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java new file mode 100644 index 0000000..1cd5faa --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/InventoryQueryDto.java @@ -0,0 +1,45 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.youchain.businessdata.service.dto; + +import com.youchain.modules.system.domain.Dept; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * @author huojin + * @website https://eladmin.vip + * @description / + * @date 2023-08-16 + **/ +@Data +public class InventoryQueryDto implements Serializable { + + /** + * ID + */ + private Long id; + private String area_name; + private String point_code; + private String item_code; + private String item_name; + private String quantity; + private String queued_qty; + private String prop_c2; + private String inv_min; +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java index a5061ad..a2f3dc4 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/InventoryServiceImpl.java @@ -48,8 +48,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import java.util.List; -import java.util.Map; +import java.math.BigInteger; +import java.util.*; import java.io.IOException; import javax.persistence.EntityManager; import javax.persistence.Query; @@ -57,8 +57,6 @@ import javax.persistence.criteria.Join; import javax.persistence.criteria.JoinType; import javax.persistence.criteria.Predicate; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; /** * @author huojin @@ -184,6 +182,71 @@ public class InventoryServiceImpl implements InventoryService { return inventoryList; } + @Override + public Map queryInvAll(InventoryQueryCriteria criteria, Pageable pageable) { + //库存查询 + int pageNum=pageable.getPageNumber();//当前页 + int pageSize=pageable.getPageSize();//条数 + Query queryTotal = getQuery(criteria,BizStatus.QUERY_TOTAL); + List l=queryTotal.getResultList(); + int pageCount=((BigInteger)l.get(0)).intValue(); + Query queryPage = getQuery(criteria,BizStatus.QUERY_PAGE); + queryPage.setFirstResult((pageNum)*pageSize); + queryPage.setMaxResults((pageNum+1)*pageSize); + long st=System.currentTimeMillis(); + List queryResultList = queryPage.unwrap(SQLQuery.class) + .setResultTransformer( + AliasToEntityMapResultTransformer.INSTANCE + ) + .list(); + log.error("查询制造库存用时:"+(System.currentTimeMillis()-st)); + Map map=new HashMap<>(); + map.put("content",queryResultList); + map.put("totalElements",pageCount); + return map; + } + + public Query getQuery(InventoryQueryCriteria criteria,String type){ + String midSql="SELECT inv.id,area.name area_name,p.code point_code,it.code item_code,it.name item_name," + + " inv.quantity ,inv.queued_qty,ik.prop_c2 ,p.inv_min " ; + if(type.equals(BizStatus.QUERY_TOTAL)){ + midSql="SELECT count(inv.id) "; + } + String sql =midSql+" " + + " from data_inventory inv\n" + + "left join base_point p on p.id=inv.point_id\n" + + "left join base_area area on area.id=inv.area_id\n" + + "left join data_item_key ik on ik.id=inv.item_key_id\n" + + "left join base_item it on it.id=ik.item_id" + + " where 1=1 " ; + if(criteria!=null) { + String item_code=criteria.getItemCodeOne(); + String item_name=criteria.getItemName(); + String point_code=criteria.getPointCode(); + String prop_c2=criteria.getBonded(); + String point_type=criteria.getPointType(); + Boolean kcbz=true; + if (item_code!=null &&item_code.equals("") ) { + sql += " and it.code like '%" + item_code + "%'"; + } + if (item_name!=null &&item_name.equals("") ) { + sql += " and it.name like '%" + item_code + "%'"; + } + if (point_code!=null &&point_code.equals("") ) { + sql += " and p.code like '%" + point_code + "%'"; + } + if (point_type!=null &&point_type.equals("") ) { + sql += " and p.type='" + point_type + "'"; + } + if (prop_c2!=null &&prop_c2.equals("") ) { + sql += " and it.name like '%" + item_code + "%'"; + } + } + sql+=" order by it.code "; + Query query = entityManager.createNativeQuery(sql); + return query; + } + public Double getInvQty(long itemId, long areaId,Long zzkwId) { String hql = "select sum(inv.quantity-inv.queuedQty) from Inventory inv where 1=1 " + " and inv.itemKey.item.id=" + itemId + " " + @@ -211,21 +274,21 @@ public class InventoryServiceImpl implements InventoryService { @Override @Transactional(rollbackFor = Exception.class) - public Inventory getInventory(ItemKey itemKey, Area area, Point point, Point zzkw, Dept dept, String type,String stockCode) { + public Inventory getInventory(ItemKey itemKey, Area area, Point point, Point zzkw,Dept dept, String type,String stockCode) { //生成Inventory String hql = " from Inventory inv where 1=1 "; - if(type.equals(BizStatus.SL_ALL)||type.equals(BizStatus.ZZKW_TL)||type.equals(BizStatus.YK_JS)){ - if(zzkw==null){ - throw new BadRequestException(HttpStatus.NOT_FOUND, "制造库位必填"); - } - if(!area.getBexb()){ - throw new BadRequestException(HttpStatus.NOT_FOUND, area.getCode()+"接收库区必须为线边仓"); - } +// if(type.equals(BizStatus.SL_ALL)||type.equals(BizStatus.ZZKW_TL)||type.equals(BizStatus.YK_JS)){ +// if(zzkw==null){ +// throw new BadRequestException(HttpStatus.NOT_FOUND, "制造库位必填"); +// } +// if(!area.getBexb()){ +// throw new BadRequestException(HttpStatus.NOT_FOUND, area.getCode()+"接收库区必须为线边仓"); +// } // if(area.getPoint()==null){ // if(area.getPointId()==null){ // throw new BadRequestException(HttpStatus.NOT_FOUND, "接收库区线边库位必填"); // } - } +// } if(type.equals(BizStatus.SL_ALL)){ //取库区默认 hql += " and inv.point.id=" + area.getPointId() + " "; @@ -266,11 +329,11 @@ public class InventoryServiceImpl implements InventoryService { inventory.setItemKey(itemKey); inventory.setPoint(point); inventory.setPointCode(point.getCode()); - if(zzkw==null){ - zzkw=pointService.getPoint("ZZKW",null,null,null); - } +// if(zzkw==null){ +// zzkw=pointService.getPoint("ZZKW",null,null,null); +// } inventory.setStockCode(stockCode); - inventory.setZzkw(zzkw); +// inventory.setZzkw(zzkw); // inventory.setStock(stock); // inventory.setStockCode(stock.getCode()); inventory.setDept(dept); @@ -353,7 +416,7 @@ public class InventoryServiceImpl implements InventoryService { //位移所需要的数据 InventoryYW inventoryYW = inventoryButton.getInventoryYW(); //原数据 - Inventory inventoryOld = inventoryYW.getInventory(); + Inventory inventoryOld = inventoryRepository.getById(inventoryYW.getInventory().getId()); // 位移数量 double rmNumber = inventoryYW.getRmNumber(); //判断 库存-要移动的数量