public static IList <JTCY> ReadJTCYExcel(string path) { ObservableCollection <JTCY> jTCies = ExcelUtils.GetExcelToObjectToObservableCollection <JTCY>(path, ReadJTCYExcelXMLPath); ObservableCollection <JTCY> hzs = ExcelUtils.GetExcelToObjectToObservableCollection <JTCY>(path, ReadHZExcelXMLPath); ObservableCollection <JTCY> list = new ObservableCollection <JTCY>(); foreach (JTCY hz in hzs) { hz.YHZGX = "02"; bool flag = true; for (int a = list.Count - 1; a >= 0; a--) { if (list[a].CBFBM == hz.CBFBM) { flag = false; break; } } if (flag) { list.Add(hz); } } //去除家庭成员 没有名字的情况 foreach (JTCY jtcy in jTCies) { if (!Utils.IsStrNull(jtcy.XM)) { list.Add(jtcy); } } return(list); }
/// <summary> /// 设置界址线表 /// </summary> /// <param name="jsydDic"></param> /// <param name="jzxs"></param> internal static void SetJZXs(ObservableCollection <JSYD> jsyds, ObservableCollection <JZXInfo> jzxs) { Dictionary <string, ObservableCollection <JZXInfo> > dic = null; try { dic = Utils.GetGroupDicToList("BZDH", jzxs); } catch (Exception e) { MessageBox.Show("界址线表:宗地编码:" + e.Message); return; } ObservableCollection <JZXInfo> list; foreach (JSYD jsyd in jsyds) { if (!Utils.IsStrNull(jsyd.ZDNUM) && dic.TryGetValue(jsyd.ZDNUM, out list)) { jsyd.JZXInfos = list; } } }
private void SelectDir_Click(object sender, RoutedEventArgs e) { string dir = FileUtils.SelectDir(); if (!Utils.IsStrNull(dir)) { model.Dir = dir; IList <string> list = FileUtils.SelectAllDirFiles(dir, ".xls", FileSelectRelation.Contains, false); AddFile(list); } }
/// <summary> /// 替换word中的内容 /// </summary> /// <param name="replaceViewModels"></param> /// <param name="doc"></param> public static void ReplaceText(IList <ReplaceViewModel> replaceViewModels, Document doc) { foreach (ReplaceViewModel replaceViewModel in replaceViewModels) { string oldText = replaceViewModel.OldText; string newText = replaceViewModel.NewText; if (newText == null) { newText = ""; } if (!Utils.IsStrNull(oldText)) { int changeCount = doc.Range.Replace(oldText, newText, true, false); } } }
private void AddDirFile_Click(object sender, RoutedEventArgs e) { string dir = FileUtils.SelectDir(); if (!Utils.IsStrNull(dir)) { model.Dir = dir; DirClass dirClass = new DirClass(dir); if (model.IsDiGuiChaZhao) { AddFile(dirClass.FindFileAll()); } else { AddFile(dirClass.Files); } } }
/// <summary> /// 代码关系转换 为文字关系 /// </summary> /// <param name="hzs"></param> private static void DMToText(IList <JTCY> hzs) { int value; Dictionary <string, string> yhzgxDic = ExcelRead.ReadExcelToDic(System.AppDomain.CurrentDomain.BaseDirectory + "家庭关系代码.xls", 0); foreach (JTCY hz in hzs) { foreach (JTCY jtcy in hz.jTCies) { string sex = jtcy.XB; if (sex != null) { if (int.TryParse(sex, out value)) { if (value % 2 == 0) { jtcy.XB = "男"; } else { jtcy.XB = "女"; } } } string yhzgx = jtcy.YHZGX; if (!Utils.IsStrNull(yhzgx) && yhzgxDic.TryGetValue(yhzgx, out yhzgx)) { jtcy.YHZGX = yhzgx; } string sfgyr = jtcy.SFGYR; if (sfgyr == "1" || sfgyr == "是") { jtcy.SFGYR = "是"; } else { jtcy.SFGYR = "否"; } } } }
public void AddFile(IList <string> files2) { IList <FileNameCustom> fileNameCustoms = new List <FileNameCustom>(); if (!Utils.CheckListExists(files2)) { return; } if (Utils.IsStrNull(Filter)) { for (int a = 0; a < files2.Count; a++) { FileNameCustom custom = new FileNameCustom(files2[a]); fileNameCustoms.Add(custom); } addFilePagerPage.AddObject(fileNameCustoms); return; } IList <string> files = new List <string>(); int count = files2.Count; string[] filters = FileterToEndWith(); for (int a = 0; a < count; a++) { string path = files2[a]; string ex = System.IO.Path.GetExtension(path); if (path != null && Array.IndexOf(filters, ex) != -1) { files.Add(path); } } for (int a = 0; a < files.Count; a++) { FileNameCustom custom = new FileNameCustom(files[a]); fileNameCustoms.Add(custom); } addFilePagerPage.AddObject(fileNameCustoms); }
/// <summary> /// excel 转换为jtcy 对象 /// </summary> /// <param name="path">Excel路径</param> /// <returns></returns> public static ObservableCollection <JTCY> GetExcelToHZS(string path) { ObservableCollection <JTCY> list = ExcelUtils.GetExcelToObjectToObservableCollection <JTCY>(path, XMLPath); ObservableCollection <JTCY> hzs = GetJTCYSToHz(list); //户主放在第一位 for (int b = 0; b < hzs.Count; b++) { JTCY hz = hzs[b]; if (Utils.IsStrNull(hz.GMSFHM)) { hzs.RemoveAt(b); b--; continue; } IList <JTCY> jTCies = hz.JTCies; for (int a = 1; a < jTCies.Count; a++) { JTCY jTCY = jTCies[a]; if (jTCY.YHZGX == "户主") { jTCies.RemoveAt(a); jTCies.Insert(0, jTCY); break; } } for (int a = 2; a < jTCies.Count; a++) { JTCY jTCY = jTCies[a]; if (jTCY.YHZGX == "妻") { jTCies.RemoveAt(a); jTCies.Insert(1, jTCY); break; } } } return(hzs); }
internal static void SetHZs(IList <JSYD> jsyds, IList <JSYD> gyrs, IList <JTCY> hzs) { Dictionary <string, JTCY> hzZJHMDic = null; try { hzZJHMDic = MyUtils.Utils.GetGroupDic("GMSFHM", hzs); } catch (Exception e) { MessageBox.Show("家庭成员表:证件号码:" + e.Message); return; } Dictionary <string, IList <JSYD> > gyrDic = Utils.GetGroupDicToList("ZDNUM", gyrs); JTCY hz; IList <JSYD> gyrTem; foreach (JSYD jsyd in jsyds) { string zjhm = jsyd.ZJHM; if (!Utils.IsStrNull(zjhm) && hzZJHMDic.TryGetValue(zjhm, out hz)) { jsyd.HZs.Add(hz); } // string zdnum = jsyd.ZDNUM; if (gyrDic.TryGetValue(zdnum, out gyrTem)) { foreach (JSYD gyr in gyrTem) { zjhm = gyr.ZJHM; if (!Utils.IsStrNull(zjhm) && hzZJHMDic.TryGetValue(zjhm, out hz)) { jsyd.HZs.Add(hz); } } } } }
/// <summary> /// 所有家庭成员 设置到户主中 去 /// </summary> /// <param name="jtcys"></param> /// <returns></returns> private static ObservableCollection <JTCY> GetJTCYSToHz(ObservableCollection <JTCY> jtcys) { if (jtcys == null) { return(null); } string tem = ""; int index = 1; foreach (JTCY jtcy in jtcys) { if (!Utils.IsStrNull(jtcy.CBFBM)) { tem = (index++) + ""; jtcy.CBFBM = tem; } else { jtcy.CBFBM = tem; } } Dictionary <string, ObservableCollection <JTCY> > jtcyGroupDic = Utils.GetGroupDicToList("CBFBM", jtcys); ObservableCollection <JTCY> hzs = new ObservableCollection <JTCY>(); foreach (string cbfbm in jtcyGroupDic.Keys) { IList <JTCY> oneJTCY = jtcyGroupDic[cbfbm]; JTCY hz = FindOneJtcyHZ(oneJTCY); if (hz != null) { hz.JTCies = oneJTCY; hzs.Add(hz); } } return(hzs); }
/// <summary> /// 导出 农村土地家庭承包农户基本情况信息表(一) /// </summary> /// <param name="hzs"></param> public static bool ExportBsicInformationExcel(IList <JTCY> hzs, string saveDir) { Dictionary <string, string> dklbDic = new Dictionary <string, string>(); dklbDic.Add("10", "承包地"); dklbDic.Add("21", "自留地"); dklbDic.Add("22", "机动地"); dklbDic.Add("23", "开荒地"); dklbDic.Add("99", "其他集体土地"); if (Utils.IsStrNull(saveDir)) { return(false); } string basicInformationExxcelTemplete = System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\农村土地家庭承包农户基本情况信息表(一)模板.xls"; Dictionary <int, XMLTable> ClazzDic = XMLRead.GetXmlToXMLTabl(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteJTCYBaicInformationExcel.xml"); Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteJTCYBaicInformationExcel.xml"); string basicInformationExxcelTemplete2 = System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\农村土地承包经营权(家庭承包)台帐(二)模板.xls"; Dictionary <int, XMLTable> ClazzDic2 = XMLRead.GetXmlToXMLTabl(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteDKBaicInformationExcel.xml"); Dictionary <string, XMLObject> xmlObjectDic2 = XMLRead.XmlToObjects(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\WriteDKBaicInformationExcel.xml"); string cbfbm; if (Utils.CheckListExists(hzs)) { DMToText(hzs); foreach (JTCY hz in hzs) { string cbfdz = hz.DZ; if (!cbfdz.EndsWith("组")) { cbfdz = cbfdz.Substring(0, cbfdz.LastIndexOf("组")) + "组"; } int index = cbfdz.IndexOf("镇"); if (index == -1) { index = cbfdz.IndexOf("乡"); } hz.DZ = cbfdz.Substring(index + 1, cbfdz.Length - index - 1); XMLTable xmlTable = ClazzDic[0]; IWorkbook workbook = ExcelRead.ReadExcel(basicInformationExxcelTemplete); ISheet sheet = workbook.GetSheetAt(0); //家庭成员表行数据插入 ExcelWrite.WriteObjects(sheet, xmlTable, hz.jTCies); //家庭成员表 文字替换 ExcelWrite.ReplaceTextByXMLObject(sheet, hz, xmlObjectDic); ExcelWrite.Save(workbook, saveDir + "//TZ-" + hz.CBFBM.Substring(0, 14) + " " + cbfdz + "\\TZ4 -" + hz.CBFBM + "-1农村土地家庭承包农户基本情况信息表(一).xls"); //写地块表 Dictionary <string, string> tdlylxDic = ExcelRead.ReadExcelToDic(System.AppDomain.CurrentDomain.BaseDirectory + "CBDTemplete\\土地利用类型映射表.xlsx", 0); IList <DK> dks = hz.DKs; if (dks == null) { continue; } foreach (DK dk in dks) { if (dk.DKLB == "21") { dk.ZLDMJ = Math.Round(dk.HTMJ, 2).ToString("f2"); } else { dk.ELCBMJ = Math.Round(dk.HTMJ, 2).ToString("f2"); } string dklb = dk.DKLB; if (dklb != null) { if (dklbDic.TryGetValue(dklb, out dklb)) { //地块类别无法识别的情况 dk.DKLB = dklb; } } string tdlylx = dk.TDLYLX; if (tdlylx != null) { if (tdlylxDic.TryGetValue(tdlylx, out tdlylx)) { dk.TDLYLX = tdlylx; } } } IWorkbook workbook2 = ExcelRead.ReadExcel(basicInformationExxcelTemplete2); ISheet sheet2 = workbook2.GetSheetAt(0); ExcelWrite.ReplaceTextByXMLObject(sheet2, hz, xmlObjectDic); ExcelWrite.WriteObjects(sheet2, ClazzDic2[0], hz.DKs); for (int a = 0; a < dks.Count; a++) { IRow row = sheet.GetRow(a + 5); } ExcelWrite.Save(workbook2, saveDir + "//TZ-" + hz.CBFBM.Substring(0, 14) + " " + cbfdz + "\\TZ4 -" + hz.CBFBM + "-2农村土地承包经营权(家庭承包)台帐(二).xls"); } return(true); } return(false); }
public void ExportZJD_QJDCB(JSYD jsyd, string saveDir) { string docTempletePath = JSYDCustom.QJDCBDocPath; XWPFDocument doc = WordRead.Read(docTempletePath); //写入界址签章表 IList <QZB> qzbs = jsyd.QZBs; WordWrite.SetTableRowObj(doc, qzbs, JZXInfoCustom.qzbReflect); //写入标示表 IList <JZXInfo> jzxinfos = jsyd.JZXInfos; JZXInfoCustom.CreateBSB(doc, jzxinfos); Dictionary <string, XMLObject> jsydXML = XMLRead.XmlToObjects(JSYDCustom.JSYDXMLPath); WordWrite.ReplaceText(doc, jsydXML, jsyd); Dictionary <string, XMLObject> xzdmXML = XMLRead.XmlToObjects(JSYDCustom.ZJDXZDMMLPath); WordWrite.ReplaceText(doc, xzdmXML, jsyd.ZJDXZDM); Dictionary <string, XMLObject> jtcyXML = XMLRead.XmlToObjects(JSYDCustom.JTCYXMLPath); WordWrite.ReplaceText(doc, jtcyXML, jsyd.HZs[0]); Dictionary <string, XMLObject> nfXML = XMLRead.XmlToObjects(JSYDCustom.NFXMLPath); WordWrite.ReplaceText(doc, nfXML, jsyd.NFs[0]); Dictionary <string, string> replaceDic = new Dictionary <string, string>(); replaceDic.Add("Company", "四川旭普信息产业发展有限公司"); string zdnum = jsyd.ZDNUM; replaceDic.Add("Qjbh", zdnum.Substring(6, 3) + "-" + zdnum.Substring(9, 3) + "-" + zdnum.Substring(12, 2) + "-" + zdnum.Substring(14, 5)); //本宗地已取得原土地使用证: 简镇清集用(1990)字第0304 - 37号; 原房屋所有权证: 简农房权字第1002010383号; StringBuilder sb = new StringBuilder(); string str = jsyd.YTDSYZSH; if (!Utils.IsStrNull(str)) { sb.Append("原土地使用证:" + str + ";"); } str = jsyd.NFs[0].SYQZH; if (!Utils.IsStrNull(str)) { sb.Append("原房屋所有权证:" + str + ";"); } if (sb.Length > 0) { sb.Insert(0, "本宗地已取得"); } replaceDic.Add("Tag0", sb.ToString()); WordWrite.ReplaceText(doc, replaceDic); string saveName = GetZJDSaveFileName(jsyd, saveDir, docTempletePath); WordWrite.SaveToFile(doc, saveName); }
/// <summary> /// 检查农房表 /// </summary> /// <param name="jsyd"></param> /// <param name="nfs"></param> private string CheckNF(IList <NF> nfs, int cellIndex) { StringBuilder sb = new StringBuilder(); NF nf = nfs[0]; double tem = 0; //检查层数 int csInt; foreach (NF nf1 in nfs) { tem += nf1.CJZMJ; if (nf1.SZC == null) { continue; } string[] csArray = nf1.SZC.Split('、'); foreach (string csStr in csArray) { if (int.TryParse(csStr, out csInt)) { if (nf.ZCS < csInt) { sb.Append("、所在层中有 大于 总层 的数字"); CheckZJDWriteError(nf1.Row, cellIndex, "、所在层中有 大于 总层 的数字"); } } else { sb.Append("、所在层中填写有不是数字"); CheckZJDWriteError(nf1.Row, cellIndex, "、所在层中填写有不是数字"); } } if (nf1.CZTJG + "结构" != nf1.JG) { sb.Append("、层主体结构 与 结构一致"); CheckZJDWriteError(nf1.Row, cellIndex, "、层主体结构一致"); } } if (Math.Abs(nf.JZMJ - tem) > 0.001) { sb.Append("、层建筑面积 与 建筑面积不相等"); CheckZJDWriteError(nf.Row, cellIndex, "、层建筑面积 与 建筑面积不相等字"); } if (nf.JZMJ < nf.FZMJ) { sb.Append("、层建筑面积 小于 建筑面积"); CheckZJDWriteError(nf.Row, cellIndex, "、层建筑面积 小于 建筑面积"); } for (int a = 1; a < nfs.Count; a++) { NF temNF = nfs[a]; if (nf.SYQZH != temNF.SYQZH) { sb.Append("、所有权号不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、所有权号不一致"); } if (nf.QLRMC != temNF.QLRMC) { sb.Append("、权利人名称不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、权利人名称不一致"); } if (nf.ZJHM != temNF.ZJHM) { sb.Append("、证件号码不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、证件号码不一致"); } if (nf.ZCS != temNF.ZCS) { sb.Append("、总层数不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、总层数不一致"); } if (nf.JZMJ != temNF.JZMJ) { sb.Append("、建筑面积不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、建筑面积不一致"); } if (nf.ZCS != temNF.CS) { sb.Append("、总层数 与 层数不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、总层数 与 层数不一致"); } if (nf.FWLY != temNF.FWLY) { sb.Append("、房屋来源 不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、房屋来源 不一致"); } if (nf.YJTTDSYZ != temNF.YJTTDSYZ) { sb.Append("、土地权属来源(是否有原件)不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、房屋来源 不一致"); } if (nf.YFWSYQZ != temNF.YFWSYQZ) { sb.Append("、房屋权属来源(是否有原件)不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、房屋权属来源(是否有原件)不一致"); } if (nf.JGRQ != temNF.JGRQ) { sb.Append("、竣工日期不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、竣工日期不一致"); } if (nf.ZL != temNF.ZL) { sb.Append("、坐落不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、坐落不一致"); } if (nf.ZL != temNF.ZL) { sb.Append("、产权来源不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、产权来源不一致"); } if (nf.ZL != temNF.ZL) { sb.Append("、产权来源不一致"); CheckZJDWriteError(temNF.Row, cellIndex, "、产权来源不一致"); } } //(nf.YJTTDSYZ == "已提交原件" || nf.YFWSYQZ == "已提交原件") || ( if (nf.YJTTDSYZ == "未确权颁证" && nf.YFWSYQZ == "未确权颁证") { if (nf.FWLY != "其他情形") { sb.Append("、房屋来源不是其他情形"); CheckZJDWriteError(nf.Row, cellIndex, "、产权来源不一致"); } if (nf.CQLY != "自建") { sb.Append("、产权来源不是自建"); CheckZJDWriteError(nf.Row, cellIndex, "、产权来源不是自建"); } } else { if (!(nf.FWLY == "改建扩建" || nf.FWLY == "其他情形")) { sb.Append("、房屋来源不是改建扩建"); CheckZJDWriteError(nf.Row, cellIndex, "、房屋来源不是改建扩建、其他情形"); } if (!(nf.CQLY == "翻建" || nf.CQLY == "自建")) { sb.Append("、产权来源不是翻建"); CheckZJDWriteError(nf.Row, cellIndex, "、产权来源不是翻建、自建"); } } if (Utils.IsStrNull(nf.SYQZH)) { if (nf.YFWSYQZ != "未确权颁证") { sb.Append("、无证号,但填写的是 确权颁证"); CheckZJDWriteError(nf.Row, cellIndex, "、无证号,但填写的是 确权颁证"); } } else { if (nf.YFWSYQZ == "未确权颁证") { sb.Append("、有证号,但填写的是 未确权颁证"); CheckZJDWriteError(nf.Row, cellIndex, "、有证号,但填写的是 未确权颁证"); } } if (sb.Length > 0) { sb.Insert(0, "农房表自查:"); return(sb.ToString()); } return(""); }
public IList <string> CheckZJD(JSYD jsyd, ZJDDataSourceViewModel model) { IList <string> erros = new List <string>(); ZJDXZDM xzdm = jsyd.ZJDXZDM; Zdinfo zdinfo = jsyd.Zdinfo; string error; if (zdinfo == null) { CheckZJDWriteError(jsyd.Row, model.JSYDTableErrorCellIndex, "未找到宗地表"); erros.Add("未找到宗地表"); } else { error = CheckJSYD_Zdinfo(jsyd, zdinfo, model.JSYDTableErrorCellIndex); if (error != "") { erros.Add(error); } } IList <NF> nfs = jsyd.NFs; if (nfs == null) { CheckZJDWriteError(jsyd.Row, model.JSYDTableErrorCellIndex, "未找到农房表"); erros.Add("未找到农房表"); } else { error = CheckNF(nfs, model.NFTableErrorCellIndex); if (error != "") { erros.Add(error); } IList <Floor> floors = jsyd.Floors; if (floors == null) { CheckZJDWriteError(jsyd.Row, model.JSYDTableErrorCellIndex, "未找到分层表"); erros.Add("未找到分层表"); } else { if (Utils.IsStrNull(jsyd.YTDSYZSH) && nfs[0].YJTTDSYZ != "未确权颁证") { erros.Add("无土地证 农房表 填写的不是 未确权颁证"); } error = CheckFloor(floors, model.FloorTableErrorCellIndex); if (error != "") { erros.Add(error); } error = CheckNF_Floor(nfs, floors, model.FloorTableErrorCellIndex); if (error != "") { erros.Add(error); } } } IList <JTCY> hzs = jsyd.HZs; CheckHZs(hzs, model.JTCYTableErrorCellIndex); IList <QZB> qzbs = jsyd.QZBs; IList <JZXInfo> jzxInfos = jsyd.JZXInfos; return(erros); }