Beispiel #1
0
    def post(self, *args, **kwargs):
        post_data = {}
        new = {}
        for key in self.request.arguments:
            post_data[key] = self.get_argument(key)
        l_id = post_data['id']
        l_res = Dal_Logistics().selectLogistics(l_id)
        if (l_res == None):
            respon = {'errorCode': "1"}  #未知物流
        else:
            if post_data.has_key('comfirm') == False:
                new['comfirm'] = "Y"
            if (Dal_Logistics().updateLogistics(post_data["id"], **new) == 1):
                respon = {'errorCode': updateManifest_error['success']}

                #入库操作

                pname = Dal_Batch().selectBatch(l_res['amount'])
                nowtime = Utils().dbTimeCreate()
                b_res = Dal_Batch().selectBatch(l_res['amount'])
                ware = Warehouse(id=None,
                                 p_name=pname['p_name'],
                                 p_id=l_res['amount'],
                                 inTime=str(nowtime),
                                 outTime=None,
                                 w_id=l_res['endPlace'],
                                 in_c_id=l_res['startPlace'],
                                 out_c_id=None,
                                 stock=b_res['amount'])
                new_ware = Dal_Warehouse().addWarehouse(ware)
            else:
                respon = {'errorCode': updateManifest_error['failed']}
        respon_json = json.dumps(respon)
        self.write(respon_json)
Beispiel #2
0
 def post(self, *args, **kwargs):
     post_data = {}
     nowtime = Utils().dbTimeCreate()
     for key in self.request.arguments:
         post_data[key] = self.get_argument(key)
     photoPath = ''
     ##图片上传
     if (self.request.files != ''):
         photo_img = self.request.files["pro_img"]
         photoPath = Dal_Batch().addPhoto(photo_img)
     newBatch = Batch(id=None,
                      prodtime=post_data['prodtime'],
                      pc_id=post_data['id'],
                      p_name=post_data['p_name'],
                      mat_list=None,
                      exptime=post_data['exptime'],
                      intro=post_data['intro'],
                      man_id=post_data['man_id'],
                      log_id=None,
                      pro_img=photoPath,
                      qr_img=None,
                      br_img=None,
                      amount=post_data['amount'],
                      time=nowtime)
     ba_id = Dal_Batch().addBatch(newBatch)
     result = Dal_Batch().selectBatch(ba_id)
     respon = {'errorcode': 0}
     respon_json = json.dumps(respon)
     self.write(respon_json)
 def post(self, *args, **kwargs):
     post_data = {}
     new = {}
     for key in self.request.arguments:
         post_data[key] = self.get_argument(key)
     company = Dal_Company().selectCompanyByN(post_data['companyName'])
     if (company == None):
         respon = {'errorCode': addLogistics_error['companyInvaild']}
     else:
         nextcompany = Dal_Company().selectCompanyByN(
             post_data['nextCompanyName'])
         if (nextcompany == None):
             respon = {'errorCode': addLogistics_error['companyInvaild']}
         else:
             driver = Dal_Staff().selectStaffByName(post_data['name'])
             if (driver == None):
                 respon = {'errorCode': addLogistics_error['driverInvaild']}
             else:
                 batch = Dal_Batch().selectBatch(post_data['amount'])
                 if (batch == None):
                     respon = {
                         'errorCode': addLogistics_error['batchInvaild']
                     }
                 else:
                     nowtime = Utils().dbTimeCreate()
                     newLogistics = Logistics(
                         id=None,
                         driverId=driver['id'],
                         plateNum=post_data['plateNum'],
                         startPlace=company['id'],
                         endPlace=nextcompany['id'],
                         time=str(nowtime),
                         comfirm='N',
                         amount=post_data['amount'])
                     id = Dal_Logistics().addLogistics(newLogistics)
                     if id == False:
                         respon = {
                             'errorCode': addLogistics_error['failed']
                         }
                     else:
                         new['log_id'] = id
                         batch_id = str(post_data["amount"])
                         if (Dal_Batch().updateBatch(batch_id, **new) == 1):
                             respon = {
                                 'errorCode': addLogistics_error['success']
                             }
                             c_id = str(company['id'])
                             c_id = str(c_id.zfill(4))
                             batch_id = str(batch_id.zfill(5))
                             text = "690" + c_id + batch_id
                             self.make_qrcode(text, batch_id)
                             self.make_brcode(text, batch_id)
     respon_json = json.dumps(respon)
     self.write(respon_json)
Beispiel #4
0
def initCache():
    Dal_user().initCache()
    Dal_Company().initCache()
    Dal_Staff().initCache()
    Dal_Warehouse().initCache()
    Dal_Logistics().initCache()
    Dal_Batch().initCache()
    Dal_Manifest().initCache()
 def post(self, *args, **kwargs):
     post_data = {}
     for key in self.request.arguments:
         post_data[key] = self.get_argument(key)
     batch = Dal_Batch().selectBatch(1 if (
         int(post_data["page"]) <= 0) else post_data["page"])
     respon = {'errorCode': selectBatch_error['success'], 'batch': batch}
     respon_json = json.dumps(respon)
     self.write(respon_json)
Beispiel #6
0
    def post(self):
        post_data = {}
        for key in self.request.arguments:
            post_data[key] = self.get_argument(key)

        encode = post_data['code']
        # 解密
        # code = decrypt(encode, '1938762450')
        c_code = int(encode[3:7])  #截取公司id
        b_code = int(encode[7:])  #截取批次id

        c_res = Dal_Company().selectCompany(c_code)  #获取公司信息
        b_res = Dal_Batch().selectBatch(b_code)  #获取批次信息

        prod = {
            'prodtime': b_res['prodtime'],
            'p_name': b_res['p_name'],
            'exptime': b_res['exptime'],
            'intro': b_res['intro'],
            'pro_img': b_res['pro_img'],
            'br_img': b_res['br_img'],
        }
        #获取订单信息
        man_id = b_res['man_id']
        m_res = Dal_Manifest().selectManifest(man_id)
        s_res = Dal_Staff().selectStaff(m_res['originatorId'])
        maniefest = {'staff': s_res['name']}
        #获取物流信息
        log_id = b_res['log_id']
        l_res = Dal_Logistics().selectLogistics(log_id)
        d_name = Dal_Staff().selectStaff(l_res['driverId'])
        logistic = {
            'd_name': d_name['name'],
            'plateNum': l_res['plateNum'],
            'start_p': Dal_Company().selectC_nameByID(l_res['startPlace']),
            'end_p': Dal_Company().selectC_nameByID(l_res['endPlace']),
            'time': l_res['time']
        }
        #获取公司信息
        company = {
            'name': c_res['name'],
            'address': c_res['address'],
            'profile': c_res['profile'],
            'tel': c_res['tel'],
            'pcPath': c_res['pcPath'],
            'blPath': c_res['blPath'],
            'scPath': c_res['scPath'],
        }

        data = {
            'errorcode': 0,
            'prod': prod,
            "maniefest": maniefest,
            "logistic": logistic,
            "company": company
        }
        self.write(json.dumps(data))
Beispiel #7
0
 def post(self, *args, **kwargs):
     post_data = {}
     for key in self.request.arguments:
         post_data[key] = self.get_argument(key)
     if (Dal_Batch().deleteBatch(post_data['id']) == False):
         respon = {'errorCode': deleteBatch_error['batchInvaild']}
     else:
         respon = {'errorCode': deleteBatch_error['success']}
     respon_json = json.dumps(respon)
     self.write(respon_json)
 def make_brcode(self, text, batch_id):
     Code = barcode.get_barcode_class('ean13')
     imagewriter = ImageWriter()
     text = str(text)
     bar = Code(text, writer=imagewriter, add_checksum=False)
     a = "C:\Users\Administrator\Desktop\Traceability\static\BarCode_img\\" + batch_id
     bar.save(a)
     new = {}
     new["br_img"] = batch_id + ".png"
     Dal_Batch().updateBatch(batch_id, **new)
Beispiel #9
0
 def post(self, *args, **kwargs):
     post_data = {}
     for key in self.request.arguments:
         post_data[key] = self.get_argument(key)
     batch = Dal_Batch().selectBatchBCid(post_data["id"])
     if batch == None:
         respon = {'errorCode': selectBatch_error['batchInvaild']}
     else:
         respon = {
             'errorCode': selectBatch_error['success'],
             'result': batch
         }
     respon_json = json.dumps(respon)
     self.write(respon_json)
Beispiel #10
0
 def getAllProdPd(self, id):
     res = {}
     i = 0
     id = int(id)
     for k, v in self._m_cache.iteritems():
         p_id = v['p_id']
         if v['in_c_id'] == id:
             batch = Dal_Batch().selectBatch(p_id)
             res[i] = {
                 "p_name": batch['p_name'],
                 "prodtime": batch['prodtime'],
                 "exptime": batch['exptime'],
                 "man_id": batch['man_id'],
                 "amount": batch['amount']
             }
             i += 1
     return res
Beispiel #11
0
 def make_qrcode(self, text, batch_id):
     qr = qrcode.QRCode(
         version=5,
         error_correction=qrcode.constants.ERROR_CORRECT_L,
         box_size=10,
         border=4,
     )
     # 加密
     # text = Dal_Logistics().decrypt(text, '1938762450')
     # 添加数据
     qr.add_data(text)
     # 生成二维码
     qr.make(fit=True)
     img = qr.make_image()
     a = "C:\Users\Administrator\Desktop\Traceability\static\BarCode_img\\" + batch_id + ".png"
     img.save(a)
     # img.show()
     new = {}
     new["qr_img"] = batch_id + ".png"
     Dal_Batch().updateBatch(batch_id, **new)
Beispiel #12
0
 def post(self, *args, **kwargs):
     respon={}
     post_data = {}
     for key in self.request.arguments:
         post_data[key] = self.get_argument(key)
     company = Dal_Company().selectCompany(post_data['id'])
     if(company==None):
         respon = {'errorCode': selectLogistics_error['companyInvaild']}
     else:
         page=1 if (int(post_data["page"]) <= 0) else int(post_data["page"])
         a = Dal_Logistics().selectAllLogistics(page,str(post_data['type']),int(post_data['id']))
         logistics = a
         total=logistics['total']
         logistics.pop('total')
         for k,v in logistics.items():
             driver=Dal_Staff().selectStaff(v['driverId'])
             company=Dal_Company().selectCompany(v['startPlace'])
             nextCompany=Dal_Company().selectCompany(v['endPlace'])
             amount=v['amount']
             num = amount.count(':')
             amount_list=amount.split(':')
             amount=''
             while num>=0:
                 batch=Dal_Batch().selectBatch(amount_list[num])
                 if batch==None:
                     respon = {'errorCode': selectLogistics_error['batchInvaild']}
                 else:
                     amount+=batch['p_name']+','
                 num-=1
             v['amount']=amount[0:-1]
             v['driverId']=driver['name']
             v['startPlace']=company['name']
             v['endPlace']=nextCompany['name']
         if(logistics=={} and respon!={}):
             respon = {'errorCode': selectLogistics_error['logisticsInvaild']}
         else:
             respon = {'errorCode': selectLogistics_error['success'],'total':total,'result':logistics}
     respon_json = json.dumps(respon)
     self.write(respon_json)
Beispiel #13
0
    def get(self):
        result_goods={}
        code=self.get_query_argument('code')
        #将12位的溯源码分为前后4位
        code_front=code[0:4]
        code_back=code[4:]
        #获取商品基本信息
        production=Dal_Production().selectProduction(code_front)
        batch=Dal_Batch().selectBatch(code_back)
        if production == None:
            respon = {"errorCode": searchProduction_error['productionInvaild']}
        else:
            if batch==None:
                respon={"errorCode":searchProduction_error['batchInvaild']}
            else:
                staff=Dal_Staff().selectStaff(batch['producterId'])
                if(staff==None):
                    respon = {"errorCode": searchProduction_error['staffInvaild']}
                else:
                    company=Dal_Company().selectCompany(staff["companyId"])
                    if(company==None):
                        respon = {"errorCode": searchProduction_error['companyInvaild']}
                    else:
                        # 将信息放入字典
                        result_goods["code"]=str
                        result_goods["title"] = production['name']
                        result_goods["date"] = batch['time']
                        result_goods["size"] = production['format']
                        result_goods["intro"] = production['abstract']
                        result_goods["photo"] = production['photopath']
                        result_goods["company_name"] =company["name"]
                        result_goods["principal"] = staff["name"]

                        respon = {"errorCode": searchProduction_error['success']}
                        respon["message"]=result_goods
        respon_json = json.dumps(respon)
        self.write(respon_json)
Beispiel #14
0
 def post(self, *args, **kwargs):
     code = self.get_argument('code')
     Dal_Batch().createQrCode(code)