|
|
|
|
@ -1,5 +1,16 @@
|
|
|
|
|
package cn.iocoder.yudao.module.mes.service.plan;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.bom.vo.BomRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.bom.BomDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.task.TaskService;
|
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
|
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@ -16,6 +27,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -68,8 +80,36 @@ public class PlanServiceImpl implements PlanService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageResult<PlanDO> getPlanPage(PlanPageReqVO pageReqVO) {
|
|
|
|
|
return planMapper.selectPage(pageReqVO);
|
|
|
|
|
public PageResult<PlanRespVO> getPlanPage(PlanPageReqVO pageReqVO) {
|
|
|
|
|
PageResult<PlanDO> pageResult = planMapper.selectPage(pageReqVO);
|
|
|
|
|
return new PageResult<>(buildVOList(pageResult.getList()),pageResult.getTotal());
|
|
|
|
|
}
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpProductService productService;
|
|
|
|
|
@Resource
|
|
|
|
|
private AdminUserService userService;
|
|
|
|
|
@Resource
|
|
|
|
|
private TaskService taskService;
|
|
|
|
|
private List<PlanRespVO> buildVOList(List<PlanDO> list) {
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
Map<Long, ErpProductDO> map = productService.getProductMap(
|
|
|
|
|
convertSet(list, PlanDO::getProductId));
|
|
|
|
|
Map<Long, AdminUserDO> userMap = userService.getUserMap(
|
|
|
|
|
convertSet(list, PlanDO::getProductionManagerId));
|
|
|
|
|
Map<Long, TaskDO> taskMap = taskService.getMap(
|
|
|
|
|
convertSet(list, PlanDO::getTaskId));
|
|
|
|
|
|
|
|
|
|
return BeanUtils.toBean(list, PlanRespVO.class, item -> {
|
|
|
|
|
MapUtils.findAndThen(map, item.getProductId(),
|
|
|
|
|
product -> item.setProductName(product.getName()));
|
|
|
|
|
|
|
|
|
|
MapUtils.findAndThen(userMap, item.getProductionManagerId(),
|
|
|
|
|
unit -> item.setProductionManager(unit.getNickname()));
|
|
|
|
|
|
|
|
|
|
MapUtils.findAndThen(taskMap, item.getTaskId(),
|
|
|
|
|
task -> item.setTaskCode(task.getCode()));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|