Merge remote-tracking branch 'origin/生产基础资料' into SCADA系统测试
This commit is contained in:
@@ -0,0 +1,300 @@
|
||||
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 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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
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/mesXslEquipmentCategory")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentCategoryController extends JeecgController<MesXslEquipmentCategory, IMesXslEquipmentCategoryService> {
|
||||
|
||||
private static final Set<String> INSPECT_DISTINCT = Set.of("generic", "distinct");
|
||||
private static final Set<String> MAINTAIN_DISTINCT = Set.of("maintain", "distinct");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Operation(summary = "MES设备类别-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentCategory>> queryPageList(
|
||||
MesXslEquipmentCategory model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentCategory> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentCategory> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentCategory> pageList = mesXslEquipmentCategoryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-添加")
|
||||
@Operation(summary = "MES设备类别-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
mesXslEquipmentCategoryService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-编辑")
|
||||
@Operation(summary = "MES设备类别-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类别:名称唯一、工序与字典校验、冗余工序名称-----------
|
||||
mesXslEquipmentCategoryService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-删除")
|
||||
@Operation(summary = "MES设备类别-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentCategoryService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类别-批量删除")
|
||||
@Operation(summary = "MES设备类别-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentCategoryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备类别-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentCategory entity = mesXslEquipmentCategoryService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验设备类别名称是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkCategoryName")
|
||||
public Result<String> checkCategoryName(
|
||||
@RequestParam(name = "categoryName", required = true) String categoryName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(categoryName) || categoryName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentCategory ctx = new MesXslEquipmentCategory();
|
||||
if (mesXslEquipmentCategoryService.isCategoryNameDuplicated(categoryName.trim(), dataId, ctx)) {
|
||||
return Result.error("该类别名称已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentCategory model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentCategory.class, "MES设备类别");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_category:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslEquipmentCategory> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentCategory.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentCategory row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String name = row.getCategoryName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称不能为空");
|
||||
}
|
||||
row.setCategoryName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return Result.error("文件导入失败:类别名称【" + name + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslEquipmentCategoryService.isCategoryNameDuplicated(name, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称【" + name + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
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());
|
||||
row.setImportOperationCode(null);
|
||||
|
||||
String ins = row.getInspectDistinct();
|
||||
if (ins != null) {
|
||||
ins = ins.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ins) || !INSPECT_DISTINCT.contains(ins)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条点检区分须为字典项值 generic 或 distinct");
|
||||
}
|
||||
row.setInspectDistinct(ins);
|
||||
|
||||
String mtn = row.getMaintainDistinct();
|
||||
if (mtn != null) {
|
||||
mtn = mtn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(mtn) || !MAINTAIN_DISTINCT.contains(mtn)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条保养区分须为字典项值 maintain 或 distinct");
|
||||
}
|
||||
row.setMaintainDistinct(mtn);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentCategoryService.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:20260514 for:【MES】设备类别导入:名称唯一、工序编码解析、字典取值校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别保存前校验与工序名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentCategory model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getCategoryName()) || model.getCategoryName().trim().isEmpty()) {
|
||||
return "类别名称不能为空";
|
||||
}
|
||||
String cn = model.getCategoryName().trim();
|
||||
model.setCategoryName(cn);
|
||||
if (mesXslEquipmentCategoryService.isCategoryNameDuplicated(cn, excludeId, model)) {
|
||||
return "类别名称已存在";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
|
||||
if (op == null) {
|
||||
return "所属工序不存在";
|
||||
}
|
||||
model.setProcessOperationName(op.getOperationName());
|
||||
|
||||
String ins = model.getInspectDistinct();
|
||||
if (ins != null) {
|
||||
ins = ins.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ins) || !INSPECT_DISTINCT.contains(ins)) {
|
||||
return "点检区分不合法(须为字典项值 generic 或 distinct)";
|
||||
}
|
||||
model.setInspectDistinct(ins);
|
||||
|
||||
String mtn = model.getMaintainDistinct();
|
||||
if (mtn != null) {
|
||||
mtn = mtn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(mtn) || !MAINTAIN_DISTINCT.contains(mtn)) {
|
||||
return "保养区分不合法(须为字典项值 maintain 或 distinct)";
|
||||
}
|
||||
model.setMaintainDistinct(mtn);
|
||||
model.setImportOperationCode(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslEquipmentCategory 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:20260514 for:【MES】设备类别保存前校验与工序名称回填-----------
|
||||
}
|
||||
@@ -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.getPartName() != null) {
|
||||
row.setPartName(row.getPartName().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.getPartName()) || model.getPartName().trim().isEmpty()) {
|
||||
return "部位名称不能为空";
|
||||
}
|
||||
model.setPartName(model.getPartName().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,325 @@
|
||||
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.entity.MesXslEquipmentSubPart;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService;
|
||||
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/mesXslEquipmentSubPart")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentSubPartController extends JeecgController<MesXslEquipmentSubPart, IMesXslEquipmentSubPartService> {
|
||||
|
||||
private static final Set<String> ENABLE_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentSubPartService mesXslEquipmentSubPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentPartService mesXslEquipmentPartService;
|
||||
|
||||
@Operation(summary = "MES设备小部位-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentSubPart>> queryPageList(
|
||||
MesXslEquipmentSubPart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentSubPart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentSubPart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentSubPart> pageList = mesXslEquipmentSubPartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-添加")
|
||||
@Operation(summary = "MES设备小部位-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentSubPart 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】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
mesXslEquipmentSubPartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-编辑")
|
||||
@Operation(summary = "MES设备小部位-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentSubPart 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】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
mesXslEquipmentSubPartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-删除")
|
||||
@Operation(summary = "MES设备小部位-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentSubPartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-批量删除")
|
||||
@Operation(summary = "MES设备小部位-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentSubPartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备小部位-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentSubPart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentSubPart entity = mesXslEquipmentSubPartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验小部位代码是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkSubPartCode")
|
||||
public Result<String> checkSubPartCode(
|
||||
@RequestParam(name = "subPartCode", required = true) String subPartCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(subPartCode) || subPartCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentSubPart ctx = new MesXslEquipmentSubPart();
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(subPartCode.trim(), dataId, ctx)) {
|
||||
return Result.error("小部位代码不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentSubPart model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentSubPart.class, "MES设备小部位");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_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<MesXslEquipmentSubPart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentSubPart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentSubPart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String sc = row.getSubPartCode();
|
||||
if (sc != null) {
|
||||
sc = sc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(sc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位代码不能为空");
|
||||
}
|
||||
row.setSubPartCode(sc);
|
||||
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());
|
||||
|
||||
String ipc = row.getImportEquipmentPartCode();
|
||||
if (ipc != null) {
|
||||
ipc = ipc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ipc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条大部位代码不能为空");
|
||||
}
|
||||
MesXslEquipmentPart part =
|
||||
mesXslEquipmentPartService.findOneActiveByPartCodeAndTenant(ipc, row.getTenantId());
|
||||
if (part == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条大部位代码【" + ipc + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
if (!cat.getId().equals(part.getEquipmentCategoryId())) {
|
||||
return Result.error(
|
||||
"文件导入失败:第 " + rowNo + " 条设备类别名称与所选大部位不匹配(大部位所属类别须与类别名称一致)");
|
||||
}
|
||||
row.setEquipmentPartId(part.getId());
|
||||
row.setEquipmentPartName(part.getPartName());
|
||||
row.setImportCategoryName(null);
|
||||
row.setImportEquipmentPartCode(null);
|
||||
|
||||
if (oConvertUtils.isEmpty(row.getSubPartName()) || row.getSubPartName().trim().isEmpty()) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位名称不能为空");
|
||||
}
|
||||
row.setSubPartName(row.getSubPartName().trim());
|
||||
|
||||
if (!codesInFile.add(sc)) {
|
||||
return Result.error("文件导入失败:小部位代码【" + sc + "】在导入文件中重复(小部位代码不能重复)");
|
||||
}
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(sc, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位代码【" + sc + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
if (row.getSubPartDescription() != null) {
|
||||
row.setSubPartDescription(row.getSubPartDescription().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();
|
||||
mesXslEquipmentSubPartService.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(MesXslEquipmentSubPart 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.getEquipmentPartId())) {
|
||||
return "请选择所属设备大部位";
|
||||
}
|
||||
MesXslEquipmentPart part = mesXslEquipmentPartService.getById(model.getEquipmentPartId());
|
||||
if (part == null) {
|
||||
return "所属设备大部位不存在";
|
||||
}
|
||||
if (!model.getEquipmentCategoryId().equals(part.getEquipmentCategoryId())) {
|
||||
return "所属设备类别与所选设备大部位不匹配";
|
||||
}
|
||||
model.setEquipmentPartName(part.getPartName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSubPartCode()) || model.getSubPartCode().trim().isEmpty()) {
|
||||
return "小部位代码不能为空";
|
||||
}
|
||||
String sc = model.getSubPartCode().trim();
|
||||
model.setSubPartCode(sc);
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(sc, excludeId, model)) {
|
||||
return "小部位代码不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSubPartName()) || model.getSubPartName().trim().isEmpty()) {
|
||||
return "小部位名称不能为空";
|
||||
}
|
||||
model.setSubPartName(model.getSubPartName().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.getSubPartDescription() != null) {
|
||||
model.setSubPartDescription(model.getSubPartDescription().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
model.setImportEquipmentPartCode(null);
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验与冗余名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
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 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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentType;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentTypeService;
|
||||
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/mesXslEquipmentType")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentTypeController extends JeecgController<MesXslEquipmentType, IMesXslEquipmentTypeService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentTypeService mesXslEquipmentTypeService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Operation(summary = "MES设备类型-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentType>> queryPageList(
|
||||
MesXslEquipmentType model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentType> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentType> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentType> pageList = mesXslEquipmentTypeService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-添加")
|
||||
@Operation(summary = "MES设备类型-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentType model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
mesXslEquipmentTypeService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-编辑")
|
||||
@Operation(summary = "MES设备类型-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentType model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类型:名称唯一、工序与设备类别校验、冗余名称-----------
|
||||
mesXslEquipmentTypeService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-删除")
|
||||
@Operation(summary = "MES设备类型-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentTypeService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备类型-批量删除")
|
||||
@Operation(summary = "MES设备类型-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentTypeService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备类型-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentType> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentType entity = mesXslEquipmentTypeService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验设备类型名称是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkTypeName")
|
||||
public Result<String> checkTypeName(
|
||||
@RequestParam(name = "typeName", required = true) String typeName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(typeName) || typeName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentType ctx = new MesXslEquipmentType();
|
||||
if (mesXslEquipmentTypeService.isTypeNameDuplicated(typeName.trim(), dataId, ctx)) {
|
||||
return Result.error("该类型名称已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentType model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentType.class, "MES设备类型");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_type:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslEquipmentType> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentType.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentType row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String tn = row.getTypeName();
|
||||
if (tn != null) {
|
||||
tn = tn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(tn)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类型名称不能为空");
|
||||
}
|
||||
row.setTypeName(tn);
|
||||
if (!namesInFile.add(tn)) {
|
||||
return Result.error("文件导入失败:类型名称【" + tn + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslEquipmentTypeService.isTypeNameDuplicated(tn, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类型名称【" + tn + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
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());
|
||||
row.setImportOperationCode(null);
|
||||
|
||||
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);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentTypeService.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:20260514 for:【MES】设备类型导入:名称唯一、工序编码与设备类别名称解析-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型保存前校验与工序、类别名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentType model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getTypeName()) || model.getTypeName().trim().isEmpty()) {
|
||||
return "类型名称不能为空";
|
||||
}
|
||||
String tn = model.getTypeName().trim();
|
||||
model.setTypeName(tn);
|
||||
if (mesXslEquipmentTypeService.isTypeNameDuplicated(tn, excludeId, model)) {
|
||||
return "类型名称已存在";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
MesXslProcessOperation op = mesXslProcessOperationService.getById(model.getProcessOperationId());
|
||||
if (op == null) {
|
||||
return "所属工序不存在";
|
||||
}
|
||||
model.setProcessOperationName(op.getOperationName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) {
|
||||
return "请选择所属设备类别";
|
||||
}
|
||||
MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属设备类别不存在";
|
||||
}
|
||||
model.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
model.setImportOperationCode(null);
|
||||
model.setImportCategoryName(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesXslProcessOperation findProcessByOperationCode(String operationCode, MesXslEquipmentType 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:20260514 for:【MES】设备类型保存前校验与工序、类别名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslManufacturerService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* MES 厂家信息
|
||||
*/
|
||||
@Tag(name = "MES厂家信息")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslManufacturer")
|
||||
@Slf4j
|
||||
public class MesXslManufacturerController extends JeecgController<MesXslManufacturer, IMesXslManufacturerService> {
|
||||
|
||||
private static final Set<String> MANUFACTURER_CATEGORIES = Set.of("mold", "capsule", "equipment");
|
||||
private static final Set<String> VALID_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslManufacturerService mesXslManufacturerService;
|
||||
|
||||
@Operation(summary = "MES厂家信息-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslManufacturer>> queryPageList(
|
||||
MesXslManufacturer model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslManufacturer> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslManufacturer> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslManufacturer> pageList = mesXslManufacturerService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-添加")
|
||||
@Operation(summary = "MES厂家信息-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslManufacturer model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
mesXslManufacturerService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-编辑")
|
||||
@Operation(summary = "MES厂家信息-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslManufacturer model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验:类别字典值、名称唯一、有效状态-----------
|
||||
mesXslManufacturerService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-删除")
|
||||
@Operation(summary = "MES厂家信息-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslManufacturerService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES厂家信息-批量删除")
|
||||
@Operation(summary = "MES厂家信息-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslManufacturerService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES厂家信息-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslManufacturer> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslManufacturer entity = mesXslManufacturerService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验厂家名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkManufacturerName")
|
||||
public Result<String> checkManufacturerName(
|
||||
@RequestParam(name = "manufacturerName", required = true) String manufacturerName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(manufacturerName) || manufacturerName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslManufacturer ctx = new MesXslManufacturer();
|
||||
if (mesXslManufacturerService.isManufacturerNameDuplicated(manufacturerName.trim(), dataId, ctx)) {
|
||||
return Result.error("厂家名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslManufacturer model) {
|
||||
return super.exportXls(request, model, MesXslManufacturer.class, "MES厂家信息");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_manufacturer:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息导入:名称唯一、文件内去重、类别与有效状态校验-----------
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
|
||||
MultipartFile file = ent.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<MesXslManufacturer> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslManufacturer.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslManufacturer row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String name = row.getManufacturerName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条厂家名称不能为空");
|
||||
}
|
||||
row.setManufacturerName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return Result.error("文件导入失败:厂家名称【" + name + "】在导入文件中重复");
|
||||
}
|
||||
String cat = row.getManufacturerCategory();
|
||||
if (oConvertUtils.isEmpty(cat) || !MANUFACTURER_CATEGORIES.contains(cat.trim())) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条厂家类别无效(须为模具厂家/胶囊厂家/设备厂家对应字典值)");
|
||||
}
|
||||
row.setManufacturerCategory(cat.trim());
|
||||
String vs = row.getValidStatus();
|
||||
if (oConvertUtils.isEmpty(vs)) {
|
||||
row.setValidStatus("0");
|
||||
} else {
|
||||
vs = vs.trim();
|
||||
if (!VALID_STATUS.contains(vs)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否有效无效(须为有效或无效对应字典值)");
|
||||
}
|
||||
row.setValidStatus(vs);
|
||||
}
|
||||
if (mesXslManufacturerService.isManufacturerNameDuplicated(name, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条厂家名称【" + name + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslManufacturerService.saveBatch(list);
|
||||
log.info("厂家信息Excel导入完成,耗时{}ms,行数={}", System.currentTimeMillis() - start, list.size());
|
||||
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg, e);
|
||||
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
||||
return Result.error("文件导入失败: 存在重复数据(厂家名称不能重复)");
|
||||
}
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息导入:名称唯一、文件内去重、类别与有效状态校验-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验-----------
|
||||
private String validateForSave(MesXslManufacturer model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getManufacturerCategory()) || model.getManufacturerCategory().trim().isEmpty()) {
|
||||
return "厂家类别不能为空";
|
||||
}
|
||||
String cat = model.getManufacturerCategory().trim();
|
||||
if (!MANUFACTURER_CATEGORIES.contains(cat)) {
|
||||
return "厂家类别无效";
|
||||
}
|
||||
model.setManufacturerCategory(cat);
|
||||
if (oConvertUtils.isEmpty(model.getManufacturerName()) || model.getManufacturerName().trim().isEmpty()) {
|
||||
return "厂家名称不能为空";
|
||||
}
|
||||
String name = model.getManufacturerName().trim();
|
||||
model.setManufacturerName(name);
|
||||
if (mesXslManufacturerService.isManufacturerNameDuplicated(name, excludeId, model)) {
|
||||
return "厂家名称不能重复";
|
||||
}
|
||||
String vs = model.getValidStatus();
|
||||
if (oConvertUtils.isEmpty(vs)) {
|
||||
model.setValidStatus("0");
|
||||
} else {
|
||||
vs = vs.trim();
|
||||
if (!VALID_STATUS.contains(vs)) {
|
||||
return "是否有效取值无效";
|
||||
}
|
||||
model.setValidStatus(vs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家信息保存前校验-----------
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
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.MesXslProcessOperation;
|
||||
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/mesXslProcessOperation")
|
||||
@Slf4j
|
||||
public class MesXslProcessOperationController extends JeecgController<MesXslProcessOperation, IMesXslProcessOperationService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Operation(summary = "MES工序管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslProcessOperation>> queryPageList(
|
||||
MesXslProcessOperation model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslProcessOperation> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslProcessOperation> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslProcessOperation> pageList = mesXslProcessOperationService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-添加")
|
||||
@Operation(summary = "MES工序管理-添加")
|
||||
@RequiresPermissions("mes:mes_process_operation:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslProcessOperation model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
if (oConvertUtils.isEmpty(model.getOperationCode()) || oConvertUtils.isEmpty(model.getOperationName())) {
|
||||
return Result.error("工序编码、工序名称不能为空");
|
||||
}
|
||||
String code = model.getOperationCode().trim();
|
||||
model.setOperationCode(code);
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, null, model)) {
|
||||
return Result.error("工序编码已存在");
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
mesXslProcessOperationService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-编辑")
|
||||
@Operation(summary = "MES工序管理-编辑")
|
||||
@RequiresPermissions("mes:mes_process_operation:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslProcessOperation model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
if (oConvertUtils.isEmpty(model.getOperationCode()) || oConvertUtils.isEmpty(model.getOperationName())) {
|
||||
return Result.error("工序编码、工序名称不能为空");
|
||||
}
|
||||
String code = model.getOperationCode().trim();
|
||||
model.setOperationCode(code);
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, model.getId(), model)) {
|
||||
return Result.error("工序编码已存在");
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
mesXslProcessOperationService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-删除")
|
||||
@Operation(summary = "MES工序管理-通过id删除")
|
||||
@RequiresPermissions("mes:mes_process_operation:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslProcessOperationService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-批量删除")
|
||||
@Operation(summary = "MES工序管理-批量删除")
|
||||
@RequiresPermissions("mes:mes_process_operation:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslProcessOperationService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES工序管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslProcessOperation> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslProcessOperation entity = mesXslProcessOperationService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验工序编码是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkOperationCode")
|
||||
public Result<String> checkOperationCode(
|
||||
@RequestParam(name = "operationCode", required = true) String operationCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(operationCode) || operationCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslProcessOperation ctx = new MesXslProcessOperation();
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(operationCode.trim(), dataId, ctx)) {
|
||||
return Result.error("该工序编码已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_process_operation:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslProcessOperation model) {
|
||||
return super.exportXls(request, model, MesXslProcessOperation.class, "MES工序管理");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_process_operation:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslProcessOperation> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslProcessOperation.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslProcessOperation row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String code = row.getOperationCode();
|
||||
if (code != null) {
|
||||
code = code.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码不能为空");
|
||||
}
|
||||
row.setOperationCode(code);
|
||||
if (oConvertUtils.isEmpty(row.getOperationName()) || row.getOperationName().trim().isEmpty()) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序名称不能为空");
|
||||
}
|
||||
row.setOperationName(row.getOperationName().trim());
|
||||
if (!codesInFile.add(code)) {
|
||||
return Result.error("文件导入失败:工序编码【" + code + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码【" + code + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslProcessOperationService.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:20260514 for:【MES】工序导入:文件内编码不重复,且与库中未删除数据不重复-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
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.math.BigDecimal;
|
||||
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.MesXslSparePart;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslUnit;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartsCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslUnitService;
|
||||
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/mesXslSparePart")
|
||||
@Slf4j
|
||||
public class MesXslSparePartController extends JeecgController<MesXslSparePart, IMesXslSparePartService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslSparePartService mesXslSparePartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslSparePartsCategoryService mesXslSparePartsCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslUnitService mesXslUnitService;
|
||||
|
||||
@Operation(summary = "MES备品件信息-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslSparePart>> queryPageList(
|
||||
MesXslSparePart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslSparePart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslSparePart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslSparePart> pageList = mesXslSparePartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-添加")
|
||||
@Operation(summary = "MES备品件信息-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslSparePart 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】备品件信息保存前校验:名称唯一、类别与单位回填、库存上下限-----------
|
||||
mesXslSparePartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-编辑")
|
||||
@Operation(summary = "MES备品件信息-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslSparePart 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】备品件信息保存前校验:名称唯一、类别与单位回填、库存上下限-----------
|
||||
mesXslSparePartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-删除")
|
||||
@Operation(summary = "MES备品件信息-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslSparePartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件信息-批量删除")
|
||||
@Operation(summary = "MES备品件信息-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslSparePartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES备品件信息-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslSparePart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslSparePart entity = mesXslSparePartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验备品件名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkSparePartName")
|
||||
public Result<String> checkSparePartName(
|
||||
@RequestParam(name = "sparePartName", required = true) String sparePartName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(sparePartName) || sparePartName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslSparePart ctx = new MesXslSparePart();
|
||||
if (mesXslSparePartService.isSparePartNameDuplicated(sparePartName.trim(), dataId, ctx)) {
|
||||
return Result.error("备品件名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslSparePart model) {
|
||||
return super.exportXls(request, model, MesXslSparePart.class, "MES备品件信息");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_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<MesXslSparePart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslSparePart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslSparePart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String pn = row.getSparePartName();
|
||||
if (pn != null) {
|
||||
pn = pn.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(pn)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件名称不能为空");
|
||||
}
|
||||
row.setSparePartName(pn);
|
||||
if (!namesInFile.add(pn)) {
|
||||
return Result.error("文件导入失败:备品件名称【" + pn + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslSparePartService.isSparePartNameDuplicated(pn, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件名称【" + pn + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件类别名称不能为空");
|
||||
}
|
||||
MesXslSparePartsCategory cat =
|
||||
mesXslSparePartsCategoryService.findOneActiveByCategoryNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条备品件类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setSparePartsCategoryId(cat.getId());
|
||||
row.setSparePartsCategoryName(cat.getCategoryName());
|
||||
row.setImportCategoryName(null);
|
||||
|
||||
String ucode = row.getImportUnitCode();
|
||||
if (ucode != null) {
|
||||
ucode = ucode.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ucode)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条单位编码不能为空");
|
||||
}
|
||||
MesXslUnit unit = mesXslUnitService.findOneActiveByUnitCodeAndTenant(ucode, row.getTenantId());
|
||||
if (unit == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条单位编码【" + ucode + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
String st = unit.getStatus();
|
||||
if (st != null && "1".equals(st.trim())) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条单位编码【" + ucode + "】对应单位已停用");
|
||||
}
|
||||
row.setUnitId(unit.getId());
|
||||
row.setUnitName(unit.getUnitName());
|
||||
row.setImportUnitCode(null);
|
||||
|
||||
String errStock = normalizeAndValidateStocks(row, rowNo);
|
||||
if (errStock != null) {
|
||||
return Result.error(errStock);
|
||||
}
|
||||
|
||||
if (row.getSpecModel() != null) {
|
||||
row.setSpecModel(row.getSpecModel().trim());
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslSparePartService.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(MesXslSparePart model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getSparePartName()) || model.getSparePartName().trim().isEmpty()) {
|
||||
return "备品件名称不能为空";
|
||||
}
|
||||
String pn = model.getSparePartName().trim();
|
||||
model.setSparePartName(pn);
|
||||
if (mesXslSparePartService.isSparePartNameDuplicated(pn, excludeId, model)) {
|
||||
return "备品件名称不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSparePartsCategoryId())) {
|
||||
return "请选择所属备品件类别";
|
||||
}
|
||||
MesXslSparePartsCategory cat = mesXslSparePartsCategoryService.getById(model.getSparePartsCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属备品件类别不存在";
|
||||
}
|
||||
model.setSparePartsCategoryName(cat.getCategoryName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getUnitId())) {
|
||||
return "请选择单位";
|
||||
}
|
||||
MesXslUnit unit = mesXslUnitService.getById(model.getUnitId());
|
||||
if (unit == null) {
|
||||
return "所选单位不存在";
|
||||
}
|
||||
String ust = unit.getStatus();
|
||||
if (ust != null && "1".equals(ust.trim())) {
|
||||
return "所选单位已停用,请重新选择";
|
||||
}
|
||||
model.setUnitName(unit.getUnitName());
|
||||
|
||||
String errStock = normalizeAndValidateStocks(model, null);
|
||||
if (errStock != null) {
|
||||
return errStock;
|
||||
}
|
||||
|
||||
if (model.getSpecModel() != null) {
|
||||
model.setSpecModel(model.getSpecModel().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
model.setImportUnitCode(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 规范化 max/min 库存并校验;rowNo 非空时错误信息带行号(导入用) */
|
||||
private String normalizeAndValidateStocks(MesXslSparePart model, Integer rowNo) {
|
||||
BigDecimal max = model.getMaxStock();
|
||||
BigDecimal min = model.getMinStock();
|
||||
if (max == null || min == null) {
|
||||
return rowNo == null ? "最大库存、最小库存不能为空" : "文件导入失败:第 " + rowNo + " 条最大库存、最小库存不能为空";
|
||||
}
|
||||
max = max.stripTrailingZeros();
|
||||
min = min.stripTrailingZeros();
|
||||
model.setMaxStock(max);
|
||||
model.setMinStock(min);
|
||||
if (max.compareTo(BigDecimal.ZERO) < 0 || min.compareTo(BigDecimal.ZERO) < 0) {
|
||||
return rowNo == null ? "最大库存、最小库存不能为负数" : "文件导入失败:第 " + rowNo + " 条最大库存、最小库存不能为负数";
|
||||
}
|
||||
if (max.compareTo(min) < 0) {
|
||||
return rowNo == null ? "最大库存不能小于最小库存" : "文件导入失败:第 " + rowNo + " 条最大库存不能小于最小库存";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件信息保存前校验与冗余名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
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.MesXslSparePartsCategory;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartsCategoryService;
|
||||
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/mesXslSparePartsCategory")
|
||||
@Slf4j
|
||||
public class MesXslSparePartsCategoryController extends JeecgController<MesXslSparePartsCategory, IMesXslSparePartsCategoryService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslSparePartsCategoryService mesXslSparePartsCategoryService;
|
||||
|
||||
@Operation(summary = "MES备品件类别-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslSparePartsCategory>> queryPageList(
|
||||
MesXslSparePartsCategory model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslSparePartsCategory> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslSparePartsCategory> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslSparePartsCategory> pageList = mesXslSparePartsCategoryService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-添加")
|
||||
@Operation(summary = "MES备品件类别-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslSparePartsCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
mesXslSparePartsCategoryService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-编辑")
|
||||
@Operation(summary = "MES备品件类别-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslSparePartsCategory model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验:类别名称唯一、描述 trim-----------
|
||||
mesXslSparePartsCategoryService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-删除")
|
||||
@Operation(summary = "MES备品件类别-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslSparePartsCategoryService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES备品件类别-批量删除")
|
||||
@Operation(summary = "MES备品件类别-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslSparePartsCategoryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES备品件类别-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslSparePartsCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslSparePartsCategory entity = mesXslSparePartsCategoryService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验备品件类别名称是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkCategoryName")
|
||||
public Result<String> checkCategoryName(
|
||||
@RequestParam(name = "categoryName", required = true) String categoryName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(categoryName) || categoryName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslSparePartsCategory ctx = new MesXslSparePartsCategory();
|
||||
if (mesXslSparePartsCategoryService.isCategoryNameDuplicated(categoryName.trim(), dataId, ctx)) {
|
||||
return Result.error("类别名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslSparePartsCategory model) {
|
||||
return super.exportXls(request, model, MesXslSparePartsCategory.class, "MES备品件类别");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_spare_parts_category: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<MesXslSparePartsCategory> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslSparePartsCategory.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslSparePartsCategory row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String name = row.getCategoryName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称不能为空");
|
||||
}
|
||||
row.setCategoryName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return Result.error("文件导入失败:类别名称【" + name + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslSparePartsCategoryService.isCategoryNameDuplicated(name, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条类别名称【" + name + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
if (row.getCategoryDescription() != null) {
|
||||
row.setCategoryDescription(row.getCategoryDescription().trim());
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslSparePartsCategoryService.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(MesXslSparePartsCategory model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getCategoryName()) || model.getCategoryName().trim().isEmpty()) {
|
||||
return "类别名称不能为空";
|
||||
}
|
||||
String name = model.getCategoryName().trim();
|
||||
model.setCategoryName(name);
|
||||
if (mesXslSparePartsCategoryService.isCategoryNameDuplicated(name, excludeId, model)) {
|
||||
return "类别名称不能重复";
|
||||
}
|
||||
if (model.getCategoryDescription() != null) {
|
||||
model.setCategoryDescription(model.getCategoryDescription().trim());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别保存前校验-----------
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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_category)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_category")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备类别")
|
||||
public class MesXslEquipmentCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称(同租户未删除数据中唯一)")
|
||||
private String categoryName;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称冗余,用于列表与导出展示")
|
||||
private String processOperationName;
|
||||
|
||||
@Excel(name = "点检区分", width = 14, dicCode = "xslmes_equipment_inspect_distinct")
|
||||
@Dict(dicCode = "xslmes_equipment_inspect_distinct")
|
||||
@Schema(description = "点检区分(字典 xslmes_equipment_inspect_distinct)")
|
||||
private String inspectDistinct;
|
||||
|
||||
@Excel(name = "保养区分", width = 14, dicCode = "xslmes_equipment_maintain_distinct")
|
||||
@Dict(dicCode = "xslmes_equipment_maintain_distinct")
|
||||
@Schema(description = "保养区分(字典 xslmes_equipment_maintain_distinct)")
|
||||
private String maintainDistinct;
|
||||
|
||||
/** 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,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 partName;
|
||||
|
||||
@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,87 @@
|
||||
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_sub_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_sub_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备小部位")
|
||||
public class MesXslEquipmentSubPart 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;
|
||||
|
||||
@Schema(description = "所属设备大部位主键 mes_xsl_equipment_part.id")
|
||||
private String equipmentPartId;
|
||||
|
||||
@Excel(name = "大部位名称", width = 20)
|
||||
@Schema(description = "设备大部位名称冗余")
|
||||
private String equipmentPartName;
|
||||
|
||||
@Excel(name = "小部位名称", width = 20)
|
||||
@Schema(description = "小部位名称")
|
||||
private String subPartName;
|
||||
|
||||
@Excel(name = "小部位代码", width = 16)
|
||||
@Schema(description = "小部位代码(同租户未删除数据中唯一)")
|
||||
private String subPartCode;
|
||||
|
||||
@Excel(name = "部位描述", width = 28)
|
||||
@Schema(description = "部位描述")
|
||||
private String subPartDescription;
|
||||
|
||||
@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;
|
||||
|
||||
/** Excel 导入用:大部位代码 mes_xsl_equipment_part.part_code,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "大部位代码", width = 16)
|
||||
@Schema(description = "导入用设备大部位代码")
|
||||
private String importEquipmentPartCode;
|
||||
|
||||
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,73 @@
|
||||
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.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 设备类型(表 mes_xsl_equipment_type)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_type")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备类型")
|
||||
public class MesXslEquipmentType implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "类型名称", width = 22)
|
||||
@Schema(description = "设备类型名称(同租户未删除数据中唯一)")
|
||||
private String typeName;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称冗余展示")
|
||||
private String processOperationName;
|
||||
|
||||
@Schema(description = "所属设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称冗余展示")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
/** Excel 导入用:工序编码,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "工序编码", width = 18)
|
||||
@Schema(description = "导入用工序编码")
|
||||
private String importOperationCode;
|
||||
|
||||
/** 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,57 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 厂家信息(表 mes_xsl_manufacturer)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_manufacturer")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES厂家信息")
|
||||
public class MesXslManufacturer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "厂家类别", width = 16, dicCode = "xslmes_manufacturer_category")
|
||||
@Dict(dicCode = "xslmes_manufacturer_category")
|
||||
@Schema(description = "厂家类别(字典 xslmes_manufacturer_category)")
|
||||
private String manufacturerCategory;
|
||||
|
||||
@Excel(name = "厂家名称", width = 28)
|
||||
@Schema(description = "厂家名称(同租户未删除数据中唯一)")
|
||||
private String manufacturerName;
|
||||
|
||||
@Excel(name = "是否有效", width = 12, dicCode = "xslmes_manufacturer_valid")
|
||||
@Dict(dicCode = "xslmes_manufacturer_valid")
|
||||
@Schema(description = "是否有效(字典 xslmes_manufacturer_valid:0有效1无效)")
|
||||
private String validStatus;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 工序管理(表 mes_process_operation)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_process_operation")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES工序管理")
|
||||
public class MesXslProcessOperation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "工序编码", width = 20)
|
||||
@Schema(description = "工序编码(同租户内唯一)")
|
||||
private String operationCode;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称")
|
||||
private String operationName;
|
||||
|
||||
@Excel(name = "备注", width = 28)
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
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,86 @@
|
||||
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.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 备品件信息(表 mes_xsl_spare_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_spare_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES备品件信息")
|
||||
public class MesXslSparePart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "备品件名称", width = 22)
|
||||
@Schema(description = "备品件名称(同租户未删除数据中唯一)")
|
||||
private String sparePartName;
|
||||
|
||||
@Schema(description = "所属备品件类别主键")
|
||||
private String sparePartsCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 20)
|
||||
@Schema(description = "备品件类别名称冗余")
|
||||
private String sparePartsCategoryName;
|
||||
|
||||
@Excel(name = "规格型号", width = 20)
|
||||
@Schema(description = "规格型号")
|
||||
private String specModel;
|
||||
|
||||
@Excel(name = "最大库存", width = 14)
|
||||
@Schema(description = "最大库存")
|
||||
private BigDecimal maxStock;
|
||||
|
||||
@Excel(name = "最小库存", width = 14)
|
||||
@Schema(description = "最小库存")
|
||||
private BigDecimal minStock;
|
||||
|
||||
@Schema(description = "单位 mes_xsl_unit.id")
|
||||
private String unitId;
|
||||
|
||||
@Excel(name = "单位名称", width = 14)
|
||||
@Schema(description = "单位名称冗余")
|
||||
private String unitName;
|
||||
|
||||
/** Excel 导入用:备品件类别名称,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "备品件类别名称", width = 22)
|
||||
@Schema(description = "导入用备品件类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
/** Excel 导入用:单位编码 mes_xsl_unit.unit_code,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "单位编码", width = 16)
|
||||
@Schema(description = "导入用单位编码")
|
||||
private String importUnitCode;
|
||||
|
||||
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,50 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 备品件类别(表 mes_xsl_spare_parts_category)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_spare_parts_category")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES备品件类别")
|
||||
public class MesXslSparePartsCategory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "类别名称", width = 24)
|
||||
@Schema(description = "类别名称(同租户未删除数据中唯一)")
|
||||
private String categoryName;
|
||||
|
||||
@Excel(name = "描述", width = 36)
|
||||
@Schema(description = "描述")
|
||||
private String categoryDescription;
|
||||
|
||||
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.MesXslEquipmentCategory;
|
||||
|
||||
/**
|
||||
* MES 设备类别 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslEquipmentCategoryMapper extends BaseMapper<MesXslEquipmentCategory> {}
|
||||
@@ -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> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
|
||||
public interface MesXslEquipmentSubPartMapper extends BaseMapper<MesXslEquipmentSubPart> {}
|
||||
@@ -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.MesXslEquipmentType;
|
||||
|
||||
/**
|
||||
* MES 设备类型 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslEquipmentTypeMapper extends BaseMapper<MesXslEquipmentType> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||
|
||||
/**
|
||||
* MES 厂家信息
|
||||
*/
|
||||
public interface MesXslManufacturerMapper extends BaseMapper<MesXslManufacturer> {}
|
||||
@@ -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.MesXslProcessOperation;
|
||||
|
||||
/**
|
||||
* MES 工序管理 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslProcessOperationMapper extends BaseMapper<MesXslProcessOperation> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePart;
|
||||
|
||||
public interface MesXslSparePartMapper extends BaseMapper<MesXslSparePart> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory;
|
||||
|
||||
public interface MesXslSparePartsCategoryMapper extends BaseMapper<MesXslSparePartsCategory> {}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})等。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})等。
|
||||
*/
|
||||
package org.jeecg.modules.xslmes;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory;
|
||||
|
||||
public interface IMesXslEquipmentCategoryService extends IService<MesXslEquipmentCategory> {
|
||||
|
||||
/**
|
||||
* 类别名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param categoryName 类别名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslEquipmentCategory context);
|
||||
|
||||
/**
|
||||
* 按类别名称在未删除数据中查询一条(同租户;名称需 trim 后传入)。用于设备类型关联类别解析等。
|
||||
*
|
||||
* @param categoryName 类别名称
|
||||
* @param tenantId 租户 ID,可为 null(不按租户过滤)
|
||||
*/
|
||||
MesXslEquipmentCategory findOneActiveByNameAndTenant(String categoryName, Integer tenantId);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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> {
|
||||
|
||||
/**
|
||||
* 按部位代码在指定租户下查找一条未删除记录(用于设备小部位导入解析等)。
|
||||
*
|
||||
* @param partCode 部位代码(已 trim)
|
||||
* @param tenantId 租户 ID,可为 null(不按租户过滤)
|
||||
*/
|
||||
MesXslEquipmentPart findOneActiveByPartCodeAndTenant(String partCode, Integer tenantId);
|
||||
|
||||
/**
|
||||
* 部位代码是否已被占用:同租户下未删除数据中部位代码不可重复。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param partCode 部位代码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isPartCodeDuplicated(String partCode, String excludeId, MesXslEquipmentPart context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
|
||||
public interface IMesXslEquipmentSubPartService extends IService<MesXslEquipmentSubPart> {
|
||||
|
||||
/**
|
||||
* 小部位代码是否已被占用:同租户下未删除数据中小部位代码不可重复。
|
||||
*
|
||||
* @param subPartCode 小部位代码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isSubPartCodeDuplicated(String subPartCode, String excludeId, MesXslEquipmentSubPart context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentType;
|
||||
|
||||
public interface IMesXslEquipmentTypeService extends IService<MesXslEquipmentType> {
|
||||
|
||||
/**
|
||||
* 类型名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param typeName 类型名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isTypeNameDuplicated(String typeName, String excludeId, MesXslEquipmentType context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManufacturer;
|
||||
|
||||
public interface IMesXslManufacturerService extends IService<MesXslManufacturer> {
|
||||
|
||||
/**
|
||||
* 厂家名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与拦截器注入逻辑一致。
|
||||
*
|
||||
* @param manufacturerName 厂家名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isManufacturerNameDuplicated(String manufacturerName, String excludeId, MesXslManufacturer context);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
|
||||
public interface IMesXslProcessOperationService extends IService<MesXslProcessOperation> {
|
||||
|
||||
/**
|
||||
* 工序编码是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param operationCode 工序编码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isOperationCodeDuplicated(String operationCode, String excludeId, MesXslProcessOperation context);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePart;
|
||||
|
||||
public interface IMesXslSparePartService extends IService<MesXslSparePart> {
|
||||
|
||||
/**
|
||||
* 备品件名称是否已被占用(同租户未删除数据中唯一)。
|
||||
*/
|
||||
boolean isSparePartNameDuplicated(String sparePartName, String excludeId, MesXslSparePart context);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory;
|
||||
|
||||
public interface IMesXslSparePartsCategoryService extends IService<MesXslSparePartsCategory> {
|
||||
|
||||
/**
|
||||
* 备品件类别名称是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param categoryName 类别名称(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslSparePartsCategory context);
|
||||
|
||||
/**
|
||||
* 按类别名称在未删除数据中查询一条(同租户),用于备品件信息导入解析等。
|
||||
*/
|
||||
MesXslSparePartsCategory findOneActiveByCategoryNameAndTenant(String categoryName, Integer tenantId);
|
||||
}
|
||||
@@ -12,4 +12,9 @@ public interface IMesXslUnitService extends IService<MesXslUnit> {
|
||||
|
||||
/** 单位分类(sys_category)选中节点及其所有下级 id,用于列表筛选 */
|
||||
List<String> listDescendantCategoryIds(String rootId);
|
||||
|
||||
/**
|
||||
* 按单位编码在未删除数据中查询一条(同租户),用于备品件信息导入解析等。
|
||||
*/
|
||||
MesXslUnit findOneActiveByUnitCodeAndTenant(String unitCode, Integer tenantId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
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.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentCategoryMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentCategoryServiceImpl extends ServiceImpl<MesXslEquipmentCategoryMapper, MesXslEquipmentCategory>
|
||||
implements IMesXslEquipmentCategoryService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类别名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslEquipmentCategory context) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentCategory::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentCategory::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentCategory::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型按类别名称解析关联,提供未删除单条查询-----------
|
||||
@Override
|
||||
public MesXslEquipmentCategory findOneActiveByNameAndTenant(String categoryName, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslEquipmentCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentCategory::getDelFlag));
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentCategory::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】设备类型按类别名称解析关联,提供未删除单条查询-----------
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentCategory 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:20260514 for:【MES】设备类别名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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)-----------
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位按代码+租户查询单条,供设备小部位导入解析大部位-----------
|
||||
@Override
|
||||
public MesXslEquipmentPart findOneActiveByPartCodeAndTenant(String partCode, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(partCode)) {
|
||||
return null;
|
||||
}
|
||||
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 (tenantId != null) {
|
||||
w.eq(MesXslEquipmentPart::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位按代码+租户查询单条,供设备小部位导入解析大部位-----------
|
||||
}
|
||||
@@ -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.MesXslEquipmentSubPart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentSubPartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentSubPartServiceImpl extends ServiceImpl<MesXslEquipmentSubPartMapper, MesXslEquipmentSubPart>
|
||||
implements IMesXslEquipmentSubPartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isSubPartCodeDuplicated(String subPartCode, String excludeId, MesXslEquipmentSubPart context) {
|
||||
if (oConvertUtils.isEmpty(subPartCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentSubPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentSubPart::getSubPartCode, subPartCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentSubPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentSubPart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentSubPart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentSubPart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentSubPart 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)-----------
|
||||
}
|
||||
@@ -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.MesXslEquipmentType;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentTypeMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentTypeServiceImpl extends ServiceImpl<MesXslEquipmentTypeMapper, MesXslEquipmentType>
|
||||
implements IMesXslEquipmentTypeService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】设备类型名称同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isTypeNameDuplicated(String typeName, String excludeId, MesXslEquipmentType context) {
|
||||
if (oConvertUtils.isEmpty(typeName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentType> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentType::getTypeName, typeName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentType::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentType::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentType::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentType::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentType 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:20260514 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.MesXslManufacturer;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslManufacturerMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslManufacturerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslManufacturerServiceImpl extends ServiceImpl<MesXslManufacturerMapper, MesXslManufacturer>
|
||||
implements IMesXslManufacturerService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】厂家名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isManufacturerNameDuplicated(String manufacturerName, String excludeId, MesXslManufacturer context) {
|
||||
if (oConvertUtils.isEmpty(manufacturerName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslManufacturer> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslManufacturer::getManufacturerName, manufacturerName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslManufacturer::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslManufacturer::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslManufacturer::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslManufacturer::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslManufacturer context) {
|
||||
if (context != null && context.getTenantId() != null) {
|
||||
return context.getTenantId();
|
||||
}
|
||||
String ts = TenantContext.getTenant();
|
||||
if (oConvertUtils.isEmpty(ts)) {
|
||||
try {
|
||||
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ts)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(ts.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】厂家名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslProcessOperationMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslProcessOperationServiceImpl extends ServiceImpl<MesXslProcessOperationMapper, MesXslProcessOperation>
|
||||
implements IMesXslProcessOperationService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isOperationCodeDuplicated(String operationCode, String excludeId, MesXslProcessOperation context) {
|
||||
if (oConvertUtils.isEmpty(operationCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
|
||||
// 仅与「未删除」数据判重:del_flag=0 或历史空值视为正常行,排除已删除(del_flag=1)
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslProcessOperation::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslProcessOperation::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslProcessOperation::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
/** 与 MybatisInterceptor 注入 tenant_id 的取值顺序尽量一致,避免前端未传 tenantId 时查不到已存在数据 */
|
||||
private static Integer resolveTenantId(MesXslProcessOperation 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:20260514 for:【MES】工序编码同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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.MesXslSparePart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslSparePartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslSparePartServiceImpl extends ServiceImpl<MesXslSparePartMapper, MesXslSparePart> implements IMesXslSparePartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isSparePartNameDuplicated(String sparePartName, String excludeId, MesXslSparePart context) {
|
||||
if (oConvertUtils.isEmpty(sparePartName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslSparePart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslSparePart::getSparePartName, sparePartName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslSparePart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslSparePart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslSparePart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslSparePart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslSparePart 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)-----------
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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.MesXslSparePartsCategory;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslSparePartsCategoryMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslSparePartsCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslSparePartsCategoryServiceImpl extends ServiceImpl<MesXslSparePartsCategoryMapper, MesXslSparePartsCategory>
|
||||
implements IMesXslSparePartsCategoryService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别名称同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isCategoryNameDuplicated(String categoryName, String excludeId, MesXslSparePartsCategory context) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslSparePartsCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslSparePartsCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslSparePartsCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslSparePartsCategory::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslSparePartsCategory::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslSparePartsCategory::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】备品件类别按名称+租户查询单条,供备品件信息导入解析-----------
|
||||
@Override
|
||||
public MesXslSparePartsCategory findOneActiveByCategoryNameAndTenant(String categoryName, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(categoryName)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslSparePartsCategory> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslSparePartsCategory::getCategoryName, categoryName.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslSparePartsCategory::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslSparePartsCategory::getDelFlag));
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslSparePartsCategory::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】备品件类别按名称+租户查询单条,供备品件信息导入解析-----------
|
||||
|
||||
private static Integer resolveTenantId(MesXslSparePartsCategory 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)-----------
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
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.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslUnit;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslUnitMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslUnitService;
|
||||
@@ -18,4 +20,20 @@ public class MesXslUnitServiceImpl extends ServiceImpl<MesXslUnitMapper, MesXslU
|
||||
public List<String> listDescendantCategoryIds(String rootId) {
|
||||
return baseMapper.listDescendantCategoryIds(rootId);
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】单位按编码+租户查询单条,供备品件信息导入解析-----------
|
||||
@Override
|
||||
public MesXslUnit findOneActiveByUnitCodeAndTenant(String unitCode, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(unitCode)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslUnit> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslUnit::getUnitCode, unitCode.trim());
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslUnit::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】单位按编码+租户查询单条,供备品件信息导入解析-----------
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user