public List<ItemIndexDTO> toInOutRecordDTO(InventoryCheckDTO inventoryCheckDTO) { List<ItemIndexDTO> itemIndexDTOList = new ArrayList<ItemIndexDTO>(); if (inventoryCheckDTO.getMergeInOutRecordFlag()) { if (NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount()) > 0) { ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO); itemIndexDTO.setItemType(ItemTypes.OUT); itemIndexDTO.setInOutRecordId(this.getId()); itemIndexDTO.setItemCount( NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount())); itemIndexDTO.setUnit(this.getSellUnit()); itemIndexDTOList.add(itemIndexDTO); } else if (NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount()) < 0) { ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO); itemIndexDTO.setItemType(ItemTypes.IN); itemIndexDTO.setInOutRecordId(this.getId()); itemIndexDTO.setItemCount( NumberUtil.round(this.getActualInventoryAmount() - this.getInventoryAmount(), 1)); itemIndexDTO.setUnit(this.getSellUnit()); itemIndexDTOList.add(itemIndexDTO); } } else { if (!ArrayUtils.isEmpty(this.getOutStorageRelationDTOs())) { for (OutStorageRelationDTO outStorageRelationDTO : getOutStorageRelationDTOs()) { ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO); itemIndexDTO.setItemType(ItemTypes.OUT); itemIndexDTO.setInOutRecordId(outStorageRelationDTO.getId()); itemIndexDTO.setRelatedSupplierId(outStorageRelationDTO.getRelatedSupplierId()); itemIndexDTO.setRelatedSupplierName(outStorageRelationDTO.getRelatedSupplierName()); itemIndexDTO.setItemCount(outStorageRelationDTO.getSupplierRelatedAmount()); itemIndexDTO.setUnit(outStorageRelationDTO.getOutStorageUnit()); itemIndexDTOList.add(itemIndexDTO); } } if (!ArrayUtils.isEmpty(this.getInStorageRecordDTOs())) { for (InStorageRecordDTO inStorageRecordDTO : getInStorageRecordDTOs()) { ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO); itemIndexDTO.setItemType(ItemTypes.IN); itemIndexDTO.setInOutRecordId(inStorageRecordDTO.getId()); itemIndexDTO.setRelatedSupplierId(inStorageRecordDTO.getSupplierId()); itemIndexDTO.setRelatedSupplierName(inStorageRecordDTO.getSupplierName()); itemIndexDTO.setItemCount(inStorageRecordDTO.getSupplierRelatedAmount()); itemIndexDTO.setUnit(inStorageRecordDTO.getInStorageUnit()); itemIndexDTOList.add(itemIndexDTO); } } } return itemIndexDTOList; }