修改填写打卡记录功能

This commit is contained in:
huangdeliang 2020-12-02 14:19:16 +08:00
parent 270da3950c
commit 7053e69a33
5 changed files with 201 additions and 130 deletions

View File

@ -83,7 +83,7 @@ spring:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://localhost:3306/stdiet_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
password: Ttj4fTtj4fAHUAHU password: Ttj4fAHU
username: root username: root
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭

View File

@ -1,5 +1,6 @@
package com.stdiet.web.controller.custom; package com.stdiet.web.controller.custom;
import com.itextpdf.io.util.DateTimeUtil;
import com.stdiet.common.annotation.Log; import com.stdiet.common.annotation.Log;
import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.domain.AjaxResult;
@ -7,7 +8,6 @@ import com.stdiet.common.core.page.TableDataInfo;
import com.stdiet.common.enums.BusinessType; import com.stdiet.common.enums.BusinessType;
import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.poi.ExcelUtil; import com.stdiet.common.utils.poi.ExcelUtil;
import com.stdiet.custom.domain.SysOrder;
import com.stdiet.custom.domain.SysWxUserInfo; import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.domain.SysWxUserLog; import com.stdiet.custom.domain.SysWxUserLog;
import com.stdiet.custom.page.WxLogInfo; import com.stdiet.custom.page.WxLogInfo;
@ -107,7 +107,7 @@ public class SysWxUserLogController extends BaseController {
} }
@GetMapping(value = "/wx/logs/list") @GetMapping(value = "/wx/logs/list")
public AjaxResult getLogs(SysWxUserLog sysWxUserLog ) { public AjaxResult getLogs(SysWxUserLog sysWxUserLog) {
List<WxLogInfo> list = sysWxUserLogService.selectWxLogInfoList(sysWxUserLog); List<WxLogInfo> list = sysWxUserLogService.selectWxLogInfoList(sysWxUserLog);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
@ -116,12 +116,13 @@ public class SysWxUserLogController extends BaseController {
public AjaxResult addLog(@RequestBody SysWxUserLog sysWxUserLog) { public AjaxResult addLog(@RequestBody SysWxUserLog sysWxUserLog) {
// 查询微信用户 // 查询微信用户
SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserLog.getOpenid()); SysWxUserInfo userInfo = sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserLog.getOpenid());
if(StringUtils.isNull(userInfo)) { if (StringUtils.isNull(userInfo)) {
return AjaxResult.error(5003, "没有用户信息"); return AjaxResult.error(5003, "没有用户信息");
} }
// 提取有用值 // 提取有用值
sysWxUserLog.setAvatarUrl(userInfo.getAvatarUrl()); sysWxUserLog.setAvatarUrl(userInfo.getAvatarUrl());
sysWxUserLog.setPhone(userInfo.getPhone()); sysWxUserLog.setPhone(userInfo.getPhone());
sysWxUserLog.setLogTime(DateTimeUtil.getCurrentTimeDate());
return add(sysWxUserLog); return add(sysWxUserLog);
} }
} }

View File

@ -65,6 +65,17 @@ public class SysWxUserLog extends BaseEntity
@Excel(name = "饮水量") @Excel(name = "饮水量")
private Long water; private Long water;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date logTime;
public void setLogTime(Date logTime) {
this.logTime = logTime;
}
public Date getLogTime() {
return logTime;
}
public void setOpenid(String openid) public void setOpenid(String openid)
{ {
this.openid = openid; this.openid = openid;
@ -194,6 +205,7 @@ public class SysWxUserLog extends BaseEntity
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("remark", getRemark()) .append("remark", getRemark())
.append("logTime", getLogTime())
.toString(); .toString();
} }
} }

View File

@ -9,8 +9,10 @@
<result property="weight" column="weight" /> <result property="weight" column="weight" />
<result property="appid" column="appid" /> <result property="appid" column="appid" />
<result property="phone" column="phone" /> <result property="phone" column="phone" />
<result property="sleepTime" column="sleep_time" /> <result property="phone" column="phone" />
<result property="logTime" column="log_time" />
<result property="wakeupTime" column="wakeup_time" /> <result property="wakeupTime" column="wakeup_time" />
<result property="sleepTime" column="sleep_time" />
<result property="sport" column="sport" /> <result property="sport" column="sport" />
<result property="avatarUrl" column="avatar_url" /> <result property="avatarUrl" column="avatar_url" />
<result property="diet" column="diet" /> <result property="diet" column="diet" />
@ -33,11 +35,11 @@
<result property="insomnia" column="insomnia" /> <result property="insomnia" column="insomnia" />
<result property="defecation" column="defecation" /> <result property="defecation" column="defecation" />
<result property="water" column="water" /> <result property="water" column="water" />
<result property="date" column="create_time" /> <result property="date" column="log_time" />
</resultMap> </resultMap>
<sql id="selectSysWxUserLogVo"> <sql id="selectSysWxUserLogVo">
select openid, weight, appid, phone, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark from sys_wx_user_log select openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark from sys_wx_user_log
</sql> </sql>
<select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult"> <select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
@ -70,6 +72,7 @@
<if test="weight != null">weight,</if> <if test="weight != null">weight,</if>
<if test="appid != null">appid,</if> <if test="appid != null">appid,</if>
<if test="phone != null">phone,</if> <if test="phone != null">phone,</if>
<if test="logTime != null">log_time,</if>
<if test="sleepTime != null">sleep_time,</if> <if test="sleepTime != null">sleep_time,</if>
<if test="wakeupTime != null">wakeup_time,</if> <if test="wakeupTime != null">wakeup_time,</if>
<if test="sport != null">sport,</if> <if test="sport != null">sport,</if>
@ -89,6 +92,7 @@
<if test="weight != null">#{weight},</if> <if test="weight != null">#{weight},</if>
<if test="appid != null">#{appid},</if> <if test="appid != null">#{appid},</if>
<if test="phone != null">#{phone},</if> <if test="phone != null">#{phone},</if>
<if test="logTime != null">#{logTime},</if>
<if test="sleepTime != null">#{sleepTime},</if> <if test="sleepTime != null">#{sleepTime},</if>
<if test="wakeupTime != null">#{wakeupTime},</if> <if test="wakeupTime != null">#{wakeupTime},</if>
<if test="sport != null">#{sport},</if> <if test="sport != null">#{sport},</if>
@ -111,6 +115,7 @@
<if test="weight != null">weight = #{weight},</if> <if test="weight != null">weight = #{weight},</if>
<if test="appid != null">appid = #{appid},</if> <if test="appid != null">appid = #{appid},</if>
<if test="phone != null">phone = #{phone},</if> <if test="phone != null">phone = #{phone},</if>
<if test="logTime != null">log_time = #{logTime},</if>
<if test="sleepTime != null">sleep_time = #{sleepTime},</if> <if test="sleepTime != null">sleep_time = #{sleepTime},</if>
<if test="wakeupTime != null">wakeup_time = #{wakeupTime},</if> <if test="wakeupTime != null">wakeup_time = #{wakeupTime},</if>
<if test="sport != null">sport = #{sport},</if> <if test="sport != null">sport = #{sport},</if>

View File

@ -37,38 +37,38 @@
>新增 >新增
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <!-- <el-col :span="1.5">-->
<el-button <!-- <el-button-->
type="success" <!-- type="success"-->
icon="el-icon-edit" <!-- icon="el-icon-edit"-->
size="mini" <!-- size="mini"-->
:disabled="single" <!-- :disabled="single"-->
@click="handleUpdate" <!-- @click="handleUpdate"-->
v-hasPermi="['custom:wxUserLog:edit']" <!-- v-hasPermi="['custom:wxUserLog:edit']"-->
>修改 <!-- >修改-->
</el-button> <!-- </el-button>-->
</el-col> <!-- </el-col>-->
<el-col :span="1.5"> <!-- <el-col :span="1.5">-->
<el-button <!-- <el-button-->
type="danger" <!-- type="danger"-->
icon="el-icon-delete" <!-- icon="el-icon-delete"-->
size="mini" <!-- size="mini"-->
:disabled="multiple" <!-- :disabled="multiple"-->
@click="handleDelete" <!-- @click="handleDelete"-->
v-hasPermi="['custom:wxUserLog:remove']" <!-- v-hasPermi="['custom:wxUserLog:remove']"-->
>删除 <!-- >删除-->
</el-button> <!-- </el-button>-->
</el-col> <!-- </el-col>-->
<el-col :span="1.5"> <!-- <el-col :span="1.5">-->
<el-button <!-- <el-button-->
type="warning" <!-- type="warning"-->
icon="el-icon-download" <!-- icon="el-icon-download"-->
size="mini" <!-- size="mini"-->
@click="handleExport" <!-- @click="handleExport"-->
v-hasPermi="['custom:wxUserLog:export']" <!-- v-hasPermi="['custom:wxUserLog:export']"-->
>导出 <!-- >导出-->
</el-button> <!-- </el-button>-->
</el-col> <!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -87,10 +87,15 @@
</el-table-column> </el-table-column>
<el-table-column label="微信应用" align="center" prop="appid" :formatter="appidFormat"/> <el-table-column label="微信应用" align="center" prop="appid" :formatter="appidFormat"/>
<el-table-column label="手机号" align="center" prop="phone"/> <el-table-column label="手机号" align="center" prop="phone"/>
<el-table-column label="打卡日期" align="center" prop="logTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.logTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="睡觉时间" align="center" prop="sleepTime" width="180"> <el-table-column label="睡觉时间" align="center" prop="sleepTime" width="180">
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- <span>{{ parseTime(scope.row.sleepTime, '{y}-{m}-{d}') }}</span>--> <!-- <span>{{ parseTime(scope.row.sleepTime, '{y}-{m}-{d}') }}</span>-->
<!-- </template>--> <!-- </template>-->
</el-table-column> </el-table-column>
<el-table-column label="起床时间" align="center" prop="wakeupTime" width="180"> <el-table-column label="起床时间" align="center" prop="wakeupTime" width="180">
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
@ -138,90 +143,128 @@
/> />
<!-- 添加或修改微信用户记录对话框 --> <!-- 添加或修改微信用户记录对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-row :gutter="15">
<el-form-item label="体重" prop="weight"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-input v-model="form.weight" placeholder="请输入体重"/> <el-col :span="12">
</el-form-item> <el-form-item label="体重" prop="weight">
<el-form-item label="微信appid" prop="appid"> <el-input v-model="form.weight" placeholder="请输入体重"/>
<el-select v-model="form.appid" placeholder="请选择微信appid"> </el-form-item>
<el-option </el-col>
v-for="dict in appidOptions" <el-col :span="12">
:key="dict.dictValue" <el-form-item label="电话" prop="phone">
:label="dict.dictLabel" <el-input v-model="form.phone" placeholder="请输入电话"/>
:value="dict.dictValue" </el-form-item>
></el-option> </el-col>
</el-select> <el-col :span="12">
</el-form-item> <el-form-item label="打卡日期" prop="logTime">
<el-form-item label="电话" prop="phone"> <el-date-picker clearable size="small" style="width: 200px"
<el-input v-model="form.phone" placeholder="请输入电话"/> v-model="form.logTime"
</el-form-item> type="date"
<el-form-item label="睡觉时间" prop="sleepTime"> value-format="yyyy-MM-dd"
<el-date-picker clearable size="small" style="width: 200px" :picker-options="logTimePickerOptions"
v-model="form.sleepTime" placeholder="选择睡觉时间">
type="date" </el-date-picker>
value-format="yyyy-MM-dd" </el-form-item>
placeholder="选择睡觉时间"> </el-col>
</el-date-picker> <el-col :span="12">
</el-form-item> <el-form-item label="睡觉时间" prop="sleepTime">
<el-form-item label="起床时间" prop="wakeupTime"> <el-time-select clearable size="small" style="width: 200px"
<el-date-picker clearable size="small" style="width: 200px" v-model="form.sleepTime"
v-model="form.wakeupTime" :picker-options="{
type="date" start: '00:00',
value-format="yyyy-MM-dd" step: '00:15',
placeholder="选择起床时间"> end: '23:45'
</el-date-picker> }"
</el-form-item> placeholder="选择睡觉时间">
<el-form-item label="运动情况" prop="sport"> </el-time-select>
<el-select v-model="form.sport" placeholder="请选择运动情况"> </el-form-item>
<el-option </el-col>
v-for="dict in sportOptions" <el-col :span="12">
:key="dict.dictValue" <el-form-item label="起床时间" prop="wakeupTime">
:label="dict.dictLabel" <el-time-select clearable size="small" style="width: 200px"
:value="parseInt(dict.dictValue)" v-model="form.wakeupTime"
></el-option> :picker-options="{
</el-select> start: '00:00',
</el-form-item> step: '00:15',
<el-form-item label="用户头像" prop="avatarUrl"> end: '23:45'
<el-input v-model="form.avatarUrl" placeholder="请输入用户头像"/> }"
</el-form-item> placeholder="选择睡觉时间">
<el-form-item label="饮食情况" prop="diet"> </el-time-select>
<el-select v-model="form.diet" placeholder="请选择饮食情况"> </el-form-item>
<el-option </el-col>
v-for="dict in dietOptions" <el-col :span="12">
:key="dict.dictValue" <el-form-item label="运动锻炼" prop="sport">
:label="dict.dictLabel" <el-select v-model="form.sport" placeholder="请选择运动情况">
:value="parseInt(dict.dictValue)" <el-option
></el-option> v-for="dict in sportOptions"
</el-select> :key="dict.dictValue"
</el-form-item> :label="dict.dictLabel"
<el-form-item label="熬夜失眠" prop="insomnia"> :value="dict.dictValue"
<el-select v-model="form.insomnia" placeholder="请选择熬夜失眠"> ></el-option>
<el-option </el-select>
v-for="dict in insomniaOptions" </el-form-item>
:key="dict.dictValue" </el-col>
:label="dict.dictLabel" <el-col :span="12">
:value="dict.dictValue" <el-form-item label="按食谱" prop="diet">
></el-option> <el-select v-model="form.diet" placeholder="请选择饮食情况">
</el-select> <el-option
</el-form-item> v-for="dict in dietOptions"
<el-form-item label="排便情况" prop="defecation"> :key="dict.dictValue"
<el-select v-model="form.defecation" placeholder="请选择排便情况"> :label="dict.dictLabel"
<el-option :value="dict.dictValue"
v-for="dict in defecationOptions" ></el-option>
:key="dict.dictValue" </el-select>
:label="dict.dictLabel" </el-form-item>
:value="parseInt(dict.dictValue)" </el-col>
></el-option> <el-col :span="12">
</el-select> <el-form-item label="熬夜失眠" prop="insomnia">
</el-form-item> <el-select v-model="form.insomnia" placeholder="请选择熬夜失眠">
<el-form-item label="饮水量" prop="water"> <el-option
<el-input v-model="form.water" placeholder="请输入饮水量"/> v-for="dict in insomniaOptions"
</el-form-item> :key="dict.dictValue"
<el-form-item label="备注" prop="remark"> :label="dict.dictLabel"
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/> :value="dict.dictValue"
</el-form-item> ></el-option>
</el-form> </el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="起床排便" prop="defecation">
<el-select v-model="form.defecation" placeholder="请选择排便情况">
<el-option
v-for="dict in defecationOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="饮水量" prop="water">
<el-input v-model="form.water" placeholder="请输入饮水量"/>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="微信应用" prop="appid">
<el-select v-model="form.appid" placeholder="请选择微信appid">
<el-option
v-for="dict in appidOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
@ -282,7 +325,12 @@
// //
form: {}, form: {},
// //
rules: {} rules: {},
logTimePickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
}; };
}, },
created() { created() {
@ -340,10 +388,13 @@
}, },
// //
reset() { reset() {
const defaultAppidType = this.appidOptions.find(opt => opt.remark === 'default');
this.form = { this.form = {
id: null,
openid: null, openid: null,
weight: null, weight: null,
appid: null, appid: defaultAppidType ? defaultAppidType.dictValue : null,
phone: null, phone: null,
sleepTime: null, sleepTime: null,
wakeupTime: null, wakeupTime: null,
@ -357,7 +408,8 @@
createTime: null, createTime: null,
updateBy: null, updateBy: null,
updateTime: null, updateTime: null,
remark: null remark: null,
logTime: null
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@ -397,7 +449,8 @@
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.openid != null) { console.log(this.form)
if (this.form.id != null) {
updateWxUserLog(this.form).then(response => { updateWxUserLog(this.form).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.msgSuccess("修改成功"); this.msgSuccess("修改成功");