diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java index b9da86a..f971ae0 100644 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java @@ -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 { diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/AssessUser.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/AssessUser.java new file mode 100644 index 0000000..8e47bcf --- /dev/null +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/AssessUser.java @@ -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; +} diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/YyyfUser.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/YyyfUser.java deleted file mode 100644 index 8170da3..0000000 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/YyyfUser.java +++ /dev/null @@ -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; - - -} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/AssessUserMapper.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/AssessUserMapper.java new file mode 100644 index 0000000..74dd063 --- /dev/null +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/AssessUserMapper.java @@ -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 { + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/YyyfUserMapper.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/YyyfUserMapper.java deleted file mode 100644 index 8818546..0000000 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/YyyfUserMapper.java +++ /dev/null @@ -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 { - -} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java new file mode 100644 index 0000000..877620e --- /dev/null +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java @@ -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); +} diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/YyyfUserService.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/YyyfUserService.java deleted file mode 100644 index 326058f..0000000 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/YyyfUserService.java +++ /dev/null @@ -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); - -} diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java new file mode 100644 index 0000000..0e876ba --- /dev/null +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java @@ -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); + } + + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/YyyfUserServiceImpl.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/YyyfUserServiceImpl.java deleted file mode 100644 index 400941a..0000000 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/YyyfUserServiceImpl.java +++ /dev/null @@ -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); - } - - -} diff --git a/blockchain-server/blockchain-server-user/src/main/resources/mapper/AssessUserMapper.xml b/blockchain-server/blockchain-server-user/src/main/resources/mapper/AssessUserMapper.xml new file mode 100644 index 0000000..0bd96a1 --- /dev/null +++ b/blockchain-server/blockchain-server-user/src/main/resources/mapper/AssessUserMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blockchain-server/blockchain-server-user/src/main/resources/mapper/YyyfUserMapper.xml b/blockchain-server/blockchain-server-user/src/main/resources/mapper/YyyfUserMapper.xml deleted file mode 100644 index 7fb5639..0000000 --- a/blockchain-server/blockchain-server-user/src/main/resources/mapper/YyyfUserMapper.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java index fd461c1..7a86deb 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java @@ -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()); //最终指标结果一致 diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java new file mode 100644 index 0000000..889328d --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java @@ -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; +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java index 3e03f41..f3e8485 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java @@ -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; + /** * 得分 */ diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java index 29b62b4..7e4efd0 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java @@ -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 { void batchUpdateTotalScoreByAssessUserDtoList(@Param("assessUserDtoList") List assessUserDtoList); List selectAssessUserDtoByIssueId(@Param("issueId") String issueId); + + /** + * @description 获取未提交的 UserTimeMoneyDto List + * @author Mr.Xu + * @date 2020-06-01 22:05:09 + * @param [] + * @return java.util.List + **/ + List selectUserTimeMoneyDtosForNotEnd(); } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java index 8a7e55f..7754f1e 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java @@ -26,4 +26,13 @@ public interface AssessUserTargetMapper extends Mapper { List selectAllStudentAssessUserTargetByIssueId(@Param("issueId")String issueId); List 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 updateAssessUserTargetList); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java index 974ba1f..23372cb 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java @@ -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 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 + **/ + public List selectUserTimeMoneyDtosForNotEnd(); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java index 627ffeb..e6b2118 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -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); @@ -111,7 +117,7 @@ public class AssessUserServiceImpl implements AssessUserService { } //区块链原始金额存入 - YyyfMoney yyyfMoney=new YyyfMoney(); + YyyfMoney yyyfMoney = new YyyfMoney(); yyyfMoney.setAssessUserId(assessUser.getId()); yyyfMoney.setAliPay(assessUser.getAlipayInitMoney()); yyyfMoney.setWxPay(assessUser.getWechatInitMoney()); @@ -147,11 +153,20 @@ public class AssessUserServiceImpl implements AssessUserService { criteria.andCondition(" assess_user_id = ", assessUserId); List assessUserTargetList = this.assessUserTargetMapper.selectByExample(example); + //获取达标参数 + Map targetResultMap = indicatorsManager.calculatePageIndicators(assessUserId); + //最终更新的指标库答题结果list + List 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 assessUserDtoList = this.assessUserMapper.selectAssessUserDtoByIssueId(issueId); List updateAssessUserDtoList = new ArrayList<>(); List yyyfStudentAnswerDtoList = new ArrayList<>(assessUserDtoList.size()); - + //最终更新的指标库答题结果list + List updateAssessUserTargetList = new ArrayList<>(); Date now = new Date(); for (AssessUserDto assessUserDto : assessUserDtoList) { + //根据assessUserId 获取当时指标情况 + Map targetResultMap = indicatorsManager.calculatePageIndicators(assessUserDto.getId()); List 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); @@ -241,9 +267,9 @@ public class AssessUserServiceImpl implements AssessUserService { @Override public int selectCountByByIssueId(String issueId) { - Example example=new Example(AssessUser.class); + Example example = new Example(AssessUser.class); Example.Criteria criteria = example.createCriteria(); - criteria.andCondition("issue_id = ",issueId); + criteria.andCondition("issue_id = ", issueId); return this.assessUserMapper.selectCountByExample(example); } @@ -252,7 +278,7 @@ public class AssessUserServiceImpl implements AssessUserService { Example example = new Example(AssessUser.class); Example.Criteria criteria = example.createCriteria(); criteria.andCondition("issue_id = ", issueId) - .andCondition("user_id = ",userId); + .andCondition("user_id = ", userId); return this.assessUserMapper.selectOneByExample(example); } @@ -261,7 +287,7 @@ public class AssessUserServiceImpl implements AssessUserService { Example example = new Example(AssessUser.class); Example.Criteria criteria = example.createCriteria(); criteria.andCondition("issue_id = ", issueId) - .andCondition("user_id = ",userId); + .andCondition("user_id = ", userId); return this.assessUserMapper.selectByExample(example); } @@ -270,5 +296,31 @@ public class AssessUserServiceImpl implements AssessUserService { return this.assessUserMapper.selectByPrimaryKey(assessUserId); } + @Override + public List 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 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); + } + } } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ExamProcessTask.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ExamProcessTask.java index 979836e..448503a 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ExamProcessTask.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ExamProcessTask.java @@ -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 userTimeMoneyDtos = this.assessUserService.selectUserTimeMoneyDtosForNotEnd(); + //2.获取 币币总资产 + 法币总资产 + 数据钱包 + 初始资产 + 挂单资金 //3.计算总资产 转换成RMB diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml index 1996a94..ef958f1 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml @@ -34,7 +34,18 @@ - + + + + + + + + + + + + @@ -99,5 +110,9 @@ WHERE u.id = t.assess_user_id and u.issue_id=#{issueId} + diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml index 9da14d4..4c90331 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml @@ -29,6 +29,13 @@ + + + update yyyf_server_assess_user_target + set answer = #{item.answer,jdbcType=INTEGER} where id = #{item.id,jdbcType=VARCHAR} + + +