检查项目 更新逻辑优化

push
鹿和sa0ChunLuyu 8 hours ago
parent 12310997f1
commit 25edb51434

@ -100,7 +100,7 @@ public function UpdateCheckItem(){
} }
// 快速查找是否已存在该 item_code // 快速查找是否已存在该 item_code
if (isset($db_map[$item_code])) { if (isset($db_map[$item_code])) {
// 存在则更新 // 存在则更新check_notice 单独条件更新,不覆盖已有值)
DB::table('s_check_item') DB::table('s_check_item')
->where('item_code', $item_code) ->where('item_code', $item_code)
->update([ ->update([
@ -110,11 +110,20 @@ public function UpdateCheckItem(){
'item_desc' => $item_name, 'item_desc' => $item_name,
'is_del' => 0, // 取消删除标记 'is_del' => 0, // 取消删除标记
'hisExecDepts'=>json_encode($department_arr, JSON_UNESCAPED_UNICODE), 'hisExecDepts'=>json_encode($department_arr, JSON_UNESCAPED_UNICODE),
'check_notice'=>$item['docmoTip']
]); ]);
// 仅当库中 check_notice 为空且 HIS 有值时才写入
if (!empty($item['docmoTip'])) {
DB::table('s_check_item')
->where('item_code', $item_code)
->where(function ($q) {
$q->whereNull('check_notice')
->orWhere('check_notice', '');
})
->update(['check_notice' => $item['docmoTip']]);
}
} else { } else {
// 不存在则插入新记录 // 不存在则插入新记录
DB::table('s_check_item')->insert([ $insertData = [
'item_class_id'=>$item_class_id, 'item_class_id'=>$item_class_id,
'sheetType'=>$item['sheetType'], 'sheetType'=>$item['sheetType'],
'item_code' => $item_code, 'item_code' => $item_code,
@ -124,8 +133,12 @@ public function UpdateCheckItem(){
'limosis' =>0, 'limosis' =>0,
'check_time' =>0, 'check_time' =>0,
'hisExecDepts'=>json_encode($department_arr, JSON_UNESCAPED_UNICODE), 'hisExecDepts'=>json_encode($department_arr, JSON_UNESCAPED_UNICODE),
'check_notice'=>$item['docmoTip'] ];
]); // 仅当 HIS 有值时才写入 check_notice
if (!empty($item['docmoTip'])) {
$insertData['check_notice'] = $item['docmoTip'];
}
DB::table('s_check_item')->insert($insertData);
// $this->updateBindDrivers($item_code,$department_arr);自动绑定检查室 ,废弃 // $this->updateBindDrivers($item_code,$department_arr);自动绑定检查室 ,废弃
} }

Loading…
Cancel
Save