📄 totalsixtable.java
字号:
package net.aetherial.gis.baobu.TotalExcel;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.aetherial.gis.output.FileOperate;
import net.aetherial.gis.surface.ItemValue;
public class TotalSixTable {
String[][] cityArray = new String[][] { { "3401", "合肥市" }, { "3402", "芜湖市" },
{ "3403", "蚌埠市" }, { "3404", "淮南市" },
{ "3405", "马鞍山市" }, { "3406", "淮北市" },
{ "3407", "铜陵市" }, { "3408", "安庆市" },
{ "3410", "黄山市" },{ "3411", "滁州市" },
{ "3412", "阜阳市" }, { "3413", "宿州市" },
{ "3414", "巢湖市" }, { "3415", "六安市" },
{ "3416", "亳州市" },{ "3417", "池州市" },
{ "3418", "宣城市" }};
Map oldLxMap = new HashMap ();
Map newLxMap = new HashMap ();
Map oldLDMap = new HashMap ();
Map newLDMap = new HashMap ();
Map oldXzMap = new HashMap ();
Map newXzMap = new HashMap ();
Map oldTdMap = new HashMap ();
Map newTdMap = new HashMap ();
Map delLxMap = new HashMap ();
Map delLdMap = new HashMap ();
private String oldFilePath = "E:\\报部JIO导出数据\\报部接口\\first"; //上一次报部数据路径
private String newFilePath = "E:\\报部JIO导出数据\\报部接口\\current"; //本次数据路径
private String outFilePath = "E:\\报部JIO比较后数据\\"; //输出路径
/*
* 构造函数
*/
public TotalSixTable(){
super();
}
public void readData(){
System.out.println("正在读取数据,请稍候...");
oldLxMap = this.readFile(oldFilePath + "\\Lx.txt");
newLxMap = this.readFile(newFilePath + "\\Lx.txt");
oldLDMap = this.readFile(oldFilePath + "\\Ld.txt");
newLDMap = this.readFile(newFilePath + "\\Ld.txt");
oldXzMap = this.readXzJzcFile(oldFilePath + "\\XzandJzc.txt");
newXzMap = this.readXzJzcFile(newFilePath + "\\XzandJzc.txt");
oldTdMap = this.readXzJzcFile(oldFilePath + "\\XzandJzcTd.txt");
newTdMap = this.readXzJzcFile(newFilePath + "\\XzandJzcTd.txt");
delLxMap = this.readCFWFile(oldFilePath + "\\Lx_超范围.txt");
delLdMap = this.readCFWLdFile(oldFilePath + "\\Ld_超范围.txt");
}
public Map getLxMap(String [] luXianList){
String cityName = "";
String cityNumber = "";
String lineStr = "";
String lxNumber = "";
String [] childStr = null;
Map LxMap = new HashMap ();
for (int i = 0; cityArray != null && i < cityArray.length ; i ++){
cityNumber = cityArray[i][0];
cityName = cityArray[i][1];
List lxList = new ArrayList();
for (int j = 1; luXianList != null && j < luXianList.length; j ++){
lineStr = luXianList[j];
if (lineStr.length() == 0 || lineStr == null) continue;
childStr = lineStr.split("\t");
lxNumber = childStr[5];
if (lxNumber.substring(4,8).equals(cityNumber))
{
//System.out.println(lineStr);
lxList.add(lineStr);
}
}
LxMap.put(cityName,lxList);
}
return LxMap;
}
//按市分类读取路线、路段数据
private Map readFile(String filename) {
File file = new File(filename);
String split = "\t";
String[] fields = null;
String cityCode = "";
Map roadMap = new HashMap();
List lxList = new ArrayList();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String road = br.readLine();//Ignore title line
road = br.readLine();
while (road != null) {
fields = road.split(split);
cityCode = fields[5].trim().substring(4,8);
if (roadMap.get((String) cityCode) == null) {
roadMap.put(cityCode, new ArrayList());
}
lxList = (List)roadMap.get(cityCode);
lxList.add(road);
road = br.readLine();
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return roadMap;
}
//按市分类读取删除的超范围路线数据
private Map readCFWFile(String filename) {
File file = new File(filename);
String split = "\t";
String[] fields = null;
String cityCode = "";
Map roadMap = new HashMap();
List lxList = new ArrayList();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String road = br.readLine();//Ignore title line
road = br.readLine();
while (road != null) {
fields = road.split(split);
cityCode = fields[0].trim().substring(4,8);
if (roadMap.get((String) cityCode) == null) {
roadMap.put(cityCode, new ArrayList());
}
lxList = (List)roadMap.get(cityCode);
lxList.add(road);
road = br.readLine();
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return roadMap;
}
//按市分类读取删除的超范围路段数据
private Map readCFWLdFile(String filename) {
File file = new File(filename);
String split = "\t";
String[] fields = null;
String cityCode = "";
Map roadMap = new HashMap();
List lxList = new ArrayList();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String road = br.readLine();//Ignore title line
road = br.readLine();
while (road != null) {
fields = road.split(split);
cityCode = fields[1].trim().substring(4,8);
if (roadMap.get((String) cityCode) == null) {
roadMap.put(cityCode, new ArrayList());
}
lxList = (List)roadMap.get(cityCode);
lxList.add(road);
road = br.readLine();
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return roadMap;
}
// 按市分类读取路线、路段数据
private Map readXzJzcFile(String filename) {
File file = new File(filename);
String split = "\t";
String[] fields = null;
String cityCode = "";
Map jzcMap = new HashMap();
List lxList = new ArrayList();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String road = br.readLine();//Ignore title line
road = br.readLine();
while (road != null) {
fields = road.split(split);
cityCode = fields[5].trim().substring(0,4);
if (jzcMap.get((String) cityCode) == null) {
jzcMap.put(cityCode, new ArrayList());
}
lxList = (List)jzcMap.get(cityCode);
lxList.add(road);
road = br.readLine();
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return jzcMap;
}
//新增路线
public void NewAddLx() throws IOException{
Iterator it = newLxMap.keySet().iterator();
String lineStr = "";
String lxNumber = "";
String [] childStr = null;
String oldlineStr = "";
String oldlxNumber = "";
String [] oldchildStr = null;
int n = 0;
String rowStr = "";
String cityName = "";
NewCommClass cc = new NewCommClass();
double gradeValue = 0.0;
double notGradeValue = 0.0;
double gradeCount = 0.0;
double notGradeCount = 0.0;
double mileCount = 0.0;
double sumMileCount = 0.0;
while (it.hasNext()) {
String key = (String) it.next(); //城市名称
//if (!key.equals("3405")) continue;
for (int k = 0; cityArray != null && k < cityArray.length; k++){
if (key.equals(cityArray[k][0]))
{cityName = cityArray[k][1];
break;
}
}
System.err.println("***************正在处理 "+ cityName + " 数据! ********************");
FileOperate fo = new FileOperate();
String outPutFile = this.outFilePath + cityName + "\\新增路线一览表.txt";
File newFile = fo.createFolder(outPutFile);
FileWriter resultFile = new FileWriter(newFile);
PrintWriter myFile = new PrintWriter(resultFile);
List newLxList = (List) newLxMap.get(key); //本次报部路线(分市)
List oldLxList = (List) oldLxMap.get(key); //上次报部路线(分市)
List newLdList = (List) newLDMap.get(key); //上次报部路线(分市)
for (int i = 0 ; newLxList != null && i < newLxList.size(); i++){
lineStr = (String)newLxList.get(i);
childStr = lineStr.split("\t");
lxNumber = childStr[5];
n = 0;
for (int j = 0 ; oldLxList != null && j < oldLxList.size(); j++){
oldlineStr = (String)oldLxList.get(j);
oldchildStr = oldlineStr.split("\t");
oldlxNumber = oldchildStr[5];
if (oldlxNumber.equals(lxNumber)){
n ++;
break;
}
}
if ( n == 0 ) {
double [] roadInfo = cc.getRoadMile1(newLdList,lxNumber); //在路段信息表中得到里程信息
mileCount = roadInfo[0]; //合计
gradeValue = roadInfo[1]; //等级
notGradeValue = roadInfo[2]; //等外
gradeCount += gradeValue ; //等级合计
notGradeCount += notGradeValue ; //等外合计
sumMileCount += mileCount ; //总合计
rowStr = lxNumber + "\t" + childStr[4] + "\t" + ItemValue.getRound(mileCount,3)
+ "\t" + ItemValue.getRound(gradeValue,3) + "\t" + ItemValue.getRound(notGradeValue,3) + "\r\n";
// rowStr = childStr[4] + "\t" + lxNumber + "\r\n";
System.out.println("新增路线: " + rowStr);
myFile.write(rowStr);
}
}
myFile.close();
System.err.println("*************** "+ cityName + " 数据,处理完毕! ********************");
}
}
// 删除超范围上报路线
public void DelLx() throws IOException{
Iterator it = oldLxMap.keySet().iterator();
String lineStr = "";
String lxNumber = "";
String [] childStr = null;
String oldlineStr = "";
String oldlxNumber = "";
String [] oldchildStr = null;
int n = 0;
String cityName = "";
String tongDaStr = "";
NewCommClass cc = new NewCommClass();
double liCheng = 0.0;
while (it.hasNext()) {
String key = (String) it.next(); //城市名称
if (key.equals("3401") || key.equals("3403")) continue;
for (int k = 0; cityArray != null && k < cityArray.length; k++){
if (key.equals(cityArray[k][0]))
{cityName = cityArray[k][1];
break;
}
}
System.err.println("***************正在处理 "+ cityName + " 数据! ********************");
FileOperate fo = new FileOperate();
String outPutFile = this.outFilePath + cityName + "\\已删除超范围调查路线一览表.txt";
File newFile = fo.createFolder(outPutFile);
FileWriter resultFile = new FileWriter(newFile);
PrintWriter myFile = new PrintWriter(resultFile);
List newLxList = (List) oldLxMap.get(key); //上次报部路线(分市)
List oldLxList = (List) newLxMap.get(key); //本次报部路线(分市)
List oldLdList = (List) oldLDMap.get(key); //上次报部路段(分市)
List oldTdList = (List) oldTdMap.get(key); //上次通达信息(分市)
List lxOfLd = new ArrayList();
for (int i = 0 ; newLxList != null && i < newLxList.size(); i++){
lineStr = (String)newLxList.get(i);
childStr = lineStr.split("\t");
lxNumber = childStr[5];
if (!lxNumber.substring(0,1).equals("C")) continue; //只取村道
n = 0;
for (int j = 0 ; oldLxList != null && j < oldLxList.size(); j++){
oldlineStr = (String)oldLxList.get(j);
oldchildStr = oldlineStr.split("\t");
oldlxNumber = oldchildStr[5];
if (!oldlxNumber.substring(0,1).equals("C")) continue; //只取村道
if (oldlxNumber.equals(lxNumber)){
n ++;
break;
}
}
if ( n == 0 ) {
lxOfLd = cc.getLdByLxnumber1(oldLdList,lxNumber);
liCheng = cc.getRoadInfo1(lxOfLd,lxNumber); //获取里程
if (liCheng > 0.0 ){
boolean isTongDa = cc.isTDLx(oldTdList,lxNumber); //判断是否是通达路线
if (isTongDa) {
System.out.println("删除路线:"+ lxNumber + " " + childStr[4]);
//tongDaStr = cc.getIsTongDa(oldTongList,oldLxNumber); //得到上次报部时所用的行政村编码
lineStr = lxNumber + "\t" + childStr[4] + "\t" + liCheng+ "\t" + tongDaStr + "\r\n";
myFile.write(lineStr);
}
}
}
}
myFile.close();
System.err.println("*************** "+ cityName + " 数据,处理完毕! ********************");
}
}
// 删除路线
public void DelFirstLx() throws IOException{
Iterator it = oldLxMap.keySet().iterator();
String lineStr = "";
String lxNumber = "";
String [] childStr = null;
String oldlineStr = "";
String oldlxNumber = "";
String [] oldchildStr = null;
int n = 0;
String cityName = "";
String tongDaStr = "";
NewCommClass cc = new NewCommClass();
double gradeValue = 0.0;
double notGradeValue = 0.0;
double gradeCount = 0.0;
double notGradeCount = 0.0;
double mileCount = 0.0;
double sumMileCount = 0.0;
double liCheng = 0.0;
String tempStr = "";
while (it.hasNext()) {
String key = (String) it.next(); //城市名称
//if (key.equals("3401") || key.equals("3403")) continue;
for (int k = 0; cityArray != null && k < cityArray.length; k++){
if (key.equals(cityArray[k][0]))
{cityName = cityArray[k][1];
break;
}
}
System.err.println("***************正在处理 "+ cityName + " 数据! ********************");
FileOperate fo = new FileOperate();
String outPutFile = this.outFilePath + cityName + "\\已删除路线一览表.txt";
File newFile = fo.createFolder(outPutFile);
FileWriter resultFile = new FileWriter(newFile);
PrintWriter myFile = new PrintWriter(resultFile);
List newLxList = (List) oldLxMap.get(key); //上次报部路线(分市)
List oldLxList = (List) newLxMap.get(key); //本次报部路线(分市)
List oldLdList = (List) oldLDMap.get(key); //上次报部路线(分市)
for (int i = 0 ; newLxList != null && i < newLxList.size(); i++){
lineStr = (String)newLxList.get(i);
childStr = lineStr.split("\t");
lxNumber = childStr[5];
// if (!lxNumber.substring(0,1).equals("C")) continue; //只取村道
n = 0;
for (int j = 0 ; oldLxList != null && j < oldLxList.size(); j++){
oldlineStr = (String)oldLxList.get(j);
oldchildStr = oldlineStr.split("\t");
oldlxNumber = oldchildStr[5];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -