feat(xslmes): 停机分类与设备/工序基础资料菜单及权限完善
新增停机大类、停机类型 CRUD(含 Flyway 与独立 db 脚本);调整工序/设备分类/设备类型菜单归属与权限;同步厂家信息菜单脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,324 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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 java.util.regex.Pattern;
|
||||
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.constant.CommonConstant;
|
||||
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.MesXslDowntimeMainType;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDowntimeMainTypeService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
|
||||
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/mesXslDowntimeMainType")
|
||||
@Slf4j
|
||||
public class MesXslDowntimeMainTypeController extends JeecgController<MesXslDowntimeMainType, IMesXslDowntimeMainTypeService> {
|
||||
|
||||
private static final Set<String> STATUS_VALUES = Set.of("0", "1");
|
||||
private static final Pattern COLOR_HEX = Pattern.compile("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$");
|
||||
|
||||
@Autowired
|
||||
private IMesXslDowntimeMainTypeService mesXslDowntimeMainTypeService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Operation(summary = "MES停机主类型-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslDowntimeMainType>> queryPageList(
|
||||
MesXslDowntimeMainType model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslDowntimeMainType> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机主类型列表默认按显示顺序升序-----------
|
||||
queryWrapper.orderByAsc("display_order").orderByDesc("create_time");
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机主类型列表默认按显示顺序升序-----------
|
||||
Page<MesXslDowntimeMainType> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslDowntimeMainType> pageList = mesXslDowntimeMainTypeService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机主类型-添加")
|
||||
@Operation(summary = "MES停机主类型-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_main_type:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslDowntimeMainType model) {
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机主类型保存前校验-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机主类型保存前校验-----------
|
||||
mesXslDowntimeMainTypeService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机主类型-编辑")
|
||||
@Operation(summary = "MES停机主类型-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_main_type:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslDowntimeMainType model) {
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机主类型保存前校验-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机主类型保存前校验-----------
|
||||
mesXslDowntimeMainTypeService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机主类型-删除")
|
||||
@Operation(summary = "MES停机主类型-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_main_type:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslDowntimeMainTypeService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机主类型-批量删除")
|
||||
@Operation(summary = "MES停机主类型-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_main_type:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslDowntimeMainTypeService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES停机主类型-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslDowntimeMainType> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslDowntimeMainType entity = mesXslDowntimeMainTypeService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验停机类型是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkDowntimeType")
|
||||
public Result<String> checkDowntimeType(
|
||||
@RequestParam(name = "downtimeType", required = true) String downtimeType,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(downtimeType) || downtimeType.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslDowntimeMainType ctx = new MesXslDowntimeMainType();
|
||||
if (mesXslDowntimeMainTypeService.isDowntimeTypeDuplicated(downtimeType.trim(), dataId, ctx)) {
|
||||
return Result.error("停机类型不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_main_type:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslDowntimeMainType model) {
|
||||
return super.exportXls(request, model, MesXslDowntimeMainType.class, "MES停机主类型");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_main_type:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260518 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<MesXslDowntimeMainType> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslDowntimeMainType.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> typesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslDowntimeMainType row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String dt = row.getDowntimeType();
|
||||
if (dt != null) {
|
||||
dt = dt.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(dt)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条停机类型不能为空");
|
||||
}
|
||||
row.setDowntimeType(dt);
|
||||
if (!typesInFile.add(dt)) {
|
||||
return Result.error("文件导入失败:停机类型【" + dt + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslDowntimeMainTypeService.isDowntimeTypeDuplicated(dt, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条停机类型【" + dt + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
String opCode = row.getImportOperationCode();
|
||||
if (opCode != null) {
|
||||
opCode = opCode.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(opCode)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码不能为空");
|
||||
}
|
||||
MesXslProcessOperation op = findProcessByOperationCode(opCode, row);
|
||||
if (op == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码【" + opCode + "】不存在");
|
||||
}
|
||||
row.setProcessOperationId(op.getId());
|
||||
row.setProcessOperationName(op.getOperationName());
|
||||
|
||||
if (row.getDisplayOrder() == null) {
|
||||
row.setDisplayOrder(0);
|
||||
}
|
||||
String colorErr = normalizeColor(row);
|
||||
if (colorErr != null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条" + colorErr);
|
||||
}
|
||||
String st = row.getStatus();
|
||||
if (oConvertUtils.isEmpty(st)) {
|
||||
row.setStatus("0");
|
||||
} else {
|
||||
st = st.trim();
|
||||
if (!STATUS_VALUES.contains(st)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否启用无效(须为 0 启用或 1 停用)");
|
||||
}
|
||||
row.setStatus(st);
|
||||
}
|
||||
row.setImportOperationCode(null);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslDowntimeMainTypeService.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:20260518 for:【MES】停机主类型导入:类型唯一、工序编码解析、颜色与启用状态校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机主类型保存前校验与工序名称回填-----------
|
||||
private String validateForSave(MesXslDowntimeMainType model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getDowntimeType()) || model.getDowntimeType().trim().isEmpty()) {
|
||||
return "停机类型不能为空";
|
||||
}
|
||||
String dt = model.getDowntimeType().trim();
|
||||
model.setDowntimeType(dt);
|
||||
if (mesXslDowntimeMainTypeService.isDowntimeTypeDuplicated(dt, excludeId, model)) {
|
||||
return "停机类型不能重复";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
|
||||
if (op == null) {
|
||||
return "所属工序不存在";
|
||||
}
|
||||
model.setProcessOperationName(op.getOperationName());
|
||||
|
||||
if (model.getDisplayOrder() == null) {
|
||||
model.setDisplayOrder(0);
|
||||
}
|
||||
|
||||
String colorErr = normalizeColor(model);
|
||||
if (colorErr != null) {
|
||||
return colorErr;
|
||||
}
|
||||
|
||||
String st = model.getStatus();
|
||||
if (oConvertUtils.isEmpty(st)) {
|
||||
model.setStatus("0");
|
||||
} else {
|
||||
st = st.trim();
|
||||
if (!STATUS_VALUES.contains(st)) {
|
||||
return "是否启用取值无效";
|
||||
}
|
||||
model.setStatus(st);
|
||||
}
|
||||
model.setImportOperationCode(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String normalizeColor(MesXslDowntimeMainType model) {
|
||||
String color = model.getDistinguishColor();
|
||||
if (oConvertUtils.isEmpty(color)) {
|
||||
model.setDistinguishColor(null);
|
||||
return null;
|
||||
}
|
||||
color = color.trim();
|
||||
if (!color.startsWith("#")) {
|
||||
color = "#" + color;
|
||||
}
|
||||
if (!COLOR_HEX.matcher(color).matches()) {
|
||||
return "区分颜色格式无效(须为十六进制色值,如 #1890ff)";
|
||||
}
|
||||
model.setDistinguishColor(color.toLowerCase());
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslDowntimeMainType context) {
|
||||
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslProcessOperation::getDelFlag));
|
||||
Integer tenantId = context != null ? context.getTenantId() : null;
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslProcessOperation::getTenantId, tenantId);
|
||||
}
|
||||
List<MesXslProcessOperation> found = mesXslProcessOperationService.list(w);
|
||||
if (found == null || found.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return found.get(0);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机主类型保存前校验与工序名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,433 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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 java.util.regex.Pattern;
|
||||
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.constant.CommonConstant;
|
||||
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.MesXslDowntimeMainType;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDowntimeMainTypeService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDowntimeTypeService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
|
||||
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/mesXslDowntimeType")
|
||||
@Slf4j
|
||||
public class MesXslDowntimeTypeController extends JeecgController<MesXslDowntimeType, IMesXslDowntimeTypeService> {
|
||||
|
||||
private static final Set<String> STATUS_VALUES = Set.of("0", "1");
|
||||
private static final Set<String> YN_VALUES = Set.of("0", "1");
|
||||
private static final Pattern COLOR_HEX = Pattern.compile("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$");
|
||||
|
||||
@Autowired
|
||||
private IMesXslDowntimeTypeService mesXslDowntimeTypeService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslDowntimeMainTypeService mesXslDowntimeMainTypeService;
|
||||
|
||||
@Operation(summary = "MES停机类型-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslDowntimeType>> queryPageList(
|
||||
MesXslDowntimeType model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslDowntimeType> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机类型列表默认按显示顺序升序-----------
|
||||
queryWrapper.orderByAsc("display_order").orderByDesc("create_time");
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机类型列表默认按显示顺序升序-----------
|
||||
Page<MesXslDowntimeType> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslDowntimeType> pageList = mesXslDowntimeTypeService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机类型-添加")
|
||||
@Operation(summary = "MES停机类型-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_type:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslDowntimeType model) {
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机类型保存前校验-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机类型保存前校验-----------
|
||||
mesXslDowntimeTypeService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机类型-编辑")
|
||||
@Operation(summary = "MES停机类型-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_type:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslDowntimeType model) {
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机类型保存前校验-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机类型保存前校验-----------
|
||||
mesXslDowntimeTypeService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机类型-删除")
|
||||
@Operation(summary = "MES停机类型-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_type:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslDowntimeTypeService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES停机类型-批量删除")
|
||||
@Operation(summary = "MES停机类型-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_type:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslDowntimeTypeService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES停机类型-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslDowntimeType> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslDowntimeType entity = mesXslDowntimeTypeService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验停机类型是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkDowntimeType")
|
||||
public Result<String> checkDowntimeType(
|
||||
@RequestParam(name = "downtimeType", required = true) String downtimeType,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(downtimeType) || downtimeType.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslDowntimeType ctx = new MesXslDowntimeType();
|
||||
if (mesXslDowntimeTypeService.isDowntimeTypeDuplicated(downtimeType.trim(), dataId, ctx)) {
|
||||
return Result.error("停机类型不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_type:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslDowntimeType model) {
|
||||
return super.exportXls(request, model, MesXslDowntimeType.class, "MES停机类型");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_downtime_type:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260518 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<MesXslDowntimeType> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslDowntimeType.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> typesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslDowntimeType row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String err = validateImportRow(row, rowNo, typesInFile);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslDowntimeTypeService.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:20260518 for:【MES】停机类型导入:必填校验、类型唯一、工序与主类型解析-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机类型保存前校验、关联工序与主类型回填-----------
|
||||
private String validateForSave(MesXslDowntimeType model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
|
||||
if (op == null) {
|
||||
return "所属工序不存在";
|
||||
}
|
||||
model.setProcessOperationName(op.getOperationName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getDowntimeMainTypeId())) {
|
||||
return "请选择所属主类型";
|
||||
}
|
||||
String mainErr = fillAndValidateMainType(model);
|
||||
if (mainErr != null) {
|
||||
return mainErr;
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getDowntimeType()) || model.getDowntimeType().trim().isEmpty()) {
|
||||
return "停机类型不能为空";
|
||||
}
|
||||
String dt = model.getDowntimeType().trim();
|
||||
model.setDowntimeType(dt);
|
||||
if (mesXslDowntimeTypeService.isDowntimeTypeDuplicated(dt, excludeId, model)) {
|
||||
return "停机类型不能重复";
|
||||
}
|
||||
|
||||
if (model.getDisplayOrder() == null) {
|
||||
return "显示顺序不能为空";
|
||||
}
|
||||
|
||||
String colorErr = normalizeColor(model);
|
||||
if (colorErr != null) {
|
||||
return colorErr;
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】责任区分、故障等级改为手填文本,仅 trim-----------
|
||||
model.setResponsibilityDistinct(trimToNull(model.getResponsibilityDistinct()));
|
||||
model.setFaultLevel(trimToNull(model.getFaultLevel()));
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】责任区分、故障等级改为手填文本,仅 trim-----------
|
||||
|
||||
String dm = model.getDowntimeMaintenance();
|
||||
if (oConvertUtils.isEmpty(dm)) {
|
||||
model.setDowntimeMaintenance("0");
|
||||
} else {
|
||||
dm = dm.trim();
|
||||
if (!YN_VALUES.contains(dm)) {
|
||||
return "是否停机维修取值无效";
|
||||
}
|
||||
model.setDowntimeMaintenance(dm);
|
||||
}
|
||||
|
||||
String st = model.getStatus();
|
||||
if (oConvertUtils.isEmpty(st)) {
|
||||
model.setStatus("0");
|
||||
} else {
|
||||
st = st.trim();
|
||||
if (!STATUS_VALUES.contains(st)) {
|
||||
return "是否启用取值无效";
|
||||
}
|
||||
model.setStatus(st);
|
||||
}
|
||||
model.setImportOperationCode(null);
|
||||
model.setImportMainTypeName(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private String fillAndValidateMainType(MesXslDowntimeType model) {
|
||||
MesXslDowntimeMainType main = mesXslDowntimeMainTypeService.getById(model.getDowntimeMainTypeId());
|
||||
if (main == null) {
|
||||
return "所属主类型不存在";
|
||||
}
|
||||
if (!model.getProcessOperationId().equals(main.getProcessOperationId())) {
|
||||
return "所属主类型与所选工序不匹配";
|
||||
}
|
||||
model.setDowntimeMainTypeName(main.getDowntimeType());
|
||||
return null;
|
||||
}
|
||||
|
||||
private String validateImportRow(MesXslDowntimeType row, int rowNo, Set<String> typesInFile) {
|
||||
String opCode = row.getImportOperationCode();
|
||||
if (opCode != null) {
|
||||
opCode = opCode.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(opCode)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条工序编码不能为空";
|
||||
}
|
||||
MesXslProcessOperation op = findProcessByOperationCode(opCode, row);
|
||||
if (op == null) {
|
||||
return "文件导入失败:第 " + rowNo + " 条工序编码【" + opCode + "】不存在";
|
||||
}
|
||||
row.setProcessOperationId(op.getId());
|
||||
row.setProcessOperationName(op.getOperationName());
|
||||
|
||||
String mainName = row.getImportMainTypeName();
|
||||
if (mainName != null) {
|
||||
mainName = mainName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(mainName)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条主类型名称不能为空";
|
||||
}
|
||||
MesXslDowntimeMainType main = findMainTypeByNameAndProcess(mainName, op.getId(), row);
|
||||
if (main == null) {
|
||||
return "文件导入失败:第 " + rowNo + " 条主类型【" + mainName + "】在所选工序下不存在";
|
||||
}
|
||||
row.setDowntimeMainTypeId(main.getId());
|
||||
row.setDowntimeMainTypeName(main.getDowntimeType());
|
||||
|
||||
String dt = row.getDowntimeType();
|
||||
if (dt != null) {
|
||||
dt = dt.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(dt)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条停机类型不能为空";
|
||||
}
|
||||
row.setDowntimeType(dt);
|
||||
if (!typesInFile.add(dt)) {
|
||||
return "文件导入失败:停机类型【" + dt + "】在导入文件中重复";
|
||||
}
|
||||
if (mesXslDowntimeTypeService.isDowntimeTypeDuplicated(dt, null, row)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条停机类型【" + dt + "】不能重复(同租户未删除数据中已存在)";
|
||||
}
|
||||
if (row.getDisplayOrder() == null) {
|
||||
return "文件导入失败:第 " + rowNo + " 条显示顺序不能为空";
|
||||
}
|
||||
|
||||
String colorErr = normalizeColor(row);
|
||||
if (colorErr != null) {
|
||||
return "文件导入失败:第 " + rowNo + " 条" + colorErr;
|
||||
}
|
||||
|
||||
row.setResponsibilityDistinct(trimToNull(row.getResponsibilityDistinct()));
|
||||
row.setFaultLevel(trimToNull(row.getFaultLevel()));
|
||||
|
||||
String dm = row.getDowntimeMaintenance();
|
||||
if (oConvertUtils.isEmpty(dm)) {
|
||||
row.setDowntimeMaintenance("0");
|
||||
} else {
|
||||
dm = dm.trim();
|
||||
if (!YN_VALUES.contains(dm)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条是否停机维修无效";
|
||||
}
|
||||
row.setDowntimeMaintenance(dm);
|
||||
}
|
||||
|
||||
String st = row.getStatus();
|
||||
if (oConvertUtils.isEmpty(st)) {
|
||||
row.setStatus("0");
|
||||
} else {
|
||||
st = st.trim();
|
||||
if (!STATUS_VALUES.contains(st)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条是否启用无效";
|
||||
}
|
||||
row.setStatus(st);
|
||||
}
|
||||
row.setImportOperationCode(null);
|
||||
row.setImportMainTypeName(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesXslDowntimeMainType findMainTypeByNameAndProcess(
|
||||
String mainTypeName, String processOperationId, MesXslDowntimeType context) {
|
||||
LambdaQueryWrapper<MesXslDowntimeMainType> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslDowntimeMainType::getDowntimeType, mainTypeName.trim());
|
||||
w.eq(MesXslDowntimeMainType::getProcessOperationId, processOperationId);
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslDowntimeMainType::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslDowntimeMainType::getDelFlag));
|
||||
Integer tenantId = context != null ? context.getTenantId() : null;
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslDowntimeMainType::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return mesXslDowntimeMainTypeService.getOne(w, false);
|
||||
}
|
||||
|
||||
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslDowntimeType context) {
|
||||
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslProcessOperation::getDelFlag));
|
||||
Integer tenantId = context != null ? context.getTenantId() : null;
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslProcessOperation::getTenantId, tenantId);
|
||||
}
|
||||
List<MesXslProcessOperation> found = mesXslProcessOperationService.list(w);
|
||||
if (found == null || found.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return found.get(0);
|
||||
}
|
||||
|
||||
private static String trimToNull(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
String v = value.trim();
|
||||
return v.isEmpty() ? null : v;
|
||||
}
|
||||
|
||||
private static String normalizeColor(MesXslDowntimeType model) {
|
||||
String color = model.getDistinguishColor();
|
||||
if (oConvertUtils.isEmpty(color)) {
|
||||
model.setDistinguishColor(null);
|
||||
return null;
|
||||
}
|
||||
color = color.trim();
|
||||
if (!color.startsWith("#")) {
|
||||
color = "#" + color;
|
||||
}
|
||||
if (!COLOR_HEX.matcher(color).matches()) {
|
||||
return "区分颜色格式无效(须为十六进制色值,如 #1890ff)";
|
||||
}
|
||||
model.setDistinguishColor(color.toLowerCase());
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】停机类型保存前校验、关联工序与主类型回填-----------
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
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_downtime_main_type)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_downtime_main_type")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES停机主类型")
|
||||
public class MesXslDowntimeMainType implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称冗余")
|
||||
private String processOperationName;
|
||||
|
||||
@Excel(name = "停机类型", width = 24)
|
||||
@Schema(description = "停机类型(同租户未删除数据中唯一)")
|
||||
private String downtimeType;
|
||||
|
||||
@Excel(name = "显示顺序", width = 12)
|
||||
@Schema(description = "显示顺序(升序)")
|
||||
private Integer displayOrder;
|
||||
|
||||
@Excel(name = "区分颜色", width = 16)
|
||||
@Schema(description = "区分颜色(十六进制色值)")
|
||||
private String distinguishColor;
|
||||
|
||||
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_downtime_main_type_status")
|
||||
@Dict(dicCode = "xslmes_downtime_main_type_status")
|
||||
@Schema(description = "是否启用(字典 xslmes_downtime_main_type_status:0启用1停用)")
|
||||
private String status;
|
||||
|
||||
/** Excel 导入用:工序编码,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "工序编码", width = 18)
|
||||
@Schema(description = "导入用工序编码")
|
||||
private String importOperationCode;
|
||||
|
||||
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,98 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
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_downtime_type)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_downtime_type")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES停机类型")
|
||||
public class MesXslDowntimeType implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称冗余")
|
||||
private String processOperationName;
|
||||
|
||||
@Schema(description = "所属停机主类型主键")
|
||||
private String downtimeMainTypeId;
|
||||
|
||||
@Excel(name = "所属主类型", width = 24)
|
||||
@Schema(description = "主类型名称冗余")
|
||||
private String downtimeMainTypeName;
|
||||
|
||||
@Excel(name = "停机类型", width = 24)
|
||||
@Schema(description = "停机类型(同租户未删除数据中唯一)")
|
||||
private String downtimeType;
|
||||
|
||||
@Excel(name = "显示顺序", width = 12)
|
||||
@Schema(description = "显示顺序(升序,必填)")
|
||||
private Integer displayOrder;
|
||||
|
||||
@Excel(name = "区分颜色", width = 16)
|
||||
@Schema(description = "区分颜色(十六进制色值)")
|
||||
private String distinguishColor;
|
||||
|
||||
@Excel(name = "责任区分", width = 20)
|
||||
@Schema(description = "责任区分(手填)")
|
||||
private String responsibilityDistinct;
|
||||
|
||||
@Excel(name = "故障等级", width = 16)
|
||||
@Schema(description = "故障等级(手填)")
|
||||
private String faultLevel;
|
||||
|
||||
@Excel(name = "是否停机维修", width = 14, dicCode = "yn")
|
||||
@Dict(dicCode = "yn")
|
||||
@Schema(description = "是否停机维修(字典 yn:1是0否)")
|
||||
private String downtimeMaintenance;
|
||||
|
||||
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_downtime_type_status")
|
||||
@Dict(dicCode = "xslmes_downtime_type_status")
|
||||
@Schema(description = "是否启用(字典 xslmes_downtime_type_status:0启用1停用)")
|
||||
private String status;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "工序编码", width = 18)
|
||||
@Schema(description = "导入用工序编码")
|
||||
private String importOperationCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "主类型名称", width = 24)
|
||||
@Schema(description = "导入用停机主类型名称")
|
||||
private String importMainTypeName;
|
||||
|
||||
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.MesXslDowntimeMainType;
|
||||
|
||||
/**
|
||||
* MES 停机主类型
|
||||
*/
|
||||
public interface MesXslDowntimeMainTypeMapper extends BaseMapper<MesXslDowntimeMainType> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
|
||||
|
||||
/**
|
||||
* MES 停机类型
|
||||
*/
|
||||
public interface MesXslDowntimeTypeMapper extends BaseMapper<MesXslDowntimeType> {}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 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.MesXslManufacturer})等。
|
||||
* 包含:客户管理({@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})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。
|
||||
*/
|
||||
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.MesXslDowntimeMainType;
|
||||
|
||||
public interface IMesXslDowntimeMainTypeService extends IService<MesXslDowntimeMainType> {
|
||||
|
||||
/**
|
||||
* 停机类型是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与拦截器注入逻辑一致。
|
||||
*
|
||||
* @param downtimeType 停机类型(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeMainType context);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslDowntimeType;
|
||||
|
||||
public interface IMesXslDowntimeTypeService extends IService<MesXslDowntimeType> {
|
||||
|
||||
/**
|
||||
* 停机类型名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与拦截器注入逻辑一致。
|
||||
*/
|
||||
boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeType 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.MesXslDowntimeMainType;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslDowntimeMainTypeMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDowntimeMainTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslDowntimeMainTypeServiceImpl extends ServiceImpl<MesXslDowntimeMainTypeMapper, MesXslDowntimeMainType>
|
||||
implements IMesXslDowntimeMainTypeService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机类型同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeMainType context) {
|
||||
if (oConvertUtils.isEmpty(downtimeType)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslDowntimeMainType> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslDowntimeMainType::getDowntimeType, downtimeType.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslDowntimeMainType::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslDowntimeMainType::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslDowntimeMainType::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslDowntimeMainType::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslDowntimeMainType 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:20260518 for:【MES】停机类型同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -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.MesXslDowntimeType;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslDowntimeTypeMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslDowntimeTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslDowntimeTypeServiceImpl extends ServiceImpl<MesXslDowntimeTypeMapper, MesXslDowntimeType>
|
||||
implements IMesXslDowntimeTypeService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】停机类型名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isDowntimeTypeDuplicated(String downtimeType, String excludeId, MesXslDowntimeType context) {
|
||||
if (oConvertUtils.isEmpty(downtimeType)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslDowntimeType> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslDowntimeType::getDowntimeType, downtimeType.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslDowntimeType::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslDowntimeType::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslDowntimeType::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslDowntimeType::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslDowntimeType 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:20260518 for:【MES】停机类型名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
Reference in New Issue
Block a user