mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-24 23:41:21 +08:00
google 代码格式化
This commit is contained in:
1
.mvn/jvm.config
Normal file
1
.mvn/jvm.config
Normal file
@@ -0,0 +1 @@
|
||||
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||
91
pom.xml
91
pom.xml
@@ -15,67 +15,10 @@
|
||||
<description>coal</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<git-code-format-maven-plugin.version>4.2</git-code-format-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>build</id>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>aliyun</id>
|
||||
<url>http://192.168.0.118:8081/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<releases>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
<enabled>false</enabled>
|
||||
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<releases>
|
||||
<updatePolicy>never</updatePolicy>
|
||||
<enabled>false</enabled>
|
||||
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>aliyun</id>
|
||||
<url>http://192.168.0.118:8081/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<repositories>
|
||||
|
||||
@@ -382,6 +325,38 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>com.cosium.code</groupId>
|
||||
<artifactId>git-code-format-maven-plugin</artifactId>
|
||||
<version>${git-code-format-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<!-- On commit, format the modified files -->
|
||||
<execution>
|
||||
<id>install-formatter-hook</id>
|
||||
<goals>
|
||||
<goal>install-hooks</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!-- On Maven verify phase, fail if any file
|
||||
(including unmodified) is badly formatted -->
|
||||
<execution>
|
||||
<id>validate-code-format</id>
|
||||
<goals>
|
||||
<goal>validate-code-format</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<!-- Enable https://github.com/google/google-java-format -->
|
||||
<dependency>
|
||||
<groupId>com.cosium.code</groupId>
|
||||
<artifactId>google-java-format</artifactId>
|
||||
<version>${git-code-format-maven-plugin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -8,11 +8,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
@EnableJpaRepositories
|
||||
public class CoalApplication {
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoalApplication.class, args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoalApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ import cn.lihongjie.coal.base.service.BaseService;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.squareup.javapoet.*;
|
||||
import jakarta.persistence.Entity;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
import java.util.Scanner;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import lombok.Data;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -33,316 +37,332 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Codegen {
|
||||
|
||||
public static final Path DIRECTORY = Path.of("src/main/java/");
|
||||
public static final Path DIRECTORY = Path.of("src/main/java/");
|
||||
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
System.out.print("请输入模块名:");
|
||||
String moduleName = new Scanner(System.in).nextLine();
|
||||
@SneakyThrows
|
||||
public static void main(String[] args) {
|
||||
System.out.print("请输入模块名:");
|
||||
String moduleName = new Scanner(System.in).nextLine();
|
||||
|
||||
System.out.print("请输入模块中文名:");
|
||||
String moduleCNName = new Scanner(System.in).nextLine();
|
||||
System.out.print("请输入模块中文名:");
|
||||
String moduleCNName = new Scanner(System.in).nextLine();
|
||||
|
||||
System.out.print("机构数据[Y]:");
|
||||
boolean orgMode =
|
||||
Objects.equals(StringUtils.defaultIfBlank(new Scanner(System.in).nextLine(), "Y"), "Y");
|
||||
|
||||
System.out.print("机构数据[Y]:");
|
||||
boolean orgMode = Objects.equals(StringUtils.defaultIfBlank(new Scanner(System.in).nextLine(), "Y"), "Y");
|
||||
String lModuleName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, moduleName);
|
||||
String prefix = Codegen.class.getPackage().getName() + "." + lModuleName;
|
||||
String entityPackage = prefix + ".entity";
|
||||
String dtoPackage = prefix + ".dto";
|
||||
String repoPackage = prefix + ".repository";
|
||||
String mapperPackage = prefix + ".mapper";
|
||||
String servicePackage = prefix + ".service";
|
||||
String controllerPackage = prefix + ".controller";
|
||||
|
||||
// 生成entity
|
||||
|
||||
String lModuleName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, moduleName);
|
||||
String prefix = Codegen.class.getPackage().getName() + "." + lModuleName;
|
||||
String entityPackage = prefix + ".entity";
|
||||
String dtoPackage = prefix + ".dto";
|
||||
String repoPackage = prefix + ".repository";
|
||||
String mapperPackage = prefix + ".mapper";
|
||||
String servicePackage = prefix + ".service";
|
||||
String controllerPackage = prefix + ".controller";
|
||||
TypeSpec entity =
|
||||
TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Entity")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonEntity.class : CommonEntity.class)
|
||||
.addAnnotation(Data.class)
|
||||
.addAnnotation(Entity.class)
|
||||
.build();
|
||||
|
||||
// 生成entity
|
||||
JavaFile.builder(entityPackage, entity).build().writeTo(DIRECTORY);
|
||||
|
||||
// 生成dto
|
||||
TypeSpec dto =
|
||||
TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Dto")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonDto.class : CommonDto.class)
|
||||
.addAnnotation(Data.class)
|
||||
.build();
|
||||
|
||||
TypeSpec entity = TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Entity")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonEntity.class: CommonEntity.class)
|
||||
.addAnnotation(Data.class)
|
||||
.addAnnotation(Entity.class)
|
||||
JavaFile.builder(dtoPackage, dto).build().writeTo(DIRECTORY);
|
||||
|
||||
.build();
|
||||
// 生成createDto
|
||||
TypeSpec createDto =
|
||||
TypeSpec.classBuilder("Create" + StringUtils.capitalize(moduleName) + "Dto")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonDto.class : CommonDto.class)
|
||||
.addAnnotation(Data.class)
|
||||
.build();
|
||||
|
||||
JavaFile.builder(entityPackage, entity)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
JavaFile.builder(dtoPackage, createDto).build().writeTo(DIRECTORY);
|
||||
|
||||
// 生成updateDto
|
||||
TypeSpec updateDto =
|
||||
TypeSpec.classBuilder("Update" + StringUtils.capitalize(moduleName) + "Dto")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonDto.class : CommonDto.class)
|
||||
.addAnnotation(Data.class)
|
||||
.build();
|
||||
|
||||
// 生成dto
|
||||
TypeSpec dto = TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Dto")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonDto.class:CommonDto.class)
|
||||
.addAnnotation(Data.class)
|
||||
JavaFile.builder(dtoPackage, updateDto).build().writeTo(DIRECTORY);
|
||||
|
||||
.build();
|
||||
// 生成repository
|
||||
TypeSpec repository =
|
||||
TypeSpec.interfaceBuilder(StringUtils.capitalize(moduleName) + "Repository")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(Repository.class)
|
||||
.addSuperinterface(
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get(BaseRepository.class), ClassName.get(entityPackage, entity.name)))
|
||||
.build();
|
||||
|
||||
JavaFile.builder(dtoPackage, dto)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
JavaFile.builder(repoPackage, repository).build().writeTo(DIRECTORY);
|
||||
|
||||
// 生成mapper
|
||||
TypeSpec mapper =
|
||||
TypeSpec.interfaceBuilder(StringUtils.capitalize(moduleName) + "Mapper")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(Mapper.class)
|
||||
.addMember(
|
||||
"componentModel",
|
||||
"org.mapstruct.MappingConstants.ComponentModel.SPRING",
|
||||
"")
|
||||
.addMember("uses", "{$T.class}", CommonMapper.class)
|
||||
.addMember("mappingControl", "$T.class", DeepClone.class)
|
||||
.build())
|
||||
.addSuperinterface(
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get(BaseMapper.class),
|
||||
ClassName.get(entityPackage, entity.name),
|
||||
ClassName.get(dtoPackage, dto.name),
|
||||
ClassName.get(dtoPackage, createDto.name),
|
||||
ClassName.get(dtoPackage, updateDto.name)))
|
||||
.build();
|
||||
|
||||
// 生成createDto
|
||||
TypeSpec createDto = TypeSpec.classBuilder("Create" + StringUtils.capitalize(moduleName) + "Dto")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonDto.class:CommonDto.class)
|
||||
.addAnnotation(Data.class)
|
||||
JavaFile.builder(mapperPackage, mapper).build().writeTo(DIRECTORY);
|
||||
|
||||
.build();
|
||||
|
||||
JavaFile.builder(dtoPackage, createDto)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
|
||||
|
||||
// 生成updateDto
|
||||
TypeSpec updateDto = TypeSpec.classBuilder("Update" + StringUtils.capitalize(moduleName) + "Dto")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(orgMode ? OrgCommonDto.class:CommonDto.class)
|
||||
.addAnnotation(Data.class)
|
||||
|
||||
.build();
|
||||
|
||||
JavaFile.builder(dtoPackage, updateDto)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
|
||||
|
||||
// 生成repository
|
||||
TypeSpec repository = TypeSpec.interfaceBuilder(StringUtils.capitalize(moduleName) + "Repository")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(Repository.class)
|
||||
.addSuperinterface(ParameterizedTypeName.get(ClassName.get(BaseRepository.class), ClassName.get(entityPackage, entity.name)))
|
||||
.build();
|
||||
|
||||
|
||||
JavaFile.builder(repoPackage, repository)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
|
||||
|
||||
// 生成mapper
|
||||
TypeSpec mapper = TypeSpec.interfaceBuilder(StringUtils.capitalize(moduleName) + "Mapper")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(AnnotationSpec.builder(Mapper.class)
|
||||
.addMember("componentModel", "org.mapstruct.MappingConstants.ComponentModel.SPRING", "")
|
||||
.addMember("uses", "{$T.class}", CommonMapper.class)
|
||||
.addMember("mappingControl", "$T.class", DeepClone.class)
|
||||
|
||||
.build())
|
||||
.addSuperinterface(ParameterizedTypeName.get(
|
||||
ClassName.get(BaseMapper.class),
|
||||
ClassName.get(entityPackage, entity.name),
|
||||
ClassName.get(dtoPackage, dto.name),
|
||||
ClassName.get(dtoPackage, createDto.name),
|
||||
ClassName.get(dtoPackage, updateDto.name)
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
)
|
||||
.build();
|
||||
|
||||
|
||||
JavaFile.builder(mapperPackage, mapper)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
|
||||
|
||||
// 生成service
|
||||
TypeSpec service = TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Service")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(Service.class)
|
||||
.addAnnotation(Slf4j.class)
|
||||
.superclass(ParameterizedTypeName.get(
|
||||
ClassName.get(BaseService.class),
|
||||
ClassName.get(entityPackage, entity.name),
|
||||
ClassName.get(repoPackage, repository.name)
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
)
|
||||
.addField(FieldSpec.builder(ClassName.get(repoPackage, repository.name), "repository", Modifier.PRIVATE).addAnnotation(Autowired.class).build())
|
||||
.addField(FieldSpec.builder(ClassName.get(mapperPackage, mapper.name), "mapper", Modifier.PRIVATE).addAnnotation(Autowired.class).build())
|
||||
.addField(FieldSpec.builder(ClassName.get(ConversionService.class), "conversionService", Modifier.PRIVATE).addAnnotation(Autowired.class).build())
|
||||
.addMethod(MethodSpec.methodBuilder("create")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(dtoPackage, createDto.name), "request")
|
||||
.addStatement("""
|
||||
// 生成service
|
||||
TypeSpec service =
|
||||
TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Service")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(Service.class)
|
||||
.addAnnotation(Slf4j.class)
|
||||
.superclass(
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get(BaseService.class),
|
||||
ClassName.get(entityPackage, entity.name),
|
||||
ClassName.get(repoPackage, repository.name)))
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
ClassName.get(repoPackage, repository.name), "repository", Modifier.PRIVATE)
|
||||
.addAnnotation(Autowired.class)
|
||||
.build())
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
ClassName.get(mapperPackage, mapper.name), "mapper", Modifier.PRIVATE)
|
||||
.addAnnotation(Autowired.class)
|
||||
.build())
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
ClassName.get(ConversionService.class),
|
||||
"conversionService",
|
||||
Modifier.PRIVATE)
|
||||
.addAnnotation(Autowired.class)
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("create")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(dtoPackage, createDto.name), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
$T entity = mapper.toEntity(request);
|
||||
|
||||
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId())
|
||||
""", ClassName.get(entityPackage, entity.name))
|
||||
|
||||
.build()
|
||||
)
|
||||
.addMethod(MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(dtoPackage, updateDto.name), "request")
|
||||
.addStatement("""
|
||||
""",
|
||||
ClassName.get(entityPackage, entity.name))
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(dtoPackage, updateDto.name), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
$T entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
|
||||
return getById(entity.getId())
|
||||
""", ClassName.get(entityPackage, entity.name))
|
||||
.build()
|
||||
)
|
||||
|
||||
.addMethod(MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "request")
|
||||
.addStatement("""
|
||||
""",
|
||||
ClassName.get(entityPackage, entity.name))
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(void.class)
|
||||
.addParameter(ClassName.get(IdRequest.class), "request")
|
||||
.addStatement(
|
||||
"""
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
""")
|
||||
.build()
|
||||
)
|
||||
.addMethod(MethodSpec.methodBuilder("getById")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(String.class), "id")
|
||||
.addStatement("""
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("getById")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addParameter(ClassName.get(String.class), "id")
|
||||
.addStatement(
|
||||
"""
|
||||
$T entity = repository.get(id);
|
||||
|
||||
|
||||
|
||||
|
||||
return mapper.toDto(entity)
|
||||
""", ClassName.get(entityPackage, entity.name))
|
||||
.build()
|
||||
)
|
||||
.addMethod(MethodSpec.methodBuilder("list")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(ParameterizedTypeName.get(ClassName.get(Page.class), ClassName.get(dtoPackage, dto.name)))
|
||||
.addParameter(ClassName.get(CommonQuery.class), "query")
|
||||
.addStatement(
|
||||
"""
|
||||
""",
|
||||
ClassName.get(entityPackage, entity.name))
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("list")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get(Page.class), ClassName.get(dtoPackage, dto.name)))
|
||||
.addParameter(ClassName.get(CommonQuery.class), "query")
|
||||
.addStatement(
|
||||
"""
|
||||
$T<$T> page = repository.findAll(query.specification(conversionService), $T.of(query.getPageNo(), query.getPageSize(), $T.by(query.getOrders())));
|
||||
|
||||
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto)
|
||||
""", ClassName.get(Page.class),ClassName.get(entityPackage, entity.name), ClassName.get(PageRequest.class), ClassName.get(Sort.class))
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
""",
|
||||
ClassName.get(Page.class),
|
||||
ClassName.get(entityPackage, entity.name),
|
||||
ClassName.get(PageRequest.class),
|
||||
ClassName.get(Sort.class))
|
||||
.build())
|
||||
.build();
|
||||
|
||||
JavaFile.builder(servicePackage, service).build().writeTo(DIRECTORY);
|
||||
|
||||
JavaFile.builder(servicePackage, service)
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
// 生成controller
|
||||
TypeSpec.Builder controllerBuilder =
|
||||
TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Controller")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(RestController.class)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(RequestMapping.class)
|
||||
.addMember("value", "$S", "/" + lModuleName)
|
||||
.build())
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(SysLog.class)
|
||||
.addMember("module", "$S", StringUtils.defaultIfBlank(moduleCNName, ""))
|
||||
.build())
|
||||
.addAnnotation(Slf4j.class);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 生成controller
|
||||
TypeSpec.Builder controllerBuilder = TypeSpec.classBuilder(StringUtils.capitalize(moduleName) + "Controller")
|
||||
if (orgMode) {
|
||||
controllerBuilder.addAnnotation(OrgScope.class);
|
||||
}
|
||||
controllerBuilder
|
||||
.addField(
|
||||
FieldSpec.builder(
|
||||
ClassName.get(servicePackage, service.name), "service", Modifier.PRIVATE)
|
||||
.addAnnotation(Autowired.class)
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("create")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addAnnotation(RestController.class)
|
||||
.addAnnotation(AnnotationSpec.builder(RequestMapping.class).addMember("value", "$S", "/" + lModuleName).build())
|
||||
.addAnnotation(AnnotationSpec.builder(SysLog.class).addMember("module", "$S", StringUtils.defaultIfBlank(moduleCNName, "")).build())
|
||||
.addAnnotation(Slf4j.class);
|
||||
|
||||
if(orgMode) {
|
||||
controllerBuilder.addAnnotation(OrgScope.class);
|
||||
}
|
||||
controllerBuilder.addField(FieldSpec.builder(ClassName.get(servicePackage, service.name), "service", Modifier.PRIVATE).addAnnotation(Autowired.class).build())
|
||||
.addMethod(MethodSpec.methodBuilder("create")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addAnnotation(AnnotationSpec.builder(PostMapping.class).addMember("value", "$S", "/create").build())
|
||||
|
||||
.addParameter(ParameterSpec.builder(ClassName.get(dtoPackage, createDto.name), "request").addAnnotation(RequestBody.class).build())
|
||||
.addStatement("""
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/create")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(ClassName.get(dtoPackage, createDto.name), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
return this.service.create(request)
|
||||
""")
|
||||
|
||||
.build()
|
||||
)
|
||||
.addMethod(MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addAnnotation(AnnotationSpec.builder(PostMapping.class).addMember("value", "$S", "/update").build())
|
||||
|
||||
.addParameter(ParameterSpec.builder(ClassName.get(dtoPackage, updateDto.name), "request").addAnnotation(RequestBody.class).build())
|
||||
.addStatement("""
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("update")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/update")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(ClassName.get(dtoPackage, updateDto.name), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
return this.service.update(request)
|
||||
""")
|
||||
.build()
|
||||
)
|
||||
|
||||
.addMethod(MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(Object.class)
|
||||
.addAnnotation(AnnotationSpec.builder(PostMapping.class).addMember("value", "$S", "/delete").build())
|
||||
|
||||
.addParameter(ParameterSpec.builder(ClassName.get(IdRequest.class), "request").addAnnotation(RequestBody.class).build())
|
||||
.addStatement("""
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("delete")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(Object.class)
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/delete")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(ClassName.get(IdRequest.class), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
this.service.delete(request);
|
||||
return true
|
||||
""")
|
||||
.build()
|
||||
)
|
||||
.addMethod(MethodSpec.methodBuilder("getById")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addAnnotation(AnnotationSpec.builder(PostMapping.class).addMember("value", "$S", "/getById").build())
|
||||
|
||||
.addParameter(ParameterSpec.builder(ClassName.get(String.class), "request").addAnnotation(RequestBody.class).build())
|
||||
.addStatement("""
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("getById")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ClassName.get(dtoPackage, dto.name))
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/getById")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(ClassName.get(String.class), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
return this.service.getById(request)
|
||||
""")
|
||||
.build()
|
||||
)
|
||||
.addMethod(MethodSpec.methodBuilder("list")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
|
||||
.returns(ParameterizedTypeName.get(ClassName.get(Page.class), ClassName.get(dtoPackage, dto.name)))
|
||||
.addAnnotation(AnnotationSpec.builder(PostMapping.class).addMember("value", "$S", "/list").build())
|
||||
|
||||
.addParameter(ParameterSpec.builder(ClassName.get(CommonQuery.class), "request").addAnnotation(RequestBody.class).build())
|
||||
.addStatement(
|
||||
"""
|
||||
.build())
|
||||
.addMethod(
|
||||
MethodSpec.methodBuilder("list")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get(Page.class), ClassName.get(dtoPackage, dto.name)))
|
||||
.addAnnotation(
|
||||
AnnotationSpec.builder(PostMapping.class)
|
||||
.addMember("value", "$S", "/list")
|
||||
.build())
|
||||
.addParameter(
|
||||
ParameterSpec.builder(ClassName.get(CommonQuery.class), "request")
|
||||
.addAnnotation(RequestBody.class)
|
||||
.build())
|
||||
.addStatement(
|
||||
"""
|
||||
return this.service.list(request)
|
||||
""", ClassName.get(Page.class), ClassName.get(entityPackage, entity.name), ClassName.get(PageRequest.class), ClassName.get(Sort.class))
|
||||
.build()
|
||||
)
|
||||
;
|
||||
""",
|
||||
ClassName.get(Page.class),
|
||||
ClassName.get(entityPackage, entity.name),
|
||||
ClassName.get(PageRequest.class),
|
||||
ClassName.get(Sort.class))
|
||||
.build());
|
||||
|
||||
|
||||
|
||||
JavaFile.builder(controllerPackage, controllerBuilder.build())
|
||||
.build()
|
||||
.writeTo(DIRECTORY);
|
||||
|
||||
|
||||
|
||||
}
|
||||
JavaFile.builder(controllerPackage, controllerBuilder.build()).build().writeTo(DIRECTORY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -10,10 +9,5 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface Anonymous {
|
||||
|
||||
boolean value() default true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -10,10 +9,5 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface OrgAdmin {
|
||||
|
||||
boolean value() default true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -10,10 +9,5 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface OrgScope {
|
||||
|
||||
boolean value() default true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -10,10 +9,5 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface SysAdmin {
|
||||
|
||||
boolean value() default true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -10,14 +9,9 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
public @interface SysLog {
|
||||
|
||||
String module() default "";
|
||||
|
||||
String action() default "";
|
||||
|
||||
|
||||
String message() default "";
|
||||
|
||||
|
||||
String module() default "";
|
||||
|
||||
String action() default "";
|
||||
|
||||
String message() default "";
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package cn.lihongjie.coal.aop;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.common.RequestUtils;
|
||||
import cn.lihongjie.coal.ip.IpQueryService;
|
||||
import cn.lihongjie.coal.syslog.entity.SysLogEntity;
|
||||
import cn.lihongjie.coal.session.SessionService;
|
||||
import cn.lihongjie.coal.syslog.entity.SysLogEntity;
|
||||
import cn.lihongjie.coal.syslog.service.SysLogService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -22,134 +24,109 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ControllerAop {
|
||||
|
||||
@Pointcut("execution (* cn.lihongjie.coal.*.controller.*.*(..))")
|
||||
public void controllerMethods() {}
|
||||
|
||||
@Pointcut("execution (* cn.lihongjie.coal.*.controller.*.*(..))")
|
||||
public void controllerMethods() {
|
||||
@Autowired SessionService sessionService;
|
||||
|
||||
@SneakyThrows
|
||||
@Around("controllerMethods()")
|
||||
public Object call(ProceedingJoinPoint proceedingJoinPoint) {
|
||||
|
||||
Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod();
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
SysLogEntity sysLogEntity = createSysLog(method, request);
|
||||
try {
|
||||
|
||||
return proceedingJoinPoint.proceed();
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
||||
logException(e, proceedingJoinPoint);
|
||||
|
||||
updateSysLog(e, sysLogEntity);
|
||||
|
||||
throw e;
|
||||
|
||||
} finally {
|
||||
|
||||
saveSysLog(sysLogEntity, System.currentTimeMillis(), start);
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
SessionService sessionService;
|
||||
private void saveSysLog(SysLogEntity sysLogEntity, long end, long start) {
|
||||
if (sysLogEntity != null) {
|
||||
sysLogEntity.setTimeCost((int) (end - start));
|
||||
|
||||
sysLogService.save(sysLogEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Around("controllerMethods()")
|
||||
public Object call(ProceedingJoinPoint proceedingJoinPoint) {
|
||||
private static void updateSysLog(Throwable e, SysLogEntity sysLogEntity) {
|
||||
if (sysLogEntity != null) {
|
||||
sysLogEntity.setOptStatus("1");
|
||||
sysLogEntity.setStacktrace(ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod();
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
@Autowired IpQueryService ipQueryService;
|
||||
|
||||
private SysLogEntity createSysLog(Method method, HttpServletRequest request) {
|
||||
SysLog sysLog = AnnotationUtils.findAnnotation(method, SysLog.class);
|
||||
|
||||
SysLogEntity sysLogEntity = null;
|
||||
String module = "";
|
||||
if (sysLog != null) {
|
||||
|
||||
module = sysLog.module();
|
||||
if (StringUtils.isEmpty(module)) {
|
||||
SysLog classLog = AnnotationUtils.findAnnotation(method.getDeclaringClass(), SysLog.class);
|
||||
if (classLog != null) {
|
||||
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
SysLogEntity sysLogEntity = createSysLog(method, request);
|
||||
try {
|
||||
|
||||
|
||||
return proceedingJoinPoint.proceed();
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
||||
|
||||
logException(e, proceedingJoinPoint);
|
||||
|
||||
|
||||
updateSysLog(e, sysLogEntity);
|
||||
|
||||
throw e;
|
||||
|
||||
|
||||
} finally {
|
||||
|
||||
|
||||
saveSysLog(sysLogEntity, System.currentTimeMillis(), start);
|
||||
module = classLog.module();
|
||||
}
|
||||
}
|
||||
|
||||
sysLogEntity = new SysLogEntity();
|
||||
sysLogEntity.setModule(module);
|
||||
sysLogEntity.setMessage(sysLog.message());
|
||||
sysLogEntity.setAction(sysLog.action());
|
||||
sysLogEntity.setIp(RequestUtils.getIp(request));
|
||||
sysLogEntity.setIpLocation(ipQueryService.query(sysLogEntity.getIp()));
|
||||
sysLogEntity.setUrl(request.getRequestURI());
|
||||
sysLogEntity.setOptStatus("0");
|
||||
sysLogEntity.setTimeCost(0);
|
||||
sysLogEntity.setUserAgent(RequestUtils.getUa(request));
|
||||
}
|
||||
return sysLogEntity;
|
||||
}
|
||||
|
||||
private void saveSysLog(SysLogEntity sysLogEntity, long end, long start) {
|
||||
if (sysLogEntity != null) {
|
||||
sysLogEntity.setTimeCost((int) (end - start));
|
||||
@Autowired SysLogService sysLogService;
|
||||
|
||||
sysLogService.save(sysLogEntity);
|
||||
private void logException(Throwable ex, ProceedingJoinPoint proceedingJoinPoint) {
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
|
||||
}
|
||||
}
|
||||
Object[] args = proceedingJoinPoint.getArgs();
|
||||
Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod();
|
||||
|
||||
private static void updateSysLog(Throwable e, SysLogEntity sysLogEntity) {
|
||||
if (sysLogEntity != null) {
|
||||
sysLogEntity.setOptStatus("1");
|
||||
sysLogEntity.setStacktrace(ExceptionUtils.getStackTrace(e));
|
||||
log.info(
|
||||
"接口调用异常: {}\nurl:{} {}\nmethod: {}\nargs: {}",
|
||||
ex.getMessage() == null ? "no message" : ex.getMessage(),
|
||||
request.getMethod(),
|
||||
request.getRequestURL(),
|
||||
method,
|
||||
Arrays.toString(args),
|
||||
ex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
IpQueryService ipQueryService;
|
||||
private SysLogEntity createSysLog(Method method, HttpServletRequest request) {
|
||||
SysLog sysLog = AnnotationUtils.findAnnotation(method, SysLog.class);
|
||||
|
||||
SysLogEntity sysLogEntity = null;
|
||||
String module = "";
|
||||
if (sysLog != null) {
|
||||
|
||||
|
||||
module = sysLog.module();
|
||||
if (StringUtils.isEmpty(module)) {
|
||||
SysLog classLog = AnnotationUtils.findAnnotation(method.getDeclaringClass(), SysLog.class);
|
||||
if (classLog != null) {
|
||||
|
||||
module = classLog.module();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sysLogEntity = new SysLogEntity();
|
||||
sysLogEntity.setModule(module);
|
||||
sysLogEntity.setMessage(sysLog.message());
|
||||
sysLogEntity.setAction(sysLog.action());
|
||||
sysLogEntity.setIp(RequestUtils.getIp(request));
|
||||
sysLogEntity.setIpLocation(ipQueryService.query(sysLogEntity.getIp()));
|
||||
sysLogEntity.setUrl(request.getRequestURI());
|
||||
sysLogEntity.setOptStatus("0");
|
||||
sysLogEntity.setTimeCost(0);
|
||||
sysLogEntity.setUserAgent(RequestUtils.getUa(request));
|
||||
|
||||
}
|
||||
return sysLogEntity;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
SysLogService sysLogService;
|
||||
|
||||
private void logException(Throwable ex, ProceedingJoinPoint proceedingJoinPoint) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
|
||||
|
||||
Object[] args = proceedingJoinPoint.getArgs();
|
||||
Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod();
|
||||
|
||||
log.info("接口调用异常: {}\nurl:{} {}\nmethod: {}\nargs: {}",
|
||||
ex.getMessage() == null ? "no message" : ex.getMessage(),
|
||||
request.getMethod(),
|
||||
request.getRequestURL(),
|
||||
method,
|
||||
Arrays.toString(args),
|
||||
|
||||
|
||||
ex);
|
||||
|
||||
request.setAttribute("__logged", true);
|
||||
|
||||
}
|
||||
request.setAttribute("__logged", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.lihongjie.coal.common.Ctx;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.lang.reflect.Method;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -18,82 +19,68 @@ import org.hibernate.Session;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
@Order
|
||||
public class OrgScopeAop {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
@PersistenceContext EntityManager entityManager;
|
||||
|
||||
private static ThreadLocal<Boolean> orgScope = new ThreadLocal<>();
|
||||
|
||||
private static ThreadLocal<Boolean> orgScope = new ThreadLocal<>();
|
||||
|
||||
@SneakyThrows
|
||||
@Around(value = "@annotation(cn.lihongjie.coal.annotation.OrgScope) || @within(cn.lihongjie.coal.annotation.OrgScope)")
|
||||
public Object beforeOrgScope(ProceedingJoinPoint pjp) {
|
||||
|
||||
Method method = ((MethodSignature) pjp.getSignature()).getMethod();
|
||||
OrgScope annotation = method.getAnnotation(OrgScope.class);
|
||||
|
||||
if (annotation == null) {
|
||||
annotation = method.getDeclaringClass().getAnnotation(OrgScope.class);
|
||||
}
|
||||
|
||||
if (annotation != null) {
|
||||
boolean enabled = annotation.value();
|
||||
|
||||
Session session = entityManager.unwrap(Session.class);
|
||||
|
||||
if (enabled) {
|
||||
|
||||
if (StringUtils.isEmpty(Ctx.currentUser().getOrganizationId())) {
|
||||
throw new BizException("当前用户未绑定机构, 无法进行机构数据过滤");
|
||||
}
|
||||
|
||||
|
||||
if (session.getEnabledFilter("orgFilter") == null) {
|
||||
|
||||
|
||||
Filter orgFilter = session.enableFilter("orgFilter");
|
||||
|
||||
orgFilter.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
} else {
|
||||
log.debug("当前session {} orgFilter已经启用, 忽略....", session.toString());
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
if (session.getEnabledFilter("orgFilter") != null) {
|
||||
|
||||
|
||||
session.disableFilter("orgFilter");
|
||||
|
||||
} else {
|
||||
log.debug("当前session {} orgFilter已经禁用, 忽略....", session.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return pjp.proceed();
|
||||
@SneakyThrows
|
||||
@Around(
|
||||
value =
|
||||
"@annotation(cn.lihongjie.coal.annotation.OrgScope) || @within(cn.lihongjie.coal.annotation.OrgScope)")
|
||||
public Object beforeOrgScope(ProceedingJoinPoint pjp) {
|
||||
|
||||
Method method = ((MethodSignature) pjp.getSignature()).getMethod();
|
||||
OrgScope annotation = method.getAnnotation(OrgScope.class);
|
||||
|
||||
if (annotation == null) {
|
||||
annotation = method.getDeclaringClass().getAnnotation(OrgScope.class);
|
||||
}
|
||||
|
||||
if (annotation != null) {
|
||||
boolean enabled = annotation.value();
|
||||
|
||||
@Before(value = "@annotation(org.springframework.transaction.annotation.Transactional))")
|
||||
public void beforeTransactionMethod() {
|
||||
Session session = entityManager.unwrap(Session.class);
|
||||
|
||||
if (enabled) {
|
||||
|
||||
if (orgScope.get() != null) {
|
||||
|
||||
Session session = entityManager.unwrap(Session.class);
|
||||
if (StringUtils.isEmpty(Ctx.currentUser().getOrganizationId())) {
|
||||
throw new BizException("当前用户未绑定机构, 无法进行机构数据过滤");
|
||||
}
|
||||
|
||||
if (session.getEnabledFilter("orgFilter") == null) {
|
||||
|
||||
Filter orgFilter = session.enableFilter("orgFilter");
|
||||
|
||||
orgFilter.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
|
||||
} else {
|
||||
log.debug("当前session {} orgFilter已经启用, 忽略....", session.toString());
|
||||
}
|
||||
} else {
|
||||
|
||||
if (session.getEnabledFilter("orgFilter") != null) {
|
||||
|
||||
session.disableFilter("orgFilter");
|
||||
|
||||
} else {
|
||||
log.debug("当前session {} orgFilter已经禁用, 忽略....", session.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return pjp.proceed();
|
||||
}
|
||||
|
||||
@Before(value = "@annotation(org.springframework.transaction.annotation.Transactional))")
|
||||
public void beforeTransactionMethod() {
|
||||
|
||||
if (orgScope.get() != null) {
|
||||
|
||||
Session session = entityManager.unwrap(Session.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,5 +7,4 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@OrgScope
|
||||
@Transactional
|
||||
@RestController
|
||||
public abstract class BaseController {
|
||||
}
|
||||
public abstract class BaseController {}
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
package cn.lihongjie.coal.base.dao;
|
||||
|
||||
import jakarta.persistence.criteria.Path;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoRepositoryBean
|
||||
public interface BaseRepository<T> extends JpaRepository<T, String>, JpaSpecificationExecutor<T> {
|
||||
|
||||
public default T get(String id) {
|
||||
public default T get(String id) {
|
||||
|
||||
return findById(id).orElseThrow(() -> new RuntimeException("数据不存在: " + id));
|
||||
return findById(id).orElseThrow(() -> new RuntimeException("数据不存在: " + id));
|
||||
}
|
||||
|
||||
}
|
||||
public default List<T> findByOrganizationId(String organizationId) {
|
||||
return findAll(
|
||||
(root, query, cb) -> {
|
||||
try {
|
||||
|
||||
public default List<T> findByOrganizationId(String organizationId) {
|
||||
return findAll((root, query, cb) -> {
|
||||
try {
|
||||
|
||||
Path<Object> path = root.get("organizationId");
|
||||
return cb.equal(path, organizationId);
|
||||
} catch (Exception e) {
|
||||
return cb.and();
|
||||
}
|
||||
Path<Object> path = root.get("organizationId");
|
||||
return cb.equal(path, organizationId);
|
||||
} catch (Exception e) {
|
||||
return cb.and();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
package cn.lihongjie.coal.base.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class BaseDto {
|
||||
|
||||
private String id;
|
||||
private String id;
|
||||
|
||||
private String createUserId;
|
||||
private String createUserId;
|
||||
|
||||
private String createUserName;
|
||||
|
||||
private String createUserName;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
private String updateUserId;
|
||||
private String updateUserName;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
private String updateUserId;
|
||||
private String updateUserName;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
@@ -8,24 +8,18 @@ import org.hibernate.annotations.Comment;
|
||||
@Setter
|
||||
public class CommonDto extends BaseDto {
|
||||
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
|
||||
|
||||
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private String status;
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private String status;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,33 +1,29 @@
|
||||
package cn.lihongjie.coal.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Data
|
||||
public class IdRequest {
|
||||
|
||||
private String id;
|
||||
private List<String> ids;
|
||||
private String id;
|
||||
private List<String> ids;
|
||||
|
||||
public List<String> getIds() {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return ids;
|
||||
} else if (CollectionUtils.isEmpty(ids)) {
|
||||
return Arrays.asList(id);
|
||||
}else {
|
||||
|
||||
|
||||
ArrayList<String> dup = new ArrayList<>(ids);
|
||||
dup.add(id);
|
||||
return dup;
|
||||
}
|
||||
public List<String> getIds() {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return ids;
|
||||
} else if (CollectionUtils.isEmpty(ids)) {
|
||||
return Arrays.asList(id);
|
||||
} else {
|
||||
|
||||
ArrayList<String> dup = new ArrayList<>(ids);
|
||||
dup.add(id);
|
||||
return dup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class OrgCommonDto extends CommonDto {
|
||||
private String organizationId;
|
||||
private String organizationId;
|
||||
}
|
||||
|
||||
@@ -6,49 +6,46 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class R<T> {
|
||||
private T data;
|
||||
private T data;
|
||||
|
||||
private String code;
|
||||
private String code;
|
||||
|
||||
private String msg;
|
||||
private String msg;
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer pageNo;
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer pageSize;
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer totalPage;
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer totalCount;
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer pageNo;
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer pageSize;
|
||||
|
||||
public R(T data, String code, String msg) {
|
||||
this.data = data;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer totalPage;
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
private Integer totalCount;
|
||||
|
||||
public R() {
|
||||
}
|
||||
public R(T data, String code, String msg) {
|
||||
this.data = data;
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public R() {}
|
||||
|
||||
public static <T> R<T> success() {
|
||||
return success(null);
|
||||
}
|
||||
public static <T> R<T> success() {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
public static <T> R<T> success(T data) {
|
||||
return create(data, "ok", "");
|
||||
}
|
||||
public static <T> R<T> success(T data) {
|
||||
return create(data, "ok", "");
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String code, String msg) {
|
||||
return create(null, code, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> create(T data, String code, String msg) {
|
||||
|
||||
return new R<>(data, code, msg);
|
||||
}
|
||||
public static <T> R<T> fail(String code, String msg) {
|
||||
return create(null, code, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> create(T data, String code, String msg) {
|
||||
|
||||
return new R<>(data, code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,178 +5,159 @@ import cn.lihongjie.coal.base.entity.CommonEntity;
|
||||
import cn.lihongjie.coal.common.ReflectUtils;
|
||||
import cn.lihongjie.coal.dictionary.dto.DictionaryItemDto;
|
||||
import cn.lihongjie.coal.dictionary.entity.DictionaryItemEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TreeDto {
|
||||
|
||||
private String id;
|
||||
private String id;
|
||||
|
||||
private String code;
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
private List<TreeDto> children;
|
||||
private List<TreeDto> children;
|
||||
|
||||
public static List<TreeDto> buildList(Object object, boolean flatten) {
|
||||
|
||||
public static List<TreeDto> buildList(Object object, boolean flatten) {
|
||||
List<TreeDto> ans;
|
||||
|
||||
List<TreeDto> ans;
|
||||
if (object instanceof Iterable<?>) {
|
||||
|
||||
if (object instanceof Iterable<?>) {
|
||||
ans = buildList0((Iterable<?>) object);
|
||||
} else {
|
||||
|
||||
ans = buildList0((Iterable<?>) object);
|
||||
} else {
|
||||
|
||||
|
||||
ans = buildList0(Arrays.asList(object));
|
||||
|
||||
}
|
||||
|
||||
if (flatten) {
|
||||
ans = flatten(ans);
|
||||
}
|
||||
return ans;
|
||||
ans = buildList0(Arrays.asList(object));
|
||||
}
|
||||
|
||||
private static List<TreeDto> flatten(List<TreeDto> ans) {
|
||||
if (flatten) {
|
||||
ans = flatten(ans);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
return ans.stream().flatMap(x -> {
|
||||
private static List<TreeDto> flatten(List<TreeDto> ans) {
|
||||
|
||||
if (x == null) {
|
||||
return ans.stream()
|
||||
.flatMap(
|
||||
x -> {
|
||||
if (x == null) {
|
||||
return Stream.empty();
|
||||
}
|
||||
}
|
||||
|
||||
if (x.getChildren() != null) {
|
||||
if (x.getChildren() != null) {
|
||||
|
||||
return Stream.concat(Stream.of(x), flatten(x.getChildren()).stream());
|
||||
} else {
|
||||
} else {
|
||||
return Stream.of(x);
|
||||
}
|
||||
}
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
}).toList();
|
||||
private static List<TreeDto> buildList0(Iterable<?> object) {
|
||||
|
||||
return StreamSupport.stream(object.spliterator(), false).map(x -> buildTree(x)).toList();
|
||||
}
|
||||
|
||||
public static TreeDto buildTree(Object x) {
|
||||
|
||||
if (x == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<TreeDto> buildList0(Iterable<?> object) {
|
||||
TreeDto dto = new TreeDto();
|
||||
|
||||
dto.setId(getId(x));
|
||||
dto.setName(getName(x));
|
||||
dto.setCode(getCode(x));
|
||||
dto.setChildren(getChildren(x));
|
||||
return dto;
|
||||
}
|
||||
|
||||
return StreamSupport.stream(object.spliterator(), false).map(x -> buildTree(x)).toList();
|
||||
|
||||
private static List<TreeDto> getChildren(Object x) {
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getChildren().stream().map(TreeDto::buildTree).toList();
|
||||
}
|
||||
|
||||
public static TreeDto buildTree(Object x) {
|
||||
Object c = ReflectUtils.getFieldValue(x, "children");
|
||||
|
||||
|
||||
if (x == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
TreeDto dto = new TreeDto();
|
||||
|
||||
dto.setId(getId(x));
|
||||
dto.setName(getName(x));
|
||||
dto.setCode(getCode(x));
|
||||
dto.setChildren(getChildren(x));
|
||||
return dto;
|
||||
if (c == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private static List<TreeDto> getChildren(Object x) {
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getChildren().stream().map(TreeDto::buildTree).toList();
|
||||
}
|
||||
|
||||
|
||||
Object c = ReflectUtils.getFieldValue(x, "children");
|
||||
|
||||
if (c == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (c instanceof Iterable<?>) {
|
||||
return buildList0((Iterable<?>) c);
|
||||
}
|
||||
|
||||
return buildList0(Arrays.asList(c));
|
||||
|
||||
|
||||
if (c instanceof Iterable<?>) {
|
||||
return buildList0((Iterable<?>) c);
|
||||
}
|
||||
|
||||
private static String getCode(Object x) {
|
||||
if (x instanceof CommonEntity) {
|
||||
return ((CommonEntity) x).getCode();
|
||||
}
|
||||
return buildList0(Arrays.asList(c));
|
||||
}
|
||||
|
||||
if (x instanceof CommonDto) {
|
||||
return ((CommonDto) x).getCode();
|
||||
}
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getCode();
|
||||
}
|
||||
|
||||
return ReflectUtils.getFieldValue(x, "code") + "";
|
||||
private static String getCode(Object x) {
|
||||
if (x instanceof CommonEntity) {
|
||||
return ((CommonEntity) x).getCode();
|
||||
}
|
||||
|
||||
private static String getName(Object x) {
|
||||
|
||||
if (x instanceof CommonEntity) {
|
||||
return ((CommonEntity) x).getName();
|
||||
}
|
||||
|
||||
if (x instanceof CommonDto) {
|
||||
return ((CommonDto) x).getName();
|
||||
}
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getName();
|
||||
}
|
||||
|
||||
return ReflectUtils.getFieldValue(x, "name") + "";
|
||||
if (x instanceof CommonDto) {
|
||||
return ((CommonDto) x).getCode();
|
||||
}
|
||||
|
||||
private static String getId(Object x) {
|
||||
|
||||
if (x instanceof DictionaryItemEntity) {
|
||||
return ((DictionaryItemEntity) x).getCode();
|
||||
}
|
||||
|
||||
if (x instanceof DictionaryItemDto) {
|
||||
return ((DictionaryItemDto) x).getCode();
|
||||
}
|
||||
|
||||
|
||||
if (x instanceof BaseEntity) {
|
||||
return ((BaseEntity) x).getId();
|
||||
}
|
||||
|
||||
if (x instanceof BaseDto) {
|
||||
return ((BaseDto) x).getId();
|
||||
}
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getId();
|
||||
}
|
||||
|
||||
|
||||
return ReflectUtils.getFieldValue(x, "id") + "";
|
||||
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getCode();
|
||||
}
|
||||
|
||||
return ReflectUtils.getFieldValue(x, "code") + "";
|
||||
}
|
||||
|
||||
private static String getName(Object x) {
|
||||
|
||||
if (x instanceof CommonEntity) {
|
||||
return ((CommonEntity) x).getName();
|
||||
}
|
||||
|
||||
if (x instanceof CommonDto) {
|
||||
return ((CommonDto) x).getName();
|
||||
}
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getName();
|
||||
}
|
||||
|
||||
return ReflectUtils.getFieldValue(x, "name") + "";
|
||||
}
|
||||
|
||||
private static String getId(Object x) {
|
||||
|
||||
if (x instanceof DictionaryItemEntity) {
|
||||
return ((DictionaryItemEntity) x).getCode();
|
||||
}
|
||||
|
||||
if (x instanceof DictionaryItemDto) {
|
||||
return ((DictionaryItemDto) x).getCode();
|
||||
}
|
||||
|
||||
if (x instanceof BaseEntity) {
|
||||
return ((BaseEntity) x).getId();
|
||||
}
|
||||
|
||||
if (x instanceof BaseDto) {
|
||||
return ((BaseDto) x).getId();
|
||||
}
|
||||
|
||||
if (x instanceof TreeDto) {
|
||||
return ((TreeDto) x).getId();
|
||||
}
|
||||
|
||||
return ReflectUtils.getFieldValue(x, "id") + "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +1,60 @@
|
||||
package cn.lihongjie.coal.base.entity;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.common.Ctx;
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
@DynamicUpdate
|
||||
public class BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private String id;
|
||||
@Comment("创建用户ID")
|
||||
private String createUserId;
|
||||
|
||||
@Formula("(select tu.name from t_user tu where tu.id = create_user_id)")
|
||||
private String createUserName;
|
||||
|
||||
@Comment("创建用户ID")
|
||||
private String createUserId;
|
||||
@Comment("创建时间")
|
||||
@CreationTimestamp(source = SourceType.VM)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Comment("更新用户ID")
|
||||
private String updateUserId;
|
||||
|
||||
@Formula("(select tu.name from t_user tu where tu.id = create_user_id)")
|
||||
private String createUserName;
|
||||
@Formula("((select tu.name from t_user tu where tu.id = create_user_id))")
|
||||
private String updateUserName;
|
||||
|
||||
@Comment("创建时间")
|
||||
@CreationTimestamp(source = SourceType.VM)
|
||||
private LocalDateTime createTime;
|
||||
@Comment("更新时间")
|
||||
@UpdateTimestamp(source = SourceType.VM)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (StringUtils.isEmpty(this.createUserId)) {
|
||||
|
||||
@Comment("更新用户ID")
|
||||
private String updateUserId;
|
||||
@Formula("((select tu.name from t_user tu where tu.id = create_user_id))")
|
||||
private String updateUserName;
|
||||
|
||||
@Comment("更新时间")
|
||||
@UpdateTimestamp(source = SourceType.VM)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (StringUtils.isEmpty(this.createUserId)) {
|
||||
|
||||
this.createUserId = Ctx.isLoggedIn() ? Ctx.getUserId() : "";
|
||||
}
|
||||
|
||||
if (this.createTime == null) {
|
||||
this.createTime = LocalDateTime.now();
|
||||
}
|
||||
this.createUserId = Ctx.isLoggedIn() ? Ctx.getUserId() : "";
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void preUpdate() {
|
||||
|
||||
this.updateUserId = Ctx.isLoggedIn() ? Ctx.getUserId() : "";
|
||||
|
||||
this.updateTime = LocalDateTime.now();
|
||||
if (this.createTime == null) {
|
||||
this.createTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void preUpdate() {
|
||||
|
||||
this.updateUserId = Ctx.isLoggedIn() ? Ctx.getUserId() : "";
|
||||
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,44 @@
|
||||
package cn.lihongjie.coal.base.entity;
|
||||
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
public class CommonEntity extends BaseEntity {
|
||||
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private Integer status;
|
||||
|
||||
public boolean isDisabled() {
|
||||
return Objects.equals(status, 0);
|
||||
}
|
||||
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
@Override
|
||||
public void prePersist() {
|
||||
this.status = this.status == null ? 1 : this.status;
|
||||
super.prePersist();
|
||||
}
|
||||
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
|
||||
public boolean isDisabled(){
|
||||
return Objects.equals(status, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void prePersist() {
|
||||
this.status = this.status == null ? 1 : this.status;
|
||||
super.prePersist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
this.status = this.status == null ? 1 : this.status;
|
||||
super.preUpdate();
|
||||
}
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
this.status = this.status == null ? 1 : this.status;
|
||||
super.preUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,22 +11,20 @@ import org.apache.commons.lang3.StringUtils;
|
||||
@Setter
|
||||
public class OrgBaseEntity extends BaseEntity {
|
||||
|
||||
private String organizationId;
|
||||
|
||||
private String organizationId;
|
||||
@Override
|
||||
public void prePersist() {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
|
||||
@Override
|
||||
public void prePersist() {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
this.organizationId = Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
}
|
||||
super.prePersist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
super.preUpdate();
|
||||
this.organizationId =
|
||||
Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
}
|
||||
super.prePersist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
super.preUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,20 @@ import org.hibernate.annotations.ParamDef;
|
||||
@Filter(name = "orgFilter", condition = "organization_id = :organizationId")
|
||||
public class OrgCommonEntity extends CommonEntity {
|
||||
|
||||
private String organizationId;
|
||||
|
||||
private String organizationId;
|
||||
@Override
|
||||
public void prePersist() {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
|
||||
@Override
|
||||
public void prePersist() {
|
||||
if (StringUtils.isEmpty(organizationId)) {
|
||||
|
||||
this.organizationId = Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
}
|
||||
super.prePersist();
|
||||
this.organizationId =
|
||||
Ctx.isLoggedIn() ? Ctx.currentUser().getOrganizationId() : organizationId;
|
||||
}
|
||||
super.prePersist();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
super.preUpdate();
|
||||
}
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
super.preUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package cn.lihongjie.coal.base.mapper;
|
||||
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
public interface BaseMapper<Entity, Dto, Create,Update> {
|
||||
Entity copy(Entity i);
|
||||
Dto copyDto(Dto i);
|
||||
public interface BaseMapper<Entity, Dto, Create, Update> {
|
||||
Entity copy(Entity i);
|
||||
|
||||
Dto copyDto(Dto i);
|
||||
|
||||
Dto toDto(Entity user);
|
||||
Dto toDto(Entity user);
|
||||
|
||||
Entity toEntity(Create request);
|
||||
Entity toEntity(Create request);
|
||||
|
||||
|
||||
void updateEntity(@MappingTarget Entity entity, Update dto);
|
||||
void updateEntity(@MappingTarget Entity entity, Update dto);
|
||||
}
|
||||
|
||||
@@ -19,156 +19,144 @@ import org.mapstruct.Mapper;
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface CommonMapper {
|
||||
|
||||
public default Integer toInt(String s) {
|
||||
try {
|
||||
|
||||
return Integer.valueOf(s);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
public default Integer toInt(String s) {
|
||||
try {
|
||||
|
||||
return Integer.valueOf(s);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
public default UserEntity createUser(String id) {
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
UserEntity user = new UserEntity();
|
||||
public default UserEntity createUser(String id) {
|
||||
|
||||
user.setId(id);
|
||||
|
||||
return user;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
UserEntity user = new UserEntity();
|
||||
|
||||
user.setId(id);
|
||||
|
||||
public default DictionaryEntity createDictionary(String id) {
|
||||
return user;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
DictionaryEntity e = new DictionaryEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
public default DictionaryEntity createDictionary(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
DictionaryEntity e = new DictionaryEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default DictionaryItemEntity createDictionaryItem(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
DictionaryItemEntity e = new DictionaryItemEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
public default DictionaryItemEntity createDictionaryItem(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
DictionaryItemEntity e = new DictionaryItemEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default SysLogEntity createOperat(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
SysLogEntity e = new SysLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
public default SysLogEntity createOperat(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
SysLogEntity e = new SysLogEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default OrganizationEntity createOrganization(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
OrganizationEntity e = new OrganizationEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
public default OrganizationEntity createOrganization(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
OrganizationEntity e = new OrganizationEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default PermissionEntity createPermission(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
PermissionEntity e = new PermissionEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
public default PermissionEntity createPermission(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
PermissionEntity e = new PermissionEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default ResourceEntity createResource(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
ResourceEntity e = new ResourceEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
public default ResourceEntity createResource(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
return null;
|
||||
}
|
||||
ResourceEntity e = new ResourceEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default RoleEntity createRole(String id) {
|
||||
public default RoleEntity createRole(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
RoleEntity e = new RoleEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
RoleEntity e = new RoleEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default ScriptEntity createScript(String id) {
|
||||
|
||||
public default ScriptEntity createScript(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
ScriptEntity e = new ScriptEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
public default SupplierEntity createSupplier(String id) {
|
||||
ScriptEntity e = new ScriptEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
public default SupplierEntity createSupplier(String id) {
|
||||
|
||||
return null;
|
||||
}
|
||||
SupplierEntity e = new SupplierEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
public default CoalInfoEntity createCoalInfo(String id) {
|
||||
SupplierEntity e = new SupplierEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
public default CoalInfoEntity createCoalInfo(String id) {
|
||||
|
||||
return null;
|
||||
}
|
||||
CoalInfoEntity e = new CoalInfoEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
public default String toString(Object o) {
|
||||
CoalInfoEntity e = new CoalInfoEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
public default String toString(Object o) {
|
||||
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof String) {
|
||||
return ((String) o);
|
||||
} else if (o instanceof BaseEntity) {
|
||||
return ((BaseEntity) o).getId();
|
||||
|
||||
} else if (o instanceof BaseDto) {
|
||||
return ((BaseDto) o).getId();
|
||||
} else {
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else if (o instanceof String) {
|
||||
return ((String) o);
|
||||
} else if (o instanceof BaseEntity) {
|
||||
return ((BaseEntity) o).getId();
|
||||
|
||||
} else if (o instanceof BaseDto) {
|
||||
return ((BaseDto) o).getId();
|
||||
} else {
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,58 +2,52 @@ package cn.lihongjie.coal.base.service;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.base.entity.BaseEntity;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import java.util.List;
|
||||
public abstract class BaseService<
|
||||
Entity extends BaseEntity, Repository extends BaseRepository<Entity>> {
|
||||
|
||||
public abstract class BaseService<Entity extends BaseEntity, Repository extends BaseRepository<Entity>> {
|
||||
@Autowired Repository dao;
|
||||
|
||||
@Autowired
|
||||
Repository dao;
|
||||
public Entity get(String id) {
|
||||
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
public Entity get(String id){
|
||||
public void save(Entity entity) {
|
||||
|
||||
return dao.get(id);
|
||||
}
|
||||
dao.save(entity);
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
dao.deleteById(id);
|
||||
}
|
||||
|
||||
public void save(Entity entity){
|
||||
public void delete(List<String> id) {
|
||||
dao.deleteAllById(id);
|
||||
}
|
||||
|
||||
dao.save(entity);
|
||||
}
|
||||
public Page<Entity> findAll(Specification<Entity> spec, Pageable page) {
|
||||
return dao.findAll(spec, page);
|
||||
}
|
||||
|
||||
public List<Entity> findAll(Specification<Entity> spec) {
|
||||
return dao.findAll(spec);
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
dao.deleteById(id);
|
||||
}
|
||||
|
||||
public void delete(List<String> id) {
|
||||
dao.deleteAllById(id);
|
||||
|
||||
}
|
||||
|
||||
public Page<Entity> findAll(Specification<Entity> spec, Pageable page){
|
||||
return dao.findAll(spec, page);
|
||||
}
|
||||
public List<Entity> findAll(Specification<Entity> spec){
|
||||
return dao.findAll(spec);
|
||||
}
|
||||
|
||||
public List<Entity> findAll(){
|
||||
return dao.findAll();
|
||||
}
|
||||
|
||||
public Long count(Specification<Entity> spec){
|
||||
return dao.count(spec);
|
||||
}
|
||||
|
||||
public Long count(){
|
||||
return dao.count();
|
||||
}
|
||||
public List<Entity> findAll() {
|
||||
return dao.findAll();
|
||||
}
|
||||
|
||||
public Long count(Specification<Entity> spec) {
|
||||
return dao.count(spec);
|
||||
}
|
||||
|
||||
public Long count() {
|
||||
return dao.count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package cn.lihongjie.coal.coal;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalConstraint{
|
||||
|
||||
private String code;
|
||||
private Double min;
|
||||
private Double max;
|
||||
private Integer priority;
|
||||
private Integer order;
|
||||
public class CoalConstraint {
|
||||
|
||||
private String code;
|
||||
private Double min;
|
||||
private Double max;
|
||||
private Integer priority;
|
||||
private Integer order;
|
||||
}
|
||||
|
||||
@@ -4,39 +4,29 @@ import cn.lihongjie.coal.annotation.Anonymous;
|
||||
import cn.lihongjie.coal.base.controller.BaseController;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CoalBlendRequest;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CoalBlendResult;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/coal")
|
||||
@Anonymous
|
||||
public class CoalController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
CoalService coalService;
|
||||
@Autowired CoalService coalService;
|
||||
|
||||
@PostMapping("/blend")
|
||||
public CoalBlendResult blend(@RequestBody CoalBlendRequest request) {
|
||||
|
||||
return coalService.blend(request);
|
||||
}
|
||||
|
||||
@PostMapping("/params")
|
||||
public List<CoalParameterDef> params() {
|
||||
|
||||
@PostMapping("/blend")
|
||||
public CoalBlendResult blend(@RequestBody CoalBlendRequest request){
|
||||
|
||||
return coalService.blend(request);
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/params")
|
||||
public List<CoalParameterDef> params(){
|
||||
|
||||
return coalService.paramDefs();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return coalService.paramDefs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,61 @@
|
||||
package cn.lihongjie.coal.coal;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalInfo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
private String name;
|
||||
/** 配煤比例明细 */
|
||||
private List<CoalPercent> percents;
|
||||
|
||||
/**
|
||||
* 配煤比例明细
|
||||
*/
|
||||
private List<CoalPercent> percents;
|
||||
private Integer min = 1;
|
||||
private Integer max = 99;
|
||||
|
||||
private Integer min = 1;
|
||||
private Integer max = 99;
|
||||
private List<CoalParameter> parameters;
|
||||
|
||||
@JsonIgnore private Map<String, CoalParameter> parameterMap;
|
||||
|
||||
private List<CoalParameter> parameters;
|
||||
public Map<String, CoalParameter> getParameterMap() {
|
||||
|
||||
if (parameterMap == null) {
|
||||
|
||||
@JsonIgnore
|
||||
private Map<String, CoalParameter> parameterMap;
|
||||
|
||||
|
||||
public Map<String, CoalParameter> getParameterMap() {
|
||||
|
||||
if (parameterMap == null) {
|
||||
|
||||
|
||||
parameterMap = parameters.stream().collect(Collectors.toMap(e -> e.getCode(), e -> e));
|
||||
}
|
||||
|
||||
return parameterMap;
|
||||
parameterMap = parameters.stream().collect(Collectors.toMap(e -> e.getCode(), e -> e));
|
||||
}
|
||||
|
||||
return parameterMap;
|
||||
}
|
||||
|
||||
public Double getParamVal(String code) {
|
||||
public Double getParamVal(String code) {
|
||||
|
||||
CoalParameter coalParameter = getParameterMap().get(code);
|
||||
return coalParameter == null ? null : coalParameter.getValue();
|
||||
}
|
||||
|
||||
CoalParameter coalParameter = getParameterMap().get(code);
|
||||
return coalParameter == null ? null : coalParameter.getValue();
|
||||
public String rowString() {
|
||||
|
||||
}
|
||||
String percentString =
|
||||
percents.stream()
|
||||
.map(x -> String.format("%5s %-3s(%1s)", x.getName(), x.getPercent(), x.getPercent2()))
|
||||
.collect(Collectors.joining("\t"));
|
||||
String paramString =
|
||||
parameters.stream()
|
||||
.map(x -> String.format("%5s:%-6.2f", x.getCode(), x.getValue()))
|
||||
.collect(Collectors.joining("\t"));
|
||||
|
||||
public String rowString() {
|
||||
return String.format("%s\t%20s\t%s", name, percentString, paramString);
|
||||
}
|
||||
|
||||
String percentString =
|
||||
percents.stream().map(x -> String.format("%5s %-3s(%1s)", x.getName(), x.getPercent(),
|
||||
x.getPercent2())).collect(Collectors.joining("\t"));
|
||||
String paramString =
|
||||
parameters.stream().map(x -> String.format("%5s:%-6.2f", x.getCode(), x.getValue())).collect(Collectors.joining(
|
||||
"\t"));
|
||||
public void calPercent2() {
|
||||
|
||||
// percents.stream().reduce(x -> x.)
|
||||
|
||||
return String.format("%s\t%20s\t%s", name, percentString, paramString);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void calPercent2() {
|
||||
|
||||
|
||||
// percents.stream().reduce(x -> x.)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class CoalParameter {
|
||||
|
||||
private String code;
|
||||
|
||||
private Double value;
|
||||
private String code;
|
||||
|
||||
private Double value;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalParameterDef {
|
||||
private String code;
|
||||
private String name;
|
||||
private String desc;
|
||||
private Integer status;
|
||||
private Integer order;
|
||||
private String code;
|
||||
private String name;
|
||||
private String desc;
|
||||
private Integer status;
|
||||
private Integer order;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,12 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalPercent {
|
||||
private String id;
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
private Long percent;
|
||||
private Long percent;
|
||||
|
||||
/**
|
||||
* gcd之后的比例
|
||||
*/
|
||||
private Long percent2;
|
||||
/** gcd之后的比例 */
|
||||
private Long percent2;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.sat.*;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -22,113 +15,114 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CoalService {
|
||||
|
||||
/**
|
||||
* 配煤
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CoalBlendResult blend(CoalBlendRequest request) {
|
||||
|
||||
/**
|
||||
* 配煤
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CoalBlendResult blend(CoalBlendRequest request) {
|
||||
if (CollectionUtils.isEmpty(request.getCoals())) {
|
||||
throw new BizException("煤不能为空");
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(request.getCoals())) {
|
||||
throw new BizException("煤不能为空");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(request.getConstraints())) {
|
||||
throw new BizException("参数配置不能为空");
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(request.getConstraints())) {
|
||||
throw new BizException("参数配置不能为空");
|
||||
}
|
||||
Loader.loadNativeLibraries();
|
||||
CoalBlendResult result = new CoalBlendResult();
|
||||
|
||||
CpModel model = new CpModel();
|
||||
|
||||
List<IntVar> vars = createPercentVars(request, model);
|
||||
|
||||
// 添加各种约束条件
|
||||
addConstrains(request, model, vars);
|
||||
|
||||
// 初始化求解器
|
||||
CpSolver cpSolver = new CpSolver();
|
||||
cpSolver.setLogCallback(x -> log.info(x));
|
||||
SatParameters.Builder parameters = cpSolver.getParameters();
|
||||
parameters.setEnumerateAllSolutions(false);
|
||||
parameters.setMaxTimeInSeconds(request.getMaxTime());
|
||||
parameters.setLogSearchProgress(false);
|
||||
parameters.setFillAdditionalSolutionsInResponse(true);
|
||||
|
||||
// 开始求最优解
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
CoalBlendResult result = new CoalBlendResult();
|
||||
List<CoalConstraint> sorted =
|
||||
request.getConstraints().stream()
|
||||
.filter(x -> x.getPriority() != null)
|
||||
.sorted(Comparator.comparing(CoalConstraint::getPriority))
|
||||
.toList();
|
||||
|
||||
CpModel model = new CpModel();
|
||||
for (CoalConstraint constraint : sorted) {
|
||||
|
||||
log.info("使用约束 {}", constraint);
|
||||
|
||||
List<IntVar> vars = createPercentVars(request, model);
|
||||
LinearExpr weightedSum =
|
||||
LinearExpr.weightedSum(
|
||||
vars.toArray(new IntVar[0]),
|
||||
request.getCoals().stream()
|
||||
.mapToLong(x -> (long) (x.getParamVal(constraint.getCode()) * 100))
|
||||
.toArray());
|
||||
if (constraint.getOrder() == -1) {
|
||||
model.maximize(weightedSum);
|
||||
|
||||
// 添加各种约束条件
|
||||
addConstrains(request, model, vars);
|
||||
} else {
|
||||
model.minimize(weightedSum);
|
||||
}
|
||||
|
||||
CpSolverStatus status = cpSolver.solve(model);
|
||||
|
||||
// 初始化求解器
|
||||
CpSolver cpSolver = new CpSolver();
|
||||
cpSolver.setLogCallback(x -> log.info(x));
|
||||
SatParameters.Builder parameters = cpSolver.getParameters();
|
||||
parameters.setEnumerateAllSolutions(false);
|
||||
parameters.setMaxTimeInSeconds(request.getMaxTime());
|
||||
parameters.setLogSearchProgress(false);
|
||||
parameters.setFillAdditionalSolutionsInResponse(true);
|
||||
|
||||
|
||||
// 开始求最优解
|
||||
|
||||
List<CoalConstraint> sorted = request.getConstraints().stream().filter(x -> x.getPriority()!=null).sorted(Comparator.comparing(CoalConstraint::getPriority)).toList();
|
||||
|
||||
|
||||
for (CoalConstraint constraint : sorted) {
|
||||
|
||||
log.info("使用约束 {}", constraint);
|
||||
|
||||
LinearExpr weightedSum = LinearExpr.weightedSum(vars.toArray(new IntVar[0]), request.getCoals().stream().mapToLong(x -> (long) (x.getParamVal(constraint.getCode()) * 100)).toArray());
|
||||
if (constraint.getOrder() == -1) {
|
||||
model.maximize(weightedSum);
|
||||
|
||||
} else {
|
||||
model.minimize(weightedSum);
|
||||
}
|
||||
|
||||
|
||||
CpSolverStatus status = cpSolver.solve(model);
|
||||
|
||||
|
||||
if (status == CpSolverStatus.FEASIBLE || status == CpSolverStatus.OPTIMAL) {
|
||||
|
||||
double constrainVal = cpSolver.objectiveValue();
|
||||
|
||||
// model.clearHints();
|
||||
//
|
||||
// for (IntVar var : vars) {
|
||||
// model.addHint(var, cpSolver.value(var));
|
||||
//
|
||||
// }
|
||||
if (constraint.getOrder() == -1) {
|
||||
model.addLessOrEqual(weightedSum, (long) constrainVal);
|
||||
log.info("添加新的条件 sum({}) <= {}", constraint.getCode(), constrainVal);
|
||||
} else {
|
||||
model.addGreaterOrEqual(weightedSum, (long) constrainVal);
|
||||
log.info("添加新的条件 sum({}) >= {}", constraint.getCode(), constrainVal);
|
||||
}
|
||||
|
||||
String validate = model.validate();
|
||||
log.info(validate);
|
||||
|
||||
} else {
|
||||
log.warn("无法求解: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 记录结果
|
||||
if (status == CpSolverStatus.FEASIBLE || status == CpSolverStatus.OPTIMAL) {
|
||||
|
||||
double constrainVal = cpSolver.objectiveValue();
|
||||
|
||||
// model.clearHints();
|
||||
//
|
||||
cpSolver.getParameters().setEnumerateAllSolutions(true);
|
||||
CpSolverStatus solverStatus = cpSolver.solve(model, new CpSolverSolutionCallback() {
|
||||
@Override
|
||||
public void onSolutionCallback() {
|
||||
// for (IntVar var : vars) {
|
||||
// model.addHint(var, cpSolver.value(var));
|
||||
//
|
||||
// }
|
||||
if (constraint.getOrder() == -1) {
|
||||
model.addLessOrEqual(weightedSum, (long) constrainVal);
|
||||
log.info("添加新的条件 sum({}) <= {}", constraint.getCode(), constrainVal);
|
||||
} else {
|
||||
model.addGreaterOrEqual(weightedSum, (long) constrainVal);
|
||||
log.info("添加新的条件 sum({}) >= {}", constraint.getCode(), constrainVal);
|
||||
}
|
||||
|
||||
String validate = model.validate();
|
||||
log.info(validate);
|
||||
|
||||
} else {
|
||||
log.warn("无法求解: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
// 记录结果
|
||||
|
||||
//
|
||||
cpSolver.getParameters().setEnumerateAllSolutions(true);
|
||||
CpSolverStatus solverStatus =
|
||||
cpSolver.solve(
|
||||
model,
|
||||
new CpSolverSolutionCallback() {
|
||||
@Override
|
||||
public void onSolutionCallback() {
|
||||
|
||||
CoalInfo solution = new CoalInfo();
|
||||
List<Long> gcdVals = new ArrayList<>();
|
||||
@@ -137,239 +131,222 @@ public class CoalService {
|
||||
solution.setParameters(new ArrayList<>());
|
||||
for (int i = 0; i < vars.size(); i++) {
|
||||
|
||||
long percent = this.value(vars.get(i));
|
||||
long percent = this.value(vars.get(i));
|
||||
|
||||
CoalInfo coal = request.getCoals().get(i);
|
||||
// 累加
|
||||
try {
|
||||
CoalInfo coal = request.getCoals().get(i);
|
||||
// 累加
|
||||
try {
|
||||
|
||||
acc(solution, percent, coal);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
acc(solution, percent, coal);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CoalPercent e = new CoalPercent();
|
||||
e.setId(coal.getId());
|
||||
e.setName(coal.getName());
|
||||
e.setPercent(percent);
|
||||
if (CollectionUtils.isNotEmpty(gcdVals)) {
|
||||
e.setPercent2(gcdVals.get(i));
|
||||
|
||||
}
|
||||
solution.getPercents().add(e);
|
||||
CoalPercent e = new CoalPercent();
|
||||
e.setId(coal.getId());
|
||||
e.setName(coal.getName());
|
||||
e.setPercent(percent);
|
||||
if (CollectionUtils.isNotEmpty(gcdVals)) {
|
||||
e.setPercent2(gcdVals.get(i));
|
||||
}
|
||||
solution.getPercents().add(e);
|
||||
}
|
||||
|
||||
// 四舍五入
|
||||
|
||||
round(solution);
|
||||
|
||||
|
||||
result.getCoals().add(solution);
|
||||
}
|
||||
});
|
||||
|
||||
sortAndSelect(request, result);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
sortAndSelect(request, result);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<IntVar> createPercentVars(CoalBlendRequest request, CpModel model) {
|
||||
int index = 0;
|
||||
|
||||
List<IntVar> vars = new ArrayList<>();
|
||||
for (CoalInfo coal : request.getCoals()) {
|
||||
IntVar x =
|
||||
model.newIntVar(Math.max(coal.getMin(), 0), Math.min(coal.getMax(), 100), "x" + index++);
|
||||
vars.add(x);
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
|
||||
private static List<IntVar> createPercentVars(CoalBlendRequest request, CpModel model) {
|
||||
int index = 0;
|
||||
private void sortAndSelect(CoalBlendRequest request, CoalBlendResult result) {
|
||||
|
||||
List<IntVar> vars = new ArrayList<>();
|
||||
for (CoalInfo coal : request.getCoals()) {
|
||||
IntVar x = model.newIntVar(Math.max(coal.getMin(), 0), Math.min(coal.getMax(), 100), "x" + index++);
|
||||
vars.add(x);
|
||||
List<CoalConstraint> list =
|
||||
request.getConstraints().stream()
|
||||
.filter(x -> x.getPriority() != null)
|
||||
.sorted(Comparator.comparing(x -> x.getPriority()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Comparator<CoalInfo> c = Comparator.comparing(x -> 1);
|
||||
if (!list.isEmpty()) {
|
||||
|
||||
for (CoalConstraint constraint : list) {
|
||||
|
||||
if (constraint.getOrder() == null || constraint.getOrder() == 1) {
|
||||
c =
|
||||
c.thenComparing(
|
||||
Comparator.<CoalInfo, Double>comparing(x -> x.getParamVal(constraint.getCode())));
|
||||
} else {
|
||||
|
||||
c =
|
||||
c.thenComparing(
|
||||
Comparator.<CoalInfo, Double>comparing(x -> x.getParamVal(constraint.getCode()))
|
||||
.reversed());
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
}
|
||||
result.setCoals(
|
||||
result.getCoals().stream()
|
||||
.sorted(c)
|
||||
.limit(request.getCount())
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
private void sortAndSelect(CoalBlendRequest request, CoalBlendResult result) {
|
||||
result.getCoals().forEach(x -> x.calPercent2());
|
||||
}
|
||||
|
||||
private void round(CoalInfo solution) {
|
||||
|
||||
List<CoalConstraint> list = request.getConstraints()
|
||||
.stream()
|
||||
.filter(x -> x.getPriority() != null)
|
||||
.sorted(Comparator.comparing(x -> x.getPriority()))
|
||||
.collect(Collectors.toList());
|
||||
solution
|
||||
.getParameters()
|
||||
.forEach(
|
||||
x ->
|
||||
x.setValue(
|
||||
x.getValue() == null
|
||||
? x.getValue()
|
||||
: BigDecimal.valueOf(x.getValue())
|
||||
.setScale(2, RoundingMode.HALF_UP)
|
||||
.doubleValue()));
|
||||
}
|
||||
|
||||
private void acc(CoalInfo solution, long percent, CoalInfo coal) {
|
||||
|
||||
Comparator<CoalInfo> c = Comparator.comparing(x -> 1);
|
||||
if (!list.isEmpty()) {
|
||||
for (CoalParameter parameter : coal.getParameters()) {
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (CoalConstraint constraint : list) {
|
||||
|
||||
if (constraint.getOrder() == null || constraint.getOrder() == 1) {
|
||||
c =
|
||||
c.thenComparing(Comparator.<CoalInfo, Double>comparing(x -> x.getParamVal(constraint.getCode())));
|
||||
} else {
|
||||
|
||||
c =
|
||||
c.thenComparing(Comparator.<CoalInfo, Double>comparing(x -> x.getParamVal(constraint.getCode())).reversed());
|
||||
}
|
||||
}
|
||||
for (CoalParameter solutionParameter : solution.getParameters()) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(parameter.getCode(), solutionParameter.getCode())) {
|
||||
|
||||
solutionParameter.setValue(
|
||||
solutionParameter.getValue() + (parameter.getValue() * percent / 100.0));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
result.setCoals(result.getCoals().stream().sorted(c).limit(request.getCount()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
result.getCoals().forEach(x -> x.calPercent2());
|
||||
if (!found) {
|
||||
CoalParameter e = new CoalParameter();
|
||||
e.setCode(parameter.getCode());
|
||||
e.setValue(parameter.getValue() * percent / 100.0);
|
||||
solution.getParameters().add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addConstrains(CoalBlendRequest request, CpModel model, List<IntVar> vars) {
|
||||
// 各种煤比例之和为 100
|
||||
|
||||
model.addEquality(LinearExpr.sum(vars.toArray(new LinearArgument[0])), 100);
|
||||
|
||||
if (request.getType() == 2) {
|
||||
|
||||
IntVar gcd = model.newIntVar(1, 100, "gcd");
|
||||
|
||||
List<IntVar> varGcdList = new ArrayList<>();
|
||||
for (IntVar var : vars) {
|
||||
|
||||
model.addModuloEquality(model.newConstant(0), var, gcd);
|
||||
|
||||
// 定义一个变量,表示 percent / gcd
|
||||
IntVar varGcd = model.newIntVar(1, 100, var.getName() + "_gcd");
|
||||
// 约束这个变量
|
||||
model.addDivisionEquality(varGcd, var, gcd);
|
||||
varGcdList.add(varGcd);
|
||||
}
|
||||
|
||||
// 约束 sum(percent / gcd) < request.getPercent2Sum()
|
||||
model.addLessOrEqual(
|
||||
LinearExpr.sum(varGcdList.toArray(new IntVar[0])), request.getPercent2Sum());
|
||||
}
|
||||
|
||||
for (CoalConstraint constrain : request.getConstraints()) {
|
||||
|
||||
private void round(CoalInfo solution) {
|
||||
if (StringUtils.isBlank(constrain.getCode())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
solution.getParameters().forEach(x -> x.setValue(x.getValue() == null ? x.getValue() :
|
||||
BigDecimal.valueOf(x.getValue()).setScale(2, RoundingMode.HALF_UP).doubleValue()));
|
||||
if (constrain.getMin() == null && constrain.getMax() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void acc(CoalInfo solution, long percent, CoalInfo coal) {
|
||||
long[] paramsOfEachCoal = new long[request.getCoals().size()];
|
||||
int index = 0;
|
||||
for (CoalInfo coal : request.getCoals()) {
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (CoalParameter parameter : coal.getParameters()) {
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (CoalParameter solutionParameter : solution.getParameters()) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(parameter.getCode(), solutionParameter.getCode())) {
|
||||
|
||||
solutionParameter.setValue(solutionParameter.getValue() + (parameter.getValue() * percent / 100.0));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
CoalParameter e = new CoalParameter();
|
||||
e.setCode(parameter.getCode());
|
||||
e.setValue(parameter.getValue() * percent / 100.0);
|
||||
solution.getParameters().add(e);
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(parameter.getCode(), constrain.getCode())) {
|
||||
|
||||
paramsOfEachCoal[index++] = (long) (parameter.getValue() * 100);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
|
||||
throw new RuntimeException(
|
||||
String.format(
|
||||
"煤 %s 没有找到指标 %s, 但是存在条件 %s <= %s <= %s",
|
||||
coal.getName(),
|
||||
constrain.getCode(),
|
||||
constrain.getMin(),
|
||||
constrain.getCode(),
|
||||
constrain.getMax()));
|
||||
}
|
||||
}
|
||||
|
||||
if (constrain.getMin() != null) {
|
||||
|
||||
model.addGreaterOrEqual(
|
||||
LinearExpr.weightedSum(vars.toArray(new LinearArgument[0]), paramsOfEachCoal),
|
||||
(long) ((constrain.getMin()) * 10000));
|
||||
}
|
||||
|
||||
if (constrain.getMax() != null) {
|
||||
|
||||
model.addLessOrEqual(
|
||||
LinearExpr.weightedSum(vars.toArray(new LinearArgument[0]), paramsOfEachCoal),
|
||||
(long) ((constrain.getMax()) * 10000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public List<CoalParameterDef> paramDefs() {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource("/config/CoalParameterDef.json");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
List<CoalParameterDef> coalParameterDefs;
|
||||
try (InputStream inputStream = classPathResource.getInputStream()) {
|
||||
coalParameterDefs =
|
||||
mapper.readValue(inputStream, new TypeReference<List<CoalParameterDef>>() {});
|
||||
}
|
||||
|
||||
private void addConstrains(CoalBlendRequest request, CpModel model, List<IntVar> vars) {
|
||||
// 各种煤比例之和为 100
|
||||
|
||||
model.addEquality(LinearExpr.sum(vars.toArray(new LinearArgument[0])), 100);
|
||||
|
||||
if (request.getType() == 2) {
|
||||
|
||||
IntVar gcd = model.newIntVar(1, 100, "gcd");
|
||||
|
||||
List<IntVar> varGcdList = new ArrayList<>();
|
||||
for (IntVar var : vars) {
|
||||
|
||||
|
||||
model.addModuloEquality(model.newConstant(0), var, gcd);
|
||||
|
||||
// 定义一个变量,表示 percent / gcd
|
||||
IntVar varGcd = model.newIntVar(1, 100, var.getName() + "_gcd");
|
||||
// 约束这个变量
|
||||
model.addDivisionEquality(varGcd, var, gcd);
|
||||
varGcdList.add(varGcd);
|
||||
}
|
||||
|
||||
|
||||
// 约束 sum(percent / gcd) < request.getPercent2Sum()
|
||||
model.addLessOrEqual(LinearExpr.sum(varGcdList.toArray(new IntVar[0])), request.getPercent2Sum());
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (CoalConstraint constrain : request.getConstraints()) {
|
||||
|
||||
|
||||
if (StringUtils.isBlank(constrain.getCode())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (constrain.getMin() == null && constrain.getMax() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
long[] paramsOfEachCoal = new long[request.getCoals().size()];
|
||||
int index = 0;
|
||||
for (CoalInfo coal : request.getCoals()) {
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (CoalParameter parameter : coal.getParameters()) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(parameter.getCode(), constrain.getCode())) {
|
||||
|
||||
paramsOfEachCoal[index++] = (long) (parameter.getValue() * 100);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!found) {
|
||||
|
||||
throw new RuntimeException(String.format("煤 %s 没有找到指标 %s, 但是存在条件 %s <= %s <= %s", coal.getName(),
|
||||
constrain.getCode(), constrain.getMin(), constrain.getCode(), constrain.getMax()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (constrain.getMin() != null) {
|
||||
|
||||
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(vars.toArray(new LinearArgument[0]), paramsOfEachCoal),
|
||||
(long) ((constrain.getMin()) * 10000));
|
||||
}
|
||||
|
||||
if (constrain.getMax() != null) {
|
||||
|
||||
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(vars.toArray(new LinearArgument[0]), paramsOfEachCoal),
|
||||
(long) ((constrain.getMax()) * 10000));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public List<CoalParameterDef> paramDefs() {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource("/config/CoalParameterDef.json");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
List<CoalParameterDef> coalParameterDefs;
|
||||
try (InputStream inputStream = classPathResource.getInputStream()) {
|
||||
coalParameterDefs = mapper.readValue(inputStream, new TypeReference<List<CoalParameterDef>>() {
|
||||
});
|
||||
}
|
||||
|
||||
return coalParameterDefs;
|
||||
|
||||
|
||||
}
|
||||
return coalParameterDefs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,47 +18,40 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/coalAnalysis")
|
||||
@SysLog(
|
||||
module = "煤源化验"
|
||||
)
|
||||
@SysLog(module = "煤源化验")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class CoalAnalysisController {
|
||||
@Autowired
|
||||
private CoalAnalysisService service;
|
||||
@Autowired private CoalAnalysisService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public CoalAnalysisDto create(@RequestBody CreateCoalAnalysisDto request) {
|
||||
return this.service.create(request)
|
||||
;
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/calculate")
|
||||
public CoalAnalysisDto calculate(@RequestBody CoalAnalysisDto request) {
|
||||
return this.service.calculate(request)
|
||||
;
|
||||
return this.service.calculate(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public CoalAnalysisDto update(@RequestBody UpdateCoalAnalysisDto request) {
|
||||
return this.service.update(request)
|
||||
;
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public CoalAnalysisDto getById(@RequestBody String request) {
|
||||
return this.service.getById(request)
|
||||
;
|
||||
return this.service.getById(request);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalAnalysisDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request)
|
||||
;
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,132 +3,145 @@ package cn.lihongjie.coal.coalAnalysis.dto;
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class CoalAnalysisDto extends OrgCommonDto {
|
||||
@Comment("关联的煤源信息")
|
||||
private CoalInfoEntity coalInfo;
|
||||
@Comment("关联的煤源信息")
|
||||
private CoalInfoEntity coalInfo;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
public Map<String, Object> toMap() {
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
HashMap<String, Object> ma = new HashMap<>();
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
ma.put("param1", param1);
|
||||
ma.put("param2", param2);
|
||||
ma.put("param3", param3);
|
||||
ma.put("param4", param4);
|
||||
ma.put("param5", param5);
|
||||
ma.put("param6", param6);
|
||||
ma.put("param7", param7);
|
||||
ma.put("param8", param8);
|
||||
ma.put("param9", param9);
|
||||
ma.put("param10", param10);
|
||||
ma.put("param11", param11);
|
||||
ma.put("param12", param12);
|
||||
ma.put("param13", param13);
|
||||
ma.put("param14", param14);
|
||||
ma.put("param15", param15);
|
||||
ma.put("param16", param16);
|
||||
ma.put("param17", param17);
|
||||
ma.put("param18", param18);
|
||||
ma.put("param19", param19);
|
||||
ma.put("param20", param20);
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
return ma;
|
||||
}
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
public void updateFromMap(Map<String, Object> map) {
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
this.param1 = (Double) map.getOrDefault("param1", null);
|
||||
this.param2 = (Double) map.getOrDefault("param2", null);
|
||||
this.param3 = (Double) map.getOrDefault("param3", null);
|
||||
this.param4 = (Double) map.getOrDefault("param4", null);
|
||||
this.param5 = (Double) map.getOrDefault("param5", null);
|
||||
this.param6 = (Double) map.getOrDefault("param6", null);
|
||||
this.param7 = (Double) map.getOrDefault("param7", null);
|
||||
this.param8 = (Double) map.getOrDefault("param8", null);
|
||||
this.param9 = (Double) map.getOrDefault("param9", null);
|
||||
this.param10 = (Double) map.getOrDefault("param10", null);
|
||||
this.param11 = (Double) map.getOrDefault("param11", null);
|
||||
this.param12 = (Double) map.getOrDefault("param12", null);
|
||||
this.param13 = (Double) map.getOrDefault("param13", null);
|
||||
this.param14 = (Double) map.getOrDefault("param14", null);
|
||||
this.param15 = (Double) map.getOrDefault("param15", null);
|
||||
this.param16 = (Double) map.getOrDefault("param16", null);
|
||||
this.param17 = (Double) map.getOrDefault("param17", null);
|
||||
this.param18 = (Double) map.getOrDefault("param18", null);
|
||||
this.param19 = (Double) map.getOrDefault("param19", null);
|
||||
this.param20 = (Double) map.getOrDefault("param20", null);
|
||||
}
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
|
||||
public Map<String, Object> toMap() {
|
||||
|
||||
HashMap<String, Object> ma = new HashMap<>();
|
||||
|
||||
ma.put("param1", param1);
|
||||
ma.put("param2", param2);
|
||||
ma.put("param3", param3);
|
||||
ma.put("param4", param4);
|
||||
ma.put("param5", param5);
|
||||
ma.put("param6", param6);
|
||||
ma.put("param7", param7);
|
||||
ma.put("param8", param8);
|
||||
ma.put("param9", param9);
|
||||
ma.put("param10", param10);
|
||||
ma.put("param11", param11);
|
||||
ma.put("param12", param12);
|
||||
ma.put("param13", param13);
|
||||
ma.put("param14", param14);
|
||||
ma.put("param15", param15);
|
||||
ma.put("param16", param16);
|
||||
ma.put("param17", param17);
|
||||
ma.put("param18", param18);
|
||||
ma.put("param19", param19);
|
||||
ma.put("param20", param20);
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
||||
public void updateFromMap(Map<String, Object> map) {
|
||||
|
||||
this.param1 = (Double) map.getOrDefault("param1", null);
|
||||
this.param2 = (Double) map.getOrDefault("param2", null);
|
||||
this.param3 = (Double) map.getOrDefault("param3", null);
|
||||
this.param4 = (Double) map.getOrDefault("param4", null);
|
||||
this.param5 = (Double) map.getOrDefault("param5", null);
|
||||
this.param6 = (Double) map.getOrDefault("param6", null);
|
||||
this.param7 = (Double) map.getOrDefault("param7", null);
|
||||
this.param8 = (Double) map.getOrDefault("param8", null);
|
||||
this.param9 = (Double) map.getOrDefault("param9", null);
|
||||
this.param10 = (Double) map.getOrDefault("param10", null);
|
||||
this.param11 = (Double) map.getOrDefault("param11", null);
|
||||
this.param12 = (Double) map.getOrDefault("param12", null);
|
||||
this.param13 = (Double) map.getOrDefault("param13", null);
|
||||
this.param14 = (Double) map.getOrDefault("param14", null);
|
||||
this.param15 = (Double) map.getOrDefault("param15", null);
|
||||
this.param16 = (Double) map.getOrDefault("param16", null);
|
||||
this.param17 = (Double) map.getOrDefault("param17", null);
|
||||
this.param18 = (Double) map.getOrDefault("param18", null);
|
||||
this.param19 = (Double) map.getOrDefault("param19", null);
|
||||
this.param20 = (Double) map.getOrDefault("param20", null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,68 +7,86 @@ import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class CreateCoalAnalysisDto extends OrgCommonDto {
|
||||
@Comment("关联的煤源信息")
|
||||
private String coalInfo;
|
||||
@Comment("关联的煤源信息")
|
||||
private String coalInfo;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
}
|
||||
|
||||
@@ -1,76 +1,92 @@
|
||||
package cn.lihongjie.coal.coalAnalysis.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class UpdateCoalAnalysisDto extends OrgCommonDto {
|
||||
@Comment("关联的煤源信息")
|
||||
private String coalInfo;
|
||||
@Comment("关联的煤源信息")
|
||||
private String coalInfo;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
}
|
||||
|
||||
@@ -11,70 +11,87 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
@Entity
|
||||
public class CoalAnalysisEntity extends OrgCommonEntity {
|
||||
@ManyToOne
|
||||
@Comment("关联的煤源信息")
|
||||
private CoalInfoEntity coalInfo;
|
||||
@ManyToOne
|
||||
@Comment("关联的煤源信息")
|
||||
private CoalInfoEntity coalInfo;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.mapstruct.control.DeepClone;
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
)
|
||||
public interface CoalAnalysisMapper extends BaseMapper<CoalAnalysisEntity, CoalAnalysisDto, CreateCoalAnalysisDto, UpdateCoalAnalysisDto> {
|
||||
}
|
||||
mappingControl = DeepClone.class)
|
||||
public interface CoalAnalysisMapper
|
||||
extends BaseMapper<
|
||||
CoalAnalysisEntity, CoalAnalysisDto, CreateCoalAnalysisDto, UpdateCoalAnalysisDto> {}
|
||||
|
||||
@@ -5,5 +5,4 @@ import cn.lihongjie.coal.coalAnalysis.entity.CoalAnalysisEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalAnalysisRepository extends BaseRepository<CoalAnalysisEntity> {
|
||||
}
|
||||
public interface CoalAnalysisRepository extends BaseRepository<CoalAnalysisEntity> {}
|
||||
|
||||
@@ -14,6 +14,11 @@ import cn.lihongjie.coal.coalParameterDef.repository.CoalParameterDefRepository;
|
||||
import cn.lihongjie.coal.common.Ctx;
|
||||
import cn.lihongjie.coal.common.GroovyScriptUtils;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -25,98 +30,82 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CoalAnalysisService extends BaseService<CoalAnalysisEntity, CoalAnalysisRepository> {
|
||||
@Autowired
|
||||
private CoalAnalysisRepository repository;
|
||||
@Autowired private CoalAnalysisRepository repository;
|
||||
|
||||
@Autowired
|
||||
private CoalAnalysisMapper mapper;
|
||||
@Autowired private CoalAnalysisMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private ConversionService conversionService;
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public CoalAnalysisDto create(CreateCoalAnalysisDto request) {
|
||||
CoalAnalysisEntity entity = mapper.toEntity(request);
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId())
|
||||
;
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
CoalParameterDefRepository coalParameterDefRepository;
|
||||
@Autowired CoalParameterDefRepository coalParameterDefRepository;
|
||||
|
||||
public CoalAnalysisDto calculate(CoalAnalysisDto dto) {
|
||||
public CoalAnalysisDto calculate(CoalAnalysisDto dto) {
|
||||
|
||||
List<CoalParameterDefEntity> parameters = coalParameterDefRepository.findByOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
List<CoalParameterDefEntity> parameters =
|
||||
coalParameterDefRepository.findByOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
|
||||
List<CoalParameterDefEntity> toCalculate =
|
||||
parameters.stream()
|
||||
.filter(x -> StringUtils.equalsIgnoreCase(x.getInputType(), "1"))
|
||||
.sorted(Comparator.comparing(x -> ObjectUtils.defaultIfNull(x.getPriority(), -1)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CoalParameterDefEntity> toCalculate = parameters.stream().filter(x -> StringUtils.equalsIgnoreCase(x.getInputType(), "1")).sorted(Comparator.comparing(x -> ObjectUtils.defaultIfNull(x.getPriority(), -1))).collect(Collectors.toList());
|
||||
Map<String, Object> map = dto.toMap();
|
||||
|
||||
for (CoalParameterDefEntity def : toCalculate) {
|
||||
|
||||
Map<String, Object> map = dto.toMap();
|
||||
|
||||
for (CoalParameterDefEntity def : toCalculate) {
|
||||
|
||||
Object exec = GroovyScriptUtils.exec(def.getFormula0(), map);
|
||||
|
||||
if (exec!=null && !(exec instanceof Number)) {
|
||||
throw new BizException("计算结果不是数字");
|
||||
}
|
||||
|
||||
Double value = exec != null ? NumberUtils.toDouble(exec + "") : null;
|
||||
if (value != null) {
|
||||
value = BigDecimal.valueOf(value).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
map.put(def.getCode(), value);
|
||||
}
|
||||
|
||||
|
||||
dto.updateFromMap(map);
|
||||
|
||||
return dto;
|
||||
|
||||
Object exec = GroovyScriptUtils.exec(def.getFormula0(), map);
|
||||
|
||||
if (exec != null && !(exec instanceof Number)) {
|
||||
throw new BizException("计算结果不是数字");
|
||||
}
|
||||
|
||||
Double value = exec != null ? NumberUtils.toDouble(exec + "") : null;
|
||||
if (value != null) {
|
||||
value = BigDecimal.valueOf(value).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
map.put(def.getCode(), value);
|
||||
}
|
||||
|
||||
dto.updateFromMap(map);
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
public CoalAnalysisDto update(UpdateCoalAnalysisDto request) {
|
||||
CoalAnalysisEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId())
|
||||
;
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
;
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public CoalAnalysisDto getById(String id) {
|
||||
CoalAnalysisEntity entity = repository.get(id);
|
||||
|
||||
|
||||
return mapper.toDto(entity)
|
||||
;
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<CoalAnalysisDto> list(CommonQuery query) {
|
||||
Page<CoalAnalysisEntity> page = repository.findAll(query.specification(conversionService), PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
Page<CoalAnalysisEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto)
|
||||
;
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import cn.lihongjie.coal.base.controller.BaseController;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CoalBlendDto;
|
||||
import cn.lihongjie.coal.coalBlend.service.CoalBlendService;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CreateCoalBlendDto;
|
||||
import cn.lihongjie.coal.coalBlend.dto.UpdateCoalBlendDto;
|
||||
import cn.lihongjie.coal.coalBlend.service.CoalBlendService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -22,45 +22,40 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Anonymous
|
||||
public class CoalBlendController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
CoalBlendService service;
|
||||
@Autowired CoalBlendService service;
|
||||
|
||||
@PostMapping("/blend")
|
||||
@SysLog(action = "配煤")
|
||||
public CoalBlendDto blend(@RequestBody CreateCoalBlendDto dto) {
|
||||
return this.service.blend(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/blend")
|
||||
@SysLog(action = "配煤")
|
||||
public CoalBlendDto blend(@RequestBody CreateCoalBlendDto dto) {
|
||||
return this.service.blend(dto);
|
||||
}
|
||||
@PostMapping("/create")
|
||||
@SysLog(action = "新增")
|
||||
public CoalBlendDto create(@RequestBody CreateCoalBlendDto dto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@SysLog(action = "新增")
|
||||
public CoalBlendDto create(@RequestBody CreateCoalBlendDto dto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
@PostMapping("/update")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalBlendDto update(@RequestBody UpdateCoalBlendDto dto) {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalBlendDto update(@RequestBody UpdateCoalBlendDto dto) {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
this.service.delete(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalBlendDto> list(@RequestBody CommonQuery dto) {
|
||||
return this.service.list(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
this.service.delete(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalBlendDto> list(@RequestBody CommonQuery dto) {
|
||||
return this.service.list(dto);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getById")
|
||||
public CoalBlendDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
@PostMapping("/getById")
|
||||
public CoalBlendDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,92 +14,182 @@ import org.hibernate.validator.constraints.Range;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@NoArgsConstructor
|
||||
public class CoalBlendCoalInfoDto extends OrgCommonDto {
|
||||
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Comment("比例最小值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class, min = 0, max = 100, message = "无效的比例")
|
||||
private Integer minPercent;
|
||||
|
||||
@Comment("比例最大值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class, min = 0, max = 100, message = "无效的比例")
|
||||
private Integer maxPercent;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("比例最小值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class,min = 0, max = 100, message = "无效的比例")
|
||||
private Integer minPercent;
|
||||
@Comment("比例最大值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class,min = 0, max = 100, message = "无效的比例")
|
||||
private Integer maxPercent;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,47 +6,41 @@ import cn.lihongjie.coal.coalBlend.entity.CoalParameterDefVo;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Comment("配煤记录")
|
||||
public class CoalBlendDto extends OrgCommonDto {
|
||||
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoDto> coals;
|
||||
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoDto> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
private List<CoalBlendResultInfoDto> results;
|
||||
|
||||
private List<CoalBlendResultInfoDto> results;
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
@Comment("最长等待时间")
|
||||
private Integer maxTime = 10;
|
||||
|
||||
@Comment("铲车配煤 配比之和 最大值")
|
||||
private Integer type2PercentSum = 10;
|
||||
|
||||
@Comment("最长等待时间")
|
||||
private Integer maxTime = 10;
|
||||
|
||||
@Comment("铲车配煤 配比之和 最大值")
|
||||
private Integer type2PercentSum = 10;
|
||||
|
||||
@Comment("目标参数, 比如: param1 param2")
|
||||
private String targetParam = "";
|
||||
|
||||
|
||||
@Comment("求目标参数最大值 -1, 最小值 1")
|
||||
private Integer targetOrder = -1;
|
||||
|
||||
@Comment("目标参数, 比如: param1 param2")
|
||||
private String targetParam = "";
|
||||
|
||||
@Comment("求目标参数最大值 -1, 最小值 1")
|
||||
private Integer targetOrder = -1;
|
||||
}
|
||||
|
||||
@@ -3,57 +3,39 @@ package cn.lihongjie.coal.coalBlend.dto;
|
||||
import cn.lihongjie.coal.coal.CoalConstraint;
|
||||
import cn.lihongjie.coal.coal.CoalInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalBlendRequest {
|
||||
private List<CoalInfo> coals;
|
||||
private List<CoalInfo> coals;
|
||||
|
||||
private List<CoalConstraint> constraints;
|
||||
@JsonIgnore private Map<String, CoalConstraint> constraintMap;
|
||||
|
||||
private List<CoalConstraint> constraints;
|
||||
@JsonIgnore
|
||||
private Map<String, CoalConstraint> constraintMap;
|
||||
/** 1 高精度 2 低精度(用于铲车配煤 类似 1:3 整比例) */
|
||||
private Integer type = 1;
|
||||
/** 低精度配比之和最大值 */
|
||||
private int percent2Sum = 10;
|
||||
|
||||
/**
|
||||
* 1 高精度
|
||||
* 2 低精度(用于铲车配煤 类似 1:3 整比例)
|
||||
*/
|
||||
private Integer type = 1;
|
||||
/**
|
||||
* 低精度配比之和最大值
|
||||
*/
|
||||
private int percent2Sum = 10;
|
||||
public Map<String, CoalConstraint> getConstraintMap() {
|
||||
if (constraintMap == null) {
|
||||
if (constraints != null) {
|
||||
|
||||
|
||||
|
||||
public Map<String, CoalConstraint> getConstraintMap() {
|
||||
if (constraintMap == null) {
|
||||
if (constraints != null) {
|
||||
|
||||
constraintMap = constraints.stream().collect(Collectors.toMap(e -> e.getCode(), e -> e));
|
||||
}else {
|
||||
constraintMap = new HashMap<>();
|
||||
}
|
||||
}
|
||||
return constraintMap;
|
||||
constraintMap = constraints.stream().collect(Collectors.toMap(e -> e.getCode(), e -> e));
|
||||
} else {
|
||||
constraintMap = new HashMap<>();
|
||||
}
|
||||
}
|
||||
return constraintMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结果个数
|
||||
*/
|
||||
private Long count = 10L;
|
||||
|
||||
|
||||
/**
|
||||
* 最长等待时间
|
||||
*/
|
||||
private Long maxTime = 10L;
|
||||
|
||||
|
||||
/** 结果个数 */
|
||||
private Long count = 10L;
|
||||
|
||||
/** 最长等待时间 */
|
||||
private Long maxTime = 10L;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
package cn.lihongjie.coal.coalBlend.dto;
|
||||
|
||||
import cn.lihongjie.coal.coal.CoalInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CoalBlendResult {
|
||||
private long numBranches = 0;
|
||||
private long numConflicts = 0;
|
||||
private long wallTime = 0;
|
||||
private long userTime = 0;
|
||||
private List<CoalInfo> coals = new ArrayList<>();
|
||||
private int totalCount;
|
||||
|
||||
public String tableString() {
|
||||
|
||||
|
||||
String headerLine = String.format("totalCount %s numBranches %s numConflicts %s wallTime %s userTime %s \n",
|
||||
totalCount, numBranches,
|
||||
numConflicts, wallTime, userTime);
|
||||
String collect = coals.stream().map(x -> x.rowString()).collect(Collectors.joining("\n"));
|
||||
return headerLine + collect;
|
||||
|
||||
}
|
||||
private long numBranches = 0;
|
||||
private long numConflicts = 0;
|
||||
private long wallTime = 0;
|
||||
private long userTime = 0;
|
||||
private List<CoalInfo> coals = new ArrayList<>();
|
||||
private int totalCount;
|
||||
|
||||
public String tableString() {
|
||||
|
||||
String headerLine =
|
||||
String.format(
|
||||
"totalCount %s numBranches %s numConflicts %s wallTime %s userTime %s \n",
|
||||
totalCount, numBranches, numConflicts, wallTime, userTime);
|
||||
String collect = coals.stream().map(x -> x.rowString()).collect(Collectors.joining("\n"));
|
||||
return headerLine + collect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import cn.lihongjie.coal.coalBlend.entity.CoalBlendEntity;
|
||||
import cn.lihongjie.coal.coalBlend.entity.CoalPercentVo;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -12,103 +15,186 @@ import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@NoArgsConstructor
|
||||
public class CoalBlendResultInfoDto extends OrgCommonDto {
|
||||
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
|
||||
private List<CoalPercentVo> percentInfos;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
private List<CoalPercentVo> percentInfos;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
public long getHashKey(){
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
return
|
||||
Arrays.hashCode(this.getPercentInfos().stream().sorted(Comparator.comparing(x->x.getPercent())).toArray(CoalPercentVo[]::new));
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
}
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
|
||||
public long getHashKey() {
|
||||
|
||||
return Arrays.hashCode(
|
||||
this.getPercentInfos().stream()
|
||||
.sorted(Comparator.comparing(x -> x.getPercent()))
|
||||
.toArray(CoalPercentVo[]::new));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,48 +6,41 @@ import cn.lihongjie.coal.coalBlend.entity.CoalParameterDefVo;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Comment("配煤记录")
|
||||
public class CreateCoalBlendDto extends OrgCommonDto {
|
||||
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoDto> coals;
|
||||
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoDto> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
private List<CoalBlendResultInfoDto> results;
|
||||
|
||||
private List<CoalBlendResultInfoDto> results;
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
@Comment("最长等待时间")
|
||||
private Integer maxTime = 10;
|
||||
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
|
||||
@Comment("最长等待时间")
|
||||
private Integer maxTime = 10;
|
||||
|
||||
@Comment("铲车配煤 配比之和 最大值")
|
||||
private Integer type2PercentSum = 10;
|
||||
|
||||
@Comment("目标参数, 比如: param1 param2")
|
||||
private String targetParam = "";
|
||||
|
||||
|
||||
@Comment("求目标参数最大值 -1, 最小值 1")
|
||||
private Integer targetOrder = -1;
|
||||
@Comment("铲车配煤 配比之和 最大值")
|
||||
private Integer type2PercentSum = 10;
|
||||
|
||||
@Comment("目标参数, 比如: param1 param2")
|
||||
private String targetParam = "";
|
||||
|
||||
@Comment("求目标参数最大值 -1, 最小值 1")
|
||||
private Integer targetOrder = -1;
|
||||
}
|
||||
|
||||
@@ -6,47 +6,40 @@ import cn.lihongjie.coal.coalBlend.entity.CoalParameterDefVo;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Comment("配煤记录")
|
||||
public class UpdateCoalBlendDto extends OrgCommonDto {
|
||||
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoDto> coals;
|
||||
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoDto> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
private List<CoalBlendResultInfoDto> results;
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
|
||||
private List<CoalBlendResultInfoDto> results;
|
||||
private String blendTypeName;
|
||||
private String blendType;
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
@Comment("最长等待时间")
|
||||
private Integer maxTime = 10;
|
||||
|
||||
@Comment("结果个数")
|
||||
private Integer count = 20;
|
||||
|
||||
|
||||
@Comment("最长等待时间")
|
||||
private Integer maxTime = 10;
|
||||
|
||||
@Comment("铲车配煤 配比之和 最大值")
|
||||
private Integer type2PercentSum = 10;
|
||||
|
||||
@Comment("目标参数, 比如: param1 param2")
|
||||
private String targetParam = "";
|
||||
|
||||
|
||||
@Comment("求目标参数最大值 -1, 最小值 1")
|
||||
private Integer targetOrder = -1;
|
||||
@Comment("铲车配煤 配比之和 最大值")
|
||||
private Integer type2PercentSum = 10;
|
||||
|
||||
@Comment("目标参数, 比如: param1 param2")
|
||||
private String targetParam = "";
|
||||
|
||||
@Comment("求目标参数最大值 -1, 最小值 1")
|
||||
private Integer targetOrder = -1;
|
||||
}
|
||||
|
||||
@@ -12,95 +12,186 @@ import org.hibernate.validator.constraints.Range;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@NoArgsConstructor
|
||||
@With
|
||||
@Entity
|
||||
public class CoalBlendCoalInfoEntity extends OrgCommonEntity {
|
||||
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ManyToOne() private CoalBlendEntity coal;
|
||||
|
||||
@ManyToOne()
|
||||
private CoalBlendEntity coal;
|
||||
@Comment("比例最小值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class, min = 0, max = 100, message = "无效的比例")
|
||||
private Integer minPercent;
|
||||
|
||||
@Comment("比例最大值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class, min = 0, max = 100, message = "无效的比例")
|
||||
private Integer maxPercent;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("比例最小值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class,min = 0, max = 100, message = "无效的比例")
|
||||
private Integer minPercent;
|
||||
@Comment("比例最大值")
|
||||
@Range(groups = CoalBlendEntity.BlendGroup.class,min = 0, max = 100, message = "无效的比例")
|
||||
private Integer maxPercent;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,207 +10,203 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
public class CoalBlendConstrainVo {
|
||||
|
||||
@Comment("参数1最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param1Max;
|
||||
|
||||
@Comment("参数1最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param1Max;
|
||||
@Comment("参数1最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param1Min;
|
||||
@Comment("参数2最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param2Min;
|
||||
@Comment("参数1最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param1Min;
|
||||
|
||||
@Comment("参数2最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param2Max;
|
||||
@Comment("参数2最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param2Min;
|
||||
|
||||
@Comment("参数3最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param3Min;
|
||||
@Comment("参数2最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param2Max;
|
||||
|
||||
@Comment("参数3最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param3Max;
|
||||
@Comment("参数3最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param3Min;
|
||||
|
||||
@Comment("参数4最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param4Min;
|
||||
@Comment("参数3最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param3Max;
|
||||
|
||||
@Comment("参数4最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param4Max;
|
||||
@Comment("参数4最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param4Min;
|
||||
|
||||
@Comment("参数5最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param5Min;
|
||||
@Comment("参数4最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param4Max;
|
||||
|
||||
@Comment("参数5最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param5Max;
|
||||
@Comment("参数5最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param5Min;
|
||||
|
||||
@Comment("参数6最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param6Min;
|
||||
@Comment("参数5最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param5Max;
|
||||
|
||||
@Comment("参数6最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param6Max;
|
||||
@Comment("参数6最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param6Min;
|
||||
|
||||
@Comment("参数7最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param7Min;
|
||||
@Comment("参数6最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param6Max;
|
||||
|
||||
@Comment("参数7最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param7Max;
|
||||
@Comment("参数7最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param7Min;
|
||||
|
||||
@Comment("参数8最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param8Min;
|
||||
@Comment("参数7最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param7Max;
|
||||
|
||||
@Comment("参数8最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param8Max;
|
||||
@Comment("参数8最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param8Min;
|
||||
|
||||
@Comment("参数9最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param9Min;
|
||||
@Comment("参数8最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param8Max;
|
||||
|
||||
@Comment("参数9最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param9Max;
|
||||
@Comment("参数9最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param9Min;
|
||||
|
||||
@Comment("参数10最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param10Min;
|
||||
@Comment("参数9最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param9Max;
|
||||
|
||||
@Comment("参数10最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param10Max;
|
||||
@Comment("参数10最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param10Min;
|
||||
|
||||
@Comment("参数11最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param11Min;
|
||||
@Comment("参数10最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param10Max;
|
||||
|
||||
@Comment("参数11最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param11Max;
|
||||
@Comment("参数11最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param11Min;
|
||||
|
||||
@Comment("参数12最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param12Min;
|
||||
@Comment("参数11最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param11Max;
|
||||
|
||||
@Comment("参数12最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param12Max;
|
||||
@Comment("参数12最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param12Min;
|
||||
|
||||
@Comment("参数13最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param13Min;
|
||||
@Comment("参数12最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param12Max;
|
||||
|
||||
@Comment("参数13最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param13Max;
|
||||
@Comment("参数13最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param13Min;
|
||||
|
||||
@Comment("参数14最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param14Min;
|
||||
@Comment("参数13最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param13Max;
|
||||
|
||||
@Comment("参数14最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param14Max;
|
||||
@Comment("参数14最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param14Min;
|
||||
|
||||
@Comment("参数15最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param15Min;
|
||||
@Comment("参数14最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param14Max;
|
||||
|
||||
@Comment("参数15最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param15Max;
|
||||
@Comment("参数15最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param15Min;
|
||||
|
||||
@Comment("参数16最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param16Min;
|
||||
@Comment("参数15最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param15Max;
|
||||
|
||||
@Comment("参数16最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param16Max;
|
||||
@Comment("参数16最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param16Min;
|
||||
|
||||
@Comment("参数17最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param17Min;
|
||||
@Comment("参数16最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param16Max;
|
||||
|
||||
@Comment("参数17最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param17Max;
|
||||
@Comment("参数17最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param17Min;
|
||||
|
||||
@Comment("参数18最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param18Min;
|
||||
@Comment("参数17最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param17Max;
|
||||
|
||||
@Comment("参数18最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param18Max;
|
||||
|
||||
@Comment("参数19最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param19Min;
|
||||
|
||||
@Comment("参数19最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param19Max;
|
||||
|
||||
@Comment("参数20最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param20Min;
|
||||
|
||||
@Comment("参数20最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param20Max;
|
||||
@Comment("参数18最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param18Min;
|
||||
|
||||
@Comment("参数18最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param18Max;
|
||||
|
||||
@Comment("参数19最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param19Min;
|
||||
|
||||
@Comment("参数19最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param19Max;
|
||||
|
||||
@Comment("参数20最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param20Min;
|
||||
|
||||
@Comment("参数20最大值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class, value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", message = "最小值无效")
|
||||
private Double param20Max;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,111 +5,196 @@ import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import lombok.*;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@NoArgsConstructor
|
||||
@With
|
||||
@Entity
|
||||
public class CoalBlendResultInfoEntity extends OrgCommonEntity {
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
@ElementCollection private List<CoalPercentVo> percentInfos;
|
||||
|
||||
@ManyToOne private CoalBlendEntity coal;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
|
||||
@ElementCollection
|
||||
private List<CoalPercentVo> percentInfos;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
|
||||
@ManyToOne
|
||||
private CoalBlendEntity coal;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
|
||||
@Comment("参数 1 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param1;
|
||||
@Comment("参数 2 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param2;
|
||||
@Comment("参数 3 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param3;
|
||||
@Comment("参数 4 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param4;
|
||||
@Comment("参数 5 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param5;
|
||||
@Comment("参数 6 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param6;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
@Comment("参数 7 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param7;
|
||||
|
||||
@Comment("参数 8 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param8;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
@Comment("参数 9 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param9;
|
||||
|
||||
@Comment("参数 10 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
|
||||
@Comment("参数 11 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
|
||||
public long getHashKey(){
|
||||
@Comment("参数 12 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
|
||||
return
|
||||
Arrays.hashCode(this.getPercentInfos().stream().sorted(Comparator.comparing(x->x.getPercent())).toArray(CoalPercentVo[]::new));
|
||||
@Comment("参数 13 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
|
||||
}
|
||||
@Comment("参数 14 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
|
||||
@Comment("参数 15 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
|
||||
@Comment("参数 16 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
|
||||
@Comment("参数 17 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
|
||||
@Comment("参数 18 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
|
||||
@Comment("参数 19 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
|
||||
@Comment("参数 20 ")
|
||||
@DecimalMin(
|
||||
groups = CoalBlendEntity.BlendGroup.class,
|
||||
value = "0.1",
|
||||
inclusive = true,
|
||||
message = "参数不能小于0.1")
|
||||
private Double param20;
|
||||
|
||||
@SneakyThrows
|
||||
public Double getParam(String param) {
|
||||
return (Double) FieldUtils.getField(this.getClass(), param, true).get(this);
|
||||
}
|
||||
|
||||
public long getHashKey() {
|
||||
|
||||
return Arrays.hashCode(
|
||||
this.getPercentInfos().stream()
|
||||
.sorted(Comparator.comparing(x -> x.getPercent()))
|
||||
.toArray(CoalPercentVo[]::new));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.coalBlend.entity;
|
||||
|
||||
public enum CoalBlendType {
|
||||
TYPE1, TYPE2
|
||||
TYPE1,
|
||||
TYPE2
|
||||
}
|
||||
|
||||
@@ -7,27 +7,23 @@ import org.hibernate.annotations.Comment;
|
||||
@Embeddable
|
||||
@Data
|
||||
public class CoalParameterDefVo {
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
@Comment("备注")
|
||||
private String parentName;
|
||||
|
||||
@Comment("备注")
|
||||
private String parentName;
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private Integer status;
|
||||
|
||||
private String id;
|
||||
private String id;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.coalBlend.entity;
|
||||
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -13,14 +12,12 @@ import org.hibernate.annotations.Comment;
|
||||
@NoArgsConstructor
|
||||
public class CoalPercentVo {
|
||||
|
||||
@Comment("煤名称")
|
||||
private String name;
|
||||
@Comment("煤的精确比例")
|
||||
private Double percent;
|
||||
@Comment("煤的铲车配煤比例")
|
||||
private Double type2Percent;
|
||||
|
||||
|
||||
@Comment("煤名称")
|
||||
private String name;
|
||||
|
||||
@Comment("煤的精确比例")
|
||||
private Double percent;
|
||||
|
||||
@Comment("煤的铲车配煤比例")
|
||||
private Double type2Percent;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.coalBlend.mapper;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CoalBlendDto;
|
||||
@@ -15,27 +14,24 @@ import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface CoalBlendMapper
|
||||
extends BaseMapper<CoalBlendEntity, CoalBlendDto, CreateCoalBlendDto, UpdateCoalBlendDto> {
|
||||
|
||||
)
|
||||
public interface CoalBlendMapper extends BaseMapper<CoalBlendEntity, CoalBlendDto, CreateCoalBlendDto, UpdateCoalBlendDto> {
|
||||
|
||||
|
||||
@AfterMapping
|
||||
public default void convertNameToUpperCase(CreateCoalBlendDto dto, @MappingTarget CoalBlendEntity entity) {
|
||||
if (CollectionUtils.isNotEmpty(entity.getCoals())) {
|
||||
|
||||
entity.getCoals().forEach(x -> x.setId(null));
|
||||
|
||||
entity.getCoals().forEach(x -> x.setCoal(entity));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(entity.getResults())) {
|
||||
|
||||
entity.getResults().forEach(x -> x.setCoal(entity));
|
||||
}
|
||||
@AfterMapping
|
||||
public default void convertNameToUpperCase(
|
||||
CreateCoalBlendDto dto, @MappingTarget CoalBlendEntity entity) {
|
||||
if (CollectionUtils.isNotEmpty(entity.getCoals())) {
|
||||
|
||||
entity.getCoals().forEach(x -> x.setId(null));
|
||||
|
||||
entity.getCoals().forEach(x -> x.setCoal(entity));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(entity.getResults())) {
|
||||
|
||||
entity.getResults().forEach(x -> x.setCoal(entity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,4 @@ import cn.lihongjie.coal.coalBlend.entity.CoalBlendEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalBlendRepository extends BaseRepository<CoalBlendEntity> {
|
||||
}
|
||||
public interface CoalBlendRepository extends BaseRepository<CoalBlendEntity> {}
|
||||
|
||||
@@ -24,89 +24,73 @@ import org.springframework.util.StopWatch;
|
||||
@Slf4j
|
||||
public class CoalBlendService extends BaseService<CoalBlendEntity, CoalBlendRepository> {
|
||||
|
||||
@Autowired
|
||||
CoalBlendRepository repository;
|
||||
@Autowired CoalBlendRepository repository;
|
||||
|
||||
@Autowired
|
||||
CoalBlendMapper mapper;
|
||||
@Autowired CoalBlendMapper mapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
public CoalBlendDto create(CreateCoalBlendDto request) {
|
||||
request.getCoals().forEach(x -> x.setId(null));
|
||||
|
||||
CoalBlendEntity entity = mapper.toEntity(request);
|
||||
|
||||
}
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public CoalBlendDto update(UpdateCoalBlendDto request) {
|
||||
CoalBlendEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
public CoalBlendDto create(CreateCoalBlendDto request) {
|
||||
request.getCoals().forEach(x -> x.setId(null));
|
||||
this.repository.save(entity);
|
||||
|
||||
CoalBlendEntity entity = mapper.toEntity(request);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
}
|
||||
public CoalBlendDto getById(String id) {
|
||||
|
||||
CoalBlendEntity entity = repository.get(id);
|
||||
|
||||
public CoalBlendDto update(UpdateCoalBlendDto request) {
|
||||
CoalBlendEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
@Autowired ConversionService conversionService;
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
public Page<CoalBlendDto> list(CommonQuery query) {
|
||||
|
||||
Page<CoalBlendEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
@Autowired RoundMapper roundMapper;
|
||||
|
||||
}
|
||||
public CoalBlendDto blend(CreateCoalBlendDto dto) {
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
public CoalBlendDto getById(String id) {
|
||||
stopWatch.start("toEntity");
|
||||
CoalBlendEntity entity = this.mapper.toEntity(dto);
|
||||
stopWatch.stop();
|
||||
stopWatch.start("blend");
|
||||
entity.blend();
|
||||
stopWatch.stop();
|
||||
stopWatch.start("toDto");
|
||||
CoalBlendDto blendDto = this.mapper.toDto(entity);
|
||||
|
||||
CoalBlendEntity entity = repository.get(id);
|
||||
stopWatch.stop();
|
||||
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
ConversionService conversionService;
|
||||
|
||||
public Page<CoalBlendDto> list(CommonQuery query) {
|
||||
|
||||
Page<CoalBlendEntity> page = repository.findAll(query.specification(conversionService), PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
RoundMapper roundMapper;
|
||||
|
||||
public CoalBlendDto blend(CreateCoalBlendDto dto) {
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
stopWatch.start("toEntity");
|
||||
CoalBlendEntity entity = this.mapper.toEntity(dto);
|
||||
stopWatch.stop();
|
||||
stopWatch.start("blend");
|
||||
entity.blend();
|
||||
stopWatch.stop();
|
||||
stopWatch.start("toDto");
|
||||
CoalBlendDto blendDto = this.mapper.toDto(entity);
|
||||
|
||||
stopWatch.stop();
|
||||
|
||||
log.info(stopWatch.prettyPrint());
|
||||
return roundMapper.round(blendDto);
|
||||
}
|
||||
log.info(stopWatch.prettyPrint());
|
||||
return roundMapper.round(blendDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,42 +18,35 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/coalInfo")
|
||||
@SysLog(
|
||||
module = "煤源信息"
|
||||
)
|
||||
@SysLog(module = "煤源信息")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class CoalInfoController {
|
||||
@Autowired
|
||||
private CoalInfoService service;
|
||||
@Autowired private CoalInfoService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public CoalInfoDto create(@RequestBody CreateCoalInfoDto request) {
|
||||
return this.service.create(request)
|
||||
;
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public CoalInfoDto update(@RequestBody UpdateCoalInfoDto request) {
|
||||
return this.service.update(request)
|
||||
;
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public CoalInfoDto getById(@RequestBody String request) {
|
||||
return this.service.getById(request)
|
||||
;
|
||||
return this.service.getById(request);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalInfoDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request)
|
||||
;
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,14 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
public class CoalInfoDto extends OrgCommonDto {
|
||||
|
||||
@Comment("供应商")
|
||||
private String supplier;
|
||||
@Comment("供应商")
|
||||
private String supplier;
|
||||
|
||||
private String supplierName;
|
||||
private String supplierName;
|
||||
|
||||
private String coalTypeName;
|
||||
private String coalType;
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
private String coalTypeName;
|
||||
private String coalType;
|
||||
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
public class CreateCoalInfoDto extends OrgCommonDto {
|
||||
|
||||
@Comment("供应商")
|
||||
private String supplier;
|
||||
@Comment("供应商")
|
||||
private String supplier;
|
||||
|
||||
private String coalType;
|
||||
private String coalType;
|
||||
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class UpdateCoalInfoDto extends OrgCommonDto {
|
||||
@Comment("供应商")
|
||||
private String supplier;
|
||||
@Comment("供应商")
|
||||
private String supplier;
|
||||
|
||||
private String coalType;
|
||||
|
||||
private String coalType;
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
}
|
||||
|
||||
@@ -12,43 +12,32 @@ import org.hibernate.annotations.Formula;
|
||||
@Entity
|
||||
public class CoalInfoEntity extends OrgCommonEntity {
|
||||
|
||||
@ManyToOne
|
||||
@Comment("供应商")
|
||||
private SupplierEntity supplier;
|
||||
@ManyToOne
|
||||
@Comment("供应商")
|
||||
private SupplierEntity supplier;
|
||||
|
||||
@Comment("煤源类型")
|
||||
private String coalType;
|
||||
|
||||
@Comment("煤源类型")
|
||||
private String coalType;
|
||||
@Formula(
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'coal.type'\n"
|
||||
+ " and i.code = coal_type)")
|
||||
private String coalTypeName;
|
||||
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
|
||||
@Formula("(select i.name\n" +
|
||||
"from t_dictionary d,\n" +
|
||||
" t_dictionary_item i\n" +
|
||||
"where d.id = i.dictionary_id\n" +
|
||||
" and d.code = 'coal.type'\n" +
|
||||
" and i.code = coal_type)")
|
||||
private String coalTypeName;
|
||||
public String getSupplierName() {
|
||||
|
||||
if (supplier != null) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Comment("初始报价")
|
||||
private Double initPrice;
|
||||
|
||||
|
||||
public String getSupplierName() {
|
||||
|
||||
if (supplier != null) {
|
||||
|
||||
return supplier.getName();
|
||||
}else {
|
||||
return "";
|
||||
}
|
||||
return supplier.getName();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,14 @@ import cn.lihongjie.coal.coalInfo.dto.CreateCoalInfoDto;
|
||||
import cn.lihongjie.coal.coalInfo.dto.UpdateCoalInfoDto;
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
)
|
||||
public interface CoalInfoMapper extends BaseMapper<CoalInfoEntity, CoalInfoDto, CreateCoalInfoDto, UpdateCoalInfoDto> {
|
||||
@Override
|
||||
CoalInfoDto toDto(CoalInfoEntity user);
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface CoalInfoMapper
|
||||
extends BaseMapper<CoalInfoEntity, CoalInfoDto, CreateCoalInfoDto, UpdateCoalInfoDto> {
|
||||
@Override
|
||||
CoalInfoDto toDto(CoalInfoEntity user);
|
||||
}
|
||||
|
||||
@@ -5,5 +5,4 @@ import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalInfoRepository extends BaseRepository<CoalInfoEntity> {
|
||||
}
|
||||
public interface CoalInfoRepository extends BaseRepository<CoalInfoEntity> {}
|
||||
|
||||
@@ -11,6 +11,7 @@ import cn.lihongjie.coal.coalInfo.mapper.CoalInfoMapper;
|
||||
import cn.lihongjie.coal.coalInfo.repository.CoalInfoRepository;
|
||||
import cn.lihongjie.coal.coalPrice.entity.CoalPriceEntity;
|
||||
import cn.lihongjie.coal.coalPrice.service.CoalPriceService;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -19,74 +20,63 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CoalInfoService extends BaseService<CoalInfoEntity, CoalInfoRepository> {
|
||||
@Autowired
|
||||
private CoalInfoRepository repository;
|
||||
@Autowired private CoalInfoRepository repository;
|
||||
|
||||
@Autowired
|
||||
private CoalInfoMapper mapper;
|
||||
@Autowired private CoalInfoMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private ConversionService conversionService;
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired
|
||||
CoalPriceService coalPriceService;
|
||||
@Autowired CoalPriceService coalPriceService;
|
||||
|
||||
public CoalInfoDto create(CreateCoalInfoDto request) {
|
||||
CoalInfoEntity entity = mapper.toEntity(request);
|
||||
public CoalInfoDto create(CreateCoalInfoDto request) {
|
||||
CoalInfoEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
this.repository.save(entity);
|
||||
updatePrice(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
updatePrice(entity);
|
||||
return getById(entity.getId())
|
||||
;
|
||||
private void updatePrice(CoalInfoEntity entity) {
|
||||
CoalPriceEntity coalPrice = new CoalPriceEntity();
|
||||
coalPrice.setCoalInfo(entity);
|
||||
coalPrice.setPrice(entity.getInitPrice());
|
||||
|
||||
coalPriceService.save(coalPrice);
|
||||
}
|
||||
|
||||
public CoalInfoDto update(UpdateCoalInfoDto request) {
|
||||
CoalInfoEntity entity = this.repository.get(request.getId());
|
||||
Double old = entity.getInitPrice();
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
if (!Objects.equals(old, request.getInitPrice())) {
|
||||
|
||||
updatePrice(entity);
|
||||
}
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
private void updatePrice(CoalInfoEntity entity) {
|
||||
CoalPriceEntity coalPrice = new CoalPriceEntity();
|
||||
coalPrice.setCoalInfo(entity);
|
||||
coalPrice.setPrice(entity.getInitPrice());
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
coalPriceService.save(coalPrice);
|
||||
}
|
||||
public CoalInfoDto getById(String id) {
|
||||
CoalInfoEntity entity = repository.get(id);
|
||||
|
||||
public CoalInfoDto update(UpdateCoalInfoDto request) {
|
||||
CoalInfoEntity entity = this.repository.get(request.getId());
|
||||
Double old = entity.getInitPrice();
|
||||
this.mapper.updateEntity(entity, request);
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
if (!Objects.equals(old, request.getInitPrice())) {
|
||||
public Page<CoalInfoDto> list(CommonQuery query) {
|
||||
Page<CoalInfoEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
updatePrice(entity);
|
||||
}
|
||||
return getById(entity.getId())
|
||||
;
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
;
|
||||
}
|
||||
|
||||
public CoalInfoDto getById(String id) {
|
||||
CoalInfoEntity entity = repository.get(id);
|
||||
|
||||
|
||||
return mapper.toDto(entity)
|
||||
;
|
||||
}
|
||||
|
||||
public Page<CoalInfoDto> list(CommonQuery query) {
|
||||
Page<CoalInfoEntity> page = repository.findAll(query.specification(conversionService), PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto)
|
||||
;
|
||||
}
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import cn.lihongjie.coal.base.controller.BaseController;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.coalParameterDef.dto.CoalParameterDefDto;
|
||||
import cn.lihongjie.coal.coalParameterDef.service.CoalParameterDefService;
|
||||
import cn.lihongjie.coal.coalParameterDef.dto.CreateCoalParameterDefDto;
|
||||
import cn.lihongjie.coal.coalParameterDef.dto.UpdateCoalParameterDefDto;
|
||||
import cn.lihongjie.coal.coalParameterDef.service.CoalParameterDefService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -24,38 +24,34 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@OrgScope
|
||||
public class CoalParameterDefController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
CoalParameterDefService service;
|
||||
@Autowired CoalParameterDefService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
@SysLog(action = "新增")
|
||||
public CoalParameterDefDto create(@RequestBody CreateCoalParameterDefDto dto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
@PostMapping("/create")
|
||||
@SysLog(action = "新增")
|
||||
public CoalParameterDefDto create(@RequestBody CreateCoalParameterDefDto dto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalParameterDefDto update(@RequestBody UpdateCoalParameterDefDto dto) {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
@PostMapping("/update")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalParameterDefDto update(@RequestBody UpdateCoalParameterDefDto dto) {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
this.service.delete(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
this.service.delete(dto);
|
||||
return true;
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Page<CoalParameterDefDto> list(@RequestBody CommonQuery dto) {
|
||||
return this.service.list(dto);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalParameterDefDto> list(@RequestBody CommonQuery dto) {
|
||||
return this.service.list(dto);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getById")
|
||||
public CoalParameterDefDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
@PostMapping("/getById")
|
||||
public CoalParameterDefDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,14 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
public class CoalParameterDefDto extends OrgCommonDto {
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
@Comment("类型 0 手动输入 1 自动计算" )
|
||||
private String inputType;
|
||||
private String inputTypeName;
|
||||
@Comment("类型 0 手动输入 1 自动计算")
|
||||
private String inputType;
|
||||
|
||||
@Comment("计算公式" )
|
||||
private String formula;
|
||||
private String inputTypeName;
|
||||
|
||||
@Comment("计算公式")
|
||||
private String formula;
|
||||
}
|
||||
|
||||
@@ -7,14 +7,12 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
public class CreateCoalParameterDefDto extends OrgCommonDto {
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
|
||||
@Comment("类型 0 手动输入 1 自动计算")
|
||||
private String inputType;
|
||||
|
||||
@Comment("类型 0 手动输入 1 自动计算" )
|
||||
private String inputType;
|
||||
|
||||
|
||||
@Comment("计算公式" )
|
||||
private String formula;
|
||||
@Comment("计算公式")
|
||||
private String formula;
|
||||
}
|
||||
|
||||
@@ -7,16 +7,12 @@ import org.hibernate.annotations.Comment;
|
||||
@Data
|
||||
public class UpdateCoalParameterDefDto extends OrgCommonDto {
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
|
||||
|
||||
@Comment("类型 0 手动输入 1 自动计算" )
|
||||
private String inputType;
|
||||
|
||||
|
||||
@Comment("计算公式" )
|
||||
private String formula;
|
||||
@Comment("类型 0 手动输入 1 自动计算")
|
||||
private String inputType;
|
||||
|
||||
@Comment("计算公式")
|
||||
private String formula;
|
||||
}
|
||||
|
||||
@@ -10,36 +10,30 @@ import org.hibernate.annotations.Formula;
|
||||
@Data
|
||||
public class CoalParameterDefEntity extends OrgCommonEntity {
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
|
||||
@Comment("上级名称")
|
||||
private String parentName;
|
||||
@Comment("类型 0 手动输入 1 自动计算")
|
||||
private String inputType;
|
||||
|
||||
@Formula(
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'coalParameter.inputType'\n"
|
||||
+ " and i.code = input_type)")
|
||||
private String inputTypeName;
|
||||
|
||||
@Comment("类型 0 手动输入 1 自动计算" )
|
||||
private String inputType;
|
||||
|
||||
@Formula("(select i.name\n" +
|
||||
"from t_dictionary d,\n" +
|
||||
" t_dictionary_item i\n" +
|
||||
"where d.id = i.dictionary_id\n" +
|
||||
" and d.code = 'coalParameter.inputType'\n" +
|
||||
" and i.code = input_type)")
|
||||
private String inputTypeName;
|
||||
|
||||
|
||||
@Comment("计算公式" )
|
||||
private String formula;
|
||||
|
||||
@Comment("解析后的公式" )
|
||||
private String formula0;
|
||||
|
||||
|
||||
@Comment("依赖的字段" )
|
||||
private String dependents;
|
||||
|
||||
@Comment("计算优先级" )
|
||||
private Integer priority;
|
||||
@Comment("计算公式")
|
||||
private String formula;
|
||||
|
||||
@Comment("解析后的公式")
|
||||
private String formula0;
|
||||
|
||||
@Comment("依赖的字段")
|
||||
private String dependents;
|
||||
|
||||
@Comment("计算优先级")
|
||||
private Integer priority;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.coalParameterDef.mapper;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.coalParameterDef.dto.CoalParameterDefDto;
|
||||
@@ -9,15 +8,15 @@ import cn.lihongjie.coal.coalParameterDef.dto.UpdateCoalParameterDefDto;
|
||||
import cn.lihongjie.coal.coalParameterDef.entity.CoalParameterDefEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
|
||||
)
|
||||
public interface CoalParameterDefMapper extends BaseMapper<CoalParameterDefEntity, CoalParameterDefDto, CreateCoalParameterDefDto, UpdateCoalParameterDefDto>{
|
||||
|
||||
}
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface CoalParameterDefMapper
|
||||
extends BaseMapper<
|
||||
CoalParameterDefEntity,
|
||||
CoalParameterDefDto,
|
||||
CreateCoalParameterDefDto,
|
||||
UpdateCoalParameterDefDto> {}
|
||||
|
||||
@@ -6,5 +6,5 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalParameterDefRepository extends BaseRepository<CoalParameterDefEntity> {
|
||||
long countByOrganizationId(String organizationId);
|
||||
}
|
||||
long countByOrganizationId(String organizationId);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.base.Splitter;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -31,197 +34,153 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CoalParameterDefService extends BaseService<CoalParameterDefEntity, CoalParameterDefRepository> {
|
||||
public class CoalParameterDefService
|
||||
extends BaseService<CoalParameterDefEntity, CoalParameterDefRepository> {
|
||||
|
||||
@Autowired
|
||||
CoalParameterDefRepository repository;
|
||||
@Autowired CoalParameterDefRepository repository;
|
||||
|
||||
@Autowired
|
||||
CoalParameterDefMapper mapper;
|
||||
@Autowired CoalParameterDefMapper mapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
public CoalParameterDefDto create(CreateCoalParameterDefDto request) {
|
||||
|
||||
CoalParameterDefEntity entity = mapper.toEntity(request);
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(entity.getInputType(), "1")) {
|
||||
GroovyScriptUtils.validate(entity.getFormula());
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
updateFormula(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public CoalParameterDefDto create(CreateCoalParameterDefDto request) {
|
||||
private void updateFormula(CoalParameterDefEntity entity) {
|
||||
|
||||
DefaultDirectedGraph<Object, DefaultEdge> graph = new DefaultDirectedGraph<>(DefaultEdge.class);
|
||||
List<CoalParameterDefEntity> all =
|
||||
this.repository.findByOrganizationId(entity.getOrganizationId());
|
||||
|
||||
CoalParameterDefEntity entity = mapper.toEntity(request);
|
||||
String formula = entity.getFormula();
|
||||
|
||||
entity.setFormula0(formula);
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(entity.getInputType(), "1")) {
|
||||
GroovyScriptUtils.validate(entity.getFormula());
|
||||
entity.setDependents(StringUtils.join(GroovyScriptUtils.variables(formula), ","));
|
||||
|
||||
for (CoalParameterDefEntity def : all) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(def.getInputType(), "1")) {
|
||||
|
||||
Iterable<String> dependents =
|
||||
Splitter.on(",").trimResults().omitEmptyStrings().split(def.getDependents());
|
||||
|
||||
for (String d : dependents) {
|
||||
|
||||
graph.addVertex(def.getCode());
|
||||
graph.addVertex(d);
|
||||
|
||||
graph.addEdge(d, def.getCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
updateFormula(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFormula(CoalParameterDefEntity entity) {
|
||||
TopologicalOrderIterator<Object, DefaultEdge> iterator = new TopologicalOrderIterator<>(graph);
|
||||
|
||||
int order = 0;
|
||||
while (iterator.hasNext()) {
|
||||
Object next = (String) iterator.next();
|
||||
|
||||
DefaultDirectedGraph<Object, DefaultEdge> graph = new DefaultDirectedGraph<>(DefaultEdge.class);
|
||||
List<CoalParameterDefEntity> all = this.repository.findByOrganizationId(entity.getOrganizationId());
|
||||
|
||||
String formula = entity.getFormula();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
entity.setFormula0(formula);
|
||||
|
||||
entity.setDependents(StringUtils.join(GroovyScriptUtils.variables(formula), ","));
|
||||
|
||||
|
||||
for (CoalParameterDefEntity def : all) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(def.getInputType(), "1")) {
|
||||
|
||||
|
||||
Iterable<String> dependents = Splitter.on(",").trimResults().omitEmptyStrings().split(def.getDependents());
|
||||
|
||||
|
||||
for (String d : dependents) {
|
||||
|
||||
graph.addVertex(def.getCode());
|
||||
graph.addVertex(d);
|
||||
|
||||
|
||||
graph.addEdge(d, def.getCode());
|
||||
|
||||
}
|
||||
}
|
||||
for (CoalParameterDefEntity coalParameterDefEntity : all) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(coalParameterDefEntity.getCode(), next + "")) {
|
||||
coalParameterDefEntity.setPriority(order++);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
TopologicalOrderIterator<Object, DefaultEdge> iterator = new TopologicalOrderIterator<>(graph);
|
||||
|
||||
int order = 0;
|
||||
while (iterator.hasNext()) {
|
||||
Object next = (String) iterator.next();
|
||||
|
||||
for (CoalParameterDefEntity coalParameterDefEntity : all) {
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(coalParameterDefEntity.getCode(), next + "")) {
|
||||
coalParameterDefEntity.setPriority(order++);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.repository.saveAll(all);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.repository.saveAll(all);
|
||||
}
|
||||
|
||||
public CoalParameterDefDto update(UpdateCoalParameterDefDto request) {
|
||||
CoalParameterDefEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
public CoalParameterDefDto update(UpdateCoalParameterDefDto request) {
|
||||
CoalParameterDefEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(entity.getInputType(), "1")) {
|
||||
GroovyScriptUtils.validate(entity.getFormula());
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
updateFormula(entity);
|
||||
return getById(entity.getId());
|
||||
if (StringUtils.equalsIgnoreCase(entity.getInputType(), "1")) {
|
||||
GroovyScriptUtils.validate(entity.getFormula());
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
updateFormula(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
|
||||
List<CoalParameterDefEntity> allDef = this.repository.findByOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
List<CoalParameterDefEntity> allDef =
|
||||
this.repository.findByOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
|
||||
Optional<CoalParameterDefEntity> type1 = allDef.stream().filter(x -> StringUtils.equalsIgnoreCase(x.getInputType(), "1")).findAny();
|
||||
Optional<CoalParameterDefEntity> type1 =
|
||||
allDef.stream().filter(x -> StringUtils.equalsIgnoreCase(x.getInputType(), "1")).findAny();
|
||||
|
||||
type1.ifPresent(this::updateFormula);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CoalParameterDefDto getById(String id) {
|
||||
|
||||
CoalParameterDefEntity entity = repository.get(id);
|
||||
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
ConversionService conversionService;
|
||||
|
||||
public Page<CoalParameterDefDto> list(CommonQuery query) {
|
||||
|
||||
Page<CoalParameterDefEntity> page = repository.findAll(query.specification(conversionService), PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
OrganizationService organizationService;
|
||||
|
||||
public void initDefault() {
|
||||
|
||||
organizationService.findAll().forEach(organizationEntity -> initDefault(organizationEntity.getId()));
|
||||
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void initDefault(String orgId) {
|
||||
|
||||
if (repository.countByOrganizationId(orgId) == 0) {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource("/config/CoalParameterDef.json");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
List<CoalParameterDefEntity> coalParameterDefs;
|
||||
try (InputStream inputStream = classPathResource.getInputStream()) {
|
||||
coalParameterDefs = mapper.readValue(inputStream, new TypeReference<List<CoalParameterDefEntity>>() {
|
||||
});
|
||||
|
||||
coalParameterDefs.forEach(x -> x.setOrganizationId(orgId));
|
||||
|
||||
this.repository.saveAll(coalParameterDefs);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
type1.ifPresent(this::updateFormula);
|
||||
}
|
||||
|
||||
public CoalParameterDefDto getById(String id) {
|
||||
|
||||
CoalParameterDefEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
@Autowired ConversionService conversionService;
|
||||
|
||||
public Page<CoalParameterDefDto> list(CommonQuery query) {
|
||||
|
||||
Page<CoalParameterDefEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
@Autowired OrganizationService organizationService;
|
||||
|
||||
public void initDefault() {
|
||||
|
||||
organizationService
|
||||
.findAll()
|
||||
.forEach(organizationEntity -> initDefault(organizationEntity.getId()));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void initDefault(String orgId) {
|
||||
|
||||
if (repository.countByOrganizationId(orgId) == 0) {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource("/config/CoalParameterDef.json");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
List<CoalParameterDefEntity> coalParameterDefs;
|
||||
try (InputStream inputStream = classPathResource.getInputStream()) {
|
||||
coalParameterDefs =
|
||||
mapper.readValue(inputStream, new TypeReference<List<CoalParameterDefEntity>>() {});
|
||||
|
||||
coalParameterDefs.forEach(x -> x.setOrganizationId(orgId));
|
||||
|
||||
this.repository.saveAll(coalParameterDefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,42 +18,35 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/coalPrice")
|
||||
@SysLog(
|
||||
module = "煤源价格记录"
|
||||
)
|
||||
@SysLog(module = "煤源价格记录")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class CoalPriceController {
|
||||
@Autowired
|
||||
private CoalPriceService service;
|
||||
@Autowired private CoalPriceService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public CoalPriceDto create(@RequestBody CreateCoalPriceDto request) {
|
||||
return this.service.create(request)
|
||||
;
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public CoalPriceDto update(@RequestBody UpdateCoalPriceDto request) {
|
||||
return this.service.update(request)
|
||||
;
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public CoalPriceDto getById(@RequestBody String request) {
|
||||
return this.service.getById(request)
|
||||
;
|
||||
return this.service.getById(request);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalPriceDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request)
|
||||
;
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@ package cn.lihongjie.coal.coalPrice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class CoalPriceDto extends OrgCommonDto {
|
||||
@Comment("煤源")
|
||||
private CoalInfoEntity coalInfo;
|
||||
@Comment("煤源")
|
||||
private CoalInfoEntity coalInfo;
|
||||
|
||||
|
||||
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class CreateCoalPriceDto extends OrgCommonDto {
|
||||
@Comment("煤源")
|
||||
private String coalInfo;
|
||||
@Comment("煤源")
|
||||
private String coalInfo;
|
||||
|
||||
|
||||
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
public class UpdateCoalPriceDto extends OrgCommonDto {
|
||||
@Comment("煤源")
|
||||
private String coalInfo;
|
||||
@Comment("煤源")
|
||||
private String coalInfo;
|
||||
|
||||
|
||||
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,10 @@ import org.hibernate.annotations.Comment;
|
||||
@Entity
|
||||
public class CoalPriceEntity extends OrgCommonEntity {
|
||||
|
||||
@Comment("煤源")
|
||||
@ManyToOne
|
||||
private CoalInfoEntity coalInfo;
|
||||
@Comment("煤源")
|
||||
@ManyToOne
|
||||
private CoalInfoEntity coalInfo;
|
||||
|
||||
|
||||
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
@Comment("价格")
|
||||
private Double price;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.mapstruct.control.DeepClone;
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
)
|
||||
public interface CoalPriceMapper extends BaseMapper<CoalPriceEntity, CoalPriceDto, CreateCoalPriceDto, UpdateCoalPriceDto> {
|
||||
}
|
||||
mappingControl = DeepClone.class)
|
||||
public interface CoalPriceMapper
|
||||
extends BaseMapper<CoalPriceEntity, CoalPriceDto, CreateCoalPriceDto, UpdateCoalPriceDto> {}
|
||||
|
||||
@@ -5,5 +5,4 @@ import cn.lihongjie.coal.coalPrice.entity.CoalPriceEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalPriceRepository extends BaseRepository<CoalPriceEntity> {
|
||||
}
|
||||
public interface CoalPriceRepository extends BaseRepository<CoalPriceEntity> {}
|
||||
|
||||
@@ -9,7 +9,6 @@ import cn.lihongjie.coal.coalPrice.dto.UpdateCoalPriceDto;
|
||||
import cn.lihongjie.coal.coalPrice.entity.CoalPriceEntity;
|
||||
import cn.lihongjie.coal.coalPrice.mapper.CoalPriceMapper;
|
||||
import cn.lihongjie.coal.coalPrice.repository.CoalPriceRepository;
|
||||
import java.lang.String;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -21,52 +20,44 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CoalPriceService extends BaseService<CoalPriceEntity, CoalPriceRepository> {
|
||||
@Autowired
|
||||
private CoalPriceRepository repository;
|
||||
@Autowired private CoalPriceRepository repository;
|
||||
|
||||
@Autowired
|
||||
private CoalPriceMapper mapper;
|
||||
@Autowired private CoalPriceMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private ConversionService conversionService;
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public CoalPriceDto create(CreateCoalPriceDto request) {
|
||||
CoalPriceEntity entity = mapper.toEntity(request);
|
||||
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId())
|
||||
;
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public CoalPriceDto update(UpdateCoalPriceDto request) {
|
||||
CoalPriceEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId())
|
||||
;
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds())
|
||||
;
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public CoalPriceDto getById(String id) {
|
||||
CoalPriceEntity entity = repository.get(id);
|
||||
|
||||
|
||||
return mapper.toDto(entity)
|
||||
;
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<CoalPriceDto> list(CommonQuery query) {
|
||||
Page<CoalPriceEntity> page = repository.findAll(query.specification(conversionService), PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
Page<CoalPriceEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto)
|
||||
;
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.controller.BaseController;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.service.CoalWashingDailyAnalysisService;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.service.CoalWashingDailyAnalysisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -22,42 +22,40 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Anonymous
|
||||
public class CoalWashingDailyAnalysisController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
CoalWashingDailyAnalysisService service;
|
||||
@PostMapping("/calculate")
|
||||
@SysLog(action = "计算")
|
||||
public CoalWashingDailyAnalysisDto calculate(@RequestBody CreateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.calculate(dto);
|
||||
}
|
||||
@PostMapping("/create")
|
||||
@SysLog(action = "新增")
|
||||
public CoalWashingDailyAnalysisDto create(@RequestBody CreateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
@Autowired CoalWashingDailyAnalysisService service;
|
||||
|
||||
@PostMapping("/update")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalWashingDailyAnalysisDto update(@RequestBody UpdateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
@PostMapping("/calculate")
|
||||
@SysLog(action = "计算")
|
||||
public CoalWashingDailyAnalysisDto calculate(@RequestBody CreateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.calculate(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@SysLog(action = "新增")
|
||||
public CoalWashingDailyAnalysisDto create(@RequestBody CreateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.create(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
this.service.delete(dto);
|
||||
return true;
|
||||
}
|
||||
@PostMapping("/update")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalWashingDailyAnalysisDto update(@RequestBody UpdateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
this.service.delete(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<CoalWashingDailyAnalysisDto> list(@RequestBody CommonQuery dto) {
|
||||
return this.service.list(dto);
|
||||
}
|
||||
@PostMapping("/list")
|
||||
public Page<CoalWashingDailyAnalysisDto> list(@RequestBody CommonQuery dto) {
|
||||
return this.service.list(dto);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getById")
|
||||
public CoalWashingDailyAnalysisDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
@PostMapping("/getById")
|
||||
public CoalWashingDailyAnalysisDto getById(@RequestBody IdRequest dto) {
|
||||
return this.service.getById(dto.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,59 +6,44 @@ import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
@Data
|
||||
@Comment("洗煤报告表")
|
||||
public class CoalWashingDailyAnalysisDto extends OrgCommonDto {
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable( foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
}
|
||||
|
||||
@@ -6,59 +6,44 @@ import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
@Data
|
||||
@Comment("洗煤报告表")
|
||||
public class CreateCoalWashingDailyAnalysisDto extends OrgCommonDto {
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable( foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
}
|
||||
|
||||
@@ -6,59 +6,44 @@ import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
@Data
|
||||
@Comment("洗煤报告表")
|
||||
public class UpdateCoalWashingDailyAnalysisDto extends OrgCommonDto {
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable( foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
}
|
||||
|
||||
@@ -2,279 +2,277 @@ package cn.lihongjie.coal.coalWashingDailyAnalysis.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
@Entity
|
||||
@Data
|
||||
@Comment("洗煤报告表")
|
||||
public class CoalWashingDailyAnalysisEntity extends OrgCommonEntity {
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("用户手动录入的记录")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> inputItems;
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
@ElementCollection
|
||||
@Comment("连续平均值")
|
||||
@CollectionTable( foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
@Comment("目标大堆 灰")
|
||||
private Double ddp1;
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("目标大堆 硫")
|
||||
private Double ddp2;
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
|
||||
public void rollingAvg() {
|
||||
|
||||
@Comment("目标大堆 挥发")
|
||||
private Double ddp3;
|
||||
rollingAvgItems = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isEmpty(inputItems)) {
|
||||
return;
|
||||
}
|
||||
inputItems.sort(
|
||||
Comparator.comparing(x -> ObjectUtils.defaultIfNull(x.getTime(), LocalTime.MIN)));
|
||||
inputItems.forEach(x -> x.calculate());
|
||||
|
||||
@Comment("目标大堆 粘结")
|
||||
private Double ddp4;
|
||||
for (int i = 0; i < inputItems.size(); i++) {
|
||||
|
||||
List<CoalWashingDailyAnalysisItemVo> current = inputItems.subList(0, i + 1);
|
||||
rollingAvgItems.add(rollingAvg(current));
|
||||
}
|
||||
}
|
||||
|
||||
@Comment("目标大堆 备用")
|
||||
private Double ddp5;
|
||||
private CoalWashingDailyAnalysisItemVo rollingAvg(List<CoalWashingDailyAnalysisItemVo> current) {
|
||||
|
||||
@Comment("产量初始值")
|
||||
private Double initTotalNumber = 0.0;
|
||||
CoalWashingDailyAnalysisItemVo vo = new CoalWashingDailyAnalysisItemVo();
|
||||
int size = current.size();
|
||||
vo.setTime(current.get(size - 1).getTime());
|
||||
vo.setTotalNumber(current.get(size - 1).getTotalNumber());
|
||||
|
||||
vo.setC0p0(current.get(size - 1).getC0p0());
|
||||
|
||||
public void rollingAvg() {
|
||||
vo.setC1p0(current.get(size - 1).getC1p0());
|
||||
|
||||
rollingAvgItems = new ArrayList<>();
|
||||
vo.setC2p0(current.get(size - 1).getC2p0());
|
||||
|
||||
if (CollectionUtils.isEmpty(inputItems)) {
|
||||
return;
|
||||
vo.setC3p0(current.get(size - 1).getC3p0());
|
||||
|
||||
vo.setC4p0(current.get(size - 1).getC4p0());
|
||||
|
||||
vo.setC5p0(current.get(size - 1).getC5p0());
|
||||
|
||||
vo.setC6p0(current.get(size - 1).getC6p0());
|
||||
|
||||
vo.setC7p0(current.get(size - 1).getC7p0());
|
||||
|
||||
vo.setC8p0(current.get(size - 1).getC8p0());
|
||||
|
||||
vo.setC9p0(current.get(size - 1).getC9p0());
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
var c = current.get(i);
|
||||
var p = i == 0 ? c.withTotalNumber(initTotalNumber) : current.get(i - 1);
|
||||
double diff = c.getTotalNumber() - p.getTotalNumber();
|
||||
if (vo.getC0p0() != null && vo.getC0p0() > 0) {
|
||||
vo.setC0p1(ObjectUtils.defaultIfNull(vo.getC0p1(), 0.0) + diff * c.getC0p1());
|
||||
vo.setC0p2(ObjectUtils.defaultIfNull(vo.getC0p2(), 0.0) + diff * c.getC0p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC0p1(vo.getC0p1() / c.getTotalNumber());
|
||||
vo.setC0p2(vo.getC0p2() / c.getTotalNumber());
|
||||
}
|
||||
inputItems.sort(Comparator.comparing(x -> ObjectUtils.defaultIfNull(x.getTime(), LocalTime.MIN)));
|
||||
inputItems.forEach(x -> x.calculate());
|
||||
|
||||
for (int i = 0; i < inputItems.size(); i++) {
|
||||
|
||||
List<CoalWashingDailyAnalysisItemVo> current = inputItems.subList(0, i + 1);
|
||||
rollingAvgItems.add(rollingAvg(current));
|
||||
|
||||
}
|
||||
if (vo.getC1p0() != null && vo.getC1p0() > 0) {
|
||||
vo.setC1p1(ObjectUtils.defaultIfNull(vo.getC1p1(), 0.0) + diff * c.getC1p1());
|
||||
vo.setC1p2(ObjectUtils.defaultIfNull(vo.getC1p2(), 0.0) + diff * c.getC1p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC1p1(vo.getC1p1() / c.getTotalNumber());
|
||||
vo.setC1p2(vo.getC1p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC2p0() != null && vo.getC2p0() > 0) {
|
||||
vo.setC2p1(ObjectUtils.defaultIfNull(vo.getC2p1(), 0.0) + diff * c.getC2p1());
|
||||
vo.setC2p2(ObjectUtils.defaultIfNull(vo.getC2p2(), 0.0) + diff * c.getC2p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC2p1(vo.getC2p1() / c.getTotalNumber());
|
||||
vo.setC2p2(vo.getC2p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC3p0() != null && vo.getC3p0() > 0) {
|
||||
vo.setC3p1(ObjectUtils.defaultIfNull(vo.getC3p1(), 0.0) + diff * c.getC3p1());
|
||||
vo.setC3p2(ObjectUtils.defaultIfNull(vo.getC3p2(), 0.0) + diff * c.getC3p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC3p1(vo.getC3p1() / c.getTotalNumber());
|
||||
vo.setC3p2(vo.getC3p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC4p0() != null && vo.getC4p0() > 0) {
|
||||
vo.setC4p1(ObjectUtils.defaultIfNull(vo.getC4p1(), 0.0) + diff * c.getC4p1());
|
||||
vo.setC4p2(ObjectUtils.defaultIfNull(vo.getC4p2(), 0.0) + diff * c.getC4p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC4p1(vo.getC4p1() / c.getTotalNumber());
|
||||
vo.setC4p2(vo.getC4p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC5p0() != null && vo.getC5p0() > 0) {
|
||||
vo.setC5p1(ObjectUtils.defaultIfNull(vo.getC5p1(), 0.0) + diff * c.getC5p1());
|
||||
vo.setC5p2(ObjectUtils.defaultIfNull(vo.getC5p2(), 0.0) + diff * c.getC5p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC5p1(vo.getC5p1() / c.getTotalNumber());
|
||||
vo.setC5p2(vo.getC5p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC6p0() != null && vo.getC6p0() > 0) {
|
||||
vo.setC6p1(ObjectUtils.defaultIfNull(vo.getC6p1(), 0.0) + diff * c.getC6p1());
|
||||
vo.setC6p2(ObjectUtils.defaultIfNull(vo.getC6p2(), 0.0) + diff * c.getC6p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC6p1(vo.getC6p1() / c.getTotalNumber());
|
||||
vo.setC6p2(vo.getC6p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC7p0() != null && vo.getC7p0() > 0) {
|
||||
vo.setC7p1(ObjectUtils.defaultIfNull(vo.getC7p1(), 0.0) + diff * c.getC7p1());
|
||||
vo.setC7p2(ObjectUtils.defaultIfNull(vo.getC7p2(), 0.0) + diff * c.getC7p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC7p1(vo.getC7p1() / c.getTotalNumber());
|
||||
vo.setC7p2(vo.getC7p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC8p0() != null && vo.getC8p0() > 0) {
|
||||
vo.setC8p1(ObjectUtils.defaultIfNull(vo.getC8p1(), 0.0) + diff * c.getC8p1());
|
||||
vo.setC8p2(ObjectUtils.defaultIfNull(vo.getC8p2(), 0.0) + diff * c.getC8p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC8p1(vo.getC8p1() / c.getTotalNumber());
|
||||
vo.setC8p2(vo.getC8p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
if (vo.getC9p0() != null && vo.getC9p0() > 0) {
|
||||
vo.setC9p1(ObjectUtils.defaultIfNull(vo.getC9p1(), 0.0) + diff * c.getC9p1());
|
||||
vo.setC9p2(ObjectUtils.defaultIfNull(vo.getC9p2(), 0.0) + diff * c.getC9p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC9p1(vo.getC9p1() / c.getTotalNumber());
|
||||
vo.setC9p2(vo.getC9p2() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
|
||||
vo.setDdp1(
|
||||
ObjectUtils.defaultIfNull(vo.getDdp1(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getDdp1(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp1(vo.getDdp1() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp2(
|
||||
ObjectUtils.defaultIfNull(vo.getDdp2(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getDdp2(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp2(vo.getDdp2() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp3(
|
||||
ObjectUtils.defaultIfNull(vo.getDdp3(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getDdp3(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp3(vo.getDdp3() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp4(
|
||||
ObjectUtils.defaultIfNull(vo.getDdp4(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getDdp4(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp4(vo.getDdp4() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp5(
|
||||
ObjectUtils.defaultIfNull(vo.getDdp5(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getDdp5(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp5(vo.getDdp5() / c.getTotalNumber());
|
||||
}
|
||||
|
||||
vo.setSysDdp1(
|
||||
ObjectUtils.defaultIfNull(vo.getSysDdp1(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getSysDdp1(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp1(vo.getSysDdp1() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp2(
|
||||
ObjectUtils.defaultIfNull(vo.getSysDdp2(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getSysDdp2(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp2(vo.getSysDdp2() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp3(
|
||||
ObjectUtils.defaultIfNull(vo.getSysDdp3(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getSysDdp3(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp3(vo.getSysDdp3() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp4(
|
||||
ObjectUtils.defaultIfNull(vo.getSysDdp4(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getSysDdp4(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp4(vo.getSysDdp4() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp5(
|
||||
ObjectUtils.defaultIfNull(vo.getSysDdp5(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getSysDdp5(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp5(vo.getSysDdp5() / c.getTotalNumber());
|
||||
}
|
||||
|
||||
vo.setAvgDdp1(
|
||||
ObjectUtils.defaultIfNull(vo.getAvgDdp1(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getAvgDdp1(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp1(vo.getAvgDdp1() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp2(
|
||||
ObjectUtils.defaultIfNull(vo.getAvgDdp2(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getAvgDdp2(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp2(vo.getAvgDdp2() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp3(
|
||||
ObjectUtils.defaultIfNull(vo.getAvgDdp3(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getAvgDdp3(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp3(vo.getAvgDdp3() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp4(
|
||||
ObjectUtils.defaultIfNull(vo.getAvgDdp4(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getAvgDdp4(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp4(vo.getAvgDdp4() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp5(
|
||||
ObjectUtils.defaultIfNull(vo.getAvgDdp5(), 0.0)
|
||||
+ diff * ObjectUtils.defaultIfNull(c.getAvgDdp5(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp5(vo.getAvgDdp5() / c.getTotalNumber());
|
||||
}
|
||||
}
|
||||
|
||||
private CoalWashingDailyAnalysisItemVo rollingAvg(List<CoalWashingDailyAnalysisItemVo> current) {
|
||||
|
||||
|
||||
CoalWashingDailyAnalysisItemVo vo = new CoalWashingDailyAnalysisItemVo();
|
||||
int size = current.size();
|
||||
vo.setTime(current.get(size - 1).getTime());
|
||||
vo.setTotalNumber(current.get(size - 1).getTotalNumber());
|
||||
|
||||
vo.setC0p0(current.get(size - 1).getC0p0());
|
||||
|
||||
vo.setC1p0(current.get(size - 1).getC1p0());
|
||||
|
||||
vo.setC2p0(current.get(size - 1).getC2p0());
|
||||
|
||||
vo.setC3p0(current.get(size - 1).getC3p0());
|
||||
|
||||
vo.setC4p0(current.get(size - 1).getC4p0());
|
||||
|
||||
vo.setC5p0(current.get(size - 1).getC5p0());
|
||||
|
||||
vo.setC6p0(current.get(size - 1).getC6p0());
|
||||
|
||||
vo.setC7p0(current.get(size - 1).getC7p0());
|
||||
|
||||
vo.setC8p0(current.get(size - 1).getC8p0());
|
||||
|
||||
vo.setC9p0(current.get(size - 1).getC9p0());
|
||||
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
var c = current.get(i);
|
||||
var p = i == 0 ? c.withTotalNumber(initTotalNumber) : current.get(i - 1);
|
||||
double diff = c.getTotalNumber() - p.getTotalNumber();
|
||||
if (vo.getC0p0() != null && vo.getC0p0() > 0) {
|
||||
vo.setC0p1(ObjectUtils.defaultIfNull(vo.getC0p1(), 0.0) + diff * c.getC0p1());
|
||||
vo.setC0p2(ObjectUtils.defaultIfNull(vo.getC0p2(), 0.0) + diff * c.getC0p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC0p1(vo.getC0p1() / c.getTotalNumber());
|
||||
vo.setC0p2(vo.getC0p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC1p0() != null && vo.getC1p0() > 0) {
|
||||
vo.setC1p1(ObjectUtils.defaultIfNull(vo.getC1p1(), 0.0) + diff * c.getC1p1());
|
||||
vo.setC1p2(ObjectUtils.defaultIfNull(vo.getC1p2(), 0.0) + diff * c.getC1p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC1p1(vo.getC1p1() / c.getTotalNumber());
|
||||
vo.setC1p2(vo.getC1p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC2p0() != null && vo.getC2p0() > 0) {
|
||||
vo.setC2p1(ObjectUtils.defaultIfNull(vo.getC2p1(), 0.0) + diff * c.getC2p1());
|
||||
vo.setC2p2(ObjectUtils.defaultIfNull(vo.getC2p2(), 0.0) + diff * c.getC2p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC2p1(vo.getC2p1() / c.getTotalNumber());
|
||||
vo.setC2p2(vo.getC2p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC3p0() != null && vo.getC3p0() > 0) {
|
||||
vo.setC3p1(ObjectUtils.defaultIfNull(vo.getC3p1(), 0.0) + diff * c.getC3p1());
|
||||
vo.setC3p2(ObjectUtils.defaultIfNull(vo.getC3p2(), 0.0) + diff * c.getC3p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC3p1(vo.getC3p1() / c.getTotalNumber());
|
||||
vo.setC3p2(vo.getC3p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC4p0() != null && vo.getC4p0() > 0) {
|
||||
vo.setC4p1(ObjectUtils.defaultIfNull(vo.getC4p1(), 0.0) + diff * c.getC4p1());
|
||||
vo.setC4p2(ObjectUtils.defaultIfNull(vo.getC4p2(), 0.0) + diff * c.getC4p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC4p1(vo.getC4p1() / c.getTotalNumber());
|
||||
vo.setC4p2(vo.getC4p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC5p0() != null && vo.getC5p0() > 0) {
|
||||
vo.setC5p1(ObjectUtils.defaultIfNull(vo.getC5p1(), 0.0) + diff * c.getC5p1());
|
||||
vo.setC5p2(ObjectUtils.defaultIfNull(vo.getC5p2(), 0.0) + diff * c.getC5p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC5p1(vo.getC5p1() / c.getTotalNumber());
|
||||
vo.setC5p2(vo.getC5p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC6p0() != null && vo.getC6p0() > 0) {
|
||||
vo.setC6p1(ObjectUtils.defaultIfNull(vo.getC6p1(), 0.0) + diff * c.getC6p1());
|
||||
vo.setC6p2(ObjectUtils.defaultIfNull(vo.getC6p2(), 0.0) + diff * c.getC6p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC6p1(vo.getC6p1() / c.getTotalNumber());
|
||||
vo.setC6p2(vo.getC6p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC7p0() != null && vo.getC7p0() > 0) {
|
||||
vo.setC7p1(ObjectUtils.defaultIfNull(vo.getC7p1(), 0.0) + diff * c.getC7p1());
|
||||
vo.setC7p2(ObjectUtils.defaultIfNull(vo.getC7p2(), 0.0) + diff * c.getC7p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC7p1(vo.getC7p1() / c.getTotalNumber());
|
||||
vo.setC7p2(vo.getC7p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC8p0() != null && vo.getC8p0() > 0) {
|
||||
vo.setC8p1(ObjectUtils.defaultIfNull(vo.getC8p1(), 0.0) + diff * c.getC8p1());
|
||||
vo.setC8p2(ObjectUtils.defaultIfNull(vo.getC8p2(), 0.0) + diff * c.getC8p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC8p1(vo.getC8p1() / c.getTotalNumber());
|
||||
vo.setC8p2(vo.getC8p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
if (vo.getC9p0() != null && vo.getC9p0() > 0) {
|
||||
vo.setC9p1(ObjectUtils.defaultIfNull(vo.getC9p1(), 0.0) + diff * c.getC9p1());
|
||||
vo.setC9p2(ObjectUtils.defaultIfNull(vo.getC9p2(), 0.0) + diff * c.getC9p1());
|
||||
if (i == size - 1) {
|
||||
vo.setC9p1(vo.getC9p1() / c.getTotalNumber());
|
||||
vo.setC9p2(vo.getC9p2() / c.getTotalNumber());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
vo.setDdp1(ObjectUtils.defaultIfNull(vo.getDdp1(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getDdp1(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp1(vo.getDdp1() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp2(ObjectUtils.defaultIfNull(vo.getDdp2(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getDdp2(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp2(vo.getDdp2() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp3(ObjectUtils.defaultIfNull(vo.getDdp3(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getDdp3(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp3(vo.getDdp3() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp4(ObjectUtils.defaultIfNull(vo.getDdp4(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getDdp4(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp4(vo.getDdp4() / c.getTotalNumber());
|
||||
}
|
||||
vo.setDdp5(ObjectUtils.defaultIfNull(vo.getDdp5(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getDdp5(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setDdp5(vo.getDdp5() / c.getTotalNumber());
|
||||
}
|
||||
|
||||
vo.setSysDdp1(ObjectUtils.defaultIfNull(vo.getSysDdp1(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getSysDdp1(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp1(vo.getSysDdp1() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp2(ObjectUtils.defaultIfNull(vo.getSysDdp2(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getSysDdp2(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp2(vo.getSysDdp2() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp3(ObjectUtils.defaultIfNull(vo.getSysDdp3(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getSysDdp3(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp3(vo.getSysDdp3() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp4(ObjectUtils.defaultIfNull(vo.getSysDdp4(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getSysDdp4(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp4(vo.getSysDdp4() / c.getTotalNumber());
|
||||
}
|
||||
vo.setSysDdp5(ObjectUtils.defaultIfNull(vo.getSysDdp5(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getSysDdp5(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setSysDdp5(vo.getSysDdp5() / c.getTotalNumber());
|
||||
}
|
||||
|
||||
|
||||
vo.setAvgDdp1(ObjectUtils.defaultIfNull(vo.getAvgDdp1(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getAvgDdp1(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp1(vo.getAvgDdp1() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp2(ObjectUtils.defaultIfNull(vo.getAvgDdp2(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getAvgDdp2(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp2(vo.getAvgDdp2() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp3(ObjectUtils.defaultIfNull(vo.getAvgDdp3(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getAvgDdp3(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp3(vo.getAvgDdp3() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp4(ObjectUtils.defaultIfNull(vo.getAvgDdp4(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getAvgDdp4(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp4(vo.getAvgDdp4() / c.getTotalNumber());
|
||||
}
|
||||
vo.setAvgDdp5(ObjectUtils.defaultIfNull(vo.getAvgDdp5(), 0.0) + diff * ObjectUtils.defaultIfNull(c.getAvgDdp5(), 0.0));
|
||||
if (i == size - 1) {
|
||||
vo.setAvgDdp5(vo.getAvgDdp5() / c.getTotalNumber());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return vo;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,273 +3,277 @@ package cn.lihongjie.coal.coalWashingDailyAnalysis.entity;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import io.vavr.collection.Stream;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.With;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
@Embeddable
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CoalWashingDailyAnalysisItemVo {
|
||||
|
||||
@Comment("时间")
|
||||
private LocalTime time;
|
||||
|
||||
@Comment("时间")
|
||||
private LocalTime time;
|
||||
@Comment("产量")
|
||||
@With
|
||||
private Double totalNumber;
|
||||
|
||||
@Comment("产量")
|
||||
@With
|
||||
private Double totalNumber;
|
||||
@Comment("成分0 比例")
|
||||
private Double c0p0;
|
||||
|
||||
@Comment("成分0 灰")
|
||||
private Double c0p1;
|
||||
|
||||
@Comment("成分0 比例")
|
||||
private Double c0p0;
|
||||
@Comment("成分0 硫")
|
||||
private Double c0p2;
|
||||
|
||||
@Comment("成分1 比例")
|
||||
private Double c1p0;
|
||||
|
||||
@Comment("成分0 灰")
|
||||
private Double c0p1;
|
||||
@Comment("成分1 灰")
|
||||
private Double c1p1;
|
||||
|
||||
@Comment("成分1 硫")
|
||||
private Double c1p2;
|
||||
|
||||
@Comment("成分0 硫")
|
||||
private Double c0p2;
|
||||
@Comment("成分2 比例")
|
||||
private Double c2p0;
|
||||
|
||||
@Comment("成分2 灰")
|
||||
private Double c2p1;
|
||||
|
||||
@Comment("成分1 比例")
|
||||
private Double c1p0;
|
||||
@Comment("成分2 硫")
|
||||
private Double c2p2;
|
||||
|
||||
@Comment("成分3 比例")
|
||||
private Double c3p0;
|
||||
|
||||
@Comment("成分1 灰")
|
||||
private Double c1p1;
|
||||
@Comment("成分3 灰")
|
||||
private Double c3p1;
|
||||
|
||||
@Comment("成分3 硫")
|
||||
private Double c3p2;
|
||||
|
||||
@Comment("成分1 硫")
|
||||
private Double c1p2;
|
||||
@Comment("成分4 比例")
|
||||
private Double c4p0;
|
||||
|
||||
@Comment("成分4 灰")
|
||||
private Double c4p1;
|
||||
|
||||
@Comment("成分2 比例")
|
||||
private Double c2p0;
|
||||
@Comment("成分4 硫")
|
||||
private Double c4p2;
|
||||
|
||||
@Comment("成分5 比例")
|
||||
private Double c5p0;
|
||||
|
||||
@Comment("成分2 灰")
|
||||
private Double c2p1;
|
||||
@Comment("成分5 灰")
|
||||
private Double c5p1;
|
||||
|
||||
@Comment("成分5 硫")
|
||||
private Double c5p2;
|
||||
|
||||
@Comment("成分2 硫")
|
||||
private Double c2p2;
|
||||
@Comment("成分6 比例")
|
||||
private Double c6p0;
|
||||
|
||||
@Comment("成分6 灰")
|
||||
private Double c6p1;
|
||||
|
||||
@Comment("成分3 比例")
|
||||
private Double c3p0;
|
||||
@Comment("成分6 硫")
|
||||
private Double c6p2;
|
||||
|
||||
@Comment("成分7 比例")
|
||||
private Double c7p0;
|
||||
|
||||
@Comment("成分3 灰")
|
||||
private Double c3p1;
|
||||
@Comment("成分7 灰")
|
||||
private Double c7p1;
|
||||
|
||||
@Comment("成分7 硫")
|
||||
private Double c7p2;
|
||||
|
||||
@Comment("成分3 硫")
|
||||
private Double c3p2;
|
||||
@Comment("成分8 比例")
|
||||
private Double c8p0;
|
||||
|
||||
@Comment("成分8 灰")
|
||||
private Double c8p1;
|
||||
|
||||
@Comment("成分4 比例")
|
||||
private Double c4p0;
|
||||
@Comment("成分8 硫")
|
||||
private Double c8p2;
|
||||
|
||||
@Comment("成分9 比例")
|
||||
private Double c9p0;
|
||||
|
||||
@Comment("成分4 灰")
|
||||
private Double c4p1;
|
||||
@Comment("成分9 灰")
|
||||
private Double c9p1;
|
||||
|
||||
@Comment("成分9 硫")
|
||||
private Double c9p2;
|
||||
|
||||
@Comment("成分4 硫")
|
||||
private Double c4p2;
|
||||
@Comment("用户输入 大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
@Comment("用户输入 大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
@Comment("成分5 比例")
|
||||
private Double c5p0;
|
||||
@Comment("用户输入 大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
@Comment("用户输入 大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
@Comment("成分5 灰")
|
||||
private Double c5p1;
|
||||
|
||||
|
||||
@Comment("成分5 硫")
|
||||
private Double c5p2;
|
||||
|
||||
|
||||
@Comment("成分6 比例")
|
||||
private Double c6p0;
|
||||
|
||||
|
||||
@Comment("成分6 灰")
|
||||
private Double c6p1;
|
||||
|
||||
|
||||
@Comment("成分6 硫")
|
||||
private Double c6p2;
|
||||
|
||||
|
||||
@Comment("成分7 比例")
|
||||
private Double c7p0;
|
||||
|
||||
|
||||
@Comment("成分7 灰")
|
||||
private Double c7p1;
|
||||
|
||||
|
||||
@Comment("成分7 硫")
|
||||
private Double c7p2;
|
||||
|
||||
|
||||
@Comment("成分8 比例")
|
||||
private Double c8p0;
|
||||
|
||||
|
||||
@Comment("成分8 灰")
|
||||
private Double c8p1;
|
||||
|
||||
|
||||
@Comment("成分8 硫")
|
||||
private Double c8p2;
|
||||
|
||||
|
||||
@Comment("成分9 比例")
|
||||
private Double c9p0;
|
||||
|
||||
|
||||
@Comment("成分9 灰")
|
||||
private Double c9p1;
|
||||
|
||||
|
||||
@Comment("成分9 硫")
|
||||
private Double c9p2;
|
||||
|
||||
|
||||
@Comment("用户输入 大堆 灰")
|
||||
private Double ddp1;
|
||||
|
||||
|
||||
@Comment("用户输入 大堆 硫")
|
||||
private Double ddp2;
|
||||
|
||||
|
||||
@Comment("用户输入 大堆 挥发")
|
||||
private Double ddp3;
|
||||
|
||||
|
||||
@Comment("用户输入 大堆 粘结")
|
||||
private Double ddp4;
|
||||
|
||||
|
||||
@Comment("用户输入 大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("用户输入 翻大堆 灰")
|
||||
private Double fddp1;
|
||||
|
||||
|
||||
@Comment("用户输入 翻大堆 硫")
|
||||
private Double fddp2;
|
||||
|
||||
|
||||
@Comment("用户输入 翻大堆 挥发")
|
||||
private Double fddp3;
|
||||
|
||||
|
||||
@Comment("用户输入 翻大堆 粘结")
|
||||
private Double fddp4;
|
||||
|
||||
|
||||
@Comment("用户输入 翻大堆 备用")
|
||||
private Double fddp5;
|
||||
|
||||
|
||||
@Comment("系统计算 大堆 灰")
|
||||
private Double sysDdp1;
|
||||
|
||||
|
||||
@Comment("系统计算 大堆 硫")
|
||||
private Double sysDdp2;
|
||||
|
||||
|
||||
@Comment("系统计算 大堆 挥发")
|
||||
private Double sysDdp3;
|
||||
|
||||
|
||||
@Comment("系统计算 大堆 粘结")
|
||||
private Double sysDdp4;
|
||||
|
||||
|
||||
@Comment("系统计算 大堆 备用")
|
||||
private Double sysDdp5;
|
||||
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 灰")
|
||||
private Double avgDdp1;
|
||||
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 硫")
|
||||
private Double avgDdp2;
|
||||
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 挥发")
|
||||
private Double avgDdp3;
|
||||
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 粘结")
|
||||
private Double avgDdp4;
|
||||
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 备用")
|
||||
private Double avgDdp5;
|
||||
|
||||
|
||||
public void calculate() {
|
||||
|
||||
|
||||
if (Stream.of(c0p0, c1p0, c2p0, c3p0, c4p0, c5p0, c6p0, c7p0, c8p0, c9p0).filter(Objects::nonNull).sum().doubleValue() != 100)
|
||||
throw new BizException("比例相加应该等于100!");
|
||||
|
||||
|
||||
sysDdp1 = 0.0;
|
||||
sysDdp2 = 0.0;
|
||||
int count1 = 0;
|
||||
int count2 = 0;
|
||||
if (c0p0 != null && c0p1!=null) {sysDdp1 += c0p1 * c0p0 / 100.00; count1++;}
|
||||
if (c0p0 != null && c0p2!=null) {sysDdp2 += c0p2 * c0p0 / 100.00; count2++;}
|
||||
if (c1p0 != null && c1p1!=null) {sysDdp1 += c1p1 * c1p0 / 100.00; count1++;}
|
||||
if (c1p0 != null && c1p2!=null) {sysDdp2 += c1p2 * c1p0 / 100.00; count2++;}
|
||||
if (c2p0 != null && c2p1!=null) {sysDdp1 += c2p1 * c2p0 / 100.00; count1++;}
|
||||
if (c2p0 != null && c2p2!=null) {sysDdp2 += c2p2 * c2p0 / 100.00; count2++;}
|
||||
if (c3p0 != null && c3p1!=null) {sysDdp1 += c3p1 * c3p0 / 100.00; count1++;}
|
||||
if (c3p0 != null && c3p2!=null) {sysDdp2 += c3p2 * c3p0 / 100.00; count2++;}
|
||||
if (c4p0 != null && c4p1!=null) {sysDdp1 += c4p1 * c4p0 / 100.00; count1++;}
|
||||
if (c4p0 != null && c4p2!=null) {sysDdp2 += c4p2 * c4p0 / 100.00; count2++;}
|
||||
if (c5p0 != null && c5p1!=null) {sysDdp1 += c5p1 * c5p0 / 100.00; count1++;}
|
||||
if (c5p0 != null && c5p2!=null) {sysDdp2 += c5p2 * c5p0 / 100.00; count2++;}
|
||||
if (c6p0 != null && c6p1!=null) {sysDdp1 += c6p1 * c6p0 / 100.00; count1++;}
|
||||
if (c6p0 != null && c6p2!=null) {sysDdp2 += c6p2 * c6p0 / 100.00; count2++;}
|
||||
if (c7p0 != null && c7p1!=null) {sysDdp1 += c7p1 * c7p0 / 100.00; count1++;}
|
||||
if (c7p0 != null && c7p2!=null) {sysDdp2 += c7p2 * c7p0 / 100.00; count2++;}
|
||||
if (c8p0 != null && c8p1!=null) {sysDdp1 += c8p1 * c8p0 / 100.00; count1++;}
|
||||
if (c8p0 != null && c8p2!=null) {sysDdp2 += c8p2 * c8p0 / 100.00; count2++;}
|
||||
if (c9p0 != null && c9p1!=null) {sysDdp1 += c9p1 * c9p0 / 100.00; count1++;}
|
||||
if (c9p0 != null && c9p2!=null) {sysDdp2 += c9p2 * c9p0 / 100.00; count2++;}
|
||||
|
||||
if (count1==0) sysDdp1 = null;
|
||||
if (count2==0) sysDdp2 = null;
|
||||
|
||||
if (ddp1 != null && sysDdp1 != null) avgDdp1 = (ddp1 + sysDdp1) / 2.0;
|
||||
if (ddp2 != null && sysDdp2 != null) avgDdp2 = (ddp2 + sysDdp2) / 2.0;
|
||||
if (ddp3 != null && sysDdp3 != null) avgDdp3 = (ddp3 + sysDdp3) / 2.0;
|
||||
if (ddp4 != null && sysDdp4 != null) avgDdp4 = (ddp4 + sysDdp4) / 2.0;
|
||||
if (ddp5 != null && sysDdp5 != null) avgDdp5 = (ddp5 + sysDdp5) / 2.0;
|
||||
|
||||
@Comment("用户输入 大堆 备用")
|
||||
private Double ddp5;
|
||||
|
||||
@Comment("用户输入 翻大堆 灰")
|
||||
private Double fddp1;
|
||||
|
||||
@Comment("用户输入 翻大堆 硫")
|
||||
private Double fddp2;
|
||||
|
||||
@Comment("用户输入 翻大堆 挥发")
|
||||
private Double fddp3;
|
||||
|
||||
@Comment("用户输入 翻大堆 粘结")
|
||||
private Double fddp4;
|
||||
|
||||
@Comment("用户输入 翻大堆 备用")
|
||||
private Double fddp5;
|
||||
|
||||
@Comment("系统计算 大堆 灰")
|
||||
private Double sysDdp1;
|
||||
|
||||
@Comment("系统计算 大堆 硫")
|
||||
private Double sysDdp2;
|
||||
|
||||
@Comment("系统计算 大堆 挥发")
|
||||
private Double sysDdp3;
|
||||
|
||||
@Comment("系统计算 大堆 粘结")
|
||||
private Double sysDdp4;
|
||||
|
||||
@Comment("系统计算 大堆 备用")
|
||||
private Double sysDdp5;
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 灰")
|
||||
private Double avgDdp1;
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 硫")
|
||||
private Double avgDdp2;
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 挥发")
|
||||
private Double avgDdp3;
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 粘结")
|
||||
private Double avgDdp4;
|
||||
|
||||
@Comment("用户输入与系统计算的平均值 大堆 备用")
|
||||
private Double avgDdp5;
|
||||
|
||||
public void calculate() {
|
||||
|
||||
if (Stream.of(c0p0, c1p0, c2p0, c3p0, c4p0, c5p0, c6p0, c7p0, c8p0, c9p0)
|
||||
.filter(Objects::nonNull)
|
||||
.sum()
|
||||
.doubleValue()
|
||||
!= 100) throw new BizException("比例相加应该等于100!");
|
||||
|
||||
sysDdp1 = 0.0;
|
||||
sysDdp2 = 0.0;
|
||||
int count1 = 0;
|
||||
int count2 = 0;
|
||||
if (c0p0 != null && c0p1 != null) {
|
||||
sysDdp1 += c0p1 * c0p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c0p0 != null && c0p2 != null) {
|
||||
sysDdp2 += c0p2 * c0p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c1p0 != null && c1p1 != null) {
|
||||
sysDdp1 += c1p1 * c1p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c1p0 != null && c1p2 != null) {
|
||||
sysDdp2 += c1p2 * c1p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c2p0 != null && c2p1 != null) {
|
||||
sysDdp1 += c2p1 * c2p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c2p0 != null && c2p2 != null) {
|
||||
sysDdp2 += c2p2 * c2p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c3p0 != null && c3p1 != null) {
|
||||
sysDdp1 += c3p1 * c3p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c3p0 != null && c3p2 != null) {
|
||||
sysDdp2 += c3p2 * c3p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c4p0 != null && c4p1 != null) {
|
||||
sysDdp1 += c4p1 * c4p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c4p0 != null && c4p2 != null) {
|
||||
sysDdp2 += c4p2 * c4p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c5p0 != null && c5p1 != null) {
|
||||
sysDdp1 += c5p1 * c5p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c5p0 != null && c5p2 != null) {
|
||||
sysDdp2 += c5p2 * c5p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c6p0 != null && c6p1 != null) {
|
||||
sysDdp1 += c6p1 * c6p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c6p0 != null && c6p2 != null) {
|
||||
sysDdp2 += c6p2 * c6p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c7p0 != null && c7p1 != null) {
|
||||
sysDdp1 += c7p1 * c7p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c7p0 != null && c7p2 != null) {
|
||||
sysDdp2 += c7p2 * c7p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c8p0 != null && c8p1 != null) {
|
||||
sysDdp1 += c8p1 * c8p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c8p0 != null && c8p2 != null) {
|
||||
sysDdp2 += c8p2 * c8p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
if (c9p0 != null && c9p1 != null) {
|
||||
sysDdp1 += c9p1 * c9p0 / 100.00;
|
||||
count1++;
|
||||
}
|
||||
if (c9p0 != null && c9p2 != null) {
|
||||
sysDdp2 += c9p2 * c9p0 / 100.00;
|
||||
count2++;
|
||||
}
|
||||
|
||||
if (count1 == 0) sysDdp1 = null;
|
||||
if (count2 == 0) sysDdp2 = null;
|
||||
|
||||
if (ddp1 != null && sysDdp1 != null) avgDdp1 = (ddp1 + sysDdp1) / 2.0;
|
||||
if (ddp2 != null && sysDdp2 != null) avgDdp2 = (ddp2 + sysDdp2) / 2.0;
|
||||
if (ddp3 != null && sysDdp3 != null) avgDdp3 = (ddp3 + sysDdp3) / 2.0;
|
||||
if (ddp4 != null && sysDdp4 != null) avgDdp4 = (ddp4 + sysDdp4) / 2.0;
|
||||
if (ddp5 != null && sysDdp5 != null) avgDdp5 = (ddp5 + sysDdp5) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.coalWashingDailyAnalysis.mapper;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDto;
|
||||
@@ -9,16 +8,15 @@ import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnal
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
|
||||
|
||||
)
|
||||
public interface CoalWashingDailyAnalysisMapper extends BaseMapper<CoalWashingDailyAnalysisEntity, CoalWashingDailyAnalysisDto, CreateCoalWashingDailyAnalysisDto, UpdateCoalWashingDailyAnalysisDto>{
|
||||
|
||||
}
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface CoalWashingDailyAnalysisMapper
|
||||
extends BaseMapper<
|
||||
CoalWashingDailyAnalysisEntity,
|
||||
CoalWashingDailyAnalysisDto,
|
||||
CreateCoalWashingDailyAnalysisDto,
|
||||
UpdateCoalWashingDailyAnalysisDto> {}
|
||||
|
||||
@@ -4,37 +4,30 @@ import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.coalBlend.dto.CoalBlendDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisItemVo;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
@Mapper(
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class
|
||||
|
||||
)
|
||||
componentModel = MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface RoundMapper {
|
||||
|
||||
CoalWashingDailyAnalysisEntity round(CoalWashingDailyAnalysisEntity entity);
|
||||
|
||||
CoalWashingDailyAnalysisEntity round(CoalWashingDailyAnalysisEntity entity);
|
||||
CoalWashingDailyAnalysisItemVo round(CoalWashingDailyAnalysisItemVo entity);
|
||||
|
||||
CoalWashingDailyAnalysisItemVo round(CoalWashingDailyAnalysisItemVo entity);
|
||||
CoalBlendDto round(CoalBlendDto entity);
|
||||
CoalBlendDto round(CoalBlendDto entity);
|
||||
|
||||
default Double formatDouble(Double d) {
|
||||
|
||||
default Double formatDouble(Double d) {
|
||||
|
||||
if (d == null) {
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
return new BigDecimal(d).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
if (d == null) {
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
return new BigDecimal(d).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysi
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalWashingDailyAnalysisRepository extends BaseRepository<CoalWashingDailyAnalysisEntity> {
|
||||
}
|
||||
public interface CoalWashingDailyAnalysisRepository
|
||||
extends BaseRepository<CoalWashingDailyAnalysisEntity> {}
|
||||
|
||||
@@ -3,13 +3,13 @@ package cn.lihongjie.coal.coalWashingDailyAnalysis.service;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.repository.CoalWashingDailyAnalysisRepository;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.CoalWashingDailyAnalysisMapper;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.RoundMapper;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.repository.CoalWashingDailyAnalysisRepository;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -21,80 +21,65 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CoalWashingDailyAnalysisService extends BaseService<CoalWashingDailyAnalysisEntity, CoalWashingDailyAnalysisRepository> {
|
||||
public class CoalWashingDailyAnalysisService
|
||||
extends BaseService<CoalWashingDailyAnalysisEntity, CoalWashingDailyAnalysisRepository> {
|
||||
|
||||
@Autowired
|
||||
CoalWashingDailyAnalysisRepository repository;
|
||||
@Autowired CoalWashingDailyAnalysisRepository repository;
|
||||
|
||||
@Autowired
|
||||
CoalWashingDailyAnalysisMapper mapper;
|
||||
@Autowired CoalWashingDailyAnalysisMapper mapper;
|
||||
|
||||
@Autowired
|
||||
RoundMapper roundMapper;
|
||||
@Autowired RoundMapper roundMapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
@PostConstruct
|
||||
public void init() {}
|
||||
|
||||
public CoalWashingDailyAnalysisDto create(CreateCoalWashingDailyAnalysisDto request) {
|
||||
|
||||
}
|
||||
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public CoalWashingDailyAnalysisDto create(CreateCoalWashingDailyAnalysisDto request) {
|
||||
public CoalWashingDailyAnalysisDto calculate(CreateCoalWashingDailyAnalysisDto request) {
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
|
||||
entity.rollingAvg();
|
||||
|
||||
return mapper.toDto(roundMapper.round(entity));
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
public CoalWashingDailyAnalysisDto update(UpdateCoalWashingDailyAnalysisDto request) {
|
||||
CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
}
|
||||
public CoalWashingDailyAnalysisDto calculate(CreateCoalWashingDailyAnalysisDto request) {
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
entity.rollingAvg();
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
return mapper.toDto(roundMapper.round(entity));
|
||||
public CoalWashingDailyAnalysisDto getById(String id) {
|
||||
|
||||
}
|
||||
CoalWashingDailyAnalysisEntity entity = repository.get(id);
|
||||
|
||||
public CoalWashingDailyAnalysisDto update(UpdateCoalWashingDailyAnalysisDto request) {
|
||||
CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
@Autowired ConversionService conversionService;
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
public Page<CoalWashingDailyAnalysisDto> list(CommonQuery query) {
|
||||
|
||||
Page<CoalWashingDailyAnalysisEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CoalWashingDailyAnalysisDto getById(String id) {
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = repository.get(id);
|
||||
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
ConversionService conversionService;
|
||||
|
||||
public Page<CoalWashingDailyAnalysisDto> list(CommonQuery query) {
|
||||
|
||||
Page<CoalWashingDailyAnalysisEntity> page = repository.findAll(query.specification(conversionService), PageRequest.of(query.getPageNo(), query.getPageSize(), Sort.by(query.getOrders())));
|
||||
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
|
||||
}
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
import io.vavr.Tuple2;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -13,69 +10,90 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
@UtilityClass
|
||||
public class CollectionUtils {
|
||||
|
||||
public static <Data, T> List<T> map(Iterable<Data> data, Function<Data, T> fn) {
|
||||
public static <Data, T> List<T> map(Iterable<Data> data, Function<Data, T> fn) {
|
||||
|
||||
return StreamSupport.stream(data.spliterator(), false).map(fn).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
return StreamSupport.stream(data.spliterator(), false)
|
||||
.map(fn)
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
public static <A, B, K> List<Tuple2<A, B>> innerHashJoin(Iterable<A> a, Iterable<B> b, Function<A, K> ak, Function<B, K> bk) {
|
||||
Map<K, List<A>> aMap = newStream(a).collect(Collectors.groupingBy(ak));
|
||||
Map<K, List<B>> bMap = newStream(b).collect(Collectors.groupingBy(bk));
|
||||
return aMap.keySet().stream().flatMap(k -> aMap.getOrDefault(k, new ArrayList<>()).stream().flatMap(av -> bMap.getOrDefault(k, new ArrayList<>()).stream().map(bv -> new Tuple2<>(av, bv)))).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
public static <A, B, K> List<Tuple2<A, B>> innerHashJoin(
|
||||
Iterable<A> a, Iterable<B> b, Function<A, K> ak, Function<B, K> bk) {
|
||||
Map<K, List<A>> aMap = newStream(a).collect(Collectors.groupingBy(ak));
|
||||
Map<K, List<B>> bMap = newStream(b).collect(Collectors.groupingBy(bk));
|
||||
return aMap.keySet().stream()
|
||||
.flatMap(
|
||||
k ->
|
||||
aMap.getOrDefault(k, new ArrayList<>()).stream()
|
||||
.flatMap(
|
||||
av ->
|
||||
bMap.getOrDefault(k, new ArrayList<>()).stream()
|
||||
.map(bv -> new Tuple2<>(av, bv))))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
public static <A, B> List<Tuple2<A, B>> innerNestJoin(Iterable<A> a, Iterable<B> b, BiFunction<A, B, Boolean> test) {
|
||||
a = ObjectUtils.defaultIfNull(a, new ArrayList<>());
|
||||
b = ObjectUtils.defaultIfNull(b, new ArrayList<>());
|
||||
public static <A, B> List<Tuple2<A, B>> innerNestJoin(
|
||||
Iterable<A> a, Iterable<B> b, BiFunction<A, B, Boolean> test) {
|
||||
a = ObjectUtils.defaultIfNull(a, new ArrayList<>());
|
||||
b = ObjectUtils.defaultIfNull(b, new ArrayList<>());
|
||||
|
||||
List<Tuple2<A, B>> ans = new ArrayList<>();
|
||||
|
||||
for (A a1 : a) {
|
||||
for (B b1 : b) {
|
||||
if (test.apply(a1, b1)) {
|
||||
ans.add(new Tuple2<>(a1, b1));
|
||||
}
|
||||
}
|
||||
List<Tuple2<A, B>> ans = new ArrayList<>();
|
||||
|
||||
for (A a1 : a) {
|
||||
for (B b1 : b) {
|
||||
if (test.apply(a1, b1)) {
|
||||
ans.add(new Tuple2<>(a1, b1));
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static <A, B, K> List<Tuple2<A, B>> leftHashJoin(Iterable<A> a, Iterable<B> b, Function<A, K> ak, Function<B, K> bk) {
|
||||
Map<K, List<A>> aMap = newStream(a).collect(Collectors.groupingBy(ak));
|
||||
Map<K, List<B>> bMap = newStream(b).collect(Collectors.groupingBy(bk));
|
||||
return aMap.keySet().stream().flatMap(k -> aMap.getOrDefault(k, new ArrayList<>()).stream().flatMap(av -> bMap.getOrDefault(k, new ArrayList<>(Arrays.asList((B)null))).stream().map(bv -> new Tuple2<>(av, bv)))).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
public static <A, B, K> List<Tuple2<A, B>> leftHashJoin(
|
||||
Iterable<A> a, Iterable<B> b, Function<A, K> ak, Function<B, K> bk) {
|
||||
Map<K, List<A>> aMap = newStream(a).collect(Collectors.groupingBy(ak));
|
||||
Map<K, List<B>> bMap = newStream(b).collect(Collectors.groupingBy(bk));
|
||||
return aMap.keySet().stream()
|
||||
.flatMap(
|
||||
k ->
|
||||
aMap.getOrDefault(k, new ArrayList<>()).stream()
|
||||
.flatMap(
|
||||
av ->
|
||||
bMap.getOrDefault(k, new ArrayList<>(Arrays.asList((B) null))).stream()
|
||||
.map(bv -> new Tuple2<>(av, bv))))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
public static <A, B> List<Tuple2<A, B>> leftNestJoin(Iterable<A> a, Iterable<B> b, BiFunction<A, B, Boolean> test) {
|
||||
a = ObjectUtils.defaultIfNull(a, new ArrayList<>());
|
||||
b = ObjectUtils.defaultIfNull(b, new ArrayList<>());
|
||||
public static <A, B> List<Tuple2<A, B>> leftNestJoin(
|
||||
Iterable<A> a, Iterable<B> b, BiFunction<A, B, Boolean> test) {
|
||||
a = ObjectUtils.defaultIfNull(a, new ArrayList<>());
|
||||
b = ObjectUtils.defaultIfNull(b, new ArrayList<>());
|
||||
|
||||
List<Tuple2<A, B>> ans = new ArrayList<>();
|
||||
List<Tuple2<A, B>> ans = new ArrayList<>();
|
||||
|
||||
for (A a1 : a) {
|
||||
boolean find = false;
|
||||
for (B b1 : b) {
|
||||
if (test.apply(a1, b1)) {
|
||||
ans.add(new Tuple2<>(a1, b1));
|
||||
find = true;
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
ans.add(new Tuple2<>(a1, null));
|
||||
}
|
||||
for (A a1 : a) {
|
||||
boolean find = false;
|
||||
for (B b1 : b) {
|
||||
if (test.apply(a1, b1)) {
|
||||
ans.add(new Tuple2<>(a1, b1));
|
||||
find = true;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
if (!find) {
|
||||
ans.add(new Tuple2<>(a1, null));
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
private static <A> Stream<A> newStream(Iterable<A> a) {
|
||||
return StreamSupport.stream(a == null ? new ArrayList<A>().spliterator() : a.spliterator(), false);
|
||||
}
|
||||
|
||||
|
||||
private static <A> Stream<A> newStream(Iterable<A> a) {
|
||||
return StreamSupport.stream(
|
||||
a == null ? new ArrayList<A>().spliterator() : a.spliterator(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package cn.lihongjie.coal.common;
|
||||
import java.util.*;
|
||||
|
||||
public class Constants {
|
||||
public static String SYSCONFIG_ENABLE_CAPTCHA = "enable_captcha";
|
||||
public static String SYSCONFIG_ENABLE_CAPTCHA = "enable_captcha";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.session.SessionService;
|
||||
import cn.lihongjie.coal.user.entity.UserEntity;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@@ -9,44 +8,34 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@UtilityClass
|
||||
public class Ctx {
|
||||
|
||||
public static String getUserId() {
|
||||
return getAuthentication().getUser().getId();
|
||||
}
|
||||
|
||||
public static boolean isLoggedIn() {
|
||||
|
||||
public static String getUserId(){
|
||||
return getAuthentication().getUser().getId();
|
||||
return getAuthentication() != null && getAuthentication().isAuthenticated();
|
||||
}
|
||||
|
||||
}
|
||||
public static String getSessionId() {
|
||||
return getAuthentication().getSessionId();
|
||||
}
|
||||
|
||||
public static boolean isLoggedIn(){
|
||||
private static SessionService.MyAuthentication getAuthentication() {
|
||||
return (SessionService.MyAuthentication) SecurityContextHolder.getContext().getAuthentication();
|
||||
}
|
||||
|
||||
return getAuthentication() != null && getAuthentication().isAuthenticated();
|
||||
}
|
||||
public static boolean isOrgAdmin() {
|
||||
|
||||
return getAuthentication().getUser().getOrgAdmin();
|
||||
}
|
||||
|
||||
public static String getSessionId(){
|
||||
return getAuthentication().getSessionId();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static SessionService.MyAuthentication getAuthentication() {
|
||||
return (SessionService.MyAuthentication) SecurityContextHolder.getContext().getAuthentication();
|
||||
}
|
||||
|
||||
public static boolean isOrgAdmin() {
|
||||
|
||||
return getAuthentication().getUser().getOrgAdmin();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isSysAdmin() {
|
||||
|
||||
return getAuthentication().getUser().getSysAdmin();
|
||||
|
||||
}
|
||||
|
||||
public static UserEntity currentUser() {
|
||||
return getAuthentication().getUser();
|
||||
}
|
||||
public static boolean isSysAdmin() {
|
||||
|
||||
return getAuthentication().getUser().getSysAdmin();
|
||||
}
|
||||
|
||||
public static UserEntity currentUser() {
|
||||
return getAuthentication().getUser();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package cn.lihongjie.coal.common;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import groovy.lang.Binding;
|
||||
import groovy.lang.GroovyShell;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -11,59 +15,51 @@ import org.codehaus.groovy.ast.GroovyCodeVisitorAdapter;
|
||||
import org.codehaus.groovy.ast.builder.AstStringCompiler;
|
||||
import org.codehaus.groovy.ast.expr.VariableExpression;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
@Slf4j
|
||||
public class GroovyScriptUtils {
|
||||
public static void validate(String formula) {
|
||||
if (StringUtils.isEmpty(formula)) {
|
||||
return;
|
||||
}
|
||||
AstStringCompiler compiler = new AstStringCompiler();
|
||||
try {
|
||||
public static void validate(String formula) {
|
||||
if (StringUtils.isEmpty(formula)) {
|
||||
return;
|
||||
}
|
||||
AstStringCompiler compiler = new AstStringCompiler();
|
||||
try {
|
||||
|
||||
List<ASTNode> astNodes = compiler.compile(formula);
|
||||
} catch (Exception e) {
|
||||
log.info(formula, e);
|
||||
throw new BizException("无效的计算公式");
|
||||
}
|
||||
List<ASTNode> astNodes = compiler.compile(formula);
|
||||
} catch (Exception e) {
|
||||
log.info(formula, e);
|
||||
throw new BizException("无效的计算公式");
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> variables(String formula) {
|
||||
if (StringUtils.isEmpty(formula)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
AstStringCompiler compiler = new AstStringCompiler();
|
||||
|
||||
public static List<String> variables(String formula) {
|
||||
if (StringUtils.isEmpty(formula)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return compiler.compile(formula).stream()
|
||||
.flatMap(
|
||||
x -> {
|
||||
ArrayList<String> ans = new ArrayList<>();
|
||||
x.visit(
|
||||
new GroovyCodeVisitorAdapter() {
|
||||
@Override
|
||||
public void visitVariableExpression(VariableExpression expression) {
|
||||
ans.add(expression.getName());
|
||||
}
|
||||
});
|
||||
|
||||
AstStringCompiler compiler = new AstStringCompiler();
|
||||
return ans.stream();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return compiler.compile(formula).stream().flatMap(x -> {
|
||||
public static Object exec(String formula0, Map<String, Object> map) {
|
||||
|
||||
ArrayList<String> ans = new ArrayList<>();
|
||||
x.visit(new GroovyCodeVisitorAdapter() {
|
||||
@Override
|
||||
public void visitVariableExpression(VariableExpression expression) {
|
||||
ans.add(expression.getName());
|
||||
}
|
||||
});
|
||||
GroovyShell shell = new GroovyShell(new Binding(map));
|
||||
|
||||
return ans.stream();
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static Object exec(String formula0, Map<String, Object> map) {
|
||||
|
||||
|
||||
GroovyShell shell = new GroovyShell(new Binding(map));
|
||||
|
||||
return shell.evaluate(formula0);
|
||||
}
|
||||
return shell.evaluate(formula0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
package cn.lihongjie.coal.common;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@UtilityClass
|
||||
public class ReflectUtils {
|
||||
|
||||
public static Object getFieldValue(Object object, String fieldName) {
|
||||
public static Object getFieldValue(Object object, String fieldName) {
|
||||
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(fieldName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Field field = ReflectionUtils.findField(object.getClass(), fieldName);
|
||||
if (field != null) {
|
||||
field.setAccessible(true);
|
||||
return ReflectionUtils.getField(field, object);
|
||||
}
|
||||
return null;
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(fieldName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Field field = ReflectionUtils.findField(object.getClass(), fieldName);
|
||||
if (field != null) {
|
||||
field.setAccessible(true);
|
||||
return ReflectionUtils.getField(field, object);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,58 +11,57 @@ import org.apache.commons.lang3.StringUtils;
|
||||
@UtilityClass
|
||||
public class RequestUtils {
|
||||
|
||||
private static final String[] HEADERS_TO_TRY = {
|
||||
"X-Forwarded-For",
|
||||
"Proxy-Client-IP",
|
||||
"WL-Proxy-Client-IP",
|
||||
"HTTP_X_FORWARDED_FOR",
|
||||
"HTTP_X_FORWARDED",
|
||||
"HTTP_X_CLUSTER_CLIENT_IP",
|
||||
"HTTP_CLIENT_IP",
|
||||
"HTTP_FORWARDED_FOR",
|
||||
"HTTP_FORWARDED",
|
||||
"HTTP_VIA",
|
||||
"REMOTE_ADDR"
|
||||
};
|
||||
|
||||
|
||||
private static final String[] HEADERS_TO_TRY = {
|
||||
"X-Forwarded-For",
|
||||
"Proxy-Client-IP",
|
||||
"WL-Proxy-Client-IP",
|
||||
"HTTP_X_FORWARDED_FOR",
|
||||
"HTTP_X_FORWARDED",
|
||||
"HTTP_X_CLUSTER_CLIENT_IP",
|
||||
"HTTP_CLIENT_IP",
|
||||
"HTTP_FORWARDED_FOR",
|
||||
"HTTP_FORWARDED",
|
||||
"HTTP_VIA",
|
||||
"REMOTE_ADDR" };
|
||||
|
||||
private String getClientIpAddress(HttpServletRequest request) {
|
||||
for (String header : HEADERS_TO_TRY) {
|
||||
String ip = request.getHeader(header);
|
||||
if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
return getClientIpAddress(request);
|
||||
private String getClientIpAddress(HttpServletRequest request) {
|
||||
for (String header : HEADERS_TO_TRY) {
|
||||
String ip = request.getHeader(header);
|
||||
if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUa(HttpServletRequest request) {
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
try {
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
return getClientIpAddress(request);
|
||||
}
|
||||
|
||||
String header = request.getHeader("User-Agent");
|
||||
if (StringUtils.isEmpty(header)) {
|
||||
return "";
|
||||
}
|
||||
UserAgent userAgent = UserAgent.parseUserAgentString(header);
|
||||
Browser browser = userAgent.getBrowser();
|
||||
public static String getUa(HttpServletRequest request) {
|
||||
|
||||
String browserName = browser.getName();
|
||||
//or
|
||||
// String browserName = browser.getGroup().getName();
|
||||
Version browserVersion = userAgent.getBrowserVersion();
|
||||
try {
|
||||
|
||||
OperatingSystem os = userAgent.getOperatingSystem();
|
||||
String header = request.getHeader("User-Agent");
|
||||
if (StringUtils.isEmpty(header)) {
|
||||
return "";
|
||||
}
|
||||
UserAgent userAgent = UserAgent.parseUserAgentString(header);
|
||||
Browser browser = userAgent.getBrowser();
|
||||
|
||||
return os.getName() + " " + browserName + browserVersion.toString();
|
||||
String browserName = browser.getName();
|
||||
// or
|
||||
// String browserName = browser.getGroup().getName();
|
||||
Version browserVersion = userAgent.getBrowserVersion();
|
||||
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
OperatingSystem os = userAgent.getOperatingSystem();
|
||||
|
||||
return os.getName() + " " + browserName + browserVersion.toString();
|
||||
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user