Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15a20db725 | ||
|
|
3ac30a6c2c | ||
|
|
95d6b6025f | ||
|
|
d0eb97b167 | ||
|
|
476f744ee9 | ||
|
|
cec96ce480 | ||
|
|
77473a1738 | ||
|
|
db74cd64fe | ||
|
|
e1f0030403 | ||
|
|
5109d8b3e5 | ||
|
|
2a0a2ef72a | ||
|
|
3a396d79a2 | ||
|
|
9c4944702b | ||
|
|
e06f89dcf6 |
No files matched your search
@@ -19,7 +19,7 @@ description: Use when starting a project, designing or prototyping project UI, i
|
|||||||
| 任务 | 读取 |
|
| 任务 | 读取 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 工单领取、并行会话、流程标签、转交、共享环境或合并排队 | [工单占用与隔离](references/issue-claims.md) |
|
| 工单领取、并行会话、流程标签、转交、共享环境或合并排队 | [工单占用与隔离](references/issue-claims.md) |
|
||||||
| 发送确认问题、请求用户操作、补发缺推荐或缺超时说明的旧题 | 先按[问题展示](references/planning.md#问题展示)在当前回复写出「待你确认」,完成[发问前检查](references/planning.md#发问前检查)后,再按[本地确认语音](references/question-notification.md)提醒 |
|
| 发送确认问题、请求用户操作、补发缺推荐或缺超时说明的旧题 | 先按[问题展示](references/planning.md#问题展示)与 Cursor 宿主节在当前回复写出「待你确认」,完成[发问前检查](references/planning.md#发问前检查)后,再按[本地确认语音](references/question-notification.md)提醒;Cursor 下 `notify-question` 须为本轮最后一次工具且发问后停手 |
|
||||||
| 关闭/恢复声音提醒 | [本地确认语音](references/question-notification.md) |
|
| 关闭/恢复声音提醒 | [本地确认语音](references/question-notification.md) |
|
||||||
| 空白工程、大需求、技术栈或架构变化 | [建设与规格](references/planning.md) |
|
| 空白工程、大需求、技术栈或架构变化 | [建设与规格](references/planning.md) |
|
||||||
| 拉取工单、理解评论和截图、续接工单或交付前核对补充 | [工单全文、评论与图片](references/issue-context.md) |
|
| 拉取工单、理解评论和截图、续接工单或交付前核对补充 | [工单全文、评论与图片](references/issue-context.md) |
|
||||||
|
|||||||
@@ -43,6 +43,14 @@
|
|||||||
|
|
||||||
必须等待的题,最后一行写「未回复时:本题保持等待。」宿主问题卡片可以同时使用,卡片内容与这份清单一致。回复正文里没有「待你确认」时,不播放提示音,也不开始 60 秒计时。
|
必须等待的题,最后一行写「未回复时:本题保持等待。」宿主问题卡片可以同时使用,卡片内容与这份清单一致。回复正文里没有「待你确认」时,不播放提示音,也不开始 60 秒计时。
|
||||||
|
|
||||||
|
### Cursor / 工具先于正文的宿主
|
||||||
|
|
||||||
|
Cursor Agent 等同轮「先跑工具、再出最终回复」的宿主上:
|
||||||
|
|
||||||
|
1. 需要播音时,`notify-question` 只能作为本轮**最后一次**工具调用;最终可见回复必须以「待你确认」开头写全清单,本轮随后不得再编辑代码、开浏览器或继续依赖答复的实现。
|
||||||
|
2. 承认提示音可能早于正文渲染数秒;用清单内一句「请在本会话回复;Queued 不是确认入口」消除错位。提示音整机可听,不保证当前聚焦会话就是发问会话。
|
||||||
|
3. 工程若提供宿主适配说明(如 `docs/agents/cursor-question-visibility.md`),发问前按该说明执行;与本节冲突时以「用户必须看见清单」为准。
|
||||||
|
|
||||||
## 发问前检查
|
## 发问前检查
|
||||||
|
|
||||||
每次发送确认问题(含调用宿主提问工具)前,逐题完成以下检查;缺项先改题,再按[问题展示](#问题展示)写入当前回复。这里是 Agent 的执行步骤,尚无自动拦截宿主问题卡片的校验器。
|
每次发送确认问题(含调用宿主提问工具)前,逐题完成以下检查;缺项先改题,再按[问题展示](#问题展示)写入当前回复。这里是 Agent 的执行步骤,尚无自动拦截宿主问题卡片的校验器。
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
1. 先核对用户/工程的静音选择。当前回复已经写上「待你确认」清单后,记录该批问题的发送时间、推荐及范围,再播放。回复里还没有这份清单时不播放,也不把这一轮当作已经发问。
|
1. 先核对用户/工程的静音选择。当前回复已经写上「待你确认」清单后,记录该批问题的发送时间、推荐及范围,再播放。回复里还没有这份清单时不播放,也不把这一轮当作已经发问。
|
||||||
2. 每批问题只播放一次,多题合并发送共用一次提醒。将“已尝试提醒/结果”记在现有任务记录;同一批等待、轮询、重试和会话恢复不重复播放。真正重新提出的新问题或用户要求再提醒时才播放下一次。
|
2. 每批问题只播放一次,多题合并发送共用一次提醒。将“已尝试提醒/结果”记在现有任务记录;同一批等待、轮询、重试和会话恢复不重复播放。真正重新提出的新问题或用户要求再提醒时才播放下一次。
|
||||||
3. 执行以下已安装入口。它只读取随包预生成的本地 WAV,并调用播放器;不联网、不调用语音生成服务、不在提问时临时生成语音。命令最多等待播放器 12 秒,不另开后台常驻进程。
|
3. **Cursor 等「工具先于最终正文」的宿主**:不得在仍要继续工具批处理时播放。需要播放时,将 `notify-question` 放在本轮最后一次工具调用,并保证同轮最终正文以「待你确认」清单为主体且本轮停手。提示音在整机播放、不绑定聊天标签;Queued/Multitasking 队列不是确认入口。工程适配见 `docs/agents/cursor-question-visibility.md`(若存在)。
|
||||||
|
4. 执行以下已安装入口。它只读取随包预生成的本地 WAV,并调用播放器;不联网、不调用语音生成服务、不在提问时临时生成语音。命令最多等待播放器 12 秒,不另开后台常驻进程。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
python3 .agents/skills/personal-dev/scripts/pda.py notify-question --project .
|
python3 .agents/skills/personal-dev/scripts/pda.py notify-question --project .
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
---
|
---
|
||||||
description: 个人开发体系的工程任务入口
|
description: 个人开发体系的工程任务入口(含 Cursor 确认可见性)
|
||||||
alwaysApply: true
|
alwaysApply: true
|
||||||
---
|
---
|
||||||
|
|
||||||
工程建设、界面设计或原型、需求开发、Bug 修复、验收反馈或提交/push/合并续聊时,先读根 AGENTS.md,再读取工程根目录的 .agents/skills/personal-dev/SKILL.md 进行任务分级。仅咨询概念时直接回答。业务约束仍按目标目录的 AGENTS.md 查阅。
|
工程建设、界面设计或原型、需求开发、Bug 修复、验收反馈或提交/push/合并续聊时,先读根 `AGENTS.md`,再读取工程根目录的 `.agents/skills/personal-dev/SKILL.md` 进行任务分级。仅咨询概念时直接回答。业务约束仍按目标目录的 `AGENTS.md` 查阅。
|
||||||
|
|
||||||
需要用户确认时,先在当前回复写出「待你确认」清单,再播放提示音。清单的写法以该 Skill 的问题展示规则为准。回复里没有这份清单时,不播放提示音。
|
需要用户确认时:
|
||||||
|
|
||||||
|
1. 先读 [Cursor 确认可见性](../../docs/agents/cursor-question-visibility.md),再按 Skill 的问题展示规则发问。
|
||||||
|
2. 本轮最终用户可见回复必须以「待你确认」清单为主体(含推荐与未回复处理);写完清单前不播放提示音。
|
||||||
|
3. 若播放提示音:`notify-question` 必须是本轮最后一次工具调用,且本轮随后不再继续编辑/浏览器/实现类工具。
|
||||||
|
4. 清单中写明请在本会话回复;底部 Queued / Multitasking 不是确认入口。
|
||||||
|
5. 回复正文没有「待你确认」时,不播放提示音。
|
||||||
@@ -576,12 +576,14 @@ def attach_presign_ledger_fields(
|
|||||||
}
|
}
|
||||||
times_by_order: Dict[str, List[str]] = {}
|
times_by_order: Dict[str, List[str]] = {}
|
||||||
if order_ids:
|
if order_ids:
|
||||||
|
# 与 confirmedDepositAmount 一致:仅已确认到账(yjf)计入刷卡时间
|
||||||
transfers = (
|
transfers = (
|
||||||
db.query(BizPresignTransfer)
|
db.query(BizPresignTransfer)
|
||||||
.filter(
|
.filter(
|
||||||
BizPresignTransfer.presign_order_id.in_(order_ids),
|
BizPresignTransfer.presign_order_id.in_(order_ids),
|
||||||
BizPresignTransfer.tenant_no == tenant_no,
|
BizPresignTransfer.tenant_no == tenant_no,
|
||||||
BizPresignTransfer.del_flag == 0,
|
BizPresignTransfer.del_flag == 0,
|
||||||
|
BizPresignTransfer.pay_status == "yjf",
|
||||||
)
|
)
|
||||||
.order_by(
|
.order_by(
|
||||||
BizPresignTransfer.transfer_time.asc(),
|
BizPresignTransfer.transfer_time.asc(),
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ def apply_planned_start_time_step_filter(
|
|||||||
planned_start_time_end: Optional[str] = None,
|
planned_start_time_end: Optional[str] = None,
|
||||||
mine_user_id: Optional[str] = None,
|
mine_user_id: Optional[str] = None,
|
||||||
):
|
):
|
||||||
"""按活跃工单/任务下未完成工艺步骤的计划开始时间过滤。"""
|
"""按工艺步骤计划开始时间过滤;工单/任务/步骤状态由外层检索条件组合控制。"""
|
||||||
start = (planned_start_time_start or "").strip()
|
start = (planned_start_time_start or "").strip()
|
||||||
end = (planned_start_time_end or "").strip()
|
end = (planned_start_time_end or "").strip()
|
||||||
if not start and not end:
|
if not start and not end:
|
||||||
@@ -104,15 +104,9 @@ def apply_planned_start_time_step_filter(
|
|||||||
BizProductionTaskStep.del_flag == 0,
|
BizProductionTaskStep.del_flag == 0,
|
||||||
BizProductionTaskStep.tenant_no == tenant_no,
|
BizProductionTaskStep.tenant_no == tenant_no,
|
||||||
BizProductionTaskStep.planned_start_time.isnot(None),
|
BizProductionTaskStep.planned_start_time.isnot(None),
|
||||||
BizProductionTaskStep.step_status != "ywc",
|
|
||||||
BizProductionTask.id == BizProductionTaskStep.task_id,
|
BizProductionTask.id == BizProductionTaskStep.task_id,
|
||||||
BizProductionTask.del_flag == 0,
|
BizProductionTask.del_flag == 0,
|
||||||
BizProductionTask.tenant_no == tenant_no,
|
BizProductionTask.tenant_no == tenant_no,
|
||||||
BizProductionTask.task_status.in_(("dpz", "jxz")),
|
|
||||||
BizProductionWorkOrder.id == BizProductionTask.work_order_id,
|
|
||||||
BizProductionWorkOrder.del_flag == 0,
|
|
||||||
BizProductionWorkOrder.tenant_no == tenant_no,
|
|
||||||
BizProductionWorkOrder.work_order_status.in_(("dpz", "jxz")),
|
|
||||||
work_order_id_column == BizProductionTask.work_order_id,
|
work_order_id_column == BizProductionTask.work_order_id,
|
||||||
]
|
]
|
||||||
if start:
|
if start:
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from app.services.sample_storage_cert_qc import (
|
|||||||
loads_payload,
|
loads_payload,
|
||||||
normalize_payload,
|
normalize_payload,
|
||||||
resolve_sample_type_key,
|
resolve_sample_type_key,
|
||||||
|
sanitize_payload_for_type,
|
||||||
)
|
)
|
||||||
from app.services.sample_storage_cert_qc_prefill import collect_prefill
|
from app.services.sample_storage_cert_qc_prefill import collect_prefill
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ def _row_to_dict(
|
|||||||
"collectionProtocolId": row.collection_protocol_id or "",
|
"collectionProtocolId": row.collection_protocol_id or "",
|
||||||
"qcWorkOrderId": row.qc_work_order_id or "",
|
"qcWorkOrderId": row.qc_work_order_id or "",
|
||||||
"filledFlag": str(row.filled_flag or "0") == "1",
|
"filledFlag": str(row.filled_flag or "0") == "1",
|
||||||
"payload": loads_payload(row.payload),
|
"payload": sanitize_payload_for_type(loads_payload(row.payload), row.sample_type_key),
|
||||||
"createTime": row.create_time.isoformat(sep=" ", timespec="seconds") if row.create_time else "",
|
"createTime": row.create_time.isoformat(sep=" ", timespec="seconds") if row.create_time else "",
|
||||||
"updateTime": row.update_time.isoformat(sep=" ", timespec="seconds") if row.update_time else "",
|
"updateTime": row.update_time.isoformat(sep=" ", timespec="seconds") if row.update_time else "",
|
||||||
}
|
}
|
||||||
@@ -173,7 +174,7 @@ def upsert(
|
|||||||
key = resolve_sample_type_key(type_name)
|
key = resolve_sample_type_key(type_name)
|
||||||
if not key:
|
if not key:
|
||||||
raise ValueError("该样本类型不支持填写储存证质检信息")
|
raise ValueError("该样本类型不支持填写储存证质检信息")
|
||||||
clean = normalize_payload(payload)
|
clean = sanitize_payload_for_type(normalize_payload(payload), key)
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
row = (
|
row = (
|
||||||
db.query(BizSampleStorageCertQc)
|
db.query(BizSampleStorageCertQc)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from app.models.models import (
|
|||||||
BizProtocolPaymentDetail,
|
BizProtocolPaymentDetail,
|
||||||
BizProtocolPaymentSchedule,
|
BizProtocolPaymentSchedule,
|
||||||
BizProtocolPaymentTransfer,
|
BizProtocolPaymentTransfer,
|
||||||
|
BizProtocolRefundRecord,
|
||||||
BizProtocolSamplePayment,
|
BizProtocolSamplePayment,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -229,6 +230,197 @@ def _first_period_first_transfer_times(
|
|||||||
return {pid: _fmt_dt(t) for pid, t in earliest.items() if _fmt_dt(t)}
|
return {pid: _fmt_dt(t) for pid, t in earliest.items() if _fmt_dt(t)}
|
||||||
|
|
||||||
|
|
||||||
|
def _received_amount_from_transfers(transfers: List[BizProtocolPaymentTransfer]) -> float:
|
||||||
|
total = Decimal("0")
|
||||||
|
for t in transfers:
|
||||||
|
st = (t.pay_status or "").strip()
|
||||||
|
if st in ("yjf", "jfqrz"):
|
||||||
|
total += t.transfer_amount or Decimal("0")
|
||||||
|
return float(total)
|
||||||
|
|
||||||
|
|
||||||
|
def _v2_schedule_detail_rows(
|
||||||
|
schedules: List[BizProtocolPaymentSchedule],
|
||||||
|
transfers: List[BizProtocolPaymentTransfer],
|
||||||
|
pay_mode: str,
|
||||||
|
) -> List[Dict[str, Any]]:
|
||||||
|
by_schedule: Dict[str, List[BizProtocolPaymentTransfer]] = {}
|
||||||
|
for t in transfers:
|
||||||
|
sid = (t.schedule_id or "").strip()
|
||||||
|
if sid:
|
||||||
|
by_schedule.setdefault(sid, []).append(t)
|
||||||
|
active = [
|
||||||
|
s
|
||||||
|
for s in schedules
|
||||||
|
if (s.schedule_status or "").strip() != "void"
|
||||||
|
]
|
||||||
|
active.sort(
|
||||||
|
key=lambda s: (
|
||||||
|
s.schedule_no if s.schedule_no is not None else 10_000,
|
||||||
|
s.order_num if s.order_num is not None else 0,
|
||||||
|
s.create_time or datetime.min,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
rows: List[Dict[str, Any]] = []
|
||||||
|
for idx, sch in enumerate(active):
|
||||||
|
sch_transfers = by_schedule.get(sch.id, [])
|
||||||
|
paid = [
|
||||||
|
t
|
||||||
|
for t in sch_transfers
|
||||||
|
if (t.pay_status or "").strip() in ("yjf", "jfqrz")
|
||||||
|
]
|
||||||
|
paid_amount = _received_amount_from_transfers(paid) if paid else None
|
||||||
|
statuses = [(t.pay_status or "").strip() for t in sch_transfers if (t.pay_status or "").strip()]
|
||||||
|
if "jfqrz" in statuses:
|
||||||
|
st = "jfqrz"
|
||||||
|
elif "yjf" in statuses and paid:
|
||||||
|
st = "yjf"
|
||||||
|
elif statuses:
|
||||||
|
st = statuses[0]
|
||||||
|
else:
|
||||||
|
st = "dfj"
|
||||||
|
times = [t.transfer_time for t in paid if t.transfer_time is not None]
|
||||||
|
transfer_time = _fmt_dt(min(times)) if times else ""
|
||||||
|
inst_no = sch.schedule_no
|
||||||
|
if pay_mode in ("fq", "djfq") and inst_no is not None:
|
||||||
|
label = f"第{inst_no}期"
|
||||||
|
else:
|
||||||
|
label = f"缴费{idx + 1}"
|
||||||
|
rows.append(
|
||||||
|
{
|
||||||
|
"installmentNo": inst_no,
|
||||||
|
"installmentLabel": label,
|
||||||
|
"installmentDueDate": _fmt_ymd(sch.due_date),
|
||||||
|
"dueAmount": _dec(sch.due_amount),
|
||||||
|
"transferAmount": paid_amount,
|
||||||
|
"refundAmount": None,
|
||||||
|
"payStatus": st,
|
||||||
|
"payStatusLabel": _PAY_STATUS_LABELS.get(st, st or "—"),
|
||||||
|
"transferTime": transfer_time,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return rows
|
||||||
|
|
||||||
|
|
||||||
|
def _load_v2_protocol_payment_amounts(
|
||||||
|
db: Session,
|
||||||
|
protocol_ids: List[str],
|
||||||
|
tenant_no: str,
|
||||||
|
) -> Dict[str, Dict[str, Any]]:
|
||||||
|
"""按协议汇总 V2 样本缴费合同额、已收、明细与退费(仅 list/export 摘要用)。"""
|
||||||
|
ids = [x.strip() for x in protocol_ids if (x or "").strip()]
|
||||||
|
if not ids:
|
||||||
|
return {}
|
||||||
|
samples = (
|
||||||
|
db.query(BizProtocolSamplePayment)
|
||||||
|
.filter(
|
||||||
|
BizProtocolSamplePayment.collection_protocol_id.in_(ids),
|
||||||
|
BizProtocolSamplePayment.tenant_no == tenant_no,
|
||||||
|
BizProtocolSamplePayment.del_flag == 0,
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
if not samples:
|
||||||
|
return {}
|
||||||
|
schedules = (
|
||||||
|
db.query(BizProtocolPaymentSchedule)
|
||||||
|
.filter(
|
||||||
|
BizProtocolPaymentSchedule.collection_protocol_id.in_(ids),
|
||||||
|
BizProtocolPaymentSchedule.tenant_no == tenant_no,
|
||||||
|
BizProtocolPaymentSchedule.del_flag == 0,
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
transfers = (
|
||||||
|
db.query(BizProtocolPaymentTransfer)
|
||||||
|
.filter(
|
||||||
|
BizProtocolPaymentTransfer.collection_protocol_id.in_(ids),
|
||||||
|
BizProtocolPaymentTransfer.tenant_no == tenant_no,
|
||||||
|
BizProtocolPaymentTransfer.del_flag == 0,
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
refunds = (
|
||||||
|
db.query(BizProtocolRefundRecord)
|
||||||
|
.filter(
|
||||||
|
BizProtocolRefundRecord.collection_protocol_id.in_(ids),
|
||||||
|
BizProtocolRefundRecord.tenant_no == tenant_no,
|
||||||
|
BizProtocolRefundRecord.del_flag == 0,
|
||||||
|
)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
samples_by: Dict[str, List[BizProtocolSamplePayment]] = {}
|
||||||
|
for sp in samples:
|
||||||
|
samples_by.setdefault(sp.collection_protocol_id, []).append(sp)
|
||||||
|
schedules_by: Dict[str, List[BizProtocolPaymentSchedule]] = {}
|
||||||
|
for s in schedules:
|
||||||
|
schedules_by.setdefault(s.collection_protocol_id, []).append(s)
|
||||||
|
transfers_by: Dict[str, List[BizProtocolPaymentTransfer]] = {}
|
||||||
|
for t in transfers:
|
||||||
|
transfers_by.setdefault(t.collection_protocol_id, []).append(t)
|
||||||
|
refund_by: Dict[str, float] = {}
|
||||||
|
refund_seen: Dict[str, bool] = {}
|
||||||
|
for r in refunds:
|
||||||
|
amt = _dec(r.refund_amount)
|
||||||
|
if amt is None:
|
||||||
|
continue
|
||||||
|
refund_seen[r.collection_protocol_id] = True
|
||||||
|
refund_by[r.collection_protocol_id] = refund_by.get(r.collection_protocol_id, 0.0) + float(amt)
|
||||||
|
|
||||||
|
out: Dict[str, Dict[str, Any]] = {}
|
||||||
|
for pid, sp_list in samples_by.items():
|
||||||
|
modes = {(sp.pay_mode or "").strip() for sp in sp_list if (sp.pay_mode or "").strip()}
|
||||||
|
ordered_modes = sorted(
|
||||||
|
modes,
|
||||||
|
key=lambda mode: ({"dj": 0, "fq": 1, "djfq": 2, "fgd": 3}.get(mode, 99), mode),
|
||||||
|
)
|
||||||
|
if modes == {"dj", "fq"}:
|
||||||
|
pay_mode = "djfq"
|
||||||
|
else:
|
||||||
|
pay_mode = "+".join(ordered_modes) if ordered_modes else ""
|
||||||
|
contract_total = Decimal("0")
|
||||||
|
has_contract = False
|
||||||
|
for sp in sp_list:
|
||||||
|
if sp.contract_amount is not None:
|
||||||
|
has_contract = True
|
||||||
|
contract_total += sp.contract_amount or Decimal("0")
|
||||||
|
contract = float(contract_total) if has_contract else None
|
||||||
|
proto_transfers = transfers_by.get(pid, [])
|
||||||
|
received = _received_amount_from_transfers(proto_transfers)
|
||||||
|
pending = max(contract - received, 0) if contract is not None else None
|
||||||
|
detail_rows = _v2_schedule_detail_rows(
|
||||||
|
schedules_by.get(pid, []),
|
||||||
|
proto_transfers,
|
||||||
|
pay_mode,
|
||||||
|
)
|
||||||
|
statuses = [(t.pay_status or "").strip() for t in proto_transfers]
|
||||||
|
overall = _protocol_overall_status(statuses, contract, pending)
|
||||||
|
hint = _protocol_status_hint(pay_mode, statuses) or overall["overallPayStatusLabel"]
|
||||||
|
installment_count = None
|
||||||
|
if pay_mode in ("fq", "djfq"):
|
||||||
|
installment_count = len(
|
||||||
|
{
|
||||||
|
d.get("installmentNo")
|
||||||
|
for d in detail_rows
|
||||||
|
if d.get("installmentNo") is not None
|
||||||
|
}
|
||||||
|
) or len(detail_rows)
|
||||||
|
payload: Dict[str, Any] = {
|
||||||
|
"payMode": pay_mode,
|
||||||
|
"contractAmount": contract,
|
||||||
|
"receivedAmount": received,
|
||||||
|
"pendingAmount": pending,
|
||||||
|
"statusHint": hint,
|
||||||
|
"installmentCount": installment_count,
|
||||||
|
"paymentDetails": detail_rows,
|
||||||
|
**overall,
|
||||||
|
}
|
||||||
|
if refund_seen.get(pid):
|
||||||
|
payload["refundAmount"] = refund_by.get(pid, 0.0)
|
||||||
|
out[pid] = payload
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def build_protocol_payment_summaries(
|
def build_protocol_payment_summaries(
|
||||||
db: Session,
|
db: Session,
|
||||||
protocol_ids: List[str],
|
protocol_ids: List[str],
|
||||||
@@ -263,6 +455,7 @@ def build_protocol_payment_summaries(
|
|||||||
):
|
):
|
||||||
details_by_payment.setdefault(d.payment_id, []).append(d)
|
details_by_payment.setdefault(d.payment_id, []).append(d)
|
||||||
sample_modes: Dict[str, set] = {}
|
sample_modes: Dict[str, set] = {}
|
||||||
|
v2_amounts: Dict[str, Dict[str, Any]] = {}
|
||||||
if include_sample_payment_modes:
|
if include_sample_payment_modes:
|
||||||
for pid, mode in db.query(
|
for pid, mode in db.query(
|
||||||
BizProtocolSamplePayment.collection_protocol_id,
|
BizProtocolSamplePayment.collection_protocol_id,
|
||||||
@@ -274,6 +467,7 @@ def build_protocol_payment_summaries(
|
|||||||
).all():
|
).all():
|
||||||
if mode:
|
if mode:
|
||||||
sample_modes.setdefault(pid, set()).add(mode)
|
sample_modes.setdefault(pid, set()).add(mode)
|
||||||
|
v2_amounts = _load_v2_protocol_payment_amounts(db, ids, tenant_no)
|
||||||
first_pay_map = _first_period_first_transfer_times(db, ids, tenant_no)
|
first_pay_map = _first_period_first_transfer_times(db, ids, tenant_no)
|
||||||
out: Dict[str, Dict[str, Any]] = {}
|
out: Dict[str, Dict[str, Any]] = {}
|
||||||
for pid in ids:
|
for pid in ids:
|
||||||
@@ -285,7 +479,8 @@ def build_protocol_payment_summaries(
|
|||||||
)
|
)
|
||||||
first_pay = first_pay_map.get(pid) or ""
|
first_pay = first_pay_map.get(pid) or ""
|
||||||
modes = sample_modes.get(pid, set())
|
modes = sample_modes.get(pid, set())
|
||||||
if not summary and not first_pay and not modes:
|
v2 = v2_amounts.get(pid)
|
||||||
|
if not summary and not first_pay and not modes and not v2:
|
||||||
continue
|
continue
|
||||||
if not summary:
|
if not summary:
|
||||||
summary = {
|
summary = {
|
||||||
@@ -294,6 +489,7 @@ def build_protocol_payment_summaries(
|
|||||||
"contractAmount": None,
|
"contractAmount": None,
|
||||||
"receivedAmount": None,
|
"receivedAmount": None,
|
||||||
"pendingAmount": None,
|
"pendingAmount": None,
|
||||||
|
"refundAmount": None,
|
||||||
"statusHint": "",
|
"statusHint": "",
|
||||||
"installmentCount": None,
|
"installmentCount": None,
|
||||||
"paymentDetails": [],
|
"paymentDetails": [],
|
||||||
@@ -309,6 +505,27 @@ def build_protocol_payment_summaries(
|
|||||||
labels = {**_PAY_MODE_LABELS, "fgd": "分改趸"}
|
labels = {**_PAY_MODE_LABELS, "fgd": "分改趸"}
|
||||||
summary["payMode"] = "djfq" if modes == {"dj", "fq"} else "+".join(ordered_modes)
|
summary["payMode"] = "djfq" if modes == {"dj", "fq"} else "+".join(ordered_modes)
|
||||||
summary["payModeLabel"] = "+".join(labels.get(mode, mode) for mode in ordered_modes)
|
summary["payModeLabel"] = "+".join(labels.get(mode, mode) for mode in ordered_modes)
|
||||||
|
# V1 摘要缺已收金额时,用 V2 样本缴费补齐(自存表导出 / 协议列表依赖)。
|
||||||
|
if v2 and summary.get("receivedAmount") is None:
|
||||||
|
if summary.get("contractAmount") is None:
|
||||||
|
summary["contractAmount"] = v2.get("contractAmount")
|
||||||
|
summary["receivedAmount"] = v2.get("receivedAmount")
|
||||||
|
if summary.get("pendingAmount") is None:
|
||||||
|
summary["pendingAmount"] = v2.get("pendingAmount")
|
||||||
|
if not summary.get("paymentDetails"):
|
||||||
|
summary["paymentDetails"] = v2.get("paymentDetails") or []
|
||||||
|
if summary.get("installmentCount") is None:
|
||||||
|
summary["installmentCount"] = v2.get("installmentCount")
|
||||||
|
if summary.get("refundAmount") is None and "refundAmount" in v2:
|
||||||
|
summary["refundAmount"] = v2.get("refundAmount")
|
||||||
|
for key in (
|
||||||
|
"statusHint",
|
||||||
|
"overallPayStatus",
|
||||||
|
"overallPayStatusLabel",
|
||||||
|
"overallPayStatusTagType",
|
||||||
|
):
|
||||||
|
if not summary.get(key) and v2.get(key):
|
||||||
|
summary[key] = v2.get(key)
|
||||||
if first_pay:
|
if first_pay:
|
||||||
summary["firstPayTransferTime"] = first_pay
|
summary["firstPayTransferTime"] = first_pay
|
||||||
out[pid] = summary
|
out[pid] = summary
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ def supports_storage_cert_qc(sample_type_name: Optional[str]) -> bool:
|
|||||||
return resolve_sample_type_key(sample_type_name) is not None
|
return resolve_sample_type_key(sample_type_name) is not None
|
||||||
|
|
||||||
|
|
||||||
|
# 脐带间充质储存证不收录母亲血液三项核酸检测。
|
||||||
|
UC_MSC_EXCLUDED_PAYLOAD_KEYS = frozenset(
|
||||||
|
{
|
||||||
|
"mother_hbv_dna",
|
||||||
|
"mother_hcv_rna",
|
||||||
|
"mother_hiv1_rna",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def normalize_payload(payload: Any) -> Dict[str, Any]:
|
def normalize_payload(payload: Any) -> Dict[str, Any]:
|
||||||
if not isinstance(payload, dict):
|
if not isinstance(payload, dict):
|
||||||
raise ValueError("payload 必须为对象")
|
raise ValueError("payload 必须为对象")
|
||||||
@@ -38,6 +48,16 @@ def normalize_payload(payload: Any) -> Dict[str, Any]:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def sanitize_payload_for_type(
|
||||||
|
payload: Dict[str, Any],
|
||||||
|
sample_type_key: Optional[str],
|
||||||
|
) -> Dict[str, Any]:
|
||||||
|
"""按样本类型去掉不应展示/落库的键。"""
|
||||||
|
if sample_type_key != SAMPLE_TYPE_KEY_UC_MSC:
|
||||||
|
return payload
|
||||||
|
return {key: value for key, value in payload.items() if key not in UC_MSC_EXCLUDED_PAYLOAD_KEYS}
|
||||||
|
|
||||||
|
|
||||||
def dumps_payload(payload: Dict[str, Any]) -> str:
|
def dumps_payload(payload: Dict[str, Any]) -> str:
|
||||||
return json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
|
return json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,11 @@ _HSC_SEROLOGY_RULES = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
_MOTHER_SEROLOGY_RULES = tuple(rule for rule in _HSC_SEROLOGY_RULES if str(rule[0]).startswith("mother_"))
|
_MOTHER_SEROLOGY_RULES = tuple(rule for rule in _HSC_SEROLOGY_RULES if str(rule[0]).startswith("mother_"))
|
||||||
|
# 脐带间充质不预填母亲血液三项核酸。
|
||||||
|
_UC_MSC_EXCLUDED_MOTHER_KEYS = frozenset({"mother_hbv_dna", "mother_hcv_rna", "mother_hiv1_rna"})
|
||||||
|
_MOTHER_SEROLOGY_RULES_UC_MSC = tuple(
|
||||||
|
rule for rule in _MOTHER_SEROLOGY_RULES if str(rule[0]) not in _UC_MSC_EXCLUDED_MOTHER_KEYS
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _serology_from_tasks(
|
def _serology_from_tasks(
|
||||||
@@ -278,9 +283,19 @@ def _process_qual_from_tasks(tasks: List[Dict[str, Any]]) -> Dict[str, str]:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def _fill_shared_mother(suggested: Dict[str, str], tasks: Optional[List[Dict[str, Any]]]) -> None:
|
def _fill_shared_mother(
|
||||||
|
suggested: Dict[str, str],
|
||||||
|
tasks: Optional[List[Dict[str, Any]]],
|
||||||
|
*,
|
||||||
|
sample_type_key: str,
|
||||||
|
) -> None:
|
||||||
"""只补母亲血液空项。共享任务里的脐血不参与。"""
|
"""只补母亲血液空项。共享任务里的脐血不参与。"""
|
||||||
shared = _serology_from_tasks(tasks or [], _MOTHER_SEROLOGY_RULES)
|
rules = (
|
||||||
|
_MOTHER_SEROLOGY_RULES_UC_MSC
|
||||||
|
if sample_type_key == "uc_msc"
|
||||||
|
else _MOTHER_SEROLOGY_RULES
|
||||||
|
)
|
||||||
|
shared = _serology_from_tasks(tasks or [], rules)
|
||||||
for key, value in shared.items():
|
for key, value in shared.items():
|
||||||
suggested.setdefault(key, value)
|
suggested.setdefault(key, value)
|
||||||
|
|
||||||
@@ -330,7 +345,7 @@ def build_suggested(
|
|||||||
if count:
|
if count:
|
||||||
suggested["available_cell_count_1e7"] = count
|
suggested["available_cell_count_1e7"] = count
|
||||||
suggested.update(_process_qual_from_tasks(process_tasks or []))
|
suggested.update(_process_qual_from_tasks(process_tasks or []))
|
||||||
suggested.update(_serology_from_tasks(gate_tasks or [], _MOTHER_SEROLOGY_RULES))
|
suggested.update(_serology_from_tasks(gate_tasks or [], _MOTHER_SEROLOGY_RULES_UC_MSC))
|
||||||
suggested.setdefault("bacteria_test", "阴性")
|
suggested.setdefault("bacteria_test", "阴性")
|
||||||
suggested.setdefault("result_judgment", "合格")
|
suggested.setdefault("result_judgment", "合格")
|
||||||
if freeze:
|
if freeze:
|
||||||
@@ -338,7 +353,7 @@ def build_suggested(
|
|||||||
suggested.update(_FIXED_COMMON)
|
suggested.update(_FIXED_COMMON)
|
||||||
suggested.update(_FIXED_UC_MSC)
|
suggested.update(_FIXED_UC_MSC)
|
||||||
if sample_type_key in ("perinatal_hsc", "uc_msc"):
|
if sample_type_key in ("perinatal_hsc", "uc_msc"):
|
||||||
_fill_shared_mother(suggested, shared_mother_tasks)
|
_fill_shared_mother(suggested, shared_mother_tasks, sample_type_key=sample_type_key)
|
||||||
return {key: value for key, value in suggested.items() if str(value).strip()}
|
return {key: value for key, value in suggested.items() if str(value).strip()}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2564,10 +2564,13 @@ def test_web_presign_list_includes_ledger_fields():
|
|||||||
order.mother_name = '陈影'
|
order.mother_name = '陈影'
|
||||||
transfer = _transfer('ledger-transfer', order_id='ledger-1', pay_status='yjf')
|
transfer = _transfer('ledger-transfer', order_id='ledger-1', pay_status='yjf')
|
||||||
transfer.transfer_time = datetime(2026, 4, 2, 16, 49, 42)
|
transfer.transfer_time = datetime(2026, 4, 2, 16, 49, 42)
|
||||||
|
pending = _transfer('ledger-pending', order_id='ledger-1', pay_status='dfj')
|
||||||
|
pending.transfer_time = datetime(2026, 4, 1, 10, 0, 0)
|
||||||
db.add_all(
|
db.add_all(
|
||||||
[
|
[
|
||||||
order,
|
order,
|
||||||
transfer,
|
transfer,
|
||||||
|
pending,
|
||||||
BizPresignOrderSampleType(
|
BizPresignOrderSampleType(
|
||||||
id='ledger-type',
|
id='ledger-type',
|
||||||
presign_order_id='ledger-1',
|
presign_order_id='ledger-1',
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
"""计划开始时间筛选:不内置工单/任务/步骤状态限制,交给外层组合条件。"""
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.dialects import mysql
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
from app.crud.production_work_order import apply_planned_start_time_step_filter
|
||||||
|
from app.models.models import BizProductionWorkOrder
|
||||||
|
|
||||||
|
|
||||||
|
def _compile_planned_start_sql() -> str:
|
||||||
|
eng = create_engine("sqlite://")
|
||||||
|
SessionLocal = sessionmaker(bind=eng)
|
||||||
|
db = SessionLocal()
|
||||||
|
try:
|
||||||
|
q = db.query(BizProductionWorkOrder).filter(BizProductionWorkOrder.del_flag == 0)
|
||||||
|
filtered = apply_planned_start_time_step_filter(
|
||||||
|
q,
|
||||||
|
tenant_no="zkxw",
|
||||||
|
work_order_id_column=BizProductionWorkOrder.id,
|
||||||
|
planned_start_time_start="2026-10-01",
|
||||||
|
planned_start_time_end="2026-12-31",
|
||||||
|
)
|
||||||
|
return str(
|
||||||
|
filtered.statement.compile(
|
||||||
|
dialect=mysql.dialect(), compile_kwargs={"literal_binds": True}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
def test_planned_start_filter_keeps_date_bounds_without_status_hardcodes():
|
||||||
|
sql = _compile_planned_start_sql().lower()
|
||||||
|
assert "planned_start_time" in sql
|
||||||
|
assert "2026-10-01 00:00:00" in sql
|
||||||
|
assert "2026-12-31 23:59:59" in sql
|
||||||
|
# 不再在 EXISTS 内强制待配置/进行中或未完成步骤
|
||||||
|
assert "work_order_status in (" not in sql
|
||||||
|
assert "task_status in (" not in sql
|
||||||
|
assert "step_status !=" not in sql
|
||||||
|
assert "step_status <>" not in sql
|
||||||
@@ -1,10 +1,18 @@
|
|||||||
"""协议列表可显式读取 V2 样本方案,其他费用摘要消费者保持原行为。"""
|
"""协议列表可显式读取 V2 样本方案,其他费用摘要消费者保持原行为。"""
|
||||||
|
from datetime import datetime
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
from app.models.base import Base
|
from app.models.base import Base
|
||||||
from app.models.models import BizProtocolSamplePayment
|
from app.models.models import (
|
||||||
|
BizProtocolPaymentSchedule,
|
||||||
|
BizProtocolPaymentTransfer,
|
||||||
|
BizProtocolRefundRecord,
|
||||||
|
BizProtocolSamplePayment,
|
||||||
|
)
|
||||||
from app.services.qc_work_order_fee_summary import build_protocol_payment_summaries
|
from app.services.qc_work_order_fee_summary import build_protocol_payment_summaries
|
||||||
|
|
||||||
|
|
||||||
@@ -31,3 +39,180 @@ def test_protocol_list_uses_active_tenant_v2_payment_modes(modes, expected, labe
|
|||||||
assert result['p1']['payModeLabel'] == label
|
assert result['p1']['payModeLabel'] == label
|
||||||
assert build_protocol_payment_summaries(db, ['p1'], 'tenant-a') == {}
|
assert build_protocol_payment_summaries(db, ['p1'], 'tenant-a') == {}
|
||||||
engine.dispose()
|
engine.dispose()
|
||||||
|
|
||||||
|
|
||||||
|
def test_protocol_list_fills_received_from_v2_sample_transfers():
|
||||||
|
engine = create_engine('sqlite:///:memory:')
|
||||||
|
Base.metadata.create_all(engine)
|
||||||
|
with sessionmaker(bind=engine)() as db:
|
||||||
|
db.add_all(
|
||||||
|
[
|
||||||
|
BizProtocolSamplePayment(
|
||||||
|
id='sp-dj',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S1',
|
||||||
|
pay_mode='dj',
|
||||||
|
contract_amount=Decimal('12800'),
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolSamplePayment(
|
||||||
|
id='sp-fq',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S2',
|
||||||
|
pay_mode='fq',
|
||||||
|
contract_amount=Decimal('22880'),
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentSchedule(
|
||||||
|
id='sch-dj-1',
|
||||||
|
sample_payment_id='sp-dj',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S1',
|
||||||
|
schedule_no=1,
|
||||||
|
due_amount=Decimal('12800'),
|
||||||
|
due_date='20260915',
|
||||||
|
schedule_status='cleared',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentSchedule(
|
||||||
|
id='sch-fq-1',
|
||||||
|
sample_payment_id='sp-fq',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S2',
|
||||||
|
schedule_no=1,
|
||||||
|
due_amount=Decimal('6480'),
|
||||||
|
due_date='20260915',
|
||||||
|
schedule_status='cleared',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentSchedule(
|
||||||
|
id='sch-fq-2',
|
||||||
|
sample_payment_id='sp-fq',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S2',
|
||||||
|
schedule_no=2,
|
||||||
|
due_amount=Decimal('16400'),
|
||||||
|
due_date='20261015',
|
||||||
|
schedule_status='open',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentTransfer(
|
||||||
|
id='tr-dj',
|
||||||
|
schedule_id='sch-dj-1',
|
||||||
|
sample_payment_id='sp-dj',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S1',
|
||||||
|
transfer_amount=Decimal('12800'),
|
||||||
|
transfer_time=datetime(2026, 9, 15, 12, 0, 0),
|
||||||
|
pay_status='yjf',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentTransfer(
|
||||||
|
id='tr-fq',
|
||||||
|
schedule_id='sch-fq-1',
|
||||||
|
sample_payment_id='sp-fq',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S2',
|
||||||
|
transfer_amount=Decimal('6480'),
|
||||||
|
transfer_time=datetime(2026, 9, 15, 11, 13, 1),
|
||||||
|
pay_status='yjf',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentTransfer(
|
||||||
|
id='tr-pending',
|
||||||
|
schedule_id='sch-fq-2',
|
||||||
|
sample_payment_id='sp-fq',
|
||||||
|
collection_protocol_id='p-v2',
|
||||||
|
sample_code='S2',
|
||||||
|
transfer_amount=None,
|
||||||
|
transfer_time=None,
|
||||||
|
pay_status='dfj',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
result = build_protocol_payment_summaries(
|
||||||
|
db, ['p-v2'], 'tenant-a', include_sample_payment_modes=True
|
||||||
|
)
|
||||||
|
summary = result['p-v2']
|
||||||
|
assert summary['payMode'] == 'djfq'
|
||||||
|
assert summary['contractAmount'] == 35680.0
|
||||||
|
assert summary['receivedAmount'] == 19280.0
|
||||||
|
assert summary['pendingAmount'] == 16400.0
|
||||||
|
details = summary['paymentDetails']
|
||||||
|
assert len(details) == 3
|
||||||
|
first = [d for d in details if d['installmentNo'] == 1]
|
||||||
|
assert sum(float(d['dueAmount'] or 0) for d in first) == 19280.0
|
||||||
|
assert sum(float(d['transferAmount'] or 0) for d in first) == 19280.0
|
||||||
|
# 未开启 include 时不补齐 V2 已收(质检费用摘要保持原语义)
|
||||||
|
plain = build_protocol_payment_summaries(db, ['p-v2'], 'tenant-a')
|
||||||
|
assert plain['p-v2'].get('receivedAmount') is None
|
||||||
|
assert plain['p-v2'].get('paymentDetails') == []
|
||||||
|
engine.dispose()
|
||||||
|
|
||||||
|
|
||||||
|
def test_protocol_list_fills_refund_amount_from_v2_refund_records():
|
||||||
|
engine = create_engine('sqlite:///:memory:')
|
||||||
|
Base.metadata.create_all(engine)
|
||||||
|
with sessionmaker(bind=engine)() as db:
|
||||||
|
db.add_all(
|
||||||
|
[
|
||||||
|
BizProtocolSamplePayment(
|
||||||
|
id='sp-void',
|
||||||
|
collection_protocol_id='p-void',
|
||||||
|
sample_code='S9',
|
||||||
|
pay_mode='dj',
|
||||||
|
contract_amount=Decimal('5000'),
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentSchedule(
|
||||||
|
id='sch-void',
|
||||||
|
sample_payment_id='sp-void',
|
||||||
|
collection_protocol_id='p-void',
|
||||||
|
sample_code='S9',
|
||||||
|
schedule_no=1,
|
||||||
|
due_amount=Decimal('5000'),
|
||||||
|
due_date='20260918',
|
||||||
|
schedule_status='cleared',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolPaymentTransfer(
|
||||||
|
id='tr-void',
|
||||||
|
schedule_id='sch-void',
|
||||||
|
sample_payment_id='sp-void',
|
||||||
|
collection_protocol_id='p-void',
|
||||||
|
sample_code='S9',
|
||||||
|
transfer_amount=Decimal('5000'),
|
||||||
|
transfer_time=datetime(2026, 9, 18, 14, 55, 4),
|
||||||
|
pay_status='yjf',
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
BizProtocolRefundRecord(
|
||||||
|
id='rf-void',
|
||||||
|
collection_protocol_id='p-void',
|
||||||
|
refund_amount=Decimal('5000'),
|
||||||
|
refund_time=datetime(2026, 9, 19, 10, 0, 0),
|
||||||
|
tenant_no='tenant-a',
|
||||||
|
del_flag=0,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
summary = build_protocol_payment_summaries(
|
||||||
|
db, ['p-void'], 'tenant-a', include_sample_payment_modes=True
|
||||||
|
)['p-void']
|
||||||
|
assert summary['receivedAmount'] == 5000.0
|
||||||
|
assert summary['refundAmount'] == 5000.0
|
||||||
|
engine.dispose()
|
||||||
@@ -10,6 +10,7 @@ from app.services.sample_storage_cert_qc import (
|
|||||||
empty_detail,
|
empty_detail,
|
||||||
normalize_payload,
|
normalize_payload,
|
||||||
resolve_sample_type_key,
|
resolve_sample_type_key,
|
||||||
|
sanitize_payload_for_type,
|
||||||
supports_storage_cert_qc,
|
supports_storage_cert_qc,
|
||||||
)
|
)
|
||||||
from app.services.sample_storage_cert_qc_prefill import (
|
from app.services.sample_storage_cert_qc_prefill import (
|
||||||
@@ -51,6 +52,34 @@ class TestNormalizePayload(unittest.TestCase):
|
|||||||
self.assertNotIn(1, out)
|
self.assertNotIn(1, out)
|
||||||
|
|
||||||
|
|
||||||
|
class TestSanitizePayloadForType(unittest.TestCase):
|
||||||
|
def test_uc_msc_drops_mother_nucleic_acids(self):
|
||||||
|
out = sanitize_payload_for_type(
|
||||||
|
{
|
||||||
|
"mother_hbsag": "阴性",
|
||||||
|
"mother_hbv_dna": "阴性",
|
||||||
|
"mother_hcv_rna": "阳性",
|
||||||
|
"mother_hiv1_rna": "阴性",
|
||||||
|
"mother_cmv_igm": "阴性",
|
||||||
|
},
|
||||||
|
SAMPLE_TYPE_KEY_UC_MSC,
|
||||||
|
)
|
||||||
|
self.assertEqual(out["mother_hbsag"], "阴性")
|
||||||
|
self.assertEqual(out["mother_cmv_igm"], "阴性")
|
||||||
|
self.assertNotIn("mother_hbv_dna", out)
|
||||||
|
self.assertNotIn("mother_hcv_rna", out)
|
||||||
|
self.assertNotIn("mother_hiv1_rna", out)
|
||||||
|
|
||||||
|
def test_perinatal_keeps_mother_nucleic_acids(self):
|
||||||
|
payload = {
|
||||||
|
"mother_hbv_dna": "阴性",
|
||||||
|
"mother_hcv_rna": "阴性",
|
||||||
|
"mother_hiv1_rna": "阴性",
|
||||||
|
}
|
||||||
|
out = sanitize_payload_for_type(payload, SAMPLE_TYPE_KEY_PERINATAL_HSC)
|
||||||
|
self.assertEqual(out, payload)
|
||||||
|
|
||||||
|
|
||||||
class TestEmptyDetail(unittest.TestCase):
|
class TestEmptyDetail(unittest.TestCase):
|
||||||
def test_shape(self):
|
def test_shape(self):
|
||||||
d = empty_detail(
|
d = empty_detail(
|
||||||
@@ -302,13 +331,13 @@ class TestStorageCertPrefill(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
suggested = build_suggested(sample_type_key="uc_msc", shared_mother_tasks=shared)
|
suggested = build_suggested(sample_type_key="uc_msc", shared_mother_tasks=shared)
|
||||||
self.assertEqual(suggested["mother_hbsag"], "阴性")
|
self.assertEqual(suggested["mother_hbsag"], "阴性")
|
||||||
self.assertEqual(suggested["mother_hbv_dna"], "阴性")
|
self.assertNotIn("mother_hbv_dna", suggested)
|
||||||
self.assertEqual(suggested["mother_anti_hcv"], "阴性")
|
self.assertEqual(suggested["mother_anti_hcv"], "阴性")
|
||||||
self.assertEqual(suggested["mother_hcv_rna"], "阴性")
|
self.assertNotIn("mother_hcv_rna", suggested)
|
||||||
self.assertEqual(suggested["mother_anti_tp"], "阴性")
|
self.assertEqual(suggested["mother_anti_tp"], "阴性")
|
||||||
self.assertEqual(suggested["mother_cmv_igm"], "阴性")
|
self.assertEqual(suggested["mother_cmv_igm"], "阴性")
|
||||||
self.assertEqual(suggested["mother_anti_hiv"], "阴性")
|
self.assertEqual(suggested["mother_anti_hiv"], "阴性")
|
||||||
self.assertEqual(suggested["mother_hiv1_rna"], "阴性")
|
self.assertNotIn("mother_hiv1_rna", suggested)
|
||||||
self.assertNotIn("hbsag", suggested)
|
self.assertNotIn("hbsag", suggested)
|
||||||
|
|
||||||
def test_own_mother_blood_wins_and_shared_only_fills_gaps(self):
|
def test_own_mother_blood_wins_and_shared_only_fills_gaps(self):
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ Agent 需要你做决定时,会在当前回复里直接写出「待你确认
|
|||||||
|
|
||||||
完整安装提供 `notify-question` 命令,由 Agent 在提问后调用,不是宿主自动弹窗钩子。当前支持用户 macOS 本机;其他系统或远程执行缺少本地播放条件时回退文字提醒,不代表你已听到。安装、更新、普通进度和结束答复不播放。细则见安装目录 `references/question-notification.md`。
|
完整安装提供 `notify-question` 命令,由 Agent 在提问后调用,不是宿主自动弹窗钩子。当前支持用户 macOS 本机;其他系统或远程执行缺少本地播放条件时回退文字提醒,不代表你已听到。安装、更新、普通进度和结束答复不播放。细则见安装目录 `references/question-notification.md`。
|
||||||
|
|
||||||
|
### 在 Cursor 里听到提示音却看不到题时
|
||||||
|
|
||||||
|
- 提示音在整机播放,**不会自动跳到对应聊天**;请到正在跑 Agent 的会话里搜索「待你确认」。
|
||||||
|
- 输入框上方的 **Queued / Start Multitasking** 是你排队的后续消息,**不是**确认清单。
|
||||||
|
- Cursor 会先跑工具再刷出最终正文,声音可能比清单早响一两秒;清单应出现在该轮助手正文开头。多会话并行时,切换其他进行中会话再搜一次。
|
||||||
|
- 工程内 Agent 适配约定见 [Cursor 确认可见性](cursor-question-visibility.md)。
|
||||||
|
|
||||||
## 日常开发怎么提需求
|
## 日常开发怎么提需求
|
||||||
|
|
||||||
| 场景 | 可以直接发送的示例 |
|
| 场景 | 可以直接发送的示例 |
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Cursor 宿主:确认问题可见性
|
||||||
|
|
||||||
|
个人开发体系要求:先在用户可见回复写出「待你确认」,再播放本机提示音。Cursor Agent 的执行顺序与此不完全同构,本文件是工程内的 Cursor 适配约定;与安装目录 `references/planning.md`、`references/question-notification.md` 并用,冲突时以「用户必须先看见清单」为准。
|
||||||
|
|
||||||
|
## Cursor 执行顺序
|
||||||
|
|
||||||
|
1. 同轮内的**工具调用先执行**,最终助手正文后出现。
|
||||||
|
2. `notify-question`(`afplay`)若作为工具调用,提示音可能比「待你确认」正文早数秒响起。
|
||||||
|
3. 提示音在**整机**播放,不绑定当前聚焦的聊天标签;多会话并行时,声音来源会话可能不是眼前这个。
|
||||||
|
4. 输入框上方的 **Queued / Start Multitasking** 是用户排队的后续消息,**不是** Agent 确认清单。
|
||||||
|
|
||||||
|
## Agent 必须遵守
|
||||||
|
|
||||||
|
发问当轮:
|
||||||
|
|
||||||
|
1. **先写清单**:该轮最终用户可见回复必须以「待你确认」开头(或紧接一句定位后立刻出现该标题),按问题展示规则写全题、推荐、理由与未回复处理。
|
||||||
|
2. **同轮停手**:写出清单并(如需)播放提示音后,本轮不得再调用编辑、浏览器、继续实现等工具;依赖答复的工作等下一轮。允许的独立只读工作若与本题无关,应在发问**之前**做完,或放到用户答复之后。
|
||||||
|
3. **提示音时机**:需要播放时,`notify-question` 必须是本轮**最后一次**工具调用,且本轮最终正文就是确认清单。禁止在仍计划继续工具批处理时提前播放。
|
||||||
|
4. **正文定位**:清单首段或标题下用一句说明「请在本会话回复;提示音不念题目,底部 Queued 不是确认入口。」
|
||||||
|
5. **无清单不播放**:最终正文没有「待你确认」时,不得调用 `notify-question`。
|
||||||
|
6. **原生卡片**:若当前 Cursor 会话提供宿主提问/确认卡片,可与清单并用,卡片内容须与「待你确认」一致;不得只用卡片、省略正文清单。
|
||||||
|
|
||||||
|
## 用户侧核对
|
||||||
|
|
||||||
|
听到「有问题待确认」时:
|
||||||
|
|
||||||
|
1. 看**正在或刚结束工具步骤的那个聊天**(不必先看 Queued)。
|
||||||
|
2. 在该会话搜索或上翻 **「待你确认」**;清单在工具时间线收折块之外的助手正文里。
|
||||||
|
3. 若多聊天并行,切换到其他进行中会话再搜同一标题。
|
||||||
|
|
||||||
|
## 静音与一分钟策略
|
||||||
|
|
||||||
|
声音开关、一分钟默认选择仍按安装目录规则;本文件不改变其语义,只约束 Cursor 下的展示与播音顺序。
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
-- Issue #24:协议单操作过程日志(before / action / after)
|
-- Issue #24:协议单操作过程日志(before / action / after)
|
||||||
-- MySQL 5.7;可重复执行(CREATE IF NOT EXISTS)。上线前须备份并在目标副本验证。
|
-- MySQL 5.7;可重复执行(CREATE IF NOT EXISTS)。上线前须备份并在目标副本验证。
|
||||||
-- DDL 隐式提交;该脚本不作为自动应用启动步骤。
|
-- DDL 隐式提交;该脚本不作为自动应用启动步骤。
|
||||||
|
--
|
||||||
|
-- 注意:若目标库已存在同名「采集协议单操作日志」旧表(含 collection_protocol_id /
|
||||||
|
-- operation_code 等列),本脚本会因 IF NOT EXISTS 直接跳过,不会纠偏。
|
||||||
|
-- 生产纠偏请改用:2026-11-09-protocol-operation-log-rebuild.sql
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS biz_protocol_operation_log (
|
CREATE TABLE IF NOT EXISTS biz_protocol_operation_log (
|
||||||
id VARCHAR(64) NOT NULL,
|
id VARCHAR(64) NOT NULL,
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
-- =============================================================================
|
||||||
|
-- 协议操作日志:兼容生产旧表同名冲突,重建为 Issue #24 模型
|
||||||
|
-- MySQL 5.7;可重复执行。上线前须备份,并在目标副本验证。
|
||||||
|
--
|
||||||
|
-- 背景:
|
||||||
|
-- 生产曾有「采集协议单操作日志」同名表(collection_protocol_id / operation_*),
|
||||||
|
-- 与当前代码(biz_type / before_json / after_json)不兼容。
|
||||||
|
-- 旧脚本 2026-11-05-protocol-operation-log.sql 使用 CREATE IF NOT EXISTS,
|
||||||
|
-- 遇到旧表会直接跳过,无法纠偏。本脚本用于生产纠偏与新环境兜底。
|
||||||
|
--
|
||||||
|
-- 行为:
|
||||||
|
-- 1) 已是新模型(有 biz_type)→ 跳过结构变更
|
||||||
|
-- 2) 旧模型且 0 行 → DROP 后按新模型 CREATE
|
||||||
|
-- 3) 旧模型且有数据 → RENAME 为 biz_protocol_operation_log_legacy_20261109 再 CREATE
|
||||||
|
-- 4) 表不存在 → 直接 CREATE
|
||||||
|
-- =============================================================================
|
||||||
|
|
||||||
|
SET @db := DATABASE();
|
||||||
|
|
||||||
|
SET @table_exists := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.tables
|
||||||
|
WHERE table_schema = @db AND table_name = 'biz_protocol_operation_log'
|
||||||
|
);
|
||||||
|
|
||||||
|
SET @has_legacy_col := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.columns
|
||||||
|
WHERE table_schema = @db
|
||||||
|
AND table_name = 'biz_protocol_operation_log'
|
||||||
|
AND column_name = 'collection_protocol_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
SET @has_new_col := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.columns
|
||||||
|
WHERE table_schema = @db
|
||||||
|
AND table_name = 'biz_protocol_operation_log'
|
||||||
|
AND column_name = 'biz_type'
|
||||||
|
);
|
||||||
|
|
||||||
|
SET @is_legacy := IF(@table_exists > 0 AND @has_legacy_col > 0 AND @has_new_col = 0, 1, 0);
|
||||||
|
|
||||||
|
SET @legacy_rows := 0;
|
||||||
|
SET @cnt_sql := IF(
|
||||||
|
@is_legacy = 1,
|
||||||
|
'SET @legacy_rows = (SELECT COUNT(*) FROM `biz_protocol_operation_log`)',
|
||||||
|
'SET @legacy_rows = 0'
|
||||||
|
);
|
||||||
|
PREPARE pol_stmt FROM @cnt_sql;
|
||||||
|
EXECUTE pol_stmt;
|
||||||
|
DEALLOCATE PREPARE pol_stmt;
|
||||||
|
|
||||||
|
-- 空旧表:直接删除
|
||||||
|
SET @drop_sql := IF(
|
||||||
|
@is_legacy = 1 AND @legacy_rows = 0,
|
||||||
|
'DROP TABLE `biz_protocol_operation_log`',
|
||||||
|
'SELECT ''skip drop empty legacy biz_protocol_operation_log'' AS migration_status'
|
||||||
|
);
|
||||||
|
PREPARE pol_stmt FROM @drop_sql;
|
||||||
|
EXECUTE pol_stmt;
|
||||||
|
DEALLOCATE PREPARE pol_stmt;
|
||||||
|
|
||||||
|
-- 有数据的旧表:改名保留,避免丢历史(当前生产为 0 行,通常不会走到这里)
|
||||||
|
SET @legacy_backup_exists := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.tables
|
||||||
|
WHERE table_schema = @db AND table_name = 'biz_protocol_operation_log_legacy_20261109'
|
||||||
|
);
|
||||||
|
SET @rename_sql := IF(
|
||||||
|
@is_legacy = 1 AND @legacy_rows > 0 AND @legacy_backup_exists = 0,
|
||||||
|
'RENAME TABLE `biz_protocol_operation_log` TO `biz_protocol_operation_log_legacy_20261109`',
|
||||||
|
IF(
|
||||||
|
@is_legacy = 1 AND @legacy_rows > 0 AND @legacy_backup_exists > 0,
|
||||||
|
'SELECT ''ERROR: legacy backup biz_protocol_operation_log_legacy_20261109 already exists; resolve manually'' AS migration_status',
|
||||||
|
'SELECT ''skip rename legacy biz_protocol_operation_log'' AS migration_status'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
PREPARE pol_stmt FROM @rename_sql;
|
||||||
|
EXECUTE pol_stmt;
|
||||||
|
DEALLOCATE PREPARE pol_stmt;
|
||||||
|
|
||||||
|
-- 新模型建表(纠偏后或全新环境)
|
||||||
|
CREATE TABLE IF NOT EXISTS `biz_protocol_operation_log` (
|
||||||
|
`id` VARCHAR(64) NOT NULL COMMENT '主键ID',
|
||||||
|
`biz_type` VARCHAR(32) NOT NULL COMMENT '业务类型 cell_storage/research_donation',
|
||||||
|
`biz_id` VARCHAR(64) NOT NULL COMMENT '协议单或捐赠单ID',
|
||||||
|
`protocol_no` VARCHAR(64) NULL COMMENT '协议/捐赠编号快照',
|
||||||
|
`action` VARCHAR(32) NOT NULL COMMENT '动作 create/update/delete/void/activate/expire/to_research/to_storage/audit',
|
||||||
|
`client_channel` VARCHAR(16) NOT NULL DEFAULT 'web' COMMENT '来源端 web/mini',
|
||||||
|
`before_json` MEDIUMTEXT NULL COMMENT '操作前协议信息JSON',
|
||||||
|
`after_json` MEDIUMTEXT NULL COMMENT '操作后协议信息JSON',
|
||||||
|
`operator_user_id` VARCHAR(64) NULL COMMENT '操作人用户ID',
|
||||||
|
`operator_user_name` VARCHAR(64) NULL COMMENT '操作人姓名快照',
|
||||||
|
`operate_time` DATETIME NOT NULL COMMENT '业务操作时间',
|
||||||
|
`tenant_no` VARCHAR(64) NOT NULL COMMENT '租户编号',
|
||||||
|
`order_num` INT NULL COMMENT '排序号',
|
||||||
|
`remark` VARCHAR(512) NULL COMMENT '备注',
|
||||||
|
`create_by` VARCHAR(64) NULL COMMENT '创建人id',
|
||||||
|
`create_dept_id` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
|
||||||
|
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_by` VARCHAR(64) NULL COMMENT '更新人id',
|
||||||
|
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
`del_flag` SMALLINT NOT NULL DEFAULT 0 COMMENT '删除标记',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `ix_pol_biz` (`tenant_no`, `biz_type`, `biz_id`, `del_flag`),
|
||||||
|
KEY `ix_pol_time` (`tenant_no`, `operate_time`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='协议单操作过程日志';
|
||||||
|
|
||||||
|
-- 验收:新模型关键列应存在
|
||||||
|
SELECT
|
||||||
|
COLUMN_NAME,
|
||||||
|
COLUMN_TYPE,
|
||||||
|
IS_NULLABLE,
|
||||||
|
COLUMN_COMMENT
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'biz_protocol_operation_log'
|
||||||
|
AND COLUMN_NAME IN (
|
||||||
|
'biz_type', 'biz_id', 'action', 'before_json', 'after_json',
|
||||||
|
'client_channel', 'operate_time', 'collection_protocol_id', 'operation_code'
|
||||||
|
)
|
||||||
|
ORDER BY ORDINAL_POSITION;
|
||||||
@@ -49,11 +49,11 @@
|
|||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
/* 小程序特有相关 */
|
/* 小程序特有相关 */
|
||||||
/* 当前:生产 AppID;切测试时把 appid 改为下方测试值 */
|
/* 当前:测试 AppID;切生产时把 appid 改为下方生产值 */
|
||||||
/* 生产 AppID:wx2b139581f4c855e4 */
|
/* 生产 AppID:wx2b139581f4c855e4 */
|
||||||
/* 测试 AppID:wxa261ad85f2c99b26 */
|
/* 测试 AppID:wxa261ad85f2c99b26 */
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "wx2b139581f4c855e4",
|
"appid" : "wxa261ad85f2c99b26",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : false,
|
"urlCheck" : false,
|
||||||
"es6" : true
|
"es6" : true
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* 微信公众平台须为对应环境配置 request / 业务域名(HTTPS)
|
* 微信公众平台须为对应环境配置 request / 业务域名(HTTPS)
|
||||||
*/
|
*/
|
||||||
export const APP_ENV = 'prod' // 'local' | 'test' | 'prod'
|
export const APP_ENV = 'local' // 'local' | 'test' | 'prod'
|
||||||
|
|
||||||
const ENV_PRESETS = {
|
const ENV_PRESETS = {
|
||||||
local: {
|
local: {
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import {
|
|||||||
buildFreightMergeRanges,
|
buildFreightMergeRanges,
|
||||||
buildPresignLedgerRows,
|
buildPresignLedgerRows,
|
||||||
buildResearchLedgerRows,
|
buildResearchLedgerRows,
|
||||||
formatLedgerDateTime
|
formatLedgerDateTime,
|
||||||
|
groupFlatRowsByFreightBatch
|
||||||
} from './collection-ledger-export'
|
} from './collection-ledger-export'
|
||||||
import type { ProtocolAuditFlatRow } from './protocol-audit-flatten'
|
import type { ProtocolAuditFlatRow } from './protocol-audit-flatten'
|
||||||
|
|
||||||
@@ -194,6 +195,71 @@ describe('buildCellStorageLedgerRows', () => {
|
|||||||
{ startRow: 2, endRow: 3, startCol: 54, endCol: 54 }
|
{ startRow: 2, endRow: 3, startCol: 54, endCol: 54 }
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('groups non-adjacent same freight batch before merging cells', () => {
|
||||||
|
const shared = {
|
||||||
|
protocol: { protocolStatus: 'sxz', remark: '', voidType: '', voidDesc: '' },
|
||||||
|
sampleCollectTime: '2025-09-11 18:13:00',
|
||||||
|
sampleTypeName: 'NK',
|
||||||
|
regionName: '常州',
|
||||||
|
hospitalName: '溧阳市人民医院',
|
||||||
|
freightTransportLabel: '专线车',
|
||||||
|
freightAmountLabel: '100'
|
||||||
|
}
|
||||||
|
const { rows, merges } = buildCellStorageLedgerRows([
|
||||||
|
{
|
||||||
|
...shared,
|
||||||
|
motherName: '甲',
|
||||||
|
sampleCode: 'S1',
|
||||||
|
labStorageCode: 'UBMC1',
|
||||||
|
freightId: 'batch-cell'
|
||||||
|
} as unknown as ProtocolAuditFlatRow,
|
||||||
|
{
|
||||||
|
...shared,
|
||||||
|
motherName: '丙',
|
||||||
|
sampleCode: 'S3',
|
||||||
|
labStorageCode: 'UBMC3',
|
||||||
|
freightId: 'other',
|
||||||
|
freightTransportLabel: '快递',
|
||||||
|
freightAmountLabel: '25'
|
||||||
|
} as unknown as ProtocolAuditFlatRow,
|
||||||
|
{
|
||||||
|
...shared,
|
||||||
|
motherName: '乙',
|
||||||
|
sampleCode: 'S2',
|
||||||
|
labStorageCode: 'UBMC2',
|
||||||
|
freightId: 'batch-cell'
|
||||||
|
} as unknown as ProtocolAuditFlatRow
|
||||||
|
])
|
||||||
|
assert.equal(rows[0][8], '甲')
|
||||||
|
assert.equal(rows[1][8], '乙')
|
||||||
|
assert.equal(rows[2][8], '丙')
|
||||||
|
assert.equal(rows[0][52], '专线车')
|
||||||
|
assert.equal(rows[0][53], '100')
|
||||||
|
assert.equal(rows[1][52], '')
|
||||||
|
assert.equal(rows[1][53], '')
|
||||||
|
assert.equal(rows[2][52], '快递')
|
||||||
|
assert.equal(rows[2][53], '25')
|
||||||
|
assert.deepEqual(merges, [
|
||||||
|
{ startRow: 2, endRow: 3, startCol: 53, endCol: 53 },
|
||||||
|
{ startRow: 2, endRow: 3, startCol: 54, endCol: 54 }
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('groupFlatRowsByFreightBatch', () => {
|
||||||
|
it('keeps first-seen batch order and leaves empty freight rows in place', () => {
|
||||||
|
const arranged = groupFlatRowsByFreightBatch([
|
||||||
|
{ motherName: 'A', freightId: 'f1' },
|
||||||
|
{ motherName: 'B', freightId: '' },
|
||||||
|
{ motherName: 'C', freightId: 'f1' },
|
||||||
|
{ motherName: 'D', freightId: 'f2' }
|
||||||
|
] as unknown as ProtocolAuditFlatRow[])
|
||||||
|
assert.deepEqual(
|
||||||
|
arranged.map((row) => row.motherName),
|
||||||
|
['A', 'C', 'B', 'D']
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('buildResearchLedgerRows', () => {
|
describe('buildResearchLedgerRows', () => {
|
||||||
@@ -335,6 +401,50 @@ describe('buildResearchLedgerRows', () => {
|
|||||||
{ startRow: 3, endRow: 4, startCol: 18, endCol: 18 }
|
{ startRow: 3, endRow: 4, startCol: 18, endCol: 18 }
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('groups non-adjacent same freight batch before merging research cells', () => {
|
||||||
|
const shared = {
|
||||||
|
protocol: { donationStatus: 'sxz', voidType: '', voidDesc: '', monthlyVerifyNo: '' },
|
||||||
|
sampleCollectTime: '2025-09-11 18:13:00',
|
||||||
|
sampleTypeName: 'NK',
|
||||||
|
regionName: '常州',
|
||||||
|
hospitalName: '溧阳市人民医院',
|
||||||
|
freightTransportLabel: '专线车',
|
||||||
|
freightAmountLabel: '100'
|
||||||
|
}
|
||||||
|
const { rows, merges } = buildResearchLedgerRows([
|
||||||
|
{
|
||||||
|
...shared,
|
||||||
|
motherName: '甲',
|
||||||
|
labStorageCode: 'A1',
|
||||||
|
freightId: 'batch-a'
|
||||||
|
} as unknown as ProtocolAuditFlatRow,
|
||||||
|
{
|
||||||
|
...shared,
|
||||||
|
motherName: '散',
|
||||||
|
labStorageCode: 'A9',
|
||||||
|
freightId: '',
|
||||||
|
freightTransportLabel: '',
|
||||||
|
freightAmountLabel: ''
|
||||||
|
} as unknown as ProtocolAuditFlatRow,
|
||||||
|
{
|
||||||
|
...shared,
|
||||||
|
motherName: '乙',
|
||||||
|
labStorageCode: 'A2',
|
||||||
|
freightId: 'batch-a'
|
||||||
|
} as unknown as ProtocolAuditFlatRow
|
||||||
|
])
|
||||||
|
assert.equal(rows[0][8], '甲')
|
||||||
|
assert.equal(rows[1][8], '乙')
|
||||||
|
assert.equal(rows[2][8], '散')
|
||||||
|
assert.equal(rows[0][16], '专线车')
|
||||||
|
assert.equal(rows[1][16], '')
|
||||||
|
assert.equal(rows[1][17], '')
|
||||||
|
assert.deepEqual(merges, [
|
||||||
|
{ startRow: 2, endRow: 3, startCol: 17, endCol: 17 },
|
||||||
|
{ startRow: 2, endRow: 3, startCol: 18, endCol: 18 }
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('buildCustomerServiceLedgerRows', () => {
|
describe('buildCustomerServiceLedgerRows', () => {
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import type { ProtocolAuditFlatRow } from './protocol-audit-flatten'
|
import type { ProtocolAuditFlatRow } from './protocol-audit-flatten'
|
||||||
|
|
||||||
/** 采集大表导出入口开关;验收未完成前隐藏按钮,改 true 即可恢复。 */
|
|
||||||
export const COLLECTION_LEDGER_EXPORT_ENABLED = false
|
|
||||||
|
|
||||||
type Row = Record<string, unknown>
|
type Row = Record<string, unknown>
|
||||||
type PayDetail = {
|
type PayDetail = {
|
||||||
installmentNo?: number | null
|
installmentNo?: number | null
|
||||||
@@ -341,6 +338,36 @@ function researchMaternalBloodText(value: unknown): string {
|
|||||||
return text(value) ? text(value) : '无母血'
|
return text(value) ? text(value) : '无母血'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将同一运费批次的行聚拢到一起(按首次出现顺序),无批次行保持相对位置。
|
||||||
|
* 模版要求同批次运输方式/运费合并单元格,故导出前先归拢再合并。
|
||||||
|
*/
|
||||||
|
export function groupFlatRowsByFreightBatch(
|
||||||
|
rows: ProtocolAuditFlatRow[]
|
||||||
|
): ProtocolAuditFlatRow[] {
|
||||||
|
const groups = new Map<string, ProtocolAuditFlatRow[]>()
|
||||||
|
const sequence: Array<{ kind: 'batch'; id: string } | { kind: 'single'; row: ProtocolAuditFlatRow }> =
|
||||||
|
[]
|
||||||
|
for (const row of rows) {
|
||||||
|
const freightId = text(row.freightId)
|
||||||
|
if (!freightId) {
|
||||||
|
sequence.push({ kind: 'single', row })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!groups.has(freightId)) {
|
||||||
|
groups.set(freightId, [])
|
||||||
|
sequence.push({ kind: 'batch', id: freightId })
|
||||||
|
}
|
||||||
|
groups.get(freightId)!.push(row)
|
||||||
|
}
|
||||||
|
const arranged: ProtocolAuditFlatRow[] = []
|
||||||
|
for (const item of sequence) {
|
||||||
|
if (item.kind === 'single') arranged.push(item.row)
|
||||||
|
else arranged.push(...(groups.get(item.id) || []))
|
||||||
|
}
|
||||||
|
return arranged
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 相邻且 freightId 相同的导出行,合并运输方式/运费列(Excel 行号含表头)。
|
* 相邻且 freightId 相同的导出行,合并运输方式/运费列(Excel 行号含表头)。
|
||||||
* @param transportCol 运输方式列(1-based)
|
* @param transportCol 运输方式列(1-based)
|
||||||
@@ -626,9 +653,10 @@ export function buildCellStorageLedgerRows(rows: ProtocolAuditFlatRow[]): {
|
|||||||
rows: string[][]
|
rows: string[][]
|
||||||
merges: LedgerMergeRange[]
|
merges: LedgerMergeRange[]
|
||||||
} {
|
} {
|
||||||
const freightIds = rows.map((row) => text(row.freightId))
|
const arranged = groupFlatRowsByFreightBatch(rows)
|
||||||
const built = rows.map((row, index) => storageLedgerRow(row, index, false))
|
const freightIds = arranged.map((row) => text(row.freightId))
|
||||||
// 自存表:运输方式=53,运费=54
|
const built = arranged.map((row, index) => storageLedgerRow(row, index, false))
|
||||||
|
// 自存表:运输方式=53,运费=54(对齐模版《自存表》)
|
||||||
return { rows: built, merges: applyFreightMerges(built, freightIds, 53, 54) }
|
return { rows: built, merges: applyFreightMerges(built, freightIds, 53, 54) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,9 +664,10 @@ export function buildResearchLedgerRows(rows: ProtocolAuditFlatRow[]): {
|
|||||||
rows: string[][]
|
rows: string[][]
|
||||||
merges: LedgerMergeRange[]
|
merges: LedgerMergeRange[]
|
||||||
} {
|
} {
|
||||||
const freightIds = rows.map((row) => text(row.freightId))
|
const arranged = groupFlatRowsByFreightBatch(rows)
|
||||||
const built = rows.map((row, index) => storageLedgerRow(row, index, true))
|
const freightIds = arranged.map((row) => text(row.freightId))
|
||||||
// 科研表:运输方式=17,运费=18
|
const built = arranged.map((row, index) => storageLedgerRow(row, index, true))
|
||||||
|
// 科研表:运输方式=17,运费=18(对齐模版《科研表》)
|
||||||
return { rows: built, merges: applyFreightMerges(built, freightIds, 17, 18) }
|
return { rows: built, merges: applyFreightMerges(built, freightIds, 17, 18) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,6 +733,19 @@ function fileStamp(): string {
|
|||||||
return `${stamp.getFullYear()}${pad(stamp.getMonth() + 1)}${pad(stamp.getDate())}${pad(stamp.getHours())}${pad(stamp.getMinutes())}${pad(stamp.getSeconds())}`
|
return `${stamp.getFullYear()}${pad(stamp.getMonth() + 1)}${pad(stamp.getDate())}${pad(stamp.getHours())}${pad(stamp.getMinutes())}${pad(stamp.getSeconds())}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const LEDGER_CELL_BORDER = {
|
||||||
|
top: { style: 'thin' as const },
|
||||||
|
left: { style: 'thin' as const },
|
||||||
|
bottom: { style: 'thin' as const },
|
||||||
|
right: { style: 'thin' as const }
|
||||||
|
}
|
||||||
|
|
||||||
|
const LEDGER_HEADER_FILL = {
|
||||||
|
type: 'pattern' as const,
|
||||||
|
pattern: 'solid' as const,
|
||||||
|
fgColor: { argb: 'FFFFFF00' }
|
||||||
|
}
|
||||||
|
|
||||||
export async function saveCollectionLedgerWorkbook(
|
export async function saveCollectionLedgerWorkbook(
|
||||||
sheetName: string,
|
sheetName: string,
|
||||||
headers: string[],
|
headers: string[],
|
||||||
@@ -715,25 +757,31 @@ export async function saveCollectionLedgerWorkbook(
|
|||||||
const FileSaver = (await import('file-saver')).default
|
const FileSaver = (await import('file-saver')).default
|
||||||
const workbook = new ExcelJS.Workbook()
|
const workbook = new ExcelJS.Workbook()
|
||||||
const sheet = workbook.addWorksheet(sheetName)
|
const sheet = workbook.addWorksheet(sheetName)
|
||||||
|
const colCount = headers.length
|
||||||
const headerRow = sheet.addRow(headers)
|
const headerRow = sheet.addRow(headers)
|
||||||
headerRow.eachCell((cell) => {
|
for (let col = 1; col <= colCount; col += 1) {
|
||||||
|
const cell = headerRow.getCell(col)
|
||||||
cell.numFmt = '@'
|
cell.numFmt = '@'
|
||||||
cell.alignment = { wrapText: true, vertical: 'middle' }
|
cell.alignment = { wrapText: true, vertical: 'middle', horizontal: 'center' }
|
||||||
})
|
cell.fill = LEDGER_HEADER_FILL
|
||||||
|
cell.border = LEDGER_CELL_BORDER
|
||||||
|
}
|
||||||
rows.forEach((line) => {
|
rows.forEach((line) => {
|
||||||
const added = sheet.addRow(line)
|
const added = sheet.addRow(line)
|
||||||
line.forEach((value, index) => {
|
for (let col = 1; col <= colCount; col += 1) {
|
||||||
const cell = added.getCell(index + 1)
|
const cell = added.getCell(col)
|
||||||
cell.value = value
|
cell.value = line[col - 1] ?? ''
|
||||||
cell.numFmt = '@'
|
cell.numFmt = '@'
|
||||||
cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true }
|
cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true }
|
||||||
})
|
cell.border = LEDGER_CELL_BORDER
|
||||||
|
}
|
||||||
})
|
})
|
||||||
merges.forEach((merge) => {
|
merges.forEach((merge) => {
|
||||||
if (merge.endRow <= merge.startRow) return
|
if (merge.endRow <= merge.startRow) return
|
||||||
sheet.mergeCells(merge.startRow, merge.startCol, merge.endRow, merge.endCol)
|
sheet.mergeCells(merge.startRow, merge.startCol, merge.endRow, merge.endCol)
|
||||||
const cell = sheet.getCell(merge.startRow, merge.startCol)
|
const cell = sheet.getCell(merge.startRow, merge.startCol)
|
||||||
cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true }
|
cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true }
|
||||||
|
cell.border = LEDGER_CELL_BORDER
|
||||||
})
|
})
|
||||||
headers.forEach((header, index) => {
|
headers.forEach((header, index) => {
|
||||||
sheet.getColumn(index + 1).width = Math.min(28, Math.max(12, header.replace(/\n/g, '').length + 2))
|
sheet.getColumn(index + 1).width = Math.min(28, Math.max(12, header.replace(/\n/g, '').length + 2))
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ export function supportsStorageCertQc(sampleTypeName?: string | null): boolean {
|
|||||||
return resolveStorageCertQcTypeKey(sampleTypeName) != null
|
return resolveStorageCertQcTypeKey(sampleTypeName) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
const MOTHER_BLOOD: StorageCertQcField[] = [
|
/** 围产期造血:母亲血液含三项核酸检测。 */
|
||||||
|
const MOTHER_BLOOD_PERINATAL: StorageCertQcField[] = [
|
||||||
{ key: 'mother_hbsag', label: '乙型肝炎病毒表面抗原(HBsAg)', control: 'select_yny' },
|
{ key: 'mother_hbsag', label: '乙型肝炎病毒表面抗原(HBsAg)', control: 'select_yny' },
|
||||||
{ key: 'mother_hbv_dna', label: '乙型肝炎病毒核酸(HBV DNA)', control: 'select_yny' },
|
{ key: 'mother_hbv_dna', label: '乙型肝炎病毒核酸(HBV DNA)', control: 'select_yny' },
|
||||||
{ key: 'mother_anti_hcv', label: '丙型肝炎病毒抗体(抗HCV)', control: 'select_yny' },
|
{ key: 'mother_anti_hcv', label: '丙型肝炎病毒抗体(抗HCV)', control: 'select_yny' },
|
||||||
@@ -48,6 +49,15 @@ const MOTHER_BLOOD: StorageCertQcField[] = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/** 脐带间充质:不展示 HBV DNA / HCV RNA / HIV-1RNA。 */
|
||||||
|
const MOTHER_BLOOD_UC_MSC: StorageCertQcField[] = [
|
||||||
|
{ key: 'mother_hbsag', label: '乙型肝炎病毒表面抗原(HBsAg)', control: 'select_yny' },
|
||||||
|
{ key: 'mother_anti_hcv', label: '丙型肝炎病毒抗体(抗HCV)', control: 'select_yny' },
|
||||||
|
{ key: 'mother_anti_tp', label: '梅毒螺旋体特异性抗体(抗TP)', control: 'select_yny' },
|
||||||
|
{ key: 'mother_cmv_igm', label: '巨细胞病毒 IgM 抗体 (CMV IgM)', control: 'select_yny' },
|
||||||
|
{ key: 'mother_anti_hiv', label: '人类免疫缺陷病毒抗体(抗HIV-1/2)', control: 'select_yny' }
|
||||||
|
]
|
||||||
|
|
||||||
export const STORAGE_CERT_QC_GROUPS: Record<StorageCertQcTypeKey, StorageCertQcGroup[]> = {
|
export const STORAGE_CERT_QC_GROUPS: Record<StorageCertQcTypeKey, StorageCertQcGroup[]> = {
|
||||||
perinatal_hsc: [
|
perinatal_hsc: [
|
||||||
{
|
{
|
||||||
@@ -77,7 +87,7 @@ export const STORAGE_CERT_QC_GROUPS: Record<StorageCertQcTypeKey, StorageCertQcG
|
|||||||
{ key: 'cmv_igm', label: '巨细胞病毒 IgM 抗体 (CMV-IgM)', control: 'select_yny' }
|
{ key: 'cmv_igm', label: '巨细胞病毒 IgM 抗体 (CMV-IgM)', control: 'select_yny' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ title: '母亲血液检测报告', variant: 'primary', fields: MOTHER_BLOOD },
|
{ title: '母亲血液检测报告', variant: 'primary', fields: MOTHER_BLOOD_PERINATAL },
|
||||||
{
|
{
|
||||||
title: '储存证收尾信息',
|
title: '储存证收尾信息',
|
||||||
variant: 'meta',
|
variant: 'meta',
|
||||||
@@ -120,7 +130,7 @@ export const STORAGE_CERT_QC_GROUPS: Record<StorageCertQcTypeKey, StorageCertQcG
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ title: '母亲血液检测报告', variant: 'primary', fields: MOTHER_BLOOD },
|
{ title: '母亲血液检测报告', variant: 'primary', fields: MOTHER_BLOOD_UC_MSC },
|
||||||
{
|
{
|
||||||
title: '储存证收尾信息',
|
title: '储存证收尾信息',
|
||||||
variant: 'meta',
|
variant: 'meta',
|
||||||
|
|||||||
@@ -56,12 +56,7 @@
|
|||||||
<el-icon><Plus /></el-icon>
|
<el-icon><Plus /></el-icon>
|
||||||
新增预签约
|
新增预签约
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button class="btn-ghost" :loading="exporting" @click="handleExport">
|
||||||
v-if="COLLECTION_LEDGER_EXPORT_ENABLED"
|
|
||||||
class="btn-ghost"
|
|
||||||
:loading="exporting"
|
|
||||||
@click="handleExport"
|
|
||||||
>
|
|
||||||
<el-icon><Download /></el-icon>
|
<el-icon><Download /></el-icon>
|
||||||
导出 Excel
|
导出 Excel
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -208,7 +203,6 @@
|
|||||||
import { Plus, Search, RefreshLeft, Edit, Delete, Check, Download } from '@element-plus/icons-vue'
|
import { Plus, Search, RefreshLeft, Edit, Delete, Check, Download } from '@element-plus/icons-vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
COLLECTION_LEDGER_EXPORT_ENABLED,
|
|
||||||
buildPresignLedgerRows,
|
buildPresignLedgerRows,
|
||||||
fetchAllPages,
|
fetchAllPages,
|
||||||
PRESIGN_HEADERS,
|
PRESIGN_HEADERS,
|
||||||
|
|||||||
@@ -75,12 +75,7 @@
|
|||||||
<el-icon><Plus /></el-icon>
|
<el-icon><Plus /></el-icon>
|
||||||
新增
|
新增
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button class="btn-ghost" :loading="exporting" @click="handleExport">
|
||||||
v-if="COLLECTION_LEDGER_EXPORT_ENABLED"
|
|
||||||
class="btn-ghost"
|
|
||||||
:loading="exporting"
|
|
||||||
@click="handleExport"
|
|
||||||
>
|
|
||||||
<el-icon><Download /></el-icon>
|
<el-icon><Download /></el-icon>
|
||||||
导出 Excel
|
导出 Excel
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -467,7 +462,6 @@
|
|||||||
} from '@/utils/protocol-doc-label'
|
} from '@/utils/protocol-doc-label'
|
||||||
import { loadVoidTypeDict } from '@/utils/void-type-dict'
|
import { loadVoidTypeDict } from '@/utils/void-type-dict'
|
||||||
import {
|
import {
|
||||||
COLLECTION_LEDGER_EXPORT_ENABLED,
|
|
||||||
RESEARCH_HEADERS,
|
RESEARCH_HEADERS,
|
||||||
buildResearchLedgerRows,
|
buildResearchLedgerRows,
|
||||||
fetchAllPages,
|
fetchAllPages,
|
||||||
|
|||||||
@@ -79,12 +79,7 @@
|
|||||||
<el-icon><Plus /></el-icon>
|
<el-icon><Plus /></el-icon>
|
||||||
新增
|
新增
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button class="btn-ghost" :loading="exporting" @click="handleExport">
|
||||||
v-if="COLLECTION_LEDGER_EXPORT_ENABLED"
|
|
||||||
class="btn-ghost"
|
|
||||||
:loading="exporting"
|
|
||||||
@click="handleExport"
|
|
||||||
>
|
|
||||||
<el-icon><Download /></el-icon>
|
<el-icon><Download /></el-icon>
|
||||||
导出 Excel
|
导出 Excel
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -435,7 +430,6 @@
|
|||||||
} from '@/utils/status-tag-registry'
|
} from '@/utils/status-tag-registry'
|
||||||
import { loadVoidTypeDict } from '@/utils/void-type-dict'
|
import { loadVoidTypeDict } from '@/utils/void-type-dict'
|
||||||
import {
|
import {
|
||||||
COLLECTION_LEDGER_EXPORT_ENABLED,
|
|
||||||
CELL_STORAGE_HEADERS,
|
CELL_STORAGE_HEADERS,
|
||||||
buildCellStorageLedgerRows,
|
buildCellStorageLedgerRows,
|
||||||
fetchAllPages,
|
fetchAllPages,
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
登记入库
|
登记入库
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="isCellStorage && COLLECTION_LEDGER_EXPORT_ENABLED"
|
v-if="isCellStorage"
|
||||||
class="btn-ghost"
|
class="btn-ghost"
|
||||||
:loading="exporting"
|
:loading="exporting"
|
||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
@@ -522,7 +522,6 @@
|
|||||||
sampleStorageFlagTagType
|
sampleStorageFlagTagType
|
||||||
} from '@/utils/status-tag-registry'
|
} from '@/utils/status-tag-registry'
|
||||||
import {
|
import {
|
||||||
COLLECTION_LEDGER_EXPORT_ENABLED,
|
|
||||||
CUSTOMER_SERVICE_HEADERS,
|
CUSTOMER_SERVICE_HEADERS,
|
||||||
buildCustomerServiceLedgerRows,
|
buildCustomerServiceLedgerRows,
|
||||||
fetchAllPages,
|
fetchAllPages,
|
||||||
|
|||||||
@@ -78,15 +78,41 @@
|
|||||||
<el-icon><RefreshRight /></el-icon>重试
|
<el-icon><RefreshRight /></el-icon>重试
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
|
<div v-if="assignment" class="list-toolbar">
|
||||||
|
<div class="list-toolbar-row">
|
||||||
|
<div class="list-toolbar-selected">
|
||||||
|
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||||
|
</div>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
class="btn-main"
|
||||||
|
:disabled="!selectedRows.length || busy"
|
||||||
|
@click="openBatch"
|
||||||
|
>
|
||||||
|
<el-icon><Edit /></el-icon>批量调整归属
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="list-body list-wrap"
|
<div class="list-body list-wrap"
|
||||||
><el-table
|
><el-table
|
||||||
|
ref="tableRef"
|
||||||
:key="query.bizType"
|
:key="query.bizType"
|
||||||
:data="rows"
|
:data="rows"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
class="list-table"
|
class="list-table"
|
||||||
stripe
|
stripe
|
||||||
|
row-key="id"
|
||||||
:empty-text="loading ? '正在加载…' : loadError ? '数据加载失败' : '暂无符合条件的单据'"
|
:empty-text="loading ? '正在加载…' : loadError ? '数据加载失败' : '暂无符合条件的单据'"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
|
<el-table-column
|
||||||
|
v-if="assignment"
|
||||||
|
type="selection"
|
||||||
|
min-width="48"
|
||||||
|
align="center"
|
||||||
|
header-align="center"
|
||||||
|
fixed
|
||||||
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
type="index"
|
type="index"
|
||||||
label="序号"
|
label="序号"
|
||||||
@@ -151,26 +177,26 @@
|
|||||||
>
|
>
|
||||||
<el-form class="form-grid-2" label-position="top">
|
<el-form class="form-grid-2" label-position="top">
|
||||||
<el-form-item label="原所属项目组">
|
<el-form-item label="原所属项目组">
|
||||||
<el-input :model-value="selected.teamName || '未归属'" disabled />
|
<el-input :model-value="originalTeamLabel" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="原所属项目">
|
<el-form-item label="原所属项目">
|
||||||
<el-input :model-value="selected.projectName || '未归属'" disabled />
|
<el-input :model-value="originalProjectLabel" disabled />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="新项目组" required>
|
<el-form-item label="新项目组" required>
|
||||||
<ProjectSelect
|
<ProjectSelect
|
||||||
:key="`team-${selected.id}`"
|
:key="`team-${dialogSelectKey}`"
|
||||||
team
|
team
|
||||||
v-model="targetTeamId"
|
v-model="targetTeamId"
|
||||||
:biz-type="selected.bizType"
|
:biz-type="dialogBizType"
|
||||||
@update:model-value="onTargetTeamChange"
|
@update:model-value="onTargetTeamChange"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="新项目" required>
|
<el-form-item label="新项目" required>
|
||||||
<ProjectSelect
|
<ProjectSelect
|
||||||
:key="`project-${selected.id}-${targetTeamId}`"
|
:key="`project-${dialogSelectKey}-${targetTeamId}`"
|
||||||
v-model="target"
|
v-model="target"
|
||||||
:team-id="targetTeamId"
|
:team-id="targetTeamId"
|
||||||
:biz-type="selected.bizType"
|
:biz-type="dialogBizType"
|
||||||
:disabled="!targetTeamId"
|
:disabled="!targetTeamId"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -262,6 +288,7 @@
|
|||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 20
|
pageSize: 20
|
||||||
})
|
})
|
||||||
|
const tableRef = ref<{ clearSelection?: () => void } | null>(null)
|
||||||
const rows = ref<ProjectRecord[]>([]),
|
const rows = ref<ProjectRecord[]>([]),
|
||||||
total = ref(0),
|
total = ref(0),
|
||||||
statusCounts = ref<Record<string, number>>({}),
|
statusCounts = ref<Record<string, number>>({}),
|
||||||
@@ -273,6 +300,8 @@
|
|||||||
target = ref(''),
|
target = ref(''),
|
||||||
reason = ref(''),
|
reason = ref(''),
|
||||||
selected = ref<ProjectRecord>({}),
|
selected = ref<ProjectRecord>({}),
|
||||||
|
selectedRows = ref<ProjectRecord[]>([]),
|
||||||
|
editTargets = ref<ProjectRecord[]>([]),
|
||||||
historyVisible = ref(false),
|
historyVisible = ref(false),
|
||||||
historyRows = ref<ProjectRecord[]>([])
|
historyRows = ref<ProjectRecord[]>([])
|
||||||
const visibleColumns = computed(() =>
|
const visibleColumns = computed(() =>
|
||||||
@@ -283,6 +312,39 @@
|
|||||||
const keywordHint = computed(() =>
|
const keywordHint = computed(() =>
|
||||||
query.bizType === 'presign' ? '请输入单据编号' : assignmentKeywordHints[query.bizType]
|
query.bizType === 'presign' ? '请输入单据编号' : assignmentKeywordHints[query.bizType]
|
||||||
)
|
)
|
||||||
|
const dialogBizType = computed(
|
||||||
|
() =>
|
||||||
|
(editTargets.value[0]?.bizType ||
|
||||||
|
selected.value.bizType ||
|
||||||
|
query.bizType) as AssignmentBizType
|
||||||
|
)
|
||||||
|
const dialogSelectKey = computed(() => {
|
||||||
|
if (editTargets.value.length <= 1) {
|
||||||
|
return String(editTargets.value[0]?.id || selected.value.id || 'empty')
|
||||||
|
}
|
||||||
|
const firstId = editTargets.value[0]?.id || ''
|
||||||
|
const lastId = editTargets.value[editTargets.value.length - 1]?.id || ''
|
||||||
|
return `batch-${editTargets.value.length}-${firstId}-${lastId}`
|
||||||
|
})
|
||||||
|
const originalTeamLabel = computed(() => {
|
||||||
|
if (editTargets.value.length <= 1) {
|
||||||
|
return editTargets.value[0]?.teamName || selected.value.teamName || '未归属'
|
||||||
|
}
|
||||||
|
return `共 ${editTargets.value.length} 条`
|
||||||
|
})
|
||||||
|
const originalProjectLabel = computed(() => {
|
||||||
|
if (editTargets.value.length <= 1) {
|
||||||
|
return editTargets.value[0]?.projectName || selected.value.projectName || '未归属'
|
||||||
|
}
|
||||||
|
return `共 ${editTargets.value.length} 条`
|
||||||
|
})
|
||||||
|
function clearSelection() {
|
||||||
|
selectedRows.value = []
|
||||||
|
tableRef.value?.clearSelection?.()
|
||||||
|
}
|
||||||
|
function handleSelectionChange(selection: ProjectRecord[]) {
|
||||||
|
selectedRows.value = selection
|
||||||
|
}
|
||||||
let loadVersion = 0
|
let loadVersion = 0
|
||||||
function statusLabel(status: string) {
|
function statusLabel(status: string) {
|
||||||
return query.bizType === 'presign'
|
return query.bizType === 'presign'
|
||||||
@@ -307,6 +369,7 @@
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
loadError.value = false
|
loadError.value = false
|
||||||
rows.value = []
|
rows.value = []
|
||||||
|
clearSelection()
|
||||||
try {
|
try {
|
||||||
const fetchRecords = props.assignment
|
const fetchRecords = props.assignment
|
||||||
? fetchAssignmentRecords
|
? fetchAssignmentRecords
|
||||||
@@ -344,6 +407,7 @@
|
|||||||
statusCounts.value = {}
|
statusCounts.value = {}
|
||||||
visible.value = false
|
visible.value = false
|
||||||
historyVisible.value = false
|
historyVisible.value = false
|
||||||
|
clearSelection()
|
||||||
search()
|
search()
|
||||||
}
|
}
|
||||||
function switchBusiness(kind: AssignmentBizType) {
|
function switchBusiness(kind: AssignmentBizType) {
|
||||||
@@ -360,16 +424,41 @@
|
|||||||
query.page = page
|
query.page = page
|
||||||
load()
|
load()
|
||||||
}
|
}
|
||||||
function open(row: ProjectRecord) {
|
function resetDialogForm(targets: ProjectRecord[]) {
|
||||||
selected.value = row
|
editTargets.value = targets
|
||||||
|
selected.value = targets[0] || {}
|
||||||
targetTeamId.value = ''
|
targetTeamId.value = ''
|
||||||
target.value = ''
|
target.value = ''
|
||||||
reason.value = ''
|
reason.value = ''
|
||||||
visible.value = true
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
function open(row: ProjectRecord) {
|
||||||
|
resetDialogForm([row])
|
||||||
|
}
|
||||||
|
function openBatch() {
|
||||||
|
if (!selectedRows.value.length) {
|
||||||
|
ElMessage.warning('请先选择要调整的记录')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resetDialogForm([...selectedRows.value])
|
||||||
|
}
|
||||||
function onTargetTeamChange() {
|
function onTargetTeamChange() {
|
||||||
target.value = ''
|
target.value = ''
|
||||||
}
|
}
|
||||||
|
async function assignOne(row: ProjectRecord, projectId: string, assignReason: string) {
|
||||||
|
const preview = await previewAssignment({
|
||||||
|
bizType: row.bizType,
|
||||||
|
id: row.id,
|
||||||
|
projectId
|
||||||
|
})
|
||||||
|
await saveAssignment({
|
||||||
|
bizType: row.bizType,
|
||||||
|
id: row.id,
|
||||||
|
projectId,
|
||||||
|
reason: assignReason,
|
||||||
|
expectedAssignments: assignmentSnapshot(preview.records)
|
||||||
|
})
|
||||||
|
}
|
||||||
async function commit() {
|
async function commit() {
|
||||||
if (!targetTeamId.value) {
|
if (!targetTeamId.value) {
|
||||||
ElMessage.warning('请选择新项目组')
|
ElMessage.warning('请选择新项目组')
|
||||||
@@ -383,33 +472,45 @@
|
|||||||
ElMessage.warning('请填写调整原因')
|
ElMessage.warning('请填写调整原因')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const targets = editTargets.value.length ? [...editTargets.value] : [selected.value]
|
||||||
|
if (!targets.length || !targets[0]?.id) {
|
||||||
|
ElMessage.warning('请选择要调整的记录')
|
||||||
|
return
|
||||||
|
}
|
||||||
busy.value = true
|
busy.value = true
|
||||||
const commitTarget = target.value
|
const commitTarget = target.value
|
||||||
const commitRecord = selected.value
|
const commitReason = reason.value.trim()
|
||||||
|
const commitTargets = targets
|
||||||
|
let successCount = 0
|
||||||
|
let failCount = 0
|
||||||
try {
|
try {
|
||||||
const preview = await previewAssignment({
|
for (const row of commitTargets) {
|
||||||
bizType: selected.value.bizType,
|
if (target.value !== commitTarget || !visible.value) {
|
||||||
id: selected.value.id,
|
return
|
||||||
projectId: target.value
|
}
|
||||||
})
|
try {
|
||||||
if (selected.value !== commitRecord || target.value !== commitTarget || !visible.value) {
|
await assignOne(row, commitTarget, commitReason)
|
||||||
|
successCount += 1
|
||||||
|
} catch {
|
||||||
|
failCount += 1
|
||||||
|
// API layer already surfaces the conflict / validation message.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.value !== commitTarget || !visible.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await saveAssignment({
|
if (successCount > 0) {
|
||||||
bizType: selected.value.bizType,
|
visible.value = false
|
||||||
id: selected.value.id,
|
clearSelection()
|
||||||
projectId: target.value,
|
if (failCount === 0) {
|
||||||
reason: reason.value.trim(),
|
ElMessage.success(
|
||||||
expectedAssignments: assignmentSnapshot(preview.records)
|
commitTargets.length > 1 ? `已调整 ${successCount} 条归属` : '归属已调整'
|
||||||
})
|
)
|
||||||
if (selected.value !== commitRecord || target.value !== commitTarget || !visible.value) {
|
} else {
|
||||||
return
|
ElMessage.warning(`成功 ${successCount} 条,失败 ${failCount} 条`)
|
||||||
|
}
|
||||||
|
await load()
|
||||||
}
|
}
|
||||||
visible.value = false
|
|
||||||
ElMessage.success('归属已调整')
|
|
||||||
await load()
|
|
||||||
} catch {
|
|
||||||
// API layer already surfaces the conflict / validation message.
|
|
||||||
} finally {
|
} finally {
|
||||||
busy.value = false
|
busy.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-23
@@ -70,21 +70,16 @@
|
|||||||
<dt>样本类型</dt>
|
<dt>样本类型</dt>
|
||||||
<dd>{{ row.sampleTypeName || '—' }}</dd>
|
<dd>{{ row.sampleTypeName || '—' }}</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="sample-reception-card__meta-item sample-reception-card__meta-item--attachment">
|
<div
|
||||||
<dt>{{ attachmentMeta(row).label }}</dt>
|
v-for="group in protocolAttachmentGroups(row)"
|
||||||
|
:key="group.label"
|
||||||
|
class="sample-reception-card__meta-item sample-reception-card__meta-item--attachment"
|
||||||
|
>
|
||||||
|
<dt>{{ group.label }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ProtocolAttachmentMiniReadonly
|
<ProtocolAttachmentMiniReadonly
|
||||||
:files="attachmentMeta(row).files"
|
:files="group.files"
|
||||||
@preview="handleAttachmentPreview"
|
empty-text="暂无附件"
|
||||||
@download="handleAttachmentDownload"
|
|
||||||
/>
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="sample-reception-card__meta-item sample-reception-card__meta-item--attachment">
|
|
||||||
<dt>{{ consentAttachmentMeta(row).label }}</dt>
|
|
||||||
<dd>
|
|
||||||
<ProtocolAttachmentMiniReadonly
|
|
||||||
:files="consentAttachmentMeta(row).files"
|
|
||||||
@preview="handleAttachmentPreview"
|
@preview="handleAttachmentPreview"
|
||||||
@download="handleAttachmentDownload"
|
@download="handleAttachmentDownload"
|
||||||
/>
|
/>
|
||||||
@@ -252,10 +247,7 @@
|
|||||||
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
|
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
|
||||||
import QcWorkOrderProtocolPaymentPanel from '@/views/quality-inspection/qc-work-order/QcWorkOrderProtocolPaymentPanel.vue'
|
import QcWorkOrderProtocolPaymentPanel from '@/views/quality-inspection/qc-work-order/QcWorkOrderProtocolPaymentPanel.vue'
|
||||||
import ProtocolAttachmentMiniReadonly from '@/components/business/protocol-attachment-mini-readonly/index.vue'
|
import ProtocolAttachmentMiniReadonly from '@/components/business/protocol-attachment-mini-readonly/index.vue'
|
||||||
import {
|
import { getSourceProtocolAttachmentGroups } from '@/utils/protocol-source-attachment'
|
||||||
getConsentProtocolAttachment,
|
|
||||||
getSourceProtocolAttachment
|
|
||||||
} from '@/utils/protocol-source-attachment'
|
|
||||||
import { useAttachmentActions } from '@/composables/useAttachmentActions'
|
import { useAttachmentActions } from '@/composables/useAttachmentActions'
|
||||||
|
|
||||||
defineOptions({ name: 'SampleReceptionCardList' })
|
defineOptions({ name: 'SampleReceptionCardList' })
|
||||||
@@ -293,12 +285,8 @@
|
|||||||
|
|
||||||
const { handleAttachmentPreview, handleAttachmentDownload } = useAttachmentActions()
|
const { handleAttachmentPreview, handleAttachmentDownload } = useAttachmentActions()
|
||||||
|
|
||||||
function attachmentMeta(row: Record<string, unknown>) {
|
function protocolAttachmentGroups(row: Record<string, unknown>) {
|
||||||
return getSourceProtocolAttachment(row)
|
return getSourceProtocolAttachmentGroups(row)
|
||||||
}
|
|
||||||
|
|
||||||
function consentAttachmentMeta(row: Record<string, unknown>) {
|
|
||||||
return getConsentProtocolAttachment(row)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
|
function protocolStatusLabelBySource(status: string, source: string, voidType?: string): string {
|
||||||
|
|||||||
Reference in new issue
Block a user