Outgoing processNext, I began to learn Django and draw the process and schema of the database.
1) Outbound delivery is created
2) With the passage of pallets through the gate - Automatic work and semi-automatic work
a. Automatic operation / When the pallet passes through the gate, the program requests the RFC in the WMS system for information about what the delivery is, its number and sends the identification response to the delivery back to the WMS system (possibly confirming the warehouse tasks (tasks for the equipment) on this pallet and all attachments). Also checks all excise stamps with information in the WMS system.
b. Semi-automatic operation / The operator enters the delivery number / machine in the gate system and drives the pallets through the gate, the gate system for each pallet sends a request to the WMS system for checking excise stamps inside.
3) Sent the composition of the delivery in the accounting system
Inbound process
1) Inbound delivery is created
2) Pallet passage through the gate
3) A request is sent to the accounting system about the composition of the acceptance to the current warehouse
4) The internal composition of the pallet of excise stamps is checked on the basis of this accounting system.
5) A signal is sent to the WMS system to unload the pallets.
Required tables :
Goal:
Identifier;
Stock:
Description.
Posting Message :
Title:
Time, system, warehouse number, gate ID.
Position:
Excise stamp, time of registration, binding to the title
ERP message about the composition (inbound delivery)
Title:
Time, system, delivery number,
Position:
Material, excise stamp, pallet number (if any)
Aggregated message (based on data from ERP) :
Title:
Time, system, warehouse number, gate identifier, delivery number from Accounting system, Direction indication (Inbound outbound), Verification script indication, machine number, warehouse gate number,
Position: Excise stamp, pallet number (opt), material (opt), delivery number, car number, position number in the document, batch (opt), packaging (opt)
class SapOptions(models.Model): name = models.CharField(verbose_name=' ', max_length=50) baseurl = models.CharField(max_length=500, verbose_name='Url ', help_text = 'URL , , :"https://moses1005:44300/sap/opu/odata/sap/ZLS_SUPPLYCHAIN_SRV/"')# URL sapset = models.CharField(default='Enter Sapset', max_length=100, verbose_name=' ()') mandt = models.CharField(max_length=3, verbose_name='') user = models.CharField(max_length=15, verbose_name=' ') passwd = models.CharField(max_length=15, verbose_name='') verify = models.BooleanField(default=False, help_text = ' ') def __str__(self): return ': '+self.name + ', : '+self.mandt class Gates(models.Model): from mainAPP.sap_connector import get_lgorts_fromsap ident = models.CharField(verbose_name='', max_length=10, help_text='',unique=True) wh = models.CharField(verbose_name=' ', default='',max_length=10, help_text=' WMS') help = models.CharField(verbose_name='', default='',max_length= 500,help_text=' , , , ') try: lgorts = get_lgorts_fromsap() except: lgorts = [('No Connect', 'No Connect'),] lgort = models.CharField(verbose_name='',default='0000', max_length=20, choices=lgorts) def __str__(self): return self.ident +' : '+self.wh+' : '+self.help
def sap_createSession(): # oDATA from scanner.models import SapOptions # SAP sap_opt = SapOptions.objects.all()[0] # s = requests.Session() s.headers.update({'Connection': 'keep-alive', 'X-CSRF-TOKEN': 'Fetch'}) auth = (sap_opt.user, sap_opt.passwd) try: r = s.get(sap_opt.baseurl, auth=auth,verify=sap_opt.verify) except: message = " %s %s"%(sap_opt.mandt, sap_opt.name) return ('NO TOKEN', 'NoSession', message) token = r.headers['x-csrf-token'] session = s sess = (token, session, None) return sess
def sap_delivery_verify(token, session, delivery): # ERP from scanner.models import SapOptions, Gates sap_opt = SapOptions.objects.all()[0] s = session format = '?$format=json' set = 'likpSet' url = sap_opt.baseurl + set + "('"+delivery+"')"+format headers = {'Content-type': 'application/json;charset=utf-8', 'X-CSRF-TOKEN': token} # auth = (sap_opt.user, sap_opt.passwd) # auth get = s.get(url, headers=headers, auth=auth,verify=sap_opt.verify)# if get.status_code ==200: delivery_out = json.loads(get.text).get('d').get('Vbeln') return (True, 'OK') else: error_text = json.loads(get.text).get('error').get('message').get('value') return (False, error_text)
def get_lgorts_fromsap(): from scanner.models import SapOptions session = sap_createSession() # token = session[0] session = session[1] sap_opt = SapOptions.objects.all()[0] # s = session format = '?$format=json' set = 't001lSet' url = sap_opt.baseurl + set +format headers = {'Content-type': 'application/json;charset=utf-8', 'X-CSRF-TOKEN': token} # auth = (sap_opt.user, sap_opt.passwd) # auth get = s.get(url, headers=headers, auth=auth,verify=sap_opt.verify)# jdata = json.loads(get.text) lgorts = [] for l in jdata.get('d').get('results'): l.get('lgort') lgorts.append((l.get('Lgort'),l.get('Lgort'))) return lgorts
class Gates(models.Model): from mainAPP.sap_connector import get_lgorts_fromsap ident = models.CharField(verbose_name='', max_length=10, help_text='',unique=True) wh = models.CharField(verbose_name=' ', default='',max_length=10, help_text=' WMS') help = models.CharField(verbose_name='', default='',max_length= 500,help_text=' , , , ') try: # SAP lgorts = get_lgorts_fromsap() except: lgorts = [('No Connect', 'No Connect'),] lgort = models.CharField(verbose_name='',default='0000', max_length=20, choices=lgorts) def __str__(self): return self.ident +' : '+self.wh+' : '+self.help
def sap_connect(token, session, data): from scanner.models import SapOptions, Gates # SAP ERP sap_opt = SapOptions.objects.all()[0] s = session delivery = data.get('delivery') url = sap_opt.baseurl + sap_opt.sapset # URL + headers = {'Content-type': 'application/json;charset=utf-8', 'X-CSRF-TOKEN': token} # auth = (sap_opt.user, sap_opt.passwd) # auth data =json.dumps({"d":{ "Mandt": sap_opt.mandt, "Lgort": Gates.objects.get(id=data.get('gates')).wh, "Vbeln":data.get('delivery'), "Mark": data.get('mark'), "Matnr": "", "Posnr": "", "Mbl": "", "InbDicid":"AAAAAAAAAAAAAAAAAAAAAA==", "DocExt": data.get('ttn'), "Exidv": data.get('pack') }}) try: r2 = s.post(url, data=data, headers=headers, auth=auth) except: return (False, ' ') if r2.status_code ==201: print(' %s '%(delivery)) return (True, ' %s : '%delivery) else: print(' %s '%(delivery)) text = r2.text SO = soup(text) s = SO.find_all("message")[0].text return (False, s)
Source: https://habr.com/ru/post/426611/
All Articles