import json
data=json.load(open('/data/www/files/ggzy_final.json'))
out=[]
for o in data:
    out.append({
        "title":o["title"],
        "buyer":o["buyer"],
        "budget":("未披露" if o["budget"] is None else f'{o["budget"]:g}'),
        "pub_date":o["date"],
        "url":o["url"],
        "source":"四川省公共资源交易信息网",
        "type":"中标公告" if o["cat"]=="002002003" else "招标公告",
    })
out.sort(key=lambda x:(x["pub_date"],x["type"]),reverse=True)
json.dump(out,open('/data/www/files/ggzy_final_out.json','w'),ensure_ascii=False,indent=1)
print(json.dumps(out,ensure_ascii=False,indent=1))
print("COUNT",len(out))
