This commit is contained in:
parent
a7f7fc6f9f
commit
f53c742df0
@ -122,16 +122,12 @@ class SetWipOutputByItemId
|
|||||||
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_code . ']找不到对应投入物料生产批次信息');
|
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_code . ']找不到对应投入物料生产批次信息');
|
||||||
}
|
}
|
||||||
$item_code_in_process_log = array_column($ret, "item_code");
|
$item_code_in_process_log = array_column($ret, "item_code");
|
||||||
//获取正向追溯的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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//获取原材料的正向追溯的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"))));
|
||||||
|
$bb = [sdfdf];
|
||||||
$batch = $ret[0]['batch'];
|
$batch = $ret[0]['batch'];
|
||||||
|
|
||||||
//对比物料信息是否与process_log表的item_code是否相同
|
//对比物料信息是否与process_log表的item_code是否相同
|
||||||
@ -227,16 +223,14 @@ class SetWipOutputByItemId
|
|||||||
} else {
|
} else {
|
||||||
$sql_val_out_result_param[] = "'" . $param_out_val . "'";
|
$sql_val_out_result_param[] = "'" . $param_out_val . "'";
|
||||||
}
|
}
|
||||||
|
$ng_code_val = 0;
|
||||||
// 判断NG是否存在
|
// 判断NG是否存在
|
||||||
if ($val['code'] == 'NG') {
|
if ($val['code'] == 'NG') {
|
||||||
if ($param_out[$val['code']] != '') {
|
if ($param_out[$val['code']] != '') {
|
||||||
$ng_code = $param_out[$val['code']];
|
$ng_code = $param_out[$val['code']];
|
||||||
} else {
|
|
||||||
$ng_code = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ng_code = $ng_code_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8.获取设备投入物料信息,为后续追加battery_map、bkv表做准备
|
// 8.获取设备投入物料信息,为后续追加battery_map、bkv表做准备
|
||||||
@ -351,15 +345,17 @@ class SetWipOutputByItemId
|
|||||||
} else {
|
} else {
|
||||||
$uuid = json_encode(array_values(array_unique($uuid)));
|
$uuid = json_encode(array_values(array_unique($uuid)));
|
||||||
}
|
}
|
||||||
//保证每个正向追溯的uuid都是唯一的
|
//需要读取input_item_id的$forward_tracing_uuid进行拼接
|
||||||
$forward_tracing_uuid_only[] = generateUniqueId();
|
$sql = "SELECT forward_tracing_uuid FROM hf_mes_bkv_batch_process_log WHERE item_id = '" . $input_item_id . "' ORDER BY id DESC LIMIT 1";
|
||||||
$forward_tracing_uuid_only = json_encode($forward_tracing_uuid_only);
|
$input_item_id_forward_tracing_uuid = Db::fetchAll($sql);
|
||||||
$decoded_uuid = json_decode($forward_tracing_uuid_only, true);
|
if (!empty($input_item_id_forward_tracing_uuid)) {
|
||||||
if (is_array($decoded_uuid)) {
|
$forward_tracing_uuid = array_unique(array_merge($forward_tracing_uuid, json_decode($input_item_id_forward_tracing_uuid[0]['forward_tracing_uuid'], true)));
|
||||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded_uuid);
|
|
||||||
}
|
}
|
||||||
$forward_tracing_uuid = json_encode(array_unique($forward_tracing_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);
|
||||||
$wip_uuid = json_encode(array_values(array_unique($wip_uuid)));
|
$wip_uuid = json_encode(array_values(array_unique($wip_uuid)));
|
||||||
$now_date = date('Y-m-d H:i:s');
|
$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');
|
$start_time = isset($param_out['START_TIME']) ? $param_out['START_TIME'] : date('Y-m-d H:i:s');
|
||||||
@ -368,9 +364,9 @@ class SetWipOutputByItemId
|
|||||||
$battery_id = $item_id;
|
$battery_id = $item_id;
|
||||||
|
|
||||||
// 新增数据到process_log表
|
// 新增数据到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) 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,input_finish_time) VALUES';
|
||||||
$wip_process_log_sql_val = sprintf(
|
$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,
|
$battery_id,
|
||||||
$batch,
|
$batch,
|
||||||
$subbatch,
|
$subbatch,
|
||||||
@ -393,7 +389,8 @@ class SetWipOutputByItemId
|
|||||||
$ng_code,
|
$ng_code,
|
||||||
$device_category_id,
|
$device_category_id,
|
||||||
1,
|
1,
|
||||||
$forward_tracing_uuid
|
$forward_tracing_uuid,
|
||||||
|
$finish_time
|
||||||
);
|
);
|
||||||
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
|
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
|
||||||
$row = Db::query($sql);
|
$row = Db::query($sql);
|
||||||
|
@ -15,30 +15,30 @@ class SetWipOutputByItemIds
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
制片段、装配段设备半成品产出出现以下场景:
|
制片段、装配段设备半成品产出出现以下场景:
|
||||||
一、1个生产批次下物料投入 => 产出当前生产批次半成品
|
一、1个生产批次下物料投入 => 产出当前生产批次半成品
|
||||||
例子:正极制片段物料 => 正极制片段半成品(生产批次用物料投入生产批次)
|
例子:正极制片段物料 => 正极制片段半成品(生产批次用物料投入生产批次)
|
||||||
|
|
||||||
二、2个以上生产批次下物料投入 => 产出新生产批次半成品
|
二、2个以上生产批次下物料投入 => 产出新生产批次半成品
|
||||||
例子:正极制片物料半成品 + 负极制片物料半成品 + 原材料 => 装配段半成品(用上传批次作为生产批次)
|
例子:正极制片物料半成品 + 负极制片物料半成品 + 原材料 => 装配段半成品(用上传批次作为生产批次)
|
||||||
|
|
||||||
接口api示例
|
接口api示例
|
||||||
{
|
{
|
||||||
"action": "do_set_wip_output_by_item_ids",
|
"action": "do_set_wip_output_by_item_ids",
|
||||||
"param": {
|
"param": {
|
||||||
"batch": "", #当batch不为空,代表装配段第一个工序,把正极制片段、负极制片段投入物料合并到装配段上;当batch为空时,代表正极制片段、负极制片段工序,batch以投入物料batch为准
|
"batch": "", #当batch不为空,代表装配段第一个工序,把正极制片段、负极制片段投入物料合并到装配段上;当batch为空时,代表正极制片段、负极制片段工序,batch以投入物料batch为准
|
||||||
"workingsubclass": "ZJ", # 工序单元
|
"workingsubclass": "ZJ", # 工序单元
|
||||||
"device_code": "FJZJ-1", # 设备编码
|
"device_code": "FJZJ-1", # 设备编码
|
||||||
"item_ids":[], # 裸电芯条码
|
"item_ids":[], # 裸电芯条码
|
||||||
"input_item_ids":[], # 上料裸电芯条码
|
"input_item_ids":[], # 上料裸电芯条码
|
||||||
"out": [{
|
"out": [{
|
||||||
"START_TIME":"tongbo", # 开始时间
|
"START_TIME":"tongbo", # 开始时间
|
||||||
"FINISH_TIME": "fengezi-1", # 结束时间
|
"FINISH_TIME": "fengezi-1", # 结束时间
|
||||||
"DEVICE_CODE": "fengezi-1" # 设备编码
|
"DEVICE_CODE": "fengezi-1" # 设备编码
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 通过batch->flow->model->bom->workingsubclass->BomRelationship对应的bom结构
|
* 通过batch->flow->model->bom->workingsubclass->BomRelationship对应的bom结构
|
||||||
@ -79,9 +79,6 @@ class SetWipOutputByItemIds
|
|||||||
if (empty($param["out"])) {
|
if (empty($param["out"])) {
|
||||||
throw new Exception("缺少out参数");
|
throw new Exception("缺少out参数");
|
||||||
}
|
}
|
||||||
if (empty($param["out"])) {
|
|
||||||
throw new Exception("缺少out参数");
|
|
||||||
}
|
|
||||||
|
|
||||||
$batch = "";
|
$batch = "";
|
||||||
$workingsubclass = $param["workingsubclass"];
|
$workingsubclass = $param["workingsubclass"];
|
||||||
@ -138,10 +135,10 @@ class SetWipOutputByItemIds
|
|||||||
//查询对应的批次表看是否存在激活状态
|
//查询对应的批次表看是否存在激活状态
|
||||||
$subbatch = $item_id_ret['subbatch'];
|
$subbatch = $item_id_ret['subbatch'];
|
||||||
$batch = $item_id_ret['batch'];
|
$batch = $item_id_ret['batch'];
|
||||||
$sql = "SELECT id FROM \"hf_mes_tmp_bkv_" . $subbatch . "\" WHERE active = 1 AND battery_id='{$item_id}' ";
|
$sql = "SELECT id FROM \"hf_mes_tmp_bkv_" . $subbatch . "\" WHERE active = 1 AND battery_id='{$item_ids[$i]}' ";
|
||||||
$item_id_info = Db::fetch($sql);
|
$item_id_info = Db::fetch($sql);
|
||||||
if ($item_id_info) {
|
if ($item_id_info) {
|
||||||
throw new Exception('电芯码[' . $item_id . ']已存在[' . $batch . ']批次', 4001);
|
throw new Exception('电芯码[' . $item_ids[$i] . ']已存在[' . $batch . ']批次', 4001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,15 +152,11 @@ class SetWipOutputByItemIds
|
|||||||
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_code . ']找不到对应投入物料生产批次信息');
|
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_code . ']找不到对应投入物料生产批次信息');
|
||||||
}
|
}
|
||||||
$item_code_in_process_log = array_column($ret, "item_code");
|
$item_code_in_process_log = array_column($ret, "item_code");
|
||||||
//获取正向追溯的uuid
|
|
||||||
$forward_tracing_uuid_in_process_log = array_column($ret, "forward_tracing_uuid");
|
//获取原材料的正向追溯的uuid固定值不变
|
||||||
$forward_tracing_uuid = [];
|
$forward_tracing_uuid_fixed = array_unique(array_merge(...array_map(function ($json) {
|
||||||
foreach ($forward_tracing_uuid_in_process_log as $json_str) {
|
return is_array($decoded = json_decode($json, true)) ? $decoded : [];
|
||||||
$decoded = json_decode($json_str, true); // 转成数组
|
}, array_column($ret, "forward_tracing_uuid"))));
|
||||||
if (is_array($decoded)) {
|
|
||||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$batch = $ret[0]['batch'];
|
$batch = $ret[0]['batch'];
|
||||||
|
|
||||||
@ -266,15 +259,14 @@ class SetWipOutputByItemIds
|
|||||||
} else {
|
} else {
|
||||||
$sql_val_out_result_param[$i][] = "'" . $param_out_val . "'";
|
$sql_val_out_result_param[$i][] = "'" . $param_out_val . "'";
|
||||||
}
|
}
|
||||||
|
$ng_code_val = 0;
|
||||||
// 判断NG是否存在
|
// 判断NG是否存在
|
||||||
if ($val['code'] == 'NG') {
|
if ($val['code'] == 'NG') {
|
||||||
if ($param_out[$i][$val['code']] != '') {
|
if ($param_out[$i][$val['code']] != '') {
|
||||||
$ng_code[] = $param_out[$i][$val['code']];
|
$ng_code_val = $param_out[$i][$val['code']];
|
||||||
} else {
|
|
||||||
$ng_code[] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ng_code[] = $ng_code_val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +342,7 @@ class SetWipOutputByItemIds
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$bb = [sdfdf];
|
||||||
if (count($input_item_ids) > 0) {
|
if (count($input_item_ids) > 0) {
|
||||||
$input_item_id = $input_item_ids[$i];
|
$input_item_id = $input_item_ids[$i];
|
||||||
//查询batch_process_log表中该裸电芯上一工序的uuid
|
//查询batch_process_log表中该裸电芯上一工序的uuid
|
||||||
@ -374,7 +366,7 @@ class SetWipOutputByItemIds
|
|||||||
|
|
||||||
Db::beginTrans();
|
Db::beginTrans();
|
||||||
try {
|
try {
|
||||||
for ($i = 0; $i < count($item_ids); $i++) {
|
for ($i = 0; $i < count(value: $item_ids); $i++) {
|
||||||
// 标记最后一条数据的状态
|
// 标记最后一条数据的状态
|
||||||
if (!empty($pid[$i])) {
|
if (!empty($pid[$i])) {
|
||||||
Event::emit('SetProcessLogEvent.updateLastStatus', $pid[$i]);
|
Event::emit('SetProcessLogEvent.updateLastStatus', $pid[$i]);
|
||||||
@ -405,14 +397,25 @@ class SetWipOutputByItemIds
|
|||||||
} else {
|
} else {
|
||||||
$uuid[$i] = json_encode(array_values(array_unique($uuid[$i])));
|
$uuid[$i] = json_encode(array_values(array_unique($uuid[$i])));
|
||||||
}
|
}
|
||||||
//保证每个正向追溯的uuid都是唯一的
|
|
||||||
$forward_tracing_uuid_only[] = generateUniqueId();
|
$forward_tracing_uuid = $forward_tracing_uuid_fixed;
|
||||||
$forward_tracing_uuid_only = json_encode($forward_tracing_uuid_only);
|
// 检查 $input_item_ids 是否非空 且当前索引存在
|
||||||
$decoded_uuid = json_decode($forward_tracing_uuid_only, true);
|
if (count($input_item_ids) > 0) {
|
||||||
if (is_array($decoded_uuid)) {
|
//需要读取input_item_id的$forward_tracing_uuid进行拼接
|
||||||
$forward_tracing_uuid = array_merge($forward_tracing_uuid, $decoded_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()]));
|
||||||
}
|
}
|
||||||
$forward_tracing_uuid = json_encode(array_unique($forward_tracing_uuid));
|
$forward_tracing_uuid = json_encode($forward_tracing_uuid);
|
||||||
|
|
||||||
$wip_uuid[$i] = json_encode(array_values(array_unique($wip_uuid[$i])));
|
$wip_uuid[$i] = json_encode(array_values(array_unique($wip_uuid[$i])));
|
||||||
|
|
||||||
$now_date = date('Y-m-d H:i:s');
|
$now_date = date('Y-m-d H:i:s');
|
||||||
@ -423,9 +426,9 @@ class SetWipOutputByItemIds
|
|||||||
$battery_id = $item_ids[$i];
|
$battery_id = $item_ids[$i];
|
||||||
|
|
||||||
// 新增数据到process_log表
|
// 新增数据到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) 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,input_finish_time) VALUES';
|
||||||
$wip_process_log_sql_val = sprintf(
|
$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,
|
$battery_id,
|
||||||
$batch,
|
$batch,
|
||||||
$subbatch,
|
$subbatch,
|
||||||
@ -448,14 +451,14 @@ class SetWipOutputByItemIds
|
|||||||
$ng_code[$i],
|
$ng_code[$i],
|
||||||
$device_category_id,
|
$device_category_id,
|
||||||
1,
|
1,
|
||||||
$forward_tracing_uuid
|
$forward_tracing_uuid,
|
||||||
|
$finish_time
|
||||||
);
|
);
|
||||||
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
|
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
|
||||||
$row = Db::query($sql);
|
$row = Db::query($sql);
|
||||||
if ($row === NULL) {
|
if ($row === NULL) {
|
||||||
throw new Exception('电芯 ' . $item_id . ' 半成品信息插入process_log表失败');
|
throw new Exception('电芯 ' . $item_id . ' 半成品信息插入process_log表失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增数据到battery_map表
|
// 新增数据到battery_map表
|
||||||
$battery_unique_value = "{$batch}_{$subbatch}_-1_{$lot}_{$battery_id}";
|
$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 ';
|
$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