添加机台与机台模板 树列表接口

This commit is contained in:
yangsb
2024-03-13 09:47:03 +08:00
parent 6dd9a16a8d
commit fc5425c414
9 changed files with 75 additions and 2 deletions
@@ -18,6 +18,7 @@ import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.object.BeanUtils; import com.cf.imes.framework.common.util.object.BeanUtils;
import java.util.List; import java.util.List;
import java.util.Map;
import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.common.pojo.CommonResult.success;
@@ -153,4 +154,13 @@ public class MachineController {
return success(respVO); return success(respVO);
} }
@GetMapping("getMachineTree")
@Operation(summary = "获得机台树")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('machine::query')")
public CommonResult<Map<Integer, List<MachineVO>>> getMachineTree() {
return success(machineService.getMachineTree());
}
} }
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.common.pojo.CommonResult.success;
@@ -31,6 +32,15 @@ public class MachineTemplateController {
@Resource @Resource
private MachineTemplateService machineTemplateService; private MachineTemplateService machineTemplateService;
@GetMapping("getMachineTemplateTree")
@Operation(summary = "获得机台模板树")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('machine-template::query')")
public CommonResult<Map<Integer, List<MachineTemplateDO>>> getMachineTemplateTree() {
return success(machineTemplateService.getMachineTemplateTree());
}
@GetMapping("page-template-machine") @GetMapping("page-template-machine")
@Operation(summary = "机台模板分页") @Operation(summary = "机台模板分页")
@PreAuthorize("@ss.hasPermission('machine-template::query')") @PreAuthorize("@ss.hasPermission('machine-template::query')")
@@ -0,0 +1,33 @@
package com.cf.imes.module.system.controller.admin.machine.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author Beal
*/
@Data
public class MachineVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14092")
@ExcelProperty("主键")
private Long id;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("名称")
private String name;
@Schema(description = "1机台设备 2CNC设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("1开料机 2钻孔机")
private Integer machineType;
@Schema(description = "标签id")
private Long labelId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}
@@ -35,7 +35,7 @@ public class MachineDO extends OrganBaseDO {
/** /**
* 1机台设备 2CNC设备 * 1机台设备 2CNC设备
*/ */
private Boolean machineType; private Long machineType;
/** /**
* 标签id * 标签id
*/ */
@@ -27,7 +27,7 @@ public class MachineTemplateDO extends BaseDO {
/** /**
* 1机台设备 2CNC设备 * 1机台设备 2CNC设备
*/ */
private Boolean machineType; private Integer machineType;
/** /**
* 是否默认模板 * 是否默认模板
*/ */
@@ -70,4 +70,6 @@ public interface MachineService {
DrillRespVO getDrill(Long id); DrillRespVO getDrill(Long id);
List<MachineDO> list(Collection<Long> ids); List<MachineDO> list(Collection<Long> ids);
Map<Integer, List<MachineVO>> getMachineTree();
} }
@@ -227,6 +227,14 @@ public class MachineServiceImpl implements MachineService {
return machineMapper.selectBatchIds(ids); return machineMapper.selectBatchIds(ids);
} }
@Override
public Map<Integer, List<MachineVO>> getMachineTree() {
List<MachineDO> machineDOS = machineMapper.selectList();
List<MachineVO> machineVOS = BeanUtils.toBean(machineDOS, MachineVO.class);
Map<Integer, List<MachineVO>> map = machineVOS.stream().collect(Collectors.groupingBy(MachineVO::getMachineType));
return map;
}
private void validateExists(Long id) { private void validateExists(Long id) {
if (machineMapper.selectById(id) == null) { if (machineMapper.selectById(id) == null) {
throw exception(MACHINE_NOT_EXISTS); throw exception(MACHINE_NOT_EXISTS);
@@ -6,6 +6,7 @@ import com.cf.imes.module.system.controller.admin.machine.vo.*;
import com.cf.imes.module.system.dal.dataobject.machinetemplate.MachineTemplateDO; import com.cf.imes.module.system.dal.dataobject.machinetemplate.MachineTemplateDO;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author there * @author there
@@ -41,4 +42,6 @@ public interface MachineTemplateService {
CuttingTemplateRespVO getDefaultCutting(); CuttingTemplateRespVO getDefaultCutting();
DrillTemplateRespVO getDefaultDrill(); DrillTemplateRespVO getDefaultDrill();
Map<Integer, List<MachineTemplateDO>> getMachineTemplateTree();
} }
@@ -250,6 +250,13 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
throw exception(DEFAULT_TEMPLATE_COUNT); throw exception(DEFAULT_TEMPLATE_COUNT);
} }
@Override
public Map<Integer, List<MachineTemplateDO>> getMachineTemplateTree() {
List<MachineTemplateDO> machineTemplateDOS = machineTemplateMapper.selectList();
Map<Integer, List<MachineTemplateDO>> map = machineTemplateDOS.stream().collect(Collectors.groupingBy(MachineTemplateDO::getMachineType));
return map;
}
@Override @Override
public Boolean deleteCuttingTemplate(Long id) { public Boolean deleteCuttingTemplate(Long id) {
MachineTemplateDO templateDO = machineTemplateMapper.selectById(id); MachineTemplateDO templateDO = machineTemplateMapper.selectById(id);