yangdamao 2 年之前
父節點
當前提交
ed2e964934

+ 29 - 34
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserSubscribeController.java

@@ -1,53 +1,38 @@
 package com.zhongzheng.controller.user;
 
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.zhongzheng.common.core.domain.model.LoginUser;
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.common.enums.BusinessType;
 import com.zhongzheng.common.utils.DateUtils;
-import com.zhongzheng.common.utils.ServletUtils;
-import com.zhongzheng.modules.bank.vo.QuestionImport;
-import com.zhongzheng.modules.base.vo.UserProfileExportGaiVo;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.exam.bo.ExamApplyGoodsQueryBo;
 import com.zhongzheng.modules.exam.service.IExamApplyGoodsService;
 import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
-import com.zhongzheng.modules.exam.vo.ExamApplyVo;
-import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
-import com.zhongzheng.modules.grade.vo.ClassPeriodStudentExportVo;
-import com.zhongzheng.modules.grade.vo.ClassStudentExportVo;
+import com.zhongzheng.modules.exam.vo.ExamSessionVo;
 import com.zhongzheng.modules.user.bo.*;
-import com.zhongzheng.modules.user.domain.UserBankRecord;
 import com.zhongzheng.modules.user.service.IUserExamGoodsService;
-import com.zhongzheng.modules.user.vo.*;
-import lombok.RequiredArgsConstructor;
-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.zhongzheng.common.annotation.Log;
-import com.zhongzheng.common.core.controller.BaseController;
-import com.zhongzheng.common.core.domain.AjaxResult;
-import com.zhongzheng.common.enums.BusinessType;
 import com.zhongzheng.modules.user.service.IUserSubscribeService;
-import com.zhongzheng.common.utils.poi.ExcelUtil;
-import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.user.vo.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 用户预约考试Controller
  *
@@ -78,6 +63,16 @@ public class UserSubscribeController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 根据月份获取当月考试场次
+     */
+    @ApiOperation("根据月份获取当月考试场次")
+    @GetMapping("/session/{month}")
+    public AjaxResult<List<ExamSessionVo>> getExamSession(@PathVariable("month")Integer month) {
+        List<ExamSessionVo> list = iUserSubscribeService.getExamSession(month);
+        return AjaxResult.success(list);
+    }
+
     /**
      * 修改用户预约考试
      */

+ 5 - 2
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -1513,11 +1513,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
 
         Map<String, String> split = Splitter.on("&").withKeyValueSeparator("=").split(param);
         Long goodsId = Long.valueOf(split.get("gid"));
+        Long tenantId = user.getTenantId();
 
         //获取对应商品
-        Goods goods = iGoodsService.getGoodsByIdNotTenant(goodsId);
+        Goods goods = iGoodsService.queryGoodsByIdTenant(goodsId,tenantId);
+        if (ObjectUtils.isNull(goods)){
+            throw new CustomException("账号不匹配,请重新登录!");
+        }
 
-        Long tenantId = user.getTenantId();
         //组装跳转路径
         SysTenant tenant = iSysTenantService.getById(tenantId);
         String post = "";

+ 17 - 13
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -657,21 +657,25 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     }
 
     private Long liveTime(Long nowTime, Integer day) {
-        Long dayAfter = DateUtils.getDayAfter(nowTime, day);
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(DateUtils.timeToDate(dayAfter));
-        int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
-        String[] weeks = new String[]{"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
-        if (weeks[index].equals("星期六") || weeks[index].equals("星期天")) {
-            //周末
-            liveTime(nowTime,day + 1);
-        }
+        for (Integer i = 0; i < day; i++) {
+            Long dayAfter = DateUtils.getDayAfter(nowTime, 1);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(DateUtils.timeToDate(dayAfter));
+            int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+            String[] weeks = new String[]{"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+            if (weeks[index].equals("星期六") || weeks[index].equals("星期天")) {
+                day += 1;
 
-        //判断当前是否为工作日
-        if (!DateUtils.isWorkingDay(dayAfter)) {
-            liveTime(nowTime,day + 1);
+            }
+            //判断当前是否为工作日
+            if (!DateUtils.isWorkingDay(dayAfter)) {
+                day += 1;
+            }
+            nowTime = dayAfter;
         }
-        return dayAfter;
+
+        return nowTime;
     }
 
     private List<UserStudyRecordPhotoVo> entity2PhotoVo(Collection<UserStudyRecordPhoto> collection) {

+ 26 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamSessionVo.java

@@ -0,0 +1,26 @@
+package com.zhongzheng.modules.exam.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年07月04日 14:51
+ */
+@Data
+public class ExamSessionVo implements Serializable {
+
+    @ApiModelProperty("考场场次")
+    private String examSession;
+
+    @ApiModelProperty("考试日期")
+    private Long examTime;
+
+    @ApiModelProperty("考点开始时间")
+    private String examStartTime;
+
+    @ApiModelProperty("考点结束时间")
+    private String examEndTime;
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -134,4 +134,7 @@ public interface IGoodsService extends IService<Goods> {
     Goods getGoodsByTenantTwo(String goodsName, String code, Long tenantId);
 
     boolean goodsNodeCopyAddTenant(GoodsNodeCopyTenantBo bo);
+
+	Goods queryGoodsByIdTenant(Long goodsId, Long tenantId);
+
 }

+ 19 - 14
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -719,20 +719,20 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         }
 
         //修改商品课程节观看权限
-        List<CourseMenuAddBo> menuList = bo.getMenuList();
-        if (CollectionUtils.isEmpty(menuList)) {
-            //商品下没有课程/节
-            iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
-                    .set(CourseSectionWatchPer::getStatus, 0)
-                    .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId()));
-        } else {
-            //对比观看权限
-            List<Long> courseIds = menuList.stream().map(CourseMenuAddBo::getCourseId).collect(Collectors.toList());
-            iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
-                    .set(CourseSectionWatchPer::getStatus, 0)
-                    .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId())
-                    .notIn(CourseSectionWatchPer::getCourseId, courseIds));
-        }
+//        List<CourseMenuAddBo> menuList = bo.getMenuList();
+//        if (CollectionUtils.isEmpty(menuList)) {
+//            //商品下没有课程/节
+//            iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
+//                    .set(CourseSectionWatchPer::getStatus, 0)
+//                    .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId()));
+//        } else {
+//            //对比观看权限
+//            List<Long> courseIds = menuList.stream().map(CourseMenuAddBo::getCourseId).collect(Collectors.toList());
+//            iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
+//                    .set(CourseSectionWatchPer::getStatus, 0)
+//                    .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId())
+//                    .notIn(CourseSectionWatchPer::getCourseId, courseIds));
+//        }
 
         return this.updateById(update);
     }
@@ -4556,6 +4556,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return false;
     }
 
+    @Override
+    public Goods queryGoodsByIdTenant(Long goodsId, Long tenantId) {
+        return baseMapper.queryGoodsByIdTenant(goodsId,tenantId);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean updateGoodsRepair(UpdateGoodsRepairBo bo) {

+ 33 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -1705,16 +1705,16 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                 //创建考试
                 ExamApply examApply = new ExamApply();
                 examApply.setApplyUrl("oss/images/avatar/20211013/1634097664410_1397766697");//默认图片地址
-                examApply.setApplyName(String.format("【%s-%s】考试",getTimeStr(millisecond,item.getStartTime()),getTimeStr(millisecond,item.getEndTime())));
+                examApply.setApplyName(String.format("【%s-%s】【%s】的考试",getTimeStr(millisecond,item.getStartTime()),getTimeStr(millisecond,item.getEndTime()),getWeeks(millisecond)));
                 examApply.setApplyIntroduce("系统生成");
                 examApply.setApplyStatus("1,2");
 
-                Long dayBefore = DateUtils.getDayBefore(millisecond,14);
+                Long dayBefore = getApplyEndTime(millisecond,7);
                 if (DateUtils.getNowTime() > dayBefore){
                     examApply.setApplyStartTime(DateUtils.getDayBefore(dayBefore,30));
                     examApply.setApplyEndTime(dayBefore);
                 }else {
-                    examApply.setApplyStartTime(DateUtils.getNowTime());
+                    examApply.setApplyStartTime(DateUtils.getDayBefore(dayBefore,30));
                     examApply.setApplyEndTime(dayBefore);
                 }
                 examApply.setCreateTime(DateUtils.getNowTime());
@@ -1773,6 +1773,36 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
 
     }
 
+    private String getWeeks(Long time){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(DateUtils.timeToDate(time));
+        int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        String[] weeks = new String[]{"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+        return weeks[index];
+    }
+
+    private Long getApplyEndTime(Long millisecond, Integer day) {
+        for (Integer i = 0; i < day; i++) {
+            Long dayAfter = DateUtils.getDayBefore(millisecond, 1);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(DateUtils.timeToDate(dayAfter));
+            int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+            String[] weeks = new String[]{"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+            if (weeks[index].equals("星期六") || weeks[index].equals("星期天")) {
+                day += 1;
+
+            }
+            //判断当前是否为工作日
+            if (!DateUtils.isWorkingDay(dayAfter)) {
+                day += 1;
+            }
+            millisecond = dayAfter;
+        }
+
+        return millisecond;
+    }
+
     private Long getTime(Long applyTime,String siteTime){
         String content = DateUtils.timestampToDateFormat(applyTime, "yyyy-MM-dd");
         String format1 = String.format("%s %s", content, siteTime);

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserSubscribeService.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.user.service;
 
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
+import com.zhongzheng.modules.exam.vo.ExamSessionVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
 import com.zhongzheng.modules.user.vo.*;
@@ -102,4 +103,5 @@ public interface IUserSubscribeService extends IService<UserSubscribe> {
 
 	Long saveByAddBo(UserSubscribeAddBo bo) throws ParseException;
 
+	List<ExamSessionVo> getExamSession(Integer month);
 }

+ 40 - 10
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -42,6 +42,7 @@ import com.zhongzheng.modules.exam.service.IExamApplySiteTimeService;
 import com.zhongzheng.modules.exam.vo.ExamApplySiteTimeTwoVo;
 import com.zhongzheng.modules.exam.vo.ExamApplySiteVo;
 import com.zhongzheng.modules.exam.vo.ExamApplyVo;
+import com.zhongzheng.modules.exam.vo.ExamSessionVo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
@@ -75,12 +76,20 @@ import java.io.*;
 import java.net.URL;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
 import java.util.List;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.zip.ZipOutputStream;
 
+import static java.util.stream.Collectors.toCollection;
+import static java.util.stream.IntStream.rangeClosed;
+
 /**
  * 用户预约考试Service业务层处理
  *
@@ -2093,6 +2102,25 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         return add.getSubscribeId();
     }
 
+    @Override
+    public List<ExamSessionVo> getExamSession(Integer month) {
+        //根据月份筛选
+        return null;
+    }
+
+    public static void main(String[] args) {
+        String dateStr = "202306"; // 指定年月
+        LocalDate date = LocalDate.parse(dateStr + "01", DateTimeFormatter.BASIC_ISO_DATE);
+        LocalDate dateFirst = date.with(TemporalAdjusters.firstDayOfMonth()); // 指定年月的第一天
+        LocalDate dateEnd = date.with(TemporalAdjusters.lastDayOfMonth()); // 指定年月的最后一天
+        ZonedDateTime zonedDateTime1 = dateFirst.atStartOfDay(ZoneId.systemDefault());
+        Date date1 = Date.from(zonedDateTime1.toInstant());
+        ZonedDateTime zonedDateTime = dateEnd.atStartOfDay(ZoneId.systemDefault());
+        Date date2 = Date.from(zonedDateTime.toInstant());
+        System.out.println("dateFirst = " + date1.getTime());
+        System.out.println("dateEnd = " + date2.getTime());
+    }
+
     private Integer getSeatNumber(UserSubscribeAddBo bo,Long userNum) {
         List<UserSubscribe> list = list(new LambdaQueryWrapper<UserSubscribe>().eq(UserSubscribe::getApplyId, bo.getApplyId())
                 .eq(UserSubscribe::getApplySiteStartTime, bo.getApplySiteStartTime())
@@ -2108,20 +2136,22 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         if (list.stream().allMatch(x -> ObjectUtils.isNull(x.getSeatNumber()))){
             return 1;
         }
-        Integer num = 0;
-        randomNum(list,num);
-        return num;
-    }
 
-    private void randomNum(List<UserSubscribe> list, Integer num) {
-        Random random = new Random();
-        Integer tNum = 1 + random.nextInt(50);
-        if (list.stream().anyMatch(x -> Integer.parseInt(x.getSeatNumber()) == tNum)){
-            randomNum(list,num);
+        List<Integer> nums = list.stream().map(x -> Integer.valueOf(x.getSeatNumber())).collect(Collectors.toList());
+        SortedSet<Integer> set = new TreeSet<Integer>(nums);
+        TreeSet<Integer> collect = rangeClosed(1, set.last()).boxed()
+                .filter(i -> !set.contains(i))
+                .collect(toCollection(TreeSet::new));
+        if (CollectionUtils.isNotEmpty(collect)){
+            Integer num = collect.stream().sorted(Comparator.comparing(o -> o)).findFirst().get();
+            return num;
         }
-        num = tNum;
+        Integer integer = nums.stream().max(Comparator.comparing(o -> o)).get();
+        return integer + 1;
     }
 
+
+
     private String drawReport(String imageStr, UserSubscribeSignReportBo bo){
         Font font = new Font("宋体", Font.BOLD, 48);// 添加字体的属性设置 微软雅黑
         String imgName = null;