|
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
|
var dom = require("xmldom").DOMParser;
|
|
|
|
|
var select = require('xpath.js');
|
|
|
|
|
|
|
|
|
|
var dataDetailPath = "/home/server_data/data-detail.xml"
|
|
|
|
|
var dataPath = "/home/server_data/data.xml"
|
|
|
|
|
var versionPath = "/home/server_data/version.txt"
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>fileId<49><64><EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
function getVersionPath(fileId){
|
|
|
|
|
|
|
|
|
|
fileId = fileId.replace(/\"/g, "");
|
|
|
|
|
var item = "<item";
|
|
|
|
|
// fs<66><73>ȡ<EFBFBD><C8A1> xmldomת<6D><D7AA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
var filedata = fs.readFileSync(dataDetailPath, "utf-8");
|
|
|
|
|
var itemArray = filedata.split(item);
|
|
|
|
|
var itemsize = itemArray.length;
|
|
|
|
|
var version = {value:0};
|
|
|
|
|
// ͬһ<CDAC><D2BB>id,<2C><>Ӧ<EFBFBD><D3A6>item<65>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD>
|
|
|
|
|
for(var i = 1; i < itemsize; i++){
|
|
|
|
|
if(itemArray[i].indexOf(fileId)!= -1){
|
|
|
|
|
var oldBigVersion = itemArray[i].split("<version>")[1].split("</version>")[0];
|
|
|
|
|
if(version.value < oldBigVersion){
|
|
|
|
|
version.value = oldBigVersion;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
version.value ++;
|
|
|
|
|
return version.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function mkdataForPage(collecttime, realtype, realpath, realbatch, realid, realname, version){
|
|
|
|
|
// var resultXmlData = "";
|
|
|
|
|
// var realpath = "/uplaods/";
|
|
|
|
|
// var realtype = "01";
|
|
|
|
|
// var realbatch = "01_A";
|
|
|
|
|
// var realid = "32550_111";
|
|
|
|
|
// var realname = "<22>Ͼ<EFBFBD><CFBE><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ϵͳ";
|
|
|
|
|
//json<6F><6E><EFBFBD>Եĸ<D4B5>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>@
|
|
|
|
|
var type ="id=\""+realtype+"\"";
|
|
|
|
|
var batch = "id=\""+realtype+"_"+realbatch+"\"";
|
|
|
|
|
var id = realtype+"_"+realbatch+"_"+realid+"\"";
|
|
|
|
|
var versionid = realtype+"_"+realbatch + "_"+realid + "_" + version +"\"";
|
|
|
|
|
var name = "name=\""+realname+"\"";
|
|
|
|
|
var path = "path=\""+realpath+"\"";
|
|
|
|
|
var versionstrutf = fs.readFileSync(versionPath, "utf-8");
|
|
|
|
|
console.log(typeof versionstrutf);
|
|
|
|
|
|
|
|
|
|
console.log("------------- mkdataForPage --------------");
|
|
|
|
|
fs.readFile(dataPath, "utf-8", function(err, data){
|
|
|
|
|
if(err){
|
|
|
|
|
console.log("<22><>ȡ<EFBFBD>ļ<EFBFBD> "+dataDetailPath+" fail " + err);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var dataNodes = data.split("<node");
|
|
|
|
|
|
|
|
|
|
var istype ="0";
|
|
|
|
|
var isbatch ="0";
|
|
|
|
|
var isexist ="0";
|
|
|
|
|
var sizel = dataNodes.length;
|
|
|
|
|
|
|
|
|
|
for(var i=0; i < sizel; i++){
|
|
|
|
|
if(dataNodes[i].indexOf(type) != -1)
|
|
|
|
|
{
|
|
|
|
|
istype ="1";
|
|
|
|
|
}
|
|
|
|
|
if((istype == "1") && (dataNodes[i].indexOf(batch) != -1))
|
|
|
|
|
{
|
|
|
|
|
isbatch ="1";
|
|
|
|
|
}
|
|
|
|
|
//id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһ<CEA8>ģ<EFBFBD> <node id="32550_113"
|
|
|
|
|
if(isbatch == "1")
|
|
|
|
|
{//<2F><><EFBFBD><EFBFBD><EFBFBD>ӵİ汾
|
|
|
|
|
var nodestr = "";
|
|
|
|
|
if(dataNodes[i].indexOf(id) != -1){
|
|
|
|
|
nodestr = nodestr + "<node id=\""+ versionid + " name=\"" + realname+"("+ versionstrutf + version + ")\"";
|
|
|
|
|
nodestr = nodestr + " path=\""+ realpath +"\"" + " time=\""+collecttime+ "\"></node>\n";
|
|
|
|
|
isexist = "1";
|
|
|
|
|
dataNodes[i] = dataNodes[i] + nodestr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isexist.indexOf("1") == -1){
|
|
|
|
|
var nodestr = "";
|
|
|
|
|
for(var i=0; i < sizel; i++){
|
|
|
|
|
if(dataNodes[i].indexOf(batch) != -1){
|
|
|
|
|
var items = dataNodes[i].split("</");
|
|
|
|
|
if(items.length == 1){
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ϵͳ<CFB5><CDB3>---<2D>汾<EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2>
|
|
|
|
|
nodestr = nodestr + "<node id=\"" + id +" "+ name + ">\n";
|
|
|
|
|
nodestr = nodestr + "<node id=\""+ versionid + " name=\"" + realname +"(" + versionstrutf + version + ")\"";
|
|
|
|
|
nodestr = nodestr + " path=\""+ realpath +"\"" + " time=\""+collecttime+ "\"></node>\n</node>\n";
|
|
|
|
|
isexist = "1";
|
|
|
|
|
dataNodes[i] = dataNodes[i] + nodestr;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var items = dataNodes[i].split("</node");
|
|
|
|
|
nodestr = nodestr + "<node id=\"" + id +" "+ name + ">\n";
|
|
|
|
|
nodestr = nodestr + "<node id=\""+ versionid + " name=\"" + realname+"(" + versionstrutf + version + ")\"";
|
|
|
|
|
nodestr = nodestr + " path=\""+ realpath +"\"" + " time=\""+collecttime+ "\"></node>\n</node>\n";
|
|
|
|
|
isexist = "1";
|
|
|
|
|
nodestr = items[0] +"\n" + nodestr +"\n</node>\n";
|
|
|
|
|
dataNodes[i] = nodestr;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var resultdatastr = "";
|
|
|
|
|
for(var j=0; j < sizel-1; j++){
|
|
|
|
|
resultdatastr = resultdatastr + dataNodes[j] + "<node";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultdatastr = resultdatastr + dataNodes[sizel-1]+"";
|
|
|
|
|
console.log("--------22222222-----------------");
|
|
|
|
|
console.log(resultdatastr);
|
|
|
|
|
console.log(typeof resultdatastr);
|
|
|
|
|
|
|
|
|
|
fs.writeFile(dataPath, resultdatastr, function(err){
|
|
|
|
|
if(err)
|
|
|
|
|
console.log(err);
|
|
|
|
|
else
|
|
|
|
|
console.log('has finished');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//saveByIdToXml("01", "B", "321200_0", "̩<><CCA9><EFBFBD><EFBFBD>_<EFBFBD><5F>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ϵͳ2","<22><><EFBFBD><EFBFBD>" , "̩<><CCA9>2", "<22>б<EFBFBD><D0B1><EFBFBD>", "<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ϵͳ", "321200_0", "0000", "lim", "13323225656",5);
|
|
|
|
|
function saveByIdToXml(collecttime, type, dataTimes, id, name, province, city, county, system, areacode, systemcode, contacts, phone, version, realpath){
|
|
|
|
|
var dataTimetemstr = "batch=\""+ type +"_" + dataTimes + "\"";
|
|
|
|
|
typestr = "type=\""+type+"\"";
|
|
|
|
|
var datatype = "<datatype";
|
|
|
|
|
var dataTimestr = "<dataTimes";
|
|
|
|
|
var dataTimeEndstr = "</dataTimes>";
|
|
|
|
|
var item = "<item";
|
|
|
|
|
var itemEnd = "</item>";
|
|
|
|
|
var dataEnd = "</data>";
|
|
|
|
|
id = type +"_" + dataTimes + "_" + id;
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ
|
|
|
|
|
// var data = fs.readFileSync(dataDetailPath, "utf-8");
|
|
|
|
|
// <20><>ȡ
|
|
|
|
|
fs.readFile(dataDetailPath, "utf-8", function(err, data){
|
|
|
|
|
//fs.readFile("data.txt", function(err, data){
|
|
|
|
|
if(err){
|
|
|
|
|
console.log("<22><>ȡ<EFBFBD>ļ<EFBFBD> "+dataDetailPath+" fail " + err);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
|
|
var resultStr = "";
|
|
|
|
|
// gbk <20><><EFBFBD><EFBFBD> linux<75><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//var str = iconv.decode(data,'gbk');
|
|
|
|
|
//data = str;
|
|
|
|
|
var typeArray = data.split(datatype);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>籣<EFBFBD><E7B1A3>{typeArray[0]:ͷ<><CDB7> typeArray[1]:<3A>籣<EFBFBD><E7B1A3> typeArray[2]:<3A><><EFBFBD><EFBFBD>}
|
|
|
|
|
if(typeArray[1].indexOf(typestr)== -1){
|
|
|
|
|
resultStr += typeArray[0];
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>籣<EFBFBD><E7B1A3>
|
|
|
|
|
resultStr += datatype;
|
|
|
|
|
resultStr += typeArray[1];
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD> <20><>typeArray[2]
|
|
|
|
|
var timesArray = typeArray[2].split(dataTimestr);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>εģ<CEB5><C4A3>ǵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>; {timesArray[0]:ͷ<><CDB7> timesArray[1]:1<><31><EFBFBD>Σ<EFBFBD> timesArray[2]:2<><32><EFBFBD><EFBFBD>}
|
|
|
|
|
if(timesArray[1].indexOf(dataTimetemstr)== -1){
|
|
|
|
|
|
|
|
|
|
resultStr += datatype;
|
|
|
|
|
resultStr += timesArray[0];
|
|
|
|
|
// <20><><EFBFBD>ϵ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += timesArray[1];
|
|
|
|
|
|
|
|
|
|
var itemArray = timesArray[2].split(item);
|
|
|
|
|
var itemsize = itemArray.length;
|
|
|
|
|
|
|
|
|
|
var nowDate = new Date();
|
|
|
|
|
// itemԪ<6D><D4AA>
|
|
|
|
|
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
|
|
|
|
|
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
|
|
|
|
|
|
|
|
|
|
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
|
|
|
|
|
// <20><><EFBFBD> <20><> resultStr
|
|
|
|
|
// û<><C3BB> item<65><6D> itemsize ==1
|
|
|
|
|
if(itemsize ==1){
|
|
|
|
|
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
|
|
|
|
|
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += dataTimebeginstr[0];
|
|
|
|
|
resultStr += "\t" + itemStr;
|
|
|
|
|
resultStr += dataTimeEndstr;
|
|
|
|
|
for(var i = 1; i < dataTimebeginstr.length;i++){
|
|
|
|
|
|
|
|
|
|
resultStr += dataTimebeginstr[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20><> item<65><6D>
|
|
|
|
|
else{
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += itemArray[0];
|
|
|
|
|
if(version == 1){
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
resultStr += item;
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var addtimes = 0;
|
|
|
|
|
var isadd = 0;
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
isadd++;
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
if(isadd == 0){
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><>1<EFBFBD><31><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
else{
|
|
|
|
|
resultStr += datatype;
|
|
|
|
|
resultStr += timesArray[0];
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
// item Ԫ<><D4AA>
|
|
|
|
|
var itemArray = timesArray[1].split(item);
|
|
|
|
|
var itemsize = itemArray.length;
|
|
|
|
|
|
|
|
|
|
var nowDate = new Date();
|
|
|
|
|
// itemԪ<6D><D4AA>
|
|
|
|
|
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
|
|
|
|
|
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
|
|
|
|
|
|
|
|
|
|
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
|
|
|
|
|
// <20><><EFBFBD> <20><> resultStr
|
|
|
|
|
// û<><C3BB> item<65><6D> itemsize ==1
|
|
|
|
|
if(itemsize ==1){
|
|
|
|
|
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
|
|
|
|
|
resultStr += dataTimebeginstr[0];
|
|
|
|
|
resultStr += "\t" + itemStr;
|
|
|
|
|
resultStr += dataTimeEndstr;
|
|
|
|
|
for(var i = 1; i < dataTimebeginstr.length;i++){
|
|
|
|
|
resultStr += dataTimebeginstr[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><> item<65><6D>
|
|
|
|
|
else{
|
|
|
|
|
resultStr += itemArray[0];
|
|
|
|
|
if(version == 1){
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
resultStr += item;
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var addtimes = 0;
|
|
|
|
|
var isadd = 0;
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
isadd++;
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
if(isadd == 0){
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ȼ<><C8BB><EFBFBD><EFBFBD>ϵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += timesArray[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>籣
|
|
|
|
|
else{
|
|
|
|
|
resultStr += typeArray[0];
|
|
|
|
|
|
|
|
|
|
//<2F>籣 <20><>typeArray[1]
|
|
|
|
|
var timesArray = typeArray[1].split(dataTimestr);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>εģ<CEB5><C4A3>ǵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>; {timesArray[0]:ͷ<><CDB7> timesArray[1]:1<><31><EFBFBD>Σ<EFBFBD> timesArray[2]:2<><32><EFBFBD><EFBFBD>}
|
|
|
|
|
if(timesArray[1].indexOf(dataTimetemstr)== -1){
|
|
|
|
|
resultStr += datatype;
|
|
|
|
|
resultStr += timesArray[0];
|
|
|
|
|
// <20><><EFBFBD>ϵ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += timesArray[1];
|
|
|
|
|
|
|
|
|
|
var itemArray = timesArray[2].split(item);
|
|
|
|
|
var itemsize = itemArray.length;
|
|
|
|
|
|
|
|
|
|
var nowDate = new Date();
|
|
|
|
|
// itemԪ<6D><D4AA>
|
|
|
|
|
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
|
|
|
|
|
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
|
|
|
|
|
|
|
|
|
|
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
|
|
|
|
|
// <20><><EFBFBD> <20><> resultStr
|
|
|
|
|
// û<><C3BB> item<65><6D> itemsize ==1
|
|
|
|
|
if(itemsize ==1){
|
|
|
|
|
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += dataTimebeginstr[0];
|
|
|
|
|
resultStr = resultStr + "\t" + itemStr;
|
|
|
|
|
resultStr += dataTimeEndstr;
|
|
|
|
|
for(var i = 1; i < dataTimebeginstr.length;i++){
|
|
|
|
|
resultStr += dataTimebeginstr[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><> item<65><6D>
|
|
|
|
|
else{
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += itemArray[0];
|
|
|
|
|
if(version == 1){
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
resultStr += item;
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var addtimes = 0;
|
|
|
|
|
var isadd = 0;
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
isadd++;
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
if(isadd == 0){
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><>1<EFBFBD><31><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
else{
|
|
|
|
|
resultStr += datatype;
|
|
|
|
|
resultStr += timesArray[0];
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
// item Ԫ<><D4AA>
|
|
|
|
|
var itemArray = timesArray[1].split(item);
|
|
|
|
|
var itemsize = itemArray.length;
|
|
|
|
|
|
|
|
|
|
var nowDate = new Date();
|
|
|
|
|
// itemԪ<6D><D4AA>
|
|
|
|
|
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
|
|
|
|
|
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
|
|
|
|
|
|
|
|
|
|
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
|
|
|
|
|
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
|
|
|
|
|
// <20><><EFBFBD> <20><> resultStr
|
|
|
|
|
// û<><C3BB> item<65><6D> itemsize ==1
|
|
|
|
|
if(itemsize ==1){
|
|
|
|
|
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
|
|
|
|
|
resultStr += dataTimebeginstr[0];
|
|
|
|
|
resultStr = resultStr + "\t" + itemStr;
|
|
|
|
|
resultStr += dataTimeEndstr;
|
|
|
|
|
for(var i = 1; i < dataTimebeginstr.length;i++){
|
|
|
|
|
resultStr += dataTimebeginstr[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><> item<65><6D>
|
|
|
|
|
else{
|
|
|
|
|
resultStr += itemArray[0];
|
|
|
|
|
if(version == 1){
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
resultStr += itemStr+"\t";
|
|
|
|
|
resultStr += item;
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
var addtimes = 0;
|
|
|
|
|
var isadd = 0;
|
|
|
|
|
for(var i=1; i < itemsize-1; i++){
|
|
|
|
|
isadd++;
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[i];
|
|
|
|
|
}
|
|
|
|
|
if(isadd == 0){
|
|
|
|
|
if(addtimes == 0){
|
|
|
|
|
if(itemArray[i].indexOf(id)!= -1){
|
|
|
|
|
resultStr += itemStr + "\t";
|
|
|
|
|
addtimes = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
|
|
|
|
|
resultStr += item;
|
|
|
|
|
resultStr += itemArray[itemsize-1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Ȼ<><C8BB><EFBFBD><EFBFBD>ϵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>
|
|
|
|
|
resultStr += dataTimestr;
|
|
|
|
|
resultStr += timesArray[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
resultStr += datatype;
|
|
|
|
|
resultStr += typeArray[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log("-----------------------------------------------");
|
|
|
|
|
console.log(resultStr);
|
|
|
|
|
console.log(typeof resultStr);
|
|
|
|
|
// д<><D0B4><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
fs.writeFile(dataDetailPath, resultStr, function(err){
|
|
|
|
|
if(err)
|
|
|
|
|
console.log(err);
|
|
|
|
|
else
|
|
|
|
|
console.log('has finished');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.getVersionPath = getVersionPath;
|
|
|
|
|
exports.mkdataForPage = mkdataForPage
|
|
|
|
|
exports.saveByIdToXml = saveByIdToXml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|