Commit 983c38c2 authored by suntao's avatar suntao

JolyneService 重写

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