Exemplo n.º 1
0
def check_disappear_data(day):

    # 获取俩个表的编码信息
    date = datetime.date.today()
    sql = "select bianma from mdr_business_gather where reportdate='%s'" % day
    diff_a = mdr_select(sql)
    sql = "select reportid from mdr_fullidlist where senddate='%s'" % day
    diff_b = mdr_select(sql)

    # 重新初始化编码信息,导入到俩个列表里面
    a = []
    b = []
    for i in diff_a:
        a.append(i[0])
    for i in diff_b:
        b.append(i[0].strip())

    # 通过比对算法,把a列表里面所有的b数据删除,最后a列表里面的数据是b列表里面没有的
    for i in range(len(b)):
        try:
            a.index(b[i])
            a.remove(b[i])
        except ValueError:
            pass

    # 进行判断,如果a列表里面有多余的数据,我们就移动到消失表里面,并且删除在主表和相关的表的数据
    if len(a) > 0:
        num = 0
        for i in range(len(a)):
            sql = "select bianma,reportunitname,reportdate,StateReportDate " \
                  "from mdr_business_gather where bianma='%s'" % a[i]
            diff_a = mdr_select(sql)
            sql = "INSERT into mdr_business_gather_disappear(bianma,reportunitname,reportdate,StateReportDate," \
                  "FoundTime) values('%s','%s','%s','%s','%s')" \
                  % (diff_a[0][0], diff_a[0][1], diff_a[0][2], diff_a[0][3], date)
            myconn = myconnect()
            mycu = myconn.cursor()
            mycu.execute(sql)
            myconn.commit()

            mycu.execute(u"delete from mdr_business_gather where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_adrbusiness where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_faultbusiness where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_icdbusiness where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_devicebusiness where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_errorlist where reportid='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_reports where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            mycu.execute("delete from mdr_appraise where bianma='%s'" % diff_a[0][0])
            myconn.commit()
            num += 1
        print u'%s的消失记录移动完毕!共移动%s条记录!' % (day, num)
Exemplo n.º 2
0
def myautodown(id, reportid):
    #has_sql = "select ReportID from pusr_business where ReportID='%s'" % (REPORT_ID)
    down_sql = "SELECT FileID,ShowFileName FROM pusr_dwfinfo_down where ReportID='%s'" % (
        reportid)
    objlistid = mdrsql.mdr_select(down_sql)
    for objid in objlistid:
        downallfiles3(objid[0], id, objid[1], reportid)
Exemplo n.º 3
0
def import_GMP_Info(data,company_name,deviceInfo):

    device_sql = "SELECT manufacturer_name_cn,province,city,district FROM `mdr_gmp` where manufacturer_name_cn='%s'  limit 1" % ( company_name )
    
    rows_device = mdrsql.mdr_select(device_sql)
    if rows_device:
        IsMatchingFactory = u'是'
        UnMatchFactory = ""
        rows_device_gmp = rows_device[0]
        
        StandardFactory = rows_device_gmp[0]
        manufacturerProvinceName = rows_device_gmp[1]
        manufacturerCity = rows_device_gmp[2]
        manufacturerCounty = rows_device_gmp[3]
    else:
        IsMatchingFactory = u'否'
        UnMatchFactory = company_name
        
        StandardFactory = ""
        manufacturerProvinceName = ""
        manufacturerCity = ""
        manufacturerCounty = ""

    device_sql = (
		    """
            replace into mdr_devicebusiness(
                BianMa, ProvinceName, District, County, ReportUnitName, 
                ReportUnitAddress,ReportUnitTel,Postalcode,UnitType,
                HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,
                State,CertificateNumber,TradeName,classification,firstreason,
                firstdone,useplace,specifications,Productnumber,Batchnumber,
                operator,ImplantationDate,StopDate,EffectiveDate,
                manufacturer_address,manufacturer_tel,IsMatchingDevice,DeviceStandard,
                PName,SubName,Name,manageclass,classcode,
                UnMatchDevice, IsMatchingFactory, StandardFactory,manufacturerProvinceName,
                manufacturerCity, manufacturerCounty,UnMatchFactory) 
                
                values
                
                (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"""
	    )

    device_data = [
                data["BianMa"], data["ProvinceName"], data["District"], data["County"],
                data["ReportUnitName"], data["ReportUnitAddress"], data["ReportUnitTel"], data["Postalcode"], 
                data["UnitType"], data["HappenDate"], data["KnowDate"], data["ReportDate"], 
                data["ReportDate"], data["StateReportDate"], data["State"], data["CertificateNumber"], 
                data["TradeName"], data["classification"], data["firstreason"], data["firstdone"], 
                data["useplace"], data["specifications"], data["Productnumber"], data["Batchnumber"], 
                data["operator"], data["ImplantationDate"], data["StopDate"], data["EffectiveDate"], 
                data["manufacturer_address"], data["manufacturer_tel"], data["IsMatchingDevice"], data["DeviceStandard"], 
                deviceInfo["SuperClassName"], deviceInfo["subname"], data["DeviceStandard"], deviceInfo["manageclass"], 
                deviceInfo["classcode"], data["UnMatchDevice"], IsMatchingFactory, StandardFactory, 
                manufacturerProvinceName, manufacturerCity, manufacturerCounty, UnMatchFactory]
    mdrsql.mdr_insert_alone(device_sql, device_data)

    return (IsMatchingFactory,UnMatchFactory)
Exemplo n.º 4
0
def mdr_falt_business(qg_info, name):
    qg_set = []
    sanlei = []
    IsMatchingFault = None
    IsADRorAccident_tag = None
    for SuperFaultName in qg_info:
        qg_sql = (
            "SELECT SuperClassName,subname FROM `mdr_deviceinstrument` where Name='%s'  limit 1" % name
        )
        rows_qg = mdrsql.mdr_select(qg_sql)
        if rows_qg:
            IsMatchingFault = u'是'
            for row_qg_data in rows_qg:
                s_name_1 = row_qg_data[0]
                s_name_2 = row_qg_data[1]
                compose_data = s_name_1+':'+s_name_2+':'+name
            accident_sql = (
                "replace into mdr_fault(SuperClassName,SubName,Name,NonStandardName,IsDeviceMatching,RealFaultName) "
                "values(%s,%s,%s,%s,%s,%s)"
            )
            accident_data = (s_name_1, s_name_2, name, None, u'是', SuperFaultName)
            mdrsql.mdr_insert_alone(accident_sql, accident_data)
            
            qg_set.append(SuperFaultName)
            qg_setdata = utils.data_set(qg_set)
            UnMatchFault = ""
            IsADRorAccident_tag = "2"
            sanlei.append(s_name_1)
            sanlei.append(s_name_2)
            sanlei.append(name)
            
        else:
            accident_sql = (
                "replace into mdr_fault(SuperClassName,SubName,Name,NonStandardName,IsDeviceMatching,RealFaultName) "
                "values(%s,%s,%s,%s,%s,%s)"
            )
            accident_data = (None, None, None, name, u'否', SuperFaultName)
            mdrsql.mdr_insert_alone(accident_sql, accident_data)
            IsMatchingFault = u'是'
            UnMatchFault = utils.str_to_unicode(SuperFaultName)
            qg_set.append(UnMatchFault)
            qg_setdata = utils.data_set(qg_set)
            sanlei.append(name)
            
        # qg_data = (
        #     data["BianMa"], data["ProvinceName"], data["District"], data["County"],
        #     data["ReportUnitName"], data["ReportUnitAddress"], data["ReportUnitTel"], data["Postalcode"],
        #     data["UnitType"], data["HappenDate"], data["KnowDate"], data["ReportDate"],
        #     data["ReportDate"], data["StateReportDate"], data["State"],StandardFault,
        #     StandardFault, IsMatchingFault, SuperFaultName, UnMatchFault)
        # qg_sql = (
        #         "replace into mdr_faultbusiness(BianMa,ProvinceName,District,County,ReportUnitName,ReportUnitAddress,ReportUnitTel,Postalcode,UnitType ,HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,State,StandardFault,Name,IsMatchingFault,SuperFaultName,UnMatchFault)"
        #         "values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        # )
        # mdrsql.mdr_insert_alone(qg_sql, qg_data)

    return (IsMatchingFault, IsADRorAccident_tag, qg_setdata, sanlei)
Exemplo n.º 5
0
def get_sh_info(sh_info, data):
    sh_set = []
    is_adr = None
    clinicdetail_Name = None
    clinicdetail_SubID = None
    clinicsub_ID = None
    clinicsub_Name = None
    clinic_ID = None
    clinic_NAME = None
    IsADRorAccident_tag = ""
    
    for sh_info_item in sh_info:
        sh_query_sql = "SELECT clinicdetail.SubID, clinicdetail.Name,clinicsub.ID,clinicsub.Name,clinic.ID,clinic.NAME FROM clinicdetail, clinicsub,clinic WHERE clinicdetail.SubID=clinicsub.ID and clinicsub.PID=clinic.ID and clinicdetail.Name= '%s'  limit 1" %(sh_info_item)
        rows_sh = mdrsql.mdr_select(sh_query_sql)
        if rows_sh:
            is_adr = u'是'
            for row_sh_data in rows_sh:
                #sh_s_name = row_sh_data[0]
                clinicdetail_Name = row_sh_data[1]
                clinicdetail_SubID = row_sh_data[0]
                clinicsub_ID = row_sh_data[2]
                clinicsub_Name = row_sh_data[3]
                clinic_ID = row_sh_data[4]
                clinic_NAME = row_sh_data[5]

            sh_set.append(sh_info_item)
            adr_data_list = sh_info_item
            IsADRorAccident_tag = "1"
            _un_sh_info = ""
        else:
            is_adr = u'否'
            _un_sh_info = u"[非标准:" + sh_info_item + u"]"
            sh_set.append(_un_sh_info)
            adr_data_list = utils.data_set(sh_set)
            #sh_s_name = ""
            clinicdetail_Name = ""
            clinicdetail_SubID = ""
            clinicsub_ID = ""
            clinicsub_Name = ""
            clinic_ID = ""
            clinic_NAME = ""
            
    sh_data =     [
        data["BianMa"], data["ProvinceName"], data["District"], data["County"],
        data["ReportUnitName"], data["ReportUnitAddress"], data["ReportUnitTel"], data["Postalcode"], 
        data["UnitType"], data["HappenDate"], data["KnowDate"], data["ReportDate"], 
        data["ReportDate"], data["StateReportDate"], data["State"], is_adr, 
        clinicdetail_Name, clinicdetail_Name, clinicdetail_SubID, clinicsub_ID, 
        clinicsub_Name, clinic_ID, clinic_NAME, _un_sh_info]

    sh_sql = (
        "replace into mdr_adrbusiness(BianMa,ProvinceName,District,County,ReportUnitName,ReportUnitAddress,ReportUnitTel,Postalcode,UnitType ,HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,State,IsMatchingADR,ADRStandardID,Name,SID1,SubID,SubName,PID,PName,UnMatchADR)"
        "values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    )
    mdrsql.mdr_insert_alone(sh_sql, sh_data)
    
    return (is_adr, adr_data_list,IsADRorAccident_tag)
Exemplo n.º 6
0
def get_icd_info(data,icd_ok):
    icd_standname = ""
    icd_set = []
    IsMatchingAffect = None
    UnMatchAffect = None
    icd_setdata = None
    _un_tag_icd_1 = utils.str_to_unicode("[非标准:")
    _un_tag_icd_2 = utils.str_to_unicode("]")
    for item in icd_ok:
        #_item = item.strip(_trim_tag).strip()
        icd_sql = (
            "SELECT StandardIcdName,icd_a_name,icd_b_name,icd_c_name,PathName FROM `mdr_icd` where StandardIcdName='%s'  limit 1" %(item)
        )

        rows_icd = mdrsql.mdr_select(icd_sql)
        if rows_icd:
            IsMatchingAffect = u'是'
            UnMatchAffect = ""
            for icd_ok_info in rows_icd:
                icd_a_name = icd_ok_info[0]
                icd_b_name = icd_ok_info[1]
                AffectStandardName = icd_ok_info[2]
                PathName = icd_ok_info[3]

            icd_set.append(item)
            icd_setdata = item
            icd_standname = AffectStandardName
        else:
            IsMatchingAffect = u'否'
            un_icd_info = _un_tag_icd_1+item+_un_tag_icd_2
            _un_icd_info = utils.str_to_unicode(un_icd_info)
            UnMatchAffect = _un_icd_info
            icd_a_name = ""
            icd_b_name = ""
            AffectStandardName = ""
            PathName = ""
            icd_standname = AffectStandardName

            icd_set.append(UnMatchAffect)
            icd_setdata = utils.data_set(icd_set)
    
    icd_sql = (
        "replace into mdr_icdbusiness(BianMa,ProvinceName,District,County,ReportUnitName,ReportUnitAddress,ReportUnitTel,Postalcode,UnitType ,HappenDate,KnowDate,ReportDate,AcceptDate,StateReportDate,State,IsMatchingAffect,AffectStandardName,icd_a_name,icd_b_name,icd_c_name,PathName,UnMatchAffect)"
        "values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    )
    
    icd_data = [
        data["BianMa"], data["ProvinceName"], data["District"], data["County"],
        data["ReportUnitName"], data["ReportUnitAddress"], data["ReportUnitTel"], data["Postalcode"], 
        data["UnitType"], data["HappenDate"], data["KnowDate"], data["ReportDate"], 
        data["ReportDate"], data["StateReportDate"], data["State"],IsMatchingAffect, 
        AffectStandardName, icd_a_name, icd_b_name, AffectStandardName, 
        PathName, UnMatchAffect]
    mdrsql.mdr_insert_alone(icd_sql, icd_data)
    
    return (IsMatchingAffect, UnMatchAffect,icd_setdata)
Exemplo n.º 7
0
def check_disappear_data(date):

    today = datetime.date.today()
    # 先查询到主表多于的数量
    sql = "select bianma from business_gather where StateReportDate='%s' and " \
          "bianma not in(select report_id2 from adr_full_id_list where report_date like '%s%s')" % (date, date, '%')
    bianma_list = mdrsql.mdr_select(sql)
    all_data = []
    delete_data = []
    move_data = []
    for i in bianma_list:
        all_data.append(i[0])
    # 把多于的报表分为两种,一种是已退回列表查询到的需要删除的报表,还有一种是已经消失的需要移动的报表
    for i in all_data:
        sql = "select bianma from adr_deleted_gather where bianma='%s'" % i
        bianma_list = mdrsql.mdr_select(sql)
        if len(bianma_list) > 0:
            delete_data.append(bianma_list[0])
        else:
            move_data.append(i)

    # 把两种报表写到两个列表以后,进行数据库处理
    myconn = config.myconnect()
    mycu = myconn.cursor()
    num = 0
    for i in delete_data:
        mycu.execute("delete from business_gather where bianma='%s'" % i)
        myconn.commit()
    print u'%s 退回报表删除完成!共删除%s条报表!' % (date, num)
    num = 0
    for i in move_data:
        sql = "select bianma,reportunitname,reportdate,StateReportDate " \
              "from business_gather where bianma='%s'" % i
        diff_a = mdrsql.mdr_select(sql)
        sql = "INSERT into adr_business_gather_disappear(bianma,reportunitname,reportdate,StateReportDate," \
              "FoundTime) values('%s','%s','%s','%s','%s')" \
              % (diff_a[0][0], diff_a[0][1], diff_a[0][2], diff_a[0][3], today)
        mycu.execute(sql)
        myconn.commit()
        mycu.execute("delete from business_gather where bianma='%s'" % i)
        myconn.commit()
        num += 1
    print u'%s 消失报表移动完成!共移动%s条记录!' %(date, num)
Exemplo n.º 8
0
def get_AppraiseLevel(unitName):

    mdr_query = "select distinct role from mhisuser where unitname='%s'" % unitName

    mdr_row = mdrsql.mdr_select(mdr_query) # 返回结果是多行
    if len(mdr_row) > 0 :
        mdr_row = mdr_row[0]
    else :
        return ""

    if len(mdr_row) > 0 :
        return mdr_row[0]
    return ""
Exemplo n.º 9
0
def get_AppraiseLevel(unitName):

    mdr_query = "select distinct role from mhisuser where unitname='%s'" % unitName

    mdr_row = mdrsql.mdr_select(mdr_query)  # 返回结果是多行
    if len(mdr_row) > 0:
        mdr_row = mdr_row[0]
    else:
        return ""

    if len(mdr_row) > 0:
        return mdr_row[0]
    return ""
Exemplo n.º 10
0
def getReportUnitDistrictInfo(ReportUnitName):
    report_unit_sql = (  """SELECT ProvinceName,DistrictTypeID,County  FROM `unit` where Name="%s" limit 1""" % (ReportUnitName) )
    rows_unit = None
    rows_unit = mdrsql.mdr_select(report_unit_sql)
    #行政区域匹配
    if rows_unit:
        for unit_info in rows_unit:
            ProvinceName = unit_info[0]
            District = unit_info[1]
            County = unit_info[2]
    else:
        County = ""
        District = ""
        ProvinceName = ""
    return (County,District,ProvinceName)
Exemplo n.º 11
0
def getReportUnitDistrictInfo(ReportUnitName):
    report_unit_sql = (
        """SELECT ProvinceName,DistrictTypeID,County  FROM `unit` where Name="%s" limit 1"""
        % (ReportUnitName))
    rows_unit = None
    rows_unit = mdrsql.mdr_select(report_unit_sql)
    #行政区域匹配
    if rows_unit:
        for unit_info in rows_unit:
            ProvinceName = unit_info[0]
            District = unit_info[1]
            County = unit_info[2]
    else:
        County = ""
        District = ""
        ProvinceName = ""
    return (County, District, ProvinceName)
Exemplo n.º 12
0
    def OnQuery(self, e):
        #wx.grid
        self.myGrid.Refresh()
        for x in range(0, 500):
            #print data[x]
            for y in range(0, 3):
                self.myGrid.SetCellValue(x, y, '')
                #print myGrid.GetCellValue(x, y)
        query_sql = "select ReportID, FileID,ShowFileName BackUp1 from pusr_dwfinfo_down_error limit 500 "
        #query_sql = "select FileType,UploadDepartmentName,FileSize,FileID,ShowFileName from pusr_dwfinfo_down limit 100 "
        query_set = mdrsql.mdr_select(query_sql)
        id = len(query_set)

        for x in range(0, id):
            #print data[x]
            for y in range(0, 3):
                outdata = query_set[x][y]
                self.myGrid.SetCellValue(x, y, outdata)
Exemplo n.º 13
0
def getDeviceInstrumentInfo(production_name):
    #获取器械的基础数据

    deviceInfo = {}
    un_device_info = None
    Is_m_device = None
    _un_tag_device_1 = str_to_unicode(u"[非标准:")
    _un_tag_device_2 = str_to_unicode(u"]")

    rows_device_sql = (
        "SELECT SuperClassName, subname, Name, classcode, manageclass FROM `mdr_deviceinstrument` where Name='%s' limit 1"
        % (production_name))
    rows_device = mdrsql.mdr_select(rows_device_sql)

    if rows_device:
        Is_m_device = u'是'
        for rows_device_info in rows_device:
            SuperClassName = rows_device_info[0]
            subname = rows_device_info[1]
            Name = rows_device_info[2]
            classcode = rows_device_info[3]
            d_5 = rows_device_info[4]
            manageclass = rows_device_info[4]
        _un_device_info = Name
        un_device_info = Name

    else:
        Is_m_device = u'否'
        un_device_info = _un_tag_device_1 + production_name + _un_tag_device_2
        un_device_info = str_to_unicode(un_device_info)
        SuperClassName = ""
        subname = ""
        Name = ""
        classcode = ""
        manageclass = ""

    deviceInfo["SuperClassName"] = SuperClassName
    deviceInfo["subname"] = subname
    deviceInfo["Name"] = Name
    deviceInfo["classcode"] = classcode
    deviceInfo["manageclass"] = manageclass

    return (un_device_info, Is_m_device, deviceInfo)
Exemplo n.º 14
0
def getDeviceInstrumentInfo(production_name):
    #获取器械的基础数据

    deviceInfo = {}
    un_device_info = None
    Is_m_device = None
    _un_tag_device_1 = str_to_unicode(u"[非标准:")
    _un_tag_device_2 = str_to_unicode(u"]")

    rows_device_sql = (
                "SELECT SuperClassName, subname, Name, classcode, manageclass FROM `mdr_deviceinstrument` where Name='%s' limit 1" % (production_name)
            )
    rows_device = mdrsql.mdr_select(rows_device_sql)

    if rows_device:
        Is_m_device = u'是'
        for rows_device_info in rows_device:
            SuperClassName = rows_device_info[0]
            subname = rows_device_info[1]
            Name = rows_device_info[2]
            classcode = rows_device_info[3]
            d_5 = rows_device_info[4]
            manageclass = rows_device_info[4]
        _un_device_info = Name
        un_device_info = Name

    else:
        Is_m_device = u'否'
        un_device_info = _un_tag_device_1+production_name+_un_tag_device_2
        un_device_info = str_to_unicode(un_device_info)
        SuperClassName = ""
        subname = ""
        Name = ""
        classcode = ""
        manageclass = ""

    deviceInfo["SuperClassName"] = SuperClassName
    deviceInfo["subname"] = subname
    deviceInfo["Name"] = Name
    deviceInfo["classcode"] = classcode
    deviceInfo["manageclass"] = manageclass

    return (un_device_info,Is_m_device,deviceInfo)
Exemplo n.º 15
0
def check_back_data(day):

    # 重数据库里面把有已退回字段的编码取出来
    myconn = myconnect()
    mycu = myconn.cursor()
    sql = u"select BianMa from mdr_business_gather where bianma " \
          u"in(select ReportID from mdr_fullidlist where SendDate='%s' and BackState='%s')" % (day, u'已退回')
    result = mdr_select(sql)

    # 在MDR主表里面找到编码信息的记录,标记Reserve4字段为已退回
    num = 0
    for item in result:
        sql = u"update mdr_business_gather set Reserve4='%s' where bianma='%s'" % (u'已退回', item[0])
        mycu.execute(sql)
        myconn.commit()
        num += 1

    if num > 0:
        print u'%s 已退回%s条报表' % (day, num)
Exemplo n.º 16
0
    def OnTestWindow(self, event):
        #
        user = self.userText.GetValue()
        pwd = self.pwdText.GetValue()
        ps2 = mymd55(pwd)

        print user, ps2
        select_sql = "SELECT LoginName,PassWord FROM `mhisuser`  where (Role='4' or Role='3')  and LoginName='%s' and `PassWord`='%s'"  % (user, ps2)
        dbok = mdrsql.mdr_select(select_sql)
        #print dbok

        if True : #dbok:
            #
            wx.MessageBox(u'登录成功', u'登录测试', wx.OK | wx.ICON_INFORMATION)
            global executeflag
            executeflag = 1
            self.Hide()
        else:
            #
            wx.MessageBox(u'登录失败,请重新检查输入数据', u'登录测试', wx.OK | wx.ICON_INFORMATION)
Exemplo n.º 17
0
def harvestdaystomonthlocal(mydays):
    itemid = []

    dayitemfilename = time.strftime("%Y-%m-%d") + '-local_adr.txt'
    reportlog = codecs.open(dayitemfilename, 'a', 'utf-8')

    for i in mydays:
        #查询ADR数据库主表,business_gather,yup
        device_sql = (
            "SELECT count(*) FROM `business_gather` where StateReportDate='%s' " % (i)
        )
        rows_device = mdrsql.mdr_select(device_sql)
        localitem = rows_device[0][0]

        itemid.append((i, localitem))

        localitem_s = str(localitem)
        reportlog.write(i + '\t' + localitem_s + '\n')

    reportlog.close()
    return itemid
Exemplo n.º 18
0
def harvestdaystomonthlocal(mydays):
    itemid = []

    dayitemfilename = time.strftime("%Y-%m-%d") + '-local_adr.txt'
    reportlog = codecs.open(dayitemfilename, 'a', 'utf-8')

    for i in mydays:
        #查询ADR数据库主表,business_gather,yup
        device_sql = (
            "SELECT count(*) FROM `business_gather` where StateReportDate='%s' "
            % (i))
        rows_device = mdrsql.mdr_select(device_sql)
        localitem = rows_device[0][0]

        itemid.append((i, localitem))

        localitem_s = str(localitem)
        reportlog.write(i + '\t' + localitem_s + '\n')

    reportlog.close()
    return itemid
Exemplo n.º 19
0
def PSUR_Report(_timedict):
    #
    t = _timedict
    t_start = t['beginTime']
    t_end = t['endTime']
    RF_list = gather_report_total(_timedict)
    for i in range(0, RF_list):
        meid = i * 100
        print "meid:", meid
        jim = {
            "funcID":
            "QUERY_DATA",
            "userID":
            78919,
            "operations": [{
                "actionName":
                "query",
                "operationDatas": [{
                    "ENTRY_START_DATE_2401": t_start,
                    "ENTRY_END_DATE_2401": t_end,
                    "ACTIVE_CONSTITUENT_2430": "",
                    "TRADENAME_CN_2431": "",
                    "DRUGNAME_CN_FORM_2431": "",
                    "DOSEFORM_2431": "",
                    "DRUG_STATUS_2431": "",
                    "APPROVAL_NO_2431": "",
                    "REPORT_ID_2430": "",
                    "PICKER_UNIT_NAME_2430": "",
                    "START_APPLY_DATE_2430": "",
                    "END_APPLY_DATE_2430": "",
                    "listid": "2430_1",
                    "start": meid,
                    "limit": 100
                }]
            }]
        }
        #查询结果列表
        try:
            _searchdata = send_post_json_me(Psur_url, jim)
            _data = json.loads(_searchdata)
            #print 'json:', _data
            searchdataid = _data['ResponseMessage']['operations'][0]['count']
            for i in range(0, searchdataid):

                PICKER_UNIT_ADDR = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][0]['v']
                REPORT_DATE = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][2]['v']
                PICKER_UNIT_FAX = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][3]['v']
                PICKER_UNIT_TEL = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][6]['v']
                DRUG_TYPE_NAME = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][7]['v']

                ACTIVE_CONSTITUENT = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][10]['v']
                OBJ_ID = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][13]['v']
                INTERNATION_BEGIN_DATE = _data['ResponseMessage'][
                    'operations'][0]['operationDatas'][i]['es'][15]['v']
                PSUR_CONCLUSION = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][17]['v']
                PROD_SOURCE_2430_SHOW = _data['ResponseMessage']['operations'][
                    0]['operationDatas'][i]['es'][18]['v']
                ENTRY_DATE = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][19]['v']

                PROD_DESC = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][21]['v']
                INDICATIONS = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][25]['v']
                PICKER_UNIT_LINKMAN = _data['ResponseMessage']['operations'][
                    0]['operationDatas'][i]['es'][26]['v']
                PICKER_UNIT_NAME = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][28]['v']
                PICKER_UNIT_EMAIL = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][29]['v']
                PICKER_UNIT_DEPT = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][31]['v']
                PICKER_SIGN = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][32]['v']

                PICKER_UNIT_POST = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][34]['v']
                DATA_END_DATE = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][35]['v']
                REPORT_ID = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][36]['v']
                DRUGNAME_CN_FORM = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][38]['v']
                DATA_START_DATE = _data['ResponseMessage']['operations'][0][
                    'operationDatas'][i]['es'][40]['v']

                tempdata = (
                    REPORT_ID,
                    #36,报告编码
                    DRUG_TYPE_NAME,
                    #7,药品分类
                    ACTIVE_CONSTITUENT,
                    #10,活性成分
                    PROD_SOURCE_2430_SHOW,
                    #18,国产/进口
                    DRUGNAME_CN_FORM,
                    #38,通用名称
                    DATA_START_DATE,
                    #41,数据起日期
                    DATA_END_DATE,
                    #35,数据止日期
                    PICKER_UNIT_NAME,
                    #28,报告单位名称
                    ENTRY_DATE,
                    #19,国家中心接收时间
                    OBJ_ID
                    #13
                )
                #新添加:
                #1.判断已存在,则不再添加
                #2.为了解决下载error中的数据,添加标识
                has_sql = "select ReportID from pusr_business where ReportID='%s'" % (
                    REPORT_ID)
                hasset = mdrsql.mdr_select(has_sql)
                if hasset:
                    #print hasset
                    print u"已存在此报告编码:", REPORT_ID
                    continue
                else:
                    #ReportID, DrugType, CFZC, Classify, TYMC, Start_Date, End_Date, FactoryName, StateReportDate, BackUp1
                    #查询数据写入
                    print "ENTRY_DATE:", ENTRY_DATE
                    insert_sql = (
                        "insert into pusr_query (ReportID, DrugType, CFZC, Classify, TYMC, Start_Date, End_Date, FactoryName, StateReportDate, BackUp1) "
                        "value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
                    mdrsql.mdr_insert_alone(insert_sql, tempdata)

                    #{
                    ylname = None
                    code = None
                    myname = None
                    ylycn = None
                    ymcn_sql = "select distinct ylname,code,myname,ylycn from ym where ymcn='%s'" % (
                        DRUGNAME_CN_FORM)
                    ymcndataset = mdrsql.mdr_select(ymcn_sql)
                    if ymcndataset:
                        for ymcndata in ymcndataset:
                            ylname = ymcndata[0]
                            code = ymcndata[1]
                            myname = ymcndata[2]
                            ylycn = ymcndata[3]
                    else:
                        ylname = ""
                        code = ""
                        myname = ""
                        ylycn = ""
                    #}
                    pname = None
                    dtypeID = None

                    localdata_sql = "select distinct ProvinceName,DistrictTypeID from unit where Name='%s'" % (
                        PICKER_UNIT_NAME)

                    localdataset = mdrsql.mdr_select(localdata_sql)
                    if localdataset:
                        for localdata in localdataset:
                            pname = localdata[0]
                            dtypeID = localdata[1]

                    else:
                        pname = ""
                        dtypeID = ""

                    boss_add_data = [
                        ylname, code, myname, ylycn, pname, dtypeID
                    ]
                    #主表信息写入
                    reportdata = [
                        #
                        #报告表编码 	36
                        REPORT_ID,
                        #国际诞生日   15
                        INTERNATION_BEGIN_DATE,
                        #活性成分(处方组成) 10
                        ACTIVE_CONSTITUENT,
                        #药品分类	7
                        DRUG_TYPE_NAME,
                        #国产/进口 18
                        PROD_SOURCE_2430_SHOW,
                        #适应症(功能主治) 25
                        INDICATIONS,
                        #产品情况说明 21
                        PROD_DESC,
                        #本期报告结论 17
                        PSUR_CONCLUSION,
                        #报告人 32
                        PICKER_SIGN,
                        #报告日期 2
                        REPORT_DATE,
                        #报告单位名称 28
                        PICKER_UNIT_NAME,
                        #传真 3
                        PICKER_UNIT_FAX,
                        #报告单位地址 0
                        PICKER_UNIT_ADDR,
                        #邮政编码 34
                        PICKER_UNIT_POST,
                        #负责部门 31
                        PICKER_UNIT_DEPT,
                        #联系电话 6
                        PICKER_UNIT_TEL,
                        #联系人26
                        PICKER_UNIT_LINKMAN,
                        #电子邮件 29
                        PICKER_UNIT_EMAIL,
                        #国家中心接收时间 19
                        ENTRY_DATE
                    ]
                    #主表信息更新
                    somedata = get_report(OBJ_ID)
                    #print u"额外数据解析,即返回整个文本",somedata
                    #extrareportdata = data2clean(extradata(somedata))
                    extrareportdata = extradata2(somedata)

                    dataall = reportdata + extrareportdata + boss_add_data

                    #报告表编码 	36
                    #REPORT_ID,INTERNATION_BEGIN_DATE,ACTIVE_CONSTITUENT,DRUG_TYPE_NAME,PROD_SOURCE_2430_SHOW,INDICATIONS,PROD_DESC,PSUR_CONCLUSION,PICKER_SIGN,REPORT_DATE,PICKER_UNIT_NAME,PICKER_UNIT_FAX,PICKER_UNIT_ADDR, PICKER_UNIT_POST,PICKER_UNIT_DEPT,PICKER_UNIT_TEL,PICKER_UNIT_LINKMAN,PICKER_UNIT_EMAIL,ENTRY_DATE
                    insert_report = (
                        "insert into pusr_business (REPORTID,INTERNATION_BEGIN_DATE,ACTIVE_CONSTITUEN,DRUG_TYPE_NAME,PROD_SOURCE,INDICATIONS,PROD_DESC,PSUR_CONCLUSION,PICKER_SIGN,REPORT_DATE,PICKER_UNIT_NAME,PICKER_UNIT_FAX,PICKER_UNIT_ADDR, PICKER_UNIT_POST,PICKER_UNIT_DEPT,PICKER_UNIT_TEL,PICKER_UNIT_LINKMAN,PICKER_UNIT_EMAIL,ENTRY_DATE,BGQ,ylname,code,myname,ylycn,ProvinceName,District) "
                        "value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
                    )
                    mdrsql.mdr_insert_alone(insert_report, dataall)
                    print REPORT_ID
                    #psur业务主表批准文号部分11字段1-N数据表
                    extrainfo = extradata3(somedata)
                    n = 11
                    dataout = [
                        extrainfo[i:i + n]
                        for i in range(0, len(extrainfo), n)
                    ]
                    for temp in dataout:
                        d0 = temp[0]
                        d1 = temp[1]
                        d2 = temp[2]
                        if d1:
                            pass
                        else:
                            d1 = "0000-00-00"
                        if d2:
                            pass
                        else:
                            d2 = "0000-00-00"

                        d3 = temp[3]
                        d4 = temp[4]
                        d5 = temp[5]
                        d6 = temp[6]
                        d7 = temp[7]
                        d8 = temp[8]
                        d9 = temp[9]
                        d10 = temp[10]
                        extraalldata = [
                            REPORT_ID, d0, d1, d2, d3, d4, d5, d6, d7, d8, d9,
                            d10
                        ]
                        insert_report_extra = (
                            "insert into pusr_business_extradata (REPORTID,RegisterID,RegisterTime,FirstRegisterTime,TYMC,SPMC,DrugMState,GG,JX,BQSC,BQXL,CountUser) "
                            "value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
                        mdrsql.mdr_insert_alone(insert_report_extra,
                                                extraalldata)
                    #评价信息读取
                    write_Eval(somedata, OBJ_ID, REPORT_ID)

                    #修改信息读取
                    write_ChangeInfo(somedata, OBJ_ID, REPORT_ID)

                    #显示附件信息读取
                    write_DWF(somedata, OBJ_ID, REPORT_ID)

                    #下载文件信息写入
                    download_fileinfo3(OBJ_ID, REPORT_ID)

                    #附件下载
                    """
                    if Tag:
                        myautodown(OBJ_ID,REPORT_ID)
                    else:
                        pass
                    """
                    myautodown(OBJ_ID, REPORT_ID)

            time.sleep(0.001)
        except (IndexError, KeyError, ValueError), exception:
            print "Main:", exception
            print "main:", _searchdata
Exemplo n.º 20
0
def PSUR_Report(_timedict):
    #
    t = _timedict
    t_start = t['beginTime']
    t_end = t['endTime']
    RF_list = gather_report_total(_timedict)
    for i in range(0, RF_list):
        meid = i*100
        print "meid:", meid
        jim = {"funcID":"QUERY_DATA","userID":78919,"operations":[{"actionName":"query","operationDatas":[{"ENTRY_START_DATE_2401":t_start,"ENTRY_END_DATE_2401":t_end,"ACTIVE_CONSTITUENT_2430":"","TRADENAME_CN_2431":"","DRUGNAME_CN_FORM_2431":"","DOSEFORM_2431":"","DRUG_STATUS_2431":"","APPROVAL_NO_2431":"","REPORT_ID_2430":"","PICKER_UNIT_NAME_2430":"","START_APPLY_DATE_2430":"","END_APPLY_DATE_2430":"","listid":"2430_1","start":meid,"limit":100}]}]}
        #查询结果列表
        try:
            _searchdata = send_post_json_me(Psur_url, jim)
            _data = json.loads(_searchdata)
            #print 'json:', _data
            searchdataid = _data['ResponseMessage']['operations'][0]['count']
            for i in range(0, searchdataid):

                PICKER_UNIT_ADDR = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][0]['v']
                REPORT_DATE = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][2]['v']
                PICKER_UNIT_FAX = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][3]['v']
                PICKER_UNIT_TEL = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][6]['v']
                DRUG_TYPE_NAME = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][7]['v']

                ACTIVE_CONSTITUENT = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][10]['v']
                OBJ_ID = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][13]['v']
                INTERNATION_BEGIN_DATE = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][15]['v']
                PSUR_CONCLUSION = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][17]['v']
                PROD_SOURCE_2430_SHOW = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][18]['v']
                ENTRY_DATE = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][19]['v']


                PROD_DESC = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][21]['v']
                INDICATIONS = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][25]['v']
                PICKER_UNIT_LINKMAN = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][26]['v']
                PICKER_UNIT_NAME = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][28]['v']
                PICKER_UNIT_EMAIL = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][29]['v']
                PICKER_UNIT_DEPT = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][31]['v']
                PICKER_SIGN = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][32]['v']

                PICKER_UNIT_POST = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][34]['v']
                DATA_END_DATE = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][35]['v']
                REPORT_ID = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][36]['v']
                DRUGNAME_CN_FORM = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][38]['v']
                DATA_START_DATE = _data['ResponseMessage']['operations'][0]['operationDatas'][i]['es'][40]['v']

                tempdata = (
                    REPORT_ID,
                    #36,报告编码
                    DRUG_TYPE_NAME,
                    #7,药品分类
                    ACTIVE_CONSTITUENT,
                    #10,活性成分
                    PROD_SOURCE_2430_SHOW,
                    #18,国产/进口
                    DRUGNAME_CN_FORM,
                    #38,通用名称
                    DATA_START_DATE,
                    #41,数据起日期
                    DATA_END_DATE,
                    #35,数据止日期
                    PICKER_UNIT_NAME,
                    #28,报告单位名称
                    ENTRY_DATE,
                    #19,国家中心接收时间
                    OBJ_ID
                    #13
                )
                #新添加:
                #1.判断已存在,则不再添加
                #2.为了解决下载error中的数据,添加标识
                has_sql = "select ReportID from pusr_business where ReportID='%s'" % (REPORT_ID)
                hasset = mdrsql.mdr_select(has_sql)
                if hasset:
                    #print hasset
                    print u"已存在此报告编码:",REPORT_ID
                    continue
                else:
                    #ReportID, DrugType, CFZC, Classify, TYMC, Start_Date, End_Date, FactoryName, StateReportDate, BackUp1
                    #查询数据写入
                    print "ENTRY_DATE:",ENTRY_DATE
                    insert_sql = (
                        "insert into pusr_query (ReportID, DrugType, CFZC, Classify, TYMC, Start_Date, End_Date, FactoryName, StateReportDate, BackUp1) "
                        "value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
                    )
                    mdrsql.mdr_insert_alone(insert_sql, tempdata)

                    #{
                    ylname = None
                    code = None
                    myname = None
                    ylycn = None
                    ymcn_sql = "select distinct ylname,code,myname,ylycn from ym where ymcn='%s'" % (DRUGNAME_CN_FORM)
                    ymcndataset = mdrsql.mdr_select(ymcn_sql)
                    if ymcndataset:
                        for ymcndata in ymcndataset:
                            ylname = ymcndata[0]
                            code = ymcndata[1]
                            myname = ymcndata[2]
                            ylycn = ymcndata[3]
                    else:
                            ylname = ""
                            code = ""
                            myname = ""
                            ylycn = ""
                    #}
                    pname =None
                    dtypeID = None

                    localdata_sql = "select distinct ProvinceName,DistrictTypeID from unit where Name='%s'" % (PICKER_UNIT_NAME)

                    localdataset = mdrsql.mdr_select(localdata_sql)
                    if localdataset:
                        for localdata in localdataset:
                            pname = localdata[0]
                            dtypeID = localdata[1]

                    else:
                            pname = ""
                            dtypeID = ""

                    boss_add_data = [ylname, code, myname, ylycn, pname, dtypeID]
                    #主表信息写入
                    reportdata =[
                        #
                        #报告表编码 	36
                        REPORT_ID,
                        #国际诞生日   15
                        INTERNATION_BEGIN_DATE,
                        #活性成分(处方组成) 10
                        ACTIVE_CONSTITUENT,
                        #药品分类	7
                        DRUG_TYPE_NAME,
                        #国产/进口 18
                        PROD_SOURCE_2430_SHOW,
                        #适应症(功能主治) 25
                        INDICATIONS,
                        #产品情况说明 21
                        PROD_DESC,
                        #本期报告结论 17
                        PSUR_CONCLUSION,
                        #报告人 32
                        PICKER_SIGN,
                        #报告日期 2
                        REPORT_DATE,
                        #报告单位名称 28
                        PICKER_UNIT_NAME,
                        #传真 3
                        PICKER_UNIT_FAX,
                        #报告单位地址 0
                        PICKER_UNIT_ADDR,
                        #邮政编码 34
                        PICKER_UNIT_POST,
                        #负责部门 31
                        PICKER_UNIT_DEPT,
                        #联系电话 6
                        PICKER_UNIT_TEL,
                        #联系人26
                        PICKER_UNIT_LINKMAN,
                        #电子邮件 29
                        PICKER_UNIT_EMAIL,
                        #国家中心接收时间 19
                        ENTRY_DATE
                    ]
                    #主表信息更新
                    somedata = get_report(OBJ_ID)
                    #print u"额外数据解析,即返回整个文本",somedata
                    #extrareportdata = data2clean(extradata(somedata))
                    extrareportdata = extradata2(somedata)

                    dataall = reportdata + extrareportdata + boss_add_data

                    #报告表编码 	36
                    #REPORT_ID,INTERNATION_BEGIN_DATE,ACTIVE_CONSTITUENT,DRUG_TYPE_NAME,PROD_SOURCE_2430_SHOW,INDICATIONS,PROD_DESC,PSUR_CONCLUSION,PICKER_SIGN,REPORT_DATE,PICKER_UNIT_NAME,PICKER_UNIT_FAX,PICKER_UNIT_ADDR, PICKER_UNIT_POST,PICKER_UNIT_DEPT,PICKER_UNIT_TEL,PICKER_UNIT_LINKMAN,PICKER_UNIT_EMAIL,ENTRY_DATE
                    insert_report = (
                        "insert into pusr_business (REPORTID,INTERNATION_BEGIN_DATE,ACTIVE_CONSTITUEN,DRUG_TYPE_NAME,PROD_SOURCE,INDICATIONS,PROD_DESC,PSUR_CONCLUSION,PICKER_SIGN,REPORT_DATE,PICKER_UNIT_NAME,PICKER_UNIT_FAX,PICKER_UNIT_ADDR, PICKER_UNIT_POST,PICKER_UNIT_DEPT,PICKER_UNIT_TEL,PICKER_UNIT_LINKMAN,PICKER_UNIT_EMAIL,ENTRY_DATE,BGQ,ylname,code,myname,ylycn,ProvinceName,District) "
                        "value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
                    )
                    mdrsql.mdr_insert_alone(insert_report, dataall)
                    print REPORT_ID
                    #psur业务主表批准文号部分11字段1-N数据表
                    extrainfo = extradata3(somedata)
                    n=11
                    dataout = [extrainfo[i:i+n] for i in range(0, len(extrainfo), n)]
                    for temp in dataout:
                        d0 = temp[0]
                        d1 = temp[1]
                        d2 = temp[2]
                        if d1:
                            pass
                        else:
                            d1 = "0000-00-00"
                        if d2:
                            pass
                        else:
                            d2 = "0000-00-00"

                        d3 = temp[3]
                        d4 = temp[4]
                        d5 = temp[5]
                        d6 = temp[6]
                        d7 = temp[7]
                        d8 = temp[8]
                        d9= temp[9]
                        d10 = temp[10]
                        extraalldata = [REPORT_ID,d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10]
                        insert_report_extra = (
                            "insert into pusr_business_extradata (REPORTID,RegisterID,RegisterTime,FirstRegisterTime,TYMC,SPMC,DrugMState,GG,JX,BQSC,BQXL,CountUser) "
                            "value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
                        )
                        mdrsql.mdr_insert_alone(insert_report_extra, extraalldata)
                    #评价信息读取
                    write_Eval(somedata, OBJ_ID, REPORT_ID)

                    #修改信息读取
                    write_ChangeInfo(somedata, OBJ_ID, REPORT_ID)

                    #显示附件信息读取
                    write_DWF(somedata, OBJ_ID, REPORT_ID)

                    #下载文件信息写入
                    download_fileinfo3(OBJ_ID,REPORT_ID)

                    #附件下载
                    """
                    if Tag:
                        myautodown(OBJ_ID,REPORT_ID)
                    else:
                        pass
                    """
                    myautodown(OBJ_ID,REPORT_ID)

            time.sleep(0.001)
        except (IndexError, KeyError, ValueError), exception:
            print "Main:",exception
            print "main:",_searchdata
Exemplo n.º 21
0
def myautodown2():
    #has_sql = "select ReportID from pusr_business where ReportID='%s'" % (REPORT_ID)
    down_sql = "SELECT FileID,ShowFileName,BackUp,ReportID FROM pusr_dwfinfo_down_error"
    objlistid = mdrsql.mdr_select(down_sql)
    for objid in objlistid:
        downallfiles3(objid[0], objid[2], objid[1],objid[3])
Exemplo n.º 22
0
def myautodown(id,reportid):
    #has_sql = "select ReportID from pusr_business where ReportID='%s'" % (REPORT_ID)
    down_sql = "SELECT FileID,ShowFileName FROM pusr_dwfinfo_down where ReportID='%s'" % (reportid)
    objlistid = mdrsql.mdr_select(down_sql)
    for objid in objlistid:
        downallfiles3(objid[0], id, objid[1],reportid)
Exemplo n.º 23
0
def get_smd_report(smdrReportViewHtml, report_id,obj_id, obj_name,ReportUnitLinkman,ReportUnitWork,DateTag):
    #D.关联性评价
    global re_evalute,re_td
    
    report_sql = (
                '''replace into mdr_reports(
                BianMa,
                ReportUnitnName,               
                ReportAppraiseDate,
                
                ReportUnitADRDateAnalyse,
                ReportUnitADRTypeAnalyse,
                ReportUnitOtherRelatedAnalyse,                
                ReportUnitAppraise, 
                
                ReportUnitLinkman,
                ReportUnitWork,
                DateTag,
                ReportUnitComments)
                values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'''
            )
    mdr_sql = "SELECT BianMa,ReportUnitName,StateReportDate FROM `mdr_business_gather` where BianMa='%s'" % (report_id)
    mdr_row = mdrsql.mdr_select(mdr_sql) # 返回结果是多行
    if len(mdr_row) > 0 :
        mdr_row = mdr_row[0]
    
    if len(mdr_row) != 3 :
        return
        
    BianMa = mdr_row[0]
    ReportUnitName = mdr_row[1]
    ReportAppraiseDate = mdr_row[2]

    eval_match = re_evalute.search(smdrReportViewHtml)
    if not eval_match:
        print u'暂时还没有关联性评价信息!'
        return 
    
    ReportUnitADRDateAnalyse = ""
    ReportUnitADRTypeAnalyse = ""
    ReportUnitOtherRelatedAnalyse = ""
    ReportUnitAppraise = ""
    ReportUnitComments=""   #单位评价备注,如果能正常抓取信息,备注默认为空,否则=Unit appraise error

    try:
        ping_jia_infos = re_td.findall(eval_match.group(1))
        if len(ping_jia_infos) > 0:
            ReportUnitADRDateAnalyse = getTdVal(ping_jia_infos[2][0])
            ReportUnitADRTypeAnalyse = getTdVal(ping_jia_infos[4][0])
            ReportUnitOtherRelatedAnalyse = getTdVal(ping_jia_infos[6][0])
            ReportUnitAppraise = getTdVal(ping_jia_infos[8][0])
        
        report_values = (BianMa,ReportUnitName,ReportAppraiseDate,ReportUnitADRDateAnalyse,ReportUnitADRTypeAnalyse,ReportUnitOtherRelatedAnalyse,ReportUnitAppraise,ReportUnitLinkman,ReportUnitWork,DateTag,ReportUnitAppraise)
        mdrsql.mdr_insert_alone(report_sql,  report_values)
    except Exception, err:
        print BianMa,u'关联性评价获取失败',err

        #评价信息默认为空
        ReportUnitADRDateAnalyse = ""
        ReportUnitADRTypeAnalyse = ""
        ReportUnitOtherRelatedAnalyse = ""
        ReportUnitAppraise =  ""
        ReportUnitComments=""
        report_values = (BianMa,ReportUnitName,ReportAppraiseDate,ReportUnitADRDateAnalyse,ReportUnitADRTypeAnalyse,ReportUnitOtherRelatedAnalyse,ReportUnitAppraise,ReportUnitLinkman,ReportUnitWork,DateTag,ReportUnitAppraise)
        mdrsql.mdr_insert_alone(report_sql,  report_values)
Exemplo n.º 24
0
def myautodown2():
    #has_sql = "select ReportID from pusr_business where ReportID='%s'" % (REPORT_ID)
    down_sql = "SELECT FileID,ShowFileName,BackUp,ReportID FROM pusr_dwfinfo_down_error"
    objlistid = mdrsql.mdr_select(down_sql)
    for objid in objlistid:
        downallfiles3(objid[0], objid[2], objid[1], objid[3])
Exemplo n.º 25
0
def get_smd_report(smdrReportViewHtml, report_id, obj_id, obj_name,
                   ReportUnitLinkman, ReportUnitWork, DateTag):
    #D.关联性评价
    global re_evalute, re_td

    report_sql = ('''replace into mdr_reports(
                BianMa,
                ReportUnitnName,               
                ReportAppraiseDate,
                
                ReportUnitADRDateAnalyse,
                ReportUnitADRTypeAnalyse,
                ReportUnitOtherRelatedAnalyse,                
                ReportUnitAppraise, 
                
                ReportUnitLinkman,
                ReportUnitWork,
                DateTag,
                ReportUnitComments)
                values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)''')
    mdr_sql = "SELECT BianMa,ReportUnitName,StateReportDate FROM `mdr_business_gather` where BianMa='%s'" % (
        report_id)
    mdr_row = mdrsql.mdr_select(mdr_sql)  # 返回结果是多行
    if len(mdr_row) > 0:
        mdr_row = mdr_row[0]

    if len(mdr_row) != 3:
        return

    BianMa = mdr_row[0]
    ReportUnitName = mdr_row[1]
    ReportAppraiseDate = mdr_row[2]

    eval_match = re_evalute.search(smdrReportViewHtml)
    if not eval_match:
        print u'暂时还没有关联性评价信息!'
        return

    ReportUnitADRDateAnalyse = ""
    ReportUnitADRTypeAnalyse = ""
    ReportUnitOtherRelatedAnalyse = ""
    ReportUnitAppraise = ""
    ReportUnitComments = ""  #单位评价备注,如果能正常抓取信息,备注默认为空,否则=Unit appraise error

    try:
        ping_jia_infos = re_td.findall(eval_match.group(1))
        if len(ping_jia_infos) > 0:
            ReportUnitADRDateAnalyse = getTdVal(ping_jia_infos[2][0])
            ReportUnitADRTypeAnalyse = getTdVal(ping_jia_infos[4][0])
            ReportUnitOtherRelatedAnalyse = getTdVal(ping_jia_infos[6][0])
            ReportUnitAppraise = getTdVal(ping_jia_infos[8][0])

        report_values = (BianMa, ReportUnitName, ReportAppraiseDate,
                         ReportUnitADRDateAnalyse, ReportUnitADRTypeAnalyse,
                         ReportUnitOtherRelatedAnalyse, ReportUnitAppraise,
                         ReportUnitLinkman, ReportUnitWork, DateTag,
                         ReportUnitAppraise)
        mdrsql.mdr_insert_alone(report_sql, report_values)
    except Exception, err:
        print BianMa, u'关联性评价获取失败', err

        #评价信息默认为空
        ReportUnitADRDateAnalyse = ""
        ReportUnitADRTypeAnalyse = ""
        ReportUnitOtherRelatedAnalyse = ""
        ReportUnitAppraise = ""
        ReportUnitComments = ""
        report_values = (BianMa, ReportUnitName, ReportAppraiseDate,
                         ReportUnitADRDateAnalyse, ReportUnitADRTypeAnalyse,
                         ReportUnitOtherRelatedAnalyse, ReportUnitAppraise,
                         ReportUnitLinkman, ReportUnitWork, DateTag,
                         ReportUnitAppraise)
        mdrsql.mdr_insert_alone(report_sql, report_values)