rrScratch3 - Progress Commit
This commit is contained in:
@@ -51,17 +51,20 @@ function normalizeJobAllocations(ack) {
|
|||||||
* is now done on the backend via buildRogogFromAllocations/buildRolaborFromRogog.
|
* is now done on the backend via buildRogogFromAllocations/buildRolaborFromRogog.
|
||||||
* This component just renders the preview from `ack.rogg` / `ack.rolabor`.
|
* This component just renders the preview from `ack.rogg` / `ack.rolabor`.
|
||||||
*/
|
*/
|
||||||
export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocationsChange }) {
|
export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocationsChange, opCode }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [roggPreview, setRoggPreview] = useState(null);
|
const [roggPreview, setRoggPreview] = useState(null);
|
||||||
const [rolaborPreview, setRolaborPreview] = useState(null);
|
const [rolaborPreview, setRolaborPreview] = useState(null);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
// Prefer the user-selected OpCode (from DmsContainer), fall back to config default
|
||||||
|
const effectiveOpCode = useMemo(() => opCode || resolveRROpCodeFromBodyshop(bodyshop), [opCode, bodyshop]);
|
||||||
|
|
||||||
const fetchAllocations = useCallback(() => {
|
const fetchAllocations = useCallback(() => {
|
||||||
if (!socket || !jobId) return;
|
if (!socket || !jobId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket.emit("rr-calculate-allocations", jobId, (ack) => {
|
socket.emit("rr-calculate-allocations", { jobId, opCode: effectiveOpCode }, (ack) => {
|
||||||
if (ack && ack.ok === false) {
|
if (ack && ack.ok === false) {
|
||||||
setRoggPreview(null);
|
setRoggPreview(null);
|
||||||
setRolaborPreview(null);
|
setRolaborPreview(null);
|
||||||
@@ -101,14 +104,12 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
|||||||
onAllocationsChange([]);
|
onAllocationsChange([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [socket, jobId, t, onAllocationsChange]);
|
}, [socket, jobId, t, onAllocationsChange, effectiveOpCode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAllocations();
|
fetchAllocations();
|
||||||
}, [fetchAllocations]);
|
}, [fetchAllocations]);
|
||||||
|
|
||||||
const opCode = resolveRROpCodeFromBodyshop(bodyshop);
|
|
||||||
|
|
||||||
const segmentLabelMap = {
|
const segmentLabelMap = {
|
||||||
partsExtras: "Parts/Extras",
|
partsExtras: "Parts/Extras",
|
||||||
laborTaxable: "Taxable Labor",
|
laborTaxable: "Taxable Labor",
|
||||||
@@ -117,8 +118,11 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
|||||||
|
|
||||||
const roggRows = useMemo(() => {
|
const roggRows = useMemo(() => {
|
||||||
if (!roggPreview || !Array.isArray(roggPreview.ops)) return [];
|
if (!roggPreview || !Array.isArray(roggPreview.ops)) return [];
|
||||||
|
|
||||||
const rows = [];
|
const rows = [];
|
||||||
roggPreview.ops.forEach((op) => {
|
roggPreview.ops.forEach((op) => {
|
||||||
|
const rowOpCode = opCode || op.opCode;
|
||||||
|
|
||||||
(op.lines || []).forEach((line, idx) => {
|
(op.lines || []).forEach((line, idx) => {
|
||||||
const baseDesc = line.itemDesc;
|
const baseDesc = line.itemDesc;
|
||||||
const segmentKind = op.segmentKind;
|
const segmentKind = op.segmentKind;
|
||||||
@@ -128,7 +132,7 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
|||||||
|
|
||||||
rows.push({
|
rows.push({
|
||||||
key: `${op.jobNo}-${idx}`,
|
key: `${op.jobNo}-${idx}`,
|
||||||
opCode: op.opCode,
|
opCode: rowOpCode,
|
||||||
jobNo: op.jobNo,
|
jobNo: op.jobNo,
|
||||||
breakOut: line.breakOut,
|
breakOut: line.breakOut,
|
||||||
itemType: line.itemType,
|
itemType: line.itemType,
|
||||||
@@ -145,22 +149,27 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
return rows;
|
return rows;
|
||||||
}, [roggPreview]);
|
}, [roggPreview, opCode]);
|
||||||
|
|
||||||
const rolaborRows = useMemo(() => {
|
const rolaborRows = useMemo(() => {
|
||||||
if (!rolaborPreview || !Array.isArray(rolaborPreview.ops)) return [];
|
if (!rolaborPreview || !Array.isArray(rolaborPreview.ops)) return [];
|
||||||
return rolaborPreview.ops.map((op, idx) => ({
|
|
||||||
key: `${op.jobNo}-${idx}`,
|
return rolaborPreview.ops.map((op, idx) => {
|
||||||
opCode: op.opCode,
|
const rowOpCode = opCode || op.opCode;
|
||||||
jobNo: op.jobNo,
|
|
||||||
custPayTypeFlag: op.custPayTypeFlag,
|
return {
|
||||||
custTxblNtxblFlag: op.custTxblNtxblFlag,
|
key: `${op.jobNo}-${idx}`,
|
||||||
payType: op.bill?.payType,
|
opCode: rowOpCode,
|
||||||
amtType: op.amount?.amtType,
|
jobNo: op.jobNo,
|
||||||
custPrice: op.amount?.custPrice,
|
custPayTypeFlag: op.custPayTypeFlag,
|
||||||
totalAmt: op.amount?.totalAmt
|
custTxblNtxblFlag: op.custTxblNtxblFlag,
|
||||||
}));
|
payType: op.bill?.payType,
|
||||||
}, [rolaborPreview]);
|
amtType: op.amount?.amtType,
|
||||||
|
custPrice: op.amount?.custPrice,
|
||||||
|
totalAmt: op.amount?.totalAmt
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}, [rolaborPreview, opCode]);
|
||||||
|
|
||||||
// Totals for ROGOG (sum custPrice + dlrCost over all lines)
|
// Totals for ROGOG (sum custPrice + dlrCost over all lines)
|
||||||
const roggTotals = useMemo(() => {
|
const roggTotals = useMemo(() => {
|
||||||
@@ -221,9 +230,10 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
|||||||
children: (
|
children: (
|
||||||
<>
|
<>
|
||||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 8 }}>
|
<Typography.Paragraph type="secondary" style={{ marginBottom: 8 }}>
|
||||||
OpCode: <strong>{opCode}</strong>. Only centers with RR GOG mapping (rr_gogcode & rr_item_type) are
|
OpCode: <strong>{effectiveOpCode}</strong>. Only centers with RR GOG mapping (rr_gogcode & rr_item_type)
|
||||||
included. Totals below reflect exactly what will be sent in ROGOG.
|
are included. Totals below reflect exactly what will be sent in ROGOG.
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
pagination={false}
|
pagination={false}
|
||||||
columns={roggColumns}
|
columns={roggColumns}
|
||||||
|
|||||||
@@ -21,10 +21,22 @@ export default connect(mapStateToProps, mapDispatchToProps)(DmsPostForm);
|
|||||||
* @param logsRef
|
* @param logsRef
|
||||||
* @param key
|
* @param key
|
||||||
* @param allocationsSummary
|
* @param allocationsSummary
|
||||||
|
* @param rrOpCodeParts
|
||||||
|
* @param onChangeRrOpCodeParts
|
||||||
* @returns {JSX.Element|null}
|
* @returns {JSX.Element|null}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export function DmsPostForm({ mode, bodyshop, socket, job, logsRef, key, allocationsSummary }) {
|
export function DmsPostForm({
|
||||||
|
mode,
|
||||||
|
bodyshop,
|
||||||
|
socket,
|
||||||
|
job,
|
||||||
|
logsRef,
|
||||||
|
key,
|
||||||
|
allocationsSummary,
|
||||||
|
rrOpCodeParts,
|
||||||
|
onChangeRrOpCodeParts
|
||||||
|
}) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DMS_MAP.reynolds:
|
case DMS_MAP.reynolds:
|
||||||
return (
|
return (
|
||||||
@@ -35,6 +47,8 @@ export function DmsPostForm({ mode, bodyshop, socket, job, logsRef, key, allocat
|
|||||||
logsRef={logsRef}
|
logsRef={logsRef}
|
||||||
key={key}
|
key={key}
|
||||||
allocationsSummary={allocationsSummary}
|
allocationsSummary={allocationsSummary}
|
||||||
|
opCodeParts={rrOpCodeParts}
|
||||||
|
onChangeOpCodeParts={onChangeRrOpCodeParts}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,20 @@ import dayjs from "../../utils/day";
|
|||||||
* @param job
|
* @param job
|
||||||
* @param logsRef
|
* @param logsRef
|
||||||
* @param allocationsSummary
|
* @param allocationsSummary
|
||||||
|
* @param opCodeParts
|
||||||
|
* @param onChangeOpCodeParts
|
||||||
* @returns {JSX.Element}
|
* @returns {JSX.Element}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function RRPostForm({ bodyshop, socket, job, logsRef, allocationsSummary }) {
|
export default function RRPostForm({
|
||||||
|
bodyshop,
|
||||||
|
socket,
|
||||||
|
job,
|
||||||
|
logsRef,
|
||||||
|
allocationsSummary,
|
||||||
|
opCodeParts,
|
||||||
|
onChangeOpCodeParts
|
||||||
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -98,19 +108,54 @@ export default function RRPostForm({ bodyshop, socket, job, logsRef, allocations
|
|||||||
: job.v_model_yr)) ||
|
: job.v_model_yr)) ||
|
||||||
2019
|
2019
|
||||||
}-01-01`
|
}-01-01`
|
||||||
)
|
),
|
||||||
|
opPrefix: opCodeParts?.prefix ?? "",
|
||||||
|
opBase: opCodeParts?.base ?? "",
|
||||||
|
opSuffix: opCodeParts?.suffix ?? ""
|
||||||
}),
|
}),
|
||||||
[job, t]
|
[job, t, opCodeParts]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Keep the RR OpCode parts in sync with DmsContainer state
|
||||||
|
const opPrefixWatch = Form.useWatch("opPrefix", form);
|
||||||
|
const opBaseWatch = Form.useWatch("opBase", form);
|
||||||
|
const opSuffixWatch = Form.useWatch("opSuffix", form);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!onChangeOpCodeParts) return;
|
||||||
|
|
||||||
|
onChangeOpCodeParts({
|
||||||
|
prefix: opPrefixWatch || "",
|
||||||
|
base: opBaseWatch || "",
|
||||||
|
suffix: opSuffixWatch || ""
|
||||||
|
});
|
||||||
|
}, [opPrefixWatch, opBaseWatch, opSuffixWatch, onChangeOpCodeParts]);
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
if (!socket) return;
|
if (!socket) return;
|
||||||
|
|
||||||
|
const { opPrefix, opBase, opSuffix, ...rest } = values;
|
||||||
|
|
||||||
|
const combinedOpCode = `${opPrefix || ""}${opBase || ""}${opSuffix || ""}`.trim();
|
||||||
|
|
||||||
|
const txEnvelope = {
|
||||||
|
...rest,
|
||||||
|
opPrefix,
|
||||||
|
opBase,
|
||||||
|
opSuffix
|
||||||
|
};
|
||||||
|
|
||||||
|
if (combinedOpCode) {
|
||||||
|
txEnvelope.opCode = combinedOpCode;
|
||||||
|
}
|
||||||
|
|
||||||
socket.emit("rr-export-job", {
|
socket.emit("rr-export-job", {
|
||||||
bodyshopId: bodyshop?.id,
|
bodyshopId: bodyshop?.id,
|
||||||
jobId: job.id,
|
jobId: job.id,
|
||||||
job,
|
job,
|
||||||
txEnvelope: values
|
txEnvelope
|
||||||
});
|
});
|
||||||
|
|
||||||
logsRef?.current?.scrollIntoView({ behavior: "smooth" });
|
logsRef?.current?.scrollIntoView({ behavior: "smooth" });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -177,10 +222,39 @@ export default function RRPostForm({ bodyshop, socket, job, logsRef, allocations
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
{/* Make Override */}
|
{/* RR OpCode (prefix / base / suffix) */}
|
||||||
<Col xs={24} sm={12} md={12} lg={8}>
|
<Col xs={24} sm={12} md={12} lg={8}>
|
||||||
<Form.Item name="makeOverride" label={t("jobs.fields.dms.make_override")}>
|
<Form.Item label={t("jobs.fields.dms.rr_opcode", "RR OpCode")}>
|
||||||
<Input allowClear placeholder={t("general.actions.optional")} />
|
<Space.Compact block>
|
||||||
|
<Form.Item name="opPrefix" noStyle>
|
||||||
|
<Input
|
||||||
|
allowClear
|
||||||
|
maxLength={4}
|
||||||
|
style={{ width: "30%" }}
|
||||||
|
placeholder={t("jobs.fields.dms.rr_opcode_prefix", "Prefix")}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="opBase"
|
||||||
|
noStyle
|
||||||
|
rules={[{ required: true, message: t("general.validation.required") }]}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
allowClear
|
||||||
|
maxLength={10}
|
||||||
|
style={{ width: "40%" }}
|
||||||
|
placeholder={t("jobs.fields.dms.rr_opcode_base", "Base")}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="opSuffix" noStyle>
|
||||||
|
<Input
|
||||||
|
allowClear
|
||||||
|
maxLength={4}
|
||||||
|
style={{ width: "30%" }}
|
||||||
|
placeholder={t("jobs.fields.dms.rr_opcode_suffix", "Suffix")}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Space.Compact>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
|
|||||||
@@ -66,16 +66,6 @@ const DMS_SOCKET_EVENTS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, insertAuditTrail }) {
|
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, insertAuditTrail }) {
|
||||||
const { t } = useTranslation();
|
|
||||||
const [resetAfterReconnect, setResetAfterReconnect] = useState(false);
|
|
||||||
const [allocationsSummary, setAllocationsSummary] = useState(null);
|
|
||||||
|
|
||||||
const history = useNavigate();
|
|
||||||
const search = queryString.parse(useLocation().search);
|
|
||||||
const { jobId } = search;
|
|
||||||
|
|
||||||
const notification = useNotification();
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
treatments: { Fortellis }
|
treatments: { Fortellis }
|
||||||
} = useSplitTreatments({
|
} = useSplitTreatments({
|
||||||
@@ -84,10 +74,46 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
splitKey: bodyshop.imexshopid
|
splitKey: bodyshop.imexshopid
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [resetAfterReconnect, setResetAfterReconnect] = useState(false);
|
||||||
|
const [allocationsSummary, setAllocationsSummary] = useState(null);
|
||||||
|
|
||||||
// Compute a single normalized mode and pick the proper socket
|
// Compute a single normalized mode and pick the proper socket
|
||||||
const mode = getDmsMode(bodyshop, Fortellis.treatment); // "rr" | "fortellis" | "cdk" | "pbs" | "none"
|
const mode = getDmsMode(bodyshop, Fortellis.treatment); // "rr" | "fortellis" | "cdk" | "pbs" | "none"
|
||||||
|
|
||||||
|
// RR-only: derive default OpCode parts from bodyshop RR configuration
|
||||||
const isRrMode = mode === DMS_MAP.reynolds;
|
const isRrMode = mode === DMS_MAP.reynolds;
|
||||||
|
|
||||||
|
const deriveDefaultRrOpCodeParts = () => {
|
||||||
|
if (!isRrMode) return null;
|
||||||
|
|
||||||
|
const cfg = bodyshop?.rr_configuration || {};
|
||||||
|
|
||||||
|
// Adjust these paths to match your real schema.
|
||||||
|
const defaults =
|
||||||
|
cfg.opCodeDefault ||
|
||||||
|
cfg.op_code_default ||
|
||||||
|
cfg.op_codes?.default ||
|
||||||
|
cfg.defaults?.opCode ||
|
||||||
|
cfg.defaults ||
|
||||||
|
cfg.default ||
|
||||||
|
{};
|
||||||
|
|
||||||
|
const prefix = defaults.prefix ?? defaults.opCodePrefix ?? "";
|
||||||
|
const base = defaults.base ?? defaults.opCodeBase ?? "";
|
||||||
|
const suffix = defaults.suffix ?? defaults.opCodeSuffix ?? "";
|
||||||
|
|
||||||
|
return { prefix, base, suffix };
|
||||||
|
};
|
||||||
|
|
||||||
|
const [rrOpCodeParts, setRrOpCodeParts] = useState(() => deriveDefaultRrOpCodeParts());
|
||||||
|
|
||||||
|
const history = useNavigate();
|
||||||
|
const search = queryString.parse(useLocation().search);
|
||||||
|
const { jobId } = search;
|
||||||
|
|
||||||
|
const notification = useNotification();
|
||||||
|
|
||||||
const { socket: wsssocket } = useSocket();
|
const { socket: wsssocket } = useSocket();
|
||||||
const activeSocket = useMemo(() => (isWssMode(mode) ? wsssocket : legacySocket), [mode, wsssocket]);
|
const activeSocket = useMemo(() => (isWssMode(mode) ? wsssocket : legacySocket), [mode, wsssocket]);
|
||||||
|
|
||||||
@@ -96,6 +122,12 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
// One place to set log level
|
// One place to set log level
|
||||||
const [logLevel, setLogLevel] = useState(mode === DMS_MAP.pbs ? "INFO" : "DEBUG");
|
const [logLevel, setLogLevel] = useState(mode === DMS_MAP.pbs ? "INFO" : "DEBUG");
|
||||||
|
|
||||||
|
const rrOpCodeCombined = useMemo(() => {
|
||||||
|
if (!rrOpCodeParts || !rrOpCodeParts.base) return "";
|
||||||
|
const { prefix, base, suffix } = rrOpCodeParts;
|
||||||
|
return `${prefix || ""}${base}${suffix || ""}`;
|
||||||
|
}, [rrOpCodeParts]);
|
||||||
|
|
||||||
const setActiveLogLevel = (level) => {
|
const setActiveLogLevel = (level) => {
|
||||||
if (!activeSocket) return;
|
if (!activeSocket) return;
|
||||||
activeSocket.emit("set-log-level", level);
|
activeSocket.emit("set-log-level", level);
|
||||||
@@ -155,6 +187,9 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
setrrValidationPending(false);
|
setrrValidationPending(false);
|
||||||
setAllocationsSummary(null);
|
setAllocationsSummary(null);
|
||||||
|
|
||||||
|
// RR OpCode parts: reset to config defaults when job/mode changes
|
||||||
|
setRrOpCodeParts(deriveDefaultRrOpCodeParts());
|
||||||
|
|
||||||
if (!activeSocket) return;
|
if (!activeSocket) return;
|
||||||
|
|
||||||
const emitReset = () => {
|
const emitReset = () => {
|
||||||
@@ -431,6 +466,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
}
|
}
|
||||||
socket={activeSocket}
|
socket={activeSocket}
|
||||||
jobId={jobId}
|
jobId={jobId}
|
||||||
|
opCode={rrOpCodeCombined}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
@@ -443,6 +479,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
|||||||
logsRef={logsRef}
|
logsRef={logsRef}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
allocationsSummary={allocationsSummary}
|
allocationsSummary={allocationsSummary}
|
||||||
|
rrOpCodeParts={rrOpCodeParts}
|
||||||
|
onChangeRrOpCodeParts={setRrOpCodeParts}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
|
|||||||
@@ -90,11 +90,15 @@ const exportJobToRR = async (args) => {
|
|||||||
const story = txEnvelope?.story ? String(txEnvelope.story).trim() : null;
|
const story = txEnvelope?.story ? String(txEnvelope.story).trim() : null;
|
||||||
const makeOverride = txEnvelope?.makeOverride ? String(txEnvelope.makeOverride).trim() : null;
|
const makeOverride = txEnvelope?.makeOverride ? String(txEnvelope.makeOverride).trim() : null;
|
||||||
|
|
||||||
|
// Optional RR OpCode segments coming from the FE (RRPostForm)
|
||||||
|
const opPrefix = txEnvelope?.opPrefix ?? txEnvelope?.op_prefix ?? null;
|
||||||
|
const opBase = txEnvelope?.opBase ?? txEnvelope?.op_base ?? null;
|
||||||
|
const opSuffix = txEnvelope?.opSuffix ?? txEnvelope?.op_suffix ?? null;
|
||||||
|
|
||||||
// RR-only extras
|
// RR-only extras
|
||||||
let rrCentersConfig = null;
|
let rrCentersConfig = null;
|
||||||
let allocations = null;
|
let allocations = null;
|
||||||
let opCode = null;
|
let opCode = null;
|
||||||
// let taxCode = null;
|
|
||||||
|
|
||||||
// 1) Responsibility center config (for visibility / debugging)
|
// 1) Responsibility center config (for visibility / debugging)
|
||||||
try {
|
try {
|
||||||
@@ -139,7 +143,15 @@ const exportJobToRR = async (args) => {
|
|||||||
|
|
||||||
const resolvedBaseOpCode = resolveRROpCodeFromBodyshop(bodyshop);
|
const resolvedBaseOpCode = resolveRROpCodeFromBodyshop(bodyshop);
|
||||||
|
|
||||||
const opCodeOverride = txEnvelope?.opCode || txEnvelope?.opcode || txEnvelope?.op_code || null;
|
let opCodeOverride = txEnvelope?.opCode || txEnvelope?.opcode || txEnvelope?.op_code || null;
|
||||||
|
|
||||||
|
// If the FE only sends segments, combine them here.
|
||||||
|
if (!opCodeOverride && (opPrefix || opBase || opSuffix)) {
|
||||||
|
const combined = `${opPrefix || ""}${opBase || ""}${opSuffix || ""}`.trim();
|
||||||
|
if (combined) {
|
||||||
|
opCodeOverride = combined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (opCodeOverride || resolvedBaseOpCode) {
|
if (opCodeOverride || resolvedBaseOpCode) {
|
||||||
opCode = String(opCodeOverride || resolvedBaseOpCode).trim() || null;
|
opCode = String(opCodeOverride || resolvedBaseOpCode).trim() || null;
|
||||||
@@ -147,7 +159,10 @@ const exportJobToRR = async (args) => {
|
|||||||
|
|
||||||
CreateRRLogEvent(socket, "SILLY", "RR OP config resolved", {
|
CreateRRLogEvent(socket, "SILLY", "RR OP config resolved", {
|
||||||
opCode,
|
opCode,
|
||||||
baseFromConfig: resolvedBaseOpCode
|
baseFromConfig: resolvedBaseOpCode,
|
||||||
|
opPrefix,
|
||||||
|
opBase,
|
||||||
|
opSuffix
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build RO payload for create.
|
// Build RO payload for create.
|
||||||
|
|||||||
@@ -896,9 +896,26 @@ const registerRREvents = ({ socket, redisHelpers }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("rr-calculate-allocations", async (jobid, cb) => {
|
// RR allocations preview (RR-only)
|
||||||
|
// Accepts either:
|
||||||
|
// - legacy: (jobid, cb)
|
||||||
|
// - new: ({ jobId, opCode, opPrefix, opBase, opSuffix }, cb)
|
||||||
|
socket.on("rr-calculate-allocations", async (payload, cb) => {
|
||||||
|
// Normalize arguments
|
||||||
|
const isObjectPayload = payload && typeof payload === "object";
|
||||||
|
const jobid = isObjectPayload ? payload.jobId || payload.jobid || payload.id : payload;
|
||||||
|
|
||||||
|
const opCodeFromClient =
|
||||||
|
isObjectPayload &&
|
||||||
|
(payload.opCode ||
|
||||||
|
payload.opcode ||
|
||||||
|
payload.op_code ||
|
||||||
|
(payload.opPrefix || payload.opBase || payload.opSuffix
|
||||||
|
? `${payload.opPrefix || ""}${payload.opBase || ""}${payload.opSuffix || ""}`.trim()
|
||||||
|
: null));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CreateRRLogEvent(socket, "DEBUG", "rr-calculate-allocations: begin", { jobid });
|
CreateRRLogEvent(socket, "DEBUG", "rr-calculate-allocations: begin", { jobid, opCodeFromClient });
|
||||||
|
|
||||||
const raw = await RRCalculateAllocations(socket, jobid);
|
const raw = await RRCalculateAllocations(socket, jobid);
|
||||||
|
|
||||||
@@ -925,20 +942,24 @@ const registerRREvents = ({ socket, redisHelpers }) => {
|
|||||||
jobAllocations = Array.isArray(ack.jobAllocations) ? ack.jobAllocations : [];
|
jobAllocations = Array.isArray(ack.jobAllocations) ? ack.jobAllocations : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to derive OpCode from bodyshop.rr_configuration.defaults; fall back to default
|
// Start with client-supplied OpCode (if any); fall back to defaults.
|
||||||
let opCode;
|
let opCode = opCodeFromClient || null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { bodyshopId } = await getSessionOrSocket(redisHelpers, socket);
|
const { bodyshopId } = await getSessionOrSocket(redisHelpers, socket);
|
||||||
const bodyshop = await getBodyshopForSocket({ bodyshopId, socket });
|
const bodyshop = await getBodyshopForSocket({ bodyshopId, socket });
|
||||||
|
|
||||||
|
// resolveRROpCodeFromBodyshop(bodyshop, existingOverride?)
|
||||||
opCode = resolveRROpCodeFromBodyshop(bodyshop, opCode);
|
opCode = resolveRROpCodeFromBodyshop(bodyshop, opCode);
|
||||||
|
|
||||||
CreateRRLogEvent(socket, "DEBUG", "rr-calculate-allocations: resolved OpCode", {
|
CreateRRLogEvent(socket, "DEBUG", "rr-calculate-allocations: resolved OpCode", {
|
||||||
opCode
|
opCode,
|
||||||
|
opCodeFromClient
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
CreateRRLogEvent(socket, "WARN", "rr-calculate-allocations: bodyshop lookup failed, using default OpCode", {
|
CreateRRLogEvent(socket, "WARN", "rr-calculate-allocations: bodyshop lookup failed, using existing OpCode", {
|
||||||
error: e.message
|
error: e.message,
|
||||||
|
opCodeFromClient
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user