|
|
|
|
@ -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<ZjSchemaRespVO> 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<PageResult<ZjSchemaRespVO>> getZjSchemaPage(@Valid ZjSchemaPageReqVO pageReqVO) {
|
|
|
|
|
PageResult<ZjSchemaDO> pageResult = zjSchemaService.getZjSchemaPage(pageReqVO);
|
|
|
|
|
return success(BeanUtils.toBean(pageResult, ZjSchemaRespVO.class));
|
|
|
|
|
List<ZjSchemaRespVO> 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<List<ZjSchemaDO>> getZjSchemaList() {
|
|
|
|
|
List<ZjSchemaDO> zjSchemaDOList = zjSchemaService.getZjSchemaList();
|
|
|
|
|
public CommonResult<List<ZjSchemaDO>> getZjSchemaList(@RequestParam(value = "productId", required = false) Long productId) {
|
|
|
|
|
List<ZjSchemaDO> zjSchemaDOList = zjSchemaService.getZjSchemaList(productId);
|
|
|
|
|
return success(zjSchemaDOList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -182,4 +188,30 @@ public class ZjSchemaController {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ZjSchemaRespVO buildZjSchemaRespVO(ZjSchemaDO zjSchema) {
|
|
|
|
|
if (zjSchema == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
ZjSchemaRespVO respVO = BeanUtils.toBean(zjSchema, ZjSchemaRespVO.class);
|
|
|
|
|
List<Long> 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<Long> 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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|