fix:修复已知问题,修改添加检验模板关联产品

ck
HuangHuiKang 4 weeks ago
parent e6197fd60a
commit 09a2c8458c

@ -99,6 +99,8 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
return selectList(new LambdaQueryWrapperX<ErpProductDO>().in(ErpProductDO::getName, names));
}
List<ErpProductDO> selectListByIdsWithDeleted(@Param("ids") Collection<Long> ids);
List<ProductRelationRespVO> selectDevicesByProductId(@Param("productId") Long productId);
List<ProductRelationRespVO> selectMoldsByProductId(@Param("productId") Long productId);

@ -349,7 +349,7 @@ public class ErpProductServiceImpl implements ErpProductService {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<ErpProductDO> list = productMapper.selectBatchIds(ids);
List<ErpProductDO> 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() + "(已被删除)");
}
});
}

@ -8,6 +8,17 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListByIdsWithDeleted" resultType="cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO">
SELECT id, name, bar_code, category_id, sub_category_id, sub_category_name, unit_id,
status, standard, remark, expiry_day, weight, purchase_price, sale_price,
min_price, safety_number, create_time, update_time, creator, updater, deleted
FROM erp_product
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="selectDevicesByProductId"
resultType="cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO">
SELECT DISTINCT

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

@ -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,6 +46,12 @@ public class ZjSchemaRespVO {
// @ExcelProperty("关联项目")
private String item;
@Schema(description = "关联产品 ID 列表", example = "[1,2,3]")
private List<Long> productIds;
@Schema(description = "关联产品列表")
private List<ErpProductRespVO> products;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@ColumnWidth(20)

@ -33,4 +33,7 @@ public class ZjSchemaSaveReqVO {
@Schema(description = "关联项目")
private String item;
@Schema(description = "关联产品 ID 列表", example = "[1,2,3]")
private List<Long> productIds;
}

@ -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")

@ -52,4 +52,9 @@ public class ZjSchemaDO extends BaseDO {
*/
private String item;
/**
* erp_product.id
*/
private String product;
}

@ -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<ZjSchemaDO> {
.orderByAsc(ZjSchemaDO::getId));
}
List<ZjSchemaDO> selectListByProductId(@Param("productId") Long productId);
}

@ -55,4 +55,6 @@ public interface ZjSchemaService {
List<ZjSchemaDO> getZjSchemaList();
List<ZjSchemaDO> getZjSchemaList(Long productId);
}

@ -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();
}
@Override
public List<ZjSchemaDO> getZjSchemaList(Long productId) {
if (productId == null) {
return zjSchemaMapper.selectList();
}
List<ZjSchemaDO> list = zjSchemaMapper.selectListByProductId(productId);
return list == null || list.isEmpty() ? zjSchemaMapper.selectList() : list;
}
private String joinProductIds(List<Long> productIds) {
if (productIds == null || productIds.isEmpty()) {
return null;
}
return productIds.stream().filter(Objects::nonNull)
.map(String::valueOf)
.distinct()
.collect(Collectors.joining(","));
}
}

@ -9,4 +9,15 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListByProductId" resultType="cn.iocoder.yudao.module.mes.dal.dataobject.zjschema.ZjSchemaDO">
SELECT id, type, name, remark, sample_method, val, item, product,
create_time, update_time, creator, updater, deleted
FROM mes_zj_schema
WHERE deleted = 0
AND product IS NOT NULL
AND product != ''
AND FIND_IN_SET(#{productId}, product)
ORDER BY id DESC
</select>
</mapper>
Loading…
Cancel
Save