Skip to content

Commit

Permalink
server: remove restricted procs and material for rebookings
Browse files Browse the repository at this point in the history
Remachining of a specific piece of material should happen without a rebooking scheduling.

Instead, create a new log type RemachiningRequest and then when the serial is scanned into a raw material queue, we can find out what needs to be done and then just do it without involving orderlink.
  • Loading branch information
wuzzeb committed Nov 7, 2024
1 parent 01944af commit 272e758
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 647 deletions.
106 changes: 3 additions & 103 deletions client/csharp-api/api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3745,105 +3745,14 @@ public virtual async System.Threading.Tasks.Task<LogEntry> RecordOperatorNotesAs
}

/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<LogEntry> RequestRebookingForMaterialAsync(long materialID, System.Collections.Generic.IEnumerable<int> restrictedProcs, string notes)
public virtual System.Threading.Tasks.Task<LogEntry> RequestRebookingAsync(string partName, int? qty, string workorder, int? priority, string notes)
{
return RequestRebookingForMaterialAsync(materialID, restrictedProcs, notes, System.Threading.CancellationToken.None);
return RequestRebookingAsync(partName, qty, workorder, priority, notes, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<LogEntry> RequestRebookingForMaterialAsync(long materialID, System.Collections.Generic.IEnumerable<int> restrictedProcs, string notes, System.Threading.CancellationToken cancellationToken)
{
if (materialID == null)
throw new System.ArgumentNullException("materialID");

var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(notes, JsonSerializerSettings);
var content_ = new System.Net.Http.StringContent(json_);
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));

var urlBuilder_ = new System.Text.StringBuilder();
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
// Operation Path: "api/v1/log/material-details/{materialID}/rebooking"
urlBuilder_.Append("api/v1/log/material-details/");
urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(materialID, System.Globalization.CultureInfo.InvariantCulture)));
urlBuilder_.Append("/rebooking");
urlBuilder_.Append('?');
if (restrictedProcs != null)
{
foreach (var item_ in restrictedProcs) { urlBuilder_.Append(System.Uri.EscapeDataString("restrictedProcs")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(item_, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); }
}
urlBuilder_.Length--;

PrepareRequest(client_, request_, urlBuilder_);

var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);

PrepareRequest(client_, request_, url_);

var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}

ProcessResponse(client_, response_);

var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<LogEntry>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}

/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<LogEntry> RequestRebookingWithoutMaterialAsync(string partName, int? qty, string workorder, int? priority, string notes)
{
return RequestRebookingWithoutMaterialAsync(partName, qty, workorder, priority, notes, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<LogEntry> RequestRebookingWithoutMaterialAsync(string partName, int? qty, string workorder, int? priority, string notes, System.Threading.CancellationToken cancellationToken)
public virtual async System.Threading.Tasks.Task<LogEntry> RequestRebookingAsync(string partName, int? qty, string workorder, int? priority, string notes, System.Threading.CancellationToken cancellationToken)
{
if (partName == null)
throw new System.ArgumentNullException("partName");
Expand Down Expand Up @@ -5078,9 +4987,6 @@ public partial class FMSInfo
[Newtonsoft.Json.JsonProperty("SupportsRebookings", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string SupportsRebookings { get; set; }

[Newtonsoft.Json.JsonProperty("ManagementOnlyRebookings", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool? ManagementOnlyRebookings { get; set; }

[Newtonsoft.Json.JsonProperty("AllowChangeWorkorderAtLoadStation", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool? AllowChangeWorkorderAtLoadStation { get; set; }

Expand Down Expand Up @@ -6399,12 +6305,6 @@ public partial class Rebooking
[Newtonsoft.Json.JsonProperty("Workorder", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string Workorder { get; set; }

[Newtonsoft.Json.JsonProperty("RestrictedProcs", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<int> RestrictedProcs { get; set; }

[Newtonsoft.Json.JsonProperty("Material", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public MaterialDetails Material { get; set; }

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
Expand Down
23 changes: 2 additions & 21 deletions client/insight/src/cell-status/rebookings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import { Atom, atom, Setter } from "jotai";
import { ServerEventAndTime } from "./loading";
import { IJob, ILogEntry, IRebooking, IRecentHistoricData, LogType, MaterialDetails } from "../network/api";
import { IJob, ILogEntry, IRebooking, IRecentHistoricData, LogType } from "../network/api";
import { LazySeq, OrderedMap } from "@seedtactics/immutable-collections";
import { JobsBackend, LogBackend } from "../network/backend";
import { loadable } from "jotai/utils";
Expand Down Expand Up @@ -79,23 +79,6 @@ function convertLogToRebooking(log: Readonly<ILogEntry>): Readonly<IRebooking> {
if (log.details?.["Quantity"]) {
qty = parseInt(log.details["Quantity"], 10);
}
let mat: MaterialDetails | undefined;
if (log.material?.[0]?.id >= 0) {
const m = log.material[0];
mat = new MaterialDetails({
materialID: m.id,
jobUnique: m.uniq,
partName: m.part,
numProcesses: m.numproc,
workorder: m.workorder,
serial: m.serial,
});
}

const restrictedProcs = LazySeq.of(log.material ?? [])
.map((m) => m.proc)
.filter((p) => p > 0)
.toSortedArray((p) => p);

return {
bookingId: log.result,
Expand All @@ -105,8 +88,6 @@ function convertLogToRebooking(log: Readonly<ILogEntry>): Readonly<IRebooking> {
priority: log.locnum,
notes: log.details?.["Notes"],
workorder: log.details?.["Workorder"] ?? log.material?.[0]?.workorder,
restrictedProcs: restrictedProcs as number[],
material: mat,
};
}

Expand Down Expand Up @@ -195,7 +176,7 @@ export function useNewRebooking(): [(n: NewRebooking) => Promise<void>, boolean]
const [loading, setLoading] = useState(false);
const callback = useCallback((n: NewRebooking) => {
setLoading(true);
return LogBackend.requestRebookingWithoutMaterial(
return LogBackend.requestRebooking(
n.part,
n.qty && !isNaN(n.qty) ? n.qty : 1,
n.workorder,
Expand Down
1 change: 0 additions & 1 deletion client/insight/src/components/operations/Rebookings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ const RebookingDialog = memo(function RebookingDialog({
<Typography>Request Time: {longDateFormat.format(rebooking?.timeUTC)}</Typography>
<Typography>Priority: {rebooking?.priority}</Typography>
{rebooking?.workorder && <Typography>Workorder: {rebooking?.workorder}</Typography>}
{rebooking?.material?.serial && <Typography>Serial: {rebooking?.material?.serial}</Typography>}
<Typography>Note: {rebooking?.notes}</Typography>
{rebooking?.job && (
<>
Expand Down
70 changes: 3 additions & 67 deletions client/insight/src/network/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1737,51 +1737,7 @@ export class LogClient {
return Promise.resolve<LogEntry>(null as any);
}

requestRebookingForMaterial(materialID: number, restrictedProcs: number[] | null | undefined, notes: string | undefined, signal?: AbortSignal): Promise<LogEntry> {
let url_ = this.baseUrl + "/api/v1/log/material-details/{materialID}/rebooking?";
if (materialID === undefined || materialID === null)
throw new Error("The parameter 'materialID' must be defined.");
url_ = url_.replace("{materialID}", encodeURIComponent("" + materialID));
if (restrictedProcs !== undefined && restrictedProcs !== null)
restrictedProcs && restrictedProcs.forEach(item => { url_ += "restrictedProcs=" + encodeURIComponent("" + item) + "&"; });
url_ = url_.replace(/[?&]$/, "");

const content_ = JSON.stringify(notes);

let options_: RequestInit = {
body: content_,
method: "POST",
signal,
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};

return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processRequestRebookingForMaterial(_response);
});
}

protected processRequestRebookingForMaterial(response: Response): Promise<LogEntry> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = LogEntry.fromJS(resultData200);
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<LogEntry>(null as any);
}

requestRebookingWithoutMaterial(partName: string, qty: number | undefined, workorder: string | null | undefined, priority: number | null | undefined, notes: string | undefined, signal?: AbortSignal): Promise<LogEntry> {
requestRebooking(partName: string, qty: number | undefined, workorder: string | null | undefined, priority: number | null | undefined, notes: string | undefined, signal?: AbortSignal): Promise<LogEntry> {
let url_ = this.baseUrl + "/api/v1/log/events/rebooking?";
if (partName === undefined || partName === null)
throw new Error("The parameter 'partName' must be defined and cannot be null.");
Expand Down Expand Up @@ -1810,11 +1766,11 @@ export class LogClient {
};

return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processRequestRebookingWithoutMaterial(_response);
return this.processRequestRebooking(_response);
});
}

protected processRequestRebookingWithoutMaterial(response: Response): Promise<LogEntry> {
protected processRequestRebooking(response: Response): Promise<LogEntry> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
Expand Down Expand Up @@ -2279,7 +2235,6 @@ export class FMSInfo implements IFMSInfo {
quarantineQueue?: string | undefined;
customStationMonitorDialogUrl?: string | undefined;
supportsRebookings?: string | undefined;
managementOnlyRebookings?: boolean | undefined;
allowChangeWorkorderAtLoadStation?: boolean | undefined;
allowSwapSerialAtLoadStation?: boolean | undefined;
allowInvalidateMaterialAtLoadStation?: boolean | undefined;
Expand Down Expand Up @@ -2319,7 +2274,6 @@ export class FMSInfo implements IFMSInfo {
this.quarantineQueue = _data["QuarantineQueue"];
this.customStationMonitorDialogUrl = _data["CustomStationMonitorDialogUrl"];
this.supportsRebookings = _data["SupportsRebookings"];
this.managementOnlyRebookings = _data["ManagementOnlyRebookings"];
this.allowChangeWorkorderAtLoadStation = _data["AllowChangeWorkorderAtLoadStation"];
this.allowSwapSerialAtLoadStation = _data["AllowSwapSerialAtLoadStation"];
this.allowInvalidateMaterialAtLoadStation = _data["AllowInvalidateMaterialAtLoadStation"];
Expand Down Expand Up @@ -2359,7 +2313,6 @@ export class FMSInfo implements IFMSInfo {
data["QuarantineQueue"] = this.quarantineQueue;
data["CustomStationMonitorDialogUrl"] = this.customStationMonitorDialogUrl;
data["SupportsRebookings"] = this.supportsRebookings;
data["ManagementOnlyRebookings"] = this.managementOnlyRebookings;
data["AllowChangeWorkorderAtLoadStation"] = this.allowChangeWorkorderAtLoadStation;
data["AllowSwapSerialAtLoadStation"] = this.allowSwapSerialAtLoadStation;
data["AllowInvalidateMaterialAtLoadStation"] = this.allowInvalidateMaterialAtLoadStation;
Expand Down Expand Up @@ -2388,7 +2341,6 @@ export interface IFMSInfo {
quarantineQueue?: string | undefined;
customStationMonitorDialogUrl?: string | undefined;
supportsRebookings?: string | undefined;
managementOnlyRebookings?: boolean | undefined;
allowChangeWorkorderAtLoadStation?: boolean | undefined;
allowSwapSerialAtLoadStation?: boolean | undefined;
allowInvalidateMaterialAtLoadStation?: boolean | undefined;
Expand Down Expand Up @@ -5386,8 +5338,6 @@ export class Rebooking implements IRebooking {
priority?: number | undefined;
notes?: string | undefined;
workorder?: string | undefined;
restrictedProcs?: number[] | undefined;
material?: MaterialDetails | undefined;

constructor(data?: IRebooking) {
if (data) {
Expand All @@ -5407,12 +5357,6 @@ export class Rebooking implements IRebooking {
this.priority = _data["Priority"];
this.notes = _data["Notes"];
this.workorder = _data["Workorder"];
if (Array.isArray(_data["RestrictedProcs"])) {
this.restrictedProcs = [] as any;
for (let item of _data["RestrictedProcs"])
this.restrictedProcs!.push(item);
}
this.material = _data["Material"] ? MaterialDetails.fromJS(_data["Material"]) : <any>undefined;
}
}

Expand All @@ -5432,12 +5376,6 @@ export class Rebooking implements IRebooking {
data["Priority"] = this.priority;
data["Notes"] = this.notes;
data["Workorder"] = this.workorder;
if (Array.isArray(this.restrictedProcs)) {
data["RestrictedProcs"] = [];
for (let item of this.restrictedProcs)
data["RestrictedProcs"].push(item);
}
data["Material"] = this.material ? this.material.toJSON() : <any>undefined;
return data;
}
}
Expand All @@ -5450,8 +5388,6 @@ export interface IRebooking {
priority?: number | undefined;
notes?: string | undefined;
workorder?: string | undefined;
restrictedProcs?: number[] | undefined;
material?: MaterialDetails | undefined;
}

export class SimulationResults implements ISimulationResults {
Expand Down
2 changes: 1 addition & 1 deletion client/insight/src/network/backend-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export function registerMockBackend(
active: "PT0S",
});
},
requestRebookingWithoutMaterial(
requestRebooking(
partName: string,
qty: number | undefined,
workorder: string | null | undefined,
Expand Down
2 changes: 1 addition & 1 deletion client/insight/src/network/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export interface LogAPI {
signal?: AbortSignal,
): Promise<ReadonlyArray<Readonly<api.IActiveWorkorder>>>;
cancelRebooking(bookingId: string): Promise<Readonly<api.ILogEntry>>;
requestRebookingWithoutMaterial(
requestRebooking(
partName: string,
qty: number | undefined,
workorder: string | null | undefined,
Expand Down
Loading

0 comments on commit 272e758

Please sign in to comment.