添加功能
This commit is contained in:
parent
4a9aad9eb4
commit
36bb7c0c30
|
|
@ -27,12 +27,16 @@ import java.util.List;
|
||||||
public class LdapScheduledTask {
|
public class LdapScheduledTask {
|
||||||
|
|
||||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN);
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IAdService adService;
|
private IAdService adService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IAdSyncService adSyncService;
|
private IAdSyncService adSyncService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DepartmentControllerService departmentControllerService;
|
private DepartmentControllerService departmentControllerService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserControllerService userControllerService;
|
private UserControllerService userControllerService;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.nflg.wms.common.constant;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum InventoryCheckTaskState {
|
||||||
|
|
||||||
|
UnPublish(0, "未发布"),
|
||||||
|
Published(1, "已发布"),
|
||||||
|
InProgress(2, "进行中"),
|
||||||
|
Completed(3, "已完成");
|
||||||
|
|
||||||
|
private final Integer state;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
public static InventoryCheckTaskState findByValue(Integer value) {
|
||||||
|
for (InventoryCheckTaskState valueEnum : InventoryCheckTaskState.values()) {
|
||||||
|
if (Objects.equals(valueEnum.getState(), value)) {
|
||||||
|
return valueEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -60,4 +60,13 @@ public class DateTimeUtil {
|
||||||
.withZoneSameInstant(ZoneId.systemDefault())
|
.withZoneSameInstant(ZoneId.systemDefault())
|
||||||
.toLocalDateTime();
|
.toLocalDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDate asUTCDate(LocalDate date) {
|
||||||
|
if (Objects.isNull(date)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return date.atStartOfDay(ZoneId.systemDefault())
|
||||||
|
.withZoneSameInstant(ZoneOffset.UTC)
|
||||||
|
.toLocalDate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInt
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||||
import com.nflg.wms.repository.handler.UTCLocalDateTimeTypeHandler;
|
import com.nflg.wms.repository.handler.UTCLocalDateTimeTypeHandler;
|
||||||
import com.nflg.wms.repository.handler.UTCLocalDateTypeHandler;
|
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
|
@ -18,7 +17,6 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
@ -39,7 +37,7 @@ public class MysqlDataSourceConfig {
|
||||||
|
|
||||||
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
|
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
|
||||||
typeHandlerRegistry.register(LocalDateTime.class, new UTCLocalDateTimeTypeHandler());
|
typeHandlerRegistry.register(LocalDateTime.class, new UTCLocalDateTimeTypeHandler());
|
||||||
typeHandlerRegistry.register(LocalDate.class, new UTCLocalDateTypeHandler());
|
// typeHandlerRegistry.register(LocalDate.class, new UTCLocalDateTypeHandler());
|
||||||
|
|
||||||
sqlSessionFactoryBean.setConfiguration(configuration);
|
sqlSessionFactoryBean.setConfiguration(configuration);
|
||||||
sqlSessionFactoryBean.setDataSource(masterDataSource);
|
sqlSessionFactoryBean.setDataSource(masterDataSource);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nflg.wms.common.constant.InventoryCheckTaskState;
|
||||||
import com.nflg.wms.common.pojo.qo.InventoryCheckTaskMaterialsQO;
|
import com.nflg.wms.common.pojo.qo.InventoryCheckTaskMaterialsQO;
|
||||||
import com.nflg.wms.common.pojo.qo.InventoryCheckTaskSaveQO;
|
import com.nflg.wms.common.pojo.qo.InventoryCheckTaskSaveQO;
|
||||||
import com.nflg.wms.common.pojo.qo.InventoryCheckTaskSearchQO;
|
import com.nflg.wms.common.pojo.qo.InventoryCheckTaskSearchQO;
|
||||||
|
|
@ -118,13 +119,13 @@ public class WmsInventoryCheckTaskServiceImpl extends ServiceImpl<WmsInventoryCh
|
||||||
public void complete(Long taskId) {
|
public void complete(Long taskId) {
|
||||||
WmsInventoryCheckTask task = getById(taskId);
|
WmsInventoryCheckTask task = getById(taskId);
|
||||||
VUtil.trueThrowBusinessError(Objects.isNull(task)).throwMessage("未找到任务");
|
VUtil.trueThrowBusinessError(Objects.isNull(task)).throwMessage("未找到任务");
|
||||||
VUtil.trueThrowBusinessError(!Objects.equals(task.getState(), 2)).throwMessage("任务未开始或已完成");
|
VUtil.trueThrowBusinessError(!Objects.equals(task.getState(), InventoryCheckTaskState.InProgress.getState())).throwMessage("任务未开始或已完成");
|
||||||
lambdaUpdate()
|
lambdaUpdate()
|
||||||
.set(WmsInventoryCheckTask::getState, 3)
|
.set(WmsInventoryCheckTask::getState, InventoryCheckTaskState.Completed.getState())
|
||||||
.set(WmsInventoryCheckTask::getUpdateBy, UserUtil.getUserName())
|
.set(WmsInventoryCheckTask::getUpdateBy, UserUtil.getUserName())
|
||||||
.set(WmsInventoryCheckTask::getUpdateTime, LocalDateTime.now())
|
.set(WmsInventoryCheckTask::getUpdateTime, LocalDateTime.now())
|
||||||
.eq(WmsInventoryCheckTask::getId, taskId)
|
.eq(WmsInventoryCheckTask::getId, taskId)
|
||||||
.eq(WmsInventoryCheckTask::getState, 2)
|
.eq(WmsInventoryCheckTask::getState, InventoryCheckTaskState.InProgress.getState())
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.nflg.wms.scheduled.processor;
|
||||||
|
|
||||||
|
import com.nflg.wms.common.constant.InventoryCheckTaskState;
|
||||||
|
import com.nflg.wms.repository.entity.WmsInventoryCheckTask;
|
||||||
|
import com.nflg.wms.repository.service.IWmsInventoryCheckTaskService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import tech.powerjob.worker.core.processor.ProcessResult;
|
||||||
|
import tech.powerjob.worker.core.processor.TaskContext;
|
||||||
|
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;
|
||||||
|
import tech.powerjob.worker.log.OmsLogger;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component(value = "InventoryCheckTaskProcessor")
|
||||||
|
public class InventoryCheckTaskProcessor implements BasicProcessor {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IWmsInventoryCheckTaskService inventoryCheckTaskService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProcessResult process(TaskContext context) {
|
||||||
|
OmsLogger omsLogger = context.getOmsLogger();
|
||||||
|
omsLogger.info("开始");
|
||||||
|
List<WmsInventoryCheckTask> datas = inventoryCheckTaskService.lambdaQuery().eq(WmsInventoryCheckTask::getState, InventoryCheckTaskState.Published.getState()).list();
|
||||||
|
omsLogger.info("共【{}】条已发布数据", datas.size());
|
||||||
|
datas.forEach(data -> {
|
||||||
|
omsLogger.info("处理【{}】开始", data.getTaskNo());
|
||||||
|
if (LocalDate.now().isAfter(data.getEndTime())) {
|
||||||
|
inventoryCheckTaskService.lambdaUpdate()
|
||||||
|
.eq(WmsInventoryCheckTask::getId, data.getId())
|
||||||
|
.set(WmsInventoryCheckTask::getState, InventoryCheckTaskState.Completed.getState())
|
||||||
|
.update();
|
||||||
|
omsLogger.info("设置为状态:{}", InventoryCheckTaskState.Completed.getDescription());
|
||||||
|
} else if (data.getStartTime().isAfter(LocalDate.now())) {
|
||||||
|
inventoryCheckTaskService.lambdaUpdate()
|
||||||
|
.eq(WmsInventoryCheckTask::getId, data.getId())
|
||||||
|
.set(WmsInventoryCheckTask::getState, InventoryCheckTaskState.InProgress.getState())
|
||||||
|
.update();
|
||||||
|
omsLogger.info("设置为状态:{}", InventoryCheckTaskState.InProgress.getDescription());
|
||||||
|
}
|
||||||
|
omsLogger.info("处理【{}】结束", data.getTaskNo());
|
||||||
|
});
|
||||||
|
return new ProcessResult(true, "处理完毕");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
root: info
|
|
||||||
com:
|
|
||||||
nflg: debug
|
|
||||||
alibaba:
|
|
||||||
cloud:
|
|
||||||
nacos: debug
|
|
||||||
org:
|
|
||||||
springframework: debug
|
|
||||||
|
|
@ -4,17 +4,17 @@ spring:
|
||||||
application:
|
application:
|
||||||
name: scheduled
|
name: scheduled
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: sit
|
||||||
config:
|
config:
|
||||||
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
|
import: nacos:shared.properties?group=${spring.profiles.active}&refreshEnabled=true
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
config:
|
config:
|
||||||
server-addr: ${nacos.server-addr:112.74.186.154:8848}
|
server-addr: ${nacos.server-addr:192.168.163.83:8848}
|
||||||
namespace: wms
|
namespace: wms
|
||||||
group: ${spring.profiles.active}
|
group: ${spring.profiles.active}
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: ${nacos.server-addr:112.74.186.154:8848}
|
server-addr: ${nacos.server-addr:192.168.163.83:8848}
|
||||||
namespace: wms
|
namespace: wms
|
||||||
group: ${spring.profiles.active}
|
group: ${spring.profiles.active}
|
||||||
logging:
|
logging:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue