简体   繁体   English

条码范围的数据库设计

[英]Database design for barcode ranges

I'm working on a shipping system for our warehouse. 我正在为我们的仓库开发运输系统。 Basically what I'm trying to accomplish is, taking a number from a barcode range, and assigning it to a shipping order. 基本上,我要完成的工作是从条形码范围中提取一个数字,并将其分配给运输订单。

The ranges are given by our partner couriers periodically and they are usually not consecutive, eg 9000000-9009999 , 9020000-9029999 . 范围是由我们的合作伙伴信使定期给予他们通常不是连续的,如9000000-90099999020000-9029999 Each number in a range should be used only once. 范围内的每个数字只能使用一次。

Currently the range is hardcoded in the script and the current index is stored in a file. 当前范围在脚本中进行了硬编码,当前索引存储在文件中。 (legacy implementation) (旧版实施)

But I feel it's proper to have an interface where even non-programmers can manage ranges, monitor the status of each range (eg which one is currently “active”, what's the current index, etc). 但是我觉得有一个接口,即使非程序员也可以管理范围,监视每个范围的状态(例如,哪个当前处于“活动状态”,当前索引是什么,等等),这是适当的。 And when the current range runs out, it should automatically switch to the next range available. 当当前范围用完时,它应自动切换到下一个可用范围。 Below is the UI design I came up with. 以下是我想到的UI设计。 条码范围管理界面

Do you think it's a good idea to store the range data in the database? 您认为将范围数据存储在数据库中是个好主意吗? If so, how should I design the database table? 如果是这样,我应该如何设计数据库表?

Some other things to be taken into considerations are: 需要考虑的其他一些事项是:

  • Some ranges are recycled by the courier, so there is a chance we receive the same range twice. 某些范围是由快递公司回收的,因此我们有可能两次收到相同的范围。 (Well, maybe some years later) (好吧,也许几年后)
  • Most of the time a range can last 4 months to 6 months, so there won't be many ranges. 在大多数情况下,范围可以持续4个月到6个月,因此不会有很多范围。 (If we use a table to store the ranges, we're looking at 2 to 4 new range records a year) (如果我们使用表格来存储范围,则我们每年要查看2到4个新的范围记录)
  • When a range is finished, it's basically useless? 范围结束后,基本上就没用了吗?

I believe you need to take a higher-level view of matters. 我相信您需要对事务有一个更高层次的了解。

Key is the GS1 system, previously known as EAN (which I use as I've used it for 20+ years.) 关键是GS1系统,以前称为EAN(我使用它已有20多年的历史了。)

Important issue is that you should not allow YOUR shipment number to be dictated by an outside agency. 重要的问题是您不应让您的货件号码由外部机构决定。 If you decide to keep shipment details for 7 years say, and they decide to recycle numbers after 3, then you have a data problem. 如果您说要保留7年的装运详细信息,而他们决定在3年后回收编号,那么您将遇到数据问题。 Equally, if you have more than one shipping agency (or take another on in the future, of the existing agency gets split into parts or sold or whatever) then again you can get a data problem when THEIR system changes. 同样,如果您拥有多个货运代理公司(或在将来承办另一家货运代理公司,或者现有的货运代理公司被拆分成部分或出售或以其他方式出售),那么在THEIR系统发生变更时,您仍然会遇到数据问题。

(and that applies to ALL data not directly controlled by your organisation) (并且适用于您的组织未直接控制的所有数据)

The EAN way is by using a SSCC - Serial Shipping Container Code. EAN方式是通过使用SSCC-串行运输容器代码。 This is an 18-digit code assigned to an object and uniquely identifies that object. 这是分配给对象的18位代码,可唯一标识该对象。 It has a nominal life of three years, so it should not be re-issued more frequently. 它的标称寿命为三年,因此不应更频繁地重新发行。

The SSCC is produced according to an internationally-recognised structure and encoded in a "code 128" barcode (hence it is often referred to as GS1-128 or EAN-128) which has a lead character of [fnc1] - internationally accepted to signify "This is a barcode following the EAN-128 format". SSCC是根据国际公认的结构生产的,并编码为“ code 128”条形码(因此通常称为GS1-128或EAN-128),其条形码特征为[fnc1]-国际上公认的表示“这是遵循EAN-128格式的条形码”。 The remaining characters are: 其余字符为:

00 - AI for an SSCC (there is a whole slough of codes for various uses. "00" means "SSCC". It is actually an Application Identifier - though even barcode-printer manufacturers have been known to believe it forms part of a "20-digit code". 00 -SSCC的AI(有多种用途的代码。“ 00”表示“ SSCC”。它实际上是一个应用程序标识符 -尽管甚至连条形码打印机制造商都认为它构成了“ 20位代码”。

1 digit - In former times, "3" was an "internal pallet" and "4" and "external pallet". 1 digit -以前,“ 3”是“内部托盘”,“ 4”是“外部托盘”。 Since the one often became the other, this system was quickly abandoned, but the legend persists - some will incorrectly insist that the leading digit must be a "3". 由于一个人经常成为另一个人,因此该系统很快就被放弃了,但传说仍然存在-有些人会错误地坚持认为前导数字必须为“ 3”。

7-9 digits - country code + organisation code. 7-9 digits -国家代码+组织代码。 Allotted by the controlling organisation and licensed to the using member organisation. 由控制组织分配并许可给使用成员组织。

9-7 digits - individual shipment number issued by the using member organisation. 9-7 digits -使用会员组织发布的个人发货编号。

1 digit - check digit produced according to the published algorithm and usually calculated by the printer firmware. 1 digit -根据发布的算法产生的校验数字,通常由打印机固件计算得出。

So the first and penultimate group of digits are allocated by the GS1-member organisation (ie your organisation) at their own discretion. 因此,GS1成员组织(即您的组织)会自行决定分配第一和倒数第二组数字。

This system can be used for shipping your goods outside of your organisation and also for tracking the goods within your organisation. 该系统可用于货物运送到组织外部,也可用于跟踪组织内部的货物。

In all probability, your shipper has allotted a subset of their numbers to you as they commonly do with small organisations that are not GS1 members. 在所有的可能性,你的托运人分配它们的数量的一个子集给你,因为他们通常与不属于GS1成员小企业做的。 Unfortunately, the clerks performing this task prefer to treat all of their customers the same way, so the legend arises that you have to use their system. 不幸的是,执行此任务的店员更喜欢以相同的方式对待所有客户,因此,传说您必须使用他们的系统。 If this idea has taken root in the fertile minds of their IT monkeys, they may have set their system up on that assumption. 如果这个想法扎根在他们的 IT猴子的肥沃头脑中,那么他们可能已经在这种假设下建立了自己的系统。

If their IT system has been set up by a professional, then they will be able to accept any complying SSCC - you simply send then your list of shipments issued with your numbers and their software will validate it against the label produced by your printer when the goods are picked up. 如果他们的 IT系统是由专业人员建立的,那么他们将能够接受任何符合规定的SSCC-您只需发送,然后将发出附有您的编号的货件清单,他们的软件将打印机打印时根据您的打印机产生的标签对它进行验证。提货。

You'd really need to talk to their IT department on what their requirements are. 您确实需要与他们的IT部门讨论他们的要求。

This would mean that you simply don't need to use their number at all - you can use the system as it was designed, using your numbers over which you have control. 这意味着,你根本不需要在所有使用它们的数量-您可以使用该系统,因为它的设计,使用你的号码了, 有控制权。

If non-adjacent ranges belong to the same Entity, then one table would have Entities, including an entity_id . 如果不相邻的范围属于同一个Entity,则一个表将具有Entities,其中包括entity_id The other table would contain barcode ranges (start and end), plus the entity_id . 另一个表将包含条形码范围(开始和结束),以及entity_id

You would need code to verify that you don't create overlapping ranges. 您将需要代码来验证您没有创建重叠范围。 And to deal with deleting a sub-range. 并处理删除子范围。

If you expect to have millions of ranges, then I suggest you adapt my IP-address blocks code. 如果您希望拥有数百万个范围,那么建议您改写我的IP地址块代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM