修复bug
This commit is contained in:
@@ -552,6 +552,8 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
}
|
||||
unset($item);
|
||||
|
||||
$this->appendPrescriptionOrderAssignSnapshotErCenterFlags($lists);
|
||||
|
||||
if ((int) ($this->params['yeji_order_drawer'] ?? 0) === 1) {
|
||||
PrescriptionOrderLogic::appendLinkedAppointmentsToListRows($lists, $this->params);
|
||||
}
|
||||
@@ -1069,4 +1071,118 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
. ")"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表行标注:指派日志快照(related_po_creator_id + related_po_create_time)是否指向本业务单,
|
||||
* 以及该次操作的新医助(to_assistant_id)是否归属「二中心」部门子树(与 DeptLogic / 业绩看板一致)。
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $lists
|
||||
*/
|
||||
private function appendPrescriptionOrderAssignSnapshotErCenterFlags(array &$lists): void
|
||||
{
|
||||
if ($lists === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$diagIds = [];
|
||||
foreach ($lists as $row) {
|
||||
$d = (int) ($row['diagnosis_id'] ?? 0);
|
||||
if ($d > 0) {
|
||||
$diagIds[$d] = true;
|
||||
}
|
||||
}
|
||||
$diagIdList = array_keys($diagIds);
|
||||
$latestSnapLogByTriple = [];
|
||||
if ($diagIdList !== []) {
|
||||
$logRows = Db::name('tcm_diagnosis_assign_log')
|
||||
->whereIn('diagnosis_id', $diagIdList)
|
||||
->field(['id', 'diagnosis_id', 'to_assistant_id', 'related_po_creator_id', 'related_po_create_time'])
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($logRows as $log) {
|
||||
$d = (int) ($log['diagnosis_id'] ?? 0);
|
||||
$rcp = (int) ($log['related_po_creator_id'] ?? 0);
|
||||
$rpct = (int) ($log['related_po_create_time'] ?? 0);
|
||||
if ($d <= 0 || $rcp <= 0 || $rpct <= 0) {
|
||||
continue;
|
||||
}
|
||||
$tripleKey = $d . ':' . $rcp . ':' . $rpct;
|
||||
if (!isset($latestSnapLogByTriple[$tripleKey])) {
|
||||
$latestSnapLogByTriple[$tripleKey] = $log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$toAssistantIdsHit = [];
|
||||
foreach ($lists as $item) {
|
||||
$diagId = (int) ($item['diagnosis_id'] ?? 0);
|
||||
$creatorId = (int) ($item['creator_id'] ?? 0);
|
||||
$poCt = (int) ($item['create_time'] ?? 0);
|
||||
$tripleKey = $diagId . ':' . $creatorId . ':' . $poCt;
|
||||
$log = $latestSnapLogByTriple[$tripleKey] ?? null;
|
||||
if (\is_array($log)) {
|
||||
$tid = (int) ($log['to_assistant_id'] ?? 0);
|
||||
if ($tid > 0) {
|
||||
$toAssistantIdsHit[$tid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$toAssistantIdList = array_keys($toAssistantIdsHit);
|
||||
|
||||
$erDeptSet = DeptLogic::getErCenterSubtreeDeptIdSet();
|
||||
$adminErCenter = [];
|
||||
if ($toAssistantIdList !== [] && $erDeptSet !== []) {
|
||||
$adRows = AdminDept::whereIn('admin_id', $toAssistantIdList)
|
||||
->field(['admin_id', 'dept_id'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($adRows as $ad) {
|
||||
$aid = (int) ($ad['admin_id'] ?? 0);
|
||||
$did = (int) ($ad['dept_id'] ?? 0);
|
||||
if ($aid > 0 && $did > 0 && isset($erDeptSet[$did])) {
|
||||
$adminErCenter[$aid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nameMap = [];
|
||||
if ($toAssistantIdList !== []) {
|
||||
$nameMap = \app\common\model\auth\Admin::whereIn('id', $toAssistantIdList)->column('name', 'id');
|
||||
}
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$diagId = (int) ($item['diagnosis_id'] ?? 0);
|
||||
$creatorId = (int) ($item['creator_id'] ?? 0);
|
||||
$poCt = (int) ($item['create_time'] ?? 0);
|
||||
|
||||
$item['po_assign_snapshot_hit'] = 0;
|
||||
$item['po_assign_to_assistant_id'] = 0;
|
||||
$item['po_assign_to_assistant_name'] = '';
|
||||
$item['po_assign_to_er_center'] = 0;
|
||||
$item['po_assign_is_release'] = 0;
|
||||
|
||||
if ($diagId <= 0 || $creatorId <= 0 || $poCt <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tripleKey = $diagId . ':' . $creatorId . ':' . $poCt;
|
||||
$log = $latestSnapLogByTriple[$tripleKey] ?? null;
|
||||
if (!\is_array($log)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['po_assign_snapshot_hit'] = 1;
|
||||
$toId = (int) ($log['to_assistant_id'] ?? 0);
|
||||
$item['po_assign_to_assistant_id'] = $toId;
|
||||
if ($toId <= 0) {
|
||||
$item['po_assign_is_release'] = 1;
|
||||
continue;
|
||||
}
|
||||
$item['po_assign_to_assistant_name'] = (string) ($nameMap[$toId] ?? '');
|
||||
$item['po_assign_to_er_center'] = isset($adminErCenter[$toId]) ? 1 : 0;
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user