基本数据管理-机床型号管理

This commit is contained in:
xusd 2024-08-27 16:04:35 +08:00
parent e99bdd54d1
commit 092d7682b3
13 changed files with 768 additions and 0 deletions

View File

@ -162,4 +162,7 @@ public interface ErrorCodeConstants {
// ========== 站内信发送 1-002-028-000 ==========
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
// ========== 基础信息模块 ==========
ErrorCode MODEL_INFO_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到机床型号信息");
}

View File

@ -0,0 +1,98 @@
package com.inspur.module.system.controller.baseData;
import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO;
import com.inspur.module.system.controller.baseData.vo.ModelInfoRespVO;
import com.inspur.module.system.controller.baseData.vo.ModelInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO;
import com.inspur.module.system.service.baseData.ModelInfoService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.pojo.CommonResult.success;
import com.inspur.framework.excel.core.util.ExcelUtils;
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*;
@Tag(name = "管理后台 - 机床型号信息")
@RestController
@RequestMapping("/admin-api/baseData/modelInfo")
@Validated
public class ModelInfoController {
@Resource
private ModelInfoService modelInfoService;
@PostMapping("/create")
@Operation(summary = "创建机床型号信息")
@PreAuthorize("@ss.hasPermission('imt:model-info:create')")
public CommonResult<String> createModelInfo(@Valid @RequestBody ModelInfoSaveReqVO createReqVO) {
return success(modelInfoService.createModelInfo(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新机床型号信息")
@PreAuthorize("@ss.hasPermission('imt:model-info:update')")
public CommonResult<Boolean> updateModelInfo(@Valid @RequestBody ModelInfoSaveReqVO updateReqVO) {
modelInfoService.updateModelInfo(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除机床型号信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:model-info:delete')")
public CommonResult<Boolean> deleteModelInfo(@RequestParam("id") String id) {
modelInfoService.deleteModelInfo(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得机床型号信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:model-info:query')")
public CommonResult<ModelInfoRespVO> getModelInfo(@RequestParam("id") String id) {
ModelInfoDO modelInfo = modelInfoService.getModelInfo(id);
return success(BeanUtils.toBean(modelInfo, ModelInfoRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得机床型号信息分页")
@PreAuthorize("@ss.hasPermission('imt:model-info:query')")
public CommonResult<PageResult<ModelInfoRespVO>> getModelInfoPage(@Valid ModelInfoPageReqVO pageReqVO) {
PageResult<ModelInfoDO> pageResult = modelInfoService.getModelInfoPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ModelInfoRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出机床型号信息 Excel")
@PreAuthorize("@ss.hasPermission('imt:model-info:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportModelInfoExcel(@Valid ModelInfoPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ModelInfoDO> list = modelInfoService.getModelInfoPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "机床型号信息.xls", "数据", ModelInfoRespVO.class, BeanUtils.toBean(list, ModelInfoRespVO.class));
}
}

View File

@ -0,0 +1,19 @@
package com.inspur.module.system.controller.baseData.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.inspur.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 机床型号信息分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ModelInfoPageReqVO extends PageParam {
@Schema(description = "机床型号名称")
private String modelName;
@Schema(description = "机床类型0立式1卧式2龙门3立车4其他")
private Integer machineType;
}

View File

@ -0,0 +1,44 @@
package com.inspur.module.system.controller.baseData.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.*;
import com.inspur.framework.excel.core.annotations.DictFormat;
import com.inspur.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 机床型号信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ModelInfoRespVO {
@Schema(description = "机床型号id", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("机床型号id")
private String modelId;
@Schema(description = "机床型号名称", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("机床型号名称")
private String modelName;
@Schema(description = "机床类型0立式1卧式2龙门3立车4其他", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty(value = "机床类型", converter = DictConvert.class)
@DictFormat("machine_type") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer machineType;
@Schema(description = "规格参数")
@ExcelProperty("规格参数")
private String modelSpn;
@Schema(description = "状态0开启1关闭")
@ExcelProperty(value = "状态", converter = DictConvert.class)
@DictFormat("common_status")
private Integer status;
@Schema(description = "备注")
@ExcelProperty("备注")
private String remark;
@Schema(description = "型号图片路径")
private String modelPicPath;
}

View File

@ -0,0 +1,39 @@
package com.inspur.module.system.controller.baseData.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 机床型号信息新增/修改 Request VO")
@Data
public class ModelInfoSaveReqVO {
@Schema(description = "机床型号id", requiredMode = Schema.RequiredMode.REQUIRED)
private String modelId;
@Schema(description = "机床型号名称", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "机床型号名称不能为空")
@Size(message = "机床型号最大不允许超过20个字符", max = 20)
private String modelName;
@Schema(description = "机床类型0立式1卧式2龙门3立车4其他", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "机床类型0立式1卧式2龙门3立车4其他不能为空")
private Integer machineType;
@Schema(description = "规格参数")
@Size(message = "规格参数最大不允许超过255个字符", max = 255)
private String modelSpn;
@Schema(description = "状态0开启1关闭")
private Integer status;
@Schema(description = "备注")
@Size(message = "备注最大不允许超过500个字符", max = 500)
private String remark;
@Schema(description = "型号图片路径")
private String modelPicPath;
}

View File

@ -0,0 +1,54 @@
package com.inspur.module.system.dal.dataobject.baseData;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
/**
* 机床型号信息 DO
*
* @author 芋道源码
*/
@TableName("imt_model_info")
@KeySequence("imt_model_info_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ModelInfoDO extends BaseDO {
/**
* 机床型号id
*/
@TableId(type = IdType.ASSIGN_UUID)
private String modelId;
/**
* 机床型号名称
*/
private String modelName;
/**
* 机床类型0立式1卧式2龙门3立车4其他
*
*/
private Integer machineType;
/**
* 规格参数
*/
private String modelSpn;
/**
* 状态0开启1关闭
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 型号图片路径
*/
private String modelPicPath;
}

View File

@ -0,0 +1,25 @@
package com.inspur.module.system.dal.mysql.baseData;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO;
import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 机床型号信息 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface ModelInfoMapper extends BaseMapperX<ModelInfoDO> {
default PageResult<ModelInfoDO> selectPage(ModelInfoPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ModelInfoDO>()
.likeIfPresent(ModelInfoDO::getModelName, reqVO.getModelName())
.eqIfPresent(ModelInfoDO::getMachineType, reqVO.getMachineType())
.orderByDesc(ModelInfoDO::getModelId));
}
}

View File

@ -0,0 +1,55 @@
package com.inspur.module.system.service.baseData;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO;
import com.inspur.module.system.controller.baseData.vo.ModelInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO;
import javax.validation.*;
/**
* 机床型号信息 Service 接口
*
* @author 芋道源码
*/
public interface ModelInfoService {
/**
* 创建机床型号信息
*
* @param createReqVO 创建信息
* @return 编号
*/
String createModelInfo(@Valid ModelInfoSaveReqVO createReqVO);
/**
* 更新机床型号信息
*
* @param updateReqVO 更新信息
*/
void updateModelInfo(@Valid ModelInfoSaveReqVO updateReqVO);
/**
* 删除机床型号信息
*
* @param id 编号
*/
void deleteModelInfo(String id);
/**
* 获得机床型号信息
*
* @param id 编号
* @return 机床型号信息
*/
ModelInfoDO getModelInfo(String id);
/**
* 获得机床型号信息分页
*
* @param pageReqVO 分页查询
* @return 机床型号信息分页
*/
PageResult<ModelInfoDO> getModelInfoPage(ModelInfoPageReqVO pageReqVO);
}

View File

@ -0,0 +1,70 @@
package com.inspur.module.system.service.baseData;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.module.system.controller.baseData.vo.ModelInfoPageReqVO;
import com.inspur.module.system.controller.baseData.vo.ModelInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.baseData.ModelInfoDO;
import com.inspur.module.system.dal.mysql.baseData.ModelInfoMapper;
import com.inspur.module.system.enums.ErrorCodeConstants;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 机床型号信息 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class ModelInfoServiceImpl implements ModelInfoService {
@Resource
private ModelInfoMapper modelInfoMapper;
@Override
public String createModelInfo(ModelInfoSaveReqVO createReqVO) {
// 插入
ModelInfoDO modelInfo = BeanUtils.toBean(createReqVO, ModelInfoDO.class);
modelInfoMapper.insert(modelInfo);
// 返回
return modelInfo.getModelId();
}
@Override
public void updateModelInfo(ModelInfoSaveReqVO updateReqVO) {
// 校验存在
validateModelInfoExists(updateReqVO.getModelId());
// 更新
ModelInfoDO updateObj = BeanUtils.toBean(updateReqVO, ModelInfoDO.class);
modelInfoMapper.updateById(updateObj);
}
@Override
public void deleteModelInfo(String id) {
// 校验存在
validateModelInfoExists(id);
// 删除
modelInfoMapper.deleteById(id);
}
private void validateModelInfoExists(String id) {
if (modelInfoMapper.selectById(id) == null) {
throw exception(ErrorCodeConstants.MODEL_INFO_NOT_EXISTS);
}
}
@Override
public ModelInfoDO getModelInfo(String id) {
return modelInfoMapper.selectById(id);
}
@Override
public PageResult<ModelInfoDO> getModelInfoPage(ModelInfoPageReqVO pageReqVO) {
return modelInfoMapper.selectPage(pageReqVO);
}
}

View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 创建机床型号信息
export function createModelInfo(data) {
return request({
url: '/baseData/modelInfo/create',
method: 'post',
data: data
})
}
// 更新机床型号信息
export function updateModelInfo(data) {
return request({
url: '/baseData/modelInfo/update',
method: 'put',
data: data
})
}
// 删除机床型号信息
export function deleteModelInfo(id) {
return request({
url: '/baseData/modelInfo/delete?id=' + id,
method: 'delete'
})
}
// 获得机床型号信息
export function getModelInfo(id) {
return request({
url: '/baseData/modelInfo/get?id=' + id,
method: 'get'
})
}
// 获得机床型号信息分页
export function getModelInfoPage(params) {
return request({
url: '/baseData/modelInfo/page',
method: 'get',
params
})
}
// 导出机床型号信息 Excel
export function exportModelInfoExcel(params) {
return request({
url: '/baseData/modelInfo/export-excel',
method: 'get',
params,
responseType: 'blob'
})
}

View File

@ -10,6 +10,9 @@ export const DICT_TYPE = {
COMMON_STATUS: 'common_status',
TERMINAL: 'terminal',
//========== imt 模块 ==========
MACHINE_TYPE: 'machine_type',
// ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX: 'system_user_sex',
SYSTEM_MENU_TYPE: 'system_menu_type',

View File

@ -0,0 +1,136 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-form-item label="机床型号" prop="modelName">
<el-input v-model="formData.modelName" placeholder="请输入机床型号"/>
</el-form-item>
<el-form-item label="机床类型" prop="machineType">
<el-select v-model="formData.machineType" placeholder="请选择机床类型">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.MACHINE_TYPE)"
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
</el-select>
</el-form-item>
<el-form-item label="规格参数" prop="modelSpn">
<el-input v-model="formData.modelSpn" placeholder="请输入规格参数"/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="parseInt(dict.value)"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
<el-form-item label="型号图片" prop="modelPicPath">
<ImageUpload v-model="formData.modelPicPath"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as ModelInfoApi from '@/api/system/baseData/modelinfo';
import ImageUpload from '@/components/ImageUpload';
export default {
name: "ModelInfoForm",
components: {
ImageUpload,
},
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
modelId: undefined,
modelName: undefined,
machineType: undefined,
modelSpn: undefined,
status: undefined,
remark: undefined,
modelPicPath: undefined,
},
//
formRules: {
modelName: [{required: true, message: '机床型号不能为空', trigger: 'blur'}],
machineType: [{
required: true,
message: '机床类型不能为空',
trigger: 'change'
}],
},
};
},
methods: {
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
//
if (id) {
this.formLoading = true;
try {
const res = await ModelInfoApi.getModelInfo(id);
this.formData = res.data;
this.title = "修改机床型号信息";
} finally {
this.formLoading = false;
}
}
this.title = "新增机床型号信息";
},
/** 提交按钮 */
async submitForm() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.modelId) {
await ModelInfoApi.updateModelInfo(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit('success');
return;
}
//
await ModelInfoApi.createModelInfo(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit('success');
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
modelId: undefined,
modelName: undefined,
machineType: undefined,
modelSpn: undefined,
status: undefined,
remark: undefined,
modelPicPath: undefined,
};
this.resetForm("formRef");
}
}
};
</script>

View File

@ -0,0 +1,169 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="机床型号" prop="modelName">
<el-input v-model="queryParams.modelName" placeholder="请输入机床型号" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="机床类型" prop="machineType">
<el-select v-model="queryParams.machineType" placeholder="请选择机床类型"
clearable size="small">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.MACHINE_TYPE)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
v-hasPermi="['imt:model-info:create']">新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
:loading="exportLoading"
v-hasPermi="['imt:model-info:export']">导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="机床型号" align="center" prop="modelName"/>
<el-table-column label="机床类型" align="center" prop="machineType">
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.MACHINE_TYPE" :value="scope.row.machineType"/>
</template>
</el-table-column>
<el-table-column label="规格参数" align="center" prop="modelSpn"/>
<el-table-column label="状态" align="center" prop="status">
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="型号图片" align="center" prop="modelPicPath">
<template v-slot="scope">
<img
:src="scope.row.modelPicPath"
style="display: block; width: 100px; height: 100px; margin: 0 auto"
/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.modelId)"
v-hasPermi="['imt:model-info:update']">修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['imt:model-info:delete']">删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<ModelInfoForm ref="formRef" @success="getList"/>
</div>
</template>
<script>
import * as ModelInfoApi from '@/api/system/baseData/modelinfo';
import ModelInfoForm from './ModelInfoForm.vue';
export default {
name: "ModelInfo",
components: {
ModelInfoForm,
},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
pageNo: 1,
pageSize: 10,
modelName: null,
machineType: null,
},
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await ModelInfoApi.getModelInfoPage(this.queryParams);
this.list = res.data.list;
this.total = res.data.total;
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
/** 删除按钮操作 */
async handleDelete(row) {
const modelId = row.modelId;
await this.$modal.confirm('是否确认删除机床型号为"' + row.modelName + '"的数据项?')
try {
await ModelInfoApi.deleteModelInfo(modelId);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {
}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm('是否确认导出所有机床型号信息数据项?');
try {
this.exportLoading = true;
const data = await ModelInfoApi.exportModelInfoExcel(this.queryParams);
this.$download.excel(data, '机床型号信息.xls');
} catch {
} finally {
this.exportLoading = false;
}
},
}
};
</script>