فهرست منبع

后台部门接口或功能调整

mingfu 3 روز پیش
والد
کامیت
6601efaa92

+ 18 - 6
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzCardsController.java

@@ -137,16 +137,18 @@ public class DzCardsController extends BaseController
     @Log(title = "制卡", businessType = BusinessType.INSERT)
     @PostMapping("/issueCard")
     @ApiOperation("制卡")
-    public AjaxResult issueCard(@ApiParam("机构") Long institutionId, @ApiParam("卡类型") CardType type, @ApiParam("数量") Integer count)
+    public AjaxResult issueCard(@ApiParam("机构") Long institutionId, @ApiParam("卡类型") Integer type, @ApiParam("数量") Integer count)
     {
-        dzCardsService.issueCard(institutionId, type, count);
+
+        dzCardsService.issueCard(institutionId, getCardType(institutionId, type), count);
         return AjaxResult.success();
     }
 
     @Log(title = "分配卡", businessType = BusinessType.INSERT)
     @PostMapping("/assignCard")
     @ApiOperation("分配卡")
-    public AjaxResult assignCard(@ApiParam("代理商") @RequestParam Long agentId, @ApiParam("开始号") @RequestParam String begin, @ApiParam("结束号") @RequestParam String end,
+    public AjaxResult assignCard(@ApiParam("代理商") @RequestParam Long agentId, @ApiParam("卡类型") Integer type,
+                                 @ApiParam("开始号") @RequestParam String begin, @ApiParam("结束号") @RequestParam String end,
                                  @ApiParam("省份") @RequestParam(required = false) String location,
                                  @ApiParam("考生类型") @RequestParam(required = false) ExamType examType,
                                  @ApiParam("学校") @RequestParam(required = false) Long schoolId,
@@ -154,18 +156,19 @@ public class DzCardsController extends BaseController
     {
         SysUser sysUser = SecurityUtils.getLoginUser().getUser();
         DzAgent agent = agentService.selectDzAgentByAgentId(agentId);
+        CardType cardType = getCardType(agent.getDeptId(), type);
         if(UserTypeEnum.Agent.getVal().equals(sysUser.getUserType())) { // 代理商分配
             if (!sysUser.getUserTypeId().equals(agent.getParentId())) {
                 throw new ValidationException("只能分配给下级代理");
             }
-            dzCardsService.assignCard(sysUser.getUserTypeId(), agentId, begin, end, location, examType, schoolId, days);
+            dzCardsService.assignCard(sysUser.getUserTypeId(), agentId, cardType, begin, end, location, examType, schoolId, days);
         } else if(UserTypeEnum.Institution.getVal().equals(sysUser.getUserType())) { // 机构分配卡给自己的下级
             if (!sysUser.getDeptId().equals(agent.getDeptId())) {
                 throw new ValidationException("只能分配给下级代理");
             }
-            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, begin, end, location, examType, schoolId, days);
+            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, cardType, begin, end, location, examType, schoolId, days);
         } else { // 平台指定, TODO 暂只支持二级代理
-            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, begin, end, location, examType, schoolId, days);
+            dzCardsService.assignCard(NumberUtils.isPositive(agent.getParentId()) ? agent.getParentId() : agentId, agentId, cardType, begin, end, location, examType, schoolId, days);
         }
         return AjaxResult.success();
     }
@@ -195,4 +198,13 @@ public class DzCardsController extends BaseController
         dzCardsService.changeCard(action, cardIds);
         return AjaxResult.success();
     }
+
+
+    private CardType getCardType(Long institutionId, Integer type) {
+        if(type.equals(9)) {
+            return CardType.Experience;
+        }
+        return (null == institutionId || institutionId.equals(101L)) ? CardType.Platform : CardType.Dept;
+    }
+
 }

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

@@ -61,9 +61,6 @@ public class CommService {
     }
 
     public void requireVip() {
-        if (true){
-            return;
-        }
         SysUser user = SecurityUtils.getLoginUser().getUser();
         if (!UserRegStatus.Student.equals(user.getRegStatus())) {
             throw new CustomException("没有权限,请开通VIP", 405);

+ 107 - 0
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -2,6 +2,7 @@ package com.ruoyi.web.service;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
+import com.github.pagehelper.PageHelper;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -25,6 +26,8 @@ import org.springframework.stereotype.Service;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -60,6 +63,110 @@ public class PaperService {
         // buildSimulatedPaperForUniversity(20962L, 11L, 156L, 2);
         // test2();
         // testCulture();
+        // corrQuestions();
+    }
+
+    public static String convertImg2Html(String text) {
+        String urlPattern = "!\\[\\]\\((https?://[\\w.-]+\\.[a-zA-Z]{2,}[/\\w.-]*\\??[/\\w.=&%-]*)\\)";
+        Pattern pattern = Pattern.compile(urlPattern);
+        Matcher matcher = pattern.matcher(text);
+
+        StringBuffer result = new StringBuffer();
+        while (matcher.find()) {
+            String url = matcher.group(1);
+            String replacement = String.format("<img src=\"%s\" />", url);
+            matcher.appendReplacement(result, replacement);
+        }
+        matcher.appendTail(result);
+        return result.toString();
+    }
+
+    public void corrQuestions() {
+        LearnQuestions cond = new LearnQuestions();
+        Long id = 0L;
+        Integer pageSize = 0;
+        List<LearnQuestions> questionsList;
+
+        String newValue;
+        do {
+            cond.setId(id);
+            PageHelper.startPage(1, pageSize, null);
+            questionsList = questionsMapper.selectLearnQuestionsList(cond);
+            for(LearnQuestions q : questionsList) {
+                boolean updated = false;
+                LearnQuestions up = new LearnQuestions();
+                up.setId(q.getId());
+                if(!q.getTitle().equals((newValue = convertImg2Html(q.getTitle())))) {
+                    up.setTitle(newValue);
+                    updated = true;
+                }
+                if(StringUtils.isNotBlank(q.getTitle0())) {
+                    if(!q.getTitle0().equals((newValue = convertImg2Html(q.getTitle0())))) {
+                        up.setTitle0(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getAnswer2())) {
+                    if(!q.getAnswer2().equals(newValue = convertImg2Html(q.getAnswer2()))) {
+                        up.setAnswer2(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getParse())) {
+                    if(!q.getParse().equals(newValue = convertImg2Html(q.getParse()))) {
+                        up.setParse(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionA())) {
+                    if(!q.getOptionA().equals(newValue = convertImg2Html(q.getOptionA()))) {
+                        up.setOptionA(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionB())) {
+                    if(!q.getOptionB().equals(newValue = convertImg2Html(q.getOptionB()))) {
+                        up.setOptionB(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionC())) {
+                    if(!q.getOptionC().equals(newValue = convertImg2Html(q.getOptionC()))) {
+                        up.setOptionC(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionD())) {
+                    if(!q.getOptionD().equals(newValue = convertImg2Html(q.getOptionD()))) {
+                        up.setOptionD(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionE())) {
+                    if(!q.getOptionE().equals(newValue = convertImg2Html(q.getOptionE()))) {
+                        up.setOptionE(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionF())) {
+                    if(!q.getOptionF().equals(newValue = convertImg2Html(q.getOptionF()))) {
+                        up.setOptionF(newValue);
+                        updated = true;
+                    }
+                }
+                if(StringUtils.isNotBlank(q.getOptionG())) {
+                    if(!q.getOptionG().equals(newValue = convertImg2Html(q.getOptionG()))) {
+                        up.setOptionG(newValue);
+                        updated = true;
+                    }
+                }
+                if(updated) {
+                    up.setIsUpdate(1L);
+                    questionsMapper.updateLearnQuestions(up);
+                }
+                id = q.getId();
+            }
+        } while(questionsList.size() != pageSize);
     }
 
     public void buildAllPapers(Integer seq) {

+ 18 - 0
ie-admin/src/main/java/com/ruoyi/web/service/UserDetailsServiceImpl.java

@@ -4,6 +4,7 @@ import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.model.LoginCard;
 import com.ruoyi.common.enums.ErrorCodes;
 import com.ruoyi.common.enums.UserRegStatus;
+import com.ruoyi.common.exception.CustomException;
 import com.ruoyi.common.exception.ErrorException;
 import com.ruoyi.common.utils.PhoneUtils;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -11,6 +12,8 @@ import com.ruoyi.dz.domain.DzCards;
 import com.ruoyi.dz.mapper.DzClassesMapper;
 import com.ruoyi.dz.mapper.DzSchoolMapper;
 import com.ruoyi.dz.service.IDzCardsService;
+import com.ruoyi.enums.CardDistributeStatus;
+import com.ruoyi.enums.CardTimeStatus;
 import com.ruoyi.framework.web.service.SysPasswordService;
 import com.ruoyi.framework.web.service.SysPermissionService;
 import org.slf4j.Logger;
@@ -29,6 +32,10 @@ import com.ruoyi.common.utils.MessageUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.service.ISysUserService;
 
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.util.Date;
+
 /**
  * 用户验证处理
  *
@@ -88,6 +95,17 @@ public class UserDetailsServiceImpl implements UserDetailsService
             if(null != dzCards.getClassId()) {
                 card.setClassName(dzClassesMapper.selectDzClassesByClassId(dzCards.getClassId()).getName());
             }
+            Date nowDate = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
+            if (CardDistributeStatus.Close.getVal().equals(dzCards.getDistributeStatus())
+                    || !CardTimeStatus.Valid.getVal().equals(dzCards.getTimeStatus())
+                    || (null != dzCards.getOutDate() && dzCards.getOutDate().getTime() < nowDate.getTime())) {
+                // 过期后处理降级
+                SysUser upUser = new SysUser();
+                upUser.setUserId(user.getUserId());
+                upUser.setRegStatus(UserRegStatus.User);
+                user.setRegStatus(UserRegStatus.User);
+                userService.updateUserProfile(upUser);
+            }
         }
         LoginUser loginUser = createLoginUser(user, card);
         if(isPhoneLogin) {

+ 54 - 0
ie-system/src/main/java/com/ruoyi/dz/domain/DzCards.java

@@ -24,6 +24,14 @@ public class DzCards extends BaseEntity
     @Excel(name = "账号")
     private String cardNo;
 
+    private String cardNoBegin;
+    private String cardNoEnd;
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String assignTimeBegin;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String assignTimeEnd;
+
     /** 初始密码 */
     @Excel(name = "初始密码")
     private String password;
@@ -67,6 +75,9 @@ public class DzCards extends BaseEntity
     /** 安排校区 */
     @Excel(name = "安排校区")
     private Long campusId;
+    /** 校区班级ID */
+    @Excel(name = "校区班级ID")
+    private Long campusClassId;
 
     @Excel(name = "分配考生省份")
     private String assignLocation;
@@ -158,6 +169,9 @@ public class DzCards extends BaseEntity
     private String nickName;
     private String phonenumber;
 
+
+
+
     public String getNickName() {
         return nickName;
     }
@@ -516,6 +530,46 @@ public class DzCards extends BaseEntity
         this.days = days;
     }
 
+    public String getCardNoBegin() {
+        return cardNoBegin;
+    }
+
+    public void setCardNoBegin(String cardNoBegin) {
+        this.cardNoBegin = cardNoBegin;
+    }
+
+    public String getCardNoEnd() {
+        return cardNoEnd;
+    }
+
+    public void setCardNoEnd(String cardNoEnd) {
+        this.cardNoEnd = cardNoEnd;
+    }
+
+    public String getAssignTimeBegin() {
+        return assignTimeBegin;
+    }
+
+    public void setAssignTimeBegin(String assignTimeBegin) {
+        this.assignTimeBegin = assignTimeBegin;
+    }
+
+    public String getAssignTimeEnd() {
+        return assignTimeEnd;
+    }
+
+    public void setAssignTimeEnd(String assignTimeEnd) {
+        this.assignTimeEnd = assignTimeEnd;
+    }
+
+    public Long getCampusClassId() {
+        return campusClassId;
+    }
+
+    public void setCampusClassId(Long campusClassId) {
+        this.campusClassId = campusClassId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 2 - 1
ie-system/src/main/java/com/ruoyi/dz/service/IDzCardsService.java

@@ -79,10 +79,11 @@ public interface IDzCardsService
      * 分配卡
      * @param agentId
      * @param leafAgentId
+     * @param cardType
      * @param beginNo
      * @param endNo
      */
-    public void assignCard(Long agentId, Long leafAgentId, String beginNo, String endNo, String location, ExamType examType, Long schoolId, Integer days);
+    public void assignCard(Long agentId, Long leafAgentId, CardType cardType, String beginNo, String endNo, String location, ExamType examType, Long schoolId, Integer days);
 
     /**
      * 开卡

+ 7 - 2
ie-system/src/main/java/com/ruoyi/dz/service/impl/DzCardsServiceImpl.java

@@ -204,7 +204,11 @@ public class DzCardsServiceImpl implements IDzCardsService
             DzCards c = new DzCards();
             c.setType(type.getVal());
             c.setCardNo(String.valueOf(maxNo + i));
-            c.setPassword(RandomUtil.randomNumbers(6));
+            String pass = RandomUtil.randomNumbers(6);
+            if (pass.charAt(0) == '0') {
+                pass = RandomUtil.randomString("123456789", 1) + pass.substring(1);
+            }
+            c.setPassword(pass);
             c.setDistributeStatus(CardDistributeStatus.Free.getVal());
             c.setStatus(CardStatus.Free.getVal());
             c.setTimeStatus(CardTimeStatus.Valid.getVal());
@@ -217,8 +221,9 @@ public class DzCardsServiceImpl implements IDzCardsService
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void assignCard(Long agentId, Long leafAgentId, String beginNo, String endNo, String location, ExamType examType, Long schoolId, Integer days) {
+    public void assignCard(Long agentId, Long leafAgentId, CardType cardType, String beginNo, String endNo, String location, ExamType examType, Long schoolId, Integer days) {
         CardCriteria cond = new CardCriteria();
+        cond.setType(cardType.getVal());
         cond.setStartNo(beginNo);
         cond.setEndNo(endNo);
         DzCards dzCards = new DzCards();

+ 1 - 1
ie-system/src/main/java/com/ruoyi/enums/CardType.java

@@ -6,7 +6,7 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum CardType {
-    Platform(6), Dept(2), ECard(7), Test(8); // 代理商 5, 教师 9
+    Platform(6), Dept(2), ECard(7), Test(8), Experience(9); // 代理商 5, 教师 9
 
     private final Integer val;
 }

+ 7 - 1
ie-system/src/main/resources/mapper/dz/DzCardsMapper.xml

@@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="agentId"    column="agent_id"    />
         <result property="leafAgentId"    column="leaf_agent_id"    />
         <result property="campusId"    column="campus_id"    />
+        <result property="campusClassId"    column="campus_class_id"    />
         <result property="assignLocation"    column="assign_location"    />
         <result property="assignExamType"    column="assign_exam_type"    />
         <result property="assignSchoolId"    column="assign_school_id"    />
@@ -41,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectDzCardsVo">
-        select card_id, card_no, password, type, status, distribute_status, time_status, pay_status, is_settlement, dept_id, agent_id, leaf_agent_id, campus_id, assign_location,assign_exam_type,assign_school_id, school_id, class_id, year, end_year, open_id, remark, distribute_time, out_date, open_time, pay_time, active_time, days, settlement_time, refund_time, close_time, create_time, update_time from dz_cards
+        select card_id, card_no, password, type, status, distribute_status, time_status, pay_status, is_settlement, dept_id, agent_id, leaf_agent_id, campus_id, campus_class_id, assign_location,assign_exam_type,assign_school_id, school_id, class_id, year, end_year, open_id, remark, distribute_time, out_date, open_time, pay_time, active_time, days, settlement_time, refund_time, close_time, create_time, update_time from dz_cards
     </sql>
 
     <select id="selectDzCardsList" parameterType="DzCards" resultMap="DzCardsResult">
@@ -63,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
             <if test="leafAgentId != null "> and leaf_agent_id = #{leafAgentId}</if>
             <if test="campusId != null "> and campus_id = #{campusId}</if>
+            <if test="campusClassId != null "> and campus_class_id = #{campusClassId}</if>
             <if test="assignLocation != null "> and assign_location = #{assignLocation}</if>
             <if test="assignExamType != null "> and assign_exam_type = #{assignExamType}</if>
             <if test="assignSchoolId != null "> and assign_school_id = #{assignSchoolId}</if>
@@ -103,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="agentId != null">agent_id,</if>
             <if test="leafAgentId != null">leaf_agent_id,</if>
             <if test="campusId != null">campus_id,</if>
+            <if test="campusClassId != null">campus_class_id,</if>
             assign_location,assign_exam_type,assign_school_id,
             <if test="schoolId != null">school_id,</if>
             <if test="classId != null">class_id,</if>
@@ -135,6 +138,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="agentId != null">#{agentId},</if>
             <if test="leafAgentId != null">#{leafAgentId},</if>
             <if test="campusId != null">#{campusId},</if>
+            <if test="campusClassId != null">#{campusClassId},</if>
             #{assignLocation},#{assignExamType},#{assignSchoolId},
             <if test="schoolId != null">#{schoolId},</if>
             <if test="classId != null">#{classId},</if>
@@ -171,6 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="agentId != null">agent_id = #{agentId},</if>
             <if test="leafAgentId != null">leaf_agent_id = #{leafAgentId},</if>
             <if test="campusId != null">campus_id = #{campusId},</if>
+            <if test="campusClassId != null">campus_class_id = #{campusClassId},</if>
             assign_location = #{assignLocation},assign_exam_type = #{assignExamType},assign_school_id = #{assignSchoolId},
             <if test="schoolId != null">school_id = #{schoolId},</if>
             <if test="classId != null">class_id = #{classId},</if>
@@ -207,6 +212,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="agentId != null">agent_id = #{agentId},</if>
             <if test="leafAgentId != null">leaf_agent_id = #{leafAgentId},</if>
             <if test="campusId != null">campus_id = #{campusId},</if>
+            <if test="campusClassId != null">campus_class_id = #{campusClassId},</if>
             assign_location = #{assignLocation},assign_exam_type = #{assignExamType},assign_school_id = #{assignSchoolId},
             <if test="schoolId != null">school_id = #{schoolId},</if>
             <if test="classId != null">class_id = #{classId},</if>

+ 3 - 1
ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml

@@ -59,7 +59,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLearnQuestionsList" parameterType="LearnQuestions" resultMap="LearnQuestionsResult">
         <include refid="selectLearnQuestionsVo"/>
         <where>
-            <if test="title != null  and title != ''"> and title = #{title}</if>
+            <if test="id != null"> and id &gt; #{id}</if>
+            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
             <if test="optionA != null  and optionA != ''"> and option_a = #{optionA}</if>
             <if test="optionB != null  and optionB != ''"> and option_b = #{optionB}</if>
             <if test="optionC != null  and optionC != ''"> and option_c = #{optionC}</if>
@@ -103,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isUpdate != null "> and isUpdate = #{isUpdate}</if>
             <if test="isSubType != null  and isSubType != ''"> and isSubType = #{isSubType}</if>
         </where>
+        order by id
     </select>
 
     <select id="selectLearnQuestionsById" parameterType="Long" resultMap="LearnQuestionsResult">