This commit is contained in:
2024-04-19 16:02:33 +08:00
parent f44380794e
commit feb0827efa
22 changed files with 320 additions and 214 deletions

View File

@@ -5,15 +5,11 @@ import cn.lihongjie.coal.base.dto.OrgCommonDto;
import cn.lihongjie.coal.common.DictCode;
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
import jakarta.persistence.ManyToOne;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Type;
import java.util.List;
@@ -42,8 +38,7 @@ public class AcAppointmentDto extends OrgCommonDto {
@Comment("事由")
private String reason;
@Formula("(select array_agg(d.id) from t_ac_device_data d where d.plate_no = plate_no and d.pass_time between start_time and end_time)")
@Type(ListArrayType.class)
private List<String> acDeviceDataIds;

View File

@@ -8,7 +8,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import java.util.HashMap;
import java.util.List;
@@ -36,14 +35,6 @@ public class CoalBlendRequest {
@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 = 'coalBlend.coalType'\n"
+ " and i.code = coal_type)")
private String coalTypeName;
public Map<String, CoalConstraint> getConstraintMap() {
if (constraintMap == null) {

View File

@@ -176,4 +176,26 @@ public class CollectionUtils {
return new BigDecimal(o.toString());
}
public static <T> List<T> toList(Object o) {
if (o == null) {
return new ArrayList<>();
}
if (o instanceof List) {
return (List<T>) o;
}
if (o instanceof Collection) {
return new ArrayList<>((Collection<T>) o);
}
// if object is array
if (o.getClass().isArray()) {
return Arrays.asList((T[]) o);
}
return new ArrayList<>();
}
}

View File

@@ -1,22 +1,61 @@
package cn.lihongjie.coal.common;
import cn.lihongjie.coal.base.dto.BaseDto;
import cn.lihongjie.coal.base.entity.BaseEntity;
import com.google.common.base.CaseFormat;
import jakarta.persistence.Tuple;
import jakarta.persistence.TupleElement;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.core.convert.ConversionService;
import java.lang.reflect.Field;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@Slf4j
public class JpaUtils {
public static Function<String, String> underscoreToCamelCase =
(String name) -> CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
public static Function<Object, String> idGetter = (Object obj) -> {
if (obj == null) {
return null;
}
if (obj instanceof Map) {
return ((Map) obj).get("id").toString();
}
if (obj instanceof BaseEntity){
return ((BaseEntity) obj).getId();
}
if (obj instanceof BaseDto){
return ((BaseDto) obj).getId();
}
try{
return FieldUtils.readField(obj, "id", true).toString();
}catch (Exception e){
return null;
}
};
public static List<Map<String, Object>> convertTuplesToMap(List<Tuple> tuples) {
return convertTuplesToMap(tuples, Function.identity(), Function.identity());
}
public static Function<Object, Object> handleArray =
(Object value) -> {
if (value == null) {
@@ -24,10 +63,9 @@ public class JpaUtils {
}
if (value.getClass().isArray()) {
Object[] objects = (Object[]) value;
if (objects.length == 0 || (objects.length == 1 && objects[0] == null) ) {
if (objects.length == 0 || (objects.length == 1 && objects[0] == null)) {
return new ArrayList<>();
}
@@ -37,6 +75,90 @@ public class JpaUtils {
}
};
public static <T> void mergeMapToPojo(
Iterable<T> pojos,
Iterable<Map> maps,
ConversionService conversionService) {
mergeMapToPojo(pojos, x -> idGetter.apply(x), maps, "id", conversionService);
}
@SneakyThrows
public static <T, ID> void mergeMapToPojo(
Iterable<T> pojos,
Function<T, ID> pojoIdGetter,
Iterable<Map> maps,
String mapKey,
ConversionService conversionService) {
if (ObjectUtils.isEmpty(maps)) {
return;
}
if (ObjectUtils.isEmpty(pojos)) {
return;
}
Map<ID, T> pojoMap =
StreamSupport.stream(pojos.spliterator(), false)
.collect(Collectors.toMap(pojoIdGetter, Function.identity()));
Map<ID, Map> mapMap =
StreamSupport.stream(maps.spliterator(), false)
.collect(Collectors.toMap(e -> (ID) e.get(mapKey), Function.identity()));
Map<Class, Map<String, Field>> fieldMapCache = new HashMap<>();
for (ID id : mapMap.keySet()) {
T pojo = pojoMap.get(id);
if (pojo == null) {
continue;
}
var fields =
fieldMapCache.computeIfAbsent(
pojo.getClass(),
cls ->
FieldUtils.getAllFieldsList(cls).stream()
.collect(Collectors.toMap(e -> e.getName(), e -> e)));
Map map = mapMap.get(id);
for (Object key : map.keySet()) {
if (StringUtils.equals(key.toString(), mapKey)){
continue;
}
String fieldName = key.toString();
Object value = map.get(key);
if (!fields.containsKey(fieldName)) {
fieldName = underscoreToCamelCase.apply(fieldName);
}
if (!fields.containsKey(fieldName)) {
log.info(
"field {}/{} not found in class {}",
key,
fieldName,
pojo.getClass().getName());
continue;
}
Field field = fields.get(fieldName);
FieldUtils.writeField(
field, pojo, conversionService.convert(value, field.getType()), true);
}
}
}
public static List<Map<String, Object>> convertTuplesToMap(
List<Tuple> tuples, Function<String, String> keyMapper) {
return convertTuplesToMap(tuples, keyMapper, Function.identity());

View File

@@ -1,44 +0,0 @@
package cn.lihongjie.coal.department.entity;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Subselect;
import org.hibernate.annotations.Type;
import java.util.List;
@Comment("部门信息")
@Getter
@Setter
@Subselect("select * from t_department")
@Entity
public class DepartmentViewEntity extends OrgCommonEntity {
@Type(ListArrayType.class)
@Formula(
"(select array_agg(e.id) from t_employee e where e.department_id = any(self_and_children_ids('t_department', id, true)))")
private List<String> allEmpIds;
@Type(ListArrayType.class)
@Formula(
"(select array_agg(e.id) from t_employee e where e.department_id = any(self_and_children_ids('t_department', id, false)))")
private List<String> childrenEmpIds;
@Type(ListArrayType.class)
@Formula("(select array_agg(e.id) from t_employee e where e.department_id = id)")
private List<String> selfEmpIds;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
private List<DepartmentViewEntity> children;
@ManyToOne private DepartmentViewEntity parent;
}

View File

@@ -6,7 +6,6 @@ import cn.lihongjie.coal.department.dto.DepartmentDto;
import cn.lihongjie.coal.department.dto.DepartmentTreeDto;
import cn.lihongjie.coal.department.dto.UpdateDepartmentDto;
import cn.lihongjie.coal.department.entity.DepartmentEntity;
import cn.lihongjie.coal.department.entity.DepartmentViewEntity;
import org.mapstruct.*;
import org.mapstruct.control.DeepClone;
@@ -34,7 +33,5 @@ public interface DepartmentMapper
DepartmentTreeDto toTreeDtoExcludeChildren(DepartmentEntity departmentEntity);
DepartmentDto toDto(DepartmentViewEntity view);
DepartmentTreeDto toTreeDto(DepartmentViewEntity de);
}

View File

@@ -3,10 +3,30 @@ package cn.lihongjie.coal.department.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.department.entity.DepartmentEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public interface DepartmentRepository extends BaseRepository<DepartmentEntity> {
DepartmentEntity findByNameAndOrganizationId(String name, String organizationId);
@Query(
value = """
select d.id as id,
(select array_agg(e.id) from t_employee e where e.department_id = any(self_and_children_ids('t_department', d.id, true))) as all_emp_ids,
(select array_agg(e.id) from t_employee e where e.department_id = any(self_and_children_ids('t_department', d.id, false))) as children_emp_ids,
(select array_agg(e.id) from t_employee e where e.department_id = d.id) as self_emp_ids
from t_department d where d.id in :ids
""", nativeQuery = true)
List<Map> empIds(@Param("ids") List<String> ids);
}

View File

@@ -1,13 +0,0 @@
package cn.lihongjie.coal.department.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.department.entity.DepartmentEntity;
import cn.lihongjie.coal.department.entity.DepartmentViewEntity;
import org.springframework.stereotype.Repository;
@Repository
public interface DepartmentViewRepository extends BaseRepository<DepartmentViewEntity> {
DepartmentEntity findByNameAndOrganizationId(String name, String organizationId);
}

View File

@@ -4,6 +4,7 @@ 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.common.Ctx;
import cn.lihongjie.coal.common.JpaUtils;
import cn.lihongjie.coal.common.TreeUtils;
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
import cn.lihongjie.coal.department.dto.CreateDepartmentDto;
@@ -11,10 +12,8 @@ import cn.lihongjie.coal.department.dto.DepartmentDto;
import cn.lihongjie.coal.department.dto.DepartmentTreeDto;
import cn.lihongjie.coal.department.dto.UpdateDepartmentDto;
import cn.lihongjie.coal.department.entity.DepartmentEntity;
import cn.lihongjie.coal.department.entity.DepartmentViewEntity;
import cn.lihongjie.coal.department.mapper.DepartmentMapper;
import cn.lihongjie.coal.department.repository.DepartmentRepository;
import cn.lihongjie.coal.department.repository.DepartmentViewRepository;
import jakarta.annotation.PostConstruct;
import jakarta.persistence.EntityManager;
@@ -33,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -94,17 +94,19 @@ class DepartmentService extends BaseService<DepartmentEntity, DepartmentReposito
}
@Autowired
DepartmentViewRepository departmentViewRepository;
public List<DepartmentTreeDto> getRoots(CommonQuery request) {
if (CollectionUtils.isEmpty(request.getItems())){
List<DepartmentViewEntity> roots = this.departmentViewRepository.findAll( (root, query, criteriaBuilder) -> criteriaBuilder.isNull(root.get("parent")));
return roots.stream().map(de -> this.mapper.toTreeDto(de)).collect(Collectors.toList());
List<DepartmentEntity> roots = this.repository.findAll( (root, query, criteriaBuilder) -> criteriaBuilder.isNull(root.get("parent")));
return addEmpIds(
roots.stream()
.map(de -> this.mapper.toTreeDto(de))
.collect(Collectors.toList()));
}else {
Page<DepartmentViewEntity> page =
departmentViewRepository.findAll(
Page<DepartmentEntity> page =
repository.findAll(
request.specification(conversionService),
PageRequest.of(
request.getPageNo(),
@@ -117,36 +119,46 @@ class DepartmentService extends BaseService<DepartmentEntity, DepartmentReposito
List<DepartmentTreeDto> selfAndParent = this.findAllByIds(selfAndParentIds).stream().map(x -> (this.mapper.toTreeDtoExcludeChildren(x))).collect(Collectors.toList());
return StreamSupport.stream(
TreeUtils.buildTreeFromList(
selfAndParent,
DepartmentTreeDto::getId,
x -> x.getParent(),
(x, y) -> {
if (x.getChildren() == null) {
x.setChildren(new ArrayList<>());
}
x.getChildren().add(y);
return null;
})
.spliterator(),
false)
.collect(Collectors.toList());
return addEmpIds(
StreamSupport.stream(
TreeUtils.buildTreeFromList(
selfAndParent,
DepartmentTreeDto::getId,
x -> x.getParent(),
(x, y) -> {
if (x.getChildren() == null) {
x.setChildren(new ArrayList<>());
}
x.getChildren().add(y);
return null;
})
.spliterator(),
false)
.collect(Collectors.toList()));
}
}
private List<DepartmentTreeDto> addEmpIds(List<DepartmentTreeDto> collect) {
List<Map> maps = repository.empIds(
cn.lihongjie.coal.common.CollectionUtils.map(collect, DepartmentTreeDto::getId));
JpaUtils.mergeMapToPojo(collect, maps, conversionService);
return collect;
}
public Page<DepartmentDto> list(CommonQuery query) {
Page<DepartmentViewEntity> page =
Page<DepartmentEntity> page =
departmentViewRepository.findAll(
repository.findAll(
query.specification(conversionService),
PageRequest.of(
query.getPageNo(),

View File

@@ -1,11 +1,13 @@
package cn.lihongjie.coal.employee.entity;
import cn.lihongjie.coal.common.DictCode;
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
import jakarta.persistence.Embeddable;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import java.util.*;
@@ -18,15 +20,9 @@ public class EmpFamilyMemberVO {
@Comment("关系")
private String relation;
@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 = 'emp.familyMember.relation'\n"
+ " and i.code = relation)")
private String relationName;
@DictTranslate(dictKey = DictCode.EMP_FAMILYMEMBER_RELATION)
private String relationName;
private String phone;

View File

@@ -7,7 +7,6 @@ import jakarta.persistence.ManyToOne;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
@Data
public class CreateEmployeeRecordDto extends OrgCommonDto {
@@ -21,14 +20,7 @@ public class CreateEmployeeRecordDto extends OrgCommonDto {
@Comment("记录类型")
private String recordType;
@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 = 'emp.record.type'\n"
+ " and i.code = record_type)")
private String recordTypeName;

View File

@@ -1,28 +0,0 @@
package cn.lihongjie.coal.jobPost.entity;
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
import jakarta.persistence.Entity;
import lombok.Data;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Subselect;
import org.hibernate.annotations.Type;
import java.util.List;
@Data
@Subselect("select * from t_job_post")
@Entity
public class JobPostViewEntity extends OrgCommonEntity {
@Type(ListArrayType.class)
@Formula("(select array_agg(e.id) from t_employee e where e.job_post_id = id)")
private List<String> selfEmpIds;
}

View File

@@ -5,7 +5,6 @@ import cn.lihongjie.coal.jobPost.dto.CreateJobPostDto;
import cn.lihongjie.coal.jobPost.dto.JobPostDto;
import cn.lihongjie.coal.jobPost.dto.UpdateJobPostDto;
import cn.lihongjie.coal.jobPost.entity.JobPostEntity;
import cn.lihongjie.coal.jobPost.entity.JobPostViewEntity;
import org.mapstruct.Mapper;
import org.mapstruct.control.DeepClone;
@@ -18,5 +17,4 @@ public interface JobPostMapper
extends BaseMapper<JobPostEntity, JobPostDto, CreateJobPostDto, UpdateJobPostDto> {
JobPostDto toDto(JobPostViewEntity view);
}

View File

@@ -3,9 +3,26 @@ package cn.lihongjie.coal.jobPost.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.jobPost.entity.JobPostEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public interface JobPostRepository extends BaseRepository<JobPostEntity> {
JobPostEntity findByNameAndOrganizationId(String name, String organizationId);
@Query(
"""
select e.jobPost.id as id, array_agg(e.id) as empIds from EmployeeEntity e
where e.jobPost.id in :ids
group by e.jobPost.id
""")
List<Map> getSelfEmpIds(@Param("ids") List<String> ids);
record JobPostEmpDto(String id, List<String> empIds) {
}
}

View File

@@ -1,12 +0,0 @@
package cn.lihongjie.coal.jobPost.repository;
import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.jobPost.entity.JobPostEntity;
import cn.lihongjie.coal.jobPost.entity.JobPostViewEntity;
import org.springframework.stereotype.Repository;
@Repository
public interface JobPostViewRepository extends BaseRepository<JobPostViewEntity> {
JobPostEntity findByNameAndOrganizationId(String name, String organizationId);
}

View File

@@ -2,16 +2,16 @@ package cn.lihongjie.coal.jobPost.service;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.base.entity.BaseEntity;
import cn.lihongjie.coal.base.service.BaseService;
import cn.lihongjie.coal.common.CollectionUtils;
import cn.lihongjie.coal.common.Ctx;
import cn.lihongjie.coal.jobPost.dto.CreateJobPostDto;
import cn.lihongjie.coal.jobPost.dto.JobPostDto;
import cn.lihongjie.coal.jobPost.dto.UpdateJobPostDto;
import cn.lihongjie.coal.jobPost.entity.JobPostEntity;
import cn.lihongjie.coal.jobPost.entity.JobPostViewEntity;
import cn.lihongjie.coal.jobPost.mapper.JobPostMapper;
import cn.lihongjie.coal.jobPost.repository.JobPostRepository;
import cn.lihongjie.coal.jobPost.repository.JobPostViewRepository;
import lombok.extern.slf4j.Slf4j;
@@ -23,19 +23,19 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
@Transactional
public
class JobPostService extends BaseService<JobPostEntity, JobPostRepository> {
public class JobPostService extends BaseService<JobPostEntity, JobPostRepository> {
@Autowired private JobPostRepository repository;
@Autowired private JobPostMapper mapper;
@Autowired private ConversionService conversionService;
@Autowired JobPostViewRepository jobPostViewRepository;
public JobPostDto create(CreateJobPostDto request) {
JobPostEntity entity = mapper.toEntity(request);
@@ -63,22 +63,34 @@ class JobPostService extends BaseService<JobPostEntity, JobPostRepository> {
}
public Page<JobPostDto> list(CommonQuery query) {
Page<JobPostViewEntity> page =
jobPostViewRepository.findAll(
Page<JobPostEntity> page =
repository.findAll(
query.specification(conversionService),
PageRequest.of(
query.getPageNo(),
query.getPageSize(),
Sort.by(query.getOrders())));
return page.map(this.mapper::toDto);
Page<JobPostDto> page1 = page.map(this.mapper::toDto);
List<Map> selfEmpIds =
repository.getSelfEmpIds(CollectionUtils.map(page.getContent(), BaseEntity::getId));
page1.forEach(
x -> {
selfEmpIds.stream()
.filter(y -> y.get("id").equals(x.getId()))
.findFirst()
.ifPresent(
y -> x.setSelfEmpIds(CollectionUtils.toList(y.get("empIds"))));
});
return page1;
}
public JobPostDto findByName(String name) {
JobPostEntity post = repository.findByNameAndOrganizationId(name, Ctx.currentUser().getOrganizationId());
return mapper.toDto(post);
JobPostEntity post =
repository.findByNameAndOrganizationId(name, Ctx.currentUser().getOrganizationId());
return mapper.toDto(post);
}
}

View File

@@ -1,8 +1,69 @@
package cn.lihongjie.coal.pdcDeviceData.dto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;
import cn.lihongjie.coal.pdcDevice.dto.PdcDeviceDto;
import jakarta.persistence.ManyToOne;
import lombok.Data;
import org.hibernate.annotations.Comment;
import java.time.LocalDateTime;
@Data
public class PdcDeviceDataDto extends OrgCommonDto {}
public class PdcDeviceDataDto extends OrgCommonDto {
@ManyToOne
private PdcDeviceDto device;
private LocalDateTime time;
@Comment("modbus地址")
private String modbusUId;
@Comment("总累计量")
private Double totalData;
@Comment("月累计量")
private Double monthData;
@Comment("日累计量")
private Double dayData;
@Comment("班累计量")
private Double classData;
@Comment(" 批累计量")
private Double batchData;
@Comment("定值累计量")
private Double fixedData;
@Comment("瞬时流量")
private Double flowData;
@Comment("瞬时速度")
private Double speedData;
@Comment("当前负荷")
private Double loadData;
@Comment("控制输出")
private Double outputData;
@Comment("故障状态")
private Double faultData;
@Comment("故障信息")
private String faultInfo;
@Comment("净重")
private Double netData;
@Comment("过程数据1")
private Double process1Data;
@Comment("过程数据2")
private Double process2Data;
}

View File

@@ -73,6 +73,6 @@ public class PdcDeviceDataEntity extends OrgCommonEntity {
private Double process2Data;
private Boolean saved;
// private Boolean saved;
}

View File

@@ -122,7 +122,8 @@ public class PdcDeviceRealTimeDataService
with tmp1 as (
select d.device_id as device_id, max(coal_type) as coal_type, max(total_data) - min(total_data) as time_total from t_pdc_device_data d
select d.device_id as device_id, max(p.coal_type) as coal_type, max(total_data) - min(total_data) as time_total from t_pdc_device_data d
left join t_pdc_device p on d.device_id = p.id
where d.organization_id = :organizationId
and d.time >= :startTime
and d.time <= :endTime

View File

@@ -5,7 +5,6 @@ import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
@Data
public class CreateProductDto extends OrgCommonDto {
@@ -14,12 +13,5 @@ public class CreateProductDto extends OrgCommonDto {
@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;
}

View File

@@ -5,19 +5,11 @@ import cn.lihongjie.coal.base.dto.OrgCommonDto;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
@Data
public class UpdateProductDto extends OrgCommonDto {
@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;
}

View File

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