处理线上登录报错

pull/3/head
unclekh 4 years ago
parent fcc3fdaa84
commit 0961639ed1
  1. 2
      blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml
  2. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/YyyfMoney.java
  3. 47
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/InitData.java
  4. 33
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/InitProject.java
  5. 59
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/init/SpringContextUtil.java
  6. 27
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/TrainCaseManageMapper.java
  7. 10
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  8. 16
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  9. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ScheduleTask.java
  10. 36
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/TrainCaseManageMapper.xml

@ -1,7 +1,5 @@
server: server:
port: 8101 port: 8101
servlet:
context-path: /user
#注册中心 #注册中心
eureka: eureka:
client: client:

@ -16,7 +16,7 @@ import java.util.Date;
* @description * @description
* @date 2020-05-26 21:30 * @date 2020-05-26 21:30
*/ */
@Table(name = "Yyyf_money") @Table(name = "yyyf_money")
@Data @Data
public class YyyfMoney implements Serializable { public class YyyfMoney implements Serializable {
private static final long serialVersionUID = 8690026237757740821L; private static final long serialVersionUID = 8690026237757740821L;

@ -0,0 +1,47 @@
package com.blockchain.server.yyyf.init;
import com.blockchain.server.yyyf.service.AssessUserService;
/**
* @author Mr.Xu
* @version 1.0
* @className InitData
* @description
* @date 2020-05-06 15:42
*/
public class InitData {
private static InitData initData=null;
public InitData(){
}
public static InitData getInstance(){
synchronized (InitData.class){
if(initData==null){
initData=new InitData();
}
}
return initData;
}
public void init(){
initExamPaperDto();
}
/**
* @description 初始化试卷项目数据
* @author Mr.Xu
* @date 2020-05-06 16:21:52
* @param []
* @return void
**/
private void initExamPaperDto(){
AssessUserService trainManageService= (AssessUserService) SpringContextUtil.getBean("assessUserService");
trainManageService.initAllExamPaperDto();
}
}

@ -0,0 +1,33 @@
package com.blockchain.server.yyyf.init;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* @author Mr.Xu
* @version 1.0
* @className InitProject
* @description 初始化项目
* @date 2020-05-06 16:16
*/
@Component
public class InitProject implements ApplicationRunner {
private static final Logger LOG = LoggerFactory.getLogger(InitProject.class);
@Override
public void run(ApplicationArguments args) throws Exception {
LOG.info("==========init project===========");
try {
InitData.getInstance().init();
LOG.info("============init data success============");
} catch (Exception e) {
LOG.error("init data error={}", e.getMessage());
}
}
}

@ -0,0 +1,59 @@
package com.blockchain.server.yyyf.init;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@Component
public class SpringContextUtil implements ApplicationContextAware {
// Spring应用上下文环境
private static ApplicationContext applicationContext;
/**
* 实现ApplicationContextAware接口的回调方法设置上下文环境
*
* @param applicationContext
*/
public void setApplicationContext(ApplicationContext applicationContext) {
SpringContextUtil.applicationContext = applicationContext;
}
/**
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/**
* 获取对象
*
* @param name
* @return Object
* @throws BeansException
*/
public static Object getBean(String name) throws BeansException {
return applicationContext.getBean(name);
}
public static <T> T getBean(Class<T> requiredType) throws BeansException {
return applicationContext.getBean(requiredType);
}
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
public static HttpServletResponse getHttpServletResponse() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
}
public static HttpSession getHttpSession() {
HttpServletRequest request = getHttpServletRequest();
return request.getSession();
}
}

@ -0,0 +1,27 @@
package com.blockchain.server.yyyf.mapper;
import com.blockchain.server.train.dto.ExamPaperDto;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* (TrainCaseManage)表数据库访问层
*
* @author qianqian.zhang
* @since 2020-04-16 16:03:48
*/
@Repository
public interface TrainCaseManageMapper {
/**
* @description
* @author Mr.Xu
* @date 2020-05-06 15:50:51
* @param []
* @return void
**/
List<ExamPaperDto> getAllExamPaperDto();
}

@ -1,6 +1,7 @@
package com.blockchain.server.yyyf.service; package com.blockchain.server.yyyf.service;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto; import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.AssessUserDto; import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto; import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
@ -106,4 +107,13 @@ public interface AssessUserService {
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto * @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto
**/ **/
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId); UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId);
/**
* @description 缓存获取所有练习和考核
* @author zijie
* @date 2020-07-22 21:48:16
* @param []
* @return void
**/
void initAllExamPaperDto();
} }

@ -1,6 +1,7 @@
package com.blockchain.server.yyyf.service.impl; package com.blockchain.server.yyyf.service.impl;
import com.blockchain.common.base.constant.YyyfConstant; import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto; import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.AssessUserDto; import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.ExamDto; import com.blockchain.server.yyyf.dto.ExamDto;
@ -14,6 +15,7 @@ import com.blockchain.server.yyyf.exceprion.YyyfException;
import com.blockchain.server.yyyf.indicators.IndicatorsManager; import com.blockchain.server.yyyf.indicators.IndicatorsManager;
import com.blockchain.server.yyyf.mapper.AssessUserMapper; import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.mapper.TrainCaseManageMapper;
import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper; import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper;
import com.blockchain.server.yyyf.service.AssessUserService; import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.utils.HttpClientUtil; import com.blockchain.server.yyyf.utils.HttpClientUtil;
@ -56,6 +58,8 @@ public class AssessUserServiceImpl implements AssessUserService {
private AssessUserTargetMapper assessUserTargetMapper; private AssessUserTargetMapper assessUserTargetMapper;
@Autowired @Autowired
private YyyfMoneyMapper yyyfMoneyMapper; private YyyfMoneyMapper yyyfMoneyMapper;
@Autowired
private TrainCaseManageMapper trainCaseManageMapper;
//@Autowired //@Autowired
private IndicatorsManager indicatorsManager; private IndicatorsManager indicatorsManager;
@ -304,6 +308,18 @@ public class AssessUserServiceImpl implements AssessUserService {
return this.assessUserMapper.getUserTimeMoneyDtoByAssessUserId(assessUserId); return this.assessUserMapper.getUserTimeMoneyDtoByAssessUserId(assessUserId);
} }
@Override
public void initAllExamPaperDto() {
List<ExamPaperDto> examPaperDtoList = trainCaseManageMapper.getAllExamPaperDto();
redisTemplate.delete(YyyfConstant.EXAM_PAPER_KEY);
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash();
for (ExamPaperDto examPaperDto : examPaperDtoList) {
examPaperOpsForHash.put(YyyfConstant.EXAM_PAPER_KEY, examPaperDto.getId(), examPaperDto);
}
}
/** /**
* @param [assessUserTarget, targetResultMap] * @param [assessUserTarget, targetResultMap]
* @return void * @return void

@ -36,6 +36,10 @@ public class ScheduleTask {
@Scheduled(initialDelay = 5000,fixedRate=60000) @Scheduled(initialDelay = 5000,fixedRate=60000)
private void OneMinuteTask() { private void OneMinuteTask() {
logger.info("开始扫描案例"+ new Date());
this.assessUserService.initAllExamPaperDto();
logger.info("完成扫描案例"+ new Date());
logger.info("开始扫描考试"+ new Date()); logger.info("开始扫描考试"+ new Date());
HashOperations<String, String, ExamDto> examDtoOpsForHash = redisTemplate.opsForHash(); HashOperations<String, String, ExamDto> examDtoOpsForHash = redisTemplate.opsForHash();
Map<String, ExamDto> examDtoMap = examDtoOpsForHash.entries(YyyfConstant.EXAM_KEY); Map<String, ExamDto> examDtoMap = examDtoOpsForHash.entries(YyyfConstant.EXAM_KEY);

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.blockchain.server.yyyf.mapper.TrainCaseManageMapper">
<resultMap type="com.blockchain.server.train.dto.ExamPaperDto" id="ExamPaperDtoMap">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="wechatInitMoney" column="wechat_init_money" jdbcType="DECIMAL"/>
<result property="alipayInitMoney" column="alipay_init_money" jdbcType="DECIMAL"/>
<result property="bankcardInitMoney" column="bankcard_init_money" jdbcType="DECIMAL"/>
<result property="digitwalletInitMoney" column="digitwallet_init_money" jdbcType="DECIMAL"/>
<collection property="trainCaseTargetList" javaType="list" ofType="com.blockchain.server.train.dto.TrainCaseTargetDto">
<result property="id" column="case_target_id" jdbcType="VARCHAR"/>
<result property="name" column="target_name" jdbcType="VARCHAR"/>
<result property="taskOperate" column="task_operate" jdbcType="INTEGER"/>
<result property="taskRate" column="task_rate" jdbcType="DOUBLE"/>
<result property="taskScore" column="task_score" jdbcType="DOUBLE"/>
<result property="targetId" column="target_id" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
</collection>
</resultMap>
<select id="getAllExamPaperDto" resultMap="ExamPaperDtoMap">
SELECT
cm.id ,cm.name,cm.type,cm.wechat_init_money,cm.alipay_init_money,cm.bankcard_init_money,cm.digitwallet_init_money,ct.id case_target_id,dt.name target_name,ct.task_rate,ct.task_score,ct.task_operate,dt.code,dt.id target_id
FROM
train_case_manage cm,
train_case_target ct,
train_dict_target dt
WHERE
cm.id = ct.case_id and ct.target_id=dt.id
AND cm.is_del = 0
</select>
</mapper>
Loading…
Cancel
Save