添加过磅数据报表配置

This commit is contained in:
2024-04-15 14:32:23 +08:00
parent fdcd91b49c
commit 3e5169444f
9 changed files with 222 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
package cn.lihongjie.coal.weightDeviceDataReport.controller;
import cn.lihongjie.coal.annotation.OrgScope;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.weightDeviceDataReport.dto.CreateWeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.dto.UpdateWeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.dto.WeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.service.WeightDeviceDataReportService;
import lombok.extern.slf4j.Slf4j;
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;
@RestController
@RequestMapping("/weightDeviceDataReport")
@SysLog(module = "过磅数据报表")
@Slf4j
@OrgScope
public class WeightDeviceDataReportController {
@Autowired private WeightDeviceDataReportService service;
@PostMapping("/create")
public WeightDeviceDataReportDto create(@RequestBody CreateWeightDeviceDataReportDto request) {
return this.service.create(request);
}
@PostMapping("/update")
public WeightDeviceDataReportDto update(@RequestBody UpdateWeightDeviceDataReportDto request) {
return this.service.update(request);
}
@PostMapping("/delete")
public Object delete(@RequestBody IdRequest request) {
this.service.delete(request);
return true;
}
@PostMapping("/getById")
public WeightDeviceDataReportDto getById(@RequestBody IdRequest request) {
return this.service.getById(request.getId());
}
@PostMapping("/list")
public Page<WeightDeviceDataReportDto> list(@RequestBody CommonQuery request) {
return this.service.list(request);
}
}

View File

@@ -0,0 +1,10 @@
package cn.lihongjie.coal.weightDeviceDataReport.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
@Data
public class CreateWeightDeviceDataReportDto extends OrgCommonDto {
private String jsonConfig;
}

View File

@@ -0,0 +1,10 @@
package cn.lihongjie.coal.weightDeviceDataReport.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
@Data
public class UpdateWeightDeviceDataReportDto extends OrgCommonDto {
private String jsonConfig;
}

View File

@@ -0,0 +1,10 @@
package cn.lihongjie.coal.weightDeviceDataReport.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
@Data
public class WeightDeviceDataReportDto extends OrgCommonDto {
private String jsonConfig;
}

View File

@@ -0,0 +1,14 @@
package cn.lihongjie.coal.weightDeviceDataReport.entity;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import jakarta.persistence.Entity;
import lombok.Data;
@Data
@Entity
public class WeightDeviceDataReportEntity extends OrgCommonEntity {
private String jsonConfig;
}

View File

@@ -0,0 +1,23 @@
package cn.lihongjie.coal.weightDeviceDataReport.mapper;
import cn.lihongjie.coal.base.mapper.BaseMapper;
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
import cn.lihongjie.coal.base.mapper.CommonMapper;
import cn.lihongjie.coal.weightDeviceDataReport.dto.CreateWeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.dto.UpdateWeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.dto.WeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.entity.WeightDeviceDataReportEntity;
import org.mapstruct.Mapper;
import org.mapstruct.control.DeepClone;
@Mapper(
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
uses = {CommonMapper.class, CommonEntityMapper.class},
mappingControl = DeepClone.class)
public interface WeightDeviceDataReportMapper
extends BaseMapper<
WeightDeviceDataReportEntity,
WeightDeviceDataReportDto,
CreateWeightDeviceDataReportDto,
UpdateWeightDeviceDataReportDto> {}

View File

@@ -0,0 +1,10 @@
package cn.lihongjie.coal.weightDeviceDataReport.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.weightDeviceDataReport.entity.WeightDeviceDataReportEntity;
import org.springframework.stereotype.Repository;
@Repository
public interface WeightDeviceDataReportRepository
extends BaseRepository<WeightDeviceDataReportEntity> {}

View File

@@ -0,0 +1,74 @@
package cn.lihongjie.coal.weightDeviceDataReport.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.dbFunctions.DbFunctionService;
import cn.lihongjie.coal.weightDeviceDataReport.dto.CreateWeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.dto.UpdateWeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.dto.WeightDeviceDataReportDto;
import cn.lihongjie.coal.weightDeviceDataReport.entity.WeightDeviceDataReportEntity;
import cn.lihongjie.coal.weightDeviceDataReport.mapper.WeightDeviceDataReportMapper;
import cn.lihongjie.coal.weightDeviceDataReport.repository.WeightDeviceDataReportRepository;
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;
import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
@Transactional
public class WeightDeviceDataReportService
extends BaseService<WeightDeviceDataReportEntity, WeightDeviceDataReportRepository> {
@Autowired private WeightDeviceDataReportRepository repository;
@Autowired private WeightDeviceDataReportMapper mapper;
@Autowired private ConversionService conversionService;
@Autowired private DbFunctionService dbFunctionService;
public WeightDeviceDataReportDto create(CreateWeightDeviceDataReportDto request) {
WeightDeviceDataReportEntity entity = mapper.toEntity(request);
this.repository.save(entity);
return getById(entity.getId());
}
public WeightDeviceDataReportDto update(UpdateWeightDeviceDataReportDto request) {
WeightDeviceDataReportEntity entity = this.repository.get(request.getId());
this.mapper.updateEntity(entity, request);
this.repository.save(entity);
return getById(entity.getId());
}
public void delete(IdRequest request) {
this.repository.deleteAllById(request.getIds());
}
public WeightDeviceDataReportDto getById(String id) {
WeightDeviceDataReportEntity entity = repository.get(id);
return mapper.toDto(entity);
}
public Page<WeightDeviceDataReportDto> list(CommonQuery query) {
Page<WeightDeviceDataReportEntity> page =
repository.findAll(
query.specification(conversionService),
PageRequest.of(
query.getPageNo(),
query.getPageSize(),
Sort.by(query.getOrders())));
return page.map(this.mapper::toDto);
}
}

View File

@@ -0,0 +1,17 @@
package scripts.dict
import cn.lihongjie.coal.base.dto.CommonQuery
import cn.lihongjie.coal.weightDeviceDataReport.controller.WeightDeviceDataReportController
import org.springframework.context.ApplicationContext
ApplicationContext ioc = ioc
def controller = ioc.getBean(WeightDeviceDataReportController.class)
return controller.list(new CommonQuery())