he2802 3 tahun lalu
induk
melakukan
4ecac048e0

+ 1 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/alioss/OssController.java

@@ -64,7 +64,7 @@ public class OssController extends BaseController {
      */
     @ApiOperation("上传file图片")
     @PostMapping("/upload")
-    public AjaxResult<String> upload(OssRequest file) throws Exception {
+    public AjaxResult<String> upload( OssRequest file) throws Exception {
         String result = ossService.upload(file);
         log.info("服务端生成签名:{}",result);
         return AjaxResult.success("返回图片路径",result);

+ 12 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/poi/ExcelUtil.java

@@ -241,6 +241,18 @@ public class ExcelUtil<T>
                                     val = Convert.toStr(val);
                                 }
                             }
+                            if (val instanceof Date)
+                            {
+                                String dateFormat = field.getAnnotation(Excel.class).dateFormat();
+                                if (Validator.isNotEmpty(dateFormat))
+                                {
+                                    val = DateUtils.parseDateToStr(dateFormat, (Date) val);
+                                }
+                                else
+                                {
+                                    val = Convert.toStr(val);
+                                }
+                            }
 
                         }
                     }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/alioss/bo/OssRequest.java

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiParam;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.springframework.boot.context.properties.bind.DefaultValue;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.constraints.NotNull;

+ 2 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/alioss/service/impl/OssServiceImpl.java

@@ -104,10 +104,10 @@ public class OssServiceImpl implements OssService {
 
     public String generateRandomFilename(OssRequest ossRequest) {
         String prefixName = "";
-        if(Validator.isNotEmpty(ossRequest.getUserId())){
+        if(Validator.isNotEmpty(ossRequest.getUserId())&&ossRequest.getUserId().longValue()>0){
             prefixName = prefixName + ossRequest.getUserId()+"/";
         }
-        if(Validator.isNotEmpty(ossRequest.getGradeId())){
+        if(Validator.isNotEmpty(ossRequest.getGradeId())&&ossRequest.getGradeId().longValue()>0){
             prefixName = prefixName + ossRequest.getGradeId()+"/";
         }
         String RandomFilename = "";

+ 34 - 16
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.course.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -203,11 +204,15 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                errorLog+="第"+Index+"条:"+"节标题空白。\r\n";
                 continue;
             }
-            System.out.println(sectionImport);
+
             if(!Validator.isNotEmpty(sectionImport.getPublishStatus())){
                 errorLog+="第"+Index+"条:"+"发布状态空白。\r\n";
                 continue;
             }
+            if(!sectionImport.getPublishStatus().equals("发布")&&!sectionImport.getPublishStatus().equals("未发布")){
+                errorLog+="第"+Index+"条:"+"发布状态错误。\r\n";
+                continue;
+            }
             //业务层次,导入每条只有一条业务层次
             List<CourseSectionBusinessAddBo> businessList = new ArrayList<>();
             CourseSectionBusinessAddBo addBo = new CourseSectionBusinessAddBo();
@@ -216,14 +221,14 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                 errorLog+="第"+Index+"条:"+sectionImport.getEducationType()+"-该教育类型不存在。\r\n";
                 continue;
             }
-            Long projectId = findProjectId(sectionImport.getProject());
+            Long projectId = findProjectId(sectionImport.getProject(),eduId);
             if(!Validator.isNotEmpty(projectId)){
-                errorLog+="第"+Index+"条:"+sectionImport.getProject()+"-该项目类型不存在。\r\n";
+                errorLog+="第"+Index+"条:"+sectionImport.getProject()+"-该项目类型不存在或者和教育类型不匹配。\r\n";
                 continue;
             }
-            Long businessId = findBusinessId(sectionImport.getBusiness());
+            Long businessId = findBusinessId(sectionImport.getBusiness(),projectId);
             if(!Validator.isNotEmpty(businessId)){
-                errorLog+="第"+Index+"条:"+sectionImport.getBusiness()+"-该业务层次不存在。\r\n";
+                errorLog+="第"+Index+"条:"+sectionImport.getBusiness()+"-该业务层次不存在或者和项目类型不匹配。\r\n";
                 continue;
             }
             Long subjectId = findSubjectId(sectionImport.getSubject());
@@ -256,15 +261,28 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
             bo.setStatus(1);
             bo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
             if(Validator.isNotEmpty(sectionImport.getLiveStartTime())){
-
-                System.out.println(sectionImport.getLiveStartTime());
-                System.out.println("开始时间");
-        /*        Long startTime = sectionImport.getLiveStartTime().getTime()/1000;
-                bo.setLiveStartTime(startTime);*/
+                if(sectionImport.getLiveStartTime().length()!=19){
+                    errorLog+="第"+Index+"条:直播开始时间不对。\r\n";
+                    continue;
+                }
+                try{
+                    bo.setLiveStartTime(Convert.toLong(DateUtils.dateTimeThrow("yyyy-MM-dd HH:mm:ss",sectionImport.getLiveStartTime()).getTime())/1000);
+                }catch (ParseException e){
+                    errorLog+="第"+Index+"条:直播开始时间不对。\r\n";
+                    continue;
+                }
             }
             if(Validator.isNotEmpty(sectionImport.getLiveEndTime())){
-                /*Long endTime = sectionImport.getLiveEndTime().getTime()/1000;
-                bo.setLiveEndTime(endTime);*/
+                if(sectionImport.getLiveStartTime().length()!=19){
+                    errorLog+="第"+Index+"条:直播结束时间不对。\r\n";
+                    continue;
+                }
+                try{
+                    bo.setLiveEndTime(Convert.toLong(DateUtils.dateTimeThrow("yyyy-MM-dd HH:mm:ss",sectionImport.getLiveEndTime()).getTime())/1000);
+                }catch (ParseException e){
+                    errorLog+="第"+Index+"条:直播结束时间不对。\r\n";
+                    continue;
+                }
             }
             errorLog = insertByAddBoImport(bo,errorLog,Index);
             i++;
@@ -342,7 +360,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
         return null;
     }
 
-    public Long findProjectId(String project){
+    public Long findProjectId(String project,Long eduId){
         if(project!=null){
             String key = "PROJ_"+project;
             Long value = redisCache.getCacheObject(key);
@@ -353,7 +371,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                 return value;
             }
             CourseProjectType info = iCourseProjectTypeService.getOne(new LambdaQueryWrapper<CourseProjectType>()
-                    .eq(CourseProjectType::getProjectName,project).eq(CourseProjectType::getStatus,1).last("limit 1"));
+                    .eq(CourseProjectType::getProjectName,project).eq(CourseProjectType::getEducationId,eduId).eq(CourseProjectType::getStatus,1).last("limit 1"));
             if(info!=null){
                 redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
                 return info.getId();
@@ -364,7 +382,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
         return null;
     }
 
-    public Long findBusinessId(String business){
+    public Long findBusinessId(String business,Long projectId){
         if(business!=null){
             String key = "BUS_"+business;
             Long value = redisCache.getCacheObject(key);
@@ -375,7 +393,7 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
                 return value;
             }
             CourseBusiness info = iCourseBusinessService.getOne(new LambdaQueryWrapper<CourseBusiness>()
-                    .eq(CourseBusiness::getBusinessName,business).eq(CourseBusiness::getStatus,1).last("limit 1"));
+                    .eq(CourseBusiness::getBusinessName,business).eq(CourseBusiness::getProjectId,projectId).eq(CourseBusiness::getStatus,1).last("limit 1"));
             if(info!=null){
                 redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
                 return info.getId();