按天复制课程
This commit is contained in:
@@ -20,3 +20,10 @@ export function remove(ids) {
|
|||||||
export function save(params) {
|
export function save(params) {
|
||||||
return http.post('/venue/lesson', params)
|
return http.post('/venue/lesson', params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制课程
|
||||||
|
*/
|
||||||
|
export function copy(params) {
|
||||||
|
return http.post('/venue/lesson/copy', params)
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
<el-button size="small" type="text" @click="handleEdit(scope.row.id)">编辑</el-button>
|
<el-button size="small" type="text" @click="handleEdit(scope.row.id)">编辑</el-button>
|
||||||
<el-button size="small" type="text" v-if="scope.row.saleNum > 0" @click="handleInfo(scope.row.id)">预约记录</el-button>
|
<el-button size="small" type="text" v-if="scope.row.saleNum > 0" @click="handleInfo(scope.row.id)">预约记录</el-button>
|
||||||
<el-button size="small" type="text" @click="showimg(scope.row.id)">复制</el-button>
|
<el-button size="small" type="text" @click="showimg(scope.row.id)">复制</el-button>
|
||||||
|
<el-button size="small" type="text" @click="showCopyByDay(scope.row.id)">按天复制</el-button>
|
||||||
<el-button size="small" v-if="scope.row.saleNum <= 0" type="text" class="danger" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button size="small" v-if="scope.row.saleNum <= 0" type="text" class="danger" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -124,6 +125,29 @@
|
|||||||
<el-button @click="dialogFormVisible = false">关 闭</el-button>
|
<el-button @click="dialogFormVisible = false">关 闭</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-dialog title="复制该课程所在日期的所有课程到目标日期范围" :visible.sync="dialogFormByDay">
|
||||||
|
<div class="dialog_div">
|
||||||
|
<span>选择复制起期:</span>
|
||||||
|
<el-date-picker
|
||||||
|
class="filter-item" v-model="copyParam.leftDate" type="date" placeholder="选择复制起期"
|
||||||
|
:picker-options="startDatePicker"
|
||||||
|
value-format="yyyy-MM-dd" format="yyyy-MM-dd">
|
||||||
|
</el-date-picker>
|
||||||
|
</div>
|
||||||
|
<div class="dialog_div">
|
||||||
|
<span>选择复制止期:</span>
|
||||||
|
<el-date-picker
|
||||||
|
class="filter-item" v-model="copyParam.rightDate" type="date" placeholder="选择复制止期"
|
||||||
|
:picker-options="endDatePicker"
|
||||||
|
value-format="yyyy-MM-dd" format="yyyy-MM-dd">
|
||||||
|
</el-date-picker>
|
||||||
|
</div>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="copyLessonByDay">保存</el-button>
|
||||||
|
<el-button @click="dialogFormByDay = false">关 闭</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -137,7 +161,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { findByVenueType } from '@/api//coach'
|
import { findByVenueType } from '@/api//coach'
|
||||||
import { remove, find, save } from '@/api//venue/lesson'
|
import { remove, find, save, copy } from '@/api//venue/lesson'
|
||||||
import waves from '@/directive/waves.js' // 水波纹指令
|
import waves from '@/directive/waves.js' // 水波纹指令
|
||||||
import Pagination from '@/components/Pagination'
|
import Pagination from '@/components/Pagination'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
@@ -152,6 +176,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
coaches: [],
|
coaches: [],
|
||||||
dialogFormVisible: false,
|
dialogFormVisible: false,
|
||||||
|
dialogFormByDay: false,
|
||||||
params: {
|
params: {
|
||||||
search_eq_v$venueId: undefined,
|
search_eq_v$venueId: undefined,
|
||||||
search_eq_v$date: undefined,
|
search_eq_v$date: undefined,
|
||||||
@@ -162,11 +187,18 @@ export default {
|
|||||||
leftTime: undefined,
|
leftTime: undefined,
|
||||||
rightTime: undefined
|
rightTime: undefined
|
||||||
},
|
},
|
||||||
|
copyParam: {
|
||||||
|
lessonId: undefined,
|
||||||
|
leftDate: '',
|
||||||
|
rightDate: ''
|
||||||
|
},
|
||||||
pickerOptions: {
|
pickerOptions: {
|
||||||
disabledDate(time) {
|
disabledDate(date) {
|
||||||
return Date.now() > time
|
return Date.now() > date
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
startDatePicker: this.beginDate(),
|
||||||
|
endDatePicker: this.processDate(),
|
||||||
time: undefined,
|
time: undefined,
|
||||||
times: '',
|
times: '',
|
||||||
data: '',
|
data: '',
|
||||||
@@ -223,9 +255,44 @@ export default {
|
|||||||
this.dialogFormVisible = true
|
this.dialogFormVisible = true
|
||||||
this.findById(id)
|
this.findById(id)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按天复制
|
||||||
|
*/
|
||||||
|
showCopyByDay(id) {
|
||||||
|
this.copyParam.lessonId = id
|
||||||
|
this.dialogFormByDay = true
|
||||||
|
},
|
||||||
|
|
||||||
onDateChange(value) {
|
onDateChange(value) {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beginDate() {
|
||||||
|
const self = this
|
||||||
|
return {
|
||||||
|
disabledDate(time) {
|
||||||
|
if (self.copyParam.rightDate && time.getTime() > Date.now()) {
|
||||||
|
return new Date(self.form.rightDate).getTime() < time.getTime()
|
||||||
|
} else {
|
||||||
|
return time.getTime() < Date.now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
processDate() {
|
||||||
|
const self = this
|
||||||
|
return {
|
||||||
|
disabledDate(time) {
|
||||||
|
if (self.copyParam.leftDate) {
|
||||||
|
return new Date(self.copyParam.leftDate).getTime() > time.getTime()
|
||||||
|
} else {
|
||||||
|
return time.getTime() < Date.now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onTimeChange(value) {
|
onTimeChange(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.form.startTime = value[0] + ':00.000'
|
this.form.startTime = value[0] + ':00.000'
|
||||||
@@ -265,6 +332,31 @@ export default {
|
|||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存复制的课程
|
||||||
|
*/
|
||||||
|
copyLessonByDay() {
|
||||||
|
if (this.copyParam.leftDate === '' || this.copyParam.leftDate === null) {
|
||||||
|
this.$message({
|
||||||
|
message: '请选择起始日期!',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.copyParam.rightDate === '' || this.copyParam.rightDate === null) {
|
||||||
|
this.$message({
|
||||||
|
message: '请选择结束日期!',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
copy(this.copyParam).then(response => {
|
||||||
|
this.$refs.pagination.handleSearch()
|
||||||
|
}).finally(() => {
|
||||||
|
this.dialogFormByDay = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询复制课程信息
|
* 查询复制课程信息
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
package com.sv.oms.controller;
|
package com.sv.oms.controller;
|
||||||
import com.sv.dto.oms.VenueLessonOmsDTO;
|
import com.sv.dto.oms.VenueLessonOmsDTO;
|
||||||
|
import com.sv.service.api.util.DateUtilCard;
|
||||||
import com.ydd.framework.core.common.Pagination;
|
import com.ydd.framework.core.common.Pagination;
|
||||||
import com.ydd.framework.core.common.dto.ResponseDTO;
|
import com.ydd.framework.core.common.dto.ResponseDTO;
|
||||||
import com.ydd.oms.controller.OmsController;
|
import com.ydd.oms.controller.OmsController;
|
||||||
import com.sv.entity.VenueLesson;
|
import com.sv.entity.VenueLesson;
|
||||||
import com.sv.service.oms.VenueLessonService;
|
import com.sv.service.oms.VenueLessonService;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller - 场馆课程
|
* Controller - 场馆课程
|
||||||
@@ -64,4 +68,16 @@ public class VenueLessonController extends OmsController {
|
|||||||
return ResponseDTO.ok("删除成功");
|
return ResponseDTO.ok("删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制课程
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/venue/lesson/copy", method = RequestMethod.POST)
|
||||||
|
public ResponseDTO copy(@RequestParam("lessonId") Integer lessonId,@RequestParam("leftDate") String leftDate,@RequestParam("rightDate") String rightDate) throws ParseException {
|
||||||
|
DateUtils.parseDate(leftDate,"YYYY-MM-DD");
|
||||||
|
Date start = DateUtilCard.getDateFromStr(leftDate);
|
||||||
|
Date end = DateUtilCard.getDateFromStr(rightDate);
|
||||||
|
venueLessonService.copy(lessonId,start,end);
|
||||||
|
return ResponseDTO.ok("保存成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF8"?>
|
<?xml version="1.0" encoding="UTF8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<jmxConfigurator />
|
<jmxConfigurator />
|
||||||
<property name="LOG_HOME" value="/home/logs/oms_log"/>
|
<property name="LOG_HOME" value="~/home/logs/oms_log"/>
|
||||||
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.sv.entity.MemberLessonTicket;
|
|||||||
import com.sv.entity.VenueLesson;
|
import com.sv.entity.VenueLesson;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,4 +141,13 @@ public interface VenueLessonMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<VenueLessonStatus> getLessonStatus(@Param("venueId") Integer venueId);
|
List<VenueLessonStatus> getLessonStatus(@Param("venueId") Integer venueId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询课程当天所有的信息
|
||||||
|
* @param venueId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<VenueLesson> getCopyLesson(@Param("venueId") Integer venueId,@Param("date") Date date);
|
||||||
|
|
||||||
|
void copyImg(@Param("id") Integer id,@Param("nId") Integer nId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,17 @@ package com.sv.service.api.util;
|
|||||||
|
|
||||||
import com.enums.VipTypeEnum;
|
import com.enums.VipTypeEnum;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
public class DateUtilCard {
|
public class DateUtilCard {
|
||||||
|
|
||||||
|
private final static SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd");
|
||||||
|
|
||||||
public static Date getYear(Date date){
|
public static Date getYear(Date date){
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(date);
|
calendar.setTime(date);
|
||||||
@@ -131,4 +135,25 @@ public class DateUtilCard {
|
|||||||
}
|
}
|
||||||
return endTime;
|
return endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Date getDateFromStr(String date){
|
||||||
|
try {
|
||||||
|
Date res = sdf.parse(date);
|
||||||
|
return res;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getStrFromDate(Date date){
|
||||||
|
return sdf.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date addOneDay(Date date){
|
||||||
|
Calendar calendar = new GregorianCalendar();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(calendar.DATE,1); //把日期往后增加一天,整数 往后推,负数往前移动
|
||||||
|
return calendar.getTime(); //这个时间就是日期往后推一天的结果
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.sv.dto.oms.VenueLessonOmsDTO;
|
import com.sv.dto.oms.VenueLessonOmsDTO;
|
||||||
import com.sv.entity.Platform;
|
import com.sv.entity.Platform;
|
||||||
import com.sv.entity.VenueLesson;
|
import com.sv.entity.VenueLesson;
|
||||||
|
import com.sv.entity.VenueLessonTag;
|
||||||
import com.sv.entity.VenueLessonTicket;
|
import com.sv.entity.VenueLessonTicket;
|
||||||
import com.sv.exception.oms.OmsException;
|
import com.sv.exception.oms.OmsException;
|
||||||
import com.sv.mapper.VenueLessonMapper;
|
import com.sv.mapper.VenueLessonMapper;
|
||||||
import com.sv.mapper.VenueLessonTagMapper;
|
import com.sv.mapper.VenueLessonTagMapper;
|
||||||
import com.sv.mapper.VenueLessonTicketMapper;
|
import com.sv.mapper.VenueLessonTicketMapper;
|
||||||
|
import com.sv.service.api.util.DateUtilCard;
|
||||||
import com.sv.service.common.OSSClientUtil;
|
import com.sv.service.common.OSSClientUtil;
|
||||||
import com.sv.service.common.PlatformService;
|
import com.sv.service.common.PlatformService;
|
||||||
import com.sv.service.common.RedisLock;
|
import com.sv.service.common.RedisLock;
|
||||||
@@ -31,10 +33,8 @@ import redis.clients.jedis.Jedis;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.function.Consumer;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.sv.entity.Constants.LESSON_TICKET_LOCK_KEY;
|
import static com.sv.entity.Constants.LESSON_TICKET_LOCK_KEY;
|
||||||
|
|
||||||
@@ -300,5 +300,30 @@ public class VenueLessonService extends BaseServiceImpl {
|
|||||||
return venueLessonMapper.countByCoachId(id);
|
return venueLessonMapper.countByCoachId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copy课程
|
||||||
|
* @param lessonId
|
||||||
|
* @param start
|
||||||
|
* @param end
|
||||||
|
*/
|
||||||
|
@Transactional(readOnly = false)
|
||||||
|
public void copy(Integer lessonId, Date start, Date end) {
|
||||||
|
VenueLesson byId = venueLessonMapper.findById(lessonId);
|
||||||
|
List<VenueLesson> copyLesson = venueLessonMapper.getCopyLesson(byId.getVenueId(), byId.getDate());
|
||||||
|
if (copyLesson != null && copyLesson.size() > 0){
|
||||||
|
while (!start.after(end)){
|
||||||
|
for (VenueLesson x : copyLesson) {
|
||||||
|
Integer oldId = x.getId();
|
||||||
|
x.setId(null);
|
||||||
|
x.setModifiedId(999);
|
||||||
|
x.setModifiedTime(new Date());
|
||||||
|
x.setDate(start);
|
||||||
|
venueLessonMapper.insert(x);
|
||||||
|
venueLessonMapper.copyImg(oldId, x.getId());
|
||||||
|
}
|
||||||
|
start = DateUtilCard.addOneDay(start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -622,4 +622,28 @@
|
|||||||
and a.venue_id = #{venueId}
|
and a.venue_id = #{venueId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- api 查询需要copy的信息 -->
|
||||||
|
<select id="getCopyLesson" resultMap="VenueLessonMap">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
sv_venue_lesson
|
||||||
|
WHERE
|
||||||
|
date = #{date}
|
||||||
|
AND venue_id = #{venueId}
|
||||||
|
AND deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- copy -->
|
||||||
|
<update id="copyImg">
|
||||||
|
INSERT INTO sv_venue_lesson_image
|
||||||
|
(lesson_id,url,platform_id,created_id,modified_id,created_time,modified_time,deleted)
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
#{nId},url,platform_id,created_id,'999',created_time,modified_time,deleted
|
||||||
|
FROM sv_venue_lesson_image where sv_venue_lesson_image.deleted = 0
|
||||||
|
AND sv_venue_lesson_image.lesson_id = #{id}
|
||||||
|
)
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user