Ejemplo n.º 1
0
 def update_productputinnote(self,
                             autoid=0,
                             in_warehouse=False,
                             putin_msg=[],
                             *args,
                             **kwargs):
     if not in_warehouse:
         return WorkshopModels.update_productputinnote(
             autoid, *args, **kwargs)
     if autoid == 0:
         return
     with transaction.atomic():
         p1 = transaction.savepoint()
         cursor = connection.cursor()
         # 每个项目对应一条产品库存记录
         # 每个项目分别是一个元组,包括3个元素,
         #   0:入库类型,1:记录对应的autoid,用于入库时补全信息, 2:本项的数量
         for item in putin_msg:
             '''
             cursor.execute(
                 r"call addprodrep(%s, %s, %s, %s, %s)" % (item[i] for i in range(0,4))
             )
             '''
             cursor.execute("call addprodrep(%s, %s, %s, %s, %s)" %
                            (item[0], item[1], item[2], item[3], item[4]))
         return WorkshopModels.update_productputinnote(
             autoid, *args, **kwargs)
Ejemplo n.º 2
0
    def update_preproductputinnote(self, autoid, putin_msg, *args, **kwargs):
        with transaction.atomic():
            p1 = transaction.savepoint()
            res1 = WarehouseModel.update_stuffrepository(**putin_msg)

            res2 = WorkshopModels.update_productputinnote(
                autoid, *args, **kwargs)
            if res1 and res2:
                return True
            else:
                transaction.savepoint_rollback(p1)
                return False
Ejemplo n.º 3
0
 def __init__(self, autoid, parent=None):
     super().__init__(parent)
     self.setupUi(self)
     self.product = ProductController()
     self.autoid = autoid
     # 当前的文档内容
     self.current_docid = 0
     self.current_content = object
     self.wsmodels = WorkshopModels()
     self.detail = self.product.get_producingplan(autoid=autoid)
     if len(self.detail) != 1:
         raise ValueError
     self.linepost = self.wsmodels.get_linepost(autoid)
     linepost_list = []
     if len(self.linepost):
         for item in self.linepost:
             linepost_list.append(item.autoid)
     self.linepostdocuments = self.wsmodels.get_linepostdocuments(
         linepost_list)
     #if len(self.linepostdocuments):
     # 初始化标题和基本信息
     self.setup_title(self.detail[0])
     # 初始化文档目录
     self.setup_filetree(list(self.linepost), list(self.linepostdocuments))
Ejemplo n.º 4
0
 def delete_data(self, table_num: int, condition={}, *args, **kwargs):
     table_str = TABLE_SET[table_num][0]
     err_msg = "删除" + TABLE_SET[table_num][1]
     return WorkshopModels.delete_data(table_str, err_msg, condition, *args,
                                       **kwargs)
Ejemplo n.º 5
0
 def get_productputinnote(self, display_flag=False, *args, **kwargs):
     return WorkshopModels.get_productputinnote(display_flag, *args,
                                                **kwargs)
Ejemplo n.º 6
0
 def get_data(self, table_num: int, display_flag=False, *args, **kwargs):
     table_str = TABLE_SET[table_num][0]
     err_msg = "查询" + TABLE_SET[table_num][1]
     return WorkshopModels.get_data(table_str, err_msg, display_flag, *args,
                                    **kwargs)
Ejemplo n.º 7
0
 def delete_prodqrcode(self, *args, **kwargs):
     return WorkshopModels.delete_prodqrcode(*args, **kwargs)
Ejemplo n.º 8
0
 def update_prodqrcode(self, key_dict=None, *args, **kwargs):
     return WorkshopModels.update_prodqrcode(key_dict, *args, **kwargs)
Ejemplo n.º 9
0
 def get_qrcoderep(self, display_flag=False, *args, **kwargs):
     return WorkshopModels.get_qrcoderep(display_flag, *args, **kwargs)
Ejemplo n.º 10
0
 def get_plids(self, display_flag=False, *args, **kwargs):
     return WorkshopModels.get_plids(False, *args, **kwargs)
Ejemplo n.º 11
0
class ProducingModule(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self, autoid, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.product = ProductController()
        self.autoid = autoid
        # 当前的文档内容
        self.current_docid = 0
        self.current_content = object
        self.wsmodels = WorkshopModels()
        self.detail = self.product.get_producingplan(autoid=autoid)
        if len(self.detail) != 1:
            raise ValueError
        self.linepost = self.wsmodels.get_linepost(autoid)
        linepost_list = []
        if len(self.linepost):
            for item in self.linepost:
                linepost_list.append(item.autoid)
        self.linepostdocuments = self.wsmodels.get_linepostdocuments(
            linepost_list)
        #if len(self.linepostdocuments):
        # 初始化标题和基本信息
        self.setup_title(self.detail[0])
        # 初始化文档目录
        self.setup_filetree(list(self.linepost), list(self.linepostdocuments))

    # 初始化标题和基本信息
    def setup_title(self, detail_list):
        self.label_prodname.setText(detail_list.prodid + ' ' +
                                    detail_list.prodname)
        self.label_batchno.setText(detail_list.batchno)
        self.label_package.setText(detail_list.package)
        self.label_medkind.setText(detail_list.medkind)
        self.label_spec.setText(detail_list.spec)
        self.label_planamount.setText(
            str(detail_list.planamount) + detail_list.spunit)
        self.label_basicamount.setText(
            str(detail_list.planamount * detail_list.basicamount) +
            detail_list.basicunit)

    # 初始化文档目录
    # post_list:岗位列表
    # document_list:文档列表
    # 数节点分3行,第一行为岗位/文档的id,第2行为岗位:0,
    # 文档:负数->内建文档,整数->自定义文档
    def setup_filetree(self, post_list, document_list):
        # 把岗位列表和文档列表合并为一个新的字典
        post_to_doucument = dict()
        for item in post_list:
            post_to_doucument[item] = []
            for it in document_list[:]:
                if item.autoid == it.lpid:
                    post_to_doucument[item].append(it)
                    document_list.remove(it)

        treeitem_root = QtWidgets.QTreeWidgetItem(self.treewidget_filetree)
        treeitem_root.setText(0, "批生产记录封面")
        treeitem_root.setText(1, '0')

        for item in post_to_doucument:
            qtreeitem = QtWidgets.QTreeWidgetItem(treeitem_root)

            qtreeitem.setText(0, item.postname)
            qtreeitem.setText(1, '1')
            qtreeitem.setText(2, str(item.autoid))
            qtreeitem.setText(3, str(item.seqid))
            qtreeitem.setText(4, str(item.expireddays))
            for it in post_to_doucument[item]:
                qtreechilditem = QtWidgets.QTreeWidgetItem(qtreeitem)
                #0:文档名称,1: 类型, 2:autoid, 3: docid, 4: aid
                if it.docid < 0:
                    # 内建文档
                    qtreechilditem.setText(0, GENERAL_DOC[it.docid])
                    qtreechilditem.setText(1, '2')
                    qtreechilditem.setText(2, str(it.autoid))
                    qtreechilditem.setText(3, str(it.docid))
                    qtreechilditem.setText(4, str(it.aid))
                    if it.docid in (-15, -16, -17, -18):
                        qtreechilditem_lr = QtWidgets.QTreeWidgetItem(
                            qtreeitem)
                        qtreechilditem_lr.setText(1, '2')
                        qtreechilditem_lr.setText(2, "-1")
                        qtreechilditem_lr.setText(3, str(it.docid))
                        qtreechilditem_lr.setText(4, str(it.aid))
                        if it.docid == -15:
                            # 半成品请验单
                            qtreechilditem_lr.setText(0, "半成品检验报告")
                        elif it.docid == -16:
                            # 成品请验单
                            qtreechilditem_lr.setText(0, "成品检验报告")
                        elif it.docid == -17:
                            # 中间产品请验单
                            qtreechilditem_lr.setText(0, "中间产品检验报告")
                        elif it.docid == -18:
                            # 验证请验单
                            qtreechilditem_lr.setText(0, "验证检验报告")
                else:
                    qtreechilditem.setText(0, it.formatname)
                    qtreechilditem.setText(1, '3')
                    qtreechilditem.setText(2, str(it.autoid))
                    qtreechilditem.setText(3, str(it.docid))
                    qtreechilditem.setText(4, '0')
        # self.treewidget_filetree.hideColumn(1)
        # self.treewidget_filetree.hideColumn(2)
        # self.treewidget_filetree.hideColumn(3)
        # self.treewidget_filetree.hideColumn(4)
        self.treewidget_filetree.expandAll()

    # 打开一个新文档
    @QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem, int)
    def on_treewidget_filetree_itemClicked(self, qitem, p_int):
        try:
            # 判断之前是否有打开过文档且没有保存
            if self.current_content.flat:
                dialog = MessageBox(self,
                                    title="提醒",
                                    text="文档尚未保存",
                                    informative="是否要保存文档",
                                    yes_text="保存",
                                    no_text="放弃保存")
                result = dialog.exec()
                if result == QtWidgets.QMessageBox.Yes:
                    # 调用保存的槽函数
                    self.on_pushButton_accept_clicked()

        except (AttributeError, TypeError):
            pass
        finally:
            if not self.gridLayout_4.isEmpty():
                self.gridLayout_4.removeWidget(self.current_content)
                self.current_content.close()

        self.label_filename.setText(qitem.text(0))
        self.current_docid = qitem.text(3)

        # 点击的是内建文档
        if qitem.text(1) == '2':
            doctype = int(qitem.text(3))
            # 生产指令
            if doctype == -1:
                self.current_content = PorductionInstructionModule(
                    self.autoid, self)
            # 领料单
            if doctype in (-2, -3, -4):
                self.current_content = StuffdrawpaperModule(
                    qitem.text(4), self)
            # 退料单
            elif doctype in (-5, -6, -7):
                self.current_content = StuffReturnPaperModule(
                    qitem.text(4), self)
            # 批包装指令
            elif doctype == -8:
                self.current_content = PackageInstructionModule(
                    self.autoid, self)
            # 批剩余(残次)标签、包装材料销毁记录
            elif doctype == -9:
                pass
            # 称量配料记录
            elif doctype == -10:
                pass
            # 半成品登记/发放记录
            elif doctype in (-11, -12):
                self.current_content = MidproddrawnoteModule(
                    self.autoid,
                    abs(doctype) - 11)
            # 前处理入库单
            elif doctype == -14:
                self.current_content = PreProdPutInModule(autoid=self.autoid,
                                                          parent=self)
            # 成品寄库单
            elif doctype == -13:
                self.current_content = ProductputinModule(
                    int(qitem.text(4)), self)
            # 请验单
            if doctype in (-15, -16, -17, -18):
                docid = qitem.text(2)
                if docid == "-1":
                    self.current_content = CheckreportModule(autoid=int(
                        qitem.text(4)),
                                                             is_view=True,
                                                             parent=self)
                else:
                    self.current_content = ApplycheckModule(autoid=int(
                        qitem.text(4)),
                                                            parent=self)

            # 清场合格证(副本)
            elif doctype == -19:
                self.current_content = CleanconfirmityCopyModule(
                    int(qitem.text(4)), self)
            # 清场合格证(正本)
            elif doctype == -20:
                self.current_content = CleanconfirmityOriginalModule(
                    qitem.text(4), int(qitem.parent().text(3)), self)
            # 库存零头领取单
            elif doctype == -21:
                pass
            # 尾料销毁记录
            elif doctype == -22:
                pass
            # 产品二维码
            elif doctype == -23:
                self.current_content = QrcodelistModule(self.autoid, self)
            # 小、中包装二维码关联
            elif doctype == -24:
                pass
            # 大、中包装二维码关联
            elif doctype == -25:
                pass
            # 巨、大包装二维码关联
            elif doctype == -26:
                pass
            # 零头登记记录
            elif doctype == -27:
                self.current_content = OddmentregisternoteModule(
                    self.autoid, self)
            # 零头发放记录
            elif doctype == -28:
                self.current_content = OddmentdrawnoteModule(self.autoid, self)
            # 退货产品领料单
            elif doctype == -29:
                pass
            self.gridLayout_4.addWidget(self.current_content)
        # 点击的是自定义文档
        elif qitem.text(1) == '3':
            # 自定义文档在Forms表里的id
            formatid = qitem.text(3)
            document = self.wsmodels.get_form(formatid)
            if document is not None:
                content = document.format
                self.current_content = XMLReadWrite(self)
                self.current_content.openxml(content)
                self.gridLayout_4.addWidget(self.current_content)
                self.current_content.__setattr__('autoid', self.autoid)
        # 点击的是岗位名
        elif qitem.text(1) == '1':
            self.current_content = PostdetailModule(qitem.text(2),
                                                    self.detail[0].lineid,
                                                    qitem.text(3),
                                                    qitem.text(0), self)
            self.gridLayout_4.addWidget(self.current_content)
        # 点击的是封面
        elif qitem.text(1) == '0':
            self.current_content = HomePageModule(self.autoid, self)
            self.gridLayout_4.addWidget(self.current_content)

    @QtCore.pyqtSlot()
    def on_pushButton_accept_clicked(self):
        if int(self.current_docid) > 0:
            res = self.wsmodels.update_form(self.current_docid,
                                            self.current_content.get_content())
            if res:
                self.current_content.flat = 0
        else:
            res = self.current_content.save()

    @QtCore.pyqtSlot()
    def on_pushButton_flush_clicked(self):
        pass

    @QtCore.pyqtSlot()
    def on_pushButton_reset_clicked(self):
        pass