Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-09-14 17:27:20 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
1e0e434b2f1d872aab068dab0c450e8f522153c2
1e0e434b
2 parents
867b77af
0fc0bca5
fix. merge conflict
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
23 deletions
server/package.json
server/src/api/bottle/bottle.ctrl.js
server/src/api/doctor/doctor.ctrl.js
server/src/lib/DataProcess.js
server/src/models/bottleMedicine.js
server/src/util/Batch.js
server/yarn.lock
server/package.json
View file @
1e0e434
...
...
@@ -20,7 +20,8 @@
"@koa/cors"
:
"^3.1.0"
,
"firebase-admin"
:
"^9.11.1"
,
"moment"
:
"^2.29.1"
,
"mqtt"
:
"^4.2.6"
"mqtt"
:
"^4.2.6"
,
"node-cron"
:
"^3.0.0"
},
"devDependencies"
:
{
"eslint"
:
"^7.32.0"
...
...
server/src/api/bottle/bottle.ctrl.js
View file @
1e0e434
...
...
@@ -143,14 +143,11 @@ exports.getBottleInfo = async(ctx) => {
const
message
=
'req'
;
await
Mqtt
.
mqttPublishMessage
(
client
,
{
topic
,
message
});
const
bottleMedicine
=
await
BottleMedicine
.
find
({
bottleId
})
.
sort
({
regDtm
:
'desc'
})
.
limit
(
1
);
const
bottleMedicine
=
await
BottleMedicine
.
findOne
({
bottleId
,
useYn
:
'Y'
});
if
(
bottleMedicine
.
length
)
{
if
(
bottleMedicine
)
{
const
takeMedicineHist
=
await
TakeMedicineHist
.
find
({
bmId
:
bottleMedicine
[
0
]
.
_id
})
.
find
({
bmId
:
bottleMedicine
.
_id
})
.
sort
({
takeDate
:
'desc'
})
.
populate
(
'bmId'
);
...
...
@@ -208,12 +205,10 @@ exports.getBottleFeedback = async ctx => {
return
;
}
const
bottleMedicine
=
await
BottleMedicine
.
find
({
bottleId
})
.
sort
({
regDtm
:
'desc'
})
.
limit
(
1
);
const
bottleMedicine
=
await
BottleMedicine
.
findOne
({
bottleId
,
useYn
:
'Y'
});
if
(
bottleMedicine
.
length
)
{
const
feedbackList
=
await
Feedback
.
find
({
bmId
:
bottleMedicine
[
0
]
.
_id
})
if
(
bottleMedicine
)
{
const
feedbackList
=
await
Feedback
.
find
({
bmId
:
bottleMedicine
.
_id
})
.
sort
({
fdbDtm
:
'desc'
})
.
populate
(
'bmId'
);
...
...
@@ -294,6 +289,7 @@ exports.setMedicine = async(ctx) => {
bottleMedicine
.
setDoctorId
(
doctorId
);
}
await
BottleMedicine
.
updateMany
({
bottleId
},
{
useYn
:
'N '
});
bottleMedicine
.
save
();
...
...
server/src/api/doctor/doctor.ctrl.js
View file @
1e0e434
...
...
@@ -145,11 +145,12 @@ exports.getPatientDetail = async ctx => {
const
reqUserBmList
=
[];
await
Promise
.
all
(
reqUserBottleList
.
map
(
async
bottle
=>
{
const
bm
List
=
await
BottleMedicine
.
find
({
const
bm
=
await
BottleMedicine
.
findOne
({
doctorId
:
userId
,
bottleId
:
bottle
.
bottleId
,
}).
sort
({
regDtm
:
'desc'
}).
limit
(
1
);
reqUserBmList
.
push
(...
bmList
);
useYn
:
'Y'
,
});
reqUserBmList
.
push
(
bm
);
}));
const
bottleList
=
await
Promise
.
all
(
reqUserBmList
.
map
(
async
bottleMedicine
=>
{
...
...
@@ -207,7 +208,7 @@ exports.getBottleDetail = async ctx => {
return
;
}
const
bottleMedicine
=
await
BottleMedicine
.
findOne
({
bottleId
,
doctorId
:
userId
});
const
bottleMedicine
=
await
BottleMedicine
.
findOne
({
bottleId
,
doctorId
:
userId
,
useYn
:
'Y'
});
if
(
!
bottleMedicine
)
{
ctx
.
status
=
403
;
ctx
.
body
=
{
...
...
@@ -318,11 +319,9 @@ exports.writeReqBottleFeedback = async ctx => {
return
;
}
const
bottleMedicine
=
await
BottleMedicine
.
find
({
bottleId
,
doctorId
:
userId
})
.
sort
({
regDtm
:
'desc'
})
.
limit
(
1
);
const
bottleMedicine
=
await
BottleMedicine
.
findOne
({
bottleId
,
doctorId
:
userId
,
useYn
:
'Y'
});
if
(
!
bottleMedicine
.
length
)
{
if
(
!
bottleMedicine
)
{
ctx
.
status
=
403
;
ctx
.
body
=
{
error
:
'약병에 대한 권한 없음'
...
...
@@ -332,7 +331,7 @@ exports.writeReqBottleFeedback = async ctx => {
const
newFeedback
=
new
Feedback
({
fdbType
,
bmId
:
bottleMedicine
[
0
]
.
_id
,
bmId
:
bottleMedicine
.
_id
,
doctorId
:
userId
,
feedback
,
});
...
...
server/src/lib/DataProcess.js
View file @
1e0e434
...
...
@@ -63,7 +63,7 @@ const bottleInfoUpdate = async(data) => {
humidity
=
parseFloat
(
humidity
);
balance
=
parseInt
(
balance
);
const
bottleMedicine
=
await
BottleMedicine
.
find
({
bottleId
}).
sort
((
a
,
b
)
=>
a
.
regDtm
<
b
.
regDtm
)[
0
]
;
const
bottleMedicine
=
await
BottleMedicine
.
find
One
({
bottleId
,
useYn
:
'Y'
})
;
if
(
bottleMedicine
)
{
if
(
isOpen
)
{
...
...
@@ -83,7 +83,7 @@ const bottleInfoUpdate = async(data) => {
const
transPublishingTopicAndMessage
=
async
(
bottleId
)
=>
{
const
topic
=
'bottle/'
+
bottleId
+
'/stb'
;
const
bottleMedicine
=
await
BottleMedicine
.
find
({
bottleId
}).
sort
((
a
,
b
)
=>
a
.
regDtm
<
b
.
regDtm
)[
0
]
;
const
bottleMedicine
=
await
BottleMedicine
.
find
One
({
bottleId
,
useYn
:
'Y'
})
;
const
takeMedicineHist
=
await
TakeMedicineHist
.
find
({
bmId
:
bottleMedicine
.
_id
}).
sort
((
a
,
b
)
=>
a
.
takeDate
<
b
.
takeDate
)[
0
];
...
...
server/src/models/bottleMedicine.js
View file @
1e0e434
...
...
@@ -28,11 +28,20 @@ const BottleMedicineSchema = new Schema({
required
:
true
,
default
:
Date
.
now
,
},
useYn
:
{
type
:
String
,
required
:
true
,
default
:
'Y'
,
},
});
BottleMedicineSchema
.
methods
.
setDoctorId
=
function
(
doctorId
)
{
this
.
doctorId
=
doctorId
;
};
BottleMedicineSchema
.
methods
.
setUseYn
=
function
(
useYn
)
{
this
.
useYn
=
useYn
;
};
module
.
exports
=
mongoose
.
model
(
'BottleMedicine'
,
BottleMedicineSchema
);
\ No newline at end of file
...
...
server/src/util/Batch.js
0 → 100644
View file @
1e0e434
//toDO : Batch System
/**
* 21/09/14
* Author : 박권수
* 배치 시스템
* 1) 매년 지나면 프로필의 Age를 +1
* 2) Dosage에 따라, Push Notification 발송
*/
const
cron
=
require
(
'node-cron'
);
const
Profile
=
require
(
'../models/profile'
);
const
BottleMedicine
=
require
(
'../models/bottleMedicine'
);
\ No newline at end of file
server/yarn.lock
View file @
1e0e434
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment