dp2 icon indicating copy to clipboard operation
dp2 copied to clipboard

某用户老系统数据格式

Open renyh opened this issue 6 years ago • 5 comments

用户1原来系统的数据格式

数据样例1,有多个复本

  |   | 00790oam2_2200229___450_¶
-- | -- | --
001 |   | guanbarteam¶
005 |   | 20100831200056.3¶
010 | __ | ‡a7-105-03351-7 ‡b平装 ‡dCNY0.00¶
100 | __ | ‡a00010101d________em_y0chiy0121____ea¶
101 | 0_ | ‡achi ‡cchi¶
102 | __ | ‡aCN ‡bCN110000 ‡2GB2260¶
106 | __ | ‡ar¶
200 | 1_ | ‡a上帝的指纹(上):获得真实预言的途径:在远古找到未来 ‡9shang di de zhi wen ( shang ) : huo de zhen shi yu yan  de tu jing : zai yuan gu zhao dao wei lai ‡b专著 ‡e ‡f(英国)葛瑞姆·汉卡克著 ‡g ‡h ‡i¶
210 | __ | ‡a北京 ‡c民族出版社 ‡d1999.1¶
215 | __ | ‡a1-371页 ‡d¶
330 | __ | ‡a¶
225 | __ | ‡a世界伟大考古纪实报告¶
606 | 0_ | ‡a ‡2ct¶
690 | __ | ‡aK86 ‡v¶
701 | _0 | ‡a(英国)葛瑞姆·汉卡克 ‡4著¶
801 | _0 | ‡aCN ‡bLZJ ‡c20100831¶
905 | __ | ‡a1 ‡bT002267 ‡c0 ‡dK86 ‡e1 ‡f2 ‡sK86/1:0 ‡a1 ‡bT002269 ‡c0 ‡dK86 ‡e1 ‡f2 ‡sK86/1:0¶

数据样例2,只有1册的情况

  |   | 00676oam2_2200241___450_¶
-- | -- | --
001 |   | guanbarteam¶
005 |   | 20100831200056.2¶
010 | __ | ‡a7-80005-427-6 ‡b平装 ‡dCNY12.50¶
100 | __ | ‡a00010101d________em_y0chiy0121____ea¶
101 | 0_ | ‡achi ‡cchi¶
102 | __ | ‡aCN ‡bCN110000 ‡2GB2260¶
106 | __ | ‡ar¶
200 | 1_ | ‡a自由的音乐之神贝多芬 ‡9zi you de yin yue zhi shen bei duo fen ‡b专著 ‡e ‡f秦子超,白楠编著 ‡g ‡h ‡i¶
210 | __ | ‡a北京 ‡c新世界出版社 ‡d1998.1¶
215 | __ | ‡a278页 ‡d¶
330 | __ | ‡a¶
225 | __ | ‡a音乐家传记丛书¶
606 | 0_ | ‡a ‡2ct¶
690 | __ | ‡aK835.46 ‡v¶
701 | _0 | ‡a秦子超 ‡4编著¶
701 | _0 | ‡a白楠 ‡4编著¶
801 | _0 | ‡aCN ‡bLZJ ‡c20100831¶
905 | __ | ‡a1 ‡bT002034 ‡c0 ‡dK835.46 ‡e2 ‡f1 ‡sK835.46/2:0

renyh avatar Mar 26 '19 06:03 renyh

典藏信息

目前观察来源marc数据,典藏信息是放在905字段的。 905 | __ | ‡a1 ‡bT002267 ‡c0 ‡dK86 ‡e1 ‡f2 ‡sK86/1:0 ‡a1 ‡bT002269 ‡c0 ‡dK86 ‡e1 ‡f2 ‡sK86/1:0¶

册信息字段名 MARC字段 册信息元素名 备注
? 905$a
册条码 905$b barcode 如 T002034
905$c -
索取号 905$d/905$e accessNo -
905$f -
索取号(带校验位) 905$s 如K835.46/2:0
馆藏地点
册类型 原系统没有册类型之类,目前导入统一使用 普通
册价格 原系统没有册价格,目前导入用书目价格作为册价格

当有多个复本时,905子字段重复出现。

renyh avatar Mar 26 '19 06:03 renyh



/*
 * 本方案用于将 UNIMARC 格式 ISO2709 文件转换为 书目转储文件(*.bdf)
 * *** 册信息根据 905 字段产生 ***
 * 
 * 册信息字段名  MARC字段  册信息元素名  备注
 * 册条码        905$b      barcode  
 * 索取号      905$d/905$e  accessNo 
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Diagnostics;

using DigitalPlatform.Xml;
using DigitalPlatform.Marc;
using dp2Circulation;
using DigitalPlatform.Text;
using DigitalPlatform.Script;
using DigitalPlatform;
public class School41 : Iso2709Statis
{
    // bdf文件writer
    XmlTextWriter writer = null;

    string m_strBiblioSyntax = "unimarc";

    long m_lErrorCount = 0;
    long lTotalRecord = 0;

    string m_strLocation = "";  // 馆藏地
    string m_strBookType = ""; // 册类型
    string m_batchNo = "";//册批处理号

    // 开始阶段
    public override void OnBegin(object sender, StatisEventArgs e)
    {
        this.ClearConsoleForPureTextOutputing();

        this.m_strLocation = "图书馆"; // 如果来源数据中没有馆藏地,按这个默认值设置
        this.m_strBookType = "普通"; // 如果来源数据中没有册类型,按这个默认值设置
        this.m_batchNo = "数据导入"+ DateTime.Now.ToString("yyyyMMdd");

        // 选择保存到哪个文件
        SaveFileDialog dlg = new SaveFileDialog()
        {
            Title = "书目转储文件名",
            Filter = "书目转储文件(*.bdf)|*.bdf",
            RestoreDirectory = true
        };
        if (dlg.ShowDialog(this.Iso2709StatisForm) != DialogResult.OK)
        {
            e.Continue = ContinueType.SkipAll;
            return;
        }
        writer = new XmlTextWriter(dlg.FileName, Encoding.UTF8)
        {
            Formatting = Formatting.Indented,
            Indentation = 4
        };
        writer.WriteStartDocument();
        writer.WriteStartElement("dprms", "collection", DpNs.dprms);
        writer.WriteAttributeString("xmlns", "dprms", null, DpNs.dprms);

        // 设操作历史属性页为活动状态
        this.MainForm.ActivateFixPage("history");

    }


    // 处理每一条记录
    public override void OnRecord(object sender, StatisEventArgs e)
    {
        this.lTotalRecord++;
        string strError = "";

        MarcRecord record = new MarcRecord(this.MARC);


        // 转换为XML
        XmlDocument domMarc = null;
        int nRet = MarcUtil.Marc2Xml(this.MARC,
            this.m_strBiblioSyntax,
            out domMarc,
            out strError);
        if (nRet == -1)
        {
            this.m_lErrorCount++;
            return;
        }

        writer.WriteStartElement("dprms", "record", DpNs.dprms);
        writer.WriteStartElement("dprms", "biblio", DpNs.dprms);
        domMarc.WriteTo(writer);
        writer.WriteEndElement(); // end biblio


        string strISBN = record.select("field[@name='010']/subfield[@name='a']").FirstContent;
        strISBN = string.IsNullOrEmpty(strISBN) ? "\t" : strISBN;

        string strTitle = record.select("field[@name='200']/subfield[@name='a']").FirstContent;
        strTitle = string.IsNullOrEmpty(strTitle) ? "\t" : strTitle;

        string strSummary = strISBN + "\t" + strTitle;



        // *** 从010$d中取得价格
        string strErrorPrice = "";
        string strCataPrice = record.select("field[@name='010']/subfield[@name='d']").FirstContent;
        if (string.IsNullOrEmpty(strCataPrice))
        {
            strError=this.CurrentRecordIndex + "\t" + strSummary + "\t价格字符串 '" + strCataPrice + "' 为空";
            strCataPrice = "CNY0";
        }
        else
        {
            List<string> temp = ItemSearchForm.VerifyPrice(strCataPrice);
            if (temp.Count > 0)
            {
                // (全10册) 转为除法形态
                string strOldPrice = strCataPrice;
                ItemClassStatisDialog.CorrectPrice(ref strCataPrice);
                if (strOldPrice != strCataPrice)
                {
                    if (ItemSearchForm.IsPriceCorrect(strCataPrice) == true)
                        strError = this.CurrentRecordIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 被自动修改为 '" + strCataPrice + "'";
                    else
                    {
                        strCataPrice = "CNY0";
                        strErrorPrice = strOldPrice;
                        strError = this.CurrentRecordIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 无法被自动修改,默认为 CNY0";
                    }
                }
                else
                {
                    strCataPrice = "CNY0";
                    strErrorPrice = strOldPrice;
                    strError = this.CurrentRecordIndex + "\t" + strSummary + "\t价格字符串 '" + strOldPrice + "' 无法被自动修改,默认为 CNY0";
                }
            }

            strCataPrice = strCataPrice.Trim();
            if (strCataPrice == "CNY")
                strCataPrice = "CNY0";
            strCataPrice = strCataPrice.Replace("元", "").Replace(" ", "");
            if (!strCataPrice.StartsWith("CNY"))
            {
                strCataPrice = "CNY" + strCataPrice;
            }
        }
        if (string.IsNullOrEmpty(strError) == false)
        {
            OperHistoryAppendHtml(strError);
        }


        // 没有册信息
        MarcNodeList nodes = record.select("field[@name='905']/subfield[@name='b']");
        if (nodes.count <= 0)
        {
            writer.WriteEndElement(); // end record

            strError = this.CurrentRecordIndex + "\t" + strSummary + "\t 没有 905$a 子字段";
            this.m_lErrorCount++;
            OperHistoryAppendHtml(strError);
            return;
        }

        int index = 0;
        writer.WriteStartElement("dprms", "itemCollection", DpNs.dprms);
        foreach (MarcNode node in nodes)
        {
            MarcNode parent = node.Parent;

            string strBarcode = node.Content;
            // 册条码号为空,则不创建册信息元素
            if (string.IsNullOrEmpty(strBarcode))
            {
                strError = this.CurrentRecordIndex + "\t" + strSummary + "\t第 " + index + " 个 985 不含有 $a 子字段内容";
                this.m_lErrorCount++;
                continue;
            }

            writer.WriteStartElement("dprms", "item", DpNs.dprms);
            strBarcode = strBarcode.Trim();
            writer.WriteElementString("barcode", strBarcode);



            string str905d = "";           
            MarcNodeList subfields = parent.select("subfield[@name='d']");
            if (subfields.count > index)
            {
                str905d = subfields[index].Content;
            }
            if (String.IsNullOrEmpty(str905d) == true)
            {
                strError = this.CurrentRecordIndex + "\t" + strSummary + "\t905字段不存在第"+index+"个$d子字段";
                this.m_lErrorCount++;
            }

            string str905e = "";
            subfields = parent.select("subfield[@name='e']");
            if (subfields.count > index)
            {
                str905e = subfields[index].Content;
            }
            if (String.IsNullOrEmpty(str905e) == true)
            {
                strError = this.CurrentRecordIndex + "\t" + strSummary + "\t905字段不存在第" + index + "个$e子字段";
                this.m_lErrorCount++;
            }


            // *** 从905$d$e取得索书号
            if (!string.IsNullOrEmpty(str905d) && !string.IsNullOrEmpty(str905e))
                writer.WriteElementString("accessNo", str905d + "/" + str905e);
            else
            {
                strError = this.CurrentRecordIndex + "\t" + strSummary + "\t册记录'" + strBarcode + "'不含有 索取号 内容";
                this.m_lErrorCount++;
            }

            // 价格
            if (!string.IsNullOrEmpty(strCataPrice))
                writer.WriteElementString("price", strCataPrice);

            // 图书类型
            if (!string.IsNullOrEmpty(this.m_strBookType))
                writer.WriteElementString("bookType", this.m_strBookType);

            // 馆藏地
            if (!string.IsNullOrEmpty(this.m_strBookType))
                writer.WriteElementString("location", this.m_strLocation);

            // 批次号
            writer.WriteElementString("batchNo", this.m_batchNo);

            writer.WriteEndElement();

            index++;
        }

        // 元素收尾
        writer.WriteEndElement();


        writer.WriteEndElement();
    }


    // 将信息输出的操作历史
    void OperHistoryAppendHtml(string s)
    {
        this.MainForm.OperHistory.AppendHtml("<div class='debug'><div class='error'>" + s + "</div></div>");
    }

    // 结束阶段
    public override void OnEnd(object sender, StatisEventArgs e)
    {
        string strMSG = "共处理'" + this.lTotalRecord + "'条数据";
        OperHistoryAppendHtml(strMSG);

        if (this.writer != null)
        {
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
            writer = null;
        }

        string strMsg = "数据转换处理结束。请使用【批处理】-【从书目转储文件导入】功能将转换的 书目转储文件 导入到目标书目库。";

        if (lTotalRecord > 0 || m_lErrorCount > 0)
            MessageBox.Show(this.Iso2709StatisForm, strMsg);
    }
}


renyh avatar Mar 26 '19 07:03 renyh

用户回复: 905字段为厂商自定义典藏字段:$a馆藏地代号$b条码号$c排架号$d分类号$e书次号$f复本量$s索书号。

0 默认馆藏地 其他代号为 其他代号为用户自定义的馆藏地名称

导出来的馆藏 其实后缀就是 .iso 或者 .txt用记事本或者marc工具都可以打开

备份数据库其实就是去掉.bak后缀的标准sqlserver数据库备份,不管有没后缀,都可以在sql server里面使用还原功能恢复数据库文件

流通信息、读者信息、馆藏信息都在数据库里面 典藏马克包 只有馆藏图书信息

Hopeshine avatar Apr 02 '19 08:04 Hopeshine

DT1000数据格式:

样例数据1

    00993sam0_2200277___45__¶
-01   /我的电脑/图书总库/ctlno/0000001|3ba1e24c0100000028¶
001   0160000048¶
005   19710304102044¶
010 __ ‡d¥0.40¶
091 __ ‡a9231.47¶
100 __ ‡a19710304d1970____efmy0chiy0121____eb¶
101 0_ ‡achi¶
105 __ ‡ayz000yy_efm_y¶
106 __ ‡ay¶
200 10 ‡a现代汉语语法 ‡AXian Dai Han Yu Yu Fa ‡f李扶乾 ‡FLi Fu Qian ‡4著¶
210 __ ‡a北京 ‡c求实出版社 ‡d1982.10¶
215 __ ‡a137页 ‡d20厘米¶
300 __ ‡a教研参考¶
330 __ ‡a本书用较大的篇幅讨论了汉语各种类型的句法结构,以便大家通过学习能够对汉语的各类句子进行分析,了解它们的内部结构关系。¶
606 _0 ‡a汉语 ‡b语法¶
690 __ ‡aH14 ‡v2¶
701 _0 ‡a李扶乾 ‡ALi Fu Qian ‡4著¶
801 __ ‡aCN ‡bXAHT¶
905 __ ‡b0010201-10 ‡dH14 ‡e2¶
906 __ ‡a ‡h0010201 ‡a ‡h0010202 ‡a ‡h0010203 ‡a ‡h0010204 ‡a ‡h0010205 ‡a ‡h0010206 ‡a ‡h0010207 ‡a ‡h0010208 ‡a ‡h0010209 ‡a ‡h0010210¶
986 __ ‡a0010201 ‡a0010202 ‡a0010203 ‡a0010204 ‡a0010205 ‡a0010206 ‡a0010207 ‡a0010208 ‡a0010209 ‡a0010210

样例数据2

    01135sam0_2200253___45__¶
-01   /我的电脑/图书总库/ctlno/0000015|3ba1e24c0f00000028¶
001   0160000036¶
005   19710303154144¶
010 __ ‡b精装 ‡d¥3.65¶
091 __ ‡a9091.32¶
100 __ ‡a19710303d1970____mk_y0chiy0121____eb¶
101 0_ ‡achi¶
105 __ ‡ay_______000yy¶
106 __ ‡ar¶
200 10 ‡a古汉语虚词手册 ‡AGu Han Yu Xu Ci Shou Ce ‡f韩峥嵘 ‡FHan Zheng Rong ‡4编¶
210 __ ‡a长春 ‡c吉林人民出版社 ‡d1984.3¶
215 __ ‡a674页 ‡d20厘米¶
330 __ ‡a本书所收虚词, 包括助动词、代词、副词、介词、连词、助词、语气词、叹词与词缀九类。其中有单字条目303条、双字条目370条、三字条目13条、总共691条。¶
690 __ ‡v2 ‡aH14¶
701 _0 ‡a韩峥嵘 ‡AHan Zheng Rong ‡4编¶
801 __ ‡aCN ‡bXAHT¶
905 __ ‡b0010303-19 ‡dH14¶
906 __ ‡a ‡h0010303 ‡a ‡h0010304 ‡a ‡h0010305 ‡a ‡h0010306 ‡a ‡h0010307 ‡a ‡h0010308 ‡a ‡h0010309 ‡a ‡h0010310 ‡a ‡h0010311 ‡a ‡h0010312 ‡a ‡h0010313 ‡a ‡h0010314 ‡a ‡h0010315 ‡a ‡h0010316 ‡a ‡h0010317 ‡a ‡h0010318 ‡a ‡h0010319¶
986 __ ‡a0010303 ‡a0010304 ‡a0010305 ‡a0010306 ‡a0010307 ‡a0010308 ‡a0010309 ‡a0010310 ‡a0010311 ‡a0010312 ‡a0010313 ‡a0010314 ‡a0010315 ‡a0010316 ‡a0010317 ‡a0010318 ‡a0010319

样例数据3

    00917nam0_2200265___45__¶
-01   /我的电脑/图书总库/ctlno/0019701|c1a1e24cbc26000028¶
001   ???????????¶
010 __ ‡a7-80116-696-8 ‡dCNY6.00¶
100 __ ‡a19961012d1996____ekmy0chiy0120____ea¶
101 0_ ‡achi¶
102 __ ‡aCN ‡b110000¶
105 __ ‡ay___z___000yy¶
106 __ ‡ar¶
200 1_ ‡a科学发展观学习读本 ‡AKe Xue Fa Zhan Guan Xue Xi Dou Ben ‡f中共中央宣传部编 ‡FZhong Gong Zhong Yang Xuan Chuan Bu Bian ‡4¶
210 __ ‡a北京 ‡c学习出版社 ‡d2008.10¶
215 __ ‡a80页 ‡c图 ‡d20cm¶
300 __ ‡a¶
606 __ ‡a¶
690 __ ‡aD61 ‡v4¶
701 _0 ‡a中共中央宣传部编¶
701 _0 ‡a¶
801 _0 ‡aCN ‡bXYDX ‡c¶
905 __ ‡a ‡b0063652-61 ‡dD61 ‡e48 ‡f10¶
906 __ ‡a ‡h ‡a ‡h0063652 ‡a ‡h0063653 ‡a ‡h0063654 ‡a ‡h0063655 ‡a ‡h0063656 ‡a ‡h0063657 ‡a ‡h0063658 ‡a ‡h0063659 ‡a ‡h0063660 ‡a ‡h0063661¶
986 __ ‡a0063652 ‡a0063653 ‡a0063654 ‡a0063655 ‡a0063656 ‡a0063657 ‡a0063658 ‡a0063659 ‡a0063660 ‡a0063661

相关册记录的字段解释:

905$b 905$d 905$e; 905$f 906$h 986$a
最小号的册条码-最大号后2位 中图法大类 种次号 复本数量 册条码号 流通库的册条码,实际未使用

由于用户系统老系统实际只用于册登记,未投入借还,所以986$a实际上并未使用

Hopeshine avatar Apr 22 '21 03:04 Hopeshine