设备部位功能新增
This commit is contained in:
@@ -0,0 +1,284 @@
|
||||
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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
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/mesXslEquipmentPart")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentPartController extends JeecgController<MesXslEquipmentPart, IMesXslEquipmentPartService> {
|
||||
|
||||
private static final Set<String> ENABLE_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentPartService mesXslEquipmentPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Operation(summary = "MES设备部位-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentPart>> queryPageList(
|
||||
MesXslEquipmentPart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentPart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentPart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentPart> pageList = mesXslEquipmentPartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-添加")
|
||||
@Operation(summary = "MES设备部位-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentPart 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】设备部位:部位代码唯一、设备类别与启用状态校验、冗余类别名称-----------
|
||||
mesXslEquipmentPartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-编辑")
|
||||
@Operation(summary = "MES设备部位-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentPart 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】设备部位:部位代码唯一、设备类别与启用状态校验、冗余类别名称-----------
|
||||
mesXslEquipmentPartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-删除")
|
||||
@Operation(summary = "MES设备部位-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentPartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备部位-批量删除")
|
||||
@Operation(summary = "MES设备部位-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentPartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备部位-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentPart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentPart entity = mesXslEquipmentPartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验部位代码是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkPartCode")
|
||||
public Result<String> checkPartCode(
|
||||
@RequestParam(name = "partCode", required = true) String partCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(partCode) || partCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentPart ctx = new MesXslEquipmentPart();
|
||||
if (mesXslEquipmentPartService.isPartCodeDuplicated(partCode.trim(), dataId, ctx)) {
|
||||
return Result.error("部位代码不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentPart model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentPart.class, "MES设备部位");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_part: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<MesXslEquipmentPart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentPart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentPart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String pc = row.getPartCode();
|
||||
if (pc != null) {
|
||||
pc = pc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(pc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条部位代码不能为空");
|
||||
}
|
||||
row.setPartCode(pc);
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称不能为空");
|
||||
}
|
||||
MesXslEquipmentCategory cat =
|
||||
mesXslEquipmentCategoryService.findOneActiveByNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setEquipmentCategoryId(cat.getId());
|
||||
row.setEquipmentCategoryName(cat.getCategoryName());
|
||||
row.setImportCategoryName(null);
|
||||
if (!codesInFile.add(pc)) {
|
||||
return Result.error("文件导入失败:部位代码【" + pc + "】在导入文件中重复(部位代码不能重复)");
|
||||
}
|
||||
if (mesXslEquipmentPartService.isPartCodeDuplicated(pc, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条部位代码【" + pc + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
if (row.getDeptName() != null) {
|
||||
row.setDeptName(row.getDeptName().trim());
|
||||
}
|
||||
if (row.getPartDescription() != null) {
|
||||
row.setPartDescription(row.getPartDescription().trim());
|
||||
}
|
||||
|
||||
String en = row.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否启用须为字典项值 0 或 1(xslmes_unit_status)");
|
||||
}
|
||||
row.setEnableStatus(en);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentPartService.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(MesXslEquipmentPart model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) {
|
||||
return "请选择所属设备类别";
|
||||
}
|
||||
MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属设备类别不存在";
|
||||
}
|
||||
model.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getPartCode()) || model.getPartCode().trim().isEmpty()) {
|
||||
return "部位代码不能为空";
|
||||
}
|
||||
String pc = model.getPartCode().trim();
|
||||
model.setPartCode(pc);
|
||||
if (mesXslEquipmentPartService.isPartCodeDuplicated(pc, excludeId, model)) {
|
||||
return "部位代码不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getDeptName()) || model.getDeptName().trim().isEmpty()) {
|
||||
return "部门名称不能为空";
|
||||
}
|
||||
model.setDeptName(model.getDeptName().trim());
|
||||
|
||||
String en = model.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return "是否启用不合法(须为字典项值 0 或 1,xslmes_unit_status)";
|
||||
}
|
||||
model.setEnableStatus(en);
|
||||
|
||||
if (model.getPartDescription() != null) {
|
||||
model.setPartDescription(model.getPartDescription().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 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_equipment_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备部位")
|
||||
public class MesXslEquipmentPart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称冗余展示")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
@Excel(name = "部门名称", width = 20)
|
||||
@Schema(description = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Excel(name = "部位代码", width = 16)
|
||||
@Schema(description = "部位代码(同租户未删除数据中唯一)")
|
||||
private String partCode;
|
||||
|
||||
@Excel(name = "部位描述", width = 28)
|
||||
@Schema(description = "部位描述")
|
||||
private String partDescription;
|
||||
|
||||
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_unit_status")
|
||||
@Dict(dicCode = "xslmes_unit_status")
|
||||
@Schema(description = "是否启用(字典xslmes_unit_status:0启用1停用)")
|
||||
private String enableStatus;
|
||||
|
||||
/** Excel 导入用:设备类别名称,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "设备类别名称", width = 22)
|
||||
@Schema(description = "导入用设备类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
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,11 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
|
||||
/**
|
||||
* MES 设备部位 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslEquipmentPartMapper extends BaseMapper<MesXslEquipmentPart> {}
|
||||
@@ -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.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})等。
|
||||
*/
|
||||
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.MesXslEquipmentPart;
|
||||
|
||||
public interface IMesXslEquipmentPartService extends IService<MesXslEquipmentPart> {
|
||||
|
||||
/**
|
||||
* 部位代码是否已被占用:同租户下未删除数据中部位代码不可重复。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param partCode 部位代码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isPartCodeDuplicated(String partCode, String excludeId, MesXslEquipmentPart 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.MesXslEquipmentPart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentPartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentPartServiceImpl extends ServiceImpl<MesXslEquipmentPartMapper, MesXslEquipmentPart>
|
||||
implements IMesXslEquipmentPartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isPartCodeDuplicated(String partCode, String excludeId, MesXslEquipmentPart context) {
|
||||
if (oConvertUtils.isEmpty(partCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentPart::getPartCode, partCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentPart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentPart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentPart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentPart 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)-----------
|
||||
}
|
||||
Reference in New Issue
Block a user