Commit 983c38c2 authored by suntao's avatar suntao

JolyneService 重写

parent a3c8849a
......@@ -25,13 +25,13 @@ import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterService;
import cn.quantgroup.cashloanflowboss.spi.clotho.service.ClothoCenterService;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneService;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneUtil;
import cn.quantgroup.cashloanflowboss.spi.jolyne.model.JolyneDB;
import cn.quantgroup.cashloanflowboss.spi.opapi.OPCenter;
import cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.Contract;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.LoanApplicationHistory;
import cn.quantgroup.cashloanflowboss.spi.xyqb.repository.CancelPreLoanRepository;
import cn.quantgroup.cashloanflowboss.spi.xyqb.service.XYQBCenterService;
import cn.quantgroup.cashloanflowboss.spi.xyqb.service.XYQBCenterServiceImpl;
import cn.quantgroup.cashloanflowboss.utils.JSONTools;
import cn.quantgroup.user.retbean.XUser;
import com.alibaba.fastjson.JSONObject;
......@@ -316,7 +316,7 @@ public class OrderServiceImpl implements OrderService{
// 修改合同状态
ArrayList<String> updateContract = Lists.newArrayList();
updateContract.add("update contract set generate_status = 2 where user_id = " + orderMapping.getQgUserId() + ";");
jolyneService.executeXYQBSQL(JolyneUtil.getJolneSql(updateContract));
jolyneService.executeSQL(JolyneDB.XYQB, JolyneUtil.getJolneSql(updateContract));
}
} else {
// 合同为空 log表记录问题,UI用户查询
......@@ -625,8 +625,8 @@ public class OrderServiceImpl implements OrderService{
@Override
public void loadSecondAuditJob() {
jolyneService.fetchDataLoanJob();
jolyneService.loanDataJob();
jolyneService.reloadJob("cn.qg.clotho.job.FetchDataLoanJob");
jolyneService.reloadJob("cn.qg.clotho.job.LoanDataJob");
}
@OperationAnno(channelNo = "#this[0]", opt = OptEnumName.ALL_REPAID, succSPEL = "#this.key", optDetailSPEL = "#this.value")
......
package cn.quantgroup.cashloanflowboss.api.test.controller;
import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneCenter;
import cn.quantgroup.cashloanflowboss.spi.xyqb.service.XYQBCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -13,10 +15,25 @@ public class TestController {
@Autowired
private JolyneCenter jolyneCenter;
@Autowired
private XYQBCenterService xyqbCenterService;
@Security(authorityId = "User.Order.cleanUserOrder")
@RequestMapping("sql_test")
public String sqlTest(@RequestBody String sqlData, @RequestParam("dbName") String dbName) {
return "1";
//return jolyneCenter.querySQL(dbName, sqlData);
}
@Security(authorityId = "User.Order.cleanUserOrder")
@RequestMapping("cleanUserOrder")
public String cleanUserOrder(Long userId) {
xyqbCenterService.cleanUserActiveOrder(userId);
return "1";
}
}
......@@ -127,7 +127,7 @@ public class UserController {
* @return
*/
@PutMapping("/order/clean")
@Security(authorityId = "User.cleanUserOrder")
@Security(authorityId = "User.Order.cleanUserOrder")
public Result<Boolean> cleanUserOrder(@RequestParam @Valid @NotEmpty(message = "无效的用户手机号") String mobile) {
Tuple<Boolean, String> result = userService.cleanUserActiveOrder(mobile);
return Result.buildSuccess(result.getKey(), result.getValue());
......@@ -140,7 +140,7 @@ public class UserController {
* @return
*/
@PutMapping("/info/clean")
@Security(authorityId = "User.cleanUserInfo")
@Security(authorityId = "User.Order.cleanUserInfo")
public Boolean deleteByUserId(@RequestParam @Valid @NotEmpty(message = "无效的用户手机号") String mobile) {
Tuple<Boolean, String> result = this.xyqbUserService.deleteByUserId(mobile);
return result.getKey();
......
......@@ -10,14 +10,16 @@ public interface JolyneCenter {
/**
* 执行xyqb sql
* 由 JolyneService 请求
* 执行sql
* @param jsonData
* @return
*/
@PostMapping(value = "/executeSQL/"+"${NAMESPACE}" + "/xyqb", consumes = "application/json")
String executeXYQBSQL(String jsonData);
@PostMapping(value = "/executeSQL/"+"${NAMESPACE}" + "/{bdName}", consumes = "application/json")
String executeSQL(@PathVariable(value = "bdName") String bdName , @RequestBody String jsonData);
/**
* 由 JolyneService 请求
* 查询xyqb sql
* @param jsonData
* @return
......@@ -27,24 +29,17 @@ public interface JolyneCenter {
/**
* 执行 [xyqb_user] sql
* @param jsonData
* @return
* 刷新clotho定时任务
* @param jobName
*/
@PostMapping(value = "/executeSQL/"+"${NAMESPACE}" + "/xyqb_user", consumes = "application/json")
String executeXYQBUserSQL(String jsonData);
@GetMapping(value = "/job/clotho-elastic-job/cn.qg.clotho.job.FetchDataLoanJob")
void fetchDataLoanJob(@RequestParam("namespace") String namespace);
@GetMapping(value = "/job/clotho-elastic-job/cn.qg.clotho.job.LoanDataJob")
void loanDataJob(@RequestParam("namespace") String namespace);
@GetMapping(value = "/job/clotho-elastic-job/{jobName}?namespace=${NAMESPACE}")
void reloadJob(@PathVariable(value = "jobName")String jobName);
@Component
class Fallback implements JolyneCenter {
@Override
public String executeXYQBSQL(String jsonData) {
public String executeSQL(String bdName, String jsonData) {
return null;
}
......@@ -53,19 +48,8 @@ public interface JolyneCenter {
return null;
}
@Override
public String executeXYQBUserSQL(String jsonData) {
return null;
}
@Override
public void fetchDataLoanJob(String namespace) {
}
@Override
public void loanDataJob(String namespace) {
public void reloadJob(String jobName) {
}
}
......
package cn.quantgroup.cashloanflowboss.spi.jolyne;
import cn.quantgroup.cashloanflowboss.spi.jolyne.model.JolyneDB;
/**
* function:
* date: 2019/9/20
......@@ -9,14 +11,10 @@ package cn.quantgroup.cashloanflowboss.spi.jolyne;
*/
public interface JolyneService {
String executeSQL(JolyneDB jolyneDB, String jsonData);
String executeXYQBSQL(String jsonData);
void fetchDataLoanJob();
void loanDataJob();
void reloadJob(String jobName);
String delayUpdateWaitingXyqbSql(Long sqlContent, Long delayTime);
String delayExecuteSql(JolyneDB jolyneDB, String jsonData, Long delayTime);
}
package cn.quantgroup.cashloanflowboss.spi.jolyne;
import cn.quantgroup.cashloanflowboss.spi.jolyne.model.JolyneDB;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.WaitingFundingCorpOperatePeople;
import cn.quantgroup.cashloanflowboss.spi.xyqb.service.XYQBCenterService;
import cn.quantgroup.cashloanflowboss.spi.xyqb.service.XYQBCenterServiceImpl;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,23 +27,17 @@ public class JolyneServiceImpl implements JolyneService {
@Autowired
private JolyneCenter jolyneCenter;
@Value("${NAMESPACE}")
private String namespace;
@Override
public String executeXYQBSQL(String jsonData) {
return jolyneCenter.executeXYQBSQL(jsonData);
public String executeSQL(JolyneDB jolyneDB, String jsonData) {
return jolyneCenter.executeSQL(jolyneDB.getDbName(), jsonData);
}
@Override
public void fetchDataLoanJob() {
jolyneCenter.fetchDataLoanJob(namespace);
}
@Override
public void loanDataJob() {
jolyneCenter.loanDataJob(namespace);
public void reloadJob(String jobName) {
jolyneCenter.reloadJob(jobName);
}
@Async
......@@ -72,12 +66,29 @@ public class JolyneServiceImpl implements JolyneService {
// 更新待放款时间(5分钟之前)
ArrayList<String> updateWaitingFundingCorpOperatePeople = Lists.newArrayList();
updateWaitingFundingCorpOperatePeople.add("update waiting_funding_corp_operate_people set created_at = DATE_SUB(created_at, interval 5 minute) where loan_application_history_id = " + loanId + ";");
return jolyneCenter.executeXYQBSQL(JolyneUtil.getJolneSql(updateWaitingFundingCorpOperatePeople));
return this.executeSQL(JolyneDB.XYQB, JolyneUtil.getJolneSql(updateWaitingFundingCorpOperatePeople));
}
fetchDataLoanJob();
loanDataJob();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
reloadJob("cn.qg.clotho.job.FetchDataLoanJob");
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
reloadJob("cn.qg.clotho.job.LoanDataJob");
return "success";
}
@Override
public String delayExecuteSql(JolyneDB jolyneDB, String jsonData, Long delayTime) {
return null;
}
}
package cn.quantgroup.cashloanflowboss.spi.jolyne.model;
/**
* function:
* date: 2019/9/27
*
* @author: suntao
*/
public enum JolyneDB {
XYQB("xyqb", "xyqb数据库"),
XYQB_USER("xyqb_user", "xyqb_ser数据库");
private JolyneDB(String dbName, String desc) {
this.dbName = dbName;
this.desc = desc;
}
private String dbName;
private String desc;
public String getDbName() {
return this.dbName;
}
}
......@@ -3,25 +3,19 @@ package cn.quantgroup.cashloanflowboss.spi.user.service;
import cn.quantgroup.cashloanflowboss.api.optlog.model.OptEnumName;
import cn.quantgroup.cashloanflowboss.core.annotation.opt.OperationAnno;
import cn.quantgroup.cashloanflowboss.core.base.Tuple;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneCenter;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneService;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneUtil;
import cn.quantgroup.cashloanflowboss.spi.jolyne.model.JolyneDB;
import cn.quantgroup.cashloanflowboss.spi.user.repository.UserDetailRepository;
import cn.quantgroup.cashloanflowboss.spi.user.repository.UserExtInfoRepository;
import cn.quantgroup.cashloanflowboss.spi.util.HttpService;
import cn.quantgroup.cashloanflowboss.utils.JSONTools;
import cn.quantgroup.cashloanflowboss.utils.MD5Tools;
import cn.quantgroup.user.bean.UserInfo;
import cn.quantgroup.user.enums.IncomeEnum;
import cn.quantgroup.user.enums.IncomeRangeEnum;
import cn.quantgroup.user.retbean.XUser;
import cn.quantgroup.user.retbean.XUserDetail;
import cn.quantgroup.user.retbean.XUserExtInfo;
import cn.quantgroup.user.vo.UserSysResult;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
......@@ -51,7 +45,7 @@ public class XyqbUserServiceImpl implements XyqbUserService {
@Value("${passportapi.http}")
private String passportapiHttp;
@Autowired
private JolyneCenter jolyneCenter;
private JolyneService jolyneService;
......@@ -151,7 +145,7 @@ public class XyqbUserServiceImpl implements XyqbUserService {
cancelList.add("delete from contact where user_id=" + userId);
cancelList.add("delete from address where user_id=" + userId);
String cancelResult = jolyneCenter.executeXYQBSQL(JolyneUtil.getJolneSql(cancelList));
String cancelResult = jolyneService.executeSQL(JolyneDB.XYQB_USER, JolyneUtil.getJolneSql(cancelList));
JSONObject resp = JSONObject.parseObject(cancelResult);
Set<String> phoneNoKeys = redisTemplate.keys(phoneNo);
......
......@@ -5,8 +5,9 @@ import cn.quantgroup.cashloanflowboss.api.order.model.XyqbHistoryOrderStatusServ
import cn.quantgroup.cashloanflowboss.core.Application;
import cn.quantgroup.cashloanflowboss.core.base.ServiceResult;
import cn.quantgroup.cashloanflowboss.core.base.Tuple;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneCenter;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneService;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneUtil;
import cn.quantgroup.cashloanflowboss.spi.jolyne.model.JolyneDB;
import cn.quantgroup.cashloanflowboss.spi.xyqb.client.XYQBCenter;
import cn.quantgroup.cashloanflowboss.spi.xyqb.entity.*;
import cn.quantgroup.cashloanflowboss.spi.xyqb.repository.*;
......@@ -25,7 +26,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentMap;
/**
* Created by WeiWei on 2019/8/12.
......@@ -49,7 +49,7 @@ public class XYQBCenterServiceImpl implements XYQBCenterService {
@Autowired
private JolyneCenter jolyneCenter;
private JolyneService jolyneService;
@Autowired
private XYQBCenter xyqbCenter;
......@@ -243,7 +243,7 @@ public class XYQBCenterServiceImpl implements XYQBCenterService {
cancelList.add("delete from apply_quota_record where user_id=" + userId);
cancelList.add("delete from user_operation_history where user_id=" + userId);
String cancelResult = jolyneCenter.executeXYQBSQL(JolyneUtil.getJolneSql(cancelList));
String cancelResult = jolyneService.executeSQL(JolyneDB.XYQB, JolyneUtil.getJolneSql(cancelList));
JSONObject resp = JSONObject.parseObject(cancelResult);
boolean result = (Objects.nonNull(resp) && resp.containsKey("code")) ? "0000".equals(resp.get("code")) : false;
return new Tuple<>(result,result?"清除用户活跃订单成功":"清除用户活跃订单失败");
......
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