add error record and stockin
parent
eaa34df5df
commit
4c636fe34a
@ -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<Long> createErrorRecord(@Valid @RequestBody ErrorRecordSaveReqVO createReqVO) {
|
||||||
|
return success(errorRecordService.createErrorRecord(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新错误记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('mes:error-record:update')")
|
||||||
|
public CommonResult<Boolean> 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<Boolean> 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<ErrorRecordRespVO> 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<PageResult<ErrorRecordRespVO>> getErrorRecordPage(@Valid ErrorRecordPageReqVO pageReqVO) {
|
||||||
|
PageResult<ErrorRecordDO> 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<ErrorRecordDO> list = errorRecordService.getErrorRecordPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "错误记录.xls", "数据", ErrorRecordRespVO.class,
|
||||||
|
BeanUtils.toBean(list, ErrorRecordRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<Long> createStockInDetail(@Valid @RequestBody StockInDetailSaveReqVO createReqVO) {
|
||||||
|
return success(stockInDetailService.createStockInDetail(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新生产入库分配明细")
|
||||||
|
@PreAuthorize("@ss.hasPermission('mes:stock-in-detail:update')")
|
||||||
|
public CommonResult<Boolean> 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<Boolean> 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<StockInDetailRespVO> 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<PageResult<StockInDetailRespVO>> getStockInDetailPage(@Valid StockInDetailPageReqVO pageReqVO) {
|
||||||
|
PageResult<StockInDetailDO> 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<StockInDetailDO> list = stockInDetailService.getStockInDetailPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "生产入库分配明细.xls", "数据", StockInDetailRespVO.class,
|
||||||
|
BeanUtils.toBean(list, StockInDetailRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<Boolean> updateStockInStatus(@RequestParam("id") Long id,
|
||||||
|
@RequestParam("status") Integer status) {
|
||||||
|
stockInService.updateStockInStatus(id, status);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<ErrorRecordDO> {
|
||||||
|
|
||||||
|
default PageResult<ErrorRecordDO> selectPage(ErrorRecordPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<ErrorRecordDO>()
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<StockInDetailDO> {
|
||||||
|
|
||||||
|
default PageResult<StockInDetailDO> selectPage(StockInDetailPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<StockInDetailDO>()
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<ErrorRecordDO> getErrorRecordPage(ErrorRecordPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<ErrorRecordDO> getErrorRecordPage(ErrorRecordPageReqVO pageReqVO) {
|
||||||
|
return errorRecordMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<StockInDetailDO> getStockInDetailPage(StockInDetailPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<StockInDetailDO> getStockInDetailPage(StockInDetailPageReqVO pageReqVO) {
|
||||||
|
return stockInDetailMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<ErpStockInItemDO> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<ErrorRecordDO> pageResult = errorRecordService.getErrorRecordPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbErrorRecord, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<StockInDetailDO> pageResult = stockInDetailService.getStockInDetailPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbStockInDetail, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue