add mold product

plp
chenyuan 2 years ago
parent 87e34e30ac
commit d7745a285c

@ -113,6 +113,22 @@ CREATE TABLE `erp_mold`
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='模具表';
CREATE TABLE `erp_mold_brand_product`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`brand_id` bigint NOT NULL COMMENT '型号ID',
`product_id` bigint NOT NULL COMMENT '产品ID',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint DEFAULT NULL COMMENT '租户id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='模具产品表';
CREATE TABLE `mes_bom`

@ -23,7 +23,7 @@ public interface ErrorCodeConstants {
ErrorCode PURCHASE_ORDER_NOT_APPROVE = new ErrorCode(1_030_101_006, "采购订单未审核,无法操作");
ErrorCode PURCHASE_ORDER_ITEM_IN_FAIL_PRODUCT_EXCEED = new ErrorCode(1_030_101_007, "采购订单项({})超过最大允许入库数量({})");
ErrorCode PURCHASE_ORDER_PROCESS_FAIL_EXISTS_IN = new ErrorCode(1_030_101_008, "反审核失败,已存在对应的采购入库单");
ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_009, "采购订单项({})超过最大允许退货数量({})");
ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_009, "采购订单项({})超过最大允许退货数量({})");
ErrorCode PURCHASE_ORDER_PROCESS_FAIL_EXISTS_RETURN = new ErrorCode(1_030_101_010, "反审核失败,已存在对应的采购退货单");
// ========== ERP 采购入库1-030-102-000 ==========
@ -168,6 +168,8 @@ ErrorCode PURCHASE_ORDER_ITEM_RETURN_FAIL_IN_EXCEED = new ErrorCode(1_030_101_00
// ========== ERP 模具 1_111_000 ==========
ErrorCode MOLD_BRAND_NOT_EXISTS = new ErrorCode(1_111_001, "模具型号不存在");
ErrorCode MOLD_NOT_EXISTS = new ErrorCode(1_111_002, "模具不存在");
ErrorCode MOLD_BRAND_PRODUCT_NOT_EXISTS = new ErrorCode(1_111_003, "模具产品不存在");
ErrorCode MOLD_BRAND_PRODUCT_EXISTS = new ErrorCode(1_111_004, "模具产品已存在");
ErrorCode AUTOCODE_RECORD_NOT_EXISTS = new ErrorCode(1_111_003, "编码生成记录不存在");

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
@ -135,4 +136,49 @@ public class MoldBrandController {
return success(moldBrandService.getMold(id));
}
// ==================== 子表(模具产品) ====================
@GetMapping("/mold-brand-product/page")
@Operation(summary = "获得模具产品分页")
@Parameter(name = "brandId", description = "型号ID")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
public CommonResult<PageResult<MoldProductRespVO>> getMoldBrandProductPage(PageParam pageReqVO,
@RequestParam("brandId") Long brandId) {
PageResult<MoldBrandProductDO> pageResult = moldBrandService.getMoldBrandProductPage(pageReqVO, brandId);
PageResult<MoldProductRespVO> result = new PageResult<>(moldBrandService.buildProduct(pageResult.getList()),pageResult.getTotal());
return success(result);
}
@PostMapping("/mold-brand-product/create")
@Operation(summary = "创建模具产品")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:create')")
public CommonResult<Long> createMoldBrandProduct(@Valid @RequestBody MoldBrandProductDO moldBrandProduct) {
return success(moldBrandService.createMoldBrandProduct(moldBrandProduct));
}
@PutMapping("/mold-brand-product/update")
@Operation(summary = "更新模具产品")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:update')")
public CommonResult<Boolean> updateMoldBrandProduct(@Valid @RequestBody MoldBrandProductDO moldBrandProduct) {
moldBrandService.updateMoldBrandProduct(moldBrandProduct);
return success(true);
}
@DeleteMapping("/mold-brand-product/delete")
@Parameter(name = "id", description = "编号", required = true)
@Operation(summary = "删除模具产品")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:delete')")
public CommonResult<Boolean> deleteMoldBrandProduct(@RequestParam("id") Long id) {
moldBrandService.deleteMoldBrandProduct(id);
return success(true);
}
@GetMapping("/mold-brand-product/get")
@Operation(summary = "获得模具产品")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
public CommonResult<MoldBrandProductDO> getMoldBrandProduct(@RequestParam("id") Long id) {
return success(moldBrandService.getMoldBrandProduct(id));
}
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
@ -50,4 +51,6 @@ public class MoldBrandPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "工序", example = "你说的对")
private String orgType;
}

@ -67,4 +67,7 @@ public class MoldBrandRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "工序", example = "你说的对")
@DictFormat("mes_org_type")
private String orgType;
}

@ -50,5 +50,7 @@ public class MoldBrandSaveReqVO {
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否启用不能为空")
private Boolean isEnable;
@Schema(description = "工序", example = "你说的对")
private String orgType;
}

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
@Schema(description = "管理后台 - 模具 Response VO")
@Data
@ExcelIgnoreUnannotated
public class MoldProductRespVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32278")
@ExcelProperty("ID")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
private Long productId;
@Schema(description = "产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
@ExcelProperty("产品")
private String productName;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "型号id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15258")
@ExcelProperty("型号id")
private Long brandId;
}

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.mold;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
@ -72,4 +74,6 @@ public class MoldBrandDO extends BaseDO {
*/
private Boolean isEnable;
// @Schema(description = "工序", example = "你说的对")
private String orgType;
}

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.mold;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author
*/
@TableName("erp_mold_brand_product")
@KeySequence("erp_mold_brand_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MoldBrandProductDO extends BaseDO {
/**
* ID
*/
@TableId
private Long id;
/**
* ID
*/
private Long brandId;
/**
* ID
*/
private Long productId;
/**
*
*/
private String remark;
}

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.erp.dal.mysql.mold;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author
*/
@Mapper
public interface MoldBrandProductMapper extends BaseMapperX<MoldBrandProductDO> {
default PageResult<MoldBrandProductDO> selectPage(PageParam reqVO, Long brandId) {
return selectPage(reqVO, new LambdaQueryWrapperX<MoldBrandProductDO>()
.eq(MoldBrandProductDO::getBrandId, brandId)
.orderByDesc(MoldBrandProductDO::getId));
}
default int deleteByBrandId(Long brandId) {
return delete(MoldBrandProductDO::getBrandId, brandId);
}
default List<MoldBrandProductDO> selectList(MoldBrandProductDO reqVO) {
return selectList(new LambdaQueryWrapperX<MoldBrandProductDO>()
.eqIfPresent(MoldBrandProductDO::getProductId, reqVO.getProductId())
.eqIfPresent(MoldBrandProductDO::getBrandId, reqVO.getBrandId())
.orderByDesc(MoldBrandProductDO::getId));
}
}

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.erp.service.mold;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -95,4 +96,44 @@ public interface MoldBrandService {
*/
MoldDO getMold(Long id);
// ==================== 子表(模具产品) ====================
/**
*
*
* @param pageReqVO
* @param brandId ID
* @return
*/
PageResult<MoldBrandProductDO> getMoldBrandProductPage(PageParam pageReqVO, Long brandId);
List<MoldProductRespVO> buildProduct(List<MoldBrandProductDO> list);
/**
*
*
* @param moldBrandProduct
* @return
*/
Long createMoldBrandProduct(@Valid MoldBrandProductDO moldBrandProduct);
/**
*
*
* @param moldBrandProduct
*/
void updateMoldBrandProduct(@Valid MoldBrandProductDO moldBrandProduct);
/**
*
*
* @param id
*/
void deleteMoldBrandProduct(Long id);
/**
*
*
* @param id
* @return
*/
MoldBrandProductDO getMoldBrandProduct(Long id);
}

@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.mysql.mold.MoldBrandProductMapper;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import org.springframework.stereotype.Service;
@ -160,4 +162,65 @@ public class MoldBrandServiceImpl implements MoldBrandService {
moldMapper.deleteByBrandId(brandId);
}
// ==================== 子表(模具产品) ====================
@Resource
private MoldBrandProductMapper moldBrandProductMapper;
@Override
public PageResult<MoldBrandProductDO> getMoldBrandProductPage(PageParam pageReqVO, Long brandId) {
return moldBrandProductMapper.selectPage(pageReqVO, brandId);
}
@Override
public List<MoldProductRespVO> buildProduct(List<MoldBrandProductDO> list) {
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
}
Map<Long, ErpProductDO> map = productService.getProductMap(
convertSet(list, MoldBrandProductDO::getProductId));
return BeanUtils.toBean(list, MoldProductRespVO.class, item -> {
MapUtils.findAndThen(map, item.getProductId(),
product -> item.setProductName(product.getName()));
});
}
@Override
public Long createMoldBrandProduct(MoldBrandProductDO moldBrandProduct) {
MoldBrandProductDO resVo = new MoldBrandProductDO().setBrandId(moldBrandProduct.getBrandId())
.setProductId(moldBrandProduct.getProductId());
List<MoldBrandProductDO> list = moldBrandProductMapper.selectList(resVo);
if(list!=null && list.size()>0){
throw exception(MOLD_BRAND_PRODUCT_EXISTS);
}
moldBrandProductMapper.insert(moldBrandProduct);
return moldBrandProduct.getId();
}
@Override
public void updateMoldBrandProduct(MoldBrandProductDO moldBrandProduct) {
// 校验存在
validateMoldBrandProductExists(moldBrandProduct.getId());
// 更新
moldBrandProductMapper.updateById(moldBrandProduct);
}
@Override
public void deleteMoldBrandProduct(Long id) {
// 校验存在
validateMoldBrandProductExists(id);
// 删除
moldBrandProductMapper.deleteById(id);
}
@Override
public MoldBrandProductDO getMoldBrandProduct(Long id) {
return moldBrandProductMapper.selectById(id);
}
private void validateMoldBrandProductExists(Long id) {
if (moldBrandProductMapper.selectById(id) == null) {
throw exception(MOLD_BRAND_PRODUCT_NOT_EXISTS);
}
}
private void deleteMoldBrandProductByBrandId(Long brandId) {
moldBrandProductMapper.deleteByBrandId(brandId);
}
}
Loading…
Cancel
Save