Compare commits

..

3 Commits

Author SHA1 Message Date
840087755b 更新 mes_in_sct/app/action/GetBatteryProcessResult.php
All checks were successful
Run Unit Tests / test (pull_request) Successful in 5s
2025-06-15 11:53:43 +08:00
d47848b927 更新 mes_in_sct/app/action/GetBatteryProcessResult.php
Some checks failed
Run Unit Tests / test (pull_request) Failing after 8s
2025-06-15 11:52:35 +08:00
c55e38a033 更新 mes_in_sct/app/action/CheckBomInfo.php 2025-06-15 11:50:58 +08:00
4 changed files with 32 additions and 83 deletions

View File

@ -1,74 +1,26 @@
name: Run Unit Tests
on:
pull_request:
push:
branches:
- main
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
- develop
pull_request:
jobs:
test:
runs-on: phpunit_test
container: mirror.ccs.tencentyun.com/xeden3/ai-code-reviewer-gitea-runner:v1.4.1
container: docker.xuanyuan.me/xeden3/ai-code-reviewer-gitea-runner:v1
steps:
- name: Checkout code
uses: http://119.91.43.128:3003/james/checkout@v4
- name: Get Pull Request Number
id: get_pr_number
run: |
# 提取 PR 编号(如 pull/14/head -> 14)
PULLS_ID=$(git branch | grep -o 'pull/[0-9]\+' | cut -d'/' -f2)
if [ -z "$PULLS_ID" ]; then
echo "❌ 无法提取 PR 编号"
exit 1
fi
echo "PR ID: $PULLS_ID"
# 写入 GITHUB_ENV(可选,兼容旧脚本)
echo "PULLS_ID=$PULLS_ID" >> $GITHUB_ENV
# 写入 outputs,供后续步骤使用
echo "pr_number=$PULLS_ID" >> $GITHUB_OUTPUT
with:
fetch-depth: 2 # 至少获取最近两次提交
- name: Run code review script
env:
# === 项目配置 ===
GIT_PROJECT_PATH: /workspace/hui/SCTMES_V5 # Gitea 的工作目录
ALLOWED_PATHS: '["EdgeManager/**", "mes_in_sct/**", "mes_in_task/**", "webman/**"]' # 允许检测目录
IGNORED_PATHS: '["EdgeManager/vendor/**", "mes_in_sct/vendor/**", "mes_in_task/vendor/**", "webman/public/**", "webman/runtime/**", "webman/vendor/**"]' # 忽略检测目录
# === Gitea API 配置(传给 audit_code.sh)===
API_URL: "http://119.91.43.128:3003/api/v1/repos/hui/SCTMES_V5/issues/${{ steps.get_pr_number.outputs.pr_number }}/comments"
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
SYSTEM_PROMPT: |
你是一位资深的PHP软件开发工程师专注于代码的规范性、功能性、稳定性、运行效率。本次任务是对员工的代码进行审查具体要求如下
### 代码审查目标:
1. 功能实现的正确性与健壮性40分 确保代码逻辑正确,能够处理各种边界情况和异常输入。
2. 命名规范10分检查代码变量和函数命名是否规范类和函数使用驼峰命名变量使用小写字母+下横线命名。
3. 是否符合最佳实践20分评估代码是否遵循行业最佳实践包括代码结构、命名规范、注释清晰度等。
4. 性能与资源利用效率20分分析代码的性能表现评估是否存在资源浪费或性能瓶颈。
5. Commits信息的清晰性与准确性10分检查提交信息是否清晰、准确是否便于后续维护和协作。
6. 所有检查**不需要考虑类名称不需要考虑SQL语句**,数据库注入风险等数据库相关的风险,**不考虑SQL预处理sprintf处理不需要考虑返回值命名$ret的情况**。
### 输出格式:
请以Markdown格式输出代码审查报告并包含以下内容
1. 问题描述和优化建议(如果有):列出代码中存在的问题,简要说明其影响,并给出优化建议,**必要时候以代码段的形式指出具体的修改方案**。
2. 评分明细:为每个评分标准提供具体分数。
3. 总分:格式为“总分:XX分”例如总分:80分确保可通过正则表达式 r"总分[:]\s*(\d+)分?" 解析出总分。
### 特别说明:
整个评论要保持sarcastic风格
评论时请大胆使用讽刺性语言,但要确保技术指正准确。
评论时请:
1. 在技术点评中加入适当幽默元素
2. 合理使用相关Emoji但不要过度
- 🐛 表示bug
- 💥 表示严重问题
- 🎯 表示改进建议
- 🔍 表示需要仔细检查
run: |
cd /workspace
./audit_code.sh

View File

@ -31,7 +31,7 @@ class CheckBomInfo
}
$sql = "SELECT id FROM hf_mes_device WHERE code='".$device_code."'";
$ret = Db::fetch($sql);
$ret = Db::fetch($sql2);
if(empty($ret)){
throw new Exception("设备编码[$device_code]不存在",4001);
}

View File

@ -28,7 +28,7 @@ class GetBatteryProcessResult
$battery_ids = $param['battery_ids'];
$process_code = $param['process_code'];
// 修改参数名字
$result = [];
// 判断结果参数是否都上传了

View File

@ -122,15 +122,11 @@ class SetWipOutputByItemId
throw new Exception('工序单元[' . $workingsubclass . ']下设备编码[' . $device_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"))));
$batch = $ret[0]['batch'];
@ -227,16 +223,14 @@ 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表做准备
@ -351,15 +345,17 @@ class SetWipOutputByItemId
} else {
$uuid = json_encode(array_values(array_unique($uuid)));
}
//保证每个正向追溯的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);
//需要读取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)));
}
$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)));
$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');
@ -368,9 +364,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) 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(
"('%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,
@ -393,7 +389,8 @@ class SetWipOutputByItemId
$ng_code,
$device_category_id,
1,
$forward_tracing_uuid
$forward_tracing_uuid,
$finish_time
);
$sql = $wip_process_log_sql_head . $wip_process_log_sql_val;
$row = Db::query($sql);