🐎 ci(以涛的提交的版本来做ci测试):
This commit is contained in:
parent
9456000582
commit
7189cb3ca1
@ -123,16 +123,15 @@ class SetWipOutput
|
||||
}
|
||||
$subbatch = $ret['subbatch'];
|
||||
// 拿到工序编码
|
||||
$ret_process = json_decode($ret['process'], true);
|
||||
// 拿到工序编码
|
||||
foreach ($ret_process as $key => $val) {
|
||||
foreach (json_decode($ret['process'], true) as $key => $val) {
|
||||
if ($val[4] == $workingsubclass) {
|
||||
if (isset($ret_process[$key + 1])) {
|
||||
$next_process_code = $ret_process[$key + 1][2];
|
||||
if (isset($process[$key + 1])) {
|
||||
$next_process_code = $process[$key + 1][2];
|
||||
}
|
||||
$process_code = $val[2];
|
||||
}
|
||||
}
|
||||
|
||||
//4.通过以上关联信息查询物料编码
|
||||
$sql = "SELECT a.flow_id,e.code as bom_source_code,e.name as bom_source_name,d.bom_source_id,d.bom_id,f.code as bom_source_category_code FROM hf_mes_production_planning_management_batch a
|
||||
INNER JOIN hf_mes_technology_flow b ON a.flow_id = b.id
|
||||
@ -322,25 +321,24 @@ class SetWipOutput
|
||||
$uuid = json_encode(array_unique($uuid));
|
||||
}
|
||||
//保证每个正向追溯的uuid都是唯一的
|
||||
$forward_tracing_uuid = json_encode(array_unique(array_merge($forward_tracing_uuid, [generateUniqueId()])));
|
||||
|
||||
$forward_tracing_uuid_only[] = generateUniqueId();
|
||||
$forward_tracing_uuid_only = json_encode($forward_tracing_uuid_only);
|
||||
$decoded_uuid = json_decode($forward_tracing_uuid_only, true);
|
||||
if (is_array($decoded_uuid)) {
|
||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded_uuid);
|
||||
}
|
||||
$forward_tracing_uuid = json_encode(array_unique($forward_tracing_uuid));
|
||||
$wip_uuid = count($wip_uuid) <= 0 ? $uuid : json_encode(array_values(array_unique($wip_uuid)));
|
||||
$now_date = date('Y-m-d H:i:s');
|
||||
$start_time = $last_time; //isset($param_out['START_TIME'])? $param_out['START_TIME'] : date('Y-m-d H:i:s');
|
||||
$finish_time = isset($param_out['FINISH_TIME']) ? $param_out['FINISH_TIME'] : date('Y-m-d H:i:s');
|
||||
$lot = strtotime($now_date);
|
||||
$wip_msg = generate_material_item_id_wip($workingsubclass, $device_code, $batch, $cut_list);
|
||||
$wip_msg = generate_material_item_id_wip($workingsubclass, $device_code, $batch, $cut_list, $gun_count, $roller_press_batch);
|
||||
if (!$wip_msg[0]) {
|
||||
throw new Exception("获取物料批次条码失败!" . $wip_msg[1]);
|
||||
} else {
|
||||
$battery_id = $wip_msg[1];
|
||||
}
|
||||
//判断物料批次条码是否已经存在于生产批次中如果存在则提示失败
|
||||
$sql = 'SELECT id FROM "hf_mes_tmp_bkv_' . $subbatch . '" WHERE battery_id = \'' . $wip_msg[1] . '\' AND active = 1';
|
||||
$ret = Db::fetch($sql);
|
||||
if (!empty($ret)) {
|
||||
throw new Exception("产出批次【$wip_msg[1]】已经激活了,不要重复产出!");
|
||||
}
|
||||
// 新增数据到process_log表
|
||||
//返回需要使用的数据
|
||||
$data_list = array_merge($data_list, [$battery_id, $bom_relationship_array['bom_source_code'], $bom_relationship_array['bom_source_name'], $batch, $device_code]);
|
||||
@ -403,15 +401,14 @@ class SetWipOutput
|
||||
}
|
||||
|
||||
// 新增数据到bkv表
|
||||
$wip_bkv_sql_head = 'INSERT INTO "hf_mes_tmp_bkv_' . $subbatch . '" (battery_id, tray, lot, active, process_code, next_process_code, item_code, item_name, item_batch, item_quantity, item_batch_start_time, pid, uuid, bom_source_id, bom_id, ' . implode(',', $sql_key_out_result_param) . ') VALUES ';
|
||||
$wip_bkv_sql_head = 'INSERT INTO "hf_mes_tmp_bkv_' . $subbatch . '" (battery_id, tray, lot, active, process_code, item_code, item_name, item_batch, item_quantity, item_batch_start_time, pid, uuid, bom_source_id, bom_id, ' . implode(',', $sql_key_out_result_param) . ') VALUES ';
|
||||
$wip_bkv_sql_val = sprintf(
|
||||
"('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',%s)",
|
||||
"('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s',%s)",
|
||||
$battery_id,
|
||||
'-1',
|
||||
$lot,
|
||||
1,
|
||||
$process_code,
|
||||
$next_process_code,
|
||||
$bom_relationship_array['bom_source_code'],
|
||||
$bom_relationship_array['bom_source_name'],
|
||||
$battery_id,
|
||||
|
@ -122,11 +122,15 @@ class SetWipOutputByItemId
|
||||
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_code . ']找不到对应投入物料生产批次信息');
|
||||
}
|
||||
$item_code_in_process_log = array_column($ret, "item_code");
|
||||
|
||||
//获取原材料的正向追溯的uuid
|
||||
$forward_tracing_uuid = array_unique(array_merge(...array_map(function ($json) {
|
||||
return is_array($decoded = json_decode($json, true)) ? $decoded : [];
|
||||
}, array_column($ret, "forward_tracing_uuid"))));
|
||||
//获取正向追溯的uuid
|
||||
$forward_tracing_uuid_in_process_log = array_column($ret, "forward_tracing_uuid");
|
||||
$forward_tracing_uuid = [];
|
||||
foreach ($forward_tracing_uuid_in_process_log as $json_str) {
|
||||
$decoded = json_decode($json_str, true); // 转成数组
|
||||
if (is_array($decoded)) {
|
||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded);
|
||||
}
|
||||
}
|
||||
|
||||
$batch = $ret[0]['batch'];
|
||||
|
||||
@ -223,14 +227,16 @@ class SetWipOutputByItemId
|
||||
} else {
|
||||
$sql_val_out_result_param[] = "'" . $param_out_val . "'";
|
||||
}
|
||||
$ng_code_val = 0;
|
||||
|
||||
// 判断NG是否存在
|
||||
if ($val['code'] == 'NG') {
|
||||
if ($param_out[$val['code']] != '') {
|
||||
$ng_code = $param_out[$val['code']];
|
||||
} else {
|
||||
$ng_code = 0;
|
||||
}
|
||||
}
|
||||
$ng_code = $ng_code_val;
|
||||
|
||||
}
|
||||
|
||||
// 8.获取设备投入物料信息,为后续追加battery_map、bkv表做准备
|
||||
@ -345,17 +351,15 @@ class SetWipOutputByItemId
|
||||
} else {
|
||||
$uuid = json_encode(array_values(array_unique($uuid)));
|
||||
}
|
||||
//需要读取input_item_id的$forward_tracing_uuid进行拼接
|
||||
$sql = "SELECT forward_tracing_uuid FROM hf_mes_bkv_batch_process_log WHERE item_id = '" . $input_item_id . "' ORDER BY id DESC LIMIT 1";
|
||||
$input_item_id_forward_tracing_uuid = Db::fetchAll($sql);
|
||||
if (!empty($input_item_id_forward_tracing_uuid)) {
|
||||
$forward_tracing_uuid = array_unique(array_merge($forward_tracing_uuid, json_decode($input_item_id_forward_tracing_uuid[0]['forward_tracing_uuid'], true)));
|
||||
//保证每个正向追溯的uuid都是唯一的
|
||||
$forward_tracing_uuid_only[] = generateUniqueId();
|
||||
$forward_tracing_uuid_only = json_encode($forward_tracing_uuid_only);
|
||||
$decoded_uuid = json_decode($forward_tracing_uuid_only, true);
|
||||
if (is_array($decoded_uuid)) {
|
||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded_uuid);
|
||||
}
|
||||
if ($input_item_id != $item_id) {
|
||||
//保证每个正向追溯的uuid都是唯一的
|
||||
$forward_tracing_uuid = array_unique(array_merge($forward_tracing_uuid, [generateUniqueId()]));
|
||||
}
|
||||
$forward_tracing_uuid = json_encode($forward_tracing_uuid);
|
||||
$forward_tracing_uuid = json_encode(array_unique($forward_tracing_uuid));
|
||||
|
||||
$wip_uuid = json_encode(array_values(array_unique($wip_uuid)));
|
||||
$now_date = date('Y-m-d H:i:s');
|
||||
$start_time = isset($param_out['START_TIME']) ? $param_out['START_TIME'] : date('Y-m-d H:i:s');
|
||||
@ -364,9 +368,9 @@ class SetWipOutputByItemId
|
||||
$battery_id = $item_id;
|
||||
|
||||
// 新增数据到process_log表
|
||||
$wip_process_log_sql_head = 'INSERT INTO "hf_mes_bkv_batch_process_log" (item_id, batch, subbatch, workingsubclass, process_code, device_code, status, start_time, finish_time, bom_source_id, item_batch, item_quantity, pid, uuid, bom_id, item_code, item_name, lot, tray, ng_code, device_category_id,last_status,forward_tracing_uuid,input_finish_time) VALUES';
|
||||
$wip_process_log_sql_head = 'INSERT INTO "hf_mes_bkv_batch_process_log" (item_id, batch, subbatch, workingsubclass, process_code, device_code, status, start_time, finish_time, bom_source_id, item_batch, item_quantity, pid, uuid, bom_id, item_code, item_name, lot, tray, ng_code, device_category_id,last_status,forward_tracing_uuid) VALUES';
|
||||
$wip_process_log_sql_val = sprintf(
|
||||
"('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
"('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
$battery_id,
|
||||
$batch,
|
||||
$subbatch,
|
||||
@ -389,8 +393,7 @@ class SetWipOutputByItemId
|
||||
$ng_code,
|
||||
$device_category_id,
|
||||
1,
|
||||
$forward_tracing_uuid,
|
||||
$finish_time
|
||||
$forward_tracing_uuid
|
||||
);
|
||||
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
|
||||
$row = Db::query($sql);
|
||||
|
@ -15,30 +15,30 @@ class SetWipOutputByItemIds
|
||||
}
|
||||
|
||||
/*
|
||||
制片段、装配段设备半成品产出出现以下场景:
|
||||
一、1个生产批次下物料投入 => 产出当前生产批次半成品
|
||||
例子:正极制片段物料 => 正极制片段半成品(生产批次用物料投入生产批次)
|
||||
制片段、装配段设备半成品产出出现以下场景:
|
||||
一、1个生产批次下物料投入 => 产出当前生产批次半成品
|
||||
例子:正极制片段物料 => 正极制片段半成品(生产批次用物料投入生产批次)
|
||||
|
||||
二、2个以上生产批次下物料投入 => 产出新生产批次半成品
|
||||
例子:正极制片物料半成品 + 负极制片物料半成品 + 原材料 => 装配段半成品(用上传批次作为生产批次)
|
||||
二、2个以上生产批次下物料投入 => 产出新生产批次半成品
|
||||
例子:正极制片物料半成品 + 负极制片物料半成品 + 原材料 => 装配段半成品(用上传批次作为生产批次)
|
||||
|
||||
接口api示例
|
||||
{
|
||||
"action": "do_set_wip_output_by_item_ids",
|
||||
"param": {
|
||||
"batch": "", #当batch不为空,代表装配段第一个工序,把正极制片段、负极制片段投入物料合并到装配段上;当batch为空时,代表正极制片段、负极制片段工序,batch以投入物料batch为准
|
||||
"workingsubclass": "ZJ", # 工序单元
|
||||
"device_code": "FJZJ-1", # 设备编码
|
||||
"item_ids":[], # 裸电芯条码
|
||||
"input_item_ids":[], # 上料裸电芯条码
|
||||
"out": [{
|
||||
"START_TIME":"tongbo", # 开始时间
|
||||
"FINISH_TIME": "fengezi-1", # 结束时间
|
||||
"DEVICE_CODE": "fengezi-1" # 设备编码
|
||||
}]
|
||||
}
|
||||
}
|
||||
*/
|
||||
接口api示例
|
||||
{
|
||||
"action": "do_set_wip_output_by_item_ids",
|
||||
"param": {
|
||||
"batch": "", #当batch不为空,代表装配段第一个工序,把正极制片段、负极制片段投入物料合并到装配段上;当batch为空时,代表正极制片段、负极制片段工序,batch以投入物料batch为准
|
||||
"workingsubclass": "ZJ", # 工序单元
|
||||
"device_code": "FJZJ-1", # 设备编码
|
||||
"item_ids":[], # 裸电芯条码
|
||||
"input_item_ids":[], # 上料裸电芯条码
|
||||
"out": [{
|
||||
"START_TIME":"tongbo", # 开始时间
|
||||
"FINISH_TIME": "fengezi-1", # 结束时间
|
||||
"DEVICE_CODE": "fengezi-1" # 设备编码
|
||||
}]
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* 通过batch->flow->model->bom->workingsubclass->BomRelationship对应的bom结构
|
||||
@ -79,6 +79,9 @@ class SetWipOutputByItemIds
|
||||
if (empty($param["out"])) {
|
||||
throw new Exception("缺少out参数");
|
||||
}
|
||||
if (empty($param["out"])) {
|
||||
throw new Exception("缺少out参数");
|
||||
}
|
||||
|
||||
$batch = "";
|
||||
$workingsubclass = $param["workingsubclass"];
|
||||
@ -135,10 +138,10 @@ class SetWipOutputByItemIds
|
||||
//查询对应的批次表看是否存在激活状态
|
||||
$subbatch = $item_id_ret['subbatch'];
|
||||
$batch = $item_id_ret['batch'];
|
||||
$sql = "SELECT id FROM \"hf_mes_tmp_bkv_" . $subbatch . "\" WHERE active = 1 AND battery_id='{$item_ids[$i]}' ";
|
||||
$sql = "SELECT id FROM \"hf_mes_tmp_bkv_" . $subbatch . "\" WHERE active = 1 AND battery_id='{$item_id}' ";
|
||||
$item_id_info = Db::fetch($sql);
|
||||
if ($item_id_info) {
|
||||
throw new Exception('电芯码[' . $item_ids[$i] . ']已存在[' . $batch . ']批次', 4001);
|
||||
throw new Exception('电芯码[' . $item_id . ']已存在[' . $batch . ']批次', 4001);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,11 +155,15 @@ class SetWipOutputByItemIds
|
||||
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_code . ']找不到对应投入物料生产批次信息');
|
||||
}
|
||||
$item_code_in_process_log = array_column($ret, "item_code");
|
||||
|
||||
//获取原材料的正向追溯的uuid固定值不变
|
||||
$forward_tracing_uuid_fixed = array_unique(array_merge(...array_map(function ($json) {
|
||||
return is_array($decoded = json_decode($json, true)) ? $decoded : [];
|
||||
}, array_column($ret, "forward_tracing_uuid"))));
|
||||
//获取正向追溯的uuid
|
||||
$forward_tracing_uuid_in_process_log = array_column($ret, "forward_tracing_uuid");
|
||||
$forward_tracing_uuid = [];
|
||||
foreach ($forward_tracing_uuid_in_process_log as $json_str) {
|
||||
$decoded = json_decode($json_str, true); // 转成数组
|
||||
if (is_array($decoded)) {
|
||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded);
|
||||
}
|
||||
}
|
||||
|
||||
$batch = $ret[0]['batch'];
|
||||
|
||||
@ -259,14 +266,15 @@ class SetWipOutputByItemIds
|
||||
} else {
|
||||
$sql_val_out_result_param[$i][] = "'" . $param_out_val . "'";
|
||||
}
|
||||
$ng_code_val = 0;
|
||||
|
||||
// 判断NG是否存在
|
||||
if ($val['code'] == 'NG') {
|
||||
if ($param_out[$i][$val['code']] != '') {
|
||||
$ng_code_val = $param_out[$i][$val['code']];
|
||||
$ng_code[] = $param_out[$i][$val['code']];
|
||||
} else {
|
||||
$ng_code[] = 0;
|
||||
}
|
||||
}
|
||||
$ng_code[] = $ng_code_val;
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,7 +374,7 @@ class SetWipOutputByItemIds
|
||||
|
||||
Db::beginTrans();
|
||||
try {
|
||||
for ($i = 0; $i < count(value: $item_ids); $i++) {
|
||||
for ($i = 0; $i < count($item_ids); $i++) {
|
||||
// 标记最后一条数据的状态
|
||||
if (!empty($pid[$i])) {
|
||||
Event::emit('SetProcessLogEvent.updateLastStatus', $pid[$i]);
|
||||
@ -397,25 +405,14 @@ class SetWipOutputByItemIds
|
||||
} else {
|
||||
$uuid[$i] = json_encode(array_values(array_unique($uuid[$i])));
|
||||
}
|
||||
|
||||
$forward_tracing_uuid = $forward_tracing_uuid_fixed;
|
||||
// 检查 $input_item_ids 是否非空 且当前索引存在
|
||||
if (count($input_item_ids) > 0) {
|
||||
//需要读取input_item_id的$forward_tracing_uuid进行拼接
|
||||
$sql = "SELECT forward_tracing_uuid FROM hf_mes_bkv_batch_process_log WHERE item_id = '" . $input_item_ids[$i] . "' ORDER BY id DESC LIMIT 1";
|
||||
$input_item_id_forward_tracing_uuid = Db::fetchAll($sql);
|
||||
if (!empty($input_item_id_forward_tracing_uuid)) {
|
||||
$forward_tracing_uuid = array_unique(array_merge($forward_tracing_uuid, json_decode($input_item_id_forward_tracing_uuid[0]['forward_tracing_uuid'], true)));
|
||||
}
|
||||
if ($input_item_ids[$i] != $item_ids[$i]) {
|
||||
//保证每个正向追溯的uuid都是唯一的
|
||||
$forward_tracing_uuid = array_unique(array_merge($forward_tracing_uuid, [generateUniqueId()]));
|
||||
}
|
||||
} else {
|
||||
$forward_tracing_uuid = array_unique(array_merge($forward_tracing_uuid, [generateUniqueId()]));
|
||||
//保证每个正向追溯的uuid都是唯一的
|
||||
$forward_tracing_uuid_only[] = generateUniqueId();
|
||||
$forward_tracing_uuid_only = json_encode($forward_tracing_uuid_only);
|
||||
$decoded_uuid = json_decode($forward_tracing_uuid_only, true);
|
||||
if (is_array($decoded_uuid)) {
|
||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded_uuid);
|
||||
}
|
||||
$forward_tracing_uuid = json_encode($forward_tracing_uuid);
|
||||
|
||||
$forward_tracing_uuid = json_encode(array_unique($forward_tracing_uuid));
|
||||
$wip_uuid[$i] = json_encode(array_values(array_unique($wip_uuid[$i])));
|
||||
|
||||
$now_date = date('Y-m-d H:i:s');
|
||||
@ -426,9 +423,9 @@ class SetWipOutputByItemIds
|
||||
$battery_id = $item_ids[$i];
|
||||
|
||||
// 新增数据到process_log表
|
||||
$wip_process_log_sql_head = 'INSERT INTO "hf_mes_bkv_batch_process_log" (item_id, batch, subbatch, workingsubclass, process_code, device_code, status, start_time, finish_time, bom_source_id, item_batch, item_quantity, pid, uuid, bom_id, item_code, item_name, lot, tray, ng_code, device_category_id,last_status,forward_tracing_uuid,input_finish_time) VALUES';
|
||||
$wip_process_log_sql_head = 'INSERT INTO "hf_mes_bkv_batch_process_log" (item_id, batch, subbatch, workingsubclass, process_code, device_code, status, start_time, finish_time, bom_source_id, item_batch, item_quantity, pid, uuid, bom_id, item_code, item_name, lot, tray, ng_code, device_category_id,last_status,forward_tracing_uuid) VALUES';
|
||||
$wip_process_log_sql_val = sprintf(
|
||||
"('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
"('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
|
||||
$battery_id,
|
||||
$batch,
|
||||
$subbatch,
|
||||
@ -451,14 +448,14 @@ class SetWipOutputByItemIds
|
||||
$ng_code[$i],
|
||||
$device_category_id,
|
||||
1,
|
||||
$forward_tracing_uuid,
|
||||
$finish_time
|
||||
$forward_tracing_uuid
|
||||
);
|
||||
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
|
||||
$row = Db::query($sql);
|
||||
if ($row === NULL) {
|
||||
throw new Exception('电芯 ' . $item_id . ' 半成品信息插入process_log表失败');
|
||||
}
|
||||
|
||||
// 新增数据到battery_map表
|
||||
$battery_unique_value = "{$batch}_{$subbatch}_-1_{$lot}_{$battery_id}";
|
||||
$wip_battery_map_sql_head = 'INSERT INTO "hf_mes_production_battery_map" (bom_source_id, battery_unique_value, battery_id, batch, subbatch, lot, tray, item_batch, pid, uuid, bom_id, workingsubclass, item_code,item_name) VALUES ';
|
||||
|
Loading…
x
Reference in New Issue
Block a user