Commit 660a851527ae52e1de66e62df3285937b72be93c
1 parent
dfa61b7d
✨ feat(mes): 添加物料消耗记录行的请求和响应 VO 及控制器
新增物料消耗记录行的请求和响应数据对象,包含分页请求和响应结构。 同时实现了控制器以支持根据报工编号分页获取消耗行列表的功能。
Showing
7 changed files
with
169 additions
and
10 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemconsume/MesWmItemConsumeLineController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo.MesWmItemConsumeLinePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo.MesWmItemConsumeLineRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | ||
| 12 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | ||
| 13 | +import cn.iocoder.yudao.module.mes.service.wm.itemconsume.MesWmItemConsumeLineService; | ||
| 14 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 16 | +import jakarta.annotation.Resource; | ||
| 17 | +import jakarta.validation.Valid; | ||
| 18 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 19 | +import org.springframework.validation.annotation.Validated; | ||
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 22 | +import org.springframework.web.bind.annotation.RestController; | ||
| 23 | + | ||
| 24 | +import java.util.Map; | ||
| 25 | + | ||
| 26 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 28 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | ||
| 29 | + | ||
| 30 | +@Tag(name = "管理后台 - MES 物料消耗记录行") | ||
| 31 | +@RestController | ||
| 32 | +@RequestMapping("/mes/wm/item-consume-line") | ||
| 33 | +@Validated | ||
| 34 | +public class MesWmItemConsumeLineController { | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private MesWmItemConsumeLineService itemConsumeLineService; | ||
| 38 | + @Resource | ||
| 39 | + private MesMdItemService itemService; | ||
| 40 | + @Resource | ||
| 41 | + private MesMdUnitMeasureService unitMeasureService; | ||
| 42 | + | ||
| 43 | + @GetMapping("/page") | ||
| 44 | + @Operation(summary = "根据报工编号分页获取消耗行列表") | ||
| 45 | + @PreAuthorize("@ss.hasPermission('mes:pro-feedback:query')") | ||
| 46 | + public CommonResult<PageResult<MesWmItemConsumeLineRespVO>> getItemConsumeLinePage( | ||
| 47 | + @Valid MesWmItemConsumeLinePageReqVO pageReqVO) { | ||
| 48 | + // 1. 分页查询消耗行 | ||
| 49 | + PageResult<MesWmItemConsumeLineDO> pageResult = | ||
| 50 | + itemConsumeLineService.getItemConsumeLinePage(pageReqVO); | ||
| 51 | + PageResult<MesWmItemConsumeLineRespVO> voPage = BeanUtils.toBean(pageResult, MesWmItemConsumeLineRespVO.class); | ||
| 52 | + // 2. 拼接物料信息 | ||
| 53 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | ||
| 54 | + convertSet(pageResult.getList(), MesWmItemConsumeLineDO::getItemId)); | ||
| 55 | + Map<Long, MesMdUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap( | ||
| 56 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | ||
| 57 | + for (MesWmItemConsumeLineRespVO vo : voPage.getList()) { | ||
| 58 | + findAndThen(itemMap, vo.getItemId(), item -> { | ||
| 59 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification()); | ||
| 60 | + findAndThen(unitMap, item.getUnitMeasureId(), unit -> vo.setUnitName(unit.getName())); | ||
| 61 | + }); | ||
| 62 | + } | ||
| 63 | + return success(voPage); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemconsume/vo/MesWmItemConsumeLinePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - MES 物料消耗记录行分页 Request VO") | ||
| 10 | +@Data | ||
| 11 | +@EqualsAndHashCode(callSuper = true) | ||
| 12 | +@ToString(callSuper = true) | ||
| 13 | +public class MesWmItemConsumeLinePageReqVO extends PageParam { | ||
| 14 | + | ||
| 15 | + @Schema(description = "报工记录编号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 16 | + private Long feedbackId; | ||
| 17 | + | ||
| 18 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemconsume/vo/MesWmItemConsumeLineRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.math.BigDecimal; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - MES 物料消耗记录行 Response VO") | ||
| 10 | +@Data | ||
| 11 | +public class MesWmItemConsumeLineRespVO { | ||
| 12 | + | ||
| 13 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "消耗记录编号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 17 | + private Long consumeId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 20 | + private Long itemId; | ||
| 21 | + | ||
| 22 | + @Schema(description = "消耗数量", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 23 | + private BigDecimal quantity; | ||
| 24 | + | ||
| 25 | + @Schema(description = "批次编号") | ||
| 26 | + private Long batchId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "批次号") | ||
| 29 | + private String batchCode; | ||
| 30 | + | ||
| 31 | + @Schema(description = "备注") | ||
| 32 | + private String remark; | ||
| 33 | + | ||
| 34 | + @Schema(description = "创建时间") | ||
| 35 | + private LocalDateTime createTime; | ||
| 36 | + | ||
| 37 | + // ==================== 关联信息 ==================== | ||
| 38 | + | ||
| 39 | + @Schema(description = "物资编码") | ||
| 40 | + private String itemCode; | ||
| 41 | + | ||
| 42 | + @Schema(description = "物资名称") | ||
| 43 | + private String itemName; | ||
| 44 | + | ||
| 45 | + @Schema(description = "规格型号") | ||
| 46 | + private String specification; | ||
| 47 | + | ||
| 48 | + @Schema(description = "单位") | ||
| 49 | + private String unitName; | ||
| 50 | + | ||
| 51 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/itemconsume/MesWmItemConsumeLineMapper.java
| 1 | package cn.iocoder.yudao.module.mes.dal.mysql.wm.itemconsume; | 1 | package cn.iocoder.yudao.module.mes.dal.mysql.wm.itemconsume; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo.MesWmItemConsumeLinePageReqVO; | ||
| 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; | 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; |
| 5 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 9 | ||
| 7 | -import java.util.List; | ||
| 8 | - | ||
| 9 | /** | 10 | /** |
| 10 | * MES 物料消耗记录行 Mapper | 11 | * MES 物料消耗记录行 Mapper |
| 11 | * | 12 | * |
| @@ -14,8 +15,11 @@ import java.util.List; | @@ -14,8 +15,11 @@ import java.util.List; | ||
| 14 | @Mapper | 15 | @Mapper |
| 15 | public interface MesWmItemConsumeLineMapper extends BaseMapperX<MesWmItemConsumeLineDO> { | 16 | public interface MesWmItemConsumeLineMapper extends BaseMapperX<MesWmItemConsumeLineDO> { |
| 16 | 17 | ||
| 17 | - default List<MesWmItemConsumeLineDO> selectListByConsumeId(Long consumeId) { | ||
| 18 | - return selectList(MesWmItemConsumeLineDO::getConsumeId, consumeId); | 18 | + default PageResult<MesWmItemConsumeLineDO> selectPage(MesWmItemConsumeLinePageReqVO reqVO, |
| 19 | + Long consumeId) { | ||
| 20 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmItemConsumeLineDO>() | ||
| 21 | + .eq(MesWmItemConsumeLineDO::getConsumeId, consumeId) | ||
| 22 | + .orderByDesc(MesWmItemConsumeLineDO::getId)); | ||
| 19 | } | 23 | } |
| 20 | 24 | ||
| 21 | } | 25 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/itemconsume/MesWmItemConsumeMapper.java
| @@ -12,4 +12,8 @@ import org.apache.ibatis.annotations.Mapper; | @@ -12,4 +12,8 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 12 | @Mapper | 12 | @Mapper |
| 13 | public interface MesWmItemConsumeMapper extends BaseMapperX<MesWmItemConsumeDO> { | 13 | public interface MesWmItemConsumeMapper extends BaseMapperX<MesWmItemConsumeDO> { |
| 14 | 14 | ||
| 15 | + default MesWmItemConsumeDO selectByFeedbackId(Long feedbackId) { | ||
| 16 | + return selectOne(MesWmItemConsumeDO::getFeedbackId, feedbackId); | ||
| 17 | + } | ||
| 18 | + | ||
| 15 | } | 19 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemconsume/MesWmItemConsumeLineService.java
| 1 | package cn.iocoder.yudao.module.mes.service.wm.itemconsume; | 1 | package cn.iocoder.yudao.module.mes.service.wm.itemconsume; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo.MesWmItemConsumeLinePageReqVO; | ||
| 3 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; |
| 4 | 6 | ||
| 5 | import java.util.List; | 7 | import java.util.List; |
| @@ -19,11 +21,11 @@ public interface MesWmItemConsumeLineService { | @@ -19,11 +21,11 @@ public interface MesWmItemConsumeLineService { | ||
| 19 | void createItemConsumeLineBatch(List<MesWmItemConsumeLineDO> lines); | 21 | void createItemConsumeLineBatch(List<MesWmItemConsumeLineDO> lines); |
| 20 | 22 | ||
| 21 | /** | 23 | /** |
| 22 | - * 根据消耗记录编号查询消耗行 | 24 | + * 根据报工记录编号分页查询消耗行 |
| 23 | * | 25 | * |
| 24 | - * @param consumeId 消耗记录编号 | ||
| 25 | - * @return 消耗行列表 | 26 | + * @param pageReqVO 分页查询参数(含 feedbackId) |
| 27 | + * @return 消耗行分页 | ||
| 26 | */ | 28 | */ |
| 27 | - List<MesWmItemConsumeLineDO> getItemConsumeLineListByConsumeId(Long consumeId); | 29 | + PageResult<MesWmItemConsumeLineDO> getItemConsumeLinePage(MesWmItemConsumeLinePageReqVO pageReqVO); |
| 28 | 30 | ||
| 29 | } | 31 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemconsume/MesWmItemConsumeLineServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.wm.itemconsume; | 1 | package cn.iocoder.yudao.module.mes.service.wm.itemconsume; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.itemconsume.vo.MesWmItemConsumeLinePageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeDO; | ||
| 3 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.itemconsume.MesWmItemConsumeLineDO; |
| 4 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.itemconsume.MesWmItemConsumeLineMapper; | 7 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.itemconsume.MesWmItemConsumeLineMapper; |
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.wm.itemconsume.MesWmItemConsumeMapper; | ||
| 5 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 6 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 7 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| @@ -20,14 +24,24 @@ public class MesWmItemConsumeLineServiceImpl implements MesWmItemConsumeLineServ | @@ -20,14 +24,24 @@ public class MesWmItemConsumeLineServiceImpl implements MesWmItemConsumeLineServ | ||
| 20 | @Resource | 24 | @Resource |
| 21 | private MesWmItemConsumeLineMapper itemConsumeLineMapper; | 25 | private MesWmItemConsumeLineMapper itemConsumeLineMapper; |
| 22 | 26 | ||
| 27 | + @Resource | ||
| 28 | + private MesWmItemConsumeMapper itemConsumeMapper; | ||
| 29 | + | ||
| 23 | @Override | 30 | @Override |
| 24 | public void createItemConsumeLineBatch(List<MesWmItemConsumeLineDO> lines) { | 31 | public void createItemConsumeLineBatch(List<MesWmItemConsumeLineDO> lines) { |
| 25 | itemConsumeLineMapper.insertBatch(lines); | 32 | itemConsumeLineMapper.insertBatch(lines); |
| 26 | } | 33 | } |
| 27 | 34 | ||
| 28 | @Override | 35 | @Override |
| 29 | - public List<MesWmItemConsumeLineDO> getItemConsumeLineListByConsumeId(Long consumeId) { | ||
| 30 | - return itemConsumeLineMapper.selectListByConsumeId(consumeId); | 36 | + public PageResult<MesWmItemConsumeLineDO> getItemConsumeLinePage( |
| 37 | + MesWmItemConsumeLinePageReqVO pageReqVO) { | ||
| 38 | + // 1. 先通过 feedbackId 找到消耗头 | ||
| 39 | + MesWmItemConsumeDO consume = itemConsumeMapper.selectByFeedbackId(pageReqVO.getFeedbackId()); | ||
| 40 | + if (consume == null) { | ||
| 41 | + return PageResult.empty(); | ||
| 42 | + } | ||
| 43 | + // 2. 分页查询消耗行 | ||
| 44 | + return itemConsumeLineMapper.selectPage(pageReqVO, consume.getId()); | ||
| 31 | } | 45 | } |
| 32 | 46 | ||
| 33 | } | 47 | } |