Merge branch 'EP-Indicator' of zhixinlian/client-server into master

pull/2/head^2
fengyu.wang 5 years ago
commit cd1779b367
  1. 5
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/YyyfConstant.java
  2. 13
      blockchain-server/blockchain-server-btc/src/main/java/com/blockchain/server/btc/inner/BtcWalletInner.java
  3. 7
      blockchain-server/blockchain-server-currency/src/main/java/com/blockchain/server/currency/inner/CurrencyMarketInnerController.java
  4. 11
      blockchain-server/blockchain-server-eos/src/main/java/com/blockchain/server/eos/inner/EosWalletInnerController.java
  5. 24
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/inner/ConfigWalletParamInner.java
  6. 19
      blockchain-server/blockchain-server-eth/src/main/java/com/blockchain/server/eth/inner/EthWalletInner.java
  7. 59
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java
  8. 146
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/AssessUser.java
  9. 50
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/YyyfUser.java
  10. 12
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/AssessUserMapper.java
  11. 16
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/YyyfUserMapper.java
  12. 62
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/AssessUserService.java
  13. 28
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/YyyfUserService.java
  14. 72
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/AssessUserServiceImpl.java
  15. 64
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/YyyfUserServiceImpl.java
  16. 5
      blockchain-server/blockchain-server-user/src/main/resources/mapper/AssessUserMapper.xml
  17. 6
      blockchain-server/blockchain-server-user/src/main/resources/mapper/YyyfUserMapper.xml
  18. 5
      blockchain-server/blockchain-server-yyyf/pom.xml
  19. 43
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java
  20. 46
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java
  21. 5
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/ExamApi.java
  22. 38
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java
  23. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java
  24. 8
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java
  25. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/YyyfMoney.java
  26. 18
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/BtcFeign.java
  27. 13
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/CurrencyFeign.java
  28. 14
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EosFeign.java
  29. 20
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EthFeign.java
  30. 29
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/dto/BtcWalletDTO.java
  31. 36
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/dto/CurrencyMarketDTO.java
  32. 29
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/dto/EosWalletDTO.java
  33. 24
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/dto/EthWalletDTO.java
  34. 65
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/DefaultIndicatorsManager.java
  35. 17
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/IndicatorsHandler.java
  36. 31
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/IndicatorsManager.java
  37. 57
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/IndicatorsUtils.java
  38. 46
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/dto/AssetsReporter.java
  39. 16
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/dto/IndicatorsDetail.java
  40. 46
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/dto/IndicatorsTypeEnum.java
  41. 14
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/dto/LastAndFirstAssetsDto.java
  42. 44
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/AnnualGrowthRateIndicatorsHandler.java
  43. 17
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/AssetLiabilityRiskRateIndicatorsHandler.java
  44. 73
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/FluctuationRateIndicatorsHandler.java
  45. 35
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/GrowthRateIndicatorsHandler.java
  46. 57
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/MaxDrawdownRateIndicatorsHandler.java
  47. 60
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/MaxLossRateIndicatorsHandler.java
  48. 63
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/ProfitLossRateRateIndicatorsHandler.java
  49. 40
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/ShapeRateIndicatorsHandler.java
  50. 17
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/TVPIIndicatorsHandler.java
  51. 40
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/indicators/handle/TotalGrowthRateIndicatorsHandler.java
  52. 21
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  53. 9
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java
  54. 15
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssetsReporterMapper.java
  55. 20
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  56. 9
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java
  57. 26
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssetsReporterService.java
  58. 80
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  59. 12
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java
  60. 41
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssetsReporterServiceImpl.java
  61. 53
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/task/ExamProcessTask.java
  62. 1
      blockchain-server/blockchain-server-yyyf/src/main/resources/bootstrap.yml
  63. 33
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml
  64. 7
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml
  65. 38
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssetsReporterMapper.xml

@ -32,5 +32,10 @@ public class YyyfConstant {
/**以渔有方与智信链用户绑定的cookies*/ /**以渔有方与智信链用户绑定的cookies*/
public static final String YYYF_ZHIXINLIAN_USER_KEY="yyyfZhixinlianUserKey"; public static final String YYYF_ZHIXINLIAN_USER_KEY="yyyfZhixinlianUserKey";
/**注册的key*/
public static final String REGISTER_KEY = "user:sms:register:";
/**注册码的时效性*/
public static final int TIME_OUT=10;
} }

@ -1,6 +1,10 @@
package com.blockchain.server.btc.inner; package com.blockchain.server.btc.inner;
import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.util.SSOHelper;
import com.blockchain.server.btc.common.constants.BtcApplicationConstans;
import com.blockchain.server.btc.controller.api.BtcWalletApi;
import com.blockchain.server.btc.dto.BtcWalletDTO;
import com.blockchain.server.btc.inner.api.BtcWalletInnerApi; import com.blockchain.server.btc.inner.api.BtcWalletInnerApi;
import com.blockchain.server.btc.service.BtcWalletService; import com.blockchain.server.btc.service.BtcWalletService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -12,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Api(BtcWalletInnerApi.MARKET_CONTROLLER_API) @Api(BtcWalletInnerApi.MARKET_CONTROLLER_API)
@RestController @RestController
@RequestMapping("/inner/wallet") @RequestMapping("/inner/wallet")
@ -26,4 +33,10 @@ public class BtcWalletInner {
return ResultDTO.requstSuccess(btcWalletService.insertWallet(userOpenId)); return ResultDTO.requstSuccess(btcWalletService.insertWallet(userOpenId));
} }
@GetMapping("/getWallets")
public ResultDTO<List<BtcWalletDTO>> getWallets(@RequestParam("userId") String userId,
@RequestParam("walletType") String walletType) {
return ResultDTO.requstSuccess(btcWalletService.selectAllByUserOpenId(userId, walletType));
}
} }

@ -1,6 +1,7 @@
package com.blockchain.server.currency.inner; package com.blockchain.server.currency.inner;
import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.currency.dto.CurrencyMarketDTO;
import com.blockchain.server.currency.inner.api.CurrencyMarketInnerApi; import com.blockchain.server.currency.inner.api.CurrencyMarketInnerApi;
import com.blockchain.server.currency.service.CurrencyMarketService; import com.blockchain.server.currency.service.CurrencyMarketService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
@Api(CurrencyMarketInnerApi.MARKET_CONTROLLER_API) @Api(CurrencyMarketInnerApi.MARKET_CONTROLLER_API)
@RestController @RestController
@ -36,4 +38,9 @@ public class CurrencyMarketInnerController {
return ResultDTO.requstSuccess(null); return ResultDTO.requstSuccess(null);
} }
@RequestMapping(value = "/getList", method = RequestMethod.GET)
public List<CurrencyMarketDTO> getList() {
return currencyMarketService.getList();
}
} }

@ -3,6 +3,8 @@ package com.blockchain.server.eos.inner;
import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.WalletChangeDTO; import com.blockchain.common.base.dto.WalletChangeDTO;
import com.blockchain.common.base.dto.WalletOrderDTO; import com.blockchain.common.base.dto.WalletOrderDTO;
import com.blockchain.common.base.util.SSOHelper;
import com.blockchain.server.eos.dto.WalletDTO;
import com.blockchain.server.eos.inner.api.EosWalletApi; import com.blockchain.server.eos.inner.api.EosWalletApi;
import com.blockchain.server.eos.service.EosWalletService; import com.blockchain.server.eos.service.EosWalletService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -13,6 +15,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/** /**
* @author Harvey * @author Harvey
* @date 2019/2/19 18:09 * @date 2019/2/19 18:09
@ -49,4 +54,10 @@ public class EosWalletInnerController {
return ResultDTO.requstSuccess(); return ResultDTO.requstSuccess();
} }
@GetMapping("/selectWalletByWalletType")
public ResultDTO<List<WalletDTO>> selectWalletByWalletType(@RequestParam("userOpenId") String userOpenId,
@RequestParam("walletType") String walletType) {
return ResultDTO.requstSuccess(eosWalletService.listWalletByWalletType(walletType, userOpenId));
}
} }

@ -0,0 +1,24 @@
package com.blockchain.server.eth.inner;
import com.blockchain.common.base.dto.GasDTO;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.eth.common.constants.EthConfigConstants;
import com.blockchain.server.eth.service.IConfigWalletParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/inner/walletParam")
public class ConfigWalletParamInner {
@Autowired
private IConfigWalletParamService walletParamService;
@GetMapping("/getGasConfig")
public ResultDTO<GasDTO> getGasConfig(@RequestParam(value = "tokenSymbol", defaultValue = EthConfigConstants.MODULE_TYPE) String tokenSymbol) {
return ResultDTO.requstSuccess(walletParamService.getGasConfig(tokenSymbol));
}
}

@ -1,13 +1,9 @@
package com.blockchain.server.eth.inner; package com.blockchain.server.eth.inner;
import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.SessionUserDTO;
import com.blockchain.common.base.util.SSOHelper; import com.blockchain.common.base.util.SSOHelper;
import com.blockchain.server.eth.common.enums.EthWalletEnums; import com.blockchain.server.eth.dto.EthWalletDTO;
import com.blockchain.server.eth.common.exception.EthWalletException;
import com.blockchain.server.eth.common.util.RedisPrivateUtil;
import com.blockchain.server.eth.inner.api.EthWalletApi; import com.blockchain.server.eth.inner.api.EthWalletApi;
import com.blockchain.server.eth.service.IEthWalletKeyService;
import com.blockchain.server.eth.service.IEthWalletService; import com.blockchain.server.eth.service.IEthWalletService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -16,10 +12,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date; import java.util.List;
/** /**
* @author YH * @author YH
@ -60,4 +59,10 @@ public class EthWalletInner {
return ResultDTO.requstSuccess(); return ResultDTO.requstSuccess();
} }
@GetMapping("/getWallets")
public ResultDTO<List<EthWalletDTO>> getWallets(@RequestParam("userId") String userId,
@RequestParam(name = "walletType", required = false) String walletType) {
return ResultDTO.requstSuccess(ethWalletService.selectByUserOpenIdAndWalletType(userId, walletType));
}
} }

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

@ -68,6 +68,11 @@
<artifactId>poi-ooxml-schemas</artifactId> <artifactId>poi-ooxml-schemas</artifactId>
<version>3.10-FINAL</version> <version>3.10-FINAL</version>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>5.3.6</version>
</dependency>
</dependencies> </dependencies>

@ -6,6 +6,8 @@ import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.YyyfUserDtoUtils; import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.yyyf.controller.api.ExamApi; import com.blockchain.server.yyyf.controller.api.ExamApi;
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.YyyfLoginDto;
import com.blockchain.server.yyyf.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.entity.YyyfMoney; import com.blockchain.server.yyyf.entity.YyyfMoney;
@ -26,7 +28,9 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -62,7 +66,6 @@ public class ExamController {
AssessUserTarget assessUserTarget = this.assessUserTargetService.selectByAssessUserAndCode(assessUserId, code); AssessUserTarget assessUserTarget = this.assessUserTargetService.selectByAssessUserAndCode(assessUserId, code);
Integer answer = -1; Integer answer = -1;
if (assessUserTarget != null) { if (assessUserTarget != null) {
assessUserTarget.setStudentRate(taskRate); assessUserTarget.setStudentRate(taskRate);
int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate()); int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate());
//最终指标结果一致 //最终指标结果一致
@ -103,7 +106,7 @@ public class ExamController {
@GetMapping("/reStart") @GetMapping("/reStart")
@ApiOperation(value = ExamApi.Restart.METHOD_NAME, @ApiOperation(value = ExamApi.Restart.METHOD_NAME,
notes = ExamApi.Restart.METHOD_NOTE) notes = ExamApi.Restart.METHOD_NOTE)
public ResultDTO reStart(HttpServletRequest request) { public ResultDTO<YyyfLoginDto> reStart(HttpServletRequest request) {
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate); YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
String assessUserId = yyyfUserDto.getAssessUserId(); String assessUserId = yyyfUserDto.getAssessUserId();
@ -112,7 +115,20 @@ public class ExamController {
throw new YyyfException(YyyfEnums.FODBID_EXAM_RESTART); throw new YyyfException(YyyfEnums.FODBID_EXAM_RESTART);
} }
Date now=new Date(); Date now=new Date();
//系统账户初始化
String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(yyyfUserDto.getUserId()));
//第一次进入进行注册
String code=String.format("%06d",new Random().nextInt(1000000));
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
//本系统密码
String password=String.format("%08d",new Random().nextInt(10000000));
assessUser.setTel(tel);
assessUser.setPassword(password);
assessUser.setStartTime(now); assessUser.setStartTime(now);
assessUser.setEndTime(null);
this.assessUserService.update(assessUser); this.assessUserService.update(assessUser);
//区块链原始金额还原 //区块链原始金额还原
@ -124,11 +140,32 @@ public class ExamController {
yyyfMoney.setBtc(BigDecimal.ZERO); yyyfMoney.setBtc(BigDecimal.ZERO);
yyyfMoney.setEth(BigDecimal.ZERO); yyyfMoney.setEth(BigDecimal.ZERO);
yyyfMoney.setUsdt(BigDecimal.ZERO); yyyfMoney.setUsdt(BigDecimal.ZERO);
yyyfMoney.setEos(BigDecimal.ZERO);
yyyfMoney.setUpdateTime(now); yyyfMoney.setUpdateTime(now);
this.yyyfMoneyService.update(yyyfMoney); this.yyyfMoneyService.update(yyyfMoney);
return ResultDTO.requstSuccess(); this.assessUserTargetService.restoreByAssessUserId(assessUserId);
YyyfLoginDto yyyfLoginDto = new YyyfLoginDto();
yyyfLoginDto.setCode(code);
yyyfLoginDto.setTel(tel);
yyyfLoginDto.setPassword(password);
return ResultDTO.requstSuccess(yyyfLoginDto);
} }
@SneakyThrows
@GetMapping("/getUserTimeMoneyDto")
@ApiOperation(value = ExamApi.GetUserTimeMoneyDto.METHOD_NAME,
notes = ExamApi.GetUserTimeMoneyDto.METHOD_NOTE)
public ResultDTO<UserTimeMoneyDto> getUserTimeMoneyDto(HttpServletRequest request) {
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
String assessUserId = yyyfUserDto.getAssessUserId();
UserTimeMoneyDto userTimeMoneyDto =this.assessUserService.getUserTimeMoneyDtoByAssessUserId(assessUserId);
return ResultDTO.requstSuccess(userTimeMoneyDto);
}
} }

@ -44,11 +44,6 @@ public class LoginController {
private static final Logger LOG = LoggerFactory.getLogger(LoginController.class); private static final Logger LOG = LoggerFactory.getLogger(LoginController.class);
private static final String REGISTER_KEY = "user:sms:register:";
private static final int TIME_OUT=10;
@Autowired @Autowired
private AssessUserService assessUserService; private AssessUserService assessUserService;
@ -104,11 +99,11 @@ public class LoginController {
AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId);
if (assessUser == null) { if (assessUser == null) {
Date now = new Date(); Date now = new Date();
String tel=new SimpleDateFormat("yyMMddHHmm").format(now).concat(String.valueOf(userId)); String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId));
//第一次进入进行注册 //第一次进入进行注册
String code=String.format("%06d",new Random().nextInt(1000000)); String code=String.format("%06d",new Random().nextInt(1000000));
redisTemplate.opsForValue().set(REGISTER_KEY.concat(tel),code,TIME_OUT, TimeUnit.MINUTES); redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
yyyfLoginDto.setCode(code); yyyfLoginDto.setCode(code);
String password=String.format("%08d",new Random().nextInt(10000000)); String password=String.format("%08d",new Random().nextInt(10000000));
@ -168,32 +163,51 @@ public class LoginController {
examDto.setExamPaperId(examPaperId); examDto.setExamPaperId(examPaperId);
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto); examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto);
} }
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000);
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId); joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
if (joinStuIds == null) { if (joinStuIds == null) {
joinStuIds = new ArrayList<Integer>(); joinStuIds = new ArrayList<Integer>();
} }
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examDto.getExamPaperId());
map.put("examId", examDto.getExamId());
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(caseKey, 30, TimeUnit.DAYS);
//如果等于0 //如果等于0
if (joinStuIds.stream() if (joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() == 0) { .filter(stuIds -> (stuIds.equals(userId))).count() == 0) {
joinStuIds.add(userId); joinStuIds.add(userId);
studentOpsForHash.put(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId, joinStuIds); studentOpsForHash.put(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId, joinStuIds);
} else { } else {
yyyfLoginDto.setStatus(1); yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
} }
} else { } else {
String jioinExamId=null;
if (redisTemplate.hasKey(caseKey)) { if (redisTemplate.hasKey(caseKey)) {
Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey); Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey);
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId")); jioinExamId= examMsgMap.get("examId");
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY,jioinExamId);
} }
//缓存是考试,要进入练习,则不让进入 //缓存是考试,要进入练习,则不让进入
if (joinStuIds != null && joinStuIds.stream() if (joinStuIds != null && joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) { .filter(stuIds -> (stuIds.equals(userId))).count() != 0) {
yyyfLoginDto.setStatus(1); yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId);
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000);
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examDto.getExamPaperId());
map.put("examId", examDto.getExamId());
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(caseKey, 30, TimeUnit.DAYS);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
} }
@ -201,14 +215,6 @@ public class LoginController {
} }
//删除强制提醒的缓存 //删除强制提醒的缓存
// redisTemplate.delete(YyyfConstant.ANSER_KEY + userId); // redisTemplate.delete(YyyfConstant.ANSER_KEY + userId);
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examPaperId);
map.put("examId", examId);
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
yyyfLoginDto.setStatus(1); yyyfLoginDto.setStatus(1);
} }

@ -25,4 +25,9 @@ public class ExamApi {
public static final String METHOD_NAME = "重新开始练习"; public static final String METHOD_NAME = "重新开始练习";
public static final String METHOD_NOTE = "重新开始练习,若考试则抛出异常 "; public static final String METHOD_NOTE = "重新开始练习,若考试则抛出异常 ";
} }
public static class GetUserTimeMoneyDto {
public static final String METHOD_NAME = "获取用户目前余额情况";
public static final String METHOD_NOTE = "获取用户目前余额情况";
}
} }

@ -0,0 +1,38 @@
package com.blockchain.server.yyyf.dto;
import com.blockchain.server.yyyf.entity.YyyfMoney;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author Mr.Xu
* @version 1.0
* @className UserTimeMoneyDto
* @description 包含以渔有方userId本系统userId开始时间以及各个币种余额情况
* @date 2020-06-01 21:23
*/
@ApiModel("用户余额Dto")
@Data
@EqualsAndHashCode(callSuper = true)
public class UserTimeMoneyDto extends YyyfMoney implements Serializable {
private static final long serialVersionUID = 5093452353347277920L;
@ApiModelProperty("以渔有方用户id")
private Integer userId;
@ApiModelProperty("本系统用户id")
private String qUserId;
@ApiModelProperty("开始时间")
private Date startTime;
@ApiModelProperty("支付宝初始资金")
private BigDecimal aliPayInit;
@ApiModelProperty("微信支付初始资金")
private BigDecimal wxPayInit;
@ApiModelProperty("银行卡初始资金")
private BigDecimal bankCardInit;
}

@ -14,7 +14,7 @@ public class YyyfLoginDto implements Serializable {
@ApiModelProperty("提示信息") @ApiModelProperty("提示信息")
private String msg; private String msg;
@ApiModelProperty("状态:0,失败,1成功,2 考试提交后重复进入,3 练习未提交提醒") @ApiModelProperty("状态:0,失败,1成功,2 考试提交后重复进入,3 考试未完成提醒")
private int status; private int status;
/*@ApiModelProperty("练习重新开始参数封装") /*@ApiModelProperty("练习重新开始参数封装")
@ -33,4 +33,6 @@ public class YyyfLoginDto implements Serializable {
@ApiModelProperty("昵称") @ApiModelProperty("昵称")
private String nickName; private String nickName;
@ApiModelProperty("剩余时间")
private Long remainingTime;
} }

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

@ -33,6 +33,8 @@ public class YyyfMoney implements Serializable {
private BigDecimal btc; private BigDecimal btc;
@Column(name = "usdt") @Column(name = "usdt")
private BigDecimal usdt; private BigDecimal usdt;
@Column(name = "eos")
private BigDecimal eos;
@Column(name = "eth") @Column(name = "eth")
private BigDecimal eth; private BigDecimal eth;

@ -0,0 +1,18 @@
package com.blockchain.server.yyyf.feign;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.yyyf.feign.dto.BtcWalletDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient("dapp-btc-server")
public interface BtcFeign {
String CONTENT_PATH = "/inner/wallet";
@PostMapping(CONTENT_PATH + "/getWallets")
ResultDTO<List<BtcWalletDTO>> getWallets(@RequestParam("userId") String userId,
@RequestParam("walletType") String walletType);
}

@ -0,0 +1,13 @@
package com.blockchain.server.yyyf.feign;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.yyyf.feign.dto.CurrencyMarketDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "dapp-currency-server")
public interface CurrencyFeign {
@GetMapping("/inner/market/getList")
ResultDTO<CurrencyMarketDTO> getList(@RequestParam("currencyPair") String currencyPair);
}

@ -0,0 +1,14 @@
package com.blockchain.server.yyyf.feign;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.yyyf.feign.dto.EosWalletDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@FeignClient("dapp-eos-server")
public interface EosFeign {
@GetMapping("/inner/walletTx/selectWalletByWalletType")
ResultDTO<List<EosWalletDTO>> selectWalletByWalletType(String userOpenId, String walletType);
}

@ -0,0 +1,20 @@
package com.blockchain.server.yyyf.feign;
import com.blockchain.common.base.dto.GasDTO;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.yyyf.feign.dto.EthWalletDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient("dapp-eth-server")
public interface EthFeign {
@GetMapping("/inner/wallet/getWallets")
ResultDTO<List<EthWalletDTO>> getWallets(@RequestParam("userId") String userId,
@RequestParam(name = "walletType") String walletType);
@GetMapping("/inner/walletParam/getGasConfig")
ResultDTO<GasDTO> getGasConfig(String tokenSymbol);
}

@ -0,0 +1,29 @@
package com.blockchain.server.yyyf.feign.dto;
import com.blockchain.common.base.entity.BaseModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* BtcWalletDTO 数据传输类
*
* @version 1.0
* @date 2019-02-16 15:08:16
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BtcWalletDTO extends BaseModel {
private String addr;
private Integer tokenId;
private String userOpenId;
private String tokenSymbol;
private Double balance;
private Double freeBalance;
private Double freezeBalance;
private java.util.Date createTime;
private java.util.Date updateTime;
private String walletType;
}

@ -0,0 +1,36 @@
package com.blockchain.server.yyyf.feign.dto;
import com.blockchain.common.base.dto.BaseDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CurrencyMarketDTO extends BaseDTO implements Comparable<CurrencyMarketDTO> {
private String currencyPair;
private BigDecimal amount;
private Long timestamp;
private float percent;
private double usdAmount;
private double cnyAmount;
private double hkdAmount;
private double eurAmount;
//最低
private BigDecimal lowest;
//最高
private BigDecimal highest;
//开盘
private BigDecimal open;
//成交量
private BigDecimal total;
@Override
public int compareTo(CurrencyMarketDTO o) {
return (int) (10000 * o.percent - 10000 * this.percent);
}
}

@ -0,0 +1,29 @@
package com.blockchain.server.yyyf.feign.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* Wallet 数据传输类
* @date 2018-11-05 15:10:47
* @version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EosWalletDTO {
private Integer id;
private String tokenName;
private String userOpenId;
private String tokenSymbol;
private BigDecimal balance;
private BigDecimal freeBalance;
private BigDecimal freezeBalance;
private java.util.Date createTime;
private java.util.Date updateTime;
private String walletType;
}

@ -0,0 +1,24 @@
package com.blockchain.server.yyyf.feign.dto;
import lombok.Data;
/**
* EthWallet 数据传输类
*
* @version 1.0
* @date 2019-02-16 15:44:06
*/
@Data
public class EthWalletDTO {
private String addr;
private String tokenAddr;
private String userOpenId;
private String tokenSymbol;
private int tokenDecimals;
private String balance;
private String freeBalance;
private String freezeBalance;
private String walletType;
private java.util.Date createTime;
private java.util.Date updateTime;
}

@ -0,0 +1,65 @@
package com.blockchain.server.yyyf.indicators;
import cn.hutool.core.map.MapUtil;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.indicators.dto.IndicatorsTypeEnum;
import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import lombok.AllArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* @author fengyu
*/
@Service
@AllArgsConstructor
public class DefaultIndicatorsManager implements IndicatorsManager {
private final ApplicationContext applicationContext;
private final AssessUserTargetMapper assessUserTargetMapper;
private final AssessUserMapper assessUserMapper;
@Override
public Map<String, Float> calculatePageIndicators(String assessUserId) {
List<AssessUserTarget> assessUserTargets = assessUserTargetMapper.selectAllStudentAssessUserTargetByIssueId(assessUserId);
Map<String, Float> result = MapUtil.newHashMap();
assessUserTargets.parallelStream().forEach(assessUser -> {
Float total = this.calculateIndicators(assessUserId, IndicatorsTypeEnum.parseCode(assessUser.getCode()));
result.put(assessUser.getCode(), total);
});
return result;
}
@Override
public BigDecimal calculateCurrentTotalAssets(String userId, String assessUserId) {
//feign interface call
UserTimeMoneyDto timeMoneyDto = assessUserMapper.selectCurrentUserTimeMoneyDto(assessUserId, userId);
//1.获取 币币总资产 + 法币总资产 + 数字钱包 + 初始资产 + 挂单资金
//cache rate
//2.计算总资产 转换成RMB
//cache RMB rate
return null;
}
/**
* calculate single indicator
*
* @param assessUserId page result id
* @param type indicators type
* @return indicators result
* @author fengyu.wang
* @date 2020-05-27 22:34:19
*/
private Float calculateIndicators(String assessUserId, IndicatorsTypeEnum type) {
IndicatorsHandler indicatorsHandler = applicationContext.getBean(type.getCode(), IndicatorsHandler.class);
return indicatorsHandler.handleIndicator(assessUserId);
}
}

@ -0,0 +1,17 @@
package com.blockchain.server.yyyf.indicators;
/**
* @author fengyu
*/
public interface IndicatorsHandler {
String HANDLER_NAME = "IndicatorsHandler";
/**
* handle indicator
*
* @param assessUserId page result id
* @return indicator result
* @author fengyu.wang
* @date 2020-06-03 21:28:18
*/
Float handleIndicator(String assessUserId);
}

@ -0,0 +1,31 @@
package com.blockchain.server.yyyf.indicators;
import java.math.BigDecimal;
import java.util.Map;
/**
* @author fengyu
*/
public interface IndicatorsManager {
/**
* calculate indicator by full exam
*
* @param assessUserId page result id
* @return indicators type -> indicators result
* @author fengyu.wang
* @date 2020-05-27 22:36:01
*/
Map<String, Float> calculatePageIndicators(String assessUserId);
/**
* calculate current total asset
*
* @param userId system user id
* @param assessUserId page result id
* @return current total assets (RMB)
* @author fengyu.wang
* @date 2020-06-02 20:15:15
*/
BigDecimal calculateCurrentTotalAssets(String userId, String assessUserId);
}

@ -0,0 +1,57 @@
package com.blockchain.server.yyyf.indicators;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.indicators.dto.LastAndFirstAssetsDto;
import lombok.Data;
import javax.persistence.EntityExistsException;
import java.util.List;
/**
* @author huan.xu
* @version 1.0
* @className IndicatorsUtils
* @description
* @date 2020-06-05 10:21
*/
@Data
public class IndicatorsUtils {
/**
* 获取 期初与期末的信息
* @param reporterList
* @return
*/
public static LastAndFirstAssetsDto getLastAndFirstAssetsDto(List<AssetsReporter> reporterList) {
LastAndFirstAssetsDto result = new LastAndFirstAssetsDto();
if (reporterList != null && reporterList.size() > 0) {
//期初资产
AssetsReporter firstAssets = null;
//交易期内最后一天
AssetsReporter lastAssets = null;
for (AssetsReporter assetsReporter : reporterList) {
if (assetsReporter.getDays() == 0) { //如果期初资产
firstAssets = assetsReporter;
} else {
if (lastAssets == null) { //最小的若为null
lastAssets = assetsReporter;
} else {
if (assetsReporter.getDays() > lastAssets.getDays()) {
lastAssets = assetsReporter;
}
}
}
}
result.setFirstAssets(firstAssets);
result.setLastAssets(lastAssets);
return result;
} else {
throw new EntityExistsException("assessUser not exit");
}
}
}

@ -0,0 +1,46 @@
package com.blockchain.server.yyyf.indicators.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
/**
* assets recoding day by day
*
* @author fengyu.wang
* @date 2020-05-27 22:59:34
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AssetsReporter {
/**
* primary key
*/
private String id;
/**
* 成绩id
*/
private String assessUserId;
/**
* 币种
*/
private String coinName;
/**
* 交易天数
*/
private long days;
/**
* 资产总额
*/
private BigDecimal assets;
/**
* 创建时间
*/
private Date createTime;
}

@ -0,0 +1,16 @@
package com.blockchain.server.yyyf.indicators.dto;
import lombok.Data;
/**
* indicators persist
*
* @author fengyu.wang
* @date 2020-05-27 22:55:14
*/
@Data
public class IndicatorsDetail {
private String assessUserId;
private IndicatorsTypeEnum type;
private float indicator;
}

@ -0,0 +1,46 @@
package com.blockchain.server.yyyf.indicators.dto;
import lombok.Getter;
/**
* @author fengyu
*/
public enum IndicatorsTypeEnum {
/*年化收益率*/
ANNUAL_GROWTH_RATE("AnnualGrowthRate"),
/*收益率*/
GROWTH_RATE("GrowthRate"),
/*累计收益率*/
TOTAL_GROWTH_RATE("TotalGrowthRate"),
/*波动率*/
FLUCTUATION_RATE("FluctuationRate"),
/*夏普比率*/
SHAPE_RATE("ShapeRate"),
/*盈亏比*/
PROFIT_LOSS_RATE("ProfitLossRate"),
/*最大回撤率*/
MAX_DRAWDOWN_RATE("MaxDrawdownRate"),
/*最大亏损率*/
MAX_LOSS_RATE("MaxLossRate"),
/*风险率(资产负债比)*/
ASSET_LIABILITY_RISK_RATE("AssetLiabilityRiskRate"),
/*TVPI*/
TVPI("TVPI");
@Getter
private final String code;
IndicatorsTypeEnum(String code) {
this.code = code;
}
public static IndicatorsTypeEnum parseCode(String code) {
for (IndicatorsTypeEnum value : IndicatorsTypeEnum.values()) {
if (code.equals(value.getCode())) {
return value;
}
}
throw new IllegalArgumentException();
}
}

@ -0,0 +1,14 @@
package com.blockchain.server.yyyf.indicators.dto;
import lombok.Data;
/**
* @author huan.xu
* @version 1.0
* @className LastAndFirstAssetsReporterDto
* @description
* @date 2020-06-05 10:22
*/
@Data
public class LastAndFirstAssetsDto {
private AssetsReporter lastAssets;
private AssetsReporter firstAssets;
}

@ -0,0 +1,44 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.IndicatorsUtils;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.indicators.dto.LastAndFirstAssetsDto;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(AnnualGrowthRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class AnnualGrowthRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "AnnualGrowthRate";
public static final String CACHE_ANNUAL_GROWTH_RATE = "yyyf_indicator_annualGrowthRate";
public static final String CACHE_KEY_ANNUAL_GROWTH_RATE = "yyyf:annualGrowthRate:";
private final AssetsReporterService assetsReporterService;
@Override
@Cacheable(cacheNames = CACHE_ANNUAL_GROWTH_RATE,
key = "#root.target.CACHE_KEY_ANNUAL_GROWTH_RATE.concat(#assessUserId)", unless = "#result == null")
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
//获取最初、最后交易的信息
LastAndFirstAssetsDto lastAndFirstAssetsDto = IndicatorsUtils.getLastAndFirstAssetsDto(reporterList);
AssetsReporter lastAssets = lastAndFirstAssetsDto.getLastAssets();
AssetsReporter firstAssets = lastAndFirstAssetsDto.getFirstAssets();
BigDecimal result = lastAssets.getAssets()
.divide(firstAssets.getAssets(), 5, BigDecimal.ROUND_HALF_UP)
.pow((int) (360.0 / lastAssets.getDays()))
.subtract(BigDecimal.valueOf(1));
return result.multiply(BigDecimal.valueOf(100)).floatValue();
}
}

@ -0,0 +1,17 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import org.springframework.stereotype.Component;
/**
* @author fengyu
*/
@Component(AssetLiabilityRiskRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class AssetLiabilityRiskRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "AssetLiabilityRiskRate";
@Override
public Float handleIndicator(String assessUserId) {
return null;
}
}

@ -0,0 +1,73 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import javax.persistence.EntityExistsException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(FluctuationRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class FluctuationRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "FluctuationRate";
public static final String CACHE_FLUCTUATION_RATE = "yyyf_indicator_fluctuationRate";
public static final String CACHE_KEY_FLUCTUATION_RATE = "yyyf:fluctuationRate:";
private final AssetsReporterService assetsReporterService;
@Override
@Cacheable(cacheNames = CACHE_FLUCTUATION_RATE,
key = "#root.target.CACHE_KEY_FLUCTUATION_RATE.concat(#assessUserId)", unless = "#result == null")
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
if (reporterList != null && reporterList.size() > 0) {
//排序
reporterList.sort(Comparator.comparingLong(AssetsReporter::getDays));
//总天数
int dayCount = reporterList.size() - 1;
//每日收益率List
List<BigDecimal> dayYieldList = new ArrayList<BigDecimal>(dayCount);
//收益率总和
BigDecimal totalYield = BigDecimal.ZERO;
//上一天的资产总额
BigDecimal upAssets = reporterList.get(0).getAssets();
//计算总收益率以及每日收益率
for (AssetsReporter assetsReporter : reporterList) {
if (assetsReporter.getDays() > 0) {
BigDecimal thisAssets = assetsReporter.getAssets();
BigDecimal subtract = thisAssets.subtract(upAssets);
//当天收益率
BigDecimal thisYeid = subtract.multiply(BigDecimal.valueOf(100)).divide(upAssets, 5, BigDecimal.ROUND_HALF_UP);
//加入每日收益率集合
dayYieldList.add(thisYeid);
//总收益率
totalYield = totalYield.add(thisYeid);
//更换上一天的总额
upAssets = thisAssets;
}
}
//平均收益率
BigDecimal avgYeid = totalYield.divide(BigDecimal.valueOf(dayCount), 5, BigDecimal.ROUND_HALF_UP);
//(每日收益率-平均收益率)的平方和
BigDecimal yeid2Count = BigDecimal.ZERO;
for (BigDecimal yeid : dayYieldList) {
yeid2Count = yeid2Count.add(yeid.subtract(avgYeid).pow(2));
}
return Float.valueOf(String.format("%.2f", Math.sqrt(BigDecimal.valueOf(360).divide(BigDecimal.valueOf(dayCount - 1), 5, BigDecimal.ROUND_HALF_UP).multiply(yeid2Count).doubleValue())));
} else {
throw new EntityExistsException("assessUser:" + assessUserId);
}
}
}

@ -0,0 +1,35 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.IndicatorsUtils;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.indicators.dto.LastAndFirstAssetsDto;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(GrowthRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class GrowthRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "GrowthRate";
private final AssetsReporterService assetsReporterService;
@Override
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
//获取最初、最后交易的信息
LastAndFirstAssetsDto lastAndFirstAssetsDto = IndicatorsUtils.getLastAndFirstAssetsDto(reporterList);
AssetsReporter lastAssets =lastAndFirstAssetsDto.getLastAssets();
AssetsReporter firstAssets =lastAndFirstAssetsDto.getFirstAssets();
return lastAssets.getAssets().subtract(firstAssets.getAssets()).divide(firstAssets.getAssets(), 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).floatValue();
}
}

@ -0,0 +1,57 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import javax.persistence.EntityExistsException;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(MaxDrawdownRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class MaxDrawdownRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "MaxDrawdownRate";
private final AssetsReporterService assetsReporterService;
@Override
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
if (reporterList != null && reporterList.size() > 0) {
//排序
reporterList.sort(Comparator.comparingLong(AssetsReporter::getDays));
BigDecimal maxDrawdownRate=BigDecimal.ZERO;
//上一天的资产总额
BigDecimal upAssets =BigDecimal.ZERO;
for (AssetsReporter assetsReporter : reporterList) {
BigDecimal thisAssets=assetsReporter.getAssets();
//交易第二天开始
if(assetsReporter.getDays()>1){
BigDecimal thisDrawdownRate=BigDecimal.ONE.subtract(thisAssets.divide(upAssets,4,BigDecimal.ROUND_HALF_UP));
if(thisDrawdownRate.compareTo(maxDrawdownRate)==1){
maxDrawdownRate=thisDrawdownRate;
}
}else{
//交易的第一天
if(assetsReporter.getDays()==1){
maxDrawdownRate=BigDecimal.ONE.subtract(thisAssets.divide(upAssets,4,BigDecimal.ROUND_HALF_UP));
}
}
upAssets=thisAssets;
}
return maxDrawdownRate.multiply(BigDecimal.valueOf(100)).floatValue();
} else {
throw new EntityExistsException("assessUser:" + assessUserId);
}
}
}

@ -0,0 +1,60 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import javax.persistence.EntityExistsException;
import java.math.BigDecimal;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(MaxLossRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class MaxLossRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "MaxLossRate";
private final AssetsReporterService assetsReporterService;
@Override
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
if (reporterList != null && reporterList.size() > 0) {
//如果期初资产
AssetsReporter firstAssets = null;
//交易期内资产最小值
AssetsReporter minAssets = null;
for (AssetsReporter assetsReporter : reporterList) {
if (assetsReporter.getDays() == 0) { //如果期初资产
firstAssets = assetsReporter;
} else {
if (minAssets == null) { //最小的若为null
minAssets = assetsReporter;
} else {
if (assetsReporter.getAssets().compareTo(minAssets.getAssets()) == -1) {
minAssets = assetsReporter;
}
}
}
}
long minDay = minAssets.getDays();
int n = (int) (360 / minDay);
Float result = BigDecimal.ONE.subtract(minAssets.getAssets().divide(firstAssets.getAssets(), 5, BigDecimal.ROUND_HALF_UP).pow(n))
.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
//负无穷的时候为0
if (result.isInfinite()) {
result = Float.valueOf(0);
}
return result;
} else {
throw new EntityExistsException("assessUser:");
}
}
}

@ -0,0 +1,63 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import javax.persistence.EntityExistsException;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(ProfitLossRateRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class ProfitLossRateRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "ProfitLossRate";
private final AssetsReporterService assetsReporterService;
@Override
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
if (reporterList != null && reporterList.size() > 0) {
//排序
reporterList.sort(Comparator.comparingLong(AssetsReporter::getDays));
//第一天(上一天)的资产总额
BigDecimal upAssets = reporterList.get(0).getAssets();
//总亏损额
BigDecimal lossMoneyCount = BigDecimal.ZERO;
//盈利计数
int profitCount = 0;
//总盈利额
BigDecimal profitMoneyCount = BigDecimal.ZERO;
for (AssetsReporter assetsReporter : reporterList) {
BigDecimal thisYeid = assetsReporter.getAssets();
//盈利
if (thisYeid.compareTo(upAssets) > 0) { //盈利
profitCount++;
profitMoneyCount = profitMoneyCount.add(thisYeid).subtract(upAssets);
}else{
lossMoneyCount = lossMoneyCount.add(thisYeid).subtract(upAssets);
}
upAssets=thisYeid;
}
if (profitCount == 0) { //每天亏损、或者每天既不盈利也不亏损
return Float.valueOf(0);
}else if(profitCount==(reporterList.size()-1)){ //每天都在盈利
return Float.POSITIVE_INFINITY;
}else { //计算盈亏比
return profitMoneyCount.divide(lossMoneyCount,4,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)).floatValue();
}
} else {
throw new EntityExistsException("assessUser:" + assessUserId);
}
}
}

@ -0,0 +1,40 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
/**
* @author fengyu
*/
@Component(ShapeRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class ShapeRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "ShapeRate";
//无风险利率,配置文件注入,防止后期更改
@Value("${rate.riskFree}")
private BigDecimal riskFree;
@Resource(name = AnnualGrowthRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
private AnnualGrowthRateIndicatorsHandler annualGrowthRateIndicatorsHandler;
@Resource(name = FluctuationRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
private FluctuationRateIndicatorsHandler fluctuationRateIndicatorsHandler;
@Override
public Float handleIndicator(String assessUserId) {
//年化收益率
Float annualGrowthRate=annualGrowthRateIndicatorsHandler.handleIndicator(assessUserId);
//波动率
Float fluctuationRate=fluctuationRateIndicatorsHandler.handleIndicator(assessUserId);
return BigDecimal.valueOf(annualGrowthRate).subtract(riskFree).divide(BigDecimal.valueOf(fluctuationRate),4,BigDecimal.ROUND_HALF_UP)
.floatValue();
}
}

@ -0,0 +1,17 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import org.springframework.stereotype.Component;
/**
* @author fengyu
*/
@Component(TVPIIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class TVPIIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "TVPI";
@Override
public Float handleIndicator(String assessUserId) {
return null;
}
}

@ -0,0 +1,40 @@
package com.blockchain.server.yyyf.indicators.handle;
import com.blockchain.server.yyyf.indicators.IndicatorsHandler;
import com.blockchain.server.yyyf.indicators.IndicatorsUtils;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.indicators.dto.LastAndFirstAssetsDto;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
/**
* @author fengyu
*/
@AllArgsConstructor
@Component(TotalGrowthRateIndicatorsHandler.HANDLER_NAME + IndicatorsHandler.HANDLER_NAME)
public class TotalGrowthRateIndicatorsHandler implements IndicatorsHandler {
public static final String HANDLER_NAME = "TotalGrowthRate";
private final AssetsReporterService assetsReporterService;
@Override
public Float handleIndicator(String assessUserId) {
List<AssetsReporter> reporterList = assetsReporterService.selectAssetsReporterListByAssessUserId(assessUserId);
//获取最初、最后交易的信息
LastAndFirstAssetsDto lastAndFirstAssetsDto = IndicatorsUtils.getLastAndFirstAssetsDto(reporterList);
AssetsReporter lastAssets =lastAndFirstAssetsDto.getLastAssets();
AssetsReporter firstAssets =lastAndFirstAssetsDto.getFirstAssets();
//充值的总金额
//todo 不知道如何获取
BigDecimal rechargeAmount=null;
return lastAssets.getAssets().subtract(firstAssets.getAssets()).divide(rechargeAmount,4,BigDecimal.ROUND_HALF_UP)
.multiply(BigDecimal.valueOf(100)).floatValue();
}
}

@ -2,6 +2,7 @@ package com.blockchain.server.yyyf.mapper;
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.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -31,4 +32,24 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
void batchUpdateTotalScoreByAssessUserDtoList(@Param("assessUserDtoList") List<AssessUserDto> assessUserDtoList); void batchUpdateTotalScoreByAssessUserDtoList(@Param("assessUserDtoList") List<AssessUserDto> assessUserDtoList);
List<AssessUserDto> selectAssessUserDtoByIssueId(@Param("issueId") String issueId); 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();
/**
* @description assessUserId通过assessUserId 获取余额情况
* @author Mr.Xu
* @date 2020-06-02 21:07:23
* @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto
**/
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(@Param("assessUserId") String assessUserId);
UserTimeMoneyDto selectCurrentUserTimeMoneyDto(@Param("assessUserId") String assessUserId, @Param("qUserId")String qUserId);
} }

@ -26,4 +26,13 @@ public interface AssessUserTargetMapper extends Mapper<AssessUserTarget> {
List<AssessUserTarget> selectAllStudentAssessUserTargetByIssueId(@Param("issueId")String issueId); List<AssessUserTarget> selectAllStudentAssessUserTargetByIssueId(@Param("issueId")String issueId);
List<StudentTargetErrorStatisticsDto> getStudentTargetErrorStatisticsDtoListByIssueId(@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);
} }

@ -0,0 +1,15 @@
package com.blockchain.server.yyyf.mapper;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
@Repository
public interface AssetsReporterMapper extends Mapper<AssetsReporter> {
List<AssetsReporter> selectByAssessUserId(String assessUserId);
void insertBatch(List<AssetsReporter> list);
}

@ -3,6 +3,7 @@ package com.blockchain.server.yyyf.service;
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.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
import java.util.List; import java.util.List;
@ -86,4 +87,23 @@ public interface AssessUserService {
List<AssessUser> getAssessUserListByIssueIdAndUserId(String issueId, Integer userId); List<AssessUser> getAssessUserListByIssueIdAndUserId(String issueId, Integer userId);
AssessUser selectById(String assessUserId); 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();
/**
* @description assessUserId通过assessUserId 获取余额情况
* @author Mr.Xu
* @date 2020-06-02 21:06:35
* @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto
**/
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId);
} }

@ -32,4 +32,13 @@ public interface AssessUserTargetService{
List<AssessUserTarget> selectAllStudentAssessUserTargetByIssueId(String issueId); List<AssessUserTarget> selectAllStudentAssessUserTargetByIssueId(String issueId);
List<StudentTargetErrorStatisticsDto> getStudentTargetErrorStatisticsDtoListByIssueId(String issueId); List<StudentTargetErrorStatisticsDto> getStudentTargetErrorStatisticsDtoListByIssueId(String issueId);
/**
* @description 还原指标表
* @author Mr.Xu
* @date 2020-06-03 00:05:17
* @param [assessUserId]
* @return void
**/
void restoreByAssessUserId(String assessUserId);
} }

@ -0,0 +1,26 @@
package com.blockchain.server.yyyf.service;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import java.util.List;
public interface AssetsReporterService {
/**
* save assets reporter item
*
* @param assetsReporterList assetsReporter list
* @author fengyu.wang
* @date 2020-06-05 21:37:21
*/
void saveList(List<AssetsReporter> assetsReporterList);
/**
* select assetsReporter list by assessUserId
*
* @param assessUserId exam result id
* @return assetsReporter list
* @author fengyu.wang
* @date 2020-06-05 21:38:09
*/
List<AssetsReporter> selectAssetsReporterListByAssessUserId(String assessUserId);
}

@ -4,12 +4,14 @@ import com.blockchain.common.base.constant.YyyfConstant;
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;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.dto.YyyfStudentAnswerDto; import com.blockchain.server.yyyf.dto.YyyfStudentAnswerDto;
import com.blockchain.server.yyyf.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.entity.YyyfMoney; import com.blockchain.server.yyyf.entity.YyyfMoney;
import com.blockchain.server.yyyf.enums.YyyfEnums; import com.blockchain.server.yyyf.enums.YyyfEnums;
import com.blockchain.server.yyyf.exceprion.YyyfException; 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.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper; import com.blockchain.server.yyyf.mapper.YyyfMoneyMapper;
@ -30,9 +32,8 @@ import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Date; import java.util.concurrent.TimeUnit;
import java.util.List;
/** /**
* @author huan.xu * @author huan.xu
@ -56,6 +57,9 @@ public class AssessUserServiceImpl implements AssessUserService {
@Autowired @Autowired
private YyyfMoneyMapper yyyfMoneyMapper; private YyyfMoneyMapper yyyfMoneyMapper;
//@Autowired
private IndicatorsManager indicatorsManager;
@Value("${yyyf.url}") @Value("${yyyf.url}")
private String yyyfUrl; private String yyyfUrl;
@ -76,7 +80,6 @@ public class AssessUserServiceImpl implements AssessUserService {
} }
@Override @Override
public AssessUser selectAssessUserByUserIdAndissueIdForNotEnd(Integer userId, String issueId) { public AssessUser selectAssessUserByUserIdAndissueIdForNotEnd(Integer userId, String issueId) {
Example example = new Example(AssessUser.class); Example example = new Example(AssessUser.class);
@ -107,11 +110,12 @@ public class AssessUserServiceImpl implements AssessUserService {
assessUserTarget.setSort(j++); assessUserTarget.setSort(j++);
assessUserTarget.setAnswer(1); assessUserTarget.setAnswer(1);
assessUserTarget.setId(IdGenerator.uuid()); assessUserTarget.setId(IdGenerator.uuid());
assessUserTarget.setStudentRate(0d);
list.add(assessUserTarget); list.add(assessUserTarget);
} }
//区块链原始金额存入 //区块链原始金额存入
YyyfMoney yyyfMoney=new YyyfMoney(); YyyfMoney yyyfMoney = new YyyfMoney();
yyyfMoney.setAssessUserId(assessUser.getId()); yyyfMoney.setAssessUserId(assessUser.getId());
yyyfMoney.setAliPay(assessUser.getAlipayInitMoney()); yyyfMoney.setAliPay(assessUser.getAlipayInitMoney());
yyyfMoney.setWxPay(assessUser.getWechatInitMoney()); yyyfMoney.setWxPay(assessUser.getWechatInitMoney());
@ -119,6 +123,7 @@ public class AssessUserServiceImpl implements AssessUserService {
yyyfMoney.setBtc(BigDecimal.ZERO); yyyfMoney.setBtc(BigDecimal.ZERO);
yyyfMoney.setEth(BigDecimal.ZERO); yyyfMoney.setEth(BigDecimal.ZERO);
yyyfMoney.setUsdt(BigDecimal.ZERO); yyyfMoney.setUsdt(BigDecimal.ZERO);
yyyfMoney.setEos(BigDecimal.ZERO);
yyyfMoney.setUpdateTime(new Date()); yyyfMoney.setUpdateTime(new Date());
this.assessUserMapper.insert(assessUser); this.assessUserMapper.insert(assessUser);
@ -136,7 +141,6 @@ public class AssessUserServiceImpl implements AssessUserService {
@Override @Override
public AssessUserDto submit(String assessUserId) { public AssessUserDto submit(String assessUserId) {
AssessUser assessUser = this.selectAssessUserById(assessUserId); AssessUser assessUser = this.selectAssessUserById(assessUserId);
if (assessUser.getEndTime() != null) { if (assessUser.getEndTime() != null) {
throw new YyyfException(YyyfEnums.PROHIBIT_DUPLICATE_SUBMISSION); throw new YyyfException(YyyfEnums.PROHIBIT_DUPLICATE_SUBMISSION);
} }
@ -147,11 +151,20 @@ public class AssessUserServiceImpl implements AssessUserService {
criteria.andCondition(" assess_user_id = ", assessUserId); criteria.andCondition(" assess_user_id = ", assessUserId);
List<AssessUserTarget> assessUserTargetList = this.assessUserTargetMapper.selectByExample(example); List<AssessUserTarget> assessUserTargetList = this.assessUserTargetMapper.selectByExample(example);
//获取达标参数
Map<String, Float> targetResultMap = indicatorsManager.calculatePageIndicators(assessUserId);
//最终更新的指标库答题结果list
List<AssessUserTarget> updateAssessUserTargetList = new ArrayList<>();
for (AssessUserTarget assessUserTarget : assessUserTargetList) { for (AssessUserTarget assessUserTarget : assessUserTargetList) {
//计算是否达标
answerResultForTarget(assessUserTarget, targetResultMap);
Double taskScore = assessUserTarget.getTaskScore(); Double taskScore = assessUserTarget.getTaskScore();
if (assessUserTarget.getAnswer() == 0) { if (assessUserTarget.getAnswer() == 0) {
totalScore += taskScore; totalScore += taskScore;
} }
updateAssessUserTargetList.add(assessUserTarget);
} }
Date startTime = assessUser.getStartTime(); Date startTime = assessUser.getStartTime();
@ -170,6 +183,8 @@ public class AssessUserServiceImpl implements AssessUserService {
} }
this.update(assessUser); this.update(assessUser);
//批量更新指标最终结果
this.assessUserTargetMapper.batchUpdateTargetAnswer(updateAssessUserTargetList);
AssessUserDto assessUserDto = new AssessUserDto(); AssessUserDto assessUserDto = new AssessUserDto();
BeanUtils.copyProperties(assessUser, assessUserDto); BeanUtils.copyProperties(assessUser, assessUserDto);
@ -184,18 +199,25 @@ public class AssessUserServiceImpl implements AssessUserService {
List<AssessUserDto> assessUserDtoList = this.assessUserMapper.selectAssessUserDtoByIssueId(issueId); List<AssessUserDto> assessUserDtoList = this.assessUserMapper.selectAssessUserDtoByIssueId(issueId);
List<AssessUserDto> updateAssessUserDtoList = new ArrayList<>(); List<AssessUserDto> updateAssessUserDtoList = new ArrayList<>();
List<YyyfStudentAnswerDto> yyyfStudentAnswerDtoList = new ArrayList<>(assessUserDtoList.size()); List<YyyfStudentAnswerDto> yyyfStudentAnswerDtoList = new ArrayList<>(assessUserDtoList.size());
//最终更新的指标库答题结果list
List<AssessUserTarget> updateAssessUserTargetList = new ArrayList<>();
Date now = new Date(); Date now = new Date();
for (AssessUserDto assessUserDto : assessUserDtoList) { for (AssessUserDto assessUserDto : assessUserDtoList) {
//根据assessUserId 获取当时指标情况
Map<String, Float> targetResultMap = indicatorsManager.calculatePageIndicators(assessUserDto.getId());
List<AssessUserTarget> assessUserTargetList = assessUserDto.getAssessUserTargetList(); List<AssessUserTarget> assessUserTargetList = assessUserDto.getAssessUserTargetList();
if (assessUserDto.getEndTime() == null) { if (assessUserDto.getEndTime() == null) {
Double totalScore = 0d; Double totalScore = 0d;
for (AssessUserTarget assessUserTarget : assessUserTargetList) { for (AssessUserTarget assessUserTarget : assessUserTargetList) {
//计算是否达标
answerResultForTarget(assessUserTarget, targetResultMap);
//计算成绩
Double taskScore = assessUserTarget.getTaskScore(); Double taskScore = assessUserTarget.getTaskScore();
if (assessUserTarget.getAnswer() == 0) { if (assessUserTarget.getAnswer() == 0) {
totalScore += taskScore; totalScore += taskScore;
} }
updateAssessUserTargetList.add(assessUserTarget);
} }
Date startTime = assessUserDto.getStartTime(); Date startTime = assessUserDto.getStartTime();
assessUserDto.setTotalScore(totalScore); assessUserDto.setTotalScore(totalScore);
@ -205,12 +227,13 @@ public class AssessUserServiceImpl implements AssessUserService {
long duration = sdf.parse(sdf.format(now)).getTime() - sdf.parse(sdf.format(startTime)).getTime(); long duration = sdf.parse(sdf.format(now)).getTime() - sdf.parse(sdf.format(startTime)).getTime();
assessUserDto.setDuration(Math.toIntExact(duration)); assessUserDto.setDuration(Math.toIntExact(duration));
updateAssessUserDtoList.add(assessUserDto); updateAssessUserDtoList.add(assessUserDto);
//指标库更新
} }
YyyfStudentAnswerDto yyyfStudentAnswerDto = new YyyfStudentAnswerDto(); YyyfStudentAnswerDto yyyfStudentAnswerDto = new YyyfStudentAnswerDto();
BeanUtils.copyProperties(assessUserDto, yyyfStudentAnswerDto); BeanUtils.copyProperties(assessUserDto, yyyfStudentAnswerDto);
yyyfStudentAnswerDto.setAssessmentId(issueId); yyyfStudentAnswerDto.setAssessmentId(issueId);
yyyfStudentAnswerDtoList.add(yyyfStudentAnswerDto); yyyfStudentAnswerDtoList.add(yyyfStudentAnswerDto);
redisTemplate.delete(YyyfConstant.CASE_KEY + assessUserDto.getUserId()); redisTemplate.delete(YyyfConstant.CASE_KEY + assessUserDto.getUserId());
} }
@ -223,6 +246,7 @@ public class AssessUserServiceImpl implements AssessUserService {
if (updateAssessUserDtoList.size() > 0) { if (updateAssessUserDtoList.size() > 0) {
this.assessUserMapper.batchUpdateTotalScoreByAssessUserDtoList(assessUserDtoList); this.assessUserMapper.batchUpdateTotalScoreByAssessUserDtoList(assessUserDtoList);
this.assessUserTargetMapper.batchUpdateTargetAnswer(updateAssessUserTargetList);
} }
HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList); HttpClientUtil.doPostWithJSON(new StringBuilder().append(yyyfUrl).append(assessmentList).toString(), yyyfStudentAnswerDtoList);
@ -241,9 +265,9 @@ public class AssessUserServiceImpl implements AssessUserService {
@Override @Override
public int selectCountByByIssueId(String issueId) { public int selectCountByByIssueId(String issueId) {
Example example=new Example(AssessUser.class); Example example = new Example(AssessUser.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andCondition("issue_id = ",issueId); criteria.andCondition("issue_id = ", issueId);
return this.assessUserMapper.selectCountByExample(example); return this.assessUserMapper.selectCountByExample(example);
} }
@ -252,7 +276,7 @@ public class AssessUserServiceImpl implements AssessUserService {
Example example = new Example(AssessUser.class); Example example = new Example(AssessUser.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andCondition("issue_id = ", issueId) criteria.andCondition("issue_id = ", issueId)
.andCondition("user_id = ",userId); .andCondition("user_id = ", userId);
return this.assessUserMapper.selectOneByExample(example); return this.assessUserMapper.selectOneByExample(example);
} }
@ -261,7 +285,7 @@ public class AssessUserServiceImpl implements AssessUserService {
Example example = new Example(AssessUser.class); Example example = new Example(AssessUser.class);
Example.Criteria criteria = example.createCriteria(); Example.Criteria criteria = example.createCriteria();
criteria.andCondition("issue_id = ", issueId) criteria.andCondition("issue_id = ", issueId)
.andCondition("user_id = ",userId); .andCondition("user_id = ", userId);
return this.assessUserMapper.selectByExample(example); return this.assessUserMapper.selectByExample(example);
} }
@ -270,5 +294,37 @@ public class AssessUserServiceImpl implements AssessUserService {
return this.assessUserMapper.selectByPrimaryKey(assessUserId); return this.assessUserMapper.selectByPrimaryKey(assessUserId);
} }
@Override
public List<UserTimeMoneyDto> selectUserTimeMoneyDtosForNotEnd() {
return this.assessUserMapper.selectUserTimeMoneyDtosForNotEnd();
}
@Override
public UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId) {
return this.assessUserMapper.getUserTimeMoneyDtoByAssessUserId(assessUserId);
}
/**
* @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);
}
}
}
} }

@ -54,4 +54,16 @@ public class AssessUserTargetServiceImpl implements AssessUserTargetService {
return this.assessUserTargetMapper.getStudentTargetErrorStatisticsDtoListByIssueId(issueId); return this.assessUserTargetMapper.getStudentTargetErrorStatisticsDtoListByIssueId(issueId);
} }
@Override
public void restoreByAssessUserId(String assessUserId) {
Example example=new Example(AssessUserTarget.class);
Example.Criteria criteria = example.createCriteria();
criteria.andCondition(" assess_user_id = " ,assessUserId);
AssessUserTarget assessUserTarget=new AssessUserTarget();
assessUserTarget.setAnswer(1);
assessUserTarget.setStudentRate(0d);
this.assessUserTargetMapper.updateByExampleSelective(assessUserTarget,example);
}
} }

@ -0,0 +1,41 @@
package com.blockchain.server.yyyf.service.impl;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.mapper.AssetsReporterMapper;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import lombok.AllArgsConstructor;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
/**
* @author fengyu
*/
@Service
@AllArgsConstructor
public class AssetsReporterServiceImpl implements AssetsReporterService {
private final AssetsReporterMapper assetsReporterMapper;
private final CacheManager cacheManager;
public static final String CACHE_ASSETS_REPORTER = "yyyf_assets_reporter";
public static final String CACHE_KEY_ASSETS_REPORTER = "yyyf:assetsReporter:";
@Override
public void saveList(List<AssetsReporter> assetsReporterList) {
//TODO Transaction rollback, retry, log
assetsReporterList.forEach(assetsReporter ->
Optional.ofNullable(cacheManager.getCache(CACHE_ASSETS_REPORTER))
.ifPresent(cache -> cache.evict(CACHE_KEY_ASSETS_REPORTER.concat(assetsReporter.getAssessUserId()))));
assetsReporterMapper.insertBatch(assetsReporterList);
}
@Override
@Cacheable(cacheNames = CACHE_ASSETS_REPORTER,
key = "#root.target.CACHE_KEY_ASSETS_REPORTER.concat(#assessUserId)", unless = "#result == null")
public List<AssetsReporter> selectAssetsReporterListByAssessUserId(String assessUserId) {
return assetsReporterMapper.selectByAssessUserId(assessUserId);
}
}

@ -0,0 +1,53 @@
package com.blockchain.server.yyyf.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.indicators.IndicatorsManager;
import com.blockchain.server.yyyf.indicators.dto.AssetsReporter;
import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.service.AssetsReporterService;
import com.blockchain.server.yyyf.utils.IdGenerator;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author fengyu
*/
@Configuration
@EnableScheduling
@AllArgsConstructor
public class ExamProcessTask {
private final AssessUserService assessUserService;
private final IndicatorsManager indicatorsManager;
private final AssetsReporterService assetsReporterService;
@Scheduled(cron = "0 1 0 * * ?")
public void processRecording() {
List<UserTimeMoneyDto> userTimeMoneyList = this.assessUserService.selectUserTimeMoneyDtosForNotEnd();
List<AssetsReporter> assetsReporterList = new ArrayList<>(userTimeMoneyList.size());
DateTime now = DateUtil.date();
userTimeMoneyList.forEach(entity -> {
BigDecimal assets = indicatorsManager.calculateCurrentTotalAssets(entity.getQUserId(), entity.getAssessUserId());
assetsReporterList.add(AssetsReporter.builder()
.id(IdGenerator.uuid())
.assessUserId(entity.getAssessUserId())
.assets(assets)
.days(DateUtil.between(entity.getStartTime(), now, DateUnit.DAY))
.coinName("RMB")
.createTime(now)
.build());
});
if (!assetsReporterList.isEmpty()) {
assetsReporterService.saveList(assetsReporterList);
}
}
}

@ -29,3 +29,4 @@ yyyf:
assessment: /api/db/v1.0/assessment assessment: /api/db/v1.0/assessment
#成绩同步(整场考试) #成绩同步(整场考试)
assessmentList: /api/db/v1.0/assessmentList assessmentList: /api/db/v1.0/assessmentList

@ -34,7 +34,22 @@
</collection> </collection>
</resultMap> </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" />
<result column="eos" jdbcType="DECIMAL" property="eos" />
<result column="alipay_init_money" jdbcType="DECIMAL" property="aliPayInit" />
<result column="wechat_init_money" jdbcType="DECIMAL" property="wxPayInit" />
<result column="bankcard_init_money" jdbcType="DECIMAL" property="bankCardInit" />
</resultMap>
@ -99,5 +114,21 @@
WHERE WHERE
u.id = t.assess_user_id and u.issue_id=#{issueId} u.id = t.assess_user_id and u.issue_id=#{issueId}
</select> </select>
<select id="selectUserTimeMoneyDtosForNotEnd" resultMap="UserTimeMoneyDtoMap">
SELECT au.id,au.user_id,au.q_user_id,au.start_time,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt,m.eos,au.alipay_init_money,au.wechat_init_money,au.bankcard_init_money
from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.end_time is null
</select>
<select id="getUserTimeMoneyDtoByAssessUserId"
resultMap="UserTimeMoneyDtoMap">
SELECT au.id,au.user_id,au.q_user_id,au.alipay_init_money,au.wechat_init_money,au.bankcard_init_money,au.start_time,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt,m.eos
from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.id=#{assessUserId}
</select>
<select id="selectCurrentUserTimeMoneyDto" resultMap="UserTimeMoneyDtoMap">
SELECT au.id,au.user_id,au.q_user_id,au.alipay_init_money,au.wechat_init_money,au.bankcard_init_money,au.start_time,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt,m.eos
from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.q_user_id=#{qUserId} and au.id={assessUserId}
</select>
</mapper> </mapper>

@ -29,6 +29,13 @@
</foreach > </foreach >
</insert> </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},student_rate=#{item.studentRate,jdbcType=DECIMAL} where id = #{item.id,jdbcType=VARCHAR}
</foreach>
</update>
<select id="selectAllStudentAssessUserTargetByIssueId" <select id="selectAllStudentAssessUserTargetByIssueId"
resultMap="AssessUserTargetMap"> resultMap="AssessUserTargetMap">
SELECT SELECT

@ -0,0 +1,38 @@
<?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.AssetsReporterMapper">
<resultMap id="BaseResultMap" type="com.blockchain.server.yyyf.indicators.dto.AssetsReporter">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="assess_user_id" property="assessUserId" jdbcType="VARCHAR"/>
<result column="coin_name" property="coinName" jdbcType="VARCHAR"/>
<result column="days" property="days" jdbcType="INTEGER"/>
<result column="assets" property="assets" jdbcType="DECIMAL"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, assess_user_id, coin_name, days, assets, create_time
</sql>
<insert id="insertBatch" parameterType="java.util.List">
insert into yyyf_assets_reporter
(<include refid="Base_Column_List"/>)
values
<foreach collection="list" item="assetsReporter" index="index" separator=",">
(
#{assetsReporter.id},
#{assetsReporter.assess_user_id},
#{assetsReporter.coin_name},
#{assetsReporter.days},
#{assetsReporter.assets},
#{assetsReporter.create_time}
)
</foreach>
</insert>
<select id="selectByAssessUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from yyyf_assets_reporter
where assess_user_id = #{assessUserId,jdbcType=VARCHAR}
</select>
</mapper>
Loading…
Cancel
Save