Merge branch 'master' of gitee.com:darlk/ShengTangManage into develop

This commit is contained in:
德仔 2021-02-22 19:49:36 +08:00 committed by Gitee
commit 5c5709d606
38 changed files with 3066 additions and 380 deletions

View File

@ -9,14 +9,11 @@ import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysCustomerHealthy; import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.domain.SysPhysicalSigns; import com.stdiet.custom.domain.SysPhysicalSigns;
import com.stdiet.custom.dto.request.CustomerInvestigateRequest; import com.stdiet.custom.dto.request.CustomerInvestigateRequest;
import com.stdiet.custom.service.ISysCustomerHealthyService; import com.stdiet.custom.dto.request.FoodHeatCalculatorRequest;
import com.stdiet.custom.service.ISysCustomerPhysicalSignsService; import com.stdiet.custom.service.*;
import com.stdiet.custom.service.ISysCustomerService;
import com.stdiet.custom.service.ISysPhysicalSignsService;
import com.stdiet.system.service.ISysDictTypeService; import com.stdiet.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -47,6 +44,9 @@ public class InvestigateController extends BaseController {
@Autowired @Autowired
private ISysCustomerService sysCustomerService; private ISysCustomerService sysCustomerService;
@Autowired
private ISysFoodHeatStatisticsService sysFoodHeatStatisticsService;
/** /**
* 建立客户信息档案 * 建立客户信息档案
*/ */
@ -107,4 +107,13 @@ public class InvestigateController extends BaseController {
return sysCustomerHealthyService.insertSysCustomerHealthy(sysCustomerHealthy); return sysCustomerHealthyService.insertSysCustomerHealthy(sysCustomerHealthy);
} }
/**
* 新增客户外食计算统计
*/
@PostMapping("/addFoodHeatStatistics")
public AjaxResult addFoodHeatStatistics(@RequestBody FoodHeatCalculatorRequest foodHeatCalculatorRequest)
{
return toAjax(sysFoodHeatStatisticsService.addMuchFoodHeat(foodHeatCalculatorRequest));
}
} }

View File

@ -53,6 +53,7 @@ public class SysCustomerController extends BaseController {
for (SysCustomer sysCus : list) { for (SysCustomer sysCus : list) {
if (StringUtils.isNotEmpty(sysCus.getPhone())) { if (StringUtils.isNotEmpty(sysCus.getPhone())) {
sysCus.setPhone(StringUtils.hiddenPhoneNumber(sysCus.getPhone())); sysCus.setPhone(StringUtils.hiddenPhoneNumber(sysCus.getPhone()));
sysCus.setEncId(sysCus.getId() != null ? AesUtils.encrypt(sysCus.getId()+"", null) : "");
} }
} }
} }
@ -143,17 +144,17 @@ public class SysCustomerController extends BaseController {
//查询健康评估信息 //查询健康评估信息
SysCustomerHealthy sysCustomerHealthy = sysCustomerHealthyService.selectSysCustomerHealthyByCustomerId(id); SysCustomerHealthy sysCustomerHealthy = sysCustomerHealthyService.selectSysCustomerHealthyByCustomerId(id);
if(sysCustomerHealthy != null){ if(sysCustomerHealthy != null){
if (StringUtils.isNotEmpty(sysCustomerHealthy.getPhone())) { /* if (StringUtils.isNotEmpty(sysCustomerHealthy.getPhone())) {
sysCustomerHealthy.setPhone(StringUtils.hiddenPhoneNumber(sysCustomerHealthy.getPhone())); sysCustomerHealthy.setPhone(StringUtils.hiddenPhoneNumber(sysCustomerHealthy.getPhone()));
} }*/
result.put(key, sysCustomerHealthy); result.put(key, sysCustomerHealthy);
}else{ }else{
//查询体征信息 //查询体征信息
SysCustomerPhysicalSigns sysCustomerPhysicalSigns = sysCustomerPhysicalSignsService.selectSysCustomerPhysicalSignsByCusId(id); SysCustomerPhysicalSigns sysCustomerPhysicalSigns = sysCustomerPhysicalSignsService.selectSysCustomerPhysicalSignsByCusId(id);
if(sysCustomerPhysicalSigns != null){ if(sysCustomerPhysicalSigns != null){
if (StringUtils.isNotEmpty(sysCustomerPhysicalSigns.getPhone())) { /* if (StringUtils.isNotEmpty(sysCustomerPhysicalSigns.getPhone())) {
sysCustomerPhysicalSigns.setPhone(StringUtils.hiddenPhoneNumber(sysCustomerPhysicalSigns.getPhone())); sysCustomerPhysicalSigns.setPhone(StringUtils.hiddenPhoneNumber(sysCustomerPhysicalSigns.getPhone()));
} }*/
result.put("type", 1); result.put("type", 1);
} }
result.put(key, sysCustomerPhysicalSigns); result.put(key, sysCustomerPhysicalSigns);

View File

@ -0,0 +1,114 @@
package com.stdiet.web.controller.custom;
import java.util.List;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.service.ISysCustomerHeatStatisticsService;
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.common.utils.poi.ExcelUtil;
import com.stdiet.common.core.page.TableDataInfo;
/**
* 外食热量统计Controller
*
* @author xzj
* @date 2021-02-19
*/
@RestController
@RequestMapping("/custom/foodHeatStatistics")
public class SysFoodHeatStatisticsController extends BaseController
{
@Autowired
private ISysCustomerHeatStatisticsService sysCustomerHeatStatisticsService;
/**
* 查询外食热量统计列表
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:list')")
@GetMapping("/list")
public TableDataInfo list(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
startPage();
List<SysCustomerHeatStatistics> list = sysCustomerHeatStatisticsService.selectSysCustomerHeatStatisticsList(sysCustomerHeatStatistics);
return getDataTable(list);
}
/**
* 导出外食热量统计列表
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:export')")
@Log(title = "外食热量统计", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
List<SysCustomerHeatStatistics> list = sysCustomerHeatStatisticsService.selectSysCustomerHeatStatisticsList(sysCustomerHeatStatistics);
ExcelUtil<SysCustomerHeatStatistics> util = new ExcelUtil<SysCustomerHeatStatistics>(SysCustomerHeatStatistics.class);
return util.exportExcel(list, "customerHeatstatistics");
}
/**
* 获取外食热量统计详细信息
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysCustomerHeatStatisticsService.selectSysCustomerHeatStatisticsById(id));
}
/**
* 新增外食热量统计
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:add')")
@Log(title = "外食热量统计", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
return toAjax(sysCustomerHeatStatisticsService.insertSysCustomerHeatStatistics(sysCustomerHeatStatistics));
}
/**
* 修改外食热量统计
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:edit')")
@Log(title = "外食热量统计", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
return toAjax(sysCustomerHeatStatisticsService.updateSysCustomerHeatStatistics(sysCustomerHeatStatistics));
}
/**
* 删除外食热量统计
*/
@PreAuthorize("@ss.hasPermi('custom:foodHeatStatistics:remove')")
@Log(title = "外食热量统计", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysCustomerHeatStatisticsService.deleteSysCustomerHeatStatisticsByIds(ids));
}
/**
* 修改食材热量并计算
*/
@Log(title = "修改食材热量并计算", businessType = BusinessType.UPDATE)
@RequestMapping("/addFoodHeatData")
public AjaxResult addFoodHeatData(@RequestBody SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
return toAjax(sysCustomerHeatStatisticsService.calculateCustomerHeat(sysCustomerHeatStatistics));
}
}

View File

@ -0,0 +1,145 @@
package com.stdiet.common.utils;
public class HealthyUtils {
public static final long maxHeatEveryDayLess = 250;
//每克蛋白质对应热量千卡
public static final int proteinHeat = 4;
//每克脂肪对应热量千卡
public static final int fatHeat = 9;
//每克碳水对应热量千卡
public static final int carbonWaterHeat = 4;
//营养成分比例
public static final Integer[] nutritionRate = {30, 20, 50};
/**
* 计算减脂每天最大摄入量千卡
* @param age 年龄
* @param tall 身高
* @param weight 体重
* @return
*/
public static long calculateMaxHeatEveryDay(Integer age, Integer tall, Double weight){
age = age == null ? 0 : age;
tall = tall == null ? 0 : tall;
weight = weight == null ? 0.0 : weight;
return calculateMetabolizeHeat(age, tall, weight) - maxHeatEveryDayLess;
}
/**
* 计算基础代谢BMR(千卡
* @param age
* @param tall
* @param weight
* @return
*/
public static Long calculateMetabolizeHeat(Integer age, Integer tall, Double weight){
return Math.round(655+(9.5*weight/2)+(1.8*tall)-(4.7*age));
}
/**
* 计算每公斤体重占比千卡/公斤
* @param metabolizeHeat 基础代谢BMR(千卡
* @param weight 体重
* @return
*/
public static double calculateHeatRateByWeight(long metabolizeHeat, double weight){
return NumberUtils.getNumberByRoundHalfUp(metabolizeHeat/weight*2, 2).doubleValue();
}
/**
* 计算每公斤体重占比目标范围
* @param heatRateByWeight 每公斤体重占比千卡/公斤
* @return
*/
public static double[] calculateHeatTargetRate(double heatRateByWeight){
double[] heatArray = new double[2];
heatArray[0] = heatRateByWeight - 10;
heatArray[1] = heatRateByWeight - 5;
return heatArray;
}
/**
* 计算减脂热量控制范围(千卡
* @param heatTargetRateArray 每公斤体重占比目标范围
* @param fatRateWeight 每公斤体重脂肪占比(/公斤)
* @return
*/
public static long[] calculateStandardHeatScopeRate(double[] heatTargetRateArray, double fatRateWeight){
long[] heatArray = new long[2];
heatArray[0] = Math.round(heatTargetRateArray[0] * fatRateWeight / 2);
heatArray[1] = Math.round(heatTargetRateArray[1] * fatRateWeight / 2);
return heatArray;
}
/**
* 根据蛋白质脂肪碳水质量计算热量
* @param proteinQuality 蛋白质质量
* @param fatQuality 脂肪质量
* @param carbonWaterQuality 碳水质量
* @return
*/
public static int calculateTotalHeatByProteinFatCarbonWater(Integer proteinQuality, Integer fatQuality, Integer carbonWaterQuality){
return calculateHeatByProteinQuality(proteinQuality) + calculateHeatByFatQuality(fatQuality) + calculateHeatByCarbonWaterQuality(carbonWaterQuality);
}
/**
* 根据蛋白质质量计算热量
* @return
*/
public static int calculateHeatByProteinQuality(Integer proteinQuality){
proteinQuality = proteinQuality == null ? 0 : proteinQuality;
return proteinQuality * proteinHeat;
}
/**
* 根据脂肪质量计算热量
* @return
*/
public static int calculateHeatByFatQuality(Integer fatQuality){
fatQuality = fatQuality == null ? 0 : fatQuality;
return fatQuality * fatHeat;
}
/**
* 根据碳水质量计算热量
* @return
*/
public static int calculateHeatByCarbonWaterQuality(Integer carbonWaterQuality){
carbonWaterQuality = carbonWaterQuality == null ? 0 : carbonWaterQuality;
return carbonWaterQuality * carbonWaterHeat;
}
/**
* 根据身高计算标准体重
* @param tall 身高厘米
* @return
*/
public static double calculateStandardWeight(int tall){
return (tall-107.5)*2;
}
/**
* 返回蛋白质脂肪碳水对应热量质量
* @param metabolizeHeat
* @return
*/
public static Integer[][] calculateNutritionHeatAndQuality(int metabolizeHeat){
Integer[] heatArray = new Integer[3];
Integer[] qualityArray = new Integer[3];
heatArray[0] = Math.round(nutritionRate[0] * metabolizeHeat /100);
heatArray[1] = Math.round(nutritionRate[1] * metabolizeHeat /100);
heatArray[2] = Math.round(nutritionRate[2] * metabolizeHeat /100);
qualityArray[0] = (int)Math.round(Double.parseDouble(heatArray[0]+"")/proteinHeat);
qualityArray[1] = (int)Math.round(Double.parseDouble(heatArray[1]+"")/fatHeat);
qualityArray[2] = (int)Math.round(Double.parseDouble(heatArray[2]+"")/carbonWaterHeat);
Integer[][] result = {heatArray, qualityArray};
return result;
}
}

View File

@ -0,0 +1,17 @@
package com.stdiet.common.utils;
import java.math.BigDecimal;
public class NumberUtils {
/**
* 对double数字进行四舍五入返回BigDecimal
* @param number 数字
* @param decimalPlaces 保留的小数点位数
* @return
*/
public static BigDecimal getNumberByRoundHalfUp(double number, int decimalPlaces){
return BigDecimal.valueOf(number).setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
}
}

View File

@ -3,6 +3,7 @@ package com.stdiet.custom.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.stdiet.common.annotation.Excel; import com.stdiet.common.annotation.Excel;
@ -14,6 +15,7 @@ import com.stdiet.common.core.domain.BaseEntity;
* @author xzj * @author xzj
* @date 2020-12-31 * @date 2020-12-31
*/ */
@Data
public class SysCustomer extends BaseEntity public class SysCustomer extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -21,6 +23,9 @@ public class SysCustomer extends BaseEntity
/** $column.columnComment */ /** $column.columnComment */
private Long id; private Long id;
//加密ID
private String encId;
/** 名字 */ /** 名字 */
@Excel(name = "名字") @Excel(name = "名字")
private String name; private String name;
@ -90,188 +95,4 @@ public class SysCustomer extends BaseEntity
/** 体征数据,非持久化字段 */ /** 体征数据,非持久化字段 */
private SysCustomerPhysicalSigns sign; private SysCustomerPhysicalSigns sign;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setPhone(String phone)
{
this.phone = phone;
}
public String getPhone()
{
return phone;
}
public void setEmail(String email)
{
this.email = email;
}
public String getEmail()
{
return email;
}
public void setAddress(String address)
{
this.address = address;
}
public String getAddress()
{
return address;
}
public void setPayDate(Date payDate)
{
this.payDate = payDate;
}
public Date getPayDate()
{
return payDate;
}
public void setStartDate(Date startDate)
{
this.startDate = startDate;
}
public Date getStartDate()
{
return startDate;
}
public void setPurchaseNum(Long purchaseNum)
{
this.purchaseNum = purchaseNum;
}
public Long getPurchaseNum()
{
return purchaseNum;
}
public void setPayTotal(BigDecimal payTotal)
{
this.payTotal = payTotal;
}
public BigDecimal getPayTotal()
{
return payTotal;
}
public void setMainDietitian(Long mainDietitian)
{
this.mainDietitian = mainDietitian;
}
public Long getMainDietitian()
{
return mainDietitian;
}
public void setAssistantDietitian(Long assistantDietitian)
{
this.assistantDietitian = assistantDietitian;
}
public Long getAssistantDietitian()
{
return assistantDietitian;
}
public void setAfterDietitian(Long afterDietitian)
{
this.afterDietitian = afterDietitian;
}
public Long getAfterDietitian()
{
return afterDietitian;
}
public void setSalesman(Long salesman)
{
this.salesman = salesman;
}
public Long getSalesman()
{
return salesman;
}
public void setChargePerson(Long chargePerson)
{
this.chargePerson = chargePerson;
}
public Long getChargePerson()
{
return chargePerson;
}
public void setFollowStatus(Long followStatus)
{
this.followStatus = followStatus;
}
public Long getFollowStatus()
{
return followStatus;
}
public SysCustomerPhysicalSigns getSign() {
return sign;
}
public void setSign(SysCustomerPhysicalSigns sign) {
this.sign = sign;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public Date getFansTime() {
return fansTime;
}
public void setFansTime(Date fansTime) {
this.fansTime = fansTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("phone", getPhone())
.append("email", getEmail())
.append("address", getAddress())
.append("payDate", getPayDate())
.append("startDate", getStartDate())
.append("purchaseNum", getPurchaseNum())
.append("payTotal", getPayTotal())
.append("mainDietitian", getMainDietitian())
.append("assistantDietitian", getAssistantDietitian())
.append("afterDietitian", getAfterDietitian())
.append("salesman", getSalesman())
.append("chargePerson", getChargePerson())
.append("followStatus", getFollowStatus())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString();
}
} }

View File

@ -0,0 +1,66 @@
package com.stdiet.custom.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 外食热量统计对象 sys_customer_heat_statistics
*
* @author xzj
* @date 2021-02-20
*/
@Data
public class SysCustomerHeatStatistics extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 客户ID */
@Excel(name = "客户ID")
private Long customerId;
/** 日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date edibleDate;
/** 最大可摄入量 */
@Excel(name = "最大可摄入量")
private Integer maxHeatValue;
/** 当天食材总热量 */
@Excel(name = "当天食材总热量")
private Integer heatValue;
/** 当天热量缺口 */
@Excel(name = "当天热量缺口")
private Integer heatGap;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
//食材热量ID
private Long[] foodHeatIdList;
//食材热量
private Integer[] foodHeatList;
//食材蛋白质质量
private Integer[] proteinQualityList;
//食材脂肪质量
private Integer[] fatQualityList;
//食材碳水质量
private Integer[] carbonWaterQualityList;
//具体食材集合
private List<SysFoodHeatStatistics> foodHeatStatisticsList;
}

View File

@ -0,0 +1,68 @@
package com.stdiet.custom.domain;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 外食热量统计对象 sys_food_heat_statistics
*
* @author xzj
* @date 2021-02-19
*/
@Data
public class SysFoodHeatStatistics extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 客户热量统计ID */
@Excel(name = "客户热量统计ID")
private Long customerHeatId;
/** 食材 */
@Excel(name = "食材")
private String ingredient;
/** 通俗单位ID */
@Excel(name = "通俗单位ID")
private Long unit;
private String unitName;
/** 通俗单位数量 */
@Excel(name = "通俗单位数量")
private Integer number;
/** 具体质量,单位:克 */
@Excel(name = "具体质量,单位:克")
private Integer quantity;
/** 类型0早 1中 2晚 */
@Excel(name = "类型0早 1中 2晚")
private Integer edibleType;
/** 蛋白质质量,克 */
@Excel(name = "蛋白质质量,克")
private Integer proteinQuality;
/** 脂肪质量,克 */
@Excel(name = "脂肪质量,克")
private Integer fatQuality;
/** 碳水质量,克 */
@Excel(name = "碳水质量,克")
private Integer carbonWaterQuality;
/** 热量数值 */
@Excel(name = "热量数值")
private Integer heatValue;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
}

View File

@ -93,6 +93,9 @@ public class SysOrder extends BaseEntity {
*/ */
private Long nutritionistId; private Long nutritionistId;
//营养师数组比例拆分单时需要两个营养师非持久化字段
private Long[] nutritionistIdList;
/** /**
* 营养师 * 营养师
*/ */
@ -227,11 +230,37 @@ public class SysOrder extends BaseEntity {
* 订单暂停记录 非持久化字段 * 订单暂停记录 非持久化字段
* */ * */
private List<SysOrderPause> orderPauseList; private List<SysOrderPause> orderPauseList;
//查询参数
private Integer amountFlag; private Integer amountFlag;
@JsonFormat(pattern = "yyyy-MM-dd") /**
public Date getStartTime() { * 订单类型 0普通单 1比例拆分单 2售后二开提成单
return startTime; */
} private String orderType;
/**
* 订单次数类型 0一开单 1二开单
*/
private String orderCountType;
/**
* 订单金额类型 0全款单 1定金单 2尾款单
*/
private String orderMoneyType;
/**
* 拆分订单中的主订单id非拆分订单时该id都为0
*/
private Long mainOrderId;
//订单类型数组用于接收订单类型订单次数类型订单金额类型非持久化字段
private Long[] orderTypeList;
//是否自动创建售后二开提成单非持久化字段
private Integer secondAfterSaleFlag;
//拆分比例1,9就是按照比例10%90%拆分非持久化字段
private Integer[] nutritionistRate;
} }

View File

@ -2,6 +2,7 @@ package com.stdiet.custom.domain;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.stdiet.common.annotation.Excel; import com.stdiet.common.annotation.Excel;
@ -13,6 +14,7 @@ import com.stdiet.common.core.domain.BaseEntity;
* @author xzj * @author xzj
* @date 2021-01-15 * @date 2021-01-15
*/ */
@Data
public class SysRecipesPlan extends BaseEntity public class SysRecipesPlan extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -24,6 +26,9 @@ public class SysRecipesPlan extends BaseEntity
//@Excel(name = "订单ID") //@Excel(name = "订单ID")
private Long orderId; private Long orderId;
//客户ID
private Long customerId;
//非持久化字段客户姓名 //非持久化字段客户姓名
@Excel(name = "客户姓名") @Excel(name = "客户姓名")
private String customer; private String customer;
@ -82,167 +87,4 @@ public class SysRecipesPlan extends BaseEntity
/** 删除标识 0未删除 1已删除 默认0 */ /** 删除标识 0未删除 1已删除 默认0 */
private Integer delFlag; private Integer delFlag;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setOrderId(Long orderId)
{
this.orderId = orderId;
}
public Long getOrderId()
{
return orderId;
}
public void setStartDate(Date startDate)
{
this.startDate = startDate;
}
public Date getStartDate()
{
return startDate;
}
public void setEndDate(Date endDate)
{
this.endDate = endDate;
}
public Date getEndDate()
{
return endDate;
}
public void setRecipesId(Long recipesId)
{
this.recipesId = recipesId;
}
public Long getRecipesId()
{
return recipesId;
}
public void setSendFlag(Integer sendFlag)
{
this.sendFlag = sendFlag;
}
public Integer getSendFlag()
{
return sendFlag;
}
public void setSendTime(Date sendTime)
{
this.sendTime = sendTime;
}
public Date getSendTime()
{
return sendTime;
}
public void setDelFlag(Integer delFlag)
{
this.delFlag = delFlag;
}
public Integer getDelFlag()
{
return delFlag;
}
public String getCustomer() {
return customer;
}
public void setCustomer(String customer) {
this.customer = customer;
}
public Long getNutritionistId() {
return nutritionistId;
}
public void setNutritionistId(Long nutritionistId) {
this.nutritionistId = nutritionistId;
}
public String getNutritionist() {
return nutritionist;
}
public void setNutritionist(String nutritionist) {
this.nutritionist = nutritionist;
}
public Long getNutritionistAssisId() {
return nutritionistAssisId;
}
public void setNutritionistAssisId(Long nutritionistAssisId) {
this.nutritionistAssisId = nutritionistAssisId;
}
public String getNutritionistAssis() {
return nutritionistAssis;
}
public void setNutritionistAssis(String nutritionistAssis) {
this.nutritionistAssis = nutritionistAssis;
}
public Date getOrderStartDate() {
return orderStartDate;
}
public void setOrderStartDate(Date orderStartDate) {
this.orderStartDate = orderStartDate;
}
public Date getOrderEndDate() {
return orderEndDate;
}
public void setOrderEndDate(Date orderEndDate) {
this.orderEndDate = orderEndDate;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getHidePhone() {
return hidePhone;
}
public void setHidePhone(String hidePhone) {
this.hidePhone = hidePhone;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderId", getOrderId())
.append("startDate", getStartDate())
.append("endDate", getEndDate())
.append("recipesId", getRecipesId())
.append("sendFlag", getSendFlag())
.append("sendTime", getSendTime())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("delFlag", getDelFlag())
.toString();
}
} }

View File

@ -29,6 +29,8 @@ public class SysWxFanStatistics extends BaseEntity
@Excel(name = "进粉账号") @Excel(name = "进粉账号")
private String account; private String account;
private Long accountId;
//销售组别 //销售组别
private String saleGroup; private String saleGroup;

View File

@ -0,0 +1,16 @@
package com.stdiet.custom.dto.request;
import com.stdiet.common.core.domain.BaseEntity;
import lombok.Data;
@Data
public class FoodHeatCalculatorRequest extends BaseEntity {
private static final long serialVersionUID = 1L;
//客户ID加密串
private String customerEncId;
//食材数据对应JSON数组字符串
private String ingredientArray;
}

View File

@ -0,0 +1,72 @@
package com.stdiet.custom.dto.response;
import lombok.Data;
import java.io.Serializable;
@Data
public class NutritionalCalories implements Serializable {
private static final long serialVersionUID = 1L;
//姓名
public String name;
//实际体重
public double weight;
//实际身高(厘米)
public int tall;
//年龄
public int age;
//标准体重
public double standardWeight;
//超重
public double overWeight;
//活动因子
public double activityFactor;
//基础代谢BMR(千卡
public int metabolizeHeat;
//减脂最大摄入量(千卡
public int maxIntakeHeat;
//不运动总热量(千卡
public int withoutExerciseHeat;
//运动总热量(千卡
public int exerciseHeat;
//每公斤体重占比(千卡/公斤
public double everyWeightHeat;
//目标范围千卡/公斤
public double[] targetEveryWeightHeat;
//减脂热量标准范围千卡/公斤
public double[] standardEveryWeightHeat;
//蛋白质脂肪碳水比例
public Integer[] nutritionalRate;
//蛋白质脂肪碳水对应热量千卡
public Integer[] nutritionalHeat;
//蛋白质脂肪碳水对应质量()
public Integer[] nutritionalQuality;
//每公斤体重对应蛋白质脂肪碳水占比(/公斤)
public double[] weightNutritionalRate;
//蛋白质脂肪碳水已摄入热量千卡
public Integer[] ingestedNutritionalHeat;
//蛋白质脂肪碳水剩余可摄入热量
public Integer[] surplusNutritionalHeat;
}

View File

@ -0,0 +1,71 @@
package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.dto.response.NutritionalCalories;
/**
* 外食热量统计Mapper接口
*
* @author xzj
* @date 2021-02-20
*/
public interface SysCustomerHeatStatisticsMapper
{
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
public SysCustomerHeatStatistics selectSysCustomerHeatStatisticsById(Long id);
/**
* 查询外食热量统计列表
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 外食热量统计集合
*/
public List<SysCustomerHeatStatistics> selectSysCustomerHeatStatisticsList(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 新增外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int insertSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 修改外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int updateSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 删除外食热量统计
*
* @param id 外食热量统计ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsById(Long id);
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsByIds(Long[] ids);
/**
* 根据客户ID日期查询客户热量统计数据
* @param sysCustomerHeatStatistics
* @return
*/
public SysCustomerHeatStatistics getCustomerHeatStatisticsByDate(SysCustomerHeatStatistics sysCustomerHeatStatistics);
}

View File

@ -0,0 +1,68 @@
package com.stdiet.custom.mapper;
import java.util.HashMap;
import java.util.List;
import com.stdiet.custom.domain.SysFoodHeatStatistics;
/**
* 外食热量统计Mapper接口
*
* @author xzj
* @date 2021-02-19
*/
public interface SysFoodHeatStatisticsMapper {
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
public SysFoodHeatStatistics selectSysFoodHeatStatisticsById(Long id);
/**
* 查询外食热量统计列表
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 外食热量统计集合
*/
public List<SysFoodHeatStatistics> selectSysFoodHeatStatisticsList(SysFoodHeatStatistics sysFoodHeatStatistics);
/**
* 新增外食热量统计
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 结果
*/
public int insertSysFoodHeatStatistics(SysFoodHeatStatistics sysFoodHeatStatistics);
/**
* 修改外食热量统计
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 结果
*/
public int updateSysFoodHeatStatistics(SysFoodHeatStatistics sysFoodHeatStatistics);
/**
* 删除外食热量统计
*
* @param id 外食热量统计ID
* @return 结果
*/
public int deleteSysFoodHeatStatisticsById(Long id);
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysFoodHeatStatisticsByIds(Long[] ids);
/**
* 批量添加
* @param sysFoodHeatStatisticsList
* @return
*/
public int insertFoodHeatBatch(List<HashMap> sysFoodHeatStatisticsList);
}

View File

@ -0,0 +1,83 @@
package com.stdiet.custom.service;
import java.util.List;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.dto.response.NutritionalCalories;
/**
* 外食热量统计Service接口
*
* @author xzj
* @date 2021-02-20
*/
public interface ISysCustomerHeatStatisticsService
{
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
public SysCustomerHeatStatistics selectSysCustomerHeatStatisticsById(Long id);
/**
* 查询外食热量统计列表
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 外食热量统计集合
*/
public List<SysCustomerHeatStatistics> selectSysCustomerHeatStatisticsList(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 新增外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int insertSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 修改外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
public int updateSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的外食热量统计ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsByIds(Long[] ids);
/**
* 删除外食热量统计信息
*
* @param id 外食热量统计ID
* @return 结果
*/
public int deleteSysCustomerHeatStatisticsById(Long id);
/**
* 更新食材热量并计算当天总热量
* @param sysCustomerHeatStatistics
* @return
*/
public int calculateCustomerHeat(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 根据日期查询是否客户热量统计
* @param sysCustomerHeatStatistics
* @return
*/
SysCustomerHeatStatistics getCustomerHeatStatisticsByDate(SysCustomerHeatStatistics sysCustomerHeatStatistics);
/**
* 根据客户热量食材统计ID查询详情
* @param id
* @return
*/
public NutritionalCalories getNutritionalCaloriesByCustomer(Long id);
}

View File

@ -0,0 +1,69 @@
package com.stdiet.custom.service;
import java.util.List;
import com.stdiet.custom.domain.SysFoodHeatStatistics;
import com.stdiet.custom.dto.request.FoodHeatCalculatorRequest;
/**
* 外食热量统计Service接口
*
* @author xzj
* @date 2021-02-19
*/
public interface ISysFoodHeatStatisticsService
{
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
public SysFoodHeatStatistics selectSysFoodHeatStatisticsById(Long id);
/**
* 查询外食热量统计列表
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 外食热量统计集合
*/
public List<SysFoodHeatStatistics> selectSysFoodHeatStatisticsList(SysFoodHeatStatistics sysFoodHeatStatistics);
/**
* 新增外食热量统计
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 结果
*/
public int insertSysFoodHeatStatistics(SysFoodHeatStatistics sysFoodHeatStatistics);
/**
* 修改外食热量统计
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 结果
*/
public int updateSysFoodHeatStatistics(SysFoodHeatStatistics sysFoodHeatStatistics);
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的外食热量统计ID
* @return 结果
*/
public int deleteSysFoodHeatStatisticsByIds(Long[] ids);
/**
* 删除外食热量统计信息
*
* @param id 外食热量统计ID
* @return 结果
*/
public int deleteSysFoodHeatStatisticsById(Long id);
/**
* 客户自己添加外食计算数据批量添加
* @param foodHeatCalculatorRequest
* @return
*/
public int addMuchFoodHeat(FoodHeatCalculatorRequest foodHeatCalculatorRequest);
}

View File

@ -0,0 +1,212 @@
package com.stdiet.custom.service.impl;
import java.math.BigDecimal;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.HealthyUtils;
import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
import com.stdiet.custom.domain.SysFoodHeatStatistics;
import com.stdiet.custom.dto.response.NutritionalCalories;
import com.stdiet.custom.service.ISysCustomerHealthyService;
import com.stdiet.custom.service.ISysCustomerPhysicalSignsService;
import com.stdiet.custom.service.ISysFoodHeatStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysCustomerHeatStatisticsMapper;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.service.ISysCustomerHeatStatisticsService;
import org.springframework.transaction.annotation.Transactional;
/**
* 外食热量统计Service业务层处理
*
* @author xzj
* @date 2021-02-20
*/
@Service
@Transactional
public class SysCustomerHeatStatisticsServiceImpl implements ISysCustomerHeatStatisticsService
{
@Autowired
private SysCustomerHeatStatisticsMapper sysCustomerHeatStatisticsMapper;
@Autowired
private ISysFoodHeatStatisticsService sysFoodHeatStatisticsService;
@Autowired
private ISysCustomerPhysicalSignsService sysCustomerPhysicalSignsService;
@Autowired
private ISysCustomerHealthyService sysCustomerHealthyService;
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
@Override
public SysCustomerHeatStatistics selectSysCustomerHeatStatisticsById(Long id)
{
return sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsById(id);
}
/**
* 查询外食热量统计列表
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 外食热量统计
*/
@Override
public List<SysCustomerHeatStatistics> selectSysCustomerHeatStatisticsList(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
return sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsList(sysCustomerHeatStatistics);
}
/**
* 新增外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
@Override
public int insertSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
sysCustomerHeatStatistics.setCreateTime(DateUtils.getNowDate());
return sysCustomerHeatStatisticsMapper.insertSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
/**
* 修改外食热量统计
*
* @param sysCustomerHeatStatistics 外食热量统计
* @return 结果
*/
@Override
public int updateSysCustomerHeatStatistics(SysCustomerHeatStatistics sysCustomerHeatStatistics)
{
sysCustomerHeatStatistics.setUpdateTime(DateUtils.getNowDate());
return sysCustomerHeatStatisticsMapper.updateSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的外食热量统计ID
* @return 结果
*/
@Override
public int deleteSysCustomerHeatStatisticsByIds(Long[] ids)
{
return sysCustomerHeatStatisticsMapper.deleteSysCustomerHeatStatisticsByIds(ids);
}
/**
* 删除外食热量统计信息
*
* @param id 外食热量统计ID
* @return 结果
*/
@Override
public int deleteSysCustomerHeatStatisticsById(Long id)
{
return sysCustomerHeatStatisticsMapper.deleteSysCustomerHeatStatisticsById(id);
}
/**
* 根据日期查询是否客户热量统计
* @param sysCustomerHeatStatistics
* @return
*/
public SysCustomerHeatStatistics getCustomerHeatStatisticsByDate(SysCustomerHeatStatistics sysCustomerHeatStatistics){
return sysCustomerHeatStatisticsMapper.getCustomerHeatStatisticsByDate(sysCustomerHeatStatistics);
}
/**
* 更新食材热量并计算当天总热量
* @param sysCustomerHeatStatistics
* @return
*/
@Override
public int calculateCustomerHeat(SysCustomerHeatStatistics sysCustomerHeatStatistics){
Long[] foodHeatId = sysCustomerHeatStatistics.getFoodHeatIdList();
Integer[] foodHeat = sysCustomerHeatStatistics.getFoodHeatList();
if(foodHeatId != null && foodHeatId.length > 0){
SysFoodHeatStatistics sysFoodHeatStatistics = new SysFoodHeatStatistics();
int totalHeatCalue = 0;
for (int i = 0; i < foodHeatId.length; i++) {
sysFoodHeatStatistics.setId(foodHeatId[i]);
sysFoodHeatStatistics.setProteinQuality(sysCustomerHeatStatistics.getProteinQualityList()[i]);
sysFoodHeatStatistics.setFatQuality(sysCustomerHeatStatistics.getFatQualityList()[i]);
sysFoodHeatStatistics.setCarbonWaterQuality(sysCustomerHeatStatistics.getCarbonWaterQualityList()[i]);
//根据蛋白质脂肪碳水计算热量
sysFoodHeatStatistics.setHeatValue(HealthyUtils.calculateTotalHeatByProteinFatCarbonWater(sysCustomerHeatStatistics.getProteinQualityList()[i],
sysCustomerHeatStatistics.getFatQualityList()[i], sysCustomerHeatStatistics.getCarbonWaterQualityList()[i]));
sysFoodHeatStatisticsService.updateSysFoodHeatStatistics(sysFoodHeatStatistics);
totalHeatCalue += sysFoodHeatStatistics.getHeatValue();
}
sysCustomerHeatStatistics.setHeatValue(totalHeatCalue);
sysCustomerHeatStatistics.setHeatGap(sysCustomerHeatStatistics.getMaxHeatValue() - totalHeatCalue);
return sysCustomerHeatStatisticsMapper.updateSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}
return 0;
}
/**
* 根据客户热量食材统计ID查询详情
* @param id
* @return
*/
public NutritionalCalories getNutritionalCaloriesByCustomer(Long id){
NutritionalCalories nutritionalCalories = new NutritionalCalories();
SysCustomerHeatStatistics sysCustomerHeatStatistics = sysCustomerHeatStatisticsMapper.selectSysCustomerHeatStatisticsById(id);
if(sysCustomerHeatStatistics != null){
SysCustomerHealthy sysCustomerHealthy = getSysCustomerHealthy(sysCustomerHeatStatistics.getCustomerId());
if(sysCustomerHealthy != null){
nutritionalCalories.setName(sysCustomerHealthy.getName());
nutritionalCalories.setAge(sysCustomerHealthy.getAge().intValue());
nutritionalCalories.setTall(sysCustomerHealthy.getTall());
nutritionalCalories.setWeight(sysCustomerHealthy.getWeight().doubleValue());
nutritionalCalories.setStandardWeight(HealthyUtils.calculateStandardWeight(nutritionalCalories.getTall()));
double overHeight = nutritionalCalories.getWeight() - nutritionalCalories.getStandardWeight();
overHeight = overHeight > 0 ? overHeight : 0;
nutritionalCalories.setOverWeight(overHeight);
nutritionalCalories.setMetabolizeHeat(HealthyUtils.calculateMetabolizeHeat(nutritionalCalories.getAge(), nutritionalCalories.getTall(), nutritionalCalories.getWeight()).intValue());
nutritionalCalories.setMaxIntakeHeat(sysCustomerHeatStatistics.getMaxHeatValue());
nutritionalCalories.setEveryWeightHeat(HealthyUtils.calculateHeatRateByWeight(nutritionalCalories.getMetabolizeHeat(), nutritionalCalories.getWeight()));
nutritionalCalories.setTargetEveryWeightHeat(HealthyUtils.calculateHeatTargetRate(nutritionalCalories.getEveryWeightHeat()));
//nutritionalCalories.setStandardEveryWeightHeat(HealthyUtils.calculateHeatTargetRate() );
nutritionalCalories.setNutritionalRate(HealthyUtils.nutritionRate);
Integer[][] nutritionalHeatAndQuality = HealthyUtils.calculateNutritionHeatAndQuality(nutritionalCalories.getMetabolizeHeat());
nutritionalCalories.setNutritionalHeat(nutritionalHeatAndQuality[0]);
nutritionalCalories.setNutritionalQuality(nutritionalHeatAndQuality[1]);
}
}
return nutritionalCalories;
}
/**
* 根据用户ID查询该用户每天最大摄入量
* @param customerId
* @return
*/
private SysCustomerHealthy getSysCustomerHealthy(Long customerId){
SysCustomerHealthy sysCustomerHealthy = sysCustomerHealthyService.selectSysCustomerHealthyByCustomerId(customerId);
if(sysCustomerHealthy != null){
return sysCustomerHealthy;
}
//查询体征信息
SysCustomerPhysicalSigns sysCustomerPhysicalSigns = sysCustomerPhysicalSignsService.selectSysCustomerPhysicalSignsByCusId(customerId);
if(sysCustomerPhysicalSigns != null){
sysCustomerHealthy = new SysCustomerHealthy();
sysCustomerHealthy.setName(sysCustomerPhysicalSigns.getName());
sysCustomerHealthy.setTall(sysCustomerPhysicalSigns.getTall());
sysCustomerHealthy.setAge(sysCustomerPhysicalSigns.getAge().longValue());
sysCustomerHealthy.setWeight(BigDecimal.valueOf(sysCustomerPhysicalSigns.getWeight()));
}
return sysCustomerHealthy;
}
}

View File

@ -0,0 +1,194 @@
package com.stdiet.custom.service.impl;
import java.util.*;
import com.alibaba.fastjson.JSON;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.HealthyUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.common.utils.sign.AesUtils;
import com.stdiet.custom.domain.SysCustomerHealthy;
import com.stdiet.custom.domain.SysCustomerHeatStatistics;
import com.stdiet.custom.domain.SysCustomerPhysicalSigns;
import com.stdiet.custom.dto.request.FoodHeatCalculatorRequest;
import com.stdiet.custom.service.ISysCustomerHealthyService;
import com.stdiet.custom.service.ISysCustomerHeatStatisticsService;
import com.stdiet.custom.service.ISysCustomerPhysicalSignsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysFoodHeatStatisticsMapper;
import com.stdiet.custom.domain.SysFoodHeatStatistics;
import com.stdiet.custom.service.ISysFoodHeatStatisticsService;
import org.springframework.transaction.annotation.Transactional;
import javax.xml.crypto.Data;
/**
* 外食热量统计Service业务层处理
*
* @author xzj
* @date 2021-02-19
*/
@Service
@Transactional
public class SysFoodHeatStatisticsServiceImpl implements ISysFoodHeatStatisticsService
{
@Autowired
private SysFoodHeatStatisticsMapper sysFoodHeatStatisticsMapper;
@Autowired
private ISysCustomerHeatStatisticsService sysCustomerHeatStatisticsService;
@Autowired
private ISysCustomerPhysicalSignsService sysCustomerPhysicalSignsService;
@Autowired
private ISysCustomerHealthyService sysCustomerHealthyService;
/**
* 查询外食热量统计
*
* @param id 外食热量统计ID
* @return 外食热量统计
*/
@Override
public SysFoodHeatStatistics selectSysFoodHeatStatisticsById(Long id)
{
return sysFoodHeatStatisticsMapper.selectSysFoodHeatStatisticsById(id);
}
/**
* 查询外食热量统计列表
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 外食热量统计
*/
@Override
public List<SysFoodHeatStatistics> selectSysFoodHeatStatisticsList(SysFoodHeatStatistics sysFoodHeatStatistics)
{
return sysFoodHeatStatisticsMapper.selectSysFoodHeatStatisticsList(sysFoodHeatStatistics);
}
/**
* 新增外食热量统计
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 结果
*/
@Override
public int insertSysFoodHeatStatistics(SysFoodHeatStatistics sysFoodHeatStatistics)
{
sysFoodHeatStatistics.setCreateTime(DateUtils.getNowDate());
return sysFoodHeatStatisticsMapper.insertSysFoodHeatStatistics(sysFoodHeatStatistics);
}
/**
* 修改外食热量统计
*
* @param sysFoodHeatStatistics 外食热量统计
* @return 结果
*/
@Override
public int updateSysFoodHeatStatistics(SysFoodHeatStatistics sysFoodHeatStatistics)
{
sysFoodHeatStatistics.setUpdateTime(DateUtils.getNowDate());
return sysFoodHeatStatisticsMapper.updateSysFoodHeatStatistics(sysFoodHeatStatistics);
}
/**
* 批量删除外食热量统计
*
* @param ids 需要删除的外食热量统计ID
* @return 结果
*/
@Override
public int deleteSysFoodHeatStatisticsByIds(Long[] ids)
{
return sysFoodHeatStatisticsMapper.deleteSysFoodHeatStatisticsByIds(ids);
}
/**
* 删除外食热量统计信息
*
* @param id 外食热量统计ID
* @return 结果
*/
@Override
public int deleteSysFoodHeatStatisticsById(Long id)
{
return sysFoodHeatStatisticsMapper.deleteSysFoodHeatStatisticsById(id);
}
/**
* 客户自己添加外食计算数据批量添加
* @param foodHeatCalculatorRequest
* @return
*/
@Override
public int addMuchFoodHeat(FoodHeatCalculatorRequest foodHeatCalculatorRequest){
//客户ID解密
String customerId = StringUtils.isNotEmpty(foodHeatCalculatorRequest.getCustomerEncId()) ? AesUtils.decrypt(foodHeatCalculatorRequest.getCustomerEncId(), null) : "";
if(StringUtils.isEmpty(customerId) || StringUtils.isEmpty(foodHeatCalculatorRequest.getIngredientArray())){
return 0;
}
List<HashMap> foodHeatList = JSON.parseArray(foodHeatCalculatorRequest.getIngredientArray(), HashMap.class);
if(foodHeatList == null || foodHeatList.size() == 0){
return 0;
}
Map<String, List<HashMap>> dateFoodMap = new HashMap<>();
//根据日期分类
for(HashMap map : foodHeatList){
String edibleDate = map.get("edibleDate").toString();
if(dateFoodMap.containsKey(edibleDate)){
dateFoodMap.get(edibleDate).add(map);
}else{
List<HashMap> list = new ArrayList<>();
list.add(map);
dateFoodMap.put(edibleDate, list);
}
}
int row = 0;
int maxHeatValue = getMaxHeatValue(Long.parseLong(customerId)).intValue();
for (String dateKey : dateFoodMap.keySet()) {
//先判断该日期下是否已存在
SysCustomerHeatStatistics sysCustomerHeatStatistics = new SysCustomerHeatStatistics();
sysCustomerHeatStatistics.setCustomerId(Long.parseLong(customerId));
sysCustomerHeatStatistics.setEdibleDate(DateUtils.parseDate(dateKey));
SysCustomerHeatStatistics customerHeatResult = sysCustomerHeatStatisticsService.getCustomerHeatStatisticsByDate(sysCustomerHeatStatistics);
if(customerHeatResult == null){
sysCustomerHeatStatistics.setMaxHeatValue(maxHeatValue);
sysCustomerHeatStatisticsService.insertSysCustomerHeatStatistics(sysCustomerHeatStatistics);
}else{
sysCustomerHeatStatistics.setId(customerHeatResult.getId());
}
if(sysCustomerHeatStatistics.getId() != null){
for(HashMap map : dateFoodMap.get(dateKey)){
map.put("customerHeatId", sysCustomerHeatStatistics.getId());
map.put("number", map.get("number") != null && "".equals(map.get("number").toString().trim()) ? null : map.get("number"));
map.put("unit", map.get("unit") != null && "".equals(map.get("unit").toString().trim()) ? null : map.get("unit"));
map.put("quantity", map.get("quantity") != null && "".equals(map.get("quantity").toString().trim()) ? null : map.get("quantity"));
}
row = sysFoodHeatStatisticsMapper.insertFoodHeatBatch(dateFoodMap.get(dateKey));
}
}
return row;
}
/**
* 根据用户ID查询该用户每天最大摄入量
* @param customerId
* @return
*/
private Long getMaxHeatValue(Long customerId){
SysCustomerHealthy sysCustomerHealthy = sysCustomerHealthyService.selectSysCustomerHealthyByCustomerId(customerId);
if(sysCustomerHealthy != null){
return HealthyUtils.calculateMaxHeatEveryDay(sysCustomerHealthy.getAge().intValue(),sysCustomerHealthy.getTall(),sysCustomerHealthy.getWeight().doubleValue());
}
//查询体征信息
SysCustomerPhysicalSigns sysCustomerPhysicalSigns = sysCustomerPhysicalSignsService.selectSysCustomerPhysicalSignsByCusId(customerId);
if(sysCustomerPhysicalSigns != null){
return HealthyUtils.calculateMaxHeatEveryDay(sysCustomerPhysicalSigns.getAge().intValue(),sysCustomerPhysicalSigns.getTall(),sysCustomerPhysicalSigns.getWeight().doubleValue());
}
return 0L;
}
}

View File

@ -0,0 +1,147 @@
<?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.SysCustomerHeatStatisticsMapper">
<resultMap type="SysCustomerHeatStatistics" id="SysCustomerHeatStatisticsResult">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="edibleDate" column="edible_date" />
<result property="maxHeatValue" column="max_heat_value" />
<result property="heatValue" column="heat_value" />
<result property="heatGap" column="heat_gap" />
<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 type="SysCustomerHeatStatistics" id="SysCustomerHeatStatisticsResultExtended">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="edibleDate" column="edible_date" />
<result property="maxHeatValue" column="max_heat_value" />
<result property="heatValue" column="heat_value" />
<result property="heatGap" column="heat_gap" />
<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" />
<!-- column是传的参数, select是调用的查询 -->
<association property="foodHeatStatisticsList" column="id" select="selectSysFoodHeatStatisticsList"/>
</resultMap>
<sql id="selectSysCustomerHeatStatisticsVo">
select id, customer_id, edible_date, max_heat_value, heat_value, heat_gap, create_time, create_by, update_time, update_by, del_flag from sys_customer_heat_statistics
</sql>
<select id="selectSysCustomerHeatStatisticsList" parameterType="SysCustomerHeatStatistics" resultMap="SysCustomerHeatStatisticsResult">
<include refid="selectSysCustomerHeatStatisticsVo"/>
<where>
<if test="customerId != null "> and customer_id = #{customerId}</if>
</where>
order by id desc
</select>
<select id="selectSysCustomerHeatStatisticsById" parameterType="Long" resultMap="SysCustomerHeatStatisticsResultExtended">
<include refid="selectSysCustomerHeatStatisticsVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysCustomerHeatStatistics" parameterType="SysCustomerHeatStatistics" useGeneratedKeys="true" keyProperty="id">
insert into sys_customer_heat_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null">customer_id,</if>
<if test="edibleDate != null">edible_date,</if>
<if test="maxHeatValue != null">max_heat_value,</if>
<if test="heatValue != null">heat_value,</if>
<if test="heatGap != null">heat_gap,</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="customerId != null">#{customerId},</if>
<if test="edibleDate != null">#{edibleDate},</if>
<if test="maxHeatValue != null">#{maxHeatValue},</if>
<if test="heatValue != null">#{heatValue},</if>
<if test="heatGap != null">#{heatGap},</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="updateSysCustomerHeatStatistics" parameterType="SysCustomerHeatStatistics">
update sys_customer_heat_statistics
<trim prefix="SET" suffixOverrides=",">
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="edibleDate != null">edible_date = #{edibleDate},</if>
<if test="maxHeatValue != null">max_heat_value = #{maxHeatValue},</if>
<if test="heatValue != null">heat_value = #{heatValue},</if>
<if test="heatGap != null">heat_gap = #{heatGap},</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="deleteSysCustomerHeatStatisticsById" parameterType="Long">
update sys_customer_heat_statistics set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysCustomerHeatStatisticsByIds" parameterType="String">
update sys_customer_heat_statistics set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 根据日期、客户ID查询是否存在热量统计 -->
<select id="getCustomerHeatStatisticsByDate" parameterType="SysCustomerHeatStatistics" resultMap="SysCustomerHeatStatisticsResult">
select id from sys_customer_heat_statistics where del_flag = 0 and customer_id = #{customerId}
<if test="edibleDate != null">and date_format(edible_date,'%y%m%d') = date_format(#{edibleDate},'%y%m%d')</if>
limit 1
</select>
<resultMap type="SysFoodHeatStatistics" id="SysFoodHeatStatisticsResult">
<result property="id" column="id" />
<result property="customerHeatId" column="customer_heat_id" />
<result property="ingredient" column="ingredient" />
<result property="unit" column="unit" />
<result property="number" column="number" />
<result property="quantity" column="quantity" />
<result property="edibleType" column="edible_type" />
<result property="proteinQuality" column="protein_quality" />
<result property="heatValue" column="heat_value" />
<result property="fatQuality" column="fat_quality" />
<result property="carbonWaterQuality" column="carbon_water_quality" />
<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" />
<result property="unitName" column="unitName"></result>
</resultMap>
<select id="selectSysFoodHeatStatisticsList" parameterType="Long" resultMap="SysFoodHeatStatisticsResult">
select sfhs.id, sfhs.customer_heat_id, sfhs.ingredient, sfhs.unit, sfhs.number, sfhs.quantity, sfhs.edible_type, sfhs.protein_quality, sfhs.fat_quality, sfhs.carbon_water_quality,sfhs.heat_value,cusUnit.dict_label as unitName
from sys_food_heat_statistics as sfhs
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_cus_unit') AS cusUnit ON cusUnit.dict_value = sfhs.unit
where sfhs.del_flag = 0 and customer_heat_id = #{id}
</select>
</mapper>

View File

@ -0,0 +1,122 @@
<?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.SysFoodHeatStatisticsMapper">
<resultMap type="SysFoodHeatStatistics" id="SysFoodHeatStatisticsResult">
<result property="id" column="id" />
<result property="customerHeatId" column="customer_heat_id" />
<result property="ingredient" column="ingredient" />
<result property="unit" column="unit" />
<result property="number" column="number" />
<result property="quantity" column="quantity" />
<result property="edibleType" column="edible_type" />
<result property="proteinQuality" column="protein_quality" />
<result property="heatValue" column="heat_value" />
<result property="fatQuality" column="fat_quality" />
<result property="carbonWaterQuality" column="carbon_water_quality" />
<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" />
<result property="unitName" column="unitName"></result>
</resultMap>
<sql id="selectSysFoodHeatStatisticsVo">
select id, customer_heat_id, ingredient, unit, number, quantity, edible_type, protein_quality, heat_value, fat_quality, carbon_water_quality,create_time, create_by, update_time, update_by, del_flag from sys_food_heat_statistics
</sql>
<select id="selectSysFoodHeatStatisticsList" parameterType="SysFoodHeatStatistics" resultMap="SysFoodHeatStatisticsResult">
select sfhs.id, sfhs.customer_heat_id, sfhs.ingredient, sfhs.unit, sfhs.number, sfhs.quantity, sfhs.edible_type, sfhs.protein_quality, sfhs.fat_quality, sfhs.carbon_water_quality,sfhs.heat_value,cusUnit.dict_label as unitName
from sys_food_heat_statistics as sfhs
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_cus_unit') AS cusUnit ON cusUnit.dict_value = sfhs.unit
where sfhs.del_flag = 0
</select>
<select id="selectSysFoodHeatStatisticsById" parameterType="Long" resultMap="SysFoodHeatStatisticsResult">
<include refid="selectSysFoodHeatStatisticsVo"/>
where id = #{id} and del_flag = 0
</select>
<insert id="insertSysFoodHeatStatistics" parameterType="SysFoodHeatStatistics" useGeneratedKeys="true" keyProperty="id">
insert into sys_food_heat_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerHeatId != null">customer_heat_id,</if>
<if test="ingredient != null">ingredient,</if>
<if test="unit != null">unit,</if>
<if test="number != null">number,</if>
<if test="quantity != null">quantity,</if>
<if test="edibleType != null">edible_type,</if>
<if test="proteinQuality != null">protein_quality,</if>
<if test="heatValue != null">heat_value,</if>
<if test="fatQuality != null">fat_quality,</if>
<if test="carbonWaterQuality != null">carbon_water_quality,</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="customerHeatId != null">#{customerHeatId},</if>
<if test="ingredient != null">#{ingredient},</if>
<if test="unit != null">#{unit},</if>
<if test="number != null">#{number},</if>
<if test="quantity != null">#{quantity},</if>
<if test="edibleType != null">#{edibleType},</if>
<if test="proteinQuality != null">#{proteinQuality},</if>
<if test="heatValue != null">#{heatValue},</if>
<if test="fatQuality != null">#{fatQuality},</if>
<if test="carbonWaterQuality != null">#{carbonWaterQuality},</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="updateSysFoodHeatStatistics" parameterType="SysFoodHeatStatistics">
update sys_food_heat_statistics
<trim prefix="SET" suffixOverrides=",">
<if test="customerHeatId != null">customer_heat_id = #{customerHeatId},</if>
<if test="ingredient != null">ingredient = #{ingredient},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="number != null">number = #{number},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="edibleType != null">edible_type = #{edibleType},</if>
<if test="proteinQuality != null">protein_quality = #{proteinQuality},</if>
<if test="heatValue != null">heat_value = #{heatValue},</if>
<if test="fatQuality != null">fat_quality = #{fatQuality},</if>
<if test="carbonWaterQuality != null">carbon_water_quality = #{carbonWaterQuality},</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="deleteSysFoodHeatStatisticsById" parameterType="Long">
update sys_food_heat_statistics set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysFoodHeatStatisticsByIds" parameterType="String">
update sys_food_heat_statistics set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<insert id="insertFoodHeatBatch" parameterType="java.util.List">
insert into sys_food_heat_statistics(customer_heat_id,ingredient,unit,number,quantity) values
<foreach collection ="list" item="food" index= "index" separator =",">
(#{food.customerHeatId}, #{food.ingredient},#{food.unit},#{food.number},#{food.quantity})
</foreach >
</insert>
</mapper>

View File

@ -18,7 +18,8 @@
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" /> <result property="delFlag" column="del_flag" />
<!-- 非持久化字段 --> <!-- 非持久化字段 -->
<result property="customer" column="customer" /> <result property="customerId" column="cus_id"></result><!-- 客户ID -->
<result property="customer" column="customer" /><!-- 客户姓名 -->
<result property="phone" column="phone" /> <result property="phone" column="phone" />
<result property="orderStartDate" column="order_start_date" /> <result property="orderStartDate" column="order_start_date" />
<result property="orderEndDate" column="order_end_date" /> <result property="orderEndDate" column="order_end_date" />
@ -126,7 +127,7 @@
<!-- 食谱计划、订单表联查 --> <!-- 食谱计划、订单表联查 -->
<select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult"> <select id="selectPlanListByCondition" parameterType="SysRecipesPlan" resultMap="SysRecipesPlanResult">
SELECT srp.id,srp.order_id,srp.recipes_id, sr.customer,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time SELECT srp.id,srp.order_id,srp.recipes_id,sr.customer,sr.cus_id,sr.phone,su_nutritionist.nick_name nutritionist,su_nutritionist_assis.nick_name AS nutritionist_assis,sr.start_time,sr.server_end_time, srp.start_date,srp.end_date,srp.send_flag,srp.send_time
FROM sys_recipes_plan srp FROM sys_recipes_plan srp
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0 LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0

View File

@ -44,6 +44,7 @@
<include refid="selectSysWxFanStatisticsVoExtended"/> where swfs.del_flag = 0 <include refid="selectSysWxFanStatisticsVoExtended"/> where swfs.del_flag = 0
<if test="fanTime != null ">and swfs.fan_time = #{fanTime}</if> <if test="fanTime != null ">and swfs.fan_time = #{fanTime}</if>
<if test="userId != null">and su.user_id = #{userId}</if> <if test="userId != null">and su.user_id = #{userId}</if>
<if test="accountId != null">and swd.account_id = #{accountId}</if>
<if test="sortFlag == null or sortFlag == 0"> <if test="sortFlag == null or sortFlag == 0">
order by swfs.id desc order by swfs.id desc
</if> </if>

View File

@ -43,3 +43,12 @@ export function getCustomerBaseMessage(id) {
}) })
} }
// 新增客户外食热量计算统计
export function addFoodHeatStatistics(data) {
return request({
url: '/investigate/addFoodHeatStatistics',
method: 'post',
data: data
})
}

View File

@ -0,0 +1,63 @@
import request from '@/utils/request'
// 查询外食热量统计列表
export function listFoodHeatStatistics(query) {
return request({
url: '/custom/foodHeatStatistics/list',
method: 'get',
params: query
})
}
// 查询外食热量统计详细
export function getFoodHeatStatistics(id) {
return request({
url: '/custom/foodHeatStatistics/' + id,
method: 'get'
})
}
// 新增外食热量统计
export function addFoodHeatStatistics(data) {
return request({
url: '/custom/foodHeatStatistics',
method: 'post',
data: data
})
}
// 修改外食热量统计
export function updateFoodHeatStatistics(data) {
return request({
url: '/custom/foodHeatStatistics',
method: 'put',
data: data
})
}
// 删除外食热量统计
export function delFoodHeatStatistics(id) {
return request({
url: '/custom/foodHeatStatistics/' + id,
method: 'delete'
})
}
// 导出外食热量统计
export function exportFoodHeatStatistics(query) {
return request({
url: '/custom/foodHeatStatistics/export',
method: 'get',
params: query
})
}
// 新增外食热量统计
export function addFoodHeatData(data) {
return request({
url: '/custom/foodHeatStatistics/addFoodHeatData',
method: 'post',
data: data
})
}

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="autohideinfo_wrapper"> <div class="autohideinfo_wrapper">
<div> <div>
{{ data.substring(0,maxLength) }}<span v-if="data.length > maxLength">...</span> {{ data ? data.substring(0,maxLength) : ""}}<span v-if="data && data.length > maxLength">...</span>
</div> </div>
<div v-if="data.length > maxLength"> <div v-if="data && data.length > maxLength">
<!--<div>...</div>--> <!--<div>...</div>-->
<el-popover placement="top-start" width="300" height="400px" popper-class="autohideinfo_detial" trigger="hover"> <el-popover placement="top-start" width="300" height="400px" popper-class="autohideinfo_detial" trigger="hover">
<div>{{ data }}</div> <div>{{ data }}</div>

View File

@ -0,0 +1,134 @@
<template>
<!-- 计算食材热量对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
<el-form ref="form" :model="form" label-position="top" :rules="rules" label-width="100px">
<el-form-item v-for="(item,index) in foodHeatList" label="" class="margin-left">
<div>
<span>食材名称</span><el-input style="width:20%" placeholder="" :readonly="true" :value="item.ingredient"/>
<span style="margin-left: 10px">份量</span><el-input style="width:20%" placeholder="" :readonly="true" :value="getNumberString(item)"/>
<!--<span style="margin-left: 10px">热量</span><el-input style="width:15%" type="number" placeholder="" v-model="item.heatValue"/><span>千卡</span>-->
<span style="margin-left: 10px">蛋白质/脂肪/碳水</span>
<el-input style="width:10%" placeholder="" v-model="item.proteinQuality"/>
<el-input style="width:10%;margin-left: 5px" placeholder="" v-model="item.fatQuality"/>
<el-input style="width:10%;margin-left: 5px" placeholder="" v-model="item.carbonWaterQuality"/>
<span style="margin-left: 5px"></span>
</div>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getFoodHeatStatistics,addFoodHeatData } from "@/api/custom/foodHeatStatistics";
import {getOptions} from "@/api/custom/order";
export default {
name: "index",
components: {
},
props: {},
data() {
return {
//
title: "",
//
open: false,
callback: undefined,
//
form: {},
//
rules: {
projectId:[
{required: true, message: "请选择调理项目", trigger: "blur"}
]
},
heatData: null,
foodHeatList: []
};
},
created() {
},
methods: {
showDialog(data, callback) {
this.callback = callback;
this.reset(data);
this.title = "计算"+`${data.edibleDate}」食材热量`;
this.open = true;
this.getFoodHeatList(data.id);
},
getFoodHeatList(id){
getFoodHeatStatistics(id).then((response) => {
//let contractDetail = response.data;
this.heatData = response.data;
this.foodHeatList = response.data.foodHeatStatisticsList != null ? response.data.foodHeatStatisticsList : [];
});
},
getNumberString(foodData){
let numberString = "";
if(foodData.number){
numberString += foodData.number + foodData.unitName;
}
if(foodData.quantity){
numberString += (numberString != "" ? "/" : "" ) + foodData.quantity + "克";
}
return numberString;
},
//
reset(obj) {
this.heatData = null;
this.foodHeatList = [];
this.resetForm("form");
},
//
cancel() {
this.open = false;
},
/** 提交按钮 */
submitForm() {
var reg = /^([1-9]\d*|[0]{1,1})$/;
if(this.foodHeatList.length == 0){
return;
}
let obj = {};
obj.id = this.heatData.id;
obj.customerId = this.heatData.customerId;
obj.maxHeatValue = this.heatData.maxHeatValue;
obj.foodHeatIdList = [];
obj.proteinQualityList = [];
obj.fatQualityList = [];
obj.carbonWaterQualityList = [];
let verifyFlag = true;
this.foodHeatList.forEach((item,index) => {
obj.foodHeatIdList.push(item.id);
if(!reg.test(item.proteinQuality) || !reg.test(item.fatQuality) || !reg.test(item.carbonWaterQuality)){
verifyFlag = false;
}else{
obj.proteinQualityList.push(item.proteinQuality);
obj.fatQualityList.push(item.fatQuality);
obj.carbonWaterQualityList.push(item.carbonWaterQuality);
}
});
if(!verifyFlag){
this.$message({message: "填写的数值格式错误", type: "warning"});
return;
}
//console.log(obj.foodHeatIdList.length);
addFoodHeatData(obj).then(response => {
if (response.code === 200) {
this.msgSuccess("提交成功");
this.open = false;
this.callback && this.callback();
}
});
}
}
};
</script>

View File

@ -0,0 +1,163 @@
<template>
<div>
<el-drawer
:title="title"
:close-on-press-escape="false"
:visible.sync="visible"
@closed="handleOnClosed"
size="40%"
>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button icon="el-icon-share" size="small" title="点击复制链接" class="copyBtn" type="primary" :data-clipboard-text="copyValue" @click="handleCopy()">外食计算器</el-button>
</el-col>
</el-row>
<el-table :data="foodHeatStatisticsList" >
<el-table-column label="日期" align="center" prop="edibleDate" width="120">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.edibleDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="食材" align="center" prop="ingredient" />
<el-table-column label="通俗计量" align="center" prop="unitName">
<template slot-scope="scope">
{{ scope.row.number ? (scope.row.number + "" + (scope.row.unitName != null ? scope.row.unitName : "")) : "" }}
</template>
</el-table-column>
<el-table-column label="质量(克)" align="center" prop="quantity" />-->
<el-table-column label="可摄入量" align="center" prop="maxHeatValue" />
<el-table-column label="食材热量" align="center" prop="heatValue" />
<el-table-column label="热量缺口" align="center" prop="heatGap" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!--<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['custom:foodHeatStatistics:edit']"
>修改</el-button>-->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleCalculate(scope.row)"
>计算</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleOnDeleteClick(scope.row)"
v-hasPermi="['custom:foodHeatStatistics:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="fetchHeatList"
/>
<heatStatisticsCalculate ref="heatStatisticsCalculateRef"></heatStatisticsCalculate>
</div>
</el-drawer>
</div>
</template>
<script>
import { listFoodHeatStatistics, getFoodHeatStatistics, delFoodHeatStatistics, addFoodHeatStatistics, updateFoodHeatStatistics, exportFoodHeatStatistics } from "@/api/custom/foodHeatStatistics";
import Clipboard from 'clipboard';
import HeatStatisticsCalculate from "@/components/HeatStatisticsCalculate";
export default {
name: "HeatStatisticsDrawer",
components: {
'heatStatisticsCalculate':HeatStatisticsCalculate
},
data() {
return {
visible: false,
title: "",
data: undefined,
foodHeatStatisticsList: [],
total: 0,
//
queryParams: {
customerId: null,
pageNum: 1,
pageSize: 10,
},
copyValue: ""
};
},
methods: {
showDrawer(data) {
// console.log(data);
this.data = data;
if (!this.data) {
return;
}
this.title = `${this.data.name}」热量统计列表`;
this.queryParams.customerId = data.id;
this.fetchHeatList();
},
fetchHeatList() {
listFoodHeatStatistics(this.queryParams).then(response => {
this.foodHeatStatisticsList = response.rows;
this.total = response.total;
this.visible = true;
});
},
handleAdd() {
},
handleOnClosed() {
this.data = undefined;
this.copyValue = "";
},
handleOnDeleteClick(data) {
const ids = data.id || this.ids;
this.$confirm(
'是否确认删除该数据项?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
)
.then(function () {
return delFoodHeatStatistics(ids);
})
.then(() => {
this.fetchHeatList();
this.msgSuccess("删除成功");
})
.catch(function () {});
},
handleCopy() {
this.copyValue = window.location.origin.replace('manage', 'sign') + "/foodHeatCalculator/"+this.data.encId;
const btnCopy = new Clipboard('.copyBtn');
this.$message({
message: '拷贝成功',
type: 'success'
});
},
handleCalculate(data){
this.$refs.heatStatisticsCalculateRef.showDialog(data,() => {
this.fetchHeatList();
});
}
},
};
</script>
<style lang="scss" scoped>
/deep/ :focus {
outline: 0;
}
</style>

View File

@ -0,0 +1,679 @@
<template>
<el-dialog
:title="title"
:visible.sync="visible"
width="820px"
append-to-body
:close-on-click-modal="false"
@closed="handleOnClosed"
>
<el-row :gutter="15">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-col :span="12">
<el-form-item label="订单类型" prop="orderType">
<el-cascader
v-model="form.orderType"
:options="orderTypeOptions"
style="width: 100%">
</el-cascader>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="自动创建售后提成订单" prop="secondAfterSaleFlag" label-width="200px">
<el-select v-model="form.secondAfterSaleFlag" :disabled="secondAfterSaleFlagShow" style="width: 100px" placeholder="请选择">
<el-option :key="0" label="否" :value="0"/>
<el-option :key="1" label="是" :value="1"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="成交金额" prop="amount">
<el-input v-model="form.amount" placeholder="请输入金额" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="收款方式" prop="payTypeId">
<el-select v-model="form.payTypeId" placeholder="请选择">
<el-option
v-for="dict in payTypeIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="收款账号" prop="accountId">
<el-select v-model="form.accountId" placeholder="请选择">
<el-option
v-for="dict in accountIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="服务时长" prop="serveTime">
<el-select v-model="form.serveTimeId" placeholder="请选服">
<el-option
v-for="dict in serveTimeIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="赠送时长" prop="serveTime">
<el-select v-model="form.giveServeDay" placeholder="请选择">
<el-option
v-for="dict in giveTimeIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="调理项目" prop="conditioningProjectId">
<el-select
v-model="form.conditioningProjectId"
placeholder="请选择"
>
<el-option
v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="售前" prop="preSaleId">
<el-select v-model="form.preSaleId" placeholder="请选择">
<el-option
v-for="dict in preSaleIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="售后" prop="afterSaleId">
<el-select v-model="form.afterSaleId" placeholder="请选择">
<el-option
v-for="dict in afterSaleIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="主营养师" prop="nutritionistIdList">
<el-select v-model="form.nutritionistIdList" multiple placeholder="请选择">
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="拆分比例" prop="nutritionistRate">
<el-select v-model="form.nutritionistRate" :disabled="orderRateOptionsShow" placeholder="请选择" >
<el-option
v-for="dict in orderRateOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="助理营养师" prop="nutriAssisId">
<el-select v-model="form.nutriAssisId" placeholder="请选择">
<el-option
v-for="dict in nutriAssisIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="策划" prop="plannerId">
<el-select v-model="form.plannerId" placeholder="请选择">
<el-option
v-for="dict in plannerIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="策划助理" prop="plannerAssisId">
<el-select v-model="form.plannerAssisId" placeholder="请选择">
<el-option
v-for="dict in plannerAssisIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="运营" prop="operatorId">
<el-select v-model="form.operatorId" placeholder="请选择">
<el-option
v-for="dict in operatorIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="运营助理" prop="operatorAssisId">
<el-select v-model="form.operatorAssisId" placeholder="请选择">
<el-option
v-for="dict in operatorAssisIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="推荐人" prop="recommender">
<el-input v-model="form.recommender" placeholder="请输入推荐人" />
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="成交时间" prop="orderTime">
<el-date-picker
style="width: 182.5px"
v-model="form.orderTime"
type="datetime"
placeholder="选择成交时间"
format="yyyy-MM-dd HH:mm"
value-format="yyyy-MM-dd HH:mm:ss"
:picker-options="orderPickerOptions"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="服务开始时间" prop="startTime" label-width="120">
<el-date-picker
style="width: 182.5px"
v-model="form.startTime"
type="date"
placeholder="选择开始日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10" v-hasPermi="['custom:order:review']">
<el-form-item label="审核状态" prop="reviewStatus">
<el-select v-model="form.reviewStatus" placeholder="请选择审核状态">
<el-option
v-for="dict in reviewStatusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</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">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { addOrder, getOptions, updateOrder } from "@/api/custom/order";
import dayjs from "dayjs";
import * as orderTypeData from "@/utils/orderType";
export default {
name: "OrderEdit",
props: {
id: {
type: String,
},
},
data() {
const checkStartTime = (rule, value, callback) => {
if (!value) {
return callback(new Error("开始时间不能为空"));
}
if (!this.form.orderTime) {
return callback(new Error("请先选择成交时间"));
}
if (
dayjs(this.form.startTime).diff(dayjs(this.form.orderTime), "day") < 0
) {
return callback(new Error("开始时间不能先于成交时间"));
}
callback();
};
const checkOrderTime = (rule, value, callback) => {
if (!value) {
return callback(new Error("成交时间不能为空"));
}
callback();
};
return {
title: "",
data: undefined,
callback: undefined,
form: {},
visible: false,
//
rules: {
customer: [
{ required: true, message: "客户姓名不能为空", trigger: "blur" },
],
amount: [{ required: true, message: "金额不能为空", trigger: "blur" }],
phone: [
{ required: true, message: "手机号不能为空", trigger: "blur" },
{
required: true,
trigger: "blur",
pattern: /^[0-9]{5,11}$/,
message: "手机号格式不正确",
},
],
orderTime: [
{ required: true, message: "成交时间不能为空", trigger: "blur" },
{ required: true, trigger: "blur", validator: checkOrderTime },
],
startTime: [
{ required: true, message: "开始时间不能为空", trigger: "blur" },
{ required: true, trigger: "blur", validator: checkStartTime },
],
// payTypeId: [
// {required: true, message: "", trigger: "blur"}
// ],
// accountId: [
// {required: true, message: "", trigger: "blur"}
// ],
// serveTimeId: [
// {required: true, message: "", trigger: "blur"}
// ],
},
pickerOptions: {
shortcuts: [
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: "最近三个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit("pick", [start, end]);
},
},
],
},
orderPickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
fanPickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
startPickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now();
},
},
//
payTypeIdOptions: [],
//
preSaleIdOptions: [],
//
afterSaleIdOptions: [],
//
nutritionistIdOptions: [],
//
nutriAssisIdOptions: [],
//
plannerIdOptions: [],
//
accountIdOptions: [],
//
serveTimeIdOption: [],
//
giveTimeIdOption: [],
//
conditioningProjectIdOption: [],
//
plannerAssisIdOptions: [],
//
operatorIdOptions: [],
//
reviewStatusOptions: [],
//
operatorAssisIdOptions: [],
//()
orderDropdownCorrespondingOptions: [],
//
orderTypeOptions: orderTypeData['orderTypeArray'],
secondAfterSaleFlagShow: true,
//
orderRateOptions: orderTypeData['orderRateArray'],
orderRateOptionsShow: true
};
},
created() {
getOptions().then((res) => {
const options = res.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [
{ dictValue: 0, dictLabel: "无", remark: null },
];
}
opts[cur.postCode].push({
dictValue: cur.userId,
dictLabel: cur.userName,
remark: cur.remark,
});
return opts;
}, {});
this.preSaleIdOptions = options["pre_sale"] || [];
this.afterSaleIdOptions = options["after_sale"] || [];
this.nutritionistIdOptions = options["nutri"] || [];
this.nutriAssisIdOptions = options["nutri_assis"] || [];
this.plannerIdOptions = options["planner"] || [];
this.plannerAssisIdOptions = options["planner_assis"] || [];
this.operatorIdOptions = options["operator"] || [];
this.operatorAssisIdOptions = options["operator_assis"] || [];
});
this.getDicts("cus_pay_type").then((response) => {
this.payTypeIdOptions = response.data;
});
this.getDicts("cus_account").then((response) => {
this.accountIdOptions = response.data;
console.log(response.data);
this.accountIdOptions.splice(0, 0, {
dictLabel: "无",
dictValue: "0",
});
});
this.getDicts("cus_serve_time").then((response) => {
this.serveTimeIdOption = response.data;
});
this.getDicts("give_serve_daye_type").then((response) => {
this.giveTimeIdOption = response.data;
});
this.getDicts("conditioning_project").then((response) => {
this.conditioningProjectIdOption = response.data;
});
this.getDicts("cus_review_status").then((response) => {
this.reviewStatusOptions = response.data;
});
this.getDicts("order_dropdown_corresponding").then((response) => {
this.orderDropdownCorrespondingOptions = response.data;
});
//
/*this.getDicts("order_type").then((response) => {
//
let removeIndex = null;
response.data.forEach((item, index) => {
if(item.dictValue == "2"){
removeIndex = index;
}
});
if(removeIndex != null){
response.data.splice(removeIndex,1);
}
this.orderTypeOptions = response.data;
});*/
},
methods: {
showDialog(data, callback) {
// this.data = data;
this.callback = callback;
this.reset(data);
this.title = `${data.orderId ? "修改" : "创建"}${
data.customer
}客户订单`;
this.visible = true;
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.orderId != null) {
updateOrder(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("修改成功");
this.visible = false;
this.callback && this.callback();
}
});
} else {
addOrder(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.visible = false;
this.callback && this.callback();
}
});
}
}
});
},
reset(obj = {}) {
const defaultPayType = this.payTypeIdOptions.find(
(opt) => opt.remark === "default"
);
const defaultServeTime = this.serveTimeIdOption.find(
(opt) => opt.remark === "default"
);
const defaultGiveServeTime = this.giveTimeIdOption.find(
(opt) => opt.remark === "default"
);
const defaultConditioningProjectIdOption = this.conditioningProjectIdOption.find(
(opt) => opt.remark === "default"
);
const defaultAccount = this.accountIdOptions.find(
(opt) => opt.remark === "default"
);
const defaultPresale = this.preSaleIdOptions.find(
(opt) => opt.remark === "default"
);
const defaultAftersale = this.afterSaleIdOptions.find(
(opt) => opt.remark === "default"
);
const defaultNutritionist = this.nutritionistIdOptions.find(
(opt) => opt.remark === "default"
);
const defaultNutriAssis = this.nutriAssisIdOptions.find(
(opt) => opt.remark === "default"
);
const accountId = defaultAccount ? parseInt(defaultAccount.dictValue) : 0;
const planningAndOperationValue = this.orderDropdownCorrespondingOptions.find(
(opt) => parseInt(opt.dictValue) === accountId
);
const defaultOrderRate = this.orderRateOptions.find((opt) => opt.remark === "default");
const [
plannerId,
plannerAssisId,
operatorId,
operatorAssisId,
] = planningAndOperationValue
? planningAndOperationValue.dictLabel
.split("|")
.map((str) => parseInt(str))
: [0, 0, 0, 0];
this.form = {
orderId: null,
orderType: [0, 0, 0],
secondAfterSaleFlag: 0,
customer: null,
phone: null,
amount: null,
weight: null,
plannerId,
plannerAssisId,
operatorId,
operatorAssisId,
startTime: dayjs().add(3, "day").format("YYYY-MM-DD"),
pauseTime: null,
payTypeId: defaultPayType ? parseInt(defaultPayType.dictValue) : null,
preSaleId: defaultPresale ? parseInt(defaultPresale.dictValue) : null,
createBy: null,
createTime: null,
afterSaleId: defaultAftersale
? parseInt(defaultAftersale.dictValue)
: null,
updateBy: null,
updateTime: null,
nutritionistId: null,
nutritionistIdList: defaultNutritionist ? [parseInt(defaultNutritionist.dictValue)] : null,
nutritionistRate: defaultOrderRate ? defaultOrderRate.dictValue : null,
remark: null,
nutriAssisId: defaultNutriAssis
? parseInt(defaultNutriAssis.dictValue)
: null,
recommender: null,
orderTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
serveTimeId: defaultServeTime
? parseInt(defaultServeTime.dictValue)
: null,
reviewStatus: "no",
giveServeDay: defaultGiveServeTime
? parseInt(defaultGiveServeTime.dictValue)
: null,
conditioningProjectId: defaultConditioningProjectIdOption
? parseInt(defaultConditioningProjectIdOption.dictValue)
: null,
accountId,
...obj,
};
this.resetForm("form");
},
handleOnClosed() {
this.reset();
},
//
cancel() {
this.visible = false;
// this.reset();
},
//ID
initPlanningAndOperation() {
if (this.form.accountId != null && this.form.accountId != undefined) {
const planningAndOperationValue = this.orderDropdownCorrespondingOptions.find(
(opt) => parseInt(opt.dictValue) === this.form.accountId
);
const [
plannerId,
plannerAssisId,
operatorId,
operatorAssisId,
] = planningAndOperationValue
? planningAndOperationValue.dictLabel
.split("|")
.map((str) => parseInt(str))
: [0, 0, 0, 0];
this.form = {
...this.form,
plannerId,
plannerAssisId,
operatorId,
operatorAssisId,
};
}
},
handleOrderTypeChange(){
console.log(this.form.orderType);
}
},
watch: {
//
"form.accountId": function (newVal, oldVal) {
this.initPlanningAndOperation();
},
"form.orderType": function (newVal, oldVal) {
//
if(newVal[1] == 1){
this.form.secondAfterSaleFlag = 1;
this.secondAfterSaleFlagShow = false;
}else{
this.form.secondAfterSaleFlag = 0;
this.secondAfterSaleFlagShow = true;
}
//
if(newVal[0] == 1){
this.orderRateOptionsShow = false;
this.form.nutritionistRate = "2,8";
}else{
this.orderRateOptionsShow = true;
this.form.nutritionistRate = "0,10";
}
},
},
};
</script>

View File

@ -92,7 +92,10 @@
</div> </div>
</el-drawer> </el-drawer>
<create-order-dialog ref="cusCreateOrderDialogRef" /> <!-- 新增订单 -->
<!--<create-order-dialog ref="cusCreateOrderDialogRef" />-->
<!-- 订单编辑 -->
<edit-order-dialog ref="cusEditOrderDialogRef" />
<order-detail ref="orderDetailRef" /> <order-detail ref="orderDetailRef" />
</div> </div>
@ -100,13 +103,15 @@
<script> <script>
import { listOrder, delOrder } from "@/api/custom/order"; import { listOrder, delOrder } from "@/api/custom/order";
import OrderEdit from "@/components/OrderEdit"; import OrderEdit from "@/components/OrderEdit";
import OrderAdd from "@/components/OrderAdd";
import OrderDetail from "@/components/OrderDetail"; import OrderDetail from "@/components/OrderDetail";
export default { export default {
name: "CustomerOrderDrawer", name: "CustomerOrderDrawer",
components: { components: {
"create-order-dialog": OrderEdit, "edit-order-dialog": OrderEdit,
"order-detail": OrderDetail, "order-detail": OrderDetail,
//"create-order-dialog": OrderAdd
}, },
data() { data() {
return { return {
@ -150,7 +155,7 @@ export default {
}); });
}, },
handleAdd() { handleAdd() {
this.$refs.cusCreateOrderDialogRef.showDialog( this.$refs.cusEditOrderDialogRef.showDialog(
{ {
customer: this.data.name, customer: this.data.name,
cusId: this.data.id, cusId: this.data.id,
@ -171,7 +176,7 @@ export default {
this.$refs.orderDetailRef.showDialog(data.orderId); this.$refs.orderDetailRef.showDialog(data.orderId);
}, },
handleOnEditClick(data) { handleOnEditClick(data) {
this.$refs.cusCreateOrderDialogRef.showDialog(data, () => { this.$refs.cusEditOrderDialogRef.showDialog(data, () => {
this.fetchOrderList(this.data.id); this.fetchOrderList(this.data.id);
}); });
}, },

View File

@ -203,8 +203,7 @@ export default {
["medicalReport_one","medicalReport_two","medicalReport_three"] ["medicalReport_one","medicalReport_two","medicalReport_three"]
] ]
], ],
copyValue: "", copyValue: ""
enc_id: ""
}; };
}, },
methods: { methods: {
@ -245,7 +244,7 @@ export default {
this.getDataListBySignMessage(res.data.customerHealthy) this.getDataListBySignMessage(res.data.customerHealthy)
} }
} }
this.enc_id = res.data.enc_id; //this.enc_id = res.data.enc_id;
this.showFlag = true; this.showFlag = true;
this.visible = true; this.visible = true;
}); });
@ -253,7 +252,7 @@ export default {
onClosed() { onClosed() {
this.dataList = []; this.dataList = [];
this.data = null; this.data = null;
this.enc_id = ""; //this.enc_id = "";
this.copyValue = ""; this.copyValue = "";
}, },
// //
@ -437,7 +436,7 @@ export default {
return str; return str;
}, },
handleCopy() { handleCopy() {
this.copyValue = window.location.origin.replace('manage', 'sign') + "/subhealthyInvestigation/"+this.enc_id; this.copyValue = window.location.origin.replace('manage', 'sign') + "/subhealthyInvestigation/"+this.data.encId;
const btnCopy = new Clipboard('.copyBtn'); const btnCopy = new Clipboard('.copyBtn');
this.$message({ this.$message({
message: '拷贝成功', message: '拷贝成功',

View File

@ -49,7 +49,8 @@ router.beforeEach((to, from, next) => {
} }
} else { } else {
// 没有token // 没有token
if (whiteList.indexOf(to.path) !== -1 || to.path.startsWith('/f/contract/') || to.path.startsWith('/subhealthyInvestigation/')) { if (whiteList.indexOf(to.path) !== -1 || to.path.startsWith('/f/contract/') || to.path.startsWith('/subhealthyInvestigation/')
|| to.path.startsWith('/foodHeatCalculator/')) {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next() next()
} else { } else {

View File

@ -173,7 +173,15 @@ export const constantRoutes = [
require(["@/views/custom/subhealthy/investigation"], resolve), require(["@/views/custom/subhealthy/investigation"], resolve),
hidden: true, hidden: true,
meta: { title: "胜唐体控健康评估表" } meta: { title: "胜唐体控健康评估表" }
} },
{
path: "/foodHeatCalculator/:id",
component: resolve =>
require(["@/views/custom/foodHeatStatistics/investigate"], resolve),
hidden: true,
meta: { title: "外食计算器" }
},
]; ];
export default new Router({ export default new Router({

View File

@ -0,0 +1,72 @@
export const orderMoneyTypeArray = [
{
value: 0,
label: "全款单"
},{
value: 1,
label: "定金单"
},
{
value: 2,
label: "尾款单"
}
]
//订单次数类型
export const orderCountTypeArray = [
{
value: 0,
label: "一开单",
children: orderMoneyTypeArray
},{
value: 1,
label: "二开单",
children: orderMoneyTypeArray
}
]
//订单类型
export const orderTypeArray = [
{
value: 0,
label: "普通单",
children: orderCountTypeArray
},{
value: 1,
label: "比例拆分单",
children: orderCountTypeArray
}
]
//订单拆分比例类型
export const orderRateArray = [
{
dictValue: "0,10",
dictLabel: "不拆分",
remark: ""
},
{
dictValue: "1,9",
dictLabel: "1-9开",
remark: ""
},{
dictValue: "2,8",
dictLabel: "2-8开",
remark: "default"
},
{
dictValue: "3,7",
dictLabel: "3-7开",
remark: ""
},
{
dictValue: "4,6",
dictLabel: "4-6开",
remark: ""
},
{
dictValue: "5,5",
dictLabel: "5-5开",
remark: ""
}
]

View File

@ -179,6 +179,16 @@
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="外食热量统计" align="center" v-hasPermi="['custom:foodHeatStatistics:list']">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="handleClickHeatStatistics(scope.row)"
>详情
</el-button>
</template>
</el-table-column>
<el-table-column label="食谱计划" align="center" v-hasPermi="['recipes:recipesPlan:list']"> <el-table-column label="食谱计划" align="center" v-hasPermi="['recipes:recipesPlan:list']">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -312,6 +322,8 @@
<contract-drawer ref="cusContractDrawerRef"></contract-drawer> <contract-drawer ref="cusContractDrawerRef"></contract-drawer>
<!-- 健康评估弹窗 --> <!-- 健康评估弹窗 -->
<physical-signs-dialog ref="physicalSignsDialogRef" /> <physical-signs-dialog ref="physicalSignsDialogRef" />
<!-- 外食热量统计 -->
<heatStatisticsDrawer ref="heatStatisticsRef"></heatStatisticsDrawer>
<!-- 食谱计划抽屉 --> <!-- 食谱计划抽屉 -->
</div> </div>
</template> </template>
@ -333,13 +345,15 @@ import { getOptions } from "@/api/custom/order";
import OrderDrawer from "@/components/OrderDrawer"; import OrderDrawer from "@/components/OrderDrawer";
import PhysicalSignsDialog from "@/components/PhysicalSignsDialog"; import PhysicalSignsDialog from "@/components/PhysicalSignsDialog";
import ContractDrawer from "@/components/ContractDrawer"; import ContractDrawer from "@/components/ContractDrawer";
import HeatStatisticsDrawer from "@/components/HeatStatisticsDrawer";
export default { export default {
name: "Customer", name: "Customer",
components: { components: {
"order-drawer": OrderDrawer, "order-drawer": OrderDrawer,
"physical-signs-dialog": PhysicalSignsDialog, "physical-signs-dialog": PhysicalSignsDialog,
"contract-drawer": ContractDrawer "contract-drawer": ContractDrawer,
"heatStatisticsDrawer": HeatStatisticsDrawer
}, },
data() { data() {
const userId = store.getters && store.getters.userId; const userId = store.getters && store.getters.userId;
@ -490,6 +504,9 @@ export default {
handleOnMenuClick(row) { handleOnMenuClick(row) {
// console.log(row); // console.log(row);
}, },
handleClickHeatStatistics(row){
this.$refs["heatStatisticsRef"].showDrawer(row);
},
// //
cancel() { cancel() {
this.open = false; this.open = false;

View File

@ -9,7 +9,7 @@
placeholder="选择日期"> placeholder="选择日期">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="销售" prop="userId"> <el-form-item label="销售" prop="userId" label-width="68px">
<el-select v-model="queryParams.userId" placeholder="请选择销售" filterable clearable> <el-select v-model="queryParams.userId" placeholder="请选择销售" filterable clearable>
<el-option <el-option
v-for="dict in preSaleIdOptions" v-for="dict in preSaleIdOptions"
@ -19,7 +19,17 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="进粉渠道" prop="accountId" label-width="88px">
<el-select v-model="queryParams.accountId" filterable placeholder="请选择渠道" clearable>
<el-option
v-for="dict in accountIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item style="margin-left: 20px">
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
@ -128,7 +138,7 @@
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="销售" prop="userId"> <el-form-item label="销售" prop="userId">
<el-select v-model="form.userId" placeholder="请选择销售" filterable clearable size="small" @change="getWxByUserId"> <el-select v-model="form.userId" placeholder="请选择销售" filterable clearable size="small">
<el-option <el-option
v-for="dict in preSaleIdOptions" v-for="dict in preSaleIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -218,7 +228,8 @@
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
fanTime: nowDate, fanTime: nowDate,
userId: null userId: null,
accountId: null
}, },
// //
form: {}, form: {},
@ -232,6 +243,8 @@
wxList:[], wxList:[],
// //
preSaleIdOptions:[], preSaleIdOptions:[],
//
accountIdOptions:[],
editOpen: false, editOpen: false,
editForm:{}, editForm:{},
// //
@ -244,6 +257,9 @@
created() { created() {
this.getList(); this.getList();
this.getSaleUserList(); this.getSaleUserList();
this.getDicts("fan_channel").then((response) => {
this.accountIdOptions = response.data;
});
}, },
methods: { methods: {
/** 查询进粉统计列表 */ /** 查询进粉统计列表 */
@ -354,6 +370,7 @@
if (response.code === 200) { if (response.code === 200) {
this.msgSuccess("新增成功"); this.msgSuccess("新增成功");
this.open = false; this.open = false;
this.reset();
this.getList(); this.getList();
} }
}); });
@ -444,6 +461,12 @@
} }
}); });
}, },
},
watch: {
// ID
"form.userId": function (newVal, oldVal) {
this.getWxByUserId(newVal);
},
} }
}; };
</script> </script>

View File

@ -0,0 +1,21 @@
<template>
<div>
</div>
</template>
<script>
export default {
name: "index",
data() {
},
methods: {
},
watch: {
}
};
</script>

View File

@ -0,0 +1,322 @@
<template>
<section>
<div style="padding: 5px; text-align: center">
<img :src="logo" style="width: 150px; height: 35px" alt="logo" />
</div>
<!--<div style="margin: 10px 15px 10px 15px;" >
<el-steps :active="stepActive" finish-status="success">
<el-step v-for="(item,index) in stepArray" title=""></el-step>
</el-steps>
</div>-->
<el-form ref="form" label-position="top" :model="form" :rules="rules" label-width="100px" style="padding: 16px">
<div>
<h3>个人信息</h3>
<!--<div><span>{{form.name}}</span></div>-->
</div>
<el-form-item :label="'姓名:'+customer.name" prop="name">
<!--<el-input v-model="customer.name" :readonly="true" placeholder="请输入真实姓名" maxlength="20"/>-->
</el-form-item>
<el-form-item :label="'手机号:'+customer.phone" prop="phone" style="margin-top: -15px">
<!--<el-input v-model="customer.name" :readonly="true" placeholder="请输入真实姓名" maxlength="20"/>-->
</el-form-item>
<div>
<h3>外食计算</h3>
</div>
<el-row>
<el-button v-for="(item,index) in modular" type="primary" plain @click="modularChange(index)">{{item}}</el-button>
</el-row>
<div style="margin-top: 40px">
<h3>{{currentTitle}}</h3>
</div>
<div v-show="currentShow == 0">
<el-form-item label="已添加的食材" prop="name">
<el-tag style="margin-left: 5px" v-for="tag in ingredientTagArray" :key="tag" closable :disable-transitions="false" @close="handleClose(tag)">
{{tag}}
</el-tag>
</el-form-item>
<div>
<el-form-item label="日期" prop="edibleDate">
<el-date-picker
v-model="form.edibleDate"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
<el-form-item label="食材名称" prop="ingredient">
<el-input v-model="form.ingredient" placeholder="请输入食材名称" maxlength="20"/>
</el-form-item>
<el-form-item label="通俗计量" prop="numberUnit">
<el-input v-model="form.number" style="width: 48%" placeholder="请输入食材数量" maxlength="10"/>
<el-select v-model="form.unit" placeholder="请选择单位" style="margin-left:5px;width: 50%" filterable clearable>
<el-option
v-for="dict in cusUnitOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item label="重量(克)" prop="quantity">
<el-input v-model="form.quantity" placeholder="请输入食材重量(整数)" maxlength="10"/>
</el-form-item>
</div>
<el-form-item style="text-align: center; margin: 40px auto" >
<el-button type="primary" @click="continueAdd()" >继续添加</el-button>
<el-button type="success" @click="submit()" >提交数据</el-button>
</el-form-item>
</div>
</el-form>
</section>
</template>
<script>
import { getDictData,getCustomerBaseMessage,addFoodHeatStatistics } from "@/api/custom/customerInvestigation";
import dayjs from "dayjs";
const nowDate = dayjs().format("YYYY-MM-DD");
const logo = require("@/assets/logo/st_logo.png");
export default {
name: "index",
data() {
const checkNumberUnit = (rule, value, callback) => {
if (this.form.number) {
if(!/^[1-9]\d*$/.test(value)){
return callback(new Error("通俗计量的数量格式错误"));
}
if(!this.form.unit){
return callback(new Error("请选择通俗计量单位"));
}
}
callback();
};
return {
modular:["食材提交"],
currentShow: -1,
currentTitle: "",
logo,
timer: null,
customerExistFlag: false,
submitFlag: false,
customer:{
customerEncId: null,
name: null,
phone: null
},
form: {
edibleDate: nowDate,
ingredient: null,
number: null,
unit: null,
quantity: null,
},
rules: {
ingredient: [{ required: true, trigger: "blur", message: "请输入食材名称" }],
edibleDate: [{ required: true, trigger: "blur", message: "请选择日期" }]
},
ingredientTagArray:[
],
ingredientArray: [
],
//
cusUnitOptions:[],
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
};
},
components: {
},
methods: {
modularChange(index){
if(index != this.currentShow){
this.currentShow = index;
this.currentTitle = this.modular[index];
}else{
this.currentShow = -1;
this.currentTitle = "";
}
},
//ID
getCustomerBase(id){
if(id == null || id == undefined){
return;
}
getCustomerBaseMessage(id).then((response) => {
if (response.code === 200) {
if(response.data){
this.customerExistFlag = true;
this.customer.name = response.data.name;
this.customer.phone = response.data.phone;
}
}
}).catch(function() {
console.log("error");
});
},
continueAdd(){
this.$refs.form.validate((valid) => {
if (valid) {
if(this.verify() && this.ingredientTagArray.indexOf(this.form.ingredient.trim()) == -1){
this.ingredientArray.push(this.form);
this.ingredientTagArray.push(this.form.ingredient);
this.reset();
}
} else {
this.$message({message: "食材数据未填写完整", type: "warning"});
}
});
},
verify(){
var reg = /^([1-9]\d*|[0]{1,1})$/;
if(this.form.number != null && this.form.number != ""){
if(!reg.test(this.form.number+"")){
this.$message({message: "通俗计量的数量格式错误", type: "warning"});
return false;
}
if(this.form.unit == null || this.form.unit == ""){
this.$message({message: "请选择通俗计量单位", type: "warning"});
return false;
}
}
if(this.form.quantity != null && this.form.quantity != "" && !reg.test(this.form.quantity)){
this.$message({message: "重量格式错误", type: "warning"});
return false;
}
if((this.form.number == null || this.form.number == "") && (this.form.quantity == null || this.form.quantity == "")){
this.$message({message: "通俗计量和重量不能都为空", type: "warning"});
return false;
}
return true;
},
reset(){
this.form = {
edibleDate: nowDate,
ingredient: null,
number: null,
unit: null,
quantity: null
}
},
againSumbit(){
this.submitFlag = false;
},
submit(){
if (this.submitFlag) {
this.$message({
message: "请勿频繁提交,一分钟后重试",
type: "warning",
});
return;
}
if(this.form.ingredient && this.ingredientTagArray.indexOf(this.form.ingredient.trim()) == -1){
if(!this.verify()){
return;
}
this.ingredientArray.push(this.form);
this.ingredientTagArray.push(this.form.ingredient);
this.reset();
}
if(this.ingredientArray.length == 0){
this.$message({message: "还未添加食材数据,无法提交", type: "warning"});
return;
}
this.timer = setTimeout(this.againSumbit,1000*60);
let submitObject = {};
submitObject.ingredientArray = JSON.stringify(this.ingredientArray);
submitObject.customerEncId = this.customer.customerEncId;
this.submitFlag = true;
addFoodHeatStatistics(submitObject).then((response) => {
this.$notify({title: "提交成功", message: "", type: "success"});
}).catch(function() {
console.log("error");
});
},
handleClose(tag) {
this.ingredientTagArray.splice(this.ingredientTagArray.indexOf(tag), 1);
let tagIndex = -1;
this.ingredientArray.forEach((item, index) => {
if(tag == item.ingredient){
tagIndex = index;
}
});
this.ingredientArray.splice(tagIndex, 1);
console.log( JSON.stringify(this.ingredientArray))
}
},
created() {
this.customer.customerEncId = this.$route.params.id;
this.getCustomerBase(this.customer.customerEncId);
getDictData("cus_cus_unit").then(response => {
this.cusUnitOptions = response.data;
});
},
beforeCreate() {
document.title = this.$route.meta.title;
},
};
</script>
<style scoped>
.el-form-item {
margin-bottom: 8px;
}
.p_title_1{
font-size: 18px;
font-weight: bold;
margin-top: 30px;
}
.p_title_2{
font-size: 16px;
font-weight: bold;
margin-top: 30px;
}
.p_title_3{
font-size: 14px;
font-weight: bold;
margin-top: 30px;
}
.margin-left{
margin-left: 14px;
}
.el-input__inner{
width: 30%;
}
.margin-top-10{
margin-top: 10px;
}
.width-50-left-8-right-5{
width:50%;
margin-left: 8px;
margin-right: 5px;
}
.width-70-left-8-right-5{
width:70%;
margin-left: 8px;
margin-right: 5px;
}
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style>