|
|
|
@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.deviceledger.DeviceLedgerMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.paigongrecord.PaigongRecordMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.paigongrecord.PaigongRecordMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.stockindetail.StockInDetailMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.stockindetail.StockInDetailMapper;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.mysql.task.TaskMapper;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.redis.no.MesNoRedisDAO;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemAnalysisService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemAnalysisService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemRequisitionService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemRequisitionService;
|
|
|
|
@ -37,6 +38,7 @@ import cn.iocoder.yudao.module.mes.service.itemrequisition.entity.ItemRequisitio
|
|
|
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.paigongrecord.PaigongRecordService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.paigongrecord.PaigongRecordService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.task.TaskService;
|
|
|
|
import cn.iocoder.yudao.module.mes.service.task.TaskService;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
@ -107,6 +109,9 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
@Lazy
|
|
|
|
@Lazy
|
|
|
|
private ErpProductService erpProductService;
|
|
|
|
private ErpProductService erpProductService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
@Lazy
|
|
|
|
|
|
|
|
private TaskMapper taskMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -286,11 +291,30 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PlanRespVO getPlanRespVO(PlanDO planDO) {
|
|
|
|
public PlanRespVO getPlanRespVO(PlanDO planDO) {
|
|
|
|
PlanRespVO planRespVO = BeanUtils.toBean(planDO, PlanRespVO.class);
|
|
|
|
PlanRespVO planRespVO = BeanUtils.toBean(planDO, PlanRespVO.class);
|
|
|
|
planRespVO.setProductName(productService.getProduct(planDO.getProductId()).getName());
|
|
|
|
|
|
|
|
planRespVO.setTaskCode(taskService.getTask(planDO.getTaskId()).getCode());
|
|
|
|
if (planDO.getProductId() != null) {
|
|
|
|
planRespVO.setWorker(userService.getUser(planDO.getWorkerId()).getUsername());
|
|
|
|
ErpProductDO product = productService.getProduct(planDO.getProductId());
|
|
|
|
planRespVO.setFeedingPipelineName(organizationService.getOrganization(planDO.getFeedingPipeline()).getName());
|
|
|
|
planRespVO.setProductName(product == null ? null : product.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (planDO.getTaskId() != null) {
|
|
|
|
|
|
|
|
TaskDO task = taskService.getTask(planDO.getTaskId());
|
|
|
|
|
|
|
|
planRespVO.setTaskCode(task == null ? null : task.getCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (planDO.getWorkerId() != null) {
|
|
|
|
|
|
|
|
AdminUserDO user = userService.getUser(planDO.getWorkerId());
|
|
|
|
|
|
|
|
planRespVO.setWorker(user == null ? null : user.getUsername());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
planRespVO.setWorker(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (planDO.getFeedingPipeline() != null) {
|
|
|
|
|
|
|
|
OrganizationDO organization = organizationService.getOrganization(planDO.getFeedingPipeline());
|
|
|
|
|
|
|
|
planRespVO.setFeedingPipelineName(organization == null ? null : organization.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return planRespVO;
|
|
|
|
return planRespVO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -538,14 +562,24 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
|
|
|
|
|
|
|
Set<Long> deviceIds = planList.stream().map(PlanDO::getDeviceId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
|
Set<Long> deviceIds = planList.stream().map(PlanDO::getDeviceId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
|
Set<Long> productIds = planList.stream().map(PlanDO::getProductId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
|
Set<Long> productIds = planList.stream().map(PlanDO::getProductId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
Set<Long> taskIds = planList.stream().map(PlanDO::getTaskId).filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, DeviceLedgerDO> deviceMap = deviceLedgerMapper.selectBatchIds(deviceIds).stream()
|
|
|
|
Map<Long, DeviceLedgerDO> deviceMap = deviceLedgerMapper.selectBatchIds(deviceIds).stream()
|
|
|
|
.collect(Collectors.toMap(DeviceLedgerDO::getId, d -> d, (a, b) -> a));
|
|
|
|
.collect(Collectors.toMap(DeviceLedgerDO::getId, d -> d, (a, b) -> a));
|
|
|
|
Map<Long, ErpProductDO> productMap = erpProductService.getProductMap(productIds);
|
|
|
|
Map<Long, ErpProductDO> productMap = erpProductService.getProductMap(productIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, String> taskCodeMap = CollUtil.isEmpty(taskIds)
|
|
|
|
|
|
|
|
? Collections.emptyMap()
|
|
|
|
|
|
|
|
: taskMapper.selectBatchIds(taskIds).stream()
|
|
|
|
|
|
|
|
.collect(Collectors.toMap(TaskDO::getId, TaskDO::getCode, (a, b) -> a));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, List<PlanDO>> group = planList.stream()
|
|
|
|
Map<Long, List<PlanDO>> group = planList.stream()
|
|
|
|
.collect(Collectors.groupingBy(PlanDO::getDeviceId, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
.collect(Collectors.groupingBy(PlanDO::getDeviceId, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<DevicePlanGanttRespVO> result = new ArrayList<>();
|
|
|
|
List<DevicePlanGanttRespVO> result = new ArrayList<>();
|
|
|
|
for (Map.Entry<Long, List<PlanDO>> entry : group.entrySet()) {
|
|
|
|
for (Map.Entry<Long, List<PlanDO>> entry : group.entrySet()) {
|
|
|
|
Long deviceId = entry.getKey();
|
|
|
|
Long deviceId = entry.getKey();
|
|
|
|
@ -557,9 +591,13 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
vo.setDeviceCode(device == null ? null : device.getDeviceCode());
|
|
|
|
vo.setDeviceCode(device == null ? null : device.getDeviceCode());
|
|
|
|
|
|
|
|
|
|
|
|
List<DevicePlanGanttRespVO.PlanItem> plans = new ArrayList<>();
|
|
|
|
List<DevicePlanGanttRespVO.PlanItem> plans = new ArrayList<>();
|
|
|
|
|
|
|
|
DateTimeFormatter DATETIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
for (PlanDO plan : entry.getValue()) {
|
|
|
|
for (PlanDO plan : entry.getValue()) {
|
|
|
|
DevicePlanGanttRespVO.PlanItem item = new DevicePlanGanttRespVO.PlanItem();
|
|
|
|
DevicePlanGanttRespVO.PlanItem item = new DevicePlanGanttRespVO.PlanItem();
|
|
|
|
item.setPlanId(plan.getId());
|
|
|
|
item.setPlanId(plan.getId());
|
|
|
|
|
|
|
|
item.setPlanCode(plan.getCode());
|
|
|
|
|
|
|
|
item.setTaskCode(taskCodeMap.get(plan.getTaskId()));
|
|
|
|
item.setPlanStartTime(plan.getPlanStartTime());
|
|
|
|
item.setPlanStartTime(plan.getPlanStartTime());
|
|
|
|
item.setPlanEndTime(plan.getPlanEndTime());
|
|
|
|
item.setPlanEndTime(plan.getPlanEndTime());
|
|
|
|
item.setLatestStartTime(plan.getLatestStartTime()); // 前提:PlanDO已加该字段
|
|
|
|
item.setLatestStartTime(plan.getLatestStartTime()); // 前提:PlanDO已加该字段
|
|
|
|
@ -569,6 +607,11 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
item.setDeviceName(device == null ? null : device.getDeviceName());
|
|
|
|
item.setDeviceName(device == null ? null : device.getDeviceName());
|
|
|
|
item.setProductCode(product == null ? null : product.getBarCode());
|
|
|
|
item.setProductCode(product == null ? null : product.getBarCode());
|
|
|
|
item.setDeviceCode(device == null ? null : device.getDeviceCode());
|
|
|
|
item.setDeviceCode(device == null ? null : device.getDeviceCode());
|
|
|
|
|
|
|
|
item.setSourceType("HISTORY");
|
|
|
|
|
|
|
|
item.setPlanStartTimeStr(plan.getPlanStartTime().format(DATETIME_FMT));
|
|
|
|
|
|
|
|
item.setPlanEndTimeStr(plan.getPlanEndTime().format(DATETIME_FMT));
|
|
|
|
|
|
|
|
item.setLatestStartTimeStr(plan.getLatestStartTime().format(DATETIME_FMT));
|
|
|
|
|
|
|
|
|
|
|
|
plans.add(item);
|
|
|
|
plans.add(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vo.setPlans(plans);
|
|
|
|
vo.setPlans(plans);
|
|
|
|
|