mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善
This commit is contained in:
@@ -16,5 +16,12 @@ public class CoalWashingDailyAnalysisYmDetailVo {
|
||||
private String name;
|
||||
private Double percent;
|
||||
private Double amount;
|
||||
|
||||
|
||||
private String remarks;
|
||||
|
||||
|
||||
private String reserve1;
|
||||
private String reserve2;
|
||||
private String reserve3;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.CreatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.PurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdateWeightDataDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.service.PurchaseOrderService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -41,6 +42,12 @@ public class PurchaseOrderController {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateWeightData")
|
||||
public PurchaseOrderDto updateWeightData(@RequestBody UpdateWeightDataDto request) {
|
||||
return this.service.updateWeightData(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
|
||||
@@ -9,6 +9,8 @@ import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreatePurchaseOrderDto extends OrgCommonDto {
|
||||
@@ -30,6 +32,16 @@ public class CreatePurchaseOrderDto extends OrgCommonDto {
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
|
||||
@Comment("完成/作废时间")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
|
||||
@Comment("订单开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
@@ -38,7 +50,7 @@ public class CreatePurchaseOrderDto extends OrgCommonDto {
|
||||
|
||||
private LocalDate lastDeliveryDate;
|
||||
|
||||
|
||||
private List<String> weightDataList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -22,19 +23,12 @@ public class PurchaseOrderDto extends OrgCommonDto {
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
|
||||
private LocalDate firstDeliveryDate;
|
||||
|
||||
private LocalDate lastDeliveryDate;
|
||||
|
||||
|
||||
private Integer dayLeft;
|
||||
|
||||
|
||||
private Integer dayAmount;
|
||||
private Double dayAmount;
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +51,11 @@ public class PurchaseOrderDto extends OrgCommonDto {
|
||||
|
||||
private Double receivedAmount;
|
||||
|
||||
@Comment("收货进度 百分比")
|
||||
private Double receivedPercentage;
|
||||
|
||||
|
||||
|
||||
|
||||
private Double totalCarCount;
|
||||
|
||||
@@ -64,6 +63,14 @@ public class PurchaseOrderDto extends OrgCommonDto {
|
||||
private Double leftAmount;
|
||||
|
||||
|
||||
@Comment("第一次送货时间")
|
||||
private LocalDateTime firstDeliveryTime;
|
||||
|
||||
@Comment("最后一次送货时间")
|
||||
private LocalDateTime lastDeliveryTime;
|
||||
|
||||
|
||||
|
||||
@Comment("采购单价")
|
||||
private Double price;
|
||||
|
||||
@@ -75,5 +82,17 @@ public class PurchaseOrderDto extends OrgCommonDto {
|
||||
@DictTranslate(dictKey = DictCode.PURCHASEORDER_STATUS)
|
||||
private String orderStatusName;
|
||||
|
||||
|
||||
|
||||
@Comment("完成/作废时间")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
|
||||
@Comment("订单开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private List<String> weightDataList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdatePurchaseOrderDto extends OrgCommonDto {
|
||||
@@ -35,4 +37,14 @@ public class UpdatePurchaseOrderDto extends OrgCommonDto {
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
|
||||
@Comment("完成/作废时间")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
|
||||
@Comment("订单开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
private List<String> weightDataList;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class UpdateWeightDataDto {
|
||||
private String id;
|
||||
private List<String> weightDataList;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package cn.lihongjie.coal.purchaseOrder.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;
|
||||
import cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@@ -14,6 +14,7 @@ import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -25,24 +26,12 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
@Comment("采购日期")
|
||||
private LocalDate purchaseDate;
|
||||
|
||||
@Comment("预计到货日期")
|
||||
private LocalDate estimateDeliveryDate;
|
||||
|
||||
|
||||
@Formula("(select min(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate firstDeliveryDate;
|
||||
|
||||
@Formula("(select max(d.delivery_date) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private LocalDate lastDeliveryDate;
|
||||
|
||||
|
||||
|
||||
@Formula("(estimate_delivery_date - now()::date)")
|
||||
private Integer dayLeft;
|
||||
|
||||
|
||||
@Formula("(estimate_delivery_date - purchase_date)")
|
||||
private Integer dayAmount;
|
||||
@OneToMany
|
||||
private List<WeightDeviceDataEntity> weightDataList;
|
||||
|
||||
|
||||
|
||||
@@ -50,21 +39,15 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
@Comment("煤炭信息")
|
||||
private CoalInfoEntity coalInfo;
|
||||
|
||||
@OneToMany(mappedBy = "purchaseOrder")
|
||||
private List<DeliveryInformationEntity> deliveryInformationList;
|
||||
|
||||
|
||||
|
||||
@Comment("采购数量")
|
||||
private Double amount;
|
||||
|
||||
|
||||
@Formula("(select sum(d.amount) from t_delivery_information d where d.purchase_order_id = id)")
|
||||
private Double receivedAmount;
|
||||
|
||||
|
||||
@Formula("(amount - (select sum(d.amount) from t_delivery_information d where d.purchase_order_id = id))")
|
||||
private Double leftAmount;
|
||||
|
||||
|
||||
@Comment("采购单价")
|
||||
private Double price;
|
||||
@@ -77,39 +60,20 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void prePersist() {
|
||||
super.prePersist();
|
||||
this.updateStatus();
|
||||
}
|
||||
@Comment("完成/作废时间")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
private void updateStatus() {
|
||||
if (this.purchaseDate.isAfter(LocalDate.now())){
|
||||
this.orderStatus = "0";
|
||||
}else {
|
||||
|
||||
double total = this.deliveryInformationList == null ? 0: this.deliveryInformationList.stream().mapToDouble(DeliveryInformationEntity::getAmount).sum();
|
||||
@Comment("订单开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
|
||||
|
||||
@Formula("(round(EXTRACT(EPOCH FROM (coalesce(finish_time, now()) - start_time)) / 1000.0 / 60.0 / 24.0 ,2))")
|
||||
private Double dayAmount;
|
||||
|
||||
|
||||
if (total >= this.amount){
|
||||
this.orderStatus = "2";
|
||||
}else {
|
||||
this.orderStatus = "1";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preUpdate() {
|
||||
super.preUpdate();
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
public void setDeliveryInformationList(List<cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity> deliveryInformationList) {
|
||||
if (deliveryInformationList == null) {
|
||||
return;
|
||||
}
|
||||
deliveryInformationList.forEach(e -> e.setPurchaseOrder(this));
|
||||
this.deliveryInformationList = deliveryInformationList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,27 @@ 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.purchaseOrder.dto.CreatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.PurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdateWeightDataDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
import cn.lihongjie.coal.purchaseOrder.mapper.PurchaseOrderMapper;
|
||||
import cn.lihongjie.coal.purchaseOrder.repository.PurchaseOrderRepository;
|
||||
import cn.lihongjie.coal.weightDeviceData.entity.WeightDeviceDataEntity;
|
||||
import cn.lihongjie.coal.weightDeviceData.mapper.WeightDeviceDataMapper;
|
||||
import cn.lihongjie.coal.weightDeviceData.repository.WeightDeviceDataRepository;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.*;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -24,6 +33,10 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional
|
||||
@@ -35,21 +48,9 @@ public class PurchaseOrderService
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public PurchaseOrderDto create(CreatePurchaseOrderDto request) {
|
||||
PurchaseOrderEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public PurchaseOrderDto update(UpdatePurchaseOrderDto request) {
|
||||
PurchaseOrderEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
@Autowired WeightDeviceDataRepository weightDeviceDataRepository;
|
||||
@Autowired WeightDeviceDataMapper weightDeviceDataMapper;
|
||||
@PersistenceContext private EntityManager entityManager;
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
@@ -61,6 +62,169 @@ public class PurchaseOrderService
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public PurchaseOrderDto create(CreatePurchaseOrderDto request) {
|
||||
PurchaseOrderEntity entity = mapper.toEntity(request);
|
||||
|
||||
if (StringUtils.equals(request.getStatus(), "0")) {
|
||||
|
||||
entity.setStartTime(null);
|
||||
entity.setFinishTime(null);
|
||||
|
||||
} else if (StringUtils.equals(request.getStatus(), "1")) {
|
||||
|
||||
entity.setStartTime(
|
||||
request.getStartTime() == null
|
||||
? request.getPurchaseDate().atStartOfDay()
|
||||
: request.getStartTime());
|
||||
entity.setFinishTime(null);
|
||||
|
||||
} else if (StringUtils.equals(request.getStatus(), "2")) {
|
||||
|
||||
entity.setStartTime(
|
||||
request.getStartTime() == null
|
||||
? request.getPurchaseDate().atStartOfDay()
|
||||
: request.getStartTime());
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
|
||||
} else if (StringUtils.equals(request.getStatus(), "3")) {
|
||||
|
||||
entity.setStartTime(
|
||||
request.getStartTime() == null
|
||||
? request.getPurchaseDate().atStartOfDay()
|
||||
: request.getStartTime());
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public PurchaseOrderDto update(UpdatePurchaseOrderDto request) {
|
||||
PurchaseOrderEntity entity = this.repository.get(request.getId());
|
||||
|
||||
String oldStatus = entity.getOrderStatus();
|
||||
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
String newStatus = request.getStatus();
|
||||
|
||||
switch (oldStatus) {
|
||||
case "0" -> {
|
||||
switch (newStatus) {
|
||||
case "0" -> {
|
||||
entity.setStartTime(null);
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "1" -> {
|
||||
entity.setStartTime(
|
||||
request.getStartTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getStartTime());
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "2" -> {
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
}
|
||||
case "3" -> {
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
case "1" -> {
|
||||
switch (newStatus) {
|
||||
case "0" -> {
|
||||
entity.setStartTime(null);
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "1" -> {}
|
||||
case "2" -> {
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
}
|
||||
case "3" -> {
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
case "2" -> {
|
||||
switch (newStatus) {
|
||||
case "0" -> {
|
||||
entity.setStartTime(null);
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "1" -> {
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "2" -> {}
|
||||
case "3" -> {
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
case "3" -> {
|
||||
switch (newStatus) {
|
||||
case "0" -> {
|
||||
entity.setStartTime(null);
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "1" -> {
|
||||
entity.setFinishTime(null);
|
||||
}
|
||||
case "2" -> {
|
||||
entity.setFinishTime(
|
||||
request.getFinishTime() == null
|
||||
? LocalDateTime.now()
|
||||
: request.getFinishTime());
|
||||
}
|
||||
case "3" -> {}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public PurchaseOrderDto updateWeightData(UpdateWeightDataDto request) {
|
||||
|
||||
PurchaseOrderEntity entity = this.repository.get(request.getId());
|
||||
entity.setWeightDataList(
|
||||
ObjectUtils.defaultIfNull(request.getWeightDataList(), new ArrayList<>()).stream()
|
||||
.map(x -> entityManager.getReference(WeightDeviceDataEntity.class, x))
|
||||
.toList());
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public Page<PurchaseOrderDto> list(CommonQuery query) {
|
||||
Page<PurchaseOrderEntity> page =
|
||||
repository.findAll(
|
||||
@@ -70,17 +234,42 @@ public class PurchaseOrderService
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
List<String> ids = page.stream().map(x -> x.getId()).toList();
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
List<Tuple> resultList =
|
||||
entityManager
|
||||
.createQuery(
|
||||
"""
|
||||
|
||||
select coalesce(sum(w.sz), 0) as receivedAmount, coalesce(count(w.id),0) as totalCarCount, coalesce(sum(p.amount),0) - coalesce(sum(w.sz),0) as leftAmount, p.id as id, (coalesce(sum(w.sz),0) / sum(p.amount)) * 100.0 as receivedPercentage,
|
||||
min(w.minTime) as firstDeliveryTime, max(w.minTime) as lastDeliveryTime
|
||||
from PurchaseOrderEntity p
|
||||
left join p.weightDataList w
|
||||
where p.id in :ids
|
||||
group by p.id
|
||||
|
||||
""",
|
||||
Tuple.class)
|
||||
.setParameter("ids", ids)
|
||||
.getResultList();
|
||||
|
||||
Page<PurchaseOrderDto> ans = page.map(this.mapper::toDto);
|
||||
JpaUtils.mergeMapToPojo(
|
||||
ans.toList(), JpaUtils.convertTuplesToRawMap(resultList), conversionService);
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
public String nextPurchaseOrderNumber(CreatePurchaseOrderDto dto) {
|
||||
|
||||
String seqName = "CG_" + Ctx.currentUser().getOrganizationId();
|
||||
entityManager.createNativeQuery("CREATE SEQUENCE if not exists " + seqName + " START 1000000;").executeUpdate();
|
||||
Object singleResult = entityManager.createNativeQuery("select nextval('" + seqName + "')").getSingleResult();
|
||||
entityManager
|
||||
.createNativeQuery("CREATE SEQUENCE if not exists " + seqName + " START 1000000;")
|
||||
.executeUpdate();
|
||||
Object singleResult =
|
||||
entityManager
|
||||
.createNativeQuery("select nextval('" + seqName + "')")
|
||||
.getSingleResult();
|
||||
|
||||
return "CG" + singleResult;
|
||||
}
|
||||
|
||||
@@ -304,6 +304,19 @@ where 更新时间>='%s' and 更新时间<='%s'
|
||||
if (this.repository.containArchived(request)) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
|
||||
Object cnt = em.createQuery("select count(1) from PurchaseOrderEntity p join p.weightDataList w where w.id in :ids")
|
||||
.setParameter("ids", request.getIds())
|
||||
.getSingleResult();
|
||||
|
||||
|
||||
if (Integer.parseInt(cnt.toString()) > 0){
|
||||
throw new BizException("部分数据已经被采购单引用, 无法删除");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.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.weightDeviceDataSelect.dto.CreateWeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.dto.UpdateWeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.dto.WeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.service.WeightDeviceDataSelectService;
|
||||
|
||||
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("/weightDeviceDataSelect")
|
||||
@SysLog(module = "")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class WeightDeviceDataSelectController {
|
||||
@Autowired private WeightDeviceDataSelectService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public WeightDeviceDataSelectDto create(@RequestBody CreateWeightDeviceDataSelectDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public WeightDeviceDataSelectDto update(@RequestBody UpdateWeightDeviceDataSelectDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public WeightDeviceDataSelectDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<WeightDeviceDataSelectDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateWeightDeviceDataSelectDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateWeightDeviceDataSelectDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,284 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class WeightDeviceDataSelectDto extends OrgCommonDto {
|
||||
@Comment("序号")
|
||||
private Integer sequenceNumber;
|
||||
|
||||
@Comment("流水号")
|
||||
private String flowNumber;
|
||||
|
||||
@Comment("车号")
|
||||
private String plateNo;
|
||||
|
||||
@Comment("过磅类型")
|
||||
private String weighType;
|
||||
|
||||
@Comment("发货单位")
|
||||
private String sendOrganization;
|
||||
|
||||
@Comment("收货单位")
|
||||
private String receiveOrganization;
|
||||
|
||||
@Comment("货名")
|
||||
private String goods;
|
||||
|
||||
@Comment("规格")
|
||||
private String specification;
|
||||
|
||||
@Comment("毛重")
|
||||
private Double mz;
|
||||
|
||||
@Comment("皮重")
|
||||
private Double pz;
|
||||
|
||||
@Comment("净重")
|
||||
private Double jz;
|
||||
|
||||
@Comment("扣重")
|
||||
private Double kz;
|
||||
|
||||
@Comment("实重")
|
||||
private Double sz;
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
@Comment("金额")
|
||||
private Double amount;
|
||||
|
||||
@Comment("折方系数")
|
||||
private Double zfxs;
|
||||
|
||||
@Comment("方量")
|
||||
private Double fl;
|
||||
|
||||
@Comment("过磅费")
|
||||
private Double weightFee;
|
||||
|
||||
@Comment("毛重司磅员")
|
||||
private String mzUser;
|
||||
|
||||
@Comment("皮重司磅员")
|
||||
private String pzUser;
|
||||
|
||||
@Comment("毛重磅号")
|
||||
private String mzbh;
|
||||
|
||||
@Comment("皮重磅号")
|
||||
private String pzbh;
|
||||
|
||||
@Comment("毛重时间")
|
||||
private LocalDateTime mzTime;
|
||||
|
||||
@Comment("皮重时间")
|
||||
private LocalDateTime pzTime;
|
||||
|
||||
@Comment("一次过磅时间")
|
||||
private LocalDateTime ycgbTIme;
|
||||
|
||||
@Comment("二次过磅时间")
|
||||
private LocalDateTime ecgbTime;
|
||||
|
||||
@Comment("更新人")
|
||||
private String updateUser;
|
||||
|
||||
@Comment("数据更新时间")
|
||||
|
||||
private LocalDateTime dataUpdateTime;
|
||||
@Comment("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@Comment("打印次数")
|
||||
private Integer printCount;
|
||||
|
||||
@Comment("上传否")
|
||||
private Integer upload;
|
||||
|
||||
@Comment("备用1")
|
||||
private String reserve1;
|
||||
|
||||
@Comment("备用2")
|
||||
private String reserve2;
|
||||
|
||||
@Comment("备用3")
|
||||
private String reserve3;
|
||||
|
||||
@Comment("备用4")
|
||||
private String reserve4;
|
||||
|
||||
@Comment("备用5")
|
||||
private String reserve5;
|
||||
|
||||
@Comment("备用6")
|
||||
private Double reserve6;
|
||||
|
||||
@Comment("备用7")
|
||||
private Double reserve7;
|
||||
|
||||
@Comment("备用8")
|
||||
private Double reserve8;
|
||||
|
||||
@Comment("备用9")
|
||||
private Double reserve9;
|
||||
|
||||
@Comment("备用10")
|
||||
private String reserve10;
|
||||
|
||||
@Comment("备用11")
|
||||
private String reserve11;
|
||||
|
||||
@Comment("备用12")
|
||||
private String reserve12;
|
||||
|
||||
@Comment("备用13")
|
||||
private String reserve13;
|
||||
|
||||
@Comment("备用14")
|
||||
private String reserve14;
|
||||
|
||||
@Comment("备用15")
|
||||
private Double reserve15;
|
||||
|
||||
@Comment("备用16")
|
||||
private Double reserve16;
|
||||
|
||||
@Comment("备用17")
|
||||
private Double reserve17;
|
||||
|
||||
@Comment("备用18")
|
||||
private Double reserve18;
|
||||
|
||||
@Comment("客户类型")
|
||||
private Integer clientType;
|
||||
|
||||
@Comment("一次过磅重")
|
||||
private Double ycgbWeight;
|
||||
|
||||
@Comment("二次过磅重")
|
||||
private Double ecgbWeight;
|
||||
|
||||
@Comment("b0")
|
||||
private String b0;
|
||||
|
||||
@Comment("aguid")
|
||||
private String aguid;
|
||||
|
||||
@Comment("PlanNumber")
|
||||
private String planNumber;
|
||||
|
||||
@Comment("RecordCreateMode")
|
||||
private Integer recordCreateMode;
|
||||
|
||||
@Comment("RecordFinish")
|
||||
private Integer recordFinish;
|
||||
|
||||
@Comment("网价同步时间")
|
||||
private LocalDateTime netPriceSyncTime;
|
||||
|
||||
@Comment("网价修改人")
|
||||
private String netPriceModifyUser;
|
||||
|
||||
@Comment("CTime")
|
||||
private LocalDateTime cTime;
|
||||
|
||||
@Comment("modify_onnet")
|
||||
private String modifyOnnet;
|
||||
|
||||
@Comment("modify_time")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
@Comment("modify_by")
|
||||
private String modifyBy;
|
||||
|
||||
@Comment("audit_flag")
|
||||
private String auditFlag;
|
||||
|
||||
@Comment("audit_time")
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
@Comment("audit_by")
|
||||
private String auditBy;
|
||||
|
||||
@Comment("e_upimg")
|
||||
private String eUpimg;
|
||||
|
||||
@Comment("备用19")
|
||||
private String reserve19;
|
||||
|
||||
@Comment("备用20")
|
||||
private String reserve20;
|
||||
|
||||
@Comment("备用21")
|
||||
private String reserve21;
|
||||
|
||||
@Comment("备用22")
|
||||
private String reserve22;
|
||||
|
||||
@Comment("备用23")
|
||||
private String reserve23;
|
||||
|
||||
@Comment("备用24")
|
||||
private String reserve24;
|
||||
|
||||
@Comment("备用25")
|
||||
private String reserve25;
|
||||
|
||||
@Comment("备用26")
|
||||
private String reserve26;
|
||||
|
||||
@Comment("备用27")
|
||||
private String reserve27;
|
||||
|
||||
@Comment("备用28")
|
||||
private String reserve28;
|
||||
|
||||
@Comment("driver_info")
|
||||
private String driverInfo;
|
||||
|
||||
@Comment("HQB_UpImg_G1")
|
||||
private Integer hqbUpImgG1;
|
||||
|
||||
@Comment("HQB_UpImg_G2")
|
||||
private Integer hqbUpImgG2;
|
||||
|
||||
@Comment("HQB_UpImg_G3")
|
||||
private Integer hqbUpImgG3;
|
||||
|
||||
@Comment("HQB_UpImg_G4")
|
||||
private Integer hqbUpImgG4;
|
||||
|
||||
@Comment("HQB_UpImg_T1")
|
||||
private Integer hqbUpImgT1;
|
||||
|
||||
@Comment("HQB_UpImg_T2")
|
||||
private Integer hqbUpImgT2;
|
||||
|
||||
@Comment("HQB_UpImg_T3")
|
||||
private Integer hqbUpImgT3;
|
||||
|
||||
@Comment("HQB_UpImg_T4")
|
||||
private Integer hqbUpImgT4;
|
||||
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
|
||||
private LocalDateTime minTime;
|
||||
|
||||
|
||||
private Boolean invalid = false;
|
||||
|
||||
private Boolean finished = true;
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Subselect;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Subselect(
|
||||
"""
|
||||
select d.*
|
||||
from t_weight_device_data d
|
||||
where d.id not in (select weight_data_list_id from t_purchase_order_weight_data_list)
|
||||
|
||||
""")
|
||||
public class WeightDeviceDataSelectEntity extends OrgCommonEntity {
|
||||
@Comment("序号")
|
||||
private Integer sequenceNumber;
|
||||
|
||||
@Comment("流水号")
|
||||
private String flowNumber;
|
||||
|
||||
@Comment("车号")
|
||||
private String plateNo;
|
||||
|
||||
@Comment("过磅类型")
|
||||
private String weighType;
|
||||
|
||||
@Comment("发货单位")
|
||||
private String sendOrganization;
|
||||
|
||||
@Comment("收货单位")
|
||||
private String receiveOrganization;
|
||||
|
||||
@Comment("货名")
|
||||
private String goods;
|
||||
|
||||
@Comment("规格")
|
||||
private String specification;
|
||||
|
||||
@Comment("毛重")
|
||||
private Double mz;
|
||||
|
||||
@Comment("皮重")
|
||||
private Double pz;
|
||||
|
||||
@Comment("净重")
|
||||
private Double jz;
|
||||
|
||||
@Comment("扣重")
|
||||
private Double kz;
|
||||
|
||||
@Comment("实重")
|
||||
private Double sz;
|
||||
|
||||
@Comment("单价")
|
||||
private Double price;
|
||||
|
||||
@Comment("金额")
|
||||
private Double amount;
|
||||
|
||||
@Comment("折方系数")
|
||||
private Double zfxs;
|
||||
|
||||
@Comment("方量")
|
||||
private Double fl;
|
||||
|
||||
@Comment("过磅费")
|
||||
private Double weightFee;
|
||||
|
||||
@Comment("毛重司磅员")
|
||||
private String mzUser;
|
||||
|
||||
@Comment("皮重司磅员")
|
||||
private String pzUser;
|
||||
|
||||
@Comment("毛重磅号")
|
||||
private String mzbh;
|
||||
|
||||
@Comment("皮重磅号")
|
||||
private String pzbh;
|
||||
|
||||
@Comment("毛重时间")
|
||||
private LocalDateTime mzTime;
|
||||
|
||||
@Comment("皮重时间")
|
||||
private LocalDateTime pzTime;
|
||||
|
||||
@Comment("一次过磅时间")
|
||||
private LocalDateTime ycgbTIme;
|
||||
|
||||
@Comment("二次过磅时间")
|
||||
private LocalDateTime ecgbTime;
|
||||
|
||||
@Comment("更新人")
|
||||
private String updateUser;
|
||||
|
||||
@Comment("数据更新时间")
|
||||
|
||||
private LocalDateTime dataUpdateTime;
|
||||
@Comment("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@Comment("打印次数")
|
||||
private Integer printCount;
|
||||
|
||||
@Comment("上传否")
|
||||
private Integer upload;
|
||||
|
||||
@Comment("备用1")
|
||||
private String reserve1;
|
||||
|
||||
@Comment("备用2")
|
||||
private String reserve2;
|
||||
|
||||
@Comment("备用3")
|
||||
private String reserve3;
|
||||
|
||||
@Comment("备用4")
|
||||
private String reserve4;
|
||||
|
||||
@Comment("备用5")
|
||||
private String reserve5;
|
||||
|
||||
@Comment("备用6")
|
||||
private Double reserve6;
|
||||
|
||||
@Comment("备用7")
|
||||
private Double reserve7;
|
||||
|
||||
@Comment("备用8")
|
||||
private Double reserve8;
|
||||
|
||||
@Comment("备用9")
|
||||
private Double reserve9;
|
||||
|
||||
@Comment("备用10")
|
||||
private String reserve10;
|
||||
|
||||
@Comment("备用11")
|
||||
private String reserve11;
|
||||
|
||||
@Comment("备用12")
|
||||
private String reserve12;
|
||||
|
||||
@Comment("备用13")
|
||||
private String reserve13;
|
||||
|
||||
@Comment("备用14")
|
||||
private String reserve14;
|
||||
|
||||
@Comment("备用15")
|
||||
private Double reserve15;
|
||||
|
||||
@Comment("备用16")
|
||||
private Double reserve16;
|
||||
|
||||
@Comment("备用17")
|
||||
private Double reserve17;
|
||||
|
||||
@Comment("备用18")
|
||||
private Double reserve18;
|
||||
|
||||
@Comment("客户类型")
|
||||
private Integer clientType;
|
||||
|
||||
@Comment("一次过磅重")
|
||||
private Double ycgbWeight;
|
||||
|
||||
@Comment("二次过磅重")
|
||||
private Double ecgbWeight;
|
||||
|
||||
@Comment("b0")
|
||||
private String b0;
|
||||
|
||||
@Comment("aguid")
|
||||
private String aguid;
|
||||
|
||||
@Comment("PlanNumber")
|
||||
private String planNumber;
|
||||
|
||||
@Comment("RecordCreateMode")
|
||||
private Integer recordCreateMode;
|
||||
|
||||
@Comment("RecordFinish")
|
||||
private Integer recordFinish;
|
||||
|
||||
@Comment("网价同步时间")
|
||||
private LocalDateTime netPriceSyncTime;
|
||||
|
||||
@Comment("网价修改人")
|
||||
private String netPriceModifyUser;
|
||||
|
||||
@Comment("CTime")
|
||||
private LocalDateTime cTime;
|
||||
|
||||
@Comment("modify_onnet")
|
||||
private String modifyOnnet;
|
||||
|
||||
@Comment("modify_time")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
@Comment("modify_by")
|
||||
private String modifyBy;
|
||||
|
||||
@Comment("audit_flag")
|
||||
private String auditFlag;
|
||||
|
||||
@Comment("audit_time")
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
@Comment("audit_by")
|
||||
private String auditBy;
|
||||
|
||||
@Comment("e_upimg")
|
||||
private String eUpimg;
|
||||
|
||||
@Comment("备用19")
|
||||
private String reserve19;
|
||||
|
||||
@Comment("备用20")
|
||||
private String reserve20;
|
||||
|
||||
@Comment("备用21")
|
||||
private String reserve21;
|
||||
|
||||
@Comment("备用22")
|
||||
private String reserve22;
|
||||
|
||||
@Comment("备用23")
|
||||
private String reserve23;
|
||||
|
||||
@Comment("备用24")
|
||||
private String reserve24;
|
||||
|
||||
@Comment("备用25")
|
||||
private String reserve25;
|
||||
|
||||
@Comment("备用26")
|
||||
private String reserve26;
|
||||
|
||||
@Comment("备用27")
|
||||
private String reserve27;
|
||||
|
||||
@Comment("备用28")
|
||||
private String reserve28;
|
||||
|
||||
@Comment("driver_info")
|
||||
private String driverInfo;
|
||||
|
||||
@Comment("HQB_UpImg_G1")
|
||||
private Integer hqbUpImgG1;
|
||||
|
||||
@Comment("HQB_UpImg_G2")
|
||||
private Integer hqbUpImgG2;
|
||||
|
||||
@Comment("HQB_UpImg_G3")
|
||||
private Integer hqbUpImgG3;
|
||||
|
||||
@Comment("HQB_UpImg_G4")
|
||||
private Integer hqbUpImgG4;
|
||||
|
||||
@Comment("HQB_UpImg_T1")
|
||||
private Integer hqbUpImgT1;
|
||||
|
||||
@Comment("HQB_UpImg_T2")
|
||||
private Integer hqbUpImgT2;
|
||||
|
||||
@Comment("HQB_UpImg_T3")
|
||||
private Integer hqbUpImgT3;
|
||||
|
||||
@Comment("HQB_UpImg_T4")
|
||||
private Integer hqbUpImgT4;
|
||||
|
||||
@Comment("归档状态")
|
||||
@ColumnDefault("'0'")
|
||||
private String archiveStatus = "0";
|
||||
|
||||
|
||||
private LocalDateTime minTime;
|
||||
|
||||
|
||||
private Boolean invalid = false;
|
||||
|
||||
private Boolean finished = true;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.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.weightDeviceDataSelect.dto.CreateWeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.dto.UpdateWeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.dto.WeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.entity.WeightDeviceDataSelectEntity;
|
||||
|
||||
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 WeightDeviceDataSelectMapper
|
||||
extends BaseMapper<
|
||||
WeightDeviceDataSelectEntity,
|
||||
WeightDeviceDataSelectDto,
|
||||
CreateWeightDeviceDataSelectDto,
|
||||
UpdateWeightDeviceDataSelectDto> {}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.entity.WeightDeviceDataSelectEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface WeightDeviceDataSelectRepository
|
||||
extends BaseRepository<WeightDeviceDataSelectEntity> {
|
||||
@Query("select false")
|
||||
boolean isLinked(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataSelect.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.weightDeviceDataSelect.dto.CreateWeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.dto.UpdateWeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.dto.WeightDeviceDataSelectDto;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.entity.WeightDeviceDataSelectEntity;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.mapper.WeightDeviceDataSelectMapper;
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.repository.WeightDeviceDataSelectRepository;
|
||||
|
||||
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 WeightDeviceDataSelectService
|
||||
extends BaseService<WeightDeviceDataSelectEntity, WeightDeviceDataSelectRepository> {
|
||||
@Autowired private WeightDeviceDataSelectRepository repository;
|
||||
|
||||
@Autowired private WeightDeviceDataSelectMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
|
||||
public WeightDeviceDataSelectDto create(CreateWeightDeviceDataSelectDto request) {
|
||||
WeightDeviceDataSelectEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public WeightDeviceDataSelectDto update(UpdateWeightDeviceDataSelectDto request) {
|
||||
WeightDeviceDataSelectEntity 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 WeightDeviceDataSelectDto getById(String id) {
|
||||
WeightDeviceDataSelectEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<WeightDeviceDataSelectDto> list(CommonQuery query) {
|
||||
Page<WeightDeviceDataSelectEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,17 @@ package scripts.dict
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.coalInfo.controller.CoalInfoController
|
||||
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(CoalInfoController.class)
|
||||
def objectMapper = ioc.getBean("objectMapper") as ObjectMapper
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery()).content.collect {
|
||||
return controller.list(params!=null ? objectMapper.convertValue(params, CommonQuery.class ) : new CommonQuery()).content.collect {
|
||||
def entity = new CoalInfoEntity()
|
||||
entity.id = it.id
|
||||
entity.code = it.code
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.weightDeviceDataSelect.controller.WeightDeviceDataSelectController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(WeightDeviceDataSelectController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user