|
|
|
|
@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.ehcache.core.util.CollectionUtil; |
|
|
|
|
import org.springblade.common.constant.CommonConstant; |
|
|
|
|
import org.springblade.common.exception.BusinessException; |
|
|
|
|
import org.springblade.common.utils.StringPrefixUtils; |
|
|
|
|
@ -23,9 +24,11 @@ import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.*; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.LocallyPlatedPart; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.UrgentPart; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.WorkCenter; |
|
|
|
|
import org.springblade.desk.basic.service.ILocallyPlatedPartService; |
|
|
|
|
import org.springblade.desk.basic.service.IQualityGradeService; |
|
|
|
|
import org.springblade.desk.basic.service.IUrgentPartService; |
|
|
|
|
import org.springblade.desk.basic.service.IWorkCenterService; |
|
|
|
|
import org.springblade.desk.common.constant.BizTypeConstant; |
|
|
|
|
import org.springblade.desk.common.feign.IMesNotifyMessageClient; |
|
|
|
|
@ -59,6 +62,9 @@ import org.springblade.desk.produce.pojo.entity.WorkOrder; |
|
|
|
|
import org.springblade.erpdata.feign.IErpYieldOrderClient; |
|
|
|
|
import org.springblade.scheduling.pojo.entity.PartRelationEntity; |
|
|
|
|
import org.springblade.scheduling.pojo.entity.QualityGradeEntity; |
|
|
|
|
import org.springblade.system.feign.IUserClient; |
|
|
|
|
import org.springblade.system.pojo.entity.User; |
|
|
|
|
import org.springblade.system.pojo.entity.UserInfo; |
|
|
|
|
import org.springblade.wms.feign.WmsTaskClient; |
|
|
|
|
import org.springblade.wms.pojo.dto.StGraphiteMoldOutDTO; |
|
|
|
|
import org.springblade.wms.pojo.entity.StGraphiteMoldOut; |
|
|
|
|
@ -78,6 +84,7 @@ import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -131,8 +138,9 @@ public class YieldOrderServiceImpl extends BaseServiceImpl<YieldOrderMapper, Yie |
|
|
|
|
@Autowired |
|
|
|
|
private IWorkCenterService workCenterService; |
|
|
|
|
|
|
|
|
|
@Lazy |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@Lazy |
|
|
|
|
private IDsTaskingService dsTaskingService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@ -152,13 +160,79 @@ public class YieldOrderServiceImpl extends BaseServiceImpl<YieldOrderMapper, Yie |
|
|
|
|
@Autowired |
|
|
|
|
private WmsTaskClient wmsTaskClient; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IUrgentPartService urgentPartService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IDsTaskingService taskingService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IUserClient userClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<YieldOrder> selectPage(IPage<YieldOrder> page, YieldOrderDto entity) { |
|
|
|
|
//烧结 热表订单
|
|
|
|
|
List<YieldOrderEnum> yieldTypeList = new ArrayList<>(); |
|
|
|
|
yieldTypeList.add(YieldOrderEnum.getEnum(entity.getYieldType())); |
|
|
|
|
|
|
|
|
|
List<YieldOrder> dataList = baseMapper.selectPage(page, entity, yieldTypeList); |
|
|
|
|
if (CollectionUtils.isNotEmpty(dataList)) { |
|
|
|
|
// 1. 收集所有需要查询的 taskingId
|
|
|
|
|
List<Long> taskingIdList = dataList.stream() |
|
|
|
|
.filter(order -> order.getTaskingId() != null) |
|
|
|
|
.map(YieldOrder::getTaskingId) |
|
|
|
|
.distinct() |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(taskingIdList)) { |
|
|
|
|
// 2. 批量查询任务信息(一次数据库查询)
|
|
|
|
|
List<DsTaskingEntity> taskingList = taskingService.listByIds(taskingIdList); |
|
|
|
|
|
|
|
|
|
// 3. 收集所有需要查询的用户ID,直接转换为逗号分隔的字符串
|
|
|
|
|
String userIdsStr = taskingList.stream() |
|
|
|
|
.filter(tasking -> tasking != null && tasking.getCraftMan() != null) |
|
|
|
|
.map(DsTaskingEntity::getCraftMan) |
|
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
|
.distinct() |
|
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
|
|
|
|
|
|
// 4. 批量查询用户信息(一次远程调用)
|
|
|
|
|
Map<Long, String> userNameMap = new HashMap<>(); |
|
|
|
|
if (StringUtils.isNotBlank(userIdsStr)) { |
|
|
|
|
try { |
|
|
|
|
List<User> userList = userClient.userListByIds(userIdsStr); |
|
|
|
|
if (CollectionUtils.isNotEmpty(userList)) { |
|
|
|
|
userNameMap = userList.stream() |
|
|
|
|
.filter(user -> user != null && user.getId() != null) |
|
|
|
|
.collect(Collectors.toMap( |
|
|
|
|
User::getId, |
|
|
|
|
User::getName, |
|
|
|
|
(v1, v2) -> v1 |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("批量获取用户信息失败", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 5. 构建 tasking 映射
|
|
|
|
|
Map<Long, DsTaskingEntity> taskingMap = taskingList.stream() |
|
|
|
|
.collect(Collectors.toMap(DsTaskingEntity::getId, Function.identity())); |
|
|
|
|
|
|
|
|
|
// 6. 组装数据
|
|
|
|
|
for (YieldOrder yieldOrder : dataList) { |
|
|
|
|
if (yieldOrder.getTaskingId() != null) { |
|
|
|
|
DsTaskingEntity tasking = taskingMap.get(yieldOrder.getTaskingId()); |
|
|
|
|
if (tasking != null && StringUtils.isNotBlank(tasking.getCraftMan())) { |
|
|
|
|
Long userId = Func.toLong(tasking.getCraftMan()); |
|
|
|
|
String userName = userNameMap.get(userId); |
|
|
|
|
if (StringUtils.isNotBlank(userName)) { |
|
|
|
|
yieldOrder.setCraftMan(userName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return page.setRecords(dataList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1429,6 +1503,26 @@ public class YieldOrderServiceImpl extends BaseServiceImpl<YieldOrderMapper, Yie |
|
|
|
|
if ("1".equals(mark)) { |
|
|
|
|
yieldOrder.setSiteWork(true); |
|
|
|
|
} |
|
|
|
|
//校验订单是否是 急件维护
|
|
|
|
|
List<UrgentPart> urgentPartList = urgentPartService.selectByPlanNoAndPartCode(yieldOrder.getYpCode(),yieldOrder.getPartCode()); |
|
|
|
|
boolean isUrgent = false; |
|
|
|
|
if (CollectionUtils.isNotEmpty(urgentPartList)) { |
|
|
|
|
for (UrgentPart urgentPart : urgentPartList) { |
|
|
|
|
// 批次号为空,急件维护
|
|
|
|
|
if (StringUtils.isEmpty(urgentPart.getBatchNo())) { |
|
|
|
|
isUrgent = true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// 批次号不为空,判断是否与订单批次号一致
|
|
|
|
|
if (urgentPart.getBatchNo().equals(yieldOrder.getBatchNo())) { |
|
|
|
|
isUrgent = true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isUrgent) { |
|
|
|
|
yieldOrder.setSiteWork(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 接收订单前置
|
|
|
|
|
yieldOrder.setReceiveTime(new Date()); |
|
|
|
|
|