Пример #1
0
    def __init__(self, autoid, lrid=0, parent=None):
        super(EditStuffCheckInModule, self).__init__(parent)
        self.ori_detail = dict()
        self.detail = {
            'content': decimal.Decimal('-1'),
            'cunit': '%',
            'water': decimal.Decimal('-1'),
            'rdensity': decimal.Decimal('-1'),
            'impurity': decimal.Decimal('-1'),
            'position': ''
        }
        self.new_detail = dict()
        self.LC = LabrecordsController()
        self.WC = WarehouseController()
        self.SFC = StuffController()
        self.setupUi(self)

        self.autoid = autoid
        self.lrid = lrid

        self.get_detail()
        if lrid != 0:
            self.set_putin_parameter()
        self.set_validator()
        self.get_location_list()
        if len(self.ori_detail):
            self.set_content_unit()
Пример #2
0
    def __init__(self,
                 spid=None,
                 paperno=None,
                 papertype=0,
                 autoid=None,
                 parent=None):
        super(EditRegStuffModule, self).__init__(parent)
        self.setupUi(self)
        if '28' not in user.powers:
            self.close()
        if user.powers['28'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['28'])
        if self.power[1] == '0':
            self.pushButton_accept.setVisible(False)
            self.pushButton_cancel.setVisible(False)
        self.ori_detail = dict()
        self.new_detail = dict()
        self.SC = SupplyerController()
        self.WC = WarehouseController()
        self.SFC = StuffController()

        self.spid = spid
        self.autoid = autoid
        self.paperno = paperno
        self.papertype = papertype

        self.get_detail()
        self.set_amount_validator()
        self.get_producer_list()
        self.get_location_list()
Пример #3
0
 def __init__(self, ppid, sdpid, kind, parent=None):
     super(DrawstuffModule, self).__init__(parent)
     self.ppid = ppid
     self.sdpid = sdpid
     self.kind = kind
     self.setupUi(self)
     if '37' not in user.powers:
         self.close()
     if user.powers['37'] == 0:
         self.close()
     self.power = '{:03b}'.format(user.powers['37'])
     if self.power[1] == '0':
         self.pushButton_accept.setVisible(False)
         self.pushButton_cancel.setVisible(False)
     self.WC = WarehouseController()
     self.SC = StuffController()
     self.PC = ProductController()
     self.PLC = ProductLineConroller()
     self.detail = dict()
     self.stuff_list = []
     # 当前正在修改的树节点
     self.edittreeitem = None
     self.stuff_repository = []
     # 公式错误信息
     self.errormsg = []
     self.treeWidget_stuffrepository.setDragDropMode(1)
     self.treeWidget_drawstuff.setDragDropMode(2)
Пример #4
0
 def __init__(self):
     self.SC = StuffController()
     self.SLC = SaleController()
     self.SP = SupplyerController()
     self.WM = WarehouseModel()
     self.WC = WorkshopController()
     self.PC = ProductController()
Пример #5
0
    def __init__(self, spid, parent=None):
        super(SelectstuffModule, self).__init__(parent)
        self.setupUi(self)
        self.spid = spid
        self.SC = SupplyerController()
        self.SFC = StuffController()

        self.get_stufflist()
Пример #6
0
    def __init__(self, autoid, is_view=False, parent=None):
        super(CheckreportModule, self).__init__(parent)
        self.setupUi(self)
        if is_view:
            self.power = '000'
        else:
            if '8' not in user.powers:
                self.close()
            if user.powers['8'] == 0:
                self.close()
            self.power = '{:03b}'.format(user.powers['8'])

        if self.power[1] == '0':
            self.pushButton_save.setVisible(False)
            self.pushButton_accept.setVisible(False)
            self.pushButton_add_oripaper.setVisible(False)
        if self.power[2] == '0':
            self.pushButton_print.setVisible(False)
        self.is_view = is_view
        self.autoid = autoid
        self.ori_detail = dict()
        self.new_detail = dict()
        self.ori_checkitem = []
        self.new_checkitem = []
        self.images_list = []
        self.current_img = object
        self.current_page = object
        self.LC = LabrecordsController()
        self.SC = StuffController()
        self.PC = ProductController()
        # 自动缩放
        self.label_image.setScaledContents(True)

        # 获取当前报告的信息
        has_find_report = self.get_report_detail(self.autoid)
        # 获取检验项目
        self.get_checkitem()
        if has_find_report:
            # 获取检验依据的下拉项目
            self.get_combobox_items(self.comboBox_checkgist,
                                    'checkgist',
                                    chkid=self.ori_detail['chkid'])
            # 获取结论的下拉项目
            self.get_combobox_items(self.comboBox_result,
                                    'result',
                                    chkid=self.ori_detail['chkid'])

        # 获取图片
        self.get_images(autoid)
        # 获取原始检验记录
        self.get_oricheckpaper(autoid)
        # 检验项目的右键菜单功能
        if len(self.ori_detail):
            if self.ori_detail['paperno'] == '':
                self.get_paperno()
            self.new_paperstatus = self.ori_detail['paperstatus']
            # 根据签名情况确定是否允许修改签名
            self.set_paperstatus()
Пример #7
0
 def __init__(self, autoid, parent=None):
     super(EditStuffReturnDetailModule, self).__init__(parent)
     self.autoid = autoid
     self.setupUi(self)
     self.SC = StuffController()
     self.ori_detail = dict()
     self.new_detail = dict()
     self.set_backamount_validator()
     self.set_pracamount_validator()
     self.set_restamount_validator()
     self.get_detail()
Пример #8
0
 def __init__(self, autoid, parent=None):
     # autoid:领料单在stuffdrawpaper中的autoid
     # kind: 领料单的类型与原料对应
     super(StuffdrawpaperModule, self).__init__(parent)
     self.autoid = autoid
     self.ori_detail = object
     self.new_detail = {}
     self.SC = StuffController()
     self.setupUi(self)
     self.pushButton_apply.setVisible(False)
     self.get_stuffdrawpaper()
 def __init__(self, autoid, parent=None):
     super(PackageInstructionModule, self).__init__(parent)
     self.autoid = autoid
     self.setupUi(self)
     self.SC = StuffController()
     self.PC = ProductController()
     self.ori_detail = dict()
     self.new_detail = dict()
     # 获取物料信息
     self.get_stufflist()
     # 获取批包装指令信息
     self.get_detail()
Пример #10
0
    def __init__(self, autoid, parent=None):
        # autoid:领料单在stuffdrawpaper中的autoid
        super(StuffReturnPaperModule, self).__init__(parent)
        self.autoid = autoid
        self.ori_detail = dict()
        self.new_detail = dict()
        self.SC = StuffController()
        self.setupUi(self)
        self.pushButton_apply.setVisible(False)
        self.pushButton_cancel.setVisible(False)

        self.get_stuffdrawpaper()
        self.get_stufflist()
Пример #11
0
 def __init__(self, parent=None):
     super(StuffDictionaryModule, self).__init__(parent)
     self.setupUi(self)
     # 数据库操作类
     self.SC = StuffController()
     if '1' not in  user.powers:
         self.close()
     if user.powers['1'] == 0:
         self.close()
     self.power = '{:03b}'.format(user.powers['1'])
     self.stufftype = 0
     # 隐藏第一列的id
     self.treeWidget_stufflist.hideColumn(0)
     # 显示物料列表
     self.get_stufflist()
Пример #12
0
    def __init__(self, parent=None):
        super(StuffRepositoryModule, self).__init__(parent)
        self.setupUi(self)

        if '41' not in user.powers:
            self.close()
        if user.powers['41'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['41'])

        self.WC = WarehouseController()
        self.CI = CheckItem()
        self.LC = LabrecordsController()
        self.SFC = StuffController()
        self.current_button = self.radioButton_batchno
        self.get_stuff_list()
Пример #13
0
    def __init__(self, spid, ppid=None, autoid=None, parent=None):
        super(EditpurstuffModule, self).__init__(parent)
        self.ori_detail = dict()
        self.new_detail = dict()
        self.SC = SupplyerController()
        self.SFC = StuffController()
        self.setupUi(self)
        # row = ('autoid', 'stuffid', 'stuffname', 'spec', 'package')
        # key = ('stuffid', 'stuffname', 'stuffkind', 'inputcode')
        # row_name = ('id', '物料编号', '物料名称', '含量规格', '包装规格')
        # self.lineEdit_supplyer.setup('Supplyer', row, key, row_name, 539, 240)

        self.autoid = autoid
        self.spid = spid
        self.ppid = ppid

        self.get_detail()
        self.set_amount_validator()
    def __init__(self, parent=None):
        super(PurchaseRegistrationModule, self).__init__(parent)
        self.setupUi(self)
        if '28' not in user.powers:
            self.close()
        if user.powers['28'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['28'])

        self.WC = WarehouseController()
        self.LC = LabrecordsController()
        self.SC = SupplyerController()
        self.SFC = StuffController()
        self.CI = CheckItem()
        self.groupBox.setVisible(False)
        self.spid = 0
        self.paperno = ''
        self.supid = ''
        self.supname = ''

        self.get_order_list()
Пример #15
0
    def __init__(self, autoid: int = 0, ppid: int = 0, parent=None):
        super(PreProdPutInModule, self).__init__(parent)
        self.setupUi(self)
        self.ppid = ppid
        self.autoid = autoid
        self.content = decimal.Decimal('-1')
        self.water = decimal.Decimal('-1')
        self.rdensity = decimal.Decimal('-1')
        self.impurity = decimal.Decimal('-1')
        self.lrid = 0
        self.checkdate = user.now_date
        # self.units = set()
        self.unit = ''
        self.cunit = '%'
        self.expireddays = 730
        self.countercheckdays = 365
        self.WC = WorkshopController()
        self.LC = LabrecordsController()
        self.PC = ProductController()
        self.SC = StuffController()
        self.product_detail = dict()
        self.ori_detail = dict()
        self.new_detail = dict()

        # 把autoid和ppid补全
        self.get_autoid_or_ppid()
        # 获取入库位置的下拉选项
        self.get_postiton()

        # 整箱数量的校验器
        self.set_valitor(self.lineEdit_amount, 0)
        # 获取产品信息
        self.get_productdetail()
        # 设置含量单位、复检日期、有效期等参数
        self.basicdetail()

        # 获取报告书的状态和编号
        self.get_labdetail()
        # 获取入库信息
        self.get_putinnote()
Пример #16
0
class SelectstuffModule(QDialog, Ui_Dialog):
    selected = pyqtSignal(int)

    def __init__(self, spid, parent=None):
        super(SelectstuffModule, self).__init__(parent)
        self.setupUi(self)
        self.spid = spid
        self.SC = SupplyerController()
        self.SFC = StuffController()

        self.get_stufflist()

    def get_stufflist(self):
        self.treeWidget_stufflist.clear()
        self.treeWidget_stufflist.hideColumn(0)
        key_dict = {'spid': self.spid}
        id_list = self.SC.get_stuffsupplyer(True, *VALUES_TUPLES_SD,
                                            **key_dict)
        if not len(id_list):
            return
        key_dict_stuff = {'autoid__in': id_list}
        res = self.SFC.get_stuffdict(False, *VALUES_TUPLES_STUFF,
                                     **key_dict_stuff)

        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, item['stuffid'])
            qtreeitem.setText(2, item['stuffname'])
            qtreeitem.setText(3, item['spec'])
            qtreeitem.setText(4, item['package'])

        for i in range(1, 5):
            self.treeWidget_stufflist.resizeColumnToContents(i)

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_stufflist_itemDoubleClicked(self, qtreeitem, p_int):
        self.selected.emit(int(qtreeitem.text(0)))
        self.accept()

    @pyqtSlot()
    def on_pushButton_accept_clicked(self):
        current_item = self.treeWidget_stufflist.currentItem()
        if current_item is not None:
            self.selected.emit(int(current_item.text(0)))
            self.accept()

    @pyqtSlot()
    def on_pushButton_cancel_clicked(self):
        self.close()
    def __init__(self, autoid, parent=None):
        super(ModifyStuffParmeter, self).__init__(parent)
        self.ori_detail = dict()
        self.detail = {}
        self.new_detail = dict()
        self.WC = WarehouseController()
        self.SFC = StuffController()
        self.setupUi(self)

        self.autoid = autoid

        self.get_detail()
        self.set_validator()
        self.get_location_list()
Пример #18
0
    def __init__(self, parent=None):
        super(PurStuffCheckInModule, self).__init__(parent)
        self.setupUi(self)
        if '29' not in user.powers:
            self.close()
        if user.powers['29'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['29'])

        self.WC = WarehouseController()
        self.LC = LabrecordsController()
        self.SC = SupplyerController()
        self.SFC = StuffController()

        self.get_stuff_list()
Пример #19
0
    def __init__(self, autoid=None, parent=None):
        super(EditStuffDetailModule, self).__init__(parent)
        self.setupUi(self)
        self.autoid = autoid

        self.SC = StuffController()
        self.LC = LabrecordsController()
        self.PC = ProductController()
        self.SPC = SupplyerController()
        self.ori_detail = {}
        self.new_detail = {}
        self.get_detail()
        if len(self.ori_detail):
            stufftype = self.ori_detail['stufftype']
            if stufftype == 1:
                self.tab.removeTab(4)
                self.tab.removeTab(1)
            else:
                self.tab.removeTab(3)
                self.tab.removeTab(2)
        self.get_formula()
        self.get_checkitem(0, self.treeWidget_checkitem)
        self.get_checkitem(2, self.treeWidget_precheckitem)
        self.get_stuffsupplyer()
Пример #20
0
 def get_sys_vars(self, kind=0):
     if self.autoid != 0:
         try:
             if kind == 0:
                 pm = ProductController()
                 vlist = ('prodid', 'prodname', 'commonname', 'batchno',
                          'spec', 'package', 'medkind', 'planamount',
                          'mpunit', 'plantime', 'realamount', 'makedate',
                          'linename', 'workshopid', 'workshopname')
                 self.proddetail = pm.get_producingplan(
                     *vlist, autoid=self.autoid)[0]
             elif kind == 1:
                 sm = StuffController()
                 self.stuffdetail = sm.get_prodstuff(ppid=self.autoid)
                 for item in self.stuffdetail:
                     stufftype = item.stufftype
                     if stufftype == 0:
                         self.stuffdetailZC.append(item)
                         self.stuffdetailZF.append(item)
                     elif stufftype == 1:
                         self.stuffdetailFC.append(item)
                         self.stuffdetailZF.append(item)
                     elif stufftype == 2:
                         self.stuffdetailNB.append(item)
                         self.stuffdetailBC.append(item)
                     elif stufftype == 3:
                         self.stuffdetailWB.append(item)
                         self.stuffdetailBC.append(item)
                     elif stufftype == 4:
                         self.stuffdetailQC.append(item)
             elif kind == 2:
                 sm = StuffController()
                 self.mstuffdetail = sm.get_Mprodstuff(self.autoid)
                 for item in self.mstuffdetail:
                     stufftype = item.stufftype
                     if stufftype == 0:
                         self.stuffdetailMZC.append(item)
                         self.stuffdetailMZF.append(item)
                     elif stufftype == 1:
                         self.stuffdetailMFC.append(item)
                         self.stuffdetailMZF.append(item)
                     elif stufftype == 2:
                         self.stuffdetailMNB.append(item)
                         self.stuffdetailMBC.append(item)
                     elif stufftype == 3:
                         self.stuffdetailMWB.append(item)
                         self.stuffdetailMBC.append(item)
                     elif stufftype == 4:
                         self.stuffdetailMQC.append(item)
             elif kind == 3:
                 lm = LabrecordsController()
                 self.labdetail = lm.get_labrecord(self.autoid)[0]
         except:
             # traceback.print_exc()
             SaveExcept("获取系统变量出错", self.get_content(), kind)
Пример #21
0
 def get_sys_vars(self, kind=0):
     if self.autoid != 0:
         try:
             if kind == 0:
                 pm = ProductController()
                 self.proddetail = pm.get_producingplan(
                     autoid=self.autoid)[0]
             elif kind == 1:
                 sm = StuffController()
                 self.stuffdetail = sm.get_prodstuff(self.autoid)
                 for item in self.stuffdetail:
                     stufftype = item.stufftype
                     if stufftype == 0:
                         self.stuffdetailZC.append(item)
                         self.stuffdetailZF.append(item)
                     elif stufftype == 1:
                         self.stuffdetailFC.append(item)
                         self.stuffdetailZF.append(item)
                     elif stufftype == 2:
                         self.stuffdetailNB.append(item)
                         self.stuffdetailBC.append(item)
                     elif stufftype == 3:
                         self.stuffdetailWB.append(item)
                         self.stuffdetailBC.append(item)
                     elif stufftype == 4:
                         self.stuffdetailQC.append(item)
             elif kind == 2:
                 sm = StuffController()
                 self.mstuffdetail = sm.get_Mprodstuff(self.autoid)
                 for item in self.mstuffdetail:
                     stufftype = item.stufftype
                     if stufftype == 0:
                         self.stuffdetailMZC.append(item)
                         self.stuffdetailMZF.append(item)
                     elif stufftype == 1:
                         self.stuffdetailMFC.append(item)
                         self.stuffdetailMZF.append(item)
                     elif stufftype == 2:
                         self.stuffdetailMNB.append(item)
                         self.stuffdetailMBC.append(item)
                     elif stufftype == 3:
                         self.stuffdetailMWB.append(item)
                         self.stuffdetailMBC.append(item)
                     elif stufftype == 4:
                         self.stuffdetailMQC.append(item)
             elif kind == 3:
                 lm = LabrecordsController()
                 self.labdetail = lm.get_labrecord(1, autoid=self.autoid)[0]
         except:
             # traceback.print_exc()
             pass
class PackageInstructionModule(QWidget, Ui_Form):

    def __init__(self, autoid, parent=None):
        super(PackageInstructionModule, self).__init__(parent)
        self.autoid = autoid
        self.setupUi(self)
        self.SC = StuffController()
        self.PC = ProductController()
        self.ori_detail = dict()
        self.new_detail = dict()
        # 获取物料信息
        self.get_stufflist()
        # 获取批包装指令信息
        self.get_detail()

    # 获取已经领取了的物料
    def get_stufflist(self):
        values_tupe = (
            "autoid", "lrid", "stuffid", "stuffname", "batchno", "spec",
            "package", "presamount", "content", "cunit", "water",
            "impurity", "rdensity", "presunit"
        )
        key_dict = {
            'ppid': self.autoid,
            'stufftype__in': (3, 4)
        }
        res = self.SC.get_prodstuff(False, *values_tupe, **key_dict)
        if len(res):
            for item in res:
                qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
                qtreeitem.setText(0, str(item['autoid']))  # autoid
                qtreeitem.setText(1, str(item['lrid']))  # lrid
                qtreeitem.setText(2, item['stuffid'] + ' ' + item[
                    'stuffname'])  # 物料
                qtreeitem.setText(3, item['batchno'])  # 进厂批号
                qtreeitem.setText(4, item['spec'])  # 含量规格
                qtreeitem.setText(5, item['package'])  # 包装规格
                qtreeitem.setText(6, str(item['presamount']) + item[
                    'presunit'])  # 计划量
                qtreeitem.setText(7, str(item['content']) + item[
                    'cunit'])  # 含量/效价
                qtreeitem.setText(8, str(item['water']) + '%')  # 水分
                qtreeitem.setText(9, str(item['impurity']))  # 相对密度
                qtreeitem.setText(10, str(item['rdensity']))  # 杂质

            self.treeWidget_stufflist.hideColumn(0)
            self.treeWidget_stufflist.hideColumn(1)
            for i in range(2, 11):
                self.treeWidget_stufflist.resizeColumnToContents(i)



    def get_detail(self):
        values_list = (
            'bpconstitutorid', 'bpconstitutorname', 'bpwarrantorid', 'bpwarrantorname',
            'bpexecutorid', 'bpexecutorname', 'bpconsdate', 'bpwarrantdate',
            'bpexecutedate', 'bpdate'
        )
        key_dict = {
            'autoid': self.autoid
        }
        res = self.PC.get_producingplan(False, *values_list, **key_dict)
        if len(res) == 0:
            return

        self.ori_detail = res[0]
        self.pushButton_bpconstitutor.setText(
            self.ori_detail['bpconstitutorid'] + ' ' +
            self.ori_detail['bpconstitutorname']
        )
        self.pushButton_bpwarrantor.setText(
            self.ori_detail['bpwarrantorid'] + ' ' +
            self.ori_detail['bpwarrantorname']
        )
        self.pushButton_bpexecutor.setText(
            self.ori_detail['bpexecutorid'] + ' ' +
            self.ori_detail['bpexecutorname']
        )
        if type(self.ori_detail['bpconsdate']) is datetime.date:
            self.dateEdit_bpconsdate.setDate(self.ori_detail['bpconsdate'])
        if type(self.ori_detail['bpwarrantdate']) is datetime.date:
            self.dateEdit_bpwarrantdate.setDate(self.ori_detail['bpwarrantdate'])
        if type(self.ori_detail['bpexecutedate']) is datetime.date:
            self.dateEdit_bpexecutedate.setDate(self.ori_detail['bpexecutedate'])
        else:
            self.dateEdit_bpexecutedate.setDate(user.now_date)
        if type(self.ori_detail['bpdate']) is datetime.date:
            self.dateEdit_bpdate.setDate(self.ori_detail['bpdate'])
        else:
            self.dateEdit_bpdate.setDate(user.now_date)

    @pyqtSlot(bool, str)
    def on_pushButton_bpexecutor_signChanged(self, p_bool, p_str):
        id, name = p_str.split(' ') if p_bool else ('', '')
        try:
            if id != self.ori_detail['bpexecutorid'] or name != self.ori_detail[
                'bpexecutorname']:
                self.new_detail['bpexecutorid'] = id
                self.new_detail['bpexecutorname'] = name
            else:
                try:
                    del self.new_detail['bpexecutorid']
                    del self.new_detail['bpexecutorname']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['bpexecutorid'] = id
            self.new_detail['bpexecutorname'] = name

    @pyqtSlot(QDate)
    def on_dateEdit_bpexecutedate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail['bpexecutedate']) is str:
                self.new_detail['bpexecutedate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail['bpexecutedate']):
                self.new_detail['bpexecutedate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail['bpexecutedate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['bpexecutedate'] = q_date.toPyDate()

    @pyqtSlot(QDate)
    def on_dateEdit_bpdate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail['bpdate']) is str:
                self.new_detail['bpdate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail['bpdate']):
                self.new_detail['bpdate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail['bpdate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['bpdate'] = q_date.toPyDate()

    @pyqtSlot()
    def on_pushButton_accept_clicked(self):
        if len(self.new_detail):
            res = self.PC.update_producingplan(self.autoid, **self.new_detail)
Пример #23
0
class StuffRepositoryModule(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(StuffRepositoryModule, self).__init__(parent)
        self.setupUi(self)

        if '41' not in user.powers:
            self.close()
        if user.powers['41'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['41'])

        self.WC = WarehouseController()
        self.CI = CheckItem()
        self.LC = LabrecordsController()
        self.SFC = StuffController()
        self.current_button = self.radioButton_batchno
        self.get_stuff_list()

    def get_stuff_list(self):
        if self.current_button == self.radioButton_batchno:
            values_tuple = VALUES_TUPLE_BATCHNO
            self.treeWidget_stuffbatchnolist.setVisible(True)
            self.treeWidget_stuffkindlist.setVisible(False)
            current_tree = self.treeWidget_stuffbatchnolist
            current_tree.hideColumn(0)
            current_tree.hideColumn(1)
        elif self.current_button == self.radioButton_kind:
            values_tuple = VALUES_TUPLE_KIND
            self.treeWidget_stuffbatchnolist.setVisible(False)
            self.treeWidget_stuffkindlist.setVisible(True)
            current_tree = self.treeWidget_stuffkindlist
        else:
            return

        current_tree.clear()
        index = self.tabWidget.currentIndex()
        key_dict = {'amount__gt': 0}
        if index != 0:
            key_dict['stufftype'] = index - 1
        stuff_list = self.WC.get_stuffrepository(False, *values_tuple,
                                                 **key_dict)
        if not len(stuff_list):
            return
        if current_tree == self.treeWidget_stuffbatchnolist:
            self.set_batchno_tree(current_tree, stuff_list)
            for i in range(2, 25):
                current_tree.resizeColumnToContents(i)
        elif current_tree == self.treeWidget_stuffkindlist:
            self.set_kind_tree(current_tree, stuff_list)
            for i in range(0, 3):
                current_tree.resizeColumnToContents(i)
        else:
            return

    def set_batchno_tree(self, current_tree, stuff_list):
        for item in stuff_list:
            qtreeitem = QTreeWidgetItem(current_tree)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, str(item['lrid']))
            qtreeitem.setText(2, STATUS[item['status']])
            qtreeitem.setText(3, item['stuffid'] + ' ' + item['stuffname'])
            qtreeitem.setText(4, item['stuffkind'])
            qtreeitem.setText(5, STUFF_KIND[item['stufftype']])
            qtreeitem.setText(6, item['batchno'])
            qtreeitem.setText(7, item['mbatchno'])
            qtreeitem.setText(8, item['spec'])
            qtreeitem.setText(9, item['package'])
            qtreeitem.setText(10, str(item['piamount']))
            qtreeitem.setText(11, str(item['amount']))
            qtreeitem.setText(12, item['basicunit'])
            qtreeitem.setText(13, item['position'])
            qtreeitem.setText(14, str(item['makedate']))
            qtreeitem.setText(15, str(item['putindate']))
            qtreeitem.setText(16, str(item['expireddate']))
            qtreeitem.setText(17, str(item['nextcheckdate']))
            qtreeitem.setText(18, item['supid'] + ' ' + item['supname'])
            qtreeitem.setText(19, item['producer'])
            qtreeitem.setText(20, str(item['content']) + item['cunit'])
            qtreeitem.setText(21, str(item['water']) + '%')
            qtreeitem.setText(22, str(item['rdensity']))
            qtreeitem.setText(23, str(item['impurity']) + '%')
            qtreeitem.setText(
                24, item['warehousemanid'] + item['warehousemanname'])

    def set_kind_tree(self, current_tree, stuff_list):
        kind_list = stuff_list.annotate(amount=Sum('amount'),
                                        piamount=Sum('piamount'))
        for item in kind_list:
            qtreeitem = QTreeWidgetItem(current_tree)
            qtreeitem.setText(0, item['stuffkind'])
            qtreeitem.setText(1, str(item['piamount']))
            qtreeitem.setText(2, str(item['amount']))
            qtreeitem.setText(3, item['basicunit'])

    @pyqtSlot(int)
    def on_tabWidget_currentChanged(self, p_int):
        curent_tab = getattr(self, 'tab_' + str(p_int))
        curent_tab.setLayout(self.gridLayout_2)
        self.get_stuff_list()

    pyqtSlot(bool)

    def on_radioButton_batchno_toggled(self, p_bool):
        if p_bool:
            self.current_button = self.radioButton_batchno
            self.get_stuff_list()

    pyqtSlot(bool)

    def on_radioButton_kind_toggled(self, p_bool):
        if p_bool:
            self.current_button = self.radioButton_kind
            self.get_stuff_list()

    @pyqtSlot(QPoint)
    def on_treeWidget_stuffbatchnolist_customContextMenuRequested(self, pos):
        if self.power[1] == '0':
            return

        id = 0
        lrid = 0
        stuffid = ''
        batchno = ''
        sender_widget = self.sender()
        current_item = sender_widget.currentItem()
        if current_item is None:
            return

        id = int(current_item.text(0))
        lrid = int(current_item.text(1))
        stuffid, stuffname = current_item.text(3).split(' ')
        batchno = current_item.text(6)

        menu = QMenu()
        button1 = menu.addAction("修改记录")
        button2 = menu.addAction("查看检验报告")
        button3 = menu.addAction("新建库存复检申请单")

        global_pos = sender_widget.mapToGlobal(pos)
        action = menu.exec(global_pos)

        if action == button1:
            detail = ModifyStuffParmeter(id, self)
            detail.accepted.connect(self.get_stuff_list)
            detail.show()

        elif action == button2:
            detail = FindCheckReportModule(stuffid, batchno, self)
            detail.show()

        elif action == button3:
            key_dict = {'stuffid': stuffid, 'stuffname': stuffname}
            checkunit = ''
            res = self.SFC.get_stuffdict(True, *VALUES_TUPLE_SD, **key_dict)
            if len(res):
                checkunit = res[0]
            kwargs = {
                'labtype':
                1,
                'chkid':
                stuffid,
                'chkname':
                stuffname,
                'batchno':
                current_item.text(6),
                'mbatchno':
                current_item.text(7),
                'spec':
                current_item.text(8),
                'package':
                current_item.text(9),
                'producer':
                current_item.text(19),
                'supplyer':
                current_item.text(18) if current_item.text(18) in ('', ' ')
                else current_item.text(18).split(' ')[2],
                'ciid':
                int(current_item.text(0)),
                'createdate':
                user.now_date,
                'checkamount':
                decimal.Decimal(current_item.text(11)),
                'caunit':
                current_item.text(12),
                'sampleunit':
                checkunit,
                'samplesource':
                current_item.text(13)
            }
            labrecord = self.LC.update_labrecord(**kwargs)
            key_dict_checkitem = {'stuffid': stuffid, 'itemtype': 0}
            checkitems = self.CI.get_checkitems(False, *VALUES_TUPLE_CHECKITEM,
                                                **key_dict_checkitem)
            for item in checkitems:
                kwargs_checkitem = {
                    'lrid': labrecord.autoid,
                    'seqid': item['seqid'],
                    'itemname': item['itemname'],
                    'kind': item['kind'],
                    'referencevalue': item['referencevalue'],
                    'labvalue': item['referencevalue'],
                    'putintype': item['putintype'],
                    'startdate': user.now_date,
                    'enddate': user.now_date,
                    'checked': 2
                }
            self.LC.update_labitem(**kwargs_checkitem)
            detail = ApplycheckModule(autoid=labrecord.autoid, parent=self)
            detail.rejected.connect(
                lambda: self.delete_check_report(labrecord.autoid))
            detail.show()

    def delete_check_report(self, lrid):
        self.LC.delete_labrecord(lrid)
        self.LC.delete_labitem(lrid)

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_stuffbatchnolist_itemDoubleClicked(
            self, qtreeitem, p_int):
        if self.power[1] == '0':
            return

        id = int(qtreeitem.text(0))
        lrid = int(qtreeitem.text(1))
        detail = ModifyStuffParmeter(id, self)
        detail.accepted.connect(self.get_stuff_list)
        detail.show()
Пример #24
0
class EditRegStuffModule(QDialog, Ui_Dialog):
    def __init__(self,
                 spid=None,
                 paperno=None,
                 papertype=0,
                 autoid=None,
                 parent=None):
        super(EditRegStuffModule, self).__init__(parent)
        self.setupUi(self)
        if '28' not in user.powers:
            self.close()
        if user.powers['28'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['28'])
        if self.power[1] == '0':
            self.pushButton_accept.setVisible(False)
            self.pushButton_cancel.setVisible(False)
        self.ori_detail = dict()
        self.new_detail = dict()
        self.SC = SupplyerController()
        self.WC = WarehouseController()
        self.SFC = StuffController()

        self.spid = spid
        self.autoid = autoid
        self.paperno = paperno
        self.papertype = papertype

        self.get_detail()
        self.set_amount_validator()
        self.get_producer_list()
        self.get_location_list()

    def get_detail(self):
        if not self.autoid:
            self.toolButton_more.setEnabled(True)
            return
        self.toolButton_more.setEnabled(False)
        key_dict = {'autoid': self.autoid}
        res = self.WC.get_stuffcheckinlist(False, *VALUES_TUPLE_CHECK_IN_LIST,
                                           **key_dict)
        if len(res) != 1:
            return
        self.ori_detail = res[0]
        self.lineEdit_stuff.setText(self.ori_detail['stuffid'] + ' ' +
                                    self.ori_detail['stuffname'])
        self.label_spec.setText(self.ori_detail['spec'])
        self.label_package.setText(self.ori_detail['package'])
        self.lineEdit_amount.setText(str(self.ori_detail['amount']))
        self.label_unit.setText(self.ori_detail['unit'])
        self.lineEdit_batchno.setText(self.ori_detail['batchno'])
        self.lineEdit_mbatchno.setText(self.ori_detail['mbatchno'])
        self.dateEdit_makedate.setDate(self.ori_detail['makedate'])
        self.dateEdit_invaliddate.setDate(self.ori_detail['expireddate'])

    def set_amount_validator(self):
        doubleValitor = QDoubleValidator()
        doubleValitor.setBottom(0)
        doubleValitor.setDecimals(3)
        doubleValitor.setNotation(QDoubleValidator.StandardNotation)
        self.lineEdit_amount.setValidator(doubleValitor)

    def get_location_list(self):
        location_list = self.WC.get_stuffcheckinlist(
            True, *VALUES_TUPLE_LOCATION).distinct()
        if len(location_list):
            self.comboBox_location.addItems(location_list)
        if len(self.ori_detail):
            self.comboBox_location.setCurrentText(self.ori_detail['position'])
        else:
            self.comboBox_location.setCurrentText("")

    def get_producer_list(self, sdid=None):
        if not (self.autoid or sdid):
            return
        if sdid is None:
            stuffid = self.ori_detail['stuffid']
            key_dict_stuff = {'stuffid': stuffid}
            stufffid_list = self.SFC.get_stuffdict(True, *VALUES_TUPLE_SDID,
                                                   **key_dict_stuff)
            if len(stufffid_list):
                sdid = stufffid_list[0]

        if sdid and self.spid:
            key_dict_producer = {'sdid': sdid, 'spid': self.spid}
            producer_list = self.SC.get_stuffsupplyer(True,
                                                      *VALUES_TUPLE_PRODUCER,
                                                      **key_dict_producer)
            if len(producer_list):
                self.comboBox_producer.addItems(producer_list)
            if len(self.ori_detail):
                self.comboBox_producer.setCurrentText(
                    self.ori_detail['producer'])

    @pyqtSlot(str)
    def on_lineEdit_amount_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail['amount']:
                self.new_detail['amount'] = p_str
                self.new_detail['piamount'] = p_str
            else:
                try:
                    del self.new_detail['amount']
                    del self.new_detail['piamount']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['amount'] = p_str
            self.new_detail['piamount'] = p_str

    @pyqtSlot(str)
    def on_comboBox_producer_currentTextChanged(self, p_str):
        try:
            if p_str != self.ori_detail['producer']:
                self.new_detail['producer'] = p_str
            else:
                try:
                    del self.new_detail['producer']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['producer'] = p_str

    @pyqtSlot(str)
    def on_comboBox_location_currentTextChanged(self, p_str):
        try:
            if p_str != self.ori_detail['position']:
                self.new_detail['position'] = p_str
            else:
                try:
                    del self.new_detail['position']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['position'] = p_str

    @pyqtSlot(str)
    def on_lineEdit_batchno_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail['batchno']:
                self.new_detail['batchno'] = p_str
            else:
                try:
                    del self.new_detail['batchno']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['batchno'] = p_str

    @pyqtSlot(str)
    def on_lineEdit_mbatchno_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail['mbatchno']:
                self.new_detail['mbatchno'] = p_str
            else:
                try:
                    del self.new_detail['mbatchno']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['mbatchno'] = p_str

    @pyqtSlot(QDate)
    def on_dateEdit_makedate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail['makedate']) is str:
                self.new_detail['makedate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail['makedate']):
                self.new_detail['makedate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail['makedate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['makedate'] = q_date.toPyDate()

    @pyqtSlot(QDate)
    def on_dateEdit_invaliddate_dateChanged(self, q_date):
        try:
            if type(self.ori_detail['expireddate']) is str:
                self.new_detail['expireddate'] = q_date.toPyDate()
                return
            if q_date != QDate(self.ori_detail['expireddate']):
                self.new_detail['expireddate'] = q_date.toPyDate()
            else:
                try:
                    del self.new_detail['expireddate']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['expireddate'] = q_date.toPyDate()

    @pyqtSlot()
    def on_toolButton_more_clicked(self):
        detail = SelectstuffModule(self.spid, self)
        detail.selected.connect(self.set_stuff)
        detail.show()

    def set_stuff(self, p_int):

        key_dict = {'autoid': p_int}
        res = self.SFC.get_stuffdict(False, *VALUES_TUPLE_STUFF, **key_dict)

        if not len(res):
            return
        stuff = res[0]
        self.lineEdit_stuff.setText(stuff['stuffid'] + stuff['stuffname'])
        self.label_spec.setText(stuff['spec'])
        self.label_package.setText(stuff['package'])
        self.label_unit.setText(stuff['spunit'])
        self.dateEdit_makedate.setDate(user.now_date)
        self.dateEdit_invaliddate.setDate(user.now_date + datetime.timedelta(
            days=stuff['expireddays']))

        self.new_detail['stuffid'] = stuff['stuffid']
        self.new_detail['stuffname'] = stuff['stuffname']
        self.new_detail['spec'] = stuff['spec']
        self.new_detail['package'] = stuff['package']
        self.new_detail['unit'] = stuff['spunit']
        self.new_detail['stufftype'] = stuff['stufftype']

        self.lineEdit_batchno.setFocus()
        self.get_producer_list(p_int)

    @pyqtSlot()
    def on_pushButton_accept_clicked(self):
        text = ''
        if self.lineEdit_stuff.text() == '':
            text = "物料不能为空!\n"
        if self.lineEdit_amount.text() in ('', '0'):
            text += "到货数量不能为空!\n"
        if self.lineEdit_batchno.text() == '':
            text += "进厂批号不能为空!\n"
        if len(text) > 0:
            message = MessageBox(self, text="以下信息填写错误", informative=text)
            message.show()
            return
        if len(self.new_detail):
            if self.spid:
                key_dict_supplyer = {'autoid': self.spid}
                supplyer_list = self.SC.get_supply(False,
                                                   *VALUES_TUPLE_SUPPLYER,
                                                   **key_dict_supplyer)
                if len(supplyer_list):
                    supplyer = supplyer_list[0]
                    self.new_detail['supid'] = supplyer['supid']
                    self.new_detail['supname'] = supplyer['supname']
                self.new_detail['paperno'] = self.paperno
                self.new_detail['papertype'] = self.papertype
                self.new_detail['checkindate'] = user.now_date
            res = self.WC.update_stuffcheckinlist(self.autoid,
                                                  **self.new_detail)

            self.accept()

    @pyqtSlot()
    def on_pushButton_cancel_clicked(self):
        self.close()
class PurchaseRegistrationModule(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(PurchaseRegistrationModule, self).__init__(parent)
        self.setupUi(self)
        if '28' not in user.powers:
            self.close()
        if user.powers['28'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['28'])

        self.WC = WarehouseController()
        self.LC = LabrecordsController()
        self.SC = SupplyerController()
        self.SFC = StuffController()
        self.CI = CheckItem()
        self.groupBox.setVisible(False)
        self.spid = 0
        self.paperno = ''
        self.supid = ''
        self.supname = ''

        self.get_order_list()

    def get_order_list(self):
        self.treeWidget_orderlist.clear()
        self.treeWidget_orderlist.hideColumn(0)
        index = self.tabWidget.currentIndex()
        key_dict = {'status': index, 'papertype': 0}
        order_list = self.WC.get_stuffcheckin(False, *VALUES_TUPLE_ORDER,
                                              **key_dict)
        if not len(order_list):
            return
        for item in order_list:
            qtreeitem = QTreeWidgetItem(self.treeWidget_orderlist)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, item['paperno'])
            qtreeitem.setText(2, item['supid'] + ' ' + item['supname'])
            qtreeitem.setText(3, item['creatorid'] + ' ' + item['creatorname'])
            qtreeitem.setText(4, str(item['buydate']))
            qtreeitem.setText(5, item['buyerid'] + ' ' + item['buyername'])
            qtreeitem.setText(6, item['pppaperno'])
            qtreeitem.setText(7, item['remark'])
        for i in range(1, 8):
            self.treeWidget_orderlist.resizeColumnToContents(i)

    def get_stuff_list(self):

        self.treeWidget_stufflist.clear()
        self.treeWidget_stufflist.hideColumn(0)
        index = self.tabWidget.currentIndex()
        key_dict = {'paperno': self.paperno, 'papertype': 0}
        stuff_list = self.WC.get_stuffcheckinlist(False, *VALUES_TUPLE_STUFF,
                                                  **key_dict)
        if not len(stuff_list):
            return
        for item in stuff_list:
            qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
            qtreeitem.setText(0, str(item['autoid']))
            qtreeitem.setText(1, STATUS[item['status']])
            qtreeitem.setText(2, item['stuffid'] + ' ' + item['stuffname'])
            qtreeitem.setText(3, item['batchno'])
            qtreeitem.setText(4, item['mbatchno'])
            qtreeitem.setText(5, STUFF_KIND[item['stufftype']])
            qtreeitem.setText(6, item['spec'])
            qtreeitem.setText(7, item['package'])
            qtreeitem.setText(8, item['position'])
            qtreeitem.setText(9, str(item['amount']))
            qtreeitem.setText(10, str(item['piamount']))
            qtreeitem.setText(11, item['unit'])
            qtreeitem.setText(12, item['producer'])
        for i in range(1, 13):
            self.treeWidget_stufflist.resizeColumnToContents(i)

    @pyqtSlot(int)
    def on_tabWidget_currentChanged(self, p_int):
        tab = getattr(self, 'tab_' + str(p_int))
        tab.setLayout(self.gridLayout_2)
        self.groupBox.setVisible(False)
        self.get_order_list()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_orderlist_itemClicked(self, qtreeitem, p_int):
        self.groupBox.setVisible(True)

        self.paperno = qtreeitem.text(1)
        self.supid = qtreeitem.text(2).split(' ')[0]
        self.supname = qtreeitem.text(2).split(' ')[1]
        key_dict = {'supid': self.supid, 'supname': self.supname}
        res = self.SC.get_supply(True, *VALUES_TUPLE_SUPPLYER, **key_dict)
        if len(res):
            self.spid = res[0]
        self.get_stuff_list()

    @pyqtSlot(QPoint)
    def on_treeWidget_orderlist_customContextMenuRequested(self, pos):
        if self.power[1] == '0':
            return
        id = 0
        index = self.tabWidget.currentIndex()
        if index != 0:
            return
            # 返回调用者的对象
        sender_widget = self.sender()
        current_item = sender_widget.currentItem()
        if current_item is not None:
            id = int(current_item.text(0))

        menu = QMenu()
        button1 = menu.addAction("新增登记单")
        button2 = menu.addAction("设置为完成状态")
        button3 = menu.addAction("设置为其他状态")

        global_pos = sender_widget.mapToGlobal(pos)
        action = menu.exec(global_pos)

        if action == button1:
            detail = NewPurchRegModule(self)
            detail.accepted.connect(self.get_order_list)
            detail.show()

        elif action == button2:
            if id is None:
                return
            key_dict = {'status': 1}
            self.WC.update_stuffcheckin(id, **key_dict)
            self.get_order_list()
        elif action == button3:
            if id is None:
                return
            key_dict = {'status': 2}
            self.WC.update_stuffcheckin(id, **key_dict)
            self.get_order_list()

    @pyqtSlot(QPoint)
    def on_treeWidget_stufflist_customContextMenuRequested(self, pos):
        if self.power[1] == '0':
            return
        id = 0
        index = self.tabWidget.currentIndex()
        if index != 0:
            return
            # 返回调用者的对象
        sender_widget = self.sender()
        current_item = sender_widget.currentItem()
        if current_item is not None:
            id = int(current_item.text(0))

        menu = QMenu()
        button1 = menu.addAction("增加")
        button2 = menu.addAction("修改")
        button3 = menu.addAction("删除")
        button4 = menu.addAction("请验单")
        button5 = menu.addAction("不合格品处理申请")
        button6 = menu.addAction("不合格品处理意见")

        global_pos = sender_widget.mapToGlobal(pos)
        action = menu.exec(global_pos)

        if action == button1:
            detail = EditRegStuffModule(spid=self.spid,
                                        paperno=self.paperno,
                                        parent=self)
            detail.accepted.connect(self.get_stuff_list)
            detail.show()

        elif action == button2:
            if not id:
                return
            detail = EditRegStuffModule(autoid=id, parent=self)
            detail.accepted.connect(self.get_stuff_list)
            detail.show()
        elif action == button3:
            if not id:
                return
            if current_item.text(1) not in ("登记", "请验中"):
                return
            key_dict_lab = {'autoid': id}
            lab_list = self.WC.get_stuffcheckinlist(True, *VALUES_TUPLE_LAB,
                                                    **key_dict_lab)
            self.LC.delete_labrecord(list(lab_list))
            self.LC.delete_labitem(list(lab_list))
            self.WC.delete_stuffcheckinlist(id)
            self.get_stuff_list()
        elif action == button4:
            if not id:
                return
            status = current_item.text(1)
            if status not in ("登记", "请验中"):
                return
            stuffid = current_item.text(2).split(' ')[0]
            stuffname = current_item.text(2).split(' ')[1]
            key_dict = {'stuffid': stuffid, 'stuffname': stuffname}
            checkunit = ''
            res = self.SFC.get_stuffdict(True, *VALUES_TUPLE_SD, **key_dict)
            if len(res):
                checkunit = res[0]
            key_dict_lab = {'ciid': id, 'labtype': 0}
            labrecord_list = self.LC.get_labrecord(False, **key_dict_lab)
            if not len(labrecord_list):
                kwargs = {
                    'labtype': 0,
                    'chkid': stuffid,
                    'chkname': stuffname,
                    'batchno': current_item.text(3),
                    'mbatchno': current_item.text(4),
                    'spec': current_item.text(6),
                    'package': current_item.text(7),
                    'producer': current_item.text(12),
                    'supplyer': self.supname,
                    'ciid': int(current_item.text(0)),
                    'createdate': user.now_date,
                    'checkamount': decimal.Decimal(current_item.text(9)),
                    'caunit': current_item.text(11),
                    'sampleunit': checkunit,
                    'samplesource': self.supname
                }
                labrecord = self.LC.update_labrecord(**kwargs)
                key_dict_checkitem = {'stuffid': stuffid, 'itemtype': 0}
                checkitems = self.CI.get_checkitems(False,
                                                    *VALUES_TUPLE_CHECKITEM,
                                                    **key_dict_checkitem)
                for item in checkitems:
                    kwargs_checkitem = {
                        'lrid': labrecord.autoid,
                        'seqid': item['seqid'],
                        'itemname': item['itemname'],
                        'kind': item['kind'],
                        'referencevalue': item['referencevalue'],
                        'labvalue': item['referencevalue'],
                        'putintype': item['putintype'],
                        'startdate': user.now_date,
                        'enddate': user.now_date,
                        'checked': 2
                    }
                    self.LC.update_labitem(**kwargs_checkitem)
            else:
                labrecord = labrecord_list[0]
            self.WC.update_stuffcheckinlist(id, lrid=labrecord.autoid)
            detail = ApplycheckModule(autoid=labrecord.autoid, parent=self)
            detail.applyed.connect(self.get_stuff_list)
            detail.show()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_stufflist_itemDoubleClicked(self, qtreeitem, p_int):
        if self.power[1] == '0':
            return
        status = qtreeitem.text(1)
        if status != "登记":
            return
        id = int(qtreeitem.text(0))
        detail = EditRegStuffModule(autoid=id, parent=self)
        detail.accepted.connect(self.get_stuff_list)
        detail.show()
Пример #26
0
class StuffReturnPaperModule(QWidget, Ui_Form):
    def __init__(self, autoid, parent=None):
        # autoid:领料单在stuffdrawpaper中的autoid
        super(StuffReturnPaperModule, self).__init__(parent)
        self.autoid = autoid
        self.ori_detail = dict()
        self.new_detail = dict()
        self.SC = StuffController()
        self.setupUi(self)
        self.pushButton_apply.setVisible(False)
        self.pushButton_cancel.setVisible(False)

        self.get_stuffdrawpaper()
        self.get_stufflist()

    # 获取领料单的状态
    def get_stuffdrawpaper(self):
        key_dict = {'autoid': self.autoid}
        res = self.SC.get_stuffdrawpaper(False, *VALUES_TUPLE_pAPER,
                                         **key_dict)
        if len(res) == 1:
            self.ori_detail = res[0]

            self.label_dept.setText(self.ori_detail['deptid'] + ' ' +
                                    self.ori_detail['deptname'])
            if self.ori_detail['wdstatus'] == 0:
                self.label_status.setText("未提交")
                self.pushButton_apply.setVisible(True)
                self.pushButton_cancel.setVisible(False)
                self.label_charger.setText('')
                # self.label_provider.setText('')
                self.dateEdit_applytime.setVisible(False)
                self.dateEdit_receivetime.setVisible(False)
            elif self.ori_detail['wdstatus'] == 1:
                self.label_status.setText("已提交")
                self.pushButton_apply.setVisible(False)
                self.pushButton_cancel.setVisible(True)
                self.label_charger.setText(self.ori_detail['wdchargerid'] +
                                           ' ' +
                                           self.ori_detail['wdchargername'])
                self.label_receiver.setText('')
                self.dateEdit_applytime.setDate(self.ori_detail['wddate'])
                self.dateEdit_applytime.setVisible(True)
                self.dateEdit_receivetime.setVisible(False)
            elif self.ori_detail['wdstatus'] == 2:
                self.pushButton_apply.setVisible(False)
                self.pushButton_cancel.setVisible(False)
                self.label_status.setText("已完成")
                self.label_charger.setText(self.ori_detail['wdchargerid'] +
                                           ' ' +
                                           self.ori_detail['wdchargername'])
                self.label_receiver.setText(self.ori_detail['wddrawerid'] +
                                            ' ' +
                                            self.ori_detail['wddrawername'])
                self.dateEdit_applytime.setDate(self.ori_detail['wddate'])
                self.dateEdit_receivetime.setDate(
                    self.ori_detail['wddrawdate'])

    # 获取已经领取了的物料
    def get_stufflist(self):
        self.treeWidget_stufflist.clear()
        self.treeWidget_stufflist.hideColumn(0)
        key_dict = {'sdpid': self.autoid}
        if self.label_status.text() == "已完成":
            key_dict['backamount__gt'] = 0
        res = self.SC.get_prodstuff(False, *VALUES_TUPLE_STUFF, **key_dict)
        if len(res):
            for item in res:
                qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
                qtreeitem.setText(0, str(item['autoid']))  # autoid
                qtreeitem.setText(1, item['stuffid'] + ' ' +
                                  item['stuffname'])  # 物料
                qtreeitem.setText(2, item['batchno'])  # 进厂批号
                qtreeitem.setText(3, item['spec'])  # 含量规格
                qtreeitem.setText(4, item['package'])  # 包装规格
                qtreeitem.setText(5,
                                  to_str(item['presamount']) +
                                  item['presunit'])  # 计划量
                qtreeitem.setText(6,
                                  to_str(item['pracamount']) +
                                  item['pracunit'])  # 实际量
                qtreeitem.setText(7,
                                  to_str(item['drawamount']) +
                                  item['drawunit'])  # 领取量
                qtreeitem.setText(8,
                                  to_str(item['restamount']) +
                                  item['drawunit'])  # 剩余量
                qtreeitem.setText(9,
                                  to_str(item['backamount']) +
                                  item['drawunit'])  # 退库量量
                qtreeitem.setText(10, item['wdid'] + item['wdname'])

            for i in range(1, 11):
                self.treeWidget_stufflist.resizeColumnToContents(i)

    # 提交领料
    @pyqtSlot()
    def on_pushButton_apply_clicked(self):
        if self.ori_detail['wdstatus'] != 0:
            return
        self.new_detail['wdstatus'] = 1
        self.new_detail['wdchargerid'] = user.user_id
        self.new_detail['wdchargername'] = user.user_name
        self.new_detail['wddate'] = user.now_date
        # print(self.new_detail)
        self.SC.update_stuffdrawpaper(autoid=self.autoid, **self.new_detail)
        self.get_stuffdrawpaper()

    @pyqtSlot()
    def on_pushButton_cancel_clicked(self):
        if self.ori_detail['wdstatus'] != 1:
            return
        self.new_detail['wdstatus'] = 0
        self.new_detail['wdchargerid'] = ''
        self.new_detail['wdchargername'] = ''
        self.new_detail['wddate'] = None
        self.SC.update_stuffdrawpaper(autoid=self.autoid, **self.new_detail)
        self.get_stuffdrawpaper()

    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_stufflist_itemDoubleClicked(self, q_treeitem, p_int):
        if self.label_status.text() != "未提交":
            return
        id = int(q_treeitem.text(0))
        detail = EditStuffReturnDetailModule(id, self)
        detail.accepted.connect(self.get_stufflist)
        detail.show()
Пример #27
0
class EditpurstuffModule(QDialog, Ui_Dialog):
    def __init__(self, spid, ppid=None, autoid=None, parent=None):
        super(EditpurstuffModule, self).__init__(parent)
        self.ori_detail = dict()
        self.new_detail = dict()
        self.SC = SupplyerController()
        self.SFC = StuffController()
        self.setupUi(self)
        # row = ('autoid', 'stuffid', 'stuffname', 'spec', 'package')
        # key = ('stuffid', 'stuffname', 'stuffkind', 'inputcode')
        # row_name = ('id', '物料编号', '物料名称', '含量规格', '包装规格')
        # self.lineEdit_supplyer.setup('Supplyer', row, key, row_name, 539, 240)

        self.autoid = autoid
        self.spid = spid
        self.ppid = ppid

        self.get_detail()
        self.set_amount_validator()

    def get_detail(self):
        if not self.autoid:
            return
        key_dict = {'autoid': self.autoid}
        res = self.SC.get_purchstuff(False, *VALUES_TUPLE_PPLIST, **key_dict)
        if len(res) != 1:
            return
        self.ori_detail = res[0]
        self.lineEdit_stuff.setText(self.ori_detail['stuffid'] + ' ' +
                                    self.ori_detail['stuffname'])
        self.label_spec.setText(self.ori_detail['spec'])
        self.label_package.setText(self.ori_detail['package'])
        self.lineEdit_amount.setText(str(self.ori_detail['amount']))
        self.label_unit.setText(self.ori_detail['unit'])

    def set_amount_validator(self):
        doubleValitor = QDoubleValidator()
        doubleValitor.setBottom(0)
        doubleValitor.setDecimals(3)
        doubleValitor.setNotation(QDoubleValidator.StandardNotation)
        self.lineEdit_amount.setValidator(doubleValitor)

    @pyqtSlot(str)
    def on_lineEdit_amount_textChanged(self, p_str):
        try:
            if p_str != self.ori_detail['amount']:
                self.new_detail['amount'] = p_str
            else:
                try:
                    del self.new_detail['amount']
                except KeyError:
                    pass
        except KeyError:
            self.new_detail['amount'] = p_str

    @pyqtSlot()
    def on_toolButton_more_clicked(self):
        detail = SelectstuffModule(self.spid, self)
        detail.selected.connect(self.set_stuff)
        detail.show()

    def set_stuff(self, p_int):

        key_dict = {'autoid': p_int}
        res = self.SFC.get_stuffdict(False, *VALUES_TUPLE_STUFF, **key_dict)

        if not len(res):
            return
        stuff = res[0]
        self.lineEdit_stuff.setText(stuff['stuffid'] + stuff['stuffname'])
        self.label_spec.setText(stuff['spec'])
        self.label_package.setText(stuff['package'])
        self.label_unit.setText(stuff['spunit'])
        self.new_detail['stuffid'] = stuff['stuffid']
        self.new_detail['stuffname'] = stuff['stuffname']
        self.new_detail['spec'] = stuff['spec']
        self.new_detail['package'] = stuff['package']
        self.new_detail['unit'] = stuff['spunit']
        self.new_detail['stufftype'] = stuff['stufftype']
        self.new_detail['expireddays'] = stuff['expireddays']
        self.lineEdit_amount.setFocus()

    @pyqtSlot()
    def on_pushButton_accept_clicked(self):
        text = ''
        if self.lineEdit_stuff.text() == '':
            text = "物料不能为空!\n"
        if self.lineEdit_amount.text() in ('', '0'):
            text += "采购数量不能为空!\n"
        if len(text) > 0:
            message = MessageBox(self, text="以下信息填写错误", informative=text)
            message.show()
            return
        if len(self.new_detail):
            if self.ppid:
                self.new_detail['ppid'] = self.ppid
            res = self.SC.update_purchstuff(self.autoid, **self.new_detail)
            self.accept()

    @pyqtSlot()
    def on_pushButton_cancel_clicked(self):
        self.close()
class PorductionInstructionModule(QWidget, Ui_Form):

    def __init__(self, autoid, parent=None):
        super(PorductionInstructionModule, self).__init__(parent)
        self.autoid = autoid
        self.setupUi(self)
        self.SC = StuffController()
        self.PC = ProductController()
        self.ori_detail = dict()
        self.new_detail = dict()
        # 获取物料信息
        self.get_stufflist()
        # 获取生产指令信息
        self.get_detail()

    # 获取已经领取了的物料
    def get_stufflist(self):
        values_tupe = (
            "autoid", "lrid", "stuffid", "stuffname", "batchno", "spec",
            "package", "presamount", "content", "cunit", "water",
            "impurity", "rdensity", "presunit"
        )
        key_dict = {
            'ppid': self.autoid,
            'stufftype__in': (0, 1, 2)
        }
        res = self.SC.get_prodstuff(False, *values_tupe, **key_dict)
        if len(res):
            for item in res:
                qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
                qtreeitem.setText(0, str(item['autoid']))  # autoid
                qtreeitem.setText(1, str(item['lrid']))  # lrid
                qtreeitem.setText(2, item['stuffid'] + ' ' + item[
                    'stuffname'])  # 物料
                qtreeitem.setText(3, item['batchno'])  # 进厂批号
                qtreeitem.setText(4, item['spec'])  # 含量规格
                qtreeitem.setText(5, item['package'])  # 包装规格
                qtreeitem.setText(6, str(item['presamount']) + item[
                    'presunit'])  # 计划量
                qtreeitem.setText(7, str(item['content']) + item[
                    'cunit'])  # 含量/效价
                qtreeitem.setText(8, str(item['water']) + '%')  # 水分
                qtreeitem.setText(9, str(item['impurity']))  # 相对密度
                qtreeitem.setText(10, str(item['rdensity']))  # 杂质

            self.treeWidget_stufflist.hideColumn(0)
            self.treeWidget_stufflist.hideColumn(1)
            for i in range(2, 11):
                self.treeWidget_stufflist.resizeColumnToContents(i)



    def get_detail(self):
        values_list = (
            'instructorid', 'instructorname', 'warrantorid', 'warrantorname',
            'executorid', 'executorname', 'plandate', 'warrantdate',
            'executedate'
        )
        key_dict = {
            'autoid': self.autoid
        }
        res = self.PC.get_producingplan(False, *values_list, **key_dict)
        if len(res) == 0:
            return

        self.ori_detail = res[0]
        self.pushButton_instructor.setText(
            self.ori_detail['instructorid'] + ' ' +
            self.ori_detail['instructorname']
        )
        self.pushButton_warrantor.setText(
            self.ori_detail['warrantorid'] + ' ' +
            self.ori_detail['warrantorname']
        )
        self.pushButton_executor.setText(
            self.ori_detail['executorid'] + ' ' +
            self.ori_detail['executorname']
        )
        if type(self.ori_detail['plandate']) is datetime.date:
            self.dateEdit_plandate.setDate(self.ori_detail['plandate'])
        if type(self.ori_detail['warrantdate']) is datetime.date:
            self.dateEdit_warrantdate.setDate(self.ori_detail['warrantdate'])
        if type(self.ori_detail['executedate']) is datetime.date:
            self.dateEdit_executedate.setDate(self.ori_detail['executedate'])
Пример #29
0
class StuffdrawpaperModule(QWidget, Ui_Form):
    def __init__(self, autoid, parent=None):
        # autoid:领料单在stuffdrawpaper中的autoid
        # kind: 领料单的类型与原料对应
        super(StuffdrawpaperModule, self).__init__(parent)
        self.autoid = autoid
        self.ori_detail = object
        self.new_detail = {}
        self.SC = StuffController()
        self.setupUi(self)
        self.pushButton_apply.setVisible(False)
        self.get_stuffdrawpaper()

    # 获取领料单的状态
    def get_stuffdrawpaper(self):
        res = self.SC.get_stuffdrawpaper(autoid=self.autoid)
        if len(res) == 1:
            self.ori_detail = res[0]

            self.label_dept.setText(
                self.ori_detail.deptid + ' ' + self.ori_detail.deptname)
            if self.ori_detail.status == 0:
                self.label_status.setText("未提交")
                self.pushButton_apply.setVisible(True)
                self.pushButton_apply.setText("提交领料")
                self.label_charger.setText('')
                self.label_provider.setText('')
                self.dateEdit_applytime.setVisible(False)
                self.dateEdit_drawtime.setVisible(False)
            elif self.ori_detail.status == 1:
                self.label_status.setText("已提交")
                self.pushButton_apply.setText("取消领料")
                self.label_charger.setText(
                    self.ori_detail.chargerid + ' ' + self.ori_detail.chargername)
                self.label_provider.setText('')
                self.dateEdit_applytime.setDate(
                    self.ori_detail.applydate)
                self.dateEdit_applytime.setVisible(True)
                self.dateEdit_drawtime.setVisible(False)
            elif self.ori_detail.status == 2:
                self.label_status.setText("已完成")
                self.label_charger.setText(
                    self.ori_detail.chargerid + ' ' + self.ori_detail.chargername)
                self.label_provider.setText(
                    self.ori_detail.providerid + ' ' + self.ori_detail.providername)
                self.dateEdit_applytime.setDate(
                    self.ori_detail.applydate)
                self.dateEdit_drawtime.setDate(self.ori_detail.drawdate)
                self.get_stufflist()

    # 获取已经领取了的物料
    def get_stufflist(self):
        values_tupe = (
            "autoid", "lrid", "stuffid", "stuffname", "batchno", "spec",
            "package", "presamount", "pracamount", "drawamount", "content",
            "cunit", "water", "impurity", "rdensity", "presunit", "pracunit",
            "drawunit"
        )
        key_dict = {'sdpid': self.autoid}
        res = self.SC.get_prodstuff(0, *values_tupe, **key_dict)
        if len(res):
            for item in res:
                qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
                qtreeitem.setText(0, str(item['autoid']))  # autoid
                qtreeitem.setText(1, str(item['lrid']))  # lrid
                qtreeitem.setText(2, item['stuffid'] + ' ' + item['stuffname'])  # 物料
                qtreeitem.setText(3, item['batchno'])  # 进厂批号
                qtreeitem.setText(4, item['spec'])  # 含量规格
                qtreeitem.setText(5, item['package'])  # 包装规格
                qtreeitem.setText(6, str(item['presamount']) + item['presunit'])  # 计划量
                qtreeitem.setText(7, str(item['pracamount']) + item['pracunit'])  # 实际量
                qtreeitem.setText(8, str(item['drawamount']) + item['drawunit'])  # 领取量
                qtreeitem.setText(9, str(item['content']) + item['cunit'])  # 含量/效价
                qtreeitem.setText(10, str(item['water']) + '%')  # 水分
                qtreeitem.setText(11, str(item['impurity']))  # 相对密度
                qtreeitem.setText(12, str(item['rdensity']))  # 杂质

            self.treeWidget_stufflist.hideColumn(0)
            self.treeWidget_stufflist.hideColumn(1)
            for i in range(2, 11):
                self.treeWidget_stufflist.resizeColumnToContents(i)

    # 提交领料
    @pyqtSlot()
    def on_pushButton_apply_clicked(self):
        if self.ori_detail.status == 0:
            self.new_detail['status'] = 1
            self.new_detail['chargerid'] = user.user_id
            self.new_detail['chargername'] = user.user_name
            self.new_detail['applydate'] = user.now_date
            # print(self.new_detail)
            res = self.SC.update_stuffdrawpaper(autoid=self.autoid,
                                                **self.new_detail)

        elif self.ori_detail.status == 1:
            self.new_detail['status'] = 0
            self.new_detail['chargerid'] = ''
            self.new_detail['chargername'] = ''
            self.new_detail['applydate'] = None
            res = self.SC.update_stuffdrawpaper(autoid=self.autoid,
                                                **self.new_detail)
        if res:
            self.get_stuffdrawpaper()
Пример #30
0
class StuffDictionaryModule(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(StuffDictionaryModule, self).__init__(parent)
        self.setupUi(self)
        # 数据库操作类
        self.SC = StuffController()
        if '1' not in  user.powers:
            self.close()
        if user.powers['1'] == 0:
            self.close()
        self.power = '{:03b}'.format(user.powers['1'])
        self.stufftype = 0
        # 隐藏第一列的id
        self.treeWidget_stufflist.hideColumn(0)
        # 显示物料列表
        self.get_stufflist()

    def get_stufflist(self):

        self.treeWidget_stufflist.clear()
        condition = {'stufftype' : self.stufftype}
        res = self.SC.get_data(0, False, *VALUES_TUPLE_SD, **condition)
        if not len(res):
            self.label_count.setText("共0条记录")
        self.label_count.setText("共%s条记录" % len(res))
        for item in res:
            qtreeitem = QTreeWidgetItem(self.treeWidget_stufflist)
            qtreeitem.setText(0, str(item["autoid"]))
            qtreeitem.setText(1, item["stuffid"])
            qtreeitem.setText(2, item["stuffname"])
            qtreeitem.setText(3, item["kind"])
            qtreeitem.setText(4, item["spec"])
            qtreeitem.setText(5, item["package"])
            qtreeitem.setText(6, item["allowno"])
            qtreeitem.setText(7, item["storage"])

        for i in range(1, 8):
            self.treeWidget_stufflist.resizeColumnToContents(i)
            if self.treeWidget_stufflist.columnWidth(i) > 200:
                self.treeWidget_stufflist.setColumnWidth(i, 200)
            elif self.treeWidget_stufflist.columnWidth(i) < 120:
                self.treeWidget_stufflist.setColumnWidth(i, 120)

    # 物料列表双击功能
    @pyqtSlot(QTreeWidgetItem, int)
    def on_treeWidget_stufflist_itemDoubleClicked(self, qtreeitem, p_int):
        if self.power[1] == '0':
            return
        autoid = int(qtreeitem.text(0))
        # 物料详细列表
        detail = EditStuffDetailModule(autoid, self)
        detail.accepted.connect(self.get_stufflist)
        # 修改了物料记录,刷新列表
        detail.show()

    @pyqtSlot(int)
    def on_tabWidget_currentChanged(self, p_int):
        getattr(self, 'tab_' + str(p_int)).setLayout(self.gridLayout_2)
        self.stufftype = p_int
        self.get_stufflist()

    @pyqtSlot(QPoint)
    def on_treeWidget_stufflist_customContextMenuRequested(self, pos):
        current_item = self.treeWidget_stufflist.currentItem()
        global_pos = self.treeWidget_stufflist.mapToGlobal(pos)
        menu = QMenu()
        action_1 = menu.addAction("增加")
        action_2 = menu.addAction("修改")
        action_3 = menu.addAction("删除")
        action = menu.exec(global_pos)
        if action == action_1:
            detail = EditStuffDetailModule(parent=self)
            detail.accepted.connect(self.get_stufflist)
            detail.show()
        elif action == action_2:
            if current_item is None:
                return
            id = int(current_item.text(0))
            detail = EditStuffDetailModule(id, self)
            detail.accepted.connect(self.get_stufflist)
            detail.show()
        elif action == action_3:
            if current_item is None:
                return
            id = int(current_item.text(0))
            condition = {'autoid': id}
            self.SC.delete_data(0, condition)
            self.get_stufflist()