dp2 icon indicating copy to clipboard operation
dp2 copied to clipboard

石家庄某用户书目数据检索

Open wuayang001 opened this issue 3 years ago • 1 comments

为石家庄某用户编写从DT1000升级到dp2服务器后,统计导入的书目数量及册数量。

解析:

原DT1000程序中没有位册记录单个创建一个库,每个册记录一般都写在MARC记录的986$a中、或者906的$h中。

所以可以通过MARC记录中是否包含986、906字段分析该书目是否来源于DT1000。 根据986$a或者906$h可以知道每个书目下面有多少个册记录。

但是用户实际情况,是将册条码写进了986$h和906$h中,且因为数据 的复杂性,两个数据值不相同,所以只能通过两个字段的并集得到当前当前系统有多少册条码(并非实际值)

详情见下面代码示例:

wuayang001 avatar Aug 02 '22 08:08 wuayang001

using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Text;
using System.Xml;

using dp2Circulation;

using DigitalPlatform.Marc;
using DigitalPlatform.Xml;
using DigitalPlatform.Script;
using DigitalPlatform;
using DigitalPlatform.Text;

public class MyMarcQueryHost : MarcQueryHost
{
	int _total_906h = 0;
	int _total_986h = 0;
	int _dp2_biblio = 0;
	int _dt_biblio = 0;
	int _total_item = 0;

	Hashtable _itemTable = new Hashtable();
	List<string> _differ_ = new List<string>();

	public override void OnRecord(object sender, StatisEventArgs e)
	{
		List<string> barcodes = new List<string>();
		int count_906 = this.MarcRecord.select("field[@name='906']").count;
		int count_986 = this.MarcRecord.select("field[@name='986']").count;

		if (count_906 > 0 || count_986 > 0) //检查是否存在906、986字段
		{ _dt_biblio ++;}
		else 
		{ _dp2_biblio ++;}


		int count_986h = this.MarcRecord.select("field[@name='986']/subfield[@name='h']").count;
		_total_986h += count_986h;//统计986$h的数量

		int count_906h = this.MarcRecord.select("field[@name='906']/subfield[@name='h']").count;
		_total_906h += count_906h;//统计906$h的数量



		var subfields = this.MarcRecord.select("field[@name='906']/subfield[@name='h']");
		foreach (MarcSubfield subfield in subfields)
		{
			var barcode = subfield.Content;
			if (string.IsNullOrEmpty(barcode) == false)
				barcodes.Add(barcode);//将906$h数据添加到列表中
		}
		subfields = this.MarcRecord.select("field[@name='986']/subfield[@name='h']");
		foreach (MarcSubfield subfield in subfields)
		{
			var barcode = subfield.Content;
			if (string.IsNullOrEmpty(barcode) == false)
				barcodes.Add(barcode);
		}

		StringUtil.RemoveDupNoSort(ref barcodes);//把一个字符串数组去重。调用前,不要求已经排序(StringUtil 是 dp2 自己实现的类。可以查一下源代码自己看看)
		_total_item += barcodes.Count;
	//	AddToTable(barcodes);

	}
	//void AddToTable(List<string> barcodes)
	//{
	//	foreach (string barcode in barcodes)
	//	{
	//		if (_itemTable.ContainsKey(barcode) == false)
	//		{
	//			_itemTable[barcode] = true;
	//		}
	//	}
	//}


	public override void OnEnd(object sender, StatisEventArgs e)
{
    MessageDlg.Show(this.MainForm,
        $"从DT1000导入书目数: {_dt_biblio}条\r\n" +
        $"dp2library新增书目数: {_dp2_biblio}条\r\n" +
        $"986字段中共有册记录: {_total_986h}条\r\n" +
        $"906字段中共有册记录: {_total_906h}条\r\n" +
        $"DT1000共导入册记录: {_total_item}条", "结果");
}
}

wuayang001 avatar Aug 02 '22 08:08 wuayang001