add plan 关联

plp
chenshuichuan 2 years ago
parent 57d7761e72
commit ca5cfa720b

@ -61,7 +61,6 @@ public class AutocodePartSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
}

@ -93,7 +93,7 @@ public class DeviceSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "数采设备类型", example = "2")

@ -34,7 +34,7 @@ public class FormulaSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
}

@ -28,7 +28,7 @@ public class GatewaySaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "网关编码")

@ -30,7 +30,7 @@ public class KanbanSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
}

@ -34,6 +34,11 @@
<artifactId>yudao-module-erp-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-biz</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>

@ -39,7 +39,7 @@ public class BomSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "产品BOM明细列表")

@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDetailDO;
@ -22,10 +23,10 @@ public class ItemRequisitionSaveReqVO {
private String code;
@Schema(description = "下料时间")
private LocalDate requisitionDate;
private LocalDateTime requisitionDate;
@Schema(description = "领料时间")
private LocalDate deliveryDate;
private LocalDateTime deliveryDate;
@Schema(description = "状态", example = "2")
private Integer status;
@ -41,7 +42,6 @@ public class ItemRequisitionSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "领料明细列表")

@ -38,7 +38,7 @@ public class OrganizationSaveReqVO {
private String email;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "组织状态", example = "1")

@ -74,8 +74,8 @@ public class PlanController {
@Operation(summary = "获得生产计划分页")
@PreAuthorize("@ss.hasPermission('mes:plan:query')")
public CommonResult<PageResult<PlanRespVO>> getPlanPage(@Valid PlanPageReqVO pageReqVO) {
PageResult<PlanDO> pageResult = planService.getPlanPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PlanRespVO.class));
PageResult<PlanRespVO> pageResult = planService.getPlanPage(pageReqVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@ -85,10 +85,9 @@ public class PlanController {
public void exportPlanExcel(@Valid PlanPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PlanDO> list = planService.getPlanPage(pageReqVO).getList();
List<PlanRespVO> list = planService.getPlanPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "生产计划.xls", "数据", PlanRespVO.class,
BeanUtils.toBean(list, PlanRespVO.class));
ExcelUtils.write(response, "生产计划.xls", "数据", PlanRespVO.class, list);
}
}

@ -24,8 +24,9 @@ public class PlanRespVO {
private String code;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21176")
@ExcelProperty("产品ID")
private Long productId;
@ExcelProperty("产品")
private String productName;
@Schema(description = "任务单明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18938")
@ExcelProperty("任务单明细ID")
@ -34,6 +35,9 @@ public class PlanRespVO {
@Schema(description = "任务单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18331")
@ExcelProperty("任务单ID")
private Long taskId;
@Schema(description = "任务单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18331")
@ExcelProperty("任务单ID")
private String taskCode;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("数量")
@ -65,8 +69,10 @@ public class PlanRespVO {
private LocalDateTime endTime;
@Schema(description = "生产主管ID", example = "10640")
@ExcelProperty("生产主管ID")
private Long productionManagerId;
@Schema(description = "生产主管", example = "10640")
@ExcelProperty("生产主管")
private String productionManager;
@Schema(description = "备注", example = "你说的对")
@ExcelProperty("备注")

@ -29,7 +29,7 @@ public class PlanSaveReqVO {
private Long taskId;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "数量不能为空")
@NotNull(message = "计划数量不能为空")
private Long planNumber;
@Schema(description = "成品数量")
@ -48,11 +48,9 @@ public class PlanSaveReqVO {
private LocalDateTime planEndTime;
@Schema(description = "实际开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "实际开始时间不能为空")
private LocalDateTime startTime;
@Schema(description = "实际结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "实际结束时间不能为空")
private LocalDateTime endTime;
@Schema(description = "生产主管ID", example = "10640")

@ -20,7 +20,6 @@ public class ProduceReportDetailSaveReqVO {
private Long reportId;
@Schema(description = "生产计划ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "22861")
@NotNull(message = "生产计划ID不能为空")
private Long planId;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14517")
@ -28,17 +27,15 @@ public class ProduceReportDetailSaveReqVO {
private Long productId;
@Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "23386")
@NotNull(message = "用户ID不能为空")
private Long userId;
@Schema(description = "组织ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1329")
@NotNull(message = "组织ID不能为空")
private Long orgId;
@Schema(description = "成品率")
private BigDecimal qualityRate;
@Schema(description = "备注", example = "不好")
@Schema(description = "废品原因", example = "不好")
private String wasteReason;
@Schema(description = "总时长")
@ -51,7 +48,6 @@ public class ProduceReportDetailSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "成品数量")

@ -42,7 +42,7 @@ public class ProduceReportSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
}

@ -45,7 +45,7 @@ public class TaskSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "生产任务单明细列表")

@ -26,7 +26,7 @@ public class WorkTeamSaveReqVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
}

@ -49,6 +49,6 @@ public interface PlanService {
* @param pageReqVO
* @return
*/
PageResult<PlanDO> getPlanPage(PlanPageReqVO pageReqVO);
PageResult<PlanRespVO> getPlanPage(PlanPageReqVO pageReqVO);
}

@ -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()));
});
}
}

@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.mes.service.task;
import java.util.*;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import javax.validation.Valid;
@ -45,6 +49,19 @@ public interface TaskService {
* @return
*/
TaskDO getTask(Long id);
/**
* Map
*
* @param ids
* @return Map
*/
default Map<Long, TaskDO> getMap(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return new HashMap<>();
}
return CollectionUtils.convertMap(getTaskList(ids), TaskDO::getId);
}
List<TaskDO> getTaskList(Collection<Long> ids);
/**
*

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import cn.iocoder.yudao.module.mes.controller.admin.bom.vo.BomDetailRespVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.bom.BomDetailDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
@ -86,7 +87,13 @@ public class TaskServiceImpl implements TaskService {
throw exception(TASK_NOT_EXISTS);
}
}
@Override
public List<TaskDO> getTaskList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return taskMapper.selectBatchIds(ids);
}
@Override
public TaskDO getTask(Long id) {
return taskMapper.selectById(id);

@ -174,7 +174,7 @@ public class PlanServiceImplTest extends BaseDbUnitTest {
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
PageResult<PlanDO> pageResult = planService.getPlanPage(reqVO);
PageResult<PlanRespVO> pageResult = planService.getPlanPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());

Loading…
Cancel
Save