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:26:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
081a5ada6a7c0f365aa70bd10033c98a14b69d59
081a5ada
1 parent
f21d36fd
feat. bottlemedicine : use Yn add
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
24 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/yarn.lock
server/package.json
View file @
081a5ad
...
...
@@ -19,7 +19,8 @@
"dependencies"
:
{
"@koa/cors"
:
"^3.1.0"
,
"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 @
081a5ad
...
...
@@ -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 @
081a5ad
...
...
@@ -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 @
081a5ad
...
...
@@ -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 @
081a5ad
...
...
@@ -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/yarn.lock
View file @
081a5ad
...
...
@@ -725,7 +725,14 @@ minimist@^1.1.0, minimist@^1.2.5:
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
moment@^2.29.1:
moment-timezone@^0.5.31:
version "0.5.33"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.33.tgz#b252fd6bb57f341c9b59a5ab61a8e51a73bbd22c"
integrity sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==
dependencies:
moment ">= 2.9.0"
"moment@>= 2.9.0", moment@^2.29.1:
version "2.29.1"
resolved "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
...
...
@@ -768,6 +775,13 @@ natural-compare@^1.4.0:
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
node-cron@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/node-cron/-/node-cron-3.0.0.tgz#b33252803e430f9cd8590cf85738efa1497a9522"
integrity sha512-DDwIvvuCwrNiaU7HEivFDULcaQualDv7KoNlB/UU1wPW0n1tDEmBJKhEIE6DlF2FuoOHcNbLJ8ITL2Iv/3AWmA==
dependencies:
moment-timezone "^0.5.31"
once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
...
...
Please
register
or
login
to post a comment