Beispiel #1
0
        // 根据 BookItem 对象构造一个 LogicChipItem 对象
        public static LogicChipItem BuildChip(BookItem book_item)
        {
            if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "3.11") < 0)
            {
                throw new Exception("当前连接的 dp2library 必须为 3.11 或以上版本,才能使用 RFID 有关功能");
            }

            LogicChipItem result = new LogicChipItem();

            result.AFI   = LogicChipItem.DefaultBookAFI;
            result.DSFID = LogicChipItem.DefaultDSFID;
            result.EAS   = LogicChipItem.DefaultBookEAS;

            // barcode --> PII
            result.NewElement(ElementOID.PII, book_item.Barcode);

            // location --> OwnerInstitution 要配置映射关系
            // 定义一系列前缀对应的 ISIL 编码。如果 location 和前缀前方一致比对成功,则得到 ISIL 编码
            MainForm.GetOwnerInstitution(
                Program.MainForm.RfidCfgDom,
                StringUtil.GetPureLocation(book_item.Location),
                out string isil,
                out string alternative);
            if (string.IsNullOrEmpty(isil) == false)
            {
                result.NewElement(ElementOID.OwnerInstitution, isil);
            }
            else if (string.IsNullOrEmpty(alternative) == false)
            {
                result.NewElement(ElementOID.AlternativeOwnerInstitution, alternative);
            }

            // SetInformation?
            // 可以考虑用 volume 元素映射过来。假设 volume 元素内容符合 (xx,xx) 格式
            string value = MainForm.GetSetInformation(book_item.Volume);

            if (value != null)
            {
                result.NewElement(ElementOID.SetInformation, value);
            }

            // TypeOfUsage?
            // (十六进制两位数字)
            // 10 一般流通馆藏
            // 20 非流通馆藏。保存本库? 加工中?
            // 70 被剔旧的馆藏。和 state 元素应该有某种对应关系,比如“注销”
            {
                string typeOfUsage = "";
                if (StringUtil.IsInList("注销", book_item.State) == true ||
                    StringUtil.IsInList("丢失", book_item.State) == true)
                {
                    typeOfUsage = "70";
                }
                else if (string.IsNullOrEmpty(book_item.State) == false &&
                         StringUtil.IsInList("加工中", book_item.State) == true)
                {
                    typeOfUsage = "20";
                }
                else
                {
                    typeOfUsage = "10";
                }

                result.NewElement(ElementOID.TypeOfUsage, typeOfUsage);
            }

            // AccessNo --> ShelfLocation
            // 注意去掉 {ns} 部分
            result.NewElement(ElementOID.ShelfLocation,
                              StringUtil.GetPlainTextCallNumber(book_item.AccessNo)
                              );

            return(result);
        }