def get(self, lcid): enterprise = Enterprise.objects(lcid=lcid).first() entprerelations = Entprerelation.objects(enttarget=lcid) entsrelations = Entsrelation.objects(entsource=lcid) entpatents = Entpatent.objects(lcid=lcid) obj = {} obj["enterprise"] = self.load_json(enterprise) obj["entprerelations"] = self.load_json(entprerelations) obj["entsrelations"] = self.load_json(entsrelations) obj["entpatents"] = self.load_json(entpatents) # relEnts = Entsrelation.objects(entsource=lcid).to_json() # print len(relEnts) if enterprise: return Status(200, 'success', obj).result else: return Status(404, 'fail', {'title': 'Not Found'}).result
def get(self, lcid): enterprise = Enterprise.objects(lcid=lcid).first() entprerelations = Entprerelation.objects(enttarget=lcid) entsrelations = Entsrelation.objects(entsource=lcid) entpatents = Entpatent.objects(lcid=lcid) obj = {} obj["enterprise"] = self.load_json(enterprise) obj["entprerelations"] = self.load_json(entprerelations) obj["entsrelations"] = self.load_json(entsrelations) obj["entpatents"] = self.load_json(entpatents) # relEnts = Entsrelation.objects(entsource=lcid).to_json() # print len(relEnts) if enterprise: return Status(200, 'success', obj).result else: return Status(404, 'fail', {'title':'Not Found'}).result
def getRelEnts(self, lcid): # 获得企业的相关企业信息 obj = {} obj["children"] = [] obj["parent"] = json.loads(Enterprise.objects(lcid=lcid).only("lcid", "entname", "regcap", "entindustry").first().to_json()) childrens = json.loads(Entsrelation.objects(entsource=lcid).only("enttarget", "entname", "entsource").to_json()) obj["investment"] = json.loads(Entprerelation.objects(enttarget=lcid).only("entpre", "conprop").to_json()) for relent in childrens: if Enterprise.objects(lcid=relent["enttarget"]).first() is not None: obj["children"].append(relent) self.rawdata.append(obj) # 自动递归 if len(obj["children"]): for relent in obj["children"]: self.getRelEnts(relent["enttarget"])