edit api
This commit is contained in:
@@ -11,7 +11,7 @@ class BatchLineItem < ApplicationRecord
|
||||
random_account_no = (0...9).map { o[rand(o.length)] }.join
|
||||
|
||||
account_no = super_merchant+account_type+location+random_account_no
|
||||
find_account_no = BatchLineItem.find_by_wristband_code(account_no)
|
||||
find_account_no = BatchLineItem.find_by_asset_identity(account_no)
|
||||
if !find_account_no.nil?
|
||||
o = [('0'..'9')].map { |i| i.to_a }.flatten
|
||||
random_account_no = (0...9).map { o[rand(o.length)] }.join
|
||||
@@ -77,6 +77,27 @@ class BatchLineItem < ApplicationRecord
|
||||
|
||||
return encrypted
|
||||
end
|
||||
def self.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
||||
batchLineItem=BatchLineItem.new
|
||||
batchLineItem.asset_identity=asset_identity
|
||||
batchLineItem.serial_no=serial_no
|
||||
batchLineItem.batch_id=batch_id
|
||||
batchLineItem.manufacture_uid = manufacture_uid
|
||||
batchLineItem.asset_type = card_type
|
||||
batchLineItem.encoded_at = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
|
||||
batchLineItem.verified_at =DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
|
||||
|
||||
if batchLineItem.save
|
||||
lookup=Lookup.find_by_name('generate_serial_no')
|
||||
max_serail_no=lookup.max_value
|
||||
lookup.max_value=max_serail_no.to_i+1
|
||||
lookup.save
|
||||
|
||||
@result = true,batchLineItem.serial_no,batchLineItem.asset_identity
|
||||
else
|
||||
@result=false,'Error occurs in registration encoder!'
|
||||
end
|
||||
end
|
||||
|
||||
# def self.encrypted(data,encrypt_key)
|
||||
# crypt = ActiveSupport::MessageEncryptor.new(encrypt_key)
|
||||
|
||||
Reference in New Issue
Block a user