Files
storage_fresco/IPKT.py

166 lines
5.5 KiB
Python

#l!/usr/bin/env python2.6
#-*- coding: utf-8 -*-
__author__ = "Michael Rest"
__date__ = "1 August 2010"
__email__ = "michi@rosstein.de"
__version__ = "$Revision: 1.0 $"[11:-2]
class IPKT:
def ipkt (self, values):
ipoint_id = values ['location']
boxnr = values ['box_nr']
try:
boxnr = int (boxnr)
except:
self.log ( "At IPKT: Bad Box Nr reset to 0")
boxnr = 0
gtin = values ['gtin']
article = values ['article']
duedate = values ['duedate']
pieces = values ['pieces']
try:
pieces = int (pieces)
except:
self.log ( "At IPKT: Bad Pieces '%s' reset to 0 " % pieces)
pieces = 0
destination = values ['destination']
try:
destination = int (destination)
except:
self.log ( "At IPKT: Bad Destination reset to 99")
destination = 99
lotnr = values ['lotnr']
try:
int (lotnr)
except:
lotnr = '0'
lotnr2 = values ['lotnr2']
# IPKT Telegram --> check data and rem. place in Storage and res in Iqueue
DB_con = self.connections['DB']
if ipoint_id not in self.transportmatrix['dstbysrc']:
self.log ( "At IPKT: Not Transports in Matrix for IPKT %s" % ipoint_id)
if not boxnr:
self.message (6, ' At IPKT bad Boxnr')
return 98 # Bad BoxNr
_state = 0
boxes = DB_con.searchbox (boxnr)
storage = 'NONE'
if not _state and boxes:
self.message (6, ' At IPKT Box is already in Storage further checks')
for _rid, _rboxnr, _rarticle, _rlotnr, _rlotnr2, _duedate, _rpieces, _rx, _ry, _rz, _rrfzts in boxes:
if _rrfzts:
#Already Inserted
_state = 94 #Already exists
self.log ( "At IPKT: box %s already inserted in Storage %s" % (boxnr, _rid))
self.message (6, " At IPKT Box %s is already inserted in %s X:%d, Y:%d, Z:%d with article %s" \
% (_rboxnr, _rid, _rx, _ry, _rz, _rarticle))
else:
#Just reserved
if len (boxes) == 1:
self.message (6, " At IPKT Box is only reserved (one time) in %s" % _rid)
DB_con.deletetransport (ipoint_id, boxnr)
#DB_con.removebox (_boxnr)
DB_con.deletealltransports (boxnr)
DB_con.deleteincomingbox (boxnr)
DB_con.removebox (_rid , boxnr)
if DB_con.getincomingbox (boxnr):
self.message (6, " At IPKT Box %s is already in Inqueue delete first" % boxnr)
DB_con.deleteincomingbox (boxnr)
if not _state:
#Box not existing - Reserve Box
self.log ( "At IPKT: box %s not inserted try to find a Place" % boxnr)
DB_con.deletealltransports (boxnr)
#Get Article information
if article not in self.articlemaster and not _state:
self.message (5,' IPKT Article not in Articlebase')
if self.parameter.get ('articlemustbedefined', 1):
_state = 91 #Article not existent
else:
_anr = article
_cap = 'undefined',
_gtin = ''
_normam = 0
_minam = 0
_zone = 1
else:
_cap, _gtin, _normam, _minam, _zone, _dest = self.articlemaster[article]
#Disabled
#_state = 93 #Younger Lots in Storage
#_dest 0 == T001, 1 = S00x
_deststorage = ''
if not _state:
#All Ok till now so check the weight
self.message (5,' IPKT Check Pieces')
if not pieces:
_state = 90 #90 Bad weight
elif (pieces >= _normam): #Assume Full Pallet
self.message (5,' IPKT Check Pieces Ok - Full Pallet')
#Full Pallet into T001
if ipoint_id in ['I001', 'I002']:
if _dest == 0:
self.message (5,' IPKT Check Pieces Ok - Full Pallet also for T001 in Articlemaster')
_deststorage = 'T001'
elif _dest == 1:
self.message (5,' IPKT Check Pieces Ok - Full Pallet For S001 in Articlemaster')
_deststorage = 'S001'
else:
_deststorage = 'S002'
#disabled Min Amount #elif pieces >= _minam:
else:
self.message (5,' IPKT Check Pieces Ok - Rest Pallet')
#Full Pallet into S001
if destination != 1:
self.message (5,' IPKT Check Pieces Rest Pallet not for T001')
_state = 90 #90 Bad weight
else:
if ipoint_id in ['I001', 'I002']:
_deststorage = 'S001'
else:
_deststorage = 'S002'
if not _state:
#default article try to find a Place
self.message (5,' IPKT Reserve Place Article at %s' %_deststorage)
_res = None
for storage, rfzNr, rfzOut, mode, prio in self.transportmatrix['dstbysrc'][ipoint_id]:
#Normal article
if (storage == _deststorage):
self.message (6, " At IPKT: check possible Transport for Std Article to %s by RFZ %s with prio %s" % (storage, rfzNr, prio))
_res = self.boxreserve ('RFZ%s' % rfzNr, ipoint_id, 0, 0, 0, \
boxnr, article, lotnr, lotnr2, duedate, pieces, storage, _zone, noreserve = 1)
if not _res:
_state = 92 #No Place
if not _state:
DB_con.addincomingbox (ipoint_id, boxnr, article, gtin, lotnr, lotnr2, duedate, pieces, _deststorage, destination)
self.message (6, " At IPKT: Create Transport with State %s" % (_state))
DB_con.createtransport (boxnr, ipoint_id, ipoint_id, 0, 0, 0, storage, destination, 0, _state)
self.generatetransport (ipoint_id, boxnr)
#DB_con.deletetransport ('IPKT', int (boxnr))
return _state