快检实验方法新增
This commit is contained in:
@@ -1,104 +1,208 @@
|
||||
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.TableLogic;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* MES 胶料快检实验方法主表
|
||||
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
||||
@TableName("mes_xsl_rubber_quick_test_method")
|
||||
|
||||
@Accessors(chain = true)
|
||||
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@Schema(description = "MES胶料快检实验方法")
|
||||
|
||||
public class MesXslRubberQuickTestMethod implements Serializable {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "方法编号", width = 14)
|
||||
|
||||
@Schema(description = "方法编号(租户内从001递增自动生成,只读)")
|
||||
|
||||
private String methodCode;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验方法名称", width = 24)
|
||||
|
||||
@Schema(description = "实验方法名称(同租户未删除唯一)")
|
||||
|
||||
private String methodName;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验类型", width = 20, dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
|
||||
|
||||
@Dict(dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
|
||||
|
||||
@Schema(description = "实验类型ID")
|
||||
|
||||
private String quickTestTypeId;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验类型名称", width = 20)
|
||||
|
||||
@Schema(description = "实验类型名称冗余")
|
||||
|
||||
private String quickTestTypeName;
|
||||
|
||||
|
||||
|
||||
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.TableLogic;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* MES 胶料快检实验方法主表
|
||||
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
||||
@TableName("mes_xsl_rubber_quick_test_method")
|
||||
|
||||
@Accessors(chain = true)
|
||||
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@Schema(description = "MES胶料快检实验方法")
|
||||
|
||||
public class MesXslRubberQuickTestMethod implements Serializable {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "方法编号", width = 14)
|
||||
|
||||
@Schema(description = "方法编号(租户内从001递增自动生成,只读)")
|
||||
|
||||
private String methodCode;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验方法名称", width = 24)
|
||||
|
||||
@Schema(description = "实验方法名称(同租户未删除唯一)")
|
||||
|
||||
private String methodName;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验类型", width = 20, dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
|
||||
|
||||
@Dict(dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
|
||||
|
||||
@Schema(description = "实验类型ID")
|
||||
|
||||
private String quickTestTypeId;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验类型名称", width = 20)
|
||||
|
||||
@Schema(description = "实验类型名称冗余")
|
||||
|
||||
private String quickTestTypeName;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验温度°C", width = 14, type = 10)
|
||||
|
||||
@Schema(description = "实验温度°C")
|
||||
|
||||
private BigDecimal testTempC;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "预热时间min", width = 14, type = 10)
|
||||
|
||||
@Schema(description = "预热时间min")
|
||||
|
||||
private BigDecimal preheatTimeMin;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验时间min", width = 14, type = 10)
|
||||
|
||||
@Schema(description = "实验时间min")
|
||||
|
||||
private BigDecimal testTimeMin;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验角度Deg", width = 14, type = 10)
|
||||
|
||||
@Schema(description = "实验角度Deg")
|
||||
|
||||
private BigDecimal testAngleDeg;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "实验频率Hz", width = 14, type = 10)
|
||||
|
||||
@Schema(description = "实验频率Hz")
|
||||
|
||||
private BigDecimal testFreqHz;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "转子类型", width = 12, dicCode = "xslmes_rubber_quick_test_rotor_type")
|
||||
|
||||
@Dict(dicCode = "xslmes_rubber_quick_test_rotor_type")
|
||||
|
||||
@Schema(description = "转子类型(字典xslmes_rubber_quick_test_rotor_type)")
|
||||
|
||||
private String rotorType;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "转子速度rpm", width = 14, type = 10)
|
||||
|
||||
@Schema(description = "转子速度rpm")
|
||||
|
||||
private BigDecimal rotorSpeedRpm;
|
||||
|
||||
|
||||
|
||||
@Excel(name = "方法描述", width = 40)
|
||||
|
||||
@Schema(description = "方法描述")
|
||||
|
||||
private String methodDesc;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
@TableLogic
|
||||
|
||||
@Schema(description = "删除状态(0正常 1已删除)")
|
||||
|
||||
private Integer delFlag;
|
||||
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
|
||||
@Schema(description = "数据点明细")
|
||||
|
||||
private List<MesXslRubberQuickTestMethodLine> lineList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,64 +1,128 @@
|
||||
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.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* MES 胶料快检实验方法明细
|
||||
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
||||
@TableName("mes_xsl_rubber_quick_test_method_line")
|
||||
|
||||
@Accessors(chain = true)
|
||||
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@Schema(description = "MES胶料快检实验方法明细")
|
||||
|
||||
public class MesXslRubberQuickTestMethodLine implements Serializable {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "主表主键 mes_xsl_rubber_quick_test_method.id")
|
||||
|
||||
private String methodId;
|
||||
|
||||
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.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* MES 胶料快检实验方法明细
|
||||
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
||||
@TableName("mes_xsl_rubber_quick_test_method_line")
|
||||
|
||||
@Accessors(chain = true)
|
||||
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
||||
@Schema(description = "MES胶料快检实验方法明细")
|
||||
|
||||
public class MesXslRubberQuickTestMethodLine implements Serializable {
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "主表主键 mes_xsl_rubber_quick_test_method.id")
|
||||
|
||||
private String methodId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "数据点主键 mes_xsl_rubber_quick_test_data_point.id")
|
||||
|
||||
private String dataPointId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "数据点名称冗余(只读带出)")
|
||||
|
||||
private String pointName;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "单位类型冗余(只读带出)")
|
||||
|
||||
private String unitType;
|
||||
|
||||
|
||||
|
||||
@Dict(dicCode = "xslmes_rubber_quick_test_torque_unit")
|
||||
|
||||
@Schema(description = "扭矩单位类型")
|
||||
|
||||
private String torqueUnitType;
|
||||
|
||||
|
||||
|
||||
@Dict(dicCode = "xslmes_rubber_quick_test_time_unit")
|
||||
|
||||
@Schema(description = "时间单位类型")
|
||||
|
||||
private String timeUnitType;
|
||||
|
||||
|
||||
|
||||
@Dict(dicCode = "xslmes_rubber_quick_test_mooney_unit")
|
||||
|
||||
@Schema(description = "门尼单位类型")
|
||||
|
||||
private String mooneyUnitType;
|
||||
|
||||
|
||||
|
||||
private Integer sortNo;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
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.MesXslRubberQuickTestMethodLine;
|
||||
|
||||
|
||||
|
||||
@Mapper
|
||||
|
||||
public interface MesXslRubberQuickTestMethodLineMapper extends BaseMapper<MesXslRubberQuickTestMethodLine> {}
|
||||
|
||||
|
||||
@@ -1,19 +1,38 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
|
||||
|
||||
@Mapper
|
||||
|
||||
public interface MesXslRubberQuickTestMethodMapper extends BaseMapper<MesXslRubberQuickTestMethod> {
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
|
||||
|
||||
@Mapper
|
||||
|
||||
public interface MesXslRubberQuickTestMethodMapper extends BaseMapper<MesXslRubberQuickTestMethod> {
|
||||
|
||||
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260522 for:【MES】胶料快检实验方法租户内最大三位数字编号-----------
|
||||
|
||||
@Select(
|
||||
|
||||
"SELECT IFNULL(MAX(CAST(method_code AS UNSIGNED)), 0) FROM mes_xsl_rubber_quick_test_method "
|
||||
|
||||
+ "WHERE del_flag = 0 AND method_code REGEXP '^[0-9]+$' "
|
||||
|
||||
+ "AND (#{tenantId} IS NULL OR tenant_id = #{tenantId})")
|
||||
|
||||
Integer selectMaxNumericMethodCode(@Param("tenantId") Integer tenantId);
|
||||
|
||||
//update-end---author:jiangxh ---date:20260522 for:【MES】胶料快检实验方法租户内最大三位数字编号-----------
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,50 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
|
||||
|
||||
|
||||
|
||||
public interface IMesXslRubberQuickTestMethodService extends IService<MesXslRubberQuickTestMethod> {
|
||||
|
||||
|
||||
|
||||
String generateNextMethodCode(MesXslRubberQuickTestMethod context);
|
||||
|
||||
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
|
||||
|
||||
|
||||
|
||||
public interface IMesXslRubberQuickTestMethodService extends IService<MesXslRubberQuickTestMethod> {
|
||||
|
||||
|
||||
|
||||
String generateNextMethodCode(MesXslRubberQuickTestMethod context);
|
||||
|
||||
|
||||
|
||||
boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context);
|
||||
|
||||
|
||||
|
||||
void saveMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList);
|
||||
|
||||
|
||||
|
||||
void updateMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList);
|
||||
|
||||
|
||||
|
||||
void delMain(String id);
|
||||
|
||||
|
||||
|
||||
void delBatchMain(Collection<? extends Serializable> idList);
|
||||
|
||||
|
||||
|
||||
List<MesXslRubberQuickTestMethodLine> selectLinesByMethodId(String methodId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,166 +1,332 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
|
||||
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodLineMapper;
|
||||
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodMapper;
|
||||
|
||||
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestMethodService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
|
||||
public class MesXslRubberQuickTestMethodServiceImpl
|
||||
|
||||
extends ServiceImpl<MesXslRubberQuickTestMethodMapper, MesXslRubberQuickTestMethod>
|
||||
|
||||
implements IMesXslRubberQuickTestMethodService {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
|
||||
private MesXslRubberQuickTestMethodLineMapper mesXslRubberQuickTestMethodLineMapper;
|
||||
|
||||
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260522 for:【MES】胶料快检实验方法编号001递增、名称同租户唯一、主子保存-----------
|
||||
|
||||
@Override
|
||||
|
||||
public String generateNextMethodCode(MesXslRubberQuickTestMethod context) {
|
||||
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
|
||||
Integer max = baseMapper.selectMaxNumericMethodCode(tenantId);
|
||||
|
||||
int next = (max == null ? 0 : max) + 1;
|
||||
|
||||
if (next > 999) {
|
||||
|
||||
throw new IllegalStateException("实验方法编号已超过999,请联系管理员");
|
||||
|
||||
}
|
||||
|
||||
return String.format("%03d", next);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context) {
|
||||
|
||||
if (oConvertUtils.isEmpty(methodName)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
|
||||
LambdaQueryWrapper<MesXslRubberQuickTestMethod> w = new LambdaQueryWrapper<>();
|
||||
|
||||
w.eq(MesXslRubberQuickTestMethod::getMethodName, methodName.trim());
|
||||
|
||||
w.and(
|
||||
|
||||
q ->
|
||||
|
||||
q.eq(MesXslRubberQuickTestMethod::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
|
||||
.or()
|
||||
|
||||
.isNull(MesXslRubberQuickTestMethod::getDelFlag));
|
||||
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
|
||||
w.ne(MesXslRubberQuickTestMethod::getId, excludeId);
|
||||
|
||||
}
|
||||
|
||||
if (tenantId != null) {
|
||||
|
||||
w.eq(MesXslRubberQuickTestMethod::getTenantId, tenantId);
|
||||
|
||||
}
|
||||
|
||||
return this.count(w) > 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void saveMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
|
||||
|
||||
assertMethodNameUniqueForSave(main, null);
|
||||
|
||||
if (oConvertUtils.isEmpty(main.getMethodCode())) {
|
||||
|
||||
main.setMethodCode(generateNextMethodCode(main));
|
||||
|
||||
}
|
||||
|
||||
this.save(main);
|
||||
|
||||
insertLines(main.getId(), lineList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void updateMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
|
||||
|
||||
if (oConvertUtils.isEmpty(main.getId())) {
|
||||
|
||||
throw new JeecgBootException("缺少主键");
|
||||
|
||||
}
|
||||
|
||||
MesXslRubberQuickTestMethod old = this.getById(main.getId());
|
||||
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
|
||||
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodLineMapper;
|
||||
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodMapper;
|
||||
|
||||
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestMethodService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
|
||||
@Service
|
||||
|
||||
public class MesXslRubberQuickTestMethodServiceImpl
|
||||
|
||||
extends ServiceImpl<MesXslRubberQuickTestMethodMapper, MesXslRubberQuickTestMethod>
|
||||
|
||||
implements IMesXslRubberQuickTestMethodService {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
|
||||
private MesXslRubberQuickTestMethodLineMapper mesXslRubberQuickTestMethodLineMapper;
|
||||
|
||||
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260522 for:【MES】胶料快检实验方法编号001递增、名称同租户唯一、主子保存-----------
|
||||
|
||||
@Override
|
||||
|
||||
public String generateNextMethodCode(MesXslRubberQuickTestMethod context) {
|
||||
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
|
||||
Integer max = baseMapper.selectMaxNumericMethodCode(tenantId);
|
||||
|
||||
int next = (max == null ? 0 : max) + 1;
|
||||
|
||||
if (next > 999) {
|
||||
|
||||
throw new IllegalStateException("实验方法编号已超过999,请联系管理员");
|
||||
|
||||
}
|
||||
|
||||
return String.format("%03d", next);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context) {
|
||||
|
||||
if (oConvertUtils.isEmpty(methodName)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
|
||||
LambdaQueryWrapper<MesXslRubberQuickTestMethod> w = new LambdaQueryWrapper<>();
|
||||
|
||||
w.eq(MesXslRubberQuickTestMethod::getMethodName, methodName.trim());
|
||||
|
||||
w.and(
|
||||
|
||||
q ->
|
||||
|
||||
q.eq(MesXslRubberQuickTestMethod::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
|
||||
.or()
|
||||
|
||||
.isNull(MesXslRubberQuickTestMethod::getDelFlag));
|
||||
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
|
||||
w.ne(MesXslRubberQuickTestMethod::getId, excludeId);
|
||||
|
||||
}
|
||||
|
||||
if (tenantId != null) {
|
||||
|
||||
w.eq(MesXslRubberQuickTestMethod::getTenantId, tenantId);
|
||||
|
||||
}
|
||||
|
||||
return this.count(w) > 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void saveMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
|
||||
|
||||
assertMethodNameUniqueForSave(main, null);
|
||||
|
||||
if (oConvertUtils.isEmpty(main.getMethodCode())) {
|
||||
|
||||
main.setMethodCode(generateNextMethodCode(main));
|
||||
|
||||
}
|
||||
|
||||
this.save(main);
|
||||
|
||||
insertLines(main.getId(), lineList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void updateMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
|
||||
|
||||
if (oConvertUtils.isEmpty(main.getId())) {
|
||||
|
||||
throw new JeecgBootException("缺少主键");
|
||||
|
||||
}
|
||||
|
||||
MesXslRubberQuickTestMethod old = this.getById(main.getId());
|
||||
|
||||
if (old == null) {
|
||||
|
||||
throw new JeecgBootException("实验方法不存在");
|
||||
|
||||
}
|
||||
|
||||
main.setMethodCode(old.getMethodCode());
|
||||
|
||||
assertMethodNameUniqueForSave(main, main.getId());
|
||||
|
||||
this.updateById(main);
|
||||
|
||||
mesXslRubberQuickTestMethodLineMapper.delete(
|
||||
|
||||
new LambdaQueryWrapper<MesXslRubberQuickTestMethodLine>()
|
||||
|
||||
.eq(MesXslRubberQuickTestMethodLine::getMethodId, main.getId()));
|
||||
|
||||
insertLines(main.getId(), lineList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void insertLines(String methodId, List<MesXslRubberQuickTestMethodLine> lineList) {
|
||||
|
||||
if (CollectionUtils.isEmpty(lineList)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int sort = 0;
|
||||
|
||||
for (MesXslRubberQuickTestMethodLine line : lineList) {
|
||||
|
||||
line.setId(null);
|
||||
|
||||
line.setMethodId(methodId);
|
||||
|
||||
line.setSortNo(sort++);
|
||||
|
||||
mesXslRubberQuickTestMethodLineMapper.insert(line);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void delMain(String id) {
|
||||
|
||||
mesXslRubberQuickTestMethodLineMapper.delete(
|
||||
|
||||
new LambdaQueryWrapper<MesXslRubberQuickTestMethodLine>()
|
||||
|
||||
.eq(MesXslRubberQuickTestMethodLine::getMethodId, id));
|
||||
|
||||
this.removeById(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void delBatchMain(Collection<? extends Serializable> idList) {
|
||||
|
||||
for (Serializable id : idList) {
|
||||
|
||||
delMain(id.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public List<MesXslRubberQuickTestMethodLine> selectLinesByMethodId(String methodId) {
|
||||
|
||||
return mesXslRubberQuickTestMethodLineMapper.selectList(
|
||||
|
||||
new LambdaQueryWrapper<MesXslRubberQuickTestMethodLine>()
|
||||
|
||||
.eq(MesXslRubberQuickTestMethodLine::getMethodId, methodId)
|
||||
|
||||
.orderByAsc(MesXslRubberQuickTestMethodLine::getSortNo));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void assertMethodNameUniqueForSave(MesXslRubberQuickTestMethod entity, String excludeId) {
|
||||
|
||||
if (entity == null || oConvertUtils.isEmpty(entity.getMethodName())) {
|
||||
|
||||
throw new JeecgBootException("实验方法名称不能为空");
|
||||
|
||||
}
|
||||
|
||||
String name = entity.getMethodName().trim();
|
||||
|
||||
entity.setMethodName(name);
|
||||
|
||||
if (isMethodNameDuplicated(name, excludeId, entity)) {
|
||||
|
||||
throw new JeecgBootException("实验方法名称已存在");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static Integer resolveTenantId(MesXslRubberQuickTestMethod 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:20260522 for:【MES】胶料快检实验方法编号001递增、名称同租户唯一、主子保存-----------
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
|
||||
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 胶料快检实验方法主子保存页 VO
|
||||
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
public class MesXslRubberQuickTestMethodPage extends MesXslRubberQuickTestMethod {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user