|
|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package cn.iocoder.yudao.module.mes.controller.admin.zjschema;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.zjitem.vo.ZjItemRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.zjitem.ZjItemDO;
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.zjitem.ZjItemService;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
@ -13,6 +16,7 @@ import javax.validation.*;
|
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
@ -37,6 +41,8 @@ public class ZjSchemaController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ZjSchemaService zjSchemaService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ZjItemService zjitemService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
|
@Operation(summary = "创建检验方案")
|
|
|
|
|
@ -92,4 +98,35 @@ public class ZjSchemaController {
|
|
|
|
|
BeanUtils.toBean(list, ZjSchemaRespVO.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getItemList")
|
|
|
|
|
@Operation(summary = "获得检验方案关联的项目列表")
|
|
|
|
|
@Parameter(name = "id", description = "检验方案编号", required = true, example = "1024")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:zj-schema:query')")
|
|
|
|
|
public CommonResult<List<ZjItemRespVO>> getItemList(@RequestParam("id") Long id) {
|
|
|
|
|
// 1. 查询检验方案主记录
|
|
|
|
|
ZjSchemaDO zjSchema = zjSchemaService.getZjSchema(id);
|
|
|
|
|
if (zjSchema == null) {
|
|
|
|
|
return success(Collections.emptyList()); // 或抛出业务异常,根据项目规范调整
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 解析item字段(处理空值和空字符串)
|
|
|
|
|
String itemStr = zjSchema.getItem();
|
|
|
|
|
if (itemStr == null || itemStr.trim().isEmpty()) {
|
|
|
|
|
return success(Collections.emptyList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. 分割字符串并转换为Long类型的项目ID列表
|
|
|
|
|
List<Long> itemIds = Arrays.stream(itemStr.split(","))
|
|
|
|
|
.map(String::trim) // 去除空格
|
|
|
|
|
.filter(str -> !str.isEmpty()) // 过滤空字符串
|
|
|
|
|
.map(Long::valueOf) // 转换为Long
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 4. 查询所有关联的项目信息(请根据实际项目调整Service方法)
|
|
|
|
|
List<ZjItemDO> itemList = zjitemService.getItemsByIds(itemIds);
|
|
|
|
|
|
|
|
|
|
// 5. 转换为VO并返回
|
|
|
|
|
return success(BeanUtils.toBean(itemList, ZjItemRespVO.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|