浏览代码

Merge branch 'henandk' of http://49.234.186.218:9000/root/ieplus into henandk

mingfu 1 周之前
父节点
当前提交
2b74d871d2

+ 11 - 12
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontNewsController.java

@@ -14,6 +14,7 @@ import com.ruoyi.syzy.domain.BWwwNews;
 import com.ruoyi.syzy.domain.BWwwNewsRef;
 import com.ruoyi.syzy.service.IBWwwNewsRefService;
 import com.ruoyi.syzy.service.IBWwwNewsService;
+import com.ruoyi.web.service.CommService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -43,6 +44,8 @@ public class FrontNewsController extends BaseController {
 
     @Autowired
     private ISysConfigService sysConfigService;
+    @Autowired
+    private CommService commService;
     @GetMapping("types")
     @ApiOperation("00 高考资讯类型")
     public TableDataInfo types() {
@@ -72,10 +75,7 @@ public class FrontNewsController extends BaseController {
     @ApiOperation("00 通关指南")
     public TableDataInfo getMainList(@ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location) {
         BWwwNewsRef cond = new BWwwNewsRef();
-        if(StringUtils.isBlank(location) && StringUtils.isBlank((location = VistorContextHolder.getLocation()))) {
-            cond.setLocation("湖南");
-        }
-        cond.setLocation(location);
+        cond.setLocation(commService.getLocation(location));
         return getDataTable(newsRefService.selectBWwwNewsRefList(cond));
     }
 
@@ -83,7 +83,7 @@ public class FrontNewsController extends BaseController {
     @ApiOperation("00 通关指南免登陆")
     public TableDataInfo getMainListNoToken(@ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location) {
         BWwwNewsRef cond = new BWwwNewsRef();
-        cond.setLocation(StringUtils.isNotBlank(location) ? location : "湖南");
+        cond.setLocation(commService.getLocation(location));
         return getDataTable(newsRefService.selectBWwwNewsRefList(cond));
     }
 
@@ -110,26 +110,23 @@ public class FrontNewsController extends BaseController {
                               @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
                               @ApiParam(value = "页数", example = "1") @RequestParam Integer pageNum,
                               @ApiParam(value = "页大小", example = "15") @RequestParam Integer pageSize) {
-        if(StringUtils.isBlank(location)) {
-            location = VistorContextHolder.getLocation();
-        }
-        return llist(ids,top,type,tag,title,location, pageNum,pageSize);
+        return llist(ids,top,type,tag,title,commService.getLocation(location), pageNum,pageSize);
     }
 
     private TableDataInfo llist(String ids,Boolean top,String type, String tag,String title,String location, Integer pageNum,Integer pageSize){
-        startPage();
         BWwwNews exam = new BWwwNews();
         exam.setIsTop(null==top?null:(top?1:0));
         exam.setType(type);
         exam.setTitle(title);
         exam.setTag(StringUtils.trimToNull(tag));
-        exam.setLocation(StringUtils.isNotBlank(location) ? location : "湖南");
+        exam.setLocation(commService.getLocation(location));
         if(StringUtils.isNotBlank(ids)){
             String[] strArray = ids.split(",");
             List<String> strList = new ArrayList<>(strArray.length);
             Collections.addAll(strList, strArray);
             exam.setIds(strList);
         }
+        startPage();
         List<BWwwNews> arr = newsService.selectBWwwNewsList(exam);
         return getDataTable(arr);
     }
@@ -141,7 +138,7 @@ public class FrontNewsController extends BaseController {
                                      @ApiParam(value = "省份 ", example = "湖南") @RequestParam(required = false) String location,
                                      @ApiParam(value = "页数", example = "1") Integer pageNum,
                                      @ApiParam(value = "页大小", example = "15") Integer pageSize) {
-        return llist(ids,top,type,tag,title,location, pageNum,pageSize);
+        return llist(ids,top,type,tag,title,commService.getLocation(location), pageNum,pageSize);
     }
 
     @GetMapping("info")
@@ -163,4 +160,6 @@ public class FrontNewsController extends BaseController {
         return AjaxResult.success(clicked);
     }
 
+
+
 }

+ 77 - 0
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontSyzyYfydController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.front;
 
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -7,8 +8,12 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.utils.CommonUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.syzy.domain.BBusiWishScoreGroups;
 import com.ruoyi.syzy.service.IBBusiWishScoreGroupsService;
+import com.ruoyi.web.service.CommService;
+import com.ruoyi.web.service.ScoreRankService;
+import com.ruoyi.web.service.ZyService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -31,6 +36,14 @@ import java.util.stream.Collectors;
 public class FrontSyzyYfydController extends BaseController {
     @Autowired
     private IBBusiWishScoreGroupsService scoreGroupsService;
+    @Autowired
+    private ScoreRankService scoreRankService;
+    @Autowired
+    private ISysConfigService configService;
+    @Autowired
+    private ZyService zyService;
+    @Autowired
+    private CommService commService;
 
     @GetMapping("locations")
     @ApiOperation("01.地域")
@@ -96,4 +109,68 @@ public class FrontSyzyYfydController extends BaseController {
         }
         return AjaxResult.success(groupList.get(0));
     }
+
+
+    @GetMapping("getEquivalentScore")
+    @ApiOperation("06.根据分数找历史等效位次")
+    public AjaxResult getEquivalentScore(@ApiParam("地域") String location, @ApiParam("录入年度")  Integer year,
+                                         @ApiParam("分数") @RequestParam Integer score) {
+        if (StringUtils.isBlank(location)) {
+            location = commService.getLocation(location);
+        }
+        String mode = String.valueOf(SecurityUtils.getLoginUser().getUser().getExamMajor());
+        // 1. 初始当前年度, 文理类型
+        List<Integer> list = scoreGroupsService.yearsNoStatus(location);
+        if (CollectionUtils.isEmpty(list)) {
+            return AjaxResult.error("无有效一分一段数据");
+        }
+        Integer currYear = zyService.getYear();
+        String forceLocation = configService.selectConfigByKey("voluntary.force.locations");
+        Integer submitYear = currYear;
+        if (null != forceLocation && forceLocation.contains(location)) {
+            submitYear = submitYear - 1;
+        }
+        if (null == year) {
+            year = list.get(0);
+        }
+
+        // Map cond = Maps.newHashMap();
+        // ZyService.appendMode(cond, location, mode);
+        // List<String> modes = cond.containsKey("modes") ? (List) cond.get("modes") : Lists.newArrayList((String) cond.get("mode"));
+
+        AjaxResult ajax = AjaxResult.success();
+
+        BBusiWishScoreGroups base = scoreRankService.getScoreGroups(location, year, mode, score);
+        ajax.put("match", base);
+        ajax.put("scores", getHistoryEqList(base, mode, currYear, year, submitYear, score, location));
+        return ajax;
+    }
+
+    private List<Map> getHistoryEqList(BBusiWishScoreGroups base, String mode, Integer maxYear, Integer userYear, Integer submitYear, Integer score, String location) {
+        List<Map> historyEqList = Lists.newArrayList();
+        if(null == base) {
+            return historyEqList;
+        }
+        BBusiWishScoreGroups currScoreRange = scoreRankService.getScoreRangeByScore(location, maxYear, mode, userYear, score);
+        if (null == currScoreRange) {
+            return historyEqList;
+        }
+        Integer minYear = submitYear - 2; // 专业线最近3年 + 计划年, 计划是新年度时共4年
+        for (int i = submitYear; i >= minYear; i--) {
+            Map tmp = new HashMap();
+            tmp.put("year" , i);
+            BBusiWishScoreGroups eqScoreRange = scoreRankService.getScoreRangeByBatch(location, maxYear, currScoreRange.getMode(), i, currScoreRange.getType());
+            Integer eqRank = scoreRankService.getEqRank(currScoreRange, eqScoreRange, location, maxYear, userYear, score, null, i);
+            if (null == eqRank) {
+                tmp.put("seat", 0);
+                tmp.put("score", 0);
+            } else {
+                tmp.put("seat" , eqRank);
+                Integer lastEqScore = scoreRankService.getScore(location, i, eqScoreRange.getMode(), eqRank);
+                tmp.put("score" , lastEqScore);
+            }
+            historyEqList.add(tmp);
+        }
+        return historyEqList;
+    }
 }

+ 14 - 0
ie-admin/src/main/java/com/ruoyi/web/service/CommService.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.service;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.ruoyi.common.core.content.VistorContextHolder;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.enums.UserRegStatus;
@@ -151,4 +152,17 @@ public class CommService {
         }
         return treeNodeList;
     }
+
+    public String getLocation(){
+        return getLocation(null);
+    }
+    public String getLocation(String location){
+        if(org.apache.commons.lang3.StringUtils.isBlank(location)) {
+            location = VistorContextHolder.getLocation();
+        }
+        if (org.apache.commons.lang3.StringUtils.isBlank(location)) {
+            location = "湖南";
+        }
+        return location;
+    }
 }

+ 22 - 1
ie-common/src/main/java/com/ruoyi/common/core/content/VistorContextHolder.java

@@ -3,6 +3,10 @@ package com.ruoyi.common.core.content;
 
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.ExamType;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 
 /**
  * 身份验证信息
@@ -33,6 +37,23 @@ public class VistorContextHolder
     }
 
     public static String getLocation() {
-        return getContext().getLocation();
+        SysUser context = getContext();
+        if (context == null) {
+            return null;
+        }
+        String location = context.getLocation();
+        if (StringUtils.isBlank(location)) {
+            return location;
+        }
+        // 如果 location 是 URL 编码的(包含 %),则进行解码
+        if (location.contains("%")) {
+            try {
+                return URLDecoder.decode(location, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                // 如果解码失败,返回原始值
+                return location;
+            }
+        }
+        return location;
     }
 }