Kaynağa Gözat

暑假大作战修改同步

shenhao 2 yıl önce
ebeveyn
işleme
51cac481a7

+ 15 - 0
src/main/java/com/ssj/api/filter/VacationExcelImportHelper.java

@@ -8,6 +8,7 @@ import com.ssj.framework.basic.config.bean.VersionConfig;
 import com.ssj.framework.core.util.SystemResourceLocator;
 import com.ssj.mapper.vacation.PrevMaterialMapper;
 import com.ssj.mapper.vacation.PrevMaterialUnitMapper;
+import com.ssj.service.vacation.ISummerVacationService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Component;
@@ -33,6 +34,9 @@ public class VacationExcelImportHelper {
     @Resource
     private PrevMaterialMapper prevMaterialMapper;
 
+    @Resource
+    private ISummerVacationService summerVacationService;
+
 
 //    public static void main(String[] args) {
 //        List<SumPrevExcelImportVO> dataList = new ArrayList<>();
@@ -104,9 +108,19 @@ public class VacationExcelImportHelper {
         //不校验数据有效性
         SumPrevMaterial prevMaterial = null;
         SumPrevMaterial temp = new SumPrevMaterial();
+        int i = 0;
         for (SumPrevExcelImportVO schoolImport : dataList) {
             //判断 学科	版本	年级	教材链接	上下册 这5个相等那么就是同一条数据
              //(schoolImport.getSemester().equals("上册")?1:2)!=temp.getSemester()
+            if(i==0){
+                temp = summerVacationService.findPreMaterialByAny(schoolImport.getSubject(),schoolImport.getVersionName(),schoolImport.getGrade(),schoolImport.getSemester());
+                if(temp == null){
+                    temp = new SumPrevMaterial();
+                }else{
+                    prevMaterial = new SumPrevMaterial();
+                    BeanUtils.copyProperties(temp,prevMaterial);
+                }
+            }
             if (schoolImport.getSubject().equals(temp.getSubject()) &&
                     schoolImport.getVersionName().equals(temp.getVersionName()) && schoolImport.getGrade().equals(temp.getGrade())
                     && (schoolImport.getSemester().equals("上册")?1:2) ==temp.getSemester()) {
@@ -131,6 +145,7 @@ public class VacationExcelImportHelper {
             materialUnit.setUnitId(schoolImport.getUnitId());
             materialUnit.setUnitSort(schoolImport.getUnitSort());
             materialUnit.setParentId(prevMaterial.getId());
+            materialUnit.setSubject(schoolImport.getSubject());
             materialUnit.setCreateTime(new Date());
             prevMaterialUnitMapper.insert(materialUnit);
         }

+ 2 - 0
src/main/java/com/ssj/bean/vacation/SumPrevMaterialUnit.java

@@ -34,6 +34,8 @@ public class SumPrevMaterialUnit {
     @TableField("parent_id")
     private String parentId;
 
+    @TableField("subject")
+    private String subject;
     /**
      * 单元名称
      */

+ 3 - 0
src/main/java/com/ssj/service/vacation/ISummerVacationService.java

@@ -2,6 +2,7 @@ package com.ssj.service.vacation;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ssj.api.domain.vo.vacation.*;
+import com.ssj.bean.vacation.SumPrevMaterial;
 
 import java.util.List;
 
@@ -34,4 +35,6 @@ public interface ISummerVacationService {
     void revMaterialVersion(VersionVo param);
 
     void delRevMaterialVersion(VersionVo param);
+
+    SumPrevMaterial findPreMaterialByAny(String subject, String versionName, String grade, String semester);
 }

+ 8 - 0
src/main/java/com/ssj/service/vacation/impl/SummerVacationServiceImpl.java

@@ -94,6 +94,9 @@ public class SummerVacationServiceImpl implements ISummerVacationService {
     public void delPreMaterialVersion(VersionVo param) {
         if(param.getId()!= null && !"".equals(param.getId())){
             prevMaterialMapper.deleteById(param.getId());
+            //删除子表信息
+            prevMaterialUnitMapper.delete(new QueryWrapper<SumPrevMaterialUnit>()
+                    .eq("parent_id",param.getId()));
         }
     }
 
@@ -174,6 +177,11 @@ public class SummerVacationServiceImpl implements ISummerVacationService {
         }
     }
 
+    @Override
+    public SumPrevMaterial findPreMaterialByAny(String subject, String versionName, String grade, String semester) {
+        return prevMaterialMapper.selectOne(new QueryWrapper<SumPrevMaterial>().eq("subject",subject).eq("grade",grade).eq("version_name",versionName).eq("semester",semester.equals("上册")?1:2));
+    }
+
     private String getVersionNameByType(int type,String subject){
         Map<String, List<VersionConfig>> data = SystemResourceLocator.getVersionList(subject);
         String reStr = "";

+ 4 - 6
src/main/java/com/ssj/sys/controller/SummerVacationController.java

@@ -271,7 +271,7 @@ public class SummerVacationController extends BaseController {
 
     @IgnoreSecurity
     @RequestMapping(value = "/del/revMaterialVersion", method = RequestMethod.POST)
-    @ApiOperation(value = "删除预习教材版本信息",  notes = "删除预习教材版本信息")
+    @ApiOperation(value = "删除复习教材版本信息",  notes = "删除复习教材版本信息")
     @ResponseBody
     public ResponseJrEntity delRevMaterialVersion(@RequestBody VersionVo param) {
         ResponseJrEntity responseEntity = new ResponseJrEntity();
@@ -295,15 +295,13 @@ public class SummerVacationController extends BaseController {
             List<SumPrevExcelImportVO> list = ExcelImportUtil.importExcel(
                     file.getInputStream(), SumPrevExcelImportVO.class, params);
             excelImportHelper.dataImporting(list);
-//            EasyExcel.read(file.getInputStream(), SumPrevExcelImportVO.class, vacationImportListener)
-//                    .sheet(0)
-//                    .headRowNumber(2)
-//                    .doRead();
+            return AjaxResult.success();
         } catch (Exception e) {
             e.printStackTrace();
             log.error("Add new school while uploading excel file throw an exception ======= {}", e.getMessage());
+            return AjaxResult.error("导入异常,请检查列中数据是否符合要求!"+e.getCause());
         }
-        return AjaxResult.success();
+
     }
 
 }

+ 39 - 73
src/main/resources/templates/sys/vacation/review.html

@@ -1,4 +1,4 @@
-
+<!DOCTYPE html>
 <html>
 <head>
     <title>私塾家</title>
@@ -98,11 +98,11 @@
                             <el-table-column type="expand">
                                 <template slot-scope="props">
                                     <el-form  label-position="left" inline class="demo-table-expand unit_item">
-                                        <div v-for="(item,index) in props.row.unitList">
+                                        <div v-for="(item,index) in props.row.unitList" :key="index">
                                             <el-form-item label="单元名称">
                                                 <span :title="item.unitName">{{ item.unitName}}</span>
                                             </el-form-item>
-                                            <el-form-item v-if="item.videoList&&(item.videoList[0].videoLink!=''||item.videoList[0].videoName!='')">
+                                            <el-form-item v-if="item.videoList.length>0&&(item.videoList[0].videoLink!=''||item.videoList[0].videoName!='')">
                                                 <div  class="link link2"><i class="el-icon-link"></i> <a target="_blank" :href="item.videoList[0].videoLink"><span :title="item.videoList[0].videoName">{{item.videoList[0].videoName}}</span></a></div>
                                             </el-form-item>
                                             <el-form-item style="float:right">
@@ -136,7 +136,7 @@
                                     label="链接"
                                     align="center" width="130">
                                 <template slot-scope="scope">
-                                    <div class="link"><i class="el-icon-link"></i> <a target="_blank" :href="scope.row.materialLink">教材链接</a></div>
+                                    <div class="link" v-if='scope.row.materialLink'><i class="el-icon-link"></i> <a target="_blank" :href="scope.row.materialLink">教材链接</a></div>
                                 </template>
                             </el-table-column>
                             <el-table-column
@@ -163,7 +163,6 @@
                             >
                             </el-pagination>
                         </div>
-                        </template>
                     </div>
                 </el-tab-pane>
                 <el-tab-pane label="复习" name="second">
@@ -209,7 +208,6 @@
                             >
                             </el-pagination>
                         </div>
-                        </template>
                     </div>
                 </el-tab-pane>
             </el-tabs>
@@ -378,9 +376,9 @@
                 volume: [
                     { required: true, message: '请选择上下册', trigger: 'change' },
                 ],
-                link: [
-                    { required: true, message: '请输入链接', trigger: 'blur' },
-                ],
+                // link: [
+                //   { required: true, message: '请输入链接', trigger: 'blur' },
+                // ],
             },
             activeName:'first',
             tabPosition:'语文',
@@ -432,66 +430,6 @@
                 }
             ],
             expands:[],
-            tableData: [{
-                "id": "xxx",
-                "subject": "科目",
-                "versionType": "版本数字描述",
-                "versionName": "版本文字描述",
-                "grade":"年级",
-                "semester":1,
-                "materialLink":"http://baidu.com",
-                "unitList":[
-                    {"id": "xxx",
-                        "unitId":"单元Id",
-                        "versionType": "版本数字描述",
-                        "versionName": "版本文字描述",
-                        "grade":"年级",
-                        "unitName":"单元",
-                        "videoList":[
-                            {'videoLink':"",
-                                'videoName':""}
-                        ]
-                    },
-                    {"id": "xxx",
-                        "unitId":"单元Id",
-                        "versionType": "版本数字描述",
-                        "versionName": "版本文字描述",
-                        "grade":"年级",
-                        "unitName":"单元",
-                        "videoList":[
-                            {'videoLink':"21312",
-                                'videoName':""}
-                        ]
-                    }
-                ]
-                //"subject": "科目",
-                //"versionType": "版本数字描述",
-                //"versionName": "版本文字描述"
-            },{
-                "id": "xxx",
-                "subject": "科目",
-                "versionType": "版本数字描述",
-                "versionName": "版本文字描述",
-                "grade":"年级",
-                "semester":1,
-                "materialLink":"http://baidu.com",
-                "unitList":[
-                    {"id": "xxx",
-                        "unitId":"单元Id",
-                        "versionType": "版本数字描述",
-                        "versionName": "版本文字描述",
-                        "grade":"年级",
-                        "unitName":"单元",
-                        "videoList":[
-                            {'videoLink':"21312",
-                                'videoName':""}
-                        ]
-                    }
-                ]
-                //"subject": "科目",
-                //"versionType": "版本数字描述",
-                //"versionName": "版本文字描述"
-            }],
             tableData_p:[],
             tableData_r:[],
             material_title:'添加教材',
@@ -578,7 +516,8 @@
                 });
 
                 var data={params:param};
-                var Host='[[${sysUrl}]]'
+                var Host='[[${sysUrl}]]/sys';
+                axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
                 axios.get(Host+url,data,successFunction)
                     .then((response)=> {
                         loading.close();
@@ -619,12 +558,14 @@
                     spinner: 'el-icon-loading',
                     background: 'rgba(0, 0, 0, 0)'
                 });
-                var Host='[[${sysUrl}]]'
+                var Host='[[${sysUrl}]]/sys';
+                axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
                 axios.post(Host+url,param,config)
                     .then((response)=> {
                         successFunction(response.data);
                         loading.close();
                     }).catch((res)=>{
+
                     loading.close();
                     if(typeof(errorFunction) == 'function'){
                         errorFunction(res);
@@ -716,7 +657,6 @@
                             this.page_p.total = data.total;
                             if(expand){
                                 this.expands=[expand];
-                                console.log(this.expands)
                             }
                         }
                     });
@@ -850,6 +790,32 @@
             submit_addUnit(formName){
                 this.$refs[formName].validate((valid) => {
                     if (valid) {
+                        var flag='1';
+                        this.videoList.forEach(element => {
+                            if(element.videoLink==''&&element.videoName!=''){
+                                this.$message({
+                                    type: 'warning',
+                                    message: `请输入视频${element.videoName}的视频链接`
+                                });
+                                flag='2';
+                            }
+                            if(element.videoLink!=''&&element.videoName==''){
+                                this.$message({
+                                    type: 'warning',
+                                    message: `请输入视频链接为${element.videoLink}的视频名称`
+                                });
+                                flag=2;
+                            }
+                        });
+                        if(flag==2){
+                            return;
+                        }
+                        var unitList=[];
+                        this.videoList.forEach(element => {
+                            if(element.videoLink!=''||element.videoName!=''){
+                                unitList.push(element);
+                            }
+                        });
                         this.post(
                             "/summerVacation/edit/preUnitVersion",
                             {
@@ -857,7 +823,7 @@
                                 unitName:this.unit_form.unitName,
                                 unitId:this.unit_form.unitId,
                                 parentId:this.unit_form.parentId,
-                                unitList:this.videoList,
+                                unitList:unitList,
                             },
                             (data) => {
                                 if (data.code == 200) {