def firstexalist(): """初审信息列表""" g.__setattr__("action", "examine.firstexalist") page = int(request.form.get("page", 1)) pagesize = int(request.form.get("page_size", 10)) action = request.form.get("action", "") # 查询条件 _county = int(request.form.get("county", 0)) inquirylist = Inquiry.query if _county: inquirylist = inquirylist.filter_by(project_address1=_county) inquirylist = inquirylist.order_by("apply_time desc").all() for inquiry in inquirylist: inquiry.project_address2 = ( COUNTY_CHOICES.__getitem__(inquiry.project_address1 - 1)[1] + "-" + inquiry.project_address2_time.strftime("%Y-%m-%d") ) inquiry.apply_time = inquiry.apply_time.strftime("%Y-%m-%d") if action == "export": return redirect(inquiry_excel_created(inquirylist)) pagination = Pagination(inquirylist, page, pagesize) inquirylist = pagination.list() return render_template( "/examine/inquirylist.html", inquirylist=inquirylist, countys=COUNTY_CHOICES, pagination=pagination, _county=str(_county), page=page, page_size=pagesize, )
def preexalist(): """预审信息""" g.__setattr__("action", "examine.preexalist") page = int(request.form.get("page", 1)) pagesize = int(request.form.get("page_size", 10)) action = request.form.get("action", "") # 查询条件 _county = int(request.form.get("county", 0)) reviewlist = Review.query if _county: reviewlist = reviewlist.filter_by(project_address1=_county) reviewlist = reviewlist.order_by("apply_time desc").all() for review in reviewlist: review.project_address2 = ( COUNTY_CHOICES.__getitem__(review.project_address1 - 1)[1] + "-" + review.project_address2 ) review.examine_time = review.examine_time.strftime("%Y-%m-%d") review.apply_time = review.apply_time.strftime("%Y-%m-%d") if action == "export": return redirect(review_excel_created(reviewlist)) pagination = Pagination(reviewlist, page, pagesize) reviewlist = pagination.list() return render_template( "/examine/reviewlist.html", reviewlist=reviewlist, countys=COUNTY_CHOICES, pagination=pagination, page=page, page_size=pagesize, _county=str(_county), )
def ground_excel_created(_QuerySet, name=u"ground"): wbk = xlwt.Workbook() sheet = wbk.add_sheet('sheet 1') sheet.write(0,0, u'序号(批次编号)') sheet.write(0,1, u'项目名称') sheet.write(0,2, u'项目类型') sheet.write(0,3, u'土地用途') sheet.write(0,4, u'地块编号') sheet.write(0,5, u'配套指标类别') sheet.write(0,6, u'配套面积') sheet.write(0,7, u'耕地面积') sheet.write(0,8, u'未用地面积') sheet.write(0,9, u'地块面积') sheet.write(0,10, u'新增建设用地面积') sheet.write(0,11, u'区县') sheet.write(0,12, u'安排指标依据') sheet.write(0,13, u'其他农用地面积') row_start_index = 0 for item in _QuerySet: row_start_index += 1 sheet.write(row_start_index,0, item.batch_name) sheet.write(row_start_index,1, item.project_name) sheet.write(row_start_index,2, PROJECT_TYPE_CHOICES.__getitem__(item.project_type-1)[1]) sheet.write(row_start_index,3, GROUND_USE_TYPE_CHOICES.__getitem__(item.used_type-2)[1]) sheet.write(row_start_index,4, item.ground_num) sheet.write(row_start_index,5, item.match_target_type) sheet.write(row_start_index,6, item.match_area) sheet.write(row_start_index,7, item.plough_area) sheet.write(row_start_index,8, item.unused_area) sheet.write(row_start_index,9, item.total_area) sheet.write(row_start_index,10, item.stock_const_area) sheet.write(row_start_index,11, COUNTY_CHOICES.__getitem__(item.county-1)[1]) sheet.write(row_start_index,12, item.target_according) sheet.write(row_start_index,13, item.other_farmland) wbk.save(current_app.config['PROJECT_DIR']+'/static/xls/%s.xls'%name) return "/static/xls/%s.xls"%name
def num2county(n): return COUNTY_CHOICES.__getitem__(n-1)[1]