feat:新增排产功能模块相关字段,修改新增计划接口

main
HuangHuiKang 5 days ago
parent bc9159c1ac
commit 977a16e6c9

@ -136,7 +136,8 @@ public interface ErrorCodeConstants {
ErrorCode PRODUCT_CODE_EXISTS = new ErrorCode(1_030_500_002, "产品编码已存在");
ErrorCode PRODUCT_NAME_AND_STANDARD_EXISTS = new ErrorCode(1_030_500_003, "名称+规格已存在且不能重复");
ErrorCode PRODUCT_CODE_NOT_EXISTS = new ErrorCode(1_030_500_004, "产品编码不存在");
ErrorCode PRODUCT_DEVICE_REL_NOT_EXISTS = new ErrorCode(1_030_500_005, "产品-设备关联不存在");
ErrorCode PRODUCT_MOLD_REL_NOT_EXISTS = new ErrorCode(1_030_500_006, "产品-模具关联不存在");
// ========== ERP 产品分类 1-030-501-000 ==========
ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在");

@ -71,8 +71,6 @@ public class ErpProductController {
// return error(400,"编码不能重复");
// }
return success(productService.createProduct(createReqVO));
}
@ -109,8 +107,7 @@ public class ErpProductController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:product:query')")
public CommonResult<ErpProductRespVO> getProduct(@RequestParam("id") Long id) {
ErpProductDO product = productService.getProduct(id);
return success(BeanUtils.toBean(product, ErpProductRespVO.class));
return success(productService.getProduct(id));
}
@GetMapping("/page")

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
@ -7,11 +8,12 @@ import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - ERP 产品 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ErpProductRespVO {
public class ErpProductRespVO extends ErpProductDO {
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672")
@ExcelProperty("产品编号")
@ -86,4 +88,17 @@ public class ErpProductRespVO {
@Schema(description = "二维码地址", example = "")
private String qrcodeUrl;
//
// @Schema(description = "关联设备ID列表", example = "[11,15,23]")
// private List<Long> deviceIds;
//
// @Schema(description = "关联模具D列表", example = "[11,15,23]")
// private List<Long> moldIds;
@Schema(description = "关联设备列表")
private List<ProductRelationRespVO> devices;
@Schema(description = "关联模具列表")
private List<ProductRelationRespVO> molds;
}

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class ProductRelationRespVO {
@Schema(description = "ID", example = "1")
private Long id;
@Schema(description = "名称", example = "设备A")
private String name;
}

@ -6,6 +6,7 @@ import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
@Schema(description = "管理后台 - ERP 产品新增/修改 Request VO")
@Data
@ -57,4 +58,10 @@ public class ProductSaveReqVO {
@Schema(description = "预警库存", example = "161.87")
private BigDecimal safetyNumber;
@Schema(description = "关联设备ID列表", example = "[11,15,23]")
private List<Long> deviceIds;
@Schema(description = "关联模具D列表", example = "[11,15,23]")
private List<Long> moldIds;
}

@ -0,0 +1,96 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.module.erp.service.productdevicerel.ProductDeviceRelService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - 产品-设备关联")
@RestController
@RequestMapping("/erp/product-device-rel")
@Validated
public class ProductDeviceRelController {
@Resource
private ProductDeviceRelService productDeviceRelService;
@PostMapping("/create")
@Operation(summary = "创建产品-设备关联")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:create')")
public CommonResult<Long> createProductDeviceRel(@Valid @RequestBody ProductDeviceRelSaveReqVO createReqVO) {
return success(productDeviceRelService.createProductDeviceRel(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新产品-设备关联")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:update')")
public CommonResult<Boolean> updateProductDeviceRel(@Valid @RequestBody ProductDeviceRelSaveReqVO updateReqVO) {
productDeviceRelService.updateProductDeviceRel(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除产品-设备关联")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:delete')")
public CommonResult<Boolean> deleteProductDeviceRel(@RequestParam("id") Long id) {
productDeviceRelService.deleteProductDeviceRel(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得产品-设备关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:query')")
public CommonResult<ProductDeviceRelRespVO> getProductDeviceRel(@RequestParam("id") Long id) {
ProductDeviceRelDO productDeviceRel = productDeviceRelService.getProductDeviceRel(id);
return success(BeanUtils.toBean(productDeviceRel, ProductDeviceRelRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得产品-设备关联分页")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:query')")
public CommonResult<PageResult<ProductDeviceRelRespVO>> getProductDeviceRelPage(@Valid ProductDeviceRelPageReqVO pageReqVO) {
PageResult<ProductDeviceRelDO> pageResult = productDeviceRelService.getProductDeviceRelPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProductDeviceRelRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出产品-设备关联 Excel")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportProductDeviceRelExcel(@Valid ProductDeviceRelPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ProductDeviceRelDO> list = productDeviceRelService.getProductDeviceRelPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "产品-设备关联.xls", "数据", ProductDeviceRelRespVO.class,
BeanUtils.toBean(list, ProductDeviceRelRespVO.class));
}
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 产品-设备关联分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductDeviceRelPageReqVO extends PageParam {
@Schema(description = "产品ID", example = "18574")
private Long productId;
@Schema(description = "设备ID", example = "21075")
private Long deviceId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 产品-设备关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProductDeviceRelRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "28748")
@ExcelProperty("主键")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18574")
@ExcelProperty("产品ID")
private Long productId;
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21075")
@ExcelProperty("设备ID")
private Long deviceId;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.util.*;
@Schema(description = "管理后台 - 产品-设备关联新增/修改 Request VO")
@Data
public class ProductDeviceRelSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "28748")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18574")
@NotNull(message = "产品ID不能为空")
private Long productId;
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21075")
@NotNull(message = "设备ID不能为空")
private Long deviceId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.module.erp.service.productmoldrel.ProductMoldRelService;
@Tag(name = "管理后台 - 产品-模具关联")
@RestController
@RequestMapping("/erp/product-mold-rel")
@Validated
public class ProductMoldRelController {
@Resource
private ProductMoldRelService productMoldRelService;
@PostMapping("/create")
@Operation(summary = "创建产品-模具关联")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:create')")
public CommonResult<Long> createProductMoldRel(@Valid @RequestBody ProductMoldRelSaveReqVO createReqVO) {
return success(productMoldRelService.createProductMoldRel(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新产品-模具关联")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:update')")
public CommonResult<Boolean> updateProductMoldRel(@Valid @RequestBody ProductMoldRelSaveReqVO updateReqVO) {
productMoldRelService.updateProductMoldRel(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除产品-模具关联")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:delete')")
public CommonResult<Boolean> deleteProductMoldRel(@RequestParam("id") Long id) {
productMoldRelService.deleteProductMoldRel(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得产品-模具关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:query')")
public CommonResult<ProductMoldRelRespVO> getProductMoldRel(@RequestParam("id") Long id) {
ProductMoldRelDO productMoldRel = productMoldRelService.getProductMoldRel(id);
return success(BeanUtils.toBean(productMoldRel, ProductMoldRelRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得产品-模具关联分页")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:query')")
public CommonResult<PageResult<ProductMoldRelRespVO>> getProductMoldRelPage(@Valid ProductMoldRelPageReqVO pageReqVO) {
PageResult<ProductMoldRelDO> pageResult = productMoldRelService.getProductMoldRelPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProductMoldRelRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出产品-模具关联 Excel")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportProductMoldRelExcel(@Valid ProductMoldRelPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ProductMoldRelDO> list = productMoldRelService.getProductMoldRelPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "产品-模具关联.xls", "数据", ProductMoldRelRespVO.class,
BeanUtils.toBean(list, ProductMoldRelRespVO.class));
}
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 产品-模具关联分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductMoldRelPageReqVO extends PageParam {
@Schema(description = "产品ID", example = "30420")
private Long productId;
@Schema(description = "模具ID", example = "243")
private Long moldId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 产品-模具关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProductMoldRelRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "11772")
@ExcelProperty("主键")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30420")
@ExcelProperty("产品ID")
private Long productId;
@Schema(description = "模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
@ExcelProperty("模具ID")
private Long moldId;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 产品-模具关联新增/修改 Request VO")
@Data
public class ProductMoldRelSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "11772")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30420")
@NotNull(message = "产品ID不能为空")
private Long productId;
@Schema(description = "模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
@NotNull(message = "模具ID不能为空")
private Long moldId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel;
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_product_device_rel")
@KeySequence("erp_product_device_rel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductDeviceRelDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* ID
*/
private Long productId;
/**
* ID
*/
private Long deviceId;
/**
*
*/
private Integer sort;
/**
*
*/
private String remark;
}

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel;
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_product_mold_rel")
@KeySequence("erp_product_mold_rel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductMoldRelDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* ID
*/
private Long productId;
/**
* ID
*/
private Long moldId;
/**
*
*/
private Integer sort;
/**
*
*/
private String remark;
}

@ -6,10 +6,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
@ -85,5 +87,8 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
return selectList(new LambdaQueryWrapperX<ErpProductDO>().in(ErpProductDO::getName, names));
}
List<ProductRelationRespVO> selectDevicesByProductId(@Param("productId") Long productId);
List<ProductRelationRespVO> selectMoldsByProductId(@Param("productId") Long productId);
}

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.productdevicerel.ProductDeviceRelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
/**
* - Mapper
*
* @author
*/
@Mapper
public interface ProductDeviceRelMapper extends BaseMapperX<ProductDeviceRelDO> {
default PageResult<ProductDeviceRelDO> selectPage(ProductDeviceRelPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductDeviceRelDO>()
.eqIfPresent(ProductDeviceRelDO::getProductId, reqVO.getProductId())
.eqIfPresent(ProductDeviceRelDO::getDeviceId, reqVO.getDeviceId())
.eqIfPresent(ProductDeviceRelDO::getSort, reqVO.getSort())
.eqIfPresent(ProductDeviceRelDO::getRemark, reqVO.getRemark())
.betweenIfPresent(ProductDeviceRelDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductDeviceRelDO::getId));
}
}

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.productmoldrel.ProductMoldRelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
/**
* - Mapper
*
* @author
*/
@Mapper
public interface ProductMoldRelMapper extends BaseMapperX<ProductMoldRelDO> {
default PageResult<ProductMoldRelDO> selectPage(ProductMoldRelPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductMoldRelDO>()
.eqIfPresent(ProductMoldRelDO::getProductId, reqVO.getProductId())
.eqIfPresent(ProductMoldRelDO::getMoldId, reqVO.getMoldId())
.eqIfPresent(ProductMoldRelDO::getSort, reqVO.getSort())
.eqIfPresent(ProductMoldRelDO::getRemark, reqVO.getRemark())
.betweenIfPresent(ProductMoldRelDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductMoldRelDO::getId));
}
}

@ -61,7 +61,7 @@ public interface ErpProductService {
* @param id
* @return
*/
ErpProductDO getProduct(Long id);
ErpProductRespVO getProduct(Long id);
/**
* VO

@ -13,17 +13,17 @@ import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportExcelVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.*;
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.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductCategoryMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel.ProductDeviceRelMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel.ProductMoldRelMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper;
import cn.iocoder.yudao.module.erp.service.stock.ErpStockService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -76,6 +76,13 @@ public class ErpProductServiceImpl implements ErpProductService {
@Resource
private ErpStockMapper erpStockMapper;
@Resource
private ProductDeviceRelMapper productDeviceRelMapper;
@Resource
private ProductMoldRelMapper productMoldRelMapper;
@Resource
@Lazy // 延迟注入
private ErpStockService erpStockService;
@ -86,7 +93,9 @@ public class ErpProductServiceImpl implements ErpProductService {
@Autowired
private AutoCodeUtil autoCodeUtil;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createProduct(ProductSaveReqVO createReqVO) throws UnsupportedEncodingException {
@ -122,19 +131,41 @@ public class ErpProductServiceImpl implements ErpProductService {
product.setBarCode(productCategory.getCode()+ "-" + code);
productMapper.insert(product);
// 生成二维码
// try {
// qrcodeService.generateOrRefresh(
// QrcodeBizTypeEnum.PRODUCT, // bizType
// product.getId(), // bizId
// product.getBarCode(), // bizCode
// "DETAIL" // scene
// );
// } catch (Exception e) {
// log.error("[产品物料] 生成二维码失败id={}, code={}",
// product.getId(), product.getBarCode(), e);
// }
//插入关联设备
List<Long> deviceIds = createReqVO.getDeviceIds();
if (CollUtil.isNotEmpty(deviceIds)) {
List<Long> distinctIds = deviceIds.stream().distinct().collect(Collectors.toList());
List<ProductDeviceRelDO> relList = distinctIds.stream()
.map(deviceId -> {
ProductDeviceRelDO rel = new ProductDeviceRelDO();
rel.setProductId(product.getId());
rel.setDeviceId(deviceId);
return rel;
})
.collect(Collectors.toList());
productDeviceRelMapper.insertBatch(relList);
}
// 插入关联模具
List<Long> moldIds = createReqVO.getMoldIds();
if (CollUtil.isNotEmpty(moldIds)) {
List<Long> distinctIds = moldIds.stream().distinct().collect(Collectors.toList());
List<ProductMoldRelDO> relList = distinctIds.stream()
.map(moldId -> {
ProductMoldRelDO rel = new ProductMoldRelDO();
rel.setProductId(product.getId());
rel.setMoldId(moldId);
return rel;
})
.collect(Collectors.toList());
productMoldRelMapper.insertBatch(relList);
}
// 生成二维码
CodeTypeEnum codeType = autoCodeUtil.queryCodeType("PRODUCT_CODE_GENERATE");
if (codeType==null){
@ -150,11 +181,14 @@ public class ErpProductServiceImpl implements ErpProductService {
codeType
);
// 返回
return product.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateProduct(ProductSaveReqVO updateReqVO) {
// TODO 芋艿:校验分类
// 校验存在
@ -171,6 +205,49 @@ public class ErpProductServiceImpl implements ErpProductService {
id = productCategory.getParentId();
}
productMapper.updateById(updateObj);
// 先删除旧关联(推荐逻辑删;如果你们没做逻辑删,也可以物理删)
productDeviceRelMapper.delete(Wrappers.<ProductDeviceRelDO>lambdaQuery()
.eq(ProductDeviceRelDO::getProductId,updateObj.getId()));
// 再插入新关联
List<Long> deviceIds = updateReqVO.getDeviceIds();
if (CollUtil.isNotEmpty(deviceIds)) {
List<Long> distinctIds = deviceIds.stream().distinct().collect(Collectors.toList());
List<ProductDeviceRelDO> relList = distinctIds.stream()
.map(deviceId -> {
ProductDeviceRelDO rel = new ProductDeviceRelDO();
rel.setProductId(updateReqVO.getId());
rel.setDeviceId(deviceId);
return rel;
})
.collect(Collectors.toList());
productDeviceRelMapper.insertBatch(relList);
}
// 删除旧模具关联
productMoldRelMapper.delete(Wrappers.<ProductMoldRelDO>lambdaQuery()
.eq(ProductMoldRelDO::getProductId, updateObj.getId()));
// 新增模具关联
List<Long> moldIds = updateReqVO.getMoldIds();
if (CollUtil.isNotEmpty(moldIds)) {
List<Long> distinctIds = moldIds.stream().distinct().collect(Collectors.toList());
List<ProductMoldRelDO> relList = distinctIds.stream()
.map(moldId -> {
ProductMoldRelDO rel = new ProductMoldRelDO();
rel.setProductId(updateReqVO.getId());
rel.setMoldId(moldId);
return rel;
})
.collect(Collectors.toList());
productMoldRelMapper.insertBatch(relList);
}
}
@Override
@ -217,14 +294,33 @@ public class ErpProductServiceImpl implements ErpProductService {
}
@Override
public ErpProductDO getProduct(Long id) {
ErpProductDO erpProductDO = productMapper.selectById(id);
public ErpProductRespVO getProduct(Long id) {
ErpProductDO product = productMapper.selectById(id);
if (product == null) {
return null;
}
String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode(QrcodeBizTypeEnum.PRODUCT.getCode(),id,erpProductDO.getBarCode());
erpProductDO.setQrcodeUrl(qrcodeUrl);
return erpProductDO ;
String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode(
QrcodeBizTypeEnum.PRODUCT.getCode(), id, product.getBarCode());
product.setQrcodeUrl(qrcodeUrl);
ErpProductRespVO respVO = BeanUtils.toBean(product, ErpProductRespVO.class);
respVO.setDevices(productMapper.selectDevicesByProductId(id));
respVO.setMolds(productMapper.selectMoldsByProductId(id));
//
// respVO.setDeviceIds(respVO.getDevices().stream()
// .map(ProductRelationRespVO::getId)
// .collect(Collectors.toList()));
// respVO.setMoldIds(respVO.getMolds().stream()
// .map(ProductRelationRespVO::getId)
// .collect(Collectors.toList()));
return respVO;
}
@Override
public List<ErpProductRespVO> getProductVOListByStatus(Integer status,Integer categoryId) {

@ -37,6 +37,7 @@ public class ErpProductUnitServiceImpl implements ErpProductUnitService {
@Lazy // 延迟加载,避免循环依赖
private ErpProductService productService;
@Override
public Long createProductUnit(ErpProductUnitSaveReqVO createReqVO) {
// 1. 校验名字唯一

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.erp.service.productdevicerel;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* - Service
*
* @author
*/
public interface ProductDeviceRelService {
/**
* -
*
* @param createReqVO
* @return
*/
Long createProductDeviceRel(@Valid ProductDeviceRelSaveReqVO createReqVO);
/**
* -
*
* @param updateReqVO
*/
void updateProductDeviceRel(@Valid ProductDeviceRelSaveReqVO updateReqVO);
/**
* -
*
* @param id
*/
void deleteProductDeviceRel(Long id);
/**
* -
*
* @param id
* @return -
*/
ProductDeviceRelDO getProductDeviceRel(Long id);
/**
* -
*
* @param pageReqVO
* @return -
*/
PageResult<ProductDeviceRelDO> getProductDeviceRelPage(ProductDeviceRelPageReqVO pageReqVO);
}

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.erp.service.productdevicerel;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
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.erp.dal.mysql.productdevicerel.ProductDeviceRelMapper;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
/**
* - Service
*
* @author
*/
@Service
@Validated
public class ProductDeviceRelServiceImpl implements ProductDeviceRelService {
@Resource
private ProductDeviceRelMapper productDeviceRelMapper;
@Override
public Long createProductDeviceRel(ProductDeviceRelSaveReqVO createReqVO) {
// 插入
ProductDeviceRelDO productDeviceRel = BeanUtils.toBean(createReqVO, ProductDeviceRelDO.class);
productDeviceRelMapper.insert(productDeviceRel);
// 返回
return productDeviceRel.getId();
}
@Override
public void updateProductDeviceRel(ProductDeviceRelSaveReqVO updateReqVO) {
// 校验存在
validateProductDeviceRelExists(updateReqVO.getId());
// 更新
ProductDeviceRelDO updateObj = BeanUtils.toBean(updateReqVO, ProductDeviceRelDO.class);
productDeviceRelMapper.updateById(updateObj);
}
@Override
public void deleteProductDeviceRel(Long id) {
// 校验存在
validateProductDeviceRelExists(id);
// 删除
productDeviceRelMapper.deleteById(id);
}
private void validateProductDeviceRelExists(Long id) {
if (productDeviceRelMapper.selectById(id) == null) {
throw exception(PRODUCT_DEVICE_REL_NOT_EXISTS);
}
}
@Override
public ProductDeviceRelDO getProductDeviceRel(Long id) {
return productDeviceRelMapper.selectById(id);
}
@Override
public PageResult<ProductDeviceRelDO> getProductDeviceRelPage(ProductDeviceRelPageReqVO pageReqVO) {
return productDeviceRelMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.erp.service.productmoldrel;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* - Service
*
* @author
*/
public interface ProductMoldRelService {
/**
* -
*
* @param createReqVO
* @return
*/
Long createProductMoldRel(@Valid ProductMoldRelSaveReqVO createReqVO);
/**
* -
*
* @param updateReqVO
*/
void updateProductMoldRel(@Valid ProductMoldRelSaveReqVO updateReqVO);
/**
* -
*
* @param id
*/
void deleteProductMoldRel(Long id);
/**
* -
*
* @param id
* @return -
*/
ProductMoldRelDO getProductMoldRel(Long id);
/**
* -
*
* @param pageReqVO
* @return -
*/
PageResult<ProductMoldRelDO> getProductMoldRelPage(ProductMoldRelPageReqVO pageReqVO);
}

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.erp.service.productmoldrel;
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 cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
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.erp.dal.mysql.productmoldrel.ProductMoldRelMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
/**
* - Service
*
* @author
*/
@Service
@Validated
public class ProductMoldRelServiceImpl implements ProductMoldRelService {
@Resource
private ProductMoldRelMapper productMoldRelMapper;
@Override
public Long createProductMoldRel(ProductMoldRelSaveReqVO createReqVO) {
// 插入
ProductMoldRelDO productMoldRel = BeanUtils.toBean(createReqVO, ProductMoldRelDO.class);
productMoldRelMapper.insert(productMoldRel);
// 返回
return productMoldRel.getId();
}
@Override
public void updateProductMoldRel(ProductMoldRelSaveReqVO updateReqVO) {
// 校验存在
validateProductMoldRelExists(updateReqVO.getId());
// 更新
ProductMoldRelDO updateObj = BeanUtils.toBean(updateReqVO, ProductMoldRelDO.class);
productMoldRelMapper.updateById(updateObj);
}
@Override
public void deleteProductMoldRel(Long id) {
// 校验存在
validateProductMoldRelExists(id);
// 删除
productMoldRelMapper.deleteById(id);
}
private void validateProductMoldRelExists(Long id) {
if (productMoldRelMapper.selectById(id) == null) {
throw exception(PRODUCT_MOLD_REL_NOT_EXISTS);
}
}
@Override
public ProductMoldRelDO getProductMoldRel(Long id) {
return productMoldRelMapper.selectById(id);
}
@Override
public PageResult<ProductMoldRelDO> getProductMoldRelPage(ProductMoldRelPageReqVO pageReqVO) {
return productMoldRelMapper.selectPage(pageReqVO);
}
}

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.common.controller.admin.mold.vo.MoldSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
@ -151,9 +152,9 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
ErpStockRecordBizTypeEnum.OTHER_OUT.getType(), stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo(),stockOut.getOutTime()));
} else {
ErpProductDO productDO = productService.getProduct(stockOutItem.getProductId());
ErpProductRespVO product = productService.getProduct(stockOutItem.getProductId());
stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO(
stockOutItem.getProductId(),productDO.getCategoryId(), stockOutItem.getWarehouseId(), count,
stockOutItem.getProductId(),product.getCategoryId(), stockOutItem.getWarehouseId(), count,
ErpStockRecordBizTypeEnum.getTypeByName(stockOut.getOutType(),status), stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo(),stockOut.getOutTime()));
}

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectDevicesByProductId"
resultType="cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO">
SELECT DISTINCT
rel.device_id AS id,
CASE
WHEN d.id IS NULL THEN CONCAT('设备[', rel.device_id, ']【已删除】')
WHEN d.deleted = b'1' THEN CONCAT(d.device_name, '(', d.device_code, ')【已删除】')
ELSE CONCAT(d.device_name, '(', d.device_code, ')')
END AS name
FROM erp_product_device_rel rel
LEFT JOIN mes_device_ledger d ON rel.device_id = d.id
WHERE rel.product_id = #{productId}
AND rel.deleted = b'0'
</select>
<select id="selectMoldsByProductId"
resultType="cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO">
SELECT DISTINCT
rel.mold_id AS id,
CASE
WHEN m.id IS NULL THEN CONCAT('模具[', rel.mold_id, ']【已删除】')
WHEN m.deleted = b'1' THEN CONCAT(m.name, '(', m.code, ')【已删除】')
ELSE CONCAT(m.name, '(', m.code, ')')
END AS name
FROM erp_product_mold_rel rel
LEFT JOIN erp_mold m ON rel.mold_id = m.id
WHERE rel.product_id = #{productId}
AND rel.deleted = b'0'
</select>
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel.ProductDeviceRelMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel.ProductMoldRelMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -19,7 +19,7 @@ public interface DevicePointRulesMapper extends BaseMapperX<DevicePointRulesDO>
default PageResult<DevicePointRulesDO> selectPage(DevicePointRulesPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<DevicePointRulesDO>()
.eqIfPresent(DevicePointRulesDO::getIdentifier, reqVO.getIdentifier())
.likeIfPresent(DevicePointRulesDO::getIdentifier, reqVO.getIdentifier())
.likeIfPresent(DevicePointRulesDO::getFieldName, reqVO.getFieldName())
.eqIfPresent(DevicePointRulesDO::getFieldRule, reqVO.getFieldRule())
.eqIfPresent(DevicePointRulesDO::getDefaultValue, reqVO.getDefaultValue())

@ -154,4 +154,10 @@ public class DeviceLedgerRespVO extends BaseDO {
@Schema(description = "二维码")
private String qrcodeUrl;
@Schema(description = "是否排产")
private Integer isScheduled;
@Schema(description = "额定产能")
private Integer ratedCapacity;
}

@ -78,4 +78,10 @@ public class DeviceLedgerSaveReqVO {
@Schema(description = "关联采集设备id")
private Long dvId;
@Schema(description = "是否排产")
private Integer isScheduled;
@Schema(description = "额定产能")
private Integer ratedCapacity;
}

@ -114,68 +114,6 @@ public class PlanController {
zjProductRecordService.createZjProductRecord(BeanUtils.toBean(zjProductRecordDO, ZjProductRecordSaveReqVO.class));
}
}
// // 生成领料出库单据
// List<ErpStockOutSaveReqVO.Item> itemList;
//
// // 1 查询最新 BOM
// BomDO bomDO = bomMapper.selectOne(
// Wrappers.<BomDO>lambdaQuery()
// .eq(BomDO::getProductId, createReqVO.getProductId())
// .orderByDesc(BomDO::getCreateTime)
// .last("limit 1")
// );
//
// if (bomDO == null) {
// return success(false);
// }
//
// // 2 查询 BOM 明细
// List<BomDetailDO> bomDetails = bomDetailMapper.selectList(
// Wrappers.<BomDetailDO>lambdaQuery()
// .eq(BomDetailDO::getBomId, bomDO.getId())
// );
//
// if (bomDetails.isEmpty()) {
// return success(false);
// }
//
// // 3 查询仓库
// ErpWarehouseDO warehouse = erpWarehouseMapper.selectOne(
// Wrappers.<ErpWarehouseDO>lambdaQuery()
// .orderByDesc(ErpWarehouseDO::getCreateTime)
// .last("limit 1")
// );
//
// if (warehouse == null) {
// return success(false);
// }
//
// // 4 计算领料数量
// Long planNumber = Optional.ofNullable(createReqVO.getPlanNumber()).orElse(0L);
//
// itemList = bomDetails.stream().map(detail -> {
//
// BigDecimal usageNumber = Optional.ofNullable(detail.getUsageNumber()).orElse(BigDecimal.ZERO);
//
// BigDecimal count = usageNumber.multiply(BigDecimal.valueOf(planNumber));
//
// ErpStockOutSaveReqVO.Item item = new ErpStockOutSaveReqVO.Item();
// item.setProductId(detail.getProductId());
// item.setWarehouseId(warehouse.getId());
// item.setCount(count);
//
// return item;
//
// }).collect(Collectors.toList());
//
// // 5 构造出库单
// ErpStockOutSaveReqVO stockOut = new ErpStockOutSaveReqVO();
// stockOut.setOutType("领料出库");
// stockOut.setOutTime(LocalDateTime.now());
// stockOut.setItems(itemList);
//
// // 6 创建出库单
// erpStockOutService.createStockOut(stockOut);
return success(true);
}

@ -27,9 +27,19 @@ public class TaskRespVO {
private LocalDateTime orderDate;
@Schema(description = "交货日期", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("交货日期")
private LocalDateTime deliveryDate;
@Schema(description = "是否急单0-否 1-是 ", example = "1")
@ExcelProperty("是否急单")
@DictFormat("iot_1_or_0") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer isUrgent;
@Schema(description = "是否完成排产0-否 1-是 ", example = "1")
@ExcelProperty("是否完成排产")
@DictFormat("iot_1_or_0") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer isScheduled;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat("mes_task_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
@ -51,7 +61,13 @@ public class TaskRespVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "任务单类型", example = "你猜")
@ExcelProperty("任务单类型")
private String taskType;
}

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.mes.controller.admin.task.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@ -50,4 +52,11 @@ public class TaskSaveReqVO {
@Schema(description = "是否采用自动编码", example = "你猜")
private Boolean isCode;
@Schema(description = "是否急单0-否 1-是 ", example = "1")
private Integer isUrgent;
@Schema(description = "是否完成排产0-否 1-是 ", example = "1")
private Integer isScheduled;
}

@ -180,4 +180,14 @@ public class DeviceLedgerDO extends BaseDO {
*/
@TableField(exist = false)
private String qrcodeUrl;
/**
*
*/
private Integer isScheduled;
/**
*
*/
private Integer ratedCapacity;
}

@ -55,6 +55,17 @@ public class TaskDO extends BaseDO {
*
*/
private String remark;
/**
* 0- 1-
*/
private Integer isUrgent;
/**
* 0- 1-
*/
private Integer isScheduled;
/**
*
* <p>
@ -63,4 +74,5 @@ public class TaskDO extends BaseDO {
private Boolean isEnable;
@Schema(description = "任务单类型", example = "你猜")
private String taskType;
}

@ -174,7 +174,14 @@ public class BomServiceImpl implements BomService {
*/
@Override
public List<BomDetailDO> getBomDetailListByProductId(Long productId, Long number) {
if (productId == null) {
return Collections.emptyList();
}
BomDO bomDO = bomMapper.selectByProductId(productId);
if (bomDO == null || bomDO.getId() == null) {
throw exception(BOM_NOT_EXISTS);
}
List<BomDetailDO> list = bomDetailMapper.selectListByBomId(bomDO.getId());
for (BomDetailDO detail : list) {
BigDecimal result = detail.getUsageNumber().multiply(BigDecimal.valueOf(number));

@ -157,6 +157,39 @@ public class PlanServiceImpl implements PlanService {
plan.setStartTime(LocalDateTime.now());
plan.setRequisitionId(id);
planMapper.insert(plan);
//判断计划是否全部完成
//查询任务明细总需求
List<TaskDetailDO> detailList = taskService.getTaskDetailListByTaskId(plan.getTaskId());
long totalNeed = detailList.stream()
.map(TaskDetailDO::getNumber)
.filter(Objects::nonNull)
.mapToLong(Long::longValue)
.sum();
// 查询该任务已计划总量(累计 mes_plan.plan_number
List<PlanDO> taskPlanList = planMapper.selectList(
Wrappers.<PlanDO>lambdaQuery()
.eq(PlanDO::getTaskId, plan.getTaskId())
.eq(PlanDO::getDeleted, false)
);
long totalPlanned = taskPlanList.stream()
.map(PlanDO::getPlanNumber)
.filter(Objects::nonNull)
.mapToLong(Long::longValue)
.sum();
//完成则更新排产字段
if (totalNeed > 0 && totalPlanned >= totalNeed) {
TaskDO task = taskService.getTask(plan.getTaskId());
if (task != null) {
task.setIsScheduled(1);
taskService.updateTask(task);
}
}
saveReqVO.setPlanId(plan.getId());
saveReqVO.setId(id);
itemRequisitionService.updateItemRequisition(saveReqVO);

Loading…
Cancel
Save