add task plan
parent
b1184b1c7f
commit
1494636e95
@ -0,0 +1,106 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.itemrequisition;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
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.itemrequisition.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDetailDO;
|
||||
import cn.iocoder.yudao.module.mes.service.itemrequisition.ItemRequisitionService;
|
||||
|
||||
@Tag(name = "管理后台 - 生产领料")
|
||||
@RestController
|
||||
@RequestMapping("/mes/item-requisition")
|
||||
@Validated
|
||||
public class ItemRequisitionController {
|
||||
|
||||
@Resource
|
||||
private ItemRequisitionService itemRequisitionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建生产领料")
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:create')")
|
||||
public CommonResult<Long> createItemRequisition(@Valid @RequestBody ItemRequisitionSaveReqVO createReqVO) {
|
||||
return success(itemRequisitionService.createItemRequisition(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新生产领料")
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:update')")
|
||||
public CommonResult<Boolean> updateItemRequisition(@Valid @RequestBody ItemRequisitionSaveReqVO updateReqVO) {
|
||||
itemRequisitionService.updateItemRequisition(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除生产领料")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:delete')")
|
||||
public CommonResult<Boolean> deleteItemRequisition(@RequestParam("id") Long id) {
|
||||
itemRequisitionService.deleteItemRequisition(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得生产领料")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:query')")
|
||||
public CommonResult<ItemRequisitionRespVO> getItemRequisition(@RequestParam("id") Long id) {
|
||||
ItemRequisitionDO itemRequisition = itemRequisitionService.getItemRequisition(id);
|
||||
return success(BeanUtils.toBean(itemRequisition, ItemRequisitionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得生产领料分页")
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:query')")
|
||||
public CommonResult<PageResult<ItemRequisitionRespVO>> getItemRequisitionPage(@Valid ItemRequisitionPageReqVO pageReqVO) {
|
||||
PageResult<ItemRequisitionDO> pageResult = itemRequisitionService.getItemRequisitionPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ItemRequisitionRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出生产领料 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportItemRequisitionExcel(@Valid ItemRequisitionPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ItemRequisitionDO> list = itemRequisitionService.getItemRequisitionPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产领料.xls", "数据", ItemRequisitionRespVO.class,
|
||||
BeanUtils.toBean(list, ItemRequisitionRespVO.class));
|
||||
}
|
||||
|
||||
// ==================== 子表(领料明细) ====================
|
||||
|
||||
@GetMapping("/item-requisition-detail/list-by-item-requisition-id")
|
||||
@Operation(summary = "获得领料明细列表")
|
||||
@Parameter(name = "itemRequisitionId", description = "领料单ID")
|
||||
@PreAuthorize("@ss.hasPermission('mes:item-requisition:query')")
|
||||
public CommonResult<List<ItemRequisitionDetailDO>> getItemRequisitionDetailListByItemRequisitionId(@RequestParam("itemRequisitionId") Long itemRequisitionId) {
|
||||
return success(itemRequisitionService.getItemRequisitionDetailListByItemRequisitionId(itemRequisitionId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
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;
|
||||
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 ItemRequisitionPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "下料时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime[] requisitionDate;
|
||||
|
||||
@Schema(description = "领料时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime[] deliveryDate;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "1634")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "计划ID", example = "15546")
|
||||
private Long planId;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
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 ItemRequisitionRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5100")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "下料时间")
|
||||
@ExcelProperty("下料时间")
|
||||
private LocalDateTime requisitionDate;
|
||||
|
||||
@Schema(description = "领料时间")
|
||||
@ExcelProperty("领料时间")
|
||||
private LocalDateTime deliveryDate;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "1634")
|
||||
@ExcelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "计划ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15546")
|
||||
@ExcelProperty("计划ID")
|
||||
private Long planId;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("是否启用")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDetailDO;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 生产领料新增/修改 Request VO")
|
||||
@Data
|
||||
public class ItemRequisitionSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5100")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "编码不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "下料时间")
|
||||
private LocalDate requisitionDate;
|
||||
|
||||
@Schema(description = "领料时间")
|
||||
private LocalDate deliveryDate;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "1634")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "计划ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "15546")
|
||||
@NotNull(message = "计划ID不能为空")
|
||||
private Long planId;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否启用不能为空")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "领料明细列表")
|
||||
private List<ItemRequisitionDetailDO> itemRequisitionDetails;
|
||||
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.plan;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
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.plan.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
||||
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
|
||||
|
||||
@Tag(name = "管理后台 - 生产计划")
|
||||
@RestController
|
||||
@RequestMapping("/mes/plan")
|
||||
@Validated
|
||||
public class PlanController {
|
||||
|
||||
@Resource
|
||||
private PlanService planService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建生产计划")
|
||||
@PreAuthorize("@ss.hasPermission('mes:plan:create')")
|
||||
public CommonResult<Long> createPlan(@Valid @RequestBody PlanSaveReqVO createReqVO) {
|
||||
return success(planService.createPlan(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新生产计划")
|
||||
@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
||||
public CommonResult<Boolean> updatePlan(@Valid @RequestBody PlanSaveReqVO updateReqVO) {
|
||||
planService.updatePlan(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除生产计划")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:plan:delete')")
|
||||
public CommonResult<Boolean> deletePlan(@RequestParam("id") Long id) {
|
||||
planService.deletePlan(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得生产计划")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mes:plan:query')")
|
||||
public CommonResult<PlanRespVO> getPlan(@RequestParam("id") Long id) {
|
||||
PlanDO plan = planService.getPlan(id);
|
||||
return success(BeanUtils.toBean(plan, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得生产计划分页")
|
||||
@PreAuthorize("@ss.hasPermission('mes:plan:query')")
|
||||
public CommonResult<PageResult<PlanRespVO>> getPlanPage(@Valid PlanPageReqVO pageReqVO) {
|
||||
PageResult<PlanDO> pageResult = planService.getPlanPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出生产计划 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('mes:plan:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportPlanExcel(@Valid PlanPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PlanDO> list = planService.getPlanPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产计划.xls", "数据", PlanRespVO.class,
|
||||
BeanUtils.toBean(list, PlanRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.plan.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 PlanPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "计划编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品ID", example = "21176")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "任务单明细ID", example = "18938")
|
||||
private Long taskDetailId;
|
||||
|
||||
@Schema(description = "任务单ID", example = "18331")
|
||||
private Long taskId;
|
||||
|
||||
@Schema(description = "数量")
|
||||
private Long planNumber;
|
||||
|
||||
@Schema(description = "成品数量")
|
||||
private Long finishNumber;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "计划开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] planStartTime;
|
||||
|
||||
@Schema(description = "计划结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] planEndTime;
|
||||
|
||||
@Schema(description = "实际开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] startTime;
|
||||
|
||||
@Schema(description = "实际结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] endTime;
|
||||
|
||||
@Schema(description = "生产主管ID", example = "10640")
|
||||
private Long productionManagerId;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.plan.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.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 生产计划 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PlanRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17689")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "计划编码")
|
||||
@ExcelProperty("计划编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21176")
|
||||
@ExcelProperty("产品ID")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "任务单明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18938")
|
||||
@ExcelProperty("任务单明细ID")
|
||||
private Long taskDetailId;
|
||||
|
||||
@Schema(description = "任务单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18331")
|
||||
@ExcelProperty("任务单ID")
|
||||
private Long taskId;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("数量")
|
||||
private Long planNumber;
|
||||
|
||||
@Schema(description = "成品数量")
|
||||
@ExcelProperty("成品数量")
|
||||
private Long finishNumber;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat("mes_plan_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "计划开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("计划开始时间")
|
||||
private LocalDateTime planStartTime;
|
||||
|
||||
@Schema(description = "计划结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("计划结束时间")
|
||||
private LocalDateTime planEndTime;
|
||||
|
||||
@Schema(description = "实际开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("实际开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "实际结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("实际结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "生产主管ID", example = "10640")
|
||||
@ExcelProperty("生产主管ID")
|
||||
private Long productionManagerId;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
@ExcelProperty(value = "是否启用", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.plan.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 生产计划新增/修改 Request VO")
|
||||
@Data
|
||||
public class PlanSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17689")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "计划编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21176")
|
||||
@NotNull(message = "产品ID不能为空")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "任务单明细ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18938")
|
||||
@NotNull(message = "任务单明细ID不能为空")
|
||||
private Long taskDetailId;
|
||||
|
||||
@Schema(description = "任务单ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18331")
|
||||
@NotNull(message = "任务单ID不能为空")
|
||||
private Long taskId;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Long planNumber;
|
||||
|
||||
@Schema(description = "成品数量")
|
||||
private Long finishNumber;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "计划开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "计划开始时间不能为空")
|
||||
private LocalDateTime planStartTime;
|
||||
|
||||
@Schema(description = "计划结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "计划结束时间不能为空")
|
||||
private LocalDateTime planEndTime;
|
||||
|
||||
@Schema(description = "实际开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "实际开始时间不能为空")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "实际结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "实际结束时间不能为空")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "生产主管ID", example = "10640")
|
||||
private Long productionManagerId;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,148 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.task;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
|
||||
import cn.iocoder.yudao.module.mes.service.task.TaskService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Tag(name = "管理后台 - 生产任务单")
|
||||
@RestController
|
||||
@RequestMapping("/mes/task")
|
||||
@Validated
|
||||
public class TaskController {
|
||||
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建生产任务单")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:create')")
|
||||
public CommonResult<Long> createTask(@Valid @RequestBody TaskSaveReqVO createReqVO) {
|
||||
return success(taskService.createTask(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新生产任务单")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:update')")
|
||||
public CommonResult<Boolean> updateTask(@Valid @RequestBody TaskSaveReqVO updateReqVO) {
|
||||
taskService.updateTask(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除生产任务单")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:delete')")
|
||||
public CommonResult<Boolean> deleteTask(@RequestParam("id") Long id) {
|
||||
taskService.deleteTask(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得生产任务单")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:query')")
|
||||
public CommonResult<TaskRespVO> getTask(@RequestParam("id") Long id) {
|
||||
TaskDO task = taskService.getTask(id);
|
||||
return success(BeanUtils.toBean(task, TaskRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得生产任务单分页")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:query')")
|
||||
public CommonResult<PageResult<TaskRespVO>> getTaskPage(@Valid TaskPageReqVO pageReqVO) {
|
||||
PageResult<TaskDO> pageResult = taskService.getTaskPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, TaskRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出生产任务单 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportTaskExcel(@Valid TaskPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<TaskDO> list = taskService.getTaskPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产任务单.xls", "数据", TaskRespVO.class,
|
||||
BeanUtils.toBean(list, TaskRespVO.class));
|
||||
}
|
||||
|
||||
// ==================== 子表(生产任务单明细) ====================
|
||||
|
||||
@GetMapping("/task-detail/list-by-task-id")
|
||||
@Operation(summary = "获得生产任务单明细列表")
|
||||
@Parameter(name = "taskId", description = "task ID")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:query')")
|
||||
public CommonResult<List<TaskDetailDO>> getTaskDetailListByTaskId(@RequestParam("taskId") Long taskId) {
|
||||
return success(taskService.getTaskDetailListByTaskId(taskId));
|
||||
}
|
||||
// ==================== 子表(生产任务单明细) ====================
|
||||
|
||||
@GetMapping("/task-detail/page")
|
||||
@Operation(summary = "获得生产任务单明细分页")
|
||||
@Parameter(name = "taskId", description = "task ID")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:query')")
|
||||
public CommonResult<PageResult<TaskDetailDO>> getTaskDetailPage(PageParam pageReqVO,
|
||||
@RequestParam("taskId") Long taskId) {
|
||||
return success(taskService.getTaskDetailPage(pageReqVO, taskId));
|
||||
}
|
||||
|
||||
@PostMapping("/task-detail/create")
|
||||
@Operation(summary = "创建生产任务单明细")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:create')")
|
||||
public CommonResult<Long> createTaskDetail(@Valid @RequestBody TaskDetailDO taskDetail) {
|
||||
return success(taskService.createTaskDetail(taskDetail));
|
||||
}
|
||||
|
||||
@PutMapping("/task-detail/update")
|
||||
@Operation(summary = "更新生产任务单明细")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:update')")
|
||||
public CommonResult<Boolean> updateTaskDetail(@Valid @RequestBody TaskDetailDO taskDetail) {
|
||||
taskService.updateTaskDetail(taskDetail);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/task-detail/delete")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Operation(summary = "删除生产任务单明细")
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:delete')")
|
||||
public CommonResult<Boolean> deleteTaskDetail(@RequestParam("id") Long id) {
|
||||
taskService.deleteTaskDetail(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/task-detail/get")
|
||||
@Operation(summary = "获得生产任务单明细")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:task:query')")
|
||||
public CommonResult<TaskDetailDO> getTaskDetail(@RequestParam("id") Long id) {
|
||||
return success(taskService.getTaskDetail(id));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.task.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
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;
|
||||
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 TaskPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "下达日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate[] orderDate;
|
||||
|
||||
@Schema(description = "交货日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate[] deliveryDate;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "13815")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.task.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 生产任务单 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class TaskRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14570")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "下达日期")
|
||||
@ExcelProperty("下达日期")
|
||||
private LocalDate orderDate;
|
||||
|
||||
@Schema(description = "交货日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("交货日期")
|
||||
private LocalDate deliveryDate;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat("mes_task_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "13815")
|
||||
@ExcelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty(value = "是否启用", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.task.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 生产任务单新增/修改 Request VO")
|
||||
@Data
|
||||
public class TaskSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14570")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "编码不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "下达日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
@Schema(description = "交货日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "交货日期不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime deliveryDate;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "13815")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否启用不能为空")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "生产任务单明细列表")
|
||||
private List<TaskDetailDO> taskDetails;
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
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_item_requisition")
|
||||
@KeySequence("mes_item_requisition_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ItemRequisitionDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 下料时间
|
||||
*/
|
||||
private LocalDate requisitionDate;
|
||||
/**
|
||||
* 领料时间
|
||||
*/
|
||||
private LocalDate deliveryDate;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 计划ID
|
||||
*/
|
||||
private Long planId;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition;
|
||||
|
||||
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_item_requisition_detail")
|
||||
@KeySequence("mes_item_requisition_detail_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ItemRequisitionDetailDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 产品ID
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* 单位ID
|
||||
*/
|
||||
private Long unitId;
|
||||
/**
|
||||
* 领料单ID
|
||||
*/
|
||||
private Long itemRequisitionId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private BigDecimal number;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.plan;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 生产计划 DO
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@TableName("mes_plan")
|
||||
@KeySequence("mes_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PlanDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 计划编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 产品ID
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* 任务单明细ID
|
||||
*/
|
||||
private Long taskDetailId;
|
||||
/**
|
||||
* 任务单ID
|
||||
*/
|
||||
private Long taskId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Long planNumber;
|
||||
/**
|
||||
* 成品数量
|
||||
*/
|
||||
private Long finishNumber;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link TODO mes_plan_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 计划开始时间
|
||||
*/
|
||||
private LocalDateTime planStartTime;
|
||||
/**
|
||||
* 计划结束时间
|
||||
*/
|
||||
private LocalDateTime planEndTime;
|
||||
/**
|
||||
* 实际开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
/**
|
||||
* 实际结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
/**
|
||||
* 生产主管ID
|
||||
*/
|
||||
private Long productionManagerId;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否启用
|
||||
*
|
||||
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.task;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
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_task")
|
||||
@KeySequence("mes_task_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaskDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 下达日期
|
||||
*/
|
||||
private LocalDateTime orderDate;
|
||||
/**
|
||||
* 交货日期
|
||||
*/
|
||||
private LocalDateTime deliveryDate;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link TODO mes_task_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否启用
|
||||
*
|
||||
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.task;
|
||||
|
||||
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_task_detail")
|
||||
@KeySequence("mes_task_detail_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaskDetailDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 产品ID
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* 单位ID
|
||||
*/
|
||||
private Long unitId;
|
||||
/**
|
||||
* task ID
|
||||
*/
|
||||
private Long taskId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Long number;
|
||||
/**
|
||||
* 打包要求(每包/个)
|
||||
*/
|
||||
private Long packageSize;
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectName;
|
||||
/**
|
||||
* 技术要求
|
||||
*/
|
||||
private String techRequirements;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.itemrequisition;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDetailDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 领料明细 Mapper
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Mapper
|
||||
public interface ItemRequisitionDetailMapper extends BaseMapperX<ItemRequisitionDetailDO> {
|
||||
|
||||
default List<ItemRequisitionDetailDO> selectListByItemRequisitionId(Long itemRequisitionId) {
|
||||
return selectList(ItemRequisitionDetailDO::getItemRequisitionId, itemRequisitionId);
|
||||
}
|
||||
|
||||
default int deleteByItemRequisitionId(Long itemRequisitionId) {
|
||||
return delete(ItemRequisitionDetailDO::getItemRequisitionId, itemRequisitionId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.itemrequisition;
|
||||
|
||||
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.itemrequisition.ItemRequisitionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.*;
|
||||
|
||||
/**
|
||||
* 生产领料 Mapper
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Mapper
|
||||
public interface ItemRequisitionMapper extends BaseMapperX<ItemRequisitionDO> {
|
||||
|
||||
default PageResult<ItemRequisitionDO> selectPage(ItemRequisitionPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ItemRequisitionDO>()
|
||||
.eqIfPresent(ItemRequisitionDO::getCode, reqVO.getCode())
|
||||
.betweenIfPresent(ItemRequisitionDO::getRequisitionDate, reqVO.getRequisitionDate())
|
||||
.betweenIfPresent(ItemRequisitionDO::getDeliveryDate, reqVO.getDeliveryDate())
|
||||
.eqIfPresent(ItemRequisitionDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ItemRequisitionDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.eqIfPresent(ItemRequisitionDO::getPlanId, reqVO.getPlanId())
|
||||
.eqIfPresent(ItemRequisitionDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(ItemRequisitionDO::getIsEnable, reqVO.getIsEnable())
|
||||
.betweenIfPresent(ItemRequisitionDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ItemRequisitionDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.plan;
|
||||
|
||||
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.plan.PlanDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.*;
|
||||
|
||||
/**
|
||||
* 生产计划 Mapper
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Mapper
|
||||
public interface PlanMapper extends BaseMapperX<PlanDO> {
|
||||
|
||||
default PageResult<PlanDO> selectPage(PlanPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PlanDO>()
|
||||
.eqIfPresent(PlanDO::getCode, reqVO.getCode())
|
||||
.eqIfPresent(PlanDO::getProductId, reqVO.getProductId())
|
||||
.eqIfPresent(PlanDO::getTaskDetailId, reqVO.getTaskDetailId())
|
||||
.eqIfPresent(PlanDO::getTaskId, reqVO.getTaskId())
|
||||
.eqIfPresent(PlanDO::getPlanNumber, reqVO.getPlanNumber())
|
||||
.eqIfPresent(PlanDO::getFinishNumber, reqVO.getFinishNumber())
|
||||
.eqIfPresent(PlanDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(PlanDO::getPlanStartTime, reqVO.getPlanStartTime())
|
||||
.betweenIfPresent(PlanDO::getPlanEndTime, reqVO.getPlanEndTime())
|
||||
.betweenIfPresent(PlanDO::getStartTime, reqVO.getStartTime())
|
||||
.betweenIfPresent(PlanDO::getEndTime, reqVO.getEndTime())
|
||||
.eqIfPresent(PlanDO::getProductionManagerId, reqVO.getProductionManagerId())
|
||||
.eqIfPresent(PlanDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(PlanDO::getIsEnable, reqVO.getIsEnable())
|
||||
.betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PlanDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.task;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 生产任务单明细 Mapper
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskDetailMapper extends BaseMapperX<TaskDetailDO> {
|
||||
|
||||
default List<TaskDetailDO> selectListByTaskId(Long taskId) {
|
||||
return selectList(TaskDetailDO::getTaskId, taskId);
|
||||
}
|
||||
|
||||
default int deleteByTaskId(Long taskId) {
|
||||
return delete(TaskDetailDO::getTaskId, taskId);
|
||||
}
|
||||
default PageResult<TaskDetailDO> selectPage(PageParam reqVO, Long taskId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TaskDetailDO>()
|
||||
.eq(TaskDetailDO::getTaskId, taskId)
|
||||
.orderByDesc(TaskDetailDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.task;
|
||||
|
||||
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.task.TaskDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.*;
|
||||
|
||||
/**
|
||||
* 生产任务单 Mapper
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskMapper extends BaseMapperX<TaskDO> {
|
||||
|
||||
default PageResult<TaskDO> selectPage(TaskPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TaskDO>()
|
||||
.eqIfPresent(TaskDO::getCode, reqVO.getCode())
|
||||
.betweenIfPresent(TaskDO::getOrderDate, reqVO.getOrderDate())
|
||||
.betweenIfPresent(TaskDO::getDeliveryDate, reqVO.getDeliveryDate())
|
||||
.eqIfPresent(TaskDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(TaskDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.eqIfPresent(TaskDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(TaskDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(TaskDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.mes.service.itemrequisition;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDetailDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 生产领料 Service 接口
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
public interface ItemRequisitionService {
|
||||
|
||||
/**
|
||||
* 创建生产领料
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createItemRequisition(@Valid ItemRequisitionSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新生产领料
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateItemRequisition(@Valid ItemRequisitionSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除生产领料
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteItemRequisition(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产领料
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 生产领料
|
||||
*/
|
||||
ItemRequisitionDO getItemRequisition(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产领料分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 生产领料分页
|
||||
*/
|
||||
PageResult<ItemRequisitionDO> getItemRequisitionPage(ItemRequisitionPageReqVO pageReqVO);
|
||||
|
||||
// ==================== 子表(领料明细) ====================
|
||||
|
||||
/**
|
||||
* 获得领料明细列表
|
||||
*
|
||||
* @param itemRequisitionId 领料单ID
|
||||
* @return 领料明细列表
|
||||
*/
|
||||
List<ItemRequisitionDetailDO> getItemRequisitionDetailListByItemRequisitionId(Long itemRequisitionId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.mes.service.plan;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 生产计划 Service 接口
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
public interface PlanService {
|
||||
|
||||
/**
|
||||
* 创建生产计划
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPlan(@Valid PlanSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新生产计划
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePlan(@Valid PlanSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除生产计划
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePlan(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产计划
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 生产计划
|
||||
*/
|
||||
PlanDO getPlan(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产计划分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 生产计划分页
|
||||
*/
|
||||
PageResult<PlanDO> getPlanPage(PlanPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.mes.service.plan;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
||||
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.plan.PlanMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 生产计划 Service 实现类
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PlanServiceImpl implements PlanService {
|
||||
|
||||
@Resource
|
||||
private PlanMapper planMapper;
|
||||
|
||||
@Override
|
||||
public Long createPlan(PlanSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
PlanDO plan = BeanUtils.toBean(createReqVO, PlanDO.class);
|
||||
planMapper.insert(plan);
|
||||
// 返回
|
||||
return plan.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlan(PlanSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePlanExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PlanDO updateObj = BeanUtils.toBean(updateReqVO, PlanDO.class);
|
||||
planMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePlan(Long id) {
|
||||
// 校验存在
|
||||
validatePlanExists(id);
|
||||
// 删除
|
||||
planMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePlanExists(Long id) {
|
||||
if (planMapper.selectById(id) == null) {
|
||||
throw exception(PLAN_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlanDO getPlan(Long id) {
|
||||
return planMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PlanDO> getPlanPage(PlanPageReqVO pageReqVO) {
|
||||
return planMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package cn.iocoder.yudao.module.mes.service.task;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDetailDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 生产任务单 Service 接口
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
public interface TaskService {
|
||||
|
||||
/**
|
||||
* 创建生产任务单
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createTask(@Valid TaskSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新生产任务单
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateTask(@Valid TaskSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除生产任务单
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteTask(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产任务单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 生产任务单
|
||||
*/
|
||||
TaskDO getTask(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产任务单分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 生产任务单分页
|
||||
*/
|
||||
PageResult<TaskDO> getTaskPage(TaskPageReqVO pageReqVO);
|
||||
|
||||
// ==================== 子表(生产任务单明细) ====================
|
||||
|
||||
/**
|
||||
* 获得生产任务单明细列表
|
||||
*
|
||||
* @param taskId task ID
|
||||
* @return 生产任务单明细列表
|
||||
*/
|
||||
List<TaskDetailDO> getTaskDetailListByTaskId(Long taskId);
|
||||
|
||||
/**
|
||||
* 获得生产任务单明细分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param taskId task ID
|
||||
* @return 生产任务单明细分页
|
||||
*/
|
||||
PageResult<TaskDetailDO> getTaskDetailPage(PageParam pageReqVO, Long taskId);
|
||||
|
||||
/**
|
||||
* 创建生产任务单明细
|
||||
*
|
||||
* @param taskDetail 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createTaskDetail(@Valid TaskDetailDO taskDetail);
|
||||
|
||||
/**
|
||||
* 更新生产任务单明细
|
||||
*
|
||||
* @param taskDetail 更新信息
|
||||
*/
|
||||
void updateTaskDetail(@Valid TaskDetailDO taskDetail);
|
||||
|
||||
/**
|
||||
* 删除生产任务单明细
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteTaskDetail(Long id);
|
||||
|
||||
/**
|
||||
* 获得生产任务单明细
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 生产任务单明细
|
||||
*/
|
||||
TaskDetailDO getTaskDetail(Long id);
|
||||
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package cn.iocoder.yudao.module.mes.service.itemrequisition;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.itemrequisition.ItemRequisitionMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link ItemRequisitionServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Import(ItemRequisitionServiceImpl.class)
|
||||
public class ItemRequisitionServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ItemRequisitionServiceImpl itemRequisitionService;
|
||||
|
||||
@Resource
|
||||
private ItemRequisitionMapper itemRequisitionMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateItemRequisition_success() {
|
||||
// 准备参数
|
||||
ItemRequisitionSaveReqVO createReqVO = randomPojo(ItemRequisitionSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long itemRequisitionId = itemRequisitionService.createItemRequisition(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(itemRequisitionId);
|
||||
// 校验记录的属性是否正确
|
||||
ItemRequisitionDO itemRequisition = itemRequisitionMapper.selectById(itemRequisitionId);
|
||||
assertPojoEquals(createReqVO, itemRequisition, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateItemRequisition_success() {
|
||||
// mock 数据
|
||||
ItemRequisitionDO dbItemRequisition = randomPojo(ItemRequisitionDO.class);
|
||||
itemRequisitionMapper.insert(dbItemRequisition);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ItemRequisitionSaveReqVO updateReqVO = randomPojo(ItemRequisitionSaveReqVO.class, o -> {
|
||||
o.setId(dbItemRequisition.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
itemRequisitionService.updateItemRequisition(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
ItemRequisitionDO itemRequisition = itemRequisitionMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, itemRequisition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateItemRequisition_notExists() {
|
||||
// 准备参数
|
||||
ItemRequisitionSaveReqVO updateReqVO = randomPojo(ItemRequisitionSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> itemRequisitionService.updateItemRequisition(updateReqVO), ITEM_REQUISITION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteItemRequisition_success() {
|
||||
// mock 数据
|
||||
ItemRequisitionDO dbItemRequisition = randomPojo(ItemRequisitionDO.class);
|
||||
itemRequisitionMapper.insert(dbItemRequisition);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbItemRequisition.getId();
|
||||
|
||||
// 调用
|
||||
itemRequisitionService.deleteItemRequisition(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(itemRequisitionMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteItemRequisition_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> itemRequisitionService.deleteItemRequisition(id), ITEM_REQUISITION_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetItemRequisitionPage() {
|
||||
// mock 数据
|
||||
ItemRequisitionDO dbItemRequisition = randomPojo(ItemRequisitionDO.class, o -> { // 等会查询到
|
||||
o.setCode(null);
|
||||
o.setRequisitionDate(null);
|
||||
o.setDeliveryDate(null);
|
||||
o.setStatus(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setPlanId(null);
|
||||
o.setRemark(null);
|
||||
o.setIsEnable(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
itemRequisitionMapper.insert(dbItemRequisition);
|
||||
// 测试 code 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setCode(null)));
|
||||
// 测试 requisitionDate 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setRequisitionDate(null)));
|
||||
// 测试 deliveryDate 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setDeliveryDate(null)));
|
||||
// 测试 status 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setStatus(null)));
|
||||
// 测试 processInstanceId 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setProcessInstanceId(null)));
|
||||
// 测试 planId 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setPlanId(null)));
|
||||
// 测试 remark 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setRemark(null)));
|
||||
// 测试 isEnable 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setIsEnable(null)));
|
||||
// 测试 createTime 不匹配
|
||||
itemRequisitionMapper.insert(cloneIgnoreId(dbItemRequisition, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ItemRequisitionPageReqVO reqVO = new ItemRequisitionPageReqVO();
|
||||
reqVO.setCode(null);
|
||||
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setProcessInstanceId(null);
|
||||
reqVO.setPlanId(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setIsEnable(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<ItemRequisitionDO> pageResult = itemRequisitionService.getItemRequisitionPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbItemRequisition, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,184 @@
|
||||
package cn.iocoder.yudao.module.mes.service.plan;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link PlanServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Import(PlanServiceImpl.class)
|
||||
public class PlanServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private PlanServiceImpl planService;
|
||||
|
||||
@Resource
|
||||
private PlanMapper planMapper;
|
||||
|
||||
@Test
|
||||
public void testCreatePlan_success() {
|
||||
// 准备参数
|
||||
PlanSaveReqVO createReqVO = randomPojo(PlanSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long planId = planService.createPlan(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(planId);
|
||||
// 校验记录的属性是否正确
|
||||
PlanDO plan = planMapper.selectById(planId);
|
||||
assertPojoEquals(createReqVO, plan, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePlan_success() {
|
||||
// mock 数据
|
||||
PlanDO dbPlan = randomPojo(PlanDO.class);
|
||||
planMapper.insert(dbPlan);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
PlanSaveReqVO updateReqVO = randomPojo(PlanSaveReqVO.class, o -> {
|
||||
o.setId(dbPlan.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
planService.updatePlan(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
PlanDO plan = planMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, plan);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatePlan_notExists() {
|
||||
// 准备参数
|
||||
PlanSaveReqVO updateReqVO = randomPojo(PlanSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> planService.updatePlan(updateReqVO), PLAN_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePlan_success() {
|
||||
// mock 数据
|
||||
PlanDO dbPlan = randomPojo(PlanDO.class);
|
||||
planMapper.insert(dbPlan);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbPlan.getId();
|
||||
|
||||
// 调用
|
||||
planService.deletePlan(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(planMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePlan_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> planService.deletePlan(id), PLAN_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetPlanPage() {
|
||||
// mock 数据
|
||||
PlanDO dbPlan = randomPojo(PlanDO.class, o -> { // 等会查询到
|
||||
o.setCode(null);
|
||||
o.setProductId(null);
|
||||
o.setTaskDetailId(null);
|
||||
o.setTaskId(null);
|
||||
o.setPlanNumber(null);
|
||||
o.setFinishNumber(null);
|
||||
o.setStatus(null);
|
||||
o.setPlanStartTime(null);
|
||||
o.setPlanEndTime(null);
|
||||
o.setStartTime(null);
|
||||
o.setEndTime(null);
|
||||
o.setProductionManagerId(null);
|
||||
o.setRemark(null);
|
||||
o.setIsEnable(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
planMapper.insert(dbPlan);
|
||||
// 测试 code 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setCode(null)));
|
||||
// 测试 productId 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setProductId(null)));
|
||||
// 测试 taskDetailId 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setTaskDetailId(null)));
|
||||
// 测试 taskId 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setTaskId(null)));
|
||||
// 测试 planNumber 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setPlanNumber(null)));
|
||||
// 测试 finishNumber 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setFinishNumber(null)));
|
||||
// 测试 status 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setStatus(null)));
|
||||
// 测试 planStartTime 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setPlanStartTime(null)));
|
||||
// 测试 planEndTime 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setPlanEndTime(null)));
|
||||
// 测试 startTime 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setStartTime(null)));
|
||||
// 测试 endTime 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setEndTime(null)));
|
||||
// 测试 productionManagerId 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setProductionManagerId(null)));
|
||||
// 测试 remark 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setRemark(null)));
|
||||
// 测试 isEnable 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setIsEnable(null)));
|
||||
// 测试 createTime 不匹配
|
||||
planMapper.insert(cloneIgnoreId(dbPlan, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
PlanPageReqVO reqVO = new PlanPageReqVO();
|
||||
reqVO.setCode(null);
|
||||
reqVO.setProductId(null);
|
||||
reqVO.setTaskDetailId(null);
|
||||
reqVO.setTaskId(null);
|
||||
reqVO.setPlanNumber(null);
|
||||
reqVO.setFinishNumber(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setPlanStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setPlanEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setProductionManagerId(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setIsEnable(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<PlanDO> pageResult = planService.getPlanPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbPlan, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
package cn.iocoder.yudao.module.mes.service.task;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.*;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.task.TaskMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link TaskServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 内蒙必硕
|
||||
*/
|
||||
@Import(TaskServiceImpl.class)
|
||||
public class TaskServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private TaskServiceImpl taskService;
|
||||
|
||||
@Resource
|
||||
private TaskMapper taskMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateTask_success() {
|
||||
// 准备参数
|
||||
TaskSaveReqVO createReqVO = randomPojo(TaskSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long taskId = taskService.createTask(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(taskId);
|
||||
// 校验记录的属性是否正确
|
||||
TaskDO task = taskMapper.selectById(taskId);
|
||||
assertPojoEquals(createReqVO, task, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateTask_success() {
|
||||
// mock 数据
|
||||
TaskDO dbTask = randomPojo(TaskDO.class);
|
||||
taskMapper.insert(dbTask);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
TaskSaveReqVO updateReqVO = randomPojo(TaskSaveReqVO.class, o -> {
|
||||
o.setId(dbTask.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
taskService.updateTask(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
TaskDO task = taskMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, task);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateTask_notExists() {
|
||||
// 准备参数
|
||||
TaskSaveReqVO updateReqVO = randomPojo(TaskSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> taskService.updateTask(updateReqVO), TASK_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteTask_success() {
|
||||
// mock 数据
|
||||
TaskDO dbTask = randomPojo(TaskDO.class);
|
||||
taskMapper.insert(dbTask);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbTask.getId();
|
||||
|
||||
// 调用
|
||||
taskService.deleteTask(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(taskMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteTask_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> taskService.deleteTask(id), TASK_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetTaskPage() {
|
||||
// mock 数据
|
||||
TaskDO dbTask = randomPojo(TaskDO.class, o -> { // 等会查询到
|
||||
o.setCode(null);
|
||||
o.setOrderDate(null);
|
||||
o.setDeliveryDate(null);
|
||||
o.setStatus(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
taskMapper.insert(dbTask);
|
||||
// 测试 code 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCode(null)));
|
||||
// 测试 orderDate 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setOrderDate(null)));
|
||||
// 测试 deliveryDate 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setDeliveryDate(null)));
|
||||
// 测试 status 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setStatus(null)));
|
||||
// 测试 processInstanceId 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setProcessInstanceId(null)));
|
||||
// 测试 remark 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setRemark(null)));
|
||||
// 测试 createTime 不匹配
|
||||
taskMapper.insert(cloneIgnoreId(dbTask, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
TaskPageReqVO reqVO = new TaskPageReqVO();
|
||||
reqVO.setCode(null);
|
||||
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setProcessInstanceId(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<TaskDO> pageResult = taskService.getTaskPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbTask, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue