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,54 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.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.deliveryInformation.dto.CreateDeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.DeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.UpdateDeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.service.DeliveryInformationService;
|
||||
|
||||
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("/deliveryInformation")
|
||||
@SysLog(module = "采购单送货记录")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class DeliveryInformationController {
|
||||
@Autowired private DeliveryInformationService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public DeliveryInformationDto create(@RequestBody CreateDeliveryInformationDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public DeliveryInformationDto update(@RequestBody UpdateDeliveryInformationDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public DeliveryInformationDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<DeliveryInformationDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateDeliveryInformationDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeliveryInformationDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateDeliveryInformationDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class DeliveryInformationEntity extends OrgCommonEntity {
|
||||
|
||||
|
||||
private LocalDate deliveryDate;
|
||||
|
||||
|
||||
@Comment("收货数量")
|
||||
private Double amount;
|
||||
|
||||
|
||||
@Comment("车数")
|
||||
private Double carCount;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
private PurchaseOrderEntity purchaseOrder;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.CreateDeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.DeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.UpdateDeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface DeliveryInformationMapper
|
||||
extends BaseMapper<
|
||||
DeliveryInformationEntity,
|
||||
DeliveryInformationDto,
|
||||
CreateDeliveryInformationDto,
|
||||
UpdateDeliveryInformationDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DeliveryInformationRepository extends BaseRepository<DeliveryInformationEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.deliveryInformation.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.deliveryInformation.dto.CreateDeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.DeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.dto.UpdateDeliveryInformationDto;
|
||||
import cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity;
|
||||
import cn.lihongjie.coal.deliveryInformation.mapper.DeliveryInformationMapper;
|
||||
import cn.lihongjie.coal.deliveryInformation.repository.DeliveryInformationRepository;
|
||||
|
||||
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 DeliveryInformationService
|
||||
extends BaseService<DeliveryInformationEntity, DeliveryInformationRepository> {
|
||||
@Autowired private DeliveryInformationRepository repository;
|
||||
|
||||
@Autowired private DeliveryInformationMapper mapper;
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
public DeliveryInformationDto create(CreateDeliveryInformationDto request) {
|
||||
DeliveryInformationEntity entity = mapper.toEntity(request);
|
||||
|
||||
this.repository.save(entity);
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public DeliveryInformationDto update(UpdateDeliveryInformationDto request) {
|
||||
DeliveryInformationEntity entity = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public DeliveryInformationDto getById(String id) {
|
||||
DeliveryInformationEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<DeliveryInformationDto> list(CommonQuery query) {
|
||||
Page<DeliveryInformationEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.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.purchaseOrder.dto.CreatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.PurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.service.PurchaseOrderService;
|
||||
|
||||
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("/purchaseOrder")
|
||||
@SysLog(module = "采购订单")
|
||||
@Slf4j
|
||||
@OrgScope
|
||||
public class PurchaseOrderController {
|
||||
@Autowired private PurchaseOrderService service;
|
||||
|
||||
@PostMapping("/create")
|
||||
public PurchaseOrderDto create(@RequestBody CreatePurchaseOrderDto request) {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public PurchaseOrderDto update(@RequestBody UpdatePurchaseOrderDto request) {
|
||||
return this.service.update(request);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@RequestBody IdRequest request) {
|
||||
this.service.delete(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getById")
|
||||
public PurchaseOrderDto getById(@RequestBody IdRequest request) {
|
||||
return this.service.getById(request.getId());
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
public Page<PurchaseOrderDto> list(@RequestBody CommonQuery request) {
|
||||
return this.service.list(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreatePurchaseOrderDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PurchaseOrderDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdatePurchaseOrderDto extends OrgCommonDto {}
|
||||
@@ -0,0 +1,68 @@
|
||||
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 jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
|
||||
@ManyToOne
|
||||
@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;
|
||||
|
||||
@Formula("(amount * price)")
|
||||
private Double total;
|
||||
|
||||
@Comment("采购单状态")
|
||||
private String orderStatus;
|
||||
|
||||
@Formula(
|
||||
"(select i.name\n"
|
||||
+ "from t_dictionary d,\n"
|
||||
+ " t_dictionary_item i\n"
|
||||
+ "where d.id = i.dictionary_id\n"
|
||||
+ " and d.code = 'purchaseOrder.status'\n"
|
||||
+ " and i.code = order_status)")
|
||||
private String orderStatusName;
|
||||
|
||||
|
||||
public void setDeliveryInformationList(List<cn.lihongjie.coal.deliveryInformation.entity.DeliveryInformationEntity> deliveryInformationList) {
|
||||
if (deliveryInformationList == null) {
|
||||
return;
|
||||
}
|
||||
deliveryInformationList.forEach(e -> e.setPurchaseOrder(this));
|
||||
this.deliveryInformationList = deliveryInformationList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.mapper;
|
||||
|
||||
import cn.lihongjie.coal.base.mapper.BaseMapper;
|
||||
import cn.lihongjie.coal.base.mapper.CommonMapper;
|
||||
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.entity.PurchaseOrderEntity;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.control.DeepClone;
|
||||
|
||||
@Mapper(
|
||||
componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
|
||||
uses = {CommonMapper.class},
|
||||
mappingControl = DeepClone.class)
|
||||
public interface PurchaseOrderMapper
|
||||
extends BaseMapper<
|
||||
PurchaseOrderEntity,
|
||||
PurchaseOrderDto,
|
||||
CreatePurchaseOrderDto,
|
||||
UpdatePurchaseOrderDto> {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.repository;
|
||||
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PurchaseOrderRepository extends BaseRepository<PurchaseOrderEntity> {}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.lihongjie.coal.purchaseOrder.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.purchaseOrder.dto.CreatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.PurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
import cn.lihongjie.coal.purchaseOrder.mapper.PurchaseOrderMapper;
|
||||
import cn.lihongjie.coal.purchaseOrder.repository.PurchaseOrderRepository;
|
||||
|
||||
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 PurchaseOrderService
|
||||
extends BaseService<PurchaseOrderEntity, PurchaseOrderRepository> {
|
||||
@Autowired private PurchaseOrderRepository repository;
|
||||
|
||||
@Autowired private PurchaseOrderMapper mapper;
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
}
|
||||
|
||||
public PurchaseOrderDto getById(String id) {
|
||||
PurchaseOrderEntity entity = repository.get(id);
|
||||
|
||||
return mapper.toDto(entity);
|
||||
}
|
||||
|
||||
public Page<PurchaseOrderDto> list(CommonQuery query) {
|
||||
Page<PurchaseOrderEntity> page =
|
||||
repository.findAll(
|
||||
query.specification(conversionService),
|
||||
PageRequest.of(
|
||||
query.getPageNo(),
|
||||
query.getPageSize(),
|
||||
Sort.by(query.getOrders())));
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
}
|
||||
@@ -1675,6 +1675,28 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "purchaseOrder.status",
|
||||
"name": "采购订单状态",
|
||||
"item": [
|
||||
{
|
||||
"code": "0",
|
||||
"name": "未开始"
|
||||
},
|
||||
{
|
||||
"code": "1",
|
||||
"name": "进行中"
|
||||
},
|
||||
{
|
||||
"code": "2",
|
||||
"name": "已完成"
|
||||
},
|
||||
{
|
||||
"code": "3",
|
||||
"name": "已取消"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "netDisk.entryType",
|
||||
"name": "网盘文件类型",
|
||||
@@ -1761,16 +1783,12 @@
|
||||
"code": "1",
|
||||
"name": "会话过期"
|
||||
},
|
||||
|
||||
{
|
||||
"code": "2",
|
||||
"name": "管理员踢出"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
"code": "permission.type",
|
||||
"name": "权限类型",
|
||||
|
||||
Reference in New Issue
Block a user