def _get_company_license_request_data(self, company_sn):
     return_data = collections.OrderedDict()
     if company_sn > 0:
         sql_connector = PgConnector(self.service)
         db_result = sql_connector.query(VcmsLicenseRequest). \
             filter(VcmsLicenseRequest.company_sn == company_sn). \
             filter(VcmsLicenseRequest.deprecated == 0). \
             order_by(VcmsLicenseRequest.sn.desc())
         for row in db_result:
             return_data[row.sn] = {
                 "sn": row.sn,
                 "company_sn": row.company_sn,
                 "company_name": row.company_name,
                 "service_name": row.service_name,
                 "license_feature": row.license_feature,
                 "version": row.version,
                 "trial_type": row.trial_type,
                 "start_date": row.start_date,
                 "expire_date": row.expire_date,
                 "license_count": row.license_count,
                 "batch_license_count": row.batch_license_count,
                 "ct_user_sn": row.ct_user_sn,
                 "ut_user_sn": row.ut_user_sn,
                 "enabled": row.enabled,
                 "ct": str(row.ct),
                 "ut": str(row.ut)
             }
         sql_connector.get_session().get_bind().close()
     return return_data
 def _get_pkl_file_content_data(self, feature_pkl_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsFeaturePklContent). \
                               filter(VcmsFeaturePklContent.feature_pkl_sn==feature_pkl_sn). \
                               filter(VcmsFeaturePklContent.enabled==1). \
                               filter(VcmsFeaturePklContent.deprecated==0). \
                               order_by(VcmsFeaturePklContent.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         barcode = None
         if row.barcode is not None:
             barcode = row.barcode
         return_data[row.sn] = {
             "sn": row.sn,
             "feature_pkl_sn": row.sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "branch_sn": row.branch_sn,
             "pkl_key": row.pkl_key,
             "image_sn": row.image_sn,
             "sku": row.sku,
             "feature_sn": row.feature_sn,
             "product_sn": row.product_sn,
             "product_name": row.product_name,
             "barcode": barcode,
             "feature": row.feature
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #3
0
 def _get_product_image_csv_contents_for_creating_product_images(
         self, product_image_csv_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductImageCsvContent). \
                               filter(VcmsCompanyProductImageCsvContent.product_image_csv_sn==int(product_image_csv_sn)) . \
                               filter(VcmsCompanyProductImageCsvContent.image_created_time==None). \
                               filter(VcmsCompanyProductImageCsvContent.image_created_mark==0). \
                               filter(VcmsCompanyProductImageCsvContent.enabled==1). \
                               filter(VcmsCompanyProductImageCsvContent.deprecated==0). \
                               order_by(VcmsCompanyProductImageCsvContent.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "company_sn": row.company_sn,
             "product_image_csv_sn": row.product_image_csv_sn,
             "sku": row.sku,
             "barcode": row.barcode,
             "product_name": row.product_name,
             "ori_file_path": row.ori_file_path,
             "sys_file_path": row.sys_file_path,
             "url": row.url,
             "service_sn": row.service_sn,
             "ct_user_sn": row.ct_user_sn
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_product_data(self, company_sn, product_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProduct). \
                               filter(VcmsCompanyProduct.company_sn==int(company_sn)). \
                               filter(VcmsCompanyProduct.sn==int(product_sn)). \
                               filter(VcmsCompanyProduct.enabled==1). \
                               filter(VcmsCompanyProduct.deprecated==0). \
                               order_by(VcmsCompanyProduct.sn.desc())
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data = {
             "sn": row.sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "barcode": row.barcode,
             "sku": row.sku,
             "product_name": row.product_name,
             "abbreviation": row.abbreviation,
             "thumbnail": row.thumbnail,
             "image_totals": row.image_totals,
             "ct_user_sn": row.ct_user_sn,
             "ut_user_sn": row.ut_user_sn,
             "enabled": row.enabled,
             "ct": str(row.ct),
             "deprecated": row.deprecated
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_company_service_data(self, company_sn):
     return_data = collections.OrderedDict()
     if company_sn > 0:
         company_list = self._get_all_company_data()
         sql_connector = PgConnector(self.service)
         db_result = sql_connector.query(VcmsCompanyService). \
                                   filter(VcmsCompanyService.company_sn==company_sn). \
                                   order_by(VcmsCompanyService.sn.desc())
         for row in db_result:
             return_data[row.sn] = {
                 "sn": row.sn,
                 "company_service_sn": row.sn,
                 "company_sn": row.company_sn,
                 "company_name":
                 company_list[row.company_sn]["company_name"],
                 "system_service_sn": row.service_sn,
                 "per_product_image_cnt": row.per_product_image_cnt,
                 "service_sn": row.service_sn,
                 "max_product_cnt": row.max_product_cnt,
                 "min_training_cnt": row.min_training_cnt,
                 "ct_user_sn": row.ct_user_sn,
                 "ut_user_sn": row.ut_user_sn,
                 "enabled": row.enabled,
                 "ct": str(row.ct),
                 "deprecated": row.deprecated
             }
         sql_connector.get_session().get_bind().close()
     return return_data
 def _get_company_license_detail_data(self, sn):
     return_data = collections.OrderedDict()
     if sn > 0:
         sql_connector = PgConnector(self.service)
         db_result = sql_connector.query(VcmsLicense). \
             filter(VcmsLicense.sn == sn). \
             filter(VcmsLicense.deprecated == 0). \
             order_by(VcmsLicense.sn.desc())
         for row in db_result:
             return_data[row.sn] = {
                 "sn": row.sn,
                 "license_key": row.license_key,
                 "generate_type": row.generate_type,
                 "request_sn": row.request_sn,
                 "company_sn": row.company_sn,
                 "company_name": row.company_name,
                 "encrypt_type": row.encrypt_type,
                 "license_feature": row.license_feature,
                 "version": row.version,
                 "trial_type": row.trial_type,
                 "id_type": row.id_type,
                 "hostid": row.hostid,
                 "start_date": row.start_date,
                 "expire_date": row.expire_date,
                 "connect_count": row.connect_count,
                 "server": row.server,
                 "port": row.port,
                 "ct_user_sn": row.ct_user_sn,
                 "ut_user_sn": row.ut_user_sn,
                 "enabled": row.enabled,
                 "ct": str(row.ct),
                 "ut": str(row.ut)
             }
         sql_connector.get_session().get_bind().close()
     return return_data
Example #7
0
 def _check_product_by_sku(self, company_sn, service_sn, sku):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProduct). \
                               filter(VcmsCompanyProduct.company_sn==int(company_sn)). \
                               filter(VcmsCompanyProduct.service_sn==int(service_sn)). \
                               filter(VcmsCompanyProduct.sku==str(sku)). \
                               filter(VcmsCompanyProduct.deprecated==0)
     check_data = 0
     for row in db_result:
         check_data = 1
     sql_connector.get_session().get_bind().close()
     return check_data
Example #8
0
 def _get_company_service_list(self, company_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyService). \
                               filter(VcmsCompanyService.company_sn==company_sn). \
                               filter(VcmsCompanyService.enabled==1). \
                               filter(VcmsCompanyService.deprecated==0). \
                               order_by(VcmsCompanyService.sn.desc())
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sysyem_service_sn": row.service_sn,
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #9
0
 def _get_empty_main_product_image(self):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProduct). \
                               filter(VcmsCompanyProduct.thumbnail==""). \
                               order_by(VcmsCompanyProduct.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _reset_feature_enabled_by_product_status(self, company_sn, service_sn):
     sql_connector = PgConnector(self.service)
     sql = """
           update company_product_image_features
           set enabled = 1
           where product_sn in (SELECT sn FROM company_products where enabled = 1 and company_sn = %s and service_sn = %s) and 
                 company_sn = %s and service_sn = %s;
           update company_product_image_features
           set enabled = 1
           where image_sn in (SELECT sn FROM company_product_images where enabled = 1 and company_sn = %s and service_sn = %s) and 
                 company_sn = %s and service_sn = %s;
           update company_product_image_features 
           set enabled = 0 
           where product_sn in (SELECT sn FROM company_products where enabled = 0 and company_sn = %s and service_sn = %s) and 
                 company_sn = %s and service_sn = %s;
           update company_product_image_features 
           set enabled = 0 
           where image_sn in (SELECT sn FROM company_product_images where enabled = 0 and company_sn = %s and service_sn = %s) and 
                 company_sn = %s and service_sn = %s;""" % (
         company_sn, service_sn, company_sn, service_sn, company_sn,
         service_sn, company_sn, service_sn, company_sn, service_sn,
         company_sn, service_sn, company_sn, service_sn, company_sn,
         service_sn)
     sql_connector.execute_raw_sql(sql)
     sql_connector.get_session().commit()
     sql_connector.get_session().get_bind().close()
     return 0
 def _add_company_license_request_data(self, parameters):
     sql_connector = PgConnector(self.service)
     company_license_request = VcmsLicenseRequest(
         company_sn=parameters["company_sn"],
         company_name=parameters["company_name"],
         encrypt_sn=parameters["encrypt_sn"],
         encrypt_type=parameters["encrypt_type"],
         service_sn=parameters["service_sn"],
         service_name=parameters["service_name"],
         license_feature=parameters["license_feature"],
         version=parameters["version"],
         trial_sn=parameters["trial_sn"],
         trial_type=parameters["trial_type"],
         id_sn=parameters["id_sn"],
         id_type=parameters["id_type"],
         hostid=parameters["hostid"],
         start_date=parameters["start_date"],
         expire_date=parameters["expire_date"],
         connect_count=parameters["connect_count"],
         server=parameters["server"],
         port=parameters["port"],
         license_count=parameters["license_count"],
         batch_license_count=parameters["batch_license_count"],
         ct_user_sn=int(session["admin_id"]))
     sql_connector.get_session().add(company_license_request)
     sql_connector.get_session().commit()
     company_license_request_sn = company_license_request.sn
     sql_connector.get_session().get_bind().close()
     return company_license_request_sn
 def _get_company_service_branch_product_enabled_status_data(
         self, company_sn, service_sn, branch_sn, enabled):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyBranchProduct). \
                               filter(VcmsCompanyBranchProduct.company_sn==int(company_sn)). \
                               filter(VcmsCompanyBranchProduct.service_sn==int(service_sn)). \
                               filter(VcmsCompanyBranchProduct.branch_sn==int(branch_sn)). \
                               filter(VcmsCompanyBranchProduct.enabled==enabled). \
                               filter(VcmsCompanyBranchProduct.deprecated==0). \
                               order_by(VcmsCompanyBranchProduct.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.product_sn] = row.product_sn
     sql_connector.get_session().get_bind().close()
     return return_data
Example #13
0
 def _get_all_company_data(self):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompany). \
                               filter(VcmsCompany.deprecated==0). \
                               order_by(VcmsCompany.sn.desc())
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "company_name": row.company_name,
             "service_list": self._get_company_service_data(int(row.sn)),
             "enabled": row.enabled
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #14
0
 def _get_prod_sku_mapping_data(self, company_sn, service_sn, sku, barcode,
                                product_name):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProduct). \
                               filter(VcmsCompanyProduct.company_sn==int(company_sn)). \
                               filter(VcmsCompanyProduct.service_sn==int(service_sn)). \
                               filter(VcmsCompanyProduct.sku==str(sku)). \
                               filter(VcmsCompanyProduct.barcode==str(barcode)). \
                               filter(VcmsCompanyProduct.product_name==str(product_name)). \
                               filter(VcmsCompanyProduct.enabled==1). \
                               order_by(VcmsCompanyProduct.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row_sn] = row.sn
     sql_connector.get_session().get_bind().close()
     return return_data
Example #15
0
 def _get_system_service_data(self):
     return_data = collections.OrderedDict()
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsRecognitionService). \
                               filter(VcmsRecognitionService.enabled==1). \
                               filter(VcmsRecognitionService.deprecated==0). \
                               order_by(VcmsRecognitionService.sn)
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "service_name": row.service_name,
             "service_type": row.service_type,
             "feature_extraction_mark": row.feature_extraction_mark,
             "enabled": row.enabled,
             "ct": str(row.ct)
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #16
0
 def _get_download_error_csv_content(self, company_sn, service_sn, csv_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductCsvContent). \
                               filter(VcmsCompanyProductCsvContent.company_sn==company_sn). \
                               filter(VcmsCompanyProductCsvContent.service_sn==service_sn). \
                               filter(VcmsCompanyProductCsvContent.product_csv_sn==int(csv_sn)). \
                               filter(VcmsCompanyProductCsvContent.product_created_mark==0). \
                               order_by(VcmsCompanyProductCsvContent.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sku": row.sku,
             "barcode": row.barcode,
             "product_name": row.product_name,
             "message": "Duplicated"
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_all_license_id_type_data(self):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsLicenseIdType). \
                               filter(VcmsLicenseIdType.deprecated==0). \
                               order_by(VcmsLicenseIdType.sn.desc())
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "id_type": row.id_type,
             "id_name": row.id_name,
             "default_select": row.default_select,
             "ct_user_sn": row.ct_user_sn,
             "ut_user_sn": row.ut_user_sn,
             "enabled": row.enabled,
             "ct": str(row.ct)
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #18
0
 def _get_product_images_by_uploading(self, company_sn, service_sn,
                                      product_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductImage). \
                               filter(VcmsCompanyProductImage.company_sn==company_sn). \
                               filter(VcmsCompanyProductImage.service_sn==service_sn). \
                               filter(VcmsCompanyProductImage.product_sn==product_sn). \
                               order_by(VcmsCompanyProductImage.sn).limit(1)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data = {
             "sn": row.sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "product_sn": row.product_sn,
             "thumbnail": row.thumbnail
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_company_all_api_settings(self):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyService). \
                               filter(VcmsCompanyService.enabled==1). \
                               filter(VcmsCompanyService.deprecated==0). \
                               order_by(VcmsCompanyService.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         if int(row.company_sn) not in return_data:
             return_data[row.company_sn] = {}
         return_data[row.company_sn][row.sn] = {
             "company_sn": row.company_sn,
             "detection_api": row.detection_api,
             "feature_api": row.feature_api,
             "self_test_api": row.self_test_api,
             "pkl_update_api": row.pkl_update_api
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_image_for_detections(self):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductImage). \
                               filter(VcmsCompanyProductImage.detection_send_time==None). \
                               filter(VcmsCompanyProductImage.detection_finish_mark==0). \
                               filter(VcmsCompanyProductImage.enabled==1). \
                               filter(VcmsCompanyProductImage.deprecated==0). \
                               order_by(VcmsCompanyProductImage.sn).limit(self.limitation)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "thumbnail": row.thumbnail,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "product_sn": row.product_sn
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_all_company_data(self):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompany). \
                               filter(VcmsCompany.deprecated==0). \
                               order_by(VcmsCompany.sn.desc())
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "company_name": row.company_name,
             "max_admin_cnt": row.max_admin_cnt,
             "max_branch_cnt": row.max_branch_cnt,
             "max_branch_user_cnt": row.max_branch_user_cnt,
             "ct_user_sn": row.ct_user_sn,
             "ut_user_sn": row.ut_user_sn,
             "enabled": row.enabled,
             "ct": str(row.ct)
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #22
0
 def _get_csv_for_importing_products(self, limitation=100):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductCsv). \
                               filter(VcmsCompanyProductCsv.file_manage_time==None). \
                               filter(VcmsCompanyProductCsv.file_manage_mark==0). \
                               filter(VcmsCompanyProductCsv.enabled==1). \
                               filter(VcmsCompanyProductCsv.deprecated==0). \
                               order_by(VcmsCompanyProductCsv.sn).limit(limitation)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "user_file_name": row.user_file_name,
             "sys_file_name": row.sys_file_name,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "ct_user_sn": row.ct_user_sn
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_output_pkl_file_data(self, pkl_key):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsFeaturePklFile). \
                               filter(VcmsFeaturePklFile.pkl_key==pkl_key). \
                               filter(VcmsFeaturePklFile.output_pkl_mark==0). \
                               filter(VcmsFeaturePklFile.enabled==1). \
                               filter(VcmsFeaturePklFile.deprecated==0). \
                               order_by(VcmsFeaturePklFile.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "feature_pkl_sn": row.sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "branch_sn": row.branch_sn,
             "pkl_key": row.pkl_key
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_company_service_product_image_deprecated_status_data(
         self, company_sn, service_sn, deprecated):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductImage). \
                               filter(VcmsCompanyProductImage.company_sn==int(company_sn)). \
                               filter(VcmsCompanyProductImage.service_sn==int(service_sn)). \
                               filter(VcmsCompanyProductImage.deprecated==int(deprecated)). \
                               order_by(VcmsCompanyProductImage.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "image_sn": row.sn,
             "product_sn": row.product_sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "thumbnail": row.thumbnail,
             "enabled": row.enabled
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #25
0
 def _get_company_service_product_data(self, service_sn, search_key, limit,
                                       offset):
     sql_connector = PgConnector(self.service)
     if search_key is None or search_key == "":
         db_result = sql_connector.query(VcmsCompanyProduct). \
                                   filter(VcmsCompanyProduct.service_sn==int(service_sn)). \
                                   filter(VcmsCompanyProduct.deprecated==0). \
                                   order_by(VcmsCompanyProduct.sn.desc()). \
                                   limit(limit).offset(offset)
     else:
         db_result = sql_connector.query(VcmsCompanyProduct). \
                                   filter(VcmsCompanyProduct.service_sn==int(service_sn)). \
                                   filter(VcmsCompanyProduct.product_name==str(search_key)). \
                                   filter(VcmsCompanyProduct.deprecated==0). \
                                   order_by(VcmsCompanyProduct.sn.desc()). \
                                   limit(limit).offset(offset)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "barcode": row.barcode,
             "sku": row.sku,
             "product_name": row.product_name,
             "abbreviation": row.abbreviation,
             "thumbnail": row.thumbnail,
             "image_totals": row.image_totals,
             "ct_user_sn": row.ct_user_sn,
             "ut_user_sn": row.ut_user_sn,
             "enabled": row.enabled,
             "ct": str(row.ct)
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #26
0
 def _get_csv_for_importing_products_log(self, company_sn, service_sn):
     sql_connector = PgConnector(self.service)
     system_service_list = self._get_company_service_list(company_sn)
     db_result = sql_connector.query(VcmsCompanyProductCsv). \
                               filter(VcmsCompanyProductCsv.company_sn==company_sn). \
                               filter(VcmsCompanyProductCsv.service_sn==service_sn). \
                               filter(VcmsCompanyProductCsv.deprecated==0). \
                               order_by(VcmsCompanyProductCsv.sn.desc())
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn":
             row.sn,
             "user_file_name":
             row.user_file_name,
             "sys_file_name":
             row.sys_file_name,
             "company_sn":
             row.company_sn,
             "service_sn":
             row.service_sn,
             "system_service_sn":
             system_service_list[row.service_sn]["sysyem_service_sn"],
             "ct_user_sn":
             row.ct_user_sn,
             "data_total":
             row.data_total,
             "file_manage_mark":
             row.file_manage_mark,
             "file_manage_time":
             row.file_manage_time,
             "enabled":
             row.enabled,
             "ct":
             row.ct,
             "error_mark":
             self._get_error_csv_content(row.sn)
         }
     sql_connector.get_session().get_bind().close()
     return return_data
 def _get_company_service_image_for_features(self, company_sn, service_sn):
     sql_connector = PgConnector(self.service)
     db_result = sql_connector.query(VcmsCompanyProductImage). \
                               filter(VcmsCompanyProductImage.company_sn==int(company_sn)). \
                               filter(VcmsCompanyProductImage.service_sn==int(service_sn)). \
                               filter(VcmsCompanyProductImage.bbox_totals>0). \
                               filter(VcmsCompanyProductImage.detection_finish_mark==1). \
                               filter(VcmsCompanyProductImage.feature_extraction_send_time==None). \
                               filter(VcmsCompanyProductImage.feature_extraction_finish_mark==0). \
                               filter(VcmsCompanyProductImage.deprecated==0). \
                               order_by(VcmsCompanyProductImage.sn)
     return_data = collections.OrderedDict()
     for row in db_result:
         return_data[row.sn] = {
             "sn": row.sn,
             "thumbnail": row.thumbnail,
             "company_sn": row.company_sn,
             "service_sn": row.service_sn,
             "product_sn": row.product_sn,
         }
     sql_connector.get_session().get_bind().close()
     return return_data
Example #28
0
 def _get_company_service_data(self, company_sn):
     return_data = collections.OrderedDict()
     if company_sn > 0:
         system_service = self._get_system_service_data()
         sql_connector = PgConnector(self.service)
         db_result = sql_connector.query(VcmsCompanyService). \
                                   filter(VcmsCompanyService.company_sn==company_sn). \
                                   order_by(VcmsCompanyService.sn.desc())
         for row in db_result:
             return_data[row.sn] = {
                 "sn": row.sn,
                 "company_service_sn": row.sn,
                 "company_sn": row.company_sn,
                 "service_sn": row.service_sn,
                 "service_name":
                 system_service[row.service_sn]["service_name"],
                 "service_type":
                 system_service[row.service_sn]["service_type"],
                 "enabled": row.enabled
             }
         sql_connector.get_session().get_bind().close()
     return return_data
Example #29
0
 def _get_error_csv_content(self, csv_sn):
     return_value = 0
     sql_connector = PgConnector(self.service)
     rs = sql_connector.query(VcmsCompanyProductCsvContent). \
                        filter(VcmsCompanyProductCsvContent.product_csv_sn==int(csv_sn)). \
                        filter(VcmsCompanyProductCsvContent.product_created_mark==0).count()
     sql_connector.get_session().commit()
     sql_connector.get_session().get_bind().close()
     if rs > 0:
         return_value = 1
     return return_value
Example #30
0
 def _set_file_manage_time_for_importing_products(self, sn):
     ut = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql_connector = PgConnector(self.service)
     rs = sql_connector.query(VcmsCompanyProductCsv). \
                        filter(VcmsCompanyProductCsv.sn==int(sn)). \
                        update({
                                "file_manage_time" : ut
                              })
     sql_connector.get_session().commit()
     sql_connector.get_session().get_bind().close()
     return rs