打卡优化,加上编辑

This commit is contained in:
xiezhijun 2021-04-22 18:35:25 +08:00
parent ac2e282b48
commit cb1300c593
9 changed files with 127 additions and 60 deletions

View File

@ -149,7 +149,10 @@ public class SysWxUserLogController extends BaseController {
@GetMapping(value = "/wx/logs/check/{openid}")
public AjaxResult checkLog(@PathVariable String openid) {
int count = sysWxUserLogService.checkWxLogInfoCount(openid);
SysWxUserLog sysWxUserLog = new SysWxUserLog();
sysWxUserLog.setLogTime(new Date());
sysWxUserLog.setOpenid(openid);
int count = sysWxUserLogService.checkWxLogInfoCount(sysWxUserLog);
return AjaxResult.success(count);
}

View File

@ -132,32 +132,8 @@ public class WechatAppletController extends BaseController {
}
}
/*for (WxLogInfo wxLogInfo : list) {
Map<String, List<String>> imageUrlMap = new HashMap<>();
List<String> breakfastImagesUrlList = StringUtils.isNotEmpty(wxLogInfo.getBreakfastImages()) ? Arrays.asList(wxLogInfo.getBreakfastImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("breakfastImages", breakfastImagesUrlList);
List<String> lunchImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getLunchImages()) ? Arrays.asList(sysWxUserLog.getLunchImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("lunchImages", lunchImagesUrlList);
List<String> dinnerImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getDinnerImages()) ? Arrays.asList(sysWxUserLog.getDinnerImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("dinnerImages", dinnerImagesUrlList);
List<String> extraMealImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getExtraMealImages()) ? Arrays.asList(sysWxUserLog.getExtraMealImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("extraMealImages", extraMealImagesUrlList);
List<String> bodyImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getBodyImages()) ? Arrays.asList(sysWxUserLog.getBodyImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("bodyImages", bodyImagesUrlList );
//生成预览链接
Map<String,List<String>> downUrlList = AliyunOSSUtils.generatePresignedUrl(imageUrlMap);
wxLogInfo.setBreakfastImagesUrl(downUrlList.get("breakfastImages"));
wxLogInfo.setLunchImagesUrl(downUrlList.get("lunchImages"));
wxLogInfo.setDinnerImagesUrl(downUrlList.get("dinnerImages"));
wxLogInfo.setExtraMealImagesUrl(downUrlList.get("extraMealImages"));
wxLogInfo.setBodyImagesUrl(downUrlList.get("bodyImages"));
/*for (WxLogInfo log : list) {
log.setId(AesUtils.encrypt(log.getId()+"", null));
}*/
Collections.reverse(list);
@ -177,7 +153,10 @@ public class WechatAppletController extends BaseController {
*/
@GetMapping(value = "/checkNowPunchLog/{openid}")
public AjaxResult checkNowPunchLog(@PathVariable String openid) {
int count = StringUtils.isEmpty(openid) ? 0 : sysWxUserLogService.checkWxLogInfoCount(openid);
SysWxUserLog sysWxUserLog = new SysWxUserLog();
sysWxUserLog.setOpenid(openid);
sysWxUserLog.setLogTime(new Date());
int count = StringUtils.isEmpty(openid) ? 0 : sysWxUserLogService.checkWxLogInfoCount(sysWxUserLog);
return AjaxResult.success(count);
}
@ -191,17 +170,26 @@ public class WechatAppletController extends BaseController {
// 查询微信用户
SysWxUserInfo userInfo = StringUtils.isEmpty(sysWxUserLog.getOpenid()) ? null : sysWxUserInfoService.selectSysWxUserInfoById(sysWxUserLog.getOpenid());
if (userInfo == null || StringUtils.isEmpty(userInfo.getPhone())) {
return AjaxResult.error("不存在客户");
return AjaxResult.error("打卡失败");
}
if(sysWxUserLog.getId() == null){
//查询今日是否已打卡
int count = sysWxUserLogService.checkWxLogInfoCount(sysWxUserLog.getOpenid());
if(sysWxUserLog.getLogTime() == null){
sysWxUserLog.setLogTime(new Date());
}
int count = sysWxUserLogService.checkWxLogInfoCount(sysWxUserLog);
if(count > 0){
return AjaxResult.error("今日已打卡,不可重复打卡");
}
sysWxUserLog.setLogTime(DateTimeUtil.getCurrentTimeDate());
return toAjax(sysWxUserLogService.insertSysWxUserLog(sysWxUserLog));
}else{
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
}
}
public static final String[] imageName = {"breakfastImages", "lunchImages", "dinnerImages", "extraMealImages", "bodyImages"};
/**
* 获取微信用户记录详细信息
*/
@ -217,28 +205,40 @@ public class WechatAppletController extends BaseController {
}
Map<String, List<String>> imageUrlMap = new HashMap<>();
List<String> breakfastImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getBreakfastImages()) ? Arrays.asList(sysWxUserLog.getBreakfastImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("breakfastImages", breakfastImagesUrlList);
imageUrlMap.put(imageName[0], breakfastImagesUrlList);
List<String> lunchImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getLunchImages()) ? Arrays.asList(sysWxUserLog.getLunchImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("lunchImages", lunchImagesUrlList);
imageUrlMap.put(imageName[1], lunchImagesUrlList);
List<String> dinnerImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getDinnerImages()) ? Arrays.asList(sysWxUserLog.getDinnerImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("dinnerImages", dinnerImagesUrlList);
imageUrlMap.put(imageName[2], dinnerImagesUrlList);
List<String> extraMealImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getExtraMealImages()) ? Arrays.asList(sysWxUserLog.getExtraMealImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("extraMealImages", extraMealImagesUrlList);
imageUrlMap.put(imageName[3], extraMealImagesUrlList);
List<String> bodyImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getBodyImages()) ? Arrays.asList(sysWxUserLog.getBodyImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("bodyImages", bodyImagesUrlList );
imageUrlMap.put(imageName[4], bodyImagesUrlList );
//生成预览链接
Map<String,List<String>> downUrlList = AliyunOSSUtils.generatePresignedUrl(imageUrlMap);
sysWxUserLog.setBreakfastImagesUrl(downUrlList.get("breakfastImages"));
sysWxUserLog.setLunchImagesUrl(downUrlList.get("lunchImages"));
sysWxUserLog.setDinnerImagesUrl(downUrlList.get("dinnerImages"));
sysWxUserLog.setExtraMealImagesUrl(downUrlList.get("extraMealImages"));
sysWxUserLog.setBodyImagesUrl(downUrlList.get("bodyImages"));
sysWxUserLog.setBreakfastImagesUrl(downUrlList.get(imageName[0]));
sysWxUserLog.setLunchImagesUrl(downUrlList.get(imageName[1]));
sysWxUserLog.setDinnerImagesUrl(downUrlList.get(imageName[2]));
sysWxUserLog.setExtraMealImagesUrl(downUrlList.get(imageName[3]));
sysWxUserLog.setBodyImagesUrl(downUrlList.get(imageName[4]));
List<String> allImagesList = new ArrayList<>();
List<String> allUrlList = new ArrayList<>();
for (String key : imageName) {
if(!"bodyImages".equals(key)){
allUrlList.addAll(downUrlList.get(key));
allImagesList.addAll(imageUrlMap.get(key));
}
}
sysWxUserLog.setAllImagesUrl(allUrlList);
sysWxUserLog.setAllImages(StringUtils.join(allImagesList, "|"));
return AjaxResult.success(sysWxUserLog);
}

View File

@ -106,6 +106,10 @@ public class SysWxUserLog extends BaseEntity
@Excel(name = "是否便秘", readConverterExp = "Y=是,N=否")
private String constipation;
/** 食材描述 */
@Excel(name = "食材描述")
private String ingredientDescribe;
/** 早餐照片 */
@Excel(name = "早餐照片")
private String breakfastImages;

View File

@ -63,7 +63,7 @@ public interface SysWxUserLogMapper
*/
public int deleteSysWxUserLogByIds(String[] ids);
public int checkWxLogInfoCount(String openid);
public int checkWxLogInfoCount(SysWxUserLog sysWxUserLog);
/**
* 根据openid和手机号查询打卡记录

View File

@ -5,6 +5,7 @@ import com.stdiet.common.utils.DateUtils;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -42,6 +43,12 @@ public class WxLogInfo implements Serializable {
/** 是否便秘Y是 N否 */
private String constipation;
/** 食材描述 */
private String ingredientDescribe;
//全部食材照片
private String allImages;
/** 早餐照片 */
private String breakfastImages;
@ -69,6 +76,8 @@ public class WxLogInfo implements Serializable {
/** 点评 */
private String comment;
private List<String> allImagesUrl;
private List<String> breakfastImagesUrl;
private List<String> lunchImagesUrl;
@ -303,6 +312,30 @@ public class WxLogInfo implements Serializable {
this.id = id;
}
public String getIngredientDescribe() {
return ingredientDescribe;
}
public void setIngredientDescribe(String ingredientDescribe) {
this.ingredientDescribe = ingredientDescribe;
}
public List<String> getAllImagesUrl() {
return this.allImagesUrl;
}
public void setAllImagesUrl(List<String> allImagesUrl) {
this.allImagesUrl = allImagesUrl;
}
public String getAllImages() {
return this.allImages;
}
public void setAllImages(String allImages) {
this.allImages = allImages;
}
@Override
public String toString() {
return "WxLogInfo{" +

View File

@ -65,7 +65,7 @@ public interface ISysWxUserLogService
*/
public int deleteSysWxUserLogById(Long id);
public int checkWxLogInfoCount(String openid);
public int checkWxLogInfoCount(SysWxUserLog sysWxUserLog);
/**
* 根据openid和手机号查询打卡记录

View File

@ -102,8 +102,8 @@ public class SysWxUserLogServiceImpl implements ISysWxUserLogService {
}
@Override
public int checkWxLogInfoCount(String openid) {
return sysWxUserLogMapper.checkWxLogInfoCount(openid);
public int checkWxLogInfoCount(SysWxUserLog sysWxUserLog) {
return sysWxUserLogMapper.checkWxLogInfoCount(sysWxUserLog);
}
/**

View File

@ -28,6 +28,7 @@
<result property="emotion" column="emotion" />
<result property="slyEatFood" column="sly_eat_food" />
<result property="constipation" column="constipation" />
<result property="ingredientDescribe" column="ingredient_describe" />
<result property="breakfastImages" column="breakfast_images" />
<result property="lunchImages" column="lunch_images" />
<result property="dinnerImages" column="dinner_images" />
@ -60,6 +61,7 @@
<result property="slyEatFood" column="sly_eat_food" />
<result property="constipation" column="constipation" />
<result property="remark" column="remark"></result>
<result property="ingredientDescribe" column="ingredient_describe" />
<result property="breakfastImages" column="breakfast_images" />
<result property="lunchImages" column="lunch_images" />
<result property="dinnerImages" column="dinner_images" />
@ -73,18 +75,18 @@
<sql id="selectSysWxUserLogVo">
select id,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,
emotion,sly_eat_food,constipation,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images,suggest,execution_score,comment
emotion,sly_eat_food,constipation,ingredient_describe,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images,suggest,execution_score,comment
from sys_wx_user_log
</sql>
<select id="checkWxLogInfoCount" parameterType="String" resultType="Integer">
select count(*) from sys_wx_user_log where to_days(log_time) = to_days(now()) and openid = #{openid} and del_flag = 0
<select id="checkWxLogInfoCount" parameterType="SysWxUserLog" resultType="Integer">
select count(*) from sys_wx_user_log where to_days(log_time) = to_days(#{logTime}) and openid = #{openid} and del_flag = 0
</select>
<!-- 后台查询 -->
<select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
SELECT wxlog.id,wxinfo.appid,wxinfo.openid,wxinfo.avatar_url,wxinfo.phone,wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet,wxlog.remark,
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images,
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.ingredient_describe,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images,
wxlog.suggest,wxlog.execution_score,wxlog.comment,sc.name as customer_name, su.nick_name as nutritionist, su_atferSale.nick_name as after_nutritionist
FROM sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
@ -156,6 +158,7 @@
<if test="emotion != null">emotion,</if>
<if test="slyEatFood != null">sly_eat_food,</if>
<if test="constipation != null">constipation,</if>
<if test="ingredientDescribe != null">ingredient_describe,</if>
<if test="breakfastImages != null">breakfast_images,</if>
<if test="lunchImages != null">lunch_images,</if>
<if test="dinnerImages != null">dinner_images,</if>
@ -189,6 +192,7 @@
<if test="emotion != null">#{emotion},</if>
<if test="slyEatFood != null">#{slyEatFood},</if>
<if test="constipation != null">#{constipation},</if>
<if test="ingredientDescribe != null">#{ingredientDescribe},</if>
<if test="breakfastImages != null">#{breakfastImages},</if>
<if test="lunchImages != null">#{lunchImages},</if>
<if test="dinnerImages != null">#{dinnerImages},</if>
@ -226,6 +230,7 @@
<if test="emotion != null">emotion = #{emotion},</if>
<if test="slyEatFood != null">sly_eat_food = #{slyEatFood},</if>
<if test="constipation != null">constipation = #{constipation},</if>
<if test="ingredientDescribe != null">ingredient_describe = #{ingredientDescribe},</if>
<if test="breakfastImages != null">breakfast_images = #{breakfastImages},</if>
<if test="lunchImages != null">lunch_images = #{lunchImages},</if>
<if test="dinnerImages != null">dinner_images = #{dinnerImages},</if>
@ -254,7 +259,7 @@
<!-- 根据openid和手机号查询对应打卡记录 -->
<select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
SELECT wxlog.id,wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet,
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.ingredient_describe,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images
,wxlog.remark,wxlog.execution_score,wxlog.comment
FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxlog.del_flag = 0 and (wxinfo.openid = #{openid} or wxinfo.phone = #{phone})
@ -295,7 +300,7 @@
<!-- 根据openid和手机号查询对应打卡记录 -->
<select id="getWxLogInfoDetailById" parameterType="SysWxUserLog" resultMap="WxLogInfo">
SELECT wxlog.id,wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet,
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.ingredient_describe,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images
,wxlog.remark,wxlog.execution_score,wxlog.comment
FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxlog.del_flag = 0 and wxlog.id = #{id}

View File

@ -26,19 +26,41 @@
<h3>基础信息</h3>
<TableDetailMessage :data="punchLogDetail"></TableDetailMessage>
<h3>图片信息</h3>
<h3>食物以及对比照信息</h3>
<div style="height: 370px; overflow: auto">
<div v-if="punchLog != null && punchLog.imagesUrl.breakfastImages.length > 0">
<h4>早餐</h4>
<div v-if="punchLog != null && punchLog.ingredientDescribe != null && punchLog.ingredientDescribe != ''">
<h4>食物描述</h4>
<div>
{{punchLog.ingredientDescribe}}
</div>
</div>
<div v-if="punchLog != null && (punchLog.imagesUrl.breakfastImages.length > 0 || punchLog.imagesUrl.lunchImages.length > 0 || punchLog.imagesUrl.dinnerImages.length > 0
|| punchLog.imagesUrl.extraMealImages.length > 0)">
<h4>食物照片</h4>
<div>
<el-image v-for="(item, index) in punchLog.imagesUrl.breakfastImages" title="点击大图预览" :key="index"
style="width: 300px; height: 300px"
:src="item"
:preview-src-list="imageUrl">
</el-image>
<el-image v-for="(item, index) in punchLog.imagesUrl.lunchImages" title="点击大图预览" :key="index"
style="width: 300px; height: 300px"
:src="item"
:preview-src-list="imageUrl">
</el-image>
<el-image v-for="(item, index) in punchLog.imagesUrl.dinnerImages" title="点击大图预览" :key="index"
style="width: 300px; height: 300px"
:src="item"
:preview-src-list="imageUrl">
</el-image>
<el-image v-for="(item, index) in punchLog.imagesUrl.extraMealImages" title="点击大图预览" :key="index"
style="width: 300px; height: 300px"
:src="item"
:preview-src-list="imageUrl">
</el-image>
</div>
</div>
<div v-if="punchLog != null && punchLog.imagesUrl.lunchImages.length > 0">
<!--<div v-if="punchLog != null && punchLog.imagesUrl.lunchImages.length > 0">
<h4>午餐</h4>
<div>
<el-image v-for="(item, index) in punchLog.imagesUrl.lunchImages" title="点击大图预览" :key="index"
@ -67,7 +89,7 @@
:preview-src-list="imageUrl">
</el-image>
</div>
</div>
</div>-->
<div v-if="punchLog != null && punchLog.imagesUrl.bodyImages.length > 0">
<h4>体型对比照</h4>
<div>