no message
parent
e8c8c59e35
commit
e44ff8250d
|
|
@ -301,7 +301,7 @@ public class BydAppServiceImpl implements BydAppService {
|
||||||
public void createAsnDetailsAndItemKeysAndTasks(List<BarCodeVo> barCodeVos, Item item, Stock stock, Point srcPoint, Point endPoint, AgvTask agvTask) {
|
public void createAsnDetailsAndItemKeysAndTasks(List<BarCodeVo> barCodeVos, Item item, Stock stock, Point srcPoint, Point endPoint, AgvTask agvTask) {
|
||||||
for (BarCodeVo barCodeVo : barCodeVos) {
|
for (BarCodeVo barCodeVo : barCodeVos) {
|
||||||
AsnDetail asnDetail = asnDetailService.createAsnDetail(item, stock, srcPoint, barCodeVo.getPropC1(), barCodeVo.getBoxNumber(), barCodeVo.getPropC3(), Timestamp.valueOf(DateUtil.formatDateTime(DateUtil.parse(barCodeVo.getPropD1()))), barCodeVo.getOrderQty(), barCodeVo.getMo());
|
AsnDetail asnDetail = asnDetailService.createAsnDetail(item, stock, srcPoint, barCodeVo.getPropC1(), barCodeVo.getBoxNumber(), barCodeVo.getPropC3(), Timestamp.valueOf(DateUtil.formatDateTime(DateUtil.parse(barCodeVo.getPropD1()))), barCodeVo.getOrderQty(), barCodeVo.getMo());
|
||||||
ItemKey itemKey = itemKeyService.createItemKey(item, barCodeVo.getPropC1(), barCodeVo.getBoxNumber());
|
ItemKey itemKey = itemKeyService.createItemKey(item, barCodeVo.getPropC1(),asnDetail.getPropD1(), barCodeVo.getBoxNumber());
|
||||||
Task task = taskService.createTask(item, asnDetail.getOrderQty(), itemKey, asnDetail, BizStatus.ASN, null, null, stock, srcPoint, endPoint, agvTask);
|
Task task = taskService.createTask(item, asnDetail.getOrderQty(), itemKey, asnDetail, BizStatus.ASN, null, null, stock, srcPoint, endPoint, agvTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ import java.util.Set;
|
||||||
**/
|
**/
|
||||||
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
|
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
|
||||||
|
|
||||||
@Query(value = "from Item i where i.code in :itemCodes ")
|
@Query(value = "from Item i where i.code in :itemCodes and (:goodType is null or i.goodType=:goodType) and i.enabled = true ")
|
||||||
List<Item> findByCodes(Set<String> itemCodes);
|
List<Item> findByCodes(Set<String> itemCodes,String goodType);
|
||||||
|
|
||||||
@Query(" from Item i where i.code = :code and i.enabled = true")
|
@Query(" from Item i where i.code = :code and i.enabled = true")
|
||||||
Item findByCode(String code);
|
Item findByCode(String code);
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ public interface ItemService {
|
||||||
*
|
*
|
||||||
* @param itemCodes 物料集合
|
* @param itemCodes 物料集合
|
||||||
*/
|
*/
|
||||||
Map<String, Item> findByCodes(Set<String> itemCodes);
|
Map<String, Item> findByCodes(Set<String> itemCodes,String goodType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入物料
|
* 导入物料
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,6 +53,7 @@ public class ItemServiceImpl implements ItemService {
|
||||||
private final ItemRepository itemRepository;
|
private final ItemRepository itemRepository;
|
||||||
private final ItemMapper itemMapper;
|
private final ItemMapper itemMapper;
|
||||||
private final FileProperties properties;
|
private final FileProperties properties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(ItemQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAll(ItemQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<Item> page = itemRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
Page<Item> page = itemRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||||
|
|
@ -141,8 +143,8 @@ public class ItemServiceImpl implements ItemService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Item> findByCodes(Set<String> itemCodes) {
|
public Map<String, Item> findByCodes(Set<String> itemCodes, String goodType) {
|
||||||
List<Item> items = itemRepository.findByCodes(itemCodes);
|
List<Item> items = itemRepository.findByCodes(itemCodes, goodType);
|
||||||
Map<String, Item> itemMap = new HashMap<>();
|
Map<String, Item> itemMap = new HashMap<>();
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
itemMap.put(item.getCode(), item);
|
itemMap.put(item.getCode(), item);
|
||||||
|
|
@ -170,7 +172,7 @@ public class ItemServiceImpl implements ItemService {
|
||||||
|
|
||||||
|
|
||||||
//获取已存在的物料
|
//获取已存在的物料
|
||||||
Map<String, Item> existingPoint = findByCodes(itemCodes);
|
Map<String, Item> existingPoint = findByCodes(itemCodes,null);
|
||||||
|
|
||||||
|
|
||||||
List<Item> itemsToCreate = new ArrayList<>();//新增物料集合
|
List<Item> itemsToCreate = new ArrayList<>();//新增物料集合
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.repository;
|
package com.youchain.businessdata.repository;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Box;
|
|
||||||
import com.youchain.basicdata.domain.Point;
|
|
||||||
import com.youchain.basicdata.domain.Stock;
|
|
||||||
import com.youchain.businessdata.domain.Inventory;
|
import com.youchain.businessdata.domain.Inventory;
|
||||||
import com.youchain.businessdata.domain.ItemKey;
|
|
||||||
import com.youchain.modules.system.domain.Dept;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
@ -28,7 +24,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huojin
|
* @author huojin
|
||||||
|
|
@ -38,11 +33,12 @@ import java.util.Set;
|
||||||
public interface InventoryRepository extends JpaRepository<Inventory, Long>, JpaSpecificationExecutor<Inventory> {
|
public interface InventoryRepository extends JpaRepository<Inventory, Long>, JpaSpecificationExecutor<Inventory> {
|
||||||
/**
|
/**
|
||||||
* 查询库存信息
|
* 查询库存信息
|
||||||
* @param stockId 容器
|
*
|
||||||
* @param itemId 物料
|
* @param stockId 容器
|
||||||
* @param pointId 点位
|
* @param itemId 物料
|
||||||
|
* @param pointId 点位
|
||||||
* @param areaName 库区
|
* @param areaName 库区
|
||||||
* @param deptId 仓库
|
* @param deptId 仓库
|
||||||
*/
|
*/
|
||||||
@Query(" from Inventory inv where inv.quantity-inv.queuedQty>0 " +
|
@Query(" from Inventory inv where inv.quantity-inv.queuedQty>0 " +
|
||||||
"and (:stockId is null or inv.stock.id=:stockId) " +
|
"and (:stockId is null or inv.stock.id=:stockId) " +
|
||||||
|
|
@ -55,14 +51,16 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, Jpa
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据箱号和容器查询库存信息
|
* 根据箱号和容器查询库存信息
|
||||||
|
*
|
||||||
* @param orderNumber 箱号
|
* @param orderNumber 箱号
|
||||||
* @param stockCode 容器
|
* @param stockCode 容器
|
||||||
*/
|
*/
|
||||||
@Query(" from Inventory inv where inv.itemKey.orderNumber=:orderNumber and inv.stockCode=:stockCode and inv.quantity-inv.queuedQty>0 ")
|
@Query(" from Inventory inv where inv.itemKey.orderNumber=:orderNumber and inv.stockCode=:stockCode and inv.quantity-inv.queuedQty>0 ")
|
||||||
Inventory findByOrderNumber(String orderNumber, String stockCode);
|
Inventory findByOrderNumber(String orderNumber, String stockCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据容器查询所有库存信息
|
* 根据容器查询所有库存信息
|
||||||
|
*
|
||||||
* @param stockCode 容器
|
* @param stockCode 容器
|
||||||
*/
|
*/
|
||||||
@Query(" from Inventory inv where inv.stockCode=:stockCode and inv.quantity>0 ")
|
@Query(" from Inventory inv where inv.stockCode=:stockCode and inv.quantity>0 ")
|
||||||
|
|
@ -79,4 +77,7 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, Jpa
|
||||||
" group by inv.stock.code,inv.point.code,inv.itemKey.item.code " +
|
" group by inv.stock.code,inv.point.code,inv.itemKey.item.code " +
|
||||||
" order by inv.point.code ")
|
" order by inv.point.code ")
|
||||||
Page<List<Object[]>> queryBigScreenPointInfo(Pageable pageable);
|
Page<List<Object[]>> queryBigScreenPointInfo(Pageable pageable);
|
||||||
|
|
||||||
|
@Query(" from Inventory inv where inv.itemKey.id in (select ik.id from ItemKey ik where ik.orderNumber in :orderNumbers ) and inv.quantity>0 ")
|
||||||
|
List<Inventory> findByOrderNumbers(List<String> orderNumbers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -109,4 +110,12 @@ public class InventoryController {
|
||||||
return new ResponseEntity<>(ApiResult.fail(OK.value(), "", object), HttpStatus.OK);
|
return new ResponseEntity<>(ApiResult.fail(OK.value(), "", object), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/import_inventory")
|
||||||
|
@Log("导入物料")
|
||||||
|
@ApiOperation("导入物料")
|
||||||
|
@PreAuthorize("@el.check('inventory:importPoint')")
|
||||||
|
public ResponseEntity<Object> importInventory(@RequestParam("file") MultipartFile multipartFile) {
|
||||||
|
return inventoryService.impoertBigItemInventory(multipartFile);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ import com.youchain.businessdata.service.dto.InventoryQueryCriteria;
|
||||||
import com.youchain.modules.system.domain.Dept;
|
import com.youchain.modules.system.domain.Dept;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -148,4 +150,19 @@ public interface InventoryService {
|
||||||
*/
|
*/
|
||||||
Page<List<Object[]>> queryBigScreenPointInfo(int currentPage, int pageSize);
|
Page<List<Object[]>> queryBigScreenPointInfo(int currentPage, int pageSize);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据箱号查询所有库存
|
||||||
|
* @param orderNumbers 箱号
|
||||||
|
*/
|
||||||
|
List<Inventory> findByOrderNumbers(List<String> orderNumbers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入大件物料库存
|
||||||
|
* @param multipartFile 文件
|
||||||
|
* @return ResponseEntity<Object>
|
||||||
|
*/
|
||||||
|
ResponseEntity<Object> impoertBigItemInventory(MultipartFile multipartFile);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ import com.youchain.businessdata.service.dto.ItemKeyDto;
|
||||||
import com.youchain.businessdata.service.dto.ItemKeyQueryCriteria;
|
import com.youchain.businessdata.service.dto.ItemKeyQueryCriteria;
|
||||||
import com.youchain.modules.system.domain.Dept;
|
import com.youchain.modules.system.domain.Dept;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -87,7 +89,8 @@ public interface ItemKeyService {
|
||||||
* 生成ItemKey
|
* 生成ItemKey
|
||||||
* @param item 物料
|
* @param item 物料
|
||||||
* @param propC1 批次
|
* @param propC1 批次
|
||||||
|
* @param propD1 生产日期
|
||||||
* @param orderNumber 工单号
|
* @param orderNumber 工单号
|
||||||
*/
|
*/
|
||||||
ItemKey createItemKey(Item item, String propC1,String orderNumber);
|
ItemKey createItemKey(Item item, String propC1, Timestamp propD1, String orderNumber);
|
||||||
}
|
}
|
||||||
|
|
@ -49,5 +49,8 @@ public class InventoryLogQueryCriteria{
|
||||||
@Query(joinName = "itemKey>", propName="propC1",type = Query.Type.INNER_LIKE)
|
@Query(joinName = "itemKey>", propName="propC1",type = Query.Type.INNER_LIKE)
|
||||||
private String propC1;
|
private String propC1;
|
||||||
|
|
||||||
|
@Query(joinName = "itemKey", propName = "orderNumber", type = Query.Type.INNER_LIKE)
|
||||||
|
private String orderNumber;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service.dto;
|
package com.youchain.businessdata.service.dto;
|
||||||
|
|
||||||
import com.youchain.base.BaseEntity;
|
import com.youchain.base.BaseEntity;
|
||||||
|
|
@ -23,6 +23,7 @@ import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.youchain.annotation.Query;
|
import com.youchain.annotation.Query;
|
||||||
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
|
|
@ -30,36 +31,39 @@ import javax.persistence.OneToOne;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author huojin
|
||||||
* @author huojin
|
* @website https://eladmin.vip
|
||||||
* @date 2023-08-22
|
* @date 2023-08-22
|
||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
public class InventoryQueryCriteria{
|
public class InventoryQueryCriteria {
|
||||||
|
|
||||||
/*@Query(joinName = "itemKey>item>", propName="code" ,type = Query.Type.INNER_LIKE)
|
/*@Query(joinName = "itemKey>item>", propName="code" ,type = Query.Type.INNER_LIKE)
|
||||||
private String itemCode;*/
|
private String itemCode;*/
|
||||||
|
|
||||||
@Query(joinName = "itemKey>item>", propName="name",type = Query.Type.INNER_LIKE)
|
@Query(joinName = "itemKey>item>", propName = "name", type = Query.Type.INNER_LIKE)
|
||||||
private String itemName;
|
private String itemName;
|
||||||
|
|
||||||
@Query(joinName = "itemKey>", propName="propC1",type = Query.Type.INNER_LIKE)
|
@Query(joinName = "itemKey>", propName = "propC1", type = Query.Type.INNER_LIKE)
|
||||||
private String propC1;
|
private String propC1;
|
||||||
|
|
||||||
@Query(joinName = "itemKey>item>", propName="code",type = Query.Type.IN)
|
@Query(joinName = "itemKey>item>", propName = "code", type = Query.Type.IN)
|
||||||
private List<String> itemCode;
|
private List<String> itemCode;
|
||||||
|
|
||||||
@Query(joinName = "itemKey>item>", propName="code" ,type = Query.Type.INNER_LIKE)
|
@Query(joinName = "itemKey>item>", propName = "code", type = Query.Type.INNER_LIKE)
|
||||||
private String itemCodeOne;
|
private String itemCodeOne;
|
||||||
|
|
||||||
// NOT_EQUAL 不等于
|
// NOT_EQUAL 不等于
|
||||||
@Query(type = Query.Type.NOT_EQUAL)
|
@Query(type = Query.Type.NOT_EQUAL)
|
||||||
private Double quantity;
|
private Double quantity;
|
||||||
|
|
||||||
@Query(joinName = "stock", propName="name",type = Query.Type.INNER_LIKE)
|
@Query(joinName = "stock", propName = "name", type = Query.Type.INNER_LIKE)
|
||||||
private String stockName;
|
private String stockName;
|
||||||
|
|
||||||
@Query(joinName = "point>area>", propName="name",type = Query.Type.IN)
|
@Query(joinName = "itemKey", propName = "orderNumber", type = Query.Type.INNER_LIKE)
|
||||||
|
private String orderNumber;
|
||||||
|
|
||||||
|
@Query(joinName = "point>area>", propName = "name", type = Query.Type.IN)
|
||||||
private List<String> areaName;
|
private List<String> areaName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,21 @@
|
||||||
package com.youchain.businessdata.service.impl;
|
package com.youchain.businessdata.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.poi.excel.ExcelReader;
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
|
import com.youchain.basicdata.service.ItemService;
|
||||||
|
import com.youchain.basicdata.service.PointService;
|
||||||
|
import com.youchain.basicdata.service.StockService;
|
||||||
import com.youchain.businessdata.domain.Inventory;
|
import com.youchain.businessdata.domain.Inventory;
|
||||||
import com.youchain.businessdata.domain.ItemKey;
|
import com.youchain.businessdata.domain.ItemKey;
|
||||||
|
import com.youchain.businessdata.service.InventoryLogService;
|
||||||
|
import com.youchain.businessdata.service.ItemKeyService;
|
||||||
import com.youchain.businessdata.service.dto.*;
|
import com.youchain.businessdata.service.dto.*;
|
||||||
|
import com.youchain.config.FileProperties;
|
||||||
|
import com.youchain.exception.handler.ApiResult;
|
||||||
import com.youchain.modules.system.domain.Dept;
|
import com.youchain.modules.system.domain.Dept;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -28,17 +38,25 @@ import com.youchain.businessdata.repository.InventoryRepository;
|
||||||
import com.youchain.businessdata.service.InventoryService;
|
import com.youchain.businessdata.service.InventoryService;
|
||||||
import com.youchain.businessdata.service.mapstruct.InventoryMapper;
|
import com.youchain.businessdata.service.mapstruct.InventoryMapper;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.persistence.EntityManager;
|
import java.util.stream.Collectors;
|
||||||
import javax.persistence.Query;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huojin
|
* @author huojin
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
|
|
@ -51,8 +69,12 @@ public class InventoryServiceImpl implements InventoryService {
|
||||||
|
|
||||||
private final InventoryRepository inventoryRepository;
|
private final InventoryRepository inventoryRepository;
|
||||||
private final InventoryMapper inventoryMapper;
|
private final InventoryMapper inventoryMapper;
|
||||||
private final EntityManager entityManager;
|
private final StockService stockService;
|
||||||
|
private final ItemService itemService;
|
||||||
|
private final PointService pointService;
|
||||||
|
private final ItemKeyService itemKeyService;
|
||||||
|
private final InventoryLogService inventoryLogService;
|
||||||
|
private final FileProperties properties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(InventoryQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAll(InventoryQueryCriteria criteria, Pageable pageable) {
|
||||||
|
|
@ -89,7 +111,15 @@ public class InventoryServiceImpl implements InventoryService {
|
||||||
@Override
|
@Override
|
||||||
public void deleteAll(Long[] ids) {
|
public void deleteAll(Long[] ids) {
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
inventoryRepository.deleteById(id);
|
Inventory inventory = this.findById(id);
|
||||||
|
Stock stock = inventory.getStock();
|
||||||
|
Point point = inventory.getPoint();
|
||||||
|
inventoryRepository.deleteById(inventory.getId());
|
||||||
|
List<Inventory> inventoryList = this.findByStockCode(stock.getCode());
|
||||||
|
if (inventoryList.isEmpty()) {
|
||||||
|
pointService.freePoint(point);
|
||||||
|
stockService.usedStock(stock, null, BaseStatus.FREE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,7 +196,140 @@ public class InventoryServiceImpl implements InventoryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<List<Object[]>> queryBigScreenPointInfo(int currentPage, int pageSize) {
|
public Page<List<Object[]>> queryBigScreenPointInfo(int currentPage, int pageSize) {
|
||||||
Pageable pageable= PageRequest.of(currentPage - 1, pageSize);
|
Pageable pageable = PageRequest.of(currentPage - 1, pageSize);
|
||||||
return inventoryRepository.queryBigScreenPointInfo(pageable);
|
return inventoryRepository.queryBigScreenPointInfo(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Inventory> findByOrderNumbers(List<String> orderNumbers) {
|
||||||
|
return inventoryRepository.findByOrderNumbers(orderNumbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ResponseEntity<Object> impoertBigItemInventory(MultipartFile multipartFile) {
|
||||||
|
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||||
|
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||||
|
String type = FileUtil.getFileType(suffix);
|
||||||
|
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||||
|
Dept dept = UserUtils.getDept();
|
||||||
|
ExcelReader reader = ExcelUtil.getReader(file);
|
||||||
|
List<Map<String, Object>> readAll = reader.readAll();
|
||||||
|
Set<String> stocks = new HashSet<>();//托盘集合
|
||||||
|
List<String> orderNumbers = new ArrayList<>();//箱号集合
|
||||||
|
Set<String> items = new HashSet<>();//物料集合
|
||||||
|
Set<String> points = new HashSet<>();//点位集合
|
||||||
|
Map<String, Set<String>> stockItemMap = new HashMap<>();//一个托盘一种物料
|
||||||
|
for (Map<String, Object> record : readAll) {
|
||||||
|
String stock = record.get("托盘号").toString().trim();
|
||||||
|
String orderNumber = record.get("箱号").toString().trim();
|
||||||
|
String itemCode = record.get("物料编码").toString().trim();
|
||||||
|
String pointCode = record.get("点位").toString().trim();
|
||||||
|
if (StringUtils.isNotEmpty(stock)) {
|
||||||
|
stocks.add(stock);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(orderNumber)) {
|
||||||
|
orderNumbers.add(orderNumber);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(itemCode)) {
|
||||||
|
items.add(itemCode);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(pointCode)) {
|
||||||
|
points.add(pointCode);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(stock) && StringUtils.isNotEmpty(itemCode)) {
|
||||||
|
Set<String> itemSet = stockItemMap.get(stock);
|
||||||
|
if (itemSet == null) {
|
||||||
|
itemSet = new HashSet<>();
|
||||||
|
}
|
||||||
|
itemSet.add(itemCode);
|
||||||
|
stockItemMap.put(stock, itemSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//验证托盘
|
||||||
|
Map<String, Stock> existingStock = stockService.findByCodes(stocks);
|
||||||
|
Set<String> stockCodes = existingStock.keySet().stream().collect(Collectors.toSet());
|
||||||
|
Set<String> differenceStockSet = stocks.stream().filter(stock -> !stockCodes.contains(stock)).collect(Collectors.toSet());
|
||||||
|
if (!differenceStockSet.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "WMS不存在的托盘集合,请维护:" + differenceStockSet, null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证箱号
|
||||||
|
boolean hasDuplicates = orderNumbers.size() != orderNumbers.stream().distinct().count();
|
||||||
|
if (hasDuplicates) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "文件中有重复的箱号,请调整", null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证物料
|
||||||
|
Map<String, Item> existingItem = itemService.findByCodes(items, "大件");
|
||||||
|
Set<String> itemCodes = existingItem.keySet().stream().collect(Collectors.toSet());
|
||||||
|
Set<String> differenceItemSet = items.stream().filter(item -> !itemCodes.contains(item)).collect(Collectors.toSet());
|
||||||
|
if (!differenceItemSet.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "WMS不存在的物料集合,请维护:" + differenceItemSet, null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证库位
|
||||||
|
Map<String, Point> existingPoint = pointService.findByCodes(points);
|
||||||
|
Set<String> pointCodes = existingPoint.keySet().stream().collect(Collectors.toSet());
|
||||||
|
Set<String> differencePointSet = points.stream().filter(point -> !pointCodes.contains(point)).collect(Collectors.toSet());
|
||||||
|
if (!differencePointSet.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "WMS不存在的点位集合,请维护:" + differencePointSet, null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证一个托盘只能一种物料;用于存储不符合条件的托盘
|
||||||
|
List<String> invalidStocks = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, Set<String>> entry : stockItemMap.entrySet()) {
|
||||||
|
String tp = entry.getKey();
|
||||||
|
Set<String> values = entry.getValue();
|
||||||
|
if (values.size() > 1) {
|
||||||
|
invalidStocks.add(tp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!invalidStocks.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "以下托盘包含多种物料:" + invalidStocks, null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//1.验证箱号是否已生成库存
|
||||||
|
List<Inventory> inventoryList = this.findByOrderNumbers(orderNumbers);
|
||||||
|
List<String> existingOrderNumber = new ArrayList<>();
|
||||||
|
for (Inventory inventory : inventoryList) {
|
||||||
|
existingOrderNumber.add(inventory.getItemKey().getOrderNumber());
|
||||||
|
}
|
||||||
|
if (!existingOrderNumber.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), "以下箱号已导入,请勿重复导入:" + existingOrderNumber, null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//2.新增库存
|
||||||
|
for (Map<String, Object> record : readAll) {
|
||||||
|
String stockCode = record.get("托盘号").toString().trim();
|
||||||
|
String orderNumber = record.get("箱号").toString().trim();
|
||||||
|
String itemCode = record.get("物料编码").toString().trim();
|
||||||
|
String quantity = record.get("数量").toString().trim();
|
||||||
|
String propC1 = record.get("批次号").toString().trim();
|
||||||
|
String propD1 = record.get("生产日期").toString().trim();
|
||||||
|
String pointCode = record.get("点位").toString().trim();
|
||||||
|
//物料
|
||||||
|
Item item = existingItem.get(itemCode);
|
||||||
|
//托盘
|
||||||
|
Stock stock = existingStock.get(stockCode);
|
||||||
|
//库位
|
||||||
|
Point point = existingPoint.get(pointCode);
|
||||||
|
//创建ItemKey
|
||||||
|
ItemKey itemKey = itemKeyService.createItemKey(item, propC1, Timestamp.valueOf(propD1), orderNumber);
|
||||||
|
//生成库存
|
||||||
|
Inventory inventory = this.createInventory(itemKey, point, stock, dept, Double.parseDouble(quantity));
|
||||||
|
//点位占用
|
||||||
|
pointService.usedPoint(point);
|
||||||
|
//占用容器
|
||||||
|
stockService.usedStock(stock, point, BaseStatus.USED);
|
||||||
|
|
||||||
|
//新增日志
|
||||||
|
inventoryLogService.createInventoryLog(BizStatus.RECEIVING_UP, BizStatus.ADD, null, itemKey, null, point, stock, stock, 0d, Double.parseDouble(quantity), BizStatus.ASN, null, inventory.getId(), null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<>(ApiResult.fail(OK.value(), "导入成功!", null), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
@ -116,7 +117,7 @@ public class ItemKeyServiceImpl implements ItemKeyService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ItemKey createItemKey(Item item, String propC1, String orderNumber) {
|
public ItemKey createItemKey(Item item, String propC1, Timestamp propD1, String orderNumber) {
|
||||||
ItemKey itemKey = itemKeyRepository.queryItemKey(item.getId(), propC1, orderNumber);
|
ItemKey itemKey = itemKeyRepository.queryItemKey(item.getId(), propC1, orderNumber);
|
||||||
if (itemKey != null) {
|
if (itemKey != null) {
|
||||||
return itemKey;
|
return itemKey;
|
||||||
|
|
@ -126,6 +127,7 @@ public class ItemKeyServiceImpl implements ItemKeyService {
|
||||||
newItemKey.setDept(item.getDept());
|
newItemKey.setDept(item.getDept());
|
||||||
newItemKey.setPropC1(propC1);
|
newItemKey.setPropC1(propC1);
|
||||||
newItemKey.setOrderNumber(orderNumber);
|
newItemKey.setOrderNumber(orderNumber);
|
||||||
|
newItemKey.setPropD1(propD1);
|
||||||
itemKeyRepository.save(newItemKey);
|
itemKeyRepository.save(newItemKey);
|
||||||
return newItemKey;
|
return newItemKey;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ public class MesServiceImpl implements MesService {
|
||||||
itemCodes.addAll(yclbl.getBlzcmx().stream().map(ItemDate::getItemCode).collect(Collectors.toSet()));
|
itemCodes.addAll(yclbl.getBlzcmx().stream().map(ItemDate::getItemCode).collect(Collectors.toSet()));
|
||||||
|
|
||||||
// 查找数据库中存在的items
|
// 查找数据库中存在的items
|
||||||
List<Item> items = itemRepository.findByCodes(itemCodes);
|
List<Item> items = itemRepository.findByCodes(itemCodes, null);
|
||||||
Set<String> newItemCodes = items.stream().map(Item::getCode).collect(Collectors.toSet());
|
Set<String> newItemCodes = items.stream().map(Item::getCode).collect(Collectors.toSet());
|
||||||
|
|
||||||
// 取itemCodes和newItemCodes的差集,说明有不存在的物料
|
// 取itemCodes和newItemCodes的差集,说明有不存在的物料
|
||||||
|
|
@ -282,7 +282,7 @@ public class MesServiceImpl implements MesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void moveCpOffLine(TransTask transTask) {
|
private synchronized void moveCpOffLine(TransTask transTask) {
|
||||||
//判断下线缓存区是否有满货架;
|
//查询下线缓存区是否有满货架;
|
||||||
List<Stock> fullStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPXXHC, BaseStatus.USED);
|
List<Stock> fullStockList = stockService.findByFreeOrUsedStock(AreaNameDic.CPXXHC, BaseStatus.USED);
|
||||||
if (!fullStockList.isEmpty()) {
|
if (!fullStockList.isEmpty()) {
|
||||||
List<Point> endPointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, AreaNameDic.CPRKQ);
|
List<Point> endPointList = pointService.queryPoints(null, BaseStatus.FREE, BaseStatus.BOX, AreaNameDic.CPRKQ);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue