增加配置区分不同环境

飞书小程序
YXY 1 year ago
parent 2c27199744
commit 4e2174176f

@ -111,3 +111,9 @@ attachment:
lark: lark:
robot: robot:
group: https://open.feishu.cn/open-apis/bot/v2/hook/cf432ef4-e526-4595-8330-2d2a361f7a29 group: https://open.feishu.cn/open-apis/bot/v2/hook/cf432ef4-e526-4595-8330-2d2a361f7a29
pdf:
generate:
path: /data/biz_file/
# path: D:\test\
sync:
flag: true

@ -126,4 +126,5 @@ public class Constants
* *
*/ */
public static final String RESOURCE_PREFIX = "/profile"; public static final String RESOURCE_PREFIX = "/profile";
public static final String FOLDER_SPLIT = "/";
} }

@ -37,6 +37,9 @@ public class ErrorLogAop {
@Value("${lark.robot.group}") @Value("${lark.robot.group}")
private String ROBOT_GROUP; private String ROBOT_GROUP;
@Value("${sync.flag}")
private Boolean syncFlag;
/** /**
* *
*/ */
@ -49,10 +52,12 @@ public class ErrorLogAop {
LarkRequest larkRequest = new LarkRequest("a", "b"); LarkRequest larkRequest = new LarkRequest("a", "b");
LarkException larkException = new LarkException("", errorMessage, larkRequest); LarkException larkException = new LarkException("", errorMessage, larkRequest);
String errorMessageBody = larkException.getErrorMessageBody(); String errorMessageBody = larkException.getErrorMessageBody();
if (Boolean.TRUE.equals(syncFlag)) {
larkRobotHelper.sendMessageByBot(ROBOT_GROUP, errorMessageBody); larkRobotHelper.sendMessageByBot(ROBOT_GROUP, errorMessageBody);
} }
} }
} }
}
/** /**
* *
@ -84,7 +89,9 @@ public class ErrorLogAop {
.map(EventLog::getErrorMessage) .map(EventLog::getErrorMessage)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(errorList)) { if (CollectionUtils.isNotEmpty(errorList)) {
larkRobotHelper.sendMessageByBot(ROBOT_GROUP,String.join(",",errorList)); if (Boolean.TRUE.equals(syncFlag)) {
larkRobotHelper.sendMessageByBot(ROBOT_GROUP, String.join(",", errorList));
}
} }
} }

@ -8,6 +8,7 @@ import com.ruoyi.flyingbook.mapper.EventMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -50,6 +51,8 @@ public class LarkApplicationRunner implements ApplicationRunner {
@Autowired @Autowired
private EventMapper eventMapper; private EventMapper eventMapper;
@Value("${sync.flag}")
private Boolean syncFlag;
@Autowired @Autowired
private LarkOperateFactory larkOperateFactory; private LarkOperateFactory larkOperateFactory;
@ -59,6 +62,7 @@ public class LarkApplicationRunner implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
if (Boolean.TRUE.equals(syncFlag)) {
//这里用线程池,后续如果出现量大的情况下可以调整 //这里用线程池,后续如果出现量大的情况下可以调整
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
@ -84,10 +88,6 @@ public class LarkApplicationRunner implements ApplicationRunner {
} }
} }
}).start(); }).start();
// threadPool.execute(() -> {
//
//
// });
} }
}
} }

@ -5,6 +5,9 @@ import com.ruoyi.quartz.task.CJT.*;
import com.ruoyi.quartz.task.MailSyncTask; import com.ruoyi.quartz.task.MailSyncTask;
import com.ruoyi.quartz.task.MonitorJobTask; import com.ruoyi.quartz.task.MonitorJobTask;
import com.ruoyi.quartz.task.ScheduledRemindersTask; import com.ruoyi.quartz.task.ScheduledRemindersTask;
import com.ruoyi.quartz.task.odoo.AccountMoveLineJob;
import com.ruoyi.quartz.task.odoo.ProductProductJob;
import com.ruoyi.quartz.task.odoo.StockQuantJob;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -36,8 +39,14 @@ public class MailInfoController extends BaseController {
private SaleDispatchSyncJob saleDispatchSyncJob; private SaleDispatchSyncJob saleDispatchSyncJob;
@Autowired @Autowired
private SaleOrderSyncJob saleOrderSyncJob; private SaleOrderSyncJob saleOrderSyncJob;
// @Autowired @Autowired
// private ProductJob productJob; private CJTCreateLarkTableJob cjtCreateLarkTableJob;
@Autowired
private ProductProductJob productProductJob;
@Autowired
private AccountMoveLineJob accountMoveLineJob;
@Autowired
private StockQuantJob stockQuantJob;
// @PostMapping("/syncEmail") // @PostMapping("/syncEmail")
// public void syncEmail(Boolean readFlag) { // public void syncEmail(Boolean readFlag) {
@ -46,33 +55,54 @@ public class MailInfoController extends BaseController {
@SneakyThrows @SneakyThrows
@PostMapping("/scheduledReminders") @PostMapping("/scheduledReminders")
public void scheduledReminders(Integer number) { public void scheduledReminders(Integer number,String cjt) {
// System.out.println(number); // odoo(number);
// Integer userId = productJob.getUserId(); // if (number > 10){
// System.out.println(userId); // cjtCreateLarkTableJob.execute();
// productJob.testProduct(); // }else {
// switch (number){ cjt(number,cjt);
// case 1:
// manufactureOrderSyncJob.executeSync(null);
// break;
// case 2:
// purchaseArrivalOpenSyncJob.executeSync(null);
// break;
// case 3:
// purchaseOrderSyncJob.executeSync(null);
// break;
// case 4:
// saleDeliverySyncJob.executeSync(null);
// break;
// case 5:
// saleDispatchSyncJob.executeSync(null);
// break;
// case 6:
// saleOrderSyncJob.executeSync(null);
// break;
// } // }
// monitorJobTask.monitor(); }
// scheduledRemindersTask.scheduledReminders();
private void odoo(Integer number){
switch (number){
case 0:
accountMoveLineJob.execute(number);
break;
case 1:
case 6:
case 8:
productProductJob.execute(number);
break;
default:
break;
}
}
private void cjt(Integer number,String cjt){
switch (number){
case 1:
manufactureOrderSyncJob.executeSync(cjt,"2023-08-01 00:00:00","2023-08-08 23:00:00");
break;
case 2:
purchaseArrivalOpenSyncJob.executeSync(cjt,"2023-08-01 00:00:00","2023-08-08 23:00:00");
break;
case 3:
purchaseOrderSyncJob.executeSync(cjt,"2023-06-07 00:00:00","2023-06-07 23:00:00");
break;
case 4:
saleDeliverySyncJob.executeSync(cjt,"2023-08-01 00:00:00","2023-08-08 23:00:00");
break;
case 5:
saleDispatchSyncJob.executeSync(cjt,"2023-08-02 16:46:00","2023-08-02 16:47:00");
break;
case 6:
saleOrderSyncJob.executeSync(cjt,"2023-08-01 00:00:00","2023-08-08 23:00:00");
break;
case 7:
retryErrorSyncJob.execute();
break;
}
} }
} }

@ -48,9 +48,14 @@ public class CJTCreateLarkTableJob{
private LarkRobotHelper larkRobotHelper; private LarkRobotHelper larkRobotHelper;
@Value("${lark.robot.group}") @Value("${lark.robot.group}")
private String ROBOT_GROUP; private String ROBOT_GROUP;
@Value("${sync.flag}")
private Boolean syncFlag;
public void execute(){ public void execute(){
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
Map<AppType, TableRelationTypeEnum> waitCreatMap = getWaitCreateMap(); Map<AppType, TableRelationTypeEnum> waitCreatMap = getWaitCreateMap();
Map<AppType, String> tableNameMap = getTableNameMap(); Map<AppType, String> tableNameMap = getTableNameMap();
String currentDate = DateUtils.ldt2str(LocalDateTime.now(), DateUtils.YYYYMM); String currentDate = DateUtils.ldt2str(LocalDateTime.now(), DateUtils.YYYYMM);

@ -6,6 +6,7 @@ import com.ruoyi.common.enums.CjtAccountEnum;
import com.ruoyi.quartz.domain.CJTRetryRequest; import com.ruoyi.quartz.domain.CJTRetryRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
@ -32,8 +33,13 @@ public class RetryErrorSyncJob {
private SaleDispatchSyncJob saleDispatchSyncJob; private SaleDispatchSyncJob saleDispatchSyncJob;
@Autowired @Autowired
private SaleOrderSyncJob saleOrderSyncJob; private SaleOrderSyncJob saleOrderSyncJob;
@Value("${sync.flag}")
private Boolean syncFlag;
public void execute(String appTypeCode,String cjt) { public void execute(String appTypeCode,String cjt) {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
AppType appType = AppType.getByCode(appTypeCode); AppType appType = AppType.getByCode(appTypeCode);
if (appType != null) { if (appType != null) {
executeDetail(appType,cjt); executeDetail(appType,cjt);
@ -41,6 +47,9 @@ public class RetryErrorSyncJob {
} }
public void execute() { public void execute() {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
for (CjtAccountEnum value : CjtAccountEnum.values()) { for (CjtAccountEnum value : CjtAccountEnum.values()) {
try { try {
List<AppType> retryJobList = retryJobList(); List<AppType> retryJobList = retryJobList();

@ -52,6 +52,8 @@ public abstract class SyncAccountsJobAbstract {
private LarkRobotHelper larkRobotHelper; private LarkRobotHelper larkRobotHelper;
@Value("${lark.robot.group}") @Value("${lark.robot.group}")
private String ROBOT_GROUP; private String ROBOT_GROUP;
@Value("${sync.flag}")
private Boolean syncFlag;
/** /**
* *
*/ */
@ -88,6 +90,9 @@ public abstract class SyncAccountsJobAbstract {
} }
public void execute(CJTRetryRequest request) { public void execute(CJTRetryRequest request) {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
if (request == null){ if (request == null){
return; return;
} }
@ -117,6 +122,9 @@ public abstract class SyncAccountsJobAbstract {
} }
public void executeSync(String cjt,String queryFromTime,String queryToTime) { public void executeSync(String cjt,String queryFromTime,String queryToTime) {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
CJTJobContext context = initContext(queryFromTime,queryToTime,now,cjt); CJTJobContext context = initContext(queryFromTime,queryToTime,now,cjt);
try { try {

@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
@ -37,8 +38,13 @@ public class MailSyncTask {
private IMailInfoService iMailInfoService; private IMailInfoService iMailInfoService;
@Autowired @Autowired
private LarkTableRelationMapper larkTableRelationMapper; private LarkTableRelationMapper larkTableRelationMapper;
@Value("${sync.flag}")
private Boolean syncFlag;
public void syncMail(Boolean readFlag) { public void syncMail(Boolean readFlag) {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
log.info("MailSyncTask start readFlag:{}",readFlag); log.info("MailSyncTask start readFlag:{}",readFlag);
MailInfo mailInfo = new MailInfo(); MailInfo mailInfo = new MailInfo();
mailInfo.setFlag(FlagStatus.OK.getCode()); mailInfo.setFlag(FlagStatus.OK.getCode());

@ -4,13 +4,9 @@ import com.ruoyi.common.enums.EventOperateType;
import com.ruoyi.flyingbook.LarkHelper.LarkRobotHelper; import com.ruoyi.flyingbook.LarkHelper.LarkRobotHelper;
import com.ruoyi.flyingbook.domain.LogCount; import com.ruoyi.flyingbook.domain.LogCount;
import com.ruoyi.flyingbook.mapper.EventLogMapper; import com.ruoyi.flyingbook.mapper.EventLogMapper;
import com.ruoyi.flyingbook.mapper.EventMapper;
import com.ruoyi.flyingbook.service.IEventLogService;
import com.ruoyi.flyingbook.service.IEventService;
import com.ruoyi.quartz.domain.JobLogCount; import com.ruoyi.quartz.domain.JobLogCount;
import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.domain.SysJobLog;
import com.ruoyi.quartz.mapper.SysJobLogMapper; import com.ruoyi.quartz.mapper.SysJobLogMapper;
import com.ruoyi.quartz.service.ISysJobService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -37,8 +33,13 @@ public class MonitorJobTask {
@Value("${lark.robot.group}") @Value("${lark.robot.group}")
private String robotGroup; private String robotGroup;
@Value("${sync.flag}")
private Boolean syncFlag;
public void monitor() { public void monitor() {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
log.info("scheduledRemindersTask start"); log.info("scheduledRemindersTask start");
Date todayStartTime = this.getTodayStartTime(); Date todayStartTime = this.getTodayStartTime();
Date endTime = new Date(); Date endTime = new Date();

@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -60,7 +61,8 @@ public class ScheduledRemindersTask {
private EventLogMapper eventLogMapper; private EventLogMapper eventLogMapper;
@Autowired @Autowired
private LarkRobotHelper larkRobotHelper; private LarkRobotHelper larkRobotHelper;
@Value("${sync.flag}")
private Boolean syncFlag;
/** /**
* *
*/ */
@ -72,6 +74,9 @@ public class ScheduledRemindersTask {
public void scheduledReminders() { public void scheduledReminders() {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
log.info("scheduledRemindersTask start"); log.info("scheduledRemindersTask start");
List<LarkCompanyTableInfo> larkList = this.getLarkList(); List<LarkCompanyTableInfo> larkList = this.getLarkList();
if (CollectionUtils.isEmpty(larkList)) { if (CollectionUtils.isEmpty(larkList)) {

@ -45,10 +45,14 @@ public class CJTOdooLarkTableJob {
private LarkRobotHelper larkRobotHelper; private LarkRobotHelper larkRobotHelper;
@Value("${lark.robot.group}") @Value("${lark.robot.group}")
private String ROBOT_GROUP; private String ROBOT_GROUP;
@Value("${sync.flag}")
private Boolean syncFlag;
private static final List<Integer> enableExecuteMonth = Arrays.asList(1,4,7,10); private static final List<Integer> enableExecuteMonth = Arrays.asList(1,4,7,10);
public void execute() { public void execute() {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
Map<AppType, TableRelationTypeEnum> waitCreatMap = getWaitCreateMap(); Map<AppType, TableRelationTypeEnum> waitCreatMap = getWaitCreateMap();
Map<TableRelationTypeEnum, String> tableNameMap = getTableNameMap(); Map<TableRelationTypeEnum, String> tableNameMap = getTableNameMap();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();

@ -54,7 +54,8 @@ public abstract class OdooAbstrackob {
private LarkRobotHelper larkRobotHelper; private LarkRobotHelper larkRobotHelper;
@Value("${lark.robot.group}") @Value("${lark.robot.group}")
private String ROBOT_GROUP; private String ROBOT_GROUP;
@Value("${sync.flag}")
private Boolean syncFlag;
private static final String GET_DATA_DB = "Fortune_test0716"; private static final String GET_DATA_DB = "Fortune_test0716";
private static final String GET_DATA_NAME = "test"; private static final String GET_DATA_NAME = "test";
@ -69,6 +70,9 @@ public abstract class OdooAbstrackob {
public void execute(Integer warehouseId) { public void execute(Integer warehouseId) {
try { try {
if (Boolean.FALSE.equals(syncFlag)) {
return;
}
log.info("===================== {} strat ======================", this.getClassName()); log.info("===================== {} strat ======================", this.getClassName());
//初始化调用对象 //初始化调用对象
OdooContext context = initContext(warehouseId); OdooContext context = initContext(warehouseId);

Loading…
Cancel
Save