(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[724],{13778:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>A});var n=a(37876),s=a(14232),r=a(60072),c=a.n(r),o=a(72647);a(96390);var l=a(64085),i=a(18525),d=a(84211),u=a(4356),p=a(44247),h=a(90922),m=a(66512),x=a(87113);let j=e=>{let{props:t}=e,[a,r]=(0,s.useState)([]),[c,o]=(0,s.useState)(!1),[j,b]=(0,s.useState)(!1);(0,s.useEffect)(()=>{o(!0),b(!1),g()},[t]);let g=async()=>{let{selectcustomer:e,carType:a,specification:n,productName:s,colorCode:r,ALCCode:c,productNumber:l}=t.state,i=Object.entries({customerName:e,carType:a,specification:n,productName:s,colorCode:r,ALCCode:c,productNumber:l}).filter(e=>{let[t,a]=e;return N(a)}).map(e=>{let[t,a]=e;return"".concat(t,"=").concat(a)}).join("&"),d="".concat("https://api-cs.neuronaware.net","/inspections/dashboard/alltime?startDate=").concat(t.state.startDate,"&endDate=").concat(t.state.endDate,"&").concat(i);await fetch(d,{method:"GET",headers:{"Content-Type":"application/json",authorization:t.state.token,customerid:t.state.customerName,"Access-Control-Allow-Origin":"*","Aceess-Control-Allow-Credentials":!0,"Access-Control-Allow-Headers":"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization"}}).then(e=>{if(200==e.status)return e.json();throw Error("Return is ".concat(e.status))}).then(e=>{console.log(e),e.length>0?y(e):(o(!1),b(!0))}).catch(e=>{console.error("!!!!!!!!!! [GET]/dashboard/alltime api ERROR !!!!!!! \n ".concat(e)),window.alert("검사 실적을 조회하는 중에 오류가 발생했습니다.")})},N=e=>!!e&&0!==e.length&&!["undefined","null","all"].includes(e.toString().toLowerCase())&&0!==e.length,y=async e=>{r([]);let t=Object.entries(Object.groupBy(e,e=>{let{inspectionDate:t}=e;return t})).sort((e,t)=>{let[a]=e,[n]=t;return new Date(a)-new Date(n)}),a=[];t.forEach(e=>{let t=e[1].filter(e=>1===e.result).length>0?e[1].find(e=>1===e.result).count:0,n=parseFloat((100*t/(t+(e[1].filter(e=>0===e.result).length>0?e[1].find(e=>0===e.result).count:0))).toFixed(2));a.push({inspectionDate:e[0],percent:isNaN(n)?null:n})}),o(!1),r(a)},f=(e,t,a)=>Math.min(Math.max(e,t),a);return(0,n.jsx)(n.Fragment,{children:!0==c?(0,n.jsx)("div",{className:"text-center mr-5 p-5",children:(0,n.jsxs)("button",{className:"btn btn-light align-middle text-center",type:"button",disabled:!0,children:[(0,n.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"검사 결과 Loading..."]})}):!0==j?(0,n.jsx)("div",{className:"text-center mr-5 p-5",children:(0,n.jsx)("button",{className:"btn btn-light align-middle text-center",type:"button",disabled:!0,children:"검사 결과가 없습니다."})}):(0,n.jsx)("div",{className:"row h-50",children:(0,n.jsx)(l.u,{width:"100%",height:300,children:(0,n.jsxs)(i.b,{width:100,height:300,data:a,margin:{top:5,right:30,left:20,bottom:5},children:[(0,n.jsx)(d.d,{strokeDasharray:"3 3"}),(0,n.jsx)(u.W,{dataKey:"inspectionDate"}),(0,n.jsx)(p.h,{domain:(e=>{let t=Math.floor(Math.min(...e.map(e=>e.percent?e.percent:1/0))),a=Math.ceil(Math.max(...e.map(e=>e.percent?e.percent:-1/0)));return[f(t,0,99),f(a,1,100)]})(a)}),(0,n.jsx)(h.m,{}),(0,n.jsx)(m.s,{}),(0,n.jsx)(x.N,{connectNulls:!0,type:"monotone",dataKey:"percent",stroke:"#8884d8",activeDot:{r:8},name:"검사 성공률(%)"},"percent")]})})})})},b=e=>{let{props:t}=e,[a,r]=(0,s.useState)([]),[c,o]=(0,s.useState)(!1),[j,b]=(0,s.useState)(!1);(0,s.useEffect)(()=>{o(!0),b(!1),g()},[t]);let g=async()=>{let{selectcustomer:e,carType:a,specification:n,productName:s,colorCode:r,ALCCode:c,productNumber:l}=t.state,i=Object.entries({customerName:e,carType:a,specification:n,productName:s,colorCode:r,ALCCode:c,productNumber:l}).filter(e=>{let[t,a]=e;return N(a)}).map(e=>{let[t,a]=e;return"".concat(t,"=").concat(encodeURIComponent(a))}).join("&"),d="".concat("https://api-cs.neuronaware.net","/inspections/dashboard/customers?startDate=").concat(t.state.startDate,"&endDate=").concat(t.state.endDate,"&").concat(i);await fetch(d,{method:"GET",headers:{"Content-Type":"application/json",authorization:t.state.token,customerid:t.state.customerName,"Access-Control-Allow-Origin":"*","Aceess-Control-Allow-Credentials":!0,"Access-Control-Allow-Headers":"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization"}}).then(e=>{if(200==e.status)return e.json();throw Error("Return is ".concat(e.status))}).then(e=>{e.length>0?y(e):(b(!0),o(!1))}).catch(e=>{console.error("!!!!!!!!!! [GET]/dashboard/alltime api ERROR !!!!!!! \n ".concat(e)),window.alert("검사 실적을 조회하는 중에 오류가 발생했습니다.")})},N=e=>!!e&&0!==e.length&&!["undefined","null","all"].includes(e.toString().toLowerCase())&&0!==e.length,y=e=>{r([]);let t=Object.entries(Object.groupBy(e,e=>{let{inspectionDate:t}=e;return t})).sort((e,t)=>{let[a]=e,[n]=t;return new Date(a)-new Date(n)}),a=[];t.forEach(e=>{let t={};t.inspectionDate=e[0],Object.entries(Object.groupBy(e[1],e=>{let{customerName:t}=e;return t})).forEach(e=>{let a=e[1].filter(e=>1===e.result).length>0?e[1].find(e=>1===e.result).count:0,n=parseFloat((100*a/(a+(e[1].filter(e=>0===e.result).length>0?e[1].find(e=>0===e.result).count:0))).toFixed(2));t[e[0]]=isNaN(n)?null:n}),a.push(t)}),o(!1),r(a)},f=(e,t,a)=>Math.min(Math.max(e,t),a),C=(e,t)=>(Math.floor(Math.random()*(t-e+1))+e).toString(16).padStart(2,"0"),w=()=>{let e=C(100,200),t=C(100,200),a=C(100,200);return"#".concat(e).concat(t).concat(a)};return(0,n.jsx)(n.Fragment,{children:"ALL"===t.state.selectcustomer&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"row g-1 p-1 m-3",children:(0,n.jsx)("h5",{className:"col-md-4 text-secondary",children:"협력사 검사 실적"})}),!0==c?(0,n.jsx)("div",{className:"text-center mr-5 p-5",children:(0,n.jsxs)("button",{className:"btn btn-light align-middle text-center",type:"button",disabled:!0,children:[(0,n.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"검사 결과 Loading..."]})}):!0==j?(0,n.jsx)("div",{className:"text-center mr-5 p-5",children:(0,n.jsx)("button",{className:"btn btn-light align-middle text-center",type:"button",disabled:!0,children:"검사 결과가 없습니다."})}):(0,n.jsx)("div",{className:"row h-50",children:(0,n.jsx)(l.u,{width:"100%",height:300,children:(0,n.jsxs)(i.b,{data:a,margin:{top:5,right:30,left:20,bottom:5},children:[(0,n.jsx)(d.d,{strokeDasharray:"3 3"}),(0,n.jsx)(u.W,{dataKey:"inspectionDate"}),(0,n.jsx)(p.h,{domain:(e=>{let t=Math.floor(Math.min(...e.map(e=>Object.values(e).filter(e=>"number"==typeof e&&!isNaN(e))).flat())),a=Math.ceil(Math.max(...e.map(e=>Object.values(e).filter(e=>"number"==typeof e&&!isNaN(e))).flat()));return[f(t,0,99),f(a,1,100)]})(a)}),(0,n.jsx)(h.m,{}),(0,n.jsx)(m.s,{}),a.length>0&&Array.from(new Set(a.flatMap(e=>Object.keys(e).filter(e=>"inspectionDate"!==e)))).map(e=>(0,n.jsx)(x.N,{connectNulls:!0,type:"monotone",dataKey:e,stroke:w(),activeDot:{r:8},name:e},e))]})})})]})})};var g=a(89099),N=a.n(g),y=a(2954),f=a(3997);let C=e=>{let{props:t}=e,[a,r]=(0,s.useState)([]),[c,o]=(0,s.useState)(!1),[i,m]=(0,s.useState)(!1);(0,s.useEffect)(()=>{o(!0),m(!1),x()},[t]);let x=async()=>{let{selectcustomer:e,carType:a,specification:n,productName:s,colorCode:r,ALCCode:c,productNumber:l}=t.state,i=Object.entries({customerName:e,carType:a,specification:n,productName:s,colorCode:r,ALCCode:c,productNumber:l}).filter(e=>{let[t,a]=e;return j(a)}).map(e=>{let[t,a]=e;return"".concat(t,"=").concat(encodeURIComponent(a))}).join("&"),d="".concat("https://api-cs.neuronaware.net","/inspections/dashboard/products?startDate=").concat(t.state.startDate,"&endDate=").concat(t.state.endDate,"&").concat(i);await fetch(d,{method:"GET",headers:{"Content-Type":"application/json",authorization:t.state.token,customerid:t.state.customerName,"Access-Control-Allow-Origin":"*","Aceess-Control-Allow-Credentials":!0,"Access-Control-Allow-Headers":"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization",csattempt:"true"}}).then(e=>{if(200==e.status)return e.json();throw Error("Return is ".concat(e.status))}).then(e=>{e.length>0?b(e):(m(!0),o(!1))}).catch(e=>{console.error("!!!!!!!!!! [GET]/dashboard/alltime api ERROR !!!!!!! \n ".concat(e)),window.alert("검사 실적을 조회하는 중에 오류가 발생했습니다.")})},j=e=>!!e&&0!==e.length&&!["undefined","null","all"].includes(e.toString().toLowerCase())&&0!==e.length,b=async e=>{r([]);let t=[];Object.entries(Object.groupBy(e,e=>{let{customerName:t}=e;return t})).sort((e,t)=>{let[a]=e,[n]=t;return a{let a=[];Object.entries(Object.groupBy(e[1],e=>{let{carType:t,productName:a}=e;return[t,a]})).forEach(e=>{let t=e[1].filter(e=>1===e.result).length>0?e[1].find(e=>1===e.result).count:0,n=e[1].filter(e=>0===e.result).length>0?e[1].find(e=>0===e.result).count:0,s=parseFloat((100*t/(t+n)).toFixed(2));a.push({carType:e[1][0].carType,productName:e[1][0].productName,passCount:t,failCount:n,passPercent:isNaN(s)?null:s.toFixed(2),failPercent:isNaN(s)?null:(100-s).toFixed(2)})}),t.push({customerName:e[0],products:a})}),o(!1),r(t)},g=e=>{let{active:t,payload:a,label:s}=e;return t&&a&&a.length?(0,n.jsxs)("div",{className:"custom-tooltip",style:{backgroundColor:"rgba(255, 255, 255, 0.9)",padding:"5px",border:"1px solid #ccc"},children:[(0,n.jsx)("p",{className:"label",style:{fontWeight:"bold"},children:"".concat(s," (").concat(a[0].payload.carType,")")}),Object.keys(a[0].payload).filter(e=>e.includes("passCount")).map(e=>(0,n.jsx)("p",{className:"passCount",children:"검사 성공 : ".concat(C(a[0].payload[e]))})),Object.keys(a[0].payload).filter(e=>e.includes("failCount")).map(e=>(0,n.jsx)("p",{className:"failCount",children:"검사 실패 : ".concat(C(a[1].payload[e]))})),Object.keys(a[0].payload).filter(e=>e.includes("passPercent")).map(e=>(0,n.jsx)("p",{className:"passPercent",children:"검사 성공률(%) : ".concat(C(a[0].payload[e]),"%")})),Object.keys(a[0].payload).filter(e=>e.includes("failPercent")).map(e=>(0,n.jsx)("p",{className:"failPercent",children:"검사 실패율(%) : ".concat(C(a[1].payload[e]),"%")}))]}):null},C=e=>e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),w=e=>{N().push({pathname:"/inspectionHistory",query:{selectcustomer:e.customerName,startDate:t.state.startDate,endDate:t.state.endDate,carType:e.carType,productName:e.productName.split("(")[0],colorCode:t.state.colorCode,ALC:t.state.ALC,productNumber:t.state.productNumber,specification:t.state.specification,inspectionResult:t.state.inspectionResult,submitInspectionHistorySearchEngine:!0,isMove:!0}},"/inspectionHistory")};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"row g-1 p-1 m-3",children:(0,n.jsx)("h5",{className:"col-md-3 text-secondary",children:"제품 검사 성공/실패 비율"})}),!0==c?(0,n.jsx)("div",{className:"text-center mr-5 p-5",children:(0,n.jsxs)("button",{className:"btn btn-light align-middle text-center",type:"button",disabled:!0,children:[(0,n.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"검사 결과 Loading..."]})}):!0==i?(0,n.jsx)("div",{className:"text-center mr-5 p-5",children:(0,n.jsx)("button",{className:"btn btn-light align-middle text-center",type:"button",disabled:!0,children:"검사 결과가 없습니다."})}):(0,n.jsx)("div",{className:"row h-50",children:a.map(e=>(0,n.jsxs)("div",{className:"row h-10",children:[(0,n.jsx)("div",{className:"row g-1 p-1 m-3",children:(0,n.jsx)("h5",{className:"col-md-3 text-secondary",children:"".concat(e.customerName)})}),(0,n.jsx)(l.u,{width:"100%",height:100*e.products.length,children:(0,n.jsxs)(y.E,{layout:"vertical",data:e.products,margin:{top:5,right:30,left:20,bottom:5},children:[(0,n.jsx)(d.d,{strokeDasharray:"3 3"}),(0,n.jsx)(u.W,{type:"number",tickFormatter:C}),(0,n.jsx)(p.h,{dataKey:"productName",tickFormatter:(t,a)=>"".concat(t," (").concat(e.products[a].carType,")"),type:"category",width:150}),(0,n.jsx)(h.m,{content:(0,n.jsx)(g,{})}),(0,n.jsx)(h.m,{}),(0,n.jsx)(f.y,{dataKey:"passCount",stackId:"0",barSize:20,name:"검사 성공",fill:"#77ef55",onClick:w}),(0,n.jsx)(f.y,{dataKey:"failCount",stackId:"0",barSize:20,name:"검사 실패",fill:"#ff3333",onClick:w})]})})]}))})]})},w=e=>(0,n.jsx)(n.Fragment,{children:!0==e.state.submitInspectionHistorySearchEngine&&(0,n.jsx)("div",{className:"container-fluid",style:{maxWidth:"100vw",maxHeight:"100vh"},children:(0,n.jsxs)("div",{className:"vh-75",children:[(0,n.jsx)("div",{className:"row g-1 p-1 m-3",children:(0,n.jsxs)("h4",{className:"col-md-10 text-secondary",children:["검사 실적 [ ",e.state.startDate," - ",e.state.endDate," ]"]})}),(0,n.jsx)(j,{props:e}),(0,n.jsx)(b,{props:e}),(0,n.jsx)(C,{props:e})]})})});class D extends s.Component{static async getInitialProps(e){return{token:c()(e).token,customerName:c()(e).customerID}}async handleSubmitInspectionHistorySearchEngine(e){this.setState({selectcustomer:e.selectcustomer,startDate:e.startDate,endDate:e.endDate,carType:e.carType,productName:e.productName,colorCode:e.colorCode,productNumber:e.productNumber,ALCCode:e.ALC,specification:e.specification,inspectionResult:e.inspectionResult,submitInspectionHistorySearchEngine:!0})}render(){return(0,n.jsxs)("div",{className:"container-fluid vh-100 d-flex flex-column",children:[(0,n.jsx)("div",{className:"row flex-grow-1 m-3",children:(0,n.jsxs)("div",{className:"w-100",children:[(0,n.jsx)("br",{}),(0,n.jsx)("br",{}),(0,n.jsx)("h3",{className:"align-middle text-center",children:"검사 실적 조회"}),(0,n.jsx)(o.A,{state:this.state,handleSubmitInspectionHistorySearchEngine:this.handleSubmitInspectionHistorySearchEngine})]})}),(0,n.jsx)("div",{className:"row flex-grow-1 overflow-auto",children:(0,n.jsx)(w,{state:this.state})})]})}constructor(e){super(e),this.handleSubmitInspectionHistorySearchEngine=this.handleSubmitInspectionHistorySearchEngine.bind(this),this.state={token:e.token,customerName:e.customerName,startDate:null,endDate:null,carTypeId:null,productNameId:null,colorCodeId:null,productNumber:null,ALCCode:null,specification:null,inspectionResult:null,submitInspectionHistorySearchEngine:!1,selectcustomer:null}}}let A=D},66663:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard",function(){return a(13778)}])}},e=>{var t=t=>e(e.s=t);e.O(0,[736,647,636,593,792],()=>t(66663)),_N_E=e.O()}]);