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,6 +16,7 @@ import cn.lihongjie.coal.noteBook.entity.NoteBookEntity;
|
||||
import cn.lihongjie.coal.noteBookChapter.entity.NoteBookChapterEntity;
|
||||
import cn.lihongjie.coal.organization.entity.OrganizationEntity;
|
||||
import cn.lihongjie.coal.permission.entity.PermissionEntity;
|
||||
import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
import cn.lihongjie.coal.resource.entity.ResourceEntity;
|
||||
import cn.lihongjie.coal.role.entity.RoleEntity;
|
||||
import cn.lihongjie.coal.script.entity.ScriptEntity;
|
||||
@@ -273,6 +274,19 @@ public interface CommonMapper {
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
default PurchaseOrderEntity createPurchaseOrder(String id) {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
var e = new PurchaseOrderEntity();
|
||||
e.setId(id);
|
||||
return e;
|
||||
}
|
||||
|
||||
default String toString(Object o) {
|
||||
|
||||
if (o == null) {
|
||||
|
||||
@@ -31,6 +31,11 @@ public class PurchaseOrderController {
|
||||
return this.service.create(request);
|
||||
}
|
||||
|
||||
@PostMapping("/nextPurchaseOrderNumber")
|
||||
public String nextPurchaseOrderNumber(@RequestBody CreatePurchaseOrderDto request) {
|
||||
return this.service.nextPurchaseOrderNumber(request);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public PurchaseOrderDto update(@RequestBody UpdatePurchaseOrderDto request) {
|
||||
return this.service.update(request);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class PurchaseOrderEntity extends OrgCommonEntity {
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
if (this.purchaseDate.isBefore(LocalDate.now())){
|
||||
if (this.purchaseDate.isAfter(LocalDate.now())){
|
||||
this.orderStatus = "0";
|
||||
}else {
|
||||
|
||||
|
||||
@@ -6,4 +6,7 @@ import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PurchaseOrderRepository extends BaseRepository<PurchaseOrderEntity> {}
|
||||
public interface PurchaseOrderRepository extends BaseRepository<PurchaseOrderEntity> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.common.Ctx;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.CreatePurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.PurchaseOrderDto;
|
||||
import cn.lihongjie.coal.purchaseOrder.dto.UpdatePurchaseOrderDto;
|
||||
@@ -10,6 +11,9 @@ import cn.lihongjie.coal.purchaseOrder.entity.PurchaseOrderEntity;
|
||||
import cn.lihongjie.coal.purchaseOrder.mapper.PurchaseOrderMapper;
|
||||
import cn.lihongjie.coal.purchaseOrder.repository.PurchaseOrderRepository;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -68,4 +72,16 @@ public class PurchaseOrderService
|
||||
|
||||
return page.map(this.mapper::toDto);
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
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();
|
||||
|
||||
return "CG" + singleResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package scripts.dict
|
||||
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery
|
||||
import cn.lihongjie.coal.purchaseOrder.controller.PurchaseOrderController
|
||||
import org.springframework.context.ApplicationContext
|
||||
|
||||
ApplicationContext ioc = ioc
|
||||
|
||||
def controller = ioc.getBean(PurchaseOrderController.class)
|
||||
|
||||
|
||||
|
||||
|
||||
return controller.list(new CommonQuery())
|
||||
|
||||
Reference in New Issue
Block a user