Compare commits
4 Commits
dc71fc95aa
...
691c4234ce
| Author | SHA1 | Date | |
|---|---|---|---|
| 691c4234ce | |||
| fd08a1ce39 | |||
| 0f5cf773ab | |||
| f5b32d31c4 |
|
|
@ -47,9 +47,9 @@ public class JobComponent {
|
||||||
*/
|
*/
|
||||||
private final IWorkService workService;
|
private final IWorkService workService;
|
||||||
|
|
||||||
private boolean isSendingCommonTask = false;
|
private volatile boolean isSendingCommonTask = false;
|
||||||
private boolean isSendingPickOutTask = false;
|
private volatile boolean isSendingPickOutTask = false;
|
||||||
private boolean isSendingPickTask = false;
|
private volatile boolean isSendingPickTask = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向Wcs下发任务
|
* 向Wcs下发任务
|
||||||
|
|
|
||||||
104
src/main/java/com/wms/entity/app/dto/KateOrdersDto.java
Normal file
104
src/main/java/com/wms/entity/app/dto/KateOrdersDto.java
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.wms.entity.app.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @program: wms_server_kate_suzhou
|
||||||
|
* @description:
|
||||||
|
* @author: Tony.wu
|
||||||
|
* @create: 2025-04-14 12:47
|
||||||
|
**/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class KateOrdersDto {
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private String orderId;
|
||||||
|
/**
|
||||||
|
* Order
|
||||||
|
*/
|
||||||
|
private String workOrder;
|
||||||
|
/**
|
||||||
|
* Material
|
||||||
|
*/
|
||||||
|
private String goodsId;
|
||||||
|
/**
|
||||||
|
* Item
|
||||||
|
*/
|
||||||
|
private String item;
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
/**
|
||||||
|
* SLoc
|
||||||
|
*/
|
||||||
|
private String sLoc;
|
||||||
|
/**
|
||||||
|
* Type
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* Status
|
||||||
|
*/
|
||||||
|
private String originStatus;
|
||||||
|
/**
|
||||||
|
* SupplyArea
|
||||||
|
*/
|
||||||
|
private String supplyArea;
|
||||||
|
/**
|
||||||
|
* SortStrng
|
||||||
|
*/
|
||||||
|
private String sortString;
|
||||||
|
/**
|
||||||
|
* Requirement Qty
|
||||||
|
*/
|
||||||
|
private BigDecimal requirementQuantity;
|
||||||
|
/**
|
||||||
|
* BUn
|
||||||
|
*/
|
||||||
|
private String goodsUnit;
|
||||||
|
/**
|
||||||
|
* 工单状态
|
||||||
|
* 0:未开始
|
||||||
|
* 1:已生成任务
|
||||||
|
* 2:已呼叫料箱
|
||||||
|
* 3:正在拣选
|
||||||
|
* 4:拣选完成
|
||||||
|
*/
|
||||||
|
private Integer orderStatus;
|
||||||
|
/**
|
||||||
|
* 缺少数量
|
||||||
|
*/
|
||||||
|
private BigDecimal lackQuantity;
|
||||||
|
/**
|
||||||
|
* 实际拣选数量
|
||||||
|
*/
|
||||||
|
private BigDecimal pickedQuantity;
|
||||||
|
/**
|
||||||
|
* 操作人员
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 完成时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime finishTime;
|
||||||
|
|
||||||
|
private String currentWorkDay;
|
||||||
|
private String workStation;
|
||||||
|
private String smallBox;
|
||||||
|
private String model;
|
||||||
|
private String bigBox;
|
||||||
|
private String configId;
|
||||||
|
private String workCenter;
|
||||||
|
private Integer workSequence;
|
||||||
|
private String dbsId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
package com.wms.mapper;
|
package com.wms.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.wms.entity.app.dto.KateOrdersDto;
|
||||||
import com.wms.entity.table.KateOrders;
|
import com.wms.entity.table.KateOrders;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface KateOrdersMapper extends BaseMapper<KateOrders> {
|
public interface KateOrdersMapper extends BaseMapper<KateOrders> {
|
||||||
|
List<KateOrdersDto> selectCurrentWorkDateKateOrders(KateOrdersDto kateOrders);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
package com.wms.service;
|
package com.wms.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.wms.entity.app.dto.KateOrdersDto;
|
||||||
import com.wms.entity.table.KateOrders;
|
import com.wms.entity.table.KateOrders;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡特工单服务接口
|
* 卡特工单服务接口
|
||||||
*/
|
*/
|
||||||
public interface KateOrdersService extends IService<KateOrders> {
|
public interface KateOrdersService extends IService<KateOrders> {
|
||||||
|
List<KateOrdersDto> selectCurrentWorkDateKateOrders(KateOrdersDto kateOrders);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +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.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.*;
|
||||||
|
|
@ -25,8 +26,11 @@ 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 static com.wms.config.InitLocalConfig.*;
|
import static com.wms.config.InitLocalConfig.*;
|
||||||
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
||||||
|
|
@ -56,9 +60,12 @@ 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;// 料箱服务
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,17 +76,15 @@ 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();
|
||||||
|
|
@ -122,7 +127,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
.orderByAsc(ETagLocation::getSequenceId));
|
.orderByAsc(ETagLocation::getSequenceId));
|
||||||
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
|
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
|
||||||
// 找非MWL机型--先平地机
|
// 找非MWL机型--先平地机
|
||||||
findWorks(workStation, currentStationWorkFlows, "NOT_MWL", currentWorkDate);
|
findWorks(workStation, currentStationWorkFlows, "MG", currentWorkDate);
|
||||||
if (currentStationWorkFlows.isEmpty()) {
|
if (currentStationWorkFlows.isEmpty()) {
|
||||||
findWorks(workStation, currentStationWorkFlows, "MWL", currentWorkDate);
|
findWorks(workStation, currentStationWorkFlows, "MWL", currentWorkDate);
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +136,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
findWorks(workStation, currentStationWorkFlows, "MWL", currentWorkDate);
|
findWorks(workStation, currentStationWorkFlows, "MWL", currentWorkDate);
|
||||||
if (currentStationWorkFlows.isEmpty()) {
|
if (currentStationWorkFlows.isEmpty()) {
|
||||||
// 找非MWL机型
|
// 找非MWL机型
|
||||||
findWorks(workStation, currentStationWorkFlows, "NOT_MWL", currentWorkDate);
|
findWorks(workStation, currentStationWorkFlows, "MG", currentWorkDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,12 +260,9 @@ 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.contains(workStation)) {
|
if (workDoingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
||||||
// 当前站台正在创建任务
|
// 当前站台正在创建任务
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
// 添加站台
|
|
||||||
workDoingStations.add(workStation);
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 查找当前站台未开始的工作流
|
// 查找当前站台未开始的工作流
|
||||||
|
|
@ -447,12 +449,9 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String finishWork(String workStation) {
|
public String finishWork(String workStation) {
|
||||||
if (workFinishingStations.contains(workStation)) {
|
if (workFinishingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
||||||
// 当前站台正在完成工作
|
// 当前站台正在完成工作
|
||||||
return "当前站台正在完成工作,请勿重复操作";
|
return "当前站台正在完成工作,请勿重复操作";
|
||||||
} else {
|
|
||||||
// 添加站台
|
|
||||||
workFinishingStations.add(workStation);
|
|
||||||
}
|
}
|
||||||
String result = "";
|
String result = "";
|
||||||
try {
|
try {
|
||||||
|
|
@ -560,109 +559,161 @@ 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 ->
|
// 生成workFlow
|
||||||
kateWorkOrder.getSupplyArea().equals(workConfig.getSmallBox())).toList();
|
WorkFlow tempWorkFlow = new WorkFlow();
|
||||||
// 当前工位没有未完成的工单
|
tempWorkFlow.setWorkFlowId(WmsUtils.generateId("WORKFLOW_"));
|
||||||
if (kateWorkOrders.isEmpty()) {
|
tempWorkFlow.setOrderId(tempOrder.getOrderId());
|
||||||
continue;
|
if("MWL".equals(model)) {
|
||||||
}
|
tempWorkFlow.setWorkStation(tempOrder.getWorkStation());
|
||||||
List<WorkCenterAndOrderDto> toDaysOrders = new ArrayList<>();
|
}else{
|
||||||
// 防止重复查询
|
tempWorkFlow.setWorkStation(workStation);
|
||||||
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 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的工作日期
|
* 获取当前的工作日期
|
||||||
|
|
@ -678,12 +729,13 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
if (!StringUtils.isEmpty(useSettingDate) && useSettingDate.equals("1")) {
|
if (!StringUtils.isEmpty(useSettingDate) && useSettingDate.equals("1")) {
|
||||||
String settingDate = configMap.get(ConfigMapKeyEnum.SETTING_DATE.getConfigKey());
|
String settingDate = configMap.get(ConfigMapKeyEnum.SETTING_DATE.getConfigKey());
|
||||||
if (!StringUtils.isEmpty(settingDate)) {
|
if (!StringUtils.isEmpty(settingDate)) {
|
||||||
String[] settingDateArray = settingDate.split("-");
|
// String[] settingDateArray = settingDate.split("-");
|
||||||
int settingDateYear = Integer.parseInt(settingDateArray[0]);
|
// int settingDateYear = Integer.parseInt(settingDateArray[0]);
|
||||||
int settingDateMonth = Integer.parseInt(settingDateArray[1]);
|
// int settingDateMonth = Integer.parseInt(settingDateArray[1]);
|
||||||
int settingDateDay = Integer.parseInt(settingDateArray[2]);
|
// int settingDateDay = Integer.parseInt(settingDateArray[2]);
|
||||||
// 系统配置的当前日期
|
// // 系统配置的当前日期
|
||||||
currentWorkDate = LocalDate.of(settingDateYear, settingDateMonth, settingDateDay);
|
// currentWorkDate = LocalDate.of(settingDateYear, settingDateMonth, settingDateDay);
|
||||||
|
currentWorkDate = LocalDate.parse(settingDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -709,10 +761,12 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
findWorks("", thisDayMWLWorks, "MWL", currentWorkDate);
|
findWorks("", thisDayMWLWorks, "MWL", currentWorkDate);
|
||||||
if (!thisDayMWLWorks.isEmpty()) {
|
if (!thisDayMWLWorks.isEmpty()) {
|
||||||
allFlows.addAll(thisDayMWLWorks);
|
allFlows.addAll(thisDayMWLWorks);
|
||||||
|
}else{
|
||||||
|
System.out.println("查询MWL为空");
|
||||||
}
|
}
|
||||||
// 获取到当天所有的平地机工作
|
// 获取到当天所有的平地机工作
|
||||||
List<WorkFlow> thisDayMGWorks = new ArrayList<>();
|
List<WorkFlow> thisDayMGWorks = new ArrayList<>();
|
||||||
findWorks("", thisDayMGWorks, "NOT_MWL", currentWorkDate);
|
findWorks("", thisDayMGWorks, "MG", currentWorkDate);
|
||||||
if (!thisDayMGWorks.isEmpty()) {
|
if (!thisDayMGWorks.isEmpty()) {
|
||||||
allFlows.addAll(thisDayMGWorks);
|
allFlows.addAll(thisDayMGWorks);
|
||||||
// 查询配置是否需要合并第二天的配置
|
// 查询配置是否需要合并第二天的配置
|
||||||
|
|
@ -723,35 +777,41 @@ 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, "NOT_MWL", nextWorkDate);
|
findWorks("", nextDayMGWorks, "MG", nextWorkDate);
|
||||||
}
|
}
|
||||||
if (!nextDayMGWorks.isEmpty()) {
|
if (!nextDayMGWorks.isEmpty()) {
|
||||||
// 添加第二天的平地机工作进汇总
|
// 添加第二天的平地机工作进汇总
|
||||||
allFlows.addAll(nextDayMGWorks);
|
allFlows.addAll(nextDayMGWorks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
System.out.println("查询MG为空");
|
||||||
}
|
}
|
||||||
// 处理这些工作流
|
// 处理这些工作流
|
||||||
List<WorkFlow> oldWorkFlows = workFlowService.list();
|
// List<WorkFlow> oldWorkFlows = workFlowService.list();
|
||||||
// 按照工单号+小盒子号+料号来map一下
|
// // 按照工单号+小盒子号+料号来map一下
|
||||||
Map<String, WorkFlow> oldWorkFlowsMap = oldWorkFlows.stream().collect(
|
// Map<String, WorkFlow> oldWorkFlowsMap = oldWorkFlows.stream().collect(
|
||||||
Collectors.toMap(workFlow ->
|
// Collectors.toMap(workFlow ->
|
||||||
workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId(), workFlow -> workFlow));
|
// workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId(), workFlow -> workFlow));
|
||||||
// 最后需要存储的工作
|
// 最后需要存储的工作
|
||||||
List<WorkFlow> finalWorkFlows = new ArrayList<>();
|
// List<WorkFlow> finalWorkFlows = new ArrayList<>();
|
||||||
for (WorkFlow workFlow : allFlows) {
|
// for (WorkFlow workFlow : allFlows) {
|
||||||
String key = workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId();
|
// String key = workFlow.getWorkOrder() + "_" + workFlow.getWorkCenter() + "_" + workFlow.getGoodsId();
|
||||||
if (oldWorkFlowsMap.containsKey(key)) {
|
// if (oldWorkFlowsMap.containsKey(key)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
workFlow.setWorkStatus(-1);// 设置暂存状态
|
// workFlow.setWorkStatus(-1);// 设置暂存状态
|
||||||
finalWorkFlows.add(workFlow);
|
// finalWorkFlows.add(workFlow);
|
||||||
}
|
// }
|
||||||
if (!finalWorkFlows.isEmpty()) {
|
// if (!finalWorkFlows.isEmpty()) {
|
||||||
|
if (!allFlows.isEmpty()) {
|
||||||
// 存储数据
|
// 存储数据
|
||||||
workFlowService.saveBatch(finalWorkFlows);
|
//设置allFlows的workStatus=-1
|
||||||
|
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)
|
||||||
|
|
@ -759,14 +819,20 @@ 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)
|
||||||
.in(KateDBS::getWorkOrder, workOrderList)
|
.in(KateDBS::getWorkOrder, workOrderList)
|
||||||
.eq(KateDBS::getDbsStatus, 0));
|
.eq(KateDBS::getDbsStatus, 0));
|
||||||
}
|
}
|
||||||
|
System.out.println("createTempWorkFlows 成功");
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("createTempWorkFlows 为空");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -777,56 +843,67 @@ 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("站台号为空===》》》》》》");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (workCreatingStations.putIfAbsent(workStation, Boolean.TRUE) != null) {
|
||||||
|
// 当前站台正在创建任务
|
||||||
|
logger.warn("当前站台正常创建任务:{}",workStation);
|
||||||
return;
|
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>());
|
||||||
|
// .eq(WorkFlow::getWorkStation, workStation)
|
||||||
|
// .eq(WorkFlow::getMachineType, 1)
|
||||||
|
// .ne(WorkFlow::getWorkStatus, -1));
|
||||||
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
|
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
|
||||||
// 当前工作优先级为先平地机后装载机
|
// 当前工作优先级为先平地机后装载机
|
||||||
// 查询当前站台是否还有装载机的任务没做完
|
// 查询当前站台是否还有装载机的任务没做完
|
||||||
List<WorkFlow> oldMwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
// List<WorkFlow> oldMwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.eq(WorkFlow::getWorkStation, workStation)
|
// .eq(WorkFlow::getWorkStation, workStation)
|
||||||
.eq(WorkFlow::getMachineType, 1)
|
// .eq(WorkFlow::getMachineType, 1)
|
||||||
.ne(WorkFlow::getWorkStatus, -1));
|
// .ne(WorkFlow::getWorkStatus, -1));
|
||||||
|
//过滤commonMwlWorks 根据workStation和machineType和workStatus=-1 workStation=workStation
|
||||||
|
List<WorkFlow> oldMwlWorks = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
||||||
if (!oldMwlWorks.isEmpty()) {
|
if (!oldMwlWorks.isEmpty()) {
|
||||||
// 装载机没做完,不允许做平地机
|
// 装载机没做完,不允许做平地机
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 查询已经生成的工作
|
// 查询已经生成的工作
|
||||||
List<WorkFlow> oldWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
// List<WorkFlow> oldWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.eq(WorkFlow::getMachineType, 2)
|
// .eq(WorkFlow::getMachineType, 2)
|
||||||
.eq(WorkFlow::getWorkStatus, -1));
|
// .eq(WorkFlow::getWorkStatus, -1));
|
||||||
|
//过滤commonMwlWorks 根据machineType=2
|
||||||
|
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, "NOT_MWL", getCurrentWorkDate());
|
findWorks("", notCreatedMGWorks, "MG", getCurrentWorkDate());
|
||||||
if (!notCreatedMGWorks.isEmpty()) {
|
if (!notCreatedMGWorks.isEmpty()) {
|
||||||
// 仍有未生成的平地机任务,跳过
|
// 仍有未生成的平地机任务,跳过
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<WorkFlow> doingMgWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
//过滤commonMwlWorks 根据machineType=2,workStatus=-1 和workStation=1
|
||||||
.eq(WorkFlow::getWorkStation, workStation)
|
List<WorkFlow> doingMgWorkFlows = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
||||||
.eq(WorkFlow::getMachineType, 2)
|
// List<WorkFlow> doingMgWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.ne(WorkFlow::getWorkStatus, -1));
|
// .eq(WorkFlow::getWorkStation, workStation)
|
||||||
|
// .eq(WorkFlow::getMachineType, 2)
|
||||||
|
// .ne(WorkFlow::getWorkStatus, -1));
|
||||||
if (!doingMgWorkFlows.isEmpty()) {
|
if (!doingMgWorkFlows.isEmpty()) {
|
||||||
// 当前站台平地机正在做
|
// 当前站台平地机正在做
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 查询装载机
|
// 查询装载机
|
||||||
List<WorkFlow> mwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
//过滤commonMwlWorks 根据machineType=1,workStatus=-1
|
||||||
.eq(WorkFlow::getMachineType, 1)
|
List<WorkFlow> mwlWorks = filterWorkFlow(commonMwlWorks, null, 1, -1, 0);
|
||||||
.eq(WorkFlow::getWorkStatus, -1));
|
// List<WorkFlow> mwlWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
|
// .eq(WorkFlow::getMachineType, 1)
|
||||||
|
// .eq(WorkFlow::getWorkStatus, -1));
|
||||||
if (mwlWorks.isEmpty()) {
|
if (mwlWorks.isEmpty()) {
|
||||||
// 没有装载机任务,跳过
|
// 没有装载机任务,跳过
|
||||||
return;
|
return;
|
||||||
|
|
@ -838,17 +915,20 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
} else {
|
} else {
|
||||||
// 默认优先级为先装载机后平地机
|
// 默认优先级为先装载机后平地机
|
||||||
// 查询当前站台是否还有平地机的任务没做完
|
// 查询当前站台是否还有平地机的任务没做完
|
||||||
List<WorkFlow> oldMgWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
//过滤commonMwlWorks 根据machineType=2,workStatus !=-1 和workStation=1
|
||||||
.eq(WorkFlow::getWorkStation, workStation)
|
List<WorkFlow> oldMgWorks = filterWorkFlow(commonMwlWorks, workStation, 2, -1, -1);
|
||||||
.eq(WorkFlow::getMachineType, 2)
|
// List<WorkFlow> oldMgWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.ne(WorkFlow::getWorkStatus, -1));
|
// .eq(WorkFlow::getWorkStation, workStation)
|
||||||
|
// .eq(WorkFlow::getMachineType, 2)
|
||||||
|
// .ne(WorkFlow::getWorkStatus, -1));
|
||||||
if (!oldMgWorks.isEmpty()) {
|
if (!oldMgWorks.isEmpty()) {
|
||||||
// 平地机没做完,不允许做装载机
|
// 平地机没做完,不允许做装载机
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<WorkFlow> oldWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
// List<WorkFlow> oldWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.eq(WorkFlow::getMachineType, 1)
|
// .eq(WorkFlow::getMachineType, 1)
|
||||||
.eq(WorkFlow::getWorkStatus, -1));
|
// .eq(WorkFlow::getWorkStatus, -1));
|
||||||
|
List<WorkFlow> oldWorkFlows = filterWorkFlow(commonMwlWorks, null, 1, -1, 0);
|
||||||
if (oldWorkFlows.isEmpty()) {
|
if (oldWorkFlows.isEmpty()) {
|
||||||
// 判断下是否有装载机任务还未生成
|
// 判断下是否有装载机任务还未生成
|
||||||
List<WorkFlow> notCreatedMWLWorks = new ArrayList<>();
|
List<WorkFlow> notCreatedMWLWorks = new ArrayList<>();
|
||||||
|
|
@ -857,18 +937,20 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
// 仍有未生成的装载机任务,跳过
|
// 仍有未生成的装载机任务,跳过
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<WorkFlow> doingMwlWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
// List<WorkFlow> doingMwlWorkFlows = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.eq(WorkFlow::getWorkStation, workStation)
|
// .eq(WorkFlow::getWorkStation, workStation)
|
||||||
.eq(WorkFlow::getMachineType, 1)
|
// .eq(WorkFlow::getMachineType, 1)
|
||||||
.ne(WorkFlow::getWorkStatus, -1));
|
// .ne(WorkFlow::getWorkStatus, -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>()
|
// List<WorkFlow> mgWorks = workFlowService.list(new LambdaQueryWrapper<WorkFlow>()
|
||||||
.eq(WorkFlow::getMachineType, 2)
|
// .eq(WorkFlow::getMachineType, 2)
|
||||||
.eq(WorkFlow::getWorkStatus, -1));
|
// .eq(WorkFlow::getWorkStatus, -1));
|
||||||
|
List<WorkFlow> mgWorks = filterWorkFlow(commonMwlWorks, null, 2, -1, 0);
|
||||||
if (mgWorks.isEmpty()) {
|
if (mgWorks.isEmpty()) {
|
||||||
// 没有平地机任务,跳过
|
// 没有平地机任务,跳过
|
||||||
return;
|
return;
|
||||||
|
|
@ -1057,6 +1139,37 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param workFlows
|
||||||
|
* @param workStation
|
||||||
|
* @param machineType
|
||||||
|
* @param workStatus
|
||||||
|
* @param flag 0: eq -1:ne
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<WorkFlow> filterWorkFlow(List<WorkFlow> workFlows,String workStation,int machineType,int workStatus,int flag){
|
||||||
|
Stream<WorkFlow> stream = workFlows.stream();
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(workStation)) {
|
||||||
|
stream = stream.filter(workFlow -> workFlow.getWorkStation().equals(workStation));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (machineType > 0) {
|
||||||
|
stream = stream.filter(workFlow -> workFlow.getMachineType().equals(machineType));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workStatus != 0) {
|
||||||
|
if (flag == 0) {
|
||||||
|
stream = stream.filter(workFlow -> workFlow.getWorkStatus().equals(workStatus));
|
||||||
|
} else {
|
||||||
|
stream = stream.filter(workFlow -> !workFlow.getWorkStatus().equals(workStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新版开始工作
|
* 新版开始工作
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wms.service.serviceImplements;
|
package com.wms.service.serviceImplements;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.wms.entity.app.dto.KateOrdersDto;
|
||||||
import com.wms.entity.table.KateOrders;
|
import com.wms.entity.table.KateOrders;
|
||||||
import com.wms.mapper.KateOrdersMapper;
|
import com.wms.mapper.KateOrdersMapper;
|
||||||
import com.wms.service.KateOrdersService;
|
import com.wms.service.KateOrdersService;
|
||||||
|
|
@ -8,10 +9,23 @@ import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡特工单服务实现
|
* 卡特工单服务实现
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
public class KateOrdersServiceImpl extends ServiceImpl<KateOrdersMapper, KateOrders> implements KateOrdersService {
|
public class KateOrdersServiceImpl extends ServiceImpl<KateOrdersMapper, KateOrders> implements KateOrdersService {
|
||||||
|
private final KateOrdersMapper kateOrdersMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算当天的工单
|
||||||
|
* @param kateOrders
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<KateOrdersDto> selectCurrentWorkDateKateOrders(KateOrdersDto kateOrders) {
|
||||||
|
return kateOrdersMapper.selectCurrentWorkDateKateOrders(kateOrders);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,56 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.wms.mapper.KateOrdersMapper">
|
<mapper namespace="com.wms.mapper.KateOrdersMapper">
|
||||||
|
<select id="selectCurrentWorkDateKateOrders" parameterType="com.wms.entity.app.dto.KateOrdersDto" resultType="com.wms.entity.app.dto.KateOrdersDto">
|
||||||
|
SELECT
|
||||||
|
ko.order_id as orderId,
|
||||||
|
ko.work_order as workOrder,
|
||||||
|
ko.goods_id as goodsId,
|
||||||
|
ko.item as item,
|
||||||
|
ko.description as description,
|
||||||
|
ko.s_loc as sLoc,
|
||||||
|
ko.type as type,
|
||||||
|
ko.origin_status as originStatus,
|
||||||
|
ko.supply_area as supplyArea,
|
||||||
|
ko.sort_string as sortString,
|
||||||
|
ko.requirement_quantity as requirementQuantity,
|
||||||
|
ko.goods_unit as goodsUnit,
|
||||||
|
ko.order_status as orderStatus,
|
||||||
|
ko.lack_quantity as lackQuantity,
|
||||||
|
ko.picked_quantity as pickedQuantity,
|
||||||
|
kd.dbs_id as dbsId,
|
||||||
|
kd.work_sequence as workSequence,
|
||||||
|
wsc.small_box as smallBox,
|
||||||
|
wsc.work_station as workStation,
|
||||||
|
wsc.big_box as bigBox,
|
||||||
|
wsc.model as model,
|
||||||
|
wsc.config_id as configId,
|
||||||
|
wsc.work_center as workCenter
|
||||||
|
FROM
|
||||||
|
tbl_app_kate_orders ko
|
||||||
|
INNER JOIN tbl_app_kate_dbs kd ON ko.work_order = kd.work_order
|
||||||
|
INNER JOIN tbl_app_work_station_config wsc ON ko.supply_area = wsc.small_box
|
||||||
|
WHERE
|
||||||
|
ko.order_status = 0
|
||||||
|
AND kd.dbs_status = 0
|
||||||
|
AND ko.sort_string = #{sortString}
|
||||||
|
<if test="workStation != null and workStation != ''">
|
||||||
|
and wsc.work_station = #{workStation}
|
||||||
|
</if>
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM tbl_app_work_flow wf
|
||||||
|
WHERE ko.order_id = wf.order_id
|
||||||
|
)
|
||||||
|
AND DATE(
|
||||||
|
CASE
|
||||||
|
WHEN wsc.start_date_adjust < 0 THEN
|
||||||
|
DATE_ADD(kd.plan_start_date, INTERVAL wsc.start_date_adjust DAY)
|
||||||
|
WHEN wsc.start_date_adjust > 0 THEN
|
||||||
|
DATE_ADD(kd.plan_start_date, INTERVAL wsc.start_date_adjust DAY)
|
||||||
|
ELSE
|
||||||
|
kd.plan_start_date
|
||||||
|
END
|
||||||
|
) = DATE(#{currentWorkDay})
|
||||||
|
order by wsc.small_box asc,kd.work_sequence asc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user