📄 datavirytabulation.java
字号:
package net.aetherial.gis.baobu.TotalExcel;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.work.MergeFiles;
import net.aetherial.gis.output.FileOperate;
import net.aetherial.gis.surface.ItemValue;
/*
* 创建时间:2006-9-9
* 作者:robet du
* 安徽省通途信息技术有限公司 (c) 2006
*
* 实现以下功能:
* 1、新增路线一览表
* 2、已删除超范围调查路线一览表
* 3、新增乡镇、建制村一览表
* 4、删除乡镇、建制村一览表
* 5、乡镇、建制村编码或名称调整一览表
* 6、通达路线选取变化一览表
*/
public class DataViryTabulation {
/**
* @param args
*/
private String oldFilePath = "E:\\temp\\first"; //上一次报部数据路径
private String newFilePath = "E:\\temp\\current"; //本次数据路径
//private String oldFilePath = "d:\\test"; //上一次报部数据路径
//private String newFilePath = "d:\\testbak"; //本次数据路径
private List newAddList = new ArrayList(); //新增的乡镇、行政村
private List delList = new ArrayList(); //已经删除的乡镇、行政村
private String [] oldLdArray = null;
private String [] newLdArray = null;
private String cityName = ""; //城市名
/*
* 构造函数
*/
public DataViryTabulation(){
super();
}
public void print(List list){
List l=list;
for( int j = 0; j<l.size(); j++){
String str=(String)l.get(j);
System.out.println(str);
}
}
public void printAll() throws IOException{
String filePath = "E:\\比较数据";
File allFile = new File(filePath);
File[] files = allFile.listFiles();// 获取城市目录列表
for (int i = 0; files != null && i < files.length ; i++){
filePath = files[i].getPath();
String tempPath = filePath.replace('\\', ',');
String[] paths = tempPath.split(",");
int lenInt = paths.length - 1;
String shiName = paths[lenInt]; // 城市名
this.oldFilePath = filePath + "\\first"; //上次报部接口文件路径
this.newFilePath = filePath + "\\current"; //本次报部接口文件路径
this.cityName = shiName ;
CommClass cc = new CommClass();
oldLdArray = cc.getOldLd(this.oldFilePath);
newLdArray = cc.getNewLd(this.newFilePath);
System.err.println("***************正在处理 "+ shiName + " 数据! ********************");
/* System.out.println(" 正在处理 新增路线一览表...");
getNewRoadS();
System.out.println(" 正在处理 已删除超范围调查路线一览表...");
hasEarseRoads();
System.out.println(" 正在处理 新增乡镇、建制村一览表...");
this.newAddList =getNewVillagesAndTowns();
System.out.println(" 正在处理 删除乡镇、建制村一览表...");
this.delList = hasEarseVillagesAndTowns();
System.out.println(" 正在处理 乡镇、建制村编码或名称调整一览表...");
changeVillagesAndTowns();
System.out.println(" 正在处理 通达路线选取变化一览表...");
changePassageRoads();
*/
System.out.println(" 正在处理 已删除路线一览表...");
getAlterRoadS();
System.err.println("*************** "+ shiName + " 数据比较完成! ********************");
}
}
/*
* 1、新增路线一览表,所有在第一次数据报送时没有填报的路线,路线里程分等外和等级;
* 2、单条路线包括重复里程和断头路里程(计入等外),合计行不包括重复里程和断头路里程;
* 3、路线按照路线编码排序
*/
public List getNewRoadS(){
List list1 = new ArrayList();
List list2 = new ArrayList();
List tempList = new ArrayList();
FileOperate fileOperate = new FileOperate();
CommClass cc = new CommClass();
cc.setTxtFilePath(this.oldFilePath);
list1 = cc.getRoadTable();
cc.setTxtFilePath(this.newFilePath);
list2 = cc.getRoadTable();
String contentTxt = "";
String oldLineStr = "";
String newLineStr = "";
String oldRoadNumber = "";
String newRoadNumber = "";
String newRoadName = "";
String [] oldLine = null;
String [] newLine = null;
double [] roadInfo = null;
double gradeValue = 0.0;
double notGradeValue = 0.0;
double gradeCount = 0.0;
double notGradeCount = 0.0;
double mileCount = 0.0;
double sumMileCount = 0.0;
String rowStr = "";
int n = 0;
int lineInt = 0;
System.out.println("正在比较数据,请稍后...");
List ldList = cc.getLd(this.newFilePath);
for (int i=0; list2 != null && i<list2.size(); i++)
{
newLineStr =(String)list2.get(i);
newLine = newLineStr.split("\t");
newRoadName = newLine[1];
newRoadNumber = newLine[0];
n=0;
for( int j = 0; list1 != null && j<list1.size(); j++){
oldLineStr =(String)list1.get(j);
oldLine = oldLineStr.split("\t");
oldRoadNumber = oldLine[0];
if ( newRoadNumber.equals(oldRoadNumber) ){
n++;
break;
}
}
if ( n == 0 ) {
lineInt ++ ;
System.out.println("新增路线: "+ newRoadNumber + " " + newRoadName);
roadInfo = cc.getRoadMile(ldList,newRoadNumber); //在路段信息表中得到里程信息
mileCount = roadInfo[0]; //合计
gradeValue = roadInfo[1]; //等级
notGradeValue = roadInfo[2]; //等外
gradeCount += gradeValue ; //等级合计
notGradeCount += notGradeValue ; //等外合计
sumMileCount += mileCount ; //总合计
rowStr = lineInt + "\t" + newRoadNumber + "\t" + newRoadName + "\t" + ItemValue.getRound(mileCount,3)
+ "\t" + ItemValue.getRound(gradeValue,3) + "\t" + ItemValue.getRound(notGradeValue,3);
contentTxt += rowStr +"\r\n";
tempList.add(rowStr);
}
}
rowStr = "\t\t\t"+ ItemValue.getRound(sumMileCount,3) + "\t" + ItemValue.getRound(gradeCount,3) + "\t" + ItemValue.getRound(notGradeCount,3) +"\t\r\n" ;
contentTxt = rowStr + contentTxt;
tempList.add(rowStr);
fileOperate.newFile("e:\\报部接口文件\\"+this.cityName + "\\新增路线一览表.txt",contentTxt);//输出文件
return tempList;
}
//已经删除的路线
public List getDelRoadS() throws IOException{
//List list1 = new ArrayList();
//List list2 = new ArrayList();
List tempList = new ArrayList();
FileOperate fileOperate = new FileOperate();
FileOperate fo = new FileOperate();
String outPutFile = "E:\\报部接口文件\\"+this.cityName + "\\已经删除的路线一览表.txt";
File newFile = fo.createFolder(outPutFile);
FileWriter resultFile = new FileWriter(newFile);
PrintWriter myFile = new PrintWriter(resultFile);
CommClass cc = new CommClass();
cc.setTxtFilePath(this.newFilePath);
String [] list1 = cc.getRoadTableArray();
cc.setTxtFilePath(this.oldFilePath);
String [] list2 = cc.getRoadTableArray();
String oldLineStr = "";
String newLineStr = "";
String oldRoadNumber = "";
String newRoadNumber = "";
String newRoadName = "";
String [] oldLine = null;
String [] newLine = null;
int n = 0;
int lineInt = 0;
System.out.println("正在比较数据,请稍后...");
for (int i=0; list2 != null && i<list2.length; i++)
{
newLineStr =list2[i];
newLine = newLineStr.split("\t");
newRoadName = newLine[1];
newRoadNumber = newLine[0];
n=0;
for( int j = 0; list1 != null && j<list1.length; j++){
oldLineStr =list1[j];
oldLine = oldLineStr.split("\t");
oldRoadNumber = oldLine[0];
if ( newRoadNumber.equals(oldRoadNumber) ){
n++;
break;
}
}
if ( n == 0 ) {
lineInt ++ ;
System.out.println("已删除路线: "+ newRoadNumber + " " + newRoadName);
myFile.write(newLineStr+"\r\n");
}
}
myFile.close();
return tempList;
}
// 已经变化路线表
public List getAlterRoadS() throws IOException{
//List list1 = new ArrayList();
//List list2 = new ArrayList();
List tempList = new ArrayList();
FileOperate fileOperate = new FileOperate();
FileOperate fo = new FileOperate();
String outPutFile = "E:\\报部接口文件\\"+this.cityName + "\\已经变化的路线一览表.txt";
File newFile = fo.createFolder(outPutFile);
FileWriter resultFile = new FileWriter(newFile);
PrintWriter myFile = new PrintWriter(resultFile);
CommClass cc = new CommClass();
cc.setTxtFilePath(this.oldFilePath);
String [] list1 = cc.getRoadTableArray();
cc.setTxtFilePath(this.newFilePath);
String [] list2 = cc.getRoadTableArray();
String tempStr = "";
String oldLineStr = "";
String newLineStr = "";
String oldRoadNumber = "";
String newRoadNumber = "";
String newRoadName = "";
String oldRoadName = "";
String [] oldLine = null;
String [] newLine = null;
int n = 0;
int lineInt = 0;
System.out.println("正在比较数据,请稍后...");
for (int i=0; list2 != null && i<list2.length; i++)
{
newLineStr =list2[i];
newLine = newLineStr.split("\t");
newRoadName = newLine[1];
newRoadNumber = newLine[0];
n=0;
for( int j = 0; list1 != null && j<list1.length; j++){
oldLineStr =list1[j];
oldLine = oldLineStr.split("\t");
oldRoadNumber = oldLine[0];
oldRoadName = oldLine[1];
if ((newRoadName.equals(oldRoadName) && newRoadNumber.equals(oldRoadNumber)))
break;
if ((!newRoadName.equals(oldRoadName) && newRoadNumber.equals(oldRoadNumber) )
|| (newRoadName.equals(oldRoadName) && !newRoadNumber.equals(oldRoadNumber))
&& oldRoadNumber.substring(4,10).equals(newRoadNumber.substring(4,10))){
n++;
break;
}
}
if ( n != 0 ) {
lineInt ++ ;
System.out.println("已变化路线: "+ newRoadNumber + " " + newRoadName);
String [] temp = cc.getOldNameAndNumber(newRoadName,newRoadNumber,list1);
oldRoadName = temp[1];
oldRoadNumber = temp[0];
tempStr = lineInt + "\t" + oldRoadNumber + " \t" + newRoadNumber +"\t"+ oldRoadName + "\t"
+ newRoadName + "\r\n";
myFile.write(tempStr);
}
}
myFile.close();
return tempList;
}
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -