胶料小料锁定原因新增
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
-- MES 胶料小料锁定原因:字典 + 建表 + 菜单(质量管理下)+ 按钮 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀:mes:mes_xsl_rubber_small_lock_reason:*
|
||||
-- 菜单 ID 段:1860000000000000208(按钮 209-214)
|
||||
-- 修改租户:改 SET @mes_tenant_id
|
||||
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_rubber_small_lock_type', '锁定/解锁', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_small_lock_type' 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, '锁定', 'lock', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'lock');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '解锁', 'unlock', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'unlock');
|
||||
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||
SELECT REPLACE(UUID(), '-', ''), 'MES胶料小料锁定条码类型', 'xslmes_rubber_small_lock_barcode_type', '小料/胶料', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_small_lock_barcode_type' 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, '小料', 'small', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_barcode_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'small');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '胶料', 'rubber', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_barcode_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'rubber');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_rubber_small_lock_reason` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`reason_code` varchar(16) NOT NULL COMMENT '编号(租户内从001递增自动生成,只读)',
|
||||
`lock_type` varchar(16) NOT NULL COMMENT '类型(字典xslmes_rubber_small_lock_type:lock锁定unlock解锁)',
|
||||
`barcode_type` varchar(16) NOT NULL COMMENT '条码类型(字典xslmes_rubber_small_lock_barcode_type:small小料rubber胶料)',
|
||||
`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_mrslr_tenant_code` (`tenant_id`, `reason_code`),
|
||||
KEY `idx_mrslr_tenant_lock` (`tenant_id`, `lock_type`, `barcode_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES胶料小料锁定原因';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_quality_pid = IFNULL(
|
||||
(SELECT `id` FROM `sys_permission` WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '质量管理' LIMIT 1),
|
||||
'1860000000000000162'
|
||||
);
|
||||
|
||||
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 ('1860000000000000208', @mes_quality_pid, '胶料小料锁定原因', '/xslmes/mesXslRubberSmallLockReason', 'xslmes/mesXslRubberSmallLockReason/MesXslRubberSmallLockReasonList', 'MesXslRubberSmallLockReasonList', 1, NULL, '1', 6, 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`), `sort_no` = VALUES(`sort_no`), `is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0, `keep_alive` = VALUES(`keep_alive`);
|
||||
|
||||
UPDATE `sys_permission` SET `icon` = 'ant-design:lock-outlined' WHERE `id` = '1860000000000000208' AND `del_flag` = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000209', '1860000000000000208', '新增', 2, 'mes:mes_xsl_rubber_small_lock_reason:add', '1', 1, '1', 0, 'admin', NOW()),
|
||||
('1860000000000000210', '1860000000000000208', '编辑', 2, 'mes:mes_xsl_rubber_small_lock_reason:edit', '1', 1, '1', 0, 'admin', NOW()),
|
||||
('1860000000000000211', '1860000000000000208', '删除', 2, 'mes:mes_xsl_rubber_small_lock_reason:delete', '1', 1, '1', 0, 'admin', NOW()),
|
||||
('1860000000000000212', '1860000000000000208', '批量删除', 2, 'mes:mes_xsl_rubber_small_lock_reason:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
|
||||
('1860000000000000213', '1860000000000000208', '导出', 2, 'mes:mes_xsl_rubber_small_lock_reason:exportXls', '1', 1, '1', 0, 'admin', NOW()),
|
||||
('1860000000000000214', '1860000000000000208', '导入', 2, 'mes:mes_xsl_rubber_small_lock_reason:importExcel', '1', 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`),
|
||||
`is_leaf` = 1, `status` = '1', `del_flag` = 0;
|
||||
|
||||
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 (
|
||||
'1860000000000000208',
|
||||
'1860000000000000209', '1860000000000000210', '1860000000000000211', '1860000000000000212',
|
||||
'1860000000000000213', '1860000000000000214'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -581,3 +581,16 @@ jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectRecord/MesXslEquipInspectRecor
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectRecord/MesXslEquipInspectRecordList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeRecord/MesXslDowntimeRecord.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslDowntimeRecord/MesXslDowntimeRecordList.vue
|
||||
|
||||
-- author:jiangxh---date:20250602--for: 【MES】胶料小料锁定原因(质量管理菜单、编号001自增、类型与条码类型字典) ---
|
||||
jeecg-boot/db/mes-xsl-rubber-small-lock-reason-menu-permission.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_118__mes_xsl_rubber_small_lock_reason.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslRubberSmallLockReason.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslRubberSmallLockReasonMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslRubberSmallLockReasonService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslRubberSmallLockReasonServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslRubberSmallLockReasonController.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockReason/MesXslRubberSmallLockReason.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockReason/MesXslRubberSmallLockReason.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockReason/MesXslRubberSmallLockReasonList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslRubberSmallLockReason/components/MesXslRubberSmallLockReasonModal.vue
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
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.exception.JeecgBootException;
|
||||
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.MesXslRubberSmallLockReason;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslRubberSmallLockReasonService;
|
||||
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/mesXslRubberSmallLockReason")
|
||||
@Slf4j
|
||||
public class MesXslRubberSmallLockReasonController
|
||||
extends JeecgController<MesXslRubberSmallLockReason, IMesXslRubberSmallLockReasonService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslRubberSmallLockReasonService mesXslRubberSmallLockReasonService;
|
||||
|
||||
@Operation(summary = "MES胶料小料锁定原因-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslRubberSmallLockReason>> queryPageList(
|
||||
MesXslRubberSmallLockReason model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslRubberSmallLockReason> queryWrapper =
|
||||
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslRubberSmallLockReason> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslRubberSmallLockReason> pageList = mesXslRubberSmallLockReasonService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES胶料小料锁定原因-添加")
|
||||
@Operation(summary = "MES胶料小料锁定原因-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_rubber_small_lock_reason:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslRubberSmallLockReason model) {
|
||||
//update-begin---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因新增校验与自动编号-----------
|
||||
if (oConvertUtils.isEmpty(model.getLockType())) {
|
||||
return Result.error("类型不能为空");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getBarcodeType())) {
|
||||
return Result.error("条码类型不能为空");
|
||||
}
|
||||
model.setReasonCode(null);
|
||||
try {
|
||||
mesXslRubberSmallLockReasonService.save(model);
|
||||
} catch (JeecgBootException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因新增校验与自动编号-----------
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES胶料小料锁定原因-编辑")
|
||||
@Operation(summary = "MES胶料小料锁定原因-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_rubber_small_lock_reason:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslRubberSmallLockReason model) {
|
||||
//update-begin---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因编辑仅改类型与条码类型、编号只读-----------
|
||||
if (oConvertUtils.isEmpty(model.getId())) {
|
||||
return Result.error("缺少主键");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getLockType())) {
|
||||
return Result.error("类型不能为空");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getBarcodeType())) {
|
||||
return Result.error("条码类型不能为空");
|
||||
}
|
||||
MesXslRubberSmallLockReason old = mesXslRubberSmallLockReasonService.getById(model.getId());
|
||||
if (old == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
old.setLockType(model.getLockType());
|
||||
old.setBarcodeType(model.getBarcodeType());
|
||||
try {
|
||||
mesXslRubberSmallLockReasonService.updateById(old);
|
||||
} catch (JeecgBootException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因编辑仅改类型与条码类型、编号只读-----------
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES胶料小料锁定原因-删除")
|
||||
@Operation(summary = "MES胶料小料锁定原因-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_rubber_small_lock_reason:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslRubberSmallLockReasonService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES胶料小料锁定原因-批量删除")
|
||||
@Operation(summary = "MES胶料小料锁定原因-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_rubber_small_lock_reason:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslRubberSmallLockReasonService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES胶料小料锁定原因-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslRubberSmallLockReason> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslRubberSmallLockReason entity = mesXslRubberSmallLockReasonService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "预览下一编号(001起)")
|
||||
@GetMapping(value = "/nextReasonCode")
|
||||
public Result<String> nextReasonCode() {
|
||||
MesXslRubberSmallLockReason ctx = new MesXslRubberSmallLockReason();
|
||||
return Result.OK(mesXslRubberSmallLockReasonService.generateNextReasonCode(ctx));
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_rubber_small_lock_reason:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslRubberSmallLockReason model) {
|
||||
return super.exportXls(request, model, MesXslRubberSmallLockReason.class, "MES胶料小料锁定原因");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_rubber_small_lock_reason:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20250602 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<MesXslRubberSmallLockReason> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslRubberSmallLockReason.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslRubberSmallLockReason row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(row.getLockType())) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类型不能为空");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(row.getBarcodeType())) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条条码类型不能为空");
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(row.getReasonCode())) {
|
||||
row.setReasonCode(row.getReasonCode().trim());
|
||||
} else {
|
||||
row.setReasonCode(null);
|
||||
}
|
||||
}
|
||||
for (MesXslRubberSmallLockReason row : list) {
|
||||
try {
|
||||
mesXslRubberSmallLockReasonService.save(row);
|
||||
} catch (JeecgBootException e) {
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
log.info("胶料小料锁定原因Excel导入完成,行数={}", list.size());
|
||||
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg, e);
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因导入:类型与条码类型必填,编号可空则自动生成-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
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 胶料小料锁定原因
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_rubber_small_lock_reason")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES胶料小料锁定原因")
|
||||
public class MesXslRubberSmallLockReason implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "编号", width = 12)
|
||||
@Schema(description = "编号(租户内从001递增自动生成,只读)")
|
||||
private String reasonCode;
|
||||
|
||||
@Excel(name = "类型", width = 12, dicCode = "xslmes_rubber_small_lock_type")
|
||||
@Dict(dicCode = "xslmes_rubber_small_lock_type")
|
||||
@Schema(description = "类型(字典:lock锁定 unlock解锁)")
|
||||
private String lockType;
|
||||
|
||||
@Excel(name = "条码类型", width = 12, dicCode = "xslmes_rubber_small_lock_barcode_type")
|
||||
@Dict(dicCode = "xslmes_rubber_small_lock_barcode_type")
|
||||
@Schema(description = "条码类型(字典:small小料 rubber胶料)")
|
||||
private String barcodeType;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
|
||||
@Excel(name = "创建人", width = 12)
|
||||
private String createBy;
|
||||
|
||||
@Excel(name = "创建日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@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;
|
||||
|
||||
@TableLogic
|
||||
@Schema(description = "删除状态(0正常 1已删除)")
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberSmallLockReason;
|
||||
|
||||
/**
|
||||
* MES 胶料小料锁定原因 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslRubberSmallLockReasonMapper extends BaseMapper<MesXslRubberSmallLockReason> {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因租户内最大三位数字编号-----------
|
||||
@Select(
|
||||
"SELECT IFNULL(MAX(CAST(reason_code AS UNSIGNED)), 0) FROM mes_xsl_rubber_small_lock_reason "
|
||||
+ "WHERE del_flag = 0 AND reason_code REGEXP '^[0-9]+$' "
|
||||
+ "AND (#{tenantId} IS NULL OR tenant_id = #{tenantId})")
|
||||
Integer selectMaxNumericReasonCode(@Param("tenantId") Integer tenantId);
|
||||
//update-end---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因租户内最大三位数字编号-----------
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberSmallLockReason;
|
||||
|
||||
public interface IMesXslRubberSmallLockReasonService extends IService<MesXslRubberSmallLockReason> {
|
||||
|
||||
/** 生成下一编号(001 起,三位数字,租户维度) */
|
||||
String generateNextReasonCode(MesXslRubberSmallLockReason context);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.common.MesXslTenantUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberSmallLockReason;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslRubberSmallLockReasonMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslRubberSmallLockReasonService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class MesXslRubberSmallLockReasonServiceImpl
|
||||
extends ServiceImpl<MesXslRubberSmallLockReasonMapper, MesXslRubberSmallLockReason>
|
||||
implements IMesXslRubberSmallLockReasonService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因编号001递增、类型与条码类型必填-----------
|
||||
@Override
|
||||
public String generateNextReasonCode(MesXslRubberSmallLockReason context) {
|
||||
Integer tenantId = MesXslTenantUtils.resolveTenantId(context != null ? context.getTenantId() : null);
|
||||
Integer max = baseMapper.selectMaxNumericReasonCode(tenantId);
|
||||
int next = (max == null ? 0 : max) + 1;
|
||||
if (next > 999) {
|
||||
throw new IllegalStateException("编号已超过999,请联系管理员");
|
||||
}
|
||||
return String.format("%03d", next);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean save(MesXslRubberSmallLockReason entity) {
|
||||
validateRequiredFields(entity);
|
||||
if (oConvertUtils.isEmpty(entity.getReasonCode())) {
|
||||
entity.setReasonCode(generateNextReasonCode(entity));
|
||||
}
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateById(MesXslRubberSmallLockReason entity) {
|
||||
if (oConvertUtils.isEmpty(entity.getId())) {
|
||||
throw new JeecgBootException("缺少主键");
|
||||
}
|
||||
validateRequiredFields(entity);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
private void validateRequiredFields(MesXslRubberSmallLockReason entity) {
|
||||
if (entity == null) {
|
||||
throw new JeecgBootException("数据不能为空");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(entity.getLockType())) {
|
||||
throw new JeecgBootException("类型不能为空");
|
||||
}
|
||||
if (oConvertUtils.isEmpty(entity.getBarcodeType())) {
|
||||
throw new JeecgBootException("条码类型不能为空");
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20250602 for:【MES】胶料小料锁定原因编号001递增、类型与条码类型必填-----------
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
-- MES 胶料小料锁定原因:字典 + 建表 + 菜单(质量管理下)+ 按钮 + 租户 admin 授权
|
||||
-- 权限前缀:mes:mes_xsl_rubber_small_lock_reason:*
|
||||
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_rubber_small_lock_type', '锁定/解锁', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_small_lock_type' 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, '锁定', 'lock', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'lock');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '解锁', 'unlock', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'unlock');
|
||||
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
|
||||
SELECT REPLACE(UUID(), '-', ''), 'MES胶料小料锁定条码类型', 'xslmes_rubber_small_lock_barcode_type', '小料/胶料', 0, 'admin', NOW(), 0, 0
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_small_lock_barcode_type' 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, '小料', 'small', 1, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_barcode_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'small');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
|
||||
SELECT REPLACE(UUID(), '-', ''), d.id, '胶料', 'rubber', 2, 1, 'admin', NOW() FROM `sys_dict` d
|
||||
WHERE d.`dict_code` = 'xslmes_rubber_small_lock_barcode_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'rubber');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_rubber_small_lock_reason` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`reason_code` varchar(16) NOT NULL COMMENT '编号(租户内从001递增自动生成,只读)',
|
||||
`lock_type` varchar(16) NOT NULL COMMENT '类型(字典xslmes_rubber_small_lock_type:lock锁定unlock解锁)',
|
||||
`barcode_type` varchar(16) NOT NULL COMMENT '条码类型(字典xslmes_rubber_small_lock_barcode_type:small小料rubber胶料)',
|
||||
`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_mrslr_tenant_code` (`tenant_id`, `reason_code`),
|
||||
KEY `idx_mrslr_tenant_lock` (`tenant_id`, `lock_type`, `barcode_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES胶料小料锁定原因';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_quality_pid = IFNULL(
|
||||
(SELECT `id` FROM `sys_permission` WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '质量管理' LIMIT 1),
|
||||
'1860000000000000162'
|
||||
);
|
||||
|
||||
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 ('1860000000000000208', @mes_quality_pid, '胶料小料锁定原因', '/xslmes/mesXslRubberSmallLockReason', 'xslmes/mesXslRubberSmallLockReason/MesXslRubberSmallLockReasonList', 'MesXslRubberSmallLockReasonList', 1, NULL, '1', 6, 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`), `sort_no` = VALUES(`sort_no`), `is_leaf` = 0, `keep_alive` = VALUES(`keep_alive`);
|
||||
|
||||
UPDATE `sys_permission` SET `icon` = 'ant-design:lock-outlined' WHERE `id` = '1860000000000000208' AND `del_flag` = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000209', '1860000000000000208', '新增', 2, 'mes:mes_xsl_rubber_small_lock_reason:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000210', '1860000000000000208', '编辑', 2, 'mes:mes_xsl_rubber_small_lock_reason:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000211', '1860000000000000208', '删除', 2, 'mes:mes_xsl_rubber_small_lock_reason:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000212', '1860000000000000208', '批量删除', 2, 'mes:mes_xsl_rubber_small_lock_reason:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000213', '1860000000000000208', '导出', 2, 'mes:mes_xsl_rubber_small_lock_reason:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000214', '1860000000000000208', '导入', 2, 'mes:mes_xsl_rubber_small_lock_reason:importExcel', '1', '1', 0, 'admin', NOW())
|
||||
ON DUPLICATE KEY UPDATE `perms` = VALUES(`perms`), `name` = VALUES(`name`);
|
||||
|
||||
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 (
|
||||
'1860000000000000208',
|
||||
'1860000000000000209', '1860000000000000210', '1860000000000000211', '1860000000000000212',
|
||||
'1860000000000000213', '1860000000000000214'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM sys_role_permission rp
|
||||
WHERE rp.role_id = r.id AND rp.permission_id = p.id
|
||||
);
|
||||
Reference in New Issue
Block a user