1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

体温上报 历史上报信息

This commit is contained in:
程序员小墨 2022-12-28 21:48:44 +08:00
parent 4594fe8e80
commit 494e578628
9 changed files with 341 additions and 57 deletions

View File

@ -13,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
@Controller
@RequestMapping("/access/report")
@ -26,9 +25,18 @@ public class ReportController {
@Autowired
private ReportServiceImpl reportService;
/**
* 体温上报
*
* @param id
* @param address
* @param timestamp
* @param temperature
* @return
*/
@PostMapping("/submit")
@ResponseBody
public Res getCodeInfo(@RequestParam("userId") Integer id,
public Res submit(@RequestParam("userId") Integer id,
@RequestParam("address") String address,
@RequestParam("timestamp") Long timestamp,
@RequestParam("temperature") Integer temperature) {
@ -53,4 +61,37 @@ public class ReportController {
return Res.success();
}
/**
* 获取用户填报信息
*
* @param userId
* @return
*/
@PostMapping("/getRecordList")
@ResponseBody
public Res getRecordList(@RequestParam("userId") Integer userId) {
User user = userService.getUserById(userId);
if (user == null) {
return Res.error("用户不存在");
}
List<Report> records = reportService.getRecordListByUserId(user.getId());
return Res.success(records);
}
/**
* 获取最近一次用户填报信息
*
* @param userId
* @return
*/
@PostMapping("/getLatestRecord")
@ResponseBody
public Res getLatestRecord(@RequestParam("userId") Integer userId) {
User user = userService.getUserById(userId);
if (user == null) {
return Res.error("用户不存在");
}
Report records = reportService.getLatestRecordByUserId(user.getId());
return Res.success(records);
}
}

View File

@ -4,8 +4,14 @@ import com.cxyxiaomo.epp.common.pojo.Report;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface ReportDao {
Integer insert(Report report);
List<Report> getReportListByUserId(Integer userId);
Report getLatestReportByUserId(Integer userId);
}

View File

@ -2,6 +2,13 @@ package com.cxyxiaomo.epp.access.service;
import com.cxyxiaomo.epp.common.pojo.Report;
import java.util.List;
public interface ReportService {
void addRecord(Report report);
List<Report> getRecordListByUserId(Integer userId);
Report getLatestRecordByUserId(Integer userId);
}

View File

@ -5,6 +5,8 @@ import com.cxyxiaomo.epp.common.pojo.Report;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ReportServiceImpl implements ReportService {
@ -15,4 +17,12 @@ public class ReportServiceImpl implements ReportService {
public void addRecord(Report report) {
reportDao.insert(report);
}
public List<Report> getRecordListByUserId(Integer userId) {
return reportDao.getReportListByUserId(userId);
}
public Report getLatestRecordByUserId(Integer userId) {
return reportDao.getLatestReportByUserId(userId);
}
}

View File

@ -7,4 +7,15 @@
INSERT INTO report (`user_id`, `name`, `address`, `time`, `temperature`)
VALUES (#{userId}, #{name}, #{address}, #{time}, #{temperature})
</insert>
<select id="getReportListByUserId" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.Report">
SELECT * FROM report
WHERE `user_id` = #{userId}
order by time desc
</select>
<select id="getLatestReportByUserId" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.Report">
SELECT * FROM report
WHERE `user_id` = #{userId}
order by time desc
LIMIT 1
</select>
</mapper>

View File

@ -8,6 +8,7 @@ export default defineAppConfig({
*/
'pages/residents/code', // 进出码
'pages/residents/report', // 体温上报
'pages/residents/reportHistory', // 体温上报-历史上报
/**
* 扫码跳转

View File

@ -41,8 +41,8 @@
</style>
<template>
<view class="form">
<view>
<view v-if="!isFilled" class="form">
<view class="row">
<view class="rowItem rowLeft center">
<text>姓名</text>
@ -97,6 +97,12 @@
<textarea v-if="this.debugMode" maxlength="-1" disabled="true" auto-height="true" style="width: 100%"
:value="JSON.stringify(formData, null, 8)"></textarea>
</view>
<view v-else style="text-align: center;">
<!-- -->
<view style="margin: 40px 0;">{{ filledMsg }}</view>
<button class="controlBtn" size="mini" type="none" @tap="myreport">历史填报</button>
</view>
</view>
</template>
<script>
@ -116,17 +122,69 @@ export default {
time: '',
timestamp: '',
temperature: 0,
}
},
//
isFilled: true,
filledMsg: "",
}
},
onShow() {
console.log('onShow')
this.userInfo = Taro.getStorageSync("userInfo")
console.log("this.userInfo", this.userInfo)
this.formData.userId = this.userInfo.id
this.formData.userRealname = this.userInfo.realname
this.updateTime();
this.timeInterval = setInterval(this.updateTime, 1000);
//
Taro.showLoading({ title: '加载中' })
var that = this;
Taro.request({
url: `${this.baseUrl}/access/report/getLatestRecord`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //post
},
data: {
userId: this.userInfo.id
},
success: function (d) {
Taro.hideLoading()
let result = d.data
console.log("result", result)
if (result.success) {
console.log("result.data", result.data);
if (result.data == null || new Date(result.data.time) < new Date(new Date().toISOString().substring(0, 10))) {
//
that.isFilled = false
} else {
//
that.isFilled = true
that.filledMsg = "您已完成今日体温填报"
}
} else {
Taro.showToast({
title: "加载填报信息失败",
icon: 'error',
duration: 2000
})
}
},
fail: function () {
Taro.hideLoading()
Taro.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
},
complete: function () {
Taro.hideNavigationBarLoading();
}
})
},
onHide() {
@ -173,9 +231,16 @@ export default {
})
Taro.hideLoading()
},
//
report() {
console.log("点击提交", "this.formData", this.formData)
if (!this.formData.address) {
Taro.showToast({
title: "请获取当前位置",
icon: 'error'
})
return;
}
Taro.showLoading({ title: '加载中' })
var that = this;
Taro.request({
@ -192,6 +257,9 @@ export default {
Taro.hideLoading()
let result = d.data;
if (result.success) {
//
that.isFilled = true
that.filledMsg = "您已完成今日体温填报"
console.log("result.data", result.data);
Taro.showToast({
title: "填报成功",
@ -226,6 +294,12 @@ export default {
that.debugMode && console.log("end complete")
}
})
},
//
myreport() {
Taro.navigateTo({
url: "/pages/residents/reportHistory"
})
}
}
}

View File

@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '体温上报 - 历史记录',
})

View File

@ -0,0 +1,131 @@
<template>
<view>
<view style="margin: 20px; text-align: center;">
<text>姓名{{ displayName }}</text>
</view>
<view class="container">
<view class="item" :class="item.temperature == 1 ? 'abnormal' : 'normal'" v-for="item of displayResult">
<view>
<view class="record_time">
<!-- 填报时间 -->
{{ item.time }}
</view>
<view class="record_address">
<!-- 地址 -->
{{ item.address }}
</view>
</view>
<view class="statusText">{{ item.temperature == 1 ? "异常" : "正常" }}</view>
</view>
</view>
</view>
</template>
<script>
import Taro from '@tarojs/taro'
import utils from '../../utils/utils'
export default {
data() {
return {
...Taro.getApp().globalData,
userInfo: null,
displayName: '',
displayResult: [],
}
},
onShow() {
console.log('onShow')
this.userInfo = Taro.getStorageSync("userInfo")
this.displayName = this.userInfo.realname
//
Taro.showLoading({ title: '加载中' })
var that = this;
Taro.request({
url: `${this.baseUrl}/access/report/getRecordList`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //post
},
data: {
userId: this.userInfo.id
},
success: function (d) {
Taro.hideLoading()
let result = d.data
console.log("result", result)
if (result.success) {
console.log("result.data", result.data)
that.displayResult = result.data.map(item => {
//
let t = new Date(item.time).getTime() + 8 * 3600 * 1000
item.time = new Date(t).toISOString().substring(0, 19).replace("T", " ")
return item
})
} else {
Taro.showToast({
title: "加载填报信息失败",
icon: 'error',
duration: 2000
})
}
},
fail: function () {
Taro.hideLoading()
Taro.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
},
complete: function () {
Taro.hideNavigationBarLoading();
}
})
},
onHide() {
console.log('onHide')
clearInterval(this.timeInterval)
},
methods: {
}
}
</script>
<style>
.item {
/* background-color: #dedede; */
border-radius: 8px;
margin: 20px 32px;
padding: 25px;
display: grid;
grid-template-columns: 1fr 130px;
place-items: center;
color: white;
}
.item.normal {
background-color: green;
}
.item.abnormal {
background-color: red;
}
.record_time {
font-size: 30px;
}
.record_address {
font-size: 25px;
}
.statusText {
font-size: large;
font-weight: bold;
}
</style>