From 20fa61bb34b2bf83dd4bf5df6e438c9ddd66db7f Mon Sep 17 00:00:00 2001 From: FOAM <491460741@qq.com> Date: Tue, 21 Oct 2025 18:29:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/BomAccountRepository.java | 4 + .../basicdata/rest/ImportDataController.java | 51 +++-- .../basicdata/rest/ItemController.java | 1 + .../service/ImportCountDetailService.java | 11 + .../basicdata/service/ImportPointService.java | 2 + .../service/impl/BomAccountServiceImpl.java | 10 + .../impl/ImportCountDetailServiceImpl.java | 196 +++++++++++++++++ .../service/impl/ImportPointServiceImpl.java | 205 +++++++++++++----- .../businessdata/inputJson/ZzkwMoveReq.java | 11 + .../inputJson/imports/CountDetailImport.java | 31 +++ .../inputJson/imports/PointImport.java | 2 + .../repository/InventoryRepository.java | 18 +- .../repository/ItemKeyRepository.java | 4 + .../rest/CountMoveController.java | 4 +- .../rest/InventoryController.java | 108 +++++++++ .../rest/PickDetailController.java | 8 +- .../service/dto/CountMoveDetailDto.java | 2 +- .../service/dto/XppRecordViewDto.java | 2 +- .../service/impl/CountMoveServiceImpl.java | 43 ++-- .../service/impl/InventoryServiceImpl.java | 5 +- .../java/com/youchain/utils/BizStatus.java | 5 + .../com/youchain/utils/FastExcelUtil.java | 1 + 22 files changed, 635 insertions(+), 89 deletions(-) create mode 100644 youchain-system/src/main/java/com/youchain/basicdata/service/ImportCountDetailService.java create mode 100644 youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportCountDetailServiceImpl.java create mode 100644 youchain-system/src/main/java/com/youchain/businessdata/inputJson/ZzkwMoveReq.java create mode 100644 youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/CountDetailImport.java diff --git a/youchain-system/src/main/java/com/youchain/basicdata/repository/BomAccountRepository.java b/youchain-system/src/main/java/com/youchain/basicdata/repository/BomAccountRepository.java index d18e549..21a9135 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/repository/BomAccountRepository.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/repository/BomAccountRepository.java @@ -58,6 +58,10 @@ public interface BomAccountRepository extends JpaRepository, J @Query(value = "SELECT IFNULL(sum(pc_qty),0) FROM `base_bom_account` b where b.r_area_id=?1 and b.item_id=?2 and b.z_point_id=?3", nativeQuery = true) Double getPcQty(Long area_id, Long item_id, Long point_id); + /**固定库位二维码解析*/ + @Query(value = "SELECT * FROM `base_bom_account` b where b.item_id=:item_id and b.z_point_id=:z_point_id and b.bonded=:bonded", nativeQuery = true) + List queryEwmJx(Long item_id, Long z_point_id,String bonded); + @Query(value = "SELECT * FROM `base_bom_account` b where b.r_area_id=?1 and b.item_id=?2", nativeQuery = true) List getBomList(Long area_id, Long item_id); diff --git a/youchain-system/src/main/java/com/youchain/basicdata/rest/ImportDataController.java b/youchain-system/src/main/java/com/youchain/basicdata/rest/ImportDataController.java index 3882ab0..e80b72c 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/rest/ImportDataController.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/rest/ImportDataController.java @@ -75,6 +75,7 @@ public class ImportDataController { private final ImportProductionPlanService importProductionPlanService; private final ImportAsnDetailService importAsnDetailService; private final ImportPickDetailService importPickDetailService; + private final ImportCountDetailService importCountDetailService; @Log("导入完成品品番") @ApiOperation("导入完成品品番") @@ -148,16 +149,16 @@ public class ImportDataController { return new ResponseEntity("导入成功", OK); } - @Log("导入移位明细") - @ApiOperation("导入移位明细") - @PostMapping(value = "/importCountMoveDetail") - @Transactional - @AnonymousAccess - public ResponseEntity importCountMoveDetail(@RequestParam Long countId, @RequestParam("file") MultipartFile multipartFile) { - List> readAll = getMaps(multipartFile); - importDataService.importCountMoveDetail(countId, readAll); - return new ResponseEntity("导入成功", OK); - } +// @Log("导入移位明细") +// @ApiOperation("导入移位明细") +// @PostMapping(value = "/importCountMoveDetail") +// @Transactional +// @AnonymousAccess +// public ResponseEntity importCountMoveDetail(@RequestParam Long countId, @RequestParam("file") MultipartFile multipartFile) { +// List> readAll = getMaps(multipartFile); +// importDataService.importCountMoveDetail(countId, readAll); +// return new ResponseEntity("导入成功", OK); +// } @Log("导入BOM工位清单") @ApiOperation("导入BOM工位清单") @@ -244,8 +245,8 @@ public class ImportDataController { return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), OK); } - @Log("导入Point") - @ApiOperation("导入Point") + @Log("导入库位") + @ApiOperation("导入库位") @PostMapping(value = "/importPoint") @Transactional @AnonymousAccess @@ -254,7 +255,31 @@ public class ImportDataController { long start = System.currentTimeMillis(); importPointService.importPoint(multipartFile); log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start)); - return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), OK); + return new ResponseEntity("导入成功", OK); + } + @Log("导入库位更新") + @ApiOperation("导入库位更新") + @PostMapping(value = "/importPointUpdate") + @Transactional + @AnonymousAccess + public ResponseEntity importPointUpdate(@RequestParam("file") MultipartFile multipartFile) { + log.info("开始导入点位"); + long start = System.currentTimeMillis(); + importPointService.importPointUpdate(multipartFile); + log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start)); + return new ResponseEntity("导入成功", OK); + } + @Log("导入移位明细") + @ApiOperation("导入移位明细") + @PostMapping(value = "/importCountMoveDetail") + @Transactional + @AnonymousAccess + public ResponseEntity importCountMoveDetail(@RequestParam Long countId, @RequestParam("file") MultipartFile multipartFile) { + log.info("开始导入移位明细"); + long start = System.currentTimeMillis(); + importCountDetailService.importData(countId, multipartFile); + log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start)); + return new ResponseEntity("导入成功", OK); } } \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/basicdata/rest/ItemController.java b/youchain-system/src/main/java/com/youchain/basicdata/rest/ItemController.java index 93a30d8..bf0764b 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/rest/ItemController.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/rest/ItemController.java @@ -187,6 +187,7 @@ public class ItemController { @ApiOperation("修改item") @PreAuthorize("@el.check('super:man')") public ResponseEntity updateItem(@Validated @RequestBody Item resources){ + resources.setSrs(resources.getExtendD3().intValue()); itemService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/ImportCountDetailService.java b/youchain-system/src/main/java/com/youchain/basicdata/service/ImportCountDetailService.java new file mode 100644 index 0000000..4922d27 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/ImportCountDetailService.java @@ -0,0 +1,11 @@ +package com.youchain.basicdata.service; + +import org.springframework.web.multipart.MultipartFile; + +public interface ImportCountDetailService { + /** + * 批量导入 + * @param file 文件 + */ + void importData(Long asnId,MultipartFile file); +} diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/ImportPointService.java b/youchain-system/src/main/java/com/youchain/basicdata/service/ImportPointService.java index 4d4792b..6dee899 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/service/ImportPointService.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/ImportPointService.java @@ -8,4 +8,6 @@ public interface ImportPointService { * @param file 文件 */ void importPoint(MultipartFile file); + + void importPointUpdate(MultipartFile file); } diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BomAccountServiceImpl.java b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BomAccountServiceImpl.java index a6120f8..041c01f 100644 --- a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BomAccountServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/BomAccountServiceImpl.java @@ -25,6 +25,7 @@ import com.youchain.basicdata.domain.BigItem; import com.youchain.basicdata.domain.BomAccount; import com.youchain.basicdata.domain.BomAccountLog; import com.youchain.basicdata.domain.Item; +import com.youchain.basicdata.repository.ItemRepository; import com.youchain.basicdata.service.BomAccountLogService; import com.youchain.basicdata.service.PointService; import com.youchain.basicdata.service.dto.*; @@ -69,6 +70,7 @@ import javax.servlet.http.HttpServletResponse; public class BomAccountServiceImpl implements BomAccountService { private final BomAccountRepository bomAccountRepository; + private final ItemRepository itemRepository; private final BomAccountMapper bomAccountMapper; private final PointService pointService; private final EntityManager entityManager; @@ -143,6 +145,14 @@ public class BomAccountServiceImpl implements BomAccountService { ValidationUtil.isNull( bomAccount.getId(),"BomAccount","id",resources.getId()); bomAccount.copy(resources); bomAccountRepository.save(bomAccount); + //更新物料收容数 + Item it=resources.getItem(); + it.setSrs(bomAccount.getSrs()); + it.setExtendD3(resources.getSrs()+0d); + it.setXz(bomAccount.getXz()); + it.setAc(bomAccount.getAc()); + it.setContents(bomAccount.getContents()); + itemRepository.save(it); delCaches(); } diff --git a/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportCountDetailServiceImpl.java b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportCountDetailServiceImpl.java new file mode 100644 index 0000000..a8b545a --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/basicdata/service/impl/ImportCountDetailServiceImpl.java @@ -0,0 +1,196 @@ +package com.youchain.basicdata.service.impl; + +import com.youchain.basicdata.domain.Item; +import com.youchain.basicdata.domain.Point; +import com.youchain.basicdata.repository.ItemRepository; +import com.youchain.basicdata.service.ImportCountDetailService; +import com.youchain.basicdata.service.ImportPickDetailService; +import com.youchain.basicdata.service.ItemService; +import com.youchain.basicdata.service.PointService; +import com.youchain.businessdata.domain.*; +import com.youchain.businessdata.inputJson.imports.CountDetailImport; +import com.youchain.businessdata.inputJson.imports.PickDetailImport; +import com.youchain.businessdata.repository.*; +import com.youchain.businessdata.service.*; +import com.youchain.exception.BadRequestException; +import com.youchain.modules.system.domain.Dept; +import com.youchain.utils.*; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +@Slf4j +public class ImportCountDetailServiceImpl implements ImportCountDetailService { + + private final ItemRepository itemRepository; + + private final ItemKeyRepository itemKeyRepository; + + private final InventoryRepository inventoryRepository; + + private final CountMoveDetailRepository countMoveDetailRepository; + + private final CountMoveRepository countMoveRepository; + + private final ItemService itemService; + + private final ItemKeyService itemKeyService; + + private final PointService pointService; + + private final CountDetailService countDetailService; + + private final CountMoveService countMoveService; + + + + @Override + @Transactional(rollbackFor = Exception.class) + public void importData(Long moveId,MultipartFile file) { + + // 验证模板类型是否正确 + isValidTemplateType(file); + + // 根据模板类型进行不同的处理 + baseImportTemplate(moveId,file); + } + + // 处理标准模板 + @Transactional + public void baseImportTemplate(Long moveId,MultipartFile file) { + // 读取sheet数据 + List dataList = FastExcelUtil.readExcelData(file, CountDetailImport.class, 0, 1); + + //批量导入 + importData(moveId,dataList); + } + + /** + * 处理批量导入 + */ + private void importData(Long moveId,List dataList) { + // TODO: 实现批量导入逻辑 + log.info("处理批量导入,数据条数: {}", dataList.size()); + + CountMove countMove=countMoveRepository.getById(moveId); + if(countMove==null||!countMove.getStatus().equals(BizStatus.OPEN)){ + throw new BadRequestException("移位单据状态不正确"); + } + //获取文件中所有的品番编码 + List itemcodes = dataList.stream().map(CountDetailImport::getItemCode).collect(Collectors.toList()); + itemcodes = itemcodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); + Map exitItemMap = validateItem(itemcodes); + + //获取文件中所有的库位编码 + List srcPointcodes = dataList.stream().map(CountDetailImport::getSrcPointCode).collect(Collectors.toList()); + srcPointcodes = srcPointcodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); + Map exitSrcPointMap = validatePoint(srcPointcodes); + + //获取文件中所有目标的库位编码 + List dstPointcodes = dataList.stream().map(CountDetailImport::getDstPointCode).collect(Collectors.toList()); + dstPointcodes = dstPointcodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); + Map exitDstPointMap = validatePoint(dstPointcodes); + + Dept dept=UserUtils.getDept(); + Double orderQty=countMove.getOrderQty(); + int i=1; + for (CountDetailImport data : dataList) { + i++; + String bonded=data.getBonded(); + String pch=data.getPc(); + String stockCode=data.getStockCode(); + if(data.getBonded()==null){ + throw new BadRequestException("税别不能为空"); + } + Item item = exitItemMap.get(data.getItemCode()); + Point srcPoint=exitSrcPointMap.get(data.getSrcPointCode()); + Point dstPoint=exitDstPointMap.get(data.getDstPointCode()); + List itemKeyList = new ArrayList<>(); + if(srcPoint.getType().equals(BaseStatus.ZZKW)){ + itemKeyList=itemKeyRepository.getItemKeyNotPc(item.getId(),bonded); + }else{ + itemKeyList=itemKeyRepository.getItemKeyPc(item.getId(),pch,bonded); + } + if (itemKeyList.size() == 0) { + throw new BadRequestException(i + "行" + data.getItemCode() + "不存在库存"); + } + ItemKey ik = itemKeyList.get(0); + //查找库存 + List inventoryList = new ArrayList<>(); + if(srcPoint.getType().equals(BaseStatus.ZZKW)){ + inventoryList=inventoryRepository.queryInvPdNotXd(srcPoint.getId(),ik.getId(),BaseStatus.ZZKW); + }else{ + if(stockCode!=null&&!stockCode.equals("")){ + inventoryList=inventoryRepository.queryInvPdXd(srcPoint.getId(),ik.getId(),BaseStatus.CH,stockCode); + }else{ + inventoryList=inventoryRepository.queryInvPdNotXd(srcPoint.getId(),ik.getId(),BaseStatus.CH); + } + } + if (inventoryList.size() == 0) { + throw new BadRequestException( i + "行" + data.getItemCode() + "不存在库存"); + } + Inventory inventory= inventoryList.get(0); + if(inventory.getQueuedQty()>0){ + throw new BadRequestException(i + "行" + data.getItemCode() + "有占用,不能移位"); + } + countMoveService.createCountDetail(countMove,inventory, ik, dstPoint); + } + } + + //验证库位 + private Map validateItem(List codes) { + Map existMap = itemService.queryByItemCodesToMap(codes); + if (existMap.isEmpty()) { + throw new BadRequestException("品番代码不存在或已失效"); + } + List existCodes = new ArrayList(existMap.keySet()); + // 获取两个集合的非交集说明品番不存在或失效,直接提示 + List difference = SmartStringUtil.getDifference(codes, existCodes); + if (CollectionUtils.isNotEmpty(difference)) { + throw new BadRequestException(difference + "品番不存在或已失效"); + } + return existMap; + } + + //验证库位 + private Map validatePoint(List codes) { + Map existMap = pointService.queryByPointCodesToMap(codes); + if (existMap.isEmpty()) { + throw new BadRequestException("库位代码不存在或已失效"); + } + List existCodes = new ArrayList(existMap.keySet()); + // 获取两个集合的非交集说明品番不存在或失效,直接提示 + List difference = SmartStringUtil.getDifference(codes, existCodes); + if (CollectionUtils.isNotEmpty(difference)) { + throw new BadRequestException(difference + "库位不存在或已失效"); + } + return existMap; + } + + + //验证模板是否使用正确 + private void isValidTemplateType(MultipartFile file) { + // 根据模板类型进行不同的处理 + List requiredColumns = Arrays.asList( + "品番", + "源库位", + "目标库位", + "批次号", + "箱单号", + "税别" + ); + List headers = FastExcelUtil.readHeadContent(file, 0, 0); + if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) { + throw new BadRequestException("标准导入模板不正确,请确认模板信息"); + } + } +} 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 e7c8ca5..e4ad854 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 @@ -2,6 +2,7 @@ package com.youchain.basicdata.service.impl; import com.youchain.basicdata.domain.Area; import com.youchain.basicdata.domain.Point; +import com.youchain.basicdata.repository.AreaRepository; import com.youchain.basicdata.repository.PointRepository; import com.youchain.basicdata.service.*; import com.youchain.businessdata.inputJson.imports.PointImport; @@ -25,6 +26,8 @@ public class ImportPointServiceImpl implements ImportPointService { private final PointRepository pointRepository; + private final AreaRepository areaRepository; + private final PointService pointService; private final AreaService areaService; @@ -33,24 +36,62 @@ public class ImportPointServiceImpl implements ImportPointService { @Override @Transactional(rollbackFor = Exception.class) public void importPoint(MultipartFile file) { - + // 根据模板类型进行不同的处理 + List requiredColumns = Arrays.asList( + "库位号", + "库区", + "存储类型", + "品番", + "库存下限", + "纳所", + "标签类型" +// , +// "总分类型", +// "关联总库位" + ); // 验证模板类型是否正确 - isValidTemplateType(file); + isValidTemplateType(file,requiredColumns); // 根据模板类型进行不同的处理 baseImportTemplate(file); } + @Override + @Transactional(rollbackFor = Exception.class) + public void importPointUpdate(MultipartFile file) { + + // 根据模板类型进行不同的处理 + List requiredColumns = Arrays.asList( + "序号" + ); + // 验证模板类型是否正确 + List headers=isValidTemplateType(file,requiredColumns); + Map headersMap=new HashMap<>(); + for(String header:headers){ + headersMap.put(header,Boolean.TRUE); + } + // 根据模板类型进行不同的处理 + baseImportTemplateUpdate(file,headersMap); + } + // 处理标准模板 @Transactional public void baseImportTemplate(MultipartFile file) { // 读取sheet数据 List dataList = FastExcelUtil.readExcelData(file, PointImport.class, 0, 1); - //批量导入 importPointData(dataList); } + // 处理更新导入模板 + @Transactional + public void baseImportTemplateUpdate(MultipartFile file,Map headersMap) { + // 读取sheet数据 + List dataList = FastExcelUtil.readExcelData(file, PointImport.class, 0, 1); + //批量导入 + importPointDataUpdate(dataList,headersMap); + } + /** * 处理批量导入 */ @@ -66,41 +107,117 @@ public class ImportPointServiceImpl implements ImportPointService { for(Point p:pointAll){ exitPointMap.put(p.getCode(),p); } -// -// //获取文件中所有的库区名称 -// List areaNames = dataList.stream().map(PointImport::getAreaName).collect(Collectors.toList()); -// areaNames = areaNames.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); -// Map exitAreaMap = validateArea(areaNames); + + //获取文件中所有的库区名称 + List areaNames = dataList.stream().map(PointImport::getAreaName).collect(Collectors.toList()); + areaNames = areaNames.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); + Map exitAreaMap = validateArea(areaNames); for (PointImport data : dataList) { - log.info(data.getAreaName()+"===="+data.getCode()); Point point = exitPointMap.get(data.getCode()); - point.setCode(data.getAreaName()); -// if (point == null) { -// point=new Point(); -// point.setCode(data.getCode()); -// point.setDept(UserUtils.getDept()); -// point.setCreateBy(SecurityUtils.getCurrentUsername()); -// point.setCreateTime(new Timestamp(new Date().getTime())); -// point.setEnabled(Boolean.TRUE); -// } -// point.setArea(exitAreaMap.get(data.getAreaName())); -// String lx = data.getType(); -// if (lx.equals("材管库位")) { -// lx = BaseStatus.CH; -// } else if (lx.equals("制造库位")) { -// lx = BaseStatus.ZZKW; -// }else if (lx.equals("缓存库位")) { -// lx = BaseStatus.HCKW; -// } -// point.setType(lx); -// point.setBeatCode(data.getNs()); -// point.setDescription(data.getBqlx()); -// point.setItemCode(data.getItemCode()); -// point.setZflx(data.getZflx()); -// point.setBqlx(data.getBqlx()); -// point.setGlzkw(data.getGlzkw()); -// point.setInvMin(Integer.parseInt(data.getKcxx())); + if (point == null) { + point=new Point(); + point.setCode(data.getCode()); + point.setDept(UserUtils.getDept()); + point.setCreateBy(SecurityUtils.getCurrentUsername()); + point.setCreateTime(new Timestamp(new Date().getTime())); + point.setEnabled(Boolean.TRUE); + } + point.setArea(exitAreaMap.get(data.getAreaName())); + String lx = data.getType(); + if (lx.equals("材管库位")) { + lx = BaseStatus.CH; + } else if (lx.equals("制造库位")) { + lx = BaseStatus.ZZKW; + }else if (lx.equals("缓存库位")) { + lx = BaseStatus.HCKW; + } + point.setType(lx); + point.setBeatCode(data.getNs()); + point.setDescription(data.getBqlx()); + point.setItemCode(data.getItemCode()); + point.setZflx(data.getZflx()); + point.setBqlx(data.getBqlx()); + point.setGlzkw(data.getGlzkw()); + point.setInvMin(Integer.parseInt(data.getKcxx())); + pointRepository.save(point); + } + } + + /** + * 处理批量更新导入 + */ + private void importPointDataUpdate(List dataList,Map headersMap) { + // TODO: 实现批量导入逻辑 + log.info("处理批量导入,数据条数: {}", dataList.size()); + List pointList=pointRepository.findAll(); + Map pointCodeMap = new HashMap<>(); + Map pointIdMap = new HashMap<>(); + for(Point point:pointList){ + pointCodeMap.put(point.getCode(),point); + pointIdMap.put(point.getId(),point); + } + List areaList=areaRepository.findAll(); + Map areaCodeMap = new HashMap<>(); + Map areaIdMap = new HashMap<>(); + for(Area area:areaList){ + areaCodeMap.put(area.getCode(),area); + areaIdMap.put(area.getId(),area); + } + Map pointTypeMap = new HashMap<>(); + pointTypeMap.put("材管库位",BaseStatus.CH); + pointTypeMap.put("制造库位",BaseStatus.ZZKW); + pointTypeMap.put("缓存库位",BaseStatus.HCKW); + Map bqTypeMap = new HashMap<>(); + bqTypeMap.put("中大物标签","中大物标签"); + bqTypeMap.put("小物标签","小物标签"); + for (PointImport data : dataList) { + String code=data.getCode(); + String areaName=data.getAreaName(); + String type= data.getType(); + String kcxx= data.getKcxx(); + String itemCode= data.getItemCode(); + String ns= data.getNs(); + String bqlx= data.getBqlx(); + Point point = pointIdMap.get(data.getId()); + if(point==null){ + throw new BadRequestException("库位不存在"); + } + if(headersMap.containsKey("库位号")) { + Point point2 = pointCodeMap.get(code); + if(point2!=null){ + throw new BadRequestException(code+"库位已存在,不能重复更新"); + } + point.setCode(code); + } + if(headersMap.containsKey("库区")) { + Area area=areaCodeMap.get(areaName); + if(area==null){ + throw new BadRequestException("库区不存在"); + } + point.setArea(area); + } + if(headersMap.containsKey("存储类型")) { + if(!pointTypeMap.containsKey(type)){ + throw new BadRequestException("存储类型填写错误"); + } + point.setType(pointTypeMap.get(type)); + } + if(headersMap.containsKey("库存下限")) { + point.setInvMin(Integer.parseInt(kcxx)); + } + if(headersMap.containsKey("品番")) { + point.setItemCode(itemCode); + } + if(headersMap.containsKey("纳所")) { + point.setBeatCode(ns); + } + if(headersMap.containsKey("标签类型")) { + if(!bqTypeMap.containsKey(bqlx)){ + throw new BadRequestException("标签类型填写错误"); + } + point.setType(bqTypeMap.get(bqlx)); + } pointRepository.save(point); } } @@ -127,23 +244,13 @@ public class ImportPointServiceImpl implements ImportPointService { } //验证模板是否使用正确 - private void isValidTemplateType(MultipartFile file) { - // 根据模板类型进行不同的处理 - List requiredColumns = Arrays.asList( - "库位号", - "库区" -// "存储类型", -// "品番", -// "库存下限", -// "纳所", -// "标签类型" -// , -// "总分类型", -// "关联总库位" - ); + private List isValidTemplateType(MultipartFile file,List requiredColumns) { List headers = FastExcelUtil.readHeadContent(file, 0, 0); if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) { throw new BadRequestException("标准导入模板不正确,请确认模板信息"); } + return headers; } + + } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/inputJson/ZzkwMoveReq.java b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/ZzkwMoveReq.java new file mode 100644 index 0000000..ac575cd --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/ZzkwMoveReq.java @@ -0,0 +1,11 @@ +package com.youchain.businessdata.inputJson; + +import lombok.Data; + +@Data +public class ZzkwMoveReq {//制造库位移位入参 + String srcPointCode; + String dstPointCode; + double moveQty; + String type; +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/CountDetailImport.java b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/CountDetailImport.java new file mode 100644 index 0000000..a877c35 --- /dev/null +++ b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/CountDetailImport.java @@ -0,0 +1,31 @@ +package com.youchain.businessdata.inputJson.imports; + +import cn.idev.excel.annotation.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 基础导入 + * @author: youzhi.gao + * @date: 2020-04-01 15:01 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CountDetailImport { + @ExcelProperty("品番") + private String itemCode; + @ExcelProperty("箱单号") + private String stockCode; + @ExcelProperty("批次号") + private String pc; + @ExcelProperty("源库位") + private String srcPointCode; + @ExcelProperty("目标库位") + private String dstPointCode; + @ExcelProperty("税别") + private String bonded; +} diff --git a/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/PointImport.java b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/PointImport.java index 8f0df2d..abe4551 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/PointImport.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/inputJson/imports/PointImport.java @@ -16,6 +16,8 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class PointImport { + @ExcelProperty("序号") + private Long id; @ExcelProperty("库位号") private String code; diff --git a/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java b/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java index c9a066a..5ffaa83 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java @@ -56,9 +56,9 @@ public interface InventoryRepository extends JpaRepository, Jpa @Query(value = "SELECT * FROM data_inventory inv " + "left join base_point p on inv.point_id=p.id " + - " WHERE inv.quantity>0 and inv.area_id=?1" + - " and p.type='CH'" , nativeQuery = true) - List queryInventoryArea2(long areaId); + " WHERE inv.quantity>0 and inv.area_id=:areaId" + + " and p.type=:point_type" , nativeQuery = true) + List queryInventoryArea2(long areaId,String point_type); @Query(value = "SELECT * from data_inventory inv \n" + "left join base_point p on inv.point_id=p.id\n" + @@ -72,4 +72,16 @@ public interface InventoryRepository extends JpaRepository, Jpa "WHERE inv.quantity>0 and p.type='CH' and inv.stock_code=:stockCode and it.code=:itemCode" , nativeQuery = true) List queryInvStockItemCode(String stockCode,String itemCode); + @Query(value = "SELECT * FROM data_inventory inv " + + "left join base_point p on inv.point_id=p.id " + + " WHERE inv.quantity>0 " + + " and inv.point_id=:point_id and inv.item_key_id=:item_key_id and p.type=:point_type and inv.stock_code is null" , nativeQuery = true) + List queryInvPdNotXd(long point_id,Long item_key_id,String point_type); + + @Query(value = "SELECT * FROM data_inventory inv " + + "left join base_point p on inv.point_id=p.id " + + " WHERE inv.quantity>0 " + + " and inv.point_id=:point_id and inv.item_key_id=:item_key_id and p.type=:point_type and inv.stock_code=:stockCode" , nativeQuery = true) + List queryInvPdXd(long point_id,Long item_key_id,String point_type,String stockCode); + } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java b/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java index c91ffbb..ea457f7 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java @@ -30,4 +30,8 @@ import java.util.List; public interface ItemKeyRepository extends JpaRepository, JpaSpecificationExecutor { @Query(value = "SELECT * FROM data_item_key ik where ik.item_id =?1 and ik.prop_c1 =?2" , nativeQuery = true) List queryItemKey(Long item_id,String prop_c1); + @Query(value = "SELECT * FROM data_item_key ik where ik.item_id =:item_id and ik.prop_c1 =:prop_c1 and ik.prop_c2 =:bonded" , nativeQuery = true) + List getItemKeyPc(Long item_id,String prop_c1,String bonded); + @Query(value = "SELECT * FROM data_item_key ik where ik.item_id =:item_id and ik.prop_c2 =:bonded" , nativeQuery = true) + List getItemKeyNotPc(Long item_id,String bonded); } \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/CountMoveController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/CountMoveController.java index dc78628..612a235 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/CountMoveController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/CountMoveController.java @@ -151,8 +151,8 @@ public class CountMoveController { countMoveService.countCheck(countMove); } } - String sql="INSERT into data_inventory_count_bak(count_id,bill_code,item_key_id,point_id,quantity,queued_qty,be_lock,be_reject,`status`,dept_id,area_id,zzkw,bf_date) \n" + - "select "+countMove.getId()+",'"+countMove.getCode()+"',item_key_id,point_id,quantity,queued_qty,be_lock,be_reject,status,dept_id,area_id,zzkw,SYSDATE() from data_inventory inv where inv.quantity!=0"; + String sql="INSERT into data_inventory_count_bak(count_id,bill_code,item_key_id,stock_code,point_id,quantity,queued_qty,be_lock,be_reject,`status`,dept_id,area_id,zzkw,bf_date) \n" + + "select "+countMove.getId()+",'"+countMove.getCode()+"',item_key_id,stock_code,point_id,quantity,queued_qty,be_lock,be_reject,status,dept_id,area_id,zzkw,SYSDATE() from data_inventory inv where inv.quantity!=0"; Query query=entityManager.createNativeQuery(sql); query.executeUpdate(); countMove.setStatus(BizStatus.COUNT); 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 e7c5112..af6b62d 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 @@ -20,11 +20,14 @@ import com.youchain.annotation.AnonymousAccess; import com.youchain.annotation.Log; import com.youchain.appupdate.inputJson.ScanItemCode; import com.youchain.basicdata.domain.BomAccount; +import com.youchain.basicdata.domain.Item; import com.youchain.basicdata.domain.Point; import com.youchain.basicdata.repository.BomAccountRepository; +import com.youchain.basicdata.repository.ItemRepository; import com.youchain.basicdata.repository.PointRepository; import com.youchain.businessdata.domain.*; import com.youchain.businessdata.inputJson.XdMoveReq; +import com.youchain.businessdata.inputJson.ZzkwMoveReq; import com.youchain.businessdata.inputJson.buttenJson.InvYW; import com.youchain.businessdata.inputJson.buttenJson.InventoryButton; import com.youchain.businessdata.repository.InventoryRepository; @@ -38,6 +41,7 @@ import com.youchain.businessdata.service.dto.*; import com.youchain.businessdata.service.dto.jsonDto.CxjlDto; import com.youchain.exception.BadRequestException; import com.youchain.exception.handler.ApiResult; +import com.youchain.utils.BaseStatus; import com.youchain.utils.BillParmType; import com.youchain.utils.BizStatus; import lombok.extern.slf4j.Slf4j; @@ -52,6 +56,7 @@ import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -74,6 +79,7 @@ public class InventoryController { private final InventoryLogService inventoryLogService; private final TaskRepository taskRepository; private final PointRepository pointRepository; + private final ItemRepository itemRepository; private final BomAccountRepository bomAccountRepository; private final ItemKeyService itemKeyService; @@ -288,6 +294,108 @@ public class InventoryController { return new ResponseEntity<>("操作成功",HttpStatus.OK); } + @PostMapping("/zzkwMoveInvApp") + @Log("制造库位移位App") + @ApiOperation("制造库位移位App") + @PreAuthorize("@el.check('super:man')") + @AnonymousAccess + @DuplicateSubmission(5) + public ResponseEntity zzkwMoveInvApp(@RequestBody ZzkwMoveReq zzkwMoveReq) throws Exception { + String type=zzkwMoveReq.getType(); + String srcPointCode=zzkwMoveReq.getSrcPointCode(); + String dstPointCode=zzkwMoveReq.getDstPointCode(); + Point srcPoint=null; + Point dstPoint=null; + List bs=new ArrayList<>(); + if(srcPointCode==null||srcPointCode.equals("")){ + throw new BadRequestException("请扫描源库位"); + } + //解析二维码内容 + String[] srcStr=srcPointCode.split("]"); + if(srcStr.length>=3) {//固定库位标签 + String pointCode = srcStr[3]; + String bomItemCode=srcStr[0]; + String bonded=srcStr[2]; + srcPoint=pointRepository.findByCode(pointCode); + Item item=itemRepository.findByCode(bomItemCode); + bs=bomAccountRepository.queryEwmJx(item.getId(),srcPoint.getId(),bonded); + }else { + srcPoint=pointRepository.findByCode(srcPointCode); + } + if(dstPointCode!=null&&!dstPointCode.equals("")) { + String[] dstStr=dstPointCode.split("]"); + if(dstStr.length>=3) {//固定库位标签 + String pointCode = dstStr[3]; + String bomItemCode=dstStr[0]; + String bonded=dstStr[2]; + dstPoint=pointRepository.findByCode(pointCode); + Item item=itemRepository.findByCode(bomItemCode); + bs=bomAccountRepository.queryEwmJx(item.getId(),dstPoint.getId(),bonded); + }else { + dstPoint=pointRepository.findByCode(dstPointCode); + } + } + if(bs.size()>0) { + BomAccount bomAccount=bs.get(0); + CxjlDto cxjlDto=new CxjlDto(); + //查询BOM,寻找收容数 + cxjlDto.setRk_id(bomAccount.getRArea().getId()); + cxjlDto.setItem_id(bomAccount.getItem().getId()); + cxjlDto.setZzkw_id(bomAccount.getZPoint().getId()); + cxjlDto.setBonded(bomAccount.getBonded()); + cxjlDto.setArea_name(bomAccount.getRArea().getName()); + cxjlDto.setPoint_code(bomAccount.getZPoint().getCode()); + cxjlDto.setItem_name(bomAccount.getItem().getName()); + cxjlDto.setItem_code(bomAccount.getItem().getCode()); + if(!type.equals("zzkc_move")) { + return new ResponseEntity<>(cxjlDto, HttpStatus.OK); + } + }else{ + return new ResponseEntity<>("扫描成功", HttpStatus.OK); + } + if(type.equals("zzkc_move")) { + if(bs.size()<=0) { + throw new BadRequestException("源库位或目标库位为制造库位"); + } + if(srcPoint==null||dstPoint==null) { + throw new BadRequestException("请扫描库位"); + } + if(!srcPoint.getType().equals(BaseStatus.ZZKW)&&!srcPoint.getType().equals(BaseStatus.HCKW)&&(srcPoint.getArea().getName()).indexOf("盘点")<0) { + throw new BadRequestException(srcPoint.getCode()+"该功能仅限于制造库位或缓存库位或盘点库位"); + } + if(!dstPoint.getType().equals(BaseStatus.ZZKW)&&!dstPoint.getType().equals(BaseStatus.HCKW)&&(dstPoint.getArea().getName()).indexOf("盘点")<0) { + throw new BadRequestException(dstPoint.getCode()+"该功能仅限于制造库位或缓存库位或盘点库位"); + } + BomAccount bomAccount=bs.get(0); + Item item=bomAccount.getItem(); + double move_qty=zzkwMoveReq.getMoveQty(); + ItemKey itemKey = itemKeyService.getItemKey(item, null, bomAccount.getBonded()); + Inventory srcInventory = inventoryService.getInventory(itemKey, srcPoint.getArea(), srcPoint, srcPoint, srcPoint.getDept(), BizStatus.MOVE, null); + if(srcInventory==null){ + throw new BadRequestException(item.getCode()+"该库位无该批次库存"); + } + int invQty=(int)(srcInventory.getQuantity()- srcInventory.getQueuedQty()); + if(invQty("操作成功",HttpStatus.OK); + } + @PostMapping("/xdMoveInv") @Log("箱单移位") @ApiOperation("箱单移位") 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 756d296..c47a8da 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 @@ -226,6 +226,7 @@ public class PickDetailController { if(point==null||!point.getType().equals("ZZKW")){ throw new BadRequestException("制造库位错误"); } + List bomAccounts=bomAccountRepository.queryEwmJx(item.getId(),point.getId(),bonded); //查询BOM,寻找收容数 cxjldto.setRk_id(point.getArea().getId()); cxjldto.setItem_id(item.getId()); @@ -235,7 +236,10 @@ public class PickDetailController { cxjldto.setPoint_code(point.getCode()); cxjldto.setItem_name(item.getName()); cxjldto.setItem_code(item.getCode()); - cxjldto.setOrder_qty(item.getSrs()); + cxjldto.setOrder_qty(item.getExtendD3().intValue()); + if(bomAccounts.size()>0){ + cxjldto.setOrder_qty(bomAccounts.get(0).getSrs()); + } return new ResponseEntity<>(cxjldto,HttpStatus.OK); }else{ throw new BadRequestException("扫描错误"); @@ -345,7 +349,7 @@ public class PickDetailController { } JSONArray array=new JSONArray(); //查询是否有Task或者库存 - List tasks=taskRepository.getPickDetailTasks(pickDetail.getId()); + List tasks=taskRepository.getPickNotAllTask(pickDetail.getId()); String view_type="01"; String view_des="无库存"; String view_name="箱单号"; diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/CountMoveDetailDto.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/CountMoveDetailDto.java index 8cd38ff..a084d9f 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/CountMoveDetailDto.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/CountMoveDetailDto.java @@ -62,7 +62,7 @@ public class CountMoveDetailDto implements Serializable { /** 修改人 */ private String updateBy; - private String src_stock_code; + private String srcStockCode; /** 创建时间 */ private Timestamp createTime; diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/XppRecordViewDto.java b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/XppRecordViewDto.java index 15ece17..5c14ea0 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/dto/XppRecordViewDto.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/dto/XppRecordViewDto.java @@ -128,7 +128,7 @@ public class XppRecordViewDto implements Serializable { */ private String jsr; /** - * 制造投料人 + * 人 */ private String zztlr; diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/CountMoveServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/CountMoveServiceImpl.java index 722b220..1fd769b 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/CountMoveServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/CountMoveServiceImpl.java @@ -120,18 +120,18 @@ public class CountMoveServiceImpl implements CountMoveService { List inventoryList=inventoryRepository.queryInventoryArea(countMove.getSrcArea().getId()); for(Inventory inv:inventoryList) { ItemKey itemKey = inv.getItemKey(); - if(inv.getStockCode()==null) {//非箱单库存根据纳入数调整库存数 - int nrs = xppRecordRepository.queryXppItemKeyPointNrs(itemKey.getId(), inv.getPoint().getId()); - if (inv.getQueuedQty() > 0) { - throw new BadRequestException(itemKey.getItem().getCode() + "包含占用数"); - } - if (inv.getQuantity().intValue() != nrs) { - inventoryLogService.storeInventoryLog(BizStatus.COUNT_MOVE, BizStatus.INVARIANT, countMove.getCode(), countMove.getDstArea(), itemKey, inv.getPoint(), inv.getPoint(), null, inv.getQuantity() + 0d, nrs + 0d, null, - BizStatus.COUNT, null, inv.getId(), "调整库存数量,和现品票匹配"); - inv.setQuantity(nrs + 0d); - inventoryService.update(inv); - } - } +// if(inv.getStockCode()==null) {//非箱单库存根据纳入数调整库存数 +// int nrs = xppRecordRepository.queryXppItemKeyPointNrs(itemKey.getId(), inv.getPoint().getId()); +// if (inv.getQueuedQty() > 0) { +// throw new BadRequestException(itemKey.getItem().getCode() + "包含占用数"); +// } +// if (inv.getQuantity().intValue() != nrs) { +// inventoryLogService.storeInventoryLog(BizStatus.COUNT_MOVE, BizStatus.INVARIANT, countMove.getCode(), countMove.getDstArea(), itemKey, inv.getPoint(), inv.getPoint(), null, inv.getQuantity() + 0d, nrs + 0d, null, +// BizStatus.COUNT, null, inv.getId(), "调整库存数量,和现品票匹配"); +// inv.setQuantity(nrs + 0d); +// inventoryService.update(inv); +// } +// } createCountDetail(countMove,inv,itemKey,countMove.getDstPoint()); } @@ -147,7 +147,7 @@ public class CountMoveServiceImpl implements CountMoveService { countMoveDetail.setSrcPoint(inv.getPoint()); countMoveDetail.setOrderQty(inv.getQuantity()); countMoveDetail.setCountQty(0d); - countMoveDetail.setSrcStockCode(inv.getStockCode()); + countMoveDetail.setSrcStockCode(inv.getStockCode());//箱单号 countMoveDetail.setDstPoint(dstPoint); countMoveDetailService.create(countMoveDetail); countMove.setOrderQty(countMove.getOrderQty()+inv.getQuantity()); @@ -217,7 +217,11 @@ public class CountMoveServiceImpl implements CountMoveService { log.info("countMoveDetailList:"+countMoveDetailObjs.size()); //得到盘点库区下所有库存 - List inventoryListAll=inventoryRepository.queryInventoryArea2(countMove.getSrcArea().getId()); + String point_type=BaseStatus.CH; + if(countMove.getSrcArea().getBexb()){ + point_type=BaseStatus.ZZKW; + } + List inventoryListAll=inventoryRepository.queryInventoryArea2(countMove.getSrcArea().getId(),point_type); log.info("inventoryListAll:"+inventoryListAll.size()); Map> map_inventory=new HashMap<>(); for (Inventory inv :inventoryListAll ) { @@ -239,7 +243,10 @@ public class CountMoveServiceImpl implements CountMoveService { log.info("map_inventory:"+map_inventory.keySet().size()); log.info("xppRecordListAll:"); - List xppRecordListAll = xppRecordRepository.queryXppItemKeyPoint2(); + List xppRecordListAll = new ArrayList<>(); + if(!countMove.getSrcArea().getBexb()) { + xppRecordRepository.queryXppItemKeyPoint2(); + } Map> map_xppRecord=new HashMap<>(); log.info("xppRecordListAll:"+xppRecordListAll.size()); for (XppRecord xpp :xppRecordListAll ) { @@ -312,8 +319,11 @@ public class CountMoveServiceImpl implements CountMoveService { inventoryService.update(newInv); inv.setQuantity(inv.getQuantity() - xpp.getNrs()); inventoryService.update(inv); + countMove.setCountQty(countMove.getCountQty()+d.getCountQty()); } }else{ + d.setCountQty(d.getCountQty() + d.getOrderQty()); + countMoveDetailService.update(d); createCountMoveDetailRecord(countMove,d,null); //查找目标库位是否有库存,有则数量累加,没有新建 Inventory newInv = inventoryService.getInventory(itemKey, d.getDstPoint().getArea(), d.getDstPoint(), inv.getZzkw(), dept, BizStatus.COUNT_MOVE, d.getSrcStockCode()); @@ -357,12 +367,15 @@ public class CountMoveServiceImpl implements CountMoveService { countMoveDetailRecord.setXppEwm(xpp.getEwm()); countMoveDetailRecord.setCountQty(xpp.getNrs() + 0d); countMoveDetailRecord.setXpp(xpp); + }else{ + countMoveDetailRecord.setCountQty(d.getCountQty()); } countMoveDetailRecord.setSrcPoint(d.getSrcPoint()); countMoveDetailRecord.setCountPoint(d.getDstPoint()); countMoveDetailRecord.setItemKey(d.getItemKey()); countMoveDetailRecord.setStatus(BizStatus.OPEN); countMoveDetailRecord.setSrcStockCode(d.getSrcStockCode()); + countMove.setCountQty(countMove.getCountQty()+countMoveDetailRecord.getCountQty()); return countMoveDetailRecordService.create(countMoveDetailRecord); } } \ No newline at end of file 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 5b3dedb..4b91f2e 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 @@ -178,11 +178,10 @@ public class InventoryServiceImpl implements InventoryService { hql += " and inv.stockCode is null"; } } - if(propC2!=null){ hql+=" and inv.itemKey.propC2='"+propC2+"'"; } - + hql+=" and inv.area.code not like '%盘点%'"; hql+= " order by inv.itemKey.propC1 asc,inv.stockCode asc "; Query query = entityManager.createQuery(hql); List inventoryList = query.getResultList(); @@ -365,7 +364,7 @@ public class InventoryServiceImpl implements InventoryService { inventory = inventoryList.get(0); } else { //创建Inventory - if (type.equals(BizStatus.ZZKW_TL) ||type.equals(BizStatus.RECEIVING_UP) || type.equals(BizStatus.MOVE)||type.equals(BizStatus.PICK_DOWN)||type.equals(BizStatus.PICK_CANCEL)||type.equals(BizStatus.SL_ALL)||type.equals(BizStatus.COUNT_MOVE)||type.equals(BizStatus.YK_JS)) { + if (type.equals(BizStatus.ZZKW_MOVE) ||type.equals(BizStatus.ZZKW_TL) ||type.equals(BizStatus.RECEIVING_UP) || type.equals(BizStatus.MOVE)||type.equals(BizStatus.PICK_DOWN)||type.equals(BizStatus.PICK_CANCEL)||type.equals(BizStatus.SL_ALL)||type.equals(BizStatus.COUNT_MOVE)||type.equals(BizStatus.YK_JS)) { inventory = new Inventory(); inventory.setItemKey(itemKey); inventory.setPoint(point); diff --git a/youchain-system/src/main/java/com/youchain/utils/BizStatus.java b/youchain-system/src/main/java/com/youchain/utils/BizStatus.java index 416d2d6..af81fb1 100644 --- a/youchain-system/src/main/java/com/youchain/utils/BizStatus.java +++ b/youchain-system/src/main/java/com/youchain/utils/BizStatus.java @@ -247,6 +247,11 @@ public class BizStatus { */ public static String ZZKW_TL = "ZZKW_TL"; + /** + * 制造库位移位 + */ + public static String ZZKW_MOVE = "ZZKW_MOVE"; + /** * 制造库位入库 */ diff --git a/youchain-system/src/main/java/com/youchain/utils/FastExcelUtil.java b/youchain-system/src/main/java/com/youchain/utils/FastExcelUtil.java index 9bb5b81..75303cc 100644 --- a/youchain-system/src/main/java/com/youchain/utils/FastExcelUtil.java +++ b/youchain-system/src/main/java/com/youchain/utils/FastExcelUtil.java @@ -238,6 +238,7 @@ public class FastExcelUtil { public static List readHeadContent(MultipartFile file, int sheetNo, int headRowNumber) { try { //判断头部内容是否包含所有必填列 + log.info(file.getInputStream()+""); return readHeadContent(file.getInputStream(), sheetNo, headRowNumber); } catch (IOException e) { throw new BadRequestException("数据格式存在问题,无法读取");