박정하 박정하 2023-07-10
230710 박정하 계정 조회 관련 기능
@37af988c0b4f2b90b5729e1368fb9bf7bf6e1cc6
client/views/component/Calendar.jsx
--- client/views/component/Calendar.jsx
+++ client/views/component/Calendar.jsx
@@ -28,9 +28,21 @@
         todayTemperature.push(item['temperature']);
       }
     })
-    return (
-      <p>{todayTemperature[0]}</p>
-    )
+    if (todayTemperature.length > 0) {
+      if (moment(date['date']).format("MM") >= 11 || moment(date['date']).format("MM") <= 2) {
+        return (
+          <p>{Math.min.apply(null, todayTemperature)}</p>
+          )
+        } else {
+          return (
+          <p>{Math.max.apply(null, todayTemperature)}</p>
+        )
+      }
+    } else {
+      return (
+        <p>-</p>
+      )
+    }
   }
 
   const mark = [];
client/views/component/chart/Chart9.jsx
--- client/views/component/chart/Chart9.jsx
+++ client/views/component/chart/Chart9.jsx
@@ -2,13 +2,14 @@
 import * as am5 from "@amcharts/amcharts5";
 import * as am5xy from "@amcharts/amcharts5/xy";
 import am5themes_Animated from "@amcharts/amcharts5/themes/Animated";
+import CommonUtil from "../../../resources/js/CommonUtil";
 
-class Chart9 extends Component {
-  componentDidMount() {
-    /* Chart code */
-    // Create root element
-    // https://www.amcharts.com/docs/v5/getting-started/#Root_element
-    let root = am5.Root.new("chart9");
+export default function Chart9({ data }) {
+  const createChart = () => {
+    console.log('createChart9 data : ', data);
+
+    let root = am5.Root.new("Chart9");
+    root._logo.dispose();
 
 
     // Set themes
@@ -37,33 +38,9 @@
     cursor.lineY.set("visible", false);
 
 
-    // Generate random data
-    let date = new Date();
-    date.setHours(0, 0, 0, 0);
-    let value = 0;
-
-    function generateData() {
-      value = Math.round((Math.random() * 100) + 1);
-      am5.time.add(date, "day", 1);
-      return {
-        date: date.getTime(),
-        value: value
-      };
-    }
-
-    function generateDatas(count) {
-      let data = [];
-      for (var i = 0; i < count; ++i) {
-        data.push(generateData());
-      }
-      return data;
-    }
-
-
     // Create axes
     // https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
     let xAxis = chart.xAxes.push(am5xy.DateAxis.new(root, {
-      maxDeviation: 0.2,
       baseInterval: {
         timeUnit: "day",
         count: 1
@@ -73,6 +50,8 @@
     }));
 
     let yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
+      min: 0,
+      max: 100,
       renderer: am5xy.AxisRendererY.new(root, {})
     }));
 
@@ -83,12 +62,16 @@
       name: "Series",
       xAxis: xAxis,
       yAxis: yAxis,
-      valueYField: "value",
-      valueXField: "date",
+      valueYField: "percent",
+      valueXField: "xName",
       tooltip: am5.Tooltip.new(root, {
         labelText: "{valueY}"
       })
     }));
+    series.strokes.template.setAll({
+      strokeWidth: 2,
+      strokeDasharray: [3, 3],
+    });
 
 
     // Add scrollbar
@@ -99,7 +82,6 @@
 
 
     // Set data
-    let data = generateDatas(120);
     series.data.setAll(data);
 
 
@@ -107,11 +89,17 @@
     // https://www.amcharts.com/docs/v5/concepts/animations/
     series.appear(1000);
     chart.appear(1000, 100);
+
   }
 
-  render() {
-    return <div id="chart9" style={{ width: "100%", height: "100%" }}></div>;
-  }
-}
+  React.useEffect(() => {
+    console.log('React.useEffect chart2 data : ', data);
+    if (CommonUtil.isEmpty(data) == false) {
+      createChart();
+    }
+  }, [data])
 
-export default Chart9;
+  return (
+    <div id="Chart9" style={{ width: "100%", height: "100%" }}></div>
+  )
+}
(No newline at end of file)
client/views/pages/equipment/AgencyEquipmentSelect.jsx
--- client/views/pages/equipment/AgencyEquipmentSelect.jsx
+++ client/views/pages/equipment/AgencyEquipmentSelect.jsx
@@ -247,7 +247,11 @@
         <div className="board-wrap" style={{ marginTop: "3rem" }} >
           <div className="btn-wrap margin-bottom">
             <div className="btn-wrap flex-end margin-bottom ">
-              <button className={"btn-small gray-btn"} onClick={() => navigate("/AgencyAdminSeniorSelect")}>대상자 관리</button>
+              {CommonUtil.isEmpty(state.loginUser) && state.loginUser['authority'] == 'ROLE_AGENCYADMIN' ? (
+                <button className={"btn-small gray-btn"} onClick={() => navigate("/AgencyAdminSeniorSelect")}>대상자 관리</button>
+              ) : (
+                <button className={"btn-small gray-btn"} onClick={() => navigate("/AgencySeniorSelect")}>대상자 관리</button>
+              )}
             </div>
             {rentalContent}
           </div>
client/views/pages/healthcare/Healthcare.jsx
--- client/views/pages/healthcare/Healthcare.jsx
+++ client/views/pages/healthcare/Healthcare.jsx
@@ -171,9 +171,9 @@
           chartData['time'] = data[i]['temperature_time'];
 
           if (data[i]['temperature_date'].substr(5, 2) >= 11 || data[i]['temperature_date'].substr(5, 2) <= 2) {
-            _stackTemperatureData.push(chartData);
-          } else {
             _stackTemperatureData.unshift(chartData);
+          } else {
+            _stackTemperatureData.push(chartData);
           }
         }
 
client/views/pages/healthcare/HealthcareSelectOne.jsx
--- client/views/pages/healthcare/HealthcareSelectOne.jsx
+++ client/views/pages/healthcare/HealthcareSelectOne.jsx
@@ -95,6 +95,7 @@
   const [seniorMedicationListByDay, setSeniorMedicationListByDay] = React.useState([]);
   const [stackChartData, setStackChartData] = React.useState([]);
   const [medicationData, setMedicationData] = React.useState([]);
+  const [medicationStats, setMedicationStats] = React.useState([]);
   //특정 대상자의 일별, 복약시간별 복약 목록 조회
   const seniorMedicationSelectListByDay = (seniorMedicationList) => {
     fetch("/user/seniorMedicationSelectListByDay.json", {
@@ -117,9 +118,11 @@
       if (CommonUtil.isEmpty(data) == false) {
         let _stackChartData = [];
         let _medicationData = [];
+        let _medicationStats = [];
         for (let i = 0; i < data.length; i++) {
           let sum = 0;      // 실제 복약량
           let counter = 0;  // 복약해야하는 양
+          let percent = 0;
           let chartData = {
             xName: data[i]['medication_default_date'],
           };
@@ -134,11 +137,17 @@
               continue;
             }
           }
+          if (sum != 0 && counter != 0) {
+            percent = Math.floor((sum / counter) * 100)
+          }
           _medicationData.push(chartData);
           _stackChartData.push({ "xName": data[i]['medication_default_date'], "sum": sum, "total": counter });
+          _medicationStats.push({ "xName": new Date(data[i]['medication_default_date']).getTime(), "percent": percent });
         }
+        console.log("_medicationStats: ", _medicationStats);
         setMedicationData(_medicationData);
         setStackChartData(_stackChartData);
+        setMedicationStats(_medicationStats);
       }
 
     }).catch((error) => {
@@ -173,8 +182,13 @@
           chartData['temperature'] = data[i]['temperature_data'];
           chartData['time'] = data[i]['temperature_time'];
 
-          _stackTemperatureData.push(chartData);
+          if (data[i]['temperature_date'].substr(5, 2) >= 11 || data[i]['temperature_date'].substr(5, 2) <= 2) {
+            _stackTemperatureData.unshift(chartData);
+          } else {
+            _stackTemperatureData.push(chartData);
+          }
         }
+
         setStackTemperatureData(_stackTemperatureData);
         console.log('_stackTemperatureData : ', _stackTemperatureData);
       }
@@ -455,7 +469,7 @@
 
     seniorBatteryListByDay.map((item, idx) => {
       if (item['battery_date'] == visitDate) {
-        clcickDayBattery = item['battery_power_data'];
+        clcickDayBattery = item['battery_power_data'] + '%';
       } else {
         return
       }
@@ -495,7 +509,7 @@
         <div className="content-wrap margin-top">
           <DetailTitle contentTitle={"대상자의 복용률을 확인 할 수 있습니다."} />
           <div className="main-guardian-chart margin-top">
-            <Chart9 />
+            <Chart9 data={medicationStats} />
           </div>
         </div>
 
client/views/pages/main/Main_guardian.jsx
--- client/views/pages/main/Main_guardian.jsx
+++ client/views/pages/main/Main_guardian.jsx
@@ -37,6 +37,7 @@
 import percent_m_60 from '../../../resources/files/images/percent_m_60.png';
 import percent_m_80 from '../../../resources/files/images/percent_m_80.png';
 import percent_m_100 from '../../../resources/files/images/percent_m_100.png';
+import Chart9 from "../../component/chart/Chart9.jsx";
 
 import CommonUtil from "../../../resources/js/CommonUtil.js";
 
@@ -62,6 +63,7 @@
       seniorSelectOne();
       seniorMedicationSelectList();
       seniorTemperatureSelectListByDay();
+      seniorBatterySelectListByDay();
       visitRecordSelectList();
     } else {
       return;
@@ -122,6 +124,7 @@
   const [seniorMedicationListByDay, setSeniorMedicationListByDay] = React.useState([]);
   const [stackChartData, setStackChartData] = React.useState([]);
   const [medicationData, setMedicationData] = React.useState([]);
+  const [medicationStats, setMedicationStats] = React.useState([]);
   //특정 대상자의 일별, 복약시간별 복약 목록 조회
   const seniorMedicationSelectListByDay = (seniorMedicationList) => {
     fetch("/user/seniorMedicationSelectListByDay.json", {
@@ -140,9 +143,11 @@
       if (CommonUtil.isEmpty(data) == false) {
         let _stackChartData = [];
         let _medicationData = [];
+        let _medicationStats = [];
         for (let i = 0; i < data.length; i++) {
           let sum = 0;      // 실제 복약량
           let counter = 0;  // 복약해야하는 양
+          let percent = 0;
           let chartData = {
             xName: data[i]['medication_default_date'],
           };
@@ -157,11 +162,17 @@
               continue;
             }
           }
+          if (sum != 0 && counter != 0) {
+            percent = Math.floor((sum / counter) * 100)
+          }
           _medicationData.push(chartData);
           _stackChartData.push({ "xName": data[i]['medication_default_date'], "sum": sum, "total": counter });
+          _medicationStats.push({ "xName": new Date(data[i]['medication_default_date']).getTime(), "percent": percent });
         }
+        console.log("_medicationStats: ", _medicationStats);
         setMedicationData(_medicationData);
         setStackChartData(_stackChartData);
+        setMedicationStats(_medicationStats);
       }
     }).catch((error) => {
       console.log('seniorMedicationSelectListByDay() /user/seniorMedicationSelectListByDay.json error : ', error);
@@ -209,13 +220,13 @@
   //특정 대상자의 일별 배터리 목록
   const [seniorBatteryListByDay, setSeniorBatteryListByDay] = React.useState([]);
   //특정 대상자의 일별 배터리 목록 조회
-  const seniorBatterySelectListByDay = (seniorNum) => {
+  const seniorBatterySelectListByDay = () => {
     fetch("/user/seniorBatterySelectListByDay.json", {
       method: "POST",
       headers: {
         'Content-Type': 'application/json; charset=UTF-8'
       },
-      body: JSON.stringify(seniorNum),
+      body: JSON.stringify(seniorSearch),
     }).then((response) => response.json()).then((data) => {
       console.log("seniorBatteryListByDay data : ", data);
       setSeniorBatteryListByDay(data);
@@ -359,7 +370,7 @@
 
     seniorBatteryListByDay.map((item, idx) => {
       if (item['battery_date'] == visitDate) {
-        clcickDayBattery = item['battery_power_data'];
+        clcickDayBattery = item['battery_power_data'] + '%';
       } else {
         return
       }
@@ -416,6 +427,12 @@
         </div>
         <Calendar data={{ senior: senior, medication: stackChartData, temperature: stackTemperatureData, visitRecordList: visitRecordList, onClick: calerndarClick }} />
 
+        <div className="content-wrap margin-top">
+          <div className="main-guardian-chart margin-top">
+            <Chart9 data={medicationStats} />
+          </div>
+        </div>
+
         <Modal open={modalOpen} close={closeModal} header="시니어 정보 관리">
           <div className="modal-visit board-wrap">
             <table className="margin-bottom">
client/views/pages/user_management/UserSelect.jsx
--- client/views/pages/user_management/UserSelect.jsx
+++ client/views/pages/user_management/UserSelect.jsx
@@ -71,12 +71,39 @@
     'government_id': state.loginUser['government_id'],
     'agency_id': state.loginUser['agency_id'],
     'authority': null,
+    'user_use': null,
 
     'searchType': null,
     'searchText': null,
     'currentPage': 1,
     'perPage': 10,
   });
+
+  const useStateChange = () => {
+    console.log("isViewType:", isViewType)
+    senior.search.user_use = isViewType ? null : false;
+    orgSelectListOfHierarchy();
+
+    if (CommonUtil.isEmpty(location.state) == false) {
+      const param = location.state;
+      if (CommonUtil.isEmpty(param['tabActiveByRoleType']) == false) {
+        setTabActiveByRoleType(param['tabActiveByRoleType']);
+      }
+      governmentChange(param['government_id']);
+      agencyChange(param['government_id'], param['agency_id']);
+    } else {
+      seniorSelectList();
+      agentSelectList();
+      agentAdminSelectList();
+      if (state.loginUser['authority'] == 'ROLE_ADMIN' || state.loginUser['authority'] == 'ROLE_GOVERNMENT') {
+        governmentSelectList();
+      }
+    }
+
+    if (state.loginUser['authority'] == 'ROLE_ADMIN') {
+      adminSelectList();
+    }
+  }
 
   //대상자(시니어) 목록 및 페이징 정보
   userSearch['authority'] = 'ROLE_SENIOR';
@@ -376,6 +403,10 @@
     }
   }, []);
 
+  React.useEffect(() => {
+    useStateChange();
+  }, [isViewType])
+
 
   return (
     <main>
Add a comment
List