完善计算报表

This commit is contained in:
2023-08-01 21:53:03 +08:00
parent 10a17ce836
commit a21078da68
19 changed files with 409 additions and 25 deletions

View File

@@ -0,0 +1,62 @@
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.CreateCoalWashingDailyAnalysisDto;
import cn.lihongjie.coal.dto.UpdateCoalWashingDailyAnalysisDto;
import cn.lihongjie.coal.dto.CoalWashingDailyAnalysisDto;
import cn.lihongjie.coal.service.CoalWashingDailyAnalysisService;
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("/coalWashingDailyAnalysis")
@RestController
@SysLog(module = "洗煤报告表")
@Anonymous
public class CoalWashingDailyAnalysisController {
@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);
}
@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 null;
}
@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());
}
}

View File

@@ -0,0 +1,64 @@
package cn.lihongjie.coal.dto;
import cn.lihongjie.coal.dto.base.OrgCommonDto;
import cn.lihongjie.coal.entity.CoalWashingDailyAnalysisItemVo;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.ForeignKey;
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;
@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;
@Comment("目标大堆 硫")
private Double ddp2;
@Comment("目标大堆 挥发")
private Double ddp3;
@Comment("目标大堆 粘结")
private Double ddp4;
@Comment("目标大堆 备用")
private Double ddp5;
@Comment("产量初始值")
private Double initTotalNumber = 0.0;
}

View File

@@ -0,0 +1,64 @@
package cn.lihongjie.coal.dto;
import cn.lihongjie.coal.dto.base.OrgCommonDto;
import cn.lihongjie.coal.entity.CoalWashingDailyAnalysisItemVo;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.ForeignKey;
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;
@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;
@Comment("目标大堆 硫")
private Double ddp2;
@Comment("目标大堆 挥发")
private Double ddp3;
@Comment("目标大堆 粘结")
private Double ddp4;
@Comment("目标大堆 备用")
private Double ddp5;
@Comment("产量初始值")
private Double initTotalNumber = 0.0;
}

View File

@@ -0,0 +1,64 @@
package cn.lihongjie.coal.dto;
import cn.lihongjie.coal.dto.base.OrgCommonDto;
import cn.lihongjie.coal.entity.CoalWashingDailyAnalysisItemVo;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.ForeignKey;
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;
@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;
@Comment("目标大堆 硫")
private Double ddp2;
@Comment("目标大堆 挥发")
private Double ddp3;
@Comment("目标大堆 粘结")
private Double ddp4;
@Comment("目标大堆 备用")
private Double ddp5;
@Comment("产量初始值")
private Double initTotalNumber = 0.0;
}

View File

@@ -26,13 +26,13 @@ public class CoalWashingDailyAnalysisEntity extends OrgCommonEntity {
@ElementCollection
@Comment("用户手动录入的记录")
@CollectionTable(name = "CoalWashingDailyAnalysisItem", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private List<CoalWashingDailyAnalysisItemVo> inputItems;
@ElementCollection
@Comment("连续平均值")
@CollectionTable(name = "CoalWashingDailyAnalysisItem", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
@CollectionTable( foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private List<CoalWashingDailyAnalysisItemVo> rollingAvgItems;

View File

@@ -1,17 +1,19 @@
package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CoalParameterDefDto;
import cn.lihongjie.coal.dto.CreateCoalParameterDefDto;
import cn.lihongjie.coal.dto.UpdateCoalParameterDefDto;
import cn.lihongjie.coal.dto.CoalParameterDefDto;
import cn.lihongjie.coal.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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface CoalParameterDefMapper {

View File

@@ -0,0 +1,27 @@
package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateCoalWashingDailyAnalysisDto;
import cn.lihongjie.coal.dto.UpdateCoalWashingDailyAnalysisDto;
import cn.lihongjie.coal.dto.CoalWashingDailyAnalysisDto;
import cn.lihongjie.coal.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 {
CoalWashingDailyAnalysisDto toDto(CoalWashingDailyAnalysisEntity user);
CoalWashingDailyAnalysisEntity toEntity(CreateCoalWashingDailyAnalysisDto request);
void updateEntity(@MappingTarget CoalWashingDailyAnalysisEntity entity, UpdateCoalWashingDailyAnalysisDto dto);
}

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateDepartmentDto;
import cn.lihongjie.coal.dto.UpdateDepartmentDto;
import cn.lihongjie.coal.dto.DepartmentDto;
import cn.lihongjie.coal.dto.UpdateDepartmentDto;
import cn.lihongjie.coal.entity.DepartmentEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface DepartmentMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateDictionaryDto;
import cn.lihongjie.coal.dto.UpdateDictionaryDto;
import cn.lihongjie.coal.dto.DictionaryDto;
import cn.lihongjie.coal.dto.UpdateDictionaryDto;
import cn.lihongjie.coal.entity.DictionaryEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface DictionaryMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateOrganizationDto;
import cn.lihongjie.coal.dto.UpdateOrganizationDto;
import cn.lihongjie.coal.dto.OrganizationDto;
import cn.lihongjie.coal.dto.UpdateOrganizationDto;
import cn.lihongjie.coal.entity.OrganizationEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface OrganizationMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreatePermissionDto;
import cn.lihongjie.coal.dto.UpdatePermissionDto;
import cn.lihongjie.coal.dto.PermissionDto;
import cn.lihongjie.coal.dto.UpdatePermissionDto;
import cn.lihongjie.coal.entity.PermissionEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface PermissionMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateResourceDto;
import cn.lihongjie.coal.dto.UpdateResourceDto;
import cn.lihongjie.coal.dto.ResourceDto;
import cn.lihongjie.coal.dto.UpdateResourceDto;
import cn.lihongjie.coal.entity.ResourceEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface ResourceMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateRoleDto;
import cn.lihongjie.coal.dto.UpdateRoleDto;
import cn.lihongjie.coal.dto.RoleDto;
import cn.lihongjie.coal.dto.UpdateRoleDto;
import cn.lihongjie.coal.entity.RoleEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface RoleMapper {

View File

@@ -4,13 +4,15 @@ import cn.lihongjie.coal.entity.CoalWashingDailyAnalysisEntity;
import cn.lihongjie.coal.entity.CoalWashingDailyAnalysisItemVo;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface RoundMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateSupplierDto;
import cn.lihongjie.coal.dto.UpdateSupplierDto;
import cn.lihongjie.coal.dto.SupplierDto;
import cn.lihongjie.coal.dto.UpdateSupplierDto;
import cn.lihongjie.coal.entity.SupplierEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface SupplierMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateSysConfigDto;
import cn.lihongjie.coal.dto.UpdateSysConfigDto;
import cn.lihongjie.coal.dto.SysConfigDto;
import cn.lihongjie.coal.dto.UpdateSysConfigDto;
import cn.lihongjie.coal.entity.SysConfigEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface SysConfigMapper {

View File

@@ -2,16 +2,18 @@ package cn.lihongjie.coal.mapper;
import cn.lihongjie.coal.dto.CreateSysLogDto;
import cn.lihongjie.coal.dto.UpdateSysLogDto;
import cn.lihongjie.coal.dto.SysLogDto;
import cn.lihongjie.coal.dto.UpdateSysLogDto;
import cn.lihongjie.coal.entity.SysLogEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface SysLogMapper {

View File

@@ -8,10 +8,12 @@ import cn.lihongjie.coal.entity.UserEntity;
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}
uses = {CommonMapper.class},
mappingControl = DeepClone.class
)
public interface UserMapper {

View File

@@ -1,11 +1,90 @@
package cn.lihongjie.coal.service;
import cn.lihongjie.coal.dao.CoalWashingDailyAnalysisRepository;
import cn.lihongjie.coal.dto.*;
import cn.lihongjie.coal.entity.CoalWashingDailyAnalysisEntity;
import cn.lihongjie.coal.mapper.CoalWashingDailyAnalysisMapper;
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 CoalWashingDailyAnalysisService extends BaseService< CoalWashingDailyAnalysisEntity,CoalWashingDailyAnalysisRepository>{
public class CoalWashingDailyAnalysisService extends BaseService<CoalWashingDailyAnalysisEntity, CoalWashingDailyAnalysisRepository> {
@Autowired
CoalWashingDailyAnalysisRepository repository;
@Autowired
CoalWashingDailyAnalysisMapper mapper;
@PostConstruct
public void init() {
}
public CoalWashingDailyAnalysisDto create(CreateCoalWashingDailyAnalysisDto request) {
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
this.repository.save(entity);
return getById(entity.getId());
}
public CoalWashingDailyAnalysisDto calculate(CreateCoalWashingDailyAnalysisDto request) {
CoalWashingDailyAnalysisEntity entity = mapper.toEntity(request);
entity.rollingAvg();
return mapper.toDto(entity);
}
public CoalWashingDailyAnalysisDto update(UpdateCoalWashingDailyAnalysisDto request) {
CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId());
this.mapper.updateEntity(entity, request);
return null;
}
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);
}
}