Compare commits
1 Commits
main
...
james-patc
Author | SHA1 | Date | |
---|---|---|---|
5ef6e47b2e |
@ -1,74 +1,26 @@
|
|||||||
name: Run Unit Tests
|
name: Run Unit Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
env:
|
- develop
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: phpunit_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:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: http://119.91.43.128:3003/james/checkout@v4
|
uses: http://119.91.43.128:3003/james/checkout@v4
|
||||||
|
with:
|
||||||
- name: Get Pull Request Number
|
fetch-depth: 2 # 至少获取最近两次提交
|
||||||
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
|
|
||||||
|
|
||||||
- name: Run code review script
|
- name: Run code review script
|
||||||
env:
|
env:
|
||||||
# === 项目配置 ===
|
|
||||||
GIT_PROJECT_PATH: /workspace/hui/SCTMES_V5 # Gitea 的工作目录
|
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: |
|
run: |
|
||||||
cd /workspace
|
cd /workspace
|
||||||
./audit_code.sh
|
./audit_code.sh
|
@ -25,7 +25,7 @@ class CheckBomInfo
|
|||||||
|
|
||||||
//2.判断工序单元、设备编码是存在?
|
//2.判断工序单元、设备编码是存在?
|
||||||
$sql = "SELECT id FROM hf_mes_process_workingsubclass WHERE code='".$workingsubclass."'";
|
$sql = "SELECT id FROM hf_mes_process_workingsubclass WHERE code='".$workingsubclass."'";
|
||||||
$ret = Db::fetch($sql);
|
$ret = Db::fetch($sql2);
|
||||||
if(empty($ret)){
|
if(empty($ret)){
|
||||||
throw new Exception("工序单元[$workingsubclass]不存在",4001);
|
throw new Exception("工序单元[$workingsubclass]不存在",4001);
|
||||||
}
|
}
|
||||||
|
@ -123,16 +123,15 @@ class SetWipOutput
|
|||||||
}
|
}
|
||||||
$subbatch = $ret['subbatch'];
|
$subbatch = $ret['subbatch'];
|
||||||
// 拿到工序编码
|
// 拿到工序编码
|
||||||
$ret_process = json_decode($ret['process'], true);
|
foreach (json_decode($ret['process'], true) as $key => $val) {
|
||||||
// 拿到工序编码
|
|
||||||
foreach ($ret_process as $key => $val) {
|
|
||||||
if ($val[4] == $workingsubclass) {
|
if ($val[4] == $workingsubclass) {
|
||||||
if (isset($ret_process[$key + 1])) {
|
if (isset($process[$key + 1])) {
|
||||||
$next_process_code = $ret_process[$key + 1][2];
|
$next_process_code = $process[$key + 1][2];
|
||||||
}
|
}
|
||||||
$process_code = $val[2];
|
$process_code = $val[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//4.通过以上关联信息查询物料编码
|
//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
|
$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
|
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 = json_encode(array_unique($uuid));
|
||||||
}
|
}
|
||||||
//保证每个正向追溯的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)));
|
$wip_uuid = count($wip_uuid) <= 0 ? $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 = $last_time; //isset($param_out['START_TIME'])? $param_out['START_TIME'] : 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');
|
$finish_time = isset($param_out['FINISH_TIME']) ? $param_out['FINISH_TIME'] : date('Y-m-d H:i:s');
|
||||||
$lot = strtotime($now_date);
|
$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]) {
|
if (!$wip_msg[0]) {
|
||||||
throw new Exception("获取物料批次条码失败!" . $wip_msg[1]);
|
throw new Exception("获取物料批次条码失败!" . $wip_msg[1]);
|
||||||
} else {
|
} else {
|
||||||
$battery_id = $wip_msg[1];
|
$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表
|
// 新增数据到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]);
|
$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表
|
// 新增数据到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(
|
$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,
|
$battery_id,
|
||||||
'-1',
|
'-1',
|
||||||
$lot,
|
$lot,
|
||||||
1,
|
1,
|
||||||
$process_code,
|
$process_code,
|
||||||
$next_process_code,
|
|
||||||
$bom_relationship_array['bom_source_code'],
|
$bom_relationship_array['bom_source_code'],
|
||||||
$bom_relationship_array['bom_source_name'],
|
$bom_relationship_array['bom_source_name'],
|
||||||
$battery_id,
|
$battery_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user