mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
添加特种设备
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package cn.lihongjie.coal.tzDevice.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.tzDevice.dto.CreateTzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.dto.TzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.dto.UpdateTzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.service.TzDeviceService;
|
||||
|
||||
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("/tzDevice")
|
||||
@SysLog(module = "特种设备")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class TzDeviceController {
|
||||
@Autowired private TzDeviceService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public TzDeviceDto create(@RequestBody CreateTzDeviceDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public TzDeviceDto update(@RequestBody UpdateTzDeviceDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public TzDeviceDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<TzDeviceDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/archive")
|
||||
public Object archive(@RequestBody IdRequest request) {
|
||||
this.service.archive(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/unarchive")
|
||||
public Object unarchive(@RequestBody IdRequest request) {
|
||||
this.service.unarchive(request);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.lihongjie.coal.tzDevice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.tzDevice.entity.TzDevicePartVo;
|
||||
|
||||
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.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreateTzDeviceDto extends OrgCommonDto {
|
||||
|
||||
@Comment("设计单位")
|
||||
private String designUnit;
|
||||
|
||||
@Comment("制造单位")
|
||||
private String manufacturingUnit;
|
||||
|
||||
@Comment("制造年月")
|
||||
private LocalDateTime manufacturingDate;
|
||||
|
||||
@Comment("投用日期")
|
||||
private LocalDateTime commissioningDate;
|
||||
|
||||
@Comment("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@Comment("主体材质")
|
||||
private String mainMaterial;
|
||||
|
||||
@Comment("设备原值")
|
||||
private Double equipmentOriginalValue;
|
||||
|
||||
@Comment("总重量")
|
||||
private Double totalWeight;
|
||||
|
||||
@Comment("壳体重量")
|
||||
private Double shellWeight;
|
||||
|
||||
@Comment("内件重量")
|
||||
private Double internalPartsWeight;
|
||||
|
||||
@Comment("检验周期")
|
||||
private String inspectionCycle;
|
||||
|
||||
@Comment("容器类别")
|
||||
private String containerCategory;
|
||||
|
||||
@Comment("压力等级")
|
||||
private Double pressureLevel;
|
||||
|
||||
@Comment("注册编号")
|
||||
private String registrationNumber;
|
||||
|
||||
@Comment("使用证编号")
|
||||
private String certificateNumber;
|
||||
|
||||
@Comment("安全状况等级")
|
||||
private String safetyConditionLevel;
|
||||
|
||||
@Comment("使用寿命")
|
||||
private String serviceLife;
|
||||
|
||||
@Comment("报废时间")
|
||||
private LocalDateTime scrapTime;
|
||||
|
||||
@Comment("容器规格 - 内径长度")
|
||||
private Double internalDiameterLength;
|
||||
|
||||
@Comment("容器规格 - 厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Comment("容器规格 - 容积")
|
||||
private Double volume;
|
||||
|
||||
@Comment("操作条件 - 温度")
|
||||
private Double operatingTemperature;
|
||||
|
||||
@Comment("操作条件 - 最高工作压力")
|
||||
private Double maxWorkingPressure;
|
||||
|
||||
@Comment("操作条件 - 介质")
|
||||
private String medium;
|
||||
|
||||
@Comment("检验日期")
|
||||
private LocalDateTime inspectionDate;
|
||||
|
||||
@Comment("下次检验日期")
|
||||
private LocalDateTime nextInspectionDate;
|
||||
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
// 设备配件
|
||||
private List<TzDevicePartVo> devicePart;
|
||||
}
|
||||
109
src/main/java/cn/lihongjie/coal/tzDevice/dto/TzDeviceDto.java
Normal file
109
src/main/java/cn/lihongjie/coal/tzDevice/dto/TzDeviceDto.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package cn.lihongjie.coal.tzDevice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
import cn.lihongjie.coal.tzDevice.entity.TzDevicePartVo;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.TzDeviceSupplierDto;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TzDeviceDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
|
||||
|
||||
@Comment("设计单位")
|
||||
private TzDeviceSupplierDto designUnit;
|
||||
|
||||
@Comment("制造单位")
|
||||
private TzDeviceSupplierDto manufacturingUnit;
|
||||
|
||||
@Comment("制造年月")
|
||||
private LocalDateTime manufacturingDate;
|
||||
|
||||
@Comment("投用日期")
|
||||
private LocalDateTime commissioningDate;
|
||||
|
||||
@Comment("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@Comment("主体材质")
|
||||
private String mainMaterial;
|
||||
|
||||
@Comment("设备原值")
|
||||
private Double equipmentOriginalValue;
|
||||
|
||||
@Comment("总重量")
|
||||
private Double totalWeight;
|
||||
|
||||
@Comment("壳体重量")
|
||||
private Double shellWeight;
|
||||
|
||||
@Comment("内件重量")
|
||||
private Double internalPartsWeight;
|
||||
|
||||
@Comment("检验周期")
|
||||
private String inspectionCycle;
|
||||
|
||||
@Comment("容器类别")
|
||||
private String containerCategory;
|
||||
|
||||
@Comment("压力等级")
|
||||
private Double pressureLevel;
|
||||
|
||||
@Comment("注册编号")
|
||||
private String registrationNumber;
|
||||
|
||||
@Comment("使用证编号")
|
||||
private String certificateNumber;
|
||||
|
||||
@Comment("安全状况等级")
|
||||
private String safetyConditionLevel;
|
||||
|
||||
@Comment("使用寿命")
|
||||
private String serviceLife;
|
||||
|
||||
@Comment("报废时间")
|
||||
private LocalDateTime scrapTime;
|
||||
|
||||
@Comment("容器规格 - 内径长度")
|
||||
private Double internalDiameterLength;
|
||||
|
||||
@Comment("容器规格 - 厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Comment("容器规格 - 容积")
|
||||
private Double volume;
|
||||
|
||||
@Comment("操作条件 - 温度")
|
||||
private Double operatingTemperature;
|
||||
|
||||
@Comment("操作条件 - 最高工作压力")
|
||||
private Double maxWorkingPressure;
|
||||
|
||||
@Comment("操作条件 - 介质")
|
||||
private String medium;
|
||||
|
||||
@Comment("检验日期")
|
||||
private LocalDateTime inspectionDate;
|
||||
|
||||
@Comment("下次检验日期")
|
||||
private LocalDateTime nextInspectionDate;
|
||||
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
// 设备配件
|
||||
private List<TzDevicePartVo> devicePart;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.lihongjie.coal.tzDevice.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.tzDevice.entity.TzDevicePartVo;
|
||||
|
||||
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.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateTzDeviceDto extends OrgCommonDto {
|
||||
|
||||
@Comment("设计单位")
|
||||
private String designUnit;
|
||||
|
||||
@Comment("制造单位")
|
||||
private String manufacturingUnit;
|
||||
|
||||
@Comment("制造年月")
|
||||
private LocalDateTime manufacturingDate;
|
||||
|
||||
@Comment("投用日期")
|
||||
private LocalDateTime commissioningDate;
|
||||
|
||||
@Comment("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@Comment("主体材质")
|
||||
private String mainMaterial;
|
||||
|
||||
@Comment("设备原值")
|
||||
private Double equipmentOriginalValue;
|
||||
|
||||
@Comment("总重量")
|
||||
private Double totalWeight;
|
||||
|
||||
@Comment("壳体重量")
|
||||
private Double shellWeight;
|
||||
|
||||
@Comment("内件重量")
|
||||
private Double internalPartsWeight;
|
||||
|
||||
@Comment("检验周期")
|
||||
private String inspectionCycle;
|
||||
|
||||
@Comment("容器类别")
|
||||
private String containerCategory;
|
||||
|
||||
@Comment("压力等级")
|
||||
private Double pressureLevel;
|
||||
|
||||
@Comment("注册编号")
|
||||
private String registrationNumber;
|
||||
|
||||
@Comment("使用证编号")
|
||||
private String certificateNumber;
|
||||
|
||||
@Comment("安全状况等级")
|
||||
private String safetyConditionLevel;
|
||||
|
||||
@Comment("使用寿命")
|
||||
private String serviceLife;
|
||||
|
||||
@Comment("报废时间")
|
||||
private LocalDateTime scrapTime;
|
||||
|
||||
@Comment("容器规格 - 内径长度")
|
||||
private Double internalDiameterLength;
|
||||
|
||||
@Comment("容器规格 - 厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Comment("容器规格 - 容积")
|
||||
private Double volume;
|
||||
|
||||
@Comment("操作条件 - 温度")
|
||||
private Double operatingTemperature;
|
||||
|
||||
@Comment("操作条件 - 最高工作压力")
|
||||
private Double maxWorkingPressure;
|
||||
|
||||
@Comment("操作条件 - 介质")
|
||||
private String medium;
|
||||
|
||||
@Comment("检验日期")
|
||||
private LocalDateTime inspectionDate;
|
||||
|
||||
@Comment("下次检验日期")
|
||||
private LocalDateTime nextInspectionDate;
|
||||
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
// 设备配件
|
||||
private List<TzDevicePartVo> devicePart;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package cn.lihongjie.coal.tzDevice.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.entity.TzDeviceSupplierEntity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_tzDevice_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class TzDeviceEntity extends OrgCommonEntity {
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
// @Comment("设备名称")
|
||||
// private String equipmentName;
|
||||
//
|
||||
// @Comment("设备编号")
|
||||
// private String equipmentNumber;
|
||||
|
||||
@Comment("设计单位")
|
||||
@ManyToOne
|
||||
private TzDeviceSupplierEntity designUnit;
|
||||
|
||||
@Comment("制造单位")
|
||||
@ManyToOne
|
||||
private TzDeviceSupplierEntity manufacturingUnit;
|
||||
|
||||
@Comment("制造年月")
|
||||
private LocalDateTime manufacturingDate;
|
||||
|
||||
@Comment("投用日期")
|
||||
private LocalDateTime commissioningDate;
|
||||
|
||||
@Comment("设备型号")
|
||||
private String equipmentModel;
|
||||
|
||||
@Comment("主体材质")
|
||||
private String mainMaterial;
|
||||
|
||||
@Comment("设备原值")
|
||||
private Double equipmentOriginalValue;
|
||||
|
||||
@Comment("总重量")
|
||||
private Double totalWeight;
|
||||
|
||||
@Comment("壳体重量")
|
||||
private Double shellWeight;
|
||||
|
||||
@Comment("内件重量")
|
||||
private Double internalPartsWeight;
|
||||
|
||||
@Comment("检验周期")
|
||||
private String inspectionCycle;
|
||||
|
||||
@Comment("容器类别")
|
||||
private String containerCategory;
|
||||
|
||||
@Comment("压力等级")
|
||||
private Double pressureLevel;
|
||||
|
||||
@Comment("注册编号")
|
||||
private String registrationNumber;
|
||||
|
||||
@Comment("使用证编号")
|
||||
private String certificateNumber;
|
||||
|
||||
@Comment("安全状况等级")
|
||||
private String safetyConditionLevel;
|
||||
|
||||
@Comment("使用寿命")
|
||||
private String serviceLife;
|
||||
|
||||
@Comment("报废时间")
|
||||
private LocalDateTime scrapTime;
|
||||
|
||||
@Comment("容器规格 - 内径长度")
|
||||
private Double internalDiameterLength;
|
||||
|
||||
@Comment("容器规格 - 厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Comment("容器规格 - 容积")
|
||||
private Double volume;
|
||||
|
||||
@Comment("操作条件 - 温度")
|
||||
private Double operatingTemperature;
|
||||
|
||||
@Comment("操作条件 - 最高工作压力")
|
||||
private Double maxWorkingPressure;
|
||||
|
||||
@Comment("操作条件 - 介质")
|
||||
private String medium;
|
||||
|
||||
@Comment("检验日期")
|
||||
private LocalDateTime inspectionDate;
|
||||
|
||||
@Comment("下次检验日期")
|
||||
private LocalDateTime nextInspectionDate;
|
||||
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
|
||||
// 设备配件
|
||||
private List<TzDevicePartVo> devicePart;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.lihongjie.coal.tzDevice.entity;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
@Embeddable
|
||||
public class TzDevicePartVo {
|
||||
|
||||
@Comment("配套附件型号")
|
||||
private String partModel;
|
||||
|
||||
@Comment("配套附件工作介质")
|
||||
private String partMedium;
|
||||
|
||||
@Comment("配套附件要求整定压力")
|
||||
private Double partSetPressure;
|
||||
|
||||
@Comment("配套附件安装部位")
|
||||
private String partInstallationPart;
|
||||
|
||||
@Comment("配套附件出厂编号")
|
||||
private String partSerialNumber;
|
||||
|
||||
@Comment("配套附件公称压力")
|
||||
private Double partNominalPressure;
|
||||
|
||||
@Comment("配套附件厂内编号")
|
||||
private String partFactoryNumber;
|
||||
|
||||
@Comment("配套附件检验日期")
|
||||
private LocalDateTime partInspectionDate;
|
||||
|
||||
@Comment("配套附件下次检验日期")
|
||||
private LocalDateTime partNextInspectionDate;
|
||||
|
||||
@Comment("配套附件使用时间")
|
||||
private String partUsageTime;
|
||||
|
||||
@Comment("使用单位")
|
||||
private String usingUnit;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.lihongjie.coal.tzDevice.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.tzDevice.dto.CreateTzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.dto.TzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.dto.UpdateTzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.entity.TzDeviceEntity;
|
||||
|
||||
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 TzDeviceMapper
|
||||
extends BaseMapper<TzDeviceEntity, TzDeviceDto, CreateTzDeviceDto, UpdateTzDeviceDto> {}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.lihongjie.coal.tzDevice.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.tzDevice.entity.TzDeviceEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TzDeviceRepository extends BaseRepository<TzDeviceEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.lihongjie.coal.tzDevice.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.exception.BizException;
|
||||
import cn.lihongjie.coal.tzDevice.dto.CreateTzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.dto.TzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.dto.UpdateTzDeviceDto;
|
||||
import cn.lihongjie.coal.tzDevice.entity.TzDeviceEntity;
|
||||
import cn.lihongjie.coal.tzDevice.mapper.TzDeviceMapper;
|
||||
import cn.lihongjie.coal.tzDevice.repository.TzDeviceRepository;
|
||||
|
||||
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 TzDeviceService extends BaseService<TzDeviceEntity, TzDeviceRepository> {
|
||||
@Autowired private TzDeviceRepository repository;
|
||||
|
||||
@Autowired private TzDeviceMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public TzDeviceDto create(CreateTzDeviceDto request) {
|
||||
TzDeviceEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public TzDeviceDto update(UpdateTzDeviceDto request) {
|
||||
TzDeviceEntity entity = this.repository.get(request.getId());
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
if (this.repository.containArchived(request)) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public TzDeviceDto getById(String id) {
|
||||
TzDeviceEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<TzDeviceDto> list(CommonQuery query) {
|
||||
Page<TzDeviceEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.archive(dto);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.unArchive(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.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.tzDeviceCategory.dto.CreateTzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryTreeDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.UpdateTzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.service.TzDeviceCategoryService;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/tzDeviceCategory")
|
||||
@SysLog(module = "特种设备分类")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class TzDeviceCategoryController {
|
||||
@Autowired private TzDeviceCategoryService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public TzDeviceCategoryDto create(@RequestBody CreateTzDeviceCategoryDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public TzDeviceCategoryDto update(@RequestBody UpdateTzDeviceCategoryDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public TzDeviceCategoryDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<TzDeviceCategoryDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/roots")
|
||||
public List<TzDeviceCategoryTreeDto> roots(@RequestBody CommonQuery request) {
|
||||
return this.service.getRoots(request);
|
||||
}
|
||||
|
||||
@PostMapping("/treeByIds")
|
||||
public List<TzDeviceCategoryTreeDto> treeByIds(@RequestBody IdRequest request) {
|
||||
return this.service.getTreeByIds(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateTzDeviceCategoryDto extends OrgCommonDto {
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TzDeviceCategoryDto extends OrgCommonDto {
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TzDeviceCategoryTreeDto extends OrgCommonDto {
|
||||
private List<TzDeviceCategoryTreeDto> children;
|
||||
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateTzDeviceCategoryDto extends OrgCommonDto {
|
||||
private String parent;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_tzDeviceCategory_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class TzDeviceCategoryEntity extends OrgCommonEntity {
|
||||
@ManyToOne private TzDeviceCategoryEntity parent;
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
|
||||
private List<TzDeviceCategoryEntity> children;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.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.tzDeviceCategory.dto.CreateTzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryTreeDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.UpdateTzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.entity.TzDeviceCategoryEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class, CommonEntityMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface TzDeviceCategoryMapper
|
||||
extends BaseMapper<
|
||||
TzDeviceCategoryEntity,
|
||||
TzDeviceCategoryDto,
|
||||
CreateTzDeviceCategoryDto,
|
||||
UpdateTzDeviceCategoryDto> {
|
||||
@Mappings({@Mapping(target = "children", qualifiedByName = "toTreeDto")})
|
||||
@Named("toTreeDto")
|
||||
TzDeviceCategoryTreeDto toTreeDto(TzDeviceCategoryEntity entity);
|
||||
|
||||
@Mappings({@Mapping(target = "children", ignore = true)})
|
||||
TzDeviceCategoryTreeDto toTreeDtoExcludeChildren(TzDeviceCategoryEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.entity.TzDeviceCategoryEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TzDeviceCategoryRepository extends BaseRepository<TzDeviceCategoryEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package cn.lihongjie.coal.tzDeviceCategory.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.common.TreeUtils;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.CreateTzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryTreeDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.dto.UpdateTzDeviceCategoryDto;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.entity.TzDeviceCategoryEntity;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.mapper.TzDeviceCategoryMapper;
|
||||
import cn.lihongjie.coal.tzDeviceCategory.repository.TzDeviceCategoryRepository;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
public class TzDeviceCategoryService
|
||||
extends BaseService<TzDeviceCategoryEntity, TzDeviceCategoryRepository> {
|
||||
@Autowired private TzDeviceCategoryRepository repository;
|
||||
|
||||
@Autowired private TzDeviceCategoryMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public TzDeviceCategoryDto create(CreateTzDeviceCategoryDto request) {
|
||||
TzDeviceCategoryEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public TzDeviceCategoryDto update(UpdateTzDeviceCategoryDto request) {
|
||||
TzDeviceCategoryEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public TzDeviceCategoryDto getById(String id) {
|
||||
TzDeviceCategoryEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<TzDeviceCategoryDto> list(CommonQuery query) {
|
||||
Page<TzDeviceCategoryEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public List<TzDeviceCategoryTreeDto> getRoots(CommonQuery request) {
|
||||
|
||||
if (CollectionUtils.isEmpty(request.getItems())) {
|
||||
List<TzDeviceCategoryEntity> roots =
|
||||
this.repository.findAll(
|
||||
(root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.isNull(root.get("parent")));
|
||||
return roots.stream().map(de -> this.mapper.toTreeDto(de)).collect(Collectors.toList());
|
||||
} else {
|
||||
Page<TzDeviceCategoryEntity> page =
|
||||
repository.findAll(
|
||||
request.specification(conversionService),
|
||||
PageRequest.of(
|
||||
request.getPageNo(),
|
||||
request.getPageSize(),
|
||||
Sort.by(request.getOrders())));
|
||||
|
||||
List<String> selfAndParentIds =
|
||||
this.dbFunctionService.selfAndParentIds(
|
||||
dbFunctionService.entityToTableName(TzDeviceCategoryEntity.class),
|
||||
page.stream().map(x -> x.getId()).collect(Collectors.toList()),
|
||||
true);
|
||||
|
||||
List<TzDeviceCategoryTreeDto> selfAndParent =
|
||||
this.findAllByIds(selfAndParentIds).stream()
|
||||
.map(x -> (this.mapper.toTreeDtoExcludeChildren(x)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return StreamSupport.stream(
|
||||
TreeUtils.buildTreeFromList(
|
||||
selfAndParent,
|
||||
TzDeviceCategoryTreeDto::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());
|
||||
}
|
||||
}
|
||||
|
||||
public List<TzDeviceCategoryTreeDto> getTreeByIds(IdRequest request) {
|
||||
if (request.getIds().isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
var roots =
|
||||
this.repository.findAll(
|
||||
(root, query, criteriaBuilder) -> root.get("id").in(request.getIds()));
|
||||
return roots.stream().map(de -> this.mapper.toTreeDto(de)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.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.tzDeviceMaintenanceRecord.dto.CreateTzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.TzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.UpdateTzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.service.TzDeviceMaintenanceRecordService;
|
||||
|
||||
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("/tzDeviceMaintenanceRecord")
|
||||
@SysLog(module = "特种设备检修记录")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class TzDeviceMaintenanceRecordController {
|
||||
@Autowired private TzDeviceMaintenanceRecordService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public TzDeviceMaintenanceRecordDto create(
|
||||
@RequestBody CreateTzDeviceMaintenanceRecordDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public TzDeviceMaintenanceRecordDto update(
|
||||
@RequestBody UpdateTzDeviceMaintenanceRecordDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public TzDeviceMaintenanceRecordDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<TzDeviceMaintenanceRecordDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/archive")
|
||||
public Object archive(@RequestBody IdRequest request) {
|
||||
this.service.archive(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/unarchive")
|
||||
public Object unarchive(@RequestBody IdRequest request) {
|
||||
this.service.unarchive(request);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CreateTzDeviceMaintenanceRecordDto extends OrgCommonDto {
|
||||
|
||||
@Comment("检维修时间")
|
||||
private LocalDateTime maintenanceDate;
|
||||
|
||||
@Comment("检维修原因")
|
||||
private String maintenanceReason;
|
||||
|
||||
@Comment("检维修内容")
|
||||
private String maintenanceContent;
|
||||
|
||||
@Comment("更换备品备件")
|
||||
private String replacedSpareParts;
|
||||
|
||||
@Comment("检维修人员")
|
||||
private String maintenancePersonnel;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class TzDeviceMaintenanceRecordDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
|
||||
|
||||
@Comment("检维修时间")
|
||||
private LocalDateTime maintenanceDate;
|
||||
|
||||
@Comment("检维修原因")
|
||||
private String maintenanceReason;
|
||||
|
||||
@Comment("检维修内容")
|
||||
private String maintenanceContent;
|
||||
|
||||
@Comment("更换备品备件")
|
||||
private String replacedSpareParts;
|
||||
|
||||
@Comment("检维修人员")
|
||||
private String maintenancePersonnel;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class UpdateTzDeviceMaintenanceRecordDto extends OrgCommonDto {
|
||||
|
||||
@Comment("检维修时间")
|
||||
private LocalDateTime maintenanceDate;
|
||||
|
||||
@Comment("检维修原因")
|
||||
private String maintenanceReason;
|
||||
|
||||
@Comment("检维修内容")
|
||||
private String maintenanceContent;
|
||||
|
||||
@Comment("更换备品备件")
|
||||
private String replacedSpareParts;
|
||||
|
||||
@Comment("检维修人员")
|
||||
private String maintenancePersonnel;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_tzDeviceMaintenanceRecord_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class TzDeviceMaintenanceRecordEntity extends OrgCommonEntity {
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
@Comment("检维修时间")
|
||||
private LocalDateTime maintenanceDate;
|
||||
|
||||
@Comment("检维修原因")
|
||||
private String maintenanceReason;
|
||||
|
||||
@Comment("检维修内容")
|
||||
private String maintenanceContent;
|
||||
|
||||
@Comment("更换备品备件")
|
||||
private String replacedSpareParts;
|
||||
|
||||
@Comment("检维修人员")
|
||||
private String maintenancePersonnel;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.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.tzDeviceMaintenanceRecord.dto.CreateTzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.TzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.UpdateTzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.entity.TzDeviceMaintenanceRecordEntity;
|
||||
|
||||
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 TzDeviceMaintenanceRecordMapper
|
||||
extends BaseMapper<
|
||||
TzDeviceMaintenanceRecordEntity,
|
||||
TzDeviceMaintenanceRecordDto,
|
||||
CreateTzDeviceMaintenanceRecordDto,
|
||||
UpdateTzDeviceMaintenanceRecordDto> {}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.entity.TzDeviceMaintenanceRecordEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TzDeviceMaintenanceRecordRepository
|
||||
extends BaseRepository<TzDeviceMaintenanceRecordEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.lihongjie.coal.tzDeviceMaintenanceRecord.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.exception.BizException;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.CreateTzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.TzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.dto.UpdateTzDeviceMaintenanceRecordDto;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.entity.TzDeviceMaintenanceRecordEntity;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.mapper.TzDeviceMaintenanceRecordMapper;
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.repository.TzDeviceMaintenanceRecordRepository;
|
||||
|
||||
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 TzDeviceMaintenanceRecordService
|
||||
extends BaseService<TzDeviceMaintenanceRecordEntity, TzDeviceMaintenanceRecordRepository> {
|
||||
@Autowired private TzDeviceMaintenanceRecordRepository repository;
|
||||
|
||||
@Autowired private TzDeviceMaintenanceRecordMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public TzDeviceMaintenanceRecordDto create(CreateTzDeviceMaintenanceRecordDto request) {
|
||||
TzDeviceMaintenanceRecordEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public TzDeviceMaintenanceRecordDto update(UpdateTzDeviceMaintenanceRecordDto request) {
|
||||
TzDeviceMaintenanceRecordEntity entity = this.repository.get(request.getId());
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
if (this.repository.containArchived(request)) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public TzDeviceMaintenanceRecordDto getById(String id) {
|
||||
TzDeviceMaintenanceRecordEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<TzDeviceMaintenanceRecordDto> list(CommonQuery query) {
|
||||
Page<TzDeviceMaintenanceRecordEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.archive(dto);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.unArchive(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.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.tzDeviceSupplier.dto.CreateTzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.TzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.UpdateTzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.service.TzDeviceSupplierService;
|
||||
|
||||
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("/tzDeviceSupplier")
|
||||
@SysLog(module = "特种设备厂家")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class TzDeviceSupplierController {
|
||||
@Autowired private TzDeviceSupplierService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public TzDeviceSupplierDto create(@RequestBody CreateTzDeviceSupplierDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public TzDeviceSupplierDto update(@RequestBody UpdateTzDeviceSupplierDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public TzDeviceSupplierDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<TzDeviceSupplierDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
|
||||
@PostMapping("/archive")
|
||||
public Object archive(@RequestBody IdRequest request) {
|
||||
this.service.archive(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/unarchive")
|
||||
public Object unarchive(@RequestBody IdRequest request) {
|
||||
this.service.unarchive(request);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateTzDeviceSupplierDto extends OrgCommonDto {
|
||||
|
||||
|
||||
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.common.DictCode;
|
||||
import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TzDeviceSupplierDto extends OrgCommonDto {
|
||||
private String archiveStatus;
|
||||
|
||||
@DictTranslate(dictKey = DictCode.ARCHIVESTATUS)
|
||||
private String archiveStatusName;
|
||||
|
||||
|
||||
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateTzDeviceSupplierDto extends OrgCommonDto {
|
||||
|
||||
|
||||
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(
|
||||
indexes =
|
||||
@jakarta.persistence.Index(
|
||||
name = "idx_tzDeviceSupplier_org_id",
|
||||
columnList = "organization_id"))
|
||||
public class TzDeviceSupplierEntity extends OrgCommonEntity {
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
|
||||
|
||||
|
||||
private String contact;
|
||||
|
||||
private String contactPhone;
|
||||
|
||||
private String address;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.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.tzDeviceSupplier.dto.CreateTzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.TzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.UpdateTzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.entity.TzDeviceSupplierEntity;
|
||||
|
||||
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 TzDeviceSupplierMapper
|
||||
extends BaseMapper<
|
||||
TzDeviceSupplierEntity,
|
||||
TzDeviceSupplierDto,
|
||||
CreateTzDeviceSupplierDto,
|
||||
UpdateTzDeviceSupplierDto> {}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.entity.TzDeviceSupplierEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TzDeviceSupplierRepository extends BaseRepository<TzDeviceSupplierEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.lihongjie.coal.tzDeviceSupplier.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.exception.BizException;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.CreateTzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.TzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.dto.UpdateTzDeviceSupplierDto;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.entity.TzDeviceSupplierEntity;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.mapper.TzDeviceSupplierMapper;
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.repository.TzDeviceSupplierRepository;
|
||||
|
||||
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 TzDeviceSupplierService
|
||||
extends BaseService<TzDeviceSupplierEntity, TzDeviceSupplierRepository> {
|
||||
@Autowired private TzDeviceSupplierRepository repository;
|
||||
|
||||
@Autowired private TzDeviceSupplierMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public TzDeviceSupplierDto create(CreateTzDeviceSupplierDto request) {
|
||||
TzDeviceSupplierEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public TzDeviceSupplierDto update(UpdateTzDeviceSupplierDto request) {
|
||||
TzDeviceSupplierEntity entity = this.repository.get(request.getId());
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
if (this.repository.containArchived(request)) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
boolean linked = this.repository.isLinked(request.getIds());
|
||||
|
||||
if (linked) {
|
||||
throw new BizException("数据已被关联,无法删除");
|
||||
}
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public TzDeviceSupplierDto getById(String id) {
|
||||
TzDeviceSupplierEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<TzDeviceSupplierDto> list(CommonQuery query) {
|
||||
Page<TzDeviceSupplierEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
public void archive(IdRequest dto) {
|
||||
this.repository.archive(dto);
|
||||
}
|
||||
|
||||
public void unarchive(IdRequest dto) {
|
||||
this.repository.unArchive(dto);
|
||||
}
|
||||
}
|
||||
17
src/main/resources/scripts/dict/enum/tzDeviceDict.groovy
Normal file
17
src/main/resources/scripts/dict/enum/tzDeviceDict.groovy
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.tzDevice.controller.TzDeviceController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(TzDeviceController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.tzDeviceMaintenanceRecord.controller.TzDeviceMaintenanceRecordController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(TzDeviceMaintenanceRecordController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.tzDeviceSupplier.controller.TzDeviceSupplierController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(TzDeviceSupplierController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.tzDeviceCategory.controller.TzDeviceCategoryController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(TzDeviceCategoryController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.roots(new CommonQuery())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user