mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package cn.lihongjie.coal.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.Anonymous;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.dto.IdRequest;
|
||||
import cn.lihongjie.coal.dto.CreateCoalBlendDto;
|
||||
import cn.lihongjie.coal.dto.UpdateCoalBlendDto;
|
||||
import cn.lihongjie.coal.dto.CoalBlendDto;
|
||||
import cn.lihongjie.coal.service.CoalBlendService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
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;
|
||||
|
||||
@RequestMapping("/coalBlend")
|
||||
@RestController
|
||||
@SysLog(module = "配煤")
|
||||
@Anonymous
|
||||
public class CoalBlendController {
|
||||
|
||||
@Autowired
|
||||
CoalBlendService service;
|
||||
|
||||
|
||||
@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("/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 null;
|
||||
}
|
||||
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.controller;
|
||||
|
||||
import cn.lihongjie.coal.annotation.Anonymous;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.dto.*;
|
||||
import cn.lihongjie.coal.service.CoalParameterDefService;
|
||||
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/coalParameterDef")
|
||||
@RestController
|
||||
@SysLog(module = "煤参数配置")
|
||||
@Anonymous
|
||||
public class CoalParameterDefController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.dao;
|
||||
|
||||
import cn.lihongjie.coal.entity.CoalBlendEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CoalBlendRepository extends BaseRepository<CoalBlendEntity> {
|
||||
}
|
||||
55
src/main/java/cn/lihongjie/coal/dto/CoalBlendDto.java
Normal file
55
src/main/java/cn/lihongjie/coal/dto/CoalBlendDto.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package cn.lihongjie.coal.dto;
|
||||
|
||||
import cn.lihongjie.coal.dto.base.OrgCommonDto;
|
||||
import cn.lihongjie.coal.entity.*;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
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 = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoEntity> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
private List<CoalBlendCoalInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
}
|
||||
58
src/main/java/cn/lihongjie/coal/dto/CreateCoalBlendDto.java
Normal file
58
src/main/java/cn/lihongjie/coal/dto/CreateCoalBlendDto.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package cn.lihongjie.coal.dto;
|
||||
|
||||
import cn.lihongjie.coal.dto.base.OrgCommonDto;
|
||||
import cn.lihongjie.coal.entity.CoalBlendCoalInfoEntity;
|
||||
import cn.lihongjie.coal.entity.CoalBlendConstrainVo;
|
||||
import cn.lihongjie.coal.entity.CoalBlendType;
|
||||
import cn.lihongjie.coal.entity.CoalParameterDefVo;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
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 = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoEntity> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
private List<CoalBlendCoalInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
}
|
||||
58
src/main/java/cn/lihongjie/coal/dto/UpdateCoalBlendDto.java
Normal file
58
src/main/java/cn/lihongjie/coal/dto/UpdateCoalBlendDto.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package cn.lihongjie.coal.dto;
|
||||
|
||||
import cn.lihongjie.coal.dto.base.OrgCommonDto;
|
||||
import cn.lihongjie.coal.entity.CoalBlendCoalInfoEntity;
|
||||
import cn.lihongjie.coal.entity.CoalBlendConstrainVo;
|
||||
import cn.lihongjie.coal.entity.CoalBlendType;
|
||||
import cn.lihongjie.coal.entity.CoalParameterDefVo;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
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 = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
private List<CoalBlendCoalInfoEntity> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
private List<CoalBlendCoalInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.OrgCommonEntity;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.*;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@NoArgsConstructor
|
||||
@With
|
||||
@Entity
|
||||
public class CoalBlendCoalInfoEntity extends OrgCommonEntity {
|
||||
|
||||
@NotEmpty(message = "煤名称不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private CoalBlendEntity coal;
|
||||
|
||||
|
||||
@ElementCollection
|
||||
private List<CoalPercentVo> percentInfos;
|
||||
|
||||
@ManyToOne
|
||||
private CoalBlendEntity result;
|
||||
|
||||
|
||||
@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("数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("参数0 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param10;
|
||||
@Comment("参数1 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param11;
|
||||
@Comment("参数2 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param12;
|
||||
@Comment("参数3 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param13;
|
||||
@Comment("参数4 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param14;
|
||||
@Comment("参数5 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param15;
|
||||
@Comment("参数6 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param16;
|
||||
@Comment("参数7 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param17;
|
||||
@Comment("参数8 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param18;
|
||||
@Comment("参数9 ")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class, value = "0.1", inclusive = true, message = "参数不能小于0.1")
|
||||
private Double param19;
|
||||
@Comment("参数0 ")
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
216
src/main/java/cn/lihongjie/coal/entity/CoalBlendConstrainVo.java
Normal file
216
src/main/java/cn/lihongjie/coal/entity/CoalBlendConstrainVo.java
Normal file
@@ -0,0 +1,216 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.validation.constraints.DecimalMax;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Embeddable
|
||||
@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 param1Min;
|
||||
@Comment("参数2最小值")
|
||||
@DecimalMax(groups = CoalBlendEntity.BlendGroup.class,value = "10000", message = "最大值无效")
|
||||
@DecimalMin(groups = CoalBlendEntity.BlendGroup.class,value = "0.1", message = "最小值无效")
|
||||
private Double param2Min;
|
||||
|
||||
@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 param3Min;
|
||||
|
||||
@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 param4Min;
|
||||
|
||||
@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 param5Min;
|
||||
|
||||
@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 param6Min;
|
||||
|
||||
@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 param7Min;
|
||||
|
||||
@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 param8Min;
|
||||
|
||||
@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 param9Min;
|
||||
|
||||
@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 param10Min;
|
||||
|
||||
@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 param11Min;
|
||||
|
||||
@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 param12Min;
|
||||
|
||||
@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 param13Min;
|
||||
|
||||
@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 param14Min;
|
||||
|
||||
@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 param15Min;
|
||||
|
||||
@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 param16Min;
|
||||
|
||||
@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 param17Min;
|
||||
|
||||
@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 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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
620
src/main/java/cn/lihongjie/coal/entity/CoalBlendEntity.java
Normal file
620
src/main/java/cn/lihongjie/coal/entity/CoalBlendEntity.java
Normal file
@@ -0,0 +1,620 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import cn.lihongjie.coal.entity.base.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.sat.*;
|
||||
import io.vavr.collection.Stream;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Comment("配煤记录")
|
||||
public class CoalBlendEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
@ElementCollection
|
||||
@NotEmpty(message = "煤参数定义不能为空")
|
||||
private List<CoalParameterDefVo> parameterDefs;
|
||||
|
||||
|
||||
@NotEmpty(message = "煤不能为空")
|
||||
@Size(message = "至少需要两种煤", min = 2)
|
||||
@OneToMany(mappedBy = "coal" )
|
||||
private List<CoalBlendCoalInfoEntity> coals;
|
||||
@NotNull(message = "约束条件不能为空")
|
||||
private CoalBlendConstrainVo constrains;
|
||||
|
||||
@OneToMany(mappedBy = "result")
|
||||
private List<CoalBlendCoalInfoEntity> results;
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
@NotNull()
|
||||
private CoalBlendType type;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
public static class BlendGroup {
|
||||
}
|
||||
|
||||
|
||||
public void blend() {
|
||||
|
||||
|
||||
this.results = new ArrayList<>();
|
||||
|
||||
|
||||
long count1 = 0;
|
||||
count1 = coals.stream().map(x1 -> x1.getParam1()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param1 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param1.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam2()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param2 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param2.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam3()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param3 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param3.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam4()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param4 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param4.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam5()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param5 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param5.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam6()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param6 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param6.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam7()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param7 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param7.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam8()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param8 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param8.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam9()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param9 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param9.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam10()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param10 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param10.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam11()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param11 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param11.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam12()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param12 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param12.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam13()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param13 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param13.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam14()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param14 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param14.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam15()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param15 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param15.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam16()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param16 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param16.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam17()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param17 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param17.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam18()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param18 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param18.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam19()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param19 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param19.set(true);
|
||||
}
|
||||
count1 = coals.stream().map(x1 -> x1.getParam20()).filter(Objects::nonNull).count();
|
||||
|
||||
AtomicBoolean param20 = new AtomicBoolean(false);
|
||||
if (count1 != coals.size()) {
|
||||
throw new BizException("煤的参数不可以留空");
|
||||
}else {
|
||||
|
||||
param20.set(true);
|
||||
}
|
||||
|
||||
|
||||
Loader.loadNativeLibraries();
|
||||
CpModel model = new CpModel();
|
||||
|
||||
|
||||
Stream<IntVar> percentVal = Stream.ofAll(coals).zipWithIndex((c, i) -> model.newIntVar(c.getMinPercent(), c.getMaxPercent(), "x" + i));
|
||||
|
||||
IntVar[] percentValArr = percentVal.toJavaArray(IntVar[]::new);
|
||||
// 各个煤累加和 100
|
||||
model.addEquality(LinearExpr.sum(percentValArr), 100);
|
||||
|
||||
addBaseConstrain(model, percentValArr);
|
||||
|
||||
|
||||
IntVar gcd = model.newIntVar(1, 100, "gcd");
|
||||
Stream<IntVar> gcdVal = Stream.ofAll(coals).zipWithIndex((c, i) -> model.newIntVar(c.getMinPercent(), c.getMaxPercent(), "gcdX" + i));
|
||||
IntVar[] gcdValArr = percentVal.toJavaArray(IntVar[]::new);
|
||||
|
||||
if (type == CoalBlendType.TYPE2) {
|
||||
|
||||
|
||||
percentVal.zip(gcdVal).forEach(t -> model.addModuloEquality(t._2, t._1, gcd));
|
||||
|
||||
model.addLessOrEqual(LinearExpr.sum(gcdValArr), type2PercentSum);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(targetParam)) {
|
||||
if (targetOrder == -1) {
|
||||
|
||||
model.maximize(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam(targetParam) * 100)).toArray()));
|
||||
} else {
|
||||
|
||||
model.minimize(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam(targetParam) * 100)).toArray()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 初始化求解器
|
||||
CpSolver cpSolver = new CpSolver();
|
||||
SatParameters.Builder parameters = cpSolver.getParameters();
|
||||
parameters.setEnumerateAllSolutions(true);
|
||||
parameters.setMaxTimeInSeconds(this.getMaxTime());
|
||||
parameters.setLogSearchProgress(false);
|
||||
parameters.setFillAdditionalSolutionsInResponse(true);
|
||||
|
||||
|
||||
cpSolver.solve(model, new CpSolverSolutionCallback() {
|
||||
|
||||
@Override
|
||||
public void onSolutionCallback() {
|
||||
|
||||
CoalBlendCoalInfoEntity vo = new CoalBlendCoalInfoEntity();
|
||||
|
||||
|
||||
vo.setPercentInfos(Stream.ofAll(coals).zip(percentVal).zip(gcdVal).map(t -> new CoalPercentVo(t._1._1.getName(), ((double) (value(t._1._2))), (double) value(t._2))).toJavaList());
|
||||
if (param1.get()) vo.setParam1(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam1() * 100)).toArray()))/ 10000.0);
|
||||
if (param2.get()) vo.setParam2(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam2() * 100)).toArray()))/ 10000.0);
|
||||
if (param3.get()) vo.setParam3(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam3() * 100)).toArray()))/ 10000.0);
|
||||
if (param4.get()) vo.setParam4(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam4() * 100)).toArray()))/ 10000.0);
|
||||
if (param5.get()) vo.setParam5(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam5() * 100)).toArray()))/ 10000.0);
|
||||
if (param6.get()) vo.setParam6(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam6() * 100)).toArray()))/ 10000.0);
|
||||
if (param7.get()) vo.setParam7(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam7() * 100)).toArray()))/ 10000.0);
|
||||
if (param8.get()) vo.setParam8(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam8() * 100)).toArray()))/ 10000.0);
|
||||
if (param9.get()) vo.setParam9(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam9() * 100)).toArray()))/ 10000.0);
|
||||
if (param10.get()) vo.setParam10(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam10() * 100)).toArray()))/ 10000.0);
|
||||
if (param11.get()) vo.setParam11(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam11() * 100)).toArray()))/ 10000.0);
|
||||
if (param12.get()) vo.setParam12(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam12() * 100)).toArray()))/ 10000.0);
|
||||
if (param13.get()) vo.setParam13(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam13() * 100)).toArray()))/ 10000.0);
|
||||
if (param14.get()) vo.setParam14(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam14() * 100)).toArray()))/ 10000.0);
|
||||
if (param15.get()) vo.setParam15(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam15() * 100)).toArray()))/ 10000.0);
|
||||
if (param16.get()) vo.setParam16(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam16() * 100)).toArray()))/ 10000.0);
|
||||
if (param17.get()) vo.setParam17(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam17() * 100)).toArray()))/ 10000.0);
|
||||
if (param18.get()) vo.setParam18(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam18() * 100)).toArray()))/ 10000.0);
|
||||
if (param19.get()) vo.setParam19(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam19() * 100)).toArray()))/ 10000.0);
|
||||
if (param20.get()) vo.setParam20(value(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam20() * 100)).toArray()))/ 10000.0);
|
||||
|
||||
|
||||
CoalBlendEntity.this.results.add(vo);
|
||||
|
||||
if (CoalBlendEntity.this.results.size() >= CoalBlendEntity.this.count) {
|
||||
stopSearch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加参数依赖
|
||||
*
|
||||
* @param model
|
||||
* @param percentValArr
|
||||
*/
|
||||
private void addBaseConstrain(CpModel model, IntVar[] percentValArr) {
|
||||
Double val = null;
|
||||
|
||||
val = constrains.getParam1Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam1() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
val = constrains.getParam2Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam2() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
val = constrains.getParam3Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam3() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
|
||||
val = constrains.getParam4Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam4() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
|
||||
val = constrains.getParam5Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam5() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
val = constrains.getParam6Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam6() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam7Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam7() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam8Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam8() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam9Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam9() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam10Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam10() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam11Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam11() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam12Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam12() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam13Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam13() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam14Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam14() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam15Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam15() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam16Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam16() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam17Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam17() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam18Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam18() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam19Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam19() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam20Min();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addGreaterOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam20() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
|
||||
val = constrains.getParam1Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam1() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
val = constrains.getParam2Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam2() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
val = constrains.getParam3Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam3() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
|
||||
val = constrains.getParam4Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam4() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
|
||||
val = constrains.getParam5Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam5() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
|
||||
val = constrains.getParam6Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam6() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam7Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam7() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam8Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam8() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam9Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam9() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam10Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam10() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam11Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam11() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam12Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam12() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam13Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam13() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam14Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam14() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam15Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam15() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam16Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam16() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam17Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam17() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam18Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam18() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam19Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam19() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
val = constrains.getParam20Max();
|
||||
|
||||
|
||||
if (val != null) {
|
||||
model.addLessOrEqual(LinearExpr.weightedSum(percentValArr, coals.stream().mapToLong(x -> (long) (x.getParam20() * 100)).toArray()), (long) (val * 10000));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
public enum CoalBlendType {
|
||||
TYPE1, TYPE2
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Embeddable
|
||||
@Data
|
||||
public class CoalParameterDefVo {
|
||||
@Comment("名称")
|
||||
private String name;
|
||||
|
||||
@Comment("编码")
|
||||
private String code;
|
||||
|
||||
|
||||
@Comment("备注")
|
||||
private String remarks;
|
||||
|
||||
|
||||
|
||||
@Comment("排序键")
|
||||
private Integer sortKey;
|
||||
|
||||
|
||||
@Comment("常用状态 0 禁用 1 启用")
|
||||
private Integer status;
|
||||
|
||||
private String id;
|
||||
}
|
||||
26
src/main/java/cn/lihongjie/coal/entity/CoalPercentVo.java
Normal file
26
src/main/java/cn/lihongjie/coal/entity/CoalPercentVo.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package cn.lihongjie.coal.entity;
|
||||
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
@Embeddable
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CoalPercentVo {
|
||||
|
||||
@Comment("煤名称")
|
||||
private String name;
|
||||
@Comment("煤的精确比例")
|
||||
private Double percent;
|
||||
@Comment("煤的铲车配煤比例")
|
||||
private Double type2Percent;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -235,27 +235,31 @@ public class CoalWashingDailyAnalysisItemVo {
|
||||
|
||||
sysDdp1 = 0.0;
|
||||
sysDdp2 = 0.0;
|
||||
if (c0p0 != null) sysDdp1 += c0p1 * c0p0 / 100.00;
|
||||
if (c0p0 != null) sysDdp2 += c0p2 * c0p0 / 100.00;
|
||||
if (c1p0 != null) sysDdp1 += c1p1 * c1p0 / 100.00;
|
||||
if (c1p0 != null) sysDdp2 += c1p2 * c1p0 / 100.00;
|
||||
if (c2p0 != null) sysDdp1 += c2p1 * c2p0 / 100.00;
|
||||
if (c2p0 != null) sysDdp2 += c2p2 * c2p0 / 100.00;
|
||||
if (c3p0 != null) sysDdp1 += c3p1 * c3p0 / 100.00;
|
||||
if (c3p0 != null) sysDdp2 += c3p2 * c3p0 / 100.00;
|
||||
if (c4p0 != null) sysDdp1 += c4p1 * c4p0 / 100.00;
|
||||
if (c4p0 != null) sysDdp2 += c4p2 * c4p0 / 100.00;
|
||||
if (c5p0 != null) sysDdp1 += c5p1 * c5p0 / 100.00;
|
||||
if (c5p0 != null) sysDdp2 += c5p2 * c5p0 / 100.00;
|
||||
if (c6p0 != null) sysDdp1 += c6p1 * c6p0 / 100.00;
|
||||
if (c6p0 != null) sysDdp2 += c6p2 * c6p0 / 100.00;
|
||||
if (c7p0 != null) sysDdp1 += c7p1 * c7p0 / 100.00;
|
||||
if (c7p0 != null) sysDdp2 += c7p2 * c7p0 / 100.00;
|
||||
if (c8p0 != null) sysDdp1 += c8p1 * c8p0 / 100.00;
|
||||
if (c8p0 != null) sysDdp2 += c8p2 * c8p0 / 100.00;
|
||||
if (c9p0 != null) sysDdp1 += c9p1 * c9p0 / 100.00;
|
||||
if (c9p0 != null) sysDdp2 += c9p2 * c9p0 / 100.00;
|
||||
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;
|
||||
@@ -264,6 +268,7 @@ public class CoalWashingDailyAnalysisItemVo {
|
||||
if (ddp5 != null && sysDdp5 != null) avgDdp5 = (ddp5 + sysDdp5) / 2.0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
26
src/main/java/cn/lihongjie/coal/mapper/CoalBlendMapper.java
Normal file
26
src/main/java/cn/lihongjie/coal/mapper/CoalBlendMapper.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package cn.lihongjie.coal.mapper;
|
||||
|
||||
|
||||
import cn.lihongjie.coal.dto.CreateCoalBlendDto;
|
||||
import cn.lihongjie.coal.dto.UpdateCoalBlendDto;
|
||||
import cn.lihongjie.coal.dto.CoalBlendDto;
|
||||
import cn.lihongjie.coal.entity.CoalBlendEntity;
|
||||
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 CoalBlendMapper {
|
||||
CoalBlendDto toDto(CoalBlendEntity user);
|
||||
|
||||
CoalBlendEntity toEntity(CreateCoalBlendDto request);
|
||||
|
||||
|
||||
void updateEntity(@MappingTarget CoalBlendEntity entity, UpdateCoalBlendDto dto);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.lihongjie.coal.service;
|
||||
|
||||
import cn.lihongjie.coal.dao.CoalBlendRepository;
|
||||
import cn.lihongjie.coal.dto.*;
|
||||
import cn.lihongjie.coal.entity.CoalBlendEntity;
|
||||
import cn.lihongjie.coal.mapper.CoalBlendMapper;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CoalBlendService extends BaseService<CoalBlendEntity, CoalBlendRepository> {
|
||||
|
||||
@Autowired
|
||||
CoalBlendRepository repository;
|
||||
|
||||
@Autowired
|
||||
CoalBlendMapper mapper;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CoalBlendDto create(CreateCoalBlendDto request) {
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CoalBlendDto getById(String id) {
|
||||
|
||||
CoalBlendEntity entity = repository.get(id);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
public CoalBlendDto blend(CreateCoalBlendDto dto) {
|
||||
|
||||
|
||||
CoalBlendEntity entity = this.mapper.toEntity(dto);
|
||||
|
||||
entity.blend();
|
||||
|
||||
return this.mapper.toDto(entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user