def makeqrcodeoutputfile(self, id, file_route):
        for item in self.orderlist:
            if item['autoid'] == id:
                proddetail = item
                break
        clientid = proddetail['clientid']
        key_dict_client = {'clientid': clientid}
        clients_detail = self.SLC.get_client(False, *VALUES_LIST_CLIENT,
                                             **key_dict_client)
        if len(clients_detail) != 1:
            return
        client = clients_detail[0]

        key_dict = {'ppopid': id}
        res = self.WC.get_ppopqrcode(False, *VALUES_LIST_QRCODE, **key_dict)
        if not len(res):
            return
        # 把二维码按比例分组
        q_list, ppid_list, batchno_list = self.sort_qrcode(
            res.order_by('batchno'))

        xml = QXmlStreamWriter()
        qfile = QFile(file_route)
        if qfile.open(QIODevice.WriteOnly):
            xml.setDevice(qfile)
        else:
            return
        xml.setAutoFormatting(True)
        xml.writeStartDocument()
        # 添加头文件信息
        self.addxmlheader(xml, client['kind'])
        self.addxmlproddetail(xml, proddetail)
        temp_ppid = ''
        for i in range(0, len(ppid_list)):
            if temp_ppid != ppid_list[i]:
                if temp_ppid != '':
                    # 把上一个Batch结束了
                    xml.writeEndElement()
                temp_ppid = ppid_list[i]
                xml.writeStartElement("Batch")
                xml.writeAttribute('batchNo', batchno_list[i])
                xml.writeAttribute('operator', proddetail['auditorname'])
                xml.writeAttribute('oprDate', str(proddetail['putoutdate']))

                xml.writeAttribute(' toUnit', client['clientname'])
                xml.writeAttribute('toProvince', client['province'])
                xml.writeAttribute('toCity', client['city'])
                xml.writeAttribute('toCounty', client['county'])
                xml.writeAttribute('toUnitcode', client['unitcode'])

            xml.writeStartElement("Data")
            xml.writeAttribute('code', q_list[i])
            xml.writeEndElement()

        xml.writeEndElement()
        xml.writeEndElement()
        xml.writeEndDocument()
Example #2
0
    def makeqrcodeoutputfile(self, id, file_route):
        for item in self.orderlist:
            if item['autoid'] == id:
                proddetail = item
                break

        key_dict = {'pwdid': id}
        res = self.WC.get_pwqrcode(False, *VALUES_LIST_QRCODE, **key_dict)
        if not len(res):
            return
        # 把二维码按比例分组
        q_list, ppid_list, batchno_list = self.sort_qrcode(
            res.order_by('ppid'))

        xml = QXmlStreamWriter()
        qfile = QFile(file_route)
        if qfile.open(QIODevice.WriteOnly):
            xml.setDevice(qfile)
        else:
            return
        xml.setAutoFormatting(True)
        xml.writeStartDocument()
        # 添加头文件信息
        self.addxmlheader(xml)
        self.addxmlproddetail(xml, proddetail)
        temp_ppid = ''
        for i in range(0, len(ppid_list)):
            if temp_ppid != ppid_list[i]:
                if temp_ppid != '':
                    # 把上一个ppid结束了
                    xml.writeEndElement()
                temp_ppid = ppid_list[i]
                xml.writeStartElement("Batch")
                xml.writeAttribute('batchNo', batchno_list[i])
                xml.writeAttribute('operator', proddetail['creatorname'])
                xml.writeAttribute('oprDate', str(proddetail['wdate']))

            xml.writeStartElement("Data")
            xml.writeAttribute('code', q_list[i])
            xml.writeEndElement()

        xml.writeEndElement()
        xml.writeEndElement()
        xml.writeEndDocument()
Example #3
0
    def makeqrcodeinputfile(self, ppid, file_route):
        for item in self.prodlist:
            if item['autoid'] == ppid:
                proddetail = item
                break
        key_dict = {'ppid': ppid}
        res = self.WC.get_qrcoderep(False, *VALUES_LIST_QRCODE, **key_dict)
        if not len(res):
            return
        # 把二维码按比例分组
        q_list, proportion_list = self.sort_qrcode(res)
        # 把比例相同的合并成一个同一个项目
        q_list_merge, proportion_list_merge = self.merge_qrcode(
            q_list, proportion_list)
        xml = QXmlStreamWriter()
        qfile = QFile(file_route)
        if qfile.open(QIODevice.WriteOnly):
            xml.setDevice(qfile)
        else:
            return

        xml.setAutoFormatting(True)
        xml.writeStartDocument()
        # 添加头文件信息
        self.addxmlheader(xml)
        self.addxmlproddetail(xml, proddetail)
        for i in range(0, len(proportion_list_merge)):
            spnum = proportion_list[i][0]
            mpnum = proportion_list[i][1]
            bpnum = proportion_list[i][2]
            lpnum = proportion_list[i][3]
            xml.writeStartElement("Batch")
            xml.writeAttribute('batchNo', proddetail['batchno'])
            xml.writeAttribute('specification', proddetail['spec'])
            xml.writeAttribute('minPackUnit', proddetail['spunit'])
            if spnum != 0:
                minTagUnit = proddetail['spunit']
            elif mpnum != 0:
                minTagUnit = proddetail['mpunit']
            else:
                minTagUnit = proddetail['bpunit']
            tagPackRatio = ''
            for num in (lpnum, bpnum, mpnum, spnum):
                if num != 0:
                    if tagPackRatio == '':
                        tagPackRatio = str(num)
                    else:
                        tagPackRatio += ':' + str(num)
            xml.writeAttribute('minTagUnit', minTagUnit)
            xml.writeAttribute('tagPackRatio', tagPackRatio)
            xml.writeAttribute('produceDate', str(proddetail['makedate']))
            xml.writeAttribute('operator', user.user_name)
            xml.writeAttribute('oprDate', str(user.now_date))
            xml.writeAttribute('count', str(len(q_list_merge[i])))
            xml.writeAttribute('countUnit',
                               '1' if minTagUnit == tagPackRatio else '2')
            qrcode = q_list_merge[i]
            for code in qrcode:
                xml.writeStartElement("Data")
                xml.writeAttribute('code', code)
                xml.writeEndElement()

            xml.writeEndElement()
        xml.writeEndElement()
        xml.writeEndElement()
        xml.writeEndDocument()