def createTender(self, jsonInfo): info = json.loads(jsonInfo) # tenderID = info['tenderID'] title = info['title'] cityID = info['cityID'] location = info['location'] url = info['url'] publishDate = info['publishDate'] detail = info['detail'] biddingNum = info['biddingNum'] reviewType = info['reviewType'] typeID = info['typeID'] tenderID = self.generateID(title) (status, reason) = self.doesTenderExists(info=info) if status is True: return (False, ErrorInfo['TENDER_15']) tender = Tender(tenderID=tenderID, title=title, cityID=cityID, location=location, url=url, publishDate=publishDate, detail=detail, typeID=typeID, biddingNum=biddingNum, reviewType=reviewType) tenderSlave = TenderSlave(tenderID=tenderID, title=title, biddingNum=biddingNum) info['tenderID'] = tenderID try: db.session.add(tender) db.session.add(tenderSlave) info['searchName'] = info['title'] info['description'] = info['detail'] info['foreignID'] = info['tenderID'] info['tag'] = SEARCH_KEY_TAG_TENDRE now = datetime.now() info['createTime'] = str(now) info['joinID'] = self.generateID(info['title']) SearchKey.createSearchInfo(info=info) db.session.commit() task1.createWeChatPush.apply_async(args=[info]) except Exception as e: print str(e) # traceback.print_stack() db.session.rollback() errorInfo = ErrorInfo['TENDER_02'] errorInfo['detail'] = str(e) return (False, errorInfo) return (True, None)
def createWinBidding(self, jsonInfo): info = json.loads(jsonInfo) title = info['title'].replace('\'', '\\\'').replace('\"', '\\\"').strip() publishDate = info['publishDate'].replace('\'', '\\\'').replace( '\"', '\\\"') biddingNum = info['biddingNum'].replace('\'', '\\\'').replace('\"', '\\\"') detail = info['detail'] cityID = info['cityID'].replace('\'', '\\\'').replace('\"', '\\\"') biddingID = self.generateID(biddingNum) # biddingNum = self.getMD5String(biddingNum.strip()) (status, reason) = self.doesBiddingExists(info=info) if status is True: return (False, ErrorInfo['TENDER_17']) if len(title) > 90: title = title[0:90] winBidding = WinBiddingPub(biddingID=biddingID, title=title, publishDate=publishDate, biddingNum=biddingNum, detail=detail, cityID=cityID) winBiddingPubSlave = WinBiddingPubSlave(biddingID=biddingID, title=title, biddingNum=biddingNum) try: db.session.add(winBidding) db.session.add(winBiddingPubSlave) info['searchName'] = title info['description'] = detail info['foreignID'] = biddingID info['tag'] = SEARCH_KEY_TAG_WIN_BIDDING now = datetime.now() info['createTime'] = str(now) info['joinID'] = self.generateID(info['title']) SearchKey.createSearchInfo(info=info) db.session.commit() except Exception as e: # traceback.print_stack() db.session.rollback() print e errorInfo = ErrorInfo['TENDER_02'] errorInfo['detail'] = str(e) return (False, errorInfo) return (True, biddingID)
def regenerateInfo(result): bidInfo = {} bidInfo['biddingID'] = result.biddingID bidInfo['title'] = result.title bidInfo['biddingNum'] = result.biddingNum bidInfo['publishDate'] = result.publishDate bidInfo['joinID'] = self.generateID(bidInfo['biddingID']) (status, addSearchInfo) = SearchKey.createSearchInfo(bidInfo)
def create(keywords): keywords = keywords.strip() if len(keywords) > 0: subscribedID = self.generateID(keywords) createInfo = {} createInfo['subscribedID'] = subscribedID createInfo['userID'] = userID createInfo['keywords'] = keywords createInfo['createTime'] = datetime.now() createInfo['frequency'] = frequency createInfo['pushType'] = pushType createInfo['searchName'] = keywords createInfo['foreignID'] = userID createInfo['searchName'] = keywords createInfo['joinID'] = subscribedID createInfo['tag'] = SEARCH_KEY_TAG_SUBSCRIBE SubscribedKey.create(createInfo=createInfo) SearchKey.createSearchInfo(info=createInfo)
def regenerateInfo(result): tenderInfo = {} tenderInfo['foreignID'] = result.tenderID tenderInfo['searchName'] = result.title tenderInfo['location'] = result.location tenderInfo['publishDate'] = result.publishDate tenderInfo['joinID'] = self.generateID(result.tenderID) tenderInfo['tag'] = SEARCH_KEY_TAG_TENDRE tenderInfo['createTime'] = datetime.now() (status, addSearchInfo) = SearchKey.createSearchInfo(tenderInfo)
def deleteTenderBackground(self, jsonInfo): info = json.loads(jsonInfo) tokenID = info['tokenID'] (status, userID) = self.isTokenValid(tokenID) if not status: errorInfo = ErrorInfo['TENDER_01'] return (False, errorInfo) try: (status, result) = SearchKey.deleteSearchKey(info) if status: (status, result) = Tender.delete(info) db.session.commit() except Exception as e: print str(e) # traceback.print_stack() db.session.rollback() errorInfo = ErrorInfo['TENDER_02'] errorInfo['detail'] = str(e) return (False, errorInfo) return (True, None)
def createCompany(self, jsonInfo): info = json.loads(jsonInfo) companyName = info['companyName'].replace('\'', '\\\'').replace('\"', '\\\"') newArchiveID = info['newArchiveID'].replace('\'', '\\\'').replace('\"', '\\\"') registerArea = info['registerArea'].replace('\'', '\\\'').replace('\"', '\\\"') companyAreaType = info['companyAreaType'].replace('\'', '\\\'').replace('\"', '\\\"') certificateID = info['certificateID'].replace('\'', '\\\'').replace('\"', '\\\"') certificationAuthority = info['certificationAuthority'].replace('\'', '\\\'').replace('\"', '\\\"') legalRepresentative = info['legalRepresentative'].replace('\'', '\\\'').replace('\"', '\\\"') enterprisePrincipal = info['enterprisePrincipal'].replace('\'', '\\\'').replace('\"', '\\\"') technologyDirector = info['technologyDirector'].replace('\'', '\\\'').replace('\"', '\\\"') remarks = info['remarks'].replace('\'', '\\\'').replace('\"', '\\\"') licenseID = info['licenseID'].replace('\'', '\\\'').replace('\"', '\\\"') registeredCapital = info['registeredCapital'] companyType = info['companyType'].replace('\'', '\\\'').replace('\"', '\\\"') foundingTime = info['foundingTime'] businessTermFrom = info['businessTermFrom'].replace('\'', '\\\'').replace('\"', '\\\"') safetyProductionPermitID = info['safetyProductionPermitID'].replace('\'', '\\\'').replace('\"', '\\\"') safePrincipal = info['safePrincipal'].replace('\'', '\\\'').replace('\"', '\\\"') businessScope = info['businessScope'].replace('\'', '\\\'').replace('\"', '\\\"') safeAuthority = info['safeAuthority'].replace('\'', '\\\'').replace('\"', '\\\"') safeFromDate = info['safeFromDate'] safeEndDate = info['safeEndDate'] creditBookID = info['creditBookID'].replace('\'', '\\\'').replace('\"', '\\\"') creditScore1 = info['creditScore1'] creditScore2 = info['creditScore2'] creditEndDate = info['creditEndDate'] creditAuthority = info['creditAuthority'].replace('\'', '\\\'').replace('\"', '\\\"') creditAddress = info['creditAddress'].replace('\'', '\\\'').replace('\"', '\\\"') creditWebSet = info['creditWebSet'].replace('\'', '\\\'').replace('\"', '\\\"') creditContact = info['creditContact'].replace('\'', '\\\'').replace('\"', '\\\"') creditNjAddress = info['creditNjAddress'].replace('\'', '\\\'').replace('\"', '\\\"') creditNjPrincipal = info['creditNjPrincipal'].replace('\'', '\\\'').replace('\"', '\\\"') creditNjTech = info['creditNjTech'].replace('\'', '\\\'').replace('\"', '\\\"') creditFinancialStaff = info['creditFinancialStaff'].replace('\'', '\\\'').replace('\"', '\\\"') companyBrief = info['companyBrief'].replace('\'', '\\\'').replace('\"', '\\\"') companyID = self.generateID(companyName) (status, reason) = self.doesCompanyExists(info=info) if status is True: errorInfo = ErrorInfo['TENDER_18'] errorInfo['detail'] = reason return (False, errorInfo) if creditScore1 == '': creditScore1 = 0 if creditScore2 == '': creditScore2 = 0 if safeEndDate == '': safeEndDate = None if safeFromDate == '': safeFromDate = None if foundingTime == '': foundingTime = None if businessTermFrom == '': businessTermFrom = None if creditEndDate == '': creditEndDate = None company = Company(companyID=companyID, companyName=companyName, newArchiveID=newArchiveID, registerArea=registerArea, companyAreaType=companyAreaType, certificateID=certificateID, certificationAuthority=certificationAuthority, legalRepresentative=legalRepresentative, enterprisePrincipal=enterprisePrincipal, technologyDirector=technologyDirector, remarks=remarks, licenseID=licenseID, registeredCapital=registeredCapital, companyType=companyType, foundingTime=foundingTime, businessTermFrom=businessTermFrom, safetyProductionPermitID=safetyProductionPermitID, safePrincipal=safePrincipal, businessScope=businessScope, safeAuthority=safeAuthority, safeFromDate=safeFromDate, safeEndDate=safeEndDate, creditBookID=creditBookID, creditScore1=creditScore1, creditScore2=creditScore2, creditEndDate=creditEndDate, creditAuthority=creditAuthority, creditAddress=creditAddress, creditWebSet=creditWebSet, creditContact=creditContact, creditNjAddress=creditNjAddress, creditNjPrincipal=creditNjPrincipal, creditNjTech=creditNjTech, creditFinancialStaff=creditFinancialStaff, companyBrief=companyBrief) companyAssistant = CompanyAssistant(companyID=companyID, companyName=companyName, foreignCompanyID=companyID) try: db.session.add(company) db.session.add(companyAssistant) #添加搜索记录 searchInfo = {} searchInfo['searchName'] = info['companyName'] searchInfo['foreignID'] = companyID searchInfo['tag'] = SEARCH_KEY_TAG_COMPANY now = datetime.now() searchInfo['createTime'] = str(now) searchInfo['joinID'] = self.generateID(info['companyName']) SearchKey.createSearchInfo(info=searchInfo) db.session.commit() except Exception as e: # traceback.print_stack() db.session.rollback() print e errorInfo = ErrorInfo['TENDER_02'] errorInfo['detail'] = str(e) return (False, errorInfo) return (True, companyID)
def createProjectManager(self, jsonInfo): info = json.loads(jsonInfo) managerName = info['managerName'].replace('\'', '\\\'').replace( '\"', '\\\"') gender = info['gender'] positionalTitles = info['positionalTitles'].replace('\'', '\\\'').replace( '\"', '\\\"') post = info['post'].replace('\'', '\\\'').replace('\"', '\\\"') safetyAssessment = info['safetyAssessment'].replace('\'', '\\\'').replace( '\"', '\\\"') safeEndDate = info['safeEndDate'].replace('\'', '\\\'').replace( '\"', '\\\"') safeAuthority = info['safeAuthority'].replace('\'', '\\\'').replace( '\"', '\\\"') safeFromDate = info['safeFromDate'].replace('\'', '\\\'').replace( '\"', '\\\"') companyID = info['companyID'].replace('\'', '\\\'').replace('\"', '\\\"') if safeEndDate == '': safeEndDate = None if safeFromDate == '': safeFromDate = None (status, reason) = self.doesProjectManagerExists(info=info) if status is True: errorInfo = ErrorInfo['TENDER_19'] errorInfo['detail'] = reason return (False, errorInfo) managerID = self.generateID(managerName) projectManager = ProjectManager(managerID=managerID, managerName=managerName, gender=gender, positionalTitles=positionalTitles, post=post, safetyAssessment=safetyAssessment, safeEndDate=safeEndDate, safeAuthority=safeAuthority, safeFromDate=safeFromDate, companyID=companyID) try: db.session.add(projectManager) #添加搜索记录 searchInfo = {} searchInfo['searchName'] = info['managerName'] searchInfo['foreignID'] = managerID searchInfo['tag'] = SEARCH_KEY_TAG_PROJECT_MANAGER now = datetime.now() searchInfo['createTime'] = str(now) searchInfo['joinID'] = self.generateID(info['managerName']) SearchKey.createSearchInfo(info=searchInfo) db.session.commit() except Exception as e: db.session.rollback() print e errorInfo = ErrorInfo['TENDER_02'] errorInfo['detail'] = str(e) return (False, errorInfo) return (True, managerID)