diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java index 604cea91e..0a39d3189 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java @@ -99,6 +99,8 @@ public interface ErpProductMapper extends BaseMapperX { return selectList(new LambdaQueryWrapperX().in(ErpProductDO::getName, names)); } + List selectListByIdsWithDeleted(@Param("ids") Collection ids); + List selectDevicesByProductId(@Param("productId") Long productId); List selectMoldsByProductId(@Param("productId") Long productId); diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java index 35f9facb2..9ed46431f 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java @@ -349,7 +349,7 @@ public class ErpProductServiceImpl implements ErpProductService { if (CollUtil.isEmpty(ids)) { return Collections.emptyList(); } - List list = productMapper.selectBatchIds(ids); + List list = productMapper.selectListByIdsWithDeleted(ids); return buildProductVOList(list); } @@ -376,6 +376,9 @@ public class ErpProductServiceImpl implements ErpProductService { subCategory -> product.setSubCategoryName(subCategory.getName())); MapUtils.findAndThen(unitMap, product.getUnitId(), unit -> product.setUnitName(unit.getName())); + if (Boolean.TRUE.equals(product.getDeleted())) { + product.setName(product.getName() + "(已被删除)"); + } }); } @@ -539,4 +542,4 @@ public class ErpProductServiceImpl implements ErpProductService { return productDO; } -} \ No newline at end of file +} diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/product/ErpProductMapper.xml b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/product/ErpProductMapper.xml index bbcac762e..78c34dd1f 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/product/ErpProductMapper.xml +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/resources/mapper/product/ErpProductMapper.xml @@ -8,6 +8,17 @@ 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> + + - \ No newline at end of file + diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/ZjSchemaController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/ZjSchemaController.java index 01ad5287f..d31634982 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/ZjSchemaController.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/ZjSchemaController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.controller.admin.zjschema; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; import cn.iocoder.yudao.module.mes.controller.admin.zjitem.vo.ZjItemRespVO; @@ -55,6 +56,8 @@ public class ZjSchemaController { private ZjTypeService zjTypeService; @Resource private ErpProductUnitService productUnitService; + @Resource + private ErpProductService erpProductService; @PostMapping("/create") @Operation(summary = "创建检验方案") @@ -86,7 +89,7 @@ public class ZjSchemaController { @PreAuthorize("@ss.hasPermission('mes:zj-schema:query')") public CommonResult getZjSchema(@RequestParam("id") Long id) { ZjSchemaDO zjSchema = zjSchemaService.getZjSchema(id); - return success(BeanUtils.toBean(zjSchema, ZjSchemaRespVO.class)); + return success(buildZjSchemaRespVO(zjSchema)); } @GetMapping("/page") @@ -94,14 +97,17 @@ public class ZjSchemaController { @PreAuthorize("@ss.hasPermission('mes:zj-schema:query')") public CommonResult> getZjSchemaPage(@Valid ZjSchemaPageReqVO pageReqVO) { PageResult pageResult = zjSchemaService.getZjSchemaPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, ZjSchemaRespVO.class)); + List list = pageResult.getList().stream() + .map(this::buildZjSchemaRespVO) + .collect(Collectors.toList()); + return success(new PageResult<>(list, pageResult.getTotal())); } @GetMapping("/list") @Operation(summary = "获得检验方案列表") @PreAuthorize("@ss.hasPermission('mes:zj-schema:query')") - public CommonResult> getZjSchemaList() { - List zjSchemaDOList = zjSchemaService.getZjSchemaList(); + public CommonResult> getZjSchemaList(@RequestParam(value = "productId", required = false) Long productId) { + List zjSchemaDOList = zjSchemaService.getZjSchemaList(productId); return success(zjSchemaDOList); } @@ -182,4 +188,30 @@ public class ZjSchemaController { } }); } -} \ No newline at end of file + + private ZjSchemaRespVO buildZjSchemaRespVO(ZjSchemaDO zjSchema) { + if (zjSchema == null) { + return null; + } + ZjSchemaRespVO respVO = BeanUtils.toBean(zjSchema, ZjSchemaRespVO.class); + List productIds = parseIds(zjSchema.getProduct()); + respVO.setProductIds(productIds); + if (CollUtil.isNotEmpty(productIds)) { + respVO.setProducts(erpProductService.getProductVOList(productIds)); + } else { + respVO.setProducts(Collections.emptyList()); + } + return respVO; + } + + private List parseIds(String ids) { + if (ids == null || ids.trim().isEmpty()) { + return Collections.emptyList(); + } + return Arrays.stream(ids.split(",")) + .map(String::trim) + .filter(str -> !str.isEmpty()) + .map(Long::valueOf) + .collect(Collectors.toList()); + } +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaRespVO.java index a2f85f95c..1778f6849 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaRespVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mes.controller.admin.zjschema.vo; +import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import com.alibaba.excel.annotation.write.style.ColumnWidth; @@ -45,9 +46,15 @@ public class ZjSchemaRespVO { // @ExcelProperty("关联项目") private String item; + @Schema(description = "关联产品 ID 列表", example = "[1,2,3]") + private List productIds; + + @Schema(description = "关联产品列表") + private List products; + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("创建时间") @ColumnWidth(20) private LocalDateTime createTime; -} \ No newline at end of file +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaSaveReqVO.java index caa710f45..48aa85073 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaSaveReqVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjschema/vo/ZjSchemaSaveReqVO.java @@ -33,4 +33,7 @@ public class ZjSchemaSaveReqVO { @Schema(description = "关联项目") private String item; -} \ No newline at end of file + @Schema(description = "关联产品 ID 列表", example = "[1,2,3]") + private List productIds; + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjtask/vo/ZjTaskSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjtask/vo/ZjTaskSaveReqVO.java index 944e0d485..d096e08f5 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjtask/vo/ZjTaskSaveReqVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/zjtask/vo/ZjTaskSaveReqVO.java @@ -41,7 +41,7 @@ public class ZjTaskSaveReqVO { private String ticket; @Schema(description = "工序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotEmpty(message = "工序不能为空") +// @NotEmpty(message = "工序不能为空") private String orgType; @Schema(description = "负责人id", example = "6442") diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/zjschema/ZjSchemaDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/zjschema/ZjSchemaDO.java index fe7a29e00..776a28f04 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/zjschema/ZjSchemaDO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/zjschema/ZjSchemaDO.java @@ -52,4 +52,9 @@ public class ZjSchemaDO extends BaseDO { */ private String item; -} \ No newline at end of file + /** + * 关联产品(逗号分隔的 erp_product.id) + */ + private String product; + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/zjschema/ZjSchemaMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/zjschema/ZjSchemaMapper.java index e895ebe01..2a381bd77 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/zjschema/ZjSchemaMapper.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/zjschema/ZjSchemaMapper.java @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairDO; import cn.iocoder.yudao.module.mes.dal.dataobject.zjschema.ZjSchemaDO; import com.alibaba.excel.util.StringUtils; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import cn.iocoder.yudao.module.mes.controller.admin.zjschema.vo.*; /** @@ -56,4 +57,6 @@ public interface ZjSchemaMapper extends BaseMapperX { .orderByAsc(ZjSchemaDO::getId)); } -} \ No newline at end of file + List selectListByProductId(@Param("productId") Long productId); + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaService.java index 161625c51..2dfde27a2 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaService.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaService.java @@ -55,4 +55,6 @@ public interface ZjSchemaService { List getZjSchemaList(); -} \ No newline at end of file + List getZjSchemaList(Long productId); + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaServiceImpl.java index 9910c8165..f6c153f90 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/zjschema/ZjSchemaServiceImpl.java @@ -1,16 +1,14 @@ package cn.iocoder.yudao.module.mes.service.zjschema; -import cn.iocoder.yudao.module.mes.dal.dataobject.zjitem.ZjItemDO; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; import cn.iocoder.yudao.module.mes.controller.admin.zjschema.vo.*; import cn.iocoder.yudao.module.mes.dal.dataobject.zjschema.ZjSchemaDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.mes.dal.mysql.zjschema.ZjSchemaMapper; @@ -32,19 +30,17 @@ public class ZjSchemaServiceImpl implements ZjSchemaService { @Override public Long createZjSchema(ZjSchemaSaveReqVO createReqVO) { - // 插入 ZjSchemaDO zjSchema = BeanUtils.toBean(createReqVO, ZjSchemaDO.class); + zjSchema.setProduct(joinProductIds(createReqVO.getProductIds())); zjSchemaMapper.insert(zjSchema); - // 返回 return zjSchema.getId(); } @Override public void updateZjSchema(ZjSchemaSaveReqVO updateReqVO) { - // 校验存在 validateZjSchemaExists(updateReqVO.getId()); - // 更新 ZjSchemaDO updateObj = BeanUtils.toBean(updateReqVO, ZjSchemaDO.class); + updateObj.setProduct(joinProductIds(updateReqVO.getProductIds())); zjSchemaMapper.updateById(updateObj); } @@ -77,4 +73,23 @@ public class ZjSchemaServiceImpl implements ZjSchemaService { return zjSchemaMapper.selectList(); } -} \ No newline at end of file + @Override + public List getZjSchemaList(Long productId) { + if (productId == null) { + return zjSchemaMapper.selectList(); + } + List list = zjSchemaMapper.selectListByProductId(productId); + return list == null || list.isEmpty() ? zjSchemaMapper.selectList() : list; + } + + private String joinProductIds(List productIds) { + if (productIds == null || productIds.isEmpty()) { + return null; + } + return productIds.stream().filter(Objects::nonNull) + .map(String::valueOf) + .distinct() + .collect(Collectors.joining(",")); + } + +} diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/zjschema/ZjSchemaMapper.xml b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/zjschema/ZjSchemaMapper.xml index e605cd694..1644e6627 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/zjschema/ZjSchemaMapper.xml +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/zjschema/ZjSchemaMapper.xml @@ -9,4 +9,15 @@ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> - \ No newline at end of file + + +