可以上传压缩包
This commit is contained in:
+52
-62
@@ -1,16 +1,11 @@
|
|||||||
package io.v.nutz.fitnessWalk.controller;
|
package io.v.nutz.fitnessWalk.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.date.DateBetween;
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUnit;
|
import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.wizzer.framework.base.Result;
|
import cn.wizzer.framework.base.Result;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import io.v.nutz.annontation.ViReturn;
|
import io.v.nutz.annontation.ViReturn;
|
||||||
import io.v.nutz.base.page.Pagination;
|
|
||||||
import io.v.nutz.base.service.BaseService;
|
import io.v.nutz.base.service.BaseService;
|
||||||
import io.v.nutz.fitnessWalk.model.FitnessWalkActivity;
|
import io.v.nutz.fitnessWalk.model.FitnessWalkActivity;
|
||||||
import io.v.nutz.fitnessWalk.model.FitnessWalkAwardUser;
|
import io.v.nutz.fitnessWalk.model.FitnessWalkAwardUser;
|
||||||
@@ -20,8 +15,6 @@ import io.v.nutz.fitnessWalk.utils.WeAppCloudUtil;
|
|||||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||||
import org.nutz.dao.Chain;
|
import org.nutz.dao.Chain;
|
||||||
import org.nutz.dao.Cnd;
|
import org.nutz.dao.Cnd;
|
||||||
import org.nutz.dao.Sqls;
|
|
||||||
import org.nutz.dao.sql.Sql;
|
|
||||||
import org.nutz.integration.jedis.RedisService;
|
import org.nutz.integration.jedis.RedisService;
|
||||||
import org.nutz.ioc.aop.Aop;
|
import org.nutz.ioc.aop.Aop;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
@@ -36,6 +29,8 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.BinaryOperator;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@IocBean
|
@IocBean
|
||||||
@@ -62,86 +57,81 @@ public class FitnessWalkStepManageController {
|
|||||||
* @param activityId 活动id
|
* @param activityId 活动id
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @param monthSteps 步数(当天往前推30天)
|
* @param monthSteps 步数(当天往前推30天)
|
||||||
* @param start_time 活动开始时间
|
|
||||||
* @param end_time 结束时间
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@At
|
@At
|
||||||
@Ok("json:full")
|
@Ok("json:full")
|
||||||
@ViReturn
|
@ViReturn
|
||||||
@Aop(TransAop.READ_COMMITTED)
|
@Aop(TransAop.READ_COMMITTED)
|
||||||
public Object updateStepMonth(String activityId, String userId, String monthSteps, Long start_time, Long end_time) {
|
public Object updateStepMonth(String activityId, String userId, String monthSteps) {
|
||||||
if (StrUtil.isBlank(userId)) {
|
if (StrUtil.isBlank(userId) || StrUtil.isBlank(monthSteps) || StrUtil.isBlank(activityId)) {
|
||||||
return Result.error("上传步数失败,请重新登录后再次上传!");
|
return Result.error("必要参数未传递!");
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime activityStartDate = DateUtil.date(start_time);
|
// 获取到的用户的步数数据
|
||||||
DateTime activityEndDate = DateUtil.date(end_time);
|
|
||||||
|
|
||||||
List<NutMap> steps = Json.fromJsonAsList(NutMap.class, monthSteps);
|
List<NutMap> steps = Json.fromJsonAsList(NutMap.class, monthSteps);
|
||||||
|
|
||||||
/*//前一个月的时间
|
|
||||||
DateTime dateTime = DateUtil.offsetMonth(new Date(), -1);
|
|
||||||
String format = DateUtil.format(dateTime, "yyyyMM");
|
|
||||||
|
|
||||||
//上一个月的步数
|
|
||||||
List<NutMap> lastMonthSteps = steps.stream().filter(v -> {
|
|
||||||
long timestamp = v.getLong("timestamp") * 1000;
|
|
||||||
String userStep = DateUtil.format(DateUtil.date(timestamp), "yyyyMM");
|
|
||||||
return userStep.equals(format);
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<FitnessWalkStep> lastMonthInsertWxSteps = steps.stream().map(v -> {
|
|
||||||
FitnessWalkStep step = new FitnessWalkStep();
|
|
||||||
step.setActivityId(activityId);
|
|
||||||
step.setUserId(userId);
|
|
||||||
step.setStep(v.getInt("step"));
|
|
||||||
DateTime date = DateUtil.date(v.getLong("timestamp") * 1000);
|
|
||||||
step.setApplyDate(date);
|
|
||||||
return step;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
List<Date> applyDates = lastMonthInsertWxSteps.stream().map(v -> v.getApplyDate()).collect(Collectors.toList());
|
|
||||||
|
|
||||||
applyDates.remove(applyDates.stream().min(Date::compareTo).orElse(null));
|
|
||||||
|
|
||||||
System.out.println(lastMonthInsertWxSteps.size());
|
|
||||||
System.out.println(applyDates.size());
|
|
||||||
System.out.println(Json.toJson(applyDates));
|
|
||||||
|
|
||||||
baseService.dao().clear("fitness_walk_step_" + format, Cnd.where("activityId", "=", activityId).and("userId", "=", userId).and("applyDate", "in", applyDates));
|
|
||||||
// baseService.dao().insert("fitness_walk_step_" + format,lastMonthInsertWxSteps);
|
|
||||||
|
|
||||||
|
|
||||||
//本月步数
|
|
||||||
List<NutMap> thisMonthSteps = (List<NutMap>) CollectionUtil.subtract(steps,lastMonthSteps);*/
|
|
||||||
|
|
||||||
//判断数据是否完整 微信运动会在晚上10点多进行步数的更新 会导致31天前的步数获取变为0 所以这里去除掉第一个元素 即为31天前的数据 每次只保存最近30天的数据
|
//判断数据是否完整 微信运动会在晚上10点多进行步数的更新 会导致31天前的步数获取变为0 所以这里去除掉第一个元素 即为31天前的数据 每次只保存最近30天的数据
|
||||||
if (Lang.isNotEmpty(steps) && steps.size() == 31) {
|
if (Lang.isNotEmpty(steps) && steps.size() == 31) {
|
||||||
steps.remove(0);
|
steps.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果在活动开始之前进来了 就只保存近7天的数据 不然前台展示为空 不好看
|
// 传递过来的步数数据
|
||||||
List<FitnessWalkStep> insertWxSteps = steps.stream().map(v -> {
|
List<FitnessWalkStep> wxSteps = steps.stream().map(v -> {
|
||||||
FitnessWalkStep step = new FitnessWalkStep();
|
FitnessWalkStep step = new FitnessWalkStep();
|
||||||
step.setActivityId(activityId);
|
step.setActivityId(activityId);
|
||||||
step.setUserId(userId);
|
step.setUserId(userId);
|
||||||
step.setStep(v.getInt("step"));
|
step.setStep(v.getInt("step"));
|
||||||
DateTime date = DateUtil.date(v.getLong("timestamp") * 1000);
|
DateTime date = DateUtil.parse(DateUtil.format(DateUtil.date(v.getLong("timestamp") * 1000), "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||||
step.setApplyDate(date);
|
step.setApplyDate(date);
|
||||||
return step;
|
return step;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
//.filter(v -> v.getApplyDate().compareTo(DateUtil.offsetDay(activityStartDate, -7)) >= 0 && v.getApplyDate().compareTo(activityEndDate) <= 0).collect(Collectors.toList());
|
|
||||||
//.filter(v -> (v.getApplyDate().compareTo(activityStartDate) >= 0) && (v.getApplyDate().compareTo(activityEndDate) <= 0)).collect(Collectors.toList());
|
|
||||||
List<Date> applyDates = insertWxSteps.stream().map(v -> v.getApplyDate()).collect(Collectors.toList());
|
|
||||||
|
|
||||||
applyDates.remove(applyDates.stream().min(Date::compareTo).orElse(null));
|
// 传递过来的所有日期的集合
|
||||||
|
List<Date> dateList = wxSteps.stream().map(FitnessWalkStep::getApplyDate).collect(Collectors.toList());
|
||||||
|
|
||||||
System.out.println(insertWxSteps.size());
|
// 去数据库查询日期,这个玩意还要保证插入到数据库的单个日期只有一条,并且这个日期数据库之前有步数,传过来没步数那就要保留数据库的步数
|
||||||
System.out.println(applyDates.size());
|
// 上面日期集合数据库的步数
|
||||||
System.out.println(Json.toJson(applyDates));
|
List<FitnessWalkStep> stepList = baseService.dao().query(FitnessWalkStep.class, Cnd.where("activityId", "=", activityId)
|
||||||
|
.and("userId", "=", userId).and("applyDate", "in", dateList));
|
||||||
|
|
||||||
baseService.dao().clear(FitnessWalkStep.class, Cnd.where("activityId", "=", activityId).and("userId", "=", userId).and("applyDate", "in", applyDates));
|
// 这就是保留每天最大步数的集合,那这个集合里面applyDate就是唯一的了
|
||||||
baseService.dao().insert(insertWxSteps);
|
List<FitnessWalkStep> dupStepList = new ArrayList<>(stepList.stream()
|
||||||
|
.collect(Collectors.toMap(FitnessWalkStep::getApplyDate, Function.identity(),
|
||||||
|
BinaryOperator.maxBy(Comparator.comparing(FitnessWalkStep::getStep))))
|
||||||
|
.values());
|
||||||
|
|
||||||
|
// 这是过滤的相同的applyDate的集合,这些数据要删除
|
||||||
|
List<String> delStepIds = stepList.stream()
|
||||||
|
.filter(step -> !dupStepList.contains(step))
|
||||||
|
.map(FitnessWalkStep::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 数据库的数据 这个map就用于判断数据库的日期和传递过来日期的步数,两个是不是相等的,保留步数多的数据
|
||||||
|
Map<Date, FitnessWalkStep> dateStepMap = dupStepList.stream().collect(Collectors.toMap(FitnessWalkStep::getApplyDate, v -> v));
|
||||||
|
|
||||||
|
List<FitnessWalkStep> resultStepList = new ArrayList<>();
|
||||||
|
// 这里循环就是,循环的传递过来的数据
|
||||||
|
for (FitnessWalkStep step : wxSteps) {
|
||||||
|
// 数据库存储的步数
|
||||||
|
FitnessWalkStep walkStep = dateStepMap.get(step.getApplyDate());
|
||||||
|
// 如果数据库没有,那就要新增
|
||||||
|
if (Lang.isEmpty(walkStep)) {
|
||||||
|
resultStepList.add(step);
|
||||||
|
} else {
|
||||||
|
// 如果数据库有,那就要保留步数多的
|
||||||
|
if (walkStep.getStep() < step.getStep()) {
|
||||||
|
walkStep.setStep(step.getStep());
|
||||||
|
resultStepList.add(walkStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最后删除重复日期,更新步数数据
|
||||||
|
baseService.dao().clear(FitnessWalkStep.class, Cnd.where("id", "in", delStepIds));
|
||||||
|
if (Lang.isNotEmpty(resultStepList)){
|
||||||
|
baseService.dao().insertOrUpdate(resultStepList);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ module.exports = {
|
|||||||
files: Array,
|
files: Array,
|
||||||
type: {
|
type: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: ['jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'pdf', 'zip', 'war']
|
default: ['jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'pdf', 'zip', 'war', 'rar']
|
||||||
},
|
},
|
||||||
max: {
|
max: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
@@ -890,12 +890,7 @@ layout("/layouts/platform.html"){
|
|||||||
<script>
|
<script>
|
||||||
let E = window.wangEditor
|
let E = window.wangEditor
|
||||||
let noteEditor = null
|
let noteEditor = null
|
||||||
let icon = new AMap.Icon({
|
|
||||||
size: new AMap.Size(25, 34),
|
|
||||||
image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
|
|
||||||
imageSize: new AMap.Size(140, 30),
|
|
||||||
imageOffset: new AMap.Pixel(-95, -3)
|
|
||||||
});
|
|
||||||
let map = null
|
let map = null
|
||||||
let marker = null
|
let marker = null
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ layout("/layouts/platform.html"){
|
|||||||
<el-row :gutter="40">
|
<el-row :gutter="40">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item prop="jdhjs" label="届数">
|
<el-form-item prop="jdhjs" label="届数">
|
||||||
<el-select @change="jdhjsChange" v-model="formData.jdhjs" filterable clearable style="width: 100%"
|
<el-select @change="jdhjsChange" v-model="formData.jdhjs" filterable clearable
|
||||||
|
style="width: 100%"
|
||||||
placeholder="届数">
|
placeholder="届数">
|
||||||
<el-option v-for="item in jsList" :key="item.id" :label="item.name"
|
<el-option v-for="item in jsList" :key="item.id" :label="item.name"
|
||||||
:value="item.code">
|
:value="item.code">
|
||||||
@@ -195,7 +196,9 @@ layout("/layouts/platform.html"){
|
|||||||
<el-form-item prop="files" label="请示附件" class="is-required">
|
<el-form-item prop="files" label="请示附件" class="is-required">
|
||||||
<file-upload :max="10" :files.sync="formData.files">
|
<file-upload :max="10" :files.sync="formData.files">
|
||||||
<template #el-upload__tip>
|
<template #el-upload__tip>
|
||||||
<div class="el-upload__tip" slot="tip">图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,上传数量为10个</div>
|
<div class="el-upload__tip" slot="tip">
|
||||||
|
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war/rar,上传数量为10个
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</file-upload>
|
</file-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -313,7 +316,7 @@ layout("/layouts/platform.html"){
|
|||||||
},
|
},
|
||||||
async openEdit(id) {
|
async openEdit(id) {
|
||||||
const resp = await $.get(loc() + "/findOne", {id})
|
const resp = await $.get(loc() + "/findOne", {id})
|
||||||
if(resp.code===0){
|
if (resp.code === 0) {
|
||||||
const data = resp.data
|
const data = resp.data
|
||||||
data.files = JSON.parse(data.files)
|
data.files = JSON.parse(data.files)
|
||||||
this.formData = data
|
this.formData = data
|
||||||
@@ -327,7 +330,7 @@ layout("/layouts/platform.html"){
|
|||||||
meetingTopicRich.txt.html(data.meeting_topic)
|
meetingTopicRich.txt.html(data.meeting_topic)
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
}else{
|
} else {
|
||||||
this.notifyWarning(resp.msg)
|
this.notifyWarning(resp.msg)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -359,7 +362,7 @@ layout("/layouts/platform.html"){
|
|||||||
});*/
|
});*/
|
||||||
|
|
||||||
this.formData.jdhallname = this.formData.jdhjs + '届'
|
this.formData.jdhallname = this.formData.jdhjs + '届'
|
||||||
if(this.formData.jdhcs) {
|
if (this.formData.jdhcs) {
|
||||||
this.formData.jdhallname += this.formData.jdhcs + '次'
|
this.formData.jdhallname += this.formData.jdhcs + '次'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ layout("/layouts/platform.html"){
|
|||||||
<file-upload :files.sync="formData.files">
|
<file-upload :files.sync="formData.files">
|
||||||
<template #el-upload__tip>
|
<template #el-upload__tip>
|
||||||
<div class="el-upload__tip" slot="tip">
|
<div class="el-upload__tip" slot="tip">
|
||||||
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war,上传数量为10个
|
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war/rar,上传数量为10个
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</file-upload>
|
</file-upload>
|
||||||
@@ -278,7 +278,7 @@ layout("/layouts/platform.html"){
|
|||||||
<file-upload :files.sync="formData.files" :max="10">
|
<file-upload :files.sync="formData.files" :max="10">
|
||||||
<template #el-upload__tip>
|
<template #el-upload__tip>
|
||||||
<div class="el-upload__tip" slot="tip">
|
<div class="el-upload__tip" slot="tip">
|
||||||
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war,上传数量为10个
|
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war/rar,上传数量为10个
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</file-upload>
|
</file-upload>
|
||||||
|
|||||||
Reference in New Issue
Block a user