新增MES厂家信息模块,包括数据库表、权限设置、服务层、控制器及前端组件,支持厂家类别、有效状态的字典管理及名称唯一性校验。
This commit is contained in:
89
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
Normal file
89
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
-- MES 厂家信息:字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权(可整文件一次执行)
|
||||||
|
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_manufacturer:*
|
||||||
|
-- 父菜单:MES基础资料 / MES资料(与备品件等脚本相同 @mes_base_pid);修改租户改 SET @mes_tenant_id
|
||||||
|
-- 新环境也可依赖 Flyway:V3.9.2_63__mes_xsl_manufacturer.sql(与本文内容一致,重复执行幂等)
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), 'MES厂家类别', 'xslmes_manufacturer_category', '模具厂家、胶囊厂家、设备厂家', 0, 'admin', NOW(), 0, 0
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_category' AND `del_flag` = 0);
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '模具厂家', 'mold', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'mold');
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '胶囊厂家', 'capsule', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'capsule');
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '设备厂家', 'equipment', 3, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'equipment');
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), 'MES厂家是否有效', 'xslmes_manufacturer_valid', '0有效1无效', 0, 'admin', NOW(), 0, 0
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_valid' AND `del_flag` = 0);
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '有效', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_valid' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '无效', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_valid' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `mes_xsl_manufacturer` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别(字典xslmes_manufacturer_category:mold模具 capsule胶囊 equipment设备)',
|
||||||
|
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称(同租户未删除数据中唯一)',
|
||||||
|
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效(字典xslmes_manufacturer_valid:0有效1无效)',
|
||||||
|
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||||
|
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||||
|
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_mxm_tenant_name` (`tenant_id`, `manufacturer_name`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES厂家信息';
|
||||||
|
|
||||||
|
SET @mes_tenant_id = 1002;
|
||||||
|
|
||||||
|
SET @mes_base_pid = (
|
||||||
|
SELECT MIN(`id`) FROM `sys_permission`
|
||||||
|
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
|
||||||
|
);
|
||||||
|
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
|
||||||
|
VALUES ('1860000000000000112', @mes_base_pid, '厂家信息', '/xslmes/mesXslManufacturer', 'xslmes/mesXslManufacturer/MesXslManufacturerList', NULL, 1, NULL, '1', 17, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
|
||||||
|
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
|
||||||
|
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
|
||||||
|
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||||
|
('1860000000000000113', '1860000000000000112', '新增', 2, 'mes:mes_xsl_manufacturer:add', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000114', '1860000000000000112', '编辑', 2, 'mes:mes_xsl_manufacturer:edit', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000115', '1860000000000000112', '删除', 2, 'mes:mes_xsl_manufacturer:delete', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000116', '1860000000000000112', '批量删除', 2, 'mes:mes_xsl_manufacturer:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000117', '1860000000000000112', '导出', 2, 'mes:mes_xsl_manufacturer:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000118', '1860000000000000112', '导入', 2, 'mes:mes_xsl_manufacturer:importExcel', '1', '1', 0, 'admin', NOW())
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
|
||||||
|
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||||
|
|
||||||
|
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
|
||||||
|
FROM `sys_role` r
|
||||||
|
CROSS JOIN `sys_permission` p
|
||||||
|
WHERE r.`tenant_id` = @mes_tenant_id
|
||||||
|
AND r.`role_code` = 'admin'
|
||||||
|
AND p.`id` IN (
|
||||||
|
'1860000000000000112',
|
||||||
|
'1860000000000000113', '1860000000000000114', '1860000000000000115', '1860000000000000116',
|
||||||
|
'1860000000000000117', '1860000000000000118'
|
||||||
|
)
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_role_permission` rp
|
||||||
|
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||||
|
);
|
||||||
18
jeecg-boot/db/mes-xsl-manufacturer.sql
Normal file
18
jeecg-boot/db/mes-xsl-manufacturer.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
-- 仅建表 mes_xsl_manufacturer。完整初始化(厂家类别/是否有效字典、菜单、租户授权)请执行 mes-xsl-manufacturer-menu-permission.sql
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `mes_xsl_manufacturer` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别(字典xslmes_manufacturer_category:mold模具 capsule胶囊 equipment设备)',
|
||||||
|
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称(同租户未删除数据中唯一)',
|
||||||
|
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效(字典xslmes_manufacturer_valid:0有效1无效)',
|
||||||
|
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||||
|
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||||
|
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_mxm_tenant_name` (`tenant_id`, `manufacturer_name`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES厂家信息';
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
package org.jeecg.modules.xslmes.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||||
|
import org.jeecg.modules.xslmes.service.IMesXslManufacturerService;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 厂家信息
|
||||||
|
*/
|
||||||
|
@Tag(name = "MES厂家信息")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/xslmes/mesXslManufacturer")
|
||||||
|
@Slf4j
|
||||||
|
public class MesXslManufacturerController extends JeecgController<MesXslManufacturer, IMesXslManufacturerService> {
|
||||||
|
|
||||||
|
private static final Set<String> MANUFACTURER_CATEGORIES = Set.of("mold", "capsule", "equipment");
|
||||||
|
private static final Set<String> VALID_STATUS = Set.of("0", "1");
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesXslManufacturerService mesXslManufacturerService;
|
||||||
|
|
||||||
|
@Operation(summary = "MES厂家信息-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<MesXslManufacturer>> queryPageList(
|
||||||
|
MesXslManufacturer model,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<MesXslManufacturer> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||||
|
Page<MesXslManufacturer> page = new Page<>(pageNo, pageSize);
|
||||||
|
IPage<MesXslManufacturer> pageList = mesXslManufacturerService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoLog(value = "MES厂家信息-添加")
|
||||||
|
@Operation(summary = "MES厂家信息-添加")
|
||||||
|
@RequiresPermissions("mes:mes_xsl_manufacturer:add")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody MesXslManufacturer model) {
|
||||||
|
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||||
|
String err = validateForSave(model, null);
|
||||||
|
if (err != null) {
|
||||||
|
return Result.error(err);
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||||
|
mesXslManufacturerService.save(model);
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoLog(value = "MES厂家信息-编辑")
|
||||||
|
@Operation(summary = "MES厂家信息-编辑")
|
||||||
|
@RequiresPermissions("mes:mes_xsl_manufacturer:edit")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody MesXslManufacturer model) {
|
||||||
|
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||||
|
String err = validateForSave(model, model.getId());
|
||||||
|
if (err != null) {
|
||||||
|
return Result.error(err);
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||||
|
mesXslManufacturerService.updateById(model);
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoLog(value = "MES厂家信息-删除")
|
||||||
|
@Operation(summary = "MES厂家信息-通过id删除")
|
||||||
|
@RequiresPermissions("mes:mes_xsl_manufacturer:delete")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
mesXslManufacturerService.removeById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoLog(value = "MES厂家信息-批量删除")
|
||||||
|
@Operation(summary = "MES厂家信息-批量删除")
|
||||||
|
@RequiresPermissions("mes:mes_xsl_manufacturer:deleteBatch")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||||
|
mesXslManufacturerService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "MES厂家信息-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<MesXslManufacturer> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
MesXslManufacturer entity = mesXslManufacturerService.getById(id);
|
||||||
|
if (entity == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "校验厂家名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||||
|
@GetMapping(value = "/checkManufacturerName")
|
||||||
|
public Result<String> checkManufacturerName(
|
||||||
|
@RequestParam(name = "manufacturerName", required = true) String manufacturerName,
|
||||||
|
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||||
|
if (oConvertUtils.isEmpty(manufacturerName) || manufacturerName.trim().isEmpty()) {
|
||||||
|
return Result.OK("该值可用!");
|
||||||
|
}
|
||||||
|
MesXslManufacturer ctx = new MesXslManufacturer();
|
||||||
|
if (mesXslManufacturerService.isManufacturerNameDuplicated(manufacturerName.trim(), dataId, ctx)) {
|
||||||
|
return Result.error("厂家名称不能重复");
|
||||||
|
}
|
||||||
|
return Result.OK("该值可用!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermissions("mes:mes_xsl_manufacturer:exportXls")
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, MesXslManufacturer model) {
|
||||||
|
return super.exportXls(request, model, MesXslManufacturer.class, "MES厂家信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermissions("mes:mes_xsl_manufacturer:importExcel")
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息导入:名称唯一、文件内去重、类别与有效状态校验-----------
|
||||||
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
|
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
|
||||||
|
MultipartFile file = ent.getValue();
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(2);
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
try {
|
||||||
|
List<MesXslManufacturer> list =
|
||||||
|
ExcelImportUtil.importExcel(file.getInputStream(), MesXslManufacturer.class, params);
|
||||||
|
if (list == null) {
|
||||||
|
list = List.of();
|
||||||
|
}
|
||||||
|
Set<String> namesInFile = new HashSet<>();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
MesXslManufacturer row = list.get(i);
|
||||||
|
int rowNo = i + 1;
|
||||||
|
if (row == null) {
|
||||||
|
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||||
|
}
|
||||||
|
String name = row.getManufacturerName();
|
||||||
|
if (name != null) {
|
||||||
|
name = name.trim();
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(name)) {
|
||||||
|
return Result.error("文件导入失败:第 " + rowNo + " 条厂家名称不能为空");
|
||||||
|
}
|
||||||
|
row.setManufacturerName(name);
|
||||||
|
if (!namesInFile.add(name)) {
|
||||||
|
return Result.error("文件导入失败:厂家名称【" + name + "】在导入文件中重复");
|
||||||
|
}
|
||||||
|
String cat = row.getManufacturerCategory();
|
||||||
|
if (oConvertUtils.isEmpty(cat) || !MANUFACTURER_CATEGORIES.contains(cat.trim())) {
|
||||||
|
return Result.error("文件导入失败:第 " + rowNo + " 条厂家类别无效(须为模具厂家/胶囊厂家/设备厂家对应字典值)");
|
||||||
|
}
|
||||||
|
row.setManufacturerCategory(cat.trim());
|
||||||
|
String vs = row.getValidStatus();
|
||||||
|
if (oConvertUtils.isEmpty(vs)) {
|
||||||
|
row.setValidStatus("0");
|
||||||
|
} else {
|
||||||
|
vs = vs.trim();
|
||||||
|
if (!VALID_STATUS.contains(vs)) {
|
||||||
|
return Result.error("文件导入失败:第 " + rowNo + " 条是否有效无效(须为有效或无效对应字典值)");
|
||||||
|
}
|
||||||
|
row.setValidStatus(vs);
|
||||||
|
}
|
||||||
|
if (mesXslManufacturerService.isManufacturerNameDuplicated(name, null, row)) {
|
||||||
|
return Result.error("文件导入失败:第 " + rowNo + " 条厂家名称【" + name + "】不能重复(同租户未删除数据中已存在)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
mesXslManufacturerService.saveBatch(list);
|
||||||
|
log.info("厂家信息Excel导入完成,耗时{}ms,行数={}", System.currentTimeMillis() - start, list.size());
|
||||||
|
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
log.error(msg, e);
|
||||||
|
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
||||||
|
return Result.error("文件导入失败: 存在重复数据(厂家名称不能重复)");
|
||||||
|
}
|
||||||
|
return Result.error("文件导入失败:" + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息导入:名称唯一、文件内去重、类别与有效状态校验-----------
|
||||||
|
return Result.error("文件导入失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验-----------
|
||||||
|
private String validateForSave(MesXslManufacturer model, String excludeId) {
|
||||||
|
if (oConvertUtils.isEmpty(model.getManufacturerCategory()) || model.getManufacturerCategory().trim().isEmpty()) {
|
||||||
|
return "厂家类别不能为空";
|
||||||
|
}
|
||||||
|
String cat = model.getManufacturerCategory().trim();
|
||||||
|
if (!MANUFACTURER_CATEGORIES.contains(cat)) {
|
||||||
|
return "厂家类别无效";
|
||||||
|
}
|
||||||
|
model.setManufacturerCategory(cat);
|
||||||
|
if (oConvertUtils.isEmpty(model.getManufacturerName()) || model.getManufacturerName().trim().isEmpty()) {
|
||||||
|
return "厂家名称不能为空";
|
||||||
|
}
|
||||||
|
String name = model.getManufacturerName().trim();
|
||||||
|
model.setManufacturerName(name);
|
||||||
|
if (mesXslManufacturerService.isManufacturerNameDuplicated(name, excludeId, model)) {
|
||||||
|
return "厂家名称不能重复";
|
||||||
|
}
|
||||||
|
String vs = model.getValidStatus();
|
||||||
|
if (oConvertUtils.isEmpty(vs)) {
|
||||||
|
model.setValidStatus("0");
|
||||||
|
} else {
|
||||||
|
vs = vs.trim();
|
||||||
|
if (!VALID_STATUS.contains(vs)) {
|
||||||
|
return "是否有效取值无效";
|
||||||
|
}
|
||||||
|
model.setValidStatus(vs);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验-----------
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package org.jeecg.modules.xslmes.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 厂家信息(表 mes_xsl_manufacturer)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mes_xsl_manufacturer")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description = "MES厂家信息")
|
||||||
|
public class MesXslManufacturer implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Excel(name = "厂家类别", width = 16, dicCode = "xslmes_manufacturer_category")
|
||||||
|
@Dict(dicCode = "xslmes_manufacturer_category")
|
||||||
|
@Schema(description = "厂家类别(字典 xslmes_manufacturer_category)")
|
||||||
|
private String manufacturerCategory;
|
||||||
|
|
||||||
|
@Excel(name = "厂家名称", width = 28)
|
||||||
|
@Schema(description = "厂家名称(同租户未删除数据中唯一)")
|
||||||
|
private String manufacturerName;
|
||||||
|
|
||||||
|
@Excel(name = "是否有效", width = 12, dicCode = "xslmes_manufacturer_valid")
|
||||||
|
@Dict(dicCode = "xslmes_manufacturer_valid")
|
||||||
|
@Schema(description = "是否有效(字典 xslmes_manufacturer_valid:0有效1无效)")
|
||||||
|
private String validStatus;
|
||||||
|
|
||||||
|
private Integer tenantId;
|
||||||
|
private String sysOrgCode;
|
||||||
|
private String createBy;
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
private String updateBy;
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
private Integer delFlag;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 厂家信息
|
||||||
|
*/
|
||||||
|
public interface MesXslManufacturerMapper extends BaseMapper<MesXslManufacturer> {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
||||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})等。
|
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})等。
|
||||||
*/
|
*/
|
||||||
package org.jeecg.modules.xslmes;
|
package org.jeecg.modules.xslmes;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.jeecg.modules.xslmes.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||||
|
|
||||||
|
public interface IMesXslManufacturerService extends IService<MesXslManufacturer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 厂家名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与拦截器注入逻辑一致。
|
||||||
|
*
|
||||||
|
* @param manufacturerName 厂家名称(已 trim 后传入)
|
||||||
|
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||||
|
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||||
|
*/
|
||||||
|
boolean isManufacturerNameDuplicated(String manufacturerName, String excludeId, MesXslManufacturer context);
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package org.jeecg.modules.xslmes.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.jeecg.common.config.TenantContext;
|
||||||
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import org.jeecg.common.util.TokenUtils;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||||
|
import org.jeecg.modules.xslmes.mapper.MesXslManufacturerMapper;
|
||||||
|
import org.jeecg.modules.xslmes.service.IMesXslManufacturerService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MesXslManufacturerServiceImpl extends ServiceImpl<MesXslManufacturerMapper, MesXslManufacturer>
|
||||||
|
implements IMesXslManufacturerService {
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||||
|
@Override
|
||||||
|
public boolean isManufacturerNameDuplicated(String manufacturerName, String excludeId, MesXslManufacturer context) {
|
||||||
|
if (oConvertUtils.isEmpty(manufacturerName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Integer tenantId = resolveTenantId(context);
|
||||||
|
LambdaQueryWrapper<MesXslManufacturer> w = new LambdaQueryWrapper<>();
|
||||||
|
w.eq(MesXslManufacturer::getManufacturerName, manufacturerName.trim());
|
||||||
|
w.and(
|
||||||
|
q ->
|
||||||
|
q.eq(MesXslManufacturer::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||||
|
.or()
|
||||||
|
.isNull(MesXslManufacturer::getDelFlag));
|
||||||
|
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||||
|
w.ne(MesXslManufacturer::getId, excludeId);
|
||||||
|
}
|
||||||
|
if (tenantId != null) {
|
||||||
|
w.eq(MesXslManufacturer::getTenantId, tenantId);
|
||||||
|
}
|
||||||
|
return this.count(w) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer resolveTenantId(MesXslManufacturer context) {
|
||||||
|
if (context != null && context.getTenantId() != null) {
|
||||||
|
return context.getTenantId();
|
||||||
|
}
|
||||||
|
String ts = TenantContext.getTenant();
|
||||||
|
if (oConvertUtils.isEmpty(ts)) {
|
||||||
|
try {
|
||||||
|
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(ts)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(ts.trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||||
|
}
|
||||||
@@ -181,3 +181,17 @@ jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePartList.vue
|
|||||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePart.data.ts
|
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePart.data.ts
|
||||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePart.api.ts
|
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/MesXslSparePart.api.ts
|
||||||
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/components/MesXslSparePartModal.vue
|
jeecgboot-vue3/src/views/xslmes/mesXslSparePart/components/MesXslSparePartModal.vue
|
||||||
|
-- author:jiangxh---date:20260515--for: 【MES】厂家信息(厂家类别字典、名称同租户唯一、是否有效) ---
|
||||||
|
jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql
|
||||||
|
jeecg-boot/db/mes-xsl-manufacturer.sql
|
||||||
|
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_63__mes_xsl_manufacturer.sql
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslManufacturer.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslManufacturerMapper.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslManufacturerService.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslManufacturerServiceImpl.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslManufacturerController.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/MesXslManufacturerList.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/MesXslManufacturer.data.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/MesXslManufacturer.api.ts
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslManufacturer/components/MesXslManufacturerModal.vue
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
-- MES 厂家信息:字典 + 建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-manufacturer-menu-permission.sql 一致)
|
||||||
|
-- 权限前缀:mes:mes_xsl_manufacturer:*;父菜单 MES基础资料 / MES资料
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), 'MES厂家类别', 'xslmes_manufacturer_category', '模具厂家、胶囊厂家、设备厂家', 0, 'admin', NOW(), 0, 0
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_category' AND `del_flag` = 0);
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '模具厂家', 'mold', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'mold');
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '胶囊厂家', 'capsule', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'capsule');
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '设备厂家', 'equipment', 3, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_category' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'equipment');
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), 'MES厂家是否有效', 'xslmes_manufacturer_valid', '0有效1无效', 0, 'admin', NOW(), 0, 0
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_manufacturer_valid' AND `del_flag` = 0);
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '有效', '0', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_valid' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '0');
|
||||||
|
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), d.id, '无效', '1', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||||
|
WHERE d.`dict_code` = 'xslmes_manufacturer_valid' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `mes_xsl_manufacturer` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`manufacturer_category` varchar(32) NOT NULL COMMENT '厂家类别(字典xslmes_manufacturer_category:mold模具 capsule胶囊 equipment设备)',
|
||||||
|
`manufacturer_name` varchar(128) NOT NULL COMMENT '厂家名称(同租户未删除数据中唯一)',
|
||||||
|
`valid_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否有效(字典xslmes_manufacturer_valid:0有效1无效)',
|
||||||
|
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||||
|
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||||
|
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_mxm_tenant_name` (`tenant_id`, `manufacturer_name`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES厂家信息';
|
||||||
|
|
||||||
|
SET @mes_tenant_id = 1002;
|
||||||
|
|
||||||
|
SET @mes_base_pid = (
|
||||||
|
SELECT MIN(`id`) FROM `sys_permission`
|
||||||
|
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
|
||||||
|
);
|
||||||
|
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
|
||||||
|
VALUES ('1860000000000000112', @mes_base_pid, '厂家信息', '/xslmes/mesXslManufacturer', 'xslmes/mesXslManufacturer/MesXslManufacturerList', NULL, 1, NULL, '1', 17, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
|
||||||
|
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
|
||||||
|
`is_route` = VALUES(`is_route`), `is_leaf` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
|
||||||
|
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||||
|
('1860000000000000113', '1860000000000000112', '新增', 2, 'mes:mes_xsl_manufacturer:add', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000114', '1860000000000000112', '编辑', 2, 'mes:mes_xsl_manufacturer:edit', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000115', '1860000000000000112', '删除', 2, 'mes:mes_xsl_manufacturer:delete', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000116', '1860000000000000112', '批量删除', 2, 'mes:mes_xsl_manufacturer:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000117', '1860000000000000112', '导出', 2, 'mes:mes_xsl_manufacturer:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||||
|
('1860000000000000118', '1860000000000000112', '导入', 2, 'mes:mes_xsl_manufacturer:importExcel', '1', '1', 0, 'admin', NOW())
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
|
||||||
|
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||||
|
|
||||||
|
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
|
||||||
|
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
|
||||||
|
FROM `sys_role` r
|
||||||
|
CROSS JOIN `sys_permission` p
|
||||||
|
WHERE r.`tenant_id` = @mes_tenant_id
|
||||||
|
AND r.`role_code` = 'admin'
|
||||||
|
AND p.`id` IN (
|
||||||
|
'1860000000000000112',
|
||||||
|
'1860000000000000113', '1860000000000000114', '1860000000000000115', '1860000000000000116',
|
||||||
|
'1860000000000000117', '1860000000000000118'
|
||||||
|
)
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_role_permission` rp
|
||||||
|
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||||
|
);
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/xslmes/mesXslManufacturer/list',
|
||||||
|
checkManufacturerName = '/xslmes/mesXslManufacturer/checkManufacturerName',
|
||||||
|
save = '/xslmes/mesXslManufacturer/add',
|
||||||
|
edit = '/xslmes/mesXslManufacturer/edit',
|
||||||
|
deleteOne = '/xslmes/mesXslManufacturer/delete',
|
||||||
|
deleteBatch = '/xslmes/mesXslManufacturer/deleteBatch',
|
||||||
|
importExcel = '/xslmes/mesXslManufacturer/importExcel',
|
||||||
|
exportXls = '/xslmes/mesXslManufacturer/exportXls',
|
||||||
|
queryById = '/xslmes/mesXslManufacturer/queryById',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
|
||||||
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
|
|
||||||
|
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
|
||||||
|
|
||||||
|
export const checkManufacturerName = (params: { manufacturerName: string; dataId?: string }) =>
|
||||||
|
defHttp.get(
|
||||||
|
{ url: Api.checkManufacturerName, params },
|
||||||
|
{
|
||||||
|
successMessageMode: 'none',
|
||||||
|
errorMessageMode: 'none',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
const url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({ url, params });
|
||||||
|
};
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||||
|
import { checkManufacturerName } from './MesXslManufacturer.api';
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{ title: '厂家类别', align: 'center', dataIndex: 'manufacturerCategory_dictText', width: 120 },
|
||||||
|
{ title: '厂家名称', align: 'center', dataIndex: 'manufacturerName', width: 200 },
|
||||||
|
{ title: '是否有效', align: 'center', dataIndex: 'validStatus_dictText', width: 100 },
|
||||||
|
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||||
|
{
|
||||||
|
title: '创建时间',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'createTime',
|
||||||
|
width: 165,
|
||||||
|
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||||
|
},
|
||||||
|
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '厂家类别',
|
||||||
|
field: 'manufacturerCategory',
|
||||||
|
component: 'JDictSelectTag',
|
||||||
|
componentProps: { dictCode: 'xslmes_manufacturer_category' },
|
||||||
|
colProps: { span: 8 },
|
||||||
|
},
|
||||||
|
{ label: '厂家名称', field: 'manufacturerName', component: 'Input', colProps: { span: 8 } },
|
||||||
|
{
|
||||||
|
label: '是否有效',
|
||||||
|
field: 'validStatus',
|
||||||
|
component: 'JDictSelectTag',
|
||||||
|
componentProps: { dictCode: 'xslmes_manufacturer_valid' },
|
||||||
|
colProps: { span: 8 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{ label: '', field: 'id', component: 'Input', show: false },
|
||||||
|
{
|
||||||
|
label: '厂家类别',
|
||||||
|
field: 'manufacturerCategory',
|
||||||
|
required: true,
|
||||||
|
component: 'JDictSelectTag',
|
||||||
|
componentProps: { dictCode: 'xslmes_manufacturer_category', placeholder: '请选择' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '厂家名称',
|
||||||
|
field: 'manufacturerName',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
|
||||||
|
dynamicRules: ({ model }) => [
|
||||||
|
{ required: true, message: '请输入厂家名称' },
|
||||||
|
{
|
||||||
|
validator: async (_rule, value) => {
|
||||||
|
const v = value == null ? '' : String(value).trim();
|
||||||
|
if (!v) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await checkManufacturerName({ manufacturerName: v, dataId: model?.id });
|
||||||
|
return Promise.resolve();
|
||||||
|
} catch (e: any) {
|
||||||
|
const msg = e?.response?.data?.message || e?.message || '厂家名称不能重复';
|
||||||
|
return Promise.reject(msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是否有效',
|
||||||
|
field: 'validStatus',
|
||||||
|
required: true,
|
||||||
|
defaultValue: '0',
|
||||||
|
component: 'JDictSelectTag',
|
||||||
|
componentProps: { dictCode: 'xslmes_manufacturer_valid', placeholder: '请选择' },
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<template #tableTitle>
|
||||||
|
<a-button type="primary" v-auth="'mes:mes_xsl_manufacturer:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||||
|
新增
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
type="primary"
|
||||||
|
v-auth="'mes:mes_xsl_manufacturer:exportXls'"
|
||||||
|
preIcon="ant-design:export-outlined"
|
||||||
|
@click="onExportXls"
|
||||||
|
>
|
||||||
|
导出
|
||||||
|
</a-button>
|
||||||
|
<j-upload-button
|
||||||
|
type="primary"
|
||||||
|
v-auth="'mes:mes_xsl_manufacturer:importExcel'"
|
||||||
|
preIcon="ant-design:import-outlined"
|
||||||
|
@click="onImportXls"
|
||||||
|
>
|
||||||
|
导入
|
||||||
|
</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button v-auth="'mes:mes_xsl_manufacturer:deleteBatch'">
|
||||||
|
批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
</template>
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_manufacturer:edit' },
|
||||||
|
]"
|
||||||
|
:dropDownActions="getDropDownAction(record)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
<MesXslManufacturerModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="xslmes-mesXslManufacturer" setup>
|
||||||
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import Icon from '/@/components/Icon';
|
||||||
|
import MesXslManufacturerModal from './components/MesXslManufacturerModal.vue';
|
||||||
|
import { columns, searchFormSchema } from './MesXslManufacturer.data';
|
||||||
|
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslManufacturer.api';
|
||||||
|
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
|
||||||
|
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: '厂家信息',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: true,
|
||||||
|
formConfig: {
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
labelWidth: 100,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 200,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: '厂家信息',
|
||||||
|
url: getExportUrl,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, { isUpdate: false, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleDelete(record) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSuccess() {
|
||||||
|
selectedRowKeys.value = [];
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDropDownAction(record) {
|
||||||
|
return [
|
||||||
|
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||||
|
auth: 'mes:mes_xsl_manufacturer:delete',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<template>
|
||||||
|
<BasicModal @register="registerModal" :title="title" width="640" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema } from '../MesXslManufacturer.data';
|
||||||
|
import { saveOrUpdate } from '../MesXslManufacturer.api';
|
||||||
|
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
const isDetail = ref(false);
|
||||||
|
|
||||||
|
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||||
|
labelWidth: 100,
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
await resetFields();
|
||||||
|
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
isDetail.value = !data?.showFooter;
|
||||||
|
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
|
||||||
|
else await setFieldsValue({ validStatus: '0' });
|
||||||
|
setProps({ disabled: !data?.showFooter });
|
||||||
|
});
|
||||||
|
|
||||||
|
const title = computed(() =>
|
||||||
|
!unref(isUpdate) ? '新增厂家信息' : unref(isDetail) ? '厂家信息详情' : '编辑厂家信息',
|
||||||
|
);
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
try {
|
||||||
|
const values = await validate();
|
||||||
|
setModalProps({ confirmLoading: true });
|
||||||
|
await saveOrUpdate(values, isUpdate.value);
|
||||||
|
closeModal();
|
||||||
|
emit('success');
|
||||||
|
} finally {
|
||||||
|
setModalProps({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user