每天执行计算指标;获取指标结算结果并进行入库

pull/1/head
unclekh 5 years ago
parent 9963b062c0
commit 2e4670a975
  1. 58
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java
  2. 146
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/AssessUser.java
  3. 50
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/YyyfUser.java
  4. 12
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/AssessUserMapper.java
  5. 16
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/YyyfUserMapper.java
  6. 62
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java
  7. 28
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/YyyfUserService.java
  8. 72
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java
  9. 64
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/YyyfUserServiceImpl.java
  10. 5
      blockchain-server/blockchain-server-user/src/main/resources/mapper/AssessUserMapper.xml
  11. 6
      blockchain-server/blockchain-server-user/src/main/resources/mapper/YyyfUserMapper.xml
  12. 1
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java
  13. 24
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java
  14. 8
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java
  15. 10
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  16. 9
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java
  17. 11
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  18. 58
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  19. 22
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ExamProcessTask.java
  20. 17
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml
  21. 7
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml

@ -19,8 +19,8 @@ import com.blockchain.server.user.common.utils.EmailCodeUtils;
import com.blockchain.server.user.common.utils.SmsCodeUtils;
import com.blockchain.server.user.controller.api.LoginApi;
import com.blockchain.server.user.dto.UserBaseDTO;
import com.blockchain.server.user.entity.AssessUser;
import com.blockchain.server.user.entity.UserMain;
import com.blockchain.server.user.entity.YyyfUser;
import com.blockchain.server.user.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -60,9 +60,8 @@ public class LoginController {
private SmsCodeUtils smsCodeUtils;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private YyyfUserService yyyfUserService;
private AssessUserService assessUserService;
@PostMapping("/password")
@ApiOperation(value = LoginApi.PassWorldLogin.METHOD_NAME,
@ -72,7 +71,7 @@ public class LoginController {
@ApiParam(LoginApi.PassWorldLogin.METHOD_API_CLIENT_ID) @RequestParam(name = "clientId", required = false) String clientId,
HttpServletRequest request) {
UserMain userMain = userLoginService.handleLoginByPassword(tel, password);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request), request);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
}
@PostMapping("/loginByCode")
@ -86,7 +85,7 @@ public class LoginController {
UserMain userMain = userLoginService.handleLoginByPhoneCode(tel);
// userMainService.selectByMobilePhone(tel);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_LOGIN);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request), request);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
}
@PostMapping("/register")
@ -104,7 +103,9 @@ public class LoginController {
smsCodeUtils.validateVerifyCode(code, tel, SmsCountEnum.SMS_COUNT_REGISTER);
UserMain userMain = userMainService.handleRegister(tel, invitationCode, internationalCode, password, nickName);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_REGISTER);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request), request);
//处理区块链用户id
dealBindYyyfAccount(userMain.getId(),request);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
}
@PostMapping("/sendLoginCode")
@ -169,21 +170,21 @@ public class LoginController {
@ApiOperation(value = LoginApi.PassWorldLoginPC.METHOD_NAME,
notes = LoginApi.PassWorldLoginPC.METHOD_NOTE)
public ResultDTO loginByPasswordPC(@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_TEL) @RequestParam(name = "tel") String tel,
@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_PASS) @RequestParam(name = "password") String password, HttpServletRequest request) {
@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_PASS) @RequestParam(name = "password") String password) {
UserMain userMain = userLoginService.handleLoginByPassword(tel, password);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue(), request);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
}
@PostMapping("/loginByCode2")
@ApiOperation(value = LoginApi.SmsCodeLoginPC.METHOD_NAME,
notes = LoginApi.SmsCodeLoginPC.METHOD_NOTE)
public ResultDTO loginBysmsCodePC(@ApiParam(LoginApi.SmsCodeLoginPC.METHOD_API_TEL) @RequestParam(name = "tel") String tel,
@ApiParam(LoginApi.SmsCodeLoginPC.METHOD_API_CODE) @RequestParam(name = "code") String code, HttpServletRequest request) {
@ApiParam(LoginApi.SmsCodeLoginPC.METHOD_API_CODE) @RequestParam(name = "code") String code) {
smsCodeUtils.validateVerifyCode(code, tel, SmsCountEnum.SMS_COUNT_LOGIN);
UserMain userMain = userLoginService.handleLoginByPhoneCode(tel);
// userMainService.selectByMobilePhone(tel);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_LOGIN);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue(), request);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
}
@PostMapping("/register2")
@ -194,13 +195,12 @@ public class LoginController {
@ApiParam(LoginApi.RegisterPC.METHOD_API_INVITATION_CODE) @RequestParam(value = "invitationCode", required = false) String invitationCode,
@ApiParam(LoginApi.RegisterPC.METHOD_API_PASSWORD) @RequestParam(value = "password", required = false) String password,
@ApiParam(LoginApi.RegisterPC.METHOD_API_INTERNATIONAL_CODE) @RequestParam(value = "internationalCode", required = false, defaultValue = InternationalConstant.DEFAULT_CODE) String internationalCode,
@ApiParam(LoginApi.RegisterPC.METHOD_API_NICK_NAME) @RequestParam(value = "nickName", required = false) String nickName, HttpServletRequest request
@ApiParam(LoginApi.RegisterPC.METHOD_API_NICK_NAME) @RequestParam(value = "nickName", required = false) String nickName
) {
smsCodeUtils.validateVerifyCode(code, tel, SmsCountEnum.SMS_COUNT_REGISTER);
UserMain userMain = userMainService.handleRegister(tel, invitationCode, internationalCode, password, nickName);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_REGISTER);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue(), request);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
}
@PostMapping("/loginout2")
@ -218,12 +218,11 @@ public class LoginController {
* @param tel 手机号
* @param timestamp 时间撮
*/
private void setUserToRedis(String id, String tel, long timestamp, String tokenType, Integer yyyfUserId) {
private void setUserToRedis(String id, String tel, long timestamp, String tokenType) {
SessionUserDTO userDTO = new SessionUserDTO();
userDTO.setId(id);
userDTO.setTel(tel);
userDTO.setTimestamp(timestamp);
userDTO.setYyyfUserId(yyyfUserId);
SSOHelper.setUser(userDTO, redisTemplate, tokenType);
}
@ -245,10 +244,10 @@ public class LoginController {
/**
* App登录成功之后的处理
*/
private ResultDTO handleAppAfterLogin(UserMain userMain, String clientId, String userLocale, HttpServletRequest request) {
private ResultDTO handleAppAfterLogin(UserMain userMain, String clientId, String userLocale) {
//保存用户客户端信息,用于消息通知
handleAfterLoginToSavePushUser(userMain.getId(), clientId, userLocale);
return handleAfterLogin(userMain, TokenTypeEnums.APP.getValue(), request);
return handleAfterLogin(userMain, TokenTypeEnums.APP.getValue());
}
/***
@ -272,11 +271,9 @@ public class LoginController {
/**
* 登录成功之后的处理
*/
private ResultDTO handleAfterLogin(UserMain userMain, String tokenType, HttpServletRequest request) {
String userId = userMain.getId();
private ResultDTO handleAfterLogin(UserMain userMain, String tokenType) {
long timestamp = System.currentTimeMillis();
setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType, dealBindYyyfAccount(userId, userMain.getMobilePhone(), request));
setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType);
String token = generateToken(userMain.getMobilePhone(), timestamp, tokenType);
UserBaseDTO userBaseDTO = userMainService.selectUserInfoById(userMain.getId());
userBaseDTO.setToken(token);
@ -317,26 +314,21 @@ public class LoginController {
return ResultDTO.requstSuccess();
}
/**
* @param [userId, tel, request]
* @param [userId, request]
* @return java.lang.String
* @description 处理yyyf账号绑定
**/
private Integer dealBindYyyfAccount(String userId, String tel, HttpServletRequest request) {
private Integer dealBindYyyfAccount(String userId,HttpServletRequest request) {
Integer yyyfUserId = null;
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
//如果有token,拿到用户信息,与以渔有方进行绑定
if (yyyfUserDto != null) {
yyyfUserId = yyyfUserDto.getUserId();
YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, tel);
if (yyyfUser == null) {
this.yyyfUserService.saveUser(yyyfUserId, userId,tel, yyyfUserDto.getUserName());
// this.redisTemplate.delete(yyyfTtoken);
} else {
if (!yyyfUser.getUserId().equals(userId)) {
throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER);
}
}
AssessUser assessUser = assessUserService.selectAssessUserById(yyyfUserDto.getAssessUserId());
assessUser.setQUserId(userId);
assessUserService.update(assessUser);
//通过当前用户id与以渔有方用户关联
redisTemplate.opsForValue().set(BaseConstant.USER_ID_YYYF_USER_KEY.concat(userId),yyyfUserDto);
} else {

@ -0,0 +1,146 @@
package com.blockchain.server.user.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Table(name = "yyyf_server_assess_user")
@Data
public class AssessUser implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id")
private String id;
/**
* 子系统id
*/
@Column(name = "train_id")
private String trainId="0001";
/**
* 已发布id
*/
@Column(name = "issue_id")
private String issueId;
/**
* 子系统练习id练习才会用到
*/
@Column(name = "ss_practise_id")
private String ssPractiseId;
/**
* 用户id
*/
@Column(name = "user_id")
private Integer userId;
/**
* 区块链用户id
*/
@Column(name = "q_user_id")
private String qUserId;
/**
* 得分
*/
@Column(name = "total_score")
private Double totalScore;
/**
* 时长
*/
@Column(name = "duration")
private Integer duration;
/**
* 时长单位
*/
@Column(name = "duration_unit")
private String durationUnit="m";
/**
* 开始时间
*/
@Column(name = "start_time")
private Date startTime;
/**
* 结束时间
*/
@Column(name = "end_time")
private Date endTime;
/**
* 案例id
*/
@Column(name = "case_id")
private String caseId;
/**
* 0 练习 1考核
*/
@Column(name = "achieve_ment_type")
private Integer achieveMentType;
/**
* 绑定班级
*/
@Column(name = "class_id")
private String classId;
/**
* 绑定的课程id
*/
@Column(name = "course_id")
private String courseId;
/**
* 绑定的课程id
*/
@Column(name = "user_name")
private String userName;
/**
* 用户类型:0学生1老师2管理员
*/
@Column(name = "user_Type")
private Integer userType;
/**
* 微信账户初始资金
*/
@Column(name = "wechat_init_money")
private BigDecimal wechatInitMoney;
/**
* 支付宝账户初始资金
*/
@Column(name = "alipay_init_money")
private BigDecimal alipayInitMoney;
/**
* 银行卡账户初始资金
*/
@Column(name = "bankcard_init_money")
private BigDecimal bankcardInitMoney;
/**
* 数字钱包初始资产
*/
@Column(name = "digitwallet_init_money")
private BigDecimal digitwalletInitMoney;
/**
* 区块链账号
*/
@Column(name = "tel")
private String tel;
/**
* 密码
*/
@Column(name = "password")
private String password;
}

@ -1,50 +0,0 @@
package com.blockchain.server.user.entity;
import com.blockchain.common.base.entity.BaseModel;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* YyyfUser 以渔有方与区块链用户关联
* @date 2019-02-21 13:37:18
* @version 1.0
*/
@Table(name = "yyyf_user")
@Data
public class YyyfUser extends BaseModel {
/**
* 以渔有方用户id
*/
@Column(name = "yyyf_user_id")
private Integer yyyfUserId;
/**
* 区块链用户id
*/
@Column(name = "user_id")
private String userId;
/**
* 以渔有方用户姓名
*/
@Column(name = "yyyf_user_name")
private String yyyfUserName;
/**
* 创建时间
*/
@Column(name = "create_time")
private java.util.Date createTime;
/**
* 手机号码
*/
@Column(name = "mobile_phone")
private String mobilePhone;
}

@ -0,0 +1,12 @@
package com.blockchain.server.user.mapper;
import com.blockchain.server.user.entity.AssessUser;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
@Repository
public interface AssessUserMapper extends Mapper<AssessUser> {
}

@ -1,16 +0,0 @@
package com.blockchain.server.user.mapper;
import com.blockchain.server.user.entity.UserInfo;
import com.blockchain.server.user.entity.YyyfUser;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
/**
* AppUUserInfoMapper 数据访问类
* @date 2019-02-21 13:37:18
* @version 1.0
*/
@Repository
public interface YyyfUserMapper extends Mapper<YyyfUser> {
}

@ -0,0 +1,62 @@
package com.blockchain.server.user.service;
import com.blockchain.server.user.entity.AssessUser;
import java.util.List;
/**
* @param
* @author huan.xu
* @description 学生用户考核信息表 服务接口类
* @date 2019-10-31 14:36:49
* @return
**/
public interface AssessUserService {
/**
* @description 根据 assessUser 表的id查询assessUser
* @param [assessUserId]
* @return com.gtafeyyyf.model.AssessUser
**/
AssessUser selectAssessUserById(String assessUserId);
/**
* @description 插入
* @author Mr.Xu
* @date 2020-05-13 22:37:12
* @param [assessUser]
* @return void
**/
void insert(AssessUser assessUser);
/**
* @description 更新数据
* @author Mr.Xu
* @date 2020-05-14 22:03:02
* @param [assessUser]
* @return void
**/
void update(AssessUser assessUser);
/**
* @description 根据assessUserId获取答题总表
* @author Mr.Xu
* @date 2020-06-01 21:51:09
* @param [assessUserId]
* @return com.blockchain.server.user.entity.AssessUser
**/
AssessUser selectById(String assessUserId);
}

@ -1,28 +0,0 @@
package com.blockchain.server.user.service;
import com.blockchain.server.user.entity.YyyfUser;
/**
* @author huangxl
* @create 2019-02-23 18:21
*/
public interface YyyfUserService {
/**
* 保存用户信息
* @param userId 用户id
* @param email
* @param hasRelation 是否有关系链信息
*/
void saveUser(Integer yyyfUserId,String userId,String tel,String yyyfName);
/**
* @description
* @author Mr.Xu
* @date 2020/5/4 13:42
* @param [yyyfUserId, tel]
* @return com.blockchain.server.user.entity.YyyfUser
**/
YyyfUser selectByYyyfUserIdAndTel(Integer yyyfUserId, String tel);
}

@ -0,0 +1,72 @@
package com.blockchain.server.user.service.impl;
import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.server.user.entity.AssessUser;
import com.blockchain.server.user.mapper.AssessUserMapper;
import com.blockchain.server.user.service.AssessUserService;
import lombok.SneakyThrows;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author huan.xu
* @version 1.0
* @className AssessUserServiceImpl
* @description 学生用户考核信息表 服务实现类
* @date 2019-10-31 14:34
*/
@Transactional(rollbackFor = Exception.class)
@Service
public class AssessUserServiceImpl implements AssessUserService {
private static Logger LOG = LoggerFactory.getLogger(AssessUserServiceImpl.class);
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private AssessUserMapper assessUserMapper;
@Override
public AssessUser selectAssessUserById(String assessUserId) {
return this.assessUserMapper.selectByPrimaryKey(assessUserId);
}
@Override
public void insert(AssessUser assessUser) {
this.assessUserMapper.insertSelective(assessUser);
}
@Override
public void update(AssessUser assessUser) {
this.assessUserMapper.updateByPrimaryKey(assessUser);
}
@Override
public AssessUser selectById(String assessUserId) {
return this.assessUserMapper.selectByPrimaryKey(assessUserId);
}
}

@ -1,64 +0,0 @@
package com.blockchain.server.user.service.impl;
import com.blockchain.common.base.enums.BaseResultEnums;
import com.blockchain.common.base.exception.BaseException;
import com.blockchain.common.base.util.ExceptionPreconditionUtils;
import com.blockchain.server.user.common.constants.other.RedisConstant;
import com.blockchain.server.user.common.constants.other.StringFormatConstant;
import com.blockchain.server.user.common.constants.sql.UserOptConstant;
import com.blockchain.server.user.common.enums.SmsCountEnum;
import com.blockchain.server.user.common.enums.UserEnums;
import com.blockchain.server.user.common.exceprion.UserException;
import com.blockchain.server.user.common.utils.CheckUtils;
import com.blockchain.server.user.common.utils.FileUploadHelper;
import com.blockchain.server.user.common.utils.GoogleAuthenticatorUtils;
import com.blockchain.server.user.entity.UserInfo;
import com.blockchain.server.user.entity.YyyfUser;
import com.blockchain.server.user.mapper.UserInfoMapper;
import com.blockchain.server.user.mapper.YyyfUserMapper;
import com.blockchain.server.user.service.UserOptLogService;
import com.blockchain.server.user.service.YyyfUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
/**
* @author huangxl
* @create 2019-02-23 18:23
*/
@Service
public class YyyfUserServiceImpl implements YyyfUserService {
@Autowired
private YyyfUserMapper yyyfUserMapper;
@Transactional
@Override
public void saveUser(Integer yyyfUserId, String userId,String tel, String yyyfName) {
YyyfUser yyyfUser=new YyyfUser();
yyyfUser.setYyyfUserId(yyyfUserId);
yyyfUser.setUserId(userId);
yyyfUser.setMobilePhone(tel);
yyyfUser.setYyyfUserName(yyyfName);
yyyfUser.setCreateTime(new Date());
this.yyyfUserMapper.insert(yyyfUser);
}
@Override
public YyyfUser selectByYyyfUserIdAndTel(Integer yyyfUserId, String tel) {
Example example=new Example(YyyfUser.class);
Example.Criteria criteria=example.createCriteria();
criteria.andCondition("yyyf_user_id = " ,yyyfUserId)
.andCondition("mobile_phone = ",tel);
return this.yyyfUserMapper.selectOneByExample(example);
}
}

@ -0,0 +1,5 @@
<?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.user.mapper.AssessUserMapper">
</mapper>

@ -1,6 +0,0 @@
<?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.user.mapper.YyyfUserMapper">
</mapper>

@ -62,7 +62,6 @@ public class ExamController {
AssessUserTarget assessUserTarget = this.assessUserTargetService.selectByAssessUserAndCode(assessUserId, code);
Integer answer = -1;
if (assessUserTarget != null) {
assessUserTarget.setStudentRate(taskRate);
int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate());
//最终指标结果一致

@ -0,0 +1,24 @@
package com.blockchain.server.yyyf.dto;
import com.blockchain.server.yyyf.entity.YyyfMoney;
import java.io.Serializable;
import java.util.Date;
/**
* @author Mr.Xu
* @version 1.0
* @className UserTimeMoneyDto
* @description 包含以渔有方userId本系统userId开始时间以及各个币种余额情况
* @date 2020-06-01 21:23
*/
public class UserTimeMoneyDto extends YyyfMoney implements Serializable {
private static final long serialVersionUID = 5093452353347277920L;
/**以渔有方用户id**/
private Integer userId;
/**本系统用户id**/
private String qUserId;
/**开始时间**/
private Date startTime;
}

@ -44,6 +44,14 @@ public class AssessUser implements Serializable {
*/
@Column(name = "user_id")
private Integer userId;
/**
* 区块链用户id
*/
@Column(name = "q_user_id")
private String qUserId;
/**
* 得分
*/

@ -2,6 +2,7 @@ package com.blockchain.server.yyyf.mapper;
import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.entity.AssessUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -31,4 +32,13 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
void batchUpdateTotalScoreByAssessUserDtoList(@Param("assessUserDtoList") List<AssessUserDto> assessUserDtoList);
List<AssessUserDto> selectAssessUserDtoByIssueId(@Param("issueId") String issueId);
/**
* @description 获取未提交的 UserTimeMoneyDto List
* @author Mr.Xu
* @date 2020-06-01 22:05:09
* @param []
* @return java.util.List<com.blockchain.server.yyyf.dto.UserTimeMoneyDto>
**/
List<UserTimeMoneyDto> selectUserTimeMoneyDtosForNotEnd();
}

@ -26,4 +26,13 @@ public interface AssessUserTargetMapper extends Mapper<AssessUserTarget> {
List<AssessUserTarget> selectAllStudentAssessUserTargetByIssueId(@Param("issueId")String issueId);
List<StudentTargetErrorStatisticsDto> getStudentTargetErrorStatisticsDtoListByIssueId(@Param("issueId")String issueId);
/**
* @description 批量更新指标库最终答题情况
* @author Mr.Xu
* @date 2020-06-01 22:54:19
* @param [updateAssessUserTargetList]
* @return void
**/
void batchUpdateTargetAnswer(@Param("list") List<AssessUserTarget> updateAssessUserTargetList);
}

@ -3,6 +3,7 @@ package com.blockchain.server.yyyf.service;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.entity.AssessUser;
import java.util.List;
@ -86,4 +87,14 @@ public interface AssessUserService {
List<AssessUser> getAssessUserListByIssueIdAndUserId(String issueId, Integer userId);
AssessUser selectById(String assessUserId);
/**
* @description 获取未提交的 UserTimeMoneyDto List
* @author Mr.Xu
* @date 2020-06-01 22:05:09
* @param []
* @return java.util.List<com.blockchain.server.yyyf.dto.UserTimeMoneyDto>
**/
public List<UserTimeMoneyDto> selectUserTimeMoneyDtosForNotEnd();
}

@ -4,12 +4,14 @@ import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.ExamDto;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.dto.YyyfStudentAnswerDto;
import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.entity.YyyfMoney;
import com.blockchain.server.yyyf.enums.YyyfEnums;
import com.blockchain.server.yyyf.exceprion.YyyfException;
import com.blockchain.server.yyyf.indicators.IndicatorsManager;
import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper;
@ -33,6 +35,8 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author huan.xu
@ -56,6 +60,9 @@ public class AssessUserServiceImpl implements AssessUserService {
@Autowired
private YyyfMoneyMapper yyyfMoneyMapper;
//@Autowired
private IndicatorsManager indicatorsManager;
@Value("${yyyf.url}")
private String yyyfUrl;
@ -76,7 +83,6 @@ public class AssessUserServiceImpl implements AssessUserService {
}
@Override
public AssessUser selectAssessUserByUserIdAndissueIdForNotEnd(Integer userId, String issueId) {
Example example = new Example(AssessUser.class);
@ -147,11 +153,20 @@ public class AssessUserServiceImpl implements AssessUserService {
criteria.andCondition(" assess_user_id = ", assessUserId);
List<AssessUserTarget> assessUserTargetList = this.assessUserTargetMapper.selectByExample(example);
//获取达标参数
Map<String, Float> targetResultMap = indicatorsManager.calculatePageIndicators(assessUserId);
//最终更新的指标库答题结果list
List<AssessUserTarget> updateAssessUserTargetList = new ArrayList<>();
for (AssessUserTarget assessUserTarget : assessUserTargetList) {
//计算是否达标
answerResultForTarget(assessUserTarget, targetResultMap);
Double taskScore = assessUserTarget.getTaskScore();
if (assessUserTarget.getAnswer() == 0) {
totalScore += taskScore;
}
updateAssessUserTargetList.add(assessUserTarget);
}
Date startTime = assessUser.getStartTime();
@ -170,6 +185,8 @@ public class AssessUserServiceImpl implements AssessUserService {
}
this.update(assessUser);
//批量更新指标最终结果
this.assessUserTargetMapper.batchUpdateTargetAnswer(updateAssessUserTargetList);
AssessUserDto assessUserDto = new AssessUserDto();
BeanUtils.copyProperties(assessUser, assessUserDto);
@ -184,18 +201,25 @@ public class AssessUserServiceImpl implements AssessUserService {
List<AssessUserDto> assessUserDtoList = this.assessUserMapper.selectAssessUserDtoByIssueId(issueId);
List<AssessUserDto> updateAssessUserDtoList = new ArrayList<>();
List<YyyfStudentAnswerDto> yyyfStudentAnswerDtoList = new ArrayList<>(assessUserDtoList.size());
//最终更新的指标库答题结果list
List<AssessUserTarget> updateAssessUserTargetList = new ArrayList<>();
Date now = new Date();
for (AssessUserDto assessUserDto : assessUserDtoList) {
//根据assessUserId 获取当时指标情况
Map<String, Float> targetResultMap = indicatorsManager.calculatePageIndicators(assessUserDto.getId());
List<AssessUserTarget> assessUserTargetList = assessUserDto.getAssessUserTargetList();
if (assessUserDto.getEndTime() == null) {
Double totalScore = 0d;
for (AssessUserTarget assessUserTarget : assessUserTargetList) {
//计算是否达标
answerResultForTarget(assessUserTarget, targetResultMap);
//计算成绩
Double taskScore = assessUserTarget.getTaskScore();
if (assessUserTarget.getAnswer() == 0) {
totalScore += taskScore;
}
updateAssessUserTargetList.add(assessUserTarget);
}
Date startTime = assessUserDto.getStartTime();
assessUserDto.setTotalScore(totalScore);
@ -205,12 +229,13 @@ public class AssessUserServiceImpl implements AssessUserService {
long duration = sdf.parse(sdf.format(now)).getTime() - sdf.parse(sdf.format(startTime)).getTime();
assessUserDto.setDuration(Math.toIntExact(duration));
updateAssessUserDtoList.add(assessUserDto);
//指标库更新
}
YyyfStudentAnswerDto yyyfStudentAnswerDto = new YyyfStudentAnswerDto();
BeanUtils.copyProperties(assessUserDto, yyyfStudentAnswerDto);
yyyfStudentAnswerDto.setAssessmentId(issueId);
yyyfStudentAnswerDtoList.add(yyyfStudentAnswerDto);
redisTemplate.delete(YyyfConstant.CASE_KEY + assessUserDto.getUserId());
}
@ -223,6 +248,7 @@ public class AssessUserServiceImpl implements AssessUserService {
if (updateAssessUserDtoList.size() > 0) {
this.assessUserMapper.batchUpdateTotalScoreByAssessUserDtoList(assessUserDtoList);
this.assessUserTargetMapper.batchUpdateTargetAnswer(updateAssessUserTargetList);
}
HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList);
@ -270,5 +296,31 @@ public class AssessUserServiceImpl implements AssessUserService {
return this.assessUserMapper.selectByPrimaryKey(assessUserId);
}
@Override
public List<UserTimeMoneyDto> selectUserTimeMoneyDtosForNotEnd() {
return this.assessUserMapper.selectUserTimeMoneyDtosForNotEnd();
}
/**
* @param [assessUserTarget, targetResultMap]
* @return void
* @description 计算是否达标
* @author Mr.Xu
* @date 2020-06-01 22:49:37
**/
private void answerResultForTarget(AssessUserTarget assessUserTarget, Map<String, Float> targetResultMap) {
assessUserTarget.setAnswer(1);
Float aFloat = targetResultMap.get(assessUserTarget.getCode());
Double taskRate = 0d;
if (aFloat != null) {
taskRate = Double.valueOf(aFloat);
}
assessUserTarget.setStudentRate(taskRate);
int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate());
//最终指标结果一致
if (assessUserTarget.getTaskOperate().intValue() == compareAnswer) {
assessUserTarget.setAnswer(0);
}
}
}

@ -1,16 +1,34 @@
package com.blockchain.server.yyyf.task;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.service.AssessUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.List;
@Configuration
@EnableScheduling
public class ExamProcessTask {
@Scheduled(cron="0 0 0 1/1 * ? *")
@Autowired
private AssessUserService assessUserService;
//下面的原注解报错,先注释掉:llegalStateException: Encountered invalid
// @Scheduled method 'processRecording': Cron expression must consist of 6 fields (found 7 in "0 0 0 1/1 * ? *")
//@Scheduled(cron="0 0 0 1/1 * ? *")
//每天 00:01:00 执行
@Scheduled(cron = "0 1 0 * * ?")
public void processRecording() {
//1.获取所有正在进行考核学生id(子系统userId)
//1.获取所有正在进行的考核、练习的 学生id(子系统userId),注意可能多个练习和一个考试并存
//包含以渔有方userId、本系统userId(qUserId)、开始时间(startTime)以及各个币种余额情况
List<UserTimeMoneyDto> userTimeMoneyDtos = this.assessUserService.selectUserTimeMoneyDtosForNotEnd();
//2.获取 币币总资产 + 法币总资产 + 数据钱包 + 初始资产 + 挂单资金
//3.计算总资产 转换成RMB

@ -34,7 +34,18 @@
</collection>
</resultMap>
<resultMap id="UserTimeMoneyDtoMap" type="com.blockchain.server.yyyf.dto.UserTimeMoneyDto">
<id column="id" jdbcType="VARCHAR" property="assessUserId" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="q_user_id" jdbcType="VARCHAR" property="qUserId" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="wx_pay" jdbcType="DECIMAL" property="wxPay" />
<result column="ali_pay" jdbcType="DECIMAL" property="aliPay" />
<result column="bank_card" jdbcType="DECIMAL" property="bankCard" />
<result column="btc" jdbcType="DECIMAL" property="btc" />
<result column="usdt" jdbcType="DECIMAL" property="usdt" />
<result column="eth" jdbcType="DECIMAL" property="eth" />
</resultMap>
@ -99,5 +110,9 @@
WHERE
u.id = t.assess_user_id and u.issue_id=#{issueId}
</select>
<select id="selectUserTimeMoneyDtosForNotEnd" resultMap="UserTimeMoneyDtoMap">
SELECT au.id ,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.end_time is null
</select>
</mapper>

@ -29,6 +29,13 @@
</foreach >
</insert>
<update id="batchUpdateTargetAnswer" parameterType="list">
<foreach collection="list" item="item" separator=";" close=";">
update yyyf_server_assess_user_target
set answer = #{item.answer,jdbcType=INTEGER} where id = #{item.id,jdbcType=VARCHAR}
</foreach>
</update>
<select id="selectAllStudentAssessUserTargetByIssueId"
resultMap="AssessUserTargetMap">
SELECT

Loading…
Cancel
Save