示例#1
0
def getData(sql, key):
    """从数据库查询 sql 语句, 并通过 key 获取结果"""
    if not g_DB.Execute(sql):
        return []
    res = g_DB.fetchAll()
    if not res:
        return []

    result = []
    for data in res:
        result.append(data[key])
    return result
示例#2
0
    def SubmitTask(self):
        data, PCBCode = self.GetDataFromView()
        if not data:
            return False

        if not g_DB.insert('u_task', data):
            return False

        SQL = r'select * from c_taskroledef order by code'

        now = str(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
        data1 = {}
        data1.setdefault('TaskName', data['TaskName'])
        data1.setdefault('SubTaskStartDate', '"%s"' % now)
        data1.setdefault('SubTaskEndDate', '"%s"' % now)
        data1.setdefault('SubTaskRealDate', '"%s"' % now)
        data1.setdefault('SubTaskOwner', data['TaskOwner'])

        IsFirst = True
        if g_DB.Execute(SQL):
            res = g_DB.fetchAll()
            if res:
                for d in res:
                    data1['SubTaskID'] = '"%d"' % d.get('Code', '')
                    data1['SubTaskName'] = '"%s"' % d.get('Role', '')
                    if IsFirst:
                        data1['SubTaskStatus'] = '"%s"' % '进行中'
                    else:
                        data1['SubTaskStatus'] = '"%s"' % '未启动'

                    if not g_DB.insert('u_taskdetail', data1):
                        return False

                    IsFirst = False
        else:
            return False

        #该需求待定
        # for code in PCBCode.split(','):
        #     data1['PCBCode'] = '"%s"' % code
        #     SQL = 'UPDATE u_r_PCB_Product SET PCBCode = %s WHERE TaskName = %s' % (('"%s"' % code), data['TaskName'])
        #     if not g_DB.Execute(SQL):
        #         return False

        g_Task.Task = data['TaskName'][1:-1]
        g_Task.ProductType = data['ProductType'][1:-1]
        g_Task.ProductEnv = data['Env'][1:-1]

        #数据库执行正确
        return True
示例#3
0
 def GetEnvInfo(self):
     SQL = r'select distinct Env from dfr_productline'
     result = []
     if g_DB.Execute(SQL):
         res = g_DB.fetchAll()
         if res:
             for data in res:
                 for key in data:
                     result.append(data[key])
         g_Log.LogInfo('获取环境信息成功')
     else:
         g_Log.LogError('获取环境信息失败')
         g_Log.LogDebug('SQL语句:' + SQL)
     return result
示例#4
0
    def GetProductFamilyInfo(self, ProductType):
        SQL = r'select productFamily from dfr_productline where Class="' + ProductType + '"'
        result = []
        if g_DB.Execute(SQL):
            res = g_DB.fetchAll()
            if res:
                for data in res:
                    for key in data:
                        result.append(data[key])

            g_Log.LogInfo('从数据库获取产品族信息成功')
        else:
            g_Log.LogError('从数据库获取产品族信息失败')
            g_Log.LogDebug('SQL语句:' + SQL)

        return result
示例#5
0
    def Submit(self):
        try:
            result = False
            destPath = g_Data.path + 'Project\\' + g_Task.task + '\\'
            if not os.path.exists(destPath):
                os.mkdir(destPath)

            SQL = 'select * from u_r_pcb_product where TaskName="' + g_Task.Task + '"'
            if not g_DB.Execute(SQL):
                return result
            res = g_DB.fetchAll()
            if not res: return result

            PCBCode = res[0]['PCBCode']
            ExcelFileName = destPath + g_Task.Task + PCBCode + '_Input.xls'
            if not self._SaveDataToExcel(ExcelFileName):
                g_Log.LogError('存储Excel错误')
                return result

            BDMPos, BrdPos = self.GetFileName()
            shutil.copy(BDMPos, destPath + '_' + PCBCode + '_Bom.xls')
            shutil.copy(BrdPos, destPath + '_' + PCBCode + '_Brd.brd')

            data = {}
            data.setdefault('brd_LocalPath', '"%s"' % BrdPos)
            data.setdefault('Bom_LocalPath', '"%s"' % BDMPos)
            data.setdefault('Input_LocalPath', '"%s"' % ExcelFileName)
            data.setdefault('InputFlag', '1')

            if not g_DB.insert('u_r_pcb_product', data, 'TaskName="'+g_Task.Task + '"'):
                return result

            result = True
            return result
        finally:
            if result:
                self._ShowMessage((PCBCode + '单板信息提交完成!'))
            else:
                self._ShowMessage(('单板信息提交失败!'))
示例#6
0
    def GetRuleListInput(self):
        SQL = 'select name from general_info where type="S_DFRLIB"'
        if not g_DB.Execute(SQL):
            return False
        res = g_DB.fetchAll()
        if not res: return False

        SQL = 'select distinct inputtype,inputmethod,inputoption from dfr_inputfact,dfr_r_rule_input,('
        IsFirst = True

        for d in res:
            if not IsFirst: SQL += ' UNION '
            SQL += 'select code,RuleContent,product'
            SQL += ' from '+ d.get('name', '')
            IsFirst = False

        SQL += ') as ruleQuery '
        SQL += 'where ((Product="通用") or (Product like "%' + g_Task.ProductType + '%"))'
        SQL += 'and ruleQuery.code=dfr_r_rule_input.ruleID and dfr_r_rule_input.inputID=dfr_inputfact.code '
        SQL += 'order by inputtype'

        if not g_DB.Execute(SQL):
            return False
        res1 = g_DB.fetchAll()
        if not res1: return False

        IsFirst = True
        top = 15
        for d1 in res1:
            SQL = 'select distinct dfr_inputfact.code as code,InputDescription,InputMethod,InputOption,TrigCond'
            SQL += ' from dfr_inputfact,dfr_r_rule_input,('
            for d in res:
                if not IsFirst: SQL += ' UNION '
                SQL += 'select code,RuleContent,product'
                SQL += ' from ' + d.get('name', '')
                IsFirst = False

            SQL += ') as ruleQuery '
            SQL += 'where ((Product="通用") or (Product like "%' + g_Task.ProductType + '%"))'
            SQL += 'and ruleQuery.code=dfr_r_rule_input.ruleID and dfr_r_rule_input.InputID=dfr_inputfact.Code '
            SQL += 'and InputType="' + d1['inputtype'] + '"'

            if not g_DB.Execute(SQL):
                return False
            res2 = g_DB.fetchAll()
            if not res2: return False

            RowCount = math.ceil(len(res1) + 1 / 6)
            height = 30 + RowCount * 22
            size = [5, top, 700, height]
            top += height + 20

            CheckBoXList = self.CreateCheckBoXList(res1[0]['inputtype'], size, RowCount)

            Row = 1
            Col = 0
            for d in res2:
                self.AddCheckBox(CheckBoXList, Row, Col, d['InputDescription'])
                Col += 1
                if Col == 6:
                    Row += 1
                    Col = 0