|
@@ -22,7 +22,9 @@ import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.PageUtil;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
+import com.ym.mec.util.excel.POIUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -30,6 +32,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
@@ -67,7 +72,7 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
BeanUtils.copyProperties(dto, entity);
|
|
|
Date now = new Date();
|
|
|
//训练时间必需大于报名时间
|
|
|
- if (dto.getTrainStartDate().getTime() > dto.getApplyStartDate().getTime()) {
|
|
|
+ if (dto.getApplyStartDate().getTime() > dto.getTrainStartDate().getTime()) {
|
|
|
throw new BizException("训练时间必需大于报名时间");
|
|
|
}
|
|
|
entity.setState(TempLittleArtistTrainingCamp.NOT_START);
|
|
@@ -186,7 +191,7 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
}
|
|
|
TempUserTrainingTimeDetailVo tempUserTrainingTimeDetailVo = new TempUserTrainingTimeDetailVo();
|
|
|
tempUserTrainingTimeDetailVo.setUserId(userId);
|
|
|
- tempUserTrainingTimeDetailVo.setTrainingDate(camp.getTrainStartDate());
|
|
|
+ tempUserTrainingTimeDetailVo.setTrainingDate(DateUtil.toDate(generateDate.toString()));
|
|
|
tempUserTrainingTimeDetailVo.setPlayTime(BigDecimal.ZERO);
|
|
|
tempUserTrainingTimeDetailVo.setIsFinish(0);
|
|
|
resultList.add(tempUserTrainingTimeDetailVo);
|
|
@@ -257,6 +262,9 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
//查询该学员是否购买过该训练营
|
|
|
TempLittleArtistTrainingCampUserRelation userRelation = tempLittleArtistTrainingCampUserRelationService.getOne(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
|
|
|
.eq(TempLittleArtistTrainingCampUserRelation::getUserId, user.getId()));
|
|
|
+ if (Objects.isNull(userRelation)) {
|
|
|
+ throw new BizException("没有参与资格!");
|
|
|
+ }
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("user", userRelation);
|
|
|
if (CollectionUtils.isNotEmpty(campList)) {
|
|
@@ -307,7 +315,7 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
List<TempLittleArtistTrainingCamp> list = stateMap.get(oldState);
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
list.forEach(camp -> {
|
|
|
- if ( now.getTime() >= dateField.apply(camp).getTime()) {
|
|
|
+ if (now.getTime() >= dateField.apply(camp).getTime()) {
|
|
|
camp.setState(newState);
|
|
|
}
|
|
|
});
|
|
@@ -347,6 +355,38 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出小小训练营想详情
|
|
|
+ */
|
|
|
+ public void exportUserTrainingDetail(Map<String, Object> param, HttpServletResponse response) throws IOException {
|
|
|
+ List<TempCampUserTrainingDetailVo> list = baseMapper.queryUserTrainingDetail(param);
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ HSSFWorkbook workbook = null;
|
|
|
+ try {
|
|
|
+ String[] header = {"学员编号", "学员姓名", "手机号", "群组", "打卡天数", "训练时长(分钟)"};
|
|
|
+ String[] body = {"id", "username", "phone", "imGroupName", "playDay", "playTime"};
|
|
|
+ workbook = POIUtil.exportExcel(header, body, list);
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
|
|
|
+ response.flushBuffer();
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+ outputStream.flush();
|
|
|
+ workbook.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ workbook.close();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private SysUser getUser() {
|
|
|
return Optional.ofNullable(sysUserFeignService.queryUserInfo())
|
|
|
.orElseThrow(() -> new BizException("用户信息获取失败,请刷新页面或者重新登录!"));
|