Commit f251d841 authored by 王业雄's avatar 王业雄

添加四个页面接口

parent 73dc6773
......@@ -72,6 +72,23 @@
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......@@ -367,6 +384,19 @@
<artifactId>aws-java-sdk-s3</artifactId>
<version>${amazonaws.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
......@@ -389,4 +419,5 @@
<version>1.6.3</version>
</dependency>
</dependencies>
</project>
......@@ -38,7 +38,7 @@ public class InitAreaCode {
logger.info("初始化区域码end:code{},name{}",concurrentHashMap.size(),concurrentNameHashMap.size());
}
private static String getString(InputStream in) throws IOException {
public static String getString(InputStream in) throws IOException {
Throwable var3 = null;
String var4;
try {
......
package com.quantgroup.asset.distribution.controller.route.channelroute;
import com.quantgroup.asset.distribution.enums.route.SystemType;
import com.quantgroup.asset.distribution.enums.route.UserLevel;
import com.quantgroup.asset.distribution.enums.route.UserTag;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelConfigInfoVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteSaveVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.FundProInfoVo;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.TypeVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.route.IChannelRouteService;
import com.quantgroup.asset.distribution.util.AllRecords;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* 渠道路由配置接口
* @author wyx 2021-08-28
*/
@Slf4j
@RestController
@RequestMapping("/channelroute")
public class ChannelRouteController {
@Autowired
private IChannelRouteService channelRouteService;
/**
* 分页查询
* @param channelRouteQueryVo
* @return
*/
@RequestMapping(value = "/queryPage",method = RequestMethod.POST)
public GlobalResponse queryPage(@RequestBody ChannelRouteQueryVo channelRouteQueryVo){
AllRecords allRecords = channelRouteService.queryPage(channelRouteQueryVo);
return GlobalResponse.success(allRecords);
}
/**
* 查询已经配置过的渠道,下拉框
* @return
*/
@RequestMapping("/queryConfigChannelIds")
public GlobalResponse queryConfigChannelIds(){
List<Long> channelIdList = channelRouteService.queryConfigChannelIds();
return GlobalResponse.success(channelIdList);
}
/**
* 根据渠道号查询渠道配置过的渠道路由信息
* @param channelId
* @return
*/
@RequestMapping("/queryConfigChannelInfo")
public GlobalResponse queryConfigChannelInfo(@NotNull Long channelId){
return channelRouteService.queryConfigChannelInfo(channelId);
}
/**
* 选择资金编号下拉框
* @return
*/
@RequestMapping("/getFundIds")
public GlobalResponse getFundIds(){
List<Long> fundIdList = channelRouteService.getFundIds();
return GlobalResponse.success(fundIdList);
}
/**
* 根据资金编号查询资金产品编号
* @param fundId
* @return
*/
@RequestMapping("/getFundCorpIdByFundId")
public GlobalResponse getFundCorpIdByFundId(@NotNull Long fundId){
List<Long> fundCorpIdList = channelRouteService.getFundCorpIdByFundId(fundId);
return GlobalResponse.success(fundCorpIdList);
}
/**
* 根据资金编号+资金产品编号查询资金名称、资金类型、机构类型、业务类型、业务系统
* @param fundId
* @param fundCorpId
* @return
*/
@RequestMapping("/getFundProductInfo")
public GlobalResponse getFundProductInfo(@NotNull Long fundId,@NotNull Long fundCorpId){
FundProInfoVo fundProInfoVo = channelRouteService.getFundProductInfo(fundId,fundCorpId);
return GlobalResponse.success(fundProInfoVo);
}
/**
* 获取用户标签下拉框
* @return
*/
@RequestMapping("/getUserTag")
public GlobalResponse getUserTag(){
List<TypeVo> list = new ArrayList<>();
for (UserTag userTag:UserTag.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(userTag.getValue());
typeVo.setName(userTag.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 获取用户等级下拉框
* @return
*/
@RequestMapping("/getUserLevel")
public GlobalResponse getUserLevel(){
List<TypeVo> list = new ArrayList<>();
for (UserLevel userLevel:UserLevel.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(userLevel.getValue());
typeVo.setName(userLevel.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 新增渠道配置信息
* @param channelRouteSaveVoList
* @param type 0表示新增 1表示编辑
* @return
*/
@RequestMapping("/addChannelConfig")
public GlobalResponse addChannelConfig(@RequestBody@Valid@NotEmpty List<ChannelRouteSaveVo> channelRouteSaveVoList, @NotNull Integer type, BindingResult bindingResult){
if (bindingResult.hasErrors()){
return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage());
}
channelRouteService.addChannelConfig(channelRouteSaveVoList,type);
return GlobalResponse.success();
}
/**
* 发布渠道配置信息
* @return
*/
@RequestMapping("/publishChannelConfig")
public GlobalResponse publishChannelConfig(@RequestBody List<Long> ids){
channelRouteService.publishChannelConfig(ids);
return GlobalResponse.success();
}
/**
* 更新渠道配置信息,未更新前使用原有配置
* @param channelId
* @return
*/
@RequestMapping("/updateChannelConfig")
public GlobalResponse updateChannelConfig(Long channelId){
channelRouteService.updateChannelConfig(channelId);
return GlobalResponse.success();
}
}
package com.quantgroup.asset.distribution.controller.route.fundproduct;
import com.quantgroup.asset.distribution.enums.route.BusinessType;
import com.quantgroup.asset.distribution.enums.route.FundType;
import com.quantgroup.asset.distribution.enums.route.OrganizationType;
import com.quantgroup.asset.distribution.enums.route.SystemType;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.FundProductQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.FundProductSaveVo;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.FundProductVo;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.TypeVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.newrule.pojo.enums.AreaEnum;
import com.quantgroup.asset.distribution.service.newrule.pojo.enums.IdCardExpireEnum;
import com.quantgroup.asset.distribution.service.route.IFundProductService;
import com.quantgroup.asset.distribution.util.AllRecords;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**
* 资金产品列表
* @author wyx 2021-08-29
*/
@Slf4j
@RestController
@RequestMapping("/fundproduct")
public class FundProductController {
@Autowired
private IFundProductService fundProductService;
/**
* 分页查询
* @param fundProductQueryVo
* @return
*/
@RequestMapping(value = "/queryPage",method = RequestMethod.POST)
public GlobalResponse queryPage(@RequestBody FundProductQueryVo fundProductQueryVo){
AllRecords allRecords = fundProductService.queryPage(fundProductQueryVo);
return GlobalResponse.success(allRecords);
}
/**
* 资金类型下拉框
* @return
*/
@RequestMapping("/getFundType")
public GlobalResponse getFundType(){
List<TypeVo> list = new ArrayList<>();
for (FundType fundType:FundType.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(fundType.getValue());
typeVo.setName(fundType.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 机构类型下拉框
* @return
*/
@RequestMapping("/getOrganizationType")
public GlobalResponse getOrganizationType(){
List<TypeVo> list = new ArrayList<>();
for (OrganizationType organizationType:OrganizationType.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(organizationType.getValue());
typeVo.setName(organizationType.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 业务类型下拉框
* @return
*/
@RequestMapping("/getBusinessType")
public GlobalResponse getBusinessType(){
List<TypeVo> list = new ArrayList<>();
for (BusinessType businessType:BusinessType.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(businessType.getValue());
typeVo.setName(businessType.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 业务系统下拉框
* @return
*/
@RequestMapping("/getSystemType")
public GlobalResponse getSystemType(){
List<TypeVo> list = new ArrayList<>();
for (SystemType systemType:SystemType.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(systemType.getValue());
typeVo.setName(systemType.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 编辑或查看资金产品信息
* @param id
* @return
*/
@RequestMapping("/lookFundProduct")
public GlobalResponse lookFundProduct(Long id){
FundProductVo fundProductVo = fundProductService.lookFundProduct(id);
return GlobalResponse.success(fundProductVo);
}
/**
* 地区要求下拉框
* @return
*/
@RequestMapping("/getAreaRequire")
public GlobalResponse getAreaRequire(){
List<TypeVo> list = new ArrayList<>();
for (AreaEnum areaEnum:AreaEnum.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(String.valueOf(areaEnum.getCode()));
typeVo.setName(areaEnum.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 身份证有效期下拉框
* @return
*/
@RequestMapping("/getIdCardExpire")
public GlobalResponse getIdCardExpire(){
List<TypeVo> list = new ArrayList<>();
for (IdCardExpireEnum idCardExpireEnum:IdCardExpireEnum.values()){
TypeVo typeVo = new TypeVo();
typeVo.setCode(String.valueOf(idCardExpireEnum.getCode()));
typeVo.setName(idCardExpireEnum.getDesc());
list.add(typeVo);
}
return GlobalResponse.success(list);
}
/**
* 保存接口
* @param fundProductSaveVo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/save",method = RequestMethod.POST)
public GlobalResponse save(@RequestBody@Valid FundProductSaveVo fundProductSaveVo, BindingResult bindingResult){
if (bindingResult.hasErrors()){
return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage());
}
return fundProductService.save(fundProductSaveVo);
}
/**
* 获取省市区分级数据
* @return
*/
@RequestMapping("/getArea")
public GlobalResponse getArea(){
try {
return fundProductService.getArea();
}catch (Exception e){
log.error("获取省市区信息异常",e);
return GlobalResponse.error("获取省市区信息异常");
}
}
}
package com.quantgroup.asset.distribution.controller.route.routerecord;
import com.quantgroup.asset.distribution.model.entity.route.routerecord.RouteRecordQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListQueryVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.route.IRouteRecordService;
import com.quantgroup.asset.distribution.util.AllRecords;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* 路由记录查询页面
*/
@Slf4j
@RestController
@RequestMapping("/routerecord")
public class RouteRecordController {
@Autowired
private IRouteRecordService routeRecordService;
/**
* 分页查询
* @param routeRecordQueryVo
* @return
*/
@RequestMapping(value = "/queryPage",method = RequestMethod.POST)
public GlobalResponse queryPage(@RequestBody RouteRecordQueryVo routeRecordQueryVo){
AllRecords allRecords = routeRecordService.queryPage(routeRecordQueryVo);
return GlobalResponse.success(allRecords);
}
}
package com.quantgroup.asset.distribution.controller.route.whitelist;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListSaveVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.route.IWhiteListService;
import com.quantgroup.asset.distribution.util.AllRecords;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
/**
* 白名单配置页面接口
*/
@Slf4j
@RestController
@RequestMapping("/whitelist")
public class WhiteListController {
@Autowired
private IWhiteListService whiteListService;
/**
* 分页查询
* @param whiteListQueryVo
* @return
*/
@RequestMapping(value = "/queryPage",method = RequestMethod.POST)
public GlobalResponse queryPage(@RequestBody WhiteListQueryVo whiteListQueryVo){
AllRecords allRecords = whiteListService.queryPage(whiteListQueryVo);
return GlobalResponse.success(allRecords);
}
/**
* 启用停用
* @param id
* @param status
* @return
*/
@RequestMapping("/updateStatus")
public GlobalResponse updateStatus(@NotNull Long id, @NotNull Byte status){
return whiteListService.updateStatus(id,status);
}
/**
* 新增白名单配置
* @param whiteListSaveVo
* @return
*/
@RequestMapping("/save")
public GlobalResponse save(@RequestBody@Valid WhiteListSaveVo whiteListSaveVo, BindingResult bindingResult){
if (bindingResult.hasErrors()){
return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage());
}
return whiteListService.save(whiteListSaveVo);
}
}
package com.quantgroup.asset.distribution.model.entity.route.channelroute;
import lombok.Data;
import java.sql.Timestamp;
/**
* 通过渠道号查询渠道配置信息返回值
*/
@Data
public class ChannelConfigInfoVo {
private Long fundId;
private Long fundCorpId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private String systermType;
private Integer creditResult;
private String userTag;
private String userLevel;
private Integer priority;
}
package com.quantgroup.asset.distribution.model.entity.route.channelroute;
import com.quantgroup.asset.distribution.util.PageVo;
import lombok.Data;
/**
* 渠道路由配置查询条件
*/
@Data
public class ChannelRouteQueryVo extends PageVo {
private Long channelId;
private Long fundId;
private String fundName;
private Byte publishStatus;
}
package com.quantgroup.asset.distribution.model.entity.route.channelroute;
import lombok.Data;
import java.sql.Timestamp;
/**
* 渠道路由配置查询结果
*/
@Data
public class ChannelRouteResultVo {
private Long id;
private Long channelId;
private Byte publishStatus;
private Long fundId;
private Long fundProId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private Integer creditResult;
private String userTag;
private String userLevel;
private Integer priority;
private Timestamp updatedAt;
}
package com.quantgroup.asset.distribution.model.entity.route.channelroute;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 保存渠道路由信息
*/
@Data
public class ChannelRouteSaveVo {
@NotNull(message = "路由等待不能为空")
private Byte routeWait;
@NotNull(message = "渠道号不能为空")
private Long channelId;
@NotNull(message = "资金编号不能为空")
private Long fundId;
@NotNull(message = "资金产品编号不能为空")
private Long fundProId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
@NotNull(message = "授信结果不能为空")
private Integer creditResult;
private String userTag;
private String userLevel;
private Integer priority;
}
package com.quantgroup.asset.distribution.model.entity.route.channelroute;
import lombok.Data;
/**
* 通过资金编号和产品编号查询资金产品信息
*/
@Data
public class FundProInfoVo {
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private String systermType;
}
package com.quantgroup.asset.distribution.model.entity.route.fundproduct;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class AreaCodeVo {
private String adcode;
private String name;
private List<AreaCodeVo> nodes=new ArrayList<>();
}
package com.quantgroup.asset.distribution.model.entity.route.fundproduct;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class FundProductQueryResultVo {
private Integer seqNo;
private Long fundId;
private Long fundProId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private String systermType;
private Timestamp updatedAt;
}
package com.quantgroup.asset.distribution.model.entity.route.fundproduct;
import com.quantgroup.asset.distribution.util.PageVo;
import lombok.Data;
@Data
public class FundProductQueryVo extends PageVo {
private Long fundId;
private Long fundProId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private String systermType;
}
package com.quantgroup.asset.distribution.model.entity.route.fundproduct;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Map;
@Data
public class FundProductSaveVo {
@NotNull(message = "id不能为空")
private Long id;
@NotNull(message = "资金编号不能为空")
private Long fundId;
@NotNull(message = "资金产品编号不能为空")
private Long fundProId;
@NotBlank(message = "资金名称不能为空")
private String fundName;
@NotBlank(message = "资金类型不能为空")
private String fundType;
@NotBlank(message = "机构类型不能为空")
private String orgType;
@NotBlank(message = "业务类型不能为空")
private String businessType;
@NotBlank(message = "业务系统不能为空")
private String systermType;
/**
* 基本信息和其他信息字段,对应的value
*/
@NotEmpty(message = "规则集不能为空")
private Map<Long,String> ruleValueMap;
}
package com.quantgroup.asset.distribution.model.entity.route.fundproduct;
import com.quantgroup.asset.distribution.service.jpa.entity.ProductRuleEntity;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* 资金产品页面返回结果
*/
@Data
public class FundProductVo {
/**
* 资金信息-value 字段由前端写死
*/
private Long fundId;
private Long fundProId;
private String fundName;
private String systermType;
private String fundType;
private String orgType;
private String businessType;
/**
* 基本信息和其他信息字段
*/
private List<ProductRuleEntity> productRuleEntityList;
/**
* 基本信息和其他信息字段,对应的value
*/
private Map<Long,String> ruleValueMap;
}
package com.quantgroup.asset.distribution.model.entity.route.fundproduct;
import lombok.Data;
/**
* 存放下拉框对应的code及名称name
*/
@Data
public class TypeVo {
private String code;
private String name;
}
package com.quantgroup.asset.distribution.model.entity.route.routerecord;
import com.quantgroup.asset.distribution.util.PageVo;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class RouteRecordQueryVo extends PageVo {
private String creditNo;
private String uuid;
private Byte status;
private Timestamp routedAtMin;
private Timestamp routedAtMax;
}
package com.quantgroup.asset.distribution.model.entity.route.routerecord;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class RouteRecordResultVo {
private String creditNo;
private String uuid;
private String phone;
private Byte status;
private String routedResult;
private Timestamp routedAt;
}
package com.quantgroup.asset.distribution.model.entity.route.whitelist;
import com.quantgroup.asset.distribution.util.PageVo;
import lombok.Data;
/**
* 白名单分页查询参数
*/
@Data
public class WhiteListQueryVo extends PageVo {
private String phone;
private String fundName;
}
package com.quantgroup.asset.distribution.model.entity.route.whitelist;
import lombok.Data;
import java.sql.Timestamp;
/**
* 分页查询返回结果
*/
@Data
public class WhiteListResultVo {
private long id;
private String phone;
private long fundId;
private long fundProId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private Byte status;
private Timestamp createdAt;
}
package com.quantgroup.asset.distribution.model.entity.route.whitelist;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 白名单配置保存参数
*/
@Data
public class WhiteListSaveVo {
@NotBlank(message = "手机号不能为空")
private String phone;
@NotNull(message = "资金编号不能为空")
private Long fundId;
@NotNull(message = "资金产品编号不能为空")
private Long fundProId;
private String fundType;
private String orgType;
private String businessType;
}
......@@ -20,7 +20,6 @@ import com.quantgroup.asset.distribution.service.rule.IRuleService;
import com.quantgroup.asset.distribution.service.rule.vo.BaseRuleVO;
import com.quantgroup.asset.distribution.service.rule.vo.IRuleVO;
import com.quantgroup.asset.distribution.service.rule.vo.UnionRuleVO;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.bag.HashBag;
......
......@@ -22,10 +22,10 @@ public class ChannelRuleEntity {
private String fundType;
private String orgType;
private String businessType;
private int creditResult;
private Integer creditResult;
private String userTag;
private String userLevel;
private int priority;
private Integer priority;
private Byte routeWait;
private Byte enable;
private Timestamp createdAt;
......
......@@ -12,14 +12,15 @@ import java.util.Objects;
@Entity
@Table(name = "fund_product", schema = "asset-distribution", catalog = "")
public class FundProductEntity {
private long id;
private long fundId;
private long fundProId;
private Long id;
private Long fundId;
private Long fundProId;
private String fundName;
private String fundType;
private String orgType;
private String businessType;
private String systermType;
private String basicRule;
private int areaTerm;
private int cardLimit;
......@@ -31,32 +32,33 @@ public class FundProductEntity {
private Timestamp updatedAt;
@Id
@GeneratedValue
@Column(name = "id", nullable = false)
public long getId() {
public Long getId() {
return id;
}
public void setId(long id) {
public void setId(Long id) {
this.id = id;
}
@Basic
@Column(name = "fund_id", nullable = false)
public long getFundId() {
public Long getFundId() {
return fundId;
}
public void setFundId(long fundId) {
public void setFundId(Long fundId) {
this.fundId = fundId;
}
@Basic
@Column(name = "fund_pro_id", nullable = false)
public long getFundProId() {
public Long getFundProId() {
return fundProId;
}
public void setFundProId(long fundProId) {
public void setFundProId(Long fundProId) {
this.fundProId = fundProId;
}
......
......@@ -18,6 +18,7 @@ public class ProductRuleEntity {
private String ruleEngine;
private String ruleChinese;
private String textType;
private String ruleType;
private Byte enable;
private Timestamp createdAt;
private Timestamp updatedAt;
......@@ -82,6 +83,17 @@ public class ProductRuleEntity {
this.textType = textType;
}
@Basic
@Column(name = "rule_type", nullable = true, length = 50)
public String getRuleType() {
return ruleType;
}
public void setRuleType(String ruleType) {
this.ruleType = ruleType;
}
@Basic
@Column(name = "enable", nullable = true)
public Byte getEnable() {
......
......@@ -2,12 +2,21 @@ package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.ChannelRuleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import java.util.List;
public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, Long>{
public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, Long>, QueryDslPredicateExecutor<ChannelRuleEntity> {
ChannelRuleEntity getByFundProductIdEquals(long fundProductId);
List<ChannelRuleEntity> getByChannelId(long channelId);
List<ChannelRuleEntity> getAllByEnableEquals(Byte enable);
List<ChannelRuleEntity> getAllByChannelIdEqualsAndEnableEquals(Long channelId,Byte enable);
List<ChannelRuleEntity> getAllByIdIn(List<Long> ids);
Boolean deleteAllByChannelIdEqualsAndEnableEquals(Long channelId,Byte enable);
}
......@@ -2,8 +2,20 @@ package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.FundProductEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import java.util.List;
public interface IFundProductRepository extends JpaRepository<FundProductEntity, Long>{
public interface IFundProductRepository extends JpaRepository<FundProductEntity, Long>, QueryDslPredicateExecutor<FundProductEntity> {
FundProductEntity getByIdEquals(Long id);
List<FundProductEntity> getAllByEnableEquals(Byte enable);
List<FundProductEntity> getAllByFundIdEqualsAndEnableEquals(Long fundId,Byte enable);
FundProductEntity getByFundIdEqualsAndFundProIdEqualsAndEnableEquals(Long fundId,Long fundProId,Byte enable);
FundProductEntity getByFundIdEqualsAndFundProIdEquals(Long fundId,Long fundProId);
}
......@@ -3,7 +3,14 @@ package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.ProductRuleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface IProductRuleRepository extends JpaRepository<ProductRuleEntity, Long>{
ProductRuleEntity getByRuleNameEquals(String ruleName);
List<ProductRuleEntity> getAllByRuleTypeEqualsAndEnableEquals(String ruleType,Byte enable);
List<ProductRuleEntity> getAllByEnableEquals(Byte enable);
}
package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.RoutingRecordEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.WhiteListEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
public interface IRoutingRecordRepository extends JpaRepository<RoutingRecordEntity, Long>{
public interface IRoutingRecordRepository extends JpaRepository<RoutingRecordEntity, Long>, QueryDslPredicateExecutor<RoutingRecordEntity> {
}
......@@ -2,8 +2,9 @@ package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.WhiteListEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
public interface IWhiteListRepository extends JpaRepository<WhiteListEntity, Long>{
public interface IWhiteListRepository extends JpaRepository<WhiteListEntity, Long>, QueryDslPredicateExecutor<WhiteListEntity> {
WhiteListEntity getByPhoneEquals(String phone);
}
package com.quantgroup.asset.distribution.service.route;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelConfigInfoVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.ChannelRouteSaveVo;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.FundProInfoVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.util.AllRecords;
import java.util.List;
public interface IChannelRouteService {
AllRecords queryPage(ChannelRouteQueryVo channelRouteQueryVo);
List<Long> queryConfigChannelIds();
GlobalResponse queryConfigChannelInfo(Long channelId);
List<Long> getFundIds();
List<Long> getFundCorpIdByFundId(Long fundId);
FundProInfoVo getFundProductInfo(Long fundId, Long fundCorpId);
void addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type);
void publishChannelConfig(List<Long> ids);
void updateChannelConfig(Long channelId);
}
package com.quantgroup.asset.distribution.service.route;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.FundProductQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.FundProductSaveVo;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.FundProductVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.util.AllRecords;
import java.io.IOException;
public interface IFundProductService {
AllRecords queryPage(FundProductQueryVo fundProductQueryVo);
FundProductVo lookFundProduct(Long id);
GlobalResponse save(FundProductSaveVo fundProductSaveVo);
GlobalResponse getArea() throws IOException;
}
package com.quantgroup.asset.distribution.service.route;
import com.quantgroup.asset.distribution.model.entity.route.routerecord.RouteRecordQueryVo;
import com.quantgroup.asset.distribution.util.AllRecords;
public interface IRouteRecordService {
AllRecords queryPage(RouteRecordQueryVo routeRecordQueryVo);
}
package com.quantgroup.asset.distribution.service.route;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListSaveVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.util.AllRecords;
public interface IWhiteListService {
AllRecords queryPage(WhiteListQueryVo whiteListQueryVo);
GlobalResponse updateStatus(Long id, Byte status);
GlobalResponse save(WhiteListSaveVo whiteListSaveVo);
}
package com.quantgroup.asset.distribution.service.route.impl;
import com.quantgroup.asset.distribution.model.entity.route.channelroute.*;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.jpa.entity.ChannelRuleEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.FundProductEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.QChannelRuleEntity;
import com.quantgroup.asset.distribution.service.jpa.repository.IChannelRuleRepository;
import com.quantgroup.asset.distribution.service.jpa.repository.IFundProductRepository;
import com.quantgroup.asset.distribution.service.route.IChannelRouteService;
import com.quantgroup.asset.distribution.util.AllRecords;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
public class ChannelRouteServiceImpl implements IChannelRouteService {
@Autowired
IChannelRuleRepository channelRuleRepository;
@Autowired
IFundProductRepository fundProductRepository;
@Override
public AllRecords queryPage(ChannelRouteQueryVo channelRouteQueryVo) {
//索引 和 每页大小 排序 条件
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
if (Objects.nonNull(channelRouteQueryVo.getChannelId())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.channelId.like(String.valueOf(channelRouteQueryVo.getChannelId())));
}
if (Objects.nonNull(channelRouteQueryVo.getFundId())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.fundId.like(String.valueOf(channelRouteQueryVo.getFundId())));
}
if (!StringUtils.isEmpty(channelRouteQueryVo.getFundName())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.fundName.like(String.valueOf(channelRouteQueryVo.getFundName())));
}
if (Objects.nonNull(channelRouteQueryVo.getPublishStatus())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.publishStatus.eq(channelRouteQueryVo.getPublishStatus()));
}
//只查有效数据
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.enable.eq(Byte.valueOf("1")));
//1.查询条件,2.索引和每页的大小,3.排序根据某个字段进行排序
//查询总条数
long count = channelRuleRepository.count(booleanExpression);
//查询数据
Page<ChannelRuleEntity> plantPage = channelRuleRepository.findAll(booleanExpression, new PageRequest(channelRouteQueryVo.getOffset(), channelRouteQueryVo.getPageSize(), new Sort(Sort.Direction.DESC, "createdAt")));
List<ChannelRuleEntity> channelRuleEntities = new ArrayList<>();
channelRuleEntities = plantPage.getContent();
List<ChannelRouteResultVo> channelRouteResultVos = new ArrayList<>();
channelRuleEntities.stream().forEach(channelRuleEntity -> {
ChannelRouteResultVo channelRouteResultVo = new ChannelRouteResultVo();
BeanUtils.copyProperties(channelRuleEntity, channelRouteResultVo);
channelRouteResultVos.add(channelRouteResultVo);
});
AllRecords allRecords = new AllRecords();
allRecords.setPageIndex(channelRouteQueryVo.getPageIndex());
allRecords.setPageSize(channelRouteQueryVo.getPageSize());
allRecords.setDataList(channelRouteResultVos);
allRecords.setTotalNumber(count);
allRecords.resetTotalNumber(count);
return allRecords;
}
@Override
public List<Long> queryConfigChannelIds() {
List<ChannelRuleEntity> allByEnableEquals = channelRuleRepository.getAllByEnableEquals(Byte.valueOf("1"));
List<Long> channelIds = new ArrayList<>();
allByEnableEquals.stream().forEach(channelRuleEntity -> {
if (!channelIds.contains(channelRuleEntity.getChannelId())){
channelIds.add(channelRuleEntity.getChannelId());
}
});
return channelIds;
}
@Override
public GlobalResponse queryConfigChannelInfo(Long channelId) {
List<ChannelConfigInfoVo> channelConfigInfoVos = new ArrayList<>();
List<ChannelRuleEntity> allByChannelIdEqualsaAndEnableEquals = channelRuleRepository.getAllByChannelIdEqualsAndEnableEquals(channelId, Byte.valueOf("1"));
if (CollectionUtils.isEmpty(allByChannelIdEqualsaAndEnableEquals)){
return GlobalResponse.error("该渠道没有对应的路由配置信息");
}else {
allByChannelIdEqualsaAndEnableEquals.stream().forEach(channelRuleEntity -> {
ChannelConfigInfoVo configInfoVo = new ChannelConfigInfoVo();
BeanUtils.copyProperties(channelRuleEntity, configInfoVo);
FundProductEntity one = fundProductRepository.findOne(channelRuleEntity.getFundProductId());
if (Objects.nonNull(one)){
configInfoVo.setSystermType(one.getSystermType());
channelConfigInfoVos.add(configInfoVo);
}
});
return GlobalResponse.success(channelConfigInfoVos);
}
}
@Override
public List<Long> getFundIds() {
List<FundProductEntity> fundProductEntityList = fundProductRepository.getAllByEnableEquals(Byte.valueOf("1"));
List<Long> fundIdList = new ArrayList<>();
fundProductEntityList.stream().forEach(fundProductEntity -> {
if (!fundIdList.contains(fundProductEntity.getFundId())){
fundIdList.add(fundProductEntity.getFundId());
}
});
return fundIdList;
}
@Override
public List<Long> getFundCorpIdByFundId(Long fundId) {
List<FundProductEntity> fundProductEntityList = fundProductRepository.getAllByFundIdEqualsAndEnableEquals(fundId,Byte.valueOf("1"));
List<Long> fundCorpList = new ArrayList<>();
fundProductEntityList.stream().forEach(fundProductEntity -> {
if (!fundCorpList.contains(fundProductEntity.getFundProId())){
fundCorpList.add(fundProductEntity.getFundProId());
}
});
return fundCorpList;
}
@Override
public FundProInfoVo getFundProductInfo(Long fundId, Long fundCorpId) {
FundProductEntity fundProductEntity = fundProductRepository.getByFundIdEqualsAndFundProIdEqualsAndEnableEquals(fundId, fundCorpId, Byte.valueOf("1"));
FundProInfoVo fundProInfoVo = new FundProInfoVo();
BeanUtils.copyProperties(fundProductEntity,fundProInfoVo);
return fundProInfoVo;
}
@Override
public void addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type) {
/**
* 编辑时要去掉所有该渠道有效性为0的其他配置(覆盖之前的未更新编辑信息)
*/
if ( 0 != type ){
channelRuleRepository.deleteAllByChannelIdEqualsAndEnableEquals(channelRouteSaveVoList.get(0).getChannelId(),Byte.valueOf("0"));
}
channelRouteSaveVoList.stream().forEach(channelRouteSaveVo -> {
ChannelRuleEntity channelRuleEntity = new ChannelRuleEntity();
BeanUtils.copyProperties(channelRouteSaveVo,channelRuleEntity);
FundProductEntity fundProductEntity = fundProductRepository.getByFundIdEqualsAndFundProIdEqualsAndEnableEquals(channelRouteSaveVo.getFundId(), channelRouteSaveVo.getFundProId(), Byte.valueOf("1"));
if (Objects.nonNull(fundProductEntity)){
channelRuleEntity.setFundProductId(fundProductEntity.getId());
channelRuleEntity.setPublishStatus(Byte.valueOf("0"));
if (0 == type){
channelRuleEntity.setEnable(Byte.valueOf("1"));
}else {
channelRuleEntity.setEnable(Byte.valueOf("0"));
}
channelRuleRepository.save(channelRuleEntity);
}
});
}
@Override
public void publishChannelConfig(List<Long> ids) {
List<ChannelRuleEntity> allByIdIn = channelRuleRepository.getAllByIdIn(ids);
allByIdIn.stream().forEach(channelRuleEntity -> {
channelRuleEntity.setPublishStatus(Byte.valueOf("1"));
channelRuleRepository.save(channelRuleEntity);
});
}
@Override
public void updateChannelConfig(Long channelId) {
Boolean aBoolean = channelRuleRepository.deleteAllByChannelIdEqualsAndEnableEquals(channelId, Byte.valueOf("1"));
if (aBoolean){
List<ChannelRuleEntity> allByChannelIdEqualsAndEnableEquals = channelRuleRepository.getAllByChannelIdEqualsAndEnableEquals(channelId, Byte.valueOf("0"));
allByChannelIdEqualsAndEnableEquals.stream().forEach(channelRuleEntity -> {
channelRuleEntity.setEnable(Byte.valueOf("1"));
channelRuleRepository.save(channelRuleEntity);
});
}
}
}
package com.quantgroup.asset.distribution.service.route.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quantgroup.asset.distribution.config.code.AreaCode;
import com.quantgroup.asset.distribution.config.code.InitAreaCode;
import com.quantgroup.asset.distribution.enums.route.SystemType;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.*;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import com.quantgroup.asset.distribution.service.jpa.entity.FundProductEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.ProductRuleEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.QFundProductEntity;
import com.quantgroup.asset.distribution.service.jpa.repository.IFundProductRepository;
import com.quantgroup.asset.distribution.service.jpa.repository.IProductRuleRepository;
import com.quantgroup.asset.distribution.service.newrule.pojo.funds.RuleParam;
import com.quantgroup.asset.distribution.service.route.IFundProductService;
import com.quantgroup.asset.distribution.util.AllRecords;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
@Slf4j
public class FundProductServiceImpl implements IFundProductService {
@Autowired
private IFundProductRepository fundProductRepository;
@Autowired
private IProductRuleRepository productRuleRepository;
@Autowired
private IHttpService httpService;
@Value("${mo-sidecar.http}")
private String modsidecarurl;
/**
* 数据来源为QG底层资金运营服务,载入页面后,资金路由优先查询底层资金运营服务产品信息,再查询本地存储产品信息,然后进行去重展示;
* @param fundProductQueryVo
* @return
*/
@Override
public AllRecords queryPage(FundProductQueryVo fundProductQueryVo) {
//1.资金路由优先查询底层资金运营服务产品信息
List<FundProductEntity> fundProductFromMoFund = getFundProductFromMoFund();
if (CollectionUtils.isEmpty(fundProductFromMoFund)){
log.error("queryPage | 资金底层服务没有查到资金产品信息");
return new AllRecords();
}
fundProductFromMoFund.stream().forEach(fundProductEntity -> {
FundProductEntity byFundIdEqualsAndFundProIdEquals = fundProductRepository.getByFundIdEqualsAndFundProIdEquals(fundProductEntity.getFundId(), fundProductEntity.getFundProId());
if (Objects.isNull(byFundIdEqualsAndFundProIdEquals)){
fundProductEntity.setEnable(Byte.valueOf("1"));
fundProductEntity.setFundType("");
fundProductEntity.setOrgType("");
fundProductEntity.setBusinessType("");
fundProductEntity.setBasicRule("");
fundProductEntity.setAreaTerm(0);
fundProductEntity.setCardLimit(0);
fundProductEntity.setTelRule("");
fundProductEntity.setAreaRule("");
fundProductEntity.setRuleList("");
fundProductEntity.setCreatedAt(Timestamp.valueOf(LocalDateTime.now()));
fundProductEntity.setUpdatedAt(Timestamp.valueOf(LocalDateTime.now()));
fundProductRepository.save(fundProductEntity);
}
});
//2.查询本地数据库
//索引 和 每页大小 排序 条件
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
if (Objects.nonNull(fundProductQueryVo.getFundId())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundId.like(String.valueOf(fundProductQueryVo.getFundId())));
}
if (Objects.nonNull(fundProductQueryVo.getFundProId())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundProId.like(String.valueOf(fundProductQueryVo.getFundProId())));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getFundName())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundName.like(fundProductQueryVo.getFundName()));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getFundType())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundType.eq(fundProductQueryVo.getFundType()));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getOrgType())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.orgType.eq(fundProductQueryVo.getOrgType()));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getBusinessType())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.businessType.eq(fundProductQueryVo.getBusinessType()));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getSystermType())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.systermType.eq(fundProductQueryVo.getSystermType()));
}
//只查有效数据
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.enable.eq(Byte.valueOf("1")));
//1.查询条件,2.索引和每页的大小,3.排序根据某个字段进行排序
//查询总条数
long count = fundProductRepository.count(booleanExpression);
//查询数据
Page<FundProductEntity> plantPage = fundProductRepository.findAll(booleanExpression, new PageRequest(fundProductQueryVo.getOffset(), fundProductQueryVo.getPageSize(), new Sort(Sort.Direction.DESC, "createdAt")));
List<FundProductEntity> fundProductEntities = new ArrayList<>();
fundProductEntities = plantPage.getContent();
List<FundProductQueryResultVo> fundProductResultVos = new ArrayList<>();
for (int i=0;i<fundProductEntities.size();i++){
FundProductQueryResultVo fundProductResultVo = new FundProductQueryResultVo();
BeanUtils.copyProperties(fundProductEntities.get(i), fundProductResultVo);
fundProductResultVo.setSeqNo(fundProductEntities.size()-i);
fundProductResultVos.add(fundProductResultVo);
}
AllRecords allRecords = new AllRecords();
allRecords.setPageIndex(fundProductQueryVo.getPageIndex());
allRecords.setPageSize(fundProductQueryVo.getPageSize());
allRecords.setDataList(fundProductResultVos);
allRecords.setTotalNumber(count);
allRecords.resetTotalNumber(count);
return allRecords;
}
private List<FundProductEntity> getFundProductFromMoFund(){
List<FundProductEntity> fundProductEntityList = new ArrayList<>();
String post = httpService.post(modsidecarurl + "/middle_office/financeProduct/infoList");
if (Objects.nonNull(post) && JSON.parseObject(post).getInteger("code") == 0){
JSONArray data = JSON.parseObject(post).getJSONArray("data");
if (Objects.nonNull(data) && !data.isEmpty()){
for (int i = 0 ; i< data.size() ;i++){
FundProductEntity fundProductEntity = new FundProductEntity();
fundProductEntity.setFundId(data.getJSONObject(i).getLong("fundCorpId"));
fundProductEntity.setFundProId(data.getJSONObject(i).getLong("financeProductId"));
fundProductEntity.setFundName(data.getJSONObject(i).getString("fundName"));
Integer systemNo = data.getJSONObject(i).getInteger("systemNo");
if (systemNo == 1){
fundProductEntity.setSystermType(SystemType.XYQB.getValue());
}else if (systemNo == 2){
fundProductEntity.setSystermType(SystemType.MO.getValue());
}
fundProductEntityList.add(fundProductEntity);
}
}
}
return fundProductEntityList;
}
@Override
public FundProductVo lookFundProduct(Long id) {
FundProductVo fundProductVo = new FundProductVo();
FundProductEntity one = fundProductRepository.findOne(id);
//1.资金信息-value
BeanUtils.copyProperties(one,fundProductVo);
//2.基本信息和其他信息字段
//所有的BASIC规则
List<ProductRuleEntity> basic = productRuleRepository.getAllByRuleTypeEqualsAndEnableEquals("BASIC", Byte.valueOf("1"));
//所有的其他规则
List<ProductRuleEntity> orther = productRuleRepository.getAllByRuleTypeEqualsAndEnableEquals("ORTHER", Byte.valueOf("1"));
basic.addAll(orther);
fundProductVo.setProductRuleEntityList(basic);
//3.基本信息和其他信息字段,对应的value
Map<Long,String> map = new HashMap<>();
//3.1解析基本规则10 <= age && age <= 50 && 10 <= amount && amount <= 20000 && term == 12 && ! include(not_permit_tels,tel)
//获取资金产品存的value
String basicRule = one.getBasicRule();
//解析value
String[] split = basicRule.split("&&");
for (int i = 0 ; i<split.length;i++){
for (ProductRuleEntity productRuleEntity:basic){
//在value中寻找对应的规则
if ("not_permit_tels".equals(productRuleEntity.getRuleVal())){
map.put(productRuleEntity.getId(),one.getTelRule());
break;
}
if (split[i].contains(productRuleEntity.getRuleVal())){
//取出value中的值
String numeric = getNumeric(split[i]);
String s = map.get(productRuleEntity.getId());
if (StringUtils.isEmpty(s)){
map.put(productRuleEntity.getId(),numeric);
}else {
map.put(productRuleEntity.getId(),s.concat(",").concat(numeric));
}
break;
}
}
}
//3.2基本规则剩下的字段
//区域类型的规则
String areaRule = one.getAreaRule();
RuleParam.AreaRuleConcrete areaRuleConcrete = JSONObject.parseObject(areaRule, RuleParam.AreaRuleConcrete.class);
//其它规则
String ruleList = one.getRuleList();
for (ProductRuleEntity productRuleEntity:basic){
switch (productRuleEntity.getRuleVal()){
case "area_term":
//地区要求
map.put(productRuleEntity.getId(),String.valueOf(one.getAreaTerm()));
break;
case "card_limit":
//身份证有效期
map.put(productRuleEntity.getId(),String.valueOf(one.getCardLimit()));
break;
case "tel_area_list":
//手机号区域限制
if (Objects.nonNull(areaRuleConcrete)){
map.put(productRuleEntity.getId(),areaRuleConcrete.getTelAreaNameList());
}
break;
case "residence_list":
//居住地区限制
if (Objects.nonNull(areaRuleConcrete)){
map.put(productRuleEntity.getId(),areaRuleConcrete.getResidenceList());
}
break;
case "native_list":
//户籍地区限制(身份证)
if (Objects.nonNull(areaRuleConcrete)){
map.put(productRuleEntity.getId(),areaRuleConcrete.getNativeList());
}
break;
case "name_same":
case "tel_same":
case "tel_no_same":
//联系人手机号不正确
//联系人手机号相同
//联系人姓名相同
map.put(productRuleEntity.getId(),ruleList.contains(String.valueOf(productRuleEntity.getId()))?"1":"0");
break;
}
}
fundProductVo.setRuleValueMap(map);
return fundProductVo;
}
@Override
public GlobalResponse save(FundProductSaveVo fundProductSaveVo) {
FundProductEntity one = fundProductRepository.findOne(fundProductSaveVo.getId());
if (Objects.isNull(one)){
return GlobalResponse.error("没有这个资金产品");
}
BeanUtils.copyProperties(fundProductSaveVo,one);
StringBuffer basicRule = new StringBuffer();
StringBuffer ruleList = new StringBuffer();
RuleParam.AreaRuleConcrete areaRuleConcrete = new RuleParam.AreaRuleConcrete();
Map<Long, String> ruleValueMap = fundProductSaveVo.getRuleValueMap();
List<ProductRuleEntity> allByEnableEquals = productRuleRepository.getAllByEnableEquals(Byte.valueOf("1"));
allByEnableEquals.stream().forEach(productRuleEntity -> {
String value = ruleValueMap.get(productRuleEntity.getId());
if (!StringUtils.isEmpty(value)){
//10 <= age && age <= 50 && 10 <= amount && amount <= 20000 && term == 12 && ! include(not_permit_tels,tel)
switch (productRuleEntity.getRuleVal()){
case "age":
basicRule.append(value.replace(",", " <= age && age <= ")).append(" && ");
break;
case "amount":
basicRule.append(value.replace(","," <= amount && amount <= ")).append(" && ");
break;
case "term":
basicRule.append("term == ").append(value).append(" && ");
break;
case "not_permit_tels":
basicRule.append("! include(not_permit_tels,tel)").append(" && ");
one.setTelRule(value);
break;
case "name_same":
case "tel_same":
case "tel_no_same":
ruleList.append(productRuleEntity.getId()).append(",");
break;
case "area_term":
one.setAreaTerm(Integer.getInteger(value));
break;
case "card_limit":
one.setCardLimit(Integer.getInteger(value));
break;
case "tel_area_list":
areaRuleConcrete.setTelAreaNameList(value);
break;
case "residence_list":
areaRuleConcrete.setResidenceList(value);
break;
case "native_list":
areaRuleConcrete.setNativeList(value);
break;
}
}
});
one.setBasicRule(basicRule.substring(0,basicRule.lastIndexOf(" && ")));
one.setRuleList(ruleList.substring(0,ruleList.lastIndexOf(",")));
one.setAreaRule(JSONObject.toJSONString(areaRuleConcrete));
fundProductRepository.save(one);
return GlobalResponse.success();
}
@Override
public GlobalResponse getArea() throws IOException {
AreaCodeVo areaCodeVo = new AreaCodeVo();
InputStream in = this.getClass().getResourceAsStream("/phone/gbt.txt");
String var4 = InitAreaCode.getString(in);
List<AreaCode> list = new ArrayList<AreaCode>();
list = JSONObject.parseArray(var4, AreaCode.class);
for (AreaCode country : list) {
if("100000".equals(country.getAdcode())){
BeanUtils.copyProperties(country,areaCodeVo);
//获取省
for(AreaCode province : list){
if (country.getAdcode().equals(province.getParent())){
AreaCodeVo provinceVo = new AreaCodeVo();
BeanUtils.copyProperties(province,provinceVo);
//获取市
for (AreaCode city : list) {
if (province.getAdcode().equals(city.getParent())){
AreaCodeVo cityVo = new AreaCodeVo();
BeanUtils.copyProperties(city,cityVo);
//获取区
for (AreaCode district : list) {
if (city.getAdcode().equals(district.getParent())){
AreaCodeVo districtVo = new AreaCodeVo();
BeanUtils.copyProperties(district,districtVo);
cityVo.getNodes().add(districtVo);
}
}
provinceVo.getNodes().add(cityVo);
}
}
areaCodeVo.getNodes().add(provinceVo);
}
}
}
}
return GlobalResponse.success(areaCodeVo);
}
/**
* 过滤非数字
* @param str
* @return
*/
public static String getNumeric(String str) {
String regEx="[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
return m.replaceAll("").trim();
}
}
package com.quantgroup.asset.distribution.service.route.impl;
import com.quantgroup.asset.distribution.model.entity.route.routerecord.RouteRecordQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.routerecord.RouteRecordResultVo;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListResultVo;
import com.quantgroup.asset.distribution.service.jpa.entity.QRoutingRecordEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.QWhiteListEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.RoutingRecordEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.WhiteListEntity;
import com.quantgroup.asset.distribution.service.jpa.repository.IRoutingRecordRepository;
import com.quantgroup.asset.distribution.service.route.IRouteRecordService;
import com.quantgroup.asset.distribution.util.AllRecords;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
public class RouteRecordServiceImpl implements IRouteRecordService {
@Autowired
private IRoutingRecordRepository routingRecordRepository;
@Override
public AllRecords queryPage(RouteRecordQueryVo routeRecordQueryVo) {
//索引 和 每页大小 排序 条件
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
if (!StringUtils.isEmpty(routeRecordQueryVo.getCreditNo())){
booleanExpression = booleanExpression.and(QRoutingRecordEntity.routingRecordEntity.creditNo.eq(routeRecordQueryVo.getCreditNo()));
}
if (!StringUtils.isEmpty(routeRecordQueryVo.getUuid())){
booleanExpression = booleanExpression.and(QRoutingRecordEntity.routingRecordEntity.uuid.eq(routeRecordQueryVo.getUuid()));
}
if (Objects.nonNull(routeRecordQueryVo.getStatus())){
booleanExpression = booleanExpression.and(QRoutingRecordEntity.routingRecordEntity.status.eq(routeRecordQueryVo.getStatus()));
}
if (Objects.nonNull(routeRecordQueryVo.getRoutedAtMin()) && Objects.nonNull(routeRecordQueryVo.getRoutedAtMax())){
booleanExpression = booleanExpression.and(QRoutingRecordEntity.routingRecordEntity.routedAt.between(routeRecordQueryVo.getRoutedAtMin(),routeRecordQueryVo.getRoutedAtMax()));
}else if (Objects.nonNull(routeRecordQueryVo.getRoutedAtMin())){
booleanExpression = booleanExpression.and(QRoutingRecordEntity.routingRecordEntity.routedAt.after(routeRecordQueryVo.getRoutedAtMin()));
}else if (Objects.nonNull(routeRecordQueryVo.getRoutedAtMax())){
booleanExpression = booleanExpression.and(QRoutingRecordEntity.routingRecordEntity.routedAt.before(routeRecordQueryVo.getRoutedAtMax()));
}
//1.查询条件,2.索引和每页的大小,3.排序根据某个字段进行排序
//查询总条数
long count = routingRecordRepository.count(booleanExpression);
//查询数据
Page<RoutingRecordEntity> plantPage = routingRecordRepository.findAll(booleanExpression, new PageRequest(routeRecordQueryVo.getOffset(), routeRecordQueryVo.getPageSize(), new Sort(Sort.Direction.DESC, "createdAt")));
List<RoutingRecordEntity> routingRecordEntityList = new ArrayList<>();
routingRecordEntityList = plantPage.getContent();
List<RouteRecordResultVo> routeRecordResultVoList = new ArrayList<>();
routingRecordEntityList.stream().forEach(routingRecordEntity -> {
RouteRecordResultVo routeRecordResultVo = new RouteRecordResultVo();
BeanUtils.copyProperties(routingRecordEntity, routeRecordResultVo);
if (StringUtils.isEmpty(routeRecordResultVo.getRoutedResult())){
routeRecordResultVo.setRoutedResult("无");
}
routeRecordResultVoList.add(routeRecordResultVo);
});
AllRecords allRecords = new AllRecords();
allRecords.setPageIndex(routeRecordQueryVo.getPageIndex());
allRecords.setPageSize(routeRecordQueryVo.getPageSize());
allRecords.setDataList(routeRecordResultVoList);
allRecords.setTotalNumber(count);
allRecords.resetTotalNumber(count);
return allRecords;
}
}
package com.quantgroup.asset.distribution.service.route.impl;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListQueryVo;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListResultVo;
import com.quantgroup.asset.distribution.model.entity.route.whitelist.WhiteListSaveVo;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.jpa.entity.FundProductEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.QWhiteListEntity;
import com.quantgroup.asset.distribution.service.jpa.entity.WhiteListEntity;
import com.quantgroup.asset.distribution.service.jpa.repository.IFundProductRepository;
import com.quantgroup.asset.distribution.service.jpa.repository.IWhiteListRepository;
import com.quantgroup.asset.distribution.service.route.IWhiteListService;
import com.quantgroup.asset.distribution.util.AllRecords;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
public class WhiteListServiceImpl implements IWhiteListService {
@Autowired
private IWhiteListRepository whiteListRepository;
@Autowired
IFundProductRepository fundProductRepository;
@Override
public AllRecords queryPage(WhiteListQueryVo whiteListQueryVo) {
//索引 和 每页大小 排序 条件
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
if (!StringUtils.isEmpty(whiteListQueryVo.getPhone())){
booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.phone.eq(String.valueOf(whiteListQueryVo.getPhone())));
}
if (!StringUtils.isEmpty(whiteListQueryVo.getFundName())){
booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.fundName.like(String.valueOf(whiteListQueryVo.getFundName())));
}
//1.查询条件,2.索引和每页的大小,3.排序根据某个字段进行排序
//查询总条数
long count = whiteListRepository.count(booleanExpression);
//查询数据
Page<WhiteListEntity> plantPage = whiteListRepository.findAll(booleanExpression, new PageRequest(whiteListQueryVo.getOffset(), whiteListQueryVo.getPageSize(), new Sort(Sort.Direction.DESC, "createdAt")));
List<WhiteListEntity> whiteListEntityList = new ArrayList<>();
whiteListEntityList = plantPage.getContent();
List<WhiteListResultVo> whiteListResultVoArrayList = new ArrayList<>();
whiteListEntityList.stream().forEach(whiteListEntity -> {
WhiteListResultVo whiteListResultVo = new WhiteListResultVo();
BeanUtils.copyProperties(whiteListEntity, whiteListResultVo);
whiteListResultVoArrayList.add(whiteListResultVo);
});
AllRecords allRecords = new AllRecords();
allRecords.setPageIndex(whiteListQueryVo.getPageIndex());
allRecords.setPageSize(whiteListQueryVo.getPageSize());
allRecords.setDataList(whiteListResultVoArrayList);
allRecords.setTotalNumber(count);
allRecords.resetTotalNumber(count);
return allRecords;
}
@Override
public GlobalResponse updateStatus(Long id, Byte status) {
WhiteListEntity one = whiteListRepository.findOne(id);
if (Objects.nonNull(one)){
one.setStatus(status);
whiteListRepository.save(one);
return GlobalResponse.success();
}else {
return GlobalResponse.error("该条记录不存在");
}
}
@Override
public GlobalResponse save(WhiteListSaveVo whiteListSaveVo) {
WhiteListEntity whiteListEntity = new WhiteListEntity();
BeanUtils.copyProperties(whiteListSaveVo,whiteListEntity);
FundProductEntity fundProductEntity = fundProductRepository.getByFundIdEqualsAndFundProIdEqualsAndEnableEquals(whiteListSaveVo.getFundId(), whiteListSaveVo.getFundProId(), Byte.valueOf("1"));
if (Objects.nonNull(fundProductEntity)){
whiteListEntity.setFundProductId(fundProductEntity.getId());
whiteListEntity.setFundName(fundProductEntity.getFundName());
whiteListEntity.setStatus(Byte.valueOf("0"));
whiteListRepository.save(whiteListEntity);
return GlobalResponse.success();
}else {
return GlobalResponse.error("要保存的白名单对应的资金产品不存在");
}
}
}
package com.quantgroup.asset.distribution.util;
import lombok.Data;
import java.util.List;
/**
*
*/
@Data
public class AllRecords<T> {
//总页数
private long totalPage;
//总数量
private long totalNumber;
//索引
private int pageIndex;
//每页条数
private long pageSize;
//分页的列表数据
private List<T> dataList;
//计算总页数
public void resetTotalNumber(long totalNumber) {
if (totalNumber!=0){
this.totalNumber = totalNumber;
this.totalPage = totalNumber / this.pageSize;
if(totalNumber % this.pageSize != 0L) {
++this.totalPage;
}
}
}
}
package com.quantgroup.asset.distribution.util;
import lombok.Data;
/**
*
* 分页参数VO,所有用到分页的实体继承此类,接受分页参数
* Created by wyx
*/
@Data
public class PageVo {
//当前页数
private int pageIndex;
//索引
private int offset;
//默认每页条数
private int pageSize;
public void setPageIndex(int pageIndex){
this.pageIndex = pageIndex;
initParamter();
}
public void setPageSize (int pageSize){
this.pageSize = pageSize;
initParamter();
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public int getPageIndex() {
return pageIndex;
}
public int getPageSize() {
return pageSize;
}
/**
* 根据前端传值,计算分页参数
*/
private void initParamter(){
if(pageIndex<1){
pageIndex = 1;//默认第一页
}
if (this.pageSize == 0) {
this.pageSize = 10;//默认每页显示10条
}
final int offset = (this.pageIndex - 1) * this.pageSize;
setOffset(offset);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment