최정우 최정우 2023-05-09
230509 최정우 푸시 알림 기능 완성 및 복약 상세 페이지 진행 중
@e4a5405dc878481f7a4e478ff6bb4b93abd8358f
client/resources/css/reset.css
--- client/resources/css/reset.css
+++ client/resources/css/reset.css
@@ -82,17 +82,15 @@
   border: 1px solid #d8d3c7;
 }
 
-input::-webkit-outer-spin-button,
-input::-webkit-inner-spin-button {
+input[type=number]:not(.spin)::-webkit-outer-spin-button,
+input[type=number]:not(.spin)::-webkit-inner-spin-button {
   -webkit-appearance: none;
   margin: 0;
 }
-
 /* Firefox */
-input[type=number] {
+input[type=number]:not(.spin) {
   -moz-appearance: textfield;
 }
-
 input[type="button"]{
   width: 100%;
   background: none;
client/views/component/chart/Chart1.jsx
--- client/views/component/chart/Chart1.jsx
+++ client/views/component/chart/Chart1.jsx
@@ -4,6 +4,17 @@
 import am5themes_Animated from "@amcharts/amcharts5/themes/Animated";
 
 class Chart1 extends Component {
+
+  constructor(props) {
+    super(props);
+
+    console.log("chart data11 : ", this.props.data);
+  }
+
+  componentWillReceiveProps(nextProps) {
+    console.log("chart data22 : ", nextProps.data);
+  }
+  
   componentDidMount() {
     let root1 = am5.Root.new("chartdiv1");
 
client/views/layout/Menu.jsx
--- client/views/layout/Menu.jsx
+++ client/views/layout/Menu.jsx
@@ -28,7 +28,7 @@
     }).then((response) => response.json()).then((data) => {
       console.log("로그아웃 결과 : ", data);
       if (data == true) {
-        navigate('/Main');
+        navigate('/');
       } else {
         alert('로그아웃 실패, 관리자에게 문의바랍니다.');
       }
client/views/pages/AppRoute.jsx
--- client/views/pages/AppRoute.jsx
+++ client/views/pages/AppRoute.jsx
@@ -9,6 +9,7 @@
 
 import HouseIcon from "@mui/icons-material/House";
 import PersonIcon from "@mui/icons-material/Person";
+import CorporateFareIcon from '@mui/icons-material/CorporateFare';
 import Diversity1Icon from "@mui/icons-material/Diversity1";
 import SpeakerPhoneIcon from "@mui/icons-material/SpeakerPhone";
 import SettingsIcon from "@mui/icons-material/Settings";
@@ -67,26 +68,26 @@
 const AdminAppMenuItems = [
   {
     title: "Home",
-    path: "/Main",
+    path: "/",
     icon: <HouseIcon sx={{ fontSize: 20, marginRight: 1 }} />,
   },
   {
     title: "기관 관리",
+    path: "/OrgSelect",
+    icon: (
+      <CorporateFareIcon
+        sx={{ fontSize: 20, marginRight: 1 }}
+      />
+    ),
+  },
+  {
+    title: "사용자 관리",
+    path: "/UserSelect",
     icon: (
       <PersonIcon
         sx={{ fontSize: 20, marginRight: 1 }}
       />
     ),
-    childrens: [
-      {
-        title: "기관 관리",
-        path: "/OrgSelect",
-      },
-      {
-        title: "사용자 관리",
-        path: "/UserSelect",
-      },
-    ],
   },
   {
     title: "장비 관리",
@@ -133,7 +134,7 @@
 
       <Route path="/Medicalcare" element={<Medicalcare />}></Route>
       <Route path="/Healthcare" element={<Healthcare />}></Route>
-      <Route path="/Main" element={<Main />}></Route>
+      <Route path="/" element={<Main />}></Route>
       <Route path="/EquipmentRentalInsert" element={<EquipmentRentalInsert />}></Route>
       <Route path="/EquipmentManagementInsert" element={<EquipmentManagementInsert />}></Route>
       <Route path="/EquipmentSelect" element={<EquipmentSelect />}></Route>
@@ -163,26 +164,26 @@
 const GovernmentAppMenuItems = [
   {
     title: "Home",
-    path: "/Main",
+    path: "/",
     icon: <HouseIcon sx={{ fontSize: 20, marginRight: 1 }} />,
   },
   {
     title: "기관 관리",
+    path: "/OrgSelect",
+    icon: (
+      <CorporateFareIcon
+        sx={{ fontSize: 20, marginRight: 1 }}
+      />
+    ),
+  },
+  {
+    title: "사용자 관리",
+    path: "/UserSelect",
     icon: (
       <PersonIcon
         sx={{ fontSize: 20, marginRight: 1 }}
       />
     ),
-    childrens: [
-      {
-        title: "기관 관리",
-        path: "/OrgSelect",
-      },
-      {
-        title: "사용자 관리",
-        path: "/UserSelect",
-      },
-    ],
   },
   {
     title: "장비 관리",
@@ -250,7 +251,7 @@
 
       <Route path="/Medicalcare" element={<Medicalcare />}></Route>
       <Route path="/Healthcare" element={<Healthcare />}></Route>
-      <Route path="/Main" element={<Main_government />}></Route>
+      <Route path="/" element={<Main_government />}></Route>
       <Route path="/AgencySelect" element={<AgencySelect />}></Route>
       <Route path="/UserSelectOk" element={<UserSelectOk />}></Route>      
       <Route path="/MedicineCareSelectOne" element={<MedicineCareSelectOne />}></Route>      
@@ -280,7 +281,7 @@
 const AgencyAppMenuItems = [
   {
     title: "Home",
-    path: "/Main",
+    path: "/",
     icon: <HouseIcon sx={{ fontSize: 20, color: "#333333", marginRight: 1 }} />,
   },
   {
@@ -330,7 +331,7 @@
       <Route path="/Join" element={<Join />}></Route>
       <Route path="/QuestionSelect" element={<QuestionSelect />}></Route>
       
-      <Route path="/Main" element={<Main_agency />}></Route>
+      <Route path="/" element={<Main_agency />}></Route>
       <Route path="/AgencySeniorSelect" element={<AgencySeniorSelect />}></Route>
       <Route path="/SeniorEdit" element={<SeniorEdit />}></Route>
       <Route path="/SeniorSelectOne" element={<SeniorSelectOne />}></Route>
@@ -367,7 +368,7 @@
 const GuardianAppMenuItems = [
   {
     title: "Home",
-    path: "/Main",
+    path: "/",
     icon: <HouseIcon sx={{ fontSize: 20, marginRight: 1 }} />,
   },
   {
@@ -389,7 +390,7 @@
   return (
     <Routes>
       <Route path="/GuardianStatistics" element={<GuardianStatistics />}></Route>
-      <Route path="/Main" element={<Main_guardian />}></Route>
+      <Route path="/" element={<Main_guardian />}></Route>
       <Route path="/QandAInsert" element={<QandAInsert />}></Route>
       <Route path="/QandASelect" element={<QandASelect />}></Route>
       <Route path="/QandASelectOne" element={<QandASelectOne />}></Route>
client/views/pages/equipment/EquipmentSelect.jsx
--- client/views/pages/equipment/EquipmentSelect.jsx
+++ client/views/pages/equipment/EquipmentSelect.jsx
@@ -540,11 +540,11 @@
 	const [tabIndex, setTabIndex] = React.useState(defaultTabIndex);
 	//탭 초기화
 	const tab = [{
-		title: `신규 장비 (${newEquipment.equipmentListCount})`,
+		title: `미등록 장비 (${newEquipment.equipmentListCount})`,
 		content: (
 			<div>
 				<div className="flex equip-tab">
-					<SubTitle explanation={"데이터 수집 정보로부터 신규 등록된 장비 목록입니다. ★장비 정보를 업데이트해주세요.★"} />
+					<SubTitle explanation={"데이터 통신을 통해 확인된 장비 목록입니다. ★장비 정보를 업데이트해주세요.★"} />
 					{/* <div className="btn-wrap flex-end margin-bottom ">
 						{isEquipmentDelivery
 							? <>
client/views/pages/healthcare/Healthcare.jsx
--- client/views/pages/healthcare/Healthcare.jsx
+++ client/views/pages/healthcare/Healthcare.jsx
@@ -101,8 +101,13 @@
 					<tbody>
 						{senior.seniorList.map((item, idx) => { return (
 						<tr key={idx} onClick={() => {
-                            navigate("/MedicineCareSelectOne");
-                        }}>
+							navigate("/MedicineCareSelectOne", {
+								state: {
+								  	'senior_id': item['user_id'],
+								  	'agency_id': item['agency_id'],
+									'government_id': item['government_id']
+								}
+							})}}>
 							<td data-label="No">{senior.seniorListCount - idx - (senior.search.currentPage - 1) * senior.search.perPage}</td>
 							<td data-label="소속기관명">{item['agency_name']}</td>
 							<td data-label="이름">{item['user_name']}</td>
client/views/pages/healthcare/medicinecare/MedicineCareSelectOne.jsx
--- client/views/pages/healthcare/medicinecare/MedicineCareSelectOne.jsx
+++ client/views/pages/healthcare/medicinecare/MedicineCareSelectOne.jsx
@@ -1,7 +1,9 @@
 import React from "react";
+import { useNavigate, useLocation } from "react-router";
+
 import Button from "../../../component/Button.jsx";
 import Modal from "../../../component/Modal.jsx";
-import { useNavigate } from "react-router";
+
 import Chart1 from "../../../component/chart/Chart1.jsx";
 import Chart3 from "../../../component/chart/Chart3.jsx";
 import Chart from "../../../component/chart/Chart.jsx";
@@ -12,8 +14,117 @@
 import LineColor_medicine from "../../../component/chart/LineColor_medicine.jsx";
 import MedicationIcon from '@mui/icons-material/Medication';
 
+import CommonUtil from "../../../../resources/js/CommonUtil.js";
+
 export default function MedicineCareSelectOne() {
   const navigate = useNavigate();
+  const location = useLocation();
+
+  //시니어 정보
+  const [senior, setSenior] = React.useState({
+    'user_id': location.state['senior_id'],
+    'user_name': null,
+    'user_password': null,
+    'user_phonenumber': null,
+    'user_birth': null,
+    'user_gender': null,
+    'user_address': null,
+    'user_email': null,
+    'authority': 'ROLE_SENIOR',
+    'agency_id': location.state['agency_id'],
+    'government_id': location.state['government_id'],
+
+    'senior_id': location.state['senior_id'],
+    'care_grade': null,
+    'medication_pill': null,
+    'underlie_disease': null,
+    'senior_note': null,
+
+    'seniorMedicationList': []
+  });
+  //시니어 상세 조회
+  const seniorSelectOne = () => {
+    fetch("/user/seniorSelectOne.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(senior),
+    }).then((response) => response.json()).then((data) => {
+      console.log("seniorSelectOne data : ", data);
+      setSenior(data);
+    }).catch((error) => {
+      console.log('seniorSelectOne() /user/seniorSelectOne.json error : ', error);
+    });
+  };
+
+  //특정 대상자의 실제 복약 정보
+  const [seniorMedicationListAndCount, setSeniorMedicationListAndCount] = React.useState([]);
+  //특정 대상자의 실제 복약 정보 목록 조회
+  const seniorMedicationSelectListAndCount = () => {
+    fetch("/user/seniorMedicationSelectListAndCount.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(senior),
+    }).then((response) => response.json()).then((data) => {
+      console.log("seniorMedicationSelectListAndCount data : ", data);
+      setSeniorMedicationListAndCount(data);
+      seniorMedicationSelectListByDay();
+    }).catch((error) => {
+      console.log('seniorMedicationSelectListAndCount() /user/seniorMedicationSelectListAndCount.json error : ', error);
+    });
+  };
+
+  //특정 대상자의 일별, 복약시간별 복약 목록
+  const [seniorMedicationListByDay, setSeniorMedicationListByDay] = React.useState([]);
+  const [stackChartData, setStackChartData] = React.useState([]);
+  //특정 대상자의 일별, 복약시간별 복약 목록 조회
+  const seniorMedicationSelectListByDay = () => {
+    fetch("/user/seniorMedicationSelectListByDay.json", {
+      method: "POST",
+      headers: {
+        'Content-Type': 'application/json; charset=UTF-8'
+      },
+      body: JSON.stringify(senior),
+    }).then((response) => response.json()).then((data) => {
+      console.log("seniorMedicationListByDay data : ", data);
+      setSeniorMedicationListByDay(data);
+
+      let showMedicationTimeCode = {};
+      for (let i = 0; i < seniorMedicationListAndCount.length; i++) {
+        if (seniorMedicationListAndCount[i]['medication_time_code_count'] > 0) {
+          showMedicationTimeCode[seniorMedicationListAndCount[i]['medication_time_code']] = true;
+        } else {
+          showMedicationTimeCode[seniorMedicationListAndCount[i]['medication_time_code']] = false;
+        }
+      }
+
+      if (CommonUtil.isEmpty(data) == false) {
+        let _stackChartData = [];
+        for (let i = 0; i < data.length; i++) {
+          let chartData = {
+            xName: data[i]['medication_default_date']
+          };
+          for (let j = 0; j < data[i]['medication_time_code_list'].length; j++) {
+            if (showMedicationTimeCode[data[i]['medication_time_code_list'][j]] == true) {
+              chartData[data[i]['medication_time_code_list'][j]] = chartData[data[i]['medication_time_code_count_list'][j]];
+            } else {
+              continue;
+            }
+          }
+          _stackChartData.push(chartData);
+        }
+        setStackChartData(_stackChartData);
+      }
+      
+    }).catch((error) => {
+      console.log('seniorMedicationSelectListByDay() /user/seniorMedicationSelectListByDay.json error : ', error);
+    });
+  };
+  
+
   const [modalOpen, setModalOpen] = React.useState(false);
   const openModal = () => {
     setModalOpen(true);
@@ -21,6 +132,13 @@
   const closeModal = () => {
     setModalOpen(false);
   };
+
+
+  React.useEffect(() => {
+    seniorSelectOne();
+    seniorMedicationSelectListAndCount();
+  }, [])
+
   return (
     <main>
       <Modal open={modalOpen} close={closeModal} header="복약 내역 수정">
@@ -108,8 +226,8 @@
       <div className="content-wrap">
         <ContentTitle contentTitle={"복약 상세 페이지"} />
         <div className="detail-graph">
-          <TableTitle tableTitle={"복약 내역"} />{/*  님의 복약 내역 */}
-          <Chart1 />
+          <TableTitle tableTitle={`${senior['user_name']}님의 복약 내역`} />{/*  님의 복약 내역 */}
+          <Chart1 data={seniorMedicationListByDay}/>
         </div>
         <div className="medicine-grid margin-bottom">
           <div><SubTitle
client/views/pages/login/Login.jsx
--- client/views/pages/login/Login.jsx
+++ client/views/pages/login/Login.jsx
@@ -39,7 +39,7 @@
     }).then((response) => response.json()).then((data) => {
       console.log("로그인 결과 : ", data);
       if (data.isSuccess == true) {
-        navigate('/Main');
+        navigate('/');
       } else {
         alert(data.message);
       }
client/views/pages/setting/RiskSet.jsx
--- client/views/pages/setting/RiskSet.jsx
+++ client/views/pages/setting/RiskSet.jsx
@@ -27,19 +27,6 @@
     const riskStandardRef = React.useRef({...riskStandard});
 
 
-    
-    //위험 기준 정보
-    const [sipal, setSipal] = React.useState({
-        'government_id': defaultGovernmentId,
-        'risk_standard_type': null,
-        'risk_standard_cycle': null,
-        'risk_standard_start_value': null,
-        'risk_standard_end_value': null
-    });
-
-
-    
-
     //위험 기준 유효성 검사
     const riskStandardValidation = () => {
         const target = riskStandard;
@@ -95,7 +82,7 @@
 		}).then((response) => response.json()).then((data) => {
 			console.log("위험 기준 수정 결과(건수) : ", data);
 			if (data > 0) {
-                //riskStandardSelectList();
+                riskStandardSelectList();
 				alert("수정완료");
 			} else {
 				alert("수정에 실패하였습니다. 관리자에게 문의바랍니다.");
@@ -124,13 +111,20 @@
 		});
     }
 
+    //현재 탭 Index
+	const [tabIndex, setTabIndex] = React.useState(0);
+
     React.useEffect(() => {
         riskStandardSelectList();
         console.log('riskStandard : ', riskStandard);
     }, []);
-    
-    //현재 탭 Index
-	const [tabIndex, setTabIndex] = React.useState(0);
+
+    React.useEffect(() => {
+        console.log('riskStandardList['+tabIndex+'] : ', riskStandardList[tabIndex]);
+        if (riskStandardList[tabIndex]) {
+            setRiskStandard(riskStandardList[tabIndex]);
+        }
+    }, tabIndex);
 
 	//탭 초기화
 	const tab = [{
@@ -142,15 +136,47 @@
                         <tr>
                             <td style={{textAlign: 'right'}}>최근 온도가</td>
                             <td>
-                                <input type="number" value={riskStandard['risk_standard_start_value']}
+                                <input type="number" className="spin"
+                                    value={riskStandard['risk_standard_start_value']}
                                     onChange={(e) => {
-                                        riskStandard['risk_standard_start_value'] = e.target.value;
+                                        let value = e.target.value
+                                        if (value < -273) {
+                                            alert('절대0도(-273℃) 보다 높아야합니다.');
+                                            value = 0;
+                                        }
+                                        if (value >= Number(riskStandard['risk_standard_end_value'])) {
+                                            alert('최대값 보다는 작아야합니다.');
+                                            value = Number(riskStandard['risk_standard_end_value']) - 1;
+                                        }
+                                        riskStandard['risk_standard_start_value'] = value;
                                         setRiskStandard({...riskStandard});
                                     }}
+                                    onKeyUp={(e) => {e.key == 'Enter' ? riskStandardUpdate() : null}}
                                     ref={el => riskStandardRef.current['risk_standard_start_value'] = el}
                                 />
                             </td>
-                            <td style={{textAlign: 'left'}}>이하 일 경우 위험알림으로 지정합니다.</td>
+                            <td style={{textAlign: 'left'}}>이하</td>
+                            <td>
+                                <input type="number" className="spin"
+                                    value={riskStandard['risk_standard_end_value']}
+                                    onChange={(e) => {
+                                        let value = e.target.value
+                                        if (value < -273) {
+                                            alert('절대0도(-273℃) 보다 높아야합니다.');
+                                            value = 0;
+                                        }
+                                        if (value <= Number(riskStandard['risk_standard_start_value'])) {
+                                            alert('최소값 보다는 커야합니다.');
+                                            value = Number(riskStandard['risk_standard_start_value']) + 1;
+                                        }
+                                        riskStandard['risk_standard_end_value'] = value;
+                                        setRiskStandard({...riskStandard});
+                                    }}
+                                    onKeyUp={(e) => {e.key == 'Enter' ? riskStandardUpdate() : null}}
+                                    ref={el => riskStandardRef.current['risk_standard_end_value'] = el}
+                                />
+                            </td>
+                            <td style={{textAlign: 'left'}}>이상 일 경우 위험알림으로 지정합니다.</td>
                             <td style={{textAlign: 'left'}}>
                                 <button className="btn-small gray-btn" onClick={() => {riskStandardUpdate()}}>저장</button>
                             </td>
@@ -168,12 +194,20 @@
                         <tr>
                             <td style={{textAlign: 'right'}}>최근 미복약 횟수가</td>
                             <td>
-                                <input type="number" value={riskStandard['risk_standard_start_value']}
+                                <input type="number" className="spin"
+                                    value={riskStandard['risk_standard_start_value']}
                                     onChange={(e) => {
-                                        riskStandard['risk_standard_start_value'] = e.target.value;
+                                        let value = e.target.value
+                                        if (value < 0) {
+                                            alert('0회 이상 이어야합니다.');
+                                            value = 0;
+                                        }
+                                        riskStandard['risk_standard_start_value'] = value;
                                         setRiskStandard({...riskStandard});
                                     }}
+                                    onKeyUp={(e) => {e.key == 'Enter' ? riskStandardUpdate() : null}}
                                     ref={el => riskStandardRef.current['risk_standard_start_value'] = el}
+                                    
                                 />
                             </td>
                             <td style={{textAlign: 'left'}}>회 이상일 경우 위험알림으로 지정합니다.</td>
@@ -194,11 +228,21 @@
                         <tr>
                             <td style={{textAlign: 'right'}}>배터리 잔량이 최근</td>
                             <td>
-                                <input type="number" value={riskStandard['risk_standard_start_value']}
+                                <input type="number" className="spin"
+                                    value={riskStandard['risk_standard_start_value']}
                                     onChange={(e) => {
-                                        riskStandard['risk_standard_start_value'] = e.target.value;
+                                        let value = e.target.value
+                                        if (value < 0) {
+                                            alert('0% 이상 이여야합니다.');
+                                            value = 0;
+                                        } else if (value > 99) {
+                                            alert('99% 이하 이어야합니다.');
+                                            value = 99;
+                                        }
+                                        riskStandard['risk_standard_start_value'] = value;
                                         setRiskStandard({...riskStandard});
                                     }}
+                                    onKeyUp={(e) => {e.key == 'Enter' ? riskStandardUpdate() : null}}
                                     ref={el => riskStandardRef.current['risk_standard_start_value'] = el}
                                 />
                             </td>
firebase-messaging-sw.js
--- firebase-messaging-sw.js
+++ firebase-messaging-sw.js
@@ -28,21 +28,21 @@
     console.log("push: ", e.data.json());
     if (!e.data.json()) return;
   
-    const resultData = e.data.json().notification;
-    console.log("push resultData : ", resultData);
-    console.log("push resultData.image : ", resultData.image);
-    const notificationTitle = resultData.title;
+    const resultData = e.data.json();
+    //console.log("push resultData : ", resultData);
+    const notificationTitle = resultData.notification.title;
     const notificationOptions = {
-      body: resultData.body,
-      //icon: resultData.image, // 웹 푸시 이미지는 icon
-      tag: resultData.tag,
+      body: resultData.notification.body,
+      icon: resultData.notification.image, // 웹 푸시 이미지는 icon
+      tag: resultData.notification.tag,
+      data: resultData.data
     };
   
     self.registration.showNotification(notificationTitle, notificationOptions);
   });
 
 self.addEventListener("notificationclick", function (event) {
-    console.log("notification click");
+    console.log("notification click event.notification : ", event.notification);
     const url = "/";
     event.notification.close();
     event.waitUntil(clients.openWindow(url));
Add a comment
List