Merge branch '生产及设备基础资料'
This commit is contained in:
@@ -0,0 +1,319 @@
|
||||
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.MesXslEquipmentLedger;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService;
|
||||
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/mesXslEquipmentLedger")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentLedgerController extends JeecgController<MesXslEquipmentLedger, IMesXslEquipmentLedgerService> {
|
||||
|
||||
private static final Set<String> EQUIPMENT_STATUS = Set.of("0", "1", "2");
|
||||
private static final Set<String> ENABLED_FLAGS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentLedgerService mesXslEquipmentLedgerService;
|
||||
|
||||
@Operation(summary = "MES设备台账-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentLedger>> queryPageList(
|
||||
MesXslEquipmentLedger model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentLedger> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentLedger> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentLedger> pageList = mesXslEquipmentLedgerService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备台账-添加")
|
||||
@Operation(summary = "MES设备台账-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_ledger:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentLedger model) {
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】设备台账保存前校验-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】设备台账保存前校验-----------
|
||||
mesXslEquipmentLedgerService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备台账-编辑")
|
||||
@Operation(summary = "MES设备台账-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_ledger:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentLedger model) {
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】设备台账保存前校验-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】设备台账保存前校验-----------
|
||||
mesXslEquipmentLedgerService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备台账-删除")
|
||||
@Operation(summary = "MES设备台账-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_ledger:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentLedgerService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备台账-批量删除")
|
||||
@Operation(summary = "MES设备台账-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_ledger:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentLedgerService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备台账-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentLedger> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentLedger entity = mesXslEquipmentLedgerService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验设备编号是否重复")
|
||||
@GetMapping(value = "/checkEquipmentCode")
|
||||
public Result<String> checkEquipmentCode(
|
||||
@RequestParam(name = "equipmentCode", required = true) String equipmentCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(equipmentCode) || equipmentCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentLedger ctx = new MesXslEquipmentLedger();
|
||||
if (mesXslEquipmentLedgerService.isEquipmentCodeDuplicated(equipmentCode.trim(), dataId, ctx)) {
|
||||
return Result.error("设备编号不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@Operation(summary = "校验设备名称是否重复")
|
||||
@GetMapping(value = "/checkEquipmentName")
|
||||
public Result<String> checkEquipmentName(
|
||||
@RequestParam(name = "equipmentName", required = true) String equipmentName,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(equipmentName) || equipmentName.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentLedger ctx = new MesXslEquipmentLedger();
|
||||
if (mesXslEquipmentLedgerService.isEquipmentNameDuplicated(equipmentName.trim(), dataId, ctx)) {
|
||||
return Result.error("设备名称不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_ledger:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentLedger model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentLedger.class, "MES设备台账");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_ledger:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
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<MesXslEquipmentLedger> list =
|
||||
ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentLedger.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
Set<String> namesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentLedger row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String err = validateImportRow(row, rowNo, codesInFile, namesInFile);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentLedgerService.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】设备台账保存与导入校验-----------
|
||||
private String validateForSave(MesXslEquipmentLedger model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getProcessOperationId())) {
|
||||
return "请选择所属工序";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentName()) || model.getEquipmentName().trim().isEmpty()) {
|
||||
return "设备名称不能为空";
|
||||
}
|
||||
String name = model.getEquipmentName().trim();
|
||||
model.setEquipmentName(name);
|
||||
if (mesXslEquipmentLedgerService.isEquipmentNameDuplicated(name, excludeId, model)) {
|
||||
return "设备名称不能重复";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCode()) || model.getEquipmentCode().trim().isEmpty()) {
|
||||
return "设备编号不能为空";
|
||||
}
|
||||
String code = model.getEquipmentCode().trim();
|
||||
model.setEquipmentCode(code);
|
||||
if (mesXslEquipmentLedgerService.isEquipmentCodeDuplicated(code, excludeId, model)) {
|
||||
return "设备编号不能重复";
|
||||
}
|
||||
trimRelationNames(model);
|
||||
String status = model.getEquipmentStatus();
|
||||
if (oConvertUtils.isEmpty(status)) {
|
||||
model.setEquipmentStatus("0");
|
||||
} else {
|
||||
status = status.trim();
|
||||
if (!EQUIPMENT_STATUS.contains(status)) {
|
||||
return "设备状态无效(须为在用/停用/报废)";
|
||||
}
|
||||
model.setEquipmentStatus(status);
|
||||
}
|
||||
String enabled = model.getEnabledFlag();
|
||||
if (oConvertUtils.isEmpty(enabled)) {
|
||||
model.setEnabledFlag("1");
|
||||
} else {
|
||||
enabled = enabled.trim();
|
||||
if (!ENABLED_FLAGS.contains(enabled)) {
|
||||
return "是否启用无效(须为是/否)";
|
||||
}
|
||||
model.setEnabledFlag(enabled);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String validateImportRow(MesXslEquipmentLedger row, int rowNo, Set<String> codesInFile, Set<String> namesInFile) {
|
||||
String code = row.getEquipmentCode();
|
||||
if (code != null) {
|
||||
code = code.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条设备编号不能为空";
|
||||
}
|
||||
row.setEquipmentCode(code);
|
||||
if (!codesInFile.add(code)) {
|
||||
return "文件导入失败:设备编号【" + code + "】在导入文件中重复";
|
||||
}
|
||||
if (mesXslEquipmentLedgerService.isEquipmentCodeDuplicated(code, null, row)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条设备编号【" + code + "】不能重复";
|
||||
}
|
||||
String name = row.getEquipmentName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(name)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条设备名称不能为空";
|
||||
}
|
||||
row.setEquipmentName(name);
|
||||
if (!namesInFile.add(name)) {
|
||||
return "文件导入失败:设备名称【" + name + "】在导入文件中重复";
|
||||
}
|
||||
if (mesXslEquipmentLedgerService.isEquipmentNameDuplicated(name, null, row)) {
|
||||
return "文件导入失败:第 " + rowNo + " 条设备名称【" + name + "】不能重复";
|
||||
}
|
||||
trimRelationNames(row);
|
||||
String status = row.getEquipmentStatus();
|
||||
if (oConvertUtils.isEmpty(status)) {
|
||||
row.setEquipmentStatus("0");
|
||||
} else if (!EQUIPMENT_STATUS.contains(status.trim())) {
|
||||
return "文件导入失败:第 " + rowNo + " 条设备状态无效";
|
||||
} else {
|
||||
row.setEquipmentStatus(status.trim());
|
||||
}
|
||||
String enabled = row.getEnabledFlag();
|
||||
if (oConvertUtils.isEmpty(enabled)) {
|
||||
row.setEnabledFlag("1");
|
||||
} else if (!ENABLED_FLAGS.contains(enabled.trim())) {
|
||||
return "文件导入失败:第 " + rowNo + " 条是否启用无效";
|
||||
} else {
|
||||
row.setEnabledFlag(enabled.trim());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void trimRelationNames(MesXslEquipmentLedger model) {
|
||||
if (model.getProcessOperationName() != null) {
|
||||
model.setProcessOperationName(model.getProcessOperationName().trim());
|
||||
}
|
||||
if (model.getManufacturerName() != null) {
|
||||
model.setManufacturerName(model.getManufacturerName().trim());
|
||||
}
|
||||
if (model.getEquipmentCategoryName() != null) {
|
||||
model.setEquipmentCategoryName(model.getEquipmentCategoryName().trim());
|
||||
}
|
||||
if (model.getEquipmentTypeName() != null) {
|
||||
model.setEquipmentTypeName(model.getEquipmentTypeName().trim());
|
||||
}
|
||||
if (model.getFactoryName() != null) {
|
||||
model.setFactoryName(model.getFactoryName().trim());
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】设备台账保存与导入校验-----------
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
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_equipment_ledger)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_ledger")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备台账")
|
||||
public class MesXslEquipmentLedger implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属工序主键")
|
||||
private String processOperationId;
|
||||
|
||||
@Excel(name = "工序名称", width = 20)
|
||||
@Schema(description = "工序名称冗余")
|
||||
private String processOperationName;
|
||||
|
||||
@Excel(name = "设备名称", width = 22)
|
||||
@Schema(description = "设备名称(同租户未删除数据中唯一)")
|
||||
private String equipmentName;
|
||||
|
||||
@Excel(name = "设备编号", width = 18)
|
||||
@Schema(description = "设备编号(同租户未删除数据中唯一)")
|
||||
private String equipmentCode;
|
||||
|
||||
@Schema(description = "所属设备厂家主键")
|
||||
private String manufacturerId;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20)
|
||||
@Schema(description = "设备厂家名称冗余")
|
||||
private String manufacturerName;
|
||||
|
||||
@Schema(description = "设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "设备类别", width = 16)
|
||||
@Schema(description = "设备类别名称冗余")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
@Schema(description = "设备类型主键")
|
||||
private String equipmentTypeId;
|
||||
|
||||
@Excel(name = "设备类型", width = 16)
|
||||
@Schema(description = "设备类型名称冗余")
|
||||
private String equipmentTypeName;
|
||||
|
||||
@Schema(description = "所属工厂主键(厂家信息)")
|
||||
private String factoryId;
|
||||
|
||||
@Excel(name = "所属工厂", width = 20)
|
||||
@Schema(description = "所属工厂名称冗余")
|
||||
private String factoryName;
|
||||
|
||||
@Excel(name = "设备型号", width = 16)
|
||||
@Schema(description = "设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@Excel(name = "设备状态", width = 12, dicCode = "xslmes_equipment_ledger_status")
|
||||
@Dict(dicCode = "xslmes_equipment_ledger_status")
|
||||
@Schema(description = "设备状态(字典:在用/停用/报废)")
|
||||
private String equipmentStatus;
|
||||
|
||||
@Excel(name = "序列号", width = 18)
|
||||
@Schema(description = "序列号")
|
||||
private String serialNo;
|
||||
|
||||
@Excel(name = "铭牌", width = 18)
|
||||
@Schema(description = "铭牌")
|
||||
private String nameplate;
|
||||
|
||||
@Excel(name = "维修部门", width = 16, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
|
||||
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
|
||||
@Schema(description = "维修部门主键")
|
||||
private String maintainDeptId;
|
||||
|
||||
@Excel(name = "维修人员", width = 12)
|
||||
@Schema(description = "维修人员")
|
||||
private String maintainPerson;
|
||||
|
||||
@Excel(name = "主管部门", width = 16, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
|
||||
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
|
||||
@Schema(description = "主管部门主键")
|
||||
private String manageDeptId;
|
||||
|
||||
@Excel(name = "资料文件编号", width = 18)
|
||||
@Schema(description = "资料文件编号")
|
||||
private String docFileNo;
|
||||
|
||||
@Excel(name = "生产日期", width = 14, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "生产日期")
|
||||
private Date productionDate;
|
||||
|
||||
@Excel(name = "购买日期", width = 14, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "购买日期")
|
||||
private Date purchaseDate;
|
||||
|
||||
@Excel(name = "使用日期", width = 14, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "使用日期")
|
||||
private Date useDate;
|
||||
|
||||
@Excel(name = "厂商联系人", width = 14)
|
||||
@Schema(description = "厂商联系人")
|
||||
private String vendorContact;
|
||||
|
||||
@Excel(name = "价值", width = 14)
|
||||
@Schema(description = "价值")
|
||||
private String assetValue;
|
||||
|
||||
@Excel(name = "受控PDA", width = 14)
|
||||
@Schema(description = "受控PDA")
|
||||
private String controlledPda;
|
||||
|
||||
@Excel(name = "超产比率", width = 12)
|
||||
@Schema(description = "超产比率")
|
||||
private String overproductionRatio;
|
||||
|
||||
@Excel(name = "有效体积", width = 12)
|
||||
@Schema(description = "有效体积")
|
||||
private String effectiveVolume;
|
||||
|
||||
@Excel(name = "是否启用", width = 10, dicCode = "yn")
|
||||
@Dict(dicCode = "yn")
|
||||
@Schema(description = "是否启用(字典yn:1是0否)")
|
||||
private String enabledFlag;
|
||||
|
||||
@Excel(name = "设备描述", width = 30)
|
||||
@Schema(description = "设备描述")
|
||||
private String equipmentDesc;
|
||||
|
||||
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,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
||||
|
||||
public interface MesXslEquipmentLedgerMapper extends BaseMapper<MesXslEquipmentLedger> {}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。
|
||||
* 包含:客户管理({@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.MesXslEquipmentLedger})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。
|
||||
*/
|
||||
package org.jeecg.modules.xslmes;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
||||
|
||||
public interface IMesXslEquipmentLedgerService extends IService<MesXslEquipmentLedger> {
|
||||
|
||||
boolean isEquipmentCodeDuplicated(String equipmentCode, String excludeId, MesXslEquipmentLedger context);
|
||||
|
||||
boolean isEquipmentNameDuplicated(String equipmentName, String excludeId, MesXslEquipmentLedger context);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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.MesXslEquipmentLedger;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentLedgerMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentLedgerServiceImpl extends ServiceImpl<MesXslEquipmentLedgerMapper, MesXslEquipmentLedger>
|
||||
implements IMesXslEquipmentLedgerService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260518 for:【MES】设备台账编号、名称同租户不可重复-----------
|
||||
@Override
|
||||
public boolean isEquipmentCodeDuplicated(String equipmentCode, String excludeId, MesXslEquipmentLedger context) {
|
||||
return isFieldDuplicated(MesXslEquipmentLedger::getEquipmentCode, equipmentCode, excludeId, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEquipmentNameDuplicated(String equipmentName, String excludeId, MesXslEquipmentLedger context) {
|
||||
return isFieldDuplicated(MesXslEquipmentLedger::getEquipmentName, equipmentName, excludeId, context);
|
||||
}
|
||||
|
||||
private boolean isFieldDuplicated(
|
||||
com.baomidou.mybatisplus.core.toolkit.support.SFunction<MesXslEquipmentLedger, String> column,
|
||||
String value,
|
||||
String excludeId,
|
||||
MesXslEquipmentLedger context) {
|
||||
if (oConvertUtils.isEmpty(value)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentLedger> w = new LambdaQueryWrapper<>();
|
||||
w.eq(column, value.trim());
|
||||
w.and(q -> q.eq(MesXslEquipmentLedger::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesXslEquipmentLedger::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentLedger::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentLedger::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentLedger context) {
|
||||
if (context != null && context.getTenantId() != null) {
|
||||
return context.getTenantId();
|
||||
}
|
||||
String ts = TenantContext.getTenant();
|
||||
if (oConvertUtils.isEmpty(ts)) {
|
||||
try {
|
||||
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ts)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(ts.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260518 for:【MES】设备台账编号、名称同租户不可重复-----------
|
||||
}
|
||||
Reference in New Issue
Block a user