!204 打卡优化

Merge pull request !204 from 德仔/xzj
This commit is contained in:
德仔 2021-04-15 12:01:47 +08:00 committed by Gitee
commit 5456e97d9a
21 changed files with 1382 additions and 50 deletions

View File

@ -2,11 +2,20 @@ package com.stdiet.web.controller;
import com.stdiet.common.config.AliyunOSSConfig; import com.stdiet.common.config.AliyunOSSConfig;
import com.stdiet.common.utils.oss.AliyunOSSUtils; import com.stdiet.common.utils.oss.AliyunOSSUtils;
import com.stdiet.custom.domain.SysNutritionQuestion;
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.mapper.SysCustomerPhysicalSignsMapper; import com.stdiet.custom.mapper.SysCustomerPhysicalSignsMapper;
import com.stdiet.custom.mapper.SysNutritionQuestionMapper;
import com.stdiet.custom.mapper.SysWxUserInfoMapper; import com.stdiet.custom.mapper.SysWxUserInfoMapper;
import com.stdiet.custom.mapper.SysWxUserLogMapper; import com.stdiet.custom.mapper.SysWxUserLogMapper;
import com.stdiet.custom.service.ISysNutritionQuestionService;
import com.stdiet.custom.service.ISysWxUserLogService;
import com.stdiet.custom.utils.LuceneIndexUtils;
import com.stdiet.framework.web.domain.server.Sys;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
@ -26,9 +35,22 @@ public class MyApplicationRunner implements ApplicationRunner {
@Autowired @Autowired
private SysWxUserInfoMapper sysWxUserInfoMapper; private SysWxUserInfoMapper sysWxUserInfoMapper;
@Autowired
private ISysNutritionQuestionService sysNutritionQuestionService;
@Autowired
private ISysWxUserLogService sysWxUserLogService;
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
System.out.println("项目启动调用方法"); System.out.println("项目启动调用方法");
/*SysNutritionQuestion sysNutritionQuestion = new SysNutritionQuestion();
sysNutritionQuestion.setTitle("如何防止猝死");
sysNutritionQuestion.setContent("少熬夜,少暴饮暴食");
sysNutritionQuestion.setKey("猝死");
sysNutritionQuestionService.insertSysNutritionQuestion(sysNutritionQuestion);*/
} }

View File

@ -0,0 +1,103 @@
package com.stdiet.custom.controller;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.stdiet.common.annotation.Log;
import com.stdiet.common.core.controller.BaseController;
import com.stdiet.common.core.domain.AjaxResult;
import com.stdiet.common.enums.BusinessType;
import com.stdiet.custom.domain.SysNutritionQuestion;
import com.stdiet.custom.service.ISysNutritionQuestionService;
import com.stdiet.common.utils.poi.ExcelUtil;
import com.stdiet.common.core.page.TableDataInfo;
/**
* 营养知识小问答Controller
*
* @author xzj
* @date 2021-04-13
*/
@RestController
@RequestMapping("/custom/nutritionQuestion")
public class SysNutritionQuestionController extends BaseController
{
@Autowired
private ISysNutritionQuestionService sysNutritionQuestionService;
/**
* 查询营养知识小问答列表
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionQuestion:list')")
@GetMapping("/list")
public TableDataInfo list(SysNutritionQuestion sysNutritionQuestion)
{
startPage();
List<SysNutritionQuestion> list = sysNutritionQuestionService.selectSysNutritionQuestionList(sysNutritionQuestion);
return getDataTable(list);
}
/**
* 导出营养知识小问答列表
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionQuestion:export')")
@Log(title = "营养知识小问答", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(SysNutritionQuestion sysNutritionQuestion)
{
List<SysNutritionQuestion> list = sysNutritionQuestionService.selectSysNutritionQuestionList(sysNutritionQuestion);
ExcelUtil<SysNutritionQuestion> util = new ExcelUtil<SysNutritionQuestion>(SysNutritionQuestion.class);
return util.exportExcel(list, "nutritionQuestion");
}
/**
* 获取营养知识小问答详细信息
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionQuestion:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysNutritionQuestionService.selectSysNutritionQuestionById(id));
}
/**
* 新增营养知识小问答
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionQuestion:add')")
@Log(title = "营养知识小问答", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysNutritionQuestion sysNutritionQuestion)
{
return toAjax(sysNutritionQuestionService.insertSysNutritionQuestion(sysNutritionQuestion));
}
/**
* 修改营养知识小问答
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionQuestion:edit')")
@Log(title = "营养知识小问答", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysNutritionQuestion sysNutritionQuestion)
{
return toAjax(sysNutritionQuestionService.updateSysNutritionQuestion(sysNutritionQuestion));
}
/**
* 删除营养知识小问答
*/
@PreAuthorize("@ss.hasPermi('custom:nutritionQuestion:remove')")
@Log(title = "营养知识小问答", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysNutritionQuestionService.deleteSysNutritionQuestionByIds(ids));
}
}

View File

@ -33,6 +33,7 @@ import java.util.*;
@RestController @RestController
@RequestMapping("/custom/wxUserLog") @RequestMapping("/custom/wxUserLog")
public class SysWxUserLogController extends BaseController { public class SysWxUserLogController extends BaseController {
@Autowired @Autowired
private ISysWxUserLogService sysWxUserLogService; private ISysWxUserLogService sysWxUserLogService;
@ -200,4 +201,13 @@ public class SysWxUserLogController extends BaseController {
List<SysWxUserLog> list = sysWxUserLogService.getWxUserLogListByCustomerId(sysWxUserLog); List<SysWxUserLog> list = sysWxUserLogService.getWxUserLogListByCustomerId(sysWxUserLog);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 点评客户打卡内容
*/
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:query')")
@PostMapping("/commentPunchContent")
public AjaxResult commentPunchContent(@RequestBody SysWxUserLog sysWxUserLog) {
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
}
} }

View File

@ -131,6 +131,35 @@ public class WechatAppletController extends BaseController {
isPunch = true; isPunch = true;
} }
} }
/*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"));
}*/
Collections.reverse(list); Collections.reverse(list);
TableDataInfo tableDataInfo = getDataTable(list); TableDataInfo tableDataInfo = getDataTable(list);
result.put("isPunch", isPunch); result.put("isPunch", isPunch);
@ -173,6 +202,47 @@ public class WechatAppletController extends BaseController {
return toAjax(sysWxUserLogService.insertSysWxUserLog(sysWxUserLog)); return toAjax(sysWxUserLogService.insertSysWxUserLog(sysWxUserLog));
} }
/**
* 获取微信用户记录详细信息
*/
@GetMapping(value = "/getPunchLogDetail/{id}")
public AjaxResult getPunchLogDetail(@PathVariable("id") String id) {
WxLogInfo sysWxUserLog = null;
//根据ID查询
SysWxUserLog param = new SysWxUserLog();
param.setId(Long.parseLong(id));
sysWxUserLog = sysWxUserLogService.getWxLogInfoDetailById(param);
if(sysWxUserLog == null){
return AjaxResult.error("打卡记录不存在");
}
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);
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);
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"));
return AjaxResult.success(sysWxUserLog);
}
/** /**
* 处理返回值的ID加密 * 处理返回值的ID加密
* @param list * @param list

View File

@ -68,5 +68,37 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<!-- lucene -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-analyzers-common -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>4.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-highlighter -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
<version>4.4.0</version>
</dependency>
<!--IK分词器 (智能中文分词器)-->
<dependency>
<groupId>com.janeluo</groupId>
<artifactId>ikanalyzer</artifactId>
<version>2012_u6</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,43 @@
package com.stdiet.custom.domain;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 营养知识小问答对象 sys_nutrition_question
*
* @author xzj
* @date 2021-04-13
*/
@Data
public class SysNutritionQuestion extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 标题 */
@Excel(name = "标题")
private String title;
/** 内容 */
@Excel(name = "内容")
private String content;
/** 关键词,逗号隔开 */
@Excel(name = "关键词,逗号隔开")
private String key;
/** 标题内容索引分词之后的关键词 */
@Excel(name = "标题内容索引分词之后的关键词")
private String titleContentIndex;
/** 是否在小程序显示0 不显示 1显示默认0 */
@Excel(name = "是否在小程序显示0 不显示 1显示默认0")
private Integer showFlag;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
}

View File

@ -76,6 +76,9 @@ public class SysWxUserLog extends BaseEntity
//客户ID //客户ID
private Long customerId; private Long customerId;
//建议
private String remark;
/** /**
* 非持久化字段客户姓名 * 非持久化字段客户姓名
*/ */
@ -123,6 +126,25 @@ public class SysWxUserLog extends BaseEntity
@Excel(name = "体型对比照") @Excel(name = "体型对比照")
private String bodyImages; private String bodyImages;
/** 服务建议 */
@Excel(name = "服务建议")
private String suggest;
/** 目标体重 */
@Excel(name = "目标体重")
private BigDecimal targetWeight;
/** 执行评分,五分制 */
@Excel(name = "执行评分,五分制")
private BigDecimal executionScore;
/** 点评 */
@Excel(name = "点评")
private String comment;
/** 删除标识 0未删除 1已删除 */
private Long delFlag;
//售后营养师ID //售后营养师ID
private Long afterNutritionistId; private Long afterNutritionistId;

View File

@ -0,0 +1,27 @@
package com.stdiet.custom.dto.response;
import com.stdiet.common.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
@Data
public class NutritionQuestionResponse implements Serializable {
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 标题 */
@Excel(name = "标题")
private String title;
/** 内容 */
@Excel(name = "内容")
private String content;
/** 关键词,逗号隔开 */
@Excel(name = "关键词,逗号隔开")
private String key;
}

View File

@ -0,0 +1,67 @@
package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysNutritionQuestion;
/**
* 营养知识小问答Mapper接口
*
* @author xzj
* @date 2021-04-13
*/
public interface SysNutritionQuestionMapper
{
/**
* 查询营养知识小问答
*
* @param id 营养知识小问答ID
* @return 营养知识小问答
*/
public SysNutritionQuestion selectSysNutritionQuestionById(Long id);
/**
* 查询营养知识小问答列表
*
* @param sysNutritionQuestion 营养知识小问答
* @return 营养知识小问答集合
*/
public List<SysNutritionQuestion> selectSysNutritionQuestionList(SysNutritionQuestion sysNutritionQuestion);
/**
* 新增营养知识小问答
*
* @param sysNutritionQuestion 营养知识小问答
* @return 结果
*/
public int insertSysNutritionQuestion(SysNutritionQuestion sysNutritionQuestion);
/**
* 修改营养知识小问答
*
* @param sysNutritionQuestion 营养知识小问答
* @return 结果
*/
public int updateSysNutritionQuestion(SysNutritionQuestion sysNutritionQuestion);
/**
* 删除营养知识小问答
*
* @param id 营养知识小问答ID
* @return 结果
*/
public int deleteSysNutritionQuestionById(Long id);
/**
* 批量删除营养知识小问答
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysNutritionQuestionByIds(Long[] ids);
/**
* 根据关键词搜索对应营养知识问答
* @return
*/
public List<String> getNutritionQuestionListByKey(SysNutritionQuestion sysNutritionQuestion);
}

View File

@ -85,4 +85,11 @@ public interface SysWxUserLogMapper
*/ */
List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog); List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog);
/**
* 根据ID查询打卡详情
* @param sysWxUserLog
* @return
*/
WxLogInfo getWxLogInfoDetailById(SysWxUserLog sysWxUserLog);
} }

View File

@ -1,14 +1,18 @@
package com.stdiet.custom.page; package com.stdiet.custom.page;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.DateUtils;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
public class WxLogInfo implements Serializable { public class WxLogInfo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id;
private String date; private String date;
private Long water; private Long water;
@ -27,6 +31,8 @@ public class WxLogInfo implements Serializable {
private String defecation; private String defecation;
private String remark;
/** 情绪 */ /** 情绪 */
private String emotion; private String emotion;
@ -51,6 +57,28 @@ public class WxLogInfo implements Serializable {
/** 体型对比照 */ /** 体型对比照 */
private String bodyImages; private String bodyImages;
/** 服务建议 */
private String suggest;
/** 目标体重 */
private BigDecimal targetWeight;
/** 执行评分,五分制 */
private BigDecimal executionScore;
/** 点评 */
private String comment;
private List<String> breakfastImagesUrl;
private List<String> lunchImagesUrl;
private List<String> dinnerImagesUrl;
private List<String> extraMealImagesUrl;
private List<String> bodyImagesUrl;
public String getDate() { public String getDate() {
return date; return date;
} }
@ -187,6 +215,94 @@ public class WxLogInfo implements Serializable {
this.bodyImages = bodyImages; this.bodyImages = bodyImages;
} }
public String getSuggest() {
return suggest;
}
public void setSuggest(String suggest) {
this.suggest = suggest;
}
public BigDecimal getTargetWeight() {
return targetWeight;
}
public void setTargetWeight(BigDecimal targetWeight) {
this.targetWeight = targetWeight;
}
public BigDecimal getExecutionScore() {
return executionScore;
}
public void setExecutionScore(BigDecimal executionScore) {
this.executionScore = executionScore;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public List<String> getBreakfastImagesUrl() {
return breakfastImagesUrl;
}
public void setBreakfastImagesUrl(List<String> breakfastImagesUrl) {
this.breakfastImagesUrl = breakfastImagesUrl;
}
public List<String> getLunchImagesUrl() {
return lunchImagesUrl;
}
public void setLunchImagesUrl(List<String> lunchImagesUrl) {
this.lunchImagesUrl = lunchImagesUrl;
}
public List<String> getDinnerImagesUrl() {
return dinnerImagesUrl;
}
public void setDinnerImagesUrl(List<String> dinnerImagesUrl) {
this.dinnerImagesUrl = dinnerImagesUrl;
}
public List<String> getExtraMealImagesUrl() {
return extraMealImagesUrl;
}
public void setExtraMealImagesUrl(List<String> extraMealImagesUrl) {
this.extraMealImagesUrl = extraMealImagesUrl;
}
public List<String> getBodyImagesUrl() {
return bodyImagesUrl;
}
public void setBodyImagesUrl(List<String> bodyImagesUrl) {
this.bodyImagesUrl = bodyImagesUrl;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override @Override
public String toString() { public String toString() {
return "WxLogInfo{" + return "WxLogInfo{" +

View File

@ -0,0 +1,70 @@
package com.stdiet.custom.service;
import java.util.List;
import java.util.Map;
import com.stdiet.custom.domain.SysNutritionQuestion;
/**
* 营养知识小问答Service接口
*
* @author xzj
* @date 2021-04-13
*/
public interface ISysNutritionQuestionService
{
/**
* 查询营养知识小问答
*
* @param id 营养知识小问答ID
* @return 营养知识小问答
*/
public SysNutritionQuestion selectSysNutritionQuestionById(Long id);
/**
* 查询营养知识小问答列表
*
* @param sysNutritionQuestion 营养知识小问答
* @return 营养知识小问答集合
*/
public List<SysNutritionQuestion> selectSysNutritionQuestionList(SysNutritionQuestion sysNutritionQuestion);
/**
* 新增营养知识小问答
*
* @param sysNutritionQuestion 营养知识小问答
* @return 结果
*/
public int insertSysNutritionQuestion(SysNutritionQuestion sysNutritionQuestion);
/**
* 修改营养知识小问答
*
* @param sysNutritionQuestion 营养知识小问答
* @return 结果
*/
public int updateSysNutritionQuestion(SysNutritionQuestion sysNutritionQuestion);
/**
* 批量删除营养知识小问答
*
* @param ids 需要删除的营养知识小问答ID
* @return 结果
*/
public int deleteSysNutritionQuestionByIds(Long[] ids);
/**
* 删除营养知识小问答信息
*
* @param id 营养知识小问答ID
* @return 结果
*/
public int deleteSysNutritionQuestionById(Long id);
/**
* 根据关键词搜索对应营养知识问答(Lucene索引分词查询)
* @return
*/
public Map<String, Object> getNutritionQuestionListByKey(SysNutritionQuestion sysNutritionQuestion, int pageNum, int pageSize);
}

View File

@ -87,4 +87,11 @@ public interface ISysWxUserLogService
*/ */
List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog); List<SysWxUserLog> getWxUserLogListByCustomerId(SysWxUserLog sysWxUserLog);
/**
* 根据ID查询打卡详情
* @param sysWxUserLog
* @return
*/
WxLogInfo getWxLogInfoDetailById(SysWxUserLog sysWxUserLog);
} }

View File

@ -0,0 +1,154 @@
package com.stdiet.custom.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.reflect.ReflectUtils;
import com.stdiet.custom.utils.LuceneIndexUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysNutritionQuestionMapper;
import com.stdiet.custom.domain.SysNutritionQuestion;
import com.stdiet.custom.service.ISysNutritionQuestionService;
/**
* 营养知识小问答Service业务层处理
*
* @author xzj
* @date 2021-04-13
*/
@Service
public class SysNutritionQuestionServiceImpl implements ISysNutritionQuestionService
{
@Autowired
private SysNutritionQuestionMapper sysNutritionQuestionMapper;
public static final String index_path = "D:\\develop\\LuceneIndex\\nutritionQuestion";
//private static final String index_path = "";
//建立索引的字段名称
public static final String[] index_field_array = {"id", "title", "content", "key"};
/**
* 查询营养知识小问答
*
* @param id 营养知识小问答ID
* @return 营养知识小问答
*/
@Override
public SysNutritionQuestion selectSysNutritionQuestionById(Long id)
{
return sysNutritionQuestionMapper.selectSysNutritionQuestionById(id);
}
/**
* 查询营养知识小问答列表
*
* @param sysNutritionQuestion 营养知识小问答
* @return 营养知识小问答
*/
@Override
public List<SysNutritionQuestion> selectSysNutritionQuestionList(SysNutritionQuestion sysNutritionQuestion)
{
return sysNutritionQuestionMapper.selectSysNutritionQuestionList(sysNutritionQuestion);
}
/**
* 新增营养知识小问答
*
* @param sysNutritionQuestion 营养知识小问答
* @return 结果
*/
@Override
public int insertSysNutritionQuestion(SysNutritionQuestion sysNutritionQuestion)
{
sysNutritionQuestion.setCreateTime(DateUtils.getNowDate());
if(sysNutritionQuestionMapper.insertSysNutritionQuestion(sysNutritionQuestion) > 0){
return createNutritionQuestionIndex(sysNutritionQuestion) ? 1 : 0;
}
return 0;
}
/**
* 修改营养知识小问答
*
* @param sysNutritionQuestion 营养知识小问答
* @return 结果
*/
@Override
public int updateSysNutritionQuestion(SysNutritionQuestion sysNutritionQuestion)
{
sysNutritionQuestion.setUpdateTime(DateUtils.getNowDate());
return sysNutritionQuestionMapper.updateSysNutritionQuestion(sysNutritionQuestion);
}
/**
* 批量删除营养知识小问答
*
* @param ids 需要删除的营养知识小问答ID
* @return 结果
*/
@Override
public int deleteSysNutritionQuestionByIds(Long[] ids)
{
return sysNutritionQuestionMapper.deleteSysNutritionQuestionByIds(ids);
}
/**
* 删除营养知识小问答信息
*
* @param id 营养知识小问答ID
* @return 结果
*/
@Override
public int deleteSysNutritionQuestionById(Long id)
{
return sysNutritionQuestionMapper.deleteSysNutritionQuestionById(id);
}
/**
* 根据关键词搜索对应营养知识问答
* @return
*/
@Override
public Map<String, Object> getNutritionQuestionListByKey(SysNutritionQuestion sysNutritionQuestion, int pageNum, int pageSize){
//return sysNutritionQuestionMapper.getNutritionQuestionListByKey(sysNutritionQuestion);
try{
//建立索引
LuceneIndexUtils luceneIndexUtils = LuceneIndexUtils.getLuceneIndexUtils(index_path);
return luceneIndexUtils.queryByKeyword(sysNutritionQuestion.getKey(), index_field_array, pageNum, pageSize);
}catch (Exception e){
e.printStackTrace();
}
Map<String, Object> result = new HashMap<>();
result.put("total", 0);
result.put("data", new ArrayList<>());
return result;
}
/**
* 建立索引
* @param sysNutritionQuestion
* @return
*/
private boolean createNutritionQuestionIndex(SysNutritionQuestion sysNutritionQuestion){
try{
//建立索引
LuceneIndexUtils luceneIndexUtils = LuceneIndexUtils.getLuceneIndexUtils(index_path);
Document document = new Document();
for (String fieldName : index_field_array) {
document.add(new TextField(fieldName, ReflectUtils.getFieldValue(sysNutritionQuestion, fieldName)+"", Field.Store.YES));
}
return luceneIndexUtils.addIndexOne(document);
}catch (Exception e){
e.printStackTrace();
return false;
}
}
}

View File

@ -133,4 +133,13 @@ public class SysWxUserLogServiceImpl implements ISysWxUserLogService {
return sysWxUserLogMapper.getWxUserLogListByCustomerId(sysWxUserLog); return sysWxUserLogMapper.getWxUserLogListByCustomerId(sysWxUserLog);
} }
/**
* 根据ID查询打卡详情
* @param sysWxUserLog
* @return
*/
public WxLogInfo getWxLogInfoDetailById(SysWxUserLog sysWxUserLog){
return sysWxUserLogMapper.getWxLogInfoDetailById(sysWxUserLog);
}
} }

View File

@ -0,0 +1,319 @@
package com.stdiet.custom.utils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.service.impl.SysNutritionQuestionServiceImpl;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.*;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;
import org.wltea.analyzer.lucene.IKAnalyzer;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Lucene的IKAnalyzer工具类
*/
public class LuceneIndexUtils {
//分词器
private IKAnalyzer analyzer = null;
//索引库
private Directory directory = null;
//分词器工具
private IndexWriterConfig config = null;
//
private IndexWriter indexWriter= null;
public static final String default_primary_key = "id";
public static final Integer max_select_count = 1000;
public static LuceneIndexUtils getLuceneIndexUtils(String indexPath){
LuceneIndexUtils luceneIndexUtils = new LuceneIndexUtils();
try {
//分词器
luceneIndexUtils.analyzer = new IKAnalyzer();
//使用智能分词
luceneIndexUtils.analyzer.setUseSmart(true);
//索引库
luceneIndexUtils.directory = FSDirectory.open(new File(indexPath));
//工具装配分词器
luceneIndexUtils.config = new IndexWriterConfig(Version.LUCENE_44, luceneIndexUtils.analyzer);
} catch (Exception e) {
e.printStackTrace();
}
return luceneIndexUtils;
}
/**
* 增加所有数据
* @return
* @throws IOException
*/
public int addIndexs(ArrayList<Document> documents) throws IOException {
// 读取索引库 加装工具
indexWriter = new IndexWriter(directory,config);
//数据进流
indexWriter.addDocuments(documents);
try {
indexWriter.commit();
return documents.size();
}catch (Exception e){
indexWriter.rollback();
return 0;
}finally {
indexWriter.close();
indexWriter= null;
//config=null;
}
}
/**
* 增加一条数据
* @param document
* @return
* @throws IOException
*/
public boolean addIndexOne(Document document) throws IOException {
// 读取索引库 加装工具
indexWriter = new IndexWriter(directory,config);
//数据进流
indexWriter.addDocument(document);
try {
indexWriter.commit();
return true;
}catch (Exception e){
indexWriter.rollback();
return false;
}finally {
indexWriter.close();
indexWriter= null;
}
}
/**
* 删除索引库所有数据
* @return
* @throws IOException
*/
public boolean deleteAllIndex() throws IOException {
try {
// 读取索引库 加装工具
indexWriter = new IndexWriter(directory,config);
indexWriter.deleteAll();
indexWriter.commit();
return true;
}catch (Exception e){
e.printStackTrace();
indexWriter.rollback();
return false;
}finally {
indexWriter.close();
indexWriter= null;
}
}
/**
* 删除索引库中一条数据
* @param term
* @return
* @throws IOException
*/
public boolean deleteOne(Term term) throws IOException {
// 读取索引库 加装工具
indexWriter = new IndexWriter(directory,config);
try {
indexWriter.deleteDocuments(term);
indexWriter.commit();
return true;
}catch (Exception e){
indexWriter.rollback();
return false;
}finally {
indexWriter.close();
indexWriter= null;
}
}
/**
* 修改索引库中一条数据
* 注意此处修改为 根据查找条件修改 如果有则修改 没有则新添 多条则修改一条索引库的底层其实做法是 先删除后修改- -
* @param term
* @param document
* @return
* @throws IOException
*/
public boolean updateOne(Term term, Document document) throws IOException {
try {
// 读取索引库 加装工具
indexWriter = new IndexWriter(directory,config);
indexWriter.updateDocument(term,document);
indexWriter.commit();
return true;
}catch (Exception e){
indexWriter.rollback();
return false;
}finally {
indexWriter.close();
indexWriter= null;
}
}
/**
* 查询索引库的数据根据输入关键字
* @param keyword
* @return
* @throws Exception
*/
public Map<String, Object> queryByKeyword(String keyword, String[] columns, int pageNum, int pageSize) throws Exception {
Map<String, Object> result = new HashMap<>();
//指定读取索引库的列数据
//String[] columns = {"articleId","articleName","articleImage","articleContent"};
//装配
MultiFieldQueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_44, columns, analyzer);
//解析输入关键字
Query query = StringUtils.isEmpty(keyword) ? new WildcardQuery(new Term(default_primary_key, "*")) : queryParser.parse(keyword);
//读索引库流
IndexReader reader = DirectoryReader.open(directory);
//获得读取对象
IndexSearcher indexSearcher = new IndexSearcher(reader);
//排序
SortField sortField = new SortField(default_primary_key, SortField.Type.INT, true);
Sort sort = new Sort(sortField);
//装配解析结果 指定读取量级
TopDocs search = indexSearcher.search(query, max_select_count, sort);
//获得数据地址数组
ScoreDoc[] scoreDocs = search.scoreDocs;
result.put("total", scoreDocs.length);
//创建返回集合 --> 方便装配
ArrayList<Document> list = new ArrayList<>();
int start = (pageNum - 1) * pageSize;
if(start < scoreDocs.length){
int end = pageSize * pageNum;
if (end > scoreDocs.length) {
end = scoreDocs.length;
}
for (int i = start; i < end; i++) {
//进集合 装配
list.add(indexSearcher.doc(scoreDocs[i].doc));
}
}
result.put("data", list);
return result;
}
/**
* 重置索引库 不解释
* @return
* @throws IOException
*/
public boolean resetIndexDB(ArrayList<Document> documents) throws IOException {
try {
boolean bool = deleteAllIndex();
System.out.println(bool);
int i = addIndexs(documents);
System.out.println(i);
return true;
} catch (Exception e) {
return false;
}
}
/**
* 打印分词结果
* @param keyWord
* @throws Exception
*/
public static void printAnalysisResult(String keyWord) throws Exception {
StringReader reader = new StringReader(keyWord);
IKSegmenter ik = new IKSegmenter(reader, true);// 当为true时分词器进行最大词长切分
Lexeme lexeme = null;
while ((lexeme = ik.next()) != null) {
System.out.println(lexeme.getLexemeText());
}
}
public static void main(String[] args) throws IOException {
try{
LuceneIndexUtils luceneIndexUtils = LuceneIndexUtils.getLuceneIndexUtils(SysNutritionQuestionServiceImpl.index_path);
/*for (int i = 1 ; i < 100; i++){
Document document = new Document();
document.add(new TextField("id",i+"", Field.Store.YES));
document.add(new TextField("title","什么食物是脂肪杀手?", Field.Store.YES));
document.add(new TextField("content","黄瓜", Field.Store.YES));
document.add(new TextField("key","脂肪|杀手|食物", Field.Store.YES));
luceneIndexUtils.addIndexOne(document);
}*/
/*Document document = new Document();
document.add(new TextField("id","1", Field.Store.YES));
document.add(new TextField("title","什么食物是脂肪杀手?", Field.Store.YES));
document.add(new TextField("content","黄瓜", Field.Store.YES));
document.add(new TextField("key","脂肪|杀手|食物", Field.Store.YES));
luceneIndexUtils.addIndexOne(document);*/
String[] columns = {"key","content","title"};
Map<String,Object> map = luceneIndexUtils.queryByKeyword("猝死", SysNutritionQuestionServiceImpl.index_field_array, 1,10);
System.out.println(Long.parseLong(map.get("total").toString()));
for(Document document : (List<Document>)map.get("data")){
System.out.println(document.get("id")+"-"+document.get("key"));
}
//LuceneIndexUtils.printAnalysisResult("什么食物是脂肪杀手?");
}catch (Exception e){
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stdiet.custom.mapper.SysNutritionQuestionMapper">
<resultMap type="SysNutritionQuestion" id="SysNutritionQuestionResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="key" column="key" />
<result property="titleContentIndex" column="title_content_index" />
<result property="showFlag" column="show_flag" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
</resultMap>
<!-- 部分字段resultMap -->
<resultMap type="com.stdiet.custom.dto.response.NutritionQuestionResponse" id="SysNutritionQuestionResultExtended">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="content" column="content" />
<result property="key" column="key" />
<result property="titleContentIndex" column="title_content_index" />
</resultMap>
<sql id="selectSysNutritionQuestionVo">
select id, title, content, `key`, title_content_index, show_flag, create_time, create_by, update_time, update_by, del_flag from sys_nutrition_question
</sql>
<select id="selectSysNutritionQuestionList" parameterType="SysNutritionQuestion" resultMap="SysNutritionQuestionResult">
<include refid="selectSysNutritionQuestionVo"/> where del_flag = 0
<if test="title != null and title != ''"> and title = #{title}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="key != null and key != ''"> and `key` = #{key}</if>
<if test="titleContentIndex != null and titleContentIndex != ''"> and title_content_index = #{titleContentIndex}</if>
<if test="showFlag != null "> and show_flag = #{showFlag}</if>
</select>
<select id="selectSysNutritionQuestionById" parameterType="Long" resultMap="SysNutritionQuestionResult">
<include refid="selectSysNutritionQuestionVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysNutritionQuestion" parameterType="SysNutritionQuestion" useGeneratedKeys="true" keyProperty="id">
insert into sys_nutrition_question
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">title,</if>
<if test="content != null">content,</if>
<if test="key != null and key != ''">`key`,</if>
<if test="titleContentIndex != null">title_content_index,</if>
<if test="showFlag != null">show_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">#{title},</if>
<if test="content != null">#{content},</if>
<if test="key != null and key != ''">#{key},</if>
<if test="titleContentIndex != null">#{titleContentIndex},</if>
<if test="showFlag != null">#{showFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysNutritionQuestion" parameterType="SysNutritionQuestion">
update sys_nutrition_question
<trim prefix="SET" suffixOverrides=",">
<if test="title != null">title = #{title},</if>
<if test="content != null">content = #{content},</if>
<if test="key != null and key != ''">`key` = #{key},</if>
<if test="titleContentIndex != null">title_content_index = #{titleContentIndex},</if>
<if test="showFlag != null">show_flag = #{showFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<update id="deleteSysNutritionQuestionById" parameterType="Long">
update sys_nutrition_question set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysNutritionQuestionByIds" parameterType="String">
update sys_nutrition_question set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 根据关键词查询对应知识问题 -->
<select id="getNutritionQuestionListByKey" parameterType="SysNutritionQuestion" resultMap="SysNutritionQuestionResultExtended">
select id, title, `key`, content where del_flag = 0
<if test="showFlag != null "> and show_flag = #{showFlag}</if>
<if test="key != null and key != ''">
and (title like CONCAT('%',#{key},'%') or key like CONCAT('%',#{key},'%') or titleContentIndex like CONCAT('%',#{key},'%'))
</if>
order by id desc
</select>
</mapper>

View File

@ -33,6 +33,11 @@
<result property="dinnerImages" column="dinner_images" /> <result property="dinnerImages" column="dinner_images" />
<result property="extraMealImages" column="extra_meal_images" /> <result property="extraMealImages" column="extra_meal_images" />
<result property="bodyImages" column="body_images" /> <result property="bodyImages" column="body_images" />
<result property="suggest" column="suggest" />
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
<result property="delFlag" column="del_flag" />
<!-- 非持久字段 --> <!-- 非持久字段 -->
<result property="customerName" column="customer_name"></result> <result property="customerName" column="customer_name"></result>
<!-- 营养师 --> <!-- 营养师 -->
@ -41,6 +46,7 @@
</resultMap> </resultMap>
<resultMap type="com.stdiet.custom.page.WxLogInfo" id="WxLogInfo"> <resultMap type="com.stdiet.custom.page.WxLogInfo" id="WxLogInfo">
<result property="id" column="id" />
<result property="weight" column="weight"/> <result property="weight" column="weight"/>
<result property="sleepTime" column="sleep_time"/> <result property="sleepTime" column="sleep_time"/>
<result property="wakeupTime" column="wakeup_time"/> <result property="wakeupTime" column="wakeup_time"/>
@ -53,34 +59,39 @@
<result property="emotion" column="emotion" /> <result property="emotion" column="emotion" />
<result property="slyEatFood" column="sly_eat_food" /> <result property="slyEatFood" column="sly_eat_food" />
<result property="constipation" column="constipation" /> <result property="constipation" column="constipation" />
<result property="remark" column="remark"></result>
<result property="breakfastImages" column="breakfast_images" /> <result property="breakfastImages" column="breakfast_images" />
<result property="lunchImages" column="lunch_images" /> <result property="lunchImages" column="lunch_images" />
<result property="dinnerImages" column="dinner_images" /> <result property="dinnerImages" column="dinner_images" />
<result property="extraMealImages" column="extra_meal_images" /> <result property="extraMealImages" column="extra_meal_images" />
<result property="bodyImages" column="body_images" /> <result property="bodyImages" column="body_images" />
<result property="suggest" column="suggest" />
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
</resultMap> </resultMap>
<sql id="selectSysWxUserLogVo"> <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, 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 emotion,sly_eat_food,constipation,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images,suggest,execution_score,comment
from sys_wx_user_log from sys_wx_user_log
</sql> </sql>
<select id="checkWxLogInfoCount" parameterType="String" resultType="Integer"> <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} select count(*) from sys_wx_user_log where to_days(log_time) = to_days(now()) and openid = #{openid} and del_flag = 0
</select> </select>
<!-- 后台查询 --> <!-- 后台查询 -->
<select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult"> <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, 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.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images,
sc.name as customer_name, su.nick_name as nutritionist, su_atferSale.nick_name as after_nutritionist 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 FROM sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0 left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0
left join sys_user su on su.user_id = sc.main_dietitian and su.del_flag = '0' left join sys_user su on su.user_id = sc.main_dietitian and su.del_flag = '0'
left join sys_user su_atferSale on su_atferSale.user_id = sc.after_dietitian and su_atferSale.del_flag = '0' left join sys_user su_atferSale on su_atferSale.user_id = sc.after_dietitian and su_atferSale.del_flag = '0'
where wxinfo.phone is not null where wxlog.del_flag = 0 and wxinfo.phone is not null
<if test="id != null"> <if test="id != null">
and wxlog.id = #{id} and wxlog.id = #{id}
</if> </if>
@ -103,24 +114,22 @@
</select> </select>
<select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo"> <select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
SELECT * FROM sys_wx_user_log log SELECT * FROM sys_wx_user_log log where log.del_flag = 0
<where> <choose>
<choose> <when test="phone == null or phone == ''">
<when test="phone == null or phone == ''"> (SELECT phone FROM sys_wx_user_info WHERE openid = #{openid}) = log.phone
(SELECT phone FROM sys_wx_user_info WHERE openid = #{openid}) = log.phone </when>
</when> <otherwise>
<otherwise> <if test="openid != null and openid != ''">and openid = #{openid}</if>
<if test="openid != null and openid != ''">and openid = #{openid}</if> <if test="phone != null and phone != ''">or phone = #{phone}</if>
<if test="phone != null and phone != ''">or phone = #{phone}</if> </otherwise>
</otherwise> </choose>
</choose>
</where>
order by log_time asc order by log_time asc
</select> </select>
<select id="selectSysWxUserLogById" parameterType="String" resultMap="SysWxUserLogResult"> <select id="selectSysWxUserLogById" parameterType="String" resultMap="SysWxUserLogResult">
<include refid="selectSysWxUserLogVo"/> <include refid="selectSysWxUserLogVo"/>
where id = #{id} where id = #{id} and del_flag = 0
</select> </select>
<insert id="insertSysWxUserLog" parameterType="SysWxUserLog"> <insert id="insertSysWxUserLog" parameterType="SysWxUserLog">
@ -152,6 +161,11 @@
<if test="dinnerImages != null">dinner_images,</if> <if test="dinnerImages != null">dinner_images,</if>
<if test="extraMealImages != null">extra_meal_images,</if> <if test="extraMealImages != null">extra_meal_images,</if>
<if test="bodyImages != null">body_images,</if> <if test="bodyImages != null">body_images,</if>
<if test="suggest != null">suggest,</if>
<if test="targetWeight != null">target_weight,</if>
<if test="executionScore != null">execution_score,</if>
<if test="comment != null">comment,</if>
<if test="delFlag != null">del_flag,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openid != null">#{openid},</if> <if test="openid != null">#{openid},</if>
@ -180,6 +194,11 @@
<if test="dinnerImages != null">#{dinnerImages},</if> <if test="dinnerImages != null">#{dinnerImages},</if>
<if test="extraMealImages != null">#{extraMealImages},</if> <if test="extraMealImages != null">#{extraMealImages},</if>
<if test="bodyImages != null">#{bodyImages},</if> <if test="bodyImages != null">#{bodyImages},</if>
<if test="suggest != null">suggest = #{suggest},</if>
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
<if test="executionScore != null">execution_score = #{executionScore},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim> </trim>
</insert> </insert>
@ -212,32 +231,38 @@
<if test="dinnerImages != null">dinner_images = #{dinnerImages},</if> <if test="dinnerImages != null">dinner_images = #{dinnerImages},</if>
<if test="extraMealImages != null">extra_meal_images = #{extraMealImages},</if> <if test="extraMealImages != null">extra_meal_images = #{extraMealImages},</if>
<if test="bodyImages != null">body_images = #{bodyImages},</if> <if test="bodyImages != null">body_images = #{bodyImages},</if>
<if test="suggest != null">suggest = #{suggest},</if>
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
<if test="executionScore != null">execution_score = #{executionScore},</if>
<if test="comment != null">comment = #{comment},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteSysWxUserLogById" parameterType="Long"> <update id="deleteSysWxUserLogById" parameterType="Long">
delete from sys_wx_user_log where id = #{id} update sys_wx_user_log set del_flag = 1 where id = #{id}
</delete> </update>
<delete id="deleteSysWxUserLogByIds" parameterType="String"> <update id="deleteSysWxUserLogByIds" parameterType="String">
delete from sys_wx_user_log where id in update sys_wx_user_log set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </update>
<!-- 根据openid和手机号查询对应打卡记录 --> <!-- 根据openid和手机号查询对应打卡记录 -->
<select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo"> <select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
SELECT wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet, 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.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 FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxinfo.openid = #{openid} or wxinfo.phone = #{phone} where wxlog.del_flag = 0 and (wxinfo.openid = #{openid} or wxinfo.phone = #{phone})
order by wxlog.log_time desc order by wxlog.log_time desc
</select> </select>
<select id="selectSysWxUserLogByDateAndOpenId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult"> <select id="selectSysWxUserLogByDateAndOpenId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
select id from sys_wx_user_log where to_days(log_time) = to_days(#{logTime}) and openid = #{openid} limit 1 select id from sys_wx_user_log where del_flag = 0 and to_days(log_time) = to_days(#{logTime}) and openid = #{openid} limit 1
</select> </select>
<!-- 根据手机号和openid查询打卡连续天数只查询前两条 --> <!-- 根据手机号和openid查询打卡连续天数只查询前两条 -->
@ -250,7 +275,7 @@
( (
SELECT log_time,CONCAT(YEAR(log_time),'-',MONTH(log_time)) AS yearMonth,DAY(log_time) AS days SELECT log_time,CONCAT(YEAR(log_time),'-',MONTH(log_time)) AS yearMonth,DAY(log_time) AS days
FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxinfo.openid = #{openid} or wxinfo.phone = #{phone} where wxlog.del_flag = 0 and wxinfo.openid = #{openid} or wxinfo.phone = #{phone}
) AS s ORDER BY s.log_time DESC ) AS s ORDER BY s.log_time DESC
) ss ) ss
) sss GROUP BY yearMonth,day_cha LIMIT 2 ) sss GROUP BY yearMonth,day_cha LIMIT 2
@ -261,10 +286,20 @@
SELECT wxlog.id,wxlog.log_time,wxlog.weight FROM sys_wx_user_log wxlog SELECT wxlog.id,wxlog.log_time,wxlog.weight FROM sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0 left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0
where wxinfo.phone is not null and sc.id = #{customerId} where wxlog.del_flag = 0 and wxinfo.phone is not null and sc.id = #{customerId}
<if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')</if> <if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')</if>
<if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if> <if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if>
order by wxlog.log_time asc order by wxlog.log_time asc
</select> </select>
<!-- 根据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.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}
order by wxlog.log_time desc
</select>
</mapper> </mapper>

View File

@ -70,4 +70,16 @@ export function getAllPunchLogByCustomerId(query) {
}) })
} }
// 点评打卡
export function commentPunchContent(data) {
return request({
url: '/custom/wxUserLog/commentPunchContent',
method: 'post',
data: data
})
}

View File

@ -8,15 +8,16 @@
> >
<div style="margin-top: -20px;"> <div style="margin-top: -20px;">
<div <div
style="float: right; " style="float: right; margin-bottom:10px"
> >
<!--<el-button <el-button
v-hasPermi="['custom:wxUserLog:query']"
type="primary" type="primary"
plain plain
>评分</el-button @click="clickComment()"
>--> >打卡点评</el-button
>
</div> </div>
@ -26,12 +27,12 @@
<h3>基础信息</h3> <h3>基础信息</h3>
<TableDetailMessage :data="punchLogDetail"></TableDetailMessage> <TableDetailMessage :data="punchLogDetail"></TableDetailMessage>
<h3>图片信息</h3> <h3>图片信息</h3>
<div style="height: 400px; overflow: auto"> <div style="height: 370px; overflow: auto">
<div v-if="punchLog != null && punchLog.imagesUrl.breakfastImages.length > 0"> <div v-if="punchLog != null && punchLog.imagesUrl.breakfastImages.length > 0">
<h4>早餐</h4> <h4>早餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.breakfastImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.breakfastImages" title="点击大图预览" :key="index"
style="width: 300px; height: 380px" style="width: 300px; height: 300px"
:src="item" :src="item"
:preview-src-list="imageUrl"> :preview-src-list="imageUrl">
</el-image> </el-image>
@ -41,7 +42,7 @@
<h4>午餐</h4> <h4>午餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.lunchImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.lunchImages" title="点击大图预览" :key="index"
style="width: 300px; height: 400px" style="width: 300px; height: 300px"
:src="item" :src="item"
:preview-src-list="imageUrl"> :preview-src-list="imageUrl">
</el-image> </el-image>
@ -51,7 +52,7 @@
<h4>晚餐</h4> <h4>晚餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.dinnerImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.dinnerImages" title="点击大图预览" :key="index"
style="width: 300px; height: 400px" style="width: 300px; height: 300px"
:src="item" :src="item"
:preview-src-list="imageUrl"> :preview-src-list="imageUrl">
</el-image> </el-image>
@ -61,7 +62,7 @@
<h4>加餐</h4> <h4>加餐</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.extraMealImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.extraMealImages" title="点击大图预览" :key="index"
style="width: 300px; height: 400px" style="width: 300px; height: 300px"
:src="item" :src="item"
:preview-src-list="imageUrl"> :preview-src-list="imageUrl">
</el-image> </el-image>
@ -71,7 +72,7 @@
<h4>体型对比照</h4> <h4>体型对比照</h4>
<div> <div>
<el-image v-for="(item, index) in punchLog.imagesUrl.bodyImages" title="点击大图预览" :key="index" <el-image v-for="(item, index) in punchLog.imagesUrl.bodyImages" title="点击大图预览" :key="index"
style="width: 300px; height: 400px" style="width: 300px; height: 300px"
:src="item" :src="item"
:preview-src-list="imageUrl"> :preview-src-list="imageUrl">
</el-image> </el-image>
@ -79,12 +80,44 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<el-dialog :visible.sync="commentVisible" :title="commentTitle" width="500px" append-to-body @closed="commentClosed">
<el-form ref="form" :model="commentForm" :rules="commentRules" label-position="top" label-width="100px">
<el-form-item label="打卡评分" prop="executionScore" >
<el-rate
v-model="commentForm.executionScore"
show-score
allow-half
text-color="#ff9900"
>
</el-rate>
</el-form-item>
<el-form-item label="点评内容" prop="comment" >
<el-input
type="textarea"
:rows="4"
maxlength="200"
show-word-limit
placeholder="请输入点评内容"
v-model="commentForm.comment">
</el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" >
<el-button type="primary" @click="commentSubmit()"> </el-button>
<el-button @click="commentClosed()"> </el-button>
</div>
</el-dialog>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { import {
getPunchLogDetail getPunchLogDetail,commentPunchContent
} from "@/api/custom/wxUserLog"; } from "@/api/custom/wxUserLog";
import TableDetailMessage from "@/components/TableDetailMessage"; import TableDetailMessage from "@/components/TableDetailMessage";
@ -98,6 +131,7 @@ export default {
visible: false, visible: false,
title: "", title: "",
data: null, data: null,
callback: null,
punchLog: null, punchLog: null,
imageUrl: [], imageUrl: [],
punchLogDetail: [], punchLogDetail: [],
@ -106,15 +140,26 @@ export default {
["姓名", "体重(斤)","饮水量(ml)"], ["姓名", "体重(斤)","饮水量(ml)"],
["睡觉时间", "起床时间","运动锻炼"], ["睡觉时间", "起床时间","运动锻炼"],
["情绪","按食谱进食","其他食物"], ["情绪","按食谱进食","其他食物"],
["熬夜失眠", "起床排便","是否便秘"] ["熬夜失眠", "起床排便","是否便秘"],
["服务建议", "评分","点评内容"]
], ],
// //
punchValueData: [ punchValueData: [
["customerName","weight","water"], ["customerName","weight","water"],
["sleepTime", "wakeupTime","sport"], ["sleepTime", "wakeupTime","sport"],
["emotion", "diet","slyEatFood"], ["emotion", "diet","slyEatFood"],
["insomnia","defecation", "constipation"] ["insomnia","defecation", "constipation"],
["remark","executionScore","comment"],
], ],
commentVisible: false,
commentTitle: "",
commentForm:{
},
commentRules:{},
scoreArray:[0.5,1,1.5,2,2.5,3,3.5,4,4.5,5],
commentFlag: false, //
}; };
}, },
methods: { methods: {
@ -137,8 +182,10 @@ export default {
return "background:#ffffff;"; return "background:#ffffff;";
} }
}, },
showDialog(data) { showDialog(data, callback) {
this.data = data; this.data = data;
this.callback = callback;
this.commentFlag = false;
this.title = `${data.customerName}`+" "+`${data.logTime}」打卡记录`; this.title = `${data.customerName}`+" "+`${data.logTime}」打卡记录`;
this.getPunchLogById(); this.getPunchLogById();
}, },
@ -152,6 +199,8 @@ export default {
res.data.insomnia = res.data.insomnia === "Y" ? "是" : "否"; res.data.insomnia = res.data.insomnia === "Y" ? "是" : "否";
res.data.defecation = res.data.defecation === "Y" ? "是" : "否"; res.data.defecation = res.data.defecation === "Y" ? "是" : "否";
res.data.constipation = res.data.constipation === "Y" ? "是" : "否"; res.data.constipation = res.data.constipation === "Y" ? "是" : "否";
res.data.isScore = res.data.executionScore == null ? "否" : "是";
this.punchLogDetail = [];
for (let i = 0; i < this.punchTitleData.length; i++) { for (let i = 0; i < this.punchTitleData.length; i++) {
this.punchLogDetail.push({ this.punchLogDetail.push({
attr_name_one: this.punchTitleData[i][0], attr_name_one: this.punchTitleData[i][0],
@ -174,9 +223,42 @@ export default {
}, },
onClosed() { onClosed() {
this.data = null; this.data = null;
this.punchLog = null, this.callback = null;
this.imageUrl = [], this.punchLog = null;
this.punchLogDetail = [] this.imageUrl = [];
this.punchLogDetail = [];
},
clickComment(){
//console.log(this.punchLog.executionScore);
this.commentForm = {
id: this.punchLog.id,
comment: this.punchLog.comment,
executionScore: this.punchLog.executionScore == null ? 0 : this.punchLog.executionScore,
}
this.commentTitle = "点评「"+this.punchLog.customerName+" "+ this.punchLog.logTime +"」打卡";
this.commentVisible = true;
},
commentClosed(){
this.commentVisible = false;
},
commentSubmit(){
/*if(this.commentForm.executionScore == null || this.commentForm.executionScore == 0){
this.msgError("评分不能为0");
return;
}*/
commentPunchContent(this.commentForm).then((res) => {
if(res.code == 200){
this.msgSuccess("点评成功");
this.commentVisible = false;
this.getPunchLogById();
this.commentFlag = true;
this.callback && this.callback();
}else{
this.msgSuccess("点评失败");
}
});
} }
}, },
}; };

View File

@ -197,7 +197,7 @@
label="情绪" label="情绪"
align="center" align="center"
prop="emotion" prop="emotion"
width="160" width="120"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<AutoHideMessage :maxLength="4" :data="scope.row.emotion"></AutoHideMessage> <AutoHideMessage :maxLength="4" :data="scope.row.emotion"></AutoHideMessage>
@ -214,7 +214,7 @@
label="其他食物" label="其他食物"
align="center" align="center"
prop="slyEatFood" prop="slyEatFood"
width="160" width="120"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<AutoHideMessage :maxLength="4" :data="scope.row.slyEatFood"></AutoHideMessage> <AutoHideMessage :maxLength="4" :data="scope.row.slyEatFood"></AutoHideMessage>
@ -243,6 +243,15 @@
<span>{{ `${scope.row.water} ml` }}</span> <span>{{ `${scope.row.water} ml` }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="是否点评" align="center" prop="executionScore">
<template slot-scope="scope">
<el-tag
:type="scope.row.executionScore == null ? 'danger' : 'success'"
>
{{ scope.row.executionScore == null ? "未点评" : "已点评" }}
</el-tag>
</template>
</el-table-column>
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
@ -534,7 +543,9 @@ export default {
.catch(function () {}); .catch(function () {});
}, },
showPunchLogDetail(data){ showPunchLogDetail(data){
this.$refs.punchLogDetailRef.showDialog(data); this.$refs.punchLogDetailRef.showDialog(data,() => {
this.getList();
});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {