feat:添加工艺参数及工艺路线相关接口
parent
ed4be3916d
commit
f8b097b4b7
@ -0,0 +1,101 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processparameter;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterPageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processparameter.ProcessParameterDO;
|
||||
import cn.iocoder.yudao.module.mes.service.processparameter.ProcessParameterService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
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.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 工艺参数")
|
||||
@RestController
|
||||
@RequestMapping("/mes/process-parameter")
|
||||
@Validated
|
||||
public class ProcessParameterController {
|
||||
|
||||
@Resource
|
||||
private ProcessParameterService processParameterService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建工艺参数")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:create')")
|
||||
public CommonResult<Long> createProcessParameter(@Valid @RequestBody ProcessParameterSaveReqVO createReqVO) {
|
||||
return success(processParameterService.createProcessParameter(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新工艺参数")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:update')")
|
||||
public CommonResult<Boolean> updateProcessParameter(@Valid @RequestBody ProcessParameterSaveReqVO updateReqVO) {
|
||||
processParameterService.updateProcessParameter(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除工艺参数")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:delete')")
|
||||
public CommonResult<Boolean> deleteProcessParameter(@RequestParam("id") Long id) {
|
||||
processParameterService.deleteProcessParameter(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得工艺参数")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:query')")
|
||||
public CommonResult<ProcessParameterRespVO> getProcessParameter(@RequestParam("id") Long id) {
|
||||
ProcessParameterDO processParameter = processParameterService.getProcessParameter(id);
|
||||
return success(BeanUtils.toBean(processParameter, ProcessParameterRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得工艺参数分页")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:query')")
|
||||
public CommonResult<PageResult<ProcessParameterRespVO>> getProcessParameterPage(@Valid ProcessParameterPageReqVO pageReqVO) {
|
||||
PageResult<ProcessParameterDO> pageResult = processParameterService.getProcessParameterPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ProcessParameterRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得工艺参数列表")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:query')")
|
||||
public CommonResult<List<ProcessParameterRespVO>> getProcessParameterList(
|
||||
@RequestParam(value = "isEnable", required = false) Boolean isEnable) {
|
||||
List<ProcessParameterDO> list = processParameterService.getProcessParameterList(isEnable);
|
||||
return success(BeanUtils.toBean(list, ProcessParameterRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出工艺参数 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-parameter:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportProcessParameterExcel(@Valid ProcessParameterPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ProcessParameterDO> list = processParameterService.getProcessParameterPage(pageReqVO).getList();
|
||||
ExcelUtils.write(response, "工艺参数.xls", "数据", ProcessParameterRespVO.class,
|
||||
BeanUtils.toBean(list, ProcessParameterRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
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 ProcessParameterPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "工艺参数编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "工艺参数名称", example = "碎浆")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "id 集合,导出用")
|
||||
private String ids;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 工艺参数 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProcessParameterRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工艺参数编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("工艺参数编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "工艺参数名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "碎浆")
|
||||
@ExcelProperty("工艺参数名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty(value = "是否启用", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
@ColumnWidth(20)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 工艺参数新增/修改 Request VO")
|
||||
@Data
|
||||
public class ProcessParameterSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工艺参数编码,不填时自动生成")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "工艺参数名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "碎浆")
|
||||
@NotEmpty(message = "工艺参数名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否启用不能为空")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processroute;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRoutePageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteDO;
|
||||
import cn.iocoder.yudao.module.mes.service.processroute.ProcessRouteService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
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.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 工艺路线")
|
||||
@RestController
|
||||
@RequestMapping("/mes/process-route")
|
||||
@Validated
|
||||
public class ProcessRouteController {
|
||||
|
||||
@Resource
|
||||
private ProcessRouteService processRouteService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建工艺路线")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:create')")
|
||||
public CommonResult<Long> createProcessRoute(@Valid @RequestBody ProcessRouteSaveReqVO createReqVO) {
|
||||
return success(processRouteService.createProcessRoute(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新工艺路线")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:update')")
|
||||
public CommonResult<Boolean> updateProcessRoute(@Valid @RequestBody ProcessRouteSaveReqVO updateReqVO) {
|
||||
processRouteService.updateProcessRoute(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除工艺路线")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:delete')")
|
||||
public CommonResult<Boolean> deleteProcessRoute(@RequestParam("id") Long id) {
|
||||
processRouteService.deleteProcessRoute(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得工艺路线")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:query')")
|
||||
public CommonResult<ProcessRouteRespVO> getProcessRoute(@RequestParam("id") Long id) {
|
||||
return success(processRouteService.getProcessRouteResp(id));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得工艺路线分页")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:query')")
|
||||
public CommonResult<PageResult<ProcessRouteRespVO>> getProcessRoutePage(@Valid ProcessRoutePageReqVO pageReqVO) {
|
||||
PageResult<ProcessRouteDO> pageResult = processRouteService.getProcessRoutePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ProcessRouteRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得工艺路线列表")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:query')")
|
||||
public CommonResult<List<ProcessRouteRespVO>> getProcessRouteList(
|
||||
@RequestParam(value = "isEnable", required = false) Boolean isEnable) {
|
||||
List<ProcessRouteDO> list = processRouteService.getProcessRouteList(isEnable);
|
||||
return success(BeanUtils.toBean(list, ProcessRouteRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出工艺路线 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('mes:process-route:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportProcessRouteExcel(@Valid ProcessRoutePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ProcessRouteDO> list = processRouteService.getProcessRoutePage(pageReqVO).getList();
|
||||
ExcelUtils.write(response, "工艺路线.xls", "数据", ProcessRouteRespVO.class,
|
||||
BeanUtils.toBean(list, ProcessRouteRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processroute.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 工艺路线明细 Response VO")
|
||||
@Data
|
||||
public class ProcessRouteItemRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工艺路线编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long routeId;
|
||||
|
||||
@Schema(description = "排序,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "工艺参数编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Long processParameterId;
|
||||
|
||||
@Schema(description = "工艺参数编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String processParameterCode;
|
||||
|
||||
@Schema(description = "工艺参数名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String processParameterName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processroute.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 工艺路线明细新增/修改 Request VO")
|
||||
@Data
|
||||
public class ProcessRouteItemSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "排序,从 1 开始。不传时按数组顺序自动填充", example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "工艺参数编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@NotNull(message = "工艺参数编号不能为空")
|
||||
private Long processParameterId;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processroute.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
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 ProcessRoutePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "工艺路线编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "工艺路线名称", example = "标准生产路线")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "id 集合,导出用")
|
||||
private String ids;
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processroute.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 工艺路线 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProcessRouteRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工艺路线编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("工艺路线编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "工艺路线名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "标准生产路线")
|
||||
@ExcelProperty("工艺路线名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty(value = "是否启用", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
@ColumnWidth(20)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "工艺参数明细")
|
||||
private List<ProcessRouteItemRespVO> items;
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.mes.controller.admin.processroute.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 工艺路线新增/修改 Request VO")
|
||||
@Data
|
||||
public class ProcessRouteSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工艺路线编码,不填时自动生成")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "工艺路线名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "标准生产路线")
|
||||
@NotEmpty(message = "工艺路线名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否启用不能为空")
|
||||
private Boolean isEnable;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "工艺参数明细,可重复选择相同工艺参数", implementation = ProcessRouteItemSaveReqVO.class)
|
||||
@Valid
|
||||
private List<ProcessRouteItemSaveReqVO> items;
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.processparameter;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 工艺参数 DO
|
||||
*/
|
||||
@TableName("mes_process_parameter")
|
||||
@KeySequence("mes_process_parameter_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProcessParameterDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 工艺参数编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 工艺参数名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.dataobject.processroute;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 工艺路线 DO
|
||||
*/
|
||||
@TableName("mes_process_route")
|
||||
@KeySequence("mes_process_route_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProcessRouteDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 工艺路线编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 工艺路线名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isEnable;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.processparameter;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterPageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processparameter.ProcessParameterDO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mapper
|
||||
public interface ProcessParameterMapper extends BaseMapperX<ProcessParameterDO> {
|
||||
|
||||
default PageResult<ProcessParameterDO> selectPage(ProcessParameterPageReqVO reqVO) {
|
||||
LambdaQueryWrapperX<ProcessParameterDO> wrapper = new LambdaQueryWrapperX<ProcessParameterDO>()
|
||||
.eqIfPresent(ProcessParameterDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(ProcessParameterDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProcessParameterDO::getIsEnable, reqVO.getIsEnable())
|
||||
.betweenIfPresent(ProcessParameterDO::getCreateTime, reqVO.getCreateTime());
|
||||
|
||||
if (StringUtils.isNotBlank(reqVO.getIds())) {
|
||||
List<Long> idList = Arrays.stream(reqVO.getIds().split(","))
|
||||
.map(String::trim)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
if (!idList.isEmpty()) {
|
||||
wrapper.in(ProcessParameterDO::getId, idList);
|
||||
}
|
||||
}
|
||||
return selectPage(reqVO, wrapper.orderByDesc(ProcessParameterDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.processroute;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteItemDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProcessRouteItemMapper extends BaseMapperX<ProcessRouteItemDO> {
|
||||
|
||||
default List<ProcessRouteItemDO> selectListByRouteId(Long routeId) {
|
||||
return selectList(new LambdaQueryWrapperX<ProcessRouteItemDO>()
|
||||
.eq(ProcessRouteItemDO::getRouteId, routeId)
|
||||
.orderByAsc(ProcessRouteItemDO::getSort)
|
||||
.orderByAsc(ProcessRouteItemDO::getId));
|
||||
}
|
||||
|
||||
default void deleteByRouteId(Long routeId) {
|
||||
delete(new LambdaQueryWrapperX<ProcessRouteItemDO>()
|
||||
.eq(ProcessRouteItemDO::getRouteId, routeId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.mes.dal.mysql.processroute;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRoutePageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteDO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mapper
|
||||
public interface ProcessRouteMapper extends BaseMapperX<ProcessRouteDO> {
|
||||
|
||||
default PageResult<ProcessRouteDO> selectPage(ProcessRoutePageReqVO reqVO) {
|
||||
LambdaQueryWrapperX<ProcessRouteDO> wrapper = new LambdaQueryWrapperX<ProcessRouteDO>()
|
||||
.eqIfPresent(ProcessRouteDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(ProcessRouteDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProcessRouteDO::getIsEnable, reqVO.getIsEnable())
|
||||
.betweenIfPresent(ProcessRouteDO::getCreateTime, reqVO.getCreateTime());
|
||||
|
||||
if (StringUtils.isNotBlank(reqVO.getIds())) {
|
||||
List<Long> idList = Arrays.stream(reqVO.getIds().split(","))
|
||||
.map(String::trim)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
if (!idList.isEmpty()) {
|
||||
wrapper.in(ProcessRouteDO::getId, idList);
|
||||
}
|
||||
}
|
||||
return selectPage(reqVO, wrapper.orderByDesc(ProcessRouteDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.mes.service.processparameter;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterPageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processparameter.ProcessParameterDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProcessParameterService {
|
||||
|
||||
Long createProcessParameter(@Valid ProcessParameterSaveReqVO createReqVO);
|
||||
|
||||
void updateProcessParameter(@Valid ProcessParameterSaveReqVO updateReqVO);
|
||||
|
||||
void deleteProcessParameter(Long id);
|
||||
|
||||
ProcessParameterDO getProcessParameter(Long id);
|
||||
|
||||
List<ProcessParameterDO> getProcessParameterList(Collection<Long> ids);
|
||||
|
||||
List<ProcessParameterDO> getProcessParameterList(Boolean isEnable);
|
||||
|
||||
PageResult<ProcessParameterDO> getProcessParameterPage(ProcessParameterPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package cn.iocoder.yudao.module.mes.service.processparameter;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterPageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processparameter.vo.ProcessParameterSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processparameter.ProcessParameterDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.processparameter.ProcessParameterMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PROCESS_PARAMETER_CODE_EXISTS;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PROCESS_PARAMETER_NOT_EXISTS;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class ProcessParameterServiceImpl implements ProcessParameterService {
|
||||
|
||||
private static final String PROCESS_PARAMETER_CODE_RULE = "PROCESS_PARAMETER_CODE";
|
||||
|
||||
@Resource
|
||||
private ProcessParameterMapper processParameterMapper;
|
||||
@Resource
|
||||
private AutoCodeUtil autoCodeUtil;
|
||||
|
||||
@Override
|
||||
public Long createProcessParameter(ProcessParameterSaveReqVO createReqVO) {
|
||||
ProcessParameterDO processParameter = BeanUtils.toBean(createReqVO, ProcessParameterDO.class);
|
||||
if (StringUtils.isBlank(processParameter.getCode())) {
|
||||
processParameter.setCode(autoCodeUtil.genSerialCode(PROCESS_PARAMETER_CODE_RULE, null));
|
||||
} else {
|
||||
validateCodeUnique(processParameter.getCode(), null);
|
||||
}
|
||||
processParameterMapper.insert(processParameter);
|
||||
return processParameter.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProcessParameter(ProcessParameterSaveReqVO updateReqVO) {
|
||||
validateProcessParameterExists(updateReqVO.getId());
|
||||
ProcessParameterDO updateObj = BeanUtils.toBean(updateReqVO, ProcessParameterDO.class);
|
||||
if (StringUtils.isBlank(updateObj.getCode())) {
|
||||
updateObj.setCode(null);
|
||||
} else {
|
||||
validateCodeUnique(updateObj.getCode(), updateObj.getId());
|
||||
}
|
||||
processParameterMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProcessParameter(Long id) {
|
||||
validateProcessParameterExists(id);
|
||||
processParameterMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessParameterDO getProcessParameter(Long id) {
|
||||
return processParameterMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessParameterDO> getProcessParameterList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return processParameterMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessParameterDO> getProcessParameterList(Boolean isEnable) {
|
||||
return processParameterMapper.selectList(Wrappers.<ProcessParameterDO>lambdaQuery()
|
||||
.eq(isEnable != null, ProcessParameterDO::getIsEnable, isEnable)
|
||||
.orderByDesc(ProcessParameterDO::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProcessParameterDO> getProcessParameterPage(ProcessParameterPageReqVO pageReqVO) {
|
||||
return processParameterMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateProcessParameterExists(Long id) {
|
||||
if (id == null || processParameterMapper.selectById(id) == null) {
|
||||
throw exception(PROCESS_PARAMETER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCodeUnique(String code, Long id) {
|
||||
Long count = processParameterMapper.selectCount(Wrappers.<ProcessParameterDO>lambdaQuery()
|
||||
.eq(ProcessParameterDO::getCode, code)
|
||||
.ne(id != null, ProcessParameterDO::getId, id));
|
||||
if (count != null && count > 0) {
|
||||
throw exception(PROCESS_PARAMETER_CODE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.mes.service.processroute;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRoutePageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteItemDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProcessRouteService {
|
||||
|
||||
Long createProcessRoute(@Valid ProcessRouteSaveReqVO createReqVO);
|
||||
|
||||
void updateProcessRoute(@Valid ProcessRouteSaveReqVO updateReqVO);
|
||||
|
||||
void deleteProcessRoute(Long id);
|
||||
ProcessRouteDO getProcessRoute(Long id);
|
||||
ProcessRouteRespVO getProcessRouteResp(Long id);
|
||||
List<ProcessRouteDO> getProcessRouteList(Boolean isEnable);
|
||||
PageResult<ProcessRouteDO> getProcessRoutePage(ProcessRoutePageReqVO pageReqVO);
|
||||
List<ProcessRouteItemDO> getProcessRouteItemListByRouteId(Long routeId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
package cn.iocoder.yudao.module.mes.service.processroute;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteItemSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRoutePageReqVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteRespVO;
|
||||
import cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteSaveReqVO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processparameter.ProcessParameterDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.dataobject.processroute.ProcessRouteItemDO;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.processparameter.ProcessParameterMapper;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.processroute.ProcessRouteItemMapper;
|
||||
import cn.iocoder.yudao.module.mes.dal.mysql.processroute.ProcessRouteMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class ProcessRouteServiceImpl implements ProcessRouteService {
|
||||
|
||||
private static final String PROCESS_ROUTE_CODE_RULE = "PROCESS_ROUTE_CODE";
|
||||
|
||||
@Resource
|
||||
private ProcessRouteMapper processRouteMapper;
|
||||
@Resource
|
||||
private ProcessRouteItemMapper processRouteItemMapper;
|
||||
@Resource
|
||||
private ProcessParameterMapper processParameterMapper;
|
||||
@Resource
|
||||
private AutoCodeUtil autoCodeUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createProcessRoute(ProcessRouteSaveReqVO createReqVO) {
|
||||
ProcessRouteDO processRoute = BeanUtils.toBean(createReqVO, ProcessRouteDO.class);
|
||||
if (StringUtils.isBlank(processRoute.getCode())) {
|
||||
processRoute.setCode(autoCodeUtil.genSerialCode(PROCESS_ROUTE_CODE_RULE, null));
|
||||
} else {
|
||||
validateCodeUnique(processRoute.getCode(), null);
|
||||
}
|
||||
processRouteMapper.insert(processRoute);
|
||||
createProcessRouteItemList(processRoute.getId(), createReqVO.getItems());
|
||||
return processRoute.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateProcessRoute(ProcessRouteSaveReqVO updateReqVO) {
|
||||
validateProcessRouteExists(updateReqVO.getId());
|
||||
ProcessRouteDO updateObj = BeanUtils.toBean(updateReqVO, ProcessRouteDO.class);
|
||||
if (StringUtils.isBlank(updateObj.getCode())) {
|
||||
updateObj.setCode(null);
|
||||
} else {
|
||||
validateCodeUnique(updateObj.getCode(), updateObj.getId());
|
||||
}
|
||||
processRouteMapper.updateById(updateObj);
|
||||
if (updateReqVO.getItems() != null) {
|
||||
processRouteItemMapper.deleteByRouteId(updateReqVO.getId());
|
||||
createProcessRouteItemList(updateReqVO.getId(), updateReqVO.getItems());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteProcessRoute(Long id) {
|
||||
validateProcessRouteExists(id);
|
||||
processRouteMapper.deleteById(id);
|
||||
processRouteItemMapper.deleteByRouteId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessRouteDO getProcessRoute(Long id) {
|
||||
return processRouteMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessRouteRespVO getProcessRouteResp(Long id) {
|
||||
ProcessRouteDO processRoute = processRouteMapper.selectById(id);
|
||||
ProcessRouteRespVO respVO = BeanUtils.toBean(processRoute, ProcessRouteRespVO.class);
|
||||
if (respVO != null) {
|
||||
respVO.setItems(BeanUtils.toBean(processRouteItemMapper.selectListByRouteId(id),
|
||||
cn.iocoder.yudao.module.mes.controller.admin.processroute.vo.ProcessRouteItemRespVO.class));
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProcessRouteDO> getProcessRoutePage(ProcessRoutePageReqVO pageReqVO) {
|
||||
return processRouteMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessRouteDO> getProcessRouteList(Boolean isEnable) {
|
||||
return processRouteMapper.selectList(Wrappers.<ProcessRouteDO>lambdaQuery()
|
||||
.eq(isEnable != null, ProcessRouteDO::getIsEnable, isEnable)
|
||||
.orderByDesc(ProcessRouteDO::getId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProcessRouteItemDO> getProcessRouteItemListByRouteId(Long routeId) {
|
||||
return processRouteItemMapper.selectListByRouteId(routeId);
|
||||
}
|
||||
|
||||
private void createProcessRouteItemList(Long routeId, List<ProcessRouteItemSaveReqVO> items) {
|
||||
if (CollUtil.isEmpty(items)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, ProcessParameterDO> parameterMap = getProcessParameterMap(convertSet(items,
|
||||
ProcessRouteItemSaveReqVO::getProcessParameterId));
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
ProcessRouteItemSaveReqVO item = items.get(i);
|
||||
ProcessParameterDO processParameter = parameterMap.get(item.getProcessParameterId());
|
||||
if (processParameter == null) {
|
||||
throw exception(PROCESS_PARAMETER_NOT_EXISTS);
|
||||
}
|
||||
ProcessRouteItemDO itemDO = BeanUtils.toBean(item, ProcessRouteItemDO.class);
|
||||
itemDO.setRouteId(routeId);
|
||||
itemDO.setSort(item.getSort() != null ? item.getSort() : i + 1);
|
||||
itemDO.setProcessParameterCode(processParameter.getCode());
|
||||
itemDO.setProcessParameterName(processParameter.getName());
|
||||
processRouteItemMapper.insert(itemDO);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Long, ProcessParameterDO> getProcessParameterMap(Collection<Long> ids) {
|
||||
List<Long> filteredIds = ids.stream().filter(Objects::nonNull).collect(java.util.stream.Collectors.toList());
|
||||
if (CollUtil.isEmpty(filteredIds)) {
|
||||
return java.util.Collections.emptyMap();
|
||||
}
|
||||
return CollectionUtils.convertMap(processParameterMapper.selectBatchIds(filteredIds), ProcessParameterDO::getId);
|
||||
}
|
||||
|
||||
private void validateProcessRouteExists(Long id) {
|
||||
if (id == null || processRouteMapper.selectById(id) == null) {
|
||||
throw exception(PROCESS_ROUTE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCodeUnique(String code, Long id) {
|
||||
Long count = processRouteMapper.selectCount(Wrappers.<ProcessRouteDO>lambdaQuery()
|
||||
.eq(ProcessRouteDO::getCode, code)
|
||||
.ne(id != null, ProcessRouteDO::getId, id));
|
||||
if (count != null && count > 0) {
|
||||
throw exception(PROCESS_ROUTE_CODE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue