Reconfigured smart scheduling to use buckets instead of load.

This commit is contained in:
Patrick Fic
2020-10-08 15:42:04 -07:00
parent 020bec3fa2
commit 5f73c879d0
16 changed files with 405 additions and 32 deletions

View File

@@ -1,15 +1,18 @@
import { Popover } from "antd";
import React from "react";
import React, { useMemo } from "react";
import { connect } from "react-redux";
import {
PolarAngleAxis,
PolarGrid,
PolarRadiusAxis,
Radar,
Legend,
RadarChart,
Tooltip,
} from "recharts";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { RadarChartOutlined } from "@ant-design/icons";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -21,44 +24,54 @@ const mapDispatchToProps = (dispatch) => ({
export function ScheduleCalendarHeaderGraph({ bodyshop, loadData }) {
const { ssbuckets } = bodyshop;
const data = Object.keys(loadData.expectedLoad).map((key) => {
const metadataBucket = ssbuckets.filter((b) => b.id === key)[0];
const data = useMemo(() => {
return Object.keys(loadData.expectedLoad).map((key) => {
const metadataBucket = ssbuckets.filter((b) => b.id === key)[0];
return {
bucket: loadData.expectedLoad[key].label,
current: loadData.expectedLoad[key].count,
target: metadataBucket && metadataBucket.target,
};
});
return {
bucket: loadData.expectedLoad[key].label,
current: loadData.expectedLoad[key].count,
target: metadataBucket && metadataBucket.target,
};
});
}, [loadData, ssbuckets]);
//d console.log("data", data);
const popContent = (
<div>
<RadarChart
cx={300}
cy={250}
outerRadius={150}
width={600}
height={500}
// cx={300}
// cy={250}
// outerRadius={150}
width={800}
height={600}
data={data}
>
<PolarGrid />
<PolarAngleAxis dataKey="bucket" />
<PolarRadiusAxis />
<PolarRadiusAxis angle={90} />
<Radar
name="Ideal Load"
dataKey="target"
stroke="darkgreen"
fill="whitr"
fillOpacity={0}
/>
<Radar
name="Current"
dataKey="current"
stroke="#8884d8"
fill="#8884d8"
stroke="dodgerblue"
fill="dodgerblue"
fillOpacity={0.6}
/>
<Tooltip />
<Legend />
</RadarChart>
</div>
);
return (
<Popover trigger="hover" placement="bottom" content={popContent}>
G
<RadarChartOutlined />
</Popover>
);
}

View File

@@ -70,12 +70,20 @@ export function ScheduleCalendarWrapperComponent({
search.view = view;
history.push({ search: queryString.stringify(search) });
}}
step={15}
step={30}
timeslots={1}
showMultiDayTimes
localizer={localizer}
min={new Date("2020-01-01T06:00:00")} //TODO Read from business settings.
max={new Date("2020-01-01T20:00:00")}
min={
bodyshop.schedule_start_time
? new Date(bodyshop.schedule_start_time)
: new Date("2020-01-01T06:00:00")
} //TODO Read from business settings.
max={
bodyshop.schedule_end_time
? new Date(bodyshop.schedule_end_time)
: new Date("2020-01-01T20:00:00")
}
eventPropGetter={handleEventPropStyles}
components={{
event: (e) => Event({ event: e.event, refetch: refetch }),

View File

@@ -8,7 +8,7 @@ import AlertComponent from "../alert/alert.component";
import { useTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils";
import FormsFieldChanged from "../form-fields-changed-alert/form-fields-changed-alert.component";
import moment from "moment";
export default function ShopInfoContainer() {
const [form] = Form.useForm();
const { t } = useTranslation();
@@ -49,7 +49,17 @@ export default function ShopInfoContainer() {
layout="vertical"
autoComplete="new-password"
onFinish={handleFinish}
initialValues={data ? data.bodyshops[0] : null}
initialValues={
data
? {
...data.bodyshops[0],
schedule_start_time: moment(
data.bodyshops[0].schedule_start_time
),
schedule_end_time: moment(data.bodyshops[0].schedule_end_time),
}
: null
}
>
<FormsFieldChanged form={form} />
<ShopInfoComponent form={form} saveLoading={saveLoading} />

View File

@@ -1,5 +1,14 @@
import { DeleteFilled } from "@ant-design/icons";
import { Button, Col, Form, Input, InputNumber, Row, Select } from "antd";
import {
Button,
Col,
Form,
Input,
InputNumber,
Row,
Select,
TimePicker,
} from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import ColorpickerFormItemComponent from "../form-items-formatted/colorpicker-form-item.component";
@@ -11,6 +20,30 @@ export default function ShopInfoSchedulingComponent({ form }) {
return (
<div>
<Form.Item
label={t("bodyshop.fields.schedule_start_time")}
name={"schedule_start_time"}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<TimePicker showSecond={false} />
</Form.Item>
<Form.Item
label={t("bodyshop.fields.schedule_end_time")}
name={"schedule_end_time"}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<TimePicker showSecond={false} />
</Form.Item>
<strong>{t("bodyshop.labels.orderstatuses")}</strong>
<Row>
<Col span={24}>

View File

@@ -72,6 +72,8 @@ export const QUERY_BODYSHOP = gql`
target_touchtime
appt_colors
appt_alt_transport
schedule_start_time
schedule_end_time
employees {
id
first_name
@@ -142,6 +144,8 @@ export const UPDATE_SHOP = gql`
target_touchtime
appt_colors
appt_alt_transport
schedule_start_time
schedule_end_time
employees {
id
first_name

View File

@@ -114,7 +114,6 @@ export function* calculateScheduleLoad({ payload: end }) {
load[current].jobsOut || []
);
}
console.log(load);
}
yield put(scheduleLoadSuccess(load));

View File

@@ -1,9 +1,11 @@
import _ from "lodash";
export const CheckJobBucket = (buckets, job) => {
const jobHours =
job.labhrs.aggregate.sum.mod_lb_hrs + job.larhrs.aggregate.sum.mod_lb_hrs;
const matchingBucket = buckets.filter(
(b) => b.gte <= jobHours && b.lt > jobHours
const matchingBucket = buckets.filter((b) =>
b.gte <= jobHours && b.lt ? b.lt > jobHours : true
);
return matchingBucket[0] && matchingBucket[0].id;
@@ -11,7 +13,7 @@ export const CheckJobBucket = (buckets, job) => {
export const CalculateLoad = (currentLoad, buckets, jobsIn, jobsOut) => {
//Add the jobs coming
const newLoad = { ...currentLoad };
const newLoad = _.cloneDeep(currentLoad);
jobsIn.forEach((job) => {
const bucketId = CheckJobBucket(buckets, job);
if (bucketId) {
@@ -30,13 +32,11 @@ export const CalculateLoad = (currentLoad, buckets, jobsIn, jobsOut) => {
newLoad[bucketId].count = newLoad[bucketId].count - 1;
} else {
console.log(
"[Util Arr Job]Uh oh, this job doesn't fit in a bucket!",
"[Util Out Job]Uh oh, this job doesn't fit in a bucket!",
job
);
}
});
console.log("newLoad", newLoad);
return newLoad;
};

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "schedule_start_time";
type: run_sql

View File

@@ -0,0 +1,6 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "schedule_start_time" timestamptz
NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "schedule_end_time";
type: run_sql

View File

@@ -0,0 +1,6 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "schedule_end_time" timestamptz
NULL;
type: run_sql

View File

@@ -0,0 +1,72 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- accountingconfig
- address1
- address2
- appt_alt_transport
- appt_colors
- appt_length
- bill_tax_rates
- city
- country
- created_at
- deliverchecklist
- email
- enforce_class
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- logo_img_path
- md_categories
- md_classes
- md_ins_cos
- md_labor_rates
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_rbac
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- messagingservicesid
- phone
- prodtargethrs
- production_config
- region_config
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- stripe_acct_id
- target_touchtime
- template_header
- textid
- updated_at
- zip_post
computed_fields: []
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,74 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- accountingconfig
- address1
- address2
- appt_alt_transport
- appt_colors
- appt_length
- bill_tax_rates
- city
- country
- created_at
- deliverchecklist
- email
- enforce_class
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- logo_img_path
- md_categories
- md_classes
- md_ins_cos
- md_labor_rates
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_rbac
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- messagingservicesid
- phone
- prodtargethrs
- production_config
- region_config
- schedule_end_time
- schedule_start_time
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- stripe_acct_id
- target_touchtime
- template_header
- textid
- updated_at
- zip_post
computed_fields: []
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,66 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- accountingconfig
- address1
- address2
- appt_alt_transport
- appt_colors
- appt_length
- bill_tax_rates
- city
- country
- created_at
- deliverchecklist
- email
- enforce_class
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- logo_img_path
- md_categories
- md_classes
- md_ins_cos
- md_labor_rates
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_rbac
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- phone
- prodtargethrs
- production_config
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- target_touchtime
- updated_at
- zip_post
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -0,0 +1,68 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- accountingconfig
- address1
- address2
- appt_alt_transport
- appt_colors
- appt_length
- bill_tax_rates
- city
- country
- created_at
- deliverchecklist
- email
- enforce_class
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- logo_img_path
- md_categories
- md_classes
- md_ins_cos
- md_labor_rates
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_rbac
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- phone
- prodtargethrs
- production_config
- schedule_end_time
- schedule_start_time
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- target_touchtime
- updated_at
- zip_post
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -734,6 +734,8 @@ tables:
- prodtargethrs
- production_config
- region_config
- schedule_end_time
- schedule_start_time
- scoreboard_target
- shopname
- shoprates
@@ -792,6 +794,8 @@ tables:
- phone
- prodtargethrs
- production_config
- schedule_end_time
- schedule_start_time
- scoreboard_target
- shopname
- shoprates