修复
This commit is contained in:
parent
3c1f3a3c37
commit
88c5652faa
|
|
@ -32,6 +32,7 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
@EnableAsync
|
||||||
public class JobComponent {
|
public class JobComponent {
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,16 +48,16 @@ public class JobComponent {
|
||||||
*/
|
*/
|
||||||
private final IWorkService workService;
|
private final IWorkService workService;
|
||||||
|
|
||||||
private volatile boolean isSendingCommonTask = false;
|
private boolean isSendingCommonTask = false;
|
||||||
private volatile boolean isSendingPickOutTask = false;
|
private boolean isSendingPickOutTask = false;
|
||||||
private volatile boolean isSendingPickTask = false;
|
private boolean isSendingPickTask = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向Wcs下发任务
|
* 向Wcs下发任务
|
||||||
* 每2秒执行一次
|
* 每2秒执行一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 2000)
|
@Scheduled(fixedDelay = 2000)
|
||||||
@Async("myThreadPool")
|
@Async
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
public void sendCommonTasks() {
|
public void sendCommonTasks() {
|
||||||
if (isSendingCommonTask) {
|
if (isSendingCommonTask) {
|
||||||
|
|
@ -85,7 +86,7 @@ public class JobComponent {
|
||||||
* 每2秒执行一次
|
* 每2秒执行一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 2000)
|
@Scheduled(fixedDelay = 2000)
|
||||||
@Async("myThreadPool")
|
@Async
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
public void sendPickOutTasks() {
|
public void sendPickOutTasks() {
|
||||||
if (isSendingPickOutTask) {
|
if (isSendingPickOutTask) {
|
||||||
|
|
@ -113,7 +114,7 @@ public class JobComponent {
|
||||||
* 每2秒执行一次
|
* 每2秒执行一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 2000)
|
@Scheduled(fixedDelay = 2000)
|
||||||
@Async("myThreadPool")
|
@Async
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
public void sendPickTasks() {
|
public void sendPickTasks() {
|
||||||
if (isSendingPickTask) {
|
if (isSendingPickTask) {
|
||||||
|
|
@ -160,7 +161,7 @@ public class JobComponent {
|
||||||
/**
|
/**
|
||||||
* 创建工作
|
* 创建工作
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 2000)
|
@Scheduled(fixedDelay = 20000)
|
||||||
public void createWork() {
|
public void createWork() {
|
||||||
String createWork = configMap.get(ConfigMapKeyEnum.CREATE_WORK.getConfigKey());
|
String createWork = configMap.get(ConfigMapKeyEnum.CREATE_WORK.getConfigKey());
|
||||||
if (StringUtils.isEmpty(createWork) || !createWork.equals("1")) {
|
if (StringUtils.isEmpty(createWork) || !createWork.equals("1")) {
|
||||||
|
|
@ -196,7 +197,7 @@ public class JobComponent {
|
||||||
/**
|
/**
|
||||||
* 执行工作
|
* 执行工作
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 2000)
|
@Scheduled(fixedDelay = 20000)
|
||||||
public void doWork() {
|
public void doWork() {
|
||||||
String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey());
|
String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey());
|
||||||
if (StringUtils.isEmpty(startWork) || !startWork.equals("1")) {
|
if (StringUtils.isEmpty(startWork) || !startWork.equals("1")) {
|
||||||
|
|
@ -228,7 +229,7 @@ public class JobComponent {
|
||||||
* 每天晚上10点执行一次
|
* 每天晚上10点执行一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 22 * * ?")
|
@Scheduled(cron = "0 0 22 * * ?")
|
||||||
@Async("myThreadPool")
|
@Async
|
||||||
public void deleteOutOfDateData() {
|
public void deleteOutOfDateData() {
|
||||||
// 删除日志数据
|
// 删除日志数据
|
||||||
wmsJobService.deleteLogsRegularly();
|
wmsJobService.deleteLogsRegularly();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.wms.annotation.MyLog;
|
import com.wms.annotation.MyLog;
|
||||||
import com.wms.constants.enums.ResponseCode;
|
import com.wms.constants.enums.ResponseCode;
|
||||||
import com.wms.entity.app.dto.PageDto;
|
import com.wms.entity.app.dto.PageDto;
|
||||||
import com.wms.entity.app.request.ELocationConfigQuery;
|
|
||||||
import com.wms.entity.app.request.ELocationQuery;
|
import com.wms.entity.app.request.ELocationQuery;
|
||||||
import com.wms.entity.app.request.LocationQuery;
|
import com.wms.entity.app.request.LocationQuery;
|
||||||
import com.wms.entity.app.request.VehicleQuery;
|
import com.wms.entity.app.request.VehicleQuery;
|
||||||
|
|
@ -16,8 +15,6 @@ import com.wms.entity.app.ResponseEntity;
|
||||||
import com.wms.entity.app.vo.ELocationVo;
|
import com.wms.entity.app.vo.ELocationVo;
|
||||||
import com.wms.entity.app.vo.LocationVo;
|
import com.wms.entity.app.vo.LocationVo;
|
||||||
import com.wms.entity.app.vo.VehicleVO;
|
import com.wms.entity.app.vo.VehicleVO;
|
||||||
import com.wms.entity.app.wcs.WcsETaskFeedbackRequest;
|
|
||||||
import com.wms.entity.table.ELocationConfig;
|
|
||||||
import com.wms.entity.table.ETagLocation;
|
import com.wms.entity.table.ETagLocation;
|
||||||
import com.wms.entity.table.Location;
|
import com.wms.entity.table.Location;
|
||||||
import com.wms.entity.table.Vehicle;
|
import com.wms.entity.table.Vehicle;
|
||||||
|
|
@ -41,7 +38,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static com.wms.utils.StringUtils.convertJsonString;
|
import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
|
|
||||||
|
|
@ -257,16 +253,19 @@ public class LocationController {
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
@MyLog(logTitle = "生成电子标签库位表", logMethod = "genELocations")
|
@MyLog(logTitle = "生成电子标签库位表", logMethod = "genELocations")
|
||||||
public String genELocations(@RequestBody ELocationQuery eLocationQuery) {
|
public String genELocations(@RequestBody ELocationQuery eLocationQuery) {
|
||||||
// 9*64*22
|
|
||||||
logger.info("接收到生成电子标签库位表数据请求:{},请求ip地址:{}", convertJsonString(eLocationQuery), HttpUtils.getIpAddr(servletRequest));
|
logger.info("接收到生成电子标签库位表数据请求:{},请求ip地址:{}", convertJsonString(eLocationQuery), HttpUtils.getIpAddr(servletRequest));
|
||||||
// 创建响应信息
|
// 创建响应信息
|
||||||
ResponseEntity rsp = new ResponseEntity();
|
ResponseEntity rsp = new ResponseEntity();
|
||||||
try {
|
try {
|
||||||
List<ETagLocation> eLocations = new ArrayList<>();
|
List<ETagLocation> eLocations = new ArrayList<>();
|
||||||
for (int i = 1; i <= 9; i++) {
|
for (int i = 1; i <= 9; i++) {
|
||||||
for (int j = 1; j <= 96; j++) {
|
for (int j = 1; j <= 120; j++) {
|
||||||
ETagLocation eTagLocation = new ETagLocation();
|
ETagLocation eTagLocation = new ETagLocation();
|
||||||
|
if (j < 100) {
|
||||||
eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0"));
|
eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0"));
|
||||||
|
} else {
|
||||||
|
eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 3, "0"));
|
||||||
|
}
|
||||||
eTagLocation.setAreaId(String.valueOf(i));
|
eTagLocation.setAreaId(String.valueOf(i));
|
||||||
eTagLocation.setSequenceId(j);
|
eTagLocation.setSequenceId(j);
|
||||||
eTagLocation.setELocationStatus(0);
|
eTagLocation.setELocationStatus(0);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.wms.constants.enums.*;
|
import com.wms.constants.enums.*;
|
||||||
import com.wms.entity.app.dto.KateOrdersDto;
|
import com.wms.entity.app.dto.WorkCenterAndOrderDto;
|
||||||
import com.wms.entity.app.dto.extend.StockDetailInfo;
|
import com.wms.entity.app.dto.extend.StockDetailInfo;
|
||||||
import com.wms.entity.table.*;
|
import com.wms.entity.table.*;
|
||||||
import com.wms.service.*;
|
import com.wms.service.*;
|
||||||
|
|
@ -25,9 +25,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
@ -59,12 +57,9 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
private final StandService standService;// 站台服务
|
private final StandService standService;// 站台服务
|
||||||
private final TaskService taskService;// 任务服务
|
private final TaskService taskService;// 任务服务
|
||||||
private final WorkFlowLastService workFlowLastService;// 服务
|
private final WorkFlowLastService workFlowLastService;// 服务
|
||||||
// private final List<String> workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台
|
private final List<String> workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台
|
||||||
// private final List<String> workDoingStations = new ArrayList<>();// 当前正在执行任务的站台
|
private final List<String> workDoingStations = new ArrayList<>();// 当前正在执行任务的站台
|
||||||
// private final List<String> workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台
|
private final List<String> workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台
|
||||||
private final Map<String, Boolean> workCreatingStations = new ConcurrentHashMap<>();
|
|
||||||
private final Map<String, Boolean> workDoingStations = new ConcurrentHashMap<>();
|
|
||||||
private final Map<String, Boolean> workFinishingStations = new ConcurrentHashMap<>();
|
|
||||||
private final VehicleService vehicleService;// 料箱服务
|
private final VehicleService vehicleService;// 料箱服务
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,15 +70,18 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
public void createWork(String workStation) {
|
public void createWork(String workStation) {
|
||||||
|
if (workCreatingStations.contains(workStation)) {
|
||||||
|
// 当前站台正在创建任务
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// 添加站台
|
||||||
|
workCreatingStations.add(workStation);
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(workStation)) {
|
if (StringUtils.isEmpty(workStation)) {
|
||||||
// 站台号为空
|
// 站台号为空
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (workCreatingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
|
||||||
// 当前站台正在创建任务
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 先判断当日是否是工作日
|
// 先判断当日是否是工作日
|
||||||
LocalDate currentWorkDate = LocalDate.now();
|
LocalDate currentWorkDate = LocalDate.now();
|
||||||
|
|
@ -259,9 +257,12 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
public void doWork(String workStation) {
|
public void doWork(String workStation) {
|
||||||
if (workDoingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
if (workDoingStations.contains(workStation)) {
|
||||||
// 当前站台正在创建任务
|
// 当前站台正在创建任务
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
// 添加站台
|
||||||
|
workDoingStations.add(workStation);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 查找当前站台未开始的工作流
|
// 查找当前站台未开始的工作流
|
||||||
|
|
@ -448,9 +449,13 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String finishWork(String workStation) {
|
public String finishWork(String workStation) {
|
||||||
if (workFinishingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
if (workFinishingStations.contains(workStation)) {
|
||||||
// 当前站台正在完成工作
|
// 当前站台正在完成工作
|
||||||
return "当前站台正在完成工作,请勿重复操作";
|
return "当前站台正在完成工作,请勿重复操作";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 添加站台
|
||||||
|
workFinishingStations.add(workStation);
|
||||||
}
|
}
|
||||||
String result = "";
|
String result = "";
|
||||||
try {
|
try {
|
||||||
|
|
@ -558,43 +563,91 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
*/
|
*/
|
||||||
private void findWorks(String workStation, List<WorkFlow> workFlows, String model, LocalDate currentWorkDate) {
|
private void findWorks(String workStation, List<WorkFlow> workFlows, String model, LocalDate currentWorkDate) {
|
||||||
// 查到当前站台所有的小工位
|
// 查到当前站台所有的小工位
|
||||||
// LambdaQueryWrapper<WorkStationConfig> stationConfigQueryWrapper = new LambdaQueryWrapper<WorkStationConfig>()
|
LambdaQueryWrapper<WorkStationConfig> stationConfigQueryWrapper = new LambdaQueryWrapper<WorkStationConfig>()
|
||||||
// .eq(StringUtils.isNotEmpty(workStation), WorkStationConfig::getWorkStation, workStation);
|
.eq(StringUtils.isNotEmpty(workStation), WorkStationConfig::getWorkStation, workStation);
|
||||||
// if (Objects.equals(model, "MWL")) {
|
if (Objects.equals(model, "MWL")) {
|
||||||
// stationConfigQueryWrapper.eq(WorkStationConfig::getModel, "MWL");
|
stationConfigQueryWrapper.eq(WorkStationConfig::getModel, "MWL");
|
||||||
// } else {
|
} else {
|
||||||
// stationConfigQueryWrapper.ne(WorkStationConfig::getModel, "MWL");
|
stationConfigQueryWrapper.ne(WorkStationConfig::getModel, "MWL");
|
||||||
// }
|
}
|
||||||
// stationConfigQueryWrapper.orderByAsc(WorkStationConfig::getSmallBox);
|
stationConfigQueryWrapper.orderByAsc(WorkStationConfig::getSmallBox);
|
||||||
// List<WorkStationConfig> currentStationConfigsOfNwl = workStationConfigService.list(stationConfigQueryWrapper);
|
List<WorkStationConfig> currentStationConfigsOfNwl = workStationConfigService.list(stationConfigQueryWrapper);
|
||||||
// // 没有工站配置
|
// 没有工站配置
|
||||||
// if (currentStationConfigsOfNwl == null || currentStationConfigsOfNwl.isEmpty()) {
|
if (currentStationConfigsOfNwl == null || currentStationConfigsOfNwl.isEmpty()) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// 今日开工的工单和小工位
|
// 今日开工的工单和小工位
|
||||||
// Map<String, List<WorkCenterAndOrderDto>> tasksOfTodayMap = new HashMap<>();
|
Map<String, List<WorkCenterAndOrderDto>> tasksOfTodayMap = new HashMap<>();
|
||||||
// 查询currentWorkDate的工单 连表查询 根据tbl_app_kate_order的work_order字段和tbL_app_kate_dbs的work_order字段
|
List<KateOrders> allNewKateWorkOrders = kateOrdersService.list(new LambdaQueryWrapper<KateOrders>()
|
||||||
//查询出supplay_area字段, 再根据supply_area字段查询tbl_app_e_location_config表的small_box字段相等的,根据
|
.eq(KateOrders::getOrderStatus, 0)
|
||||||
//tbl_app_e_location_config的start_date_adjust字段的值,
|
.eq(KateOrders::getSortString, configMap.get(ConfigMapKeyEnum.SLOC_FILTER_STRING.getConfigKey())));
|
||||||
// 如果小于0,则在currentWorkDate减n的值,如果大于0,则在currentWorkDate加n的值,如果=0,则currentWorkDate
|
// 查询所有的dbs
|
||||||
KateOrdersDto kateOrders = new KateOrdersDto();
|
List<KateDBS> allKateDBS = kateDBSService.list(new LambdaQueryWrapper<KateDBS>().orderByAsc(KateDBS::getWorkSequence));
|
||||||
kateOrders.setSortString(configMap.get(ConfigMapKeyEnum.SLOC_FILTER_STRING.getConfigKey()));
|
// 根据所有小工位,查到对应的任务
|
||||||
kateOrders.setOrderStatus(0);
|
for (WorkStationConfig workConfig : currentStationConfigsOfNwl) {
|
||||||
String currentDay = currentWorkDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
// 查询当前小工位是否已经判断过开工日期
|
||||||
kateOrders.setCurrentWorkDay(currentDay);
|
if (StringUtils.isEmpty(workConfig.getSmallBox()) || tasksOfTodayMap.containsKey(workConfig.getSmallBox())) {
|
||||||
kateOrders.setModel(model);
|
continue;
|
||||||
kateOrders.setWorkStation(workStation);
|
}
|
||||||
List<KateOrdersDto> allNewKateWorkOrders = kateOrdersService.selectCurrentWorkDateKateOrders(kateOrders);
|
// 通过工单表查询到对应的工单
|
||||||
for (KateOrdersDto tempOrder : allNewKateWorkOrders) {
|
List<KateOrders> kateWorkOrders = allNewKateWorkOrders.stream().filter(kateWorkOrder ->
|
||||||
|
kateWorkOrder.getSupplyArea().equals(workConfig.getSmallBox())).toList();
|
||||||
|
// 当前工位没有未完成的工单
|
||||||
|
if (kateWorkOrders.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<WorkCenterAndOrderDto> toDaysOrders = new ArrayList<>();
|
||||||
|
// 防止重复查询
|
||||||
|
Map<String, KateDBS> ordersAndDBSMap = new HashMap<>();
|
||||||
|
for (KateOrders kateWorkOrder : kateWorkOrders) {
|
||||||
|
if (!ordersAndDBSMap.containsKey(kateWorkOrder.getWorkOrder())) {
|
||||||
|
// 从DBS表查询对应的工单以及开工时间
|
||||||
|
KateDBS kateDBS = allKateDBS.stream().filter(tempKateDBS ->
|
||||||
|
tempKateDBS.getWorkOrder().equals(kateWorkOrder.getWorkOrder())).findFirst().orElse(null);
|
||||||
|
if (kateDBS == null || StringUtils.isEmpty(kateDBS.getWorkOrder())) {// 不存在对应的工单计划
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 判断是否是当天开工
|
||||||
|
int indexOfDbs = localWorkDateList.indexOf(kateDBS.getPlanStartDate().toLocalDate());
|
||||||
|
if (indexOfDbs == -1) {
|
||||||
|
// 工作日不包含此开工日期
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int indexAfterAdjust = indexOfDbs + workConfig.getStartDateAdjust();
|
||||||
|
if (indexAfterAdjust < 0 || indexAfterAdjust >= localWorkDateList.size()) {
|
||||||
|
// 调整后的日期不再工作日范围
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (localWorkDateList.get(indexAfterAdjust).equals(currentWorkDate)) {
|
||||||
|
// 已经查询过的为了不重复查询,添加map
|
||||||
|
ordersAndDBSMap.put(kateWorkOrder.getWorkOrder(), kateDBS);
|
||||||
|
// 添加工作计划
|
||||||
|
WorkCenterAndOrderDto wcoDto = new WorkCenterAndOrderDto();
|
||||||
|
wcoDto.setWorkCenter(workConfig.getSmallBox());
|
||||||
|
wcoDto.setWorkOrder(kateWorkOrder.getWorkOrder());
|
||||||
|
wcoDto.setStartDate(LocalDateTime.now().toLocalDate().atStartOfDay());
|
||||||
|
wcoDto.setDbsSequence(kateDBS.getWorkSequence());
|
||||||
|
toDaysOrders.add(wcoDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasksOfTodayMap.put(workConfig.getSmallBox(), toDaysOrders);
|
||||||
|
}
|
||||||
|
// 判断是否有今天开工的工单和小工位
|
||||||
|
if (!tasksOfTodayMap.isEmpty()) {
|
||||||
|
for (String smallBoxKey : tasksOfTodayMap.keySet()) {
|
||||||
|
List<WorkCenterAndOrderDto> currentWorkCenterAndOrderDtoList = tasksOfTodayMap.get(smallBoxKey).stream().sorted(Comparator.comparingInt(WorkCenterAndOrderDto::getDbsSequence)).toList();
|
||||||
|
for (WorkCenterAndOrderDto currentWorkCenterAndOrderDto : currentWorkCenterAndOrderDtoList) {
|
||||||
|
// 通过工单表查询到对应的工单
|
||||||
|
List<KateOrders> kateWorkOrderList = allNewKateWorkOrders.stream().filter(kateWorkOrder ->
|
||||||
|
kateWorkOrder.getWorkOrder().equals(currentWorkCenterAndOrderDto.getWorkOrder())
|
||||||
|
&& kateWorkOrder.getSupplyArea().equals(currentWorkCenterAndOrderDto.getWorkCenter())).toList();
|
||||||
|
for (KateOrders tempOrder : kateWorkOrderList) {
|
||||||
// 生成workFlow
|
// 生成workFlow
|
||||||
WorkFlow tempWorkFlow = new WorkFlow();
|
WorkFlow tempWorkFlow = new WorkFlow();
|
||||||
tempWorkFlow.setWorkFlowId(WmsUtils.generateId("WORKFLOW_"));
|
tempWorkFlow.setWorkFlowId(WmsUtils.generateId("WORKFLOW_"));
|
||||||
tempWorkFlow.setOrderId(tempOrder.getOrderId());
|
tempWorkFlow.setOrderId(tempOrder.getOrderId());
|
||||||
if("MWL".equals(model)) {
|
|
||||||
tempWorkFlow.setWorkStation(tempOrder.getWorkStation());
|
|
||||||
}else{
|
|
||||||
tempWorkFlow.setWorkStation(workStation);
|
tempWorkFlow.setWorkStation(workStation);
|
||||||
}
|
|
||||||
tempWorkFlow.setWorkOrder(tempOrder.getWorkOrder());
|
tempWorkFlow.setWorkOrder(tempOrder.getWorkOrder());
|
||||||
tempWorkFlow.setWorkCenter(tempOrder.getSupplyArea());
|
tempWorkFlow.setWorkCenter(tempOrder.getSupplyArea());
|
||||||
tempWorkFlow.setGoodsId(tempOrder.getGoodsId());
|
tempWorkFlow.setGoodsId(tempOrder.getGoodsId());
|
||||||
|
|
@ -609,110 +662,9 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
workFlows.add(tempWorkFlow);
|
workFlows.add(tempWorkFlow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// List<KateOrders> allNewKateWorkOrders = kateOrdersService.list(new LambdaQueryWrapper<KateOrders>()
|
}
|
||||||
// .eq(KateOrders::getOrderStatus, 0)
|
}
|
||||||
// .eq(KateOrders::getSortString, configMap.get(ConfigMapKeyEnum.SLOC_FILTER_STRING.getConfigKey())));
|
}
|
||||||
// 查询所有的dbs
|
|
||||||
// List<KateDBS> allKateDBS = kateDBSService.list(new LambdaQueryWrapper<KateDBS>().orderByAsc(KateDBS::getWorkSequence));
|
|
||||||
// 根据所有小工位,查到对应的任务
|
|
||||||
// for (WorkStationConfig workConfig : currentStationConfigsOfNwl) {
|
|
||||||
// // 查询当前小工位是否已经判断过开工日期
|
|
||||||
// if (StringUtils.isEmpty(workConfig.getSmallBox()) || tasksOfTodayMap.containsKey(workConfig.getSmallBox())) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // 通过工单表查询到对应的工单
|
|
||||||
// List<KateOrders> kateWorkOrders = allNewKateWorkOrders.stream().filter(kateWorkOrder ->
|
|
||||||
// kateWorkOrder.getSupplyArea().equals(workConfig.getSmallBox())).toList();
|
|
||||||
// // 当前工位没有未完成的工单
|
|
||||||
// if (kateWorkOrders.isEmpty()) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// List<WorkCenterAndOrderDto> toDaysOrders = new ArrayList<>();
|
|
||||||
// // 防止重复查询
|
|
||||||
// Map<String, KateDBS> ordersAndDBSMap = new HashMap<>();
|
|
||||||
// for (KateOrders kateWorkOrder : kateWorkOrders) {
|
|
||||||
// if (!ordersAndDBSMap.containsKey(kateWorkOrder.getWorkOrder())) {
|
|
||||||
// // 从DBS表查询对应的工单以及开工时间
|
|
||||||
// KateDBS kateDBS = allKateDBS.stream().filter(tempKateDBS ->
|
|
||||||
// tempKateDBS.getWorkOrder().equals(kateWorkOrder.getWorkOrder())).findFirst().orElse(null);
|
|
||||||
// if (kateDBS == null || StringUtils.isEmpty(kateDBS.getWorkOrder())) {// 不存在对应的工单计划
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // 判断是否是当天开工
|
|
||||||
// int indexOfDbs = localWorkDateList.indexOf(kateDBS.getPlanStartDate().toLocalDate());
|
|
||||||
// if (indexOfDbs == -1) {
|
|
||||||
// // 工作日不包含此开工日期
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// int indexAfterAdjust = indexOfDbs + workConfig.getStartDateAdjust();
|
|
||||||
// if (indexAfterAdjust < 0 || indexAfterAdjust >= localWorkDateList.size()) {
|
|
||||||
// // 调整后的日期不再工作日范围
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (localWorkDateList.get(indexAfterAdjust).equals(currentWorkDate)) {
|
|
||||||
// // 已经查询过的为了不重复查询,添加map
|
|
||||||
// ordersAndDBSMap.put(kateWorkOrder.getWorkOrder(), kateDBS);
|
|
||||||
// // 添加工作计划
|
|
||||||
// WorkCenterAndOrderDto wcoDto = new WorkCenterAndOrderDto();
|
|
||||||
// wcoDto.setWorkCenter(workConfig.getSmallBox());
|
|
||||||
// wcoDto.setWorkOrder(kateWorkOrder.getWorkOrder());
|
|
||||||
// wcoDto.setStartDate(LocalDateTime.now().toLocalDate().atStartOfDay());
|
|
||||||
// wcoDto.setDbsSequence(kateDBS.getWorkSequence());
|
|
||||||
// toDaysOrders.add(wcoDto);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// tasksOfTodayMap.put(workConfig.getSmallBox(), toDaysOrders);
|
|
||||||
// }
|
|
||||||
//过滤allNewKateWorkOrders,根据smallBox进行分组,然后根据workOrder进行排序,然后根据workSequence进行排序
|
|
||||||
// Map<String, List<KateOrdersDto>> smallBoxAndKateOrdersMap = allNewKateWorkOrders.stream().collect(Collectors.groupingBy(KateOrdersDto::getSmallBox));
|
|
||||||
// for (String smallBoxKey : smallBoxAndKateOrdersMap.keySet()) {
|
|
||||||
// List<KateOrdersDto> kateWorkOrderList = smallBoxAndKateOrdersMap.get(smallBoxKey);
|
|
||||||
// List<KateOrdersDto> kateWorkOrderListSorted = kateWorkOrderList.stream().sorted(Comparator.comparingInt(KateOrdersDto::getWorkSequence)).toList();
|
|
||||||
// List<WorkCenterAndOrderDto> toDaysOrders = new ArrayList<>();
|
|
||||||
// for (KateOrdersDto kateWorkOrder : kateWorkOrderListSorted) {
|
|
||||||
// // 添加工作计划
|
|
||||||
// WorkCenterAndOrderDto wcoDto = new WorkCenterAndOrderDto();
|
|
||||||
// wcoDto.setWorkCenter(kateWorkOrder.getSmallBox());
|
|
||||||
// wcoDto.setWorkOrder(kateWorkOrder.getWorkOrder());
|
|
||||||
// wcoDto.setStartDate(LocalDateTime.now().toLocalDate().atStartOfDay());
|
|
||||||
// wcoDto.setDbsSequence(kateWorkOrder.getWorkSequence());
|
|
||||||
// toDaysOrders.add(wcoDto);
|
|
||||||
// }
|
|
||||||
// tasksOfTodayMap.put(smallBoxKey, toDaysOrders);
|
|
||||||
// }
|
|
||||||
// 判断是否有今天开工的工单和小工位
|
|
||||||
// if (!tasksOfTodayMap.isEmpty()) {
|
|
||||||
// for (String smallBoxKey : tasksOfTodayMap.keySet()) {
|
|
||||||
// List<WorkCenterAndOrderDto> currentWorkCenterAndOrderDtoList = tasksOfTodayMap.get(smallBoxKey).stream().sorted(Comparator.comparingInt(WorkCenterAndOrderDto::getDbsSequence)).toList();
|
|
||||||
// for (WorkCenterAndOrderDto currentWorkCenterAndOrderDto : currentWorkCenterAndOrderDtoList) {
|
|
||||||
// // 通过工单表查询到对应的工单
|
|
||||||
// List<KateOrders> kateWorkOrderList = allNewKateWorkOrders.stream().filter(kateWorkOrder ->
|
|
||||||
// kateWorkOrder.getWorkOrder().equals(currentWorkCenterAndOrderDto.getWorkOrder())
|
|
||||||
// && kateWorkOrder.getSupplyArea().equals(currentWorkCenterAndOrderDto.getWorkCenter())).toList();
|
|
||||||
// for (KateOrders tempOrder : kateWorkOrderList) {
|
|
||||||
// // 生成workFlow
|
|
||||||
// WorkFlow tempWorkFlow = new WorkFlow();
|
|
||||||
// tempWorkFlow.setWorkFlowId(WmsUtils.generateId("WORKFLOW_"));
|
|
||||||
// tempWorkFlow.setOrderId(tempOrder.getOrderId());
|
|
||||||
// tempWorkFlow.setWorkStation(workStation);
|
|
||||||
// tempWorkFlow.setWorkOrder(tempOrder.getWorkOrder());
|
|
||||||
// tempWorkFlow.setWorkCenter(tempOrder.getSupplyArea());
|
|
||||||
// tempWorkFlow.setGoodsId(tempOrder.getGoodsId());
|
|
||||||
// tempWorkFlow.setNeedNum(tempOrder.getRequirementQuantity());
|
|
||||||
// tempWorkFlow.setCreateTime(LocalDateTime.now());
|
|
||||||
// tempWorkFlow.setWorkStatus(0);
|
|
||||||
// tempWorkFlow.setLightStatus(0);
|
|
||||||
// tempWorkFlow.setPickedNum(BigDecimal.ZERO);
|
|
||||||
// // 改动
|
|
||||||
// tempWorkFlow.setMachineType(Objects.equals(model, "MWL") ? 1 : 2);
|
|
||||||
// tempWorkFlow.setPlanDate(currentWorkDate);
|
|
||||||
// workFlows.add(tempWorkFlow);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的工作日期
|
* 获取当前的工作日期
|
||||||
|
|
@ -753,6 +705,10 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
if (!localWorkDateList.contains(currentWorkDate)) {
|
if (!localWorkDateList.contains(currentWorkDate)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (workFlowService.exists(new LambdaQueryWrapper<>())) {
|
||||||
|
// 工作流已经生成过,不做处理
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 添加进总汇总数据
|
// 添加进总汇总数据
|
||||||
List<WorkFlow> allFlows = new ArrayList<>();
|
List<WorkFlow> allFlows = new ArrayList<>();
|
||||||
// 获取当天所有的装载机工作
|
// 获取当天所有的装载机工作
|
||||||
|
|
@ -765,7 +721,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
// 获取到当天所有的平地机工作
|
// 获取到当天所有的平地机工作
|
||||||
List<WorkFlow> thisDayMGWorks = new ArrayList<>();
|
List<WorkFlow> thisDayMGWorks = new ArrayList<>();
|
||||||
findWorks("", thisDayMGWorks, "MG", currentWorkDate);
|
findWorks("", thisDayMGWorks, "NOT_MWL", currentWorkDate);
|
||||||
if (!thisDayMGWorks.isEmpty()) {
|
if (!thisDayMGWorks.isEmpty()) {
|
||||||
allFlows.addAll(thisDayMGWorks);
|
allFlows.addAll(thisDayMGWorks);
|
||||||
// 查询配置是否需要合并第二天的配置
|
// 查询配置是否需要合并第二天的配置
|
||||||
|
|
@ -776,7 +732,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
// 获取下一个工作日
|
// 获取下一个工作日
|
||||||
LocalDate nextWorkDate = nextWorkDate(currentWorkDate);
|
LocalDate nextWorkDate = nextWorkDate(currentWorkDate);
|
||||||
if (nextWorkDate != null && nextWorkDate.isAfter(currentWorkDate)) {
|
if (nextWorkDate != null && nextWorkDate.isAfter(currentWorkDate)) {
|
||||||
findWorks("", nextDayMGWorks, "MG", nextWorkDate);
|
findWorks("", nextDayMGWorks, "NOT_MWL", nextWorkDate);
|
||||||
}
|
}
|
||||||
if (!nextDayMGWorks.isEmpty()) {
|
if (!nextDayMGWorks.isEmpty()) {
|
||||||
// 添加第二天的平地机工作进汇总
|
// 添加第二天的平地机工作进汇总
|
||||||
|
|
@ -786,31 +742,28 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
} else {
|
} else {
|
||||||
System.out.println("查询MG为空");
|
System.out.println("查询MG为空");
|
||||||
}
|
}
|
||||||
// 处理这些工作流
|
|
||||||
// List<WorkFlow> oldWorkFlows = workFlowService.list();
|
|
||||||
// // 按照工单号+小盒子号+料号来map一下
|
|
||||||
// Map<String, WorkFlow> oldWorkFlowsMap = oldWorkFlows.stream().collect(
|
|
||||||
// Collectors.toMap(workFlow ->
|
|
||||||
// workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId(), workFlow -> workFlow));
|
|
||||||
// 最后需要存储的工作
|
|
||||||
// List<WorkFlow> finalWorkFlows = new ArrayList<>();
|
|
||||||
// for (WorkFlow workFlow : allFlows) {
|
|
||||||
// String key = workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId();
|
|
||||||
// if (oldWorkFlowsMap.containsKey(key)) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// workFlow.setWorkStatus(-1);// 设置暂存状态
|
|
||||||
// finalWorkFlows.add(workFlow);
|
|
||||||
// }
|
|
||||||
// if (!finalWorkFlows.isEmpty()) {
|
|
||||||
if (!allFlows.isEmpty()) {
|
if (!allFlows.isEmpty()) {
|
||||||
|
// 处理这些工作流
|
||||||
|
List<WorkFlow> oldWorkFlows = workFlowService.list();
|
||||||
|
// 按照工单号+小盒子号+料号来map一下
|
||||||
|
Map<String, WorkFlow> oldWorkFlowsMap = oldWorkFlows.stream().collect(
|
||||||
|
Collectors.toMap(workFlow ->
|
||||||
|
workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId(), workFlow -> workFlow));
|
||||||
|
// 最后需要存储的工作
|
||||||
|
List<WorkFlow> finalWorkFlows = new ArrayList<>();
|
||||||
|
for (WorkFlow workFlow : allFlows) {
|
||||||
|
String key = workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId();
|
||||||
|
if (oldWorkFlowsMap.containsKey(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
workFlow.setWorkStatus(-1);// 设置暂存状态
|
||||||
|
finalWorkFlows.add(workFlow);
|
||||||
|
}
|
||||||
|
if (!finalWorkFlows.isEmpty()) {
|
||||||
// 存储数据
|
// 存储数据
|
||||||
//设置allFlows的workStatus=-1
|
workFlowService.saveBatch(finalWorkFlows);
|
||||||
allFlows.forEach(workFlow -> workFlow.setWorkStatus(-1)); //暂存状态
|
|
||||||
workFlowService.saveBatch(allFlows);
|
|
||||||
// 更新工单状态
|
// 更新工单状态
|
||||||
// List<String> orderIds = finalWorkFlows.stream().map(WorkFlow::getOrderId).toList();
|
List<String> orderIds = finalWorkFlows.stream().map(WorkFlow::getOrderId).toList();
|
||||||
List<String> orderIds = allFlows.stream().map(WorkFlow::getOrderId).toList();
|
|
||||||
if (!orderIds.isEmpty()) {
|
if (!orderIds.isEmpty()) {
|
||||||
kateOrdersService.update(new LambdaUpdateWrapper<KateOrders>()
|
kateOrdersService.update(new LambdaUpdateWrapper<KateOrders>()
|
||||||
.set(KateOrders::getOrderStatus, 1)
|
.set(KateOrders::getOrderStatus, 1)
|
||||||
|
|
@ -818,8 +771,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
.eq(KateOrders::getOrderStatus, 0));
|
.eq(KateOrders::getOrderStatus, 0));
|
||||||
}
|
}
|
||||||
// 更新dbs表
|
// 更新dbs表
|
||||||
// List<String> workOrderList = finalWorkFlows.stream().map(WorkFlow::getWorkOrder).distinct().toList();
|
List<String> workOrderList = finalWorkFlows.stream().map(WorkFlow::getWorkOrder).distinct().toList();
|
||||||
List<String> workOrderList = allFlows.stream().map(WorkFlow::getWorkOrder).distinct().toList();
|
|
||||||
if (!workOrderList.isEmpty()) {
|
if (!workOrderList.isEmpty()) {
|
||||||
kateDBSService.update(new LambdaUpdateWrapper<KateDBS>()
|
kateDBSService.update(new LambdaUpdateWrapper<KateDBS>()
|
||||||
.set(KateDBS::getDbsStatus, 1)
|
.set(KateDBS::getDbsStatus, 1)
|
||||||
|
|
@ -828,7 +780,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
System.out.println("createTempWorkFlows 成功");
|
System.out.println("createTempWorkFlows 成功");
|
||||||
}
|
}
|
||||||
else{
|
} else {
|
||||||
System.out.println("createTempWorkFlows 为空");
|
System.out.println("createTempWorkFlows 为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -842,58 +794,42 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void distributeWorks(String workStation) {
|
public void distributeWorks(String workStation) {
|
||||||
|
if (workCreatingStations.contains(workStation)) {
|
||||||
|
// 当前站台正在创建任务
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// 添加站台
|
||||||
|
workCreatingStations.add(workStation);
|
||||||
|
}
|
||||||
if (StringUtils.isEmpty(workStation)) {
|
if (StringUtils.isEmpty(workStation)) {
|
||||||
// 站台号为空
|
// 站台号为空
|
||||||
logger.error("站台号为空===》》》》》》");
|
logger.error("站台号为空===》》》》》》");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (workCreatingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
|
||||||
// 当前站台正在创建任务
|
|
||||||
logger.warn("当前站台正常创建任务:{}",workStation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// 获取工作优先级
|
// 获取工作优先级
|
||||||
String workPriority = configMap.get(ConfigMapKeyEnum.WORK_PRIORITY.getConfigKey());
|
String workPriority = configMap.get(ConfigMapKeyEnum.WORK_PRIORITY.getConfigKey());
|
||||||
List<WorkFlow> needDistributeWorks = new ArrayList<>();
|
List<WorkFlow> needDistributeWorks = new ArrayList<>();
|
||||||
List<WorkFlow> commonMwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>());
|
List<WorkFlow> commonMwlWorks = workFlowService.list(new LambdaQueryWrapper<>());
|
||||||
// .eq(WorkFlow::getWorkStation, workStation)
|
int currentWorkType;
|
||||||
// .eq(WorkFlow::getMachineType, 1)
|
List<WorkFlow> doingWorks = filterWorkFlow(commonMwlWorks, workStation, 0, -1, -1);
|
||||||
// .ne(WorkFlow::getWorkStatus, -1));
|
if (!doingWorks.isEmpty()) {
|
||||||
int currentWorkType = -1;
|
// 当前站台还有正在做的工作,不允许再分配新工作
|
||||||
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
|
|
||||||
// 当前工作优先级为先平地机后装载机
|
|
||||||
// 查询当前站台是否还有装载机的任务没做完
|
|
||||||
// List<WorkFlow> oldMwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getWorkStation, workStation)
|
|
||||||
// .eq(WorkFlow::getMachineType, 1)
|
|
||||||
// .ne(WorkFlow::getWorkStatus, -1));
|
|
||||||
//过滤commonMwlWorks 根据workStation和machineType和workStatus=-1 workStation=workStation
|
|
||||||
List<WorkFlow> oldMwlWorks = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
|
||||||
if (!oldMwlWorks.isEmpty()) {
|
|
||||||
// 装载机没做完,不允许做平地机
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 查询已经生成的工作
|
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
|
||||||
// List<WorkFlow> oldWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
// 当前工作优先级为先平地机后装载机
|
||||||
// .eq(WorkFlow::getMachineType, 2)
|
|
||||||
// .eq(WorkFlow::getWorkStatus, -1));
|
|
||||||
//过滤commonMwlWorks 根据machineType=2
|
|
||||||
List<WorkFlow> oldWorkFlows = filterWorkFlow(commonMwlWorks, null, 2, -1, 0);
|
List<WorkFlow> oldWorkFlows = filterWorkFlow(commonMwlWorks, null, 2, -1, 0);
|
||||||
if (oldWorkFlows.isEmpty()) {
|
if (oldWorkFlows.isEmpty()) {
|
||||||
// 判断下是否有平地机任务还未生成
|
// 判断下是否有平地机任务还未生成
|
||||||
List<WorkFlow> notCreatedMGWorks = new ArrayList<>();
|
List<WorkFlow> notCreatedMGWorks = new ArrayList<>();
|
||||||
findWorks("", notCreatedMGWorks, "MG", getCurrentWorkDate());
|
findWorks("", notCreatedMGWorks, "NOT_MWL", getCurrentWorkDate());
|
||||||
if (!notCreatedMGWorks.isEmpty()) {
|
if (!notCreatedMGWorks.isEmpty()) {
|
||||||
// 仍有未生成的平地机任务,跳过
|
// 仍有未生成的平地机任务,跳过
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//过滤commonMwlWorks 根据machineType=2,workStatus=-1 和workStation=1
|
//过滤commonMwlWorks 根据machineType=2,workStatus=-1 和workStation=1
|
||||||
List<WorkFlow> doingMgWorkFlows = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
List<WorkFlow> doingMgWorkFlows = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
||||||
// List<WorkFlow> doingMgWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getWorkStation, workStation)
|
|
||||||
// .eq(WorkFlow::getMachineType, 2)
|
|
||||||
// .ne(WorkFlow::getWorkStatus, -1));
|
|
||||||
if (!doingMgWorkFlows.isEmpty()) {
|
if (!doingMgWorkFlows.isEmpty()) {
|
||||||
// 当前站台平地机正在做
|
// 当前站台平地机正在做
|
||||||
return;
|
return;
|
||||||
|
|
@ -901,9 +837,6 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
// 查询装载机
|
// 查询装载机
|
||||||
//过滤commonMwlWorks 根据machineType=1,workStatus=-1
|
//过滤commonMwlWorks 根据machineType=1,workStatus=-1
|
||||||
List<WorkFlow> mwlWorks = filterWorkFlow(commonMwlWorks, null, 1, -1, 0);
|
List<WorkFlow> mwlWorks = filterWorkFlow(commonMwlWorks, null, 1, -1, 0);
|
||||||
// List<WorkFlow> mwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getMachineType, 1)
|
|
||||||
// .eq(WorkFlow::getWorkStatus, -1));
|
|
||||||
if (mwlWorks.isEmpty()) {
|
if (mwlWorks.isEmpty()) {
|
||||||
// 没有装载机任务,跳过
|
// 没有装载机任务,跳过
|
||||||
return;
|
return;
|
||||||
|
|
@ -916,20 +849,6 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 默认优先级为先装载机后平地机
|
// 默认优先级为先装载机后平地机
|
||||||
// 查询当前站台是否还有平地机的任务没做完
|
|
||||||
//过滤commonMwlWorks 根据machineType=2,workStatus !=-1 和workStation=1
|
|
||||||
List<WorkFlow> oldMgWorks = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
|
||||||
// List<WorkFlow> oldMgWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getWorkStation, workStation)
|
|
||||||
// .eq(WorkFlow::getMachineType, 2)
|
|
||||||
// .ne(WorkFlow::getWorkStatus, -1));
|
|
||||||
if (!oldMgWorks.isEmpty()) {
|
|
||||||
// 平地机没做完,不允许做装载机
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// List<WorkFlow> oldWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getMachineType, 1)
|
|
||||||
// .eq(WorkFlow::getWorkStatus, -1));
|
|
||||||
List<WorkFlow> oldWorkFlows = filterWorkFlow(commonMwlWorks, null, 1, -1, 0);
|
List<WorkFlow> oldWorkFlows = filterWorkFlow(commonMwlWorks, null, 1, -1, 0);
|
||||||
if (oldWorkFlows.isEmpty()) {
|
if (oldWorkFlows.isEmpty()) {
|
||||||
// 判断下是否有装载机任务还未生成
|
// 判断下是否有装载机任务还未生成
|
||||||
|
|
@ -939,19 +858,12 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
// 仍有未生成的装载机任务,跳过
|
// 仍有未生成的装载机任务,跳过
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// List<WorkFlow> doingMwlWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getWorkStation, workStation)
|
|
||||||
// .eq(WorkFlow::getMachineType, 1)
|
|
||||||
// .ne(WorkFlow::getWorkStatus, -1));
|
|
||||||
List<WorkFlow> doingMwlWorkFlows = filterWorkFlow(commonMwlWorks, workStation, 1, -1, -1);
|
List<WorkFlow> doingMwlWorkFlows = filterWorkFlow(commonMwlWorks, workStation, 1, -1, -1);
|
||||||
if (!doingMwlWorkFlows.isEmpty()) {
|
if (!doingMwlWorkFlows.isEmpty()) {
|
||||||
// 当前站台装载机正在做
|
// 当前站台装载机正在做
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 查询平地机
|
// 查询平地机
|
||||||
// List<WorkFlow> mgWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
|
||||||
// .eq(WorkFlow::getMachineType, 2)
|
|
||||||
// .eq(WorkFlow::getWorkStatus, -1));
|
|
||||||
List<WorkFlow> mgWorks = filterWorkFlow(commonMwlWorks, null, 2, -1, 0);
|
List<WorkFlow> mgWorks = filterWorkFlow(commonMwlWorks, null, 2, -1, 0);
|
||||||
if (mgWorks.isEmpty()) {
|
if (mgWorks.isEmpty()) {
|
||||||
// 没有平地机任务,跳过
|
// 没有平地机任务,跳过
|
||||||
|
|
@ -1142,6 +1054,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
.set(WorkFlow::getWorkStation, workStation)
|
.set(WorkFlow::getWorkStation, workStation)
|
||||||
.in(WorkFlow::getWorkFlowId, flowIds));
|
.in(WorkFlow::getWorkFlowId, flowIds));
|
||||||
}
|
}
|
||||||
|
System.out.println("分配站台" + workStation + "工作完成");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("分配站台:{}工作发生异常:{}", workStation, convertJsonString(e));
|
logger.error("分配站台:{}工作发生异常:{}", workStation, convertJsonString(e));
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
|
|
@ -1153,13 +1066,14 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 过滤工作流
|
||||||
*
|
*
|
||||||
* @param workFlows
|
* @param workFlows 工作流
|
||||||
* @param workStation
|
* @param workStation 工作站台
|
||||||
* @param machineType
|
* @param machineType 机型
|
||||||
* @param workStatus
|
* @param workStatus 工作状态
|
||||||
* @param flag 0: eq -1:ne
|
* @param flag 0: eq -1:ne
|
||||||
* @return
|
* @return 过滤后的数据
|
||||||
*/
|
*/
|
||||||
private List<WorkFlow> filterWorkFlow(List<WorkFlow> workFlows, String workStation, int machineType, int workStatus, int flag) {
|
private List<WorkFlow> filterWorkFlow(List<WorkFlow> workFlows, String workStation, int machineType, int workStatus, int flag) {
|
||||||
Stream<WorkFlow> stream = workFlows.stream();
|
Stream<WorkFlow> stream = workFlows.stream();
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,13 @@ spring:
|
||||||
username: developer
|
username: developer
|
||||||
password: developer
|
password: developer
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
#
|
|
||||||
# url: jdbc:mysql://127.0.0.1:3306/wms_szkt?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
|
||||||
# username: root
|
|
||||||
# password: Root123456
|
|
||||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
|
||||||
|
|
||||||
# 宝开服务器--内网
|
# 宝开服务器--内网
|
||||||
# url: jdbc:mysql://192.168.3.254:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
# url: jdbc:mysql://192.168.3.254:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
# username: coder
|
# username: coder
|
||||||
# password: coder
|
# password: coder
|
||||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
## # 本地环境
|
# 本地环境
|
||||||
# url: jdbc:mysql://localhost:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
# url: jdbc:mysql://localhost:3306/wms_kate_suzhou_test?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
# username: root
|
# username: root
|
||||||
# password: liangzhou
|
# password: liangzhou
|
||||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user