diff --git a/sql/mysql/mesdata.sql b/sql/mysql/mesdata.sql index df0af3a685..07b2373360 100644 --- a/sql/mysql/mesdata.sql +++ b/sql/mysql/mesdata.sql @@ -271,3 +271,27 @@ CREATE TABLE `mes_error_record` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC COMMENT ='错误记录'; + + +CREATE TABLE `mes_stock_in_detail` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `stock_in_id` bigint DEFAULT NULL COMMENT '入库单id', + `stock_in_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '入库单编号', + `stock_in_item_id` bigint DEFAULT NULL COMMENT '入库单项id', + `plan_id` bigint DEFAULT NULL COMMENT '计划id', + `product_id` bigint DEFAULT NULL COMMENT '产品', + `number` decimal(24, 6) DEFAULT NULL 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 NOT NULL DEFAULT '0' COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB + AUTO_INCREMENT = 2 + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_unicode_ci + ROW_FORMAT = DYNAMIC COMMENT ='生产入库分配明细'; 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 a1076d16dd..f5c762ed89 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 @@ -54,6 +54,7 @@ public interface ErrorCodeConstants { ErrorCode FEEDING_RECORD_NOT_EXISTS = new ErrorCode(5_0081, "投料明细不存在"); ErrorCode FEEDING_RECORD_PLAN_NOT_EXISTS = new ErrorCode(5_0082, "投料分配计划不存在"); - + ErrorCode STOCK_IN_DETAIL_NOT_EXISTS = new ErrorCode(5_0082, "生产入库分配计划不存在"); + ErrorCode ERROR_RECORD_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/errorrecord/ErrorRecordController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/ErrorRecordController.java new file mode 100644 index 0000000000..cade5a8ae5 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/ErrorRecordController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.mes.controller.admin.errorrecord; + +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.mes.controller.admin.errorrecord.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.errorrecord.ErrorRecordDO; +import cn.iocoder.yudao.module.mes.service.errorrecord.ErrorRecordService; + +@Tag(name = "管理后台 - 错误记录") +@RestController +@RequestMapping("/mes/error-record") +@Validated +public class ErrorRecordController { + + @Resource + private ErrorRecordService errorRecordService; + + @PostMapping("/create") + @Operation(summary = "创建错误记录") + @PreAuthorize("@ss.hasPermission('mes:error-record:create')") + public CommonResult createErrorRecord(@Valid @RequestBody ErrorRecordSaveReqVO createReqVO) { + return success(errorRecordService.createErrorRecord(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新错误记录") + @PreAuthorize("@ss.hasPermission('mes:error-record:update')") + public CommonResult updateErrorRecord(@Valid @RequestBody ErrorRecordSaveReqVO updateReqVO) { + errorRecordService.updateErrorRecord(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除错误记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:error-record:delete')") + public CommonResult deleteErrorRecord(@RequestParam("id") Long id) { + errorRecordService.deleteErrorRecord(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得错误记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:error-record:query')") + public CommonResult getErrorRecord(@RequestParam("id") Long id) { + ErrorRecordDO errorRecord = errorRecordService.getErrorRecord(id); + return success(BeanUtils.toBean(errorRecord, ErrorRecordRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得错误记录分页") + @PreAuthorize("@ss.hasPermission('mes:error-record:query')") + public CommonResult> getErrorRecordPage(@Valid ErrorRecordPageReqVO pageReqVO) { + PageResult pageResult = errorRecordService.getErrorRecordPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, ErrorRecordRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出错误记录 Excel") + @PreAuthorize("@ss.hasPermission('mes:error-record:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportErrorRecordExcel(@Valid ErrorRecordPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = errorRecordService.getErrorRecordPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "错误记录.xls", "数据", ErrorRecordRespVO.class, + BeanUtils.toBean(list, ErrorRecordRespVO.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/errorrecord/vo/ErrorRecordPageReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/vo/ErrorRecordPageReqVO.java new file mode 100644 index 0000000000..38f545b572 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/vo/ErrorRecordPageReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.controller.admin.errorrecord.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 ErrorRecordPageReqVO extends PageParam { + + @Schema(description = "标题") + private String title; + + @Schema(description = "位置") + private String location; + + @Schema(description = "异常") + private String exception; + + @Schema(description = "前数据") + private String preData; + + @Schema(description = "后数据") + private String postData; + + @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/errorrecord/vo/ErrorRecordRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/vo/ErrorRecordRespVO.java new file mode 100644 index 0000000000..5ee873b866 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/vo/ErrorRecordRespVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.mes.controller.admin.errorrecord.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +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 ErrorRecordRespVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31541") + @ExcelProperty("id") + private Long id; + + @Schema(description = "标题") + @ExcelProperty("标题") + private String title; + + @Schema(description = "位置") + @ExcelProperty("位置") + private String location; + + @Schema(description = "异常") + @ExcelProperty("异常") + private String exception; + + @Schema(description = "前数据") + @ExcelProperty("前数据") + private String preData; + + @Schema(description = "后数据") + @ExcelProperty("后数据") + private String postData; + + @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/errorrecord/vo/ErrorRecordSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/vo/ErrorRecordSaveReqVO.java new file mode 100644 index 0000000000..de75a298a6 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/errorrecord/vo/ErrorRecordSaveReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.mes.controller.admin.errorrecord.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 ErrorRecordSaveReqVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31541") + private Long id; + + @Schema(description = "标题") + private String title; + + @Schema(description = "位置") + private String location; + + @Schema(description = "异常") + private String exception; + + @Schema(description = "前数据") + private String preData; + + @Schema(description = "后数据") + private String postData; + +} \ 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/stockindetail/StockInDetailController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/StockInDetailController.java new file mode 100644 index 0000000000..848d8299ea --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/StockInDetailController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.mes.controller.admin.stockindetail; + +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.mes.controller.admin.stockindetail.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.stockindetail.StockInDetailDO; +import cn.iocoder.yudao.module.mes.service.stockindetail.StockInDetailService; + +@Tag(name = "管理后台 - 生产入库分配明细") +@RestController +@RequestMapping("/mes/stock-in-detail") +@Validated +public class StockInDetailController { + + @Resource + private StockInDetailService stockInDetailService; + + @PostMapping("/create") + @Operation(summary = "创建生产入库分配明细") + @PreAuthorize("@ss.hasPermission('mes:stock-in-detail:create')") + public CommonResult createStockInDetail(@Valid @RequestBody StockInDetailSaveReqVO createReqVO) { + return success(stockInDetailService.createStockInDetail(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新生产入库分配明细") + @PreAuthorize("@ss.hasPermission('mes:stock-in-detail:update')") + public CommonResult updateStockInDetail(@Valid @RequestBody StockInDetailSaveReqVO updateReqVO) { + stockInDetailService.updateStockInDetail(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除生产入库分配明细") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:stock-in-detail:delete')") + public CommonResult deleteStockInDetail(@RequestParam("id") Long id) { + stockInDetailService.deleteStockInDetail(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得生产入库分配明细") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:stock-in-detail:query')") + public CommonResult getStockInDetail(@RequestParam("id") Long id) { + StockInDetailDO stockInDetail = stockInDetailService.getStockInDetail(id); + return success(BeanUtils.toBean(stockInDetail, StockInDetailRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得生产入库分配明细分页") + @PreAuthorize("@ss.hasPermission('mes:stock-in-detail:query')") + public CommonResult> getStockInDetailPage(@Valid StockInDetailPageReqVO pageReqVO) { + PageResult pageResult = stockInDetailService.getStockInDetailPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, StockInDetailRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出生产入库分配明细 Excel") + @PreAuthorize("@ss.hasPermission('mes:stock-in-detail:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportStockInDetailExcel(@Valid StockInDetailPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = stockInDetailService.getStockInDetailPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "生产入库分配明细.xls", "数据", StockInDetailRespVO.class, + BeanUtils.toBean(list, StockInDetailRespVO.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/stockindetail/vo/StockInDetailPageReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/vo/StockInDetailPageReqVO.java new file mode 100644 index 0000000000..4095f799fd --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/vo/StockInDetailPageReqVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.mes.controller.admin.stockindetail.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 StockInDetailPageReqVO extends PageParam { + + @Schema(description = "入库单id", example = "6344") + private Long stockInId; + + @Schema(description = "入库单编号") + private String stockInNo; + + @Schema(description = "入库单项id", example = "24135") + private Long stockInItemId; + + @Schema(description = "计划id", example = "24750") + private Long planId; + + @Schema(description = "产品", example = "258") + private Long productId; + + @Schema(description = "数量") + private BigDecimal number; + + @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/stockindetail/vo/StockInDetailRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/vo/StockInDetailRespVO.java new file mode 100644 index 0000000000..b1d0a4de35 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/vo/StockInDetailRespVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.mes.controller.admin.stockindetail.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 StockInDetailRespVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1487") + @ExcelProperty("id") + private Long id; + + @Schema(description = "入库单id", example = "6344") + @ExcelProperty("入库单id") + private Long stockInId; + + @Schema(description = "入库单编号") + @ExcelProperty("入库单编号") + private String stockInNo; + + @Schema(description = "入库单项id", example = "24135") + @ExcelProperty("入库单项id") + private Long stockInItemId; + + @Schema(description = "计划id", example = "24750") + @ExcelProperty("计划id") + private Long planId; + + @Schema(description = "产品", example = "258") + @ExcelProperty("产品") + private Long productId; + + @Schema(description = "数量") + @ExcelProperty("数量") + private BigDecimal number; + + @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/stockindetail/vo/StockInDetailSaveReqVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/vo/StockInDetailSaveReqVO.java new file mode 100644 index 0000000000..65d9ac2769 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockindetail/vo/StockInDetailSaveReqVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.mes.controller.admin.stockindetail.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import java.math.BigDecimal; + +@Schema(description = "管理后台 - 生产入库分配明细新增/修改 Request VO") +@Data +public class StockInDetailSaveReqVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1487") + private Long id; + + @Schema(description = "入库单id", example = "6344") + private Long stockInId; + + @Schema(description = "入库单编号") + private String stockInNo; + + @Schema(description = "入库单项id", example = "24135") + private Long stockInItemId; + + @Schema(description = "计划id", example = "24750") + private Long planId; + + @Schema(description = "产品", example = "258") + private Long productId; + + @Schema(description = "数量") + private BigDecimal number; + +} \ 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/stockworkshop/MesStockInController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockworkshop/MesStockInController.java new file mode 100644 index 0000000000..34b3c236ae --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockworkshop/MesStockInController.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.mes.controller.admin.stockworkshop; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 生产入库单") +@RestController +@RequestMapping("/mes/stock-in") +@Validated +public class MesStockInController { + + @Resource + private ErpStockInService stockInService; + + @PutMapping("/update-status") + @Operation(summary = "更新入库单的状态") + @PreAuthorize("@ss.hasPermission('erp:stock-in:update-status')") + public CommonResult updateStockInStatus(@RequestParam("id") Long id, + @RequestParam("status") Integer status) { + stockInService.updateStockInStatus(id, status); + return success(true); + } + +} \ 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/stockworkshop/MesStockOutController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockworkshop/MesStockOutController.java index 90f05c8a56..15e5059b16 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockworkshop/MesStockOutController.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/stockworkshop/MesStockOutController.java @@ -1,8 +1,6 @@ package cn.iocoder.yudao.module.mes.controller.admin.stockworkshop; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockOutService; -import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; import cn.iocoder.yudao.module.mes.service.stockworkshop.MesStockOutService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,10 +20,6 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Validated public class MesStockOutController { - @Resource - private ErpStockOutService stockOutService; - @Resource - private ErpStockService stockService; @Resource private MesStockOutService mesStockOutService; diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/errorrecord/ErrorRecordDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/errorrecord/ErrorRecordDO.java new file mode 100644 index 0000000000..9c2724c253 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/errorrecord/ErrorRecordDO.java @@ -0,0 +1,51 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.errorrecord; + +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("mes_error_record") +@KeySequence("mes_error_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ErrorRecordDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 标题 + */ + private String title; + /** + * 位置 + */ + private String location; + /** + * 异常 + */ + private String exception; + /** + * 前数据 + */ + private String preData; + /** + * 后数据 + */ + private String postData; + +} \ 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/stockindetail/StockInDetailDO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/stockindetail/StockInDetailDO.java new file mode 100644 index 0000000000..51da80323f --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/stockindetail/StockInDetailDO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.stockindetail; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +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_stock_in_detail") +@KeySequence("mes_stock_in_detail_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StockInDetailDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 入库单id + */ + private Long stockInId; + /** + * 入库单编号 + */ + private String stockInNo; + /** + * 入库单项id + */ + private Long stockInItemId; + /** + * 计划id + */ + private Long planId; + /** + * 产品 + */ + private Long productId; + /** + * 数量 + */ + private BigDecimal number; + +} \ 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/errorrecord/ErrorRecordMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/errorrecord/ErrorRecordMapper.java new file mode 100644 index 0000000000..140a18084c --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/errorrecord/ErrorRecordMapper.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.errorrecord; + +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.errorrecord.ErrorRecordDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.mes.controller.admin.errorrecord.vo.*; + +/** + * 错误记录 Mapper + * + * @author 内蒙必硕 + */ +@Mapper +public interface ErrorRecordMapper extends BaseMapperX { + + default PageResult selectPage(ErrorRecordPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ErrorRecordDO::getTitle, reqVO.getTitle()) + .eqIfPresent(ErrorRecordDO::getLocation, reqVO.getLocation()) + .eqIfPresent(ErrorRecordDO::getException, reqVO.getException()) + .eqIfPresent(ErrorRecordDO::getPreData, reqVO.getPreData()) + .eqIfPresent(ErrorRecordDO::getPostData, reqVO.getPostData()) + .betweenIfPresent(ErrorRecordDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ErrorRecordDO::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/stockindetail/StockInDetailMapper.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/stockindetail/StockInDetailMapper.java new file mode 100644 index 0000000000..d06257ec14 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/stockindetail/StockInDetailMapper.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.stockindetail; + +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.stockindetail.StockInDetailDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.mes.controller.admin.stockindetail.vo.*; + +/** + * 生产入库分配明细 Mapper + * + * @author 内蒙必硕 + */ +@Mapper +public interface StockInDetailMapper extends BaseMapperX { + + default PageResult selectPage(StockInDetailPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(StockInDetailDO::getStockInId, reqVO.getStockInId()) + .eqIfPresent(StockInDetailDO::getStockInNo, reqVO.getStockInNo()) + .eqIfPresent(StockInDetailDO::getStockInItemId, reqVO.getStockInItemId()) + .eqIfPresent(StockInDetailDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(StockInDetailDO::getProductId, reqVO.getProductId()) + .eqIfPresent(StockInDetailDO::getNumber, reqVO.getNumber()) + .betweenIfPresent(StockInDetailDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(StockInDetailDO::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/service/errorrecord/ErrorRecordService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/errorrecord/ErrorRecordService.java new file mode 100644 index 0000000000..b2b9c507e2 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/errorrecord/ErrorRecordService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.mes.service.errorrecord; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.mes.controller.admin.errorrecord.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.errorrecord.ErrorRecordDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 错误记录 Service 接口 + * + * @author 内蒙必硕 + */ +public interface ErrorRecordService { + + /** + * 创建错误记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createErrorRecord(@Valid ErrorRecordSaveReqVO createReqVO); + + /** + * 更新错误记录 + * + * @param updateReqVO 更新信息 + */ + void updateErrorRecord(@Valid ErrorRecordSaveReqVO updateReqVO); + + /** + * 删除错误记录 + * + * @param id 编号 + */ + void deleteErrorRecord(Long id); + + /** + * 获得错误记录 + * + * @param id 编号 + * @return 错误记录 + */ + ErrorRecordDO getErrorRecord(Long id); + + /** + * 获得错误记录分页 + * + * @param pageReqVO 分页查询 + * @return 错误记录分页 + */ + PageResult getErrorRecordPage(ErrorRecordPageReqVO 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/errorrecord/ErrorRecordServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/errorrecord/ErrorRecordServiceImpl.java new file mode 100644 index 0000000000..793385920d --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/errorrecord/ErrorRecordServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.mes.service.errorrecord; + +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.mes.controller.admin.errorrecord.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.errorrecord.ErrorRecordDO; +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.errorrecord.ErrorRecordMapper; + +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 ErrorRecordServiceImpl implements ErrorRecordService { + + @Resource + private ErrorRecordMapper errorRecordMapper; + + @Override + public Long createErrorRecord(ErrorRecordSaveReqVO createReqVO) { + // 插入 + ErrorRecordDO errorRecord = BeanUtils.toBean(createReqVO, ErrorRecordDO.class); + errorRecordMapper.insert(errorRecord); + // 返回 + return errorRecord.getId(); + } + + @Override + public void updateErrorRecord(ErrorRecordSaveReqVO updateReqVO) { + // 校验存在 + validateErrorRecordExists(updateReqVO.getId()); + // 更新 + ErrorRecordDO updateObj = BeanUtils.toBean(updateReqVO, ErrorRecordDO.class); + errorRecordMapper.updateById(updateObj); + } + + @Override + public void deleteErrorRecord(Long id) { + // 校验存在 + validateErrorRecordExists(id); + // 删除 + errorRecordMapper.deleteById(id); + } + + private void validateErrorRecordExists(Long id) { + if (errorRecordMapper.selectById(id) == null) { + throw exception(ERROR_RECORD_NOT_EXISTS); + } + } + + @Override + public ErrorRecordDO getErrorRecord(Long id) { + return errorRecordMapper.selectById(id); + } + + @Override + public PageResult getErrorRecordPage(ErrorRecordPageReqVO pageReqVO) { + return errorRecordMapper.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/stockindetail/StockInDetailService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockindetail/StockInDetailService.java new file mode 100644 index 0000000000..2c503567c1 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockindetail/StockInDetailService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.mes.service.stockindetail; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.mes.controller.admin.stockindetail.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.stockindetail.StockInDetailDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 生产入库分配明细 Service 接口 + * + * @author 内蒙必硕 + */ +public interface StockInDetailService { + + /** + * 创建生产入库分配明细 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStockInDetail(@Valid StockInDetailSaveReqVO createReqVO); + + /** + * 更新生产入库分配明细 + * + * @param updateReqVO 更新信息 + */ + void updateStockInDetail(@Valid StockInDetailSaveReqVO updateReqVO); + + /** + * 删除生产入库分配明细 + * + * @param id 编号 + */ + void deleteStockInDetail(Long id); + + /** + * 获得生产入库分配明细 + * + * @param id 编号 + * @return 生产入库分配明细 + */ + StockInDetailDO getStockInDetail(Long id); + + /** + * 获得生产入库分配明细分页 + * + * @param pageReqVO 分页查询 + * @return 生产入库分配明细分页 + */ + PageResult getStockInDetailPage(StockInDetailPageReqVO 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/stockindetail/StockInDetailServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockindetail/StockInDetailServiceImpl.java new file mode 100644 index 0000000000..183ef850a0 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockindetail/StockInDetailServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.mes.service.stockindetail; + +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.mes.controller.admin.stockindetail.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.stockindetail.StockInDetailDO; +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.stockindetail.StockInDetailMapper; + +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 StockInDetailServiceImpl implements StockInDetailService { + + @Resource + private StockInDetailMapper stockInDetailMapper; + + @Override + public Long createStockInDetail(StockInDetailSaveReqVO createReqVO) { + // 插入 + StockInDetailDO stockInDetail = BeanUtils.toBean(createReqVO, StockInDetailDO.class); + stockInDetailMapper.insert(stockInDetail); + // 返回 + return stockInDetail.getId(); + } + + @Override + public void updateStockInDetail(StockInDetailSaveReqVO updateReqVO) { + // 校验存在 + validateStockInDetailExists(updateReqVO.getId()); + // 更新 + StockInDetailDO updateObj = BeanUtils.toBean(updateReqVO, StockInDetailDO.class); + stockInDetailMapper.updateById(updateObj); + } + + @Override + public void deleteStockInDetail(Long id) { + // 校验存在 + validateStockInDetailExists(id); + // 删除 + stockInDetailMapper.deleteById(id); + } + + private void validateStockInDetailExists(Long id) { + if (stockInDetailMapper.selectById(id) == null) { + throw exception(STOCK_IN_DETAIL_NOT_EXISTS); + } + } + + @Override + public StockInDetailDO getStockInDetail(Long id) { + return stockInDetailMapper.selectById(id); + } + + @Override + public PageResult getStockInDetailPage(StockInDetailPageReqVO pageReqVO) { + return stockInDetailMapper.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/stockworkshop/MesStockInService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockworkshop/MesStockInService.java new file mode 100644 index 0000000000..7d205132d4 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockworkshop/MesStockInService.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.mes.service.stockworkshop; + +/** + * ERP 其它入库单 Service 接口 + * + * @author 芋道源码 + */ +public interface MesStockInService { + + + /** + * 更新其它入库单的状态 + * + * @param id 编号 + * @param status 状态 + */ + void updateStockInStatus(Long id, Integer status); + + + +} \ 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/stockworkshop/MesStockInServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockworkshop/MesStockInServiceImpl.java new file mode 100644 index 0000000000..7b3440f741 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/stockworkshop/MesStockInServiceImpl.java @@ -0,0 +1,100 @@ +package cn.iocoder.yudao.module.mes.service.stockworkshop; + +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInDO; +import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO; +import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInItemMapper; +import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockInMapper; +import cn.iocoder.yudao.module.erp.dal.redis.no.ErpNoRedisDAO; +import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; +import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum; +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; +import cn.iocoder.yudao.module.erp.service.purchase.ErpSupplierService; +import cn.iocoder.yudao.module.erp.service.stock.ErpStockRecordService; +import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; +import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; + +// TODO 芋艿:记录操作日志 + +/** + * 生产入库单 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class MesStockInServiceImpl implements MesStockInService { + + @Resource + private ErpStockInMapper stockInMapper; + @Resource + private ErpStockInItemMapper stockInItemMapper; + + @Resource + private ErpNoRedisDAO noRedisDAO; + + @Resource + private ErpProductService productService; + @Resource + private ErpWarehouseService warehouseService; + @Resource + private ErpSupplierService supplierService; + @Resource + private ErpStockRecordService stockRecordService; + + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateStockInStatus(Long id, Integer status) { + boolean approve = ErpAuditStatus.APPROVE.getStatus().equals(status); + // 1.1 校验存在 + ErpStockInDO stockIn = validateStockInExists(id); + // 1.2 校验状态 + if (stockIn.getStatus().equals(status)) { + throw exception(approve ? STOCK_IN_APPROVE_FAIL : STOCK_IN_PROCESS_FAIL); + } + + // 2. 更新状态 + int updateCount = stockInMapper.updateByIdAndStatus(id, stockIn.getStatus(), + new ErpStockInDO().setStatus(status)); + if (updateCount == 0) { + throw exception(approve ? STOCK_IN_APPROVE_FAIL : STOCK_IN_PROCESS_FAIL); + } + + // 3. 变更库存 + List stockInItems = stockInItemMapper.selectListByInId(id); + Integer bizType = approve ? ErpStockRecordBizTypeEnum.OTHER_IN.getType() + : ErpStockRecordBizTypeEnum.OTHER_IN_CANCEL.getType(); + stockInItems.forEach(stockInItem -> { + BigDecimal count = approve ? stockInItem.getCount() : stockInItem.getCount().negate(); + ErpProductDO productDO = productService.getProduct(stockInItem.getProductId()); + stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( + stockInItem.getProductId(),productDO.getCategoryId(), stockInItem.getWarehouseId(), count, + bizType, stockInItem.getInId(), stockInItem.getId(), stockIn.getNo())); + }); + + //生产入库分配给计划 + + } + + + private ErpStockInDO validateStockInExists(Long id) { + ErpStockInDO stockIn = stockInMapper.selectById(id); + if (stockIn == null) { + throw exception(STOCK_IN_NOT_EXISTS); + } + return stockIn; + } + + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/errorrecord/ErrorRecordMapper.xml b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/errorrecord/ErrorRecordMapper.xml new file mode 100644 index 0000000000..9bde1f1db8 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/errorrecord/ErrorRecordMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/stockindetail/StockInDetailMapper.xml b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/stockindetail/StockInDetailMapper.xml new file mode 100644 index 0000000000..721c61794d --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/resources/mapper/stockindetail/StockInDetailMapper.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/errorrecord/ErrorRecordServiceImplTest.java b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/errorrecord/ErrorRecordServiceImplTest.java new file mode 100644 index 0000000000..a4db18a70b --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/errorrecord/ErrorRecordServiceImplTest.java @@ -0,0 +1,150 @@ +package cn.iocoder.yudao.module.mes.service.errorrecord; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.mes.controller.admin.errorrecord.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.errorrecord.ErrorRecordDO; +import cn.iocoder.yudao.module.mes.dal.mysql.errorrecord.ErrorRecordMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +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 ErrorRecordServiceImpl} 的单元测试类 + * + * @author 内蒙必硕 + */ +@Import(ErrorRecordServiceImpl.class) +public class ErrorRecordServiceImplTest extends BaseDbUnitTest { + + @Resource + private ErrorRecordServiceImpl errorRecordService; + + @Resource + private ErrorRecordMapper errorRecordMapper; + + @Test + public void testCreateErrorRecord_success() { + // 准备参数 + ErrorRecordSaveReqVO createReqVO = randomPojo(ErrorRecordSaveReqVO.class).setId(null); + + // 调用 + Long errorRecordId = errorRecordService.createErrorRecord(createReqVO); + // 断言 + assertNotNull(errorRecordId); + // 校验记录的属性是否正确 + ErrorRecordDO errorRecord = errorRecordMapper.selectById(errorRecordId); + assertPojoEquals(createReqVO, errorRecord, "id"); + } + + @Test + public void testUpdateErrorRecord_success() { + // mock 数据 + ErrorRecordDO dbErrorRecord = randomPojo(ErrorRecordDO.class); + errorRecordMapper.insert(dbErrorRecord);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ErrorRecordSaveReqVO updateReqVO = randomPojo(ErrorRecordSaveReqVO.class, o -> { + o.setId(dbErrorRecord.getId()); // 设置更新的 ID + }); + + // 调用 + errorRecordService.updateErrorRecord(updateReqVO); + // 校验是否更新正确 + ErrorRecordDO errorRecord = errorRecordMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, errorRecord); + } + + @Test + public void testUpdateErrorRecord_notExists() { + // 准备参数 + ErrorRecordSaveReqVO updateReqVO = randomPojo(ErrorRecordSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> errorRecordService.updateErrorRecord(updateReqVO), ERROR_RECORD_NOT_EXISTS); + } + + @Test + public void testDeleteErrorRecord_success() { + // mock 数据 + ErrorRecordDO dbErrorRecord = randomPojo(ErrorRecordDO.class); + errorRecordMapper.insert(dbErrorRecord);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbErrorRecord.getId(); + + // 调用 + errorRecordService.deleteErrorRecord(id); + // 校验数据不存在了 + assertNull(errorRecordMapper.selectById(id)); + } + + @Test + public void testDeleteErrorRecord_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> errorRecordService.deleteErrorRecord(id), ERROR_RECORD_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetErrorRecordPage() { + // mock 数据 + ErrorRecordDO dbErrorRecord = randomPojo(ErrorRecordDO.class, o -> { // 等会查询到 + o.setTitle(null); + o.setLocation(null); + o.setException(null); + o.setPreData(null); + o.setPostData(null); + o.setCreateTime(null); + }); + errorRecordMapper.insert(dbErrorRecord); + // 测试 title 不匹配 + errorRecordMapper.insert(cloneIgnoreId(dbErrorRecord, o -> o.setTitle(null))); + // 测试 location 不匹配 + errorRecordMapper.insert(cloneIgnoreId(dbErrorRecord, o -> o.setLocation(null))); + // 测试 exception 不匹配 + errorRecordMapper.insert(cloneIgnoreId(dbErrorRecord, o -> o.setException(null))); + // 测试 preData 不匹配 + errorRecordMapper.insert(cloneIgnoreId(dbErrorRecord, o -> o.setPreData(null))); + // 测试 postData 不匹配 + errorRecordMapper.insert(cloneIgnoreId(dbErrorRecord, o -> o.setPostData(null))); + // 测试 createTime 不匹配 + errorRecordMapper.insert(cloneIgnoreId(dbErrorRecord, o -> o.setCreateTime(null))); + // 准备参数 + ErrorRecordPageReqVO reqVO = new ErrorRecordPageReqVO(); + reqVO.setTitle(null); + reqVO.setLocation(null); + reqVO.setException(null); + reqVO.setPreData(null); + reqVO.setPostData(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = errorRecordService.getErrorRecordPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbErrorRecord, 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/stockindetail/StockInDetailServiceImplTest.java b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/stockindetail/StockInDetailServiceImplTest.java new file mode 100644 index 0000000000..16e19f1a7e --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/test/java/cn/iocoder/yudao/module/mes/service/stockindetail/StockInDetailServiceImplTest.java @@ -0,0 +1,154 @@ +package cn.iocoder.yudao.module.mes.service.stockindetail; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.mes.controller.admin.stockindetail.vo.*; +import cn.iocoder.yudao.module.mes.dal.dataobject.stockindetail.StockInDetailDO; +import cn.iocoder.yudao.module.mes.dal.mysql.stockindetail.StockInDetailMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +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 StockInDetailServiceImpl} 的单元测试类 + * + * @author 内蒙必硕 + */ +@Import(StockInDetailServiceImpl.class) +public class StockInDetailServiceImplTest extends BaseDbUnitTest { + + @Resource + private StockInDetailServiceImpl stockInDetailService; + + @Resource + private StockInDetailMapper stockInDetailMapper; + + @Test + public void testCreateStockInDetail_success() { + // 准备参数 + StockInDetailSaveReqVO createReqVO = randomPojo(StockInDetailSaveReqVO.class).setId(null); + + // 调用 + Long stockInDetailId = stockInDetailService.createStockInDetail(createReqVO); + // 断言 + assertNotNull(stockInDetailId); + // 校验记录的属性是否正确 + StockInDetailDO stockInDetail = stockInDetailMapper.selectById(stockInDetailId); + assertPojoEquals(createReqVO, stockInDetail, "id"); + } + + @Test + public void testUpdateStockInDetail_success() { + // mock 数据 + StockInDetailDO dbStockInDetail = randomPojo(StockInDetailDO.class); + stockInDetailMapper.insert(dbStockInDetail);// @Sql: 先插入出一条存在的数据 + // 准备参数 + StockInDetailSaveReqVO updateReqVO = randomPojo(StockInDetailSaveReqVO.class, o -> { + o.setId(dbStockInDetail.getId()); // 设置更新的 ID + }); + + // 调用 + stockInDetailService.updateStockInDetail(updateReqVO); + // 校验是否更新正确 + StockInDetailDO stockInDetail = stockInDetailMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, stockInDetail); + } + + @Test + public void testUpdateStockInDetail_notExists() { + // 准备参数 + StockInDetailSaveReqVO updateReqVO = randomPojo(StockInDetailSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> stockInDetailService.updateStockInDetail(updateReqVO), STOCK_IN_DETAIL_NOT_EXISTS); + } + + @Test + public void testDeleteStockInDetail_success() { + // mock 数据 + StockInDetailDO dbStockInDetail = randomPojo(StockInDetailDO.class); + stockInDetailMapper.insert(dbStockInDetail);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbStockInDetail.getId(); + + // 调用 + stockInDetailService.deleteStockInDetail(id); + // 校验数据不存在了 + assertNull(stockInDetailMapper.selectById(id)); + } + + @Test + public void testDeleteStockInDetail_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> stockInDetailService.deleteStockInDetail(id), STOCK_IN_DETAIL_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetStockInDetailPage() { + // mock 数据 + StockInDetailDO dbStockInDetail = randomPojo(StockInDetailDO.class, o -> { // 等会查询到 + o.setStockInId(null); + o.setStockInNo(null); + o.setStockInItemId(null); + o.setPlanId(null); + o.setProductId(null); + o.setNumber(null); + o.setCreateTime(null); + }); + stockInDetailMapper.insert(dbStockInDetail); + // 测试 stockInId 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setStockInId(null))); + // 测试 stockInNo 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setStockInNo(null))); + // 测试 stockInItemId 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setStockInItemId(null))); + // 测试 planId 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setPlanId(null))); + // 测试 productId 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setProductId(null))); + // 测试 number 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setNumber(null))); + // 测试 createTime 不匹配 + stockInDetailMapper.insert(cloneIgnoreId(dbStockInDetail, o -> o.setCreateTime(null))); + // 准备参数 + StockInDetailPageReqVO reqVO = new StockInDetailPageReqVO(); + reqVO.setStockInId(null); + reqVO.setStockInNo(null); + reqVO.setStockInItemId(null); + reqVO.setPlanId(null); + reqVO.setProductId(null); + reqVO.setNumber(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = stockInDetailService.getStockInDetailPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbStockInDetail, pageResult.getList().get(0)); + } + +} \ No newline at end of file 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 4b3d75fd9b..2f9038f13c 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 @@ -39,6 +39,10 @@ DELETE FROM "mes_feeding_record_plan"; -- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 DELETE FROM "mes_feeding_record_detail"; +-- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "mes_error_record"; +-- 将该删表 SQL 语句,添加到 yudao-module-mes-biz 模块的 test/resources/sql/clean.sql 文件里 +DELETE FROM "mes_stock_in_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 275bdff9f3..d6879801cc 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 @@ -432,3 +432,37 @@ CREATE TABLE IF NOT EXISTS "mes_feeding_record_detail" PRIMARY KEY ("id") ) COMMENT '投料记录明细'; +CREATE TABLE IF NOT EXISTS "mes_error_record" +( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "title" varchar, + "location" varchar, + "exception" varchar, + "pre_data" varchar, + "post_data" 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 NOT NULL, + PRIMARY KEY ("id") +) COMMENT '错误记录'; +CREATE TABLE IF NOT EXISTS "mes_stock_in_detail" +( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "stock_in_id" bigint, + "stock_in_no" varchar, + "stock_in_item_id" bigint, + "plan_id" bigint, + "product_id" bigint, + "number" 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 NOT NULL, + PRIMARY KEY ("id") +) COMMENT '生产入库分配明细'; +