diff --git a/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java b/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java index ab05ee70a0..a1076d16dd 100644 --- a/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java +++ b/yudao-module-mes/yudao-module-mes-api/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java @@ -53,4 +53,7 @@ public interface ErrorCodeConstants { ErrorCode STOCK_WORKSHOP_NOT_EXISTS = new ErrorCode(5_0081, "车间仓库存不存在"); ErrorCode FEEDING_RECORD_NOT_EXISTS = new ErrorCode(5_0081, "投料明细不存在"); + ErrorCode FEEDING_RECORD_PLAN_NOT_EXISTS = new ErrorCode(5_0082, "投料分配计划不存在"); + + } diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/FeedingRecordPlanController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/FeedingRecordPlanController.java new file mode 100644 index 0000000000..57f169230f --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/FeedingRecordPlanController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.mes.controller.admin.feedingplan; + +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.mes.controller.admin.feedingplan.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO; +import cn.iocoder.yudao.module.mes.service.feedingplan.FeedingRecordPlanService; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +@Tag(name = "管理后台 - 投料分配计划") +@RestController +@RequestMapping("/mes/feeding-record-plan") +@Validated +public class FeedingRecordPlanController { + + @Resource + private FeedingRecordPlanService feedingRecordPlanService; + + @PostMapping("/create") + @Operation(summary = "创建投料分配计划") + @PreAuthorize("@ss.hasPermission('mes:feeding-record-plan:create')") + public CommonResult createFeedingRecordPlan(@Valid @RequestBody FeedingRecordPlanSaveReqVO createReqVO) { + return success(feedingRecordPlanService.createFeedingRecordPlan(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新投料分配计划") + @PreAuthorize("@ss.hasPermission('mes:feeding-record-plan:update')") + public CommonResult updateFeedingRecordPlan(@Valid @RequestBody FeedingRecordPlanSaveReqVO updateReqVO) { + feedingRecordPlanService.updateFeedingRecordPlan(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除投料分配计划") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:feeding-record-plan:delete')") + public CommonResult deleteFeedingRecordPlan(@RequestParam("id") Long id) { + feedingRecordPlanService.deleteFeedingRecordPlan(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得投料分配计划") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:feeding-record-plan:query')") + public CommonResult getFeedingRecordPlan(@RequestParam("id") Long id) { + FeedingRecordPlanDO feedingRecordPlan = feedingRecordPlanService.getFeedingRecordPlan(id); + return success(BeanUtils.toBean(feedingRecordPlan, FeedingRecordPlanRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得投料分配计划分页") + @PreAuthorize("@ss.hasPermission('mes:feeding-record-plan:query')") + public CommonResult> getFeedingRecordPlanPage(@Valid FeedingRecordPlanPageReqVO pageReqVO) { + PageResult pageResult = feedingRecordPlanService.getFeedingRecordPlanPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, FeedingRecordPlanRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出投料分配计划 Excel") + @PreAuthorize("@ss.hasPermission('mes:feeding-record-plan:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportFeedingRecordPlanExcel(@Valid FeedingRecordPlanPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = feedingRecordPlanService.getFeedingRecordPlanPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "投料分配计划.xls", "数据", FeedingRecordPlanRespVO.class, + BeanUtils.toBean(list, FeedingRecordPlanRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanPageReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanPageReqVO.java new file mode 100644 index 0000000000..dca7c4e91a --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanPageReqVO.java @@ -0,0 +1,48 @@ +package cn.iocoder.yudao.module.mes.controller.admin.feedingplan.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.math.BigDecimal; +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 FeedingRecordPlanPageReqVO extends PageParam { + + @Schema(description = "记录id", example = "997") + private Long recordId; + + @Schema(description = "记录明细id", example = "2395") + private Long recordDetailId; + + @Schema(description = "计划id", example = "17658") + private Long planId; + + @Schema(description = "原料id", example = "19133") + private Long itemId; + + @Schema(description = "重量") + private BigDecimal weight; + + @Schema(description = "单位", example = "27598") + private Long unitId; + + @Schema(description = "记录人", example = "14853") + private Long userId; + + @Schema(description = "投料时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] feedingTime; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanRespVO.java new file mode 100644 index 0000000000..5929400bb5 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanRespVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.mes.controller.admin.feedingplan.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import java.math.BigDecimal; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 投料分配计划 Response VO") +@Data +@ExcelIgnoreUnannotated +public class FeedingRecordPlanRespVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "881") + @ExcelProperty("id") + private Long id; + + @Schema(description = "记录id", example = "997") + @ExcelProperty("记录id") + private Long recordId; + + @Schema(description = "记录明细id", example = "2395") + @ExcelProperty("记录明细id") + private Long recordDetailId; + + @Schema(description = "计划id", example = "17658") + @ExcelProperty("计划id") + private Long planId; + + @Schema(description = "原料id", example = "19133") + @ExcelProperty("原料id") + private Long itemId; + + @Schema(description = "重量") + @ExcelProperty("重量") + private BigDecimal weight; + + @Schema(description = "单位", example = "27598") + @ExcelProperty("单位") + private Long unitId; + + @Schema(description = "记录人", example = "14853") + @ExcelProperty("记录人") + private Long userId; + + @Schema(description = "投料时间") + @ExcelProperty("投料时间") + private LocalDateTime feedingTime; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanSaveReqVO.java new file mode 100644 index 0000000000..4c0209cd43 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingplan/vo/FeedingRecordPlanSaveReqVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.mes.controller.admin.feedingplan.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.math.BigDecimal; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 投料分配计划新增/修改 Request VO") +@Data +public class FeedingRecordPlanSaveReqVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "881") + private Long id; + + @Schema(description = "记录id", example = "997") + private Long recordId; + + @Schema(description = "记录明细id", example = "2395") + private Long recordDetailId; + + @Schema(description = "计划id", example = "17658") + private Long planId; + + @Schema(description = "原料id", example = "19133") + private Long itemId; + + @Schema(description = "重量") + private BigDecimal weight; + + @Schema(description = "单位", example = "27598") + private Long unitId; + + @Schema(description = "记录人", example = "14853") + private Long userId; + + @Schema(description = "投料时间") + private LocalDateTime feedingTime; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/FeedingRecordController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/FeedingRecordController.java index 81df46ae71..97d3a1124b 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/FeedingRecordController.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/FeedingRecordController.java @@ -1,16 +1,12 @@ package cn.iocoder.yudao.module.mes.controller.admin.feedingrecord; 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 javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; import java.util.*; import java.io.IOException; @@ -27,8 +23,13 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; import cn.iocoder.yudao.module.mes.controller.admin.feedingrecord.vo.*; import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO; import cn.iocoder.yudao.module.mes.service.feedingrecord.FeedingRecordService; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + @Tag(name = "管理后台 - 投料记录") @RestController @RequestMapping("/mes/feeding-record") @@ -92,4 +93,14 @@ public class FeedingRecordController { BeanUtils.toBean(list, FeedingRecordRespVO.class)); } + // ==================== 子表(投料记录明细) ==================== + + @GetMapping("/feeding-record-detail/list-by-record-id") + @Operation(summary = "获得投料记录明细列表") + @Parameter(name = "recordId", description = "记录id") + @PreAuthorize("@ss.hasPermission('mes:feeding-record:query')") + public CommonResult> getFeedingRecordDetailListByRecordId(@RequestParam("recordId") Long recordId) { + return success(feedingRecordService.getFeedingRecordDetailListByRecordId(recordId)); + } + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordRespVO.java index b6053239d1..a9f3abe8b2 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordRespVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordRespVO.java @@ -63,7 +63,8 @@ public class FeedingRecordRespVO { private String remark; @Schema(description = "状态", example = "1") - @ExcelProperty("状态") + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("mes_feeding_record_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 private String recordStatus; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordSaveReqVO.java index 5c2caffc37..af2d06252f 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordSaveReqVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/feedingrecord/vo/FeedingRecordSaveReqVO.java @@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.mes.controller.admin.feedingrecord.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; +import java.util.*; import java.math.BigDecimal; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO; @Schema(description = "管理后台 - 投料记录新增/修改 Request VO") @Data @@ -46,4 +48,7 @@ public class FeedingRecordSaveReqVO { @Schema(description = "状态", example = "1") private String recordStatus; + @Schema(description = "投料记录明细列表") + private List feedingRecordDetails; + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingplan/FeedingRecordPlanDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingplan/FeedingRecordPlanDO.java new file mode 100644 index 0000000000..d7be293997 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingplan/FeedingRecordPlanDO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +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("mes_feeding_record_plan") +@KeySequence("mes_feeding_record_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FeedingRecordPlanDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 记录id + */ + private Long recordId; + /** + * 记录明细id + */ + private Long recordDetailId; + /** + * 计划id + */ + private Long planId; + /** + * 原料id + */ + private Long itemId; + /** + * 重量 + */ + private BigDecimal weight; + /** + * 单位 + */ + private Long unitId; + /** + * 记录人 + */ + private Long userId; + /** + * 投料时间 + */ + private LocalDateTime feedingTime; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDO.java index 4ce42342c0..3f10070fd1 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDO.java @@ -75,6 +75,8 @@ public class FeedingRecordDO extends BaseDO { private String remark; /** * 状态 + * + * 枚举 {@link TODO mes_feeding_record_status 对应的类} */ private String recordStatus; diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDetailDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDetailDO.java new file mode 100644 index 0000000000..91910865dd --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/feedingrecord/FeedingRecordDetailDO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +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("mes_feeding_record_detail") +@KeySequence("mes_feeding_record_detail_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class FeedingRecordDetailDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 记录id + */ + private Long recordId; + /** + * 原料id + */ + private Long itemId; + /** + * 重量 + */ + private BigDecimal weight; + /** + * 单位 + */ + private Long unitId; + /** + * 记录人 + */ + private Long userId; + /** + * 投料时间 + */ + private LocalDateTime feedingTime; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/feedingplan/FeedingRecordPlanMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/feedingplan/FeedingRecordPlanMapper.java new file mode 100644 index 0000000000..94783c3e4c --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/feedingplan/FeedingRecordPlanMapper.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.feedingplan; + +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.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.mes.controller.admin.feedingplan.vo.*; + +/** + * 投料分配计划 Mapper + * + * @author 内蒙必硕 + */ +@Mapper +public interface FeedingRecordPlanMapper extends BaseMapperX { + + default PageResult selectPage(FeedingRecordPlanPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(FeedingRecordPlanDO::getRecordId, reqVO.getRecordId()) + .eqIfPresent(FeedingRecordPlanDO::getRecordDetailId, reqVO.getRecordDetailId()) + .eqIfPresent(FeedingRecordPlanDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(FeedingRecordPlanDO::getItemId, reqVO.getItemId()) + .eqIfPresent(FeedingRecordPlanDO::getWeight, reqVO.getWeight()) + .eqIfPresent(FeedingRecordPlanDO::getUnitId, reqVO.getUnitId()) + .eqIfPresent(FeedingRecordPlanDO::getUserId, reqVO.getUserId()) + .betweenIfPresent(FeedingRecordPlanDO::getFeedingTime, reqVO.getFeedingTime()) + .betweenIfPresent(FeedingRecordPlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(FeedingRecordPlanDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/feedingrecord/FeedingRecordDetailMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/feedingrecord/FeedingRecordDetailMapper.java new file mode 100644 index 0000000000..880e5d05e2 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/feedingrecord/FeedingRecordDetailMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord; + +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.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 投料记录明细 Mapper + * + * @author 内蒙必硕 + */ +@Mapper +public interface FeedingRecordDetailMapper extends BaseMapperX { + + default List selectListByRecordId(Long recordId) { + return selectList(FeedingRecordDetailDO::getRecordId, recordId); + } + + default int deleteByRecordId(Long recordId) { + return delete(FeedingRecordDetailDO::getRecordId, recordId); + } + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanService.java new file mode 100644 index 0000000000..fa6d76a392 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.mes.service.feedingplan; + +import cn.iocoder.yudao.module.mes.controller.admin.feedingplan.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +import javax.validation.Valid; + +/** + * 投料分配计划 Service 接口 + * + * @author 内蒙必硕 + */ +public interface FeedingRecordPlanService { + + /** + * 创建投料分配计划 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createFeedingRecordPlan(@Valid FeedingRecordPlanSaveReqVO createReqVO); + + /** + * 更新投料分配计划 + * + * @param updateReqVO 更新信息 + */ + void updateFeedingRecordPlan(@Valid FeedingRecordPlanSaveReqVO updateReqVO); + + /** + * 删除投料分配计划 + * + * @param id 编号 + */ + void deleteFeedingRecordPlan(Long id); + + /** + * 获得投料分配计划 + * + * @param id 编号 + * @return 投料分配计划 + */ + FeedingRecordPlanDO getFeedingRecordPlan(Long id); + + /** + * 获得投料分配计划分页 + * + * @param pageReqVO 分页查询 + * @return 投料分配计划分页 + */ + PageResult getFeedingRecordPlanPage(FeedingRecordPlanPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanServiceImpl.java new file mode 100644 index 0000000000..856effec21 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanServiceImpl.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.mes.service.feedingplan; + +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.mes.controller.admin.feedingplan.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO; +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.feedingplan.FeedingRecordPlanMapper; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; + +/** + * 投料分配计划 Service 实现类 + * + * @author 内蒙必硕 + */ +@Service +@Validated +public class FeedingRecordPlanServiceImpl implements FeedingRecordPlanService { + + @Resource + private FeedingRecordPlanMapper feedingRecordPlanMapper; + + @Override + public Long createFeedingRecordPlan(FeedingRecordPlanSaveReqVO createReqVO) { + // 插入 + FeedingRecordPlanDO feedingRecordPlan = BeanUtils.toBean(createReqVO, FeedingRecordPlanDO.class); + feedingRecordPlanMapper.insert(feedingRecordPlan); + // 返回 + return feedingRecordPlan.getId(); + } + + @Override + public void updateFeedingRecordPlan(FeedingRecordPlanSaveReqVO updateReqVO) { + // 校验存在 + validateFeedingRecordPlanExists(updateReqVO.getId()); + // 更新 + FeedingRecordPlanDO updateObj = BeanUtils.toBean(updateReqVO, FeedingRecordPlanDO.class); + feedingRecordPlanMapper.updateById(updateObj); + } + + @Override + public void deleteFeedingRecordPlan(Long id) { + // 校验存在 + validateFeedingRecordPlanExists(id); + // 删除 + feedingRecordPlanMapper.deleteById(id); + } + + private void validateFeedingRecordPlanExists(Long id) { + if (feedingRecordPlanMapper.selectById(id) == null) { + throw exception(FEEDING_RECORD_PLAN_NOT_EXISTS); + } + } + + @Override + public FeedingRecordPlanDO getFeedingRecordPlan(Long id) { + return feedingRecordPlanMapper.selectById(id); + } + + @Override + public PageResult getFeedingRecordPlanPage(FeedingRecordPlanPageReqVO pageReqVO) { + return feedingRecordPlanMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordService.java index db6d0c0204..8b9cd9eb63 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordService.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordService.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.service.feedingrecord; import java.util.*; import cn.iocoder.yudao.module.mes.controller.admin.feedingrecord.vo.*; import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; @@ -53,4 +54,14 @@ public interface FeedingRecordService { */ PageResult getFeedingRecordPage(FeedingRecordPageReqVO pageReqVO); + // ==================== 子表(投料记录明细) ==================== + + /** + * 获得投料记录明细列表 + * + * @param recordId 记录id + * @return 投料记录明细列表 + */ + List getFeedingRecordDetailListByRecordId(Long recordId); + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImpl.java index 4bfe0ff804..ba9d52c5a0 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImpl.java @@ -7,11 +7,13 @@ import org.springframework.transaction.annotation.Transactional; import java.util.*; import cn.iocoder.yudao.module.mes.controller.admin.feedingrecord.vo.*; import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDetailDO; 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.feedingrecord.FeedingRecordMapper; +import cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord.FeedingRecordDetailMapper; import javax.annotation.Resource; @@ -29,31 +31,45 @@ public class FeedingRecordServiceImpl implements FeedingRecordService { @Resource private FeedingRecordMapper feedingRecordMapper; + @Resource + private FeedingRecordDetailMapper feedingRecordDetailMapper; @Override + @Transactional(rollbackFor = Exception.class) public Long createFeedingRecord(FeedingRecordSaveReqVO createReqVO) { // 插入 FeedingRecordDO feedingRecord = BeanUtils.toBean(createReqVO, FeedingRecordDO.class); feedingRecordMapper.insert(feedingRecord); + + // 插入子表 + createFeedingRecordDetailList(feedingRecord.getId(), createReqVO.getFeedingRecordDetails()); // 返回 return feedingRecord.getId(); } @Override + @Transactional(rollbackFor = Exception.class) public void updateFeedingRecord(FeedingRecordSaveReqVO updateReqVO) { // 校验存在 validateFeedingRecordExists(updateReqVO.getId()); // 更新 FeedingRecordDO updateObj = BeanUtils.toBean(updateReqVO, FeedingRecordDO.class); feedingRecordMapper.updateById(updateObj); + + // 更新子表 + updateFeedingRecordDetailList(updateReqVO.getId(), updateReqVO.getFeedingRecordDetails()); } @Override + @Transactional(rollbackFor = Exception.class) public void deleteFeedingRecord(Long id) { // 校验存在 validateFeedingRecordExists(id); // 删除 feedingRecordMapper.deleteById(id); + + // 删除子表 + deleteFeedingRecordDetailByRecordId(id); } private void validateFeedingRecordExists(Long id) { @@ -72,4 +88,26 @@ public class FeedingRecordServiceImpl implements FeedingRecordService { return feedingRecordMapper.selectPage(pageReqVO); } + // ==================== 子表(投料记录明细) ==================== + + @Override + public List getFeedingRecordDetailListByRecordId(Long recordId) { + return feedingRecordDetailMapper.selectListByRecordId(recordId); + } + + private void createFeedingRecordDetailList(Long recordId, List list) { + list.forEach(o -> o.setRecordId(recordId)); + feedingRecordDetailMapper.insertBatch(list); + } + + private void updateFeedingRecordDetailList(Long recordId, List list) { + deleteFeedingRecordDetailByRecordId(recordId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createFeedingRecordDetailList(recordId, list); + } + + private void deleteFeedingRecordDetailByRecordId(Long recordId) { + feedingRecordDetailMapper.deleteByRecordId(recordId); + } + } \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/feedingplan/FeedingRecordPlanMapper.xml b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/feedingplan/FeedingRecordPlanMapper.xml new file mode 100644 index 0000000000..a66d7f0d64 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/feedingplan/FeedingRecordPlanMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanServiceImplTest.java b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanServiceImplTest.java new file mode 100644 index 0000000000..6cb12d5f31 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingplan/FeedingRecordPlanServiceImplTest.java @@ -0,0 +1,160 @@ +package cn.iocoder.yudao.module.mes.service.feedingplan; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.mes.controller.admin.feedingplan.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.feedingplan.FeedingRecordPlanDO; +import cn.iocoder.yudao.module.mes.dal.mysql.feedingplan.FeedingRecordPlanMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link FeedingRecordPlanServiceImpl} 的单元测试类 + * + * @author 内蒙必硕 + */ +@Import(FeedingRecordPlanServiceImpl.class) +public class FeedingRecordPlanServiceImplTest extends BaseDbUnitTest { + + @Resource + private FeedingRecordPlanServiceImpl feedingRecordPlanService; + + @Resource + private FeedingRecordPlanMapper feedingRecordPlanMapper; + + @Test + public void testCreateFeedingRecordPlan_success() { + // 准备参数 + FeedingRecordPlanSaveReqVO createReqVO = randomPojo(FeedingRecordPlanSaveReqVO.class).setId(null); + + // 调用 + Long feedingRecordPlanId = feedingRecordPlanService.createFeedingRecordPlan(createReqVO); + // 断言 + assertNotNull(feedingRecordPlanId); + // 校验记录的属性是否正确 + FeedingRecordPlanDO feedingRecordPlan = feedingRecordPlanMapper.selectById(feedingRecordPlanId); + assertPojoEquals(createReqVO, feedingRecordPlan, "id"); + } + + @Test + public void testUpdateFeedingRecordPlan_success() { + // mock 数据 + FeedingRecordPlanDO dbFeedingRecordPlan = randomPojo(FeedingRecordPlanDO.class); + feedingRecordPlanMapper.insert(dbFeedingRecordPlan);// @Sql: 先插入出一条存在的数据 + // 准备参数 + FeedingRecordPlanSaveReqVO updateReqVO = randomPojo(FeedingRecordPlanSaveReqVO.class, o -> { + o.setId(dbFeedingRecordPlan.getId()); // 设置更新的 ID + }); + + // 调用 + feedingRecordPlanService.updateFeedingRecordPlan(updateReqVO); + // 校验是否更新正确 + FeedingRecordPlanDO feedingRecordPlan = feedingRecordPlanMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, feedingRecordPlan); + } + + @Test + public void testUpdateFeedingRecordPlan_notExists() { + // 准备参数 + FeedingRecordPlanSaveReqVO updateReqVO = randomPojo(FeedingRecordPlanSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> feedingRecordPlanService.updateFeedingRecordPlan(updateReqVO), FEEDING_RECORD_PLAN_NOT_EXISTS); + } + + @Test + public void testDeleteFeedingRecordPlan_success() { + // mock 数据 + FeedingRecordPlanDO dbFeedingRecordPlan = randomPojo(FeedingRecordPlanDO.class); + feedingRecordPlanMapper.insert(dbFeedingRecordPlan);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbFeedingRecordPlan.getId(); + + // 调用 + feedingRecordPlanService.deleteFeedingRecordPlan(id); + // 校验数据不存在了 + assertNull(feedingRecordPlanMapper.selectById(id)); + } + + @Test + public void testDeleteFeedingRecordPlan_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> feedingRecordPlanService.deleteFeedingRecordPlan(id), FEEDING_RECORD_PLAN_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetFeedingRecordPlanPage() { + // mock 数据 + FeedingRecordPlanDO dbFeedingRecordPlan = randomPojo(FeedingRecordPlanDO.class, o -> { // 等会查询到 + o.setRecordId(null); + o.setRecordDetailId(null); + o.setPlanId(null); + o.setItemId(null); + o.setWeight(null); + o.setUnitId(null); + o.setUserId(null); + o.setFeedingTime(null); + o.setCreateTime(null); + }); + feedingRecordPlanMapper.insert(dbFeedingRecordPlan); + // 测试 recordId 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setRecordId(null))); + // 测试 recordDetailId 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setRecordDetailId(null))); + // 测试 planId 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setPlanId(null))); + // 测试 itemId 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setItemId(null))); + // 测试 weight 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setWeight(null))); + // 测试 unitId 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setUnitId(null))); + // 测试 userId 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setUserId(null))); + // 测试 feedingTime 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setFeedingTime(null))); + // 测试 createTime 不匹配 + feedingRecordPlanMapper.insert(cloneIgnoreId(dbFeedingRecordPlan, o -> o.setCreateTime(null))); + // 准备参数 + FeedingRecordPlanPageReqVO reqVO = new FeedingRecordPlanPageReqVO(); + reqVO.setRecordId(null); + reqVO.setRecordDetailId(null); + reqVO.setPlanId(null); + reqVO.setItemId(null); + reqVO.setWeight(null); + reqVO.setUnitId(null); + reqVO.setUserId(null); + reqVO.setFeedingTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = feedingRecordPlanService.getFeedingRecordPlanPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbFeedingRecordPlan, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImplTest.java b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImplTest.java index 35520ef11c..acb59be426 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImplTest.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/feedingrecord/FeedingRecordServiceImplTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; + import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.mes.controller.admin.feedingrecord.vo.*; @@ -11,6 +12,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.feedingrecord.FeedingRecordDO; import cn.iocoder.yudao.module.mes.dal.mysql.feedingrecord.FeedingRecordMapper; import cn.iocoder.yudao.framework.common.pojo.PageResult; + import org.springframework.context.annotation.Import; import javax.annotation.Resource; diff --git a/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/clean.sql b/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/clean.sql index 954ee9ae3e..4b3d75fd9b 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/clean.sql @@ -24,24 +24,20 @@ DELETE FROM "mes_record_suijiang"; DELETE FROM "mes_work_team"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_work_team_detail"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_produce_report"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_produce_report_detail"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_machine_component"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_stock_workshop_detail"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_stock_workshop"; --- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_feeding_record"; +DELETE FROM "mes_feeding_record_plan"; +-- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "mes_feeding_record_detail"; diff --git a/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/create_tables.sql index 2a9bc43b3e..275bdff9f3 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-mes/yudao-module-mes-biz/src/test/resources/sql/create_tables.sql @@ -356,7 +356,7 @@ CREATE TABLE IF NOT EXISTS "mes_feeding_record" "updater" varchar DEFAULT '', "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint , + "tenant_id" bigint, PRIMARY KEY ("id") ) COMMENT '投料记录'; CREATE TABLE IF NOT EXISTS "mes_stock_workshop" @@ -370,7 +370,7 @@ CREATE TABLE IF NOT EXISTS "mes_stock_workshop" "updater" varchar DEFAULT '', "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint , + "tenant_id" bigint, PRIMARY KEY ("id") ) COMMENT '车间仓库存'; CREATE TABLE IF NOT EXISTS "mes_stock_workshop_detail" @@ -390,8 +390,45 @@ CREATE TABLE IF NOT EXISTS "mes_stock_workshop_detail" "updater" varchar DEFAULT '', "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, - "tenant_id" bigint , + "tenant_id" bigint, PRIMARY KEY ("id") ) COMMENT '车间仓出入库明细'; +CREATE TABLE IF NOT EXISTS "mes_feeding_record_plan" +( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "record_id" bigint, + "record_detail_id" bigint, + "plan_id" bigint, + "item_id" bigint, + "weight" varchar, + "unit_id" bigint, + "user_id" bigint, + "feeding_time" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint, + PRIMARY KEY ("id") +) COMMENT '投料记录分配计划'; + +CREATE TABLE IF NOT EXISTS "mes_feeding_record_detail" +( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "record_id" bigint, + "item_id" bigint, + "weight" varchar, + "unit_id" bigint, + "user_id" bigint, + "feeding_time" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint, + PRIMARY KEY ("id") +) COMMENT '投料记录明细';