python 输出设施农用地材料
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
import sys
import time, os, win32com.client, shutil, traceback
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QAction
from PyQt5.QtWidgets import QMessageBox
import jm, jm_cjxm, jm_jjzz
import globalvar as gl
gl._init()
def create_txt(file2):
file2.write(‘用地人:\n’)
file2.write(‘证件号:\n’)
file2.write(‘法人代表:\n’)
file2.write(‘电话号码:\n’)
file2.write(‘项目名称:\n’)
file2.write(‘项目地址:\n’)
file2.write(‘养殖类型:\n’)
file2.write(‘生成设施:\n’)
file2.write(‘附属设施:\n’)
file2.write(‘四至东:\n’)
file2.write(‘四至南:\n’)
file2.write(‘四至西:\n’)
file2.write(‘四至北:\n’)
file2.write(‘协议编号:\n’)
file2.write(‘协议签订时间:2000/1/1\n’)
file2.write(‘起始时间:2000/1/1\n’)
file2.write(‘结束时间:2000/1/1\n’)
file2.write(‘权利人类型:\n’)
# 地类分析表\n’)
file2.write(‘生产耕地面积:\n’)
file2.write(‘生产园地面积:\n’)
file2.write(‘生产养殖坑塘:\n’)
file2.write(‘生产未利用地:\n’)
file2.write(‘生产建设用地:\n’)
file2.write(‘生产其他农用地:\n’)
file2.write(‘生产林地面积:\n’)
file2.write(‘生产水田面积:\n’)
file2.write(‘附属耕地面积:\n’)
file2.write(‘附属园地面积:\n’)
file2.write(‘附属养殖坑塘:\n’)
file2.write(‘附属未利用地:\n’)
file2.write(‘附属建设用地:\n’)
file2.write(‘附属其他农用地:\n’)
file2.write(‘附属林地面积:\n’)
file2.write(‘附属水田面积:\n’)
file2.write(‘生产面积:\n’)
file2.write(‘附属面积:\n’)
# 村委信息\n’)
file2.write(‘经济组织:\n’)
file2.write(‘组织机构代码:\n’)
file2.write(‘村委地址:\n’)
file2.write(‘村名简称:\n’)
# 政府信息\n’)
file2.write(‘镇名:\n’)
file2.write(‘镇联系人:\n’)
file2.write(‘镇联系电话:\n’)
# 矢量信息\n’)
file2.write(‘项目总图:\n’)
file2.write(‘生产设施图:\n’)
file2.write(‘附属设施图:\n’)
file2.write(‘影像图:\n’)
file2.write(‘制图员:\n’)
file2.write(‘制图日期:2000/1/1\n’)
file2.write(‘保存路径:\n’)
class fu(QDialog):
def cjxm(self):
gcxmmc1 = self.child.lineEdit.text()
gcpath1 = self.child.lineEdit_2.text()
if gcxmmc1 == ‘’ or gcpath1 == ‘’:
QMessageBox.information(None, ‘提示’, ‘【工程项目名称】与【工程项目路径】不能为空’)
else:
try:
os.mkdir(os.path.join(gcpath1, gcxmmc1))
os.mkdir(os.path.join(gcpath1, gcxmmc1, ‘temp’))
gl.set_value(‘ye_gcxmmc’, gcxmmc1)
gl.set_value(‘ye_gcpath’, gcpath1)
path_txt = os.path.join(gcpath1, gcxmmc1, ‘temp’, ‘项目信息.txt’)
file2 = open(path_txt, ‘w+’)
create_txt(file2)
child_td.close()
child_jtcy.main_ui.frame.setVisible(True)
except:
if QMessageBox.information(None, ‘提示’, ‘工程路径已存在【%s】是否替换调工程,否的话将用-1进行命名】’%gcxmmc1,
QMessageBox.Yes | QMessageBox.No) == 16384:
try:
os.mkdir(os.path.join(gcpath1, gcxmmc1, ‘temp’))
except:
pass
gl.set_value(‘ye_gcxmmc’, gcxmmc1)
gl.set_value(‘ye_gcpath’, gcpath1)
path_txt = os.path.join(gcpath1, gcxmmc1, ‘temp’, ‘项目信息.txt’)
file2 = open(path_txt, ‘w+’)
create_txt(file2)
child_td.close()
child_jtcy.main_ui.frame.setVisible(True)
else:
gcxmmc1 = ‘%s-1’%gcxmmc1
os.mkdir(os.path.join(gcpath1, gcxmmc1))
os.mkdir(os.path.join(gcpath1, gcxmmc1, ‘temp’))
gl.set_value(‘ye_gcxmmc’, gcxmmc1)
gl.set_value(‘ye_gcpath’, gcpath1)
path_txt = os.path.join(gcpath1, gcxmmc1, ‘temp’, ‘项目信息.txt’)
file2 = open(path_txt, ‘w+’)
create_txt(file2)
child_td.close()
child_jtcy.main_ui.frame.setVisible(True)
def askdirectory_xz(self):
""""""
_translate = QtCore.QCoreApplication.translate
folder = QFileDialog.getExistingDirectory()
self.child.lineEdit_2.setText(_translate("Form", folder))
def __init__(self, ):
QDialog.__init__(self)
self.child = jm_cjxm.Ui_Dialog()
self.child.setupUi(self)
self.child.pushButton.clicked.connect(self.cjxm)
self.child.toolButton.clicked.connect(self.askdirectory_xz)
class jjzz(QMainWindow):
def init(self, MainWindow):
QMainWindow.init(self)
self.main_jjzz = jm_jjzz.Ui_MainWindow()
self.main_jjzz.setupUi(self)
self.select_txt_jjzz()
self.main_jjzz.lineEdit.editingFinished.connect(self.ed_jjzz)
self.main_jjzz.tableWidget.doubleClicked.connect(self.double_value)
def double_value(self):
item = self.main_jjzz.tableWidget.selectedItems()
if item:
tem = self.main_jjzz.tableWidget.indexFromItem(item[0]).row()
jjzzmc = self.main_jjzz.tableWidget.item(tem, 0).text()
jjzzdm = self.main_jjzz.tableWidget.item(tem, 1).text()
child_jtcy.main_ui.jjzz.setText(jjzzmc)
child_jtcy.main_ui.zzjgdm.setText(jjzzdm)
child_jjzz.close()
def ye(self, row, col, text):
#print(row, col)
item = QtWidgets.QTableWidgetItem()
self.main_jjzz.tableWidget.setItem(row, col, item)
item = self.main_jjzz.tableWidget.item(row, col)
item.setText(text)
def print_huxx(self, list_huxx1):
i = 0
# print(list_huxx1)
for hbmxx in list_huxx1:
list = hbmxx.split('$')
self.ye(i, 0, list[0])
self.ye(i, 1, list[1])
i += 1
def select_txt_jjzz(self):
path_txt = os.path.join(os.path.split(sys.argv[0])[0], 'temp', 'jjzzxx.txt')
self.list1 = []
with open(path_txt) as f:
for line in f.readlines():
list_txt = line.split('\n')[0]
self.list1.append(list_txt)
def ed_jjzz(self):
text = self.main_jjzz.lineEdit.text()
self.jjzzxx = []
for jjzzs in self.list1:
if text in jjzzs:
self.jjzzxx.append(jjzzs)
self.main_jjzz.tableWidget.setRowCount(len(self.jjzzxx))
self.print_huxx(self.jjzzxx)
#打开工程项目
def open_gcxm():
list1 = {}
folder = QFileDialog.getExistingDirectory()
try:
gcpath, gcxmmc = os.path.split(folder)
gl.set_value(‘ye_gcxmmc’, gcxmmc)
gl.set_value(‘ye_gcpath’, gcpath)
with open(os.path.join(folder, ‘temp’, ‘项目信息.txt’)) as f:
for line in f.readlines():
list_txt = line.replace(‘\n’, ‘’).split(‘:’)
list1[list_txt[0]] = list_txt[1]
child_jtcy.main_ui.frame.setVisible(True)
child_jtcy.main_ui.ydr.setText(list1['用地人'])
child_jtcy.main_ui.zjh.setText(list1['证件号'])
child_jtcy.main_ui.frdb.setText(list1['法人代表'])
child_jtcy.main_ui.dhhm.setText(list1['电话号码'])
child_jtcy.main_ui.xmmc.setText(list1['项目名称'])
child_jtcy.main_ui.xmdz.setText(list1['项目地址'])
child_jtcy.main_ui.yzlx.setItemText(0, list1['养殖类型'])
#child_jtcy.main_ui.yzlx.setText(list1['养殖类型'])
child_jtcy.main_ui.scss.setText(list1['生成设施'])
child_jtcy.main_ui.fsss.setText(list1['附属设施'])
child_jtcy.main_ui.szd.setText(list1['四至东'])
child_jtcy.main_ui.szn.setText(list1['四至南'])
child_jtcy.main_ui.szx.setText(list1['四至西'])
child_jtcy.main_ui.szb.setText(list1['四至北'])
child_jtcy.main_ui.xybh.setText(list1['协议编号'])
child_jtcy.main_ui.xyqdsj.setDisplayFormat(list1['协议签订时间'])
child_jtcy.main_ui.qssj.setDisplayFormat(list1['起始时间'])
child_jtcy.main_ui.jssj.setDisplayFormat(list1['结束时间'])
# 获取地类分析表.setText(list1[''])
child_jtcy.main_ui.gdmj.setText(list1['生产耕地面积'])
child_jtcy.main_ui.ydmj.setText(list1['生产园地面积'])
child_jtcy.main_ui.yzkt.setText(list1['生产养殖坑塘'])
child_jtcy.main_ui.wlyd.setText(list1['生产未利用地'])
child_jtcy.main_ui.jsyd.setText(list1['生产建设用地'])
child_jtcy.main_ui.qtnyd.setText(list1['生产其他农用地'])
child_jtcy.main_ui.ldmj.setText(list1['生产林地面积'])
child_jtcy.main_ui.stmj.setText(list1['生产水田面积'])
child_jtcy.main_ui.gdmj_2.setText(list1['附属耕地面积'])
child_jtcy.main_ui.ydmj_2.setText(list1['附属园地面积'])
child_jtcy.main_ui.yzkt_2.setText(list1['附属养殖坑塘'])
child_jtcy.main_ui.wlyd_2.setText(list1['附属未利用地'])
child_jtcy.main_ui.jsyd_2.setText(list1['附属建设用地'])
child_jtcy.main_ui.qtnyd_2.setText(list1['附属其他农用地'])
child_jtcy.main_ui.ldmj_2.setText(list1['附属林地面积'])
child_jtcy.main_ui.stmj_2.setText(list1['附属水田面积'])
child_jtcy.main_ui.qlrlx.setItemText(0, list1['权利人类型'])
child_jtcy.main_ui.sctxmj.setText(list1['生产面积'])
child_jtcy.main_ui.sstxmj.setText(list1['附属面积'])
# 村委信息.setText(list1[''])
child_jtcy.main_ui.jjzz.setText(list1['经济组织'])
child_jtcy.main_ui.zzjgdm.setText(list1['组织机构代码'])
child_jtcy.main_ui.cwdz.setText(list1['村委地址'])
child_jtcy.main_ui.cmjc.setText(list1['村名简称'])
# 政府信息.setText(list1[''])
child_jtcy.main_ui.zm.setText(list1['镇名'])
child_jtcy.main_ui.zlxr.setText(list1['镇联系人'])
child_jtcy.main_ui.zlxdh.setText(list1['镇联系电话'])
# 矢量信息.setText(list1[''])
child_jtcy.main_ui.xmzt.setText(list1['项目总图'])
child_jtcy.main_ui.scsst.setText(list1['生产设施图'])
child_jtcy.main_ui.fssst.setText(list1['附属设施图'])
child_jtcy.main_ui.yxt.setText(list1['影像图'])
child_jtcy.main_ui.zty.setText(list1['制图员'])
list_date = list1['制图日期'].split('/')
child_jtcy.main_ui.ztrq.setDate(QtCore.QDate(int(list_date[0]), int(list_date[1]), int(list_date[2])))
except:
QMessageBox.information(None, '提示', '请确保【%s】是有效的工'
'程项目\n出错了%s\n' % (folder, traceback.format_exc()))
class zhu(QMainWindow):
def init(self, MainWindow):
QMainWindow.init(self)
self.main_ui = jm.Ui_MainWindow()
self.main_ui.setupUi(self)
#self.main_ui.action11.triggered.connect(fu)
if name == ‘main’:
app = QApplication(sys.argv)
MainWindow = QMainWindow()
child_td = fu()
child_jtcy = zhu(MainWindow)
child_jjzz = jjzz(MainWindow)
import setup
setup.main(child_jtcy.main_ui)
#child_jtcy.setWindowTitle(“精测房地一体数据转换程序”)
child_jtcy.main_ui.frame.setVisible(False)
child_jtcy.main_ui.action11.triggered.connect(child_td.show)
child_jtcy.main_ui.action11_2.triggered.connect(open_gcxm)
child_jtcy.main_ui.toolButton_jjzz.clicked.connect(child_jjzz.show)
child_jtcy.show()
sys.exit(app.exec_())