def op60(op50): op60_data = {} std = 0.0025 product_key = op50[0] op60_process_time = op50[4] op60_l = op50[1] op60_data['op60_l'] = op60_l op60_w = op50[2] op60_data['op60_w'] = op60_w op60_h = op50[3] op60_data['op60_h'] = op60_h op60_data['op60_process_time'] = op60_process_time if (op60_l < 259.99) or (op60_l > 260.01): length_test = 1 else: length_test = 0 if (op60_w < 179.99) or (op60_w > 180.01): width_test = 1 else: width_test = 0 if (op60_h < 59.99) or (op60_h > 60.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: op60_test = 'OK' op60_data['op60_test'] = op60_test else: op60_test = 'NOK' op60_data['op60_test'] = op60_test now = op50[5] time_stamp = now + timedelta(seconds=10) op60_data['op60_time_stamp'] = time_stamp time_stamp = str(time_stamp) product_key = time_stamp + product_key op60_data['product_key'] = product_key # product_history 적재 product_history_data_list = [] product_history_insert = {} op60_master_data = product_master.EGRC(1) product_code = op60_master_data['product_code'] product_history_insert['product_key'] = product_key product_history_insert['product_code'] = product_code product_history_insert['product_timestamp'] = time_stamp product_history_data_list.append(product_history_insert) MySQL_query.insert_product_history( product_history_data_list) # 히스토리 데이터 DB 적재 # product_quality 적재 product_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 product_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 product_quality_insert['product_key'] = product_key product_quality_insert['product_size_l'] = str(op60_l) product_quality_insert['product_size_w'] = str(op60_w) product_quality_insert['product_size_h'] = str(op60_h) product_quality_insert['product_test'] = str(op60_test) product_quality_insert['product_test_timestamp'] = str(time_stamp) product_quality_data_list.append(product_quality_insert) MySQL_query.insert_product_quality( product_quality_data_list) # 품질 데이터 DB 적재 # machine 적재 machine_data_list = [] # 딕셔너리 데이터 저장할 리스트 machine_data_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 machine_master_data = machine_master.op60(1) # machine_code 가져오기 machine_code = machine_master_data['machine_code'] machine_data_insert['machine_code'] = machine_code machine_data_insert['product_key'] = product_key machine_data_insert['start_time'] = str(now) machine_data_insert['end_time'] = str(time_stamp) machine_data_insert['makespan'] = '123' machine_data_insert['process_time'] = str(op60_process_time) machine_data_insert['machine_data'] = str(131.1) machine_data_insert['machine_data_code'] = 'TEST' machine_data_list.append(machine_data_insert) MySQL_query.insert_machine(machine_data_list) # machine 데이터 DB 적재 return op60_data
def op50(op40): op50_data = {} std = 0.0025 product_key = op40[0] flange2_l = np.random.normal(30, std) flange2_l = round(flange2_l, 5) flange2_w = np.random.normal(80, std) flange2_w = round(flange2_w, 5) flange2_h = np.random.normal(40, std) flange2_h = round(flange2_h, 5) op50_process_time = op40[4] op50_temperature = np.random.uniform(489.75, 510.25) op50_temperature = round(op50_temperature, 5) op50_data['flange2_l'] = flange2_l op50_data['flange2_w'] = flange2_w op50_data['flange2_h'] = flange2_h if 490 < op50_temperature < 510: op50_l = op40[1] + flange2_l op50_l = round(op50_l, 5) else: op50_l = op40[1] + flange2_l - 1 op50_data['op50_l'] = op50_l op50_w = op40[2] op50_data['op50_w'] = op50_w op50_h = op40[3] op50_data['op50_h'] = op50_h op50_data['op50_temperature'] = op50_temperature op50_data['op50_process_time'] = op50_process_time if (op50_l < 259.99) or (op50_l > 260.01): length_test = 1 else: length_test = 0 if (op50_w < 179.99) or (op50_w > 180.01): width_test = 1 else: width_test = 0 if (op50_h < 59.99) or (op50_h > 60.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: op50_test = 'OK' op50_data['op50_test'] = op50_test else: op50_test = 'NOK' op50_data['op50_test'] = op50_test # 부품 테스트 if (flange2_l < 29.99) or (flange2_l > 30.01): length_test = 1 else: length_test = 0 if (flange2_w < 79.99) or (flange2_w > 80.01): width_test = 1 else: width_test = 0 if (flange2_h < 39.99) or (flange2_h > 40.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: flange2_test = 'OK' else: flange2_test = 'NOK' now = op40[5] time_stamp = now + timedelta(seconds=10) op50_data['op50_time_stamp'] = time_stamp time_stamp = str(time_stamp) product_key = time_stamp + product_key op50_data['product_key'] = product_key # product_history 적재 product_history_data_list = [] product_history_insert = {} op50_master_data = product_master.op50_WIP(1) product_code = op50_master_data['product_code'] product_history_insert['product_key'] = product_key product_history_insert['product_code'] = product_code product_history_insert['product_timestamp'] = time_stamp product_history_data_list.append(product_history_insert) MySQL_query.insert_product_history( product_history_data_list) # 히스토리 데이터 DB 적재 # 부품 데이터 모아서 적재 (flange2) part_data_list = [] part_history_insert = {} part_history_insert['product_key'] = time_stamp + '-flange2' part_history_insert['product_code'] = 'flange2' part_history_insert['product_timestamp'] = time_stamp part_data_list.append(part_history_insert) MySQL_query.insert_product_history(part_data_list) # 히스토리 데이터 DB 적재 # product_quality 적재 product_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 product_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 product_quality_insert['product_key'] = product_key product_quality_insert['product_size_l'] = str(op50_l) product_quality_insert['product_size_w'] = str(op50_w) product_quality_insert['product_size_h'] = str(op50_h) product_quality_insert['product_test'] = str(op50_test) product_quality_insert['product_test_timestamp'] = str(time_stamp) product_quality_data_list.append(product_quality_insert) MySQL_query.insert_product_quality( product_quality_data_list) # 품질 데이터 DB 적재 # product_quality 적재 product_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 product_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 product_quality_insert['product_key'] = time_stamp + '-flange2' product_quality_insert['product_size_l'] = str(flange2_l) product_quality_insert['product_size_w'] = str(flange2_w) product_quality_insert['product_size_h'] = str(flange2_h) product_quality_insert['product_test'] = str(flange2_test) product_quality_insert['product_test_timestamp'] = str(time_stamp) product_quality_data_list.append(product_quality_insert) MySQL_query.insert_product_quality( product_quality_data_list) # 품질 데이터 DB 적재 # machine 적재 machine_data_list = [] # 딕셔너리 데이터 저장할 리스트 machine_data_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 machine_master_data = machine_master.op50(1) # machine_code 가져오기 machine_code = machine_master_data['machine_code'] machine_data_insert['machine_code'] = machine_code machine_data_insert['product_key'] = product_key machine_data_insert['start_time'] = str(now) machine_data_insert['end_time'] = str(time_stamp) machine_data_insert['makespan'] = '123' machine_data_insert['process_time'] = str(op50_process_time) machine_data_insert['machine_data'] = str(op50_temperature) machine_data_insert['machine_data_code'] = 'T01' machine_data_list.append(machine_data_insert) MySQL_query.insert_machine(machine_data_list) # machine 데이터 DB 적재 return op50_data
def op10(body): op10_data = {} std = 0.0025 # 표준편차 product_key = body[0] # 값 리스트 받을 때 첫번째 요소 wavyfin_l = np.random.normal(100, std) wavyfin_l = round(wavyfin_l, 5) wavyfin_w = np.random.normal(50, std) wavyfin_w = round(wavyfin_w, 5) wavyfin_h = np.random.normal(60, std) wavyfin_h = round(wavyfin_h, 5) op10_electricity = np.random.uniform(89.75, 100) # 균일 분포 / (최소, 최대) op10_electricity = round(op10_electricity, 5) op10_data['body_l'] = body[1] op10_data['body_w'] = body[2] op10_data['body_h'] = body[3] op10_data['wavyfin_l'] = wavyfin_l op10_data['wavyfin_w'] = wavyfin_w op10_data['wavyfin_h'] = wavyfin_h op10_l = body[1] # 값이 안바껴서 그대로 둠 op10_data['op10_l'] = op10_l op10_w = body[2] op10_data['op10_w'] = op10_w op10_h = wavyfin_h op10_data['op10_h'] = op10_h op10_process_time = body[4] op10_data['op10_electricity'] = op10_electricity op10_data['op10_process_time'] = op10_process_time # 재공품 테스트 if (op10_l < 199.99) or (op10_l > 200.01): length_test = 1 else: length_test = 0 if (op10_w < 99.99) or (op10_w > 100.01): width_test = 1 else: width_test = 0 if (op10_h < 59.99) or (op10_h > 60.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: op10_test = 'OK' op10_data['op10_test'] = op10_test else: op10_test = 'NOK' op10_data['op10_test'] = op10_test # 부품 테스트 (body) if (body[1] < 199.99) or (body[1] > 200.01): length_test = 1 else: length_test = 0 if (body[2] < 99.99) or (body[2] > 100.01): width_test = 1 else: width_test = 0 if (body[3] < 49.99) or (body[3] > 50.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: body_test = 'OK' else: body_test = 'NOK' # 부품 테스트 if (wavyfin_l < 99.99) or (wavyfin_l > 100.01): length_test = 1 else: length_test = 0 if (wavyfin_w < 49.99) or (wavyfin_w > 50.01): width_test = 1 else: width_test = 0 if (wavyfin_h < 59.99) or (wavyfin_h > 60.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: wavyfin_test = 'OK' else: wavyfin_test = 'NOK' now = body[5] # 현재 시간 time_stamp = now + timedelta( seconds=10) # 현재 시간에서 가동시간만큼 추가된 시간 / 형식 = datetime op10_data['op10_time_stamp'] = time_stamp # 추가된 시간이 완료되고 나가는 시간 time_stamp = str(time_stamp) # 문자형으로 저장 product_key = time_stamp + product_key # 키는 시간 + 아이템 정보로 저장 op10_data['product_key'] = product_key # product_history 적재 product_history_data_list = [] product_history_insert = {} op10_master_data = product_master.op10_WIP(1) product_code = op10_master_data['product_code'] product_history_insert['product_key'] = product_key product_history_insert['product_code'] = product_code product_history_insert['product_timestamp'] = time_stamp product_history_data_list.append(product_history_insert) MySQL_query.insert_product_history( product_history_data_list) # 히스토리 데이터 DB 적재 # 부품 히스토리 데이터 모아서 적재 (body) part_data_list_body = [] part_history_insert_body = {} part_history_insert_body['product_key'] = time_stamp + '-body' part_history_insert_body['product_code'] = 'body' part_history_insert_body['product_timestamp'] = time_stamp part_data_list_body.append(part_history_insert_body) MySQL_query.insert_product_history( part_data_list_body) # 히스토리 데이터 DB 적재 # 부품 히스토리 데이터 모아서 적재 (wavyfin) part_data_list = [] part_history_insert = {} part_history_insert['product_key'] = time_stamp + '-wavyfin' part_history_insert['product_code'] = 'wavyfin' part_history_insert['product_timestamp'] = time_stamp part_data_list.append(part_history_insert) MySQL_query.insert_product_history(part_data_list) # 히스토리 데이터 DB 적재 # product_quality 적재 product_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 product_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 product_quality_insert['product_key'] = product_key product_quality_insert['product_size_l'] = str(op10_l) product_quality_insert['product_size_w'] = str(op10_w) product_quality_insert['product_size_h'] = str(op10_h) product_quality_insert['product_test'] = str(op10_test) product_quality_insert['product_test_timestamp'] = str(time_stamp) product_quality_data_list.append(product_quality_insert) MySQL_query.insert_product_quality( product_quality_data_list) # 품질 데이터 DB 적재 # 부품 quality 적재 (body) part_quality_data_list_body = [] # 딕셔너리 데이터 저장할 리스트 part_quality_insert_body = {} # DB 저장할 데이터 모아주는 딕셔너리 part_quality_insert_body['product_key'] = time_stamp + '-body' part_quality_insert_body['product_size_l'] = str(body[1]) part_quality_insert_body['product_size_w'] = str(body[2]) part_quality_insert_body['product_size_h'] = str(body[3]) part_quality_insert_body['product_test'] = str(body_test) part_quality_insert_body['product_test_timestamp'] = str(time_stamp) part_quality_data_list_body.append(part_quality_insert_body) MySQL_query.insert_product_quality( part_quality_data_list_body) # 품질 데이터 DB 적재 # 부품 quality 적재 (wavyfin) part_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 part_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 part_quality_insert['product_key'] = time_stamp + '-wavyfin' part_quality_insert['product_size_l'] = str(wavyfin_l) part_quality_insert['product_size_w'] = str(wavyfin_w) part_quality_insert['product_size_h'] = str(wavyfin_h) part_quality_insert['product_test'] = str(wavyfin_test) part_quality_insert['product_test_timestamp'] = str(time_stamp) part_quality_data_list.append(part_quality_insert) MySQL_query.insert_product_quality( part_quality_data_list) # 품질 데이터 DB 적재 # machine 적재 machine_data_list = [] # 딕셔너리 데이터 저장할 리스트 machine_data_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 machine_master_data = machine_master.op10(1) # machine_code 가져오기 machine_code = machine_master_data['machine_code'] machine_data_insert['machine_code'] = machine_code machine_data_insert['product_key'] = product_key machine_data_insert['start_time'] = str(now) machine_data_insert['end_time'] = str(time_stamp) machine_data_insert['makespan'] = '123' machine_data_insert['process_time'] = str(op10_process_time) machine_data_insert['machine_data'] = str(op10_electricity) machine_data_insert['machine_data_code'] = 'E01' machine_data_list.append(machine_data_insert) MySQL_query.insert_machine(machine_data_list) # machine 데이터 DB 적재 return op10_data
def op30(op20): op30_data = {} std = 0.0025 product_key = op20[0] pipe2_l = np.random.normal(30, std) pipe2_l = round(pipe2_l, 5) pipe2_w = np.random.normal(50, std) pipe2_w = round(pipe2_w, 5) pipe2_h = np.random.normal(30, std) pipe2_h = round(pipe2_h, 5) op30_process_time = op20[4] op30_electricity = np.random.uniform(89.5, 100) op30_electricity = round(op30_electricity, 5) op30_data['pipe2_l'] = pipe2_l op30_data['pipe2_w'] = pipe2_w op30_data['pipe2_h'] = pipe2_h if op30_electricity < 90: op30_w = op20[2] + pipe2_w - op30_electricity * 0.11 op30_w = round(op30_w, 5) else: op30_w = op20[2] + pipe2_w - 10 op30_w = round(op30_w, 5) op30_l = op20[1] op30_data['op30_l'] = op20[1] op30_data['op30_w'] = op30_w op30_h = op20[3] op30_data['op30_h'] = op20[3] op30_data['op30_electricity'] = op30_electricity op30_data['op30_process_time'] = op30_process_time if (op30_l < 199.99) or (op30_l > 200.01): length_test = 1 else: length_test = 0 if (op30_w < 179.99) or (op30_w > 180.01): width_test = 1 else: width_test = 0 if (op30_h < 59.99) or (op30_h > 60.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: op30_test = 'OK' op30_data['op30_test'] = op30_test else: op30_test = 'NOK' op30_data['op30_test'] = op30_test # 부품 테스트 if (pipe2_l < 29.99) or (pipe2_l > 30.01): length_test = 1 else: length_test = 0 if (pipe2_w < 49.99) or (pipe2_w > 50.01): width_test = 1 else: width_test = 0 if (pipe2_h < 29.99) or (pipe2_h > 30.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: pipe2_test = 'OK' else: pipe2_test = 'NOK' now = op20[5] time_stamp = now + timedelta(seconds=10) op30_data['op30_time_stamp'] = time_stamp time_stamp = str(time_stamp) product_key = time_stamp + product_key op30_data['product_key'] = product_key # product_history 적재 product_history_data_list = [] product_history_insert = {} op30_master_data = product_master.op30_WIP(1) product_code = op30_master_data['product_code'] product_history_insert['product_key'] = product_key product_history_insert['product_code'] = product_code product_history_insert['product_timestamp'] = time_stamp product_history_data_list.append(product_history_insert) MySQL_query.insert_product_history( product_history_data_list) # 히스토리 데이터 DB 적재 # 부품 데이터 모아서 적재 (pipe2) part_data_list = [] part_history_insert = {} part_history_insert['product_key'] = time_stamp + '-pipe2' part_history_insert['product_code'] = 'pipe2' part_history_insert['product_timestamp'] = time_stamp part_data_list.append(part_history_insert) MySQL_query.insert_product_history(part_data_list) # 히스토리 데이터 DB 적재 # product_quality 적재 product_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 product_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 product_quality_insert['product_key'] = product_key product_quality_insert['product_size_l'] = str(op30_l) product_quality_insert['product_size_w'] = str(op30_w) product_quality_insert['product_size_h'] = str(op30_h) product_quality_insert['product_test'] = str(op30_test) product_quality_insert['product_test_timestamp'] = str(time_stamp) product_quality_data_list.append(product_quality_insert) MySQL_query.insert_product_quality( product_quality_data_list) # 품질 데이터 DB 적재 # 부품 quality 적재 (pipe2) part_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 part_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 part_quality_insert['product_key'] = time_stamp + '-pipe2' part_quality_insert['product_size_l'] = str(pipe2_l) part_quality_insert['product_size_w'] = str(pipe2_w) part_quality_insert['product_size_h'] = str(pipe2_h) part_quality_insert['product_test'] = str(pipe2_test) part_quality_insert['product_test_timestamp'] = str(time_stamp) part_quality_data_list.append(part_quality_insert) MySQL_query.insert_product_quality( part_quality_data_list) # 품질 데이터 DB 적재 # machine 적재 machine_data_list = [] # 딕셔너리 데이터 저장할 리스트 machine_data_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 machine_master_data = machine_master.op30(1) # machine_code 가져오기 machine_code = machine_master_data['machine_code'] machine_data_insert['machine_code'] = machine_code machine_data_insert['product_key'] = product_key machine_data_insert['start_time'] = str(now) machine_data_insert['end_time'] = str(time_stamp) machine_data_insert['makespan'] = '123' machine_data_insert['process_time'] = str(op30_process_time) machine_data_insert['machine_data'] = str(op30_electricity) machine_data_insert['machine_data_code'] = 'E01' machine_data_list.append(machine_data_insert) MySQL_query.insert_machine(machine_data_list) # machine 데이터 DB 적재 return op30_data
def op10(body): op10_data = {} std = 0.0025 product_key = body[0] wavyfin_l = np.random.normal(100, std) wavyfin_l = round(wavyfin_l, 5) wavyfin_w = np.random.normal(50, std) wavyfin_w = round(wavyfin_w, 5) wavyfin_h = np.random.normal(60, std) wavyfin_h = round(wavyfin_h, 5) op10_electricity = np.random.uniform(89, 100) op10_electricity = round(op10_electricity, 5) op10_data['product_key'] = product_key op10_data['body_l'] = body[1] op10_data['body_w'] = body[2] op10_data['body_h'] = body[3] op10_data['wavyfin_l'] = wavyfin_l op10_data['wavyfin_w'] = wavyfin_w op10_data['wavyfin_h'] = wavyfin_h op10_l = body[1] op10_data['op10_l'] = op10_l op10_w = body[2] op10_data['op10_w'] = op10_w op10_h = wavyfin_h op10_data['op10_h'] = op10_h op10_process_time = body[3] op10_data['op10_electricity'] = op10_electricity op10_data['op10_process_time'] = op10_process_time if (op10_l < 199.99) or (op10_l > 200.01): length_test = 1 else: length_test = 0 if (op10_w < 99.99) or (op10_w > 100.01): width_test = 1 else: width_test = 0 if (op10_h < 59.99) or (op10_h > 60.01): height_test = 1 else: height_test = 0 if length_test == 0 and width_test == 0 and height_test == 0: op10_test = 'OK' op10_data['op10_test'] = op10_test else: op10_test = 'NOK' op10_data['op10_test'] = op10_test now = datetime.now() time_stamp = now + timedelta(seconds=op10_process_time) op10_data['op10_time_stamp'] = time_stamp time_stamp = str(time_stamp) product_key = time_stamp + product_key # product_history 적재 product_history_data_list = [] product_history_insert = {} op10_master_data = product_master.op10_WIP(1) product_code = op10_master_data['product_code'] product_history_insert['product_key'] = product_key product_history_insert['product_code'] = product_code product_history_insert['product_timestamp'] = time_stamp product_history_data_list.append(product_history_insert) MySQL_query.insert_product_history(product_history_data_list) # 히스토리 데이터 DB 적재 # product_quality 적재 product_quality_data_list = [] # 딕셔너리 데이터 저장할 리스트 product_quality_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 product_quality_insert['product_key'] = product_key product_quality_insert['product_size_l'] = str(op10_l) product_quality_insert['product_size_w'] = str(op10_w) product_quality_insert['product_size_h'] = str(op10_h) product_quality_insert['product_test'] = str(op10_test) product_quality_insert['product_test_timestamp'] = str(time_stamp) product_quality_data_list.append(product_quality_insert) MySQL_query.insert_product_quality(product_quality_data_list) # 품질 데이터 DB 적재 # machine 적재 machine_data_list = [] # 딕셔너리 데이터 저장할 리스트 machine_data_insert = {} # DB 저장할 데이터 모아주는 딕셔너리 machine_master_data = machine_master.op10(1) # machine_code 가져오기 machine_code = machine_master_data['machine_code'] machine_data_insert['machine_code'] = machine_code machine_data_insert['product_key'] = product_key machine_data_insert['start_time'] = str(now) machine_data_insert['end_time'] = str(time_stamp) machine_data_insert['makespan'] = '123' machine_data_insert['process_time'] = str(op10_process_time) machine_data_insert['machine_data'] = str(op10_electricity) machine_data_insert['machine_data_code'] = 'E01' machine_data_list.append(machine_data_insert) MySQL_query.insert_machine(machine_data_list) # machine 데이터 DB 적재 return op10_data